forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
36 lines (33 loc) · 798 Bytes
/
Copy pathutils.ts
File metadata and controls
36 lines (33 loc) · 798 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
33
34
35
36
import type { IsomorphicClerk } from '../isomorphicClerk';
/**
* @internal
*/
const clerkLoaded = (isomorphicClerk: IsomorphicClerk) => {
return new Promise<void>(resolve => {
if (isomorphicClerk.loaded) {
resolve();
}
isomorphicClerk.addOnLoaded(resolve);
});
};
/**
* @internal
*/
export const createGetToken = (isomorphicClerk: IsomorphicClerk) => {
return async (options: any) => {
await clerkLoaded(isomorphicClerk);
if (!isomorphicClerk.session) {
return null;
}
return isomorphicClerk.session.getToken(options);
};
};
/**
* @internal
*/
export const createSignOut = (isomorphicClerk: IsomorphicClerk) => {
return async (...args: any) => {
await clerkLoaded(isomorphicClerk);
return isomorphicClerk.signOut(...args);
};
};