@authsome/ui-core 0.1.8 → 1.0.0
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 +1140 -618
- package/dist/index.js +1458 -1515
- package/dist/index.js.map +1 -1
- package/package.json +22 -45
- package/README.md +0 -166
- package/dist/adapters/index.d.mts +0 -65
- package/dist/adapters/index.d.ts +0 -65
- package/dist/adapters/index.js +0 -94
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/index.mjs +0 -92
- package/dist/adapters/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -772
- package/dist/index.mjs +0 -1734
- package/dist/index.mjs.map +0 -1
- package/dist/provider-S9ZY5hsp.d.mts +0 -787
- package/dist/provider-S9ZY5hsp.d.ts +0 -787
- package/dist/types/index.d.mts +0 -98
- package/dist/types/index.d.ts +0 -98
- package/dist/types/index.js +0 -180
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -170
- package/dist/types/index.mjs.map +0 -1
package/dist/index.d.mts
DELETED
|
@@ -1,772 +0,0 @@
|
|
|
1
|
-
import { A as AuthErrorType, a as AuthError, V as ValidationError, C as CookieData, b as AuthContext, c as AuthProvider, S as SignInRequest, d as SignUpRequest, U as UpdateUserRequest, P as PasswordChangeRequest, e as PasswordResetRequest, f as PasswordResetConfirmRequest, O as OAuthSignInRequest, g as OAuthCallbackRequest, h as OAuthProvider, M as MagicLinkRequest, i as MagicLinkVerifyRequest, j as PhoneAuthRequest, k as PhoneVerifyRequest, T as TwoFactorSetupRequest, l as TwoFactorSetupResponse, m as TwoFactorVerifyRequest, n as TwoFactorMethod, o as PasskeyRegisterRequest, p as PasskeyCredential, q as PasskeyAuthRequest, r as Organization, s as OrganizationMembership, t as User, u as Session } from './provider-S9ZY5hsp.mjs';
|
|
2
|
-
export { E as AuthResponse, v as AuthState, X as Device, L as EnrollMFAFactorRequest, B as FieldDefinition, z as FieldType, F as FieldValidation, Z as ListSessionsOptions, _ as ListSessionsResponse, Q as MFAChallengeRequest, W as MFAChallengeResponse, K as MFAFactor, x as OAuthConfig, G as ProviderConfig, R as RequestContext, J as ResendVerificationRequest, H as SendVerificationEmailRequest, w as SessionData, Y as SessionInfo, D as SignupFieldsResponse, y as TwoFactorConfig, I as VerifyEmailRequest, N as VerifyMFAFactorRequest } from './provider-S9ZY5hsp.mjs';
|
|
3
|
-
import { Storage, Observable, Unsubscribe } from './types/index.mjs';
|
|
4
|
-
export { Listener, LocalStorageAdapter, MemoryStorageAdapter, SessionStorageAdapter } from './types/index.mjs';
|
|
5
|
-
export { BaseAuthProvider } from './adapters/index.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Error handling utilities
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create an auth error
|
|
13
|
-
*
|
|
14
|
-
* @deprecated Use `new AuthError()` directly instead
|
|
15
|
-
*/
|
|
16
|
-
declare function createAuthError(type: AuthErrorType, message: string, details?: Record<string, unknown>, code?: string | number): AuthError;
|
|
17
|
-
/**
|
|
18
|
-
* Check if an error is an auth error
|
|
19
|
-
*/
|
|
20
|
-
declare function isAuthError(error: unknown): error is AuthError;
|
|
21
|
-
/**
|
|
22
|
-
* Convert unknown error to auth error
|
|
23
|
-
*/
|
|
24
|
-
declare function toAuthError(error: unknown): AuthError;
|
|
25
|
-
/**
|
|
26
|
-
* Check if error is a network error
|
|
27
|
-
*/
|
|
28
|
-
declare function isNetworkError(error: unknown): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Check if error indicates authentication is required
|
|
31
|
-
*/
|
|
32
|
-
declare function isUnauthenticatedError(error: unknown): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Check if error requires MFA
|
|
35
|
-
*/
|
|
36
|
-
declare function isMFARequiredError(error: unknown): boolean;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Internationalization (i18n) types and interfaces
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Complete locale interface for all auth-related text
|
|
43
|
-
*/
|
|
44
|
-
interface AuthLocale {
|
|
45
|
-
common: {
|
|
46
|
-
loading: string;
|
|
47
|
-
submit: string;
|
|
48
|
-
cancel: string;
|
|
49
|
-
continue: string;
|
|
50
|
-
back: string;
|
|
51
|
-
or: string;
|
|
52
|
-
optional: string;
|
|
53
|
-
};
|
|
54
|
-
auth: {
|
|
55
|
-
signIn: string;
|
|
56
|
-
signUp: string;
|
|
57
|
-
signOut: string;
|
|
58
|
-
email: string;
|
|
59
|
-
password: string;
|
|
60
|
-
confirmPassword: string;
|
|
61
|
-
username: string;
|
|
62
|
-
phone: string;
|
|
63
|
-
rememberMe: string;
|
|
64
|
-
forgotPassword: string;
|
|
65
|
-
continueWith: string;
|
|
66
|
-
orContinueWith: string;
|
|
67
|
-
};
|
|
68
|
-
oauth: {
|
|
69
|
-
google: string;
|
|
70
|
-
github: string;
|
|
71
|
-
microsoft: string;
|
|
72
|
-
facebook: string;
|
|
73
|
-
apple: string;
|
|
74
|
-
discord: string;
|
|
75
|
-
twitter: string;
|
|
76
|
-
linkedin: string;
|
|
77
|
-
chooseProvider: string;
|
|
78
|
-
signInPreferred: string;
|
|
79
|
-
};
|
|
80
|
-
magicLink: {
|
|
81
|
-
sendLink: string;
|
|
82
|
-
checkEmail: string;
|
|
83
|
-
linkSent: string;
|
|
84
|
-
enterEmail: string;
|
|
85
|
-
};
|
|
86
|
-
phone: {
|
|
87
|
-
enterPhone: string;
|
|
88
|
-
sendCode: string;
|
|
89
|
-
enterCode: string;
|
|
90
|
-
verifyPhone: string;
|
|
91
|
-
codeLabel: string;
|
|
92
|
-
};
|
|
93
|
-
mfa: {
|
|
94
|
-
required: string;
|
|
95
|
-
selectMethod: string;
|
|
96
|
-
verify: string;
|
|
97
|
-
enterCode: string;
|
|
98
|
-
sms: string;
|
|
99
|
-
authenticator: string;
|
|
100
|
-
email: string;
|
|
101
|
-
};
|
|
102
|
-
passkey: {
|
|
103
|
-
signInWith: string;
|
|
104
|
-
register: string;
|
|
105
|
-
usePasskey: string;
|
|
106
|
-
};
|
|
107
|
-
signUp: {
|
|
108
|
-
title: string;
|
|
109
|
-
subtitle: string;
|
|
110
|
-
haveAccount: string;
|
|
111
|
-
signInLink: string;
|
|
112
|
-
agreeToTerms: string;
|
|
113
|
-
terms: string;
|
|
114
|
-
};
|
|
115
|
-
signIn: {
|
|
116
|
-
title: string;
|
|
117
|
-
subtitle: string;
|
|
118
|
-
noAccount: string;
|
|
119
|
-
signUpLink: string;
|
|
120
|
-
enterEmail: string;
|
|
121
|
-
};
|
|
122
|
-
validation: {
|
|
123
|
-
emailRequired: string;
|
|
124
|
-
emailInvalid: string;
|
|
125
|
-
passwordRequired: string;
|
|
126
|
-
passwordTooShort: string;
|
|
127
|
-
passwordRequireUppercase: string;
|
|
128
|
-
passwordRequireLowercase: string;
|
|
129
|
-
passwordRequireNumber: string;
|
|
130
|
-
passwordRequireSpecial: string;
|
|
131
|
-
passwordMismatch: string;
|
|
132
|
-
usernameRequired: string;
|
|
133
|
-
usernameInvalid: string;
|
|
134
|
-
phoneRequired: string;
|
|
135
|
-
phoneInvalid: string;
|
|
136
|
-
codeRequired: string;
|
|
137
|
-
codeInvalid: string;
|
|
138
|
-
fieldRequired: string;
|
|
139
|
-
termsRequired: string;
|
|
140
|
-
};
|
|
141
|
-
errors: {
|
|
142
|
-
invalidCredentials: string;
|
|
143
|
-
userNotFound: string;
|
|
144
|
-
userExists: string;
|
|
145
|
-
invalidToken: string;
|
|
146
|
-
tokenExpired: string;
|
|
147
|
-
networkError: string;
|
|
148
|
-
mfaRequired: string;
|
|
149
|
-
emailNotVerified: string;
|
|
150
|
-
phoneNotVerified: string;
|
|
151
|
-
rateLimitExceeded: string;
|
|
152
|
-
unknownError: string;
|
|
153
|
-
generic: string;
|
|
154
|
-
};
|
|
155
|
-
success: {
|
|
156
|
-
signedIn: string;
|
|
157
|
-
signedUp: string;
|
|
158
|
-
signedOut: string;
|
|
159
|
-
linkSent: string;
|
|
160
|
-
codeSent: string;
|
|
161
|
-
verified: string;
|
|
162
|
-
welcome: string;
|
|
163
|
-
};
|
|
164
|
-
placeholders: {
|
|
165
|
-
email: string;
|
|
166
|
-
password: string;
|
|
167
|
-
confirmPassword: string;
|
|
168
|
-
username: string;
|
|
169
|
-
phone: string;
|
|
170
|
-
code: string;
|
|
171
|
-
fullName: string;
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Deep partial type for locale overrides
|
|
176
|
-
*/
|
|
177
|
-
type DeepPartial<T> = {
|
|
178
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Validation utilities
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Validate email address
|
|
187
|
-
*/
|
|
188
|
-
declare function validateEmail(email: string, locale?: AuthLocale): ValidationError | null;
|
|
189
|
-
/**
|
|
190
|
-
* Validate password
|
|
191
|
-
*/
|
|
192
|
-
declare function validatePassword(password: string, options?: {
|
|
193
|
-
minLength?: number;
|
|
194
|
-
requireUppercase?: boolean;
|
|
195
|
-
requireLowercase?: boolean;
|
|
196
|
-
requireNumber?: boolean;
|
|
197
|
-
requireSpecial?: boolean;
|
|
198
|
-
locale?: AuthLocale;
|
|
199
|
-
}): ValidationError | null;
|
|
200
|
-
/**
|
|
201
|
-
* Validate phone number
|
|
202
|
-
*/
|
|
203
|
-
declare function validatePhone(phone: string, locale?: AuthLocale): ValidationError | null;
|
|
204
|
-
/**
|
|
205
|
-
* Validate username
|
|
206
|
-
*/
|
|
207
|
-
declare function validateUsername(username: string, locale?: AuthLocale): ValidationError | null;
|
|
208
|
-
/**
|
|
209
|
-
* Validate 2FA code
|
|
210
|
-
*/
|
|
211
|
-
declare function validate2FACode(code: string, locale?: AuthLocale): ValidationError | null;
|
|
212
|
-
/**
|
|
213
|
-
* Validate required field
|
|
214
|
-
*/
|
|
215
|
-
declare function validateRequired(value: unknown, fieldName: string, locale?: AuthLocale): ValidationError | null;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Token management utilities
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Token manager class
|
|
223
|
-
*/
|
|
224
|
-
declare class TokenManager {
|
|
225
|
-
private storage;
|
|
226
|
-
constructor(storage?: Storage);
|
|
227
|
-
/**
|
|
228
|
-
* Get access token
|
|
229
|
-
*/
|
|
230
|
-
getToken(): Promise<string | null>;
|
|
231
|
-
/**
|
|
232
|
-
* Set access token
|
|
233
|
-
*/
|
|
234
|
-
setToken(token: string): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Remove access token
|
|
237
|
-
*/
|
|
238
|
-
removeToken(): Promise<void>;
|
|
239
|
-
/**
|
|
240
|
-
* Get refresh token
|
|
241
|
-
*/
|
|
242
|
-
getRefreshToken(): Promise<string | null>;
|
|
243
|
-
/**
|
|
244
|
-
* Set refresh token
|
|
245
|
-
*/
|
|
246
|
-
setRefreshToken(token: string): Promise<void>;
|
|
247
|
-
/**
|
|
248
|
-
* Remove refresh token
|
|
249
|
-
*/
|
|
250
|
-
removeRefreshToken(): Promise<void>;
|
|
251
|
-
/**
|
|
252
|
-
* Clear all tokens
|
|
253
|
-
*/
|
|
254
|
-
clearTokens(): Promise<void>;
|
|
255
|
-
/**
|
|
256
|
-
* Check if token is expired
|
|
257
|
-
*/
|
|
258
|
-
isTokenExpired(token: string): boolean;
|
|
259
|
-
/**
|
|
260
|
-
* Decode JWT token (without verification)
|
|
261
|
-
*/
|
|
262
|
-
private decodeToken;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Cookie utility functions
|
|
267
|
-
* Framework-agnostic helpers for cookie parsing and serialization
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Parse Set-Cookie header value into CookieData
|
|
272
|
-
* @param setCookieHeader - The Set-Cookie header value
|
|
273
|
-
* @returns Parsed cookie data
|
|
274
|
-
*/
|
|
275
|
-
declare function parseCookie(setCookieHeader: string): CookieData | null;
|
|
276
|
-
/**
|
|
277
|
-
* Extract multiple cookies from Set-Cookie headers
|
|
278
|
-
* @param setCookieHeaders - Array of Set-Cookie header values or single string
|
|
279
|
-
* @returns Array of parsed cookies
|
|
280
|
-
*/
|
|
281
|
-
declare function extractCookiesFromHeaders(setCookieHeaders: string | string[]): CookieData[];
|
|
282
|
-
/**
|
|
283
|
-
* Serialize a CookieData object into a Set-Cookie header value
|
|
284
|
-
* @param cookie - The cookie data to serialize
|
|
285
|
-
* @returns Set-Cookie header value
|
|
286
|
-
*/
|
|
287
|
-
declare function serializeCookie(cookie: CookieData): string;
|
|
288
|
-
/**
|
|
289
|
-
* Parse Cookie header value into key-value pairs
|
|
290
|
-
* @param cookieHeader - The Cookie header value
|
|
291
|
-
* @returns Object with cookie name-value pairs
|
|
292
|
-
*/
|
|
293
|
-
declare function parseCookieOptions(cookieHeader: string): Record<string, string>;
|
|
294
|
-
/**
|
|
295
|
-
* Convert cookie object to Cookie header string
|
|
296
|
-
* @param cookies - Object with cookie name-value pairs
|
|
297
|
-
* @returns Cookie header value
|
|
298
|
-
*/
|
|
299
|
-
declare function serializeCookies(cookies: Record<string, string>): string;
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Locale utility functions
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Default locale (English)
|
|
307
|
-
*/
|
|
308
|
-
declare const defaultLocale: AuthLocale;
|
|
309
|
-
/**
|
|
310
|
-
* Create a complete locale by merging overrides with the default English locale
|
|
311
|
-
*
|
|
312
|
-
* @param overrides - Partial locale object with custom translations
|
|
313
|
-
* @returns Complete locale object with all required keys
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```typescript
|
|
317
|
-
* const spanishLocale = createLocale({
|
|
318
|
-
* auth: {
|
|
319
|
-
* signIn: 'Iniciar sesión',
|
|
320
|
-
* signUp: 'Registrarse',
|
|
321
|
-
* }
|
|
322
|
-
* });
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
declare function createLocale(overrides?: DeepPartial<AuthLocale>): AuthLocale;
|
|
326
|
-
/**
|
|
327
|
-
* Interpolate template string with values
|
|
328
|
-
*
|
|
329
|
-
* Replaces {key} placeholders with corresponding values from the provided object.
|
|
330
|
-
*
|
|
331
|
-
* @param template - Template string with {key} placeholders
|
|
332
|
-
* @param values - Object with key-value pairs for interpolation
|
|
333
|
-
* @returns Interpolated string
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* ```typescript
|
|
337
|
-
* interpolate('Hello, {name}!', { name: 'John' })
|
|
338
|
-
* // Returns: "Hello, John!"
|
|
339
|
-
*
|
|
340
|
-
* interpolate('Password must be at least {min} characters', { min: '8' })
|
|
341
|
-
* // Returns: "Password must be at least 8 characters"
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
declare function interpolate(template: string, values: Record<string, string | number>): string;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Auth client configuration
|
|
348
|
-
*/
|
|
349
|
-
interface AuthClientConfig {
|
|
350
|
-
provider: AuthProvider;
|
|
351
|
-
autoRefresh?: boolean;
|
|
352
|
-
refreshInterval?: number;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Auth client class
|
|
356
|
-
*/
|
|
357
|
-
declare class AuthClient {
|
|
358
|
-
private provider;
|
|
359
|
-
private autoRefresh;
|
|
360
|
-
private refreshInterval;
|
|
361
|
-
private refreshTimer?;
|
|
362
|
-
readonly state: Observable<AuthContext>;
|
|
363
|
-
get adapter(): AuthProvider;
|
|
364
|
-
constructor(config: AuthClientConfig);
|
|
365
|
-
/**
|
|
366
|
-
* Initialize the auth client
|
|
367
|
-
*/
|
|
368
|
-
initialize(): Promise<void>;
|
|
369
|
-
/**
|
|
370
|
-
* Sign in with credentials
|
|
371
|
-
*/
|
|
372
|
-
signIn(request: SignInRequest): Promise<void>;
|
|
373
|
-
/**
|
|
374
|
-
* Sign up with credentials
|
|
375
|
-
*/
|
|
376
|
-
signUp(request: SignUpRequest): Promise<void>;
|
|
377
|
-
/**
|
|
378
|
-
* Sign out
|
|
379
|
-
*/
|
|
380
|
-
signOut(): Promise<void>;
|
|
381
|
-
/**
|
|
382
|
-
* Update user profile
|
|
383
|
-
*/
|
|
384
|
-
updateUser(request: UpdateUserRequest): Promise<void>;
|
|
385
|
-
/**
|
|
386
|
-
* Change password
|
|
387
|
-
*/
|
|
388
|
-
changePassword(request: PasswordChangeRequest): Promise<void>;
|
|
389
|
-
/**
|
|
390
|
-
* Request password reset
|
|
391
|
-
*/
|
|
392
|
-
requestPasswordReset(request: PasswordResetRequest): Promise<void>;
|
|
393
|
-
/**
|
|
394
|
-
* Confirm password reset
|
|
395
|
-
*/
|
|
396
|
-
confirmPasswordReset(request: PasswordResetConfirmRequest): Promise<void>;
|
|
397
|
-
/**
|
|
398
|
-
* Get OAuth sign in URL
|
|
399
|
-
*/
|
|
400
|
-
getOAuthUrl(request: OAuthSignInRequest): Promise<string>;
|
|
401
|
-
/**
|
|
402
|
-
* Handle OAuth callback
|
|
403
|
-
*/
|
|
404
|
-
handleOAuthCallback(request: OAuthCallbackRequest): Promise<void>;
|
|
405
|
-
/**
|
|
406
|
-
* Get available OAuth providers
|
|
407
|
-
*/
|
|
408
|
-
getOAuthProviders(): Promise<OAuthProvider[]>;
|
|
409
|
-
/**
|
|
410
|
-
* Send magic link
|
|
411
|
-
*/
|
|
412
|
-
sendMagicLink(request: MagicLinkRequest): Promise<void>;
|
|
413
|
-
/**
|
|
414
|
-
* Verify magic link
|
|
415
|
-
*/
|
|
416
|
-
verifyMagicLink(request: MagicLinkVerifyRequest): Promise<void>;
|
|
417
|
-
/**
|
|
418
|
-
* Send phone verification code
|
|
419
|
-
*/
|
|
420
|
-
sendPhoneCode(request: PhoneAuthRequest): Promise<void>;
|
|
421
|
-
/**
|
|
422
|
-
* Verify phone code
|
|
423
|
-
*/
|
|
424
|
-
verifyPhoneCode(request: PhoneVerifyRequest): Promise<void>;
|
|
425
|
-
/**
|
|
426
|
-
* Setup 2FA
|
|
427
|
-
*/
|
|
428
|
-
setupTwoFactor(request: TwoFactorSetupRequest): Promise<TwoFactorSetupResponse>;
|
|
429
|
-
/**
|
|
430
|
-
* Verify 2FA code
|
|
431
|
-
*/
|
|
432
|
-
verifyTwoFactor(request: TwoFactorVerifyRequest): Promise<void>;
|
|
433
|
-
/**
|
|
434
|
-
* Disable 2FA
|
|
435
|
-
*/
|
|
436
|
-
disableTwoFactor(): Promise<void>;
|
|
437
|
-
/**
|
|
438
|
-
* Get 2FA status
|
|
439
|
-
*/
|
|
440
|
-
getTwoFactorStatus(): Promise<TwoFactorMethod[]>;
|
|
441
|
-
/**
|
|
442
|
-
* Register passkey
|
|
443
|
-
*/
|
|
444
|
-
registerPasskey(request: PasskeyRegisterRequest): Promise<PasskeyCredential>;
|
|
445
|
-
/**
|
|
446
|
-
* Authenticate with passkey
|
|
447
|
-
*/
|
|
448
|
-
authenticatePasskey(request: PasskeyAuthRequest): Promise<void>;
|
|
449
|
-
/**
|
|
450
|
-
* List passkeys
|
|
451
|
-
*/
|
|
452
|
-
listPasskeys(): Promise<PasskeyCredential[]>;
|
|
453
|
-
/**
|
|
454
|
-
* Delete passkey
|
|
455
|
-
*/
|
|
456
|
-
deletePasskey(credentialId: string): Promise<void>;
|
|
457
|
-
/**
|
|
458
|
-
* Get all organizations the user belongs to
|
|
459
|
-
* Only available if the provider supports organizations
|
|
460
|
-
*/
|
|
461
|
-
getOrganizations(): Promise<Organization[]>;
|
|
462
|
-
/**
|
|
463
|
-
* Get the currently active organization
|
|
464
|
-
* Only available if the provider supports organizations
|
|
465
|
-
*/
|
|
466
|
-
getActiveOrganization(): Promise<Organization | null>;
|
|
467
|
-
/**
|
|
468
|
-
* Set the active organization and refresh user state
|
|
469
|
-
* Only available if the provider supports organizations
|
|
470
|
-
*/
|
|
471
|
-
setActiveOrganization(organizationId: string): Promise<void>;
|
|
472
|
-
/**
|
|
473
|
-
* Get organization memberships with roles and permissions
|
|
474
|
-
* Only available if the provider supports organizations
|
|
475
|
-
*/
|
|
476
|
-
getOrganizationMemberships(): Promise<OrganizationMembership[]>;
|
|
477
|
-
/**
|
|
478
|
-
* Check if the provider supports organizations
|
|
479
|
-
*/
|
|
480
|
-
supportsOrganizations(): boolean;
|
|
481
|
-
/**
|
|
482
|
-
* Refresh session
|
|
483
|
-
*/
|
|
484
|
-
refreshSession(): Promise<void>;
|
|
485
|
-
/**
|
|
486
|
-
* Get current user
|
|
487
|
-
*/
|
|
488
|
-
getUser(): User | null;
|
|
489
|
-
/**
|
|
490
|
-
* Get current session
|
|
491
|
-
*/
|
|
492
|
-
getSession(): Session | null;
|
|
493
|
-
/**
|
|
494
|
-
* Check if authenticated
|
|
495
|
-
*/
|
|
496
|
-
isAuthenticated(): boolean;
|
|
497
|
-
/**
|
|
498
|
-
* Get current error
|
|
499
|
-
*/
|
|
500
|
-
getError(): AuthError | null;
|
|
501
|
-
/**
|
|
502
|
-
* Clear error
|
|
503
|
-
*/
|
|
504
|
-
clearError(): void;
|
|
505
|
-
/**
|
|
506
|
-
* Subscribe to auth state changes
|
|
507
|
-
*/
|
|
508
|
-
subscribe(listener: (context: AuthContext) => void): Unsubscribe;
|
|
509
|
-
/**
|
|
510
|
-
* Cleanup resources
|
|
511
|
-
*/
|
|
512
|
-
destroy(): void;
|
|
513
|
-
private updateState;
|
|
514
|
-
private setLoading;
|
|
515
|
-
private handleError;
|
|
516
|
-
private startAutoRefresh;
|
|
517
|
-
private stopAutoRefresh;
|
|
518
|
-
private createUnsupportedError;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Authentication flow types and state machine
|
|
523
|
-
*/
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Available authentication flow steps
|
|
527
|
-
*/
|
|
528
|
-
declare enum FlowStep {
|
|
529
|
-
SIGN_IN = "sign_in",
|
|
530
|
-
SIGN_UP = "sign_up",
|
|
531
|
-
EMAIL_PASSWORD_SIGN_IN = "email_password_sign_in",
|
|
532
|
-
EMAIL_PASSWORD_SIGN_UP = "email_password_sign_up",
|
|
533
|
-
OAUTH_SELECT = "oauth_select",
|
|
534
|
-
OAUTH_CALLBACK = "oauth_callback",
|
|
535
|
-
MAGIC_LINK_REQUEST = "magic_link_request",
|
|
536
|
-
MAGIC_LINK_VERIFY = "magic_link_verify",
|
|
537
|
-
MAGIC_LINK_SENT = "magic_link_sent",
|
|
538
|
-
PHONE_REQUEST = "phone_request",
|
|
539
|
-
PHONE_VERIFY = "phone_verify",
|
|
540
|
-
USERNAME_SIGN_IN = "username_sign_in",
|
|
541
|
-
USERNAME_SIGN_UP = "username_sign_up",
|
|
542
|
-
PASSKEY_REGISTER = "passkey_register",
|
|
543
|
-
PASSKEY_AUTHENTICATE = "passkey_authenticate",
|
|
544
|
-
MFA_REQUIRED = "mfa_required",
|
|
545
|
-
MFA_SETUP = "mfa_setup",
|
|
546
|
-
MFA_VERIFY = "mfa_verify",
|
|
547
|
-
MFA_SELECT_METHOD = "mfa_select_method",
|
|
548
|
-
EMAIL_VERIFICATION_REQUIRED = "email_verification_required",
|
|
549
|
-
EMAIL_VERIFICATION_SENT = "email_verification_sent",
|
|
550
|
-
PHONE_VERIFICATION_REQUIRED = "phone_verification_required",
|
|
551
|
-
PASSWORD_RESET_REQUEST = "password_reset_request",
|
|
552
|
-
PASSWORD_RESET_SENT = "password_reset_sent",
|
|
553
|
-
PASSWORD_RESET_CONFIRM = "password_reset_confirm",
|
|
554
|
-
PASSWORD_CHANGE = "password_change",
|
|
555
|
-
PROFILE_UPDATE = "profile_update",
|
|
556
|
-
PROFILE_COMPLETE = "profile_complete",
|
|
557
|
-
SUCCESS = "success",
|
|
558
|
-
ERROR = "error",
|
|
559
|
-
CANCELLED = "cancelled"
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* Flow state data that can be passed between steps
|
|
563
|
-
*/
|
|
564
|
-
interface FlowState {
|
|
565
|
-
currentStep: FlowStep;
|
|
566
|
-
previousStep?: FlowStep;
|
|
567
|
-
user?: User;
|
|
568
|
-
session?: Session;
|
|
569
|
-
email?: string;
|
|
570
|
-
phone?: string;
|
|
571
|
-
username?: string;
|
|
572
|
-
mfaRequired?: boolean;
|
|
573
|
-
mfaMethods?: TwoFactorMethod[];
|
|
574
|
-
mfaToken?: string;
|
|
575
|
-
oauthProvider?: OAuthProvider;
|
|
576
|
-
oauthRedirectUrl?: string;
|
|
577
|
-
verificationRequired?: boolean;
|
|
578
|
-
verificationToken?: string;
|
|
579
|
-
verificationSent?: boolean;
|
|
580
|
-
error?: AuthError;
|
|
581
|
-
metadata?: Record<string, unknown>;
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Flow transition result
|
|
585
|
-
*/
|
|
586
|
-
interface FlowTransition {
|
|
587
|
-
nextStep: FlowStep;
|
|
588
|
-
state: Partial<FlowState>;
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Flow configuration for a specific authentication journey
|
|
592
|
-
*/
|
|
593
|
-
interface FlowConfig {
|
|
594
|
-
name: string;
|
|
595
|
-
description?: string;
|
|
596
|
-
initialStep: FlowStep;
|
|
597
|
-
allowedSteps: FlowStep[];
|
|
598
|
-
transitions: {
|
|
599
|
-
[key in FlowStep]?: {
|
|
600
|
-
onSuccess?: FlowStep;
|
|
601
|
-
onError?: FlowStep;
|
|
602
|
-
onCancel?: FlowStep;
|
|
603
|
-
onBack?: FlowStep;
|
|
604
|
-
conditions?: Array<{
|
|
605
|
-
when: (state: FlowState) => boolean;
|
|
606
|
-
then: FlowStep;
|
|
607
|
-
}>;
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
onStepChange?: (step: FlowStep, state: FlowState) => void;
|
|
611
|
-
onComplete?: (user: User, session: Session) => void;
|
|
612
|
-
onError?: (error: AuthError, state: FlowState) => void;
|
|
613
|
-
onCancel?: (state: FlowState) => void;
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Predefined flow configurations
|
|
617
|
-
*/
|
|
618
|
-
declare enum FlowConfigType {
|
|
619
|
-
SIMPLE_SIGN_IN = "simple_sign_in",
|
|
620
|
-
SIMPLE_SIGN_UP = "simple_sign_up",
|
|
621
|
-
SIGN_UP_WITH_EMAIL_VERIFICATION = "sign_up_with_email_verification",
|
|
622
|
-
SIGN_IN_WITH_MFA = "sign_in_with_mfa",
|
|
623
|
-
OAUTH_SIGN_IN = "oauth_sign_in",
|
|
624
|
-
MAGIC_LINK_FLOW = "magic_link_flow",
|
|
625
|
-
PHONE_AUTH_FLOW = "phone_auth_flow",
|
|
626
|
-
COMPLETE_SIGN_UP_FLOW = "complete_sign_up_flow",// signup → verify email → complete profile
|
|
627
|
-
SECURE_SIGN_IN_FLOW = "secure_sign_in_flow",// signin → MFA → success
|
|
628
|
-
PASSWORD_RESET_FLOW = "password_reset_flow",
|
|
629
|
-
EMAIL_VERIFICATION_FLOW = "email_verification_flow",
|
|
630
|
-
CUSTOM = "custom"
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* Flow action types
|
|
634
|
-
*/
|
|
635
|
-
declare enum FlowAction {
|
|
636
|
-
START = "start",
|
|
637
|
-
NEXT = "next",
|
|
638
|
-
BACK = "back",
|
|
639
|
-
CANCEL = "cancel",
|
|
640
|
-
ERROR = "error",
|
|
641
|
-
RESET = "reset"
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Flow event for state machine
|
|
645
|
-
*/
|
|
646
|
-
interface FlowEvent {
|
|
647
|
-
action: FlowAction;
|
|
648
|
-
data?: Partial<FlowState>;
|
|
649
|
-
error?: AuthError;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Authentication flow state machine engine
|
|
654
|
-
*/
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Flow engine that manages authentication flow state transitions
|
|
658
|
-
*/
|
|
659
|
-
declare class FlowEngine {
|
|
660
|
-
private config;
|
|
661
|
-
private state;
|
|
662
|
-
private history;
|
|
663
|
-
constructor(config: FlowConfig, initialState?: Partial<FlowState>);
|
|
664
|
-
/**
|
|
665
|
-
* Get current flow state
|
|
666
|
-
*/
|
|
667
|
-
getState(): FlowState;
|
|
668
|
-
/**
|
|
669
|
-
* Get current step
|
|
670
|
-
*/
|
|
671
|
-
getCurrentStep(): FlowStep;
|
|
672
|
-
/**
|
|
673
|
-
* Check if step is allowed in this flow
|
|
674
|
-
*/
|
|
675
|
-
isStepAllowed(step: FlowStep): boolean;
|
|
676
|
-
/**
|
|
677
|
-
* Transition to next step based on action
|
|
678
|
-
*/
|
|
679
|
-
transition(event: FlowEvent): Promise<FlowState>;
|
|
680
|
-
/**
|
|
681
|
-
* Start or restart the flow
|
|
682
|
-
*/
|
|
683
|
-
private handleStart;
|
|
684
|
-
/**
|
|
685
|
-
* Move to next step
|
|
686
|
-
*/
|
|
687
|
-
private handleNext;
|
|
688
|
-
/**
|
|
689
|
-
* Go back to previous step
|
|
690
|
-
*/
|
|
691
|
-
private handleBack;
|
|
692
|
-
/**
|
|
693
|
-
* Cancel the flow
|
|
694
|
-
*/
|
|
695
|
-
private handleCancel;
|
|
696
|
-
/**
|
|
697
|
-
* Handle error in flow
|
|
698
|
-
*/
|
|
699
|
-
private handleError;
|
|
700
|
-
/**
|
|
701
|
-
* Reset flow to initial state
|
|
702
|
-
*/
|
|
703
|
-
private handleReset;
|
|
704
|
-
/**
|
|
705
|
-
* Move to a specific step
|
|
706
|
-
*/
|
|
707
|
-
private moveToStep;
|
|
708
|
-
/**
|
|
709
|
-
* Get flow history
|
|
710
|
-
*/
|
|
711
|
-
getHistory(): FlowStep[];
|
|
712
|
-
/**
|
|
713
|
-
* Check if can go back
|
|
714
|
-
*/
|
|
715
|
-
canGoBack(): boolean;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Predefined flow configurations
|
|
720
|
-
*/
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* Simple sign-in flow (email/password only)
|
|
724
|
-
*/
|
|
725
|
-
declare const simpleSignInFlow: FlowConfig;
|
|
726
|
-
/**
|
|
727
|
-
* Sign-in with MFA support
|
|
728
|
-
*/
|
|
729
|
-
declare const signInWithMFAFlow: FlowConfig;
|
|
730
|
-
/**
|
|
731
|
-
* Complete sign-up flow with email verification
|
|
732
|
-
*/
|
|
733
|
-
declare const completeSignUpFlow: FlowConfig;
|
|
734
|
-
/**
|
|
735
|
-
* Magic link authentication flow
|
|
736
|
-
*/
|
|
737
|
-
declare const magicLinkFlow: FlowConfig;
|
|
738
|
-
/**
|
|
739
|
-
* Phone authentication flow
|
|
740
|
-
*/
|
|
741
|
-
declare const phoneAuthFlow: FlowConfig;
|
|
742
|
-
/**
|
|
743
|
-
* OAuth sign-in flow
|
|
744
|
-
*/
|
|
745
|
-
declare const oauthSignInFlow: FlowConfig;
|
|
746
|
-
/**
|
|
747
|
-
* Password reset flow
|
|
748
|
-
*/
|
|
749
|
-
declare const passwordResetFlow: FlowConfig;
|
|
750
|
-
/**
|
|
751
|
-
* Email verification flow
|
|
752
|
-
*/
|
|
753
|
-
declare const emailVerificationFlow: FlowConfig;
|
|
754
|
-
/**
|
|
755
|
-
* Get predefined flow configuration by type
|
|
756
|
-
*/
|
|
757
|
-
declare function getFlowConfig(type: FlowConfigType): FlowConfig;
|
|
758
|
-
/**
|
|
759
|
-
* Export all predefined flows
|
|
760
|
-
*/
|
|
761
|
-
declare const predefinedFlows: {
|
|
762
|
-
simple_sign_in: FlowConfig;
|
|
763
|
-
sign_in_with_mfa: FlowConfig;
|
|
764
|
-
complete_sign_up_flow: FlowConfig;
|
|
765
|
-
magic_link_flow: FlowConfig;
|
|
766
|
-
phone_auth_flow: FlowConfig;
|
|
767
|
-
oauth_sign_in: FlowConfig;
|
|
768
|
-
password_reset_flow: FlowConfig;
|
|
769
|
-
email_verification_flow: FlowConfig;
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
export { AuthClient, type AuthClientConfig, AuthContext, AuthError, AuthErrorType, type AuthLocale, AuthProvider, CookieData, type DeepPartial, FlowAction, type FlowConfig, FlowConfigType, FlowEngine, type FlowEvent, type FlowState, FlowStep, type FlowTransition, MagicLinkRequest, MagicLinkVerifyRequest, OAuthCallbackRequest, OAuthProvider, OAuthSignInRequest, Observable, Organization, OrganizationMembership, PasskeyAuthRequest, PasskeyCredential, PasskeyRegisterRequest, PasswordChangeRequest, PasswordResetConfirmRequest, PasswordResetRequest, PhoneAuthRequest, PhoneVerifyRequest, Session, SignInRequest, SignUpRequest, Storage, TokenManager, TwoFactorMethod, TwoFactorSetupRequest, TwoFactorSetupResponse, TwoFactorVerifyRequest, Unsubscribe, UpdateUserRequest, User, ValidationError, completeSignUpFlow, createAuthError, createLocale, defaultLocale, emailVerificationFlow, extractCookiesFromHeaders, getFlowConfig, interpolate, isAuthError, isMFARequiredError, isNetworkError, isUnauthenticatedError, magicLinkFlow, oauthSignInFlow, parseCookie, parseCookieOptions, passwordResetFlow, phoneAuthFlow, predefinedFlows, serializeCookie, serializeCookies, signInWithMFAFlow, simpleSignInFlow, toAuthError, validate2FACode, validateEmail, validatePassword, validatePhone, validateRequired, validateUsername };
|