forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.ts
More file actions
116 lines (108 loc) · 2.87 KB
/
Copy pathhooks.ts
File metadata and controls
116 lines (108 loc) · 2.87 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import type { OrganizationCustomRoleKey } from 'organizationMembership';
import type { SignInResource } from 'signIn';
import type { SetActive, SignOut } from './clerk';
import type { ActJWTClaim } from './jwt';
import type {
ActiveSessionResource,
CheckAuthorizationWithCustomPermissions,
GetToken,
SessionResource,
} from './session';
import type { SignUpResource } from './signUp';
import type { UserResource } from './user';
type CheckAuthorizationSignedOut = undefined;
type CheckAuthorizationWithoutOrgOrUser = (params: Parameters<CheckAuthorizationWithCustomPermissions>[0]) => false;
export type UseAuthReturn =
| {
isLoaded: false;
isSignedIn: undefined;
userId: undefined;
sessionId: undefined;
actor: undefined;
orgId: undefined;
orgRole: undefined;
orgSlug: undefined;
has: CheckAuthorizationSignedOut;
signOut: SignOut;
getToken: GetToken;
}
| {
isLoaded: true;
isSignedIn: false;
userId: null;
sessionId: null;
actor: null;
orgId: null;
orgRole: null;
orgSlug: null;
has: CheckAuthorizationWithoutOrgOrUser;
signOut: SignOut;
getToken: GetToken;
}
| {
isLoaded: true;
isSignedIn: true;
userId: string;
sessionId: string;
actor: ActJWTClaim | null;
orgId: null;
orgRole: null;
orgSlug: null;
has: CheckAuthorizationWithCustomPermissions;
signOut: SignOut;
getToken: GetToken;
}
| {
isLoaded: true;
isSignedIn: true;
userId: string;
sessionId: string;
actor: ActJWTClaim | null;
orgId: string;
orgRole: OrganizationCustomRoleKey;
orgSlug: string | null;
has: CheckAuthorizationWithCustomPermissions;
signOut: SignOut;
getToken: GetToken;
};
export type UseSignInReturn =
| {
isLoaded: false;
signIn: undefined;
setActive: undefined;
}
| {
isLoaded: true;
signIn: SignInResource;
setActive: SetActive;
};
export type UseSignUpReturn =
| {
isLoaded: false;
signUp: undefined;
setActive: undefined;
}
| {
isLoaded: true;
signUp: SignUpResource;
setActive: SetActive;
};
export type UseSessionReturn =
| { isLoaded: false; isSignedIn: undefined; session: undefined }
| { isLoaded: true; isSignedIn: false; session: null }
| { isLoaded: true; isSignedIn: true; session: ActiveSessionResource };
export type UseSessionListReturn =
| {
isLoaded: false;
sessions: undefined;
setActive: undefined;
}
| {
isLoaded: true;
sessions: SessionResource[];
setActive: SetActive;
};
export type UseUserReturn =
| { isLoaded: false; isSignedIn: undefined; user: undefined }
| { isLoaded: true; isSignedIn: false; user: null }
| { isLoaded: true; isSignedIn: true; user: UserResource };