@holo-js/auth-clerk 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +123 -26
- package/dist/index.mjs +748 -244
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AuthClerkProviderConfig } from '@holo-js/config';
|
|
1
|
+
import { AuthResult, AuthLogoutResult, AuthFieldErrors, AuthenticatedAuthUser, AuthEstablishedSession, authRuntimeInternals } from '@holo-js/auth';
|
|
2
|
+
import { AuthClerkProviderConfig, NormalizedAuthClerkProviderConfig } from '@holo-js/config';
|
|
3
3
|
|
|
4
4
|
interface ClerkEmailAddress {
|
|
5
5
|
readonly id?: string;
|
|
@@ -8,16 +8,20 @@ interface ClerkEmailAddress {
|
|
|
8
8
|
}
|
|
9
9
|
interface ClerkUserProfile {
|
|
10
10
|
readonly id: string;
|
|
11
|
-
readonly email
|
|
12
|
-
readonly emailVerified
|
|
11
|
+
readonly email: string;
|
|
12
|
+
readonly emailVerified: boolean;
|
|
13
13
|
readonly firstName?: string;
|
|
14
14
|
readonly lastName?: string;
|
|
15
|
-
readonly name
|
|
15
|
+
readonly name: string;
|
|
16
16
|
readonly imageUrl?: string;
|
|
17
17
|
readonly primaryEmailAddressId?: string;
|
|
18
18
|
readonly emailAddresses?: readonly ClerkEmailAddress[];
|
|
19
19
|
readonly raw?: unknown;
|
|
20
20
|
}
|
|
21
|
+
type ClerkUserAttributeValue = string | number | boolean | Date | null | undefined | readonly ClerkUserAttributeValue[] | {
|
|
22
|
+
readonly [key: string]: ClerkUserAttributeValue;
|
|
23
|
+
};
|
|
24
|
+
type ClerkUserAttributes = Readonly<Record<string, ClerkUserAttributeValue>>;
|
|
21
25
|
interface ClerkVerifiedSession {
|
|
22
26
|
readonly sessionId: string;
|
|
23
27
|
readonly user: ClerkUserProfile;
|
|
@@ -28,6 +32,56 @@ interface ClerkVerifiedSession {
|
|
|
28
32
|
};
|
|
29
33
|
readonly raw?: unknown;
|
|
30
34
|
}
|
|
35
|
+
interface ClerkLogoutSession {
|
|
36
|
+
readonly provider: string;
|
|
37
|
+
readonly sessionId: string;
|
|
38
|
+
}
|
|
39
|
+
type ClerkHostedAuthFailureFields = AuthFieldErrors<'_root'>;
|
|
40
|
+
interface ClerkCompleteAuthData<TUser extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> {
|
|
41
|
+
readonly provider: string;
|
|
42
|
+
readonly guard: string;
|
|
43
|
+
readonly authProvider: string;
|
|
44
|
+
readonly status: ClerkSyncStatus;
|
|
45
|
+
readonly user: ClerkAuthenticatedUser<TUser>;
|
|
46
|
+
readonly identity: HostedIdentityRecord;
|
|
47
|
+
readonly session: ClerkVerifiedSession;
|
|
48
|
+
readonly authSession?: AuthEstablishedSession;
|
|
49
|
+
}
|
|
50
|
+
type ClerkCompleteAuthResult<TUser extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> = AuthResult<ClerkCompleteAuthData<TUser>, string, ClerkHostedAuthFailureFields>;
|
|
51
|
+
type ClerkRequestHeaders = Headers | ReadonlyArray<readonly [string, string]> | Record<string, string | readonly string[] | undefined> | {
|
|
52
|
+
readonly get?: (name: string) => string | null | undefined;
|
|
53
|
+
readonly forEach?: (callback: (value: string, key: string) => void) => void;
|
|
54
|
+
readonly entries?: () => Iterable<readonly [string, string]>;
|
|
55
|
+
};
|
|
56
|
+
type ClerkRequestLike = {
|
|
57
|
+
readonly method?: string;
|
|
58
|
+
readonly path?: string;
|
|
59
|
+
readonly url?: string | URL;
|
|
60
|
+
readonly headers?: ClerkRequestHeaders;
|
|
61
|
+
readonly request?: Request;
|
|
62
|
+
readonly req?: Request | {
|
|
63
|
+
readonly method?: string;
|
|
64
|
+
readonly url?: string;
|
|
65
|
+
readonly headers?: ClerkRequestHeaders;
|
|
66
|
+
};
|
|
67
|
+
readonly node?: {
|
|
68
|
+
readonly req?: {
|
|
69
|
+
readonly method?: string;
|
|
70
|
+
readonly url?: string;
|
|
71
|
+
readonly headers?: ClerkRequestHeaders;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
readonly web?: {
|
|
75
|
+
readonly request?: Request;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type ClerkRequestInput = Request | ClerkRequestLike;
|
|
79
|
+
type ClerkLogoutErrorCode = 'clerk_logout_failed' | 'clerk_session_missing';
|
|
80
|
+
interface ClerkLogoutData {
|
|
81
|
+
readonly url: string;
|
|
82
|
+
readonly local: AuthLogoutResult;
|
|
83
|
+
}
|
|
84
|
+
type ClerkLogoutResult = AuthResult<ClerkLogoutData, ClerkLogoutErrorCode, ClerkHostedAuthFailureFields>;
|
|
31
85
|
interface ClerkVerifyRequestContext {
|
|
32
86
|
readonly provider: string;
|
|
33
87
|
readonly request: Request;
|
|
@@ -42,7 +96,6 @@ interface ClerkProviderRuntime {
|
|
|
42
96
|
verifyRequest?(context: ClerkVerifyRequestContext): Promise<ClerkVerifiedSession | null>;
|
|
43
97
|
verifySession?(context: ClerkVerifySessionContext): Promise<ClerkVerifiedSession | null>;
|
|
44
98
|
}
|
|
45
|
-
type RuntimeAuthProviderAdapter = ReturnType<typeof authRuntimeInternals.getRuntimeBindings>['providers'][string];
|
|
46
99
|
interface HostedIdentityRecord {
|
|
47
100
|
readonly provider: string;
|
|
48
101
|
readonly providerUserId: string;
|
|
@@ -58,15 +111,19 @@ interface HostedIdentityRecord {
|
|
|
58
111
|
interface HostedIdentityStore {
|
|
59
112
|
findByProviderUserId(provider: string, providerUserId: string): Promise<HostedIdentityRecord | null>;
|
|
60
113
|
findByUserId(provider: string, authProvider: string, userId: string | number): Promise<HostedIdentityRecord | null>;
|
|
114
|
+
claim?(record: HostedIdentityRecord): Promise<HostedIdentityRecord>;
|
|
61
115
|
save(record: HostedIdentityRecord): Promise<void>;
|
|
62
116
|
}
|
|
63
117
|
type ClerkSyncStatus = 'created' | 'updated' | 'linked' | 'relinked';
|
|
64
|
-
|
|
118
|
+
type ClerkAuthenticatedUser<TUser extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> = AuthenticatedAuthUser & TUser & {
|
|
119
|
+
readonly id: string | number;
|
|
120
|
+
};
|
|
121
|
+
interface ClerkAuthenticationResult<TUser extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> {
|
|
65
122
|
readonly provider: string;
|
|
66
123
|
readonly guard: string;
|
|
67
124
|
readonly authProvider: string;
|
|
68
125
|
readonly status: ClerkSyncStatus;
|
|
69
|
-
readonly user:
|
|
126
|
+
readonly user: ClerkAuthenticatedUser<TUser>;
|
|
70
127
|
readonly identity: HostedIdentityRecord;
|
|
71
128
|
readonly session: ClerkVerifiedSession;
|
|
72
129
|
readonly authSession?: AuthEstablishedSession;
|
|
@@ -79,11 +136,31 @@ interface ConfigureClerkAuthRuntimeOptions {
|
|
|
79
136
|
readonly providers?: Readonly<Record<string, ClerkProviderRuntime>>;
|
|
80
137
|
readonly identityStore?: HostedIdentityStore;
|
|
81
138
|
}
|
|
139
|
+
type ClerkDefaultUserAttributes$1 = {
|
|
140
|
+
readonly email: string;
|
|
141
|
+
readonly name: string;
|
|
142
|
+
};
|
|
82
143
|
interface ClerkAuthFacade {
|
|
83
|
-
|
|
144
|
+
loginWithClerk(request: ClerkRequestInput, options?: {
|
|
145
|
+
readonly provider?: string;
|
|
146
|
+
}): Promise<Response>;
|
|
147
|
+
registerWithClerk(request: ClerkRequestInput, options?: {
|
|
148
|
+
readonly provider?: string;
|
|
149
|
+
}): Promise<Response>;
|
|
150
|
+
logoutWithClerk(request: ClerkRequestInput, options?: {
|
|
151
|
+
readonly provider?: string;
|
|
152
|
+
readonly returnTo?: string;
|
|
153
|
+
}): Promise<ClerkLogoutResult>;
|
|
154
|
+
completeClerkAuth<TUserAttributes extends ClerkUserAttributes = ClerkDefaultUserAttributes$1>(request: ClerkRequestInput, options?: {
|
|
155
|
+
readonly provider?: string;
|
|
156
|
+
readonly user?: (clerkUser: ClerkUserProfile) => TUserAttributes;
|
|
157
|
+
}): Promise<ClerkCompleteAuthResult<TUserAttributes>>;
|
|
158
|
+
verifyRequest(request: ClerkRequestInput, provider?: string): Promise<ClerkVerifiedSession | null>;
|
|
84
159
|
verifySession(token: string, provider?: string): Promise<ClerkVerifiedSession | null>;
|
|
85
|
-
syncIdentity(session: ClerkVerifiedSession, provider?: string
|
|
86
|
-
|
|
160
|
+
syncIdentity<TUserAttributes extends ClerkUserAttributes = ClerkDefaultUserAttributes$1>(session: ClerkVerifiedSession, provider?: string, options?: {
|
|
161
|
+
readonly user?: (clerkUser: ClerkUserProfile) => TUserAttributes;
|
|
162
|
+
}): Promise<ClerkAuthenticationResult<TUserAttributes>>;
|
|
163
|
+
authenticate(request: ClerkRequestInput, provider?: string): Promise<ClerkAuthenticationResult | null>;
|
|
87
164
|
}
|
|
88
165
|
declare class ClerkAuthConflictError extends Error {
|
|
89
166
|
readonly code = "clerk_identity_conflict";
|
|
@@ -97,20 +174,22 @@ declare class ClerkAuthConflictError extends Error {
|
|
|
97
174
|
readonly message: string;
|
|
98
175
|
});
|
|
99
176
|
}
|
|
177
|
+
|
|
178
|
+
type RuntimeAuthProviderAdapter = ReturnType<typeof authRuntimeInternals.getRuntimeBindings>['providers'][string];
|
|
179
|
+
type ClerkDefaultUserAttributes = {
|
|
180
|
+
readonly email: string;
|
|
181
|
+
readonly name: string;
|
|
182
|
+
};
|
|
183
|
+
type CompleteClerkAuthOptions<TUserAttributes extends ClerkUserAttributes = ClerkDefaultUserAttributes> = {
|
|
184
|
+
readonly provider?: string;
|
|
185
|
+
readonly user?: (clerkUser: ClerkUserProfile) => TUserAttributes;
|
|
186
|
+
};
|
|
100
187
|
declare function getBindings(): ClerkAuthBindings;
|
|
188
|
+
declare function normalizeClerkUserProfile(user: Readonly<Record<string, unknown>>): ClerkUserProfile;
|
|
101
189
|
declare function resolveConfiguredProviderName(provider?: string): string;
|
|
102
190
|
declare function getConfiguredProviderConfig(provider?: string): {
|
|
103
191
|
readonly name: string;
|
|
104
|
-
|
|
105
|
-
readonly secretKey?: string;
|
|
106
|
-
readonly jwtKey?: string;
|
|
107
|
-
readonly apiUrl?: string;
|
|
108
|
-
readonly frontendApi?: string;
|
|
109
|
-
readonly sessionCookie: string;
|
|
110
|
-
readonly authorizedParties: readonly string[];
|
|
111
|
-
readonly guard?: string;
|
|
112
|
-
readonly mapToProvider?: string;
|
|
113
|
-
};
|
|
192
|
+
} & NormalizedAuthClerkProviderConfig;
|
|
114
193
|
declare function resolveGuardAndProvider(provider?: string): {
|
|
115
194
|
readonly guard: string;
|
|
116
195
|
readonly authProvider: string;
|
|
@@ -120,18 +199,35 @@ declare function resolvePrimaryEmail(profile: ClerkUserProfile): {
|
|
|
120
199
|
email?: string;
|
|
121
200
|
emailVerified: boolean;
|
|
122
201
|
};
|
|
123
|
-
declare function resolveDisplayName(profile: ClerkUserProfile): string
|
|
202
|
+
declare function resolveDisplayName(profile: ClerkUserProfile): string;
|
|
124
203
|
declare function resolveEmailForCreation(profile: ClerkUserProfile): string;
|
|
125
204
|
declare function normalizeHostedProfile(profile: ClerkUserProfile): Readonly<Record<string, unknown>>;
|
|
126
205
|
declare function getSessionTokenFromRequest(request: Request, sessionCookie: string): string | null;
|
|
127
206
|
declare function verifySession(token: string, provider?: string): Promise<ClerkVerifiedSession | null>;
|
|
128
|
-
declare function verifyRequest(
|
|
129
|
-
declare function syncIdentity(session: ClerkVerifiedSession, provider?: string
|
|
130
|
-
|
|
207
|
+
declare function verifyRequest(input: ClerkRequestInput, provider?: string): Promise<ClerkVerifiedSession | null>;
|
|
208
|
+
declare function syncIdentity<TUserAttributes extends ClerkUserAttributes = ClerkDefaultUserAttributes>(session: ClerkVerifiedSession, provider?: string, options?: {
|
|
209
|
+
readonly user?: (clerkUser: ClerkUserProfile) => TUserAttributes;
|
|
210
|
+
}): Promise<ClerkAuthenticationResult<TUserAttributes>>;
|
|
211
|
+
declare function authenticate(input: ClerkRequestInput, provider?: string): Promise<ClerkAuthenticationResult | null>;
|
|
212
|
+
declare function loginWithClerk(_input: ClerkRequestInput, options?: {
|
|
213
|
+
readonly provider?: string;
|
|
214
|
+
}): Promise<Response>;
|
|
215
|
+
declare function registerWithClerk(_input: ClerkRequestInput, options?: {
|
|
216
|
+
readonly provider?: string;
|
|
217
|
+
}): Promise<Response>;
|
|
218
|
+
declare function logoutWithClerk(input: ClerkRequestInput, options?: {
|
|
219
|
+
readonly provider?: string;
|
|
220
|
+
readonly returnTo?: string;
|
|
221
|
+
}): Promise<ClerkLogoutResult>;
|
|
222
|
+
declare function completeClerkAuth<TUserAttributes extends ClerkUserAttributes = ClerkDefaultUserAttributes>(input: ClerkRequestInput, options?: CompleteClerkAuthOptions<TUserAttributes>): Promise<ClerkCompleteAuthResult<TUserAttributes>>;
|
|
131
223
|
declare function configureClerkAuthRuntime(bindings?: ConfigureClerkAuthRuntimeOptions): void;
|
|
132
224
|
declare function resetClerkAuthRuntime(): void;
|
|
133
225
|
declare const clerkAuth: Readonly<{
|
|
134
226
|
authenticate: typeof authenticate;
|
|
227
|
+
completeClerkAuth: typeof completeClerkAuth;
|
|
228
|
+
loginWithClerk: typeof loginWithClerk;
|
|
229
|
+
logoutWithClerk: typeof logoutWithClerk;
|
|
230
|
+
registerWithClerk: typeof registerWithClerk;
|
|
135
231
|
syncIdentity: typeof syncIdentity;
|
|
136
232
|
verifyRequest: typeof verifyRequest;
|
|
137
233
|
verifySession: typeof verifySession;
|
|
@@ -140,6 +236,7 @@ declare const clerkAuthInternals: {
|
|
|
140
236
|
getBindings: typeof getBindings;
|
|
141
237
|
getConfiguredProviderConfig: typeof getConfiguredProviderConfig;
|
|
142
238
|
getSessionTokenFromRequest: typeof getSessionTokenFromRequest;
|
|
239
|
+
normalizeClerkUserProfile: typeof normalizeClerkUserProfile;
|
|
143
240
|
normalizeHostedProfile: typeof normalizeHostedProfile;
|
|
144
241
|
resolveConfiguredProviderName: typeof resolveConfiguredProviderName;
|
|
145
242
|
resolveDisplayName: typeof resolveDisplayName;
|
|
@@ -148,4 +245,4 @@ declare const clerkAuthInternals: {
|
|
|
148
245
|
resolvePrimaryEmail: typeof resolvePrimaryEmail;
|
|
149
246
|
};
|
|
150
247
|
|
|
151
|
-
export { type ClerkAuthBindings, ClerkAuthConflictError, type ClerkAuthFacade, type ClerkAuthenticationResult, type ClerkEmailAddress, type ClerkProviderRuntime, type ClerkSyncStatus, type ClerkUserProfile, type ClerkVerifiedSession, type ClerkVerifyRequestContext, type ClerkVerifySessionContext, type ConfigureClerkAuthRuntimeOptions, type HostedIdentityRecord, type HostedIdentityStore, authenticate, clerkAuth, clerkAuthInternals, configureClerkAuthRuntime, resetClerkAuthRuntime, syncIdentity, verifyRequest, verifySession };
|
|
248
|
+
export { type ClerkAuthBindings, ClerkAuthConflictError, type ClerkAuthFacade, type ClerkAuthenticatedUser, type ClerkAuthenticationResult, type ClerkCompleteAuthData, type ClerkCompleteAuthResult, type ClerkEmailAddress, type ClerkHostedAuthFailureFields, type ClerkLogoutData, type ClerkLogoutErrorCode, type ClerkLogoutResult, type ClerkLogoutSession, type ClerkProviderRuntime, type ClerkRequestHeaders, type ClerkRequestInput, type ClerkRequestLike, type ClerkSyncStatus, type ClerkUserAttributeValue, type ClerkUserAttributes, type ClerkUserProfile, type ClerkVerifiedSession, type ClerkVerifyRequestContext, type ClerkVerifySessionContext, type ConfigureClerkAuthRuntimeOptions, type HostedIdentityRecord, type HostedIdentityStore, authenticate, clerkAuth, clerkAuthInternals, completeClerkAuth, configureClerkAuthRuntime, loginWithClerk, logoutWithClerk, registerWithClerk, resetClerkAuthRuntime, syncIdentity, verifyRequest, verifySession };
|