@djangocfg/api 2.1.580 → 2.1.582

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/auth.d.cts CHANGED
@@ -13,6 +13,8 @@ declare const AUTH_CONSTANTS: {
13
13
  readonly TOTP_LENGTH: 6;
14
14
  /** Backup code max length. */
15
15
  readonly BACKUP_CODE_MAX_LENGTH: 12;
16
+ /** Resend cooldown (s) when the server does not state one. Mirrors the backend per-email cooldown. */
17
+ readonly RESEND_COOLDOWN_SECONDS: 30;
16
18
  };
17
19
 
18
20
  type SessionStatus = 'authenticated' | 'anonymous';
@@ -124,6 +126,14 @@ type OtpRequestResponse = {
124
126
  * Webmail deep-link for the recipient's provider, or null if the domain is unknown.
125
127
  */
126
128
  webmail?: WebmailLink | null;
129
+ /**
130
+ * Seconds until a new code may be requested for this email.
131
+ */
132
+ resend_in?: number;
133
+ /**
134
+ * Seconds the code stays valid.
135
+ */
136
+ expires_in?: number;
127
137
  };
128
138
  /**
129
139
  * Serializer for OTP verification.
@@ -470,7 +480,7 @@ type PasswordLoginRequestWritable = {
470
480
  * Used by both @djangocfg/api/auth hooks and @djangocfg/layouts/AuthLayout.
471
481
  */
472
482
 
473
- type AuthStep = 'identifier' | 'otp' | '2fa' | '2fa-setup' | 'success';
483
+ type AuthStep = 'identifier' | 'otp' | 'success';
474
484
  interface OTPRequestResult {
475
485
  success: boolean;
476
486
  message: string;
@@ -478,6 +488,8 @@ interface OTPRequestResult {
478
488
  retryAfter?: number;
479
489
  /** Webmail deep-link for the recipient's provider, or null if unknown. */
480
490
  webmail?: WebmailLink | null;
491
+ /** Seconds until a new code may be requested. */
492
+ resendIn?: number;
481
493
  }
482
494
  /**
483
495
  * Marketing-consent payload attached to an OTP request when the consuming
@@ -541,20 +553,16 @@ interface AuthFormState {
541
553
  step: AuthStep;
542
554
  /** Error message */
543
555
  error: string;
544
- /** 2FA session ID from OTP/OAuth verification */
545
- twoFactorSessionId: string | null;
546
- /** Whether user should be prompted to enable 2FA */
547
- shouldPrompt2FA: boolean;
548
- /** 2FA code input */
549
- twoFactorCode: string;
550
- /** Using backup code instead of TOTP */
551
- useBackupCode: boolean;
552
556
  /** Seconds remaining until rate limit lifts (0 = not rate limited) */
553
557
  rateLimitSeconds: number;
554
558
  /** True when rateLimitSeconds > 0 — submit should be disabled */
555
559
  isRateLimited: boolean;
556
560
  /** Formatted countdown label, e.g. "19:00" or "42s" */
557
561
  rateLimitLabel: string;
562
+ /** Seconds until another code may be requested (0 = may resend now) */
563
+ resendSeconds: number;
564
+ /** Formatted resend countdown, e.g. "28s" */
565
+ resendLabel: string;
558
566
  /** Webmail deep-link for the current identifier's provider (null = no button). */
559
567
  webmail: WebmailLink | null;
560
568
  }
@@ -569,12 +577,10 @@ interface AuthFormStateHandlers {
569
577
  clearError: () => void;
570
578
  setStep: (step: AuthStep) => void;
571
579
  setIsLoading: (loading: boolean) => void;
572
- setTwoFactorSessionId: (sessionId: string | null) => void;
573
- setShouldPrompt2FA: (prompt: boolean) => void;
574
- setTwoFactorCode: (code: string) => void;
575
- setUseBackupCode: (useBackup: boolean) => void;
576
580
  /** Start a countdown timer that disables submit for `seconds` seconds */
577
581
  startRateLimitCountdown: (seconds: number) => void;
582
+ /** Start the countdown before another code may be requested */
583
+ startResendCountdown: (seconds: number) => void;
578
584
  /** Set (or clear) the webmail deep-link for the current identifier */
579
585
  setWebmail: (webmail: WebmailLink | null) => void;
580
586
  }
@@ -586,12 +592,6 @@ interface AuthFormSubmitHandlers {
586
592
  handleResendOTP: () => Promise<void>;
587
593
  handleBackToIdentifier: () => void;
588
594
  forceOTPStep: () => void;
589
- /** Handle 2FA TOTP/backup code verification */
590
- handle2FASubmit: (e: React.FormEvent) => Promise<void>;
591
- /** Switch to backup code input */
592
- handleUseBackupCode: () => void;
593
- /** Switch back to TOTP input */
594
- handleUseTOTP: () => void;
595
595
  }
596
596
  interface AuthFormValidation {
597
597
  /** Validate identifier format */
@@ -601,15 +601,7 @@ interface AuthFormAutoSubmit {
601
601
  /** Ref to track if auto-submit from URL is in progress */
602
602
  isAutoSubmittingFromUrl: MutableRefObject<boolean>;
603
603
  }
604
- interface AuthForm2FAState {
605
- /** Loading state for 2FA verification */
606
- is2FALoading: boolean;
607
- /** Warning message from 2FA (e.g., low backup codes) */
608
- twoFactorWarning: string | null;
609
- /** Remaining attempts before 2FA lockout (null = unknown) */
610
- twoFactorAttemptsRemaining: number | null;
611
- }
612
- interface AuthFormReturn extends AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthFormAutoSubmit, AuthForm2FAState {
604
+ interface AuthFormReturn extends AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthFormAutoSubmit {
613
605
  }
614
606
  interface UseAuthFormOptions {
615
607
  /** Callback when identifier step succeeds */
@@ -1059,6 +1051,17 @@ interface UseTwoFactorReturn {
1059
1051
  */
1060
1052
  declare const useTwoFactor: (options?: UseTwoFactorOptions) => UseTwoFactorReturn;
1061
1053
 
1054
+ /** A pending login that needs a TOTP or backup code before tokens are issued. */
1055
+ interface TwoFactorChallenge {
1056
+ sessionId: string;
1057
+ }
1058
+ /** Called by whichever step received `requires_2fa` (OTP, password, OAuth callback). */
1059
+ declare const beginTwoFactorChallenge: (challenge: TwoFactorChallenge) => void;
1060
+ /** Called when the challenge is verified or abandoned. */
1061
+ declare const endTwoFactorChallenge: () => void;
1062
+ /** The pending challenge, or null. */
1063
+ declare const useTwoFactorChallenge: () => TwoFactorChallenge | null;
1064
+
1062
1065
  interface AuthRedirectOptions {
1063
1066
  fallbackUrl?: string;
1064
1067
  clearOnUse?: boolean;
@@ -1429,4 +1432,4 @@ declare const Analytics: {
1429
1432
  setUser(userId: string | null): void;
1430
1433
  };
1431
1434
 
1432
- export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AnalyticsSink, type AuthConfig, AuthContext, type AuthContextType, type AuthErrorCopy, type AuthErrorKey, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type GuardInput, type OTPRequestConsent, type OTPRequestResult, type PasswordLoginOptions, type PasswordLoginResult, type PatchedCfgUserUpdateRequest, type ProfileCacheOptions, type SessionSnapshot, type SessionStatus, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UseTwoFactorVerifyOptions, type UseTwoFactorVerifyReturn, type UserProfile, type WebmailLink, authLogger, clearProfileCache, consumeSavedRedirect, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, isAllowedAuthPath, isForbidden, logAuthFailure, logger, normalizePath, peekSavedRedirect, resolveAuthError, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSession, useSessionStorage, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1435
+ export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AnalyticsSink, type AuthConfig, AuthContext, type AuthContextType, type AuthErrorCopy, type AuthErrorKey, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type GuardInput, type OTPRequestConsent, type OTPRequestResult, type PasswordLoginOptions, type PasswordLoginResult, type PatchedCfgUserUpdateRequest, type ProfileCacheOptions, type SessionSnapshot, type SessionStatus, type TwoFactorChallenge, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UseTwoFactorVerifyOptions, type UseTwoFactorVerifyReturn, type UserProfile, type WebmailLink, authLogger, beginTwoFactorChallenge, clearProfileCache, consumeSavedRedirect, decodeBase64, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, isAllowedAuthPath, isForbidden, logAuthFailure, logger, normalizePath, peekSavedRedirect, resolveAuthError, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSession, useSessionStorage, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
package/dist/auth.d.ts CHANGED
@@ -13,6 +13,8 @@ declare const AUTH_CONSTANTS: {
13
13
  readonly TOTP_LENGTH: 6;
14
14
  /** Backup code max length. */
15
15
  readonly BACKUP_CODE_MAX_LENGTH: 12;
16
+ /** Resend cooldown (s) when the server does not state one. Mirrors the backend per-email cooldown. */
17
+ readonly RESEND_COOLDOWN_SECONDS: 30;
16
18
  };
17
19
 
18
20
  type SessionStatus = 'authenticated' | 'anonymous';
@@ -124,6 +126,14 @@ type OtpRequestResponse = {
124
126
  * Webmail deep-link for the recipient's provider, or null if the domain is unknown.
125
127
  */
126
128
  webmail?: WebmailLink | null;
129
+ /**
130
+ * Seconds until a new code may be requested for this email.
131
+ */
132
+ resend_in?: number;
133
+ /**
134
+ * Seconds the code stays valid.
135
+ */
136
+ expires_in?: number;
127
137
  };
128
138
  /**
129
139
  * Serializer for OTP verification.
@@ -470,7 +480,7 @@ type PasswordLoginRequestWritable = {
470
480
  * Used by both @djangocfg/api/auth hooks and @djangocfg/layouts/AuthLayout.
471
481
  */
472
482
 
473
- type AuthStep = 'identifier' | 'otp' | '2fa' | '2fa-setup' | 'success';
483
+ type AuthStep = 'identifier' | 'otp' | 'success';
474
484
  interface OTPRequestResult {
475
485
  success: boolean;
476
486
  message: string;
@@ -478,6 +488,8 @@ interface OTPRequestResult {
478
488
  retryAfter?: number;
479
489
  /** Webmail deep-link for the recipient's provider, or null if unknown. */
480
490
  webmail?: WebmailLink | null;
491
+ /** Seconds until a new code may be requested. */
492
+ resendIn?: number;
481
493
  }
482
494
  /**
483
495
  * Marketing-consent payload attached to an OTP request when the consuming
@@ -541,20 +553,16 @@ interface AuthFormState {
541
553
  step: AuthStep;
542
554
  /** Error message */
543
555
  error: string;
544
- /** 2FA session ID from OTP/OAuth verification */
545
- twoFactorSessionId: string | null;
546
- /** Whether user should be prompted to enable 2FA */
547
- shouldPrompt2FA: boolean;
548
- /** 2FA code input */
549
- twoFactorCode: string;
550
- /** Using backup code instead of TOTP */
551
- useBackupCode: boolean;
552
556
  /** Seconds remaining until rate limit lifts (0 = not rate limited) */
553
557
  rateLimitSeconds: number;
554
558
  /** True when rateLimitSeconds > 0 — submit should be disabled */
555
559
  isRateLimited: boolean;
556
560
  /** Formatted countdown label, e.g. "19:00" or "42s" */
557
561
  rateLimitLabel: string;
562
+ /** Seconds until another code may be requested (0 = may resend now) */
563
+ resendSeconds: number;
564
+ /** Formatted resend countdown, e.g. "28s" */
565
+ resendLabel: string;
558
566
  /** Webmail deep-link for the current identifier's provider (null = no button). */
559
567
  webmail: WebmailLink | null;
560
568
  }
@@ -569,12 +577,10 @@ interface AuthFormStateHandlers {
569
577
  clearError: () => void;
570
578
  setStep: (step: AuthStep) => void;
571
579
  setIsLoading: (loading: boolean) => void;
572
- setTwoFactorSessionId: (sessionId: string | null) => void;
573
- setShouldPrompt2FA: (prompt: boolean) => void;
574
- setTwoFactorCode: (code: string) => void;
575
- setUseBackupCode: (useBackup: boolean) => void;
576
580
  /** Start a countdown timer that disables submit for `seconds` seconds */
577
581
  startRateLimitCountdown: (seconds: number) => void;
582
+ /** Start the countdown before another code may be requested */
583
+ startResendCountdown: (seconds: number) => void;
578
584
  /** Set (or clear) the webmail deep-link for the current identifier */
579
585
  setWebmail: (webmail: WebmailLink | null) => void;
580
586
  }
@@ -586,12 +592,6 @@ interface AuthFormSubmitHandlers {
586
592
  handleResendOTP: () => Promise<void>;
587
593
  handleBackToIdentifier: () => void;
588
594
  forceOTPStep: () => void;
589
- /** Handle 2FA TOTP/backup code verification */
590
- handle2FASubmit: (e: React.FormEvent) => Promise<void>;
591
- /** Switch to backup code input */
592
- handleUseBackupCode: () => void;
593
- /** Switch back to TOTP input */
594
- handleUseTOTP: () => void;
595
595
  }
596
596
  interface AuthFormValidation {
597
597
  /** Validate identifier format */
@@ -601,15 +601,7 @@ interface AuthFormAutoSubmit {
601
601
  /** Ref to track if auto-submit from URL is in progress */
602
602
  isAutoSubmittingFromUrl: MutableRefObject<boolean>;
603
603
  }
604
- interface AuthForm2FAState {
605
- /** Loading state for 2FA verification */
606
- is2FALoading: boolean;
607
- /** Warning message from 2FA (e.g., low backup codes) */
608
- twoFactorWarning: string | null;
609
- /** Remaining attempts before 2FA lockout (null = unknown) */
610
- twoFactorAttemptsRemaining: number | null;
611
- }
612
- interface AuthFormReturn extends AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthFormAutoSubmit, AuthForm2FAState {
604
+ interface AuthFormReturn extends AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthFormAutoSubmit {
613
605
  }
614
606
  interface UseAuthFormOptions {
615
607
  /** Callback when identifier step succeeds */
@@ -1059,6 +1051,17 @@ interface UseTwoFactorReturn {
1059
1051
  */
1060
1052
  declare const useTwoFactor: (options?: UseTwoFactorOptions) => UseTwoFactorReturn;
1061
1053
 
1054
+ /** A pending login that needs a TOTP or backup code before tokens are issued. */
1055
+ interface TwoFactorChallenge {
1056
+ sessionId: string;
1057
+ }
1058
+ /** Called by whichever step received `requires_2fa` (OTP, password, OAuth callback). */
1059
+ declare const beginTwoFactorChallenge: (challenge: TwoFactorChallenge) => void;
1060
+ /** Called when the challenge is verified or abandoned. */
1061
+ declare const endTwoFactorChallenge: () => void;
1062
+ /** The pending challenge, or null. */
1063
+ declare const useTwoFactorChallenge: () => TwoFactorChallenge | null;
1064
+
1062
1065
  interface AuthRedirectOptions {
1063
1066
  fallbackUrl?: string;
1064
1067
  clearOnUse?: boolean;
@@ -1429,4 +1432,4 @@ declare const Analytics: {
1429
1432
  setUser(userId: string | null): void;
1430
1433
  };
1431
1434
 
1432
- export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AnalyticsSink, type AuthConfig, AuthContext, type AuthContextType, type AuthErrorCopy, type AuthErrorKey, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type GuardInput, type OTPRequestConsent, type OTPRequestResult, type PasswordLoginOptions, type PasswordLoginResult, type PatchedCfgUserUpdateRequest, type ProfileCacheOptions, type SessionSnapshot, type SessionStatus, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UseTwoFactorVerifyOptions, type UseTwoFactorVerifyReturn, type UserProfile, type WebmailLink, authLogger, clearProfileCache, consumeSavedRedirect, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, isAllowedAuthPath, isForbidden, logAuthFailure, logger, normalizePath, peekSavedRedirect, resolveAuthError, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSession, useSessionStorage, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1435
+ export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AnalyticsSink, type AuthConfig, AuthContext, type AuthContextType, type AuthErrorCopy, type AuthErrorKey, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type GuardInput, type OTPRequestConsent, type OTPRequestResult, type PasswordLoginOptions, type PasswordLoginResult, type PatchedCfgUserUpdateRequest, type ProfileCacheOptions, type SessionSnapshot, type SessionStatus, type TwoFactorChallenge, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UseTwoFactorVerifyOptions, type UseTwoFactorVerifyReturn, type UserProfile, type WebmailLink, authLogger, beginTwoFactorChallenge, clearProfileCache, consumeSavedRedirect, decodeBase64, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, isAllowedAuthPath, isForbidden, logAuthFailure, logger, normalizePath, peekSavedRedirect, resolveAuthError, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSession, useSessionStorage, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };