@passflow/react 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +42 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.es.js +146 -133
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/components/flow/passflow/index.d.ts.map +1 -1
  8. package/dist/src/components/form/reset-password/index.d.cts +2 -0
  9. package/dist/src/components/form/reset-password/index.d.ts +2 -0
  10. package/dist/src/components/form/reset-password/index.d.ts.map +1 -1
  11. package/dist/src/components/form/signin/index.d.ts.map +1 -1
  12. package/dist/src/components/form/signup/index.d.ts.map +1 -1
  13. package/dist/src/components/provider/passflow-provider.d.cts +1 -0
  14. package/dist/src/components/provider/passflow-provider.d.ts +1 -0
  15. package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
  16. package/dist/src/components/provider/use-dispose-on-replace.d.cts +17 -0
  17. package/dist/src/components/provider/use-dispose-on-replace.d.ts +17 -0
  18. package/dist/src/components/provider/use-dispose-on-replace.d.ts.map +1 -0
  19. package/dist/src/components/ui/button/index.d.ts.map +1 -1
  20. package/dist/src/components/ui/fields/field-otp.d.cts +3 -1
  21. package/dist/src/components/ui/fields/field-otp.d.ts +3 -1
  22. package/dist/src/components/ui/fields/field-otp.d.ts.map +1 -1
  23. package/dist/src/components/ui/login-screen/email-code.d.cts +10 -0
  24. package/dist/src/components/ui/login-screen/email-code.d.ts +10 -0
  25. package/dist/src/components/ui/login-screen/email-code.d.ts.map +1 -0
  26. package/dist/src/components/ui/login-screen/index.d.cts +1 -1
  27. package/dist/src/components/ui/login-screen/index.d.ts +1 -1
  28. package/dist/src/components/ui/login-screen/index.d.ts.map +1 -1
  29. package/dist/src/components/ui/login-screen/login-screen.d.ts.map +1 -1
  30. package/dist/src/components/ui/login-screen/new-password.d.cts +10 -0
  31. package/dist/src/components/ui/login-screen/new-password.d.ts +10 -0
  32. package/dist/src/components/ui/login-screen/new-password.d.ts.map +1 -0
  33. package/dist/src/components/ui/login-screen/status.d.ts.map +1 -1
  34. package/dist/src/components/ui/login-screen/types.d.cts +62 -3
  35. package/dist/src/components/ui/login-screen/types.d.ts +62 -3
  36. package/dist/src/components/ui/login-screen/types.d.ts.map +1 -1
  37. package/dist/src/context/auth-context.d.cts +5 -4
  38. package/dist/src/context/auth-context.d.ts +5 -4
  39. package/dist/src/context/auth-context.d.ts.map +1 -1
  40. package/dist/src/hooks/index.d.cts +3 -1
  41. package/dist/src/hooks/index.d.ts +3 -1
  42. package/dist/src/hooks/index.d.ts.map +1 -1
  43. package/dist/src/hooks/use-email-code-step.d.cts +39 -0
  44. package/dist/src/hooks/use-email-code-step.d.ts +39 -0
  45. package/dist/src/hooks/use-email-code-step.d.ts.map +1 -0
  46. package/dist/src/hooks/use-join-invite.d.ts.map +1 -1
  47. package/dist/src/hooks/use-refresh-status.d.cts +36 -0
  48. package/dist/src/hooks/use-refresh-status.d.ts +36 -0
  49. package/dist/src/hooks/use-refresh-status.d.ts.map +1 -0
  50. package/dist/src/hooks/use-reset-password.d.cts +14 -1
  51. package/dist/src/hooks/use-reset-password.d.ts +14 -1
  52. package/dist/src/hooks/use-reset-password.d.ts.map +1 -1
  53. package/dist/src/hooks/use-session-expired.d.cts +8 -4
  54. package/dist/src/hooks/use-session-expired.d.ts +8 -4
  55. package/dist/src/hooks/use-session-expired.d.ts.map +1 -1
  56. package/dist/src/hooks/use-signin.d.cts +6 -0
  57. package/dist/src/hooks/use-signin.d.ts +6 -0
  58. package/dist/src/hooks/use-signin.d.ts.map +1 -1
  59. package/dist/src/hooks/use-signup.d.cts +6 -0
  60. package/dist/src/hooks/use-signup.d.ts +6 -0
  61. package/dist/src/hooks/use-signup.d.ts.map +1 -1
  62. package/dist/src/index.d.cts +1 -0
  63. package/dist/src/index.d.ts +1 -0
  64. package/dist/src/index.d.ts.map +1 -1
  65. package/dist/src/types/email-verification.d.cts +18 -0
  66. package/dist/src/types/email-verification.d.ts +18 -0
  67. package/dist/src/types/email-verification.d.ts.map +1 -0
  68. package/dist/src/types/index.d.cts +1 -0
  69. package/dist/src/types/index.d.ts +1 -0
  70. package/dist/src/types/index.d.ts.map +1 -1
  71. package/dist/src/utils/auth-error.d.cts +46 -0
  72. package/dist/src/utils/auth-error.d.ts +46 -0
  73. package/dist/src/utils/auth-error.d.ts.map +1 -1
  74. package/dist/src/utils/email-verification.d.cts +44 -0
  75. package/dist/src/utils/email-verification.d.ts +44 -0
  76. package/dist/src/utils/email-verification.d.ts.map +1 -0
  77. package/dist/src/utils/get-url-errors.d.ts.map +1 -1
  78. package/dist/src/utils/index.d.cts +2 -1
  79. package/dist/src/utils/index.d.ts +2 -1
  80. package/dist/src/utils/index.d.ts.map +1 -1
  81. package/dist/style.css +1 -1
  82. package/package.json +2 -2
@@ -0,0 +1,39 @@
1
+ import type { PassflowAuthorizationResponse } from '@passflow/core';
2
+ import type { EmailCodeStep } from '../types/index.cjs';
3
+ export type UseEmailCodeStepOptions = {
4
+ /**
5
+ * Repeats the request that produced the step (the same sign-up or sign-in body). Absent when the code cannot be
6
+ * sent again, as after a password change: the reset link is spent.
7
+ */
8
+ resend?: () => Promise<unknown>;
9
+ /** The step ended (cancelled, verified, or turned into a link): anything held only for resend can be dropped. */
10
+ onRelease?: () => void;
11
+ };
12
+ export type UseEmailCodeStep = {
13
+ step: EmailCodeStep;
14
+ /** Enters the step when `answer` is an email verification step; `false` (nothing changes) for any other answer. */
15
+ enter: (answer: unknown) => boolean;
16
+ /**
17
+ * Posts the code. Resolves the session answer on success (the caller runs its post-auth path), `null` on a failure
18
+ * (shown in `error`), when a verify is already in flight, or when the step was left meanwhile.
19
+ */
20
+ verify: (otp: string) => Promise<PassflowAuthorizationResponse | null>;
21
+ /**
22
+ * Sends a new code by repeating the original request. Resolves `null` normally (the step moves to the new code or
23
+ * to the link); resolves the session answer in the rare case the repeated request signed the user in directly.
24
+ */
25
+ resend: () => Promise<PassflowAuthorizationResponse | null>;
26
+ canResend: boolean;
27
+ /** Leaves the step for the screen's own form. Ignored while a verify is in flight. */
28
+ cancel: () => void;
29
+ isVerifying: boolean;
30
+ isResending: boolean;
31
+ error: string | null;
32
+ };
33
+ /**
34
+ * The emailed-code step of a sign-up, sign-in or password change: holds the step, posts the code with
35
+ * `passflow.verifyEmailCode`, and resends by repeating the original request. An answer that arrives after the user
36
+ * left the step (or after a newer step replaced it) is dropped.
37
+ */
38
+ export declare const useEmailCodeStep: (options?: UseEmailCodeStepOptions) => UseEmailCodeStep;
39
+ //# sourceMappingURL=use-email-code-step.d.ts.map
@@ -0,0 +1,39 @@
1
+ import type { PassflowAuthorizationResponse } from '@passflow/core';
2
+ import type { EmailCodeStep } from '../types/index.js';
3
+ export type UseEmailCodeStepOptions = {
4
+ /**
5
+ * Repeats the request that produced the step (the same sign-up or sign-in body). Absent when the code cannot be
6
+ * sent again, as after a password change: the reset link is spent.
7
+ */
8
+ resend?: () => Promise<unknown>;
9
+ /** The step ended (cancelled, verified, or turned into a link): anything held only for resend can be dropped. */
10
+ onRelease?: () => void;
11
+ };
12
+ export type UseEmailCodeStep = {
13
+ step: EmailCodeStep;
14
+ /** Enters the step when `answer` is an email verification step; `false` (nothing changes) for any other answer. */
15
+ enter: (answer: unknown) => boolean;
16
+ /**
17
+ * Posts the code. Resolves the session answer on success (the caller runs its post-auth path), `null` on a failure
18
+ * (shown in `error`), when a verify is already in flight, or when the step was left meanwhile.
19
+ */
20
+ verify: (otp: string) => Promise<PassflowAuthorizationResponse | null>;
21
+ /**
22
+ * Sends a new code by repeating the original request. Resolves `null` normally (the step moves to the new code or
23
+ * to the link); resolves the session answer in the rare case the repeated request signed the user in directly.
24
+ */
25
+ resend: () => Promise<PassflowAuthorizationResponse | null>;
26
+ canResend: boolean;
27
+ /** Leaves the step for the screen's own form. Ignored while a verify is in flight. */
28
+ cancel: () => void;
29
+ isVerifying: boolean;
30
+ isResending: boolean;
31
+ error: string | null;
32
+ };
33
+ /**
34
+ * The emailed-code step of a sign-up, sign-in or password change: holds the step, posts the code with
35
+ * `passflow.verifyEmailCode`, and resends by repeating the original request. An answer that arrives after the user
36
+ * left the step (or after a newer step replaced it) is dropped.
37
+ */
38
+ export declare const useEmailCodeStep: (options?: UseEmailCodeStepOptions) => UseEmailCodeStep;
39
+ //# sourceMappingURL=use-email-code-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-email-code-step.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-email-code-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,mHAAmH;IACnH,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IACpC;;;OAGG;IACH,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAAC;IACvE;;;OAGG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAAC;IAC5D,SAAS,EAAE,OAAO,CAAC;IACnB,sFAAsF;IACtF,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAa,uBAAuB,KAAQ,gBAiIxE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-join-invite.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-join-invite.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,kBAAkB,GAAG,MAAM;IACrC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBA4B3B,CAAC"}
1
+ {"version":3,"file":"use-join-invite.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-join-invite.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG,MAAM;IACrC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBA4B3B,CAAC"}
@@ -0,0 +1,36 @@
1
+ export interface UseRefreshStatusResult {
2
+ /**
3
+ * True inside a transient-failure episode: a token refresh failed for a reason that
4
+ * does not end the session (network, 5xx) and core is retrying. The session is kept.
5
+ */
6
+ isFailing: boolean;
7
+ /**
8
+ * Epoch ms of the episode's first transient failure (`RefreshFailing.since`).
9
+ */
10
+ since: number | null;
11
+ /**
12
+ * Epoch ms of the pending retry, when core knows it (`RefreshFailing.nextRetryAt`).
13
+ */
14
+ nextRetryAt: number | null;
15
+ }
16
+ /**
17
+ * Hook to show a "connection trouble" notice while token refresh is failing transiently.
18
+ *
19
+ * Set by `RefreshFailing`; cleared by `RefreshRecovered`, and by `SessionExpired`,
20
+ * `SignOut`, `SignIn` and `Register`, which end or replace the session the episode
21
+ * belonged to. A real end of the session is reported by `useSessionExpired`, not here.
22
+ *
23
+ * Core reports the episode only as events (there is no getter to read on mount), so a
24
+ * component that mounts after `RefreshFailing` starts idle. Call the hook in a component
25
+ * that lives for the whole app, near `PassflowProvider`.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * function ConnectionNotice() {
30
+ * const { isFailing } = useRefreshStatus();
31
+ * return isFailing ? <Banner>Reconnecting...</Banner> : null;
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function useRefreshStatus(): UseRefreshStatusResult;
36
+ //# sourceMappingURL=use-refresh-status.d.ts.map
@@ -0,0 +1,36 @@
1
+ export interface UseRefreshStatusResult {
2
+ /**
3
+ * True inside a transient-failure episode: a token refresh failed for a reason that
4
+ * does not end the session (network, 5xx) and core is retrying. The session is kept.
5
+ */
6
+ isFailing: boolean;
7
+ /**
8
+ * Epoch ms of the episode's first transient failure (`RefreshFailing.since`).
9
+ */
10
+ since: number | null;
11
+ /**
12
+ * Epoch ms of the pending retry, when core knows it (`RefreshFailing.nextRetryAt`).
13
+ */
14
+ nextRetryAt: number | null;
15
+ }
16
+ /**
17
+ * Hook to show a "connection trouble" notice while token refresh is failing transiently.
18
+ *
19
+ * Set by `RefreshFailing`; cleared by `RefreshRecovered`, and by `SessionExpired`,
20
+ * `SignOut`, `SignIn` and `Register`, which end or replace the session the episode
21
+ * belonged to. A real end of the session is reported by `useSessionExpired`, not here.
22
+ *
23
+ * Core reports the episode only as events (there is no getter to read on mount), so a
24
+ * component that mounts after `RefreshFailing` starts idle. Call the hook in a component
25
+ * that lives for the whole app, near `PassflowProvider`.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * function ConnectionNotice() {
30
+ * const { isFailing } = useRefreshStatus();
31
+ * return isFailing ? <Banner>Reconnecting...</Banner> : null;
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function useRefreshStatus(): UseRefreshStatusResult;
36
+ //# sourceMappingURL=use-refresh-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-refresh-status.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-refresh-status.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAaD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CA4BzD"}
@@ -1,9 +1,22 @@
1
+ import { type UseEmailCodeStep } from './use-email-code-step.cjs';
1
2
  export type UseResetPasswordProps = () => {
2
- fetch: (newPassword: string) => Promise<boolean>;
3
+ /**
4
+ * Saves the new password. Pass the reset link's `token` when you have it: without it core looks for `?token=` in
5
+ * the address bar, which a hash or memory router does not keep. Resolves `true` for a session, `false` on an error
6
+ * or when the server asks for an emailed code first (`emailCode` then holds the step).
7
+ */
8
+ fetch: (newPassword: string, resetToken?: string) => Promise<boolean>;
3
9
  isLoading: boolean;
4
10
  isError: boolean;
5
11
  error: string;
12
+ /**
13
+ * The password was changed, but the emailed code that should follow was refused for now (429). Asking for the
14
+ * password again would be wrong: the user should sign in with it later.
15
+ */
16
+ isPasswordSaved: boolean;
6
17
  reset: () => void;
18
+ /** The emailed-code step a password change may answer with. No resend: the reset link is spent. */
19
+ emailCode: UseEmailCodeStep;
7
20
  };
8
21
  export declare const useResetPassword: UseResetPasswordProps;
9
22
  //# sourceMappingURL=use-reset-password.d.ts.map
@@ -1,9 +1,22 @@
1
+ import { type UseEmailCodeStep } from './use-email-code-step.js';
1
2
  export type UseResetPasswordProps = () => {
2
- fetch: (newPassword: string) => Promise<boolean>;
3
+ /**
4
+ * Saves the new password. Pass the reset link's `token` when you have it: without it core looks for `?token=` in
5
+ * the address bar, which a hash or memory router does not keep. Resolves `true` for a session, `false` on an error
6
+ * or when the server asks for an emailed code first (`emailCode` then holds the step).
7
+ */
8
+ fetch: (newPassword: string, resetToken?: string) => Promise<boolean>;
3
9
  isLoading: boolean;
4
10
  isError: boolean;
5
11
  error: string;
12
+ /**
13
+ * The password was changed, but the emailed code that should follow was refused for now (429). Asking for the
14
+ * password again would be wrong: the user should sign in with it later.
15
+ */
16
+ isPasswordSaved: boolean;
6
17
  reset: () => void;
18
+ /** The emailed-code step a password change may answer with. No resend: the reset link is spent. */
19
+ emailCode: UseEmailCodeStep;
7
20
  };
8
21
  export declare const useResetPassword: UseResetPasswordProps;
9
22
  //# sourceMappingURL=use-reset-password.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-reset-password.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-reset-password.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,qBAAqB,GAAG,MAAM;IACxC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,qBA8B9B,CAAC"}
1
+ {"version":3,"file":"use-reset-password.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-reset-password.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAGhF,MAAM,MAAM,qBAAqB,GAAG,MAAM;IACxC;;;;OAIG;IACH,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,mGAAmG;IACnG,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,qBAuC9B,CAAC"}
@@ -1,4 +1,4 @@
1
- export type SessionExpiredReason = 'refresh_failed' | 'token_invalid' | 'logged_out';
1
+ import { type SessionExpiredReason } from '@passflow/core';
2
2
  export interface UseSessionExpiredOptions {
3
3
  /**
4
4
  * Called when the session expires.
@@ -23,9 +23,13 @@ export interface UseSessionExpiredResult {
23
23
  /**
24
24
  * Hook to handle session expiration events.
25
25
  *
26
- * When the SDK detects that the session is invalid (e.g., refresh token expired),
27
- * it emits a SessionExpired event. This hook allows you to react to that event
28
- * and redirect users to your login page.
26
+ * Core emits SessionExpired only when the session has really ended: the last
27
+ * auth strike (`'refresh_failed'`), no successor token pair in time
28
+ * (`'successor_timeout'`), or another user's tokens in storage
29
+ * (`'identity_changed'`). A transient refresh failure (network, 5xx) keeps the
30
+ * session and is reported as RefreshFailing / RefreshRecovered instead; see
31
+ * `useRefreshStatus`. This hook lets you react to the real end and redirect
32
+ * users to your login page.
29
33
  *
30
34
  * @example
31
35
  * ```tsx
@@ -1,4 +1,4 @@
1
- export type SessionExpiredReason = 'refresh_failed' | 'token_invalid' | 'logged_out';
1
+ import { type SessionExpiredReason } from '@passflow/core';
2
2
  export interface UseSessionExpiredOptions {
3
3
  /**
4
4
  * Called when the session expires.
@@ -23,9 +23,13 @@ export interface UseSessionExpiredResult {
23
23
  /**
24
24
  * Hook to handle session expiration events.
25
25
  *
26
- * When the SDK detects that the session is invalid (e.g., refresh token expired),
27
- * it emits a SessionExpired event. This hook allows you to react to that event
28
- * and redirect users to your login page.
26
+ * Core emits SessionExpired only when the session has really ended: the last
27
+ * auth strike (`'refresh_failed'`), no successor token pair in time
28
+ * (`'successor_timeout'`), or another user's tokens in storage
29
+ * (`'identity_changed'`). A transient refresh failure (network, 5xx) keeps the
30
+ * session and is reported as RefreshFailing / RefreshRecovered instead; see
31
+ * `useRefreshStatus`. This hook lets you react to the real end and redirect
32
+ * users to your login page.
29
33
  *
30
34
  * @example
31
35
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"use-session-expired.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-session-expired.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,GAAG,YAAY,CAAC;AAErF,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,uBAAuB,CAsC7F"}
1
+ {"version":3,"file":"use-session-expired.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-session-expired.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAInG,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,uBAAuB,CAsC7F"}
@@ -1,11 +1,17 @@
1
1
  import type { PassflowPasskeyAuthenticateStartPayload, PassflowPasswordlessResponse, PassflowPasswordlessSignInPayload, PassflowSignInPayload } from '@passflow/core';
2
2
  import type { AuthOperation, AuthUiError } from '../types/index.cjs';
3
+ import { type UseEmailCodeStep } from './use-email-code-step.cjs';
3
4
  export type UseSignInProps = () => {
4
5
  fetch: (payload: PassflowPasskeyAuthenticateStartPayload | PassflowSignInPayload | PassflowPasswordlessSignInPayload, type: AuthOperation) => Promise<boolean | string | PassflowPasswordlessResponse>;
5
6
  isLoading: boolean;
6
7
  isError: boolean;
7
8
  error: AuthUiError | null;
8
9
  reset: () => void;
10
+ /**
11
+ * The emailed-code step. A password request the server answers with a code (or a link) enters it, and `fetch`
12
+ * resolves `false`: there is no session yet.
13
+ */
14
+ emailCode: UseEmailCodeStep;
9
15
  };
10
16
  export declare const useSignIn: UseSignInProps;
11
17
  //# sourceMappingURL=use-signin.d.ts.map
@@ -1,11 +1,17 @@
1
1
  import type { PassflowPasskeyAuthenticateStartPayload, PassflowPasswordlessResponse, PassflowPasswordlessSignInPayload, PassflowSignInPayload } from '@passflow/core';
2
2
  import type { AuthOperation, AuthUiError } from '../types/index.js';
3
+ import { type UseEmailCodeStep } from './use-email-code-step.js';
3
4
  export type UseSignInProps = () => {
4
5
  fetch: (payload: PassflowPasskeyAuthenticateStartPayload | PassflowSignInPayload | PassflowPasswordlessSignInPayload, type: AuthOperation) => Promise<boolean | string | PassflowPasswordlessResponse>;
5
6
  isLoading: boolean;
6
7
  isError: boolean;
7
8
  error: AuthUiError | null;
8
9
  reset: () => void;
10
+ /**
11
+ * The emailed-code step. A password request the server answers with a code (or a link) enters it, and `fetch`
12
+ * resolves `false`: there is no session yet.
13
+ */
14
+ emailCode: UseEmailCodeStep;
9
15
  };
10
16
  export declare const useSignIn: UseSignInProps;
11
17
  //# sourceMappingURL=use-signin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-signin.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-signin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI1D,MAAM,MAAM,cAAc,GAAG,MAAM;IACjC,KAAK,EAAE,CACL,OAAO,EAAE,uCAAuC,GAAG,qBAAqB,GAAG,iCAAiC,EAC5G,IAAI,EAAE,aAAa,KAChB,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,4BAA4B,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cA4CvB,CAAC"}
1
+ {"version":3,"file":"use-signin.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-signin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAGhF,MAAM,MAAM,cAAc,GAAG,MAAM;IACjC,KAAK,EAAE,CACL,OAAO,EAAE,uCAAuC,GAAG,qBAAqB,GAAG,iCAAiC,EAC5G,IAAI,EAAE,aAAa,KAChB,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,4BAA4B,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAqEvB,CAAC"}
@@ -1,11 +1,17 @@
1
1
  import type { PassflowPasskeyRegisterStartPayload, PassflowPasswordlessResponse, PassflowPasswordlessSignInPayload, PassflowSignUpPayload } from '@passflow/core';
2
2
  import type { AuthOperation, AuthUiError } from '../types/index.cjs';
3
+ import { type UseEmailCodeStep } from './use-email-code-step.cjs';
3
4
  export type UseSignUpProps = () => {
4
5
  fetch: (payload: PassflowPasskeyRegisterStartPayload | PassflowSignUpPayload | PassflowPasswordlessSignInPayload, type: AuthOperation) => Promise<boolean | string | PassflowPasswordlessResponse>;
5
6
  isLoading: boolean;
6
7
  isError: boolean;
7
8
  error: AuthUiError | null;
8
9
  reset: () => void;
10
+ /**
11
+ * The emailed-code step. A password request the server answers with a code (or a link) enters it, and `fetch`
12
+ * resolves `false`: there is no session yet.
13
+ */
14
+ emailCode: UseEmailCodeStep;
9
15
  };
10
16
  export declare const useSignUp: UseSignUpProps;
11
17
  //# sourceMappingURL=use-signup.d.ts.map
@@ -1,11 +1,17 @@
1
1
  import type { PassflowPasskeyRegisterStartPayload, PassflowPasswordlessResponse, PassflowPasswordlessSignInPayload, PassflowSignUpPayload } from '@passflow/core';
2
2
  import type { AuthOperation, AuthUiError } from '../types/index.js';
3
+ import { type UseEmailCodeStep } from './use-email-code-step.js';
3
4
  export type UseSignUpProps = () => {
4
5
  fetch: (payload: PassflowPasskeyRegisterStartPayload | PassflowSignUpPayload | PassflowPasswordlessSignInPayload, type: AuthOperation) => Promise<boolean | string | PassflowPasswordlessResponse>;
5
6
  isLoading: boolean;
6
7
  isError: boolean;
7
8
  error: AuthUiError | null;
8
9
  reset: () => void;
10
+ /**
11
+ * The emailed-code step. A password request the server answers with a code (or a link) enters it, and `fetch`
12
+ * resolves `false`: there is no session yet.
13
+ */
14
+ emailCode: UseEmailCodeStep;
9
15
  };
10
16
  export declare const useSignUp: UseSignUpProps;
11
17
  //# sourceMappingURL=use-signup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-signup.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-signup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI1D,MAAM,MAAM,cAAc,GAAG,MAAM;IACjC,KAAK,EAAE,CACL,OAAO,EAAE,mCAAmC,GAAG,qBAAqB,GAAG,iCAAiC,EACxG,IAAI,EAAE,aAAa,KAChB,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,4BAA4B,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cA+CvB,CAAC"}
1
+ {"version":3,"file":"use-signup.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-signup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAGhF,MAAM,MAAM,cAAc,GAAG,MAAM;IACjC,KAAK,EAAE,CACL,OAAO,EAAE,mCAAmC,GAAG,qBAAqB,GAAG,iCAAiC,EACxG,IAAI,EAAE,aAAa,KAChB,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,4BAA4B,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAwEvB,CAAC"}
@@ -6,5 +6,6 @@ export { PassflowProvider, UpgradeProvider } from './components/provider/index.c
6
6
  export * from './components/ui/index.cjs';
7
7
  export { INERT_UPGRADE_CONTEXT, UpgradeContext, type UpgradeContextValue, type UpgradeElevateOptions, type UpgradeErrorStatusKind, type UpgradeHookState, type UpgradePromptView, type UpgradeSettledState, } from './context/upgrade-context.cjs';
8
8
  export * from './hooks/index.cjs';
9
+ export type { EmailCodeStep, EmailVerificationStep } from './types/index.cjs';
9
10
  export { attachAuth, withAuth } from './utils/upgrade-auth.cjs';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -6,5 +6,6 @@ export { PassflowProvider, UpgradeProvider } from './components/provider/index.j
6
6
  export * from './components/ui/index.js';
7
7
  export { INERT_UPGRADE_CONTEXT, UpgradeContext, type UpgradeContextValue, type UpgradeElevateOptions, type UpgradeErrorStatusKind, type UpgradeHookState, type UpgradePromptView, type UpgradeSettledState, } from './context/upgrade-context.js';
8
8
  export * from './hooks/index.js';
9
+ export type { EmailCodeStep, EmailVerificationStep } from './types/index.js';
9
10
  export { attachAuth, withAuth } from './utils/upgrade-auth.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC;AAEjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC1E,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC;AAEjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC1E,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What a sign-up, sign-in or password change answered instead of a session: `code` when a code was emailed
3
+ * (finish it with `verifyEmailCode`), `link` when a link was emailed instead (the sign-in finishes on that page).
4
+ * `message` is the server's text, or fixed copy when the server sent none.
5
+ */
6
+ export type EmailVerificationStep = {
7
+ kind: 'code';
8
+ challengeId: string;
9
+ message: string;
10
+ } | {
11
+ kind: 'link';
12
+ message: string;
13
+ };
14
+ /** The emailed-code step of a screen: `none` while the screen shows its own form. */
15
+ export type EmailCodeStep = {
16
+ kind: 'none';
17
+ } | EmailVerificationStep;
18
+ //# sourceMappingURL=email-verification.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What a sign-up, sign-in or password change answered instead of a session: `code` when a code was emailed
3
+ * (finish it with `verifyEmailCode`), `link` when a link was emailed instead (the sign-in finishes on that page).
4
+ * `message` is the server's text, or fixed copy when the server sent none.
5
+ */
6
+ export type EmailVerificationStep = {
7
+ kind: 'code';
8
+ challengeId: string;
9
+ message: string;
10
+ } | {
11
+ kind: 'link';
12
+ message: string;
13
+ };
14
+ /** The emailed-code step of a screen: `none` while the screen shows its own form. */
15
+ export type EmailCodeStep = {
16
+ kind: 'none';
17
+ } | EmailVerificationStep;
18
+ //# sourceMappingURL=email-verification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-verification.d.ts","sourceRoot":"","sources":["../../../src/types/email-verification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/H,qFAAqF;AACrF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,CAAC"}
@@ -5,6 +5,7 @@ export type SuccessAuthRedirect = string;
5
5
  export type { RegisteredTwoFactorMethod, TwoFactorChallengeResponse, TwoFactorMethod, TwoFactorVerifyRequestV2, TwoFactorVerifyResponseV2, } from '@passflow/core';
6
6
  export type { AuthErrorScope, AuthFlow, AuthOperation, AuthUiError } from './auth-errors.cjs';
7
7
  export type { DeviceError, DeviceErrorType } from './device-errors.cjs';
8
+ export type { EmailCodeStep, EmailVerificationStep } from './email-verification.cjs';
8
9
  export type { TwoFactorError, TwoFactorErrorType } from './two-factor-errors.cjs';
9
10
  export interface UseTwoFactorChallengeReturn {
10
11
  challenge: import('@passflow/core').TwoFactorChallengeResponse | null;
@@ -5,6 +5,7 @@ export type SuccessAuthRedirect = string;
5
5
  export type { RegisteredTwoFactorMethod, TwoFactorChallengeResponse, TwoFactorMethod, TwoFactorVerifyRequestV2, TwoFactorVerifyResponseV2, } from '@passflow/core';
6
6
  export type { AuthErrorScope, AuthFlow, AuthOperation, AuthUiError } from './auth-errors.js';
7
7
  export type { DeviceError, DeviceErrorType } from './device-errors.js';
8
+ export type { EmailCodeStep, EmailVerificationStep } from './email-verification.js';
8
9
  export type { TwoFactorError, TwoFactorErrorType } from './two-factor-errors.js';
9
10
  export interface UseTwoFactorChallengeReturn {
10
11
  challenge: import('@passflow/core').TwoFactorChallengeResponse | null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,OAAO,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAGzC,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,OAAO,gBAAgB,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gBAAgB,EAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,gBAAgB,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,cAAc,EAAE,OAAO,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,OAAO,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAC7D,iBAAiB,EAAE,OAAO,gBAAgB,EAAE,yBAAyB,EAAE,CAAC;IACxE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,OAAO,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAGzC,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACjF,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,OAAO,gBAAgB,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gBAAgB,EAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,gBAAgB,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,cAAc,EAAE,OAAO,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,OAAO,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAC7D,iBAAiB,EAAE,OAAO,gBAAgB,EAAE,yBAAyB,EAAE,CAAC;IACxE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD"}
@@ -4,4 +4,50 @@ export declare const verificationLinkErrorMessage = "This verification link is i
4
4
  export declare const invitationLinkErrorMessage = "This invitation link is invalid or has expired.";
5
5
  export declare const verificationRequestErrorMessage = "This verification request is no longer available. Start again to request a new link or code.";
6
6
  export declare const authErrorFor: (flow: AuthFlow, operation: AuthOperation) => AuthUiError;
7
+ /**
8
+ * Server error ids whose `message` is written for the end user (localized, no operator detail) and may be shown as
9
+ * is. Every other id keeps the SDK's fixed copy, so server text that was not meant for a sign-in screen never reaches
10
+ * one. `error.not.found` is deliberately absent: it is a generic id across the API (its text can name a missing user).
11
+ */
12
+ export declare const SERVER_MESSAGE_ERROR_IDS: ReadonlySet<string>;
13
+ /**
14
+ * The server's own message for an allow-listed error id, trimmed; `null` for anything else. Duck-typed on
15
+ * `{ id, message }`, so it reads a `PassflowError`, a raw axios rejection's body, or a plain object such as a
16
+ * redirect's query.
17
+ */
18
+ export declare const serverMessageFor: (error: unknown) => string | null;
19
+ /** A hook's display error: the server's message for an allow-listed id, else the fixed copy for the operation. */
20
+ export declare const authErrorFrom: (error: unknown, flow: AuthFlow, operation: AuthOperation) => AuthUiError;
21
+ /**
22
+ * The message for a federated redirect that came back as `?error=<id>&message=<text>`: the server's text when the id
23
+ * is allow-listed, else the generic redirect copy.
24
+ */
25
+ export declare const authRedirectErrorFrom: (error: string, message: string | null) => string;
26
+ export declare const invitationJoinErrorMessage = "We couldn't accept this invitation. Try again.";
27
+ /** Invitation join error: the server's message for an allow-listed id, else the fixed copy. */
28
+ export declare const invitationJoinErrorFrom: (error: unknown) => string;
29
+ export declare const emailCodeInvalidMessage = "This code is no longer valid. Request a new code.";
30
+ export declare const emailCodeUnavailableMessage = "We couldn't check the code. Try again.";
31
+ export declare const emailCodeRestartMessage = "We couldn't verify the code. Go back and start again.";
32
+ /**
33
+ * Error copy for the emailed-code step (`/auth/validate`, resend): allow-listed ids (wrong, expired or spent code,
34
+ * rate limit, ...) show the server message; `error.not.found` (unknown or spent challenge) asks for a new code; a
35
+ * request that got no answer at all (offline, CORS, timeout) asks to retry; every other server answer (401, a missing
36
+ * PKCE verifier, an unlisted 4xx or a 5xx) asks to start again, and the screen keeps its way back to the form.
37
+ */
38
+ export declare const emailCodeErrorMessage: (error: unknown) => string;
39
+ export declare const resetLinkInvalidMessage = "This link is invalid or has expired. Request a new one.";
40
+ export declare const newPasswordUnavailableMessage = "We couldn't save your password. Try again.";
41
+ export declare const passwordSavedRateLimitedMessage = "Your password was saved, but we cannot send a verification code right now. Wait a few minutes, then sign in with your new password.";
42
+ /**
43
+ * A 429 from `/auth/password/change`: the password was already changed, only the emailed code that should follow
44
+ * was refused, so the screen must not ask for the password again.
45
+ */
46
+ export declare const isPasswordSavedRateLimit: (error: unknown) => boolean;
47
+ /**
48
+ * Error copy for the new-password screen (reset link or registration continuation): allow-listed ids show the server
49
+ * message; a refused or spent link (any other 4xx, an `error.token.*` id) asks for a new one; a server or network
50
+ * failure asks to retry. The raw message of anything else is never shown.
51
+ */
52
+ export declare const newPasswordErrorMessage: (error: unknown) => string;
7
53
  //# sourceMappingURL=auth-error.d.ts.map
@@ -4,4 +4,50 @@ export declare const verificationLinkErrorMessage = "This verification link is i
4
4
  export declare const invitationLinkErrorMessage = "This invitation link is invalid or has expired.";
5
5
  export declare const verificationRequestErrorMessage = "This verification request is no longer available. Start again to request a new link or code.";
6
6
  export declare const authErrorFor: (flow: AuthFlow, operation: AuthOperation) => AuthUiError;
7
+ /**
8
+ * Server error ids whose `message` is written for the end user (localized, no operator detail) and may be shown as
9
+ * is. Every other id keeps the SDK's fixed copy, so server text that was not meant for a sign-in screen never reaches
10
+ * one. `error.not.found` is deliberately absent: it is a generic id across the API (its text can name a missing user).
11
+ */
12
+ export declare const SERVER_MESSAGE_ERROR_IDS: ReadonlySet<string>;
13
+ /**
14
+ * The server's own message for an allow-listed error id, trimmed; `null` for anything else. Duck-typed on
15
+ * `{ id, message }`, so it reads a `PassflowError`, a raw axios rejection's body, or a plain object such as a
16
+ * redirect's query.
17
+ */
18
+ export declare const serverMessageFor: (error: unknown) => string | null;
19
+ /** A hook's display error: the server's message for an allow-listed id, else the fixed copy for the operation. */
20
+ export declare const authErrorFrom: (error: unknown, flow: AuthFlow, operation: AuthOperation) => AuthUiError;
21
+ /**
22
+ * The message for a federated redirect that came back as `?error=<id>&message=<text>`: the server's text when the id
23
+ * is allow-listed, else the generic redirect copy.
24
+ */
25
+ export declare const authRedirectErrorFrom: (error: string, message: string | null) => string;
26
+ export declare const invitationJoinErrorMessage = "We couldn't accept this invitation. Try again.";
27
+ /** Invitation join error: the server's message for an allow-listed id, else the fixed copy. */
28
+ export declare const invitationJoinErrorFrom: (error: unknown) => string;
29
+ export declare const emailCodeInvalidMessage = "This code is no longer valid. Request a new code.";
30
+ export declare const emailCodeUnavailableMessage = "We couldn't check the code. Try again.";
31
+ export declare const emailCodeRestartMessage = "We couldn't verify the code. Go back and start again.";
32
+ /**
33
+ * Error copy for the emailed-code step (`/auth/validate`, resend): allow-listed ids (wrong, expired or spent code,
34
+ * rate limit, ...) show the server message; `error.not.found` (unknown or spent challenge) asks for a new code; a
35
+ * request that got no answer at all (offline, CORS, timeout) asks to retry; every other server answer (401, a missing
36
+ * PKCE verifier, an unlisted 4xx or a 5xx) asks to start again, and the screen keeps its way back to the form.
37
+ */
38
+ export declare const emailCodeErrorMessage: (error: unknown) => string;
39
+ export declare const resetLinkInvalidMessage = "This link is invalid or has expired. Request a new one.";
40
+ export declare const newPasswordUnavailableMessage = "We couldn't save your password. Try again.";
41
+ export declare const passwordSavedRateLimitedMessage = "Your password was saved, but we cannot send a verification code right now. Wait a few minutes, then sign in with your new password.";
42
+ /**
43
+ * A 429 from `/auth/password/change`: the password was already changed, only the emailed code that should follow
44
+ * was refused, so the screen must not ask for the password again.
45
+ */
46
+ export declare const isPasswordSavedRateLimit: (error: unknown) => boolean;
47
+ /**
48
+ * Error copy for the new-password screen (reset link or registration continuation): allow-listed ids show the server
49
+ * message; a refused or spent link (any other 4xx, an `error.token.*` id) asks for a new one; a server or network
50
+ * failure asks to retry. The raw message of anything else is never shown.
51
+ */
52
+ export declare const newPasswordErrorMessage: (error: unknown) => string;
7
53
  //# 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,MAAM,4BAA4B,+FACqD,CAAC;AAE/F,eAAO,MAAM,0BAA0B,oDAAoD,CAAC;AAE5F,eAAO,MAAM,+BAA+B,iGACoD,CAAC;AAEjG,eAAO,MAAM,YAAY,SAAU,QAAQ,aAAa,aAAa,KAAG,WAA+C,CAAC"}
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,MAAM,4BAA4B,+FACqD,CAAC;AAE/F,eAAO,MAAM,0BAA0B,oDAAoD,CAAC;AAE5F,eAAO,MAAM,+BAA+B,iGACoD,CAAC;AAEjG,eAAO,MAAM,YAAY,SAAU,QAAQ,aAAa,aAAa,KAAG,WAA+C,CAAC;AAExH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,CAavD,CAAC;AAkBH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,MAAM,GAAG,IAQ1D,CAAC;AAEF,kHAAkH;AAClH,eAAO,MAAM,aAAa,UAAW,OAAO,QAAQ,QAAQ,aAAa,aAAa,KAAG,WAGxF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,WAAW,MAAM,GAAG,IAAI,KAAG,MACR,CAAC;AAEvE,eAAO,MAAM,0BAA0B,mDAAmD,CAAC;AAE3F,+FAA+F;AAC/F,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,MAA+D,CAAC;AAEzH,eAAO,MAAM,uBAAuB,sDAAsD,CAAC;AAC3F,eAAO,MAAM,2BAA2B,2CAA2C,CAAC;AACpF,eAAO,MAAM,uBAAuB,0DAA0D,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAW,OAAO,KAAG,MAUtD,CAAC;AAEF,eAAO,MAAM,uBAAuB,4DAA4D,CAAC;AACjG,eAAO,MAAM,6BAA6B,+CAA+C,CAAC;AAC1F,eAAO,MAAM,+BAA+B,wIAC2F,CAAC;AAExI;;;GAGG;AACH,eAAO,MAAM,wBAAwB,UAAW,OAAO,KAAG,OAGzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,MAWxD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { EmailCodeStep, EmailVerificationStep } from '../types/index.cjs';
2
+ export declare const emailCodeSentFallbackMessage = "We sent a code to your email.";
3
+ export declare const emailLinkSentFallbackMessage = "Check your email for a link to finish signing up.";
4
+ /**
5
+ * Reads an auth answer as an email verification step: `code` when the server emailed a code (a non-empty
6
+ * `challenge_id`), `link` when it emailed a link instead. `null` for anything else (tokens, a 2FA token, no answer).
7
+ */
8
+ export declare const readEmailVerificationStep: (answer: unknown) => EmailVerificationStep | null;
9
+ export type EmailCodeStepState = {
10
+ step: EmailCodeStep;
11
+ /** The display message of the last failed verify or resend; cleared by the next attempt or a new code. */
12
+ error: string | null;
13
+ };
14
+ export type EmailCodeStepEvent = {
15
+ type: 'ENTER';
16
+ step: EmailVerificationStep;
17
+ } | {
18
+ type: 'VERIFY_STARTED';
19
+ } | {
20
+ type: 'VERIFY_OK';
21
+ } | {
22
+ type: 'VERIFY_FAILED';
23
+ message: string;
24
+ } | {
25
+ type: 'RESENT';
26
+ challengeId: string;
27
+ message: string;
28
+ } | {
29
+ type: 'LINK_SENT';
30
+ message: string;
31
+ } | {
32
+ type: 'RESEND_FAILED';
33
+ message: string;
34
+ } | {
35
+ type: 'CANCEL';
36
+ };
37
+ export declare const initialEmailCodeStepState: EmailCodeStepState;
38
+ /**
39
+ * The emailed-code step as a transition table. Only `ENTER` leaves `none`: a verify or resend answer that lands
40
+ * after the user went back is a real race, not a bug, so it is ignored rather than resurrecting the step. Verify and
41
+ * resend events only change a `code` step; in `link` there is nothing left to verify or resend.
42
+ */
43
+ export declare const emailCodeStepReducer: (state: EmailCodeStepState, event: EmailCodeStepEvent) => EmailCodeStepState;
44
+ //# sourceMappingURL=email-verification.d.ts.map