|
| 1 | +import type { OrganizationCustomRoleKey } from 'organizationMembership'; |
| 2 | +import type { SignInResource } from 'signIn'; |
| 3 | + |
| 4 | +import type { SetActive, SignOut } from './clerk'; |
| 5 | +import type { ActJWTClaim } from './jwt'; |
| 6 | +import type { |
| 7 | + ActiveSessionResource, |
| 8 | + CheckAuthorizationWithCustomPermissions, |
| 9 | + GetToken, |
| 10 | + SessionResource, |
| 11 | +} from './session'; |
| 12 | +import type { SignUpResource } from './signUp'; |
| 13 | +import type { UserResource } from './user'; |
| 14 | + |
| 15 | +type CheckAuthorizationSignedOut = undefined; |
| 16 | +type CheckAuthorizationWithoutOrgOrUser = (params: Parameters<CheckAuthorizationWithCustomPermissions>[0]) => false; |
| 17 | + |
| 18 | +export type UseAuthReturn = |
| 19 | + | { |
| 20 | + isLoaded: false; |
| 21 | + isSignedIn: undefined; |
| 22 | + userId: undefined; |
| 23 | + sessionId: undefined; |
| 24 | + actor: undefined; |
| 25 | + orgId: undefined; |
| 26 | + orgRole: undefined; |
| 27 | + orgSlug: undefined; |
| 28 | + has: CheckAuthorizationSignedOut; |
| 29 | + signOut: SignOut; |
| 30 | + getToken: GetToken; |
| 31 | + } |
| 32 | + | { |
| 33 | + isLoaded: true; |
| 34 | + isSignedIn: false; |
| 35 | + userId: null; |
| 36 | + sessionId: null; |
| 37 | + actor: null; |
| 38 | + orgId: null; |
| 39 | + orgRole: null; |
| 40 | + orgSlug: null; |
| 41 | + has: CheckAuthorizationWithoutOrgOrUser; |
| 42 | + signOut: SignOut; |
| 43 | + getToken: GetToken; |
| 44 | + } |
| 45 | + | { |
| 46 | + isLoaded: true; |
| 47 | + isSignedIn: true; |
| 48 | + userId: string; |
| 49 | + sessionId: string; |
| 50 | + actor: ActJWTClaim | null; |
| 51 | + orgId: null; |
| 52 | + orgRole: null; |
| 53 | + orgSlug: null; |
| 54 | + has: CheckAuthorizationWithCustomPermissions; |
| 55 | + signOut: SignOut; |
| 56 | + getToken: GetToken; |
| 57 | + } |
| 58 | + | { |
| 59 | + isLoaded: true; |
| 60 | + isSignedIn: true; |
| 61 | + userId: string; |
| 62 | + sessionId: string; |
| 63 | + actor: ActJWTClaim | null; |
| 64 | + orgId: string; |
| 65 | + orgRole: OrganizationCustomRoleKey; |
| 66 | + orgSlug: string | null; |
| 67 | + has: CheckAuthorizationWithCustomPermissions; |
| 68 | + signOut: SignOut; |
| 69 | + getToken: GetToken; |
| 70 | + }; |
| 71 | + |
| 72 | +export type UseSignInReturn = |
| 73 | + | { |
| 74 | + isLoaded: false; |
| 75 | + signIn: undefined; |
| 76 | + setActive: undefined; |
| 77 | + } |
| 78 | + | { |
| 79 | + isLoaded: true; |
| 80 | + signIn: SignInResource; |
| 81 | + setActive: SetActive; |
| 82 | + }; |
| 83 | + |
| 84 | +export type UseSignUpReturn = |
| 85 | + | { |
| 86 | + isLoaded: false; |
| 87 | + signUp: undefined; |
| 88 | + setActive: undefined; |
| 89 | + } |
| 90 | + | { |
| 91 | + isLoaded: true; |
| 92 | + signUp: SignUpResource; |
| 93 | + setActive: SetActive; |
| 94 | + }; |
| 95 | + |
| 96 | +export type UseSessionReturn = |
| 97 | + | { isLoaded: false; isSignedIn: undefined; session: undefined } |
| 98 | + | { isLoaded: true; isSignedIn: false; session: null } |
| 99 | + | { isLoaded: true; isSignedIn: true; session: ActiveSessionResource }; |
| 100 | + |
| 101 | +export type UseSessionListReturn = |
| 102 | + | { |
| 103 | + isLoaded: false; |
| 104 | + sessions: undefined; |
| 105 | + setActive: undefined; |
| 106 | + } |
| 107 | + | { |
| 108 | + isLoaded: true; |
| 109 | + sessions: SessionResource[]; |
| 110 | + setActive: SetActive; |
| 111 | + }; |
| 112 | + |
| 113 | +export type UseUserReturn = |
| 114 | + | { isLoaded: false; isSignedIn: undefined; user: undefined } |
| 115 | + | { isLoaded: true; isSignedIn: false; user: null } |
| 116 | + | { isLoaded: true; isSignedIn: true; user: UserResource }; |
0 commit comments