@parsrun/auth 0.2.6 → 0.2.10

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 CHANGED
@@ -1,87 +1,20 @@
1
- import { A as AuthProvider, b as AuthInput, c as AuthResult, a as ProviderInfo, T as TwoFactorProvider, e as TwoFactorSetupResult, h as AuthAdapter, i as ParsAuthConfig } from './base-BI-SilX-.js';
2
- export { t as AdapterAuthMethod, v as AdapterMembership, s as AdapterSession, u as AdapterTenant, r as AdapterUser, q as AuthCallbacks, C as CookieConfig, y as CreateAuthMethodInput, z as CreateMembershipInput, x as CreateSessionInput, w as CreateUserInput, j as CsrfConfig, J as JwtConfig, M as MagicLinkConfig, O as OAuthProvider, o as OAuthProviderConfig, f as OAuthUserInfo, g as OtpConfig, n as PasswordConfig, P as ProviderType, p as SecurityConfig, S as SessionConfig, k as TenantConfig, l as TenantResolutionStrategy, m as TotpConfig, V as VerifyInput, d as VerifyResult, W as WebAuthnConfig, D as defaultConfig, E as mergeConfig, F as validateConfig } from './base-BI-SilX-.js';
3
- import { P as ParsAuthEngine } from './index-kATaLVps.js';
4
- export { t as AcceptInvitationInput, u as AcceptInvitationResult, X as AdapterAuthContext, k as AddMemberInput, A as AuthContext, Z as AuthResponse, Q as AuthVariables, Y as CookieOptions, C as CreateTenantInput, W as HonoAdapterConfig, p as InvitationConfig, q as InvitationRecord, I as InvitationService, v as InvitationStatusResult, M as MultiStrategyTenantResolver, R as RefreshTokenResult, r as SendInvitationInput, s as SendInvitationResult, d as SessionInfo, S as SignInInput, a as SignInResult, b as SignUpInput, c as SignUpResult, i as TenantManager, h as TenantResolutionResult, T as TenantResolver, g as TenantResolverConfig, m as TenantWithMembers, l as UpdateMemberInput, U as UpdateTenantInput, n as UserTenantMembership, V as VerifyTokenResult, B as createAuthCookies, w as createAuthMiddleware, y as createAuthRoutes, z as createHonoAuth, o as createInvitationService, D as createLogoutCookies, f as createMultiStrategyResolver, x as createOptionalAuthMiddleware, j as createTenantManager, e as createTenantResolver, K as requireAdmin, N as requireAll, O as requireAny, G as requireAnyPermission, L as requireOwnerOrPermission, F as requirePermission, E as requireRole, H as requireTenant, J as requireTenantAccess } from './index-kATaLVps.js';
1
+ import { h as AuthAdapter, i as ParsAuthConfig } from './base-DbUdEGJ4.js';
2
+ export { t as AdapterAuthMethod, v as AdapterMembership, s as AdapterSession, u as AdapterTenant, r as AdapterUser, q as AuthCallbacks, b as AuthInput, A as AuthProvider, c as AuthResult, C as CookieConfig, y as CreateAuthMethodInput, z as CreateMembershipInput, x as CreateSessionInput, w as CreateUserInput, j as CsrfConfig, J as JwtConfig, M as MagicLinkConfig, O as OAuthProvider, o as OAuthProviderConfig, f as OAuthUserInfo, g as OtpConfig, n as PasswordConfig, a as ProviderInfo, P as ProviderType, p as SecurityConfig, S as SessionConfig, k as TenantConfig, l as TenantResolutionStrategy, m as TotpConfig, T as TwoFactorProvider, e as TwoFactorSetupResult, V as VerifyInput, d as VerifyResult, W as WebAuthnConfig, D as defaultConfig, E as mergeConfig, F as validateConfig } from './base-DbUdEGJ4.js';
3
+ import { O as OAuthProvider, G as GoogleConfig, a as OAuthTokens, b as OAuthUserInfo, c as GitHubConfig, M as MicrosoftConfig, A as AppleConfig, P as ParsAuthEngine } from './index-ZRaviVhS.js';
4
+ export { y as AcceptInvitationInput, z as AcceptInvitationResult, ay as AdapterAuthContext, p as AddMemberInput, d as AuthContext, aA as AuthResponse, aw as AuthVariables, a8 as AuthenticationOptions, ab as AuthenticatorData, aa as ClientDataJSON, az as CookieOptions, C as CreateTenantInput, ax as HonoAdapterConfig, u as InvitationConfig, v as InvitationRecord, I as InvitationService, B as InvitationStatusResult, W as MagicLinkProvider, Y as MagicLinkProviderConfig, i as MultiStrategyTenantResolver, L as OAuthCallbackResult, J as OAuthConfig, K as OAuthFlowResult, D as OAuthManager, Q as OAuthProviderName, N as OAuthState, ac as PasswordProvider, ae as PasswordProviderConfig, ag as PasswordStrength, af as PasswordValidationResult, R as RefreshTokenResult, a7 as RegistrationOptions, w as SendInvitationInput, x as SendInvitationResult, Z as SendMagicLinkResult, h as SessionInfo, S as SignInInput, e as SignInResult, f as SignUpInput, g as SignUpResult, $ as TOTPProvider, a1 as TOTPProviderConfig, a2 as TOTPSetupData, a3 as TOTPVerifyResult, n as TenantManager, m as TenantResolutionResult, T as TenantResolver, l as TenantResolverConfig, r as TenantWithMembers, q as UpdateMemberInput, U as UpdateTenantInput, s as UserTenantMembership, _ as VerifyMagicLinkResult, V as VerifyTokenResult, a9 as WebAuthnCredential, a4 as WebAuthnProvider, a6 as WebAuthnProviderConfig, al as createAuthCookies, ah as createAuthMiddleware, aj as createAuthRoutes, ak as createHonoAuth, t as createInvitationService, am as createLogoutCookies, X as createMagicLinkProvider, k as createMultiStrategyResolver, E as createOAuthManager, ai as createOptionalAuthMiddleware, ad as createPasswordProvider, a0 as createTOTPProvider, o as createTenantManager, j as createTenantResolver, a5 as createWebAuthnProvider, F as generatePKCE, H as generateState, as as requireAdmin, au as requireAll, av as requireAny, ap as requireAnyPermission, at as requireOwnerOrPermission, ao as requirePermission, an as requireRole, aq as requireTenant, ar as requireTenantAccess } from './index-ZRaviVhS.js';
5
5
  export { ProviderRegistry } from './providers/index.js';
6
- export { e as OTPConfig, a as OTPManager, O as OTPProvider, f as OTPRecord, g as RateLimitCheck, R as RequestOTPInput, d as RequestOTPResult, S as StoreOTPResult, V as VerifyOTPResult, b as createOTPManager, c as createOTPProvider } from './index-DC7A0IbX.js';
7
- import { K as KVStorage } from './types-DSjafxJ4.js';
8
- export { C as CloudflareKVConfig, D as DenoKVConfig, M as MemoryConfig, R as RedisConfig, S as StorageConfig, a as StorageType } from './types-DSjafxJ4.js';
6
+ export { e as OTPConfig, a as OTPManager, O as OTPProvider, f as OTPRecord, g as RateLimitCheck, R as RequestOTPInput, d as RequestOTPResult, S as StoreOTPResult, V as VerifyOTPResult, b as createOTPManager, c as createOTPProvider } from './index-Bcldwbx0.js';
9
7
  export { a as JwtError, J as JwtManager, b as JwtManagerConfig, d as JwtPayload, K as KeyRotationResult, T as TokenPair, c as createJwtManager, e as extractBearerToken, p as parseDuration } from './jwt-manager-CH8H0kmm.js';
10
8
  export { BlocklistConfig, SessionBlocklist, TokenBlocklist, createSessionBlocklist, createTokenBlocklist } from './session/index.js';
11
9
  export { MemoryStorage, StorageKeys, createMemoryStorage, createStorage, createStorageSync } from './storage/index.js';
12
10
  export { CsrfManager, CsrfConfig as CsrfManagerConfig, CsrfTokenPair, CsrfUtils, DefaultLockoutConfig, LockoutConfig, LockoutManager, LockoutStatus, RateLimitConfig, RateLimitPresets, RateLimitResult, RateLimiter, createCsrfManager, createLockoutManager, createRateLimiter } from './security/index.js';
13
11
  export { b as AuthorizationContext, A as AuthorizationGuard, e as AuthorizationRequirements, d as AuthorizationResult, f as PermissionPattern, P as Permissions, R as Roles, T as TenantMembershipInfo, a as authorize, c as createAuthorizationGuard } from './authorization-By1Xp8Za.js';
12
+ import { K as KVStorage } from './types-DSjafxJ4.js';
13
+ export { C as CloudflareKVConfig, D as DenoKVConfig, M as MemoryConfig, R as RedisConfig, S as StorageConfig, a as StorageType } from './types-DSjafxJ4.js';
14
14
  import 'hono/types';
15
15
  import 'hono';
16
16
  import 'jose';
17
17
 
18
- /**
19
- * OAuth Types
20
- */
21
- interface OAuthUserInfo {
22
- /** Provider-specific user ID */
23
- id: string;
24
- /** User email */
25
- email: string;
26
- /** Display name */
27
- name?: string;
28
- /** Avatar URL */
29
- avatarUrl?: string;
30
- /** Whether email is verified */
31
- emailVerified: boolean;
32
- /** Raw provider response */
33
- raw: Record<string, unknown>;
34
- }
35
- interface OAuthTokens {
36
- accessToken: string;
37
- refreshToken?: string;
38
- expiresIn?: number;
39
- idToken?: string;
40
- tokenType?: string;
41
- scope?: string;
42
- }
43
- interface OAuthProviderConfig {
44
- clientId: string;
45
- clientSecret: string;
46
- redirectUri: string;
47
- scopes?: string[];
48
- }
49
- interface GoogleConfig extends OAuthProviderConfig {
50
- }
51
- interface GitHubConfig extends OAuthProviderConfig {
52
- }
53
- interface MicrosoftConfig extends OAuthProviderConfig {
54
- tenantId?: string;
55
- }
56
- interface AppleConfig {
57
- clientId: string;
58
- teamId: string;
59
- keyId: string;
60
- privateKey: string;
61
- redirectUri: string;
62
- scopes?: string[];
63
- }
64
- interface OAuthProvider {
65
- readonly name: string;
66
- getAuthorizationUrl(state: string, codeChallenge?: string): Promise<string>;
67
- exchangeCode(code: string, codeVerifier?: string): Promise<OAuthTokens>;
68
- getUserInfo(accessToken: string): Promise<OAuthUserInfo>;
69
- /**
70
- * Refresh access token using refresh token
71
- * Not all providers support refresh tokens
72
- */
73
- refreshToken?(refreshToken: string): Promise<OAuthTokens>;
74
- }
75
- type OAuthProviderName = 'google' | 'github' | 'microsoft' | 'apple';
76
- interface OAuthState {
77
- state: string;
78
- provider: OAuthProviderName;
79
- codeVerifier?: string;
80
- tenantId?: string;
81
- redirectUrl?: string;
82
- expiresAt: Date;
83
- }
84
-
85
18
  /**
86
19
  * Google OAuth Provider
87
20
  */
@@ -156,625 +89,6 @@ declare class AppleProvider implements OAuthProvider {
156
89
  private base64UrlEncode;
157
90
  }
158
91
 
159
- /**
160
- * OAuth Provider
161
- * Manages OAuth2 authentication flows with PKCE support
162
- */
163
-
164
- /**
165
- * OAuth configuration
166
- */
167
- interface OAuthConfig {
168
- google?: GoogleConfig;
169
- github?: GitHubConfig;
170
- microsoft?: MicrosoftConfig;
171
- apple?: AppleConfig;
172
- }
173
- /**
174
- * OAuth flow result
175
- */
176
- interface OAuthFlowResult {
177
- authorizationUrl: string;
178
- state: string;
179
- }
180
- /**
181
- * OAuth callback result
182
- */
183
- interface OAuthCallbackResult {
184
- userInfo: OAuthUserInfo;
185
- tokens: OAuthTokens;
186
- tenantId?: string;
187
- redirectUrl?: string;
188
- }
189
- /**
190
- * Generate PKCE code verifier and challenge
191
- */
192
- declare function generatePKCE(): Promise<{
193
- codeVerifier: string;
194
- codeChallenge: string;
195
- }>;
196
- /**
197
- * Generate secure random state
198
- */
199
- declare function generateState(): string;
200
- /**
201
- * OAuth Manager
202
- * Handles OAuth flows with state management via KVStorage
203
- */
204
- declare class OAuthManager {
205
- private storage;
206
- private providers;
207
- private stateExpirySeconds;
208
- constructor(storage: KVStorage, config: OAuthConfig, options?: {
209
- stateExpirySeconds?: number;
210
- });
211
- /**
212
- * Get available providers
213
- */
214
- getAvailableProviders(): OAuthProviderName[];
215
- /**
216
- * Check if a provider is configured
217
- */
218
- hasProvider(name: string): boolean;
219
- /**
220
- * Get a provider by name
221
- */
222
- getProvider(name: string): OAuthProvider | undefined;
223
- /**
224
- * Start OAuth flow - returns authorization URL
225
- */
226
- startFlow(providerName: OAuthProviderName, options?: {
227
- tenantId?: string;
228
- redirectUrl?: string;
229
- }): Promise<OAuthFlowResult>;
230
- /**
231
- * Handle OAuth callback
232
- */
233
- handleCallback(providerName: OAuthProviderName, code: string, state: string): Promise<OAuthCallbackResult>;
234
- /**
235
- * Refresh OAuth tokens (if supported by provider)
236
- */
237
- refreshTokens(providerName: OAuthProviderName, refreshToken: string): Promise<OAuthTokens>;
238
- /**
239
- * Check if provider supports token refresh
240
- */
241
- supportsRefresh(providerName: OAuthProviderName): boolean;
242
- }
243
- /**
244
- * Create OAuth manager
245
- */
246
- declare function createOAuthManager(storage: KVStorage, config: OAuthConfig, options?: {
247
- stateExpirySeconds?: number;
248
- }): OAuthManager;
249
-
250
- /**
251
- * Magic Link Provider
252
- * Passwordless email authentication via secure links
253
- */
254
-
255
- /**
256
- * Magic Link configuration
257
- */
258
- interface MagicLinkConfig {
259
- /** Base URL for magic links (e.g., https://app.example.com) */
260
- baseUrl: string;
261
- /** Path for callback (default: /auth/magic-link/callback) */
262
- callbackPath?: string;
263
- /** Token expiration in seconds (default: 900 = 15 minutes) */
264
- expiresIn?: number;
265
- /** Token length in bytes (default: 32) */
266
- tokenLength?: number;
267
- /** Email sender function */
268
- send: (email: string, url: string, expiresIn: number) => Promise<void>;
269
- }
270
- /**
271
- * Send magic link result
272
- */
273
- interface SendMagicLinkResult {
274
- success: boolean;
275
- expiresAt?: Date;
276
- error?: string;
277
- }
278
- /**
279
- * Verify magic link result
280
- */
281
- interface VerifyMagicLinkResult {
282
- success: boolean;
283
- email?: string;
284
- tenantId?: string;
285
- redirectUrl?: string;
286
- error?: string;
287
- }
288
- /**
289
- * Magic Link Provider
290
- */
291
- declare class MagicLinkProvider implements AuthProvider {
292
- readonly name = "magic-link";
293
- readonly type: "magic-link";
294
- private storage;
295
- private config;
296
- private _enabled;
297
- constructor(storage: KVStorage, config: MagicLinkConfig);
298
- get enabled(): boolean;
299
- /**
300
- * Send magic link to email
301
- */
302
- sendMagicLink(email: string, options?: {
303
- tenantId?: string;
304
- redirectUrl?: string;
305
- }): Promise<SendMagicLinkResult>;
306
- /**
307
- * Verify magic link token
308
- */
309
- verifyMagicLink(token: string): Promise<VerifyMagicLinkResult>;
310
- /**
311
- * Authenticate with magic link token (implements AuthProvider)
312
- */
313
- authenticate(input: AuthInput): Promise<AuthResult>;
314
- /**
315
- * Get provider info
316
- */
317
- getInfo(): ProviderInfo;
318
- /**
319
- * Request magic link (for use in auth routes)
320
- */
321
- requestMagicLink(email: string, options?: {
322
- tenantId?: string;
323
- redirectUrl?: string;
324
- }): Promise<SendMagicLinkResult>;
325
- }
326
- /**
327
- * Create Magic Link provider
328
- */
329
- declare function createMagicLinkProvider(storage: KVStorage, config: MagicLinkConfig): MagicLinkProvider;
330
-
331
- /**
332
- * TOTP Provider (Time-based One-Time Password)
333
- * RFC 6238 compliant, Google Authenticator compatible
334
- */
335
-
336
- /**
337
- * TOTP Configuration
338
- */
339
- interface TOTPConfig {
340
- /** Issuer name (your app name) */
341
- issuer: string;
342
- /** Hash algorithm (default: SHA1 for compatibility) */
343
- algorithm?: 'SHA1' | 'SHA256' | 'SHA512';
344
- /** Number of digits (default: 6) */
345
- digits?: 6 | 8;
346
- /** Time period in seconds (default: 30) */
347
- period?: number;
348
- /** Time window for drift tolerance (default: 1) */
349
- window?: number;
350
- /** Number of backup codes (default: 10) */
351
- backupCodeCount?: number;
352
- /** Encryption key for storing secrets */
353
- encryptionKey?: string;
354
- }
355
- /**
356
- * TOTP setup result
357
- */
358
- interface TOTPSetupData {
359
- /** Base32 encoded secret */
360
- secret: string;
361
- /** QR code URL */
362
- qrCodeUrl: string;
363
- /** Backup codes */
364
- backupCodes: string[];
365
- /** otpauth:// URI */
366
- otpauthUri: string;
367
- }
368
- /**
369
- * TOTP verify result
370
- */
371
- interface TOTPVerifyResult {
372
- valid: boolean;
373
- usedBackupCode?: boolean;
374
- }
375
- /**
376
- * TOTP Provider
377
- */
378
- declare class TOTPProvider implements TwoFactorProvider {
379
- readonly name = "totp";
380
- readonly type: "totp";
381
- private storage;
382
- private config;
383
- private _enabled;
384
- constructor(storage: KVStorage, config: TOTPConfig);
385
- get enabled(): boolean;
386
- /**
387
- * Setup TOTP for a user
388
- * Note: Use setupWithEmail for full setup including QR code URL
389
- */
390
- setup(userId: string): Promise<TwoFactorSetupResult>;
391
- /**
392
- * Setup TOTP for a user with email for QR code label
393
- */
394
- setupWithEmail(userId: string, userEmail: string): Promise<TwoFactorSetupResult & {
395
- qrCodeUrl: string;
396
- otpauthUri: string;
397
- }>;
398
- /**
399
- * Verify TOTP and activate 2FA (for TwoFactorProvider interface)
400
- */
401
- verifySetup(userId: string, token: string): Promise<boolean>;
402
- /**
403
- * Verify TOTP during login (for TwoFactorProvider interface)
404
- */
405
- verifyLogin(userId: string, code: string): Promise<boolean>;
406
- /**
407
- * Authenticate (for AuthProvider interface)
408
- */
409
- authenticate(_input: AuthInput): Promise<AuthResult>;
410
- /**
411
- * Verify TOTP token
412
- */
413
- verifyCode(userId: string, token: string): Promise<TOTPVerifyResult>;
414
- /**
415
- * Disable TOTP for user
416
- */
417
- disable(userId: string): Promise<void>;
418
- /**
419
- * Regenerate backup codes
420
- */
421
- regenerateBackupCodes(userId: string): Promise<string[]>;
422
- /**
423
- * Get remaining backup codes count
424
- */
425
- getBackupCodesCount(userId: string): Promise<number>;
426
- /**
427
- * Check if TOTP is enabled for user
428
- */
429
- isEnabled(userId: string): Promise<boolean>;
430
- /**
431
- * Generate current TOTP (for testing)
432
- */
433
- generateCurrent(userId: string): Promise<string>;
434
- /**
435
- * Get provider info
436
- */
437
- getInfo(): ProviderInfo;
438
- /**
439
- * Create otpauth URI for QR code
440
- */
441
- private createOtpauthUri;
442
- }
443
- /**
444
- * Create TOTP provider
445
- */
446
- declare function createTOTPProvider(storage: KVStorage, config: TOTPConfig): TOTPProvider;
447
-
448
- /**
449
- * WebAuthn Provider (Passkeys)
450
- * FIDO2 passwordless authentication
451
- */
452
-
453
- /**
454
- * WebAuthn Configuration
455
- */
456
- interface WebAuthnConfig {
457
- /** Relying Party name (your app name) */
458
- rpName: string;
459
- /** Relying Party ID (domain without protocol) */
460
- rpId: string;
461
- /** Full origin (e.g., https://example.com) */
462
- origin: string;
463
- /** Timeout in milliseconds (default: 60000) */
464
- timeout?: number;
465
- /** Attestation preference (default: none) */
466
- attestation?: 'none' | 'indirect' | 'direct';
467
- /** User verification preference (default: preferred) */
468
- userVerification?: 'required' | 'preferred' | 'discouraged';
469
- }
470
- /**
471
- * Registration options returned to client
472
- */
473
- interface RegistrationOptions {
474
- challenge: string;
475
- rp: {
476
- name: string;
477
- id: string;
478
- };
479
- user: {
480
- id: string;
481
- name: string;
482
- displayName: string;
483
- };
484
- pubKeyCredParams: Array<{
485
- type: 'public-key';
486
- alg: number;
487
- }>;
488
- timeout: number;
489
- attestation: 'none' | 'indirect' | 'direct';
490
- authenticatorSelection: {
491
- authenticatorAttachment?: 'platform' | 'cross-platform';
492
- residentKey: 'required' | 'preferred' | 'discouraged';
493
- userVerification: 'required' | 'preferred' | 'discouraged';
494
- };
495
- excludeCredentials: Array<{
496
- id: string;
497
- type: 'public-key';
498
- transports?: string[];
499
- }>;
500
- }
501
- /**
502
- * Authentication options returned to client
503
- */
504
- interface AuthenticationOptions {
505
- challenge: string;
506
- timeout: number;
507
- rpId: string;
508
- allowCredentials: Array<{
509
- id: string;
510
- type: 'public-key';
511
- transports?: string[];
512
- }>;
513
- userVerification: 'required' | 'preferred' | 'discouraged';
514
- }
515
- /**
516
- * Registration response from client
517
- */
518
- interface RegistrationResponse {
519
- id: string;
520
- rawId: string;
521
- type: 'public-key';
522
- response: {
523
- clientDataJSON: string;
524
- attestationObject: string;
525
- transports?: string[];
526
- };
527
- }
528
- /**
529
- * Authentication response from client
530
- */
531
- interface AuthenticationResponse {
532
- id: string;
533
- rawId: string;
534
- type: 'public-key';
535
- response: {
536
- clientDataJSON: string;
537
- authenticatorData: string;
538
- signature: string;
539
- userHandle?: string;
540
- };
541
- }
542
- /**
543
- * Client data JSON structure
544
- */
545
- interface ClientDataJSON {
546
- type: 'webauthn.create' | 'webauthn.get';
547
- challenge: string;
548
- origin: string;
549
- crossOrigin?: boolean;
550
- }
551
- /**
552
- * Authenticator data structure
553
- */
554
- interface AuthenticatorData {
555
- rpIdHash: Uint8Array;
556
- flags: {
557
- userPresent: boolean;
558
- userVerified: boolean;
559
- attestedCredentialData: boolean;
560
- extensionDataIncluded?: boolean;
561
- };
562
- signCount: number;
563
- attestedCredentialData?: {
564
- aaguid: Uint8Array;
565
- credentialId: Uint8Array;
566
- publicKey: Uint8Array;
567
- };
568
- }
569
- /**
570
- * Stored credential (exported as WebAuthnCredential)
571
- */
572
- interface WebAuthnCredential {
573
- id: string;
574
- credentialId: string;
575
- userId: string;
576
- publicKey: string;
577
- counter: number;
578
- transports: string[];
579
- name: string;
580
- deviceType?: string;
581
- createdAt: string;
582
- lastUsedAt?: string;
583
- }
584
- /**
585
- * WebAuthn Provider
586
- */
587
- declare class WebAuthnProvider implements TwoFactorProvider {
588
- readonly name = "webauthn";
589
- readonly type: "webauthn";
590
- private storage;
591
- private config;
592
- private _enabled;
593
- constructor(storage: KVStorage, config: WebAuthnConfig);
594
- get enabled(): boolean;
595
- /**
596
- * Generate registration options
597
- */
598
- generateRegistrationOptions(userId: string, userName: string, userDisplayName: string, authenticatorType?: 'platform' | 'cross-platform'): Promise<RegistrationOptions>;
599
- /**
600
- * Verify registration response
601
- */
602
- verifyRegistration(response: RegistrationResponse, challenge: string, credentialName?: string): Promise<{
603
- success: boolean;
604
- credentialId?: string;
605
- error?: string;
606
- }>;
607
- /**
608
- * Generate authentication options
609
- */
610
- generateAuthenticationOptions(userId?: string): Promise<AuthenticationOptions>;
611
- /**
612
- * Verify authentication response
613
- */
614
- verifyAuthentication(response: AuthenticationResponse, challenge: string): Promise<{
615
- success: boolean;
616
- userId?: string;
617
- credentialId?: string;
618
- error?: string;
619
- }>;
620
- /**
621
- * Get user's credentials
622
- */
623
- getUserCredentials(userId: string): Promise<WebAuthnCredential[]>;
624
- /**
625
- * Remove a credential
626
- */
627
- removeCredential(userId: string, credentialId: string): Promise<boolean>;
628
- /**
629
- * Check if user has any passkeys
630
- */
631
- hasPasskeys(userId: string): Promise<boolean>;
632
- /**
633
- * Setup (for TwoFactorProvider interface)
634
- */
635
- setup(userId: string): Promise<TwoFactorSetupResult>;
636
- /**
637
- * Verify setup (for TwoFactorProvider interface)
638
- */
639
- verifySetup(userId: string, _code: string): Promise<boolean>;
640
- /**
641
- * Verify login (for TwoFactorProvider interface)
642
- */
643
- verifyLogin(userId: string, _code: string): Promise<boolean>;
644
- /**
645
- * Disable 2FA for user
646
- */
647
- disable(userId: string): Promise<void>;
648
- /**
649
- * Authenticate (for AuthProvider interface)
650
- */
651
- authenticate(_input: AuthInput): Promise<AuthResult>;
652
- /**
653
- * Get provider info
654
- */
655
- getInfo(): ProviderInfo;
656
- }
657
- /**
658
- * Create WebAuthn provider
659
- */
660
- declare function createWebAuthnProvider(storage: KVStorage, config: WebAuthnConfig): WebAuthnProvider;
661
-
662
- /**
663
- * Password Provider
664
- * Traditional password-based authentication
665
- * DISABLED BY DEFAULT - use passwordless methods when possible
666
- */
667
-
668
- /**
669
- * Password configuration
670
- */
671
- interface PasswordConfig {
672
- /** Minimum password length (default: 8) */
673
- minLength?: number;
674
- /** Maximum password length (default: 128) */
675
- maxLength?: number;
676
- /** Require uppercase letter (default: true) */
677
- requireUppercase?: boolean;
678
- /** Require lowercase letter (default: true) */
679
- requireLowercase?: boolean;
680
- /** Require number (default: true) */
681
- requireNumber?: boolean;
682
- /** Require special character (default: false) */
683
- requireSpecial?: boolean;
684
- /** Bcrypt cost factor (default: 12) */
685
- bcryptCost?: number;
686
- /** Password hash function (for custom implementations) */
687
- hashPassword?: (password: string) => Promise<string>;
688
- /** Password verify function (for custom implementations) */
689
- verifyPassword?: (password: string, hash: string) => Promise<boolean>;
690
- }
691
- /**
692
- * Password validation result
693
- */
694
- interface PasswordValidationResult {
695
- valid: boolean;
696
- errors: string[];
697
- }
698
- /**
699
- * Password strength levels
700
- */
701
- type PasswordStrength = 'weak' | 'fair' | 'strong' | 'very-strong';
702
- /**
703
- * Password Provider
704
- * WARNING: This provider is disabled by default.
705
- * Consider using passwordless authentication (OTP, Magic Link, OAuth) for better security.
706
- */
707
- declare class PasswordProvider implements AuthProvider {
708
- readonly name = "password";
709
- readonly type: "password";
710
- private storage;
711
- private config;
712
- private _enabled;
713
- constructor(storage: KVStorage, config?: PasswordConfig);
714
- get enabled(): boolean;
715
- /**
716
- * Enable the password provider
717
- * Must be explicitly called to enable password authentication
718
- */
719
- enable(): void;
720
- /**
721
- * Disable the password provider
722
- */
723
- disable(): void;
724
- /**
725
- * Validate password against policy
726
- */
727
- validatePassword(password: string): PasswordValidationResult;
728
- /**
729
- * Check password strength
730
- */
731
- checkStrength(password: string): PasswordStrength;
732
- /**
733
- * Hash a password
734
- * Uses Web Crypto API for PBKDF2 (bcrypt alternative for edge runtime)
735
- */
736
- hashPassword(password: string): Promise<string>;
737
- /**
738
- * Verify a password against a hash
739
- */
740
- verifyPassword(password: string, hash: string): Promise<boolean>;
741
- /**
742
- * Authenticate with password (implements AuthProvider)
743
- */
744
- authenticate(input: AuthInput): Promise<AuthResult>;
745
- /**
746
- * Store password hash for a user
747
- */
748
- setPassword(userId: string, password: string): Promise<{
749
- success: boolean;
750
- errors?: string[];
751
- }>;
752
- /**
753
- * Verify password for a user
754
- */
755
- verifyUserPassword(userId: string, password: string): Promise<boolean>;
756
- /**
757
- * Check if user has password set
758
- */
759
- hasPassword(userId: string): Promise<boolean>;
760
- /**
761
- * Remove password for a user (switch to passwordless)
762
- */
763
- removePassword(userId: string): Promise<void>;
764
- /**
765
- * Get provider info
766
- */
767
- getInfo(): ProviderInfo;
768
- /**
769
- * Constant-time comparison to prevent timing attacks
770
- */
771
- private constantTimeEquals;
772
- }
773
- /**
774
- * Create Password provider
775
- */
776
- declare function createPasswordProvider(storage: KVStorage, config?: PasswordConfig): PasswordProvider;
777
-
778
92
  /**
779
93
  * Runtime detection utilities for multi-runtime support
780
94
  * Supports: Node.js, Deno, Cloudflare Workers, Bun
@@ -896,13 +210,12 @@ interface DrizzleAuthSchema {
896
210
  }
897
211
  /**
898
212
  * User model
213
+ * Note: emailVerified/phoneVerified are tracked via auth_methods.verified
899
214
  */
900
215
  interface DrizzleUser {
901
216
  id: string;
902
217
  displayName: string | null;
903
218
  avatarUrl: string | null;
904
- emailVerified: boolean;
905
- phoneVerified: boolean;
906
219
  twoFactorEnabled: boolean;
907
220
  twoFactorSecret: string | null;
908
221
  status: string;
@@ -1582,4 +895,4 @@ declare function createEmailVerificationService(storage: KVStorage, config: Emai
1582
895
  */
1583
896
  declare function createAuth(config: ParsAuthConfig): ParsAuthEngine;
1584
897
 
1585
- export { type AppleConfig, AppleProvider, AuthAdapter, AuthInput, AuthProvider, AuthResult, type AuthenticationOptions, type AuthenticatorData, type ClientDataJSON, type DrizzleAdapterConfig, type DrizzleAuthMethod, type DrizzleAuthSchema, type DrizzleDatabase, type DrizzleEmailVerificationToken, type DrizzleRole, type DrizzleSession, type DrizzleTenant, type DrizzleTenantMembership, type DrizzleUser, type EmailAttachment, type EmailOptions, type EmailProvider, type EmailResult, EmailService, type EmailServiceConfig, type EmailVerificationConfig, EmailVerificationService, type GitHubConfig, GitHubProvider, type GoogleConfig, GoogleProvider, type InvitationEmailOptions, KVStorage, type MagicLinkEmailOptions, MagicLinkProvider, type MagicLinkConfig as MagicLinkProviderConfig, type MicrosoftConfig, MicrosoftProvider, type NetGSMConfig, NetGSMProvider, type OAuthCallbackResult, type OAuthConfig, type OAuthFlowResult, OAuthManager, type OAuthProviderName, type OAuthState, type OAuthTokens, type OAuthUserInfo as OAuthUser, type OTPEmailOptions, type OTPSMSOptions, ParsAuthConfig, ParsAuthEngine, PasswordProvider, type PasswordConfig as PasswordProviderConfig, type PasswordResetEmailOptions, type PasswordStrength, type PasswordValidationResult, ProviderInfo, type RegistrationOptions, type RequestVerificationResult, ResendEmailProvider, type Runtime, type SMSOptions, type SMSProvider, type SMSResult, SMSService, type SMSServiceConfig, type SendMagicLinkResult, TOTPProvider, type TOTPConfig as TOTPProviderConfig, type TOTPSetupData, type TOTPVerifyResult, TwoFactorProvider, TwoFactorSetupResult, type VerificationEmailOptions, type VerificationStatus, type VerifyEmailResult, type VerifyMagicLinkResult, type WebAuthnCredential, WebAuthnProvider, type WebAuthnConfig as WebAuthnProviderConfig, type WelcomeEmailOptions, base64UrlDecode, base64UrlEncode, bytesToHex, createAuth, createDrizzleAdapter, createEmailService, createEmailVerificationService, createMagicLinkProvider, createNetGSMProvider, createOAuthManager, createPasswordProvider, createResendProvider, createSMSService, createTOTPProvider, createWebAuthnProvider, detectRuntime, generatePKCE, generateRandomBase64Url, generateRandomHex, generateState, getEnv, hexToBytes, isBun, isCloudflare, isDeno, isEdge, isNode, randomInt, sha256, sha256Hex, timingSafeEqual, timingSafeEqualBytes };
898
+ export { AppleConfig, AppleProvider, AuthAdapter, type DrizzleAdapterConfig, type DrizzleAuthMethod, type DrizzleAuthSchema, type DrizzleDatabase, type DrizzleEmailVerificationToken, type DrizzleRole, type DrizzleSession, type DrizzleTenant, type DrizzleTenantMembership, type DrizzleUser, type EmailAttachment, type EmailOptions, type EmailProvider, type EmailResult, EmailService, type EmailServiceConfig, type EmailVerificationConfig, EmailVerificationService, GitHubConfig, GitHubProvider, GoogleConfig, GoogleProvider, type InvitationEmailOptions, KVStorage, type MagicLinkEmailOptions, MicrosoftConfig, MicrosoftProvider, type NetGSMConfig, NetGSMProvider, OAuthTokens, OAuthUserInfo as OAuthUser, type OTPEmailOptions, type OTPSMSOptions, ParsAuthConfig, ParsAuthEngine, type PasswordResetEmailOptions, type RequestVerificationResult, ResendEmailProvider, type Runtime, type SMSOptions, type SMSProvider, type SMSResult, SMSService, type SMSServiceConfig, type VerificationEmailOptions, type VerificationStatus, type VerifyEmailResult, type WelcomeEmailOptions, base64UrlDecode, base64UrlEncode, bytesToHex, createAuth, createDrizzleAdapter, createEmailService, createEmailVerificationService, createNetGSMProvider, createResendProvider, createSMSService, detectRuntime, generateRandomBase64Url, generateRandomHex, getEnv, hexToBytes, isBun, isCloudflare, isDeno, isEdge, isNode, randomInt, sha256, sha256Hex, timingSafeEqual, timingSafeEqualBytes };