@parsrun/auth 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.
Files changed (54) hide show
  1. package/README.md +133 -0
  2. package/dist/adapters/hono.d.ts +9 -0
  3. package/dist/adapters/hono.js +6 -0
  4. package/dist/adapters/hono.js.map +1 -0
  5. package/dist/adapters/index.d.ts +9 -0
  6. package/dist/adapters/index.js +7 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/authorization-By1Xp8Za.d.ts +213 -0
  9. package/dist/base-BKyR8rcE.d.ts +646 -0
  10. package/dist/chunk-42MGHABB.js +263 -0
  11. package/dist/chunk-42MGHABB.js.map +1 -0
  12. package/dist/chunk-7GOBAL4G.js +3 -0
  13. package/dist/chunk-7GOBAL4G.js.map +1 -0
  14. package/dist/chunk-G5I3T73A.js +152 -0
  15. package/dist/chunk-G5I3T73A.js.map +1 -0
  16. package/dist/chunk-IB4WUQDZ.js +410 -0
  17. package/dist/chunk-IB4WUQDZ.js.map +1 -0
  18. package/dist/chunk-MOG4Y6I7.js +415 -0
  19. package/dist/chunk-MOG4Y6I7.js.map +1 -0
  20. package/dist/chunk-NK4TJV2W.js +295 -0
  21. package/dist/chunk-NK4TJV2W.js.map +1 -0
  22. package/dist/chunk-RHNVRCF3.js +838 -0
  23. package/dist/chunk-RHNVRCF3.js.map +1 -0
  24. package/dist/chunk-YTCPXJR5.js +570 -0
  25. package/dist/chunk-YTCPXJR5.js.map +1 -0
  26. package/dist/cloudflare-kv-L64CZKDK.js +105 -0
  27. package/dist/cloudflare-kv-L64CZKDK.js.map +1 -0
  28. package/dist/deno-kv-F55HKKP6.js +111 -0
  29. package/dist/deno-kv-F55HKKP6.js.map +1 -0
  30. package/dist/index-C3kz9XqE.d.ts +226 -0
  31. package/dist/index-DOGcetyD.d.ts +1041 -0
  32. package/dist/index.d.ts +1579 -0
  33. package/dist/index.js +4294 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/jwt-manager-CH8H0kmm.d.ts +182 -0
  36. package/dist/providers/index.d.ts +90 -0
  37. package/dist/providers/index.js +3 -0
  38. package/dist/providers/index.js.map +1 -0
  39. package/dist/providers/otp/index.d.ts +3 -0
  40. package/dist/providers/otp/index.js +4 -0
  41. package/dist/providers/otp/index.js.map +1 -0
  42. package/dist/redis-5TIS6XCA.js +121 -0
  43. package/dist/redis-5TIS6XCA.js.map +1 -0
  44. package/dist/security/index.d.ts +301 -0
  45. package/dist/security/index.js +5 -0
  46. package/dist/security/index.js.map +1 -0
  47. package/dist/session/index.d.ts +117 -0
  48. package/dist/session/index.js +4 -0
  49. package/dist/session/index.js.map +1 -0
  50. package/dist/storage/index.d.ts +97 -0
  51. package/dist/storage/index.js +3 -0
  52. package/dist/storage/index.js.map +1 -0
  53. package/dist/types-DSjafxJ4.d.ts +193 -0
  54. package/package.json +102 -0
@@ -0,0 +1,646 @@
1
+ import { S as StorageConfig } from './types-DSjafxJ4.js';
2
+
3
+ /**
4
+ * Pars Auth Configuration
5
+ * Passwordless-first, provider-based authentication
6
+ */
7
+
8
+ /**
9
+ * Session configuration
10
+ */
11
+ interface SessionConfig {
12
+ /** Access token expiry in seconds (default: 900 = 15 minutes) */
13
+ accessTokenExpiry?: number;
14
+ /** Refresh token expiry in seconds (default: 604800 = 7 days) */
15
+ refreshTokenExpiry?: number;
16
+ /** Enable sliding window for refresh tokens (default: true) */
17
+ slidingWindow?: boolean;
18
+ /** Maximum concurrent sessions per user (default: 5) */
19
+ maxSessions?: number;
20
+ /** Invalidate all sessions on password change (default: true) */
21
+ invalidateOnPasswordChange?: boolean;
22
+ }
23
+ /**
24
+ * JWT configuration
25
+ */
26
+ interface JwtConfig {
27
+ /** JWT signing algorithm (default: HS256) */
28
+ algorithm?: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512';
29
+ /** JWT issuer claim */
30
+ issuer?: string;
31
+ /** JWT audience claim */
32
+ audience?: string | string[];
33
+ }
34
+ /**
35
+ * Cookie configuration
36
+ */
37
+ interface CookieConfig {
38
+ /** Cookie name prefix (default: 'pars') */
39
+ prefix?: string;
40
+ /** Cookie domain */
41
+ domain?: string;
42
+ /** Cookie path (default: '/') */
43
+ path?: string;
44
+ /** Use secure cookies (default: true in production) */
45
+ secure?: boolean;
46
+ /** SameSite attribute (default: 'lax') */
47
+ sameSite?: 'strict' | 'lax' | 'none';
48
+ /** HttpOnly for refresh token (default: true) */
49
+ httpOnly?: boolean;
50
+ }
51
+ /**
52
+ * CSRF configuration
53
+ */
54
+ interface CsrfConfig {
55
+ /** Enable CSRF protection (default: true) */
56
+ enabled?: boolean;
57
+ /** CSRF header name (default: 'x-csrf-token') */
58
+ headerName?: string;
59
+ /** CSRF cookie name (default: 'csrf') */
60
+ cookieName?: string;
61
+ }
62
+ /**
63
+ * Tenant resolution strategy
64
+ */
65
+ type TenantResolutionStrategy = 'subdomain' | 'header' | 'path' | 'query' | 'custom';
66
+ /**
67
+ * Multi-tenant configuration
68
+ */
69
+ interface TenantConfig {
70
+ /** Enable multi-tenancy (default: true) */
71
+ enabled?: boolean;
72
+ /** Tenant resolution strategy (default: 'header') */
73
+ strategy?: TenantResolutionStrategy;
74
+ /** Header name for tenant ID (default: 'x-tenant-id') */
75
+ headerName?: string;
76
+ /** Custom tenant resolver */
77
+ resolver?: (request: Request) => Promise<string | null>;
78
+ }
79
+ /**
80
+ * OAuth provider configuration
81
+ */
82
+ interface OAuthProviderConfig {
83
+ /** Enable this provider */
84
+ enabled?: boolean;
85
+ /** OAuth client ID */
86
+ clientId: string;
87
+ /** OAuth client secret */
88
+ clientSecret: string;
89
+ /** OAuth scopes */
90
+ scopes?: string[];
91
+ /** Callback URL (default: baseUrl + /auth/callback/:provider) */
92
+ callbackUrl?: string;
93
+ }
94
+ /**
95
+ * OTP (One-Time Password) configuration
96
+ */
97
+ interface OtpConfig {
98
+ /** Enable OTP authentication (default: true) */
99
+ enabled?: boolean;
100
+ /** Email OTP configuration */
101
+ email?: {
102
+ /** Enable email OTP (default: true) */
103
+ enabled?: boolean;
104
+ /** OTP expiry in seconds (default: 600 = 10 minutes) */
105
+ expiresIn?: number;
106
+ /** OTP code length (default: 6) */
107
+ length?: number;
108
+ /** Maximum verification attempts (default: 3) */
109
+ maxAttempts?: number;
110
+ /** Rate limit: max requests per window (default: 5) */
111
+ rateLimit?: number;
112
+ /** Rate limit window in seconds (default: 900 = 15 minutes) */
113
+ rateLimitWindow?: number;
114
+ /** Email sending function */
115
+ send: (to: string, code: string) => Promise<void>;
116
+ };
117
+ /** SMS OTP configuration */
118
+ sms?: {
119
+ /** Enable SMS OTP (default: false) */
120
+ enabled?: boolean;
121
+ /** OTP expiry in seconds (default: 300 = 5 minutes) */
122
+ expiresIn?: number;
123
+ /** OTP code length (default: 6) */
124
+ length?: number;
125
+ /** Maximum verification attempts (default: 3) */
126
+ maxAttempts?: number;
127
+ /** Rate limit: max requests per window (default: 3) */
128
+ rateLimit?: number;
129
+ /** Rate limit window in seconds (default: 900 = 15 minutes) */
130
+ rateLimitWindow?: number;
131
+ /** SMS sending function */
132
+ send: (to: string, code: string) => Promise<void>;
133
+ };
134
+ }
135
+ /**
136
+ * Magic Link configuration
137
+ */
138
+ interface MagicLinkConfig {
139
+ /** Enable magic link authentication (default: false) */
140
+ enabled?: boolean;
141
+ /** Link expiry in seconds (default: 900 = 15 minutes) */
142
+ expiresIn?: number;
143
+ /** Email sending function */
144
+ send: (to: string, url: string) => Promise<void>;
145
+ }
146
+ /**
147
+ * TOTP (Time-based One-Time Password) configuration for 2FA
148
+ */
149
+ interface TotpConfig {
150
+ /** Enable TOTP 2FA (default: false) */
151
+ enabled?: boolean;
152
+ /** TOTP issuer name (shown in authenticator apps) */
153
+ issuer?: string;
154
+ /** Number of backup codes to generate (default: 10) */
155
+ backupCodesCount?: number;
156
+ }
157
+ /**
158
+ * WebAuthn/Passkey configuration
159
+ */
160
+ interface WebAuthnConfig {
161
+ /** Enable WebAuthn (default: false) */
162
+ enabled?: boolean;
163
+ /** Relying party name (your app name) */
164
+ rpName: string;
165
+ /** Relying party ID (your domain) */
166
+ rpId: string;
167
+ /** Allowed origins */
168
+ origins?: string[];
169
+ }
170
+ /**
171
+ * Password configuration (DISABLED BY DEFAULT)
172
+ */
173
+ interface PasswordConfig {
174
+ /**
175
+ * Enable password authentication
176
+ * @default false - Passwordless is recommended
177
+ */
178
+ enabled?: boolean;
179
+ /** Minimum password length (default: 8) */
180
+ minLength?: number;
181
+ /** Require uppercase letters (default: false) */
182
+ requireUppercase?: boolean;
183
+ /** Require lowercase letters (default: false) */
184
+ requireLowercase?: boolean;
185
+ /** Require numbers (default: false) */
186
+ requireNumbers?: boolean;
187
+ /** Require special characters (default: false) */
188
+ requireSymbols?: boolean;
189
+ /** Check against common passwords (default: true) */
190
+ checkCommonPasswords?: boolean;
191
+ }
192
+ /**
193
+ * Security configuration
194
+ */
195
+ interface SecurityConfig {
196
+ /** Rate limiting configuration */
197
+ rateLimit?: {
198
+ /** Enable rate limiting (default: true) */
199
+ enabled?: boolean;
200
+ /** Login attempts per window (default: 5) */
201
+ loginAttempts?: number;
202
+ /** Window size in seconds (default: 900 = 15 minutes) */
203
+ windowSize?: number;
204
+ };
205
+ /** Account lockout configuration */
206
+ lockout?: {
207
+ /** Enable account lockout (default: true) */
208
+ enabled?: boolean;
209
+ /** Failed attempts before lockout (default: 5) */
210
+ maxAttempts?: number;
211
+ /** Lockout duration in seconds (default: 900 = 15 minutes) */
212
+ duration?: number;
213
+ };
214
+ /** CSRF configuration */
215
+ csrf?: CsrfConfig;
216
+ }
217
+ /**
218
+ * Auth callbacks for extensibility
219
+ */
220
+ interface AuthCallbacks {
221
+ /** Called after successful sign up */
222
+ onSignUp?: (user: {
223
+ id: string;
224
+ email?: string | null;
225
+ }) => Promise<void>;
226
+ /** Called after successful sign in */
227
+ onSignIn?: (user: {
228
+ id: string;
229
+ email?: string | null;
230
+ }, session: {
231
+ id: string;
232
+ }) => Promise<void>;
233
+ /** Called after sign out */
234
+ onSignOut?: (userId: string, sessionId: string) => Promise<void>;
235
+ /** Called when a new session is created */
236
+ onSessionCreated?: (session: {
237
+ id: string;
238
+ userId: string;
239
+ }) => Promise<void>;
240
+ /** Validate sign in (return false to reject) */
241
+ validateSignIn?: (user: {
242
+ id: string;
243
+ email?: string | null;
244
+ }) => Promise<boolean>;
245
+ }
246
+ /**
247
+ * Database adapter interface
248
+ * Implement this to connect Pars Auth to your database
249
+ */
250
+ interface AuthAdapter {
251
+ findUserById(id: string): Promise<AdapterUser | null>;
252
+ findUserByEmail(email: string): Promise<AdapterUser | null>;
253
+ findUserByPhone(phone: string): Promise<AdapterUser | null>;
254
+ createUser(data: CreateUserInput): Promise<AdapterUser>;
255
+ updateUser(id: string, data: Partial<AdapterUser>): Promise<AdapterUser>;
256
+ deleteUser(id: string): Promise<void>;
257
+ findSessionById(id: string): Promise<AdapterSession | null>;
258
+ findSessionsByUserId(userId: string): Promise<AdapterSession[]>;
259
+ createSession(data: CreateSessionInput): Promise<AdapterSession>;
260
+ updateSession(id: string, data: Partial<AdapterSession>): Promise<AdapterSession>;
261
+ deleteSession(id: string): Promise<void>;
262
+ deleteSessionsByUserId(userId: string): Promise<void>;
263
+ findAuthMethod(provider: string, providerId: string): Promise<AdapterAuthMethod | null>;
264
+ findAuthMethodsByUserId(userId: string): Promise<AdapterAuthMethod[]>;
265
+ createAuthMethod(data: CreateAuthMethodInput): Promise<AdapterAuthMethod>;
266
+ deleteAuthMethod(id: string): Promise<void>;
267
+ findTenantById?(id: string): Promise<AdapterTenant | null>;
268
+ findTenantBySlug?(slug: string): Promise<AdapterTenant | null>;
269
+ findMembership?(userId: string, tenantId: string): Promise<AdapterMembership | null>;
270
+ findMembershipsByUserId?(userId: string): Promise<AdapterMembership[]>;
271
+ createMembership?(data: CreateMembershipInput): Promise<AdapterMembership>;
272
+ updateMembership?(id: string, data: Partial<AdapterMembership>): Promise<AdapterMembership>;
273
+ deleteMembership?(id: string): Promise<void>;
274
+ }
275
+ interface AdapterUser {
276
+ id: string;
277
+ email?: string | null;
278
+ phone?: string | null;
279
+ emailVerified?: boolean;
280
+ phoneVerified?: boolean;
281
+ name?: string | null;
282
+ avatar?: string | null;
283
+ twoFactorEnabled?: boolean;
284
+ status: 'active' | 'inactive' | 'suspended';
285
+ createdAt: Date;
286
+ updatedAt: Date;
287
+ }
288
+ interface AdapterSession {
289
+ id: string;
290
+ userId: string;
291
+ tenantId?: string | null;
292
+ expiresAt: Date;
293
+ refreshExpiresAt?: Date | null;
294
+ deviceType?: string | null;
295
+ deviceName?: string | null;
296
+ userAgent?: string | null;
297
+ ipAddress?: string | null;
298
+ status: 'active' | 'expired' | 'revoked';
299
+ createdAt: Date;
300
+ updatedAt: Date;
301
+ }
302
+ interface AdapterAuthMethod {
303
+ id: string;
304
+ userId: string;
305
+ provider: string;
306
+ providerId: string;
307
+ verified: boolean;
308
+ metadata?: Record<string, unknown>;
309
+ createdAt: Date;
310
+ updatedAt: Date;
311
+ }
312
+ interface AdapterTenant {
313
+ id: string;
314
+ name: string;
315
+ slug: string;
316
+ status: 'active' | 'suspended' | 'inactive';
317
+ createdAt: Date;
318
+ updatedAt: Date;
319
+ }
320
+ interface AdapterMembership {
321
+ id: string;
322
+ userId: string;
323
+ tenantId: string;
324
+ role: string;
325
+ permissions?: string[];
326
+ status: 'active' | 'inactive' | 'pending';
327
+ createdAt: Date;
328
+ updatedAt: Date;
329
+ }
330
+ interface CreateUserInput {
331
+ email?: string;
332
+ phone?: string;
333
+ name?: string;
334
+ avatar?: string;
335
+ emailVerified?: boolean;
336
+ phoneVerified?: boolean;
337
+ }
338
+ interface CreateSessionInput {
339
+ userId: string;
340
+ tenantId?: string;
341
+ expiresAt: Date;
342
+ refreshExpiresAt?: Date;
343
+ deviceType?: string;
344
+ deviceName?: string;
345
+ userAgent?: string;
346
+ ipAddress?: string;
347
+ }
348
+ interface CreateAuthMethodInput {
349
+ userId: string;
350
+ provider: string;
351
+ providerId: string;
352
+ verified?: boolean;
353
+ metadata?: Record<string, unknown>;
354
+ }
355
+ interface CreateMembershipInput {
356
+ userId: string;
357
+ tenantId: string;
358
+ role: string;
359
+ permissions?: string[];
360
+ }
361
+ /**
362
+ * Main Pars Auth Configuration
363
+ */
364
+ interface ParsAuthConfig {
365
+ /**
366
+ * Secret key for signing tokens (required)
367
+ * Use a strong, random string of at least 32 characters
368
+ */
369
+ secret: string;
370
+ /**
371
+ * Base URL of your application
372
+ * Used for OAuth callbacks, magic links, etc.
373
+ */
374
+ baseUrl?: string;
375
+ /**
376
+ * Storage configuration for OTP, rate limiting, etc.
377
+ * Auto-detects runtime if not specified
378
+ */
379
+ storage?: StorageConfig;
380
+ /**
381
+ * Authentication providers
382
+ */
383
+ providers?: {
384
+ /** OTP configuration (enabled by default) */
385
+ otp?: OtpConfig;
386
+ /** Magic Link configuration */
387
+ magicLink?: MagicLinkConfig;
388
+ /** OAuth providers */
389
+ oauth?: {
390
+ google?: OAuthProviderConfig;
391
+ github?: OAuthProviderConfig;
392
+ microsoft?: OAuthProviderConfig;
393
+ apple?: OAuthProviderConfig;
394
+ /** Custom OAuth providers */
395
+ custom?: Record<string, OAuthProviderConfig>;
396
+ };
397
+ /** TOTP 2FA configuration */
398
+ totp?: TotpConfig;
399
+ /** WebAuthn/Passkey configuration */
400
+ webauthn?: WebAuthnConfig;
401
+ /**
402
+ * Password configuration
403
+ * @default { enabled: false }
404
+ */
405
+ password?: PasswordConfig;
406
+ };
407
+ /** Session configuration */
408
+ session?: SessionConfig;
409
+ /** JWT configuration */
410
+ jwt?: JwtConfig;
411
+ /** Cookie configuration */
412
+ cookies?: CookieConfig;
413
+ /** Security configuration */
414
+ security?: SecurityConfig;
415
+ /** Multi-tenant configuration */
416
+ tenant?: TenantConfig;
417
+ /** Database adapter (required) */
418
+ adapter: AuthAdapter;
419
+ /** Lifecycle callbacks */
420
+ callbacks?: AuthCallbacks;
421
+ }
422
+ /**
423
+ * Default configuration (passwordless-first)
424
+ */
425
+ declare const defaultConfig: Partial<ParsAuthConfig>;
426
+ /**
427
+ * Merge user config with defaults
428
+ */
429
+ declare function mergeConfig(config: ParsAuthConfig): Required<ParsAuthConfig>;
430
+ /**
431
+ * Validate configuration
432
+ */
433
+ declare function validateConfig(config: ParsAuthConfig): void;
434
+
435
+ /**
436
+ * Base provider types and interfaces
437
+ * All auth providers must implement these interfaces
438
+ */
439
+
440
+ /**
441
+ * Provider types
442
+ */
443
+ type ProviderType = 'otp' | 'magic-link' | 'oauth' | 'totp' | 'webauthn' | 'password';
444
+ /**
445
+ * Provider metadata
446
+ */
447
+ interface ProviderInfo {
448
+ /** Provider unique name */
449
+ name: string;
450
+ /** Provider type */
451
+ type: ProviderType;
452
+ /** Whether the provider is enabled */
453
+ enabled: boolean;
454
+ /** Human-readable display name */
455
+ displayName?: string;
456
+ /** Provider icon URL */
457
+ icon?: string;
458
+ }
459
+ /**
460
+ * Authentication input (varies by provider)
461
+ */
462
+ interface AuthInput {
463
+ /** User identifier (email, phone, username) */
464
+ identifier?: string;
465
+ /** Credential (OTP code, password, OAuth code, etc.) */
466
+ credential?: string;
467
+ /** Tenant ID for multi-tenant apps */
468
+ tenantId?: string;
469
+ /** Provider-specific data */
470
+ data?: Record<string, unknown>;
471
+ }
472
+ /**
473
+ * Authentication result
474
+ */
475
+ interface AuthResult {
476
+ /** Whether authentication was successful */
477
+ success: boolean;
478
+ /** Authenticated user (if successful) */
479
+ user?: AdapterUser;
480
+ /** Session (if created) */
481
+ session?: AdapterSession;
482
+ /** Whether this is a new user */
483
+ isNewUser?: boolean;
484
+ /** Whether 2FA is required */
485
+ requiresTwoFactor?: boolean;
486
+ /** 2FA challenge data */
487
+ twoFactorChallenge?: {
488
+ type: 'totp' | 'webauthn' | 'sms';
489
+ challengeId?: string;
490
+ };
491
+ /** Error message (if failed) */
492
+ error?: string;
493
+ /** Error code (if failed) */
494
+ errorCode?: string;
495
+ }
496
+ /**
497
+ * Verification input
498
+ */
499
+ interface VerifyInput {
500
+ /** Verification target (email, phone) */
501
+ identifier: string;
502
+ /** Verification type */
503
+ type: 'email' | 'sms';
504
+ /** Verification code or token */
505
+ code: string;
506
+ /** Tenant ID */
507
+ tenantId?: string;
508
+ }
509
+ /**
510
+ * Verification result
511
+ */
512
+ interface VerifyResult {
513
+ /** Whether verification was successful */
514
+ success: boolean;
515
+ /** Remaining attempts (if failed) */
516
+ attemptsLeft?: number;
517
+ /** Error message */
518
+ error?: string;
519
+ }
520
+ /**
521
+ * Base auth provider interface
522
+ * All providers must implement this interface
523
+ */
524
+ interface AuthProvider {
525
+ /** Provider unique name (e.g., 'email-otp', 'google', 'password') */
526
+ readonly name: string;
527
+ /** Provider type */
528
+ readonly type: ProviderType;
529
+ /** Whether the provider is currently enabled */
530
+ readonly enabled: boolean;
531
+ /**
532
+ * Initialize the provider with config
533
+ * Called once during auth system setup
534
+ */
535
+ initialize?(config: ParsAuthConfig): Promise<void>;
536
+ /**
537
+ * Authenticate a user
538
+ * This is the main authentication entry point
539
+ */
540
+ authenticate(input: AuthInput): Promise<AuthResult>;
541
+ /**
542
+ * Verify a code/token (optional)
543
+ * Used by OTP, magic link, etc.
544
+ */
545
+ verify?(input: VerifyInput): Promise<VerifyResult>;
546
+ /**
547
+ * Get provider info for display
548
+ */
549
+ getInfo(): ProviderInfo;
550
+ }
551
+ /**
552
+ * Two-factor auth provider interface
553
+ * Extends base provider for 2FA capabilities
554
+ */
555
+ interface TwoFactorProvider extends AuthProvider {
556
+ /** Provider type is always 'totp' or 'webauthn' for 2FA */
557
+ readonly type: 'totp' | 'webauthn';
558
+ /**
559
+ * Setup 2FA for a user
560
+ * Returns setup data (QR code, backup codes, etc.)
561
+ */
562
+ setup(userId: string): Promise<TwoFactorSetupResult>;
563
+ /**
564
+ * Verify 2FA and complete setup
565
+ */
566
+ verifySetup(userId: string, code: string): Promise<boolean>;
567
+ /**
568
+ * Verify 2FA during login
569
+ */
570
+ verifyLogin(userId: string, code: string): Promise<boolean>;
571
+ /**
572
+ * Disable 2FA for a user
573
+ */
574
+ disable(userId: string): Promise<void>;
575
+ }
576
+ /**
577
+ * 2FA setup result
578
+ */
579
+ interface TwoFactorSetupResult {
580
+ /** Secret key (for TOTP) */
581
+ secret?: string;
582
+ /** QR code data URL */
583
+ qrCode?: string;
584
+ /** Backup codes */
585
+ backupCodes?: string[];
586
+ /** WebAuthn challenge */
587
+ challenge?: string;
588
+ }
589
+ /**
590
+ * OAuth provider interface
591
+ * Extends base provider for OAuth flows
592
+ */
593
+ interface OAuthProvider extends AuthProvider {
594
+ /** Provider type is always 'oauth' */
595
+ readonly type: 'oauth';
596
+ /**
597
+ * Get OAuth authorization URL
598
+ */
599
+ getAuthorizationUrl(state: string, codeVerifier?: string): Promise<string>;
600
+ /**
601
+ * Exchange authorization code for tokens
602
+ */
603
+ exchangeCode(code: string, codeVerifier?: string): Promise<{
604
+ accessToken: string;
605
+ refreshToken?: string;
606
+ expiresIn?: number;
607
+ idToken?: string;
608
+ }>;
609
+ /**
610
+ * Get user info from OAuth provider
611
+ */
612
+ getUserInfo(accessToken: string): Promise<OAuthUserInfo>;
613
+ }
614
+ /**
615
+ * OAuth user info
616
+ */
617
+ interface OAuthUserInfo {
618
+ /** Provider-specific user ID */
619
+ id: string;
620
+ /** User email */
621
+ email?: string;
622
+ /** Whether email is verified */
623
+ emailVerified?: boolean;
624
+ /** User name */
625
+ name?: string;
626
+ /** Avatar URL */
627
+ avatar?: string;
628
+ /** Raw provider data */
629
+ raw?: Record<string, unknown>;
630
+ }
631
+ /**
632
+ * Abstract base class for providers
633
+ * Provides common functionality
634
+ */
635
+ declare abstract class BaseProvider implements AuthProvider {
636
+ abstract readonly name: string;
637
+ abstract readonly type: ProviderType;
638
+ protected config?: ParsAuthConfig;
639
+ protected _enabled: boolean;
640
+ get enabled(): boolean;
641
+ initialize(config: ParsAuthConfig): Promise<void>;
642
+ abstract authenticate(input: AuthInput): Promise<AuthResult>;
643
+ getInfo(): ProviderInfo;
644
+ }
645
+
646
+ export { type AuthProvider as A, BaseProvider as B, type CookieConfig as C, defaultConfig as D, mergeConfig as E, validateConfig as F, type JwtConfig as J, type MagicLinkConfig as M, type OAuthProvider as O, type ProviderType as P, type SessionConfig as S, type TwoFactorProvider as T, type VerifyInput as V, type WebAuthnConfig as W, type ProviderInfo as a, type AuthInput as b, type AuthResult as c, type VerifyResult as d, type TwoFactorSetupResult as e, type OAuthUserInfo as f, type OtpConfig as g, type AuthAdapter as h, type ParsAuthConfig as i, type CsrfConfig as j, type TenantConfig as k, type TenantResolutionStrategy as l, type TotpConfig as m, type PasswordConfig as n, type OAuthProviderConfig as o, type SecurityConfig as p, type AuthCallbacks as q, type AdapterUser as r, type AdapterSession as s, type AdapterAuthMethod as t, type AdapterTenant as u, type AdapterMembership as v, type CreateUserInput as w, type CreateSessionInput as x, type CreateAuthMethodInput as y, type CreateMembershipInput as z };