-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathhooks.client.ts
More file actions
32 lines (29 loc) · 1016 Bytes
/
hooks.client.ts
File metadata and controls
32 lines (29 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { getAuthUser } from '$lib/stores/auth-user';
import { consumeAuthCookies } from '$lib/utilities/auth-user-cookie';
import { initCoreProvider } from '$lib/utilities/core-provider';
import {
ossGetDataEncoderEndpoint,
ossPostResponse,
ossPreRequest,
} from '$lib/utilities/oss-provider.svelte';
if (typeof crypto !== 'undefined' && !crypto.randomUUID) {
crypto.randomUUID = function randomUUID() {
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => {
const char = parseInt(c, 10);
return (
char ^
((crypto.getRandomValues(new Uint8Array(1))[0] & 15) >> (char / 4))
).toString(16);
}) as `${string}-${string}-${string}-${string}-${string}`;
};
}
consumeAuthCookies();
initCoreProvider({
getAccessToken: async () => getAuthUser().accessToken ?? '',
getIdToken: async () => getAuthUser().idToken,
api: {
preRequest: ossPreRequest,
postResponse: ossPostResponse,
},
getDataEncoderEndpoint: ossGetDataEncoderEndpoint,
});