@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.
Files changed (228) hide show
  1. package/README.md +44 -4
  2. package/dist/account/account-parts.d.ts +21 -0
  3. package/dist/account/account-parts.js +40 -0
  4. package/dist/account/account-parts.js.map +1 -0
  5. package/dist/account/data-export-setting.d.ts +73 -0
  6. package/dist/account/data-export-setting.js +113 -0
  7. package/dist/account/data-export-setting.js.map +1 -0
  8. package/dist/account/delete-account-setting.d.ts +91 -0
  9. package/dist/account/delete-account-setting.js +199 -0
  10. package/dist/account/delete-account-setting.js.map +1 -0
  11. package/dist/account/email-change-setting.d.ts +136 -0
  12. package/dist/account/email-change-setting.js +277 -0
  13. package/dist/account/email-change-setting.js.map +1 -0
  14. package/dist/account/sessions-setting.d.ts +110 -0
  15. package/dist/account/sessions-setting.js +146 -0
  16. package/dist/account/sessions-setting.js.map +1 -0
  17. package/dist/admin/admin-action-confirm.d.ts +91 -0
  18. package/dist/admin/admin-action-confirm.js +276 -0
  19. package/dist/admin/admin-action-confirm.js.map +1 -0
  20. package/dist/admin/admin-action-log.d.ts +105 -0
  21. package/dist/admin/admin-action-log.js +153 -0
  22. package/dist/admin/admin-action-log.js.map +1 -0
  23. package/dist/admin/admin-parts.d.ts +40 -0
  24. package/dist/admin/admin-parts.js +45 -0
  25. package/dist/admin/admin-parts.js.map +1 -0
  26. package/dist/admin/invitations-panel.d.ts +91 -0
  27. package/dist/admin/invitations-panel.js +289 -0
  28. package/dist/admin/invitations-panel.js.map +1 -0
  29. package/dist/admin/reviewer-scope-editor.d.ts +91 -0
  30. package/dist/admin/reviewer-scope-editor.js +134 -0
  31. package/dist/admin/reviewer-scope-editor.js.map +1 -0
  32. package/dist/admin/role-select.d.ts +91 -0
  33. package/dist/admin/role-select.js +128 -0
  34. package/dist/admin/role-select.js.map +1 -0
  35. package/dist/admin/transfer-ownership-dialog.d.ts +91 -0
  36. package/dist/admin/transfer-ownership-dialog.js +83 -0
  37. package/dist/admin/transfer-ownership-dialog.js.map +1 -0
  38. package/dist/admin/user-roster.d.ts +91 -0
  39. package/dist/admin/user-roster.js +285 -0
  40. package/dist/admin/user-roster.js.map +1 -0
  41. package/dist/auth/accept-invitation.d.ts +90 -0
  42. package/dist/auth/accept-invitation.js +117 -0
  43. package/dist/auth/accept-invitation.js.map +1 -0
  44. package/dist/auth/auth-errors.d.ts +139 -0
  45. package/dist/auth/auth-errors.js +92 -0
  46. package/dist/auth/auth-errors.js.map +1 -0
  47. package/dist/auth/complete-name-dialog.d.ts +71 -0
  48. package/dist/auth/complete-name-dialog.js +168 -0
  49. package/dist/auth/complete-name-dialog.js.map +1 -0
  50. package/dist/auth/email-tag.d.ts +60 -0
  51. package/dist/auth/email-tag.js +23 -0
  52. package/dist/auth/email-tag.js.map +1 -0
  53. package/dist/auth/forgot-password-form.d.ts +86 -0
  54. package/dist/auth/forgot-password-form.js +123 -0
  55. package/dist/auth/forgot-password-form.js.map +1 -0
  56. package/dist/auth/form-rules.d.ts +27 -0
  57. package/dist/auth/form-rules.js +23 -0
  58. package/dist/auth/form-rules.js.map +1 -0
  59. package/dist/auth/new-password-fields.d.ts +38 -0
  60. package/dist/auth/new-password-fields.js +54 -0
  61. package/dist/auth/new-password-fields.js.map +1 -0
  62. package/dist/auth/not-found-page.d.ts +57 -0
  63. package/dist/auth/not-found-page.js +40 -0
  64. package/dist/auth/not-found-page.js.map +1 -0
  65. package/dist/auth/register-form.d.ts +91 -0
  66. package/dist/auth/register-form.js +270 -0
  67. package/dist/auth/register-form.js.map +1 -0
  68. package/dist/auth/reset-password-form.d.ts +131 -0
  69. package/dist/auth/reset-password-form.js +167 -0
  70. package/dist/auth/reset-password-form.js.map +1 -0
  71. package/dist/auth/sign-in-form.d.ts +295 -0
  72. package/dist/auth/sign-in-form.js +426 -0
  73. package/dist/auth/sign-in-form.js.map +1 -0
  74. package/dist/auth/status-parts.d.ts +78 -0
  75. package/dist/auth/status-parts.js +83 -0
  76. package/dist/auth/status-parts.js.map +1 -0
  77. package/dist/auth/verify-email.d.ts +126 -0
  78. package/dist/auth/verify-email.js +243 -0
  79. package/dist/auth/verify-email.js.map +1 -0
  80. package/dist/chart.d.ts +25 -5
  81. package/dist/components/account-chips.d.ts +47 -7
  82. package/dist/components/account-chips.js +19 -3
  83. package/dist/components/account-chips.js.map +1 -1
  84. package/dist/components/account-settings-labels.d.ts +12 -1
  85. package/dist/components/account-settings-labels.js +4 -1
  86. package/dist/components/account-settings-labels.js.map +1 -1
  87. package/dist/components/account-settings.d.ts +61 -6
  88. package/dist/components/account-settings.js +115 -15
  89. package/dist/components/account-settings.js.map +1 -1
  90. package/dist/components/amount-input.d.ts +26 -5
  91. package/dist/components/button-group.d.ts +26 -5
  92. package/dist/components/calculator.d.ts +26 -5
  93. package/dist/components/confirm-dialog.d.ts +26 -5
  94. package/dist/components/copy-button.d.ts +23 -2
  95. package/dist/components/danger-confirm.d.ts +26 -5
  96. package/dist/components/facing-pair.d.ts +26 -5
  97. package/dist/components/file-button.d.ts +26 -5
  98. package/dist/components/file-dropzone.d.ts +26 -5
  99. package/dist/components/form-actions.d.ts +26 -5
  100. package/dist/components/iban-input.d.ts +26 -5
  101. package/dist/components/language-select.d.ts +26 -12
  102. package/dist/components/legal-page.d.ts +26 -5
  103. package/dist/components/legal.d.ts +26 -5
  104. package/dist/components/money-field.d.ts +26 -5
  105. package/dist/components/number-field.d.ts +26 -5
  106. package/dist/components/number-input.d.ts +26 -5
  107. package/dist/components/numpad-sheet.d.ts +26 -5
  108. package/dist/components/phone-input.d.ts +26 -5
  109. package/dist/components/series-chart.d.ts +26 -5
  110. package/dist/components/settings-fields.d.ts +25 -7
  111. package/dist/components/share-card.d.ts +25 -4
  112. package/dist/components/text-link.d.ts +26 -5
  113. package/dist/components/time-input.d.ts +26 -5
  114. package/dist/components/ui.d.ts +23 -2
  115. package/dist/components/user-avatar.d.ts +16 -2
  116. package/dist/components/user-avatar.js +7 -3
  117. package/dist/components/user-avatar.js.map +1 -1
  118. package/dist/{kit-labels-Du0uHBq4.d.ts → delete-account-setting-CGVMckMw.d.ts} +6654 -5302
  119. package/dist/feedback/feedback-attachment.d.ts +26 -5
  120. package/dist/feedback/feedback-context.d.ts +26 -5
  121. package/dist/feedback/feedback-crash.d.ts +26 -5
  122. package/dist/feedback/feedback-dialog.d.ts +26 -5
  123. package/dist/feedback/feedback-inbox.d.ts +26 -5
  124. package/dist/feedback/feedback-labels.d.ts +26 -5
  125. package/dist/feedback/feedback-menu.d.ts +26 -5
  126. package/dist/feedback/feedback-record.d.ts +26 -5
  127. package/dist/feedback/feedback-row-detail.d.ts +26 -5
  128. package/dist/feedback/feedback-status-undo.d.ts +26 -5
  129. package/dist/feedback/feedback-submit.d.ts +26 -5
  130. package/dist/feedback/feedback-swipe.d.ts +26 -5
  131. package/dist/feedback/feedback-table.d.ts +23 -2
  132. package/dist/feedback/feedback-thread.d.ts +26 -5
  133. package/dist/feedback.d.ts +26 -5
  134. package/dist/hooks/use-anchored-panel.d.ts +6 -2
  135. package/dist/hooks/use-anchored-panel.js +2 -1
  136. package/dist/hooks/use-anchored-panel.js.map +1 -1
  137. package/dist/hooks/use-file-drop.d.ts +26 -5
  138. package/dist/i18n/defaults.d.ts +26 -5
  139. package/dist/i18n/defaults.js +40 -0
  140. package/dist/i18n/defaults.js.map +1 -1
  141. package/dist/i18n/german.d.ts +26 -5
  142. package/dist/i18n/german.js +343 -2
  143. package/dist/i18n/german.js.map +1 -1
  144. package/dist/i18n/kit-labels.d.ts +23 -2
  145. package/dist/i18n/kit-labels.js.map +1 -1
  146. package/dist/i18n/languages.d.ts +21 -204
  147. package/dist/i18n/locales/de-CH.d.ts +26 -5
  148. package/dist/i18n/locales/en.d.ts +26 -5
  149. package/dist/i18n/locales/es.d.ts +26 -5
  150. package/dist/i18n/locales/es.js +337 -3
  151. package/dist/i18n/locales/es.js.map +1 -1
  152. package/dist/i18n/locales/fr.d.ts +26 -5
  153. package/dist/i18n/locales/fr.js +344 -2
  154. package/dist/i18n/locales/fr.js.map +1 -1
  155. package/dist/i18n/locales/hu.d.ts +26 -5
  156. package/dist/i18n/locales/hu.js +337 -3
  157. package/dist/i18n/locales/hu.js.map +1 -1
  158. package/dist/i18n/locales/it.d.ts +26 -5
  159. package/dist/i18n/locales/it.js +342 -2
  160. package/dist/i18n/locales/it.js.map +1 -1
  161. package/dist/i18n/locales/zh.d.ts +26 -5
  162. package/dist/i18n/locales/zh.js +333 -2
  163. package/dist/i18n/locales/zh.js.map +1 -1
  164. package/dist/i18n/review.d.ts +26 -5
  165. package/dist/i18n/review.js +45 -1
  166. package/dist/i18n/review.js.map +1 -1
  167. package/dist/index.d.ts +19 -3
  168. package/dist/index.js +89 -0
  169. package/dist/index.js.map +1 -1
  170. package/dist/lib/person-name.d.ts +69 -0
  171. package/dist/lib/person-name.js +65 -0
  172. package/dist/lib/person-name.js.map +1 -0
  173. package/dist/rhf/fields.d.ts +26 -5
  174. package/dist/rhf/form.d.ts +26 -5
  175. package/dist/rhf.d.ts +26 -5
  176. package/dist/shell/app-shell.d.ts +26 -5
  177. package/dist/shell/company-switcher.d.ts +59 -0
  178. package/dist/shell/company-switcher.js +85 -0
  179. package/dist/shell/company-switcher.js.map +1 -0
  180. package/dist/shell/top-bar-brand.d.ts +26 -5
  181. package/dist/shell/topbar-action-menu.d.ts +1 -0
  182. package/dist/shell.d.ts +20 -5
  183. package/dist/wizard/stepper-nav.d.ts +26 -5
  184. package/dist/wizard.d.ts +26 -5
  185. package/package.json +1 -1
  186. package/src/account/account-parts.ts +67 -0
  187. package/src/account/data-export-setting.tsx +218 -0
  188. package/src/account/delete-account-setting.tsx +362 -0
  189. package/src/account/email-change-setting.tsx +457 -0
  190. package/src/account/sessions-setting.tsx +283 -0
  191. package/src/admin/admin-action-confirm.tsx +495 -0
  192. package/src/admin/admin-action-log.tsx +297 -0
  193. package/src/admin/admin-parts.ts +82 -0
  194. package/src/admin/invitations-panel.tsx +516 -0
  195. package/src/admin/reviewer-scope-editor.tsx +234 -0
  196. package/src/admin/role-select.tsx +286 -0
  197. package/src/admin/transfer-ownership-dialog.tsx +172 -0
  198. package/src/admin/user-roster.tsx +573 -0
  199. package/src/auth/accept-invitation.tsx +227 -0
  200. package/src/auth/auth-errors.ts +262 -0
  201. package/src/auth/complete-name-dialog.tsx +253 -0
  202. package/src/auth/email-tag.ts +75 -0
  203. package/src/auth/forgot-password-form.tsx +229 -0
  204. package/src/auth/form-rules.ts +40 -0
  205. package/src/auth/new-password-fields.tsx +85 -0
  206. package/src/auth/not-found-page.tsx +98 -0
  207. package/src/auth/register-form.tsx +477 -0
  208. package/src/auth/reset-password-form.tsx +351 -0
  209. package/src/auth/sign-in-form.tsx +859 -0
  210. package/src/auth/status-parts.tsx +138 -0
  211. package/src/auth/verify-email.tsx +409 -0
  212. package/src/components/account-chips.tsx +64 -7
  213. package/src/components/account-settings-labels.ts +15 -1
  214. package/src/components/account-settings.tsx +199 -23
  215. package/src/components/user-avatar.tsx +22 -4
  216. package/src/hooks/use-anchored-panel.ts +14 -3
  217. package/src/i18n/defaults.ts +40 -0
  218. package/src/i18n/german.ts +379 -0
  219. package/src/i18n/kit-labels.tsx +60 -0
  220. package/src/i18n/locales/es.ts +371 -1
  221. package/src/i18n/locales/fr.ts +379 -0
  222. package/src/i18n/locales/hu.ts +366 -1
  223. package/src/i18n/locales/it.ts +373 -0
  224. package/src/i18n/locales/zh.ts +343 -0
  225. package/src/i18n/review.ts +44 -0
  226. package/src/index.ts +146 -0
  227. package/src/lib/person-name.ts +157 -0
  228. package/src/shell/company-switcher.tsx +140 -0
@@ -0,0 +1,426 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useEffectEvent, useId, useRef, useState } from "react";
4
+ import { KeyRound } from "lucide-react";
5
+ import { useKitLabels } from "../i18n/kit-labels.js";
6
+ import { cn } from "../lib/cn.js";
7
+ import { AlertBanner } from "../components/alert-banner.js";
8
+ import { hasMessage } from "../components/choice-parts.js";
9
+ import { CurrentPasswordInput } from "../components/danger-confirm.js";
10
+ import { OneTimeCodeInput } from "../components/one-time-code-input.js";
11
+ import { TextLink } from "../components/text-link.js";
12
+ import { Button, Input } from "../components/ui.js";
13
+ import { authErrorCode, englishRateLimited, isRateLimited, retryAfterSeconds } from "./auth-errors.js";
14
+ import { taggedEmail } from "./email-tag.js";
15
+ import { newPasswordProblem } from "./form-rules.js";
16
+ import { NewPasswordFields } from "./new-password-fields.js";
17
+ const DEFAULT_SIGN_IN_LABELS = {
18
+ email: "Email",
19
+ password: "Password",
20
+ submit: "Sign in",
21
+ passkey: "Sign in with a passkey",
22
+ forgotPassword: "Forgot your password?",
23
+ noAccount: "No account yet?",
24
+ register: "Create account",
25
+ invalidCredentials: "The email or password is incorrect.",
26
+ failed: "Sign-in failed. Please try again.",
27
+ passkeyFailed: "Passkey sign-in failed.",
28
+ deactivatedHint: "Account deactivated? Write to {contact}.",
29
+ tagHint: (taggedAddress) => `Signed up with ${taggedAddress}? Use that address.`,
30
+ twoFactorTitle: "Two-factor authentication",
31
+ twoFactorIntro: "Enter the code your authenticator app shows.",
32
+ code: "2FA code",
33
+ verify: "Verify",
34
+ codeInvalid: "Invalid 2FA code.",
35
+ setPasswordTitle: "Choose a new password",
36
+ setPasswordIntro: "A new password was requested for this account. Choose one and you are straight back in.",
37
+ newPassword: "New password",
38
+ confirmPassword: "Repeat new password",
39
+ passwordMismatch: "The passwords don't match.",
40
+ setPasswordSubmit: "Set password and sign in",
41
+ setPasswordFailed: "The password could not be set.",
42
+ expired: "This sign-in has expired. Please sign in again.",
43
+ backToSignIn: "Back to sign in",
44
+ useRecoveryCode: "Use a backup code",
45
+ useAuthenticatorCode: "Use your authenticator app",
46
+ recoveryCode: "Backup code",
47
+ recoveryIntro: "Enter one of the backup codes you saved when you turned on two-factor authentication.",
48
+ recoveryCodeHint: (length) => `${length} letters and digits. Dashes and spaces don\u2019t matter.`,
49
+ recoveryCodeInvalid: "This backup code is not valid, or it has been used already.",
50
+ rateLimited: englishRateLimited
51
+ };
52
+ function withContact(template, contact) {
53
+ const node = typeof contact === "string" && contact.includes("@") ? /* @__PURE__ */ jsx(TextLink, { href: `mailto:${contact}`, tone: "secondary", children: contact }, "contact") : /* @__PURE__ */ jsx("span", { children: contact }, "contact");
54
+ if (!template.includes("{contact}")) return [template, " ", node];
55
+ return template.split(/(\{contact\})/).filter((part) => part !== "").map((part) => part === "{contact}" ? node : part);
56
+ }
57
+ const HINT_CLASS = "text-xs text-[var(--text-secondary)]";
58
+ const RECOVERY_CODE_LENGTH = 16;
59
+ function recoveryCharacters(value) {
60
+ return value.replace(/[^\p{L}\p{N}]/gu, "").length;
61
+ }
62
+ const INTRO_CLASS = "text-sm text-[var(--text-secondary)]";
63
+ function SignInForm({
64
+ onSubmit,
65
+ onCode,
66
+ onSetPassword,
67
+ onPasskey,
68
+ passkeyAutofill,
69
+ forgotHref,
70
+ registerHref,
71
+ defaultEmail = "",
72
+ emailTag,
73
+ deactivatedContact,
74
+ codeLength = 6,
75
+ recoveryCode,
76
+ credentialsContent,
77
+ twoFactorContent,
78
+ passwordChangeContent,
79
+ describeError,
80
+ onStepChange,
81
+ headingAs: Heading = "h2",
82
+ labels: labelsProp,
83
+ className,
84
+ ...rest
85
+ }) {
86
+ const labels = useKitLabels("signIn", DEFAULT_SIGN_IN_LABELS, labelsProp);
87
+ const [step, setStep] = useState("credentials");
88
+ const [email, setEmail] = useState(defaultEmail);
89
+ const [password, setPassword] = useState("");
90
+ const [code, setCode] = useState("");
91
+ const [useRecovery, setUseRecovery] = useState(false);
92
+ const [recovery, setRecovery] = useState("");
93
+ const [newPassword, setNewPassword] = useState("");
94
+ const [confirm, setConfirm] = useState("");
95
+ const [challenge, setChallenge] = useState(
96
+ null
97
+ );
98
+ const [busy, setBusy] = useState(null);
99
+ const [failure, setFailure] = useState(null);
100
+ const headingId = useId();
101
+ const emailRef = useRef(null);
102
+ const passwordRef = useRef(null);
103
+ const codeRef = useRef(null);
104
+ const recoveryRef = useRef(null);
105
+ const newPasswordRef = useRef(null);
106
+ const mounted = useRef(true);
107
+ useEffect(() => {
108
+ mounted.current = true;
109
+ return () => {
110
+ mounted.current = false;
111
+ };
112
+ }, []);
113
+ const goTo = (next) => {
114
+ setStep(next);
115
+ onStepChange?.(next);
116
+ };
117
+ const present = (answer) => {
118
+ setFailure(null);
119
+ if (answer.kind === "signed-in") {
120
+ setBusy("done");
121
+ return;
122
+ }
123
+ setBusy(null);
124
+ setPassword("");
125
+ setCode("");
126
+ setRecovery("");
127
+ setUseRecovery(false);
128
+ setNewPassword("");
129
+ setConfirm("");
130
+ if (answer.kind === "2fa") {
131
+ setChallenge({ token: answer.challengeToken });
132
+ goTo("2fa");
133
+ } else if (answer.kind === "password-change") {
134
+ setChallenge({ token: answer.challengeToken, extra: answer.extra });
135
+ goTo("password-change");
136
+ }
137
+ };
138
+ const messageFor = (error, action, code2, recoveryUsed) => {
139
+ const own = describeError?.(error, action);
140
+ if (hasMessage(own)) return own;
141
+ if (isRateLimited(error)) return (labels.rateLimited ?? DEFAULT_SIGN_IN_LABELS.rateLimited)(retryAfterSeconds(error));
142
+ if (action === "password") return code2 === "invalid_credentials" ? labels.invalidCredentials : labels.failed;
143
+ if (action === "passkey") return labels.passkeyFailed;
144
+ if (action === "code") {
145
+ if (code2 === "token_invalid") return labels.expired;
146
+ return recoveryUsed ? labels.recoveryCodeInvalid ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeInvalid : labels.codeInvalid;
147
+ }
148
+ return code2 === "token_invalid" ? labels.expired : labels.setPasswordFailed;
149
+ };
150
+ const fail = (error, action, sentEmail, recoveryUsed = false) => {
151
+ setBusy(null);
152
+ if (error?.name === "AbortError") return;
153
+ const code2 = authErrorCode(error);
154
+ const message = messageFor(error, action, code2, recoveryUsed);
155
+ if ((action === "code" || action === "set-password") && code2 === "token_invalid") {
156
+ setChallenge(null);
157
+ setCode("");
158
+ setRecovery("");
159
+ setUseRecovery(false);
160
+ setNewPassword("");
161
+ setConfirm("");
162
+ goTo("credentials");
163
+ }
164
+ setFailure({ action, code: code2, message, email: sentEmail });
165
+ };
166
+ const attempt = (action, call, sentEmail, recoveryUsed = false) => {
167
+ if (busy) return;
168
+ setBusy(action);
169
+ setFailure(null);
170
+ let result;
171
+ try {
172
+ result = Promise.resolve(call());
173
+ } catch (error) {
174
+ result = Promise.reject(error);
175
+ }
176
+ result.then(
177
+ (answer) => {
178
+ if (mounted.current) present(answer);
179
+ },
180
+ (error) => {
181
+ if (mounted.current) fail(error, action, sentEmail, recoveryUsed);
182
+ }
183
+ );
184
+ };
185
+ const armAutofill = useEffectEvent((signal) => passkeyAutofill?.(signal));
186
+ const autofillAnswered = useEffectEvent((answer) => {
187
+ if (busy === null) present(answer);
188
+ });
189
+ useEffect(() => {
190
+ const controller = new AbortController();
191
+ let pending;
192
+ try {
193
+ pending = Promise.resolve(armAutofill(controller.signal));
194
+ } catch (error) {
195
+ pending = Promise.reject(error);
196
+ }
197
+ pending.then(
198
+ (answer) => {
199
+ if (answer && !controller.signal.aborted && mounted.current) autofillAnswered(answer);
200
+ },
201
+ () => {
202
+ }
203
+ );
204
+ return () => controller.abort();
205
+ }, []);
206
+ const shownStep = useRef(step);
207
+ useEffect(() => {
208
+ if (shownStep.current === step) return;
209
+ shownStep.current = step;
210
+ if (step === "2fa") codeRef.current?.focus();
211
+ else if (step === "password-change") newPasswordRef.current?.focus();
212
+ else if (emailRef.current?.value) passwordRef.current?.focus();
213
+ else emailRef.current?.focus();
214
+ }, [step]);
215
+ const shownRecovery = useRef(useRecovery);
216
+ useEffect(() => {
217
+ if (shownRecovery.current === useRecovery) return;
218
+ shownRecovery.current = useRecovery;
219
+ if (step !== "2fa") return;
220
+ (useRecovery ? recoveryRef : codeRef).current?.focus();
221
+ }, [useRecovery, step]);
222
+ const backToCredentials = () => {
223
+ if (busy) return;
224
+ setChallenge(null);
225
+ setFailure(null);
226
+ setCode("");
227
+ setRecovery("");
228
+ setUseRecovery(false);
229
+ setNewPassword("");
230
+ setConfirm("");
231
+ goTo("credentials");
232
+ };
233
+ const working = busy !== null;
234
+ const rootClass = cn("space-y-3", className);
235
+ if (step === "2fa" && challenge) {
236
+ const recoveryOn = recoveryCode !== void 0 && recoveryCode !== false;
237
+ const recoveryLength = (typeof recoveryCode === "object" ? recoveryCode.length : void 0) ?? RECOVERY_CODE_LENGTH;
238
+ const asRecovery = recoveryOn && useRecovery;
239
+ const recoveryReady = recoveryCharacters(recovery) === recoveryLength;
240
+ const ready = asRecovery ? recoveryReady : code.length === codeLength;
241
+ const submitCode = (e) => {
242
+ e.preventDefault();
243
+ if (!ready) return;
244
+ if (asRecovery) {
245
+ attempt(
246
+ "code",
247
+ () => onCode({ challengeToken: challenge.token, code: recovery.trim(), kind: "recovery" }),
248
+ void 0,
249
+ true
250
+ );
251
+ return;
252
+ }
253
+ attempt("code", () => onCode({ challengeToken: challenge.token, code }));
254
+ };
255
+ const switchCode = () => {
256
+ if (working) return;
257
+ setFailure(null);
258
+ setCode("");
259
+ setRecovery("");
260
+ setUseRecovery((on) => !on);
261
+ };
262
+ const codeError = failure?.action === "code" ? failure.message : void 0;
263
+ const content = typeof twoFactorContent === "function" ? twoFactorContent(challenge.token) : twoFactorContent;
264
+ return /* @__PURE__ */ jsxs("div", { ...rest, "data-step": "2fa", className: rootClass, children: [
265
+ /* @__PURE__ */ jsxs("form", { className: "space-y-3", "aria-labelledby": headingId, onSubmit: submitCode, children: [
266
+ /* @__PURE__ */ jsx(Heading, { id: headingId, className: "text-base font-semibold text-[var(--text-primary)]", children: labels.twoFactorTitle }),
267
+ /* @__PURE__ */ jsx("p", { className: INTRO_CLASS, children: asRecovery ? labels.recoveryIntro ?? DEFAULT_SIGN_IN_LABELS.recoveryIntro : labels.twoFactorIntro }),
268
+ content,
269
+ asRecovery ? (
270
+ // A plain text field, not the digits-only one: a backup code is letters and
271
+ // digits in printed groups. Nothing a phone keyboard would "correct", and no
272
+ // autofill — the browser's suggestion for an unknown field is the username.
273
+ /* @__PURE__ */ jsx(
274
+ Input,
275
+ {
276
+ ref: recoveryRef,
277
+ label: labels.recoveryCode ?? DEFAULT_SIGN_IN_LABELS.recoveryCode,
278
+ name: "recovery-code",
279
+ value: recovery,
280
+ onChange: (e) => {
281
+ setRecovery(e.target.value);
282
+ if (failure) setFailure(null);
283
+ },
284
+ autoComplete: "off",
285
+ autoCapitalize: "characters",
286
+ autoCorrect: "off",
287
+ spellCheck: false,
288
+ inputClassName: "font-mono",
289
+ hint: (labels.recoveryCodeHint ?? DEFAULT_SIGN_IN_LABELS.recoveryCodeHint)(recoveryLength),
290
+ readOnly: working,
291
+ error: codeError,
292
+ required: true
293
+ }
294
+ )
295
+ ) : /* @__PURE__ */ jsx(
296
+ OneTimeCodeInput,
297
+ {
298
+ ref: codeRef,
299
+ label: labels.code,
300
+ name: "code",
301
+ value: code,
302
+ length: codeLength,
303
+ onChange: (next) => {
304
+ setCode(next);
305
+ if (failure) setFailure(null);
306
+ },
307
+ readOnly: working,
308
+ error: codeError,
309
+ required: true
310
+ }
311
+ ),
312
+ recoveryOn && /* @__PURE__ */ jsx("p", { className: "text-sm", children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", disabled: working, onClick: switchCode, children: asRecovery ? labels.useAuthenticatorCode ?? DEFAULT_SIGN_IN_LABELS.useAuthenticatorCode : labels.useRecoveryCode ?? DEFAULT_SIGN_IN_LABELS.useRecoveryCode }) }),
313
+ /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: !working && !ready, pending: working, children: labels.verify })
314
+ ] }),
315
+ /* @__PURE__ */ jsx(BackLink, { label: labels.backToSignIn, onClick: backToCredentials, disabled: working })
316
+ ] });
317
+ }
318
+ if (step === "password-change" && challenge) {
319
+ const problem = newPasswordProblem(newPassword, confirm);
320
+ const submitPassword = (e) => {
321
+ e.preventDefault();
322
+ if (problem) return;
323
+ attempt("set-password", () => onSetPassword({ challengeToken: challenge.token, password: newPassword }));
324
+ };
325
+ const content = typeof passwordChangeContent === "function" ? passwordChangeContent(challenge.extra) : passwordChangeContent;
326
+ return /* @__PURE__ */ jsxs("div", { ...rest, "data-step": "password-change", className: rootClass, children: [
327
+ /* @__PURE__ */ jsxs("form", { className: "space-y-3", "aria-labelledby": headingId, onSubmit: submitPassword, children: [
328
+ /* @__PURE__ */ jsx(Heading, { id: headingId, className: "text-base font-semibold text-[var(--text-primary)]", children: labels.setPasswordTitle }),
329
+ /* @__PURE__ */ jsx("p", { className: INTRO_CLASS, children: labels.setPasswordIntro }),
330
+ content,
331
+ email !== "" && /* @__PURE__ */ jsx("input", { type: "email", name: "username", autoComplete: "username", value: email, readOnly: true, hidden: true }),
332
+ /* @__PURE__ */ jsx(
333
+ NewPasswordFields,
334
+ {
335
+ password: newPassword,
336
+ confirm,
337
+ onPasswordChange: setNewPassword,
338
+ onConfirmChange: setConfirm,
339
+ busy: working,
340
+ passwordRef: newPasswordRef,
341
+ text: { password: labels.newPassword, confirm: labels.confirmPassword, mismatch: labels.passwordMismatch }
342
+ }
343
+ ),
344
+ failure?.action === "set-password" && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", role: "alert", children: failure.message }),
345
+ /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: !working && problem !== null, pending: working, children: labels.setPasswordSubmit })
346
+ ] }),
347
+ /* @__PURE__ */ jsx(BackLink, { label: labels.backToSignIn, onClick: backToCredentials, disabled: working })
348
+ ] });
349
+ }
350
+ const submitCredentials = (e) => {
351
+ e.preventDefault();
352
+ const sent = email.trim();
353
+ if (sent === "" || password === "") return;
354
+ attempt("password", () => onSubmit({ email: sent, password }), sent);
355
+ };
356
+ const refused = failure?.code === "invalid_credentials";
357
+ const tagged = refused && failure?.action === "password" && emailTag && failure.email ? taggedEmail(failure.email, emailTag) : null;
358
+ const showDeactivated = refused && hasMessage(deactivatedContact);
359
+ return /* @__PURE__ */ jsxs("div", { ...rest, "data-step": "credentials", className: rootClass, children: [
360
+ /* @__PURE__ */ jsxs("form", { className: "space-y-3", onSubmit: submitCredentials, children: [
361
+ credentialsContent,
362
+ /* @__PURE__ */ jsx(
363
+ Input,
364
+ {
365
+ ref: emailRef,
366
+ type: "email",
367
+ name: "email",
368
+ autoComplete: "username webauthn",
369
+ label: labels.email,
370
+ value: email,
371
+ onChange: (e) => setEmail(e.target.value),
372
+ readOnly: working,
373
+ required: true
374
+ }
375
+ ),
376
+ /* @__PURE__ */ jsx(
377
+ CurrentPasswordInput,
378
+ {
379
+ ref: passwordRef,
380
+ name: "password",
381
+ label: labels.password,
382
+ value: password,
383
+ onValueChange: setPassword,
384
+ busy: working,
385
+ required: true
386
+ }
387
+ ),
388
+ failure && // One live region for the sentence and its hints: they are one answer.
389
+ /* @__PURE__ */ jsxs("div", { role: "alert", className: "space-y-1.5", children: [
390
+ /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", children: failure.message }),
391
+ showDeactivated && /* @__PURE__ */ jsx("p", { className: HINT_CLASS, children: withContact(labels.deactivatedHint, deactivatedContact) }),
392
+ tagged && /* @__PURE__ */ jsx("p", { className: HINT_CLASS, children: labels.tagHint(tagged) })
393
+ ] }),
394
+ /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", pending: busy === "password" || busy === "done", disabled: busy === "passkey", children: labels.submit }),
395
+ onPasskey && /* @__PURE__ */ jsxs(
396
+ Button,
397
+ {
398
+ type: "button",
399
+ variant: "secondary",
400
+ className: "w-full",
401
+ pending: busy === "passkey",
402
+ disabled: busy === "password" || busy === "done",
403
+ onClick: () => attempt("passkey", onPasskey),
404
+ children: [
405
+ /* @__PURE__ */ jsx(KeyRound, { "aria-hidden": true, className: "size-4" }),
406
+ labels.passkey
407
+ ]
408
+ }
409
+ )
410
+ ] }),
411
+ forgotHref !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-center text-sm", children: /* @__PURE__ */ jsx(TextLink, { href: forgotHref, tone: "secondary", children: labels.forgotPassword }) }),
412
+ registerHref !== void 0 && /* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-[var(--text-secondary)]", children: [
413
+ labels.noAccount,
414
+ " ",
415
+ /* @__PURE__ */ jsx(TextLink, { href: registerHref, tone: "primary", children: labels.register })
416
+ ] })
417
+ ] });
418
+ }
419
+ function BackLink({ label, onClick, disabled }) {
420
+ return /* @__PURE__ */ jsx("p", { className: "text-center text-sm", children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", tone: "muted", size: "sm", disabled, onClick, children: label }) });
421
+ }
422
+ export {
423
+ DEFAULT_SIGN_IN_LABELS,
424
+ SignInForm
425
+ };
426
+ //# sourceMappingURL=sign-in-form.js.map
@@ -0,0 +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=\"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,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"]}
@@ -0,0 +1,78 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * The pieces the signed-out status pages share — {@link ForgotPasswordForm},
6
+ * {@link ResetPasswordForm}, {@link VerifyEmailStatus}, {@link AcceptInvitation} and
7
+ * {@link NotFoundPage} (docs/auth-harmonization.md §7).
8
+ *
9
+ * @internal Not part of the barrel; the pages are.
10
+ */
11
+ /** A heading level a page part may take. Default `h2`, under the page's `h1`
12
+ * (`AuthLayout`'s `title`, the app's name), as on `SignInForm`'s steps; deeper for a
13
+ * page embedded in another (a preview, the docs). */
14
+ type AuthHeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
15
+ /** The form pages' heading: start-aligned, the size of `SignInForm`'s step headings. */
16
+ declare const FORM_HEADING_CLASS = "text-base font-semibold text-[var(--text-primary)]";
17
+ /** The status pages' heading: centred over the centred outcome below it. */
18
+ declare const STATUS_HEADING_CLASS = "text-center text-base font-semibold text-[var(--text-primary)]";
19
+ declare const INTRO_CLASS = "text-sm text-[var(--text-secondary)]";
20
+ /**
21
+ * kastlan's outcome block (verify-email-page, reset-password-page): the kit's
22
+ * `EmptyState` without its dashed box, because it already sits in `AuthLayout`'s card —
23
+ * a box in a box. The icon and the title carry the tone.
24
+ */
25
+ declare const OUTCOME_CLASS = "border-0 bg-transparent px-0 py-3";
26
+ /** `href` with `key=value` added to its query, before any `#fragment`: the reset page's
27
+ * "Sign in" carries the address (`/login?email=ada%40example.com`). */
28
+ declare function withQuery(href: string, key: string, value: string): string;
29
+ /** What a callback's promise came to. */
30
+ type Settled<T> = {
31
+ ok: true;
32
+ value: T;
33
+ } | {
34
+ ok: false;
35
+ error: unknown;
36
+ };
37
+ /**
38
+ * Run `start(key)` ONCE per key, and hand what it settles to into `settle` — unless the
39
+ * key moved on in the meantime, when the stale answer is dropped.
40
+ *
41
+ * keksdose's verify-email and join pages fire their request from an effect behind a
42
+ * `useRef` guard, and say why: the token is single-use, and StrictMode's
43
+ * mount → unmount → remount would send it twice and turn a success into "invalid" on
44
+ * the second answer. The guard is the same here; there is deliberately no "unmounted"
45
+ * flag set in the cleanup, because StrictMode's simulated unmount would set it and the
46
+ * remount would never clear the guard — the page would hang on its spinner (the bug
47
+ * keksdose hit on /join with a react-query observer). A state update after a real
48
+ * unmount is a no-op in React 18 and later.
49
+ *
50
+ * `key === null` runs nothing (no token, not signed in yet) and forgets the last key, so
51
+ * the same token runs again once it is back.
52
+ */
53
+ declare function useOncePerKey<T>(key: string | null, start: (key: string) => T | Promise<T>, settle: (key: string, result: Settled<T>) => void): void;
54
+ /** Whether a callback's return is a promise to wait for. A callback that returns
55
+ * nothing is done when it returns. */
56
+ declare function isThenable(value: unknown): value is PromiseLike<unknown>;
57
+ /**
58
+ * Move focus to `ref` when `active` turns true — the outcome a person's own submit led
59
+ * to ("If an account exists … the link is on its way", "Your password has been
60
+ * changed"). The submit button they pressed is gone with the form, which drops focus to
61
+ * `<body>`; a screen reader then hears nothing at all. Focusing the message (a
62
+ * `tabIndex={-1}` box) reads it out and leaves the next Tab where the page continues.
63
+ */
64
+ declare function useFocusWhen(active: boolean, ref: {
65
+ current: HTMLElement | null;
66
+ }): void;
67
+ /** The box {@link useFocusWhen} focuses: centred, no focus ring of its own (it is not a
68
+ * control; the ring would read as one). */
69
+ declare function OutcomeMessage({ icon, children, focusRef, className, }: {
70
+ icon: ReactNode;
71
+ children: ReactNode;
72
+ focusRef?: {
73
+ current: HTMLDivElement | null;
74
+ };
75
+ className?: string;
76
+ }): react.JSX.Element;
77
+
78
+ export { type AuthHeadingLevel, FORM_HEADING_CLASS, INTRO_CLASS, OUTCOME_CLASS, OutcomeMessage, STATUS_HEADING_CLASS, type Settled, isThenable, useFocusWhen, useOncePerKey, withQuery };