@eifi1/ui-kit 0.30.0 → 0.31.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.
- package/README.md +42 -5
- package/dist/account/data-export-setting.js +3 -2
- package/dist/account/data-export-setting.js.map +1 -1
- package/dist/account/delete-account-setting.d.ts +5 -1
- package/dist/account/delete-account-setting.js +3 -2
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/account/email-change-setting.js +4 -3
- package/dist/account/email-change-setting.js.map +1 -1
- package/dist/account/sessions-setting.js +3 -2
- package/dist/account/sessions-setting.js.map +1 -1
- package/dist/admin/admin-action-confirm.d.ts +5 -1
- package/dist/admin/admin-parts.d.ts +8 -1
- package/dist/admin/admin-parts.js +1 -1
- package/dist/admin/admin-parts.js.map +1 -1
- package/dist/admin/invitations-panel.d.ts +5 -1
- package/dist/admin/invitations-panel.js +3 -2
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.d.ts +5 -1
- package/dist/admin/role-select.d.ts +5 -1
- package/dist/admin/transfer-ownership-dialog.d.ts +5 -1
- package/dist/admin/user-roster.d.ts +5 -1
- package/dist/auth/auth-errors.d.ts +24 -6
- package/dist/auth/auth-errors.js +7 -1
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/register-form.d.ts +5 -1
- package/dist/auth/reset-password-form.d.ts +1 -1
- package/dist/auth/reset-password-form.js +2 -1
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form.d.ts +15 -1
- package/dist/auth/sign-in-form.js +12 -3
- package/dist/auth/sign-in-form.js.map +1 -1
- package/dist/auth/verify-email.d.ts +4 -0
- package/dist/auth/verify-email.js +3 -2
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/chart.d.ts +5 -1
- package/dist/components/account-settings-labels.d.ts +12 -0
- package/dist/components/account-settings-labels.js +2 -1
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/account-settings.d.ts +8 -2
- package/dist/components/account-settings.js +19 -11
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +5 -1
- package/dist/components/button-group.d.ts +5 -1
- package/dist/components/calculator.d.ts +5 -1
- package/dist/components/confirm-dialog.d.ts +5 -1
- package/dist/components/confirm-dialog.js +7 -1
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/danger-confirm.d.ts +5 -1
- package/dist/components/data-table.js +8 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +9 -4
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/facing-pair.d.ts +5 -1
- package/dist/components/file-button.d.ts +5 -1
- package/dist/components/file-dropzone.d.ts +5 -1
- package/dist/components/form-actions.d.ts +5 -1
- package/dist/components/iban-input.d.ts +5 -1
- package/dist/components/language-select.d.ts +5 -1
- package/dist/components/legal-page.d.ts +5 -1
- package/dist/components/legal.d.ts +5 -1
- package/dist/components/money-field.d.ts +5 -1
- package/dist/components/number-field.d.ts +5 -1
- package/dist/components/number-input.d.ts +5 -1
- package/dist/components/numpad-sheet.d.ts +5 -1
- package/dist/components/passkeys-setting.js +2 -1
- package/dist/components/passkeys-setting.js.map +1 -1
- package/dist/components/phone-input.d.ts +5 -1
- package/dist/components/series-chart.d.ts +5 -1
- package/dist/components/settings-fields.d.ts +40 -3
- package/dist/components/settings-fields.js +20 -1
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/share-card.d.ts +5 -1
- package/dist/components/text-link.d.ts +5 -1
- package/dist/components/time-input.d.ts +5 -1
- package/dist/components/ui.d.ts +5 -1
- package/dist/{delete-account-setting-CGVMckMw.d.ts → delete-account-setting-CpIhzxxZ.d.ts} +60 -23
- package/dist/demo/demo-banner.d.ts +51 -0
- package/dist/demo/demo-banner.js +97 -0
- package/dist/demo/demo-banner.js.map +1 -0
- package/dist/demo/demo-countdown.d.ts +58 -0
- package/dist/demo/demo-countdown.js +79 -0
- package/dist/demo/demo-countdown.js.map +1 -0
- package/dist/demo/demo-ended.d.ts +45 -0
- package/dist/demo/demo-ended.js +42 -0
- package/dist/demo/demo-ended.js.map +1 -0
- package/dist/demo/demo-labels.d.ts +53 -0
- package/dist/demo/demo-labels.js +29 -0
- package/dist/demo/demo-labels.js.map +1 -0
- package/dist/demo/demo-session.d.ts +30 -0
- package/dist/demo/demo-session.js +8 -0
- package/dist/demo/demo-session.js.map +1 -0
- package/dist/demo/demo-start.d.ts +54 -0
- package/dist/demo/demo-start.js +68 -0
- package/dist/demo/demo-start.js.map +1 -0
- package/dist/feedback/feedback-attachment.d.ts +5 -1
- package/dist/feedback/feedback-context.d.ts +5 -1
- package/dist/feedback/feedback-crash.d.ts +5 -1
- package/dist/feedback/feedback-dialog.d.ts +5 -1
- package/dist/feedback/feedback-inbox.d.ts +5 -1
- package/dist/feedback/feedback-inbox.js +12 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-labels.d.ts +5 -1
- package/dist/feedback/feedback-labels.js +1 -0
- package/dist/feedback/feedback-labels.js.map +1 -1
- package/dist/feedback/feedback-menu.d.ts +5 -1
- package/dist/feedback/feedback-record.d.ts +5 -1
- package/dist/feedback/feedback-record.js +2 -0
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +5 -1
- package/dist/feedback/feedback-row-detail.js +7 -0
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.d.ts +5 -1
- package/dist/feedback/feedback-submit.d.ts +5 -1
- package/dist/feedback/feedback-swipe.d.ts +6 -2
- package/dist/feedback/feedback-swipe.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +5 -1
- package/dist/feedback/feedback-thread.d.ts +5 -1
- package/dist/feedback.d.ts +5 -1
- package/dist/hooks/use-file-drop.d.ts +5 -1
- package/dist/i18n/defaults.d.ts +5 -1
- package/dist/i18n/defaults.js +6 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +5 -1
- package/dist/i18n/german.js +85 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +5 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +5 -1
- package/dist/i18n/locales/de-CH.d.ts +5 -1
- package/dist/i18n/locales/en.d.ts +5 -1
- package/dist/i18n/locales/es.d.ts +5 -1
- package/dist/i18n/locales/es.js +82 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +5 -1
- package/dist/i18n/locales/fr.js +83 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +5 -1
- package/dist/i18n/locales/hu.js +83 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +5 -1
- package/dist/i18n/locales/it.js +82 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +5 -1
- package/dist/i18n/locales/zh.js +81 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +5 -1
- package/dist/i18n/review.js +15 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +25 -3
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -1
- package/dist/landing/access.d.ts +48 -0
- package/dist/landing/access.js +38 -0
- package/dist/landing/access.js.map +1 -0
- package/dist/landing/landing-actions.d.ts +140 -0
- package/dist/landing/landing-actions.js +39 -0
- package/dist/landing/landing-actions.js.map +1 -0
- package/dist/landing/landing-labels.d.ts +43 -0
- package/dist/landing/landing-labels.js +23 -0
- package/dist/landing/landing-labels.js.map +1 -0
- package/dist/landing/landing-sections.d.ts +218 -0
- package/dist/landing/landing-sections.js +167 -0
- package/dist/landing/landing-sections.js.map +1 -0
- package/dist/landing/page-seo.d.ts +99 -0
- package/dist/landing/page-seo.js +121 -0
- package/dist/landing/page-seo.js.map +1 -0
- package/dist/landing/public-header.d.ts +148 -0
- package/dist/landing/public-header.js +49 -0
- package/dist/landing/public-header.js.map +1 -0
- package/dist/landing/routing.d.ts +231 -0
- package/dist/landing/routing.js +84 -0
- package/dist/landing/routing.js.map +1 -0
- package/dist/rhf/fields.d.ts +5 -1
- package/dist/rhf/form.d.ts +5 -1
- package/dist/rhf.d.ts +5 -1
- package/dist/settings/settings-catalogue.d.ts +84 -0
- package/dist/settings/settings-catalogue.js +47 -0
- package/dist/settings/settings-catalogue.js.map +1 -0
- package/dist/settings/settings-context.d.ts +31 -0
- package/dist/settings/settings-context.js +11 -0
- package/dist/settings/settings-context.js.map +1 -0
- package/dist/settings/settings-heading.d.ts +50 -0
- package/dist/settings/settings-heading.js +27 -0
- package/dist/settings/settings-heading.js.map +1 -0
- package/dist/settings/settings-labels.d.ts +48 -0
- package/dist/settings/settings-labels.js +43 -0
- package/dist/settings/settings-labels.js.map +1 -0
- package/dist/settings/settings-layout.d.ts +77 -0
- package/dist/settings/settings-layout.js +242 -0
- package/dist/settings/settings-layout.js.map +1 -0
- package/dist/settings/settings-section.d.ts +133 -0
- package/dist/settings/settings-section.js +63 -0
- package/dist/settings/settings-section.js.map +1 -0
- package/dist/settings/use-account-language.d.ts +83 -0
- package/dist/settings/use-account-language.js +62 -0
- package/dist/settings/use-account-language.js.map +1 -0
- package/dist/settings/use-settings-focus.d.ts +34 -0
- package/dist/settings/use-settings-focus.js +77 -0
- package/dist/settings/use-settings-focus.js.map +1 -0
- package/dist/settings/use-settings-route.d.ts +118 -0
- package/dist/settings/use-settings-route.js +120 -0
- package/dist/settings/use-settings-route.js.map +1 -0
- package/dist/shell/app-shell.d.ts +11 -1
- package/dist/shell/app-shell.js +3 -2
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/top-bar-brand.d.ts +5 -1
- package/dist/shell.d.ts +15 -1
- package/dist/shell.js +56 -0
- package/dist/shell.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +5 -1
- package/dist/wizard.d.ts +5 -1
- package/package.json +2 -1
- package/src/account/data-export-setting.tsx +3 -2
- package/src/account/delete-account-setting.tsx +3 -2
- package/src/account/email-change-setting.tsx +4 -7
- package/src/account/sessions-setting.tsx +3 -2
- package/src/admin/admin-parts.ts +9 -2
- package/src/admin/invitations-panel.tsx +11 -4
- package/src/auth/auth-errors.ts +36 -5
- package/src/auth/reset-password-form.tsx +6 -2
- package/src/auth/sign-in-form.tsx +34 -3
- package/src/auth/verify-email.tsx +14 -2
- package/src/components/account-settings-labels.ts +13 -0
- package/src/components/account-settings.tsx +33 -12
- package/src/components/confirm-dialog.tsx +20 -1
- package/src/components/data-table.tsx +8 -0
- package/src/components/date-picker.tsx +9 -4
- package/src/components/passkeys-setting.tsx +2 -1
- package/src/components/settings-fields.tsx +50 -1
- package/src/demo/demo-banner.tsx +159 -0
- package/src/demo/demo-countdown.ts +141 -0
- package/src/demo/demo-ended.tsx +89 -0
- package/src/demo/demo-labels.ts +78 -0
- package/src/demo/demo-session.ts +32 -0
- package/src/demo/demo-start.tsx +150 -0
- package/src/feedback/feedback-inbox.tsx +21 -8
- package/src/feedback/feedback-labels.ts +2 -1
- package/src/feedback/feedback-record.ts +10 -7
- package/src/feedback/feedback-row-detail.tsx +28 -4
- package/src/feedback/feedback-swipe.tsx +1 -1
- package/src/i18n/defaults.ts +6 -0
- package/src/i18n/german.ts +87 -0
- package/src/i18n/kit-labels.tsx +9 -0
- package/src/i18n/locales/es.ts +84 -0
- package/src/i18n/locales/fr.ts +85 -0
- package/src/i18n/locales/hu.ts +85 -0
- package/src/i18n/locales/it.ts +84 -0
- package/src/i18n/locales/zh.ts +82 -0
- package/src/i18n/review.ts +14 -0
- package/src/index.ts +98 -1
- package/src/landing/access.ts +97 -0
- package/src/landing/landing-actions.tsx +96 -0
- package/src/landing/landing-labels.ts +59 -0
- package/src/landing/landing-sections.tsx +337 -0
- package/src/landing/page-seo.ts +251 -0
- package/src/landing/public-header.tsx +120 -0
- package/src/landing/routing.tsx +226 -0
- package/src/settings/settings-catalogue.ts +132 -0
- package/src/settings/settings-context.ts +33 -0
- package/src/settings/settings-heading.tsx +65 -0
- package/src/settings/settings-labels.ts +87 -0
- package/src/settings/settings-layout.tsx +379 -0
- package/src/settings/settings-section.tsx +108 -0
- package/src/settings/use-account-language.ts +146 -0
- package/src/settings/use-settings-focus.ts +120 -0
- package/src/settings/use-settings-route.ts +258 -0
- package/src/shell/app-shell.tsx +10 -2
- package/src/shell.ts +51 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/reset-password-form.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"./auth-errors\";\nimport { newPasswordProblem } from \"./form-rules\";\nimport { NewPasswordFields } from \"./new-password-fields\";\nimport {\n FORM_HEADING_CLASS,\n INTRO_CLASS,\n OUTCOME_CLASS,\n OutcomeMessage,\n useFocusWhen,\n useOncePerKey,\n withQuery,\n} from \"./status-parts\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the form renders — the `resetPassword` namespace. keksdose's words\n * (`auth.reset.*`), which kastlan took over. */\nexport interface ResetPasswordLabels {\n /** The heading, on every state. */\n title: string;\n /** While the link is checked. */\n checking: string;\n /** Over the fields, given the account's address (when the check returned one). */\n intro: (email: string) => string;\n newPassword: string;\n confirmPassword: string;\n /** Under the confirmation while it differs. */\n mismatch: string;\n submit: string;\n /** The new password was not saved, for a reason that is not the link. */\n failed: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** The link is unknown, spent or expired — one sentence, as the server gives one\n * code (`token_invalid`). */\n invalid: string;\n /** Under it. */\n invalidHint: string;\n /** The way forward from an invalid link: back to \"Forgot password\". */\n requestNew: string;\n /** Done. */\n success: string;\n /** Under it: a reset ends every session (§6.3). */\n sessionsEnded: string;\n /** The button out — to sign-in, with the address filled in. */\n signIn: string;\n /** 0.30.0: the save was throttled — HTTP 429 ({@link isRateLimited}) — given the\n * `Retry-After` wait in seconds, or `undefined` without one. OPTIONAL, like every key\n * added to a shipped interface; the provider's `resetPassword`, then English, fill\n * it. */\n rateLimited?: (seconds?: number) => string;\n}\n\n/** `Required`: every key, the 0.30 one included, has its English here. */\nexport const DEFAULT_RESET_PASSWORD_LABELS: Required<ResetPasswordLabels> = {\n title: \"Choose a new password\",\n checking: \"Checking the link…\",\n intro: (email) => `You’re setting a new password for ${email}.`,\n newPassword: \"New password\",\n confirmPassword: \"Repeat new password\",\n mismatch: \"The passwords don’t match.\",\n submit: \"Save password\",\n failed: \"The password could not be changed.\",\n noToken: \"This link is incomplete.\",\n invalid: \"This link is invalid or has expired.\",\n invalidHint: \"Links are valid for one hour and work only once. Just request a new one.\",\n requestNew: \"Request a new link\",\n success: \"Your password has been changed. You can sign in with it now.\",\n sessionsEnded: \"Signed-in devices were signed out — you’ll need to sign in again there.\",\n signIn: \"Go to sign in\",\n rateLimited: englishRateLimited,\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** What `onCheck` may resolve with — keksdose's `/password-reset/check` answer. */\nexport interface ResetPasswordCheck {\n /** The account's address: named over the fields (\"You're setting a new password for\n * …\") and handed to the password manager, which files the new password under it. */\n email?: string;\n /** The app's notices over the fields, shown BEFORE the password is typed — keksdose's\n * \"your account is end-to-end encrypted: this restores your sign-in, not your data\". */\n notices?: ReactNode;\n}\n\n/** What `onSubmit` hands over. */\nexport interface ResetPasswordValues {\n token: string;\n password: string;\n}\n\n/** What `onSubmit` resolves with — keksdose's `/password-reset/confirm` answer, which\n * carries no tokens (§6.3). */\nexport interface ResetPasswordResult {\n /** The account's address — the sign-in it leads to is filled in with it. */\n email: string;\n /** The app's outcomes, shown on the done state: keksdose's recovery-code notice for an\n * encrypted account, \"Your 2 personal access tokens were revoked\". */\n notices?: ReactNode;\n}\n\ntype Phase =\n | { kind: \"form\"; check: ResetPasswordCheck }\n | { kind: \"invalid\" }\n | { kind: \"done\"; result: ResetPasswordResult };\n\nexport interface ResetPasswordFormProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSubmit\" | \"children\" | \"title\"> {\n /** The link's token — the app's `?token=` (keksdose, kastlan: `/reset-password?token=…`).\n * Empty: the link was cut short, and the page says so without asking anyone. */\n token: string;\n /**\n * Check the link before the form shows (`/auth/password-reset/check`) — once per\n * token, on mount. Checking does not use it up, so a reload is free. Resolve (with\n * the address and any notices) for a live link; reject for a dead one, and the page\n * says \"This link is invalid or has expired\" with the way to a new one.\n */\n onCheck: (token: string) => Promise<ResetPasswordCheck | void | undefined>;\n /**\n * The new password was submitted: send `/auth/password-reset/confirm`. Resolve with\n * the account's address (and the app's notices) — no tokens: a reset is not a sign-in\n * (§6.3). Reject with the client's error: `token_invalid` (the link expired or was\n * used in another tab while the form was open) goes to the invalid state; anything\n * else stays on the form with the password kept.\n */\n onSubmit: (values: ResetPasswordValues) => Promise<ResetPasswordResult>;\n /** \"Go to sign in\" calls this with the address, for an app that routes in code.\n * Without it, the button is a link to `signInHref`. */\n onSignIn?: (email: string) => void;\n /** Where \"Go to sign in\" leads, with `?email=` added — read it into `SignInForm`'s\n * `defaultEmail`. Default `/login`. */\n signInHref?: string;\n /** \"Request a new link\" — the app's \"Forgot password\" page. Default\n * `/forgot-password`. */\n forgotHref?: string;\n /** The app's words for a failed save (the device offline), or `undefined` for the\n * kit's: `rateLimited` for a bare `429` (0.30.0), else `failed`. Not asked for\n * `token_invalid`, which is a state. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it\n * in `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<ResetPasswordLabels>;\n}\n\n/**\n * Redeem a password-reset link (`/reset-password?token=…`, docs/auth-harmonization.md\n * §6.3, §7) — keksdose's `ResetPasswordPage` (features/auth/reset-password-page.tsx),\n * which kastlan built its own on.\n *\n * **The link is checked first** (`onCheck`), and only then does the form appear: an\n * expired link should say so before someone types a new password twice, not after.\n *\n * **A reset is not a sign-in** (§6.3, §10.11). The confirm answers without tokens, so a\n * 2FA account cannot skip its second factor by way of its inbox, and the page ends on\n * \"Go to sign in\" with the address filled in — the person has just typed the new\n * password twice; signing in is one step. What else the reset did is said there:\n * every other session ended (the kit's line, true in all three apps), and the app's own\n * outcomes in `notices` — keksdose's recovery-code notice and its revoked API tokens.\n *\n * **The password** is chosen with the same fields as `RegisterForm` and `SignInForm`'s\n * set-password step ({@link NewPasswordFields}): the strength meter and its checklist as\n * advice, and only the two hard rules — at least 8 characters, at most 72 bytes (§8).\n * The submit waits for both and a matching confirmation.\n *\n * The form never sends a request itself (§8): the token and the password go to the\n * callbacks, and the page renders what they resolve with.\n */\nexport function ResetPasswordForm({\n token,\n onCheck,\n onSubmit,\n onSignIn,\n signInHref = \"/login\",\n forgotHref = \"/forgot-password\",\n describeError,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: ResetPasswordFormProps) {\n const labels = useKitLabels(\"resetPassword\", DEFAULT_RESET_PASSWORD_LABELS, labelsProp);\n // The phase belongs to the token it was reached with: a new token starts over at the\n // check without a reset effect.\n const [phase, setPhase] = useState<{ token: string; phase: Phase } | null>(null);\n const current: Phase | \"checking\" =\n token === \"\" ? { kind: \"invalid\" } : phase?.token === token ? phase.phase : \"checking\";\n\n useOncePerKey(token === \"\" ? null : token, onCheck, (key, result) =>\n setPhase({\n token: key,\n phase: result.ok ? { kind: \"form\", check: result.value ?? {} } : { kind: \"invalid\" },\n }),\n );\n\n const [password, setPassword] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const headingId = useId();\n const passwordRef = useRef<HTMLInputElement>(null);\n const doneRef = useRef<HTMLDivElement>(null);\n const kind = current === \"checking\" ? \"checking\" : current.kind;\n\n // The form arrives after the check: the field is where the person is going.\n useEffect(() => {\n if (kind === \"form\") passwordRef.current?.focus();\n }, [kind]);\n useFocusWhen(kind === \"done\", doneRef);\n\n const heading =\n title === null ? null : (\n <Heading id={headingId} className={FORM_HEADING_CLASS}>\n {title ?? labels.title}\n </Heading>\n );\n const rootClass = cn(\"space-y-3\", className);\n\n if (current === \"checking\") {\n return (\n <div {...rest} data-state=\"checking\" aria-busy className={rootClass}>\n {heading}\n <LoadingState size=\"sm\" label={labels.checking} />\n </div>\n );\n }\n\n if (current.kind === \"invalid\") {\n return (\n <div {...rest} data-state=\"invalid\" className={rootClass}>\n {heading}\n <EmptyState\n tone=\"danger\"\n icon={<XCircle />}\n title={token === \"\" ? labels.noToken : labels.invalid}\n hint={labels.invalidHint}\n action={\n <Button href={forgotHref} variant=\"brand\">\n {labels.requestNew}\n </Button>\n }\n className={OUTCOME_CLASS}\n />\n </div>\n );\n }\n\n if (current.kind === \"done\") {\n const { email, notices } = current.result;\n return (\n <div {...rest} data-state=\"done\" className={rootClass}>\n {heading}\n <OutcomeMessage icon={<CheckCircle2 className=\"text-[var(--success)]\" />} focusRef={doneRef}>\n <p className={INTRO_CLASS}>{labels.success}</p>\n </OutcomeMessage>\n {notices}\n <p className=\"text-xs text-[var(--text-muted)]\">{labels.sessionsEnded}</p>\n {onSignIn ? (\n <Button type=\"button\" variant=\"brand\" className=\"w-full\" onClick={() => onSignIn(email)}>\n {labels.signIn}\n </Button>\n ) : (\n <Button href={email ? withQuery(signInHref, \"email\", email) : signInHref} variant=\"brand\" className=\"w-full\">\n {labels.signIn}\n </Button>\n )}\n </div>\n );\n }\n\n const { email, notices } = current.check;\n const problem = newPasswordProblem(password, confirm);\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (pending || problem !== null) return;\n setFailure(null);\n setPending(true);\n Promise.resolve()\n .then(() => onSubmit({ token, password }))\n .then(\n (result) => {\n setPending(false);\n setPassword(\"\");\n setConfirm(\"\");\n setPhase({ token, phase: { kind: \"done\", result } });\n },\n (error: unknown) => {\n setPending(false);\n if (authErrorCode(error) === \"token_invalid\") {\n setPassword(\"\");\n setConfirm(\"\");\n setPhase({ token, phase: { kind: \"invalid\" } });\n return;\n }\n // The app's words first, then the throttle's, then the kit's catch-all.\n setFailure(\n describeError?.(error) ??\n (isRateLimited(error)\n ? (labels.rateLimited ?? DEFAULT_RESET_PASSWORD_LABELS.rateLimited)(retryAfterSeconds(error))\n : labels.failed),\n );\n },\n );\n };\n\n return (\n <div {...rest} data-state=\"form\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={title === null ? undefined : headingId} onSubmit={submit}>\n {heading}\n {email ? <p className={INTRO_CLASS}>{labels.intro(email)}</p> : null}\n {notices}\n {/* Which account the new password is for, for the password manager: it files\n the new password under this username instead of guessing (kastlan). */}\n {email ? <input type=\"email\" name=\"username\" autoComplete=\"username\" value={email} readOnly hidden /> : null}\n <NewPasswordFields\n password={password}\n confirm={confirm}\n onPasswordChange={(next) => {\n setPassword(next);\n if (failure) setFailure(null);\n }}\n onConfirmChange={setConfirm}\n busy={pending}\n passwordRef={passwordRef}\n text={{ password: labels.newPassword, confirm: labels.confirmPassword, mismatch: labels.mismatch }}\n />\n {failure != null && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!pending && problem !== null} pending={pending}>\n {labels.submit}\n </Button>\n </form>\n </div>\n );\n}\n"],"mappings":";AAgOM,cAQA,YARA;AAhON,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,cAAc,eAAe;AACtC,SAAS,UAAU;AAC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C,IAC1F,OAAO;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACJ;AAEA,SACE,oBAAC,SAAK,GAAG,MAAM,cAAW,QAAO,WAAW,WAC1C,+BAAC,UAAK,WAAU,aAAY,mBAAiB,UAAU,OAAO,SAAY,WAAW,UAAU,QAC5F;AAAA;AAAA,IACA,QAAQ,oBAAC,OAAE,WAAW,aAAc,iBAAO,MAAM,KAAK,GAAE,IAAO;AAAA,IAC/D;AAAA,IAGA,QAAQ,oBAAC,WAAM,MAAK,SAAQ,MAAK,YAAW,cAAa,YAAW,OAAO,OAAO,UAAQ,MAAC,QAAM,MAAC,IAAK;AAAA,IACxG;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,kBAAkB,CAAC,SAAS;AAC1B,sBAAY,IAAI;AAChB,cAAI,QAAS,YAAW,IAAI;AAAA,QAC9B;AAAA,QACA,iBAAiB;AAAA,QACjB,MAAM;AAAA,QACN;AAAA,QACA,MAAM,EAAE,UAAU,OAAO,aAAa,SAAS,OAAO,iBAAiB,UAAU,OAAO,SAAS;AAAA;AAAA,IACnG;AAAA,IACC,WAAW,QACV,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,IAEF,oBAAC,UAAO,MAAK,UAAS,WAAU,UAAS,UAAU,CAAC,WAAW,YAAY,MAAM,SAC9E,iBAAO,QACV;AAAA,KACF,GACF;AAEJ;","names":["email","notices"]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/reset-password-form.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { CheckCircle2, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"./auth-errors\";\nimport { newPasswordProblem } from \"./form-rules\";\nimport { NewPasswordFields } from \"./new-password-fields\";\nimport {\n FORM_HEADING_CLASS,\n INTRO_CLASS,\n OUTCOME_CLASS,\n OutcomeMessage,\n useFocusWhen,\n useOncePerKey,\n withQuery,\n} from \"./status-parts\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the form renders — the `resetPassword` namespace. keksdose's words\n * (`auth.reset.*`), which kastlan took over. */\nexport interface ResetPasswordLabels {\n /** The heading, on every state. */\n title: string;\n /** While the link is checked. */\n checking: string;\n /** Over the fields, given the account's address (when the check returned one). */\n intro: (email: string) => string;\n newPassword: string;\n confirmPassword: string;\n /** Under the confirmation while it differs. */\n mismatch: string;\n submit: string;\n /** The new password was not saved, for a reason that is not the link. */\n failed: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** The link is unknown, spent or expired — one sentence, as the server gives one\n * code (`token_invalid`). */\n invalid: string;\n /** Under it. */\n invalidHint: string;\n /** The way forward from an invalid link: back to \"Forgot password\". */\n requestNew: string;\n /** Done. */\n success: string;\n /** Under it: a reset ends every session (§6.3). */\n sessionsEnded: string;\n /** The button out — to sign-in, with the address filled in. */\n signIn: string;\n /** 0.30.0: the save was throttled — HTTP 429 ({@link isRateLimited}) — given the\n * `Retry-After` wait in seconds, or `undefined` without one. OPTIONAL, like every key\n * added to a shipped interface; the provider's `resetPassword`, then English, fill\n * it. */\n rateLimited?: (seconds?: number) => string;\n}\n\n/** `Required`: every key, the 0.30 one included, has its English here. */\nexport const DEFAULT_RESET_PASSWORD_LABELS: Required<ResetPasswordLabels> = {\n title: \"Choose a new password\",\n checking: \"Checking the link…\",\n intro: (email) => `You’re setting a new password for ${email}.`,\n newPassword: \"New password\",\n confirmPassword: \"Repeat new password\",\n mismatch: \"The passwords don’t match.\",\n submit: \"Save password\",\n failed: \"The password could not be changed.\",\n noToken: \"This link is incomplete.\",\n invalid: \"This link is invalid or has expired.\",\n invalidHint: \"Links are valid for one hour and work only once. Just request a new one.\",\n requestNew: \"Request a new link\",\n success: \"Your password has been changed. You can sign in with it now.\",\n sessionsEnded: \"Signed-in devices were signed out — you’ll need to sign in again there.\",\n signIn: \"Go to sign in\",\n rateLimited: englishRateLimited,\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** What `onCheck` may resolve with — keksdose's `/password-reset/check` answer. */\nexport interface ResetPasswordCheck {\n /** The account's address: named over the fields (\"You're setting a new password for\n * …\") and handed to the password manager, which files the new password under it. */\n email?: string;\n /** The app's notices over the fields, shown BEFORE the password is typed — keksdose's\n * \"your account is end-to-end encrypted: this restores your sign-in, not your data\". */\n notices?: ReactNode;\n}\n\n/** What `onSubmit` hands over. */\nexport interface ResetPasswordValues {\n token: string;\n password: string;\n}\n\n/** What `onSubmit` resolves with — keksdose's `/password-reset/confirm` answer, which\n * carries no tokens (§6.3). */\nexport interface ResetPasswordResult {\n /** The account's address — the sign-in it leads to is filled in with it. */\n email: string;\n /** The app's outcomes, shown on the done state: keksdose's recovery-code notice for an\n * encrypted account, \"Your 2 personal access tokens were revoked\". */\n notices?: ReactNode;\n}\n\ntype Phase =\n | { kind: \"form\"; check: ResetPasswordCheck }\n | { kind: \"invalid\" }\n | { kind: \"done\"; result: ResetPasswordResult };\n\nexport interface ResetPasswordFormProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSubmit\" | \"children\" | \"title\"> {\n /** The link's token — the app's `?token=` (keksdose, kastlan: `/reset-password?token=…`).\n * Empty: the link was cut short, and the page says so without asking anyone. */\n token: string;\n /**\n * Check the link before the form shows (`/auth/password-reset/check`) — once per\n * token, on mount. Checking does not use it up, so a reload is free. Resolve (with\n * the address and any notices) for a live link; reject for a dead one, and the page\n * says \"This link is invalid or has expired\" with the way to a new one.\n */\n onCheck: (token: string) => Promise<ResetPasswordCheck | void | undefined>;\n /**\n * The new password was submitted: send `/auth/password-reset/confirm`. Resolve with\n * the account's address (and the app's notices) — no tokens: a reset is not a sign-in\n * (§6.3). Reject with the client's error: `token_invalid` (the link expired or was\n * used in another tab while the form was open) goes to the invalid state; anything\n * else stays on the form with the password kept.\n */\n onSubmit: (values: ResetPasswordValues) => Promise<ResetPasswordResult>;\n /** \"Go to sign in\" calls this with the address, for an app that routes in code.\n * Without it, the button is a link to `signInHref`. */\n onSignIn?: (email: string) => void;\n /** Where \"Go to sign in\" leads, with `?email=` added — read it into `SignInForm`'s\n * `defaultEmail`. Default `/login`. */\n signInHref?: string;\n /** \"Request a new link\" — the app's \"Forgot password\" page. Default\n * `/forgot-password`. */\n forgotHref?: string;\n /** The app's words for a failed save (the device offline), or `undefined` for the\n * kit's: `rateLimited` for a bare `429` (0.30.0), else `failed`. Not asked for\n * `token_invalid` or `token_expired`, which are a state. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it\n * in `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<ResetPasswordLabels>;\n}\n\n/**\n * Redeem a password-reset link (`/reset-password?token=…`, docs/auth-harmonization.md\n * §6.3, §7) — keksdose's `ResetPasswordPage` (features/auth/reset-password-page.tsx),\n * which kastlan built its own on.\n *\n * **The link is checked first** (`onCheck`), and only then does the form appear: an\n * expired link should say so before someone types a new password twice, not after.\n *\n * **A reset is not a sign-in** (§6.3, §10.11). The confirm answers without tokens, so a\n * 2FA account cannot skip its second factor by way of its inbox, and the page ends on\n * \"Go to sign in\" with the address filled in — the person has just typed the new\n * password twice; signing in is one step. What else the reset did is said there:\n * every other session ended (the kit's line, true in all three apps), and the app's own\n * outcomes in `notices` — keksdose's recovery-code notice and its revoked API tokens.\n *\n * **The password** is chosen with the same fields as `RegisterForm` and `SignInForm`'s\n * set-password step ({@link NewPasswordFields}): the strength meter and its checklist as\n * advice, and only the two hard rules — at least 8 characters, at most 72 bytes (§8).\n * The submit waits for both and a matching confirmation.\n *\n * The form never sends a request itself (§8): the token and the password go to the\n * callbacks, and the page renders what they resolve with.\n */\nexport function ResetPasswordForm({\n token,\n onCheck,\n onSubmit,\n onSignIn,\n signInHref = \"/login\",\n forgotHref = \"/forgot-password\",\n describeError,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: ResetPasswordFormProps) {\n const labels = useKitLabels(\"resetPassword\", DEFAULT_RESET_PASSWORD_LABELS, labelsProp);\n // The phase belongs to the token it was reached with: a new token starts over at the\n // check without a reset effect.\n const [phase, setPhase] = useState<{ token: string; phase: Phase } | null>(null);\n const current: Phase | \"checking\" =\n token === \"\" ? { kind: \"invalid\" } : phase?.token === token ? phase.phase : \"checking\";\n\n useOncePerKey(token === \"\" ? null : token, onCheck, (key, result) =>\n setPhase({\n token: key,\n phase: result.ok ? { kind: \"form\", check: result.value ?? {} } : { kind: \"invalid\" },\n }),\n );\n\n const [password, setPassword] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const headingId = useId();\n const passwordRef = useRef<HTMLInputElement>(null);\n const doneRef = useRef<HTMLDivElement>(null);\n const kind = current === \"checking\" ? \"checking\" : current.kind;\n\n // The form arrives after the check: the field is where the person is going.\n useEffect(() => {\n if (kind === \"form\") passwordRef.current?.focus();\n }, [kind]);\n useFocusWhen(kind === \"done\", doneRef);\n\n const heading =\n title === null ? null : (\n <Heading id={headingId} className={FORM_HEADING_CLASS}>\n {title ?? labels.title}\n </Heading>\n );\n const rootClass = cn(\"space-y-3\", className);\n\n if (current === \"checking\") {\n return (\n <div {...rest} data-state=\"checking\" aria-busy className={rootClass}>\n {heading}\n <LoadingState size=\"sm\" label={labels.checking} />\n </div>\n );\n }\n\n if (current.kind === \"invalid\") {\n return (\n <div {...rest} data-state=\"invalid\" className={rootClass}>\n {heading}\n <EmptyState\n tone=\"danger\"\n icon={<XCircle />}\n title={token === \"\" ? labels.noToken : labels.invalid}\n hint={labels.invalidHint}\n action={\n <Button href={forgotHref} variant=\"brand\">\n {labels.requestNew}\n </Button>\n }\n className={OUTCOME_CLASS}\n />\n </div>\n );\n }\n\n if (current.kind === \"done\") {\n const { email, notices } = current.result;\n return (\n <div {...rest} data-state=\"done\" className={rootClass}>\n {heading}\n <OutcomeMessage icon={<CheckCircle2 className=\"text-[var(--success)]\" />} focusRef={doneRef}>\n <p className={INTRO_CLASS}>{labels.success}</p>\n </OutcomeMessage>\n {notices}\n <p className=\"text-xs text-[var(--text-muted)]\">{labels.sessionsEnded}</p>\n {onSignIn ? (\n <Button type=\"button\" variant=\"brand\" className=\"w-full\" onClick={() => onSignIn(email)}>\n {labels.signIn}\n </Button>\n ) : (\n <Button href={email ? withQuery(signInHref, \"email\", email) : signInHref} variant=\"brand\" className=\"w-full\">\n {labels.signIn}\n </Button>\n )}\n </div>\n );\n }\n\n const { email, notices } = current.check;\n const problem = newPasswordProblem(password, confirm);\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (pending || problem !== null) return;\n setFailure(null);\n setPending(true);\n Promise.resolve()\n .then(() => onSubmit({ token, password }))\n .then(\n (result) => {\n setPending(false);\n setPassword(\"\");\n setConfirm(\"\");\n setPhase({ token, phase: { kind: \"done\", result } });\n },\n (error: unknown) => {\n setPending(false);\n // A link that died between the check and the save — used, or run out — is the\n // dead-link state, under either code (0.31.1: keksdose mapped `token_expired`\n // to it itself, `asDeadLink`).\n const code = authErrorCode(error);\n if (code === \"token_invalid\" || code === \"token_expired\") {\n setPassword(\"\");\n setConfirm(\"\");\n setPhase({ token, phase: { kind: \"invalid\" } });\n return;\n }\n // The app's words first, then the throttle's, then the kit's catch-all.\n setFailure(\n describeError?.(error) ??\n (isRateLimited(error)\n ? (labels.rateLimited ?? DEFAULT_RESET_PASSWORD_LABELS.rateLimited)(retryAfterSeconds(error))\n : labels.failed),\n );\n },\n );\n };\n\n return (\n <div {...rest} data-state=\"form\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={title === null ? undefined : headingId} onSubmit={submit}>\n {heading}\n {email ? <p className={INTRO_CLASS}>{labels.intro(email)}</p> : null}\n {notices}\n {/* Which account the new password is for, for the password manager: it files\n the new password under this username instead of guessing (kastlan). */}\n {email ? <input type=\"email\" name=\"username\" autoComplete=\"username\" value={email} readOnly hidden /> : null}\n <NewPasswordFields\n password={password}\n confirm={confirm}\n onPasswordChange={(next) => {\n setPassword(next);\n if (failure) setFailure(null);\n }}\n onConfirmChange={setConfirm}\n busy={pending}\n passwordRef={passwordRef}\n text={{ password: labels.newPassword, confirm: labels.confirmPassword, mismatch: labels.mismatch }}\n />\n {failure != null && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!pending && problem !== null} pending={pending}>\n {labels.submit}\n </Button>\n </form>\n </div>\n );\n}\n"],"mappings":";AAgOM,cAQA,YARA;AAhON,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,cAAc,eAAe;AACtC,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAkB;AACnC,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AACpF,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4CA,MAAM,gCAA+D;AAAA,EAC1E,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO,CAAC,UAAU,0CAAqC,KAAK;AAAA,EAC5D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aA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AC,SAAS;AAC1B,sBAAY,IAAI;AAChB,cAAI,QAAS,YAAW,IAAI;AAAA,QAC9B;AAAA,QACA,iBAAiB;AAAA,QACjB,MAAM;AAAA,QACN;AAAA,QACA,MAAM,EAAE,UAAU,OAAO,aAAa,SAAS,OAAO,iBAAiB,UAAU,OAAO,SAAS;AAAA;AAAA,IACnG;AAAA,IACC,WAAW,QACV,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,mBACH;AAAA,IAEF,oBAAC,UAAO,MAAK,UAAS,WAAU,UAAS,UAAU,CAAC,WAAW,YAAY,MAAM,SAC9E,iBAAO,QACV;AAAA,KACF,GACF;AAEJ;","names":["email","notices"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { AccessChoice } from '../landing/access.js';
|
|
4
|
+
import '../landing/landing-labels.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* What a sign-in call answers, in the kit's words — docs/auth-harmonization.md §5.1,
|
|
@@ -142,6 +144,9 @@ interface SignInLabels {
|
|
|
142
144
|
* wait its `Retry-After` asks for, in seconds ({@link retryAfterSeconds}), or
|
|
143
145
|
* `undefined` (or `0`) without one. */
|
|
144
146
|
rateLimited?: (seconds?: number) => string;
|
|
147
|
+
/** 0.31.0: the link after `noAccount` for an invitation-only app (`access` of kind
|
|
148
|
+
* `request`) — a mail to support, in place of `register`. */
|
|
149
|
+
requestAccess?: string;
|
|
145
150
|
}
|
|
146
151
|
/** `Required`: every key, the 0.30 ones included, has its English here. */
|
|
147
152
|
declare const DEFAULT_SIGN_IN_LABELS: Required<SignInLabels>;
|
|
@@ -185,6 +190,15 @@ interface SignInFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmi
|
|
|
185
190
|
forgotHref?: string;
|
|
186
191
|
/** "No account yet? Create account" goes here — `/register`. Left out, no line. */
|
|
187
192
|
registerHref?: string;
|
|
193
|
+
/**
|
|
194
|
+
* 0.31.0 (docs/landing-demo-harmonization.md §4.2): how a visitor gets an account —
|
|
195
|
+
* the same value the landing's `PublicHeader` and `Hero` take. `{kind: "request",
|
|
196
|
+
* email}` turns the line into "No account yet? Request access", a mail to support with
|
|
197
|
+
* the subject and body of `accessAction` (every app is invitation-only); `{kind:
|
|
198
|
+
* "register", href}` keeps "Create account", to `href`. Wins over `registerHref`; left
|
|
199
|
+
* out, `registerHref` works as before.
|
|
200
|
+
*/
|
|
201
|
+
access?: AccessChoice;
|
|
188
202
|
/** The email field's start value — the reset page ends on "Sign in" with the address
|
|
189
203
|
* filled in (§6.3). */
|
|
190
204
|
defaultEmail?: string;
|
|
@@ -290,6 +304,6 @@ interface SignInFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmi
|
|
|
290
304
|
* The password is dropped from state once the credentials are answered; "Back to sign in"
|
|
291
305
|
* returns to an empty password field.
|
|
292
306
|
*/
|
|
293
|
-
declare function SignInForm({ onSubmit, onCode, onSetPassword, onPasskey, passkeyAutofill, forgotHref, registerHref, defaultEmail, emailTag, deactivatedContact, codeLength, recoveryCode, credentialsContent, twoFactorContent, passwordChangeContent, describeError, onStepChange, headingAs: Heading, labels: labelsProp, className, ...rest }: SignInFormProps): react.JSX.Element;
|
|
307
|
+
declare function SignInForm({ onSubmit, onCode, onSetPassword, onPasskey, passkeyAutofill, forgotHref, registerHref, access, defaultEmail, emailTag, deactivatedContact, codeLength, recoveryCode, credentialsContent, twoFactorContent, passwordChangeContent, describeError, onStepChange, headingAs: Heading, labels: labelsProp, className, ...rest }: SignInFormProps): react.JSX.Element;
|
|
294
308
|
|
|
295
309
|
export { DEFAULT_SIGN_IN_LABELS, type SignInAction, type SignInAnswer, type SignInCodeValues, type SignInCredentials, SignInForm, type SignInFormProps, type SignInLabels, type SignInNewPasswordValues, type SignInStep };
|
|
@@ -10,6 +10,8 @@ import { CurrentPasswordInput } from "../components/danger-confirm.js";
|
|
|
10
10
|
import { OneTimeCodeInput } from "../components/one-time-code-input.js";
|
|
11
11
|
import { TextLink } from "../components/text-link.js";
|
|
12
12
|
import { Button, Input } from "../components/ui.js";
|
|
13
|
+
import { accessAction } from "../landing/access.js";
|
|
14
|
+
import { useLandingLabels } from "../landing/landing-labels.js";
|
|
13
15
|
import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "./auth-errors.js";
|
|
14
16
|
import { taggedEmail } from "./email-tag.js";
|
|
15
17
|
import { newPasswordProblem } from "./form-rules.js";
|
|
@@ -47,7 +49,8 @@ const DEFAULT_SIGN_IN_LABELS = {
|
|
|
47
49
|
recoveryIntro: "Enter one of the backup codes you saved when you turned on two-factor authentication.",
|
|
48
50
|
recoveryCodeHint: (length) => `${length} letters and digits. Dashes and spaces don\u2019t matter.`,
|
|
49
51
|
recoveryCodeInvalid: "This backup code is not valid, or it has been used already.",
|
|
50
|
-
rateLimited: englishRateLimited
|
|
52
|
+
rateLimited: englishRateLimited,
|
|
53
|
+
requestAccess: "Request access"
|
|
51
54
|
};
|
|
52
55
|
function withContact(template, contact) {
|
|
53
56
|
const node = typeof contact === "string" && contact.includes("@") ? /* @__PURE__ */ jsx(TextLink, { href: `mailto:${contact}`, tone: "secondary", children: contact }, "contact") : /* @__PURE__ */ jsx("span", { children: contact }, "contact");
|
|
@@ -68,6 +71,7 @@ function SignInForm({
|
|
|
68
71
|
passkeyAutofill,
|
|
69
72
|
forgotHref,
|
|
70
73
|
registerHref,
|
|
74
|
+
access,
|
|
71
75
|
defaultEmail = "",
|
|
72
76
|
emailTag,
|
|
73
77
|
deactivatedContact,
|
|
@@ -84,6 +88,11 @@ function SignInForm({
|
|
|
84
88
|
...rest
|
|
85
89
|
}) {
|
|
86
90
|
const labels = useKitLabels("signIn", DEFAULT_SIGN_IN_LABELS, labelsProp);
|
|
91
|
+
const landing = useLandingLabels();
|
|
92
|
+
const accountLink = access === void 0 ? registerHref === void 0 ? null : { href: registerHref, label: labels.register } : access.kind === "register" ? { href: access.href, label: labels.register } : {
|
|
93
|
+
href: accessAction(access, landing).href,
|
|
94
|
+
label: labels.requestAccess ?? DEFAULT_SIGN_IN_LABELS.requestAccess
|
|
95
|
+
};
|
|
87
96
|
const [step, setStep] = useState("credentials");
|
|
88
97
|
const [email, setEmail] = useState(defaultEmail);
|
|
89
98
|
const [password, setPassword] = useState("");
|
|
@@ -409,10 +418,10 @@ function SignInForm({
|
|
|
409
418
|
)
|
|
410
419
|
] }),
|
|
411
420
|
forgotHref !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-center text-sm", children: /* @__PURE__ */ jsx(TextLink, { href: forgotHref, tone: "secondary", children: labels.forgotPassword }) }),
|
|
412
|
-
|
|
421
|
+
accountLink !== null && /* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-[var(--text-secondary)]", children: [
|
|
413
422
|
labels.noAccount,
|
|
414
423
|
" ",
|
|
415
|
-
/* @__PURE__ */ jsx(TextLink, { href:
|
|
424
|
+
/* @__PURE__ */ jsx(TextLink, { href: accountLink.href, tone: "primary", children: accountLink.label })
|
|
416
425
|
] })
|
|
417
426
|
] });
|
|
418
427
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/sign-in-form.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { KeyRound } from \"lucide-react\";\n\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { CurrentPasswordInput } from \"../components/danger-confirm\";\nimport { OneTimeCodeInput } from \"../components/one-time-code-input\";\nimport { TextLink } from \"../components/text-link\";\nimport { Button, Input } from \"../components/ui\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"./auth-errors\";\nimport type { KitErrorCode } from \"./auth-errors\";\nimport { taggedEmail } from \"./email-tag\";\nimport { newPasswordProblem } from \"./form-rules\";\nimport { NewPasswordFields } from \"./new-password-fields\";\n\n/* ── The answers (§5.1) ──────────────────────────────────────────────────── */\n\n/**\n * What a sign-in call answers, in the kit's words — docs/auth-harmonization.md §5.1,\n * keksdose's three shapes. The app maps its own HTTP answer to one of these and resolves\n * with it; a refusal REJECTS (with whatever its client throws — {@link authErrorCode}\n * reads the code out of it).\n *\n * | the server answers (keksdose) | resolve with |\n * |---|---|\n * | `TokenResponse` `{access_token, refresh_token, token_type, user}` | `{ kind: \"signed-in\" }`, after the app has stored the session |\n * | `{requires_2fa: true, challenge_token}` | `{ kind: \"2fa\", challengeToken: challenge_token }` |\n * | `{requires_password_change: true, challenge_token, encrypted}` | `{ kind: \"password-change\", challengeToken: challenge_token, extra: { encrypted } }` |\n * | `401 {code: \"invalid_credentials\"}` | reject — let the client's error through |\n *\n * ```ts\n * async function toAnswer(res: TokenResponse | TwoFactorChallenge | PasswordChangeChallenge): Promise<SignInAnswer> {\n * if (\"requires_2fa\" in res) return { kind: \"2fa\", challengeToken: res.challenge_token };\n * if (\"requires_password_change\" in res)\n * return { kind: \"password-change\", challengeToken: res.challenge_token, extra: { encrypted: res.encrypted } };\n * await onLoginSuccess(res); // store tokens, load /auth/me, switch language\n * return { kind: \"signed-in\" };\n * }\n * <SignInForm onSubmit={async (v) => toAnswer(await authApi.login(v))} … />\n * ```\n *\n * The same mapping serves `/auth/login/2fa`, `/auth/login/set-password` and the passkey\n * finish, which answer the same union.\n */\nexport type SignInAnswer =\n | { kind: \"signed-in\" }\n | { kind: \"2fa\"; challengeToken: string }\n | {\n kind: \"password-change\";\n challengeToken: string;\n /** The challenge's app fields, passed through untouched — keksdose's `encrypted`,\n * which its note on this step reads (`passwordChangeContent`). */\n extra?: Readonly<Record<string, unknown>>;\n };\n\n/** The step on screen: the credentials, the second factor, or a new password. */\nexport type SignInStep = \"credentials\" | \"2fa\" | \"password-change\";\n\n/** What the person did when a call failed — {@link SignInFormProps.describeError}'s\n * second argument. */\nexport type SignInAction = \"password\" | \"passkey\" | \"code\" | \"set-password\";\n\nexport interface SignInCredentials {\n /** Trimmed. Lower-casing is the server's (§3.1). */\n email: string;\n /** As typed, never trimmed. */\n password: string;\n}\n\nexport interface SignInCodeValues {\n challengeToken: string;\n /** Digits only — {@link OneTimeCodeInput} drops the spaces of \"123 456\". A backup code\n * (`kind: \"recovery\"`) is trimmed and otherwise as typed: its dashes and case are the\n * server's to normalise, as kastlan's `_normalise_backup_code` does. */\n code: string;\n /**\n * 0.30.0: `\"recovery\"` when the person typed one of their backup codes instead\n * (`recoveryCode`); absent for the authenticator's code, as before. kastlan's\n * `/auth/login/2fa` takes either in the same `code` and tells them apart itself; an\n * app whose server takes a backup code elsewhere routes on this.\n */\n kind?: \"recovery\";\n}\n\nexport interface SignInNewPasswordValues {\n challengeToken: string;\n password: string;\n}\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/**\n * Every string `SignInForm` renders — the `signIn` namespace of `<UiKitProvider\n * labels>`, overridable per instance through `labels`. keksdose's words where it has\n * them (`auth.*` in its catalogue).\n */\nexport interface SignInLabels {\n email: string;\n password: string;\n /** The submit button. */\n submit: string;\n /** The passkey button (`onPasskey`). */\n passkey: string;\n /** The link to `forgotHref`. */\n forgotPassword: string;\n /** Before the link to `registerHref`. */\n noAccount: string;\n /** The link to `registerHref`. */\n register: string;\n /** The ONE answer to an unknown address, a wrong password and a deactivated account\n * (`invalid_credentials`, §5.2). */\n invalidCredentials: string;\n /** Any other failed sign-in (the network, a 500). */\n failed: string;\n /** A failed or refused passkey sign-in. */\n passkeyFailed: string;\n /**\n * The hint under `invalidCredentials` (§2.10), shown when `deactivatedContact` is\n * given. A TEMPLATE: `{contact}` is replaced by the contact — a `mailto:` link for an\n * address — so a language puts it where its grammar needs it.\n */\n deactivatedHint: string;\n /** The hint under `invalidCredentials` when `emailTag` is given (§4.5), given the\n * typed address with the app's tag: \"Signed up with ada+kastlan@example.com?\". */\n tagHint: (taggedAddress: string) => string;\n /** The second-factor step's heading. */\n twoFactorTitle: string;\n twoFactorIntro: string;\n /** The code field's label. */\n code: string;\n /** The code step's submit button. */\n verify: string;\n /** The code was refused. */\n codeInvalid: string;\n /** The set-a-new-password step's heading. */\n setPasswordTitle: string;\n setPasswordIntro: string;\n newPassword: string;\n confirmPassword: string;\n passwordMismatch: string;\n /** The set-a-new-password step's submit button. */\n setPasswordSubmit: string;\n setPasswordFailed: string;\n /** A challenge was refused as `token_invalid` — it expired between the steps; the\n * form is back on the credentials. */\n expired: string;\n /** From the second and third step back to the credentials. */\n backToSignIn: string;\n /*\n * 0.30.0 — OPTIONAL, like `TwoFactorSettingLabels.qrAlt` and for its reason: a new\n * required key is a compile error at every call site that annotates this interface\n * (CONTRIBUTING's additive-API rule). Each falls back to the provider's `signIn`, then\n * English.\n */\n /** The second-factor step's switch to a backup code (`recoveryCode`). */\n useRecoveryCode?: string;\n /** The switch back, from the backup-code field to the authenticator's code. */\n useAuthenticatorCode?: string;\n /** The backup-code field's label. */\n recoveryCode?: string;\n /** The step's intro while a backup code is asked for, in place of `twoFactorIntro`. */\n recoveryIntro?: string;\n /** Under the backup-code field, given how many letters and digits a code has. */\n recoveryCodeHint?: (length: number) => string;\n /** A refused backup code — wrong, or spent already (each one works once). */\n recoveryCodeInvalid?: string;\n /** Any step's request was throttled — HTTP 429 ({@link isRateLimited}) — given the\n * wait its `Retry-After` asks for, in seconds ({@link retryAfterSeconds}), or\n * `undefined` (or `0`) without one. */\n rateLimited?: (seconds?: number) => string;\n}\n\n/** `Required`: every key, the 0.30 ones included, has its English here. */\nexport const DEFAULT_SIGN_IN_LABELS: Required<SignInLabels> = {\n email: \"Email\",\n password: \"Password\",\n submit: \"Sign in\",\n passkey: \"Sign in with a passkey\",\n forgotPassword: \"Forgot your password?\",\n noAccount: \"No account yet?\",\n register: \"Create account\",\n invalidCredentials: \"The email or password is incorrect.\",\n failed: \"Sign-in failed. Please try again.\",\n passkeyFailed: \"Passkey sign-in failed.\",\n deactivatedHint: \"Account deactivated? Write to {contact}.\",\n tagHint: (taggedAddress) => `Signed up with ${taggedAddress}? Use that address.`,\n twoFactorTitle: \"Two-factor authentication\",\n twoFactorIntro: \"Enter the code your authenticator app shows.\",\n code: \"2FA code\",\n verify: \"Verify\",\n codeInvalid: \"Invalid 2FA code.\",\n setPasswordTitle: \"Choose a new password\",\n setPasswordIntro: \"A new password was requested for this account. Choose one and you are straight back in.\",\n newPassword: \"New password\",\n confirmPassword: \"Repeat new password\",\n passwordMismatch: \"The passwords don't match.\",\n setPasswordSubmit: \"Set password and sign in\",\n setPasswordFailed: \"The password could not be set.\",\n expired: \"This sign-in has expired. Please sign in again.\",\n backToSignIn: \"Back to sign in\",\n useRecoveryCode: \"Use a backup code\",\n useAuthenticatorCode: \"Use your authenticator app\",\n recoveryCode: \"Backup code\",\n recoveryIntro: \"Enter one of the backup codes you saved when you turned on two-factor authentication.\",\n recoveryCodeHint: (length) => `${length} letters and digits. Dashes and spaces don’t matter.`,\n recoveryCodeInvalid: \"This backup code is not valid, or it has been used already.\",\n rateLimited: englishRateLimited,\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\nexport interface SignInFormProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSubmit\" | \"children\"> {\n /**\n * The credentials step was submitted. Send them, and resolve with the answer\n * ({@link SignInAnswer}) or reject with the client's error. The form never sends a\n * request itself (§8): keksdose must see the password on its way, to refuse the same\n * string as an encryption passphrase later.\n *\n * On `signed-in` the form's job is over — it stays busy while the app navigates.\n */\n onSubmit: (credentials: SignInCredentials) => Promise<SignInAnswer>;\n /** The second factor was submitted (`/auth/login/2fa`). Resolves with the next answer\n * — keksdose may still require a new password after the code. */\n onCode: (values: SignInCodeValues) => Promise<SignInAnswer>;\n /** The new password was submitted (`/auth/login/set-password`). Resolves with the\n * answer, `signed-in` in practice; keksdose's `key_wrap_unchanged` note is the app's\n * to show from here. */\n onSetPassword: (values: SignInNewPasswordValues) => Promise<SignInAnswer>;\n /**\n * The passkey button was pressed: run the ceremony (`/auth/passkey/login/begin|finish`)\n * and resolve with its answer. It asks for NO email — a passkey is bound to the site,\n * and the browser offers every one it holds (keksdose #126). Left out, no button: pass\n * it only where `PublicKeyCredential` exists.\n */\n onPasskey?: () => Promise<SignInAnswer>;\n /**\n * Passkey autofill (conditional mediation). The email field is\n * `autoComplete=\"username webauthn\"`, so a pending `navigator.credentials.get({\n * mediation: \"conditional\" })` lists the site's passkeys in its dropdown. The form\n * calls this ONCE on mount; arm the request there and resolve with its answer when the\n * person picks a passkey, or with `null` when nothing happens. The signal aborts on\n * unmount — cancel the pending request then (keksdose: `armPasskeyAutofill(onDone,\n * signal)` + `cancelPasskeyAutofill()`). A rejection is silent: the button stays the\n * reliable path.\n */\n passkeyAutofill?: (signal: AbortSignal) => Promise<SignInAnswer | null | undefined>;\n /** \"Forgot your password?\" goes here — the app's `/forgot-password`. Left out, no\n * link. */\n forgotHref?: string;\n /** \"No account yet? Create account\" goes here — `/register`. Left out, no line. */\n registerHref?: string;\n /** The email field's start value — the reset page ends on \"Sign in\" with the address\n * filled in (§6.3). */\n defaultEmail?: string;\n /**\n * The app's address tag (`\"kastlan\"`, §4.5). After `invalid_credentials` the form also\n * says \"Signed up with you+kastlan@example.com? Use that address.\" — sign-in stays\n * exact, and the server looks nothing up.\n */\n emailTag?: string;\n /**\n * Who a deactivated user writes to (§2.10): an address (drawn as a `mailto:` link) or\n * the app's own node. Shown after `invalid_credentials` as \"Account deactivated? Write\n * to …\". Left out, no hint.\n */\n deactivatedContact?: ReactNode;\n /** Digits of the second factor. Default 6 (TOTP). */\n codeLength?: number;\n /**\n * 0.30.0: offer a backup code on the second-factor step (kastlan's 0.29 adoption: its\n * `/auth/login/2fa` takes one of the eight codes minted at 2FA setup, and the kit's\n * step had no way to type one). A \"Use a backup code\" switch under the code field\n * swaps the digits-only {@link OneTimeCodeInput} for a plain text field; the code goes\n * to `onCode` with the same challenge and `kind: \"recovery\"`.\n *\n * `true` for a 16-character code (kastlan's `ABCD-EFGH-JKLM-NPQR`), or `{ length }`.\n * The length counts letters and digits only — the dashes and spaces a printed code is\n * grouped with don't count — and \"Verify\" waits for it. Left out, no switch.\n */\n recoveryCode?: boolean | { length?: number };\n /** App content at the top of the credentials step — a notice, a demo button. */\n credentialsContent?: ReactNode;\n /**\n * App content on the second-factor step, under its intro. 0.30.0: pass a function and\n * it gets the challenge token — kastlan kept its own copy of the token for a \"lost\n * your device?\" link, which the step now hands over.\n */\n twoFactorContent?: ReactNode | ((challengeToken: string) => ReactNode);\n /**\n * App content on the set-a-new-password step, under its intro — keksdose's\n * private-mode note (\"Your encrypted data is untouched …\"), which depends on the\n * challenge: pass a function and it gets the challenge's `extra`.\n */\n passwordChangeContent?: ReactNode | ((extra: Readonly<Record<string, unknown>> | undefined) => ReactNode);\n /**\n * The app's own words for a failure, or `undefined` for the kit's: the device being\n * offline, a throttle with its wait (\"try again in an hour\"). Asked first, for every\n * failure; what it returns replaces the message, and the `invalid_credentials` hints\n * still follow. A bare `429` needs none since 0.30.0: the kit says `rateLimited`.\n */\n describeError?: (error: unknown, action: SignInAction) => ReactNode | undefined;\n /** The step changed — retitle the page (`AuthLayout`'s `title`) if the app wants. */\n onStepChange?: (step: SignInStep) => void;\n /** The level of the second and third step's heading. Default `h2`, under the page's\n * `h1`; one level under `AuthLayout`'s `headingAs` where that is embedded lower. */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n labels?: Partial<SignInLabels>;\n}\n\n/* ── Parts ───────────────────────────────────────────────────────────────── */\n\ninterface Failure {\n action: SignInAction;\n code: KitErrorCode | undefined;\n message: ReactNode;\n /** The address the failed credentials carried — the tag hint names its tagged form. */\n email?: string;\n}\n\n/** `{contact}` in the template, replaced by the contact (a `mailto:` link for an\n * address). Split, not interpolated, so the link is an element. A template that lost\n * its placeholder still shows the contact, after it. */\nfunction withContact(template: string, contact: ReactNode): ReactNode[] {\n const node =\n typeof contact === \"string\" && contact.includes(\"@\") ? (\n <TextLink key=\"contact\" href={`mailto:${contact}`} tone=\"secondary\">\n {contact}\n </TextLink>\n ) : (\n <span key=\"contact\">{contact}</span>\n );\n if (!template.includes(\"{contact}\")) return [template, \" \", node];\n return template\n .split(/(\\{contact\\})/)\n .filter((part) => part !== \"\")\n .map((part) => (part === \"{contact}\" ? node : part));\n}\n\nconst HINT_CLASS = \"text-xs text-[var(--text-secondary)]\";\n\n/** A backup code's letters and digits — kastlan's: 16, printed `ABCD-EFGH-JKLM-NPQR`. */\nconst RECOVERY_CODE_LENGTH = 16;\n\n/** How many letters and digits a typed backup code has: the dashes and spaces it is\n * printed in groups with don't count, so \"abcd-efgh ijkl mnop\" is 16 — the count\n * kastlan's server normalises the code to before it compares. */\nfunction recoveryCharacters(value: string): number {\n return value.replace(/[^\\p{L}\\p{N}]/gu, \"\").length;\n}\nconst INTRO_CLASS = \"text-sm text-[var(--text-secondary)]\";\n\n/* ── The form ────────────────────────────────────────────────────────────── */\n\n/**\n * Sign-in for every app (docs/auth-harmonization.md §5, §8): email and password, or a\n * passkey; then the second factor when it is on; then a new password when an admin\n * required one. keksdose's `LoginPage` and `ForcedPasswordChangeStep`\n * (features/auth/login-page.tsx, forced-password-change.tsx), as one component.\n *\n * **It never sends a request.** Each step hands its input to a callback and renders the\n * {@link SignInAnswer} it resolves with; a rejection is shown in the step it came from.\n * The challenge token lives in this component's state only, as in keksdose, so a reload\n * costs a fresh sign-in — no route, no storage.\n *\n * **One error for every wrong credential** (§2.10, §5.2): `invalid_credentials` shows one\n * sentence, whatever was wrong, plus two hints UNDER it — \"Account deactivated? Write to\n * …\" (`deactivatedContact`) and \"Signed up with you+kastlan@…? Use that address.\"\n * (`emailTag`). Any other failure says \"Sign-in failed\" and no hint: the hints answer a\n * refused credential, not a network that is down. `describeError` puts the app's words\n * on a failure the kit cannot know (a throttled attempt).\n *\n * **The steps.**\n * - Credentials: the email field is `username webauthn` (passkey autofill, see\n * `passkeyAutofill`), the password a `CurrentPasswordInput` (a password manager fills\n * it and never offers a new one). The submit is not disabled while the fields are\n * empty: a browser that autofills on load withholds the values until the first\n * interaction, and a disabled button would swallow that first click. The fields'\n * own `required` answers an empty submit instead. \"Forgot your password?\" sits under\n * the buttons, where someone whose password just failed is already looking\n * (keksdose #198).\n * - Second factor: {@link OneTimeCodeInput}, focused on arrival. \"Verify\" waits for the\n * whole code. A refused code stays here with its error; `token_invalid` (the\n * challenge expired) goes back to the credentials and says why. Kurvenschmiede has\n * no 2FA yet, and the step is here from the start, so adding it is backend work only\n * (§10.5). With `recoveryCode` (0.30.0) a switch under the field takes a backup code\n * instead, through the same `onCode` with `kind: \"recovery\"`.\n *\n * **A throttled request** (HTTP 429, {@link isRateLimited}) says \"Too many attempts. Try\n * again in 30 s.\" on any step (0.30.0) — the wait from its `Retry-After`, else \"Wait a\n * moment and try again.\" — after `describeError`, whose words still come first, and\n * instead of \"wrong password\" or \"invalid code\", which would send the person to try\n * another one.\n * - New password: new + confirm with the strength meter, the 8-character / 72-byte\n * rules and nothing else (§8). It reads as explained, not blocked (keksdose): the\n * person did nothing wrong.\n *\n * The password is dropped from state once the credentials are answered; \"Back to sign in\"\n * returns to an empty password field.\n */\nexport function SignInForm({\n onSubmit,\n onCode,\n onSetPassword,\n onPasskey,\n passkeyAutofill,\n forgotHref,\n registerHref,\n defaultEmail = \"\",\n emailTag,\n deactivatedContact,\n codeLength = 6,\n recoveryCode,\n credentialsContent,\n twoFactorContent,\n passwordChangeContent,\n describeError,\n onStepChange,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: SignInFormProps) {\n const labels = useKitLabels(\"signIn\", DEFAULT_SIGN_IN_LABELS, labelsProp);\n const [step, setStep] = useState<SignInStep>(\"credentials\");\n const [email, setEmail] = useState(defaultEmail);\n const [password, setPassword] = useState(\"\");\n const [code, setCode] = useState(\"\");\n // 0.30.0: the second factor as a backup code instead of the authenticator's digits.\n const [useRecovery, setUseRecovery] = useState(false);\n const [recovery, setRecovery] = useState(\"\");\n const [newPassword, setNewPassword] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [challenge, setChallenge] = useState<{ token: string; extra?: Readonly<Record<string, unknown>> } | null>(\n null,\n );\n // What is running: one call at a time. \"done\" after `signed-in` — the app has the\n // session and is leaving; the buttons stay busy so nothing is sent twice meanwhile.\n const [busy, setBusy] = useState<SignInAction | \"done\" | null>(null);\n const [failure, setFailure] = useState<Failure | null>(null);\n const headingId = useId();\n\n const emailRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const codeRef = useRef<HTMLInputElement>(null);\n const recoveryRef = useRef<HTMLInputElement>(null);\n const newPasswordRef = useRef<HTMLInputElement>(null);\n\n // A late answer after unmount (the app navigated away) must not set state.\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const goTo = (next: SignInStep) => {\n setStep(next);\n onStepChange?.(next);\n };\n\n const present = (answer: SignInAnswer) => {\n setFailure(null);\n if (answer.kind === \"signed-in\") {\n setBusy(\"done\");\n return;\n }\n setBusy(null);\n // The password has done its work; it does not stay in state for the next steps.\n setPassword(\"\");\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n if (answer.kind === \"2fa\") {\n setChallenge({ token: answer.challengeToken });\n goTo(\"2fa\");\n } else if (answer.kind === \"password-change\") {\n setChallenge({ token: answer.challengeToken, extra: answer.extra });\n goTo(\"password-change\");\n }\n };\n\n const messageFor = (\n error: unknown,\n action: SignInAction,\n code: KitErrorCode | undefined,\n recoveryUsed: boolean,\n ): ReactNode => {\n const own = describeError?.(error, action);\n if (hasMessage(own)) return own;\n // After the app's words, before the kit's generic ones (0.30.0): a throttle is\n // neither a wrong password nor a wrong code, and saying so sends the person to try\n // another one — which the limiter counts too.\n if (isRateLimited(error)) return (labels.rateLimited ?? DEFAULT_SIGN_IN_LABELS.rateLimited)(retryAfterSeconds(error));\n if (action === \"password\") return code === \"invalid_credentials\" ? labels.invalidCredentials : labels.failed;\n if (action === \"passkey\") return labels.passkeyFailed;\n if (action === \"code\") {\n if (code === \"token_invalid\") return labels.expired;\n return recoveryUsed\n ? (labels.recoveryCodeInvalid ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeInvalid)\n : labels.codeInvalid;\n }\n return code === \"token_invalid\" ? labels.expired : labels.setPasswordFailed;\n };\n\n const fail = (error: unknown, action: SignInAction, sentEmail?: string, recoveryUsed = false) => {\n setBusy(null);\n // Our own abort (a passkey ceremony cancelled by the unmount) is no failure.\n if ((error as { name?: unknown } | null)?.name === \"AbortError\") return;\n const code = authErrorCode(error);\n const message = messageFor(error, action, code, recoveryUsed);\n // The challenge expired between the steps: only a fresh sign-in helps.\n if ((action === \"code\" || action === \"set-password\") && code === \"token_invalid\") {\n setChallenge(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n goTo(\"credentials\");\n }\n setFailure({ action, code, message, email: sentEmail });\n };\n\n const attempt = (\n action: SignInAction,\n call: () => Promise<SignInAnswer>,\n sentEmail?: string,\n recoveryUsed = false,\n ) => {\n if (busy) return;\n setBusy(action);\n setFailure(null);\n let result: Promise<SignInAnswer>;\n try {\n result = Promise.resolve(call());\n } catch (error) {\n result = Promise.reject(error);\n }\n result.then(\n (answer) => {\n if (mounted.current) present(answer);\n },\n (error: unknown) => {\n if (mounted.current) fail(error, action, sentEmail, recoveryUsed);\n },\n );\n };\n\n // Passkey autofill: armed once, on mount; the signal aborts on unmount. Its answer\n // arrives whenever the person picks a passkey from the email field's dropdown — and\n // is dropped if they have meanwhile started a sign-in of their own.\n const armAutofill = useEffectEvent((signal: AbortSignal) => passkeyAutofill?.(signal));\n const autofillAnswered = useEffectEvent((answer: SignInAnswer) => {\n if (busy === null) present(answer);\n });\n useEffect(() => {\n const controller = new AbortController();\n let pending: Promise<SignInAnswer | null | undefined>;\n try {\n pending = Promise.resolve(armAutofill(controller.signal));\n } catch (error) {\n pending = Promise.reject(error);\n }\n pending.then(\n (answer) => {\n if (answer && !controller.signal.aborted && mounted.current) autofillAnswered(answer);\n },\n () => {\n /* silent — unsupported, declined or aborted; the button stays the way in */\n },\n );\n return () => controller.abort();\n }, []);\n\n // Focus follows the step — not on mount (where it would pop a phone's keyboard over\n // the page), only once the person moved to another step.\n const shownStep = useRef(step);\n useEffect(() => {\n if (shownStep.current === step) return;\n shownStep.current = step;\n if (step === \"2fa\") codeRef.current?.focus();\n else if (step === \"password-change\") newPasswordRef.current?.focus();\n else if (emailRef.current?.value) passwordRef.current?.focus();\n else emailRef.current?.focus();\n }, [step]);\n // The backup-code switch swaps one field for the other under the focus that pressed\n // it; the field that came in is where the person is going. Only after a switch on\n // this step — arriving on it is the effect above.\n const shownRecovery = useRef(useRecovery);\n useEffect(() => {\n if (shownRecovery.current === useRecovery) return;\n shownRecovery.current = useRecovery;\n if (step !== \"2fa\") return;\n (useRecovery ? recoveryRef : codeRef).current?.focus();\n }, [useRecovery, step]);\n\n const backToCredentials = () => {\n if (busy) return;\n setChallenge(null);\n setFailure(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n goTo(\"credentials\");\n };\n\n const working = busy !== null;\n const rootClass = cn(\"space-y-3\", className);\n\n /* ── Step 2: the second factor ── */\n if (step === \"2fa\" && challenge) {\n const recoveryOn = recoveryCode !== undefined && recoveryCode !== false;\n const recoveryLength = (typeof recoveryCode === \"object\" ? recoveryCode.length : undefined) ?? RECOVERY_CODE_LENGTH;\n const asRecovery = recoveryOn && useRecovery;\n const recoveryReady = recoveryCharacters(recovery) === recoveryLength;\n const ready = asRecovery ? recoveryReady : code.length === codeLength;\n const submitCode = (e: FormEvent) => {\n e.preventDefault();\n if (!ready) return;\n if (asRecovery) {\n attempt(\n \"code\",\n () => onCode({ challengeToken: challenge.token, code: recovery.trim(), kind: \"recovery\" }),\n undefined,\n true,\n );\n return;\n }\n attempt(\"code\", () => onCode({ challengeToken: challenge.token, code }));\n };\n const switchCode = () => {\n if (working) return;\n setFailure(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery((on) => !on);\n };\n const codeError = failure?.action === \"code\" ? failure.message : undefined;\n const content =\n typeof twoFactorContent === \"function\" ? twoFactorContent(challenge.token) : twoFactorContent;\n return (\n <div {...rest} data-step=\"2fa\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={headingId} onSubmit={submitCode}>\n <Heading id={headingId} className=\"text-base font-semibold text-[var(--text-primary)]\">\n {labels.twoFactorTitle}\n </Heading>\n <p className={INTRO_CLASS}>\n {asRecovery ? (labels.recoveryIntro ?? DEFAULT_SIGN_IN_LABELS.recoveryIntro) : labels.twoFactorIntro}\n </p>\n {content}\n {asRecovery ? (\n // A plain text field, not the digits-only one: a backup code is letters and\n // digits in printed groups. Nothing a phone keyboard would \"correct\", and no\n // autofill — the browser's suggestion for an unknown field is the username.\n <Input\n ref={recoveryRef}\n label={labels.recoveryCode ?? DEFAULT_SIGN_IN_LABELS.recoveryCode}\n name=\"recovery-code\"\n value={recovery}\n onChange={(e) => {\n setRecovery(e.target.value);\n if (failure) setFailure(null);\n }}\n autoComplete=\"off\"\n autoCapitalize=\"characters\"\n autoCorrect=\"off\"\n spellCheck={false}\n inputClassName=\"font-mono\"\n hint={(labels.recoveryCodeHint ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeHint)(recoveryLength)}\n readOnly={working}\n error={codeError}\n required\n />\n ) : (\n <OneTimeCodeInput\n ref={codeRef}\n label={labels.code}\n name=\"code\"\n value={code}\n length={codeLength}\n onChange={(next) => {\n setCode(next);\n if (failure) setFailure(null);\n }}\n readOnly={working}\n error={codeError}\n required\n />\n )}\n {recoveryOn && (\n <p className=\"text-sm\">\n <Button type=\"button\" variant=\"link\" size=\"sm\" disabled={working} onClick={switchCode}>\n {asRecovery\n ? (labels.useAuthenticatorCode ?? DEFAULT_SIGN_IN_LABELS.useAuthenticatorCode)\n : (labels.useRecoveryCode ?? DEFAULT_SIGN_IN_LABELS.useRecoveryCode)}\n </Button>\n </p>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!working && !ready} pending={working}>\n {labels.verify}\n </Button>\n </form>\n <BackLink label={labels.backToSignIn} onClick={backToCredentials} disabled={working} />\n </div>\n );\n }\n\n /* ── Step 3: a new password ── */\n if (step === \"password-change\" && challenge) {\n const problem = newPasswordProblem(newPassword, confirm);\n const submitPassword = (e: FormEvent) => {\n e.preventDefault();\n if (problem) return;\n attempt(\"set-password\", () => onSetPassword({ challengeToken: challenge.token, password: newPassword }));\n };\n const content =\n typeof passwordChangeContent === \"function\" ? passwordChangeContent(challenge.extra) : passwordChangeContent;\n return (\n <div {...rest} data-step=\"password-change\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={headingId} onSubmit={submitPassword}>\n <Heading id={headingId} className=\"text-base font-semibold text-[var(--text-primary)]\">\n {labels.setPasswordTitle}\n </Heading>\n <p className={INTRO_CLASS}>{labels.setPasswordIntro}</p>\n {content}\n {/* Which account the new password is for, for the password manager: it files\n the new password under this username instead of guessing. */}\n {email !== \"\" && (\n <input type=\"email\" name=\"username\" autoComplete=\"username\" value={email} readOnly hidden />\n )}\n <NewPasswordFields\n password={newPassword}\n confirm={confirm}\n onPasswordChange={setNewPassword}\n onConfirmChange={setConfirm}\n busy={working}\n passwordRef={newPasswordRef}\n text={{ password: labels.newPassword, confirm: labels.confirmPassword, mismatch: labels.passwordMismatch }}\n />\n {failure?.action === \"set-password\" && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!working && problem !== null} pending={working}>\n {labels.setPasswordSubmit}\n </Button>\n </form>\n <BackLink label={labels.backToSignIn} onClick={backToCredentials} disabled={working} />\n </div>\n );\n }\n\n /* ── Step 1: the credentials ── */\n const submitCredentials = (e: FormEvent) => {\n e.preventDefault();\n const sent = email.trim();\n if (sent === \"\" || password === \"\") return;\n attempt(\"password\", () => onSubmit({ email: sent, password }), sent);\n };\n\n const refused = failure?.code === \"invalid_credentials\";\n const tagged =\n refused && failure?.action === \"password\" && emailTag && failure.email ? taggedEmail(failure.email, emailTag) : null;\n const showDeactivated = refused && hasMessage(deactivatedContact);\n\n return (\n <div {...rest} data-step=\"credentials\" className={rootClass}>\n <form className=\"space-y-3\" onSubmit={submitCredentials}>\n {credentialsContent}\n <Input\n ref={emailRef}\n type=\"email\"\n name=\"email\"\n // \"webauthn\" lets the browser list passkeys in this field's dropdown, paired\n // with the conditional request `passkeyAutofill` arms.\n autoComplete=\"username webauthn\"\n label={labels.email}\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n readOnly={working}\n required\n />\n <CurrentPasswordInput\n ref={passwordRef}\n name=\"password\"\n label={labels.password}\n value={password}\n onValueChange={setPassword}\n busy={working}\n required\n />\n {failure && (\n // One live region for the sentence and its hints: they are one answer.\n <div role=\"alert\" className=\"space-y-1.5\">\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure.message}\n </AlertBanner>\n {showDeactivated && (\n <p className={HINT_CLASS}>{withContact(labels.deactivatedHint, deactivatedContact)}</p>\n )}\n {tagged && <p className={HINT_CLASS}>{labels.tagHint(tagged)}</p>}\n </div>\n )}\n <Button type=\"submit\" className=\"w-full\" pending={busy === \"password\" || busy === \"done\"} disabled={busy === \"passkey\"}>\n {labels.submit}\n </Button>\n {onPasskey && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n className=\"w-full\"\n pending={busy === \"passkey\"}\n disabled={busy === \"password\" || busy === \"done\"}\n onClick={() => attempt(\"passkey\", onPasskey)}\n >\n <KeyRound aria-hidden className=\"size-4\" />\n {labels.passkey}\n </Button>\n )}\n </form>\n {forgotHref !== undefined && (\n <p className=\"text-center text-sm\">\n <TextLink href={forgotHref} tone=\"secondary\">\n {labels.forgotPassword}\n </TextLink>\n </p>\n )}\n {registerHref !== undefined && (\n <p className=\"text-center text-sm text-[var(--text-secondary)]\">\n {labels.noAccount}{\" \"}\n <TextLink href={registerHref} tone=\"primary\">\n {labels.register}\n </TextLink>\n </p>\n )}\n </div>\n );\n}\n\n/** \"Back to sign in\" under the second and third step: a button, since it changes the\n * step in place rather than going anywhere. */\nfunction BackLink({ label, onClick, disabled }: { label: string; onClick: () => void; disabled: boolean }) {\n return (\n <p className=\"text-center text-sm\">\n <Button type=\"button\" variant=\"link\" tone=\"muted\" size=\"sm\" disabled={disabled} onClick={onClick}>\n {label}\n </Button>\n </p>\n );\n}\n"],"mappings":";AAwUM,cAkUE,YAlUF;AAxUN,SAAS,WAAW,gBAAgB,OAAO,QAAQ,gBAAgB;AAEnE,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,QAAQ,aAAa;AAC9B,SAAS,eAAe,oBAAoB,eAAe,yBAAyB;AAEpF,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAgK3B,MAAM,yBAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,SAAS,CAAC,kBAAkB,kBAAkB,aAAa;AAAA,EAC3D,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBA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AAQ,MAAM,GAAE;AAAA,SAC/D;AAAA,MAEF,oBAAC,UAAO,MAAK,UAAS,WAAU,UAAS,SAAS,SAAS,cAAc,SAAS,QAAQ,UAAU,SAAS,WAC1G,iBAAO,QACV;AAAA,MACC,aACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,SAAS,SAAS;AAAA,UAClB,UAAU,SAAS,cAAc,SAAS;AAAA,UAC1C,SAAS,MAAM,QAAQ,WAAW,SAAS;AAAA,UAE3C;AAAA,gCAAC,YAAS,eAAW,MAAC,WAAU,UAAS;AAAA,YACxC,OAAO;AAAA;AAAA;AAAA,MACV;AAAA,OAEJ;AAAA,IACC,eAAe,UACd,oBAAC,OAAE,WAAU,uBACX,8BAAC,YAAS,MAAM,YAAY,MAAK,aAC9B,iBAAO,gBACV,GACF;AAAA,IAED,iBAAiB,UAChB,qBAAC,OAAE,WAAU,oDACV;AAAA,aAAO;AAAA,MAAW;AAAA,MACnB,oBAAC,YAAS,MAAM,cAAc,MAAK,WAChC,iBAAO,UACV;AAAA,OACF;AAAA,KAEJ;AAEJ;AAIA,SAAS,SAAS,EAAE,OAAO,SAAS,SAAS,GAA8D;AACzG,SACE,oBAAC,OAAE,WAAU,uBACX,8BAAC,UAAO,MAAK,UAAS,SAAQ,QAAO,MAAK,SAAQ,MAAK,MAAK,UAAoB,SAC7E,iBACH,GACF;AAEJ;","names":["code"]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/sign-in-form.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, ReactNode } from \"react\";\nimport { KeyRound } from \"lucide-react\";\n\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { hasMessage } from \"../components/choice-parts\";\nimport { CurrentPasswordInput } from \"../components/danger-confirm\";\nimport { OneTimeCodeInput } from \"../components/one-time-code-input\";\nimport { TextLink } from \"../components/text-link\";\nimport { Button, Input } from \"../components/ui\";\nimport { accessAction } from \"../landing/access\";\nimport type { AccessChoice } from \"../landing/access\";\nimport { useLandingLabels } from \"../landing/landing-labels\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"./auth-errors\";\nimport type { KitErrorCode } from \"./auth-errors\";\nimport { taggedEmail } from \"./email-tag\";\nimport { newPasswordProblem } from \"./form-rules\";\nimport { NewPasswordFields } from \"./new-password-fields\";\n\n/* ── The answers (§5.1) ──────────────────────────────────────────────────── */\n\n/**\n * What a sign-in call answers, in the kit's words — docs/auth-harmonization.md §5.1,\n * keksdose's three shapes. The app maps its own HTTP answer to one of these and resolves\n * with it; a refusal REJECTS (with whatever its client throws — {@link authErrorCode}\n * reads the code out of it).\n *\n * | the server answers (keksdose) | resolve with |\n * |---|---|\n * | `TokenResponse` `{access_token, refresh_token, token_type, user}` | `{ kind: \"signed-in\" }`, after the app has stored the session |\n * | `{requires_2fa: true, challenge_token}` | `{ kind: \"2fa\", challengeToken: challenge_token }` |\n * | `{requires_password_change: true, challenge_token, encrypted}` | `{ kind: \"password-change\", challengeToken: challenge_token, extra: { encrypted } }` |\n * | `401 {code: \"invalid_credentials\"}` | reject — let the client's error through |\n *\n * ```ts\n * async function toAnswer(res: TokenResponse | TwoFactorChallenge | PasswordChangeChallenge): Promise<SignInAnswer> {\n * if (\"requires_2fa\" in res) return { kind: \"2fa\", challengeToken: res.challenge_token };\n * if (\"requires_password_change\" in res)\n * return { kind: \"password-change\", challengeToken: res.challenge_token, extra: { encrypted: res.encrypted } };\n * await onLoginSuccess(res); // store tokens, load /auth/me, switch language\n * return { kind: \"signed-in\" };\n * }\n * <SignInForm onSubmit={async (v) => toAnswer(await authApi.login(v))} … />\n * ```\n *\n * The same mapping serves `/auth/login/2fa`, `/auth/login/set-password` and the passkey\n * finish, which answer the same union.\n */\nexport type SignInAnswer =\n | { kind: \"signed-in\" }\n | { kind: \"2fa\"; challengeToken: string }\n | {\n kind: \"password-change\";\n challengeToken: string;\n /** The challenge's app fields, passed through untouched — keksdose's `encrypted`,\n * which its note on this step reads (`passwordChangeContent`). */\n extra?: Readonly<Record<string, unknown>>;\n };\n\n/** The step on screen: the credentials, the second factor, or a new password. */\nexport type SignInStep = \"credentials\" | \"2fa\" | \"password-change\";\n\n/** What the person did when a call failed — {@link SignInFormProps.describeError}'s\n * second argument. */\nexport type SignInAction = \"password\" | \"passkey\" | \"code\" | \"set-password\";\n\nexport interface SignInCredentials {\n /** Trimmed. Lower-casing is the server's (§3.1). */\n email: string;\n /** As typed, never trimmed. */\n password: string;\n}\n\nexport interface SignInCodeValues {\n challengeToken: string;\n /** Digits only — {@link OneTimeCodeInput} drops the spaces of \"123 456\". A backup code\n * (`kind: \"recovery\"`) is trimmed and otherwise as typed: its dashes and case are the\n * server's to normalise, as kastlan's `_normalise_backup_code` does. */\n code: string;\n /**\n * 0.30.0: `\"recovery\"` when the person typed one of their backup codes instead\n * (`recoveryCode`); absent for the authenticator's code, as before. kastlan's\n * `/auth/login/2fa` takes either in the same `code` and tells them apart itself; an\n * app whose server takes a backup code elsewhere routes on this.\n */\n kind?: \"recovery\";\n}\n\nexport interface SignInNewPasswordValues {\n challengeToken: string;\n password: string;\n}\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/**\n * Every string `SignInForm` renders — the `signIn` namespace of `<UiKitProvider\n * labels>`, overridable per instance through `labels`. keksdose's words where it has\n * them (`auth.*` in its catalogue).\n */\nexport interface SignInLabels {\n email: string;\n password: string;\n /** The submit button. */\n submit: string;\n /** The passkey button (`onPasskey`). */\n passkey: string;\n /** The link to `forgotHref`. */\n forgotPassword: string;\n /** Before the link to `registerHref`. */\n noAccount: string;\n /** The link to `registerHref`. */\n register: string;\n /** The ONE answer to an unknown address, a wrong password and a deactivated account\n * (`invalid_credentials`, §5.2). */\n invalidCredentials: string;\n /** Any other failed sign-in (the network, a 500). */\n failed: string;\n /** A failed or refused passkey sign-in. */\n passkeyFailed: string;\n /**\n * The hint under `invalidCredentials` (§2.10), shown when `deactivatedContact` is\n * given. A TEMPLATE: `{contact}` is replaced by the contact — a `mailto:` link for an\n * address — so a language puts it where its grammar needs it.\n */\n deactivatedHint: string;\n /** The hint under `invalidCredentials` when `emailTag` is given (§4.5), given the\n * typed address with the app's tag: \"Signed up with ada+kastlan@example.com?\". */\n tagHint: (taggedAddress: string) => string;\n /** The second-factor step's heading. */\n twoFactorTitle: string;\n twoFactorIntro: string;\n /** The code field's label. */\n code: string;\n /** The code step's submit button. */\n verify: string;\n /** The code was refused. */\n codeInvalid: string;\n /** The set-a-new-password step's heading. */\n setPasswordTitle: string;\n setPasswordIntro: string;\n newPassword: string;\n confirmPassword: string;\n passwordMismatch: string;\n /** The set-a-new-password step's submit button. */\n setPasswordSubmit: string;\n setPasswordFailed: string;\n /** A challenge was refused as `token_invalid` — it expired between the steps; the\n * form is back on the credentials. */\n expired: string;\n /** From the second and third step back to the credentials. */\n backToSignIn: string;\n /*\n * 0.30.0 — OPTIONAL, like `TwoFactorSettingLabels.qrAlt` and for its reason: a new\n * required key is a compile error at every call site that annotates this interface\n * (CONTRIBUTING's additive-API rule). Each falls back to the provider's `signIn`, then\n * English.\n */\n /** The second-factor step's switch to a backup code (`recoveryCode`). */\n useRecoveryCode?: string;\n /** The switch back, from the backup-code field to the authenticator's code. */\n useAuthenticatorCode?: string;\n /** The backup-code field's label. */\n recoveryCode?: string;\n /** The step's intro while a backup code is asked for, in place of `twoFactorIntro`. */\n recoveryIntro?: string;\n /** Under the backup-code field, given how many letters and digits a code has. */\n recoveryCodeHint?: (length: number) => string;\n /** A refused backup code — wrong, or spent already (each one works once). */\n recoveryCodeInvalid?: string;\n /** Any step's request was throttled — HTTP 429 ({@link isRateLimited}) — given the\n * wait its `Retry-After` asks for, in seconds ({@link retryAfterSeconds}), or\n * `undefined` (or `0`) without one. */\n rateLimited?: (seconds?: number) => string;\n /** 0.31.0: the link after `noAccount` for an invitation-only app (`access` of kind\n * `request`) — a mail to support, in place of `register`. */\n requestAccess?: string;\n}\n\n/** `Required`: every key, the 0.30 ones included, has its English here. */\nexport const DEFAULT_SIGN_IN_LABELS: Required<SignInLabels> = {\n email: \"Email\",\n password: \"Password\",\n submit: \"Sign in\",\n passkey: \"Sign in with a passkey\",\n forgotPassword: \"Forgot your password?\",\n noAccount: \"No account yet?\",\n register: \"Create account\",\n invalidCredentials: \"The email or password is incorrect.\",\n failed: \"Sign-in failed. Please try again.\",\n passkeyFailed: \"Passkey sign-in failed.\",\n deactivatedHint: \"Account deactivated? Write to {contact}.\",\n tagHint: (taggedAddress) => `Signed up with ${taggedAddress}? Use that address.`,\n twoFactorTitle: \"Two-factor authentication\",\n twoFactorIntro: \"Enter the code your authenticator app shows.\",\n code: \"2FA code\",\n verify: \"Verify\",\n codeInvalid: \"Invalid 2FA code.\",\n setPasswordTitle: \"Choose a new password\",\n setPasswordIntro: \"A new password was requested for this account. Choose one and you are straight back in.\",\n newPassword: \"New password\",\n confirmPassword: \"Repeat new password\",\n passwordMismatch: \"The passwords don't match.\",\n setPasswordSubmit: \"Set password and sign in\",\n setPasswordFailed: \"The password could not be set.\",\n expired: \"This sign-in has expired. Please sign in again.\",\n backToSignIn: \"Back to sign in\",\n useRecoveryCode: \"Use a backup code\",\n useAuthenticatorCode: \"Use your authenticator app\",\n recoveryCode: \"Backup code\",\n recoveryIntro: \"Enter one of the backup codes you saved when you turned on two-factor authentication.\",\n recoveryCodeHint: (length) => `${length} letters and digits. Dashes and spaces don’t matter.`,\n recoveryCodeInvalid: \"This backup code is not valid, or it has been used already.\",\n rateLimited: englishRateLimited,\n requestAccess: \"Request access\",\n};\n\n/* ── Props ───────────────────────────────────────────────────────────────── */\n\nexport interface SignInFormProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSubmit\" | \"children\"> {\n /**\n * The credentials step was submitted. Send them, and resolve with the answer\n * ({@link SignInAnswer}) or reject with the client's error. The form never sends a\n * request itself (§8): keksdose must see the password on its way, to refuse the same\n * string as an encryption passphrase later.\n *\n * On `signed-in` the form's job is over — it stays busy while the app navigates.\n */\n onSubmit: (credentials: SignInCredentials) => Promise<SignInAnswer>;\n /** The second factor was submitted (`/auth/login/2fa`). Resolves with the next answer\n * — keksdose may still require a new password after the code. */\n onCode: (values: SignInCodeValues) => Promise<SignInAnswer>;\n /** The new password was submitted (`/auth/login/set-password`). Resolves with the\n * answer, `signed-in` in practice; keksdose's `key_wrap_unchanged` note is the app's\n * to show from here. */\n onSetPassword: (values: SignInNewPasswordValues) => Promise<SignInAnswer>;\n /**\n * The passkey button was pressed: run the ceremony (`/auth/passkey/login/begin|finish`)\n * and resolve with its answer. It asks for NO email — a passkey is bound to the site,\n * and the browser offers every one it holds (keksdose #126). Left out, no button: pass\n * it only where `PublicKeyCredential` exists.\n */\n onPasskey?: () => Promise<SignInAnswer>;\n /**\n * Passkey autofill (conditional mediation). The email field is\n * `autoComplete=\"username webauthn\"`, so a pending `navigator.credentials.get({\n * mediation: \"conditional\" })` lists the site's passkeys in its dropdown. The form\n * calls this ONCE on mount; arm the request there and resolve with its answer when the\n * person picks a passkey, or with `null` when nothing happens. The signal aborts on\n * unmount — cancel the pending request then (keksdose: `armPasskeyAutofill(onDone,\n * signal)` + `cancelPasskeyAutofill()`). A rejection is silent: the button stays the\n * reliable path.\n */\n passkeyAutofill?: (signal: AbortSignal) => Promise<SignInAnswer | null | undefined>;\n /** \"Forgot your password?\" goes here — the app's `/forgot-password`. Left out, no\n * link. */\n forgotHref?: string;\n /** \"No account yet? Create account\" goes here — `/register`. Left out, no line. */\n registerHref?: string;\n /**\n * 0.31.0 (docs/landing-demo-harmonization.md §4.2): how a visitor gets an account —\n * the same value the landing's `PublicHeader` and `Hero` take. `{kind: \"request\",\n * email}` turns the line into \"No account yet? Request access\", a mail to support with\n * the subject and body of `accessAction` (every app is invitation-only); `{kind:\n * \"register\", href}` keeps \"Create account\", to `href`. Wins over `registerHref`; left\n * out, `registerHref` works as before.\n */\n access?: AccessChoice;\n /** The email field's start value — the reset page ends on \"Sign in\" with the address\n * filled in (§6.3). */\n defaultEmail?: string;\n /**\n * The app's address tag (`\"kastlan\"`, §4.5). After `invalid_credentials` the form also\n * says \"Signed up with you+kastlan@example.com? Use that address.\" — sign-in stays\n * exact, and the server looks nothing up.\n */\n emailTag?: string;\n /**\n * Who a deactivated user writes to (§2.10): an address (drawn as a `mailto:` link) or\n * the app's own node. Shown after `invalid_credentials` as \"Account deactivated? Write\n * to …\". Left out, no hint.\n */\n deactivatedContact?: ReactNode;\n /** Digits of the second factor. Default 6 (TOTP). */\n codeLength?: number;\n /**\n * 0.30.0: offer a backup code on the second-factor step (kastlan's 0.29 adoption: its\n * `/auth/login/2fa` takes one of the eight codes minted at 2FA setup, and the kit's\n * step had no way to type one). A \"Use a backup code\" switch under the code field\n * swaps the digits-only {@link OneTimeCodeInput} for a plain text field; the code goes\n * to `onCode` with the same challenge and `kind: \"recovery\"`.\n *\n * `true` for a 16-character code (kastlan's `ABCD-EFGH-JKLM-NPQR`), or `{ length }`.\n * The length counts letters and digits only — the dashes and spaces a printed code is\n * grouped with don't count — and \"Verify\" waits for it. Left out, no switch.\n */\n recoveryCode?: boolean | { length?: number };\n /** App content at the top of the credentials step — a notice, a demo button. */\n credentialsContent?: ReactNode;\n /**\n * App content on the second-factor step, under its intro. 0.30.0: pass a function and\n * it gets the challenge token — kastlan kept its own copy of the token for a \"lost\n * your device?\" link, which the step now hands over.\n */\n twoFactorContent?: ReactNode | ((challengeToken: string) => ReactNode);\n /**\n * App content on the set-a-new-password step, under its intro — keksdose's\n * private-mode note (\"Your encrypted data is untouched …\"), which depends on the\n * challenge: pass a function and it gets the challenge's `extra`.\n */\n passwordChangeContent?: ReactNode | ((extra: Readonly<Record<string, unknown>> | undefined) => ReactNode);\n /**\n * The app's own words for a failure, or `undefined` for the kit's: the device being\n * offline, a throttle with its wait (\"try again in an hour\"). Asked first, for every\n * failure; what it returns replaces the message, and the `invalid_credentials` hints\n * still follow. A bare `429` needs none since 0.30.0: the kit says `rateLimited`.\n */\n describeError?: (error: unknown, action: SignInAction) => ReactNode | undefined;\n /** The step changed — retitle the page (`AuthLayout`'s `title`) if the app wants. */\n onStepChange?: (step: SignInStep) => void;\n /** The level of the second and third step's heading. Default `h2`, under the page's\n * `h1`; one level under `AuthLayout`'s `headingAs` where that is embedded lower. */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n labels?: Partial<SignInLabels>;\n}\n\n/* ── Parts ───────────────────────────────────────────────────────────────── */\n\ninterface Failure {\n action: SignInAction;\n code: KitErrorCode | undefined;\n message: ReactNode;\n /** The address the failed credentials carried — the tag hint names its tagged form. */\n email?: string;\n}\n\n/** `{contact}` in the template, replaced by the contact (a `mailto:` link for an\n * address). Split, not interpolated, so the link is an element. A template that lost\n * its placeholder still shows the contact, after it. */\nfunction withContact(template: string, contact: ReactNode): ReactNode[] {\n const node =\n typeof contact === \"string\" && contact.includes(\"@\") ? (\n <TextLink key=\"contact\" href={`mailto:${contact}`} tone=\"secondary\">\n {contact}\n </TextLink>\n ) : (\n <span key=\"contact\">{contact}</span>\n );\n if (!template.includes(\"{contact}\")) return [template, \" \", node];\n return template\n .split(/(\\{contact\\})/)\n .filter((part) => part !== \"\")\n .map((part) => (part === \"{contact}\" ? node : part));\n}\n\nconst HINT_CLASS = \"text-xs text-[var(--text-secondary)]\";\n\n/** A backup code's letters and digits — kastlan's: 16, printed `ABCD-EFGH-JKLM-NPQR`. */\nconst RECOVERY_CODE_LENGTH = 16;\n\n/** How many letters and digits a typed backup code has: the dashes and spaces it is\n * printed in groups with don't count, so \"abcd-efgh ijkl mnop\" is 16 — the count\n * kastlan's server normalises the code to before it compares. */\nfunction recoveryCharacters(value: string): number {\n return value.replace(/[^\\p{L}\\p{N}]/gu, \"\").length;\n}\nconst INTRO_CLASS = \"text-sm text-[var(--text-secondary)]\";\n\n/* ── The form ────────────────────────────────────────────────────────────── */\n\n/**\n * Sign-in for every app (docs/auth-harmonization.md §5, §8): email and password, or a\n * passkey; then the second factor when it is on; then a new password when an admin\n * required one. keksdose's `LoginPage` and `ForcedPasswordChangeStep`\n * (features/auth/login-page.tsx, forced-password-change.tsx), as one component.\n *\n * **It never sends a request.** Each step hands its input to a callback and renders the\n * {@link SignInAnswer} it resolves with; a rejection is shown in the step it came from.\n * The challenge token lives in this component's state only, as in keksdose, so a reload\n * costs a fresh sign-in — no route, no storage.\n *\n * **One error for every wrong credential** (§2.10, §5.2): `invalid_credentials` shows one\n * sentence, whatever was wrong, plus two hints UNDER it — \"Account deactivated? Write to\n * …\" (`deactivatedContact`) and \"Signed up with you+kastlan@…? Use that address.\"\n * (`emailTag`). Any other failure says \"Sign-in failed\" and no hint: the hints answer a\n * refused credential, not a network that is down. `describeError` puts the app's words\n * on a failure the kit cannot know (a throttled attempt).\n *\n * **The steps.**\n * - Credentials: the email field is `username webauthn` (passkey autofill, see\n * `passkeyAutofill`), the password a `CurrentPasswordInput` (a password manager fills\n * it and never offers a new one). The submit is not disabled while the fields are\n * empty: a browser that autofills on load withholds the values until the first\n * interaction, and a disabled button would swallow that first click. The fields'\n * own `required` answers an empty submit instead. \"Forgot your password?\" sits under\n * the buttons, where someone whose password just failed is already looking\n * (keksdose #198).\n * - Second factor: {@link OneTimeCodeInput}, focused on arrival. \"Verify\" waits for the\n * whole code. A refused code stays here with its error; `token_invalid` (the\n * challenge expired) goes back to the credentials and says why. Kurvenschmiede has\n * no 2FA yet, and the step is here from the start, so adding it is backend work only\n * (§10.5). With `recoveryCode` (0.30.0) a switch under the field takes a backup code\n * instead, through the same `onCode` with `kind: \"recovery\"`.\n *\n * **A throttled request** (HTTP 429, {@link isRateLimited}) says \"Too many attempts. Try\n * again in 30 s.\" on any step (0.30.0) — the wait from its `Retry-After`, else \"Wait a\n * moment and try again.\" — after `describeError`, whose words still come first, and\n * instead of \"wrong password\" or \"invalid code\", which would send the person to try\n * another one.\n * - New password: new + confirm with the strength meter, the 8-character / 72-byte\n * rules and nothing else (§8). It reads as explained, not blocked (keksdose): the\n * person did nothing wrong.\n *\n * The password is dropped from state once the credentials are answered; \"Back to sign in\"\n * returns to an empty password field.\n */\nexport function SignInForm({\n onSubmit,\n onCode,\n onSetPassword,\n onPasskey,\n passkeyAutofill,\n forgotHref,\n registerHref,\n access,\n defaultEmail = \"\",\n emailTag,\n deactivatedContact,\n codeLength = 6,\n recoveryCode,\n credentialsContent,\n twoFactorContent,\n passwordChangeContent,\n describeError,\n onStepChange,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: SignInFormProps) {\n const labels = useKitLabels(\"signIn\", DEFAULT_SIGN_IN_LABELS, labelsProp);\n // The mail's subject and body are the landing's words (`landing` namespace), so the\n // request reads the same from every page that offers it.\n const landing = useLandingLabels();\n const accountLink =\n access === undefined\n ? registerHref === undefined\n ? null\n : { href: registerHref, label: labels.register }\n : access.kind === \"register\"\n ? { href: access.href, label: labels.register }\n : {\n href: accessAction(access, landing).href,\n label: labels.requestAccess ?? DEFAULT_SIGN_IN_LABELS.requestAccess,\n };\n const [step, setStep] = useState<SignInStep>(\"credentials\");\n const [email, setEmail] = useState(defaultEmail);\n const [password, setPassword] = useState(\"\");\n const [code, setCode] = useState(\"\");\n // 0.30.0: the second factor as a backup code instead of the authenticator's digits.\n const [useRecovery, setUseRecovery] = useState(false);\n const [recovery, setRecovery] = useState(\"\");\n const [newPassword, setNewPassword] = useState(\"\");\n const [confirm, setConfirm] = useState(\"\");\n const [challenge, setChallenge] = useState<{ token: string; extra?: Readonly<Record<string, unknown>> } | null>(\n null,\n );\n // What is running: one call at a time. \"done\" after `signed-in` — the app has the\n // session and is leaving; the buttons stay busy so nothing is sent twice meanwhile.\n const [busy, setBusy] = useState<SignInAction | \"done\" | null>(null);\n const [failure, setFailure] = useState<Failure | null>(null);\n const headingId = useId();\n\n const emailRef = useRef<HTMLInputElement>(null);\n const passwordRef = useRef<HTMLInputElement>(null);\n const codeRef = useRef<HTMLInputElement>(null);\n const recoveryRef = useRef<HTMLInputElement>(null);\n const newPasswordRef = useRef<HTMLInputElement>(null);\n\n // A late answer after unmount (the app navigated away) must not set state.\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const goTo = (next: SignInStep) => {\n setStep(next);\n onStepChange?.(next);\n };\n\n const present = (answer: SignInAnswer) => {\n setFailure(null);\n if (answer.kind === \"signed-in\") {\n setBusy(\"done\");\n return;\n }\n setBusy(null);\n // The password has done its work; it does not stay in state for the next steps.\n setPassword(\"\");\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n if (answer.kind === \"2fa\") {\n setChallenge({ token: answer.challengeToken });\n goTo(\"2fa\");\n } else if (answer.kind === \"password-change\") {\n setChallenge({ token: answer.challengeToken, extra: answer.extra });\n goTo(\"password-change\");\n }\n };\n\n const messageFor = (\n error: unknown,\n action: SignInAction,\n code: KitErrorCode | undefined,\n recoveryUsed: boolean,\n ): ReactNode => {\n const own = describeError?.(error, action);\n if (hasMessage(own)) return own;\n // After the app's words, before the kit's generic ones (0.30.0): a throttle is\n // neither a wrong password nor a wrong code, and saying so sends the person to try\n // another one — which the limiter counts too.\n if (isRateLimited(error)) return (labels.rateLimited ?? DEFAULT_SIGN_IN_LABELS.rateLimited)(retryAfterSeconds(error));\n if (action === \"password\") return code === \"invalid_credentials\" ? labels.invalidCredentials : labels.failed;\n if (action === \"passkey\") return labels.passkeyFailed;\n if (action === \"code\") {\n if (code === \"token_invalid\") return labels.expired;\n return recoveryUsed\n ? (labels.recoveryCodeInvalid ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeInvalid)\n : labels.codeInvalid;\n }\n return code === \"token_invalid\" ? labels.expired : labels.setPasswordFailed;\n };\n\n const fail = (error: unknown, action: SignInAction, sentEmail?: string, recoveryUsed = false) => {\n setBusy(null);\n // Our own abort (a passkey ceremony cancelled by the unmount) is no failure.\n if ((error as { name?: unknown } | null)?.name === \"AbortError\") return;\n const code = authErrorCode(error);\n const message = messageFor(error, action, code, recoveryUsed);\n // The challenge expired between the steps: only a fresh sign-in helps.\n if ((action === \"code\" || action === \"set-password\") && code === \"token_invalid\") {\n setChallenge(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n goTo(\"credentials\");\n }\n setFailure({ action, code, message, email: sentEmail });\n };\n\n const attempt = (\n action: SignInAction,\n call: () => Promise<SignInAnswer>,\n sentEmail?: string,\n recoveryUsed = false,\n ) => {\n if (busy) return;\n setBusy(action);\n setFailure(null);\n let result: Promise<SignInAnswer>;\n try {\n result = Promise.resolve(call());\n } catch (error) {\n result = Promise.reject(error);\n }\n result.then(\n (answer) => {\n if (mounted.current) present(answer);\n },\n (error: unknown) => {\n if (mounted.current) fail(error, action, sentEmail, recoveryUsed);\n },\n );\n };\n\n // Passkey autofill: armed once, on mount; the signal aborts on unmount. Its answer\n // arrives whenever the person picks a passkey from the email field's dropdown — and\n // is dropped if they have meanwhile started a sign-in of their own.\n const armAutofill = useEffectEvent((signal: AbortSignal) => passkeyAutofill?.(signal));\n const autofillAnswered = useEffectEvent((answer: SignInAnswer) => {\n if (busy === null) present(answer);\n });\n useEffect(() => {\n const controller = new AbortController();\n let pending: Promise<SignInAnswer | null | undefined>;\n try {\n pending = Promise.resolve(armAutofill(controller.signal));\n } catch (error) {\n pending = Promise.reject(error);\n }\n pending.then(\n (answer) => {\n if (answer && !controller.signal.aborted && mounted.current) autofillAnswered(answer);\n },\n () => {\n /* silent — unsupported, declined or aborted; the button stays the way in */\n },\n );\n return () => controller.abort();\n }, []);\n\n // Focus follows the step — not on mount (where it would pop a phone's keyboard over\n // the page), only once the person moved to another step.\n const shownStep = useRef(step);\n useEffect(() => {\n if (shownStep.current === step) return;\n shownStep.current = step;\n if (step === \"2fa\") codeRef.current?.focus();\n else if (step === \"password-change\") newPasswordRef.current?.focus();\n else if (emailRef.current?.value) passwordRef.current?.focus();\n else emailRef.current?.focus();\n }, [step]);\n // The backup-code switch swaps one field for the other under the focus that pressed\n // it; the field that came in is where the person is going. Only after a switch on\n // this step — arriving on it is the effect above.\n const shownRecovery = useRef(useRecovery);\n useEffect(() => {\n if (shownRecovery.current === useRecovery) return;\n shownRecovery.current = useRecovery;\n if (step !== \"2fa\") return;\n (useRecovery ? recoveryRef : codeRef).current?.focus();\n }, [useRecovery, step]);\n\n const backToCredentials = () => {\n if (busy) return;\n setChallenge(null);\n setFailure(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery(false);\n setNewPassword(\"\");\n setConfirm(\"\");\n goTo(\"credentials\");\n };\n\n const working = busy !== null;\n const rootClass = cn(\"space-y-3\", className);\n\n /* ── Step 2: the second factor ── */\n if (step === \"2fa\" && challenge) {\n const recoveryOn = recoveryCode !== undefined && recoveryCode !== false;\n const recoveryLength = (typeof recoveryCode === \"object\" ? recoveryCode.length : undefined) ?? RECOVERY_CODE_LENGTH;\n const asRecovery = recoveryOn && useRecovery;\n const recoveryReady = recoveryCharacters(recovery) === recoveryLength;\n const ready = asRecovery ? recoveryReady : code.length === codeLength;\n const submitCode = (e: FormEvent) => {\n e.preventDefault();\n if (!ready) return;\n if (asRecovery) {\n attempt(\n \"code\",\n () => onCode({ challengeToken: challenge.token, code: recovery.trim(), kind: \"recovery\" }),\n undefined,\n true,\n );\n return;\n }\n attempt(\"code\", () => onCode({ challengeToken: challenge.token, code }));\n };\n const switchCode = () => {\n if (working) return;\n setFailure(null);\n setCode(\"\");\n setRecovery(\"\");\n setUseRecovery((on) => !on);\n };\n const codeError = failure?.action === \"code\" ? failure.message : undefined;\n const content =\n typeof twoFactorContent === \"function\" ? twoFactorContent(challenge.token) : twoFactorContent;\n return (\n <div {...rest} data-step=\"2fa\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={headingId} onSubmit={submitCode}>\n <Heading id={headingId} className=\"text-base font-semibold text-[var(--text-primary)]\">\n {labels.twoFactorTitle}\n </Heading>\n <p className={INTRO_CLASS}>\n {asRecovery ? (labels.recoveryIntro ?? DEFAULT_SIGN_IN_LABELS.recoveryIntro) : labels.twoFactorIntro}\n </p>\n {content}\n {asRecovery ? (\n // A plain text field, not the digits-only one: a backup code is letters and\n // digits in printed groups. Nothing a phone keyboard would \"correct\", and no\n // autofill — the browser's suggestion for an unknown field is the username.\n <Input\n ref={recoveryRef}\n label={labels.recoveryCode ?? DEFAULT_SIGN_IN_LABELS.recoveryCode}\n name=\"recovery-code\"\n value={recovery}\n onChange={(e) => {\n setRecovery(e.target.value);\n if (failure) setFailure(null);\n }}\n autoComplete=\"off\"\n autoCapitalize=\"characters\"\n autoCorrect=\"off\"\n spellCheck={false}\n inputClassName=\"font-mono\"\n hint={(labels.recoveryCodeHint ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeHint)(recoveryLength)}\n readOnly={working}\n error={codeError}\n required\n />\n ) : (\n <OneTimeCodeInput\n ref={codeRef}\n label={labels.code}\n name=\"code\"\n value={code}\n length={codeLength}\n onChange={(next) => {\n setCode(next);\n if (failure) setFailure(null);\n }}\n readOnly={working}\n error={codeError}\n required\n />\n )}\n {recoveryOn && (\n <p className=\"text-sm\">\n <Button type=\"button\" variant=\"link\" size=\"sm\" disabled={working} onClick={switchCode}>\n {asRecovery\n ? (labels.useAuthenticatorCode ?? DEFAULT_SIGN_IN_LABELS.useAuthenticatorCode)\n : (labels.useRecoveryCode ?? DEFAULT_SIGN_IN_LABELS.useRecoveryCode)}\n </Button>\n </p>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!working && !ready} pending={working}>\n {labels.verify}\n </Button>\n </form>\n <BackLink label={labels.backToSignIn} onClick={backToCredentials} disabled={working} />\n </div>\n );\n }\n\n /* ── Step 3: a new password ── */\n if (step === \"password-change\" && challenge) {\n const problem = newPasswordProblem(newPassword, confirm);\n const submitPassword = (e: FormEvent) => {\n e.preventDefault();\n if (problem) return;\n attempt(\"set-password\", () => onSetPassword({ challengeToken: challenge.token, password: newPassword }));\n };\n const content =\n typeof passwordChangeContent === \"function\" ? passwordChangeContent(challenge.extra) : passwordChangeContent;\n return (\n <div {...rest} data-step=\"password-change\" className={rootClass}>\n <form className=\"space-y-3\" aria-labelledby={headingId} onSubmit={submitPassword}>\n <Heading id={headingId} className=\"text-base font-semibold text-[var(--text-primary)]\">\n {labels.setPasswordTitle}\n </Heading>\n <p className={INTRO_CLASS}>{labels.setPasswordIntro}</p>\n {content}\n {/* Which account the new password is for, for the password manager: it files\n the new password under this username instead of guessing. */}\n {email !== \"\" && (\n <input type=\"email\" name=\"username\" autoComplete=\"username\" value={email} readOnly hidden />\n )}\n <NewPasswordFields\n password={newPassword}\n confirm={confirm}\n onPasswordChange={setNewPassword}\n onConfirmChange={setConfirm}\n busy={working}\n passwordRef={newPasswordRef}\n text={{ password: labels.newPassword, confirm: labels.confirmPassword, mismatch: labels.passwordMismatch }}\n />\n {failure?.action === \"set-password\" && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure.message}\n </AlertBanner>\n )}\n <Button type=\"submit\" className=\"w-full\" disabled={!working && problem !== null} pending={working}>\n {labels.setPasswordSubmit}\n </Button>\n </form>\n <BackLink label={labels.backToSignIn} onClick={backToCredentials} disabled={working} />\n </div>\n );\n }\n\n /* ── Step 1: the credentials ── */\n const submitCredentials = (e: FormEvent) => {\n e.preventDefault();\n const sent = email.trim();\n if (sent === \"\" || password === \"\") return;\n attempt(\"password\", () => onSubmit({ email: sent, password }), sent);\n };\n\n const refused = failure?.code === \"invalid_credentials\";\n const tagged =\n refused && failure?.action === \"password\" && emailTag && failure.email ? taggedEmail(failure.email, emailTag) : null;\n const showDeactivated = refused && hasMessage(deactivatedContact);\n\n return (\n <div {...rest} data-step=\"credentials\" className={rootClass}>\n <form className=\"space-y-3\" onSubmit={submitCredentials}>\n {credentialsContent}\n <Input\n ref={emailRef}\n type=\"email\"\n name=\"email\"\n // \"webauthn\" lets the browser list passkeys in this field's dropdown, paired\n // with the conditional request `passkeyAutofill` arms.\n autoComplete=\"username webauthn\"\n label={labels.email}\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n readOnly={working}\n required\n />\n <CurrentPasswordInput\n ref={passwordRef}\n name=\"password\"\n label={labels.password}\n value={password}\n onValueChange={setPassword}\n busy={working}\n required\n />\n {failure && (\n // One live region for the sentence and its hints: they are one answer.\n <div role=\"alert\" className=\"space-y-1.5\">\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure.message}\n </AlertBanner>\n {showDeactivated && (\n <p className={HINT_CLASS}>{withContact(labels.deactivatedHint, deactivatedContact)}</p>\n )}\n {tagged && <p className={HINT_CLASS}>{labels.tagHint(tagged)}</p>}\n </div>\n )}\n <Button type=\"submit\" className=\"w-full\" pending={busy === \"password\" || busy === \"done\"} disabled={busy === \"passkey\"}>\n {labels.submit}\n </Button>\n {onPasskey && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n className=\"w-full\"\n pending={busy === \"passkey\"}\n disabled={busy === \"password\" || busy === \"done\"}\n onClick={() => attempt(\"passkey\", onPasskey)}\n >\n <KeyRound aria-hidden className=\"size-4\" />\n {labels.passkey}\n </Button>\n )}\n </form>\n {forgotHref !== undefined && (\n <p className=\"text-center text-sm\">\n <TextLink href={forgotHref} tone=\"secondary\">\n {labels.forgotPassword}\n </TextLink>\n </p>\n )}\n {accountLink !== null && (\n <p className=\"text-center text-sm text-[var(--text-secondary)]\">\n {labels.noAccount}{\" \"}\n <TextLink href={accountLink.href} tone=\"primary\">\n {accountLink.label}\n </TextLink>\n </p>\n )}\n </div>\n );\n}\n\n/** \"Back to sign in\" under the second and third step: a button, since it changes the\n * step in place rather than going anywhere. */\nfunction BackLink({ label, onClick, disabled }: { label: string; onClick: () => void; disabled: boolean }) {\n return (\n <p className=\"text-center text-sm\">\n <Button type=\"button\" variant=\"link\" tone=\"muted\" size=\"sm\" disabled={disabled} onClick={onClick}>\n {label}\n </Button>\n </p>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;AAAA,SAC/D;AAAA,MAEF,oBAAC,UAAO,MAAK,UAAS,WAAU,UAAS,SAAS,SAAS,cAAc,SAAS,QAAQ,UAAU,SAAS,WAC1G,iBAAO,QACV;AAAA,MACC,aACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,SAAS,SAAS;AAAA,UAClB,UAAU,SAAS,cAAc,SAAS;AAAA,UAC1C,SAAS,MAAM,QAAQ,WAAW,SAAS;AAAA,UAE3C;AAAA,gCAAC,YAAS,eAAW,MAAC,WAAU,UAAS;AAAA,YACxC,OAAO;AAAA;AAAA;AAAA,MACV;AAAA,OAEJ;AAAA,IACC,eAAe,UACd,oBAAC,OAAE,WAAU,uBACX,8BAAC,YAAS,MAAM,YAAY,MAAK,aAC9B,iBAAO,gBACV,GACF;AAAA,IAED,gBAAgB,QACf,qBAAC,OAAE,WAAU,oDACV;AAAA,aAAO;AAAA,MAAW;AAAA,MACnB,oBAAC,YAAS,MAAM,YAAY,MAAM,MAAK,WACpC,sBAAY,OACf;AAAA,OACF;AAAA,KAEJ;AAEJ;AAIA,SAAS,SAAS,EAAE,OAAO,SAAS,SAAS,GAA8D;AACzG,SACE,oBAAC,OAAE,WAAU,uBACX,8BAAC,UAAO,MAAK,UAAS,SAAQ,QAAO,MAAK,SAAQ,MAAK,MAAK,UAAoB,SAC7E,iBACH,GACF;AAEJ;","names":["code"]}
|
|
@@ -30,6 +30,10 @@ interface VerifyEmailLabels {
|
|
|
30
30
|
resent: string;
|
|
31
31
|
/** Said (and shown) after a resend failed. */
|
|
32
32
|
resendError: string;
|
|
33
|
+
/** 0.31.1: a resend refused as throttled — HTTP 429 (`isRateLimited`) — given the
|
|
34
|
+
* `Retry-After` seconds, when the app's `describeError` has no words of its own
|
|
35
|
+
* (keksdose borrowed the sign-in namespace's). */
|
|
36
|
+
rateLimited?: (seconds?: number) => string;
|
|
33
37
|
/** The banner's message. */
|
|
34
38
|
banner: string;
|
|
35
39
|
/** The banner's ×: it defers, it does not close anything. */
|
|
@@ -9,7 +9,7 @@ import { AlertBanner } from "../components/alert-banner.js";
|
|
|
9
9
|
import { LoadingState } from "../components/loading-state.js";
|
|
10
10
|
import { Button, EmptyState } from "../components/ui.js";
|
|
11
11
|
import { OUTCOME_CLASS, STATUS_HEADING_CLASS, isThenable, useOncePerKey } from "./status-parts.js";
|
|
12
|
-
import { authErrorCode } from "./auth-errors.js";
|
|
12
|
+
import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "./auth-errors.js";
|
|
13
13
|
const DEFAULT_VERIFY_EMAIL_LABELS = {
|
|
14
14
|
title: "Confirm your email address",
|
|
15
15
|
verifying: "Confirming\u2026",
|
|
@@ -25,6 +25,7 @@ const DEFAULT_VERIFY_EMAIL_LABELS = {
|
|
|
25
25
|
resendIn: (seconds) => `Send again in ${seconds} s`,
|
|
26
26
|
resent: "Confirmation email sent",
|
|
27
27
|
resendError: "Could not send the confirmation email",
|
|
28
|
+
rateLimited: englishRateLimited,
|
|
28
29
|
banner: "Please confirm your email address.",
|
|
29
30
|
dismiss: "Not now"
|
|
30
31
|
};
|
|
@@ -90,7 +91,7 @@ function ResendStatus({
|
|
|
90
91
|
labels,
|
|
91
92
|
className
|
|
92
93
|
}) {
|
|
93
|
-
const failed = phase === "failed" ? describeError?.(error) ?? labels.resendError : "";
|
|
94
|
+
const failed = phase === "failed" ? describeError?.(error) ?? (isRateLimited(error) ? (labels.rateLimited ?? englishRateLimited)(retryAfterSeconds(error)) : labels.resendError) : "";
|
|
94
95
|
return /* @__PURE__ */ jsx(
|
|
95
96
|
"span",
|
|
96
97
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/verify-email.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { CheckCircle2, MailWarning, TimerOff, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { OUTCOME_CLASS, STATUS_HEADING_CLASS, isThenable, useOncePerKey } from \"./status-parts\";\nimport { authErrorCode } from \"./auth-errors\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the verification page and banner render — the `verifyEmail` namespace.\n * keksdose's words (`verify_email.*`, and its server's \"has expired\"). */\nexport interface VerifyEmailLabels {\n /** The page's heading. */\n title: string;\n /** While the link is redeemed. */\n verifying: string;\n verified: string;\n /** The way on from the page — into the app, or to sign-in. */\n continue: string;\n invalid: string;\n expired: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** Under `invalid`: why a link stops working. */\n invalidHint: string;\n /** Under a dead link, signed out: where a new one comes from. */\n requestInApp: string;\n /** Under a dead link, signed in, beside \"Send again\". */\n requestHere: string;\n /** The resend button, on the page and in the banner. */\n resend: string;\n /** The resend button while a just-sent mail cools down, given the seconds left. */\n resendIn: (seconds: number) => string;\n /** Said (and shown) after a resend went out. */\n resent: string;\n /** Said (and shown) after a resend failed. */\n resendError: string;\n /** The banner's message. */\n banner: string;\n /** The banner's ×: it defers, it does not close anything. */\n dismiss: string;\n}\n\nexport const DEFAULT_VERIFY_EMAIL_LABELS: VerifyEmailLabels = {\n title: \"Confirm your email address\",\n verifying: \"Confirming…\",\n verified: \"Your email address is confirmed.\",\n continue: \"Continue\",\n invalid: \"This confirmation link is not valid\",\n expired: \"This confirmation link has expired\",\n noToken: \"This link is missing its confirmation token.\",\n invalidHint: \"The link may have expired or already been used.\",\n requestInApp: \"You can request a new one from inside the app.\",\n requestHere: \"You can request a new one here.\",\n resend: \"Send again\",\n resendIn: (seconds) => `Send again in ${seconds} s`,\n resent: \"Confirmation email sent\",\n resendError: \"Could not send the confirmation email\",\n banner: \"Please confirm your email address.\",\n dismiss: \"Not now\",\n};\n\n/** A minute: long enough that an impatient second click does not mail twice, short\n * enough that a mail lost to a spam filter can be re-sent without leaving the page. The\n * server's own limit is the real one (kastlan: 3 an hour per address). */\nconst DEFAULT_COOLDOWN = 60;\n\n/* ── Resend ──────────────────────────────────────────────────────────────── */\n\ntype ResendPhase = \"idle\" | \"sending\" | \"sent\" | \"failed\";\n\n/**\n * \"Send again\" with its own memory: busy while the request runs, then — after a mail\n * went out — held for `cooldown` seconds with the countdown on the button, so a second\n * click cannot mail twice and a throttled server is not asked to refuse. A failure frees\n * it at once. The outcome is a polite live region that is always rendered (a region that\n * mounts with its message is often not read), and visible.\n */\nfunction useResend(onResend: (() => Promise<unknown> | void) | undefined, cooldown: number) {\n const [phase, setPhase] = useState<ResendPhase>(\"idle\");\n // The refusal itself, for `describeError` (0.29.1): the server's own sentence — keksdose's\n // per-address throttle, \"try again in N minutes\" — beats a fixed \"could not send\".\n const [error, setError] = useState<unknown>(undefined);\n const [remaining, setRemaining] = useState(0);\n const counting = remaining > 0;\n useEffect(() => {\n if (!counting) return;\n const id = setInterval(() => setRemaining((r) => Math.max(0, r - 1)), 1000);\n return () => clearInterval(id);\n }, [counting]);\n\n const sent = () => {\n setPhase(\"sent\");\n setRemaining(Math.max(0, Math.round(cooldown)));\n };\n const send = () => {\n if (!onResend || phase === \"sending\" || counting) return;\n let result: unknown;\n try {\n result = onResend();\n } catch (e) {\n setError(e);\n setPhase(\"failed\");\n return;\n }\n if (!isThenable(result)) {\n sent();\n return;\n }\n setPhase(\"sending\");\n result.then(sent, (e: unknown) => {\n setError(e);\n setPhase(\"failed\");\n });\n };\n return { phase, remaining, send, error };\n}\n\nfunction ResendButton({\n state,\n labels,\n variant,\n}: {\n state: ReturnType<typeof useResend>;\n labels: VerifyEmailLabels;\n variant: \"secondary\" | \"brand\";\n}) {\n return (\n <Button\n type=\"button\"\n variant={variant}\n size={variant === \"secondary\" ? \"sm\" : undefined}\n onClick={state.send}\n pending={state.phase === \"sending\"}\n // `disabledReason`, not `disabled`: the button just pressed has the focus, and a\n // native `disabled` would drop it to <body>. The reason is what just happened.\n disabledReason={state.remaining > 0 ? labels.resent : undefined}\n >\n {state.remaining > 0 ? labels.resendIn(state.remaining) : labels.resend}\n </Button>\n );\n}\n\nfunction ResendStatus({\n phase,\n error,\n describeError,\n labels,\n className,\n}: {\n phase: ResendPhase;\n error?: unknown;\n describeError?: (error: unknown) => string | undefined;\n labels: VerifyEmailLabels;\n className?: string;\n}) {\n const failed = phase === \"failed\" ? (describeError?.(error) ?? labels.resendError) : \"\";\n return (\n <span\n role=\"status\"\n className={cn(phase === \"failed\" ? \"text-[var(--danger)]\" : \"text-[var(--success)]\", className)}\n >\n {phase === \"sent\" ? labels.resent : failed}\n </span>\n );\n}\n\n/* ── The page ────────────────────────────────────────────────────────────── */\n\n/** What became of a confirmation link that did not verify. */\nexport type VerifyEmailFailure = \"invalid\" | \"expired\";\n\n/** The default when the app gives no `classifyError`: the coded refusal decides. */\nfunction defaultVerifyFailure(error: unknown): VerifyEmailFailure {\n return authErrorCode(error) === \"token_expired\" ? \"expired\" : \"invalid\";\n}\n\nexport interface VerifyEmailStatusProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"title\"> {\n /** The link's token — the app's `?token=`. Empty: the link was cut short, and the\n * page says so without asking anyone. */\n token: string;\n /**\n * Redeem it — `POST /auth/verify-email {token}`, once per token, on mount. A POST and\n * not the link's own GET (§10.10): a mail scanner that opens every link must not\n * confirm an address nobody read. Resolve when it verified (an address that already\n * was counts: keksdose's redeem is idempotent); reject with the client's error.\n */\n onVerify: (token: string) => Promise<unknown>;\n /** Which dead end a rejection is. Default: `invalid` for everything — §5.2's servers\n * answer one `token_invalid`; an app whose server tells expiry apart maps it here. */\n classifyError?: (error: unknown) => VerifyEmailFailure;\n /** 0.29.1: the words for a refused resend — the server's own sentence (a throttle's\n * \"try again in N minutes\"), else the kit's `resendError`. */\n describeError?: (error: unknown) => string | undefined;\n /** Someone is signed in on this device: \"Continue\" goes into the app, and a dead link\n * offers \"Send again\" (with `onResend`). */\n signedIn?: boolean;\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`) — offered on a dead\n * link while signed in. */\n onResend?: () => Promise<unknown> | void;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** Where \"Continue\" goes. Default `/` signed in, `/login` signed out. */\n continueHref?: string;\n /** App content under \"confirmed\" — keksdose's \"Others can now share a budget with you\n * directly.\" */\n verifiedContent?: ReactNode;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it in\n * `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<VerifyEmailLabels>;\n}\n\ntype VerifyOutcome = \"verified\" | VerifyEmailFailure;\n\n/**\n * Redeem an email-confirmation link (`/verify-email?token=…`, docs/auth-harmonization.md\n * §7) — keksdose's `VerifyEmailPage` (features/auth/verify-email-page.tsx), with\n * kastlan's outcome blocks and its separate \"expired\".\n *\n * Opened from an inbox, often in a browser with no session, so the token is the only\n * credential and the page renders signed-out. It redeems once per token on mount\n * (StrictMode's double effect included — the token is single-use) and shows one of:\n * confirmed; not valid; expired; or the link had no token at all. Verification gates\n * nothing (§2.8), so every outcome ends on \"Continue\". Signed in, a dead link also\n * offers \"Send again\", which waits `cooldown` seconds after a mail went out.\n *\n * The outcome replaces the spinner, which says nothing to a screen reader on its own,\n * so it is also announced.\n */\nexport function VerifyEmailStatus({\n token,\n onVerify,\n classifyError,\n describeError,\n signedIn = false,\n onResend,\n cooldown = DEFAULT_COOLDOWN,\n continueHref,\n verifiedContent,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: VerifyEmailStatusProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const [settled, setSettled] = useState<{ token: string; outcome: VerifyOutcome } | null>(null);\n const outcome: VerifyOutcome | \"verifying\" =\n token === \"\" ? \"invalid\" : settled?.token === token ? settled.outcome : \"verifying\";\n const { announce, regionProps } = useAnnounce();\n const resend = useResend(onResend, cooldown);\n\n useOncePerKey(token === \"\" ? null : token, onVerify, (key, result) => {\n // Without a classifier, the coded refusal decides (0.29.1): `token_expired` is\n // \"expired\", anything else \"invalid\".\n const next: VerifyOutcome = result.ok\n ? \"verified\"\n : (classifyError ?? defaultVerifyFailure)(result.error);\n setSettled({ token: key, outcome: next });\n announce(labels[next]);\n });\n\n const href = continueHref ?? (signedIn ? \"/\" : \"/login\");\n // `replace`: the token is spent, so Back must not land on this page again (keksdose F1).\n const continueButton = (\n <Button href={href} replace variant={outcome === \"verified\" ? \"brand\" : \"secondary\"}>\n {labels.continue}\n </Button>\n );\n const canResend = signedIn && onResend !== undefined;\n\n let body: ReactNode;\n if (outcome === \"verifying\") {\n body = <LoadingState size=\"sm\" label={labels.verifying} />;\n } else if (outcome === \"verified\") {\n body = (\n <EmptyState\n tone=\"success\"\n icon={<CheckCircle2 />}\n title={labels.verified}\n hint={verifiedContent}\n action={continueButton}\n className={OUTCOME_CLASS}\n />\n );\n } else {\n const hint = (\n <>\n {outcome === \"invalid\" && token !== \"\" ? `${labels.invalidHint} ` : \"\"}\n {canResend ? labels.requestHere : labels.requestInApp}\n </>\n );\n body = (\n <EmptyState\n tone=\"danger\"\n icon={outcome === \"expired\" ? <TimerOff /> : <XCircle />}\n title={token === \"\" ? labels.noToken : labels[outcome]}\n hint={hint}\n action={\n <>\n {canResend && <ResendButton state={resend} labels={labels} variant=\"brand\" />}\n {continueButton}\n </>\n }\n className={OUTCOME_CLASS}\n />\n );\n }\n\n return (\n <div\n {...rest}\n data-state={outcome}\n aria-busy={outcome === \"verifying\" || undefined}\n className={cn(\"space-y-3\", className)}\n >\n {title === null ? null : <Heading className={STATUS_HEADING_CLASS}>{title ?? labels.title}</Heading>}\n {body}\n {canResend && (\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"block text-center text-xs\"\n />\n )}\n {/* Rendered from the start, so the outcome is read when it arrives. */}\n <div {...regionProps} />\n </div>\n );\n}\n\n/* ── The banner ──────────────────────────────────────────────────────────── */\n\nexport interface EmailVerificationBannerProps {\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`). Resolve when it\n * went out; reject and the banner says it could not. */\n onResend: () => Promise<unknown> | void;\n /** 0.29.1: the words for a refused resend — the server's own sentence, else the kit's. */\n describeError?: (error: unknown) => string | undefined;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** The ×, \"Not now\". The banner does not hide itself: the app stops rendering it —\n * keksdose for the rest of the session. Left out, no ×. */\n onDismiss?: () => void;\n /** `strip` (default): keksdose's band across the top of the shell. `box`: kastlan's\n * callout inside the page. */\n variant?: \"strip\" | \"box\";\n /** The app's sentence after the kit's — keksdose's \"Until you do, nobody can share a\n * budget with you directly.\" */\n children?: ReactNode;\n className?: string;\n labels?: Partial<VerifyEmailLabels>;\n}\n\n/**\n * The nudge for a signed-in account whose address is not confirmed — keksdose's\n * `VerifyEmailBanner` (features/auth/verify-email-banner.tsx), kastlan's copy of it.\n *\n * A prompt, not a wall: verification gates nothing (§2.8). The app renders it while\n * `/auth/me` says `email_verified: false`, and stops when the user dismisses it or the\n * page above confirms the address. \"Send again\" waits `cooldown` seconds after a mail\n * went out (the button says how long), and its outcome is written into the banner and\n * read out — no toast needed.\n */\nexport function EmailVerificationBanner({\n onResend,\n describeError,\n cooldown = DEFAULT_COOLDOWN,\n onDismiss,\n variant = \"strip\",\n children,\n className,\n labels: labelsProp,\n}: EmailVerificationBannerProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const resend = useResend(onResend, cooldown);\n return (\n <AlertBanner\n tone=\"warning\"\n variant={variant}\n icon={<MailWarning />}\n action={<ResendButton state={resend} labels={labels} variant=\"secondary\" />}\n onDismiss={onDismiss}\n dismissLabel={onDismiss ? labels.dismiss : undefined}\n className={className}\n >\n {labels.banner}\n {children != null && children !== false && <> {children}</>}{\" \"}\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"font-medium\"\n />\n </AlertBanner>\n );\n}\n"],"mappings":";AAsII,SAkKE,UAlKF,KAkKE,YAlKF;AAtIJ,SAAS,WAAW,gBAAgB;AAEpC,SAAS,cAAc,aAAa,UAAU,eAAe;AAC7D,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAkB;AACnC,SAAS,eAAe,sBAAsB,YAAY,qBAAqB;AAC/E,SAAS,qBAAqB;AAuCvB,MAAM,8BAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,UAAU,CAAC,YAAY,iBAAiB,OAAO;AAAA,EAC/C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AACX;AAKA,MAAM,mBAAmB;AAazB,SAAS,UAAU,UAAuD,UAAkB;AAC1F,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAsB,MAAM;AAGtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,MAAS;AACrD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,CAAC;AAC5C,QAAM,WAAW,YAAY;AAC7B,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AACf,UAAM,KAAK,YAAY,MAAM,aAAa,CAAC,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC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AAA,MACA,MAAM,oBAAC,eAAY;AAAA,MACnB,QAAQ,oBAAC,gBAAa,OAAO,QAAQ,QAAgB,SAAQ,aAAY;AAAA,MACzE;AAAA,MACA,cAAc,YAAY,OAAO,UAAU;AAAA,MAC3C;AAAA,MAEC;AAAA,eAAO;AAAA,QACP,YAAY,QAAQ,aAAa,SAAS,iCAAE;AAAA;AAAA,UAAE;AAAA,WAAS;AAAA,QAAK;AAAA,QAC7D;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,OAAO;AAAA,YACd,OAAO,OAAO;AAAA,YACd;AAAA,YACA;AAAA,YACA,WAAU;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/verify-email.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { CheckCircle2, MailWarning, TimerOff, XCircle } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { LoadingState } from \"../components/loading-state\";\nimport { Button, EmptyState } from \"../components/ui\";\nimport { OUTCOME_CLASS, STATUS_HEADING_CLASS, isThenable, useOncePerKey } from \"./status-parts\";\nimport { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from \"./auth-errors\";\nimport type { AuthHeadingLevel } from \"./status-parts\";\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the verification page and banner render — the `verifyEmail` namespace.\n * keksdose's words (`verify_email.*`, and its server's \"has expired\"). */\nexport interface VerifyEmailLabels {\n /** The page's heading. */\n title: string;\n /** While the link is redeemed. */\n verifying: string;\n verified: string;\n /** The way on from the page — into the app, or to sign-in. */\n continue: string;\n invalid: string;\n expired: string;\n /** The page was opened without a `token`. */\n noToken: string;\n /** Under `invalid`: why a link stops working. */\n invalidHint: string;\n /** Under a dead link, signed out: where a new one comes from. */\n requestInApp: string;\n /** Under a dead link, signed in, beside \"Send again\". */\n requestHere: string;\n /** The resend button, on the page and in the banner. */\n resend: string;\n /** The resend button while a just-sent mail cools down, given the seconds left. */\n resendIn: (seconds: number) => string;\n /** Said (and shown) after a resend went out. */\n resent: string;\n /** Said (and shown) after a resend failed. */\n resendError: string;\n /** 0.31.1: a resend refused as throttled — HTTP 429 (`isRateLimited`) — given the\n * `Retry-After` seconds, when the app's `describeError` has no words of its own\n * (keksdose borrowed the sign-in namespace's). */\n rateLimited?: (seconds?: number) => string;\n /** The banner's message. */\n banner: string;\n /** The banner's ×: it defers, it does not close anything. */\n dismiss: string;\n}\n\nexport const DEFAULT_VERIFY_EMAIL_LABELS: VerifyEmailLabels = {\n title: \"Confirm your email address\",\n verifying: \"Confirming…\",\n verified: \"Your email address is confirmed.\",\n continue: \"Continue\",\n invalid: \"This confirmation link is not valid\",\n expired: \"This confirmation link has expired\",\n noToken: \"This link is missing its confirmation token.\",\n invalidHint: \"The link may have expired or already been used.\",\n requestInApp: \"You can request a new one from inside the app.\",\n requestHere: \"You can request a new one here.\",\n resend: \"Send again\",\n resendIn: (seconds) => `Send again in ${seconds} s`,\n resent: \"Confirmation email sent\",\n resendError: \"Could not send the confirmation email\",\n rateLimited: englishRateLimited,\n banner: \"Please confirm your email address.\",\n dismiss: \"Not now\",\n};\n\n/** A minute: long enough that an impatient second click does not mail twice, short\n * enough that a mail lost to a spam filter can be re-sent without leaving the page. The\n * server's own limit is the real one (kastlan: 3 an hour per address). */\nconst DEFAULT_COOLDOWN = 60;\n\n/* ── Resend ──────────────────────────────────────────────────────────────── */\n\ntype ResendPhase = \"idle\" | \"sending\" | \"sent\" | \"failed\";\n\n/**\n * \"Send again\" with its own memory: busy while the request runs, then — after a mail\n * went out — held for `cooldown` seconds with the countdown on the button, so a second\n * click cannot mail twice and a throttled server is not asked to refuse. A failure frees\n * it at once. The outcome is a polite live region that is always rendered (a region that\n * mounts with its message is often not read), and visible.\n */\nfunction useResend(onResend: (() => Promise<unknown> | void) | undefined, cooldown: number) {\n const [phase, setPhase] = useState<ResendPhase>(\"idle\");\n // The refusal itself, for `describeError` (0.29.1): the server's own sentence — keksdose's\n // per-address throttle, \"try again in N minutes\" — beats a fixed \"could not send\".\n const [error, setError] = useState<unknown>(undefined);\n const [remaining, setRemaining] = useState(0);\n const counting = remaining > 0;\n useEffect(() => {\n if (!counting) return;\n const id = setInterval(() => setRemaining((r) => Math.max(0, r - 1)), 1000);\n return () => clearInterval(id);\n }, [counting]);\n\n const sent = () => {\n setPhase(\"sent\");\n setRemaining(Math.max(0, Math.round(cooldown)));\n };\n const send = () => {\n if (!onResend || phase === \"sending\" || counting) return;\n let result: unknown;\n try {\n result = onResend();\n } catch (e) {\n setError(e);\n setPhase(\"failed\");\n return;\n }\n if (!isThenable(result)) {\n sent();\n return;\n }\n setPhase(\"sending\");\n result.then(sent, (e: unknown) => {\n setError(e);\n setPhase(\"failed\");\n });\n };\n return { phase, remaining, send, error };\n}\n\nfunction ResendButton({\n state,\n labels,\n variant,\n}: {\n state: ReturnType<typeof useResend>;\n labels: VerifyEmailLabels;\n variant: \"secondary\" | \"brand\";\n}) {\n return (\n <Button\n type=\"button\"\n variant={variant}\n size={variant === \"secondary\" ? \"sm\" : undefined}\n onClick={state.send}\n pending={state.phase === \"sending\"}\n // `disabledReason`, not `disabled`: the button just pressed has the focus, and a\n // native `disabled` would drop it to <body>. The reason is what just happened.\n disabledReason={state.remaining > 0 ? labels.resent : undefined}\n >\n {state.remaining > 0 ? labels.resendIn(state.remaining) : labels.resend}\n </Button>\n );\n}\n\nfunction ResendStatus({\n phase,\n error,\n describeError,\n labels,\n className,\n}: {\n phase: ResendPhase;\n error?: unknown;\n describeError?: (error: unknown) => string | undefined;\n labels: VerifyEmailLabels;\n className?: string;\n}) {\n // The app's words first, then the throttle's, then the kit's catch-all.\n const failed =\n phase === \"failed\"\n ? (describeError?.(error) ??\n (isRateLimited(error)\n ? (labels.rateLimited ?? englishRateLimited)(retryAfterSeconds(error))\n : labels.resendError))\n : \"\";\n return (\n <span\n role=\"status\"\n className={cn(phase === \"failed\" ? \"text-[var(--danger)]\" : \"text-[var(--success)]\", className)}\n >\n {phase === \"sent\" ? labels.resent : failed}\n </span>\n );\n}\n\n/* ── The page ────────────────────────────────────────────────────────────── */\n\n/** What became of a confirmation link that did not verify. */\nexport type VerifyEmailFailure = \"invalid\" | \"expired\";\n\n/** The default when the app gives no `classifyError`: the coded refusal decides. */\nfunction defaultVerifyFailure(error: unknown): VerifyEmailFailure {\n return authErrorCode(error) === \"token_expired\" ? \"expired\" : \"invalid\";\n}\n\nexport interface VerifyEmailStatusProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"title\"> {\n /** The link's token — the app's `?token=`. Empty: the link was cut short, and the\n * page says so without asking anyone. */\n token: string;\n /**\n * Redeem it — `POST /auth/verify-email {token}`, once per token, on mount. A POST and\n * not the link's own GET (§10.10): a mail scanner that opens every link must not\n * confirm an address nobody read. Resolve when it verified (an address that already\n * was counts: keksdose's redeem is idempotent); reject with the client's error.\n */\n onVerify: (token: string) => Promise<unknown>;\n /** Which dead end a rejection is. Default: `invalid` for everything — §5.2's servers\n * answer one `token_invalid`; an app whose server tells expiry apart maps it here. */\n classifyError?: (error: unknown) => VerifyEmailFailure;\n /** 0.29.1: the words for a refused resend — the server's own sentence (a throttle's\n * \"try again in N minutes\"), else the kit's `resendError`. */\n describeError?: (error: unknown) => string | undefined;\n /** Someone is signed in on this device: \"Continue\" goes into the app, and a dead link\n * offers \"Send again\" (with `onResend`). */\n signedIn?: boolean;\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`) — offered on a dead\n * link while signed in. */\n onResend?: () => Promise<unknown> | void;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** Where \"Continue\" goes. Default `/` signed in, `/login` signed out. */\n continueHref?: string;\n /** App content under \"confirmed\" — keksdose's \"Others can now share a budget with you\n * directly.\" */\n verifiedContent?: ReactNode;\n /** The heading. Default `labels.title`; `null` draws none, for a page that puts it in\n * `AuthLayout`'s `title` instead. */\n title?: ReactNode;\n /** The heading's level. Default `h2`, under the page's `h1`. */\n headingAs?: AuthHeadingLevel;\n labels?: Partial<VerifyEmailLabels>;\n}\n\ntype VerifyOutcome = \"verified\" | VerifyEmailFailure;\n\n/**\n * Redeem an email-confirmation link (`/verify-email?token=…`, docs/auth-harmonization.md\n * §7) — keksdose's `VerifyEmailPage` (features/auth/verify-email-page.tsx), with\n * kastlan's outcome blocks and its separate \"expired\".\n *\n * Opened from an inbox, often in a browser with no session, so the token is the only\n * credential and the page renders signed-out. It redeems once per token on mount\n * (StrictMode's double effect included — the token is single-use) and shows one of:\n * confirmed; not valid; expired; or the link had no token at all. Verification gates\n * nothing (§2.8), so every outcome ends on \"Continue\". Signed in, a dead link also\n * offers \"Send again\", which waits `cooldown` seconds after a mail went out.\n *\n * The outcome replaces the spinner, which says nothing to a screen reader on its own,\n * so it is also announced.\n */\nexport function VerifyEmailStatus({\n token,\n onVerify,\n classifyError,\n describeError,\n signedIn = false,\n onResend,\n cooldown = DEFAULT_COOLDOWN,\n continueHref,\n verifiedContent,\n title,\n headingAs: Heading = \"h2\",\n labels: labelsProp,\n className,\n ...rest\n}: VerifyEmailStatusProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const [settled, setSettled] = useState<{ token: string; outcome: VerifyOutcome } | null>(null);\n const outcome: VerifyOutcome | \"verifying\" =\n token === \"\" ? \"invalid\" : settled?.token === token ? settled.outcome : \"verifying\";\n const { announce, regionProps } = useAnnounce();\n const resend = useResend(onResend, cooldown);\n\n useOncePerKey(token === \"\" ? null : token, onVerify, (key, result) => {\n // Without a classifier, the coded refusal decides (0.29.1): `token_expired` is\n // \"expired\", anything else \"invalid\".\n const next: VerifyOutcome = result.ok\n ? \"verified\"\n : (classifyError ?? defaultVerifyFailure)(result.error);\n setSettled({ token: key, outcome: next });\n announce(labels[next]);\n });\n\n const href = continueHref ?? (signedIn ? \"/\" : \"/login\");\n // `replace`: the token is spent, so Back must not land on this page again (keksdose F1).\n const continueButton = (\n <Button href={href} replace variant={outcome === \"verified\" ? \"brand\" : \"secondary\"}>\n {labels.continue}\n </Button>\n );\n const canResend = signedIn && onResend !== undefined;\n\n let body: ReactNode;\n if (outcome === \"verifying\") {\n body = <LoadingState size=\"sm\" label={labels.verifying} />;\n } else if (outcome === \"verified\") {\n body = (\n <EmptyState\n tone=\"success\"\n icon={<CheckCircle2 />}\n title={labels.verified}\n hint={verifiedContent}\n action={continueButton}\n className={OUTCOME_CLASS}\n />\n );\n } else {\n const hint = (\n <>\n {outcome === \"invalid\" && token !== \"\" ? `${labels.invalidHint} ` : \"\"}\n {canResend ? labels.requestHere : labels.requestInApp}\n </>\n );\n body = (\n <EmptyState\n tone=\"danger\"\n icon={outcome === \"expired\" ? <TimerOff /> : <XCircle />}\n title={token === \"\" ? labels.noToken : labels[outcome]}\n hint={hint}\n action={\n <>\n {canResend && <ResendButton state={resend} labels={labels} variant=\"brand\" />}\n {continueButton}\n </>\n }\n className={OUTCOME_CLASS}\n />\n );\n }\n\n return (\n <div\n {...rest}\n data-state={outcome}\n aria-busy={outcome === \"verifying\" || undefined}\n className={cn(\"space-y-3\", className)}\n >\n {title === null ? null : <Heading className={STATUS_HEADING_CLASS}>{title ?? labels.title}</Heading>}\n {body}\n {canResend && (\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"block text-center text-xs\"\n />\n )}\n {/* Rendered from the start, so the outcome is read when it arrives. */}\n <div {...regionProps} />\n </div>\n );\n}\n\n/* ── The banner ──────────────────────────────────────────────────────────── */\n\nexport interface EmailVerificationBannerProps {\n /** Send a new confirmation mail (`POST /auth/verify-email/resend`). Resolve when it\n * went out; reject and the banner says it could not. */\n onResend: () => Promise<unknown> | void;\n /** 0.29.1: the words for a refused resend — the server's own sentence, else the kit's. */\n describeError?: (error: unknown) => string | undefined;\n /** Seconds \"Send again\" waits after a mail went out. Default 60; `0` never waits. */\n cooldown?: number;\n /** The ×, \"Not now\". The banner does not hide itself: the app stops rendering it —\n * keksdose for the rest of the session. Left out, no ×. */\n onDismiss?: () => void;\n /** `strip` (default): keksdose's band across the top of the shell. `box`: kastlan's\n * callout inside the page. */\n variant?: \"strip\" | \"box\";\n /** The app's sentence after the kit's — keksdose's \"Until you do, nobody can share a\n * budget with you directly.\" */\n children?: ReactNode;\n className?: string;\n labels?: Partial<VerifyEmailLabels>;\n}\n\n/**\n * The nudge for a signed-in account whose address is not confirmed — keksdose's\n * `VerifyEmailBanner` (features/auth/verify-email-banner.tsx), kastlan's copy of it.\n *\n * A prompt, not a wall: verification gates nothing (§2.8). The app renders it while\n * `/auth/me` says `email_verified: false`, and stops when the user dismisses it or the\n * page above confirms the address. \"Send again\" waits `cooldown` seconds after a mail\n * went out (the button says how long), and its outcome is written into the banner and\n * read out — no toast needed.\n */\nexport function EmailVerificationBanner({\n onResend,\n describeError,\n cooldown = DEFAULT_COOLDOWN,\n onDismiss,\n variant = \"strip\",\n children,\n className,\n labels: labelsProp,\n}: EmailVerificationBannerProps) {\n const labels = useKitLabels(\"verifyEmail\", DEFAULT_VERIFY_EMAIL_LABELS, labelsProp);\n const resend = useResend(onResend, cooldown);\n return (\n <AlertBanner\n tone=\"warning\"\n variant={variant}\n icon={<MailWarning />}\n action={<ResendButton state={resend} labels={labels} variant=\"secondary\" />}\n onDismiss={onDismiss}\n dismissLabel={onDismiss ? labels.dismiss : undefined}\n className={className}\n >\n {labels.banner}\n {children != null && children !== false && <> {children}</>}{\" \"}\n <ResendStatus\n phase={resend.phase}\n error={resend.error}\n describeError={describeError}\n labels={labels}\n className=\"font-medium\"\n />\n </AlertBanner>\n );\n}\n"],"mappings":";AA2II,SAyKE,UAzKF,KAyKE,YAzKF;AA3IJ,SAAS,WAAW,gBAAgB;AAEpC,SAAS,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