dvStudioBrowserTransport function
The browser's transport: same-origin, with the session cookie, and the CSRF header every write needs.
base goes before every path: <mount>/ for Studio in the application,
whose pages are at the application's base rather than the mount's.
Implementation
DVStudioTransport dvStudioBrowserTransport({String base = ''}) {
final math.Random random = math.Random.secure();
const String alphabet =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
final String csrf = String.fromCharCodes(<int>[
for (int i = 0; i < 32; i++)
alphabet.codeUnitAt(random.nextInt(alphabet.length)),
]);
return (String method, String path, {Object? body}) =>
transport.dvStudioSend(method, '$base$path', body: body, csrf: csrf);
}