@passflow/react 0.19.0 → 0.20.1

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 (102) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +1 -1
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.es.js +135 -144
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/components/error/index.d.ts.map +1 -1
  8. package/dist/src/components/flow/passflow/index.d.ts.map +1 -1
  9. package/dist/src/components/flow/two-factor-setup-magic-link/index.d.ts.map +1 -1
  10. package/dist/src/components/flow/two-factor-verify/index.d.cts +0 -2
  11. package/dist/src/components/flow/two-factor-verify/index.d.ts +0 -2
  12. package/dist/src/components/flow/two-factor-verify/index.d.ts.map +1 -1
  13. package/dist/src/components/flow/two-factor-verify/screen.d.cts +5 -0
  14. package/dist/src/components/flow/two-factor-verify/screen.d.ts +5 -0
  15. package/dist/src/components/flow/two-factor-verify/screen.d.ts.map +1 -0
  16. package/dist/src/components/form/invitation-join/index.d.ts.map +1 -1
  17. package/dist/src/components/form/reset-password/index.d.ts.map +1 -1
  18. package/dist/src/components/form/signed-in/index.d.cts +9 -0
  19. package/dist/src/components/form/signed-in/index.d.ts +9 -0
  20. package/dist/src/components/form/signed-in/index.d.ts.map +1 -0
  21. package/dist/src/components/form/signin/index.d.ts.map +1 -1
  22. package/dist/src/components/form/signup/index.d.ts.map +1 -1
  23. package/dist/src/components/form/two-factor-challenge/index.d.ts.map +1 -1
  24. package/dist/src/components/form/two-factor-setup/setup-screen.d.cts +29 -0
  25. package/dist/src/components/form/two-factor-setup/setup-screen.d.ts +29 -0
  26. package/dist/src/components/form/two-factor-setup/setup-screen.d.ts.map +1 -0
  27. package/dist/src/components/form/two-factor-setup/two-factor-setup-form.d.cts +3 -0
  28. package/dist/src/components/form/two-factor-setup/two-factor-setup-form.d.ts +3 -0
  29. package/dist/src/components/form/two-factor-setup/two-factor-setup-form.d.ts.map +1 -1
  30. package/dist/src/components/form/two-factor-verify/two-factor-recovery-form.d.cts +5 -2
  31. package/dist/src/components/form/two-factor-verify/two-factor-recovery-form.d.ts +5 -2
  32. package/dist/src/components/form/two-factor-verify/two-factor-recovery-form.d.ts.map +1 -1
  33. package/dist/src/components/form/two-factor-verify/two-factor-verify-form.d.cts +5 -3
  34. package/dist/src/components/form/two-factor-verify/two-factor-verify-form.d.ts +5 -3
  35. package/dist/src/components/form/two-factor-verify/two-factor-verify-form.d.ts.map +1 -1
  36. package/dist/src/components/form/verify-challenge/verify-challenge-magic-link.d.ts.map +1 -1
  37. package/dist/src/components/form/verify-challenge/verify-challenge-otp-manual.d.ts.map +1 -1
  38. package/dist/src/components/form/verify-challenge/verify-challenge-otp-redirect.d.ts.map +1 -1
  39. package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
  40. package/dist/src/components/ui/login-screen/index.d.cts +1 -1
  41. package/dist/src/components/ui/login-screen/index.d.ts +1 -1
  42. package/dist/src/components/ui/login-screen/index.d.ts.map +1 -1
  43. package/dist/src/components/ui/login-screen/login-screen.d.ts.map +1 -1
  44. package/dist/src/components/ui/login-screen/shared.d.cts +4 -0
  45. package/dist/src/components/ui/login-screen/shared.d.ts +4 -0
  46. package/dist/src/components/ui/login-screen/shared.d.ts.map +1 -1
  47. package/dist/src/components/ui/login-screen/status.d.ts.map +1 -1
  48. package/dist/src/components/ui/login-screen/two-factor-code.d.cts +8 -0
  49. package/dist/src/components/ui/login-screen/two-factor-code.d.ts +8 -0
  50. package/dist/src/components/ui/login-screen/two-factor-code.d.ts.map +1 -0
  51. package/dist/src/components/ui/login-screen/two-factor-recovery-codes.d.cts +5 -0
  52. package/dist/src/components/ui/login-screen/two-factor-recovery-codes.d.ts +5 -0
  53. package/dist/src/components/ui/login-screen/two-factor-recovery-codes.d.ts.map +1 -0
  54. package/dist/src/components/ui/login-screen/two-factor-setup.d.cts +4 -0
  55. package/dist/src/components/ui/login-screen/two-factor-setup.d.ts +4 -0
  56. package/dist/src/components/ui/login-screen/two-factor-setup.d.ts.map +1 -0
  57. package/dist/src/components/ui/login-screen/types.d.cts +115 -6
  58. package/dist/src/components/ui/login-screen/types.d.ts +115 -6
  59. package/dist/src/components/ui/login-screen/types.d.ts.map +1 -1
  60. package/dist/src/context/navigation-context.d.cts +6 -1
  61. package/dist/src/context/navigation-context.d.ts +6 -1
  62. package/dist/src/context/navigation-context.d.ts.map +1 -1
  63. package/dist/src/hooks/index.d.cts +1 -0
  64. package/dist/src/hooks/index.d.ts +1 -0
  65. package/dist/src/hooks/index.d.ts.map +1 -1
  66. package/dist/src/hooks/use-navigation.d.cts +2 -0
  67. package/dist/src/hooks/use-navigation.d.ts +2 -0
  68. package/dist/src/hooks/use-navigation.d.ts.map +1 -1
  69. package/dist/src/hooks/use-sign-in-ending.d.cts +16 -0
  70. package/dist/src/hooks/use-sign-in-ending.d.ts +16 -0
  71. package/dist/src/hooks/use-sign-in-ending.d.ts.map +1 -0
  72. package/dist/src/hooks/use-two-factor-enrollment.d.cts +58 -0
  73. package/dist/src/hooks/use-two-factor-enrollment.d.ts +58 -0
  74. package/dist/src/hooks/use-two-factor-enrollment.d.ts.map +1 -0
  75. package/dist/src/hooks/use-two-factor-setup-magic-link.d.cts +5 -15
  76. package/dist/src/hooks/use-two-factor-setup-magic-link.d.ts +5 -15
  77. package/dist/src/hooks/use-two-factor-setup-magic-link.d.ts.map +1 -1
  78. package/dist/src/hooks/use-two-factor-setup.d.ts.map +1 -1
  79. package/dist/src/hooks/use-two-factor-verify.d.ts.map +1 -1
  80. package/dist/src/types/two-factor-errors.d.cts +1 -2
  81. package/dist/src/types/two-factor-errors.d.ts +1 -2
  82. package/dist/src/types/two-factor-errors.d.ts.map +1 -1
  83. package/dist/src/utils/auth-error.d.cts +23 -0
  84. package/dist/src/utils/auth-error.d.ts +23 -0
  85. package/dist/src/utils/auth-error.d.ts.map +1 -1
  86. package/dist/src/utils/classify-two-factor-error.d.cts +5 -6
  87. package/dist/src/utils/classify-two-factor-error.d.ts +5 -6
  88. package/dist/src/utils/classify-two-factor-error.d.ts.map +1 -1
  89. package/dist/src/utils/index.d.cts +4 -3
  90. package/dist/src/utils/index.d.ts +4 -3
  91. package/dist/src/utils/index.d.ts.map +1 -1
  92. package/dist/src/utils/is-sign-in-page.d.cts +5 -0
  93. package/dist/src/utils/is-sign-in-page.d.ts +5 -0
  94. package/dist/src/utils/is-sign-in-page.d.ts.map +1 -0
  95. package/dist/src/utils/second-factor.d.cts +22 -2
  96. package/dist/src/utils/second-factor.d.ts +22 -2
  97. package/dist/src/utils/second-factor.d.ts.map +1 -1
  98. package/dist/style.css +1 -1
  99. package/package.json +2 -2
  100. package/dist/src/components/form/verify-challenge/verify-challenge-success.d.cts +0 -3
  101. package/dist/src/components/form/verify-challenge/verify-challenge-success.d.ts +0 -3
  102. package/dist/src/components/form/verify-challenge/verify-challenge-success.d.ts.map +0 -1
@@ -1,11 +1,4 @@
1
- /**
2
- * Magic link validation error type
3
- */
4
- export type TwoFactorSetupMagicLinkError = {
5
- code: 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'RATE_LIMITED' | 'SERVER_ERROR';
6
- message: string;
7
- retryAfter?: number;
8
- };
1
+ import type { TwoFactorSetupMagicLinkError } from '@passflow/core';
9
2
  /**
10
3
  * Return type for useTwoFactorSetupMagicLink hook
11
4
  */
@@ -26,8 +19,6 @@ export type UseTwoFactorSetupMagicLinkReturn = {
26
19
  appId: string | null;
27
20
  /** Session expiration in seconds */
28
21
  expiresIn: number | null;
29
- /** Retry countdown for rate-limited errors (null if not rate limited) */
30
- retryCountdown: number | null;
31
22
  /** Manual retry function for transient errors */
32
23
  retry: () => Promise<void>;
33
24
  };
@@ -35,19 +26,18 @@ export type UseTwoFactorSetupMagicLinkReturn = {
35
26
  * Hook to validate magic link token for 2FA setup
36
27
  *
37
28
  * This hook:
38
- * - Validates token on mount (automatic)
39
- * - Caches validation result per token (prevents duplicate calls)
29
+ * - Validates once per token on mount (StrictMode included), after app id discovery ends: the session lives in memory
30
+ * on the Passflow instance, and discovery replaces the instance
40
31
  * - Provides loading, error, and success states
41
32
  * - Allows manual retry for transient failures
42
- * - Handles rate limit countdown
43
33
  * - Cleans up conditionally on unmount (only if validation failed or not validated)
44
34
  *
45
35
  * Usage:
46
36
  * ```tsx
47
- * const { isLoading, isValidated, error, retry, retryCountdown } = useTwoFactorSetupMagicLink(token);
37
+ * const { isLoading, isValidated, error, retry } = useTwoFactorSetupMagicLink(token);
48
38
  *
49
39
  * if (isLoading) return <Loading />;
50
- * if (error) return <ErrorUI error={error} onRetry={retry} countdown={retryCountdown} />;
40
+ * if (error) return <ErrorUI error={error} onRetry={retry} />;
51
41
  * if (isValidated) return <TwoFactorSetupForm />;
52
42
  * ```
53
43
  */
@@ -1,11 +1,4 @@
1
- /**
2
- * Magic link validation error type
3
- */
4
- export type TwoFactorSetupMagicLinkError = {
5
- code: 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'RATE_LIMITED' | 'SERVER_ERROR';
6
- message: string;
7
- retryAfter?: number;
8
- };
1
+ import type { TwoFactorSetupMagicLinkError } from '@passflow/core';
9
2
  /**
10
3
  * Return type for useTwoFactorSetupMagicLink hook
11
4
  */
@@ -26,8 +19,6 @@ export type UseTwoFactorSetupMagicLinkReturn = {
26
19
  appId: string | null;
27
20
  /** Session expiration in seconds */
28
21
  expiresIn: number | null;
29
- /** Retry countdown for rate-limited errors (null if not rate limited) */
30
- retryCountdown: number | null;
31
22
  /** Manual retry function for transient errors */
32
23
  retry: () => Promise<void>;
33
24
  };
@@ -35,19 +26,18 @@ export type UseTwoFactorSetupMagicLinkReturn = {
35
26
  * Hook to validate magic link token for 2FA setup
36
27
  *
37
28
  * This hook:
38
- * - Validates token on mount (automatic)
39
- * - Caches validation result per token (prevents duplicate calls)
29
+ * - Validates once per token on mount (StrictMode included), after app id discovery ends: the session lives in memory
30
+ * on the Passflow instance, and discovery replaces the instance
40
31
  * - Provides loading, error, and success states
41
32
  * - Allows manual retry for transient failures
42
- * - Handles rate limit countdown
43
33
  * - Cleans up conditionally on unmount (only if validation failed or not validated)
44
34
  *
45
35
  * Usage:
46
36
  * ```tsx
47
- * const { isLoading, isValidated, error, retry, retryCountdown } = useTwoFactorSetupMagicLink(token);
37
+ * const { isLoading, isValidated, error, retry } = useTwoFactorSetupMagicLink(token);
48
38
  *
49
39
  * if (isLoading) return <Loading />;
50
- * if (error) return <ErrorUI error={error} onRetry={retry} countdown={retryCountdown} />;
40
+ * if (error) return <ErrorUI error={error} onRetry={retry} />;
51
41
  * if (isValidated) return <TwoFactorSetupForm />;
52
42
  * ```
53
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use-two-factor-setup-magic-link.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-two-factor-setup-magic-link.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,cAAc,CAAC;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAcF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,6BAA6B;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,gCAAgC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,CAAC;IACrB,yCAAyC;IACzC,KAAK,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC3C,iCAAiC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,oCAAoC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yEAAyE;IACzE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iDAAiD;IACjD,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,UAAW,MAAM,KAAG,gCAiL1D,CAAC"}
1
+ {"version":3,"file":"use-two-factor-setup-magic-link.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-two-factor-setup-magic-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAoC,MAAM,gBAAgB,CAAC;AAcrG;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,6BAA6B;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,gCAAgC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,CAAC;IACrB,yCAAyC;IACzC,KAAK,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC3C,iCAAiC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,oCAAoC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iDAAiD;IACjD,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,UAAW,MAAM,KAAG,gCAyG1D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-two-factor-setup.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-two-factor-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIvF,M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EAAE,MAAM,CAAC;CACf,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,sBAmE/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-two-factor-verify.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-two-factor-verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAErH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpF,MAAM,MAAM,uBAAuB,GAAG,MAAM;IAC1C,sBAAsB,EAAE,MAAM,OAAO,CAAC;IACtC,qFAAqF;IACrF,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;IACxG,qFAAqF;IACrF,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAC;IACnH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,uBAkFhC,CAAC"}
1
+ {"version":3,"file":"use-two-factor-verify.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-two-factor-verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAErH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpF,MAAM,MAAM,uBAAuB,GAAG,MAAM;IAC1C,sBAAsB,EAAE,MAAM,OAAO,CAAC;IACtC,qFAAqF;IACrF,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;IACxG,qFAAqF;IACrF,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAC;IACnH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,uBAiFhC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Types of 2FA errors with different handling strategies
3
3
  */
4
- export type TwoFactorErrorType = 'expired' | 'not_enabled' | 'invalid_code' | 'generic';
4
+ export type TwoFactorErrorType = 'expired' | 'rate_limited' | 'not_enabled' | 'invalid_code' | 'generic';
5
5
  /**
6
6
  * Structured error information for 2FA errors
7
7
  */
@@ -9,6 +9,5 @@ export type TwoFactorError = {
9
9
  type: TwoFactorErrorType;
10
10
  message: string;
11
11
  isRecoverable: boolean;
12
- shouldAutoRedirect: boolean;
13
12
  };
14
13
  //# sourceMappingURL=two-factor-errors.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Types of 2FA errors with different handling strategies
3
3
  */
4
- export type TwoFactorErrorType = 'expired' | 'not_enabled' | 'invalid_code' | 'generic';
4
+ export type TwoFactorErrorType = 'expired' | 'rate_limited' | 'not_enabled' | 'invalid_code' | 'generic';
5
5
  /**
6
6
  * Structured error information for 2FA errors
7
7
  */
@@ -9,6 +9,5 @@ export type TwoFactorError = {
9
9
  type: TwoFactorErrorType;
10
10
  message: string;
11
11
  isRecoverable: boolean;
12
- shouldAutoRedirect: boolean;
13
12
  };
14
13
  //# sourceMappingURL=two-factor-errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"two-factor-errors.d.ts","sourceRoot":"","sources":["../../../src/types/two-factor-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,aAAa,GACb,cAAc,GACd,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC"}
1
+ {"version":3,"file":"two-factor-errors.d.ts","sourceRoot":"","sources":["../../../src/types/two-factor-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,cAAc,GACd,aAAa,GACb,cAAc,GACd,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC"}
@@ -81,4 +81,27 @@ export declare const isPasswordSavedRateLimit: (error: unknown) => boolean;
81
81
  * failure asks to retry. The raw message of anything else is never shown.
82
82
  */
83
83
  export declare const newPasswordErrorMessage: (error: unknown) => string;
84
+ export declare const twoFactorSignInOverMessage = "Your sign-in has ended. Sign in again.";
85
+ export declare const twoFactorSetupSavedSignInMessage = "Your setup is saved. Sign in again.";
86
+ export declare const twoFactorSetupSavedNewCodeMessage = "Your setup is saved. Enter a new code from your authenticator app to finish signing in.";
87
+ export declare const twoFactorSetupCodeChangedMessage = "Your setup code changed. Scan this new QR code.";
88
+ export declare const twoFactorRateLimitedMessage = "Too many attempts. Sign in again later.";
89
+ export declare const twoFactorWrongCodeMessage = "Invalid code. Please check your authenticator app and try again.";
90
+ export declare const twoFactorWrongRecoveryCodeMessage = "Invalid recovery code.";
91
+ export declare const twoFactorNotEnabledMessage = "Two-factor authentication is not enabled for your account. Please contact your administrator to enable 2FA.";
92
+ export declare const twoFactorSendFailedMessage = "We could not send the setup email. Try again later or contact your administrator.";
93
+ export declare const twoFactorTryAgainMessage = "Something went wrong. Try again.";
94
+ export declare const twoFactorLinkAlreadyUsedMessage = "This link was already used. Sign in.";
95
+ export declare const twoFactorBackToSignInLabel = "Back to sign in";
96
+ export declare const twoFactorSignInLabel = "Sign in";
97
+ export type EnrollmentFailure = 'over' | 'rate_limited' | 'wrong_code' | 'setup_incomplete' | 'not_allowed' | 'send_failed' | 'unavailable' | 'other';
98
+ /** The id of a server error, in a `PassflowError` or a raw axios rejection's object body. */
99
+ export declare const serverErrorIdFrom: (error: unknown) => unknown;
100
+ /** The HTTP status of a server error. `readServerError` skips a raw 429's string body, so its response is read too. */
101
+ export declare const serverErrorStatusFrom: (error: unknown) => unknown;
102
+ /**
103
+ * What a failed confirm, verify, begin or send means for the sign-in. The order matters: several ids answer 401 and do
104
+ * not mean the sign-in ended. Network errors, core's format errors and a `TypeError` from a string body are `other`.
105
+ */
106
+ export declare const enrollmentFailureFrom: (error: unknown) => EnrollmentFailure;
84
107
  //# sourceMappingURL=auth-error.d.ts.map
@@ -81,4 +81,27 @@ export declare const isPasswordSavedRateLimit: (error: unknown) => boolean;
81
81
  * failure asks to retry. The raw message of anything else is never shown.
82
82
  */
83
83
  export declare const newPasswordErrorMessage: (error: unknown) => string;
84
+ export declare const twoFactorSignInOverMessage = "Your sign-in has ended. Sign in again.";
85
+ export declare const twoFactorSetupSavedSignInMessage = "Your setup is saved. Sign in again.";
86
+ export declare const twoFactorSetupSavedNewCodeMessage = "Your setup is saved. Enter a new code from your authenticator app to finish signing in.";
87
+ export declare const twoFactorSetupCodeChangedMessage = "Your setup code changed. Scan this new QR code.";
88
+ export declare const twoFactorRateLimitedMessage = "Too many attempts. Sign in again later.";
89
+ export declare const twoFactorWrongCodeMessage = "Invalid code. Please check your authenticator app and try again.";
90
+ export declare const twoFactorWrongRecoveryCodeMessage = "Invalid recovery code.";
91
+ export declare const twoFactorNotEnabledMessage = "Two-factor authentication is not enabled for your account. Please contact your administrator to enable 2FA.";
92
+ export declare const twoFactorSendFailedMessage = "We could not send the setup email. Try again later or contact your administrator.";
93
+ export declare const twoFactorTryAgainMessage = "Something went wrong. Try again.";
94
+ export declare const twoFactorLinkAlreadyUsedMessage = "This link was already used. Sign in.";
95
+ export declare const twoFactorBackToSignInLabel = "Back to sign in";
96
+ export declare const twoFactorSignInLabel = "Sign in";
97
+ export type EnrollmentFailure = 'over' | 'rate_limited' | 'wrong_code' | 'setup_incomplete' | 'not_allowed' | 'send_failed' | 'unavailable' | 'other';
98
+ /** The id of a server error, in a `PassflowError` or a raw axios rejection's object body. */
99
+ export declare const serverErrorIdFrom: (error: unknown) => unknown;
100
+ /** The HTTP status of a server error. `readServerError` skips a raw 429's string body, so its response is read too. */
101
+ export declare const serverErrorStatusFrom: (error: unknown) => unknown;
102
+ /**
103
+ * What a failed confirm, verify, begin or send means for the sign-in. The order matters: several ids answer 401 and do
104
+ * not mean the sign-in ended. Network errors, core's format errors and a `TypeError` from a string body are `other`.
105
+ */
106
+ export declare const enrollmentFailureFrom: (error: unknown) => EnrollmentFailure;
84
107
  //# sourceMappingURL=auth-error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-error.d.ts","sourceRoot":"","sources":["../../../src/utils/auth-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiCpE,eAAO,MAAM,wBAAwB,uFAAuF,CAAC;AAE7H,eAAO,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OAAO,KAAG,OAC2C,CAAC;AAiBnG;;;GAGG;AACH,eAAO,MAAM,qBAAqB,UAAW,OAAO,KAAG,iBAetD,CAAC"}
@@ -1,11 +1,10 @@
1
- import type { TwoFactorError } from '../types/two-factor-errors.cjs';
1
+ import type { TwoFactorError, TwoFactorErrorType } from '../types/two-factor-errors.cjs';
2
2
  /**
3
- * Classify 2FA error based on error message
4
- *
5
- * @param errorMessage - Error message from SDK
6
- * @returns Classified error with handling strategy
3
+ * Classify a 2FA error from the error itself, not its message: the server localises messages.
7
4
  */
8
- export declare function classifyTwoFactorError(errorMessage: string): TwoFactorError;
5
+ export declare function classifyTwoFactorError(error: unknown): TwoFactorError;
6
+ /** No further code can be taken on the screen: only the way back to sign in is left. */
7
+ export declare const isTerminalTwoFactorError: (type: TwoFactorErrorType | undefined) => boolean;
9
8
  /**
10
9
  * Get user-friendly error message based on error type
11
10
  */
@@ -1,11 +1,10 @@
1
- import type { TwoFactorError } from '../types/two-factor-errors.js';
1
+ import type { TwoFactorError, TwoFactorErrorType } from '../types/two-factor-errors.js';
2
2
  /**
3
- * Classify 2FA error based on error message
4
- *
5
- * @param errorMessage - Error message from SDK
6
- * @returns Classified error with handling strategy
3
+ * Classify a 2FA error from the error itself, not its message: the server localises messages.
7
4
  */
8
- export declare function classifyTwoFactorError(errorMessage: string): TwoFactorError;
5
+ export declare function classifyTwoFactorError(error: unknown): TwoFactorError;
6
+ /** No further code can be taken on the screen: only the way back to sign in is left. */
7
+ export declare const isTerminalTwoFactorError: (type: TwoFactorErrorType | undefined) => boolean;
9
8
  /**
10
9
  * Get user-friendly error message based on error type
11
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"classify-two-factor-error.d.ts","sourceRoot":"","sources":["../../../src/utils/classify-two-factor-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAWhE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAwC3E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAWzE"}
1
+ {"version":3,"file":"classify-two-factor-error.d.ts","sourceRoot":"","sources":["../../../src/utils/classify-two-factor-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AA0BpF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAOrE;AAED,wFAAwF;AACxF,eAAO,MAAM,wBAAwB,SAAU,kBAAkB,GAAG,SAAS,KAAG,OACP,CAAC;AAE1E;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAazE"}
@@ -1,6 +1,6 @@
1
- export { type ApprovalError, approvalAlreadyDecidedMessage, approvalApprovedMessage, approvalAttemptsMessage, approvalConnectionMessage, approvalDeniedMessage, approvalErrorFrom, approvalInvalidMessage, approvalUnavailableMessage, approvalUnknownErrorMessage, authErrorFor, authErrorFrom, authRedirectErrorFrom, authRedirectErrorMessage, emailCodeErrorMessage, invitationJoinErrorFrom, invitationLinkErrorMessage, isApprovalMatchError, isPasswordSavedRateLimit, newPasswordErrorMessage, passwordlessCompleteErrorMessage, passwordlessLinkExpiredMessage, passwordlessSignInFailedMessage, passwordlessWaitCompletedMessage, passwordlessWaitDeniedMessage, serverMessageFor, verificationLinkErrorMessage, verificationRequestErrorMessage, } from './auth-error.cjs';
1
+ export { type ApprovalError, approvalAlreadyDecidedMessage, approvalApprovedMessage, approvalAttemptsMessage, approvalConnectionMessage, approvalDeniedMessage, approvalErrorFrom, approvalInvalidMessage, approvalUnavailableMessage, approvalUnknownErrorMessage, authErrorFor, authErrorFrom, authRedirectErrorFrom, authRedirectErrorMessage, emailCodeErrorMessage, invitationJoinErrorFrom, invitationLinkErrorMessage, isApprovalMatchError, isPasswordSavedRateLimit, newPasswordErrorMessage, passwordlessCompleteErrorMessage, passwordlessLinkExpiredMessage, passwordlessSignInFailedMessage, passwordlessWaitCompletedMessage, passwordlessWaitDeniedMessage, serverMessageFor, twoFactorBackToSignInLabel, twoFactorLinkAlreadyUsedMessage, twoFactorRateLimitedMessage, twoFactorSignInLabel, twoFactorWrongRecoveryCodeMessage, verificationLinkErrorMessage, verificationRequestErrorMessage, } from './auth-error.cjs';
2
2
  export { classifyDeviceError, DeviceApiError, deviceErrorOfType } from './classify-device-error.cjs';
3
- export { classifyTwoFactorError, getUserFriendlyErrorMessage } from './classify-two-factor-error.cjs';
3
+ export { classifyTwoFactorError, getUserFriendlyErrorMessage, isTerminalTwoFactorError } from './classify-two-factor-error.cjs';
4
4
  export { cn } from './cn.cjs';
5
5
  export * from './dayjs/index.cjs';
6
6
  export { type EmailCodeStepEvent, type EmailCodeStepState, emailCodeStepReducer, initialEmailCodeStepState, readEmailVerificationStep, } from './email-verification.cjs';
@@ -9,7 +9,8 @@ export { getIdentityLabel, getPasswordlessData, getValidationErrorsLabel } from
9
9
  export { getUrlErrors } from './get-url-errors.cjs';
10
10
  export { getUrlWithTokens, type TokenUrlFormat } from './get-url-with-tokens.cjs';
11
11
  export { getInvitationAuthChrome, type InvitationAuthIntent } from './invitation-auth-chrome.cjs';
12
- export { routeToSecondFactor, urlCarriesTwoFactorToken } from './second-factor.cjs';
12
+ export { isSameOriginPath, isSignInPage } from './is-sign-in-page.cjs';
13
+ export { routeToSecondFactor, signInSearch, urlCarriesTwoFactorToken } from './second-factor.cjs';
13
14
  export { TwoFactorLoopPrevention } from './two-factor-loop-prevention.cjs';
14
15
  export { undefinedOnCatch } from './undefined-on-catch.cjs';
15
16
  export { attachAuth, registerUpgradeAuthInstance, releaseUpgradeAuthInstance, upgradeAuthInstance, withAuth, } from './upgrade-auth.cjs';
@@ -1,6 +1,6 @@
1
- export { type ApprovalError, approvalAlreadyDecidedMessage, approvalApprovedMessage, approvalAttemptsMessage, approvalConnectionMessage, approvalDeniedMessage, approvalErrorFrom, approvalInvalidMessage, approvalUnavailableMessage, approvalUnknownErrorMessage, authErrorFor, authErrorFrom, authRedirectErrorFrom, authRedirectErrorMessage, emailCodeErrorMessage, invitationJoinErrorFrom, invitationLinkErrorMessage, isApprovalMatchError, isPasswordSavedRateLimit, newPasswordErrorMessage, passwordlessCompleteErrorMessage, passwordlessLinkExpiredMessage, passwordlessSignInFailedMessage, passwordlessWaitCompletedMessage, passwordlessWaitDeniedMessage, serverMessageFor, verificationLinkErrorMessage, verificationRequestErrorMessage, } from './auth-error.js';
1
+ export { type ApprovalError, approvalAlreadyDecidedMessage, approvalApprovedMessage, approvalAttemptsMessage, approvalConnectionMessage, approvalDeniedMessage, approvalErrorFrom, approvalInvalidMessage, approvalUnavailableMessage, approvalUnknownErrorMessage, authErrorFor, authErrorFrom, authRedirectErrorFrom, authRedirectErrorMessage, emailCodeErrorMessage, invitationJoinErrorFrom, invitationLinkErrorMessage, isApprovalMatchError, isPasswordSavedRateLimit, newPasswordErrorMessage, passwordlessCompleteErrorMessage, passwordlessLinkExpiredMessage, passwordlessSignInFailedMessage, passwordlessWaitCompletedMessage, passwordlessWaitDeniedMessage, serverMessageFor, twoFactorBackToSignInLabel, twoFactorLinkAlreadyUsedMessage, twoFactorRateLimitedMessage, twoFactorSignInLabel, twoFactorWrongRecoveryCodeMessage, verificationLinkErrorMessage, verificationRequestErrorMessage, } from './auth-error.js';
2
2
  export { classifyDeviceError, DeviceApiError, deviceErrorOfType } from './classify-device-error.js';
3
- export { classifyTwoFactorError, getUserFriendlyErrorMessage } from './classify-two-factor-error.js';
3
+ export { classifyTwoFactorError, getUserFriendlyErrorMessage, isTerminalTwoFactorError } from './classify-two-factor-error.js';
4
4
  export { cn } from './cn.js';
5
5
  export * from './dayjs/index.js';
6
6
  export { type EmailCodeStepEvent, type EmailCodeStepState, emailCodeStepReducer, initialEmailCodeStepState, readEmailVerificationStep, } from './email-verification.js';
@@ -9,7 +9,8 @@ export { getIdentityLabel, getPasswordlessData, getValidationErrorsLabel } from
9
9
  export { getUrlErrors } from './get-url-errors.js';
10
10
  export { getUrlWithTokens, type TokenUrlFormat } from './get-url-with-tokens.js';
11
11
  export { getInvitationAuthChrome, type InvitationAuthIntent } from './invitation-auth-chrome.js';
12
- export { routeToSecondFactor, urlCarriesTwoFactorToken } from './second-factor.js';
12
+ export { isSameOriginPath, isSignInPage } from './is-sign-in-page.js';
13
+ export { routeToSecondFactor, signInSearch, urlCarriesTwoFactorToken } from './second-factor.js';
13
14
  export { TwoFactorLoopPrevention } from './two-factor-loop-prevention.js';
14
15
  export { undefinedOnCatch } from './undefined-on-catch.js';
15
16
  export { attachAuth, registerUpgradeAuthInstance, releaseUpgradeAuthInstance, upgradeAuthInstance, withAuth, } from './upgrade-auth.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,6BAA6B,EAC7B,gBAAgB,EAChB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,SAAS,C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;AACxD,OAAO,EACL,UAAU,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** Whether a target is a path on this page's origin, as opposed to a full address or anything that could leave it. */
2
+ export declare const isSameOriginPath: (target: string) => boolean;
3
+ /** Whether a sign-in's target is the sign-in page of this app, whatever its query or fragment. */
4
+ export declare const isSignInPage: (target: string, signInPath?: string) => boolean;
5
+ //# sourceMappingURL=is-sign-in-page.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Whether a target is a path on this page's origin, as opposed to a full address or anything that could leave it. */
2
+ export declare const isSameOriginPath: (target: string) => boolean;
3
+ /** Whether a sign-in's target is the sign-in page of this app, whatever its query or fragment. */
4
+ export declare const isSignInPage: (target: string, signInPath?: string) => boolean;
5
+ //# sourceMappingURL=is-sign-in-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-sign-in-page.d.ts","sourceRoot":"","sources":["../../../src/utils/is-sign-in-page.ts"],"names":[],"mappings":"AAKA,sHAAsH;AACtH,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,OAOjD,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,YAAY,WAAY,MAAM,eAAc,MAAM,KAAwB,OAOtF,CAAC"}
@@ -1,5 +1,10 @@
1
- import type { Passflow } from '@passflow/core';
1
+ import { type Passflow } from '@passflow/core';
2
2
  import type { NavigateFunction } from '../context/index.cjs';
3
+ /**
4
+ * The search for a new sign-in or its 2FA step: the original one, without anything that belonged to this attempt. A
5
+ * reset token must not reach the verify URL, and the attempt's own destination is not carried across 2FA.
6
+ */
7
+ export declare const signInSearch: (search: string) => string;
3
8
  /**
4
9
  * Sends a sign-in that still owes its second factor to the 2FA screen.
5
10
  *
@@ -8,9 +13,10 @@ import type { NavigateFunction } from '../context/index.cjs';
8
13
  * `isTwoFactorVerificationRequired()` reads true. The caller must then stop:
9
14
  * no success redirect, and no `getUrlWithTokens` — there are no tokens yet.
10
15
  *
16
+ * @param search the current search; what `signInSearch` keeps goes onto the 2FA URL
11
17
  * @returns true when it navigated, so the caller returns without redirecting
12
18
  */
13
- export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactorVerificationRequired'>, navigate: NavigateFunction, twoFactorVerifyPath: string) => boolean;
19
+ export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactorVerificationRequired'>, navigate: NavigateFunction, twoFactorVerifyPath: string, search?: string) => boolean;
14
20
  /**
15
21
  * Whether the current URL is a landing that owes its second factor: a
16
22
  * federated sign-in on a non-PKCE app comes back with `#tfa_token=` in the
@@ -18,4 +24,18 @@ export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactor
18
24
  * because core adopts the token and strips the fragment as it starts.
19
25
  */
20
26
  export declare const urlCarriesTwoFactorToken: () => boolean;
27
+ /**
28
+ * Whether the current URL is a non-PKCE federated return with tokens in the query. Read it before `@passflow/core` is
29
+ * constructed, because core adopts them and strips the query as it starts.
30
+ */
31
+ export declare const urlCarriesAccessToken: () => boolean;
32
+ /**
33
+ * The app a `#tfa_token=` landing belongs to: the one the token names in `aud`. A federated return carries no `appid`,
34
+ * and the server takes the token only under that app, so discovery (which answers with the default login app) would be
35
+ * wrong. Read for routing only: the server checks the signature and refuses any other pairing.
36
+ *
37
+ * Only on a page served by the API's own origin, the hosted login, which already takes its app from the URL. Any other
38
+ * page keeps its app whatever a link says.
39
+ */
40
+ export declare const twoFactorTokenAppId: (apiUrl: string | undefined) => string | undefined;
21
41
  //# sourceMappingURL=second-factor.d.ts.map
@@ -1,5 +1,10 @@
1
- import type { Passflow } from '@passflow/core';
1
+ import { type Passflow } from '@passflow/core';
2
2
  import type { NavigateFunction } from '../context/index.js';
3
+ /**
4
+ * The search for a new sign-in or its 2FA step: the original one, without anything that belonged to this attempt. A
5
+ * reset token must not reach the verify URL, and the attempt's own destination is not carried across 2FA.
6
+ */
7
+ export declare const signInSearch: (search: string) => string;
3
8
  /**
4
9
  * Sends a sign-in that still owes its second factor to the 2FA screen.
5
10
  *
@@ -8,9 +13,10 @@ import type { NavigateFunction } from '../context/index.js';
8
13
  * `isTwoFactorVerificationRequired()` reads true. The caller must then stop:
9
14
  * no success redirect, and no `getUrlWithTokens` — there are no tokens yet.
10
15
  *
16
+ * @param search the current search; what `signInSearch` keeps goes onto the 2FA URL
11
17
  * @returns true when it navigated, so the caller returns without redirecting
12
18
  */
13
- export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactorVerificationRequired'>, navigate: NavigateFunction, twoFactorVerifyPath: string) => boolean;
19
+ export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactorVerificationRequired'>, navigate: NavigateFunction, twoFactorVerifyPath: string, search?: string) => boolean;
14
20
  /**
15
21
  * Whether the current URL is a landing that owes its second factor: a
16
22
  * federated sign-in on a non-PKCE app comes back with `#tfa_token=` in the
@@ -18,4 +24,18 @@ export declare const routeToSecondFactor: (passflow: Pick<Passflow, 'isTwoFactor
18
24
  * because core adopts the token and strips the fragment as it starts.
19
25
  */
20
26
  export declare const urlCarriesTwoFactorToken: () => boolean;
27
+ /**
28
+ * Whether the current URL is a non-PKCE federated return with tokens in the query. Read it before `@passflow/core` is
29
+ * constructed, because core adopts them and strips the query as it starts.
30
+ */
31
+ export declare const urlCarriesAccessToken: () => boolean;
32
+ /**
33
+ * The app a `#tfa_token=` landing belongs to: the one the token names in `aud`. A federated return carries no `appid`,
34
+ * and the server takes the token only under that app, so discovery (which answers with the default login app) would be
35
+ * wrong. Read for routing only: the server checks the signature and refuses any other pairing.
36
+ *
37
+ * Only on a page served by the API's own origin, the hosted login, which already takes its app from the URL. Any other
38
+ * page keeps its app whatever a link says.
39
+ */
40
+ export declare const twoFactorTokenAppId: (apiUrl: string | undefined) => string | undefined;
21
41
  //# sourceMappingURL=second-factor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"second-factor.d.ts","sourceRoot":"","sources":["../../../src/utils/second-factor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,aACpB,IAAI,CAAC,QAAQ,EAAE,iCAAiC,CAAC,YACjD,gBAAgB,uBACL,MAAM,KAC1B,OAIF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAO,OAG3C,CAAC"}
1
+ {"version":3,"file":"second-factor.d.ts","sourceRoot":"","sources":["../../../src/utils/second-factor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,KAAG,MAI7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,aACpB,IAAI,CAAC,QAAQ,EAAE,iCAAiC,CAAC,YACjD,gBAAgB,uBACL,MAAM,sBAE1B,OAIF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAO,OAG3C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,OACyD,CAAC;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SASzE,CAAC"}