@cosmicdrift/kumiko-samples 0.406.0 → 0.410.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 (257) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +31 -4
  3. package/packages/bundled-features/src/account-security/feature.ts +9 -1
  4. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  5. package/packages/bundled-features/src/admin-shell/feature.ts +4 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +1 -0
  7. package/packages/bundled-features/src/agent-tools/changes.json +6 -0
  8. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -0
  9. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  10. package/packages/bundled-features/src/audit/event-classification.ts +1 -0
  11. package/packages/bundled-features/src/auth-email-password/bootstrap.ts +1 -0
  12. package/packages/bundled-features/src/auth-email-password/errors.ts +18 -66
  13. package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
  14. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  15. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +30 -64
  16. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +2 -2
  17. package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +20 -66
  18. package/packages/bundled-features/src/auth-email-password/web/index.ts +1 -0
  19. package/packages/bundled-features/src/auth-email-password/web/read-path-param.ts +8 -0
  20. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +3 -2
  21. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +97 -0
  22. package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +20 -68
  23. package/packages/bundled-features/src/auth-foundation/boot-checks.ts +22 -15
  24. package/packages/bundled-features/src/auth-foundation/boot-rules.ts +33 -0
  25. package/packages/bundled-features/src/auth-mfa/errors.ts +12 -42
  26. package/packages/bundled-features/src/auth-mfa/feature-exports.ts +6 -45
  27. package/packages/bundled-features/src/auth-mfa/feature.ts +8 -19
  28. package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +19 -33
  29. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-notify.ts +1 -0
  30. package/packages/bundled-features/src/billing-foundation/web/plan-price.ts +20 -7
  31. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -0
  32. package/packages/bundled-features/src/channel-in-app/changes.json +7 -0
  33. package/packages/bundled-features/src/channel-in-app/feature.ts +2 -0
  34. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +35 -0
  35. package/packages/bundled-features/src/channel-in-app/in-app-channel.ts +1 -0
  36. package/packages/bundled-features/src/channel-in-app/tables.ts +5 -1
  37. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +4 -1
  38. package/packages/bundled-features/src/contact/challenge.ts +41 -0
  39. package/packages/bundled-features/src/contact/changes.json +33 -0
  40. package/packages/bundled-features/src/contact/client/contact-client-source.ts +203 -0
  41. package/packages/bundled-features/src/contact/client/contact-website-client.ts +29 -0
  42. package/packages/bundled-features/src/contact/client/index.ts +9 -0
  43. package/packages/bundled-features/src/contact/entity.ts +168 -0
  44. package/packages/bundled-features/src/contact/feature.ts +174 -0
  45. package/packages/bundled-features/src/contact/handlers/access.ts +17 -0
  46. package/packages/bundled-features/src/contact/handlers/attempts.ts +76 -0
  47. package/packages/bundled-features/src/contact/handlers/challenge.query.ts +44 -0
  48. package/packages/bundled-features/src/contact/handlers/forward-request.write.ts +98 -0
  49. package/packages/bundled-features/src/contact/handlers/mark-done.write.ts +40 -0
  50. package/packages/bundled-features/src/contact/handlers/notify-reporter-in-app.write.ts +48 -0
  51. package/packages/bundled-features/src/contact/handlers/open-count.query.ts +15 -0
  52. package/packages/bundled-features/src/contact/handlers/open-count.ts +17 -0
  53. package/packages/bundled-features/src/contact/handlers/replies.query.ts +29 -0
  54. package/packages/bundled-features/src/contact/handlers/reply.write.ts +197 -0
  55. package/packages/bundled-features/src/contact/handlers/report.write.ts +126 -0
  56. package/packages/bundled-features/src/contact/handlers/request-delivery.query.ts +143 -0
  57. package/packages/bundled-features/src/contact/handlers/request-detail.query.ts +50 -0
  58. package/packages/bundled-features/src/contact/handlers/request-list.query.ts +14 -0
  59. package/packages/bundled-features/src/contact/handlers/send-reply-mail.write.ts +124 -0
  60. package/packages/bundled-features/src/contact/handlers/send-test.write.ts +45 -0
  61. package/packages/bundled-features/src/contact/handlers/submit.write.ts +194 -0
  62. package/packages/bundled-features/src/contact/handlers/take-over-uploads.ts +47 -0
  63. package/packages/bundled-features/src/contact/i18n.ts +192 -0
  64. package/packages/bundled-features/src/contact/index.ts +29 -0
  65. package/packages/bundled-features/src/contact/lib.ts +176 -0
  66. package/packages/bundled-features/src/contact/mail.ts +401 -0
  67. package/packages/bundled-features/src/contact/options.ts +95 -0
  68. package/packages/bundled-features/src/contact/panels.ts +28 -0
  69. package/packages/bundled-features/src/contact/payloads.ts +106 -0
  70. package/packages/bundled-features/src/contact/pow.ts +22 -0
  71. package/packages/bundled-features/src/contact/screens.ts +507 -0
  72. package/packages/bundled-features/src/contact/subject.ts +13 -0
  73. package/packages/bundled-features/src/contact/user-agent.ts +39 -0
  74. package/packages/bundled-features/src/contact/user-data-hooks.ts +180 -0
  75. package/packages/bundled-features/src/contact/web/constants.ts +160 -0
  76. package/packages/bundled-features/src/contact/web/index.ts +29 -0
  77. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +5 -16
  78. package/packages/bundled-features/src/data-retention/changes.json +6 -0
  79. package/packages/bundled-features/src/data-retention/feature.ts +16 -2
  80. package/packages/bundled-features/src/data-retention/index.ts +5 -0
  81. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +138 -41
  82. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +196 -0
  83. package/packages/bundled-features/src/delivery/address-opt-out.ts +1 -0
  84. package/packages/bundled-features/src/delivery/changes.json +7 -0
  85. package/packages/bundled-features/src/delivery/channel-context.ts +2 -0
  86. package/packages/bundled-features/src/delivery/delivery-service.ts +29 -5
  87. package/packages/bundled-features/src/delivery/events.ts +2 -0
  88. package/packages/bundled-features/src/delivery/feature.ts +3 -2
  89. package/packages/bundled-features/src/delivery/handlers/attempts-by-keys.query.ts +55 -0
  90. package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
  91. package/packages/bundled-features/src/delivery/jobs.ts +5 -0
  92. package/packages/bundled-features/src/delivery/tables.ts +13 -2
  93. package/packages/bundled-features/src/delivery/types.ts +3 -0
  94. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +2 -0
  95. package/packages/bundled-features/src/delivery/web/delivery-channel-cell.tsx +1 -1
  96. package/packages/bundled-features/src/delivery/web/delivery-error-cell.tsx +1 -1
  97. package/packages/bundled-features/src/delivery/web/delivery-status-cell.tsx +1 -1
  98. package/packages/bundled-features/src/delivery/web/delivery-time-cell.tsx +3 -2
  99. package/packages/bundled-features/src/delivery/web/delivery-type-cell.tsx +1 -1
  100. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  101. package/packages/bundled-features/src/document-ingest-foundation/boot-checks.ts +14 -9
  102. package/packages/bundled-features/src/document-ingest-foundation/boot-rules.ts +22 -0
  103. package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
  104. package/packages/bundled-features/src/document-ingest-foundation/events.ts +17 -0
  105. package/packages/bundled-features/src/document-ingest-foundation/feature.ts +39 -1
  106. package/packages/bundled-features/src/document-ingest-foundation/index.ts +10 -0
  107. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +43 -0
  108. package/packages/bundled-features/src/document-ingest-foundation/tables.ts +43 -0
  109. package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
  110. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  111. package/packages/bundled-features/src/files-tenant-data/changes.json +6 -0
  112. package/packages/bundled-features/src/files-tenant-data/hooks.ts +4 -1
  113. package/packages/bundled-features/src/folders/web/folder-manager.tsx +8 -9
  114. package/packages/bundled-features/src/folders/web/folder-section.tsx +1 -1
  115. package/packages/bundled-features/src/form-draft-user-data/index.ts +2 -0
  116. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +13 -0
  117. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +2 -0
  118. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +2 -0
  119. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +6 -6
  120. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +7 -0
  121. package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +6 -0
  122. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +6 -2
  123. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.query.ts +3 -0
  124. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.ts +19 -0
  125. package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +2 -0
  126. package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +150 -0
  127. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +1 -0
  128. package/packages/bundled-features/src/jobs/job-run-logger.ts +24 -25
  129. package/packages/bundled-features/src/ledger/handlers/reports.query.ts +46 -31
  130. package/packages/bundled-features/src/ledger/recurring.ts +1 -0
  131. package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
  132. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
  133. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
  134. package/packages/bundled-features/src/notes-history/web/notes-section.tsx +3 -1
  135. package/packages/bundled-features/src/personal-access-tokens/feature.ts +9 -17
  136. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +2 -7
  137. package/packages/bundled-features/src/secrets/changes.json +6 -0
  138. package/packages/bundled-features/src/secrets/handlers/delete.write.ts +8 -4
  139. package/packages/bundled-features/src/secrets/handlers/list.query.ts +6 -3
  140. package/packages/bundled-features/src/secrets/handlers/set.write.ts +9 -4
  141. package/packages/bundled-features/src/secrets/secret-scope.ts +33 -0
  142. package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
  143. package/packages/bundled-features/src/sessions/changes.json +6 -0
  144. package/packages/bundled-features/src/sessions/feature.ts +21 -18
  145. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.query.ts +53 -0
  146. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.route.ts +39 -0
  147. package/packages/bundled-features/src/sessions/screens.ts +1 -0
  148. package/packages/bundled-features/src/sessions/session-callbacks.ts +13 -12
  149. package/packages/bundled-features/src/sessions/web/i18n.ts +4 -1
  150. package/packages/bundled-features/src/shared/assert-billing-live.ts +14 -0
  151. package/packages/bundled-features/src/shared/collect-extension-options.ts +12 -0
  152. package/packages/bundled-features/src/shared/index.ts +16 -0
  153. package/packages/bundled-features/src/shared/late-bound-slot.ts +19 -0
  154. package/packages/bundled-features/src/shared/mail-locale-templates.ts +7 -1
  155. package/packages/bundled-features/src/shared/price-env-shape.ts +44 -0
  156. package/packages/bundled-features/src/shared/purge-row-file-refs.ts +1 -1
  157. package/packages/bundled-features/src/shared/read-feature-export-fn.ts +16 -0
  158. package/packages/bundled-features/src/shared/signup-handover.ts +3 -4
  159. package/packages/bundled-features/src/shared/tenant-destruction-hold.ts +49 -0
  160. package/packages/bundled-features/src/shared/unprocessable.ts +19 -0
  161. package/packages/bundled-features/src/shared/web/index.ts +3 -0
  162. package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
  163. package/packages/bundled-features/src/subscription-paddle/feature.ts +7 -15
  164. package/packages/bundled-features/src/subscription-paddle/runtime.ts +4 -7
  165. package/packages/bundled-features/src/subscription-stripe/feature.ts +7 -15
  166. package/packages/bundled-features/src/subscription-stripe/runtime.ts +4 -7
  167. package/packages/bundled-features/src/tags/entity.ts +1 -0
  168. package/packages/bundled-features/src/tags/web/tag-chip.tsx +14 -0
  169. package/packages/bundled-features/src/tags/web/tag-filter.tsx +4 -5
  170. package/packages/bundled-features/src/tags/web/tag-manager.tsx +1 -1
  171. package/packages/bundled-features/src/tags/web/tag-section.tsx +3 -6
  172. package/packages/bundled-features/src/tags/web/tags-cell.tsx +4 -5
  173. package/packages/bundled-features/src/template-resolver/compile-document-body.ts +27 -15
  174. package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
  175. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +12 -9
  176. package/packages/bundled-features/src/template-resolver/handlers/discard-draft.write.ts +1 -0
  177. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +1 -0
  178. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +5 -5
  179. package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +3 -0
  180. package/packages/bundled-features/src/template-resolver/linked-resources.ts +11 -6
  181. package/packages/bundled-features/src/template-resolver/store-template-resource.ts +15 -12
  182. package/packages/bundled-features/src/template-resolver/web/document-images.ts +6 -6
  183. package/packages/bundled-features/src/template-resolver/web/document-insert-fields.tsx +41 -36
  184. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -12
  185. package/packages/bundled-features/src/template-resolver/web/tiptap-attribute-parse-rule.ts +19 -0
  186. package/packages/bundled-features/src/tenant/i18n.ts +3 -0
  187. package/packages/bundled-features/src/tenant/schema/tenant.ts +1 -0
  188. package/packages/bundled-features/src/tenant/web/member-roles-cell.tsx +1 -1
  189. package/packages/bundled-features/src/tenant/web/member-status-cell.tsx +1 -1
  190. package/packages/bundled-features/src/tenant-inactivity/changes.json +8 -0
  191. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +260 -0
  192. package/packages/bundled-features/src/tenant-inactivity/constants.ts +12 -0
  193. package/packages/bundled-features/src/tenant-inactivity/email-templates.ts +24 -0
  194. package/packages/bundled-features/src/tenant-inactivity/feature.ts +66 -0
  195. package/packages/bundled-features/src/tenant-inactivity/handlers/inactivity-state.query.ts +49 -0
  196. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +59 -0
  197. package/packages/bundled-features/src/tenant-inactivity/inactivity-plan.ts +187 -0
  198. package/packages/bundled-features/src/tenant-inactivity/index.ts +5 -0
  199. package/packages/bundled-features/src/tenant-inactivity/keep-token.ts +44 -0
  200. package/packages/bundled-features/src/tenant-inactivity/mail-notifications.ts +62 -0
  201. package/packages/bundled-features/src/tenant-inactivity/options.ts +38 -0
  202. package/packages/bundled-features/src/tenant-inactivity/remote-activity.ts +32 -0
  203. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +71 -0
  204. package/packages/bundled-features/src/tenant-inactivity/state-table.ts +50 -0
  205. package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +8 -6
  206. package/packages/bundled-features/src/tenant-lifecycle/boot-rules.ts +16 -0
  207. package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
  208. package/packages/bundled-features/src/tenant-lifecycle/feature.ts +24 -1
  209. package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +12 -87
  210. package/packages/bundled-features/src/tenant-lifecycle/index.ts +4 -0
  211. package/packages/bundled-features/src/tenant-lifecycle/request-tenant-destruction.ts +108 -0
  212. package/packages/bundled-features/src/tenant-lifecycle/retention-config-destroy-hooks.ts +62 -0
  213. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +58 -5
  214. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +31 -2
  215. package/packages/bundled-features/src/tenant-lifecycle/testing.ts +1 -1
  216. package/packages/bundled-features/src/tier-engine/caps-for-tier-from-map.ts +16 -0
  217. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  218. package/packages/bundled-features/src/tier-engine/compose-app.ts +21 -20
  219. package/packages/bundled-features/src/tier-engine/index.ts +1 -0
  220. package/packages/bundled-features/src/user-data-rights/feature.ts +2 -0
  221. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +4 -1
  222. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -0
  223. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +4 -1
  224. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +2 -0
  225. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  226. package/packages/bundled-features/src/user-data-rights/zip-path.ts +1 -0
  227. package/packages/bundled-features/src/user-data-rights-defaults/hooks/config-value.userdata-hook.ts +8 -27
  228. package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +11 -8
  229. package/packages/bundled-features/src/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.ts +42 -0
  230. package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +8 -27
  231. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +2 -6
  232. package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +2 -3
  233. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  234. package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +1 -2
  235. package/samples/apps/styleguide/src/features/widgets/i18n.ts +6 -0
  236. package/samples/apps/styleguide/src/features/widgets/web/InboxReaderExamples.tsx +158 -0
  237. package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +2 -0
  238. package/samples/apps/styleguide/src/features/widgets/web/sample-pdf.ts +28 -0
  239. package/samples/apps/use-all-bundled/feature-manifest.json +113 -2
  240. package/samples/apps/use-all-bundled/kumiko/migrations/0063_contact.rebuild.json +4 -0
  241. package/samples/apps/use-all-bundled/package.json +1 -0
  242. package/samples/apps/use-all-bundled/src/app/client.tsx +3 -0
  243. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +46 -2
  244. package/samples/apps/use-all-bundled/src/run-config.ts +23 -1
  245. package/samples/recipes/anonymous-access/README.md +2 -0
  246. package/samples/recipes/anonymous-access/src/feature.ts +7 -1
  247. package/samples/recipes/contact/README.md +52 -0
  248. package/samples/recipes/contact/package.json +12 -0
  249. package/samples/recipes/contact/src/feature.ts +27 -0
  250. package/samples/recipes/delivery-notifications/src/feature.ts +3 -0
  251. package/samples/recipes/record-detail-layout/src/feature.ts +9 -1
  252. package/samples/recipes/search/README.md +2 -0
  253. package/samples/recipes/search/src/feature.ts +27 -2
  254. package/samples/recipes/secrets-demo/README.md +1 -0
  255. package/samples/recipes/secrets-demo/src/feature.ts +56 -0
  256. package/samples/recipes/tenant-inactivity/README.md +21 -0
  257. package/samples/recipes/tenant-inactivity/package.json +12 -0
@@ -2,14 +2,11 @@
2
2
  // it to /api/auth/confirm-account-unlock on mount, shows success/error.
3
3
  // Idempotent server-side (clearLockoutState is a no-op when already
4
4
  // unlocked), so no re-submit risk. Mirrors VerifyEmailScreen 1:1.
5
- //
6
- // useEffect with empty deps + a once-guard so React Strict Mode's double
7
- // useEffect dispatch in dev fires the confirm call only once.
8
5
 
9
- import { usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
10
- import { type ReactNode, useEffect, useRef, useState } from "react";
6
+ import { useTranslation } from "@cosmicdrift/kumiko-renderer";
7
+ import type { ReactNode } from "react";
11
8
  import { confirmAccountUnlock } from "./auth-client.ts";
12
- import { AuthCard, useUrlToken } from "./auth-form-primitives.tsx";
9
+ import { TokenConfirmScreen } from "./token-confirm-screen.tsx";
13
10
 
14
11
  export type ConfirmAccountUnlockScreenProps = {
15
12
  readonly title?: string;
@@ -19,71 +16,28 @@ export type ConfirmAccountUnlockScreenProps = {
19
16
  readonly loginHref?: string;
20
17
  };
21
18
 
22
- type Status = "verifying" | "success" | "error" | "missing-token";
23
-
19
+ // guard:dup-ok TokenConfirmScreen holds the logic; each screen only supplies its own literal label keys
24
20
  export function ConfirmAccountUnlockScreen({
25
21
  title,
26
- token: tokenProp,
22
+ token,
27
23
  loginHref = "/login",
28
24
  }: ConfirmAccountUnlockScreenProps): ReactNode {
29
25
  const t = useTranslation();
30
- const { Link } = usePrimitives();
31
- const token = useUrlToken(tokenProp);
32
- const [status, setStatus] = useState<Status>(token === "" ? "missing-token" : "verifying");
33
- const startedRef = useRef(false);
34
-
35
- // kumiko-lint-ignore no-raw-hooks not yet converted to the framework hook set
36
- useEffect(() => {
37
- if (status !== "verifying") return;
38
- if (startedRef.current) return;
39
- startedRef.current = true;
40
- void (async () => {
41
- const res = await confirmAccountUnlock(token);
42
- setStatus(res.ok ? "success" : "error");
43
- })();
44
- }, [status, token]);
45
-
46
- if (status === "missing-token") {
47
- return (
48
- <AuthCard title={title ?? t("auth.unlockAccount.errorTitle")}>
49
- <p className="text-sm text-muted-foreground">{t("auth.unlockAccount.missingToken")}</p>
50
- <Link href={loginHref} variant="muted">
51
- {t("auth.unlockAccount.goToLogin")}
52
- </Link>
53
- </AuthCard>
54
- );
55
- }
56
-
57
- if (status === "verifying") {
58
- return (
59
- <AuthCard>
60
- <div className="p-6">
61
- <p className="text-sm text-muted-foreground" role="status">
62
- {t("auth.unlockAccount.verifying")}
63
- </p>
64
- </div>
65
- </AuthCard>
66
- );
67
- }
68
-
69
- if (status === "success") {
70
- return (
71
- <AuthCard title={title ?? t("auth.unlockAccount.successTitle")}>
72
- <p className="text-sm text-muted-foreground">{t("auth.unlockAccount.successBody")}</p>
73
- <Link href={loginHref} variant="button">
74
- {t("auth.unlockAccount.goToLogin")}
75
- </Link>
76
- </AuthCard>
77
- );
78
- }
79
-
80
- // status === "error"
81
26
  return (
82
- <AuthCard title={title ?? t("auth.unlockAccount.errorTitle")}>
83
- <p className="text-sm text-muted-foreground">{t("auth.unlockAccount.errorBody")}</p>
84
- <Link href={loginHref} variant="muted">
85
- {t("auth.unlockAccount.goToLogin")}
86
- </Link>
87
- </AuthCard>
27
+ <TokenConfirmScreen
28
+ title={title}
29
+ token={token}
30
+ loginHref={loginHref}
31
+ confirm={confirmAccountUnlock}
32
+ labels={{
33
+ errorTitle: t("auth.unlockAccount.errorTitle"),
34
+ missingToken: t("auth.unlockAccount.missingToken"),
35
+ goToLogin: t("auth.unlockAccount.goToLogin"),
36
+ verifying: t("auth.unlockAccount.verifying"),
37
+ successTitle: t("auth.unlockAccount.successTitle"),
38
+ successBody: t("auth.unlockAccount.successBody"),
39
+ errorBody: t("auth.unlockAccount.errorBody"),
40
+ }}
41
+ />
88
42
  );
89
43
  }
@@ -51,6 +51,7 @@ export type {
51
51
  export { emailPasswordClient } from "./client-plugin.ts";
52
52
  export type { ConfirmAccountUnlockScreenProps } from "./confirm-account-unlock-screen.tsx";
53
53
  export { ConfirmAccountUnlockScreen } from "./confirm-account-unlock-screen.tsx";
54
+ export { AuthHandlers } from "./constants.ts";
54
55
  export type { DefaultTopbarActionsProps } from "./default-topbar-actions.tsx";
55
56
  export { DefaultTopbarActions } from "./default-topbar-actions.tsx";
56
57
  export type { ForgotPasswordScreenProps } from "./forgot-password-screen.tsx";
@@ -0,0 +1,8 @@
1
+ export function readPathParam(
2
+ search: string,
3
+ paramName: string,
4
+ isSafePath: (candidate: unknown) => candidate is string,
5
+ ): string | null {
6
+ const candidate = new URLSearchParams(search).get(paramName);
7
+ return isSafePath(candidate) ? candidate : null;
8
+ }
@@ -1,6 +1,8 @@
1
1
  // Shared by the server (mail link) and the web pages (landing page), so it is plain string logic:
2
2
  // no DOM, no window, no `new URL` (React Native's URL getters throw).
3
3
 
4
+ import { readPathParam } from "./read-path-param.ts";
5
+
4
6
  export const RETURN_TO_QUERY_PARAM = "returnTo";
5
7
  export const MAX_RETURN_PATH_LENGTH = 2048;
6
8
 
@@ -30,6 +32,5 @@ export function isSafeReturnPath(candidate: unknown): candidate is string {
30
32
  }
31
33
 
32
34
  export function readReturnToFromSearch(search: string): string | null {
33
- const candidate = new URLSearchParams(search).get(RETURN_TO_QUERY_PARAM);
34
- return isSafeReturnPath(candidate) ? candidate : null;
35
+ return readPathParam(search, RETURN_TO_QUERY_PARAM, isSafeReturnPath);
35
36
  }
@@ -0,0 +1,97 @@
1
+ // Reads `?token=...` from the URL, auto-posts it on mount and shows success/error. The server
2
+ // side is idempotent, so a repeated call is safe.
3
+ //
4
+ // useEffect with empty deps + a once-guard so React Strict Mode's double
5
+ // useEffect dispatch in dev fires the confirm call only once.
6
+
7
+ import { usePrimitives } from "@cosmicdrift/kumiko-renderer";
8
+ import { type ReactNode, useEffect, useRef, useState } from "react";
9
+ import { AuthCard, useUrlToken } from "./auth-form-primitives.tsx";
10
+
11
+ export type TokenConfirmLabels = {
12
+ readonly errorTitle: string;
13
+ readonly missingToken: string;
14
+ readonly goToLogin: string;
15
+ readonly verifying: string;
16
+ readonly successTitle: string;
17
+ readonly successBody: string;
18
+ readonly errorBody: string;
19
+ };
20
+
21
+ export type TokenConfirmScreenProps = {
22
+ readonly title?: string | undefined;
23
+ readonly token?: string | undefined;
24
+ readonly loginHref: string;
25
+ readonly confirm: (token: string) => Promise<{ readonly ok: boolean }>;
26
+ readonly labels: TokenConfirmLabels;
27
+ };
28
+
29
+ type Status = "verifying" | "success" | "error" | "missing-token";
30
+
31
+ export function TokenConfirmScreen({
32
+ title,
33
+ token: tokenProp,
34
+ loginHref,
35
+ confirm,
36
+ labels,
37
+ }: TokenConfirmScreenProps): ReactNode {
38
+ const { Link } = usePrimitives();
39
+ const token = useUrlToken(tokenProp);
40
+ const [status, setStatus] = useState<Status>(token === "" ? "missing-token" : "verifying");
41
+ const startedRef = useRef(false);
42
+
43
+ // kumiko-lint-ignore no-raw-hooks not yet converted to the framework hook set
44
+ useEffect(() => {
45
+ if (status !== "verifying") return;
46
+ if (startedRef.current) return;
47
+ startedRef.current = true;
48
+ void (async () => {
49
+ const res = await confirm(token);
50
+ setStatus(res.ok ? "success" : "error");
51
+ })();
52
+ }, [status, token, confirm]);
53
+
54
+ if (status === "missing-token") {
55
+ return (
56
+ <AuthCard title={title ?? labels.errorTitle}>
57
+ <p className="text-sm text-muted-foreground">{labels.missingToken}</p>
58
+ <Link href={loginHref} variant="muted">
59
+ {labels.goToLogin}
60
+ </Link>
61
+ </AuthCard>
62
+ );
63
+ }
64
+
65
+ if (status === "verifying") {
66
+ return (
67
+ <AuthCard>
68
+ <div className="p-6">
69
+ <p className="text-sm text-muted-foreground" role="status">
70
+ {labels.verifying}
71
+ </p>
72
+ </div>
73
+ </AuthCard>
74
+ );
75
+ }
76
+
77
+ if (status === "success") {
78
+ return (
79
+ <AuthCard title={title ?? labels.successTitle}>
80
+ <p className="text-sm text-muted-foreground">{labels.successBody}</p>
81
+ <Link href={loginHref} variant="button">
82
+ {labels.goToLogin}
83
+ </Link>
84
+ </AuthCard>
85
+ );
86
+ }
87
+
88
+ // status === "error"
89
+ return (
90
+ <AuthCard title={title ?? labels.errorTitle}>
91
+ <p className="text-sm text-muted-foreground">{labels.errorBody}</p>
92
+ <Link href={loginHref} variant="muted">
93
+ {labels.goToLogin}
94
+ </Link>
95
+ </AuthCard>
96
+ );
97
+ }
@@ -2,16 +2,11 @@
2
2
  // /api/auth/verify-email on mount, then shows success/error. The server-side
3
3
  // operation is idempotent (repeating it sets emailVerified=true again), so
4
4
  // retries are safe.
5
- //
6
- // The empty-deps effect and once guard prevent React Strict Mode from firing
7
- // the verification call twice (Strict Mode dispatches useEffect twice in dev).
8
- // The token roundtrip is single-use server-side, but this avoids showing an
9
- // invalid-token banner after the first valid mount call.
10
5
 
11
- import { usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
12
- import { type ReactNode, useEffect, useRef, useState } from "react";
6
+ import { useTranslation } from "@cosmicdrift/kumiko-renderer";
7
+ import type { ReactNode } from "react";
13
8
  import { verifyEmail } from "./auth-client.ts";
14
- import { AuthCard, useUrlToken } from "./auth-form-primitives.tsx";
9
+ import { TokenConfirmScreen } from "./token-confirm-screen.tsx";
15
10
 
16
11
  export type VerifyEmailScreenProps = {
17
12
  readonly title?: string;
@@ -21,71 +16,28 @@ export type VerifyEmailScreenProps = {
21
16
  readonly loginHref?: string;
22
17
  };
23
18
 
24
- type Status = "verifying" | "success" | "error" | "missing-token";
25
-
19
+ // guard:dup-ok TokenConfirmScreen holds the logic; each screen only supplies its own literal label keys
26
20
  export function VerifyEmailScreen({
27
21
  title,
28
- token: tokenProp,
22
+ token,
29
23
  loginHref = "/login",
30
24
  }: VerifyEmailScreenProps): ReactNode {
31
25
  const t = useTranslation();
32
- const { Link } = usePrimitives();
33
- const token = useUrlToken(tokenProp);
34
- const [status, setStatus] = useState<Status>(token === "" ? "missing-token" : "verifying");
35
- const startedRef = useRef(false);
36
-
37
- // kumiko-lint-ignore no-raw-hooks not yet converted to the framework hook set
38
- useEffect(() => {
39
- if (status !== "verifying") return;
40
- if (startedRef.current) return;
41
- startedRef.current = true;
42
- void (async () => {
43
- const res = await verifyEmail(token);
44
- setStatus(res.ok ? "success" : "error");
45
- })();
46
- }, [status, token]);
47
-
48
- if (status === "missing-token") {
49
- return (
50
- <AuthCard title={title ?? t("auth.verifyEmail.errorTitle")}>
51
- <p className="text-sm text-muted-foreground">{t("auth.verifyEmail.missingToken")}</p>
52
- <Link href={loginHref} variant="muted">
53
- {t("auth.verifyEmail.goToLogin")}
54
- </Link>
55
- </AuthCard>
56
- );
57
- }
58
-
59
- if (status === "verifying") {
60
- return (
61
- <AuthCard>
62
- <div className="p-6">
63
- <p className="text-sm text-muted-foreground" role="status">
64
- {t("auth.verifyEmail.verifying")}
65
- </p>
66
- </div>
67
- </AuthCard>
68
- );
69
- }
70
-
71
- if (status === "success") {
72
- return (
73
- <AuthCard title={title ?? t("auth.verifyEmail.successTitle")}>
74
- <p className="text-sm text-muted-foreground">{t("auth.verifyEmail.successBody")}</p>
75
- <Link href={loginHref} variant="button">
76
- {t("auth.verifyEmail.goToLogin")}
77
- </Link>
78
- </AuthCard>
79
- );
80
- }
81
-
82
- // status === "error"
83
26
  return (
84
- <AuthCard title={title ?? t("auth.verifyEmail.errorTitle")}>
85
- <p className="text-sm text-muted-foreground">{t("auth.verifyEmail.errorBody")}</p>
86
- <Link href={loginHref} variant="muted">
87
- {t("auth.verifyEmail.goToLogin")}
88
- </Link>
89
- </AuthCard>
27
+ <TokenConfirmScreen
28
+ title={title}
29
+ token={token}
30
+ loginHref={loginHref}
31
+ confirm={verifyEmail}
32
+ labels={{
33
+ errorTitle: t("auth.verifyEmail.errorTitle"),
34
+ missingToken: t("auth.verifyEmail.missingToken"),
35
+ goToLogin: t("auth.verifyEmail.goToLogin"),
36
+ verifying: t("auth.verifyEmail.verifying"),
37
+ successTitle: t("auth.verifyEmail.successTitle"),
38
+ successBody: t("auth.verifyEmail.successBody"),
39
+ errorBody: t("auth.verifyEmail.errorBody"),
40
+ }}
41
+ />
90
42
  );
91
43
  }
@@ -13,6 +13,8 @@
13
13
  // the right time to catch it).
14
14
 
15
15
  import type { FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
16
+ import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
17
+ import { AUTH_FOUNDATION_BOOT_RULES } from "./boot-rules.ts";
16
18
  import {
17
19
  EXT_SESSION_STORE,
18
20
  EXT_TENANT_EXISTENCE,
@@ -32,10 +34,11 @@ export function validateTokenVerifierMultiplicity(features: readonly FeatureDefi
32
34
  for (const usage of feature.extensionUsages) {
33
35
  if (usage.extensionName !== EXT_TOKEN_VERIFIER) continue;
34
36
  if (!isAuthProviderPlugin(usage.options)) {
35
- throw new Error(
36
- `[auth-foundation] tokenVerifier provider "${usage.entityName}" (feature "${feature.name}") ` +
37
+ throw bootRuleError(AUTH_FOUNDATION_BOOT_RULES.tokenVerifierInvalidPlugin, {
38
+ message:
39
+ `[auth-foundation] tokenVerifier provider "${usage.entityName}" (feature "${feature.name}") ` +
37
40
  `registered without a valid AuthProviderPlugin — options must have a { shape, build } shape.`,
38
- );
41
+ });
39
42
  }
40
43
  const key = tokenShapeKey(usage.options.shape);
41
44
  const names = namesByShape.get(key) ?? [];
@@ -53,20 +56,22 @@ export function validateTokenVerifierMultiplicity(features: readonly FeatureDefi
53
56
  if (usage.extensionName === EXT_SESSION_STORE) return;
54
57
  }
55
58
  }
56
- throw new Error(
57
- "[auth-foundation] no tokenVerifier providers and no sessionStore registered — mount " +
59
+ throw bootRuleError(AUTH_FOUNDATION_BOOT_RULES.noTokenVerifierOrSessionStore, {
60
+ message:
61
+ "[auth-foundation] no tokenVerifier providers and no sessionStore registered — mount " +
58
62
  "at least one auth-provider-* feature (e.g. auth-provider-jwt / personal-access-tokens) " +
59
63
  "or a sessionStore (e.g. sessions) alongside auth-foundation.",
60
- );
64
+ });
61
65
  }
62
66
 
63
67
  for (const [key, names] of namesByShape) {
64
68
  if (names.length >= 2) {
65
- throw new Error(
66
- `[auth-foundation] ${names.length} tokenVerifier providers claim the same shape "${key}" ` +
69
+ throw bootRuleError(AUTH_FOUNDATION_BOOT_RULES.tokenVerifierShapeCollision, {
70
+ message:
71
+ `[auth-foundation] ${names.length} tokenVerifier providers claim the same shape "${key}" ` +
67
72
  `(${names.join(", ")}) — resolveTokenVerifier can't route between them unambiguously. ` +
68
73
  `Give each provider a distinct shape.`,
69
- );
74
+ });
70
75
  }
71
76
  }
72
77
  }
@@ -97,20 +102,22 @@ function validateSingleProvider(
97
102
  for (const usage of feature.extensionUsages) {
98
103
  if (usage.extensionName !== ext) continue;
99
104
  if (!guard(usage.options)) {
100
- throw new Error(
101
- `[auth-foundation] ${label} provider "${usage.entityName}" (feature "${feature.name}") ` +
105
+ throw bootRuleError(AUTH_FOUNDATION_BOOT_RULES.singleProviderInvalidShape, {
106
+ message:
107
+ `[auth-foundation] ${label} provider "${usage.entityName}" (feature "${feature.name}") ` +
102
108
  `registered without a valid ${shapeHint}.`,
103
- );
109
+ });
104
110
  }
105
111
  names.push(usage.entityName);
106
112
  }
107
113
  }
108
114
 
109
115
  if (names.length >= 2) {
110
- throw new Error(
111
- `[auth-foundation] ${names.length} ${label} providers registered (${names.join(", ")}) — ` +
116
+ throw bootRuleError(AUTH_FOUNDATION_BOOT_RULES.singleProviderMultiple, {
117
+ message:
118
+ `[auth-foundation] ${names.length} ${label} providers registered (${names.join(", ")}) — ` +
112
119
  `only one ${label} provider may be mounted at a time.`,
113
- );
120
+ });
114
121
  }
115
122
  }
116
123
 
@@ -0,0 +1,33 @@
1
+ import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
2
+
3
+ export const AUTH_FOUNDATION_BOOT_RULES = {
4
+ tokenVerifierInvalidPlugin: {
5
+ id: "auth-foundation/token-verifier-invalid-plugin",
6
+ summary:
7
+ "A tokenVerifier provider registers a valid AuthProviderPlugin with a { shape, build } options shape.",
8
+ fix: "Register the provider with options of shape { shape, build }.",
9
+ },
10
+ noTokenVerifierOrSessionStore: {
11
+ id: "auth-foundation/no-token-verifier-or-session-store",
12
+ summary:
13
+ "At least one tokenVerifier provider or a sessionStore is registered alongside auth-foundation.",
14
+ fix: "Mount an auth-provider-* feature (e.g. auth-provider-jwt / personal-access-tokens) or a sessionStore (e.g. sessions).",
15
+ },
16
+ tokenVerifierShapeCollision: {
17
+ id: "auth-foundation/token-verifier-shape-collision",
18
+ summary:
19
+ "No two tokenVerifier providers claim the same token shape, so resolveTokenVerifier can route unambiguously.",
20
+ fix: "Give each provider a distinct shape.",
21
+ },
22
+ singleProviderInvalidShape: {
23
+ id: "auth-foundation/single-provider-invalid-shape",
24
+ summary:
25
+ "A single-provider extension registration carries the options shape its provider type requires.",
26
+ fix: "Register the provider with the options shape named in the error message.",
27
+ },
28
+ singleProviderMultiple: {
29
+ id: "auth-foundation/single-provider-multiple",
30
+ summary: "At most one provider of a single-provider extension is mounted at a time.",
31
+ fix: "Unmount all but one provider.",
32
+ },
33
+ } as const satisfies BootRuleTable;
@@ -1,66 +1,36 @@
1
- import {
2
- UnprocessableError,
3
- type WriteFailure,
4
- writeFailure,
5
- } from "@cosmicdrift/kumiko-framework/errors";
6
- import { AuthMfaErrorCodes } from "./web/constants.ts";
1
+ import type { WriteFailure } from "@cosmicdrift/kumiko-framework/errors";
2
+ import { unprocessable } from "../shared/index.ts";
3
+ import { AuthMfaErrorCodes as Code } from "./web/constants.ts";
7
4
 
8
5
  export { AuthMfaErrorCodes as AuthMfaErrors } from "./web/constants.ts";
9
6
 
10
7
  export function mfaAlreadyEnabled(): WriteFailure {
11
- return writeFailure(
12
- new UnprocessableError(AuthMfaErrorCodes.mfaAlreadyEnabled, {
13
- i18nKey: "auth.mfa.errors.mfaAlreadyEnabled",
14
- }),
15
- );
8
+ return unprocessable(Code.mfaAlreadyEnabled, "auth.mfa.errors.mfaAlreadyEnabled");
16
9
  }
17
10
 
18
11
  export function mfaNotEnabled(): WriteFailure {
19
- return writeFailure(
20
- new UnprocessableError(AuthMfaErrorCodes.mfaNotEnabled, {
21
- i18nKey: "auth.mfa.errors.mfaNotEnabled",
22
- }),
23
- );
12
+ return unprocessable(Code.mfaNotEnabled, "auth.mfa.errors.mfaNotEnabled");
24
13
  }
25
14
 
26
15
  export function invalidSetupToken(): WriteFailure {
27
- return writeFailure(
28
- new UnprocessableError(AuthMfaErrorCodes.invalidSetupToken, {
29
- i18nKey: "auth.mfa.errors.invalidSetupToken",
30
- }),
31
- );
16
+ return unprocessable(Code.invalidSetupToken, "auth.mfa.errors.invalidSetupToken");
32
17
  }
33
18
 
34
19
  export function invalidTotpCode(): WriteFailure {
35
- return writeFailure(
36
- new UnprocessableError(AuthMfaErrorCodes.invalidTotpCode, {
37
- i18nKey: "auth.mfa.errors.invalidTotpCode",
38
- }),
39
- );
20
+ return unprocessable(Code.invalidTotpCode, "auth.mfa.errors.invalidTotpCode");
40
21
  }
41
22
 
42
23
  export function invalidRecoveryCode(): WriteFailure {
43
- return writeFailure(
44
- new UnprocessableError(AuthMfaErrorCodes.invalidRecoveryCode, {
45
- i18nKey: "auth.mfa.errors.invalidRecoveryCode",
46
- }),
47
- );
24
+ return unprocessable(Code.invalidRecoveryCode, "auth.mfa.errors.invalidRecoveryCode");
48
25
  }
49
26
 
50
27
  export function invalidChallengeToken(): WriteFailure {
51
- return writeFailure(
52
- new UnprocessableError(AuthMfaErrorCodes.invalidChallengeToken, {
53
- i18nKey: "auth.mfa.errors.invalidChallengeToken",
54
- }),
55
- );
28
+ return unprocessable(Code.invalidChallengeToken, "auth.mfa.errors.invalidChallengeToken");
56
29
  }
57
30
 
58
31
  // retryAfterSeconds drives the login UI countdown — must stay > 0.
59
32
  export function tooManyAttempts(retryAfterSeconds: number): WriteFailure {
60
- return writeFailure(
61
- new UnprocessableError(AuthMfaErrorCodes.tooManyAttempts, {
62
- i18nKey: "auth.mfa.errors.tooManyAttempts",
63
- details: { retryAfterSeconds },
64
- }),
65
- );
33
+ return unprocessable(Code.tooManyAttempts, "auth.mfa.errors.tooManyAttempts", {
34
+ retryAfterSeconds,
35
+ });
66
36
  }
@@ -1,4 +1,5 @@
1
1
  import type { FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { readFeatureExportFn } from "../shared/index.ts";
2
3
  import type { MfaCodeVerifier } from "./mfa-code-verifier.ts";
3
4
  import type { MfaStatusChecker } from "./mfa-status-checker.ts";
4
5
  import type { MfaTokenSecretsEnv } from "./token-secrets.ts";
@@ -17,15 +18,7 @@ export type BindMfaRevokeAllOtherSessions = (
17
18
  export function bindMfaRevokeAllOtherSessionsFromFeature(
18
19
  feature: FeatureDefinition,
19
20
  ): BindMfaRevokeAllOtherSessions | undefined {
20
- const exports = feature.exports;
21
- if (exports && typeof exports === "object" && "bindRevokeAllOtherSessions" in exports) {
22
- const { bindRevokeAllOtherSessions } = exports;
23
- if (typeof bindRevokeAllOtherSessions === "function") {
24
- // @cast-boundary feature-exports — feature.exports is untyped by design
25
- return bindRevokeAllOtherSessions as BindMfaRevokeAllOtherSessions;
26
- }
27
- }
28
- return undefined;
21
+ return readFeatureExportFn<BindMfaRevokeAllOtherSessions>(feature, "bindRevokeAllOtherSessions");
29
22
  }
30
23
 
31
24
  // Reads the eagerly-built `checkMfaStatus` off a mounted auth-mfa feature's
@@ -33,15 +26,7 @@ export function bindMfaRevokeAllOtherSessionsFromFeature(
33
26
  export function mfaStatusCheckerFromFeature(
34
27
  feature: FeatureDefinition,
35
28
  ): MfaStatusChecker | undefined {
36
- const exports = feature.exports;
37
- if (exports && typeof exports === "object" && "checkMfaStatus" in exports) {
38
- const { checkMfaStatus } = exports;
39
- if (typeof checkMfaStatus === "function") {
40
- // @cast-boundary feature-exports — feature.exports is untyped by design
41
- return checkMfaStatus as MfaStatusChecker;
42
- }
43
- }
44
- return undefined;
29
+ return readFeatureExportFn<MfaStatusChecker>(feature, "checkMfaStatus");
45
30
  }
46
31
 
47
32
  // Reads the eagerly-built `verifyMfaCode` off a mounted auth-mfa feature's
@@ -49,15 +34,7 @@ export function mfaStatusCheckerFromFeature(
49
34
  // mfaVerifier (re-auth gate for minting a token). Same no-bind-setter
50
35
  // reasoning as checkMfaStatus above.
51
36
  export function mfaVerifierFromFeature(feature: FeatureDefinition): MfaCodeVerifier | undefined {
52
- const exports = feature.exports;
53
- if (exports && typeof exports === "object" && "verifyMfaCode" in exports) {
54
- const { verifyMfaCode } = exports;
55
- if (typeof verifyMfaCode === "function") {
56
- // @cast-boundary feature-exports — feature.exports is untyped by design
57
- return verifyMfaCode as MfaCodeVerifier;
58
- }
59
- }
60
- return undefined;
37
+ return readFeatureExportFn<MfaCodeVerifier>(feature, "verifyMfaCode");
61
38
  }
62
39
 
63
40
  export type BindMfaTokenSecrets = (masterSecret: string, env: MfaTokenSecretsEnv) => void;
@@ -68,15 +45,7 @@ export type BindMfaTokenSecrets = (masterSecret: string, env: MfaTokenSecretsEnv
68
45
  export function bindMfaTokenSecretsFromFeature(
69
46
  feature: FeatureDefinition,
70
47
  ): BindMfaTokenSecrets | undefined {
71
- const exports = feature.exports;
72
- if (exports && typeof exports === "object" && "bindTokenSecrets" in exports) {
73
- const { bindTokenSecrets } = exports;
74
- if (typeof bindTokenSecrets === "function") {
75
- // @cast-boundary feature-exports — feature.exports is untyped by design
76
- return bindTokenSecrets as BindMfaTokenSecrets;
77
- }
78
- }
79
- return undefined;
48
+ return readFeatureExportFn<BindMfaTokenSecrets>(feature, "bindTokenSecrets");
80
49
  }
81
50
 
82
51
  export type BindRevokeAllPatTokens = (revoker: (userId: string) => Promise<number>) => () => void;
@@ -88,13 +57,5 @@ export type BindRevokeAllPatTokens = (revoker: (userId: string) => Promise<numbe
88
57
  export function bindRevokeAllPatTokensFromFeature(
89
58
  feature: FeatureDefinition,
90
59
  ): BindRevokeAllPatTokens | undefined {
91
- const exports = feature.exports;
92
- if (exports && typeof exports === "object" && "bindRevokeAllPatTokens" in exports) {
93
- const { bindRevokeAllPatTokens } = exports;
94
- if (typeof bindRevokeAllPatTokens === "function") {
95
- // @cast-boundary feature-exports — feature.exports is untyped by design
96
- return bindRevokeAllPatTokens as BindRevokeAllPatTokens;
97
- }
98
- }
99
- return undefined;
60
+ return readFeatureExportFn<BindRevokeAllPatTokens>(feature, "bindRevokeAllPatTokens");
100
61
  }