@authsome/ui-core 0.1.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/README.md +164 -0
- package/dist/adapters/index.d.mts +57 -0
- package/dist/adapters/index.d.ts +57 -0
- package/dist/adapters/index.js +94 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +92 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/index.d.mts +540 -0
- package/dist/index.d.ts +540 -0
- package/dist/index.js +1453 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1415 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider-DXf_a2WT.d.mts +457 -0
- package/dist/provider-DXf_a2WT.d.ts +457 -0
- package/dist/types/index.d.mts +98 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/index.js +180 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +170 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core authentication types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Authentication state enum
|
|
6
|
+
*/
|
|
7
|
+
declare enum AuthState {
|
|
8
|
+
AUTHENTICATED = "authenticated",
|
|
9
|
+
UNAUTHENTICATED = "unauthenticated",
|
|
10
|
+
LOADING = "loading",
|
|
11
|
+
ERROR = "error"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* User profile interface
|
|
15
|
+
*/
|
|
16
|
+
interface User {
|
|
17
|
+
id: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
username?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
emailVerified?: boolean;
|
|
22
|
+
phoneVerified?: boolean;
|
|
23
|
+
name?: string;
|
|
24
|
+
firstName?: string;
|
|
25
|
+
lastName?: string;
|
|
26
|
+
avatar?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
updatedAt?: Date;
|
|
30
|
+
organizationId?: string;
|
|
31
|
+
organizationRole?: string;
|
|
32
|
+
organizationMemberships?: OrganizationMembership[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Session interface
|
|
36
|
+
*/
|
|
37
|
+
interface Session {
|
|
38
|
+
id: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
token: string;
|
|
41
|
+
expiresAt?: Date;
|
|
42
|
+
createdAt?: Date;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Auth error types
|
|
47
|
+
*/
|
|
48
|
+
declare enum AuthErrorType {
|
|
49
|
+
INVALID_CREDENTIALS = "invalid_credentials",
|
|
50
|
+
USER_NOT_FOUND = "user_not_found",
|
|
51
|
+
USER_ALREADY_EXISTS = "user_already_exists",
|
|
52
|
+
INVALID_TOKEN = "invalid_token",
|
|
53
|
+
TOKEN_EXPIRED = "token_expired",
|
|
54
|
+
NETWORK_ERROR = "network_error",
|
|
55
|
+
VALIDATION_ERROR = "validation_error",
|
|
56
|
+
MFA_REQUIRED = "mfa_required",
|
|
57
|
+
EMAIL_NOT_VERIFIED = "email_not_verified",
|
|
58
|
+
PHONE_NOT_VERIFIED = "phone_not_verified",
|
|
59
|
+
RATE_LIMIT_EXCEEDED = "rate_limit_exceeded",
|
|
60
|
+
UNKNOWN_ERROR = "unknown_error"
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Auth error class
|
|
64
|
+
*
|
|
65
|
+
* Extends Error to provide proper error handling with auth-specific context
|
|
66
|
+
*/
|
|
67
|
+
declare class AuthError extends Error {
|
|
68
|
+
readonly type: AuthErrorType;
|
|
69
|
+
readonly details?: Record<string, unknown>;
|
|
70
|
+
readonly code?: string | number;
|
|
71
|
+
readonly originalError?: unknown;
|
|
72
|
+
constructor(message: string, type?: AuthErrorType, options?: {
|
|
73
|
+
details?: Record<string, unknown>;
|
|
74
|
+
code?: string | number;
|
|
75
|
+
originalError?: unknown;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Auth context state
|
|
80
|
+
*/
|
|
81
|
+
interface AuthContext {
|
|
82
|
+
state: AuthState;
|
|
83
|
+
user: User | null;
|
|
84
|
+
session: Session | null;
|
|
85
|
+
error: AuthError | null;
|
|
86
|
+
isAuthenticated: boolean;
|
|
87
|
+
isLoading: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* OAuth provider types
|
|
91
|
+
*/
|
|
92
|
+
declare enum OAuthProvider {
|
|
93
|
+
GOOGLE = "google",
|
|
94
|
+
GITHUB = "github",
|
|
95
|
+
FACEBOOK = "facebook",
|
|
96
|
+
TWITTER = "twitter",
|
|
97
|
+
MICROSOFT = "microsoft",
|
|
98
|
+
APPLE = "apple",
|
|
99
|
+
LINKEDIN = "linkedin",
|
|
100
|
+
DISCORD = "discord"
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* OAuth configuration
|
|
104
|
+
*/
|
|
105
|
+
interface OAuthConfig {
|
|
106
|
+
provider: OAuthProvider;
|
|
107
|
+
clientId: string;
|
|
108
|
+
redirectUri: string;
|
|
109
|
+
scope?: string[];
|
|
110
|
+
state?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 2FA method types
|
|
114
|
+
*/
|
|
115
|
+
declare enum TwoFactorMethod {
|
|
116
|
+
TOTP = "totp",
|
|
117
|
+
SMS = "sms",
|
|
118
|
+
EMAIL = "email",
|
|
119
|
+
BACKUP_CODE = "backup_code"
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 2FA configuration
|
|
123
|
+
*/
|
|
124
|
+
interface TwoFactorConfig {
|
|
125
|
+
method: TwoFactorMethod;
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
verified?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Passkey/WebAuthn types
|
|
131
|
+
*/
|
|
132
|
+
interface PasskeyCredential {
|
|
133
|
+
id: string;
|
|
134
|
+
name?: string;
|
|
135
|
+
createdAt?: Date;
|
|
136
|
+
lastUsedAt?: Date;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Validation error
|
|
140
|
+
*/
|
|
141
|
+
interface ValidationError {
|
|
142
|
+
field: string;
|
|
143
|
+
message: string;
|
|
144
|
+
code?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Organization interface
|
|
148
|
+
*/
|
|
149
|
+
interface Organization {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
slug: string;
|
|
153
|
+
logoUrl?: string;
|
|
154
|
+
createdAt?: Date;
|
|
155
|
+
metadata?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Organization membership interface
|
|
159
|
+
*/
|
|
160
|
+
interface OrganizationMembership {
|
|
161
|
+
organization: Organization;
|
|
162
|
+
role: 'owner' | 'admin' | 'member';
|
|
163
|
+
permissions?: string[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sign in request
|
|
168
|
+
*/
|
|
169
|
+
interface SignInRequest {
|
|
170
|
+
email?: string;
|
|
171
|
+
username?: string;
|
|
172
|
+
phone?: string;
|
|
173
|
+
password?: string;
|
|
174
|
+
remember?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Sign up request
|
|
178
|
+
*/
|
|
179
|
+
interface SignUpRequest {
|
|
180
|
+
email?: string;
|
|
181
|
+
username?: string;
|
|
182
|
+
phone?: string;
|
|
183
|
+
password: string;
|
|
184
|
+
name?: string;
|
|
185
|
+
firstName?: string;
|
|
186
|
+
lastName?: string;
|
|
187
|
+
metadata?: Record<string, unknown>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* OAuth sign in request
|
|
191
|
+
*/
|
|
192
|
+
interface OAuthSignInRequest {
|
|
193
|
+
provider: OAuthProvider;
|
|
194
|
+
redirectUri?: string;
|
|
195
|
+
state?: string;
|
|
196
|
+
scope?: string[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* OAuth callback request
|
|
200
|
+
*/
|
|
201
|
+
interface OAuthCallbackRequest {
|
|
202
|
+
provider: OAuthProvider;
|
|
203
|
+
code: string;
|
|
204
|
+
state?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Magic link request
|
|
208
|
+
*/
|
|
209
|
+
interface MagicLinkRequest {
|
|
210
|
+
email: string;
|
|
211
|
+
redirectUri?: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Magic link verify request
|
|
215
|
+
*/
|
|
216
|
+
interface MagicLinkVerifyRequest {
|
|
217
|
+
token: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Phone auth request
|
|
221
|
+
*/
|
|
222
|
+
interface PhoneAuthRequest {
|
|
223
|
+
phone: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Phone verify request
|
|
227
|
+
*/
|
|
228
|
+
interface PhoneVerifyRequest {
|
|
229
|
+
phone: string;
|
|
230
|
+
code: string;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 2FA setup request
|
|
234
|
+
*/
|
|
235
|
+
interface TwoFactorSetupRequest {
|
|
236
|
+
method: TwoFactorMethod;
|
|
237
|
+
phone?: string;
|
|
238
|
+
email?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* 2FA setup response
|
|
242
|
+
*/
|
|
243
|
+
interface TwoFactorSetupResponse {
|
|
244
|
+
method: TwoFactorMethod;
|
|
245
|
+
secret?: string;
|
|
246
|
+
qrCode?: string;
|
|
247
|
+
backupCodes?: string[];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 2FA verify request
|
|
251
|
+
*/
|
|
252
|
+
interface TwoFactorVerifyRequest {
|
|
253
|
+
code: string;
|
|
254
|
+
method?: TwoFactorMethod;
|
|
255
|
+
remember?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Passkey registration request
|
|
259
|
+
*/
|
|
260
|
+
interface PasskeyRegisterRequest {
|
|
261
|
+
name?: string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Passkey authentication request
|
|
265
|
+
*/
|
|
266
|
+
interface PasskeyAuthRequest {
|
|
267
|
+
credentialId?: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Password reset request
|
|
271
|
+
*/
|
|
272
|
+
interface PasswordResetRequest {
|
|
273
|
+
email: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Password reset confirm request
|
|
277
|
+
*/
|
|
278
|
+
interface PasswordResetConfirmRequest {
|
|
279
|
+
token: string;
|
|
280
|
+
password: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Password change request
|
|
284
|
+
*/
|
|
285
|
+
interface PasswordChangeRequest {
|
|
286
|
+
currentPassword: string;
|
|
287
|
+
newPassword: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Update user request
|
|
291
|
+
*/
|
|
292
|
+
interface UpdateUserRequest {
|
|
293
|
+
name?: string;
|
|
294
|
+
firstName?: string;
|
|
295
|
+
lastName?: string;
|
|
296
|
+
avatar?: string;
|
|
297
|
+
metadata?: Record<string, unknown>;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Auth response
|
|
301
|
+
*/
|
|
302
|
+
interface AuthResponse {
|
|
303
|
+
user: User;
|
|
304
|
+
session: Session;
|
|
305
|
+
requiresTwoFactor?: boolean;
|
|
306
|
+
twoFactorMethods?: TwoFactorMethod[];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Provider configuration
|
|
310
|
+
*/
|
|
311
|
+
interface ProviderConfig {
|
|
312
|
+
apiUrl?: string;
|
|
313
|
+
apiKey?: string;
|
|
314
|
+
[key: string]: unknown;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Auth provider interface
|
|
318
|
+
*
|
|
319
|
+
* This interface defines the contract that all auth providers must implement.
|
|
320
|
+
* Providers can be for different backends like AuthSome, Clerk, Supabase, etc.
|
|
321
|
+
*/
|
|
322
|
+
interface AuthProvider {
|
|
323
|
+
/**
|
|
324
|
+
* Provider name/identifier
|
|
325
|
+
*/
|
|
326
|
+
readonly name: string;
|
|
327
|
+
/**
|
|
328
|
+
* Initialize the provider
|
|
329
|
+
*/
|
|
330
|
+
initialize(config: ProviderConfig): Promise<void>;
|
|
331
|
+
/**
|
|
332
|
+
* Sign in with email/username/phone and password
|
|
333
|
+
*/
|
|
334
|
+
signIn(request: SignInRequest): Promise<AuthResponse>;
|
|
335
|
+
/**
|
|
336
|
+
* Sign up with email/username/phone and password
|
|
337
|
+
*/
|
|
338
|
+
signUp(request: SignUpRequest): Promise<AuthResponse>;
|
|
339
|
+
/**
|
|
340
|
+
* Sign out
|
|
341
|
+
*/
|
|
342
|
+
signOut(): Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* Get current user
|
|
345
|
+
*/
|
|
346
|
+
getCurrentUser(): Promise<User | null>;
|
|
347
|
+
/**
|
|
348
|
+
* Get current session
|
|
349
|
+
*/
|
|
350
|
+
getCurrentSession(): Promise<Session | null>;
|
|
351
|
+
/**
|
|
352
|
+
* Refresh session
|
|
353
|
+
*/
|
|
354
|
+
refreshSession(): Promise<Session>;
|
|
355
|
+
/**
|
|
356
|
+
* Update user profile
|
|
357
|
+
*/
|
|
358
|
+
updateUser(request: UpdateUserRequest): Promise<User>;
|
|
359
|
+
/**
|
|
360
|
+
* Change password
|
|
361
|
+
*/
|
|
362
|
+
changePassword(request: PasswordChangeRequest): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Request password reset
|
|
365
|
+
*/
|
|
366
|
+
requestPasswordReset(request: PasswordResetRequest): Promise<void>;
|
|
367
|
+
/**
|
|
368
|
+
* Confirm password reset
|
|
369
|
+
*/
|
|
370
|
+
confirmPasswordReset(request: PasswordResetConfirmRequest): Promise<void>;
|
|
371
|
+
/**
|
|
372
|
+
* Initiate OAuth sign in
|
|
373
|
+
*/
|
|
374
|
+
oauthSignIn(request: OAuthSignInRequest): Promise<string>;
|
|
375
|
+
/**
|
|
376
|
+
* Handle OAuth callback
|
|
377
|
+
*/
|
|
378
|
+
oauthCallback(request: OAuthCallbackRequest): Promise<AuthResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Get available OAuth providers
|
|
381
|
+
*/
|
|
382
|
+
getOAuthProviders(): Promise<OAuthProvider[]>;
|
|
383
|
+
/**
|
|
384
|
+
* Send magic link
|
|
385
|
+
*/
|
|
386
|
+
sendMagicLink(request: MagicLinkRequest): Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Verify magic link
|
|
389
|
+
*/
|
|
390
|
+
verifyMagicLink(request: MagicLinkVerifyRequest): Promise<AuthResponse>;
|
|
391
|
+
/**
|
|
392
|
+
* Send phone verification code
|
|
393
|
+
*/
|
|
394
|
+
sendPhoneCode(request: PhoneAuthRequest): Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* Verify phone code
|
|
397
|
+
*/
|
|
398
|
+
verifyPhoneCode(request: PhoneVerifyRequest): Promise<AuthResponse>;
|
|
399
|
+
/**
|
|
400
|
+
* Setup 2FA
|
|
401
|
+
*/
|
|
402
|
+
setupTwoFactor(request: TwoFactorSetupRequest): Promise<TwoFactorSetupResponse>;
|
|
403
|
+
/**
|
|
404
|
+
* Verify 2FA
|
|
405
|
+
*/
|
|
406
|
+
verifyTwoFactor(request: TwoFactorVerifyRequest): Promise<AuthResponse>;
|
|
407
|
+
/**
|
|
408
|
+
* Disable 2FA
|
|
409
|
+
*/
|
|
410
|
+
disableTwoFactor(): Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Get 2FA status
|
|
413
|
+
*/
|
|
414
|
+
getTwoFactorStatus(): Promise<TwoFactorMethod[]>;
|
|
415
|
+
/**
|
|
416
|
+
* Register passkey
|
|
417
|
+
*/
|
|
418
|
+
registerPasskey(request: PasskeyRegisterRequest): Promise<PasskeyCredential>;
|
|
419
|
+
/**
|
|
420
|
+
* Authenticate with passkey
|
|
421
|
+
*/
|
|
422
|
+
authenticatePasskey(request: PasskeyAuthRequest): Promise<AuthResponse>;
|
|
423
|
+
/**
|
|
424
|
+
* List passkeys
|
|
425
|
+
*/
|
|
426
|
+
listPasskeys(): Promise<PasskeyCredential[]>;
|
|
427
|
+
/**
|
|
428
|
+
* Delete passkey
|
|
429
|
+
*/
|
|
430
|
+
deletePasskey(credentialId: string): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Normalize provider-specific errors to AuthError
|
|
433
|
+
*/
|
|
434
|
+
normalizeError(error: unknown): AuthError;
|
|
435
|
+
/**
|
|
436
|
+
* Get all organizations the user belongs to
|
|
437
|
+
* Optional - only available if adapter supports organizations
|
|
438
|
+
*/
|
|
439
|
+
getOrganizations?(): Promise<Organization[]>;
|
|
440
|
+
/**
|
|
441
|
+
* Get the currently active organization
|
|
442
|
+
* Optional - only available if adapter supports organizations
|
|
443
|
+
*/
|
|
444
|
+
getActiveOrganization?(): Promise<Organization | null>;
|
|
445
|
+
/**
|
|
446
|
+
* Set the active organization
|
|
447
|
+
* Optional - only available if adapter supports organizations
|
|
448
|
+
*/
|
|
449
|
+
setActiveOrganization?(organizationId: string): Promise<void>;
|
|
450
|
+
/**
|
|
451
|
+
* Get organization memberships with roles and permissions
|
|
452
|
+
* Optional - only available if adapter supports organizations
|
|
453
|
+
*/
|
|
454
|
+
getOrganizationMemberships?(): Promise<OrganizationMembership[]>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export { AuthErrorType as A, type MagicLinkRequest as M, type OAuthSignInRequest as O, type PasswordChangeRequest as P, type SignInRequest as S, type TwoFactorSetupRequest as T, type UpdateUserRequest as U, type ValidationError as V, AuthError as a, type AuthContext as b, type AuthProvider as c, type SignUpRequest as d, type PasswordResetRequest as e, type PasswordResetConfirmRequest as f, type OAuthCallbackRequest as g, OAuthProvider as h, type MagicLinkVerifyRequest as i, type PhoneAuthRequest as j, type PhoneVerifyRequest as k, type TwoFactorSetupResponse as l, type TwoFactorVerifyRequest as m, TwoFactorMethod as n, type PasskeyRegisterRequest as o, type PasskeyCredential as p, type PasskeyAuthRequest as q, type Organization as r, type OrganizationMembership as s, type User as t, type Session as u, AuthState as v, type OAuthConfig as w, type TwoFactorConfig as x, type AuthResponse as y, type ProviderConfig as z };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export { b as AuthContext, a as AuthError, A as AuthErrorType, c as AuthProvider, y as AuthResponse, v as AuthState, M as MagicLinkRequest, i as MagicLinkVerifyRequest, g as OAuthCallbackRequest, w as OAuthConfig, h as OAuthProvider, O as OAuthSignInRequest, r as Organization, s as OrganizationMembership, q as PasskeyAuthRequest, p as PasskeyCredential, o as PasskeyRegisterRequest, P as PasswordChangeRequest, f as PasswordResetConfirmRequest, e as PasswordResetRequest, j as PhoneAuthRequest, k as PhoneVerifyRequest, z as ProviderConfig, u as Session, S as SignInRequest, d as SignUpRequest, x as TwoFactorConfig, n as TwoFactorMethod, T as TwoFactorSetupRequest, l as TwoFactorSetupResponse, m as TwoFactorVerifyRequest, U as UpdateUserRequest, t as User, V as ValidationError } from '../provider-DXf_a2WT.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Storage abstraction for auth tokens and data
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Storage interface
|
|
8
|
+
*/
|
|
9
|
+
interface Storage {
|
|
10
|
+
/**
|
|
11
|
+
* Get item from storage
|
|
12
|
+
*/
|
|
13
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Set item in storage
|
|
16
|
+
*/
|
|
17
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove item from storage
|
|
20
|
+
*/
|
|
21
|
+
removeItem(key: string): Promise<void> | void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all items from storage
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void> | void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Storage adapter for localStorage
|
|
29
|
+
*/
|
|
30
|
+
declare class LocalStorageAdapter implements Storage {
|
|
31
|
+
getItem(key: string): string | null;
|
|
32
|
+
setItem(key: string, value: string): void;
|
|
33
|
+
removeItem(key: string): void;
|
|
34
|
+
clear(): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Storage adapter for sessionStorage
|
|
38
|
+
*/
|
|
39
|
+
declare class SessionStorageAdapter implements Storage {
|
|
40
|
+
getItem(key: string): string | null;
|
|
41
|
+
setItem(key: string, value: string): void;
|
|
42
|
+
removeItem(key: string): void;
|
|
43
|
+
clear(): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* In-memory storage adapter (for testing or SSR)
|
|
47
|
+
*/
|
|
48
|
+
declare class MemoryStorageAdapter implements Storage {
|
|
49
|
+
private store;
|
|
50
|
+
getItem(key: string): string | null;
|
|
51
|
+
setItem(key: string, value: string): void;
|
|
52
|
+
removeItem(key: string): void;
|
|
53
|
+
clear(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Observable pattern for state management across frameworks
|
|
58
|
+
*/
|
|
59
|
+
type Listener<T> = (value: T) => void;
|
|
60
|
+
type Unsubscribe = () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Observable state container
|
|
63
|
+
*/
|
|
64
|
+
declare class Observable<T> {
|
|
65
|
+
private value;
|
|
66
|
+
private listeners;
|
|
67
|
+
constructor(initialValue: T);
|
|
68
|
+
/**
|
|
69
|
+
* Get current value
|
|
70
|
+
*/
|
|
71
|
+
getValue(): T;
|
|
72
|
+
/**
|
|
73
|
+
* Set new value and notify listeners
|
|
74
|
+
*/
|
|
75
|
+
setValue(newValue: T): void;
|
|
76
|
+
/**
|
|
77
|
+
* Update value with a function
|
|
78
|
+
*/
|
|
79
|
+
update(updater: (current: T) => T): void;
|
|
80
|
+
/**
|
|
81
|
+
* Subscribe to value changes
|
|
82
|
+
*/
|
|
83
|
+
subscribe(listener: Listener<T>): Unsubscribe;
|
|
84
|
+
/**
|
|
85
|
+
* Notify all listeners
|
|
86
|
+
*/
|
|
87
|
+
private notify;
|
|
88
|
+
/**
|
|
89
|
+
* Clear all listeners
|
|
90
|
+
*/
|
|
91
|
+
clearListeners(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get number of listeners
|
|
94
|
+
*/
|
|
95
|
+
getListenerCount(): number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { type Listener, LocalStorageAdapter, MemoryStorageAdapter, Observable, SessionStorageAdapter, type Storage, type Unsubscribe };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export { b as AuthContext, a as AuthError, A as AuthErrorType, c as AuthProvider, y as AuthResponse, v as AuthState, M as MagicLinkRequest, i as MagicLinkVerifyRequest, g as OAuthCallbackRequest, w as OAuthConfig, h as OAuthProvider, O as OAuthSignInRequest, r as Organization, s as OrganizationMembership, q as PasskeyAuthRequest, p as PasskeyCredential, o as PasskeyRegisterRequest, P as PasswordChangeRequest, f as PasswordResetConfirmRequest, e as PasswordResetRequest, j as PhoneAuthRequest, k as PhoneVerifyRequest, z as ProviderConfig, u as Session, S as SignInRequest, d as SignUpRequest, x as TwoFactorConfig, n as TwoFactorMethod, T as TwoFactorSetupRequest, l as TwoFactorSetupResponse, m as TwoFactorVerifyRequest, U as UpdateUserRequest, t as User, V as ValidationError } from '../provider-DXf_a2WT.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Storage abstraction for auth tokens and data
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Storage interface
|
|
8
|
+
*/
|
|
9
|
+
interface Storage {
|
|
10
|
+
/**
|
|
11
|
+
* Get item from storage
|
|
12
|
+
*/
|
|
13
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Set item in storage
|
|
16
|
+
*/
|
|
17
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove item from storage
|
|
20
|
+
*/
|
|
21
|
+
removeItem(key: string): Promise<void> | void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all items from storage
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void> | void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Storage adapter for localStorage
|
|
29
|
+
*/
|
|
30
|
+
declare class LocalStorageAdapter implements Storage {
|
|
31
|
+
getItem(key: string): string | null;
|
|
32
|
+
setItem(key: string, value: string): void;
|
|
33
|
+
removeItem(key: string): void;
|
|
34
|
+
clear(): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Storage adapter for sessionStorage
|
|
38
|
+
*/
|
|
39
|
+
declare class SessionStorageAdapter implements Storage {
|
|
40
|
+
getItem(key: string): string | null;
|
|
41
|
+
setItem(key: string, value: string): void;
|
|
42
|
+
removeItem(key: string): void;
|
|
43
|
+
clear(): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* In-memory storage adapter (for testing or SSR)
|
|
47
|
+
*/
|
|
48
|
+
declare class MemoryStorageAdapter implements Storage {
|
|
49
|
+
private store;
|
|
50
|
+
getItem(key: string): string | null;
|
|
51
|
+
setItem(key: string, value: string): void;
|
|
52
|
+
removeItem(key: string): void;
|
|
53
|
+
clear(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Observable pattern for state management across frameworks
|
|
58
|
+
*/
|
|
59
|
+
type Listener<T> = (value: T) => void;
|
|
60
|
+
type Unsubscribe = () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Observable state container
|
|
63
|
+
*/
|
|
64
|
+
declare class Observable<T> {
|
|
65
|
+
private value;
|
|
66
|
+
private listeners;
|
|
67
|
+
constructor(initialValue: T);
|
|
68
|
+
/**
|
|
69
|
+
* Get current value
|
|
70
|
+
*/
|
|
71
|
+
getValue(): T;
|
|
72
|
+
/**
|
|
73
|
+
* Set new value and notify listeners
|
|
74
|
+
*/
|
|
75
|
+
setValue(newValue: T): void;
|
|
76
|
+
/**
|
|
77
|
+
* Update value with a function
|
|
78
|
+
*/
|
|
79
|
+
update(updater: (current: T) => T): void;
|
|
80
|
+
/**
|
|
81
|
+
* Subscribe to value changes
|
|
82
|
+
*/
|
|
83
|
+
subscribe(listener: Listener<T>): Unsubscribe;
|
|
84
|
+
/**
|
|
85
|
+
* Notify all listeners
|
|
86
|
+
*/
|
|
87
|
+
private notify;
|
|
88
|
+
/**
|
|
89
|
+
* Clear all listeners
|
|
90
|
+
*/
|
|
91
|
+
clearListeners(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get number of listeners
|
|
94
|
+
*/
|
|
95
|
+
getListenerCount(): number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { type Listener, LocalStorageAdapter, MemoryStorageAdapter, Observable, SessionStorageAdapter, type Storage, type Unsubscribe };
|