@eifi1/ui-kit 0.28.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/account/account-parts.d.ts +21 -0
- package/dist/account/account-parts.js +40 -0
- package/dist/account/account-parts.js.map +1 -0
- package/dist/account/data-export-setting.d.ts +73 -0
- package/dist/account/data-export-setting.js +113 -0
- package/dist/account/data-export-setting.js.map +1 -0
- package/dist/account/delete-account-setting.d.ts +91 -0
- package/dist/account/delete-account-setting.js +199 -0
- package/dist/account/delete-account-setting.js.map +1 -0
- package/dist/account/email-change-setting.d.ts +136 -0
- package/dist/account/email-change-setting.js +277 -0
- package/dist/account/email-change-setting.js.map +1 -0
- package/dist/account/sessions-setting.d.ts +110 -0
- package/dist/account/sessions-setting.js +146 -0
- package/dist/account/sessions-setting.js.map +1 -0
- package/dist/admin/admin-action-confirm.d.ts +91 -0
- package/dist/admin/admin-action-confirm.js +276 -0
- package/dist/admin/admin-action-confirm.js.map +1 -0
- package/dist/admin/admin-action-log.d.ts +105 -0
- package/dist/admin/admin-action-log.js +153 -0
- package/dist/admin/admin-action-log.js.map +1 -0
- package/dist/admin/admin-parts.d.ts +40 -0
- package/dist/admin/admin-parts.js +45 -0
- package/dist/admin/admin-parts.js.map +1 -0
- package/dist/admin/invitations-panel.d.ts +91 -0
- package/dist/admin/invitations-panel.js +289 -0
- package/dist/admin/invitations-panel.js.map +1 -0
- package/dist/admin/reviewer-scope-editor.d.ts +91 -0
- package/dist/admin/reviewer-scope-editor.js +134 -0
- package/dist/admin/reviewer-scope-editor.js.map +1 -0
- package/dist/admin/role-select.d.ts +91 -0
- package/dist/admin/role-select.js +128 -0
- package/dist/admin/role-select.js.map +1 -0
- package/dist/admin/transfer-ownership-dialog.d.ts +91 -0
- package/dist/admin/transfer-ownership-dialog.js +83 -0
- package/dist/admin/transfer-ownership-dialog.js.map +1 -0
- package/dist/admin/user-roster.d.ts +91 -0
- package/dist/admin/user-roster.js +285 -0
- package/dist/admin/user-roster.js.map +1 -0
- package/dist/auth/accept-invitation.d.ts +90 -0
- package/dist/auth/accept-invitation.js +117 -0
- package/dist/auth/accept-invitation.js.map +1 -0
- package/dist/auth/auth-errors.d.ts +139 -0
- package/dist/auth/auth-errors.js +92 -0
- package/dist/auth/auth-errors.js.map +1 -0
- package/dist/auth/complete-name-dialog.d.ts +71 -0
- package/dist/auth/complete-name-dialog.js +168 -0
- package/dist/auth/complete-name-dialog.js.map +1 -0
- package/dist/auth/email-tag.d.ts +60 -0
- package/dist/auth/email-tag.js +23 -0
- package/dist/auth/email-tag.js.map +1 -0
- package/dist/auth/forgot-password-form.d.ts +86 -0
- package/dist/auth/forgot-password-form.js +123 -0
- package/dist/auth/forgot-password-form.js.map +1 -0
- package/dist/auth/form-rules.d.ts +27 -0
- package/dist/auth/form-rules.js +23 -0
- package/dist/auth/form-rules.js.map +1 -0
- package/dist/auth/new-password-fields.d.ts +38 -0
- package/dist/auth/new-password-fields.js +54 -0
- package/dist/auth/new-password-fields.js.map +1 -0
- package/dist/auth/not-found-page.d.ts +57 -0
- package/dist/auth/not-found-page.js +40 -0
- package/dist/auth/not-found-page.js.map +1 -0
- package/dist/auth/register-form.d.ts +91 -0
- package/dist/auth/register-form.js +270 -0
- package/dist/auth/register-form.js.map +1 -0
- package/dist/auth/reset-password-form.d.ts +131 -0
- package/dist/auth/reset-password-form.js +167 -0
- package/dist/auth/reset-password-form.js.map +1 -0
- package/dist/auth/sign-in-form.d.ts +295 -0
- package/dist/auth/sign-in-form.js +426 -0
- package/dist/auth/sign-in-form.js.map +1 -0
- package/dist/auth/status-parts.d.ts +78 -0
- package/dist/auth/status-parts.js +83 -0
- package/dist/auth/status-parts.js.map +1 -0
- package/dist/auth/verify-email.d.ts +126 -0
- package/dist/auth/verify-email.js +243 -0
- package/dist/auth/verify-email.js.map +1 -0
- package/dist/chart.d.ts +25 -5
- package/dist/components/account-chips.d.ts +47 -7
- package/dist/components/account-chips.js +19 -3
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +12 -1
- package/dist/components/account-settings-labels.js +4 -1
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/account-settings.d.ts +61 -6
- package/dist/components/account-settings.js +115 -15
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +26 -5
- package/dist/components/button-group.d.ts +26 -5
- package/dist/components/calculator.d.ts +26 -5
- package/dist/components/confirm-dialog.d.ts +26 -5
- package/dist/components/copy-button.d.ts +23 -2
- package/dist/components/danger-confirm.d.ts +26 -5
- package/dist/components/facing-pair.d.ts +26 -5
- package/dist/components/file-button.d.ts +26 -5
- package/dist/components/file-dropzone.d.ts +26 -5
- package/dist/components/form-actions.d.ts +26 -5
- package/dist/components/iban-input.d.ts +26 -5
- package/dist/components/language-select.d.ts +26 -12
- package/dist/components/legal-page.d.ts +26 -5
- package/dist/components/legal.d.ts +26 -5
- package/dist/components/money-field.d.ts +26 -5
- package/dist/components/number-field.d.ts +26 -5
- package/dist/components/number-input.d.ts +26 -5
- package/dist/components/numpad-sheet.d.ts +26 -5
- package/dist/components/phone-input.d.ts +26 -5
- package/dist/components/series-chart.d.ts +26 -5
- package/dist/components/settings-fields.d.ts +25 -7
- package/dist/components/share-card.d.ts +25 -4
- package/dist/components/text-link.d.ts +26 -5
- package/dist/components/time-input.d.ts +26 -5
- package/dist/components/ui.d.ts +23 -2
- package/dist/components/user-avatar.d.ts +16 -2
- package/dist/components/user-avatar.js +7 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/{kit-labels-Du0uHBq4.d.ts → delete-account-setting-CGVMckMw.d.ts} +6654 -5302
- package/dist/feedback/feedback-attachment.d.ts +26 -5
- package/dist/feedback/feedback-context.d.ts +26 -5
- package/dist/feedback/feedback-crash.d.ts +26 -5
- package/dist/feedback/feedback-dialog.d.ts +26 -5
- package/dist/feedback/feedback-inbox.d.ts +26 -5
- package/dist/feedback/feedback-labels.d.ts +26 -5
- package/dist/feedback/feedback-menu.d.ts +26 -5
- package/dist/feedback/feedback-record.d.ts +26 -5
- package/dist/feedback/feedback-row-detail.d.ts +26 -5
- package/dist/feedback/feedback-status-undo.d.ts +26 -5
- package/dist/feedback/feedback-submit.d.ts +26 -5
- package/dist/feedback/feedback-swipe.d.ts +26 -5
- package/dist/feedback/feedback-table.d.ts +23 -2
- package/dist/feedback/feedback-thread.d.ts +26 -5
- package/dist/feedback.d.ts +26 -5
- package/dist/hooks/use-anchored-panel.d.ts +6 -2
- package/dist/hooks/use-anchored-panel.js +2 -1
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +26 -5
- package/dist/i18n/defaults.d.ts +26 -5
- package/dist/i18n/defaults.js +40 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +26 -5
- package/dist/i18n/german.js +343 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +23 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +21 -204
- package/dist/i18n/locales/de-CH.d.ts +26 -5
- package/dist/i18n/locales/en.d.ts +26 -5
- package/dist/i18n/locales/es.d.ts +26 -5
- package/dist/i18n/locales/es.js +337 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +26 -5
- package/dist/i18n/locales/fr.js +344 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +26 -5
- package/dist/i18n/locales/hu.js +337 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +26 -5
- package/dist/i18n/locales/it.js +342 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +26 -5
- package/dist/i18n/locales/zh.js +333 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +26 -5
- package/dist/i18n/review.js +45 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/person-name.d.ts +69 -0
- package/dist/lib/person-name.js +65 -0
- package/dist/lib/person-name.js.map +1 -0
- package/dist/rhf/fields.d.ts +26 -5
- package/dist/rhf/form.d.ts +26 -5
- package/dist/rhf.d.ts +26 -5
- package/dist/shell/app-shell.d.ts +26 -5
- package/dist/shell/company-switcher.d.ts +59 -0
- package/dist/shell/company-switcher.js +85 -0
- package/dist/shell/company-switcher.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +26 -5
- package/dist/shell/topbar-action-menu.d.ts +1 -0
- package/dist/shell.d.ts +20 -5
- package/dist/wizard/stepper-nav.d.ts +26 -5
- package/dist/wizard.d.ts +26 -5
- package/package.json +1 -1
- package/src/account/account-parts.ts +67 -0
- package/src/account/data-export-setting.tsx +218 -0
- package/src/account/delete-account-setting.tsx +362 -0
- package/src/account/email-change-setting.tsx +457 -0
- package/src/account/sessions-setting.tsx +283 -0
- package/src/admin/admin-action-confirm.tsx +495 -0
- package/src/admin/admin-action-log.tsx +297 -0
- package/src/admin/admin-parts.ts +82 -0
- package/src/admin/invitations-panel.tsx +516 -0
- package/src/admin/reviewer-scope-editor.tsx +234 -0
- package/src/admin/role-select.tsx +286 -0
- package/src/admin/transfer-ownership-dialog.tsx +172 -0
- package/src/admin/user-roster.tsx +573 -0
- package/src/auth/accept-invitation.tsx +227 -0
- package/src/auth/auth-errors.ts +262 -0
- package/src/auth/complete-name-dialog.tsx +253 -0
- package/src/auth/email-tag.ts +75 -0
- package/src/auth/forgot-password-form.tsx +229 -0
- package/src/auth/form-rules.ts +40 -0
- package/src/auth/new-password-fields.tsx +85 -0
- package/src/auth/not-found-page.tsx +98 -0
- package/src/auth/register-form.tsx +477 -0
- package/src/auth/reset-password-form.tsx +351 -0
- package/src/auth/sign-in-form.tsx +859 -0
- package/src/auth/status-parts.tsx +138 -0
- package/src/auth/verify-email.tsx +409 -0
- package/src/components/account-chips.tsx +64 -7
- package/src/components/account-settings-labels.ts +15 -1
- package/src/components/account-settings.tsx +199 -23
- package/src/components/user-avatar.tsx +22 -4
- package/src/hooks/use-anchored-panel.ts +14 -3
- package/src/i18n/defaults.ts +40 -0
- package/src/i18n/german.ts +379 -0
- package/src/i18n/kit-labels.tsx +60 -0
- package/src/i18n/locales/es.ts +371 -1
- package/src/i18n/locales/fr.ts +379 -0
- package/src/i18n/locales/hu.ts +366 -1
- package/src/i18n/locales/it.ts +373 -0
- package/src/i18n/locales/zh.ts +343 -0
- package/src/i18n/review.ts +44 -0
- package/src/index.ts +146 -0
- package/src/lib/person-name.ts +157 -0
- package/src/shell/company-switcher.tsx +140 -0
|
@@ -0,0 +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":"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","names":["email","notices"]}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a sign-in call answers, in the kit's words — docs/auth-harmonization.md §5.1,
|
|
6
|
+
* keksdose's three shapes. The app maps its own HTTP answer to one of these and resolves
|
|
7
|
+
* with it; a refusal REJECTS (with whatever its client throws — {@link authErrorCode}
|
|
8
|
+
* reads the code out of it).
|
|
9
|
+
*
|
|
10
|
+
* | the server answers (keksdose) | resolve with |
|
|
11
|
+
* |---|---|
|
|
12
|
+
* | `TokenResponse` `{access_token, refresh_token, token_type, user}` | `{ kind: "signed-in" }`, after the app has stored the session |
|
|
13
|
+
* | `{requires_2fa: true, challenge_token}` | `{ kind: "2fa", challengeToken: challenge_token }` |
|
|
14
|
+
* | `{requires_password_change: true, challenge_token, encrypted}` | `{ kind: "password-change", challengeToken: challenge_token, extra: { encrypted } }` |
|
|
15
|
+
* | `401 {code: "invalid_credentials"}` | reject — let the client's error through |
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* async function toAnswer(res: TokenResponse | TwoFactorChallenge | PasswordChangeChallenge): Promise<SignInAnswer> {
|
|
19
|
+
* if ("requires_2fa" in res) return { kind: "2fa", challengeToken: res.challenge_token };
|
|
20
|
+
* if ("requires_password_change" in res)
|
|
21
|
+
* return { kind: "password-change", challengeToken: res.challenge_token, extra: { encrypted: res.encrypted } };
|
|
22
|
+
* await onLoginSuccess(res); // store tokens, load /auth/me, switch language
|
|
23
|
+
* return { kind: "signed-in" };
|
|
24
|
+
* }
|
|
25
|
+
* <SignInForm onSubmit={async (v) => toAnswer(await authApi.login(v))} … />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* The same mapping serves `/auth/login/2fa`, `/auth/login/set-password` and the passkey
|
|
29
|
+
* finish, which answer the same union.
|
|
30
|
+
*/
|
|
31
|
+
type SignInAnswer = {
|
|
32
|
+
kind: "signed-in";
|
|
33
|
+
} | {
|
|
34
|
+
kind: "2fa";
|
|
35
|
+
challengeToken: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "password-change";
|
|
38
|
+
challengeToken: string;
|
|
39
|
+
/** The challenge's app fields, passed through untouched — keksdose's `encrypted`,
|
|
40
|
+
* which its note on this step reads (`passwordChangeContent`). */
|
|
41
|
+
extra?: Readonly<Record<string, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
/** The step on screen: the credentials, the second factor, or a new password. */
|
|
44
|
+
type SignInStep = "credentials" | "2fa" | "password-change";
|
|
45
|
+
/** What the person did when a call failed — {@link SignInFormProps.describeError}'s
|
|
46
|
+
* second argument. */
|
|
47
|
+
type SignInAction = "password" | "passkey" | "code" | "set-password";
|
|
48
|
+
interface SignInCredentials {
|
|
49
|
+
/** Trimmed. Lower-casing is the server's (§3.1). */
|
|
50
|
+
email: string;
|
|
51
|
+
/** As typed, never trimmed. */
|
|
52
|
+
password: string;
|
|
53
|
+
}
|
|
54
|
+
interface SignInCodeValues {
|
|
55
|
+
challengeToken: string;
|
|
56
|
+
/** Digits only — {@link OneTimeCodeInput} drops the spaces of "123 456". A backup code
|
|
57
|
+
* (`kind: "recovery"`) is trimmed and otherwise as typed: its dashes and case are the
|
|
58
|
+
* server's to normalise, as kastlan's `_normalise_backup_code` does. */
|
|
59
|
+
code: string;
|
|
60
|
+
/**
|
|
61
|
+
* 0.30.0: `"recovery"` when the person typed one of their backup codes instead
|
|
62
|
+
* (`recoveryCode`); absent for the authenticator's code, as before. kastlan's
|
|
63
|
+
* `/auth/login/2fa` takes either in the same `code` and tells them apart itself; an
|
|
64
|
+
* app whose server takes a backup code elsewhere routes on this.
|
|
65
|
+
*/
|
|
66
|
+
kind?: "recovery";
|
|
67
|
+
}
|
|
68
|
+
interface SignInNewPasswordValues {
|
|
69
|
+
challengeToken: string;
|
|
70
|
+
password: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Every string `SignInForm` renders — the `signIn` namespace of `<UiKitProvider
|
|
74
|
+
* labels>`, overridable per instance through `labels`. keksdose's words where it has
|
|
75
|
+
* them (`auth.*` in its catalogue).
|
|
76
|
+
*/
|
|
77
|
+
interface SignInLabels {
|
|
78
|
+
email: string;
|
|
79
|
+
password: string;
|
|
80
|
+
/** The submit button. */
|
|
81
|
+
submit: string;
|
|
82
|
+
/** The passkey button (`onPasskey`). */
|
|
83
|
+
passkey: string;
|
|
84
|
+
/** The link to `forgotHref`. */
|
|
85
|
+
forgotPassword: string;
|
|
86
|
+
/** Before the link to `registerHref`. */
|
|
87
|
+
noAccount: string;
|
|
88
|
+
/** The link to `registerHref`. */
|
|
89
|
+
register: string;
|
|
90
|
+
/** The ONE answer to an unknown address, a wrong password and a deactivated account
|
|
91
|
+
* (`invalid_credentials`, §5.2). */
|
|
92
|
+
invalidCredentials: string;
|
|
93
|
+
/** Any other failed sign-in (the network, a 500). */
|
|
94
|
+
failed: string;
|
|
95
|
+
/** A failed or refused passkey sign-in. */
|
|
96
|
+
passkeyFailed: string;
|
|
97
|
+
/**
|
|
98
|
+
* The hint under `invalidCredentials` (§2.10), shown when `deactivatedContact` is
|
|
99
|
+
* given. A TEMPLATE: `{contact}` is replaced by the contact — a `mailto:` link for an
|
|
100
|
+
* address — so a language puts it where its grammar needs it.
|
|
101
|
+
*/
|
|
102
|
+
deactivatedHint: string;
|
|
103
|
+
/** The hint under `invalidCredentials` when `emailTag` is given (§4.5), given the
|
|
104
|
+
* typed address with the app's tag: "Signed up with ada+kastlan@example.com?". */
|
|
105
|
+
tagHint: (taggedAddress: string) => string;
|
|
106
|
+
/** The second-factor step's heading. */
|
|
107
|
+
twoFactorTitle: string;
|
|
108
|
+
twoFactorIntro: string;
|
|
109
|
+
/** The code field's label. */
|
|
110
|
+
code: string;
|
|
111
|
+
/** The code step's submit button. */
|
|
112
|
+
verify: string;
|
|
113
|
+
/** The code was refused. */
|
|
114
|
+
codeInvalid: string;
|
|
115
|
+
/** The set-a-new-password step's heading. */
|
|
116
|
+
setPasswordTitle: string;
|
|
117
|
+
setPasswordIntro: string;
|
|
118
|
+
newPassword: string;
|
|
119
|
+
confirmPassword: string;
|
|
120
|
+
passwordMismatch: string;
|
|
121
|
+
/** The set-a-new-password step's submit button. */
|
|
122
|
+
setPasswordSubmit: string;
|
|
123
|
+
setPasswordFailed: string;
|
|
124
|
+
/** A challenge was refused as `token_invalid` — it expired between the steps; the
|
|
125
|
+
* form is back on the credentials. */
|
|
126
|
+
expired: string;
|
|
127
|
+
/** From the second and third step back to the credentials. */
|
|
128
|
+
backToSignIn: string;
|
|
129
|
+
/** The second-factor step's switch to a backup code (`recoveryCode`). */
|
|
130
|
+
useRecoveryCode?: string;
|
|
131
|
+
/** The switch back, from the backup-code field to the authenticator's code. */
|
|
132
|
+
useAuthenticatorCode?: string;
|
|
133
|
+
/** The backup-code field's label. */
|
|
134
|
+
recoveryCode?: string;
|
|
135
|
+
/** The step's intro while a backup code is asked for, in place of `twoFactorIntro`. */
|
|
136
|
+
recoveryIntro?: string;
|
|
137
|
+
/** Under the backup-code field, given how many letters and digits a code has. */
|
|
138
|
+
recoveryCodeHint?: (length: number) => string;
|
|
139
|
+
/** A refused backup code — wrong, or spent already (each one works once). */
|
|
140
|
+
recoveryCodeInvalid?: string;
|
|
141
|
+
/** Any step's request was throttled — HTTP 429 ({@link isRateLimited}) — given the
|
|
142
|
+
* wait its `Retry-After` asks for, in seconds ({@link retryAfterSeconds}), or
|
|
143
|
+
* `undefined` (or `0`) without one. */
|
|
144
|
+
rateLimited?: (seconds?: number) => string;
|
|
145
|
+
}
|
|
146
|
+
/** `Required`: every key, the 0.30 ones included, has its English here. */
|
|
147
|
+
declare const DEFAULT_SIGN_IN_LABELS: Required<SignInLabels>;
|
|
148
|
+
interface SignInFormProps extends Omit<ComponentPropsWithoutRef<"div">, "onSubmit" | "children"> {
|
|
149
|
+
/**
|
|
150
|
+
* The credentials step was submitted. Send them, and resolve with the answer
|
|
151
|
+
* ({@link SignInAnswer}) or reject with the client's error. The form never sends a
|
|
152
|
+
* request itself (§8): keksdose must see the password on its way, to refuse the same
|
|
153
|
+
* string as an encryption passphrase later.
|
|
154
|
+
*
|
|
155
|
+
* On `signed-in` the form's job is over — it stays busy while the app navigates.
|
|
156
|
+
*/
|
|
157
|
+
onSubmit: (credentials: SignInCredentials) => Promise<SignInAnswer>;
|
|
158
|
+
/** The second factor was submitted (`/auth/login/2fa`). Resolves with the next answer
|
|
159
|
+
* — keksdose may still require a new password after the code. */
|
|
160
|
+
onCode: (values: SignInCodeValues) => Promise<SignInAnswer>;
|
|
161
|
+
/** The new password was submitted (`/auth/login/set-password`). Resolves with the
|
|
162
|
+
* answer, `signed-in` in practice; keksdose's `key_wrap_unchanged` note is the app's
|
|
163
|
+
* to show from here. */
|
|
164
|
+
onSetPassword: (values: SignInNewPasswordValues) => Promise<SignInAnswer>;
|
|
165
|
+
/**
|
|
166
|
+
* The passkey button was pressed: run the ceremony (`/auth/passkey/login/begin|finish`)
|
|
167
|
+
* and resolve with its answer. It asks for NO email — a passkey is bound to the site,
|
|
168
|
+
* and the browser offers every one it holds (keksdose #126). Left out, no button: pass
|
|
169
|
+
* it only where `PublicKeyCredential` exists.
|
|
170
|
+
*/
|
|
171
|
+
onPasskey?: () => Promise<SignInAnswer>;
|
|
172
|
+
/**
|
|
173
|
+
* Passkey autofill (conditional mediation). The email field is
|
|
174
|
+
* `autoComplete="username webauthn"`, so a pending `navigator.credentials.get({
|
|
175
|
+
* mediation: "conditional" })` lists the site's passkeys in its dropdown. The form
|
|
176
|
+
* calls this ONCE on mount; arm the request there and resolve with its answer when the
|
|
177
|
+
* person picks a passkey, or with `null` when nothing happens. The signal aborts on
|
|
178
|
+
* unmount — cancel the pending request then (keksdose: `armPasskeyAutofill(onDone,
|
|
179
|
+
* signal)` + `cancelPasskeyAutofill()`). A rejection is silent: the button stays the
|
|
180
|
+
* reliable path.
|
|
181
|
+
*/
|
|
182
|
+
passkeyAutofill?: (signal: AbortSignal) => Promise<SignInAnswer | null | undefined>;
|
|
183
|
+
/** "Forgot your password?" goes here — the app's `/forgot-password`. Left out, no
|
|
184
|
+
* link. */
|
|
185
|
+
forgotHref?: string;
|
|
186
|
+
/** "No account yet? Create account" goes here — `/register`. Left out, no line. */
|
|
187
|
+
registerHref?: string;
|
|
188
|
+
/** The email field's start value — the reset page ends on "Sign in" with the address
|
|
189
|
+
* filled in (§6.3). */
|
|
190
|
+
defaultEmail?: string;
|
|
191
|
+
/**
|
|
192
|
+
* The app's address tag (`"kastlan"`, §4.5). After `invalid_credentials` the form also
|
|
193
|
+
* says "Signed up with you+kastlan@example.com? Use that address." — sign-in stays
|
|
194
|
+
* exact, and the server looks nothing up.
|
|
195
|
+
*/
|
|
196
|
+
emailTag?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Who a deactivated user writes to (§2.10): an address (drawn as a `mailto:` link) or
|
|
199
|
+
* the app's own node. Shown after `invalid_credentials` as "Account deactivated? Write
|
|
200
|
+
* to …". Left out, no hint.
|
|
201
|
+
*/
|
|
202
|
+
deactivatedContact?: ReactNode;
|
|
203
|
+
/** Digits of the second factor. Default 6 (TOTP). */
|
|
204
|
+
codeLength?: number;
|
|
205
|
+
/**
|
|
206
|
+
* 0.30.0: offer a backup code on the second-factor step (kastlan's 0.29 adoption: its
|
|
207
|
+
* `/auth/login/2fa` takes one of the eight codes minted at 2FA setup, and the kit's
|
|
208
|
+
* step had no way to type one). A "Use a backup code" switch under the code field
|
|
209
|
+
* swaps the digits-only {@link OneTimeCodeInput} for a plain text field; the code goes
|
|
210
|
+
* to `onCode` with the same challenge and `kind: "recovery"`.
|
|
211
|
+
*
|
|
212
|
+
* `true` for a 16-character code (kastlan's `ABCD-EFGH-JKLM-NPQR`), or `{ length }`.
|
|
213
|
+
* The length counts letters and digits only — the dashes and spaces a printed code is
|
|
214
|
+
* grouped with don't count — and "Verify" waits for it. Left out, no switch.
|
|
215
|
+
*/
|
|
216
|
+
recoveryCode?: boolean | {
|
|
217
|
+
length?: number;
|
|
218
|
+
};
|
|
219
|
+
/** App content at the top of the credentials step — a notice, a demo button. */
|
|
220
|
+
credentialsContent?: ReactNode;
|
|
221
|
+
/**
|
|
222
|
+
* App content on the second-factor step, under its intro. 0.30.0: pass a function and
|
|
223
|
+
* it gets the challenge token — kastlan kept its own copy of the token for a "lost
|
|
224
|
+
* your device?" link, which the step now hands over.
|
|
225
|
+
*/
|
|
226
|
+
twoFactorContent?: ReactNode | ((challengeToken: string) => ReactNode);
|
|
227
|
+
/**
|
|
228
|
+
* App content on the set-a-new-password step, under its intro — keksdose's
|
|
229
|
+
* private-mode note ("Your encrypted data is untouched …"), which depends on the
|
|
230
|
+
* challenge: pass a function and it gets the challenge's `extra`.
|
|
231
|
+
*/
|
|
232
|
+
passwordChangeContent?: ReactNode | ((extra: Readonly<Record<string, unknown>> | undefined) => ReactNode);
|
|
233
|
+
/**
|
|
234
|
+
* The app's own words for a failure, or `undefined` for the kit's: the device being
|
|
235
|
+
* offline, a throttle with its wait ("try again in an hour"). Asked first, for every
|
|
236
|
+
* failure; what it returns replaces the message, and the `invalid_credentials` hints
|
|
237
|
+
* still follow. A bare `429` needs none since 0.30.0: the kit says `rateLimited`.
|
|
238
|
+
*/
|
|
239
|
+
describeError?: (error: unknown, action: SignInAction) => ReactNode | undefined;
|
|
240
|
+
/** The step changed — retitle the page (`AuthLayout`'s `title`) if the app wants. */
|
|
241
|
+
onStepChange?: (step: SignInStep) => void;
|
|
242
|
+
/** The level of the second and third step's heading. Default `h2`, under the page's
|
|
243
|
+
* `h1`; one level under `AuthLayout`'s `headingAs` where that is embedded lower. */
|
|
244
|
+
headingAs?: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
245
|
+
labels?: Partial<SignInLabels>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Sign-in for every app (docs/auth-harmonization.md §5, §8): email and password, or a
|
|
249
|
+
* passkey; then the second factor when it is on; then a new password when an admin
|
|
250
|
+
* required one. keksdose's `LoginPage` and `ForcedPasswordChangeStep`
|
|
251
|
+
* (features/auth/login-page.tsx, forced-password-change.tsx), as one component.
|
|
252
|
+
*
|
|
253
|
+
* **It never sends a request.** Each step hands its input to a callback and renders the
|
|
254
|
+
* {@link SignInAnswer} it resolves with; a rejection is shown in the step it came from.
|
|
255
|
+
* The challenge token lives in this component's state only, as in keksdose, so a reload
|
|
256
|
+
* costs a fresh sign-in — no route, no storage.
|
|
257
|
+
*
|
|
258
|
+
* **One error for every wrong credential** (§2.10, §5.2): `invalid_credentials` shows one
|
|
259
|
+
* sentence, whatever was wrong, plus two hints UNDER it — "Account deactivated? Write to
|
|
260
|
+
* …" (`deactivatedContact`) and "Signed up with you+kastlan@…? Use that address."
|
|
261
|
+
* (`emailTag`). Any other failure says "Sign-in failed" and no hint: the hints answer a
|
|
262
|
+
* refused credential, not a network that is down. `describeError` puts the app's words
|
|
263
|
+
* on a failure the kit cannot know (a throttled attempt).
|
|
264
|
+
*
|
|
265
|
+
* **The steps.**
|
|
266
|
+
* - Credentials: the email field is `username webauthn` (passkey autofill, see
|
|
267
|
+
* `passkeyAutofill`), the password a `CurrentPasswordInput` (a password manager fills
|
|
268
|
+
* it and never offers a new one). The submit is not disabled while the fields are
|
|
269
|
+
* empty: a browser that autofills on load withholds the values until the first
|
|
270
|
+
* interaction, and a disabled button would swallow that first click. The fields'
|
|
271
|
+
* own `required` answers an empty submit instead. "Forgot your password?" sits under
|
|
272
|
+
* the buttons, where someone whose password just failed is already looking
|
|
273
|
+
* (keksdose #198).
|
|
274
|
+
* - Second factor: {@link OneTimeCodeInput}, focused on arrival. "Verify" waits for the
|
|
275
|
+
* whole code. A refused code stays here with its error; `token_invalid` (the
|
|
276
|
+
* challenge expired) goes back to the credentials and says why. Kurvenschmiede has
|
|
277
|
+
* no 2FA yet, and the step is here from the start, so adding it is backend work only
|
|
278
|
+
* (§10.5). With `recoveryCode` (0.30.0) a switch under the field takes a backup code
|
|
279
|
+
* instead, through the same `onCode` with `kind: "recovery"`.
|
|
280
|
+
*
|
|
281
|
+
* **A throttled request** (HTTP 429, {@link isRateLimited}) says "Too many attempts. Try
|
|
282
|
+
* again in 30 s." on any step (0.30.0) — the wait from its `Retry-After`, else "Wait a
|
|
283
|
+
* moment and try again." — after `describeError`, whose words still come first, and
|
|
284
|
+
* instead of "wrong password" or "invalid code", which would send the person to try
|
|
285
|
+
* another one.
|
|
286
|
+
* - New password: new + confirm with the strength meter, the 8-character / 72-byte
|
|
287
|
+
* rules and nothing else (§8). It reads as explained, not blocked (keksdose): the
|
|
288
|
+
* person did nothing wrong.
|
|
289
|
+
*
|
|
290
|
+
* The password is dropped from state once the credentials are answered; "Back to sign in"
|
|
291
|
+
* returns to an empty password field.
|
|
292
|
+
*/
|
|
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;
|
|
294
|
+
|
|
295
|
+
export { DEFAULT_SIGN_IN_LABELS, type SignInAction, type SignInAnswer, type SignInCodeValues, type SignInCredentials, SignInForm, type SignInFormProps, type SignInLabels, type SignInNewPasswordValues, type SignInStep };
|