@cosmicdrift/kumiko-samples 0.385.0 → 0.387.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 (395) hide show
  1. package/LICENSE +21 -57
  2. package/README.md +1 -1
  3. package/package.json +2 -2
  4. package/packages/bundled-features/package.json +2 -2
  5. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -1
  6. package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +0 -2
  7. package/packages/bundled-features/src/audit/screens.ts +1 -1
  8. package/packages/bundled-features/src/auth-email-password/auth-user-row.ts +10 -10
  9. package/packages/bundled-features/src/auth-email-password/feature.ts +6 -6
  10. package/packages/bundled-features/src/auth-email-password/handlers/change-password.write.ts +3 -3
  11. package/packages/bundled-features/src/auth-email-password/handlers/confirm-token-flow.ts +5 -5
  12. package/packages/bundled-features/src/auth-email-password/handlers/invite-accept-with-login.write.ts +1 -1
  13. package/packages/bundled-features/src/auth-email-password/handlers/invite-accept.write.ts +18 -18
  14. package/packages/bundled-features/src/auth-email-password/handlers/invite-create.write.ts +12 -12
  15. package/packages/bundled-features/src/auth-email-password/handlers/invite-info.query.ts +1 -1
  16. package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +24 -26
  17. package/packages/bundled-features/src/auth-email-password/handlers/login.write.ts +1 -1
  18. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  19. package/packages/bundled-features/src/auth-email-password/handlers/signup-confirm.write.ts +34 -37
  20. package/packages/bundled-features/src/auth-email-password/handlers/signup-request.write.ts +6 -7
  21. package/packages/bundled-features/src/auth-email-password/handlers/switch-tenant-mfa-gate.write.ts +1 -5
  22. package/packages/bundled-features/src/auth-email-password/index.ts +5 -5
  23. package/packages/bundled-features/src/auth-email-password/lockout-store.ts +1 -1
  24. package/packages/bundled-features/src/auth-email-password/seeding.ts +63 -66
  25. package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +8 -8
  26. package/packages/bundled-features/src/auth-email-password/testing.ts +3 -3
  27. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +57 -57
  28. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +14 -14
  29. package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +15 -16
  30. package/packages/bundled-features/src/auth-email-password/web/client-plugin.ts +11 -12
  31. package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +1 -1
  32. package/packages/bundled-features/src/auth-email-password/web/constants.ts +3 -3
  33. package/packages/bundled-features/src/auth-email-password/web/default-topbar-actions.tsx +14 -14
  34. package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +11 -11
  35. package/packages/bundled-features/src/auth-email-password/web/index.ts +5 -5
  36. package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +17 -17
  37. package/packages/bundled-features/src/auth-email-password/web/login-screen.tsx +3 -4
  38. package/packages/bundled-features/src/auth-email-password/web/reset-password-screen.tsx +16 -17
  39. package/packages/bundled-features/src/auth-email-password/web/session.tsx +34 -34
  40. package/packages/bundled-features/src/auth-email-password/web/signup-complete-screen.tsx +3 -3
  41. package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +14 -14
  42. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +26 -27
  43. package/packages/bundled-features/src/auth-email-password/web/use-shell-user.ts +12 -13
  44. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +17 -18
  45. package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +11 -12
  46. package/packages/bundled-features/src/auth-foundation/boot-checks.ts +4 -4
  47. package/packages/bundled-features/src/auth-foundation/resolve-anonymous-access.ts +4 -4
  48. package/packages/bundled-features/src/auth-foundation/types.ts +2 -2
  49. package/packages/bundled-features/src/auth-mfa/handlers/disable.write.ts +3 -3
  50. package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm-preauth.write.ts +4 -4
  51. package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm.write.ts +2 -2
  52. package/packages/bundled-features/src/auth-mfa/handlers/enable-start-preauth.write.ts +1 -1
  53. package/packages/bundled-features/src/auth-mfa/handlers/reencrypt.job.ts +1 -1
  54. package/packages/bundled-features/src/auth-mfa/handlers/regenerate-recovery.write.ts +5 -5
  55. package/packages/bundled-features/src/auth-mfa/handlers/verify.write.ts +1 -1
  56. package/packages/bundled-features/src/auth-mfa/token-secrets.ts +1 -1
  57. package/packages/bundled-features/src/auth-mfa/web/client-plugin.ts +2 -2
  58. package/packages/bundled-features/src/auth-mfa/web/i18n.ts +3 -3
  59. package/packages/bundled-features/src/auth-mfa/web/index.ts +4 -4
  60. package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +17 -16
  61. package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +6 -6
  62. package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +10 -11
  63. package/packages/bundled-features/src/billing-foundation/entities.ts +27 -27
  64. package/packages/bundled-features/src/billing-foundation/events.ts +22 -21
  65. package/packages/bundled-features/src/billing-foundation/feature.ts +42 -43
  66. package/packages/bundled-features/src/billing-foundation/get-subscription-for-tenant.ts +3 -5
  67. package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +18 -17
  68. package/packages/bundled-features/src/billing-foundation/handlers/create-portal-session.write.ts +11 -12
  69. package/packages/bundled-features/src/billing-foundation/handlers/list-subscriptions.query.ts +4 -4
  70. package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +20 -20
  71. package/packages/bundled-features/src/billing-foundation/projection.ts +38 -37
  72. package/packages/bundled-features/src/billing-foundation/subscription-tier-sync.ts +3 -3
  73. package/packages/bundled-features/src/billing-foundation/tenant-destroy-hook.ts +7 -8
  74. package/packages/bundled-features/src/billing-foundation/types.ts +64 -65
  75. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +4 -4
  76. package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +1 -1
  77. package/packages/bundled-features/src/cap-counter/aggregate-id.ts +8 -9
  78. package/packages/bundled-features/src/cap-counter/constants.ts +11 -12
  79. package/packages/bundled-features/src/cap-counter/enforce-cap.ts +64 -67
  80. package/packages/bundled-features/src/cap-counter/entity.ts +29 -29
  81. package/packages/bundled-features/src/cap-counter/feature.ts +34 -35
  82. package/packages/bundled-features/src/cap-counter/handlers/increment-rolling.write.ts +31 -31
  83. package/packages/bundled-features/src/cap-counter/handlers/mark-soft-warned.write.ts +4 -5
  84. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -1
  85. package/packages/bundled-features/src/cap-counter/with-cap-enforcement.ts +3 -5
  86. package/packages/bundled-features/src/cap-overview/handlers/caps-usage.query.ts +1 -3
  87. package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +1 -1
  88. package/packages/bundled-features/src/channel-email/smtp-transport.ts +34 -31
  89. package/packages/bundled-features/src/channel-in-app/handlers/unread-count.query.ts +3 -4
  90. package/packages/bundled-features/src/compliance-profiles/feature.ts +15 -16
  91. package/packages/bundled-features/src/compliance-profiles/handlers/for-tenant.query.ts +3 -6
  92. package/packages/bundled-features/src/compliance-profiles/handlers/list-profiles.query.ts +5 -5
  93. package/packages/bundled-features/src/compliance-profiles/handlers/needs-profile.query.ts +4 -4
  94. package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +13 -14
  95. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +9 -11
  96. package/packages/bundled-features/src/compliance-profiles/resolve-for-tenant.ts +7 -7
  97. package/packages/bundled-features/src/compliance-profiles/schema/profile-selection.ts +18 -23
  98. package/packages/bundled-features/src/compliance-profiles/seeding.ts +14 -15
  99. package/packages/bundled-features/src/compliance-profiles-ops/handlers/tenants-missing-profile.query.ts +3 -3
  100. package/packages/bundled-features/src/compliance-profiles-ops/index.ts +2 -2
  101. package/packages/bundled-features/src/config/handlers/readiness.query.ts +7 -7
  102. package/packages/bundled-features/src/config/handlers/reencrypt.job.ts +4 -5
  103. package/packages/bundled-features/src/config/handlers/set.write.ts +4 -4
  104. package/packages/bundled-features/src/config/resolver.ts +4 -4
  105. package/packages/bundled-features/src/config/table.ts +10 -10
  106. package/packages/bundled-features/src/config/write-helpers.ts +1 -1
  107. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +13 -12
  108. package/packages/bundled-features/src/custom-fields/aggregate-id.ts +16 -17
  109. package/packages/bundled-features/src/custom-fields/entity.ts +49 -47
  110. package/packages/bundled-features/src/custom-fields/events.ts +7 -8
  111. package/packages/bundled-features/src/custom-fields/feature.ts +70 -72
  112. package/packages/bundled-features/src/custom-fields/handlers/clear-custom-field.write.ts +9 -8
  113. package/packages/bundled-features/src/custom-fields/handlers/define-tenant-field.write.ts +28 -26
  114. package/packages/bundled-features/src/custom-fields/handlers/delete-system-field.write.ts +6 -7
  115. package/packages/bundled-features/src/custom-fields/handlers/delete-tenant-field.write.ts +12 -13
  116. package/packages/bundled-features/src/custom-fields/handlers/set-custom-field.write.ts +25 -28
  117. package/packages/bundled-features/src/custom-fields/handlers/update-tenant-field.write.ts +6 -6
  118. package/packages/bundled-features/src/custom-fields/lib/field-access.ts +2 -2
  119. package/packages/bundled-features/src/custom-fields/lib/parse-serialized-field.ts +1 -1
  120. package/packages/bundled-features/src/custom-fields/lib/quota.ts +1 -1
  121. package/packages/bundled-features/src/custom-fields/lib/value-schema.ts +10 -12
  122. package/packages/bundled-features/src/custom-fields/run-retention.ts +3 -3
  123. package/packages/bundled-features/src/custom-fields/schemas.ts +14 -14
  124. package/packages/bundled-features/src/custom-fields/web/client-plugin.tsx +2 -5
  125. package/packages/bundled-features/src/custom-fields/web/constants.ts +2 -2
  126. package/packages/bundled-features/src/custom-fields/web/custom-fields-form-section.tsx +26 -26
  127. package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +65 -67
  128. package/packages/bundled-features/src/custom-fields/wire-user-data-rights.ts +3 -3
  129. package/packages/bundled-features/src/data-retention/_internal/parse-override.ts +2 -3
  130. package/packages/bundled-features/src/data-retention/feature.ts +11 -18
  131. package/packages/bundled-features/src/data-retention/handlers/policy-for.query.ts +6 -6
  132. package/packages/bundled-features/src/data-retention/keep-for.ts +17 -17
  133. package/packages/bundled-features/src/data-retention/override-schema.ts +13 -15
  134. package/packages/bundled-features/src/data-retention/presets.ts +18 -23
  135. package/packages/bundled-features/src/data-retention/resolve-for-tenant.ts +1 -1
  136. package/packages/bundled-features/src/data-retention/resolve-tenant-preset.ts +17 -16
  137. package/packages/bundled-features/src/data-retention/resolver.ts +33 -32
  138. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +71 -58
  139. package/packages/bundled-features/src/data-retention/schema/tenant-retention-override.ts +13 -11
  140. package/packages/bundled-features/src/delivery/feature.ts +3 -3
  141. package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
  142. package/packages/bundled-features/src/delivery/tables.ts +9 -8
  143. package/packages/bundled-features/src/delivery/unsubscribe.ts +4 -4
  144. package/packages/bundled-features/src/delivery/upsert-preference.ts +3 -4
  145. package/packages/bundled-features/src/document-ingest-foundation/entity.ts +5 -5
  146. package/packages/bundled-features/src/document-ingest-foundation/events.ts +2 -2
  147. package/packages/bundled-features/src/document-ingest-foundation/feature.ts +2 -2
  148. package/packages/bundled-features/src/document-ingest-foundation/pages.ts +1 -1
  149. package/packages/bundled-features/src/document-ingest-foundation/tenant-destroy-hook.ts +4 -4
  150. package/packages/bundled-features/src/feature-toggles/compose-tier-resolver.ts +1 -1
  151. package/packages/bundled-features/src/feature-toggles/feature.ts +1 -1
  152. package/packages/bundled-features/src/feature-toggles/global-feature-state-table.ts +1 -1
  153. package/packages/bundled-features/src/feature-toggles/handlers/registered.query.ts +5 -5
  154. package/packages/bundled-features/src/feature-toggles/toggle-runtime.ts +1 -1
  155. package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +1 -1
  156. package/packages/bundled-features/src/feature-toggles/web/constants.ts +1 -1
  157. package/packages/bundled-features/src/file-derivatives/feature.ts +2 -2
  158. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  159. package/packages/bundled-features/src/file-derivatives/presets.ts +1 -1
  160. package/packages/bundled-features/src/file-foundation/feature.ts +6 -6
  161. package/packages/bundled-features/src/file-provider-inmemory/feature.ts +16 -16
  162. package/packages/bundled-features/src/file-provider-s3/feature.ts +16 -16
  163. package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +6 -6
  164. package/packages/bundled-features/src/files/feature.ts +6 -6
  165. package/packages/bundled-features/src/files-tenant-data/handlers/sweep-orphaned-derivatives.job.ts +5 -5
  166. package/packages/bundled-features/src/files-tenant-data/hooks.ts +24 -26
  167. package/packages/bundled-features/src/files-tenant-data/index.ts +1 -1
  168. package/packages/bundled-features/src/folders/feature.ts +1 -1
  169. package/packages/bundled-features/src/folders/web/folder-manager.tsx +2 -2
  170. package/packages/bundled-features/src/folders/web/tree.ts +5 -5
  171. package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +1 -1
  172. package/packages/bundled-features/src/form-draft/db/queries/owned-file-refs.ts +1 -1
  173. package/packages/bundled-features/src/form-draft/entity.ts +3 -3
  174. package/packages/bundled-features/src/form-draft/feature.ts +4 -5
  175. package/packages/bundled-features/src/form-draft/handlers/discard.write.ts +1 -1
  176. package/packages/bundled-features/src/form-draft/release-file-refs.ts +6 -6
  177. package/packages/bundled-features/src/form-draft/schemas.ts +3 -3
  178. package/packages/bundled-features/src/form-draft/web/constants.ts +0 -2
  179. package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +19 -19
  180. package/packages/bundled-features/src/inbound-mail-foundation/connect-routes.ts +4 -3
  181. package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +30 -33
  182. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +47 -48
  183. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +54 -50
  184. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +39 -39
  185. package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-state.ts +8 -8
  186. package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +25 -26
  187. package/packages/bundled-features/src/inbound-mail-foundation/handlers/disconnect-account.write.ts +7 -7
  188. package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +50 -51
  189. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-accounts.query.ts +8 -8
  190. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +10 -10
  191. package/packages/bundled-features/src/inbound-mail-foundation/handlers/scope-visibility.ts +3 -4
  192. package/packages/bundled-features/src/inbound-mail-foundation/handlers/update-account.write.ts +11 -11
  193. package/packages/bundled-features/src/inbound-mail-foundation/oauth-state.ts +16 -15
  194. package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +31 -29
  195. package/packages/bundled-features/src/inbound-mail-foundation/provider-factory.ts +9 -9
  196. package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +45 -41
  197. package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -16
  198. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +66 -67
  199. package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +69 -68
  200. package/packages/bundled-features/src/inbound-provider-imap/credential-document.ts +13 -13
  201. package/packages/bundled-features/src/inbound-provider-imap/feature.ts +42 -40
  202. package/packages/bundled-features/src/inbound-provider-imap/imap-client.ts +20 -19
  203. package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +21 -21
  204. package/packages/bundled-features/src/jobs/db/queries/retention.ts +2 -2
  205. package/packages/bundled-features/src/jobs/db/queries/stale-run-sweep.ts +3 -3
  206. package/packages/bundled-features/src/jobs/events.ts +1 -1
  207. package/packages/bundled-features/src/jobs/feature.ts +6 -7
  208. package/packages/bundled-features/src/jobs/handlers/detail.query.ts +4 -4
  209. package/packages/bundled-features/src/jobs/handlers/list.query.ts +1 -1
  210. package/packages/bundled-features/src/jobs/handlers/projection-rebuild.job.ts +1 -1
  211. package/packages/bundled-features/src/jobs/handlers/reindex-entity.job.ts +1 -1
  212. package/packages/bundled-features/src/jobs/handlers/retry.write.ts +1 -1
  213. package/packages/bundled-features/src/jobs/job-instant.ts +1 -1
  214. package/packages/bundled-features/src/jobs/job-run-logger.ts +14 -15
  215. package/packages/bundled-features/src/jobs/job-run-table.ts +3 -3
  216. package/packages/bundled-features/src/jobs/screens.ts +1 -1
  217. package/packages/bundled-features/src/jobs/tenant-job-failure-table.ts +1 -1
  218. package/packages/bundled-features/src/jobs/tenant-job-run-table.ts +1 -1
  219. package/packages/bundled-features/src/ledger/entity.ts +5 -5
  220. package/packages/bundled-features/src/ledger/feature.ts +3 -3
  221. package/packages/bundled-features/src/ledger/handlers/confirm-schedule-period.write.ts +3 -3
  222. package/packages/bundled-features/src/ledger/recurring.ts +12 -12
  223. package/packages/bundled-features/src/ledger/schemas.ts +1 -1
  224. package/packages/bundled-features/src/ledger/web/constants.ts +2 -2
  225. package/packages/bundled-features/src/ledger/web/index.ts +7 -7
  226. package/packages/bundled-features/src/legal-pages/feature.ts +40 -41
  227. package/packages/bundled-features/src/legal-pages/markdown.ts +3 -3
  228. package/packages/bundled-features/src/legal-pages/web/client-plugin.ts +23 -24
  229. package/packages/bundled-features/src/legal-pages/web/index.ts +0 -2
  230. package/packages/bundled-features/src/mail-foundation/feature.ts +26 -27
  231. package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +27 -28
  232. package/packages/bundled-features/src/mail-transport-smtp/feature.ts +20 -20
  233. package/packages/bundled-features/src/managed-pages/branding.ts +6 -6
  234. package/packages/bundled-features/src/managed-pages/feature.ts +62 -62
  235. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +5 -6
  236. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +8 -8
  237. package/packages/bundled-features/src/managed-pages/handlers/set.write.ts +5 -7
  238. package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +11 -11
  239. package/packages/bundled-features/src/managed-pages/seeding.ts +8 -8
  240. package/packages/bundled-features/src/managed-pages/table.ts +16 -15
  241. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +6 -6
  242. package/packages/bundled-features/src/managed-pages/web/i18n.ts +1 -1
  243. package/packages/bundled-features/src/notes-history/entity.ts +4 -4
  244. package/packages/bundled-features/src/notes-history/feature.ts +2 -2
  245. package/packages/bundled-features/src/notes-history-user-data/hooks.ts +1 -1
  246. package/packages/bundled-features/src/page-render/layout.ts +9 -9
  247. package/packages/bundled-features/src/page-render/markdown.ts +11 -11
  248. package/packages/bundled-features/src/page-render/security-headers.ts +7 -6
  249. package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -5
  250. package/packages/bundled-features/src/personal-access-tokens/roles.ts +2 -2
  251. package/packages/bundled-features/src/readiness/handlers/status.query.ts +3 -3
  252. package/packages/bundled-features/src/renderer-foundation/api.ts +12 -13
  253. package/packages/bundled-features/src/renderer-foundation/constants.ts +2 -2
  254. package/packages/bundled-features/src/renderer-foundation/feature.ts +7 -7
  255. package/packages/bundled-features/src/renderer-foundation/types.ts +11 -12
  256. package/packages/bundled-features/src/secrets/feature.ts +9 -9
  257. package/packages/bundled-features/src/secrets/web/constants.ts +2 -2
  258. package/packages/bundled-features/src/seo/feature.ts +3 -3
  259. package/packages/bundled-features/src/sessions/constants.ts +1 -1
  260. package/packages/bundled-features/src/sessions/feature.ts +9 -9
  261. package/packages/bundled-features/src/sessions/handlers/revoke-all-for-user.write.ts +2 -2
  262. package/packages/bundled-features/src/sessions/handlers/revoke-all-others.write.ts +2 -2
  263. package/packages/bundled-features/src/sessions/handlers/revoke.write.ts +1 -1
  264. package/packages/bundled-features/src/sessions/schema/user-session.ts +4 -4
  265. package/packages/bundled-features/src/sessions/screens.ts +2 -2
  266. package/packages/bundled-features/src/sessions/session-callbacks.ts +2 -2
  267. package/packages/bundled-features/src/sessions/session-revoked-event.ts +2 -2
  268. package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +1 -1
  269. package/packages/bundled-features/src/shared/decrypt-stored-pii.ts +1 -1
  270. package/packages/bundled-features/src/shared/encrypt-for-direct-write.ts +1 -1
  271. package/packages/bundled-features/src/shared/map-with-concurrency.ts +5 -4
  272. package/packages/bundled-features/src/shared/parent-visibility.ts +2 -2
  273. package/packages/bundled-features/src/shared/password-hashing.ts +1 -1
  274. package/packages/bundled-features/src/shared/signup-handover.ts +1 -2
  275. package/packages/bundled-features/src/shared/single-use-token-store.ts +1 -1
  276. package/packages/bundled-features/src/subscription-mollie/constants.ts +15 -17
  277. package/packages/bundled-features/src/subscription-mollie/feature.ts +41 -42
  278. package/packages/bundled-features/src/subscription-mollie/index.ts +3 -3
  279. package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +17 -16
  280. package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +34 -34
  281. package/packages/bundled-features/src/subscription-stripe/constants.ts +4 -6
  282. package/packages/bundled-features/src/subscription-stripe/feature.ts +44 -43
  283. package/packages/bundled-features/src/subscription-stripe/index.ts +6 -6
  284. package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +22 -27
  285. package/packages/bundled-features/src/subscription-stripe/runtime.ts +2 -2
  286. package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +62 -64
  287. package/packages/bundled-features/src/tags/feature.ts +3 -3
  288. package/packages/bundled-features/src/tags/screens.ts +1 -1
  289. package/packages/bundled-features/src/template-resolver/api.ts +10 -10
  290. package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +5 -5
  291. package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +1 -1
  292. package/packages/bundled-features/src/template-resolver/handlers/shared.ts +2 -2
  293. package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +3 -3
  294. package/packages/bundled-features/src/template-resolver/handlers/upsert-system.write.ts +3 -4
  295. package/packages/bundled-features/src/template-resolver/handlers/upsert-tenant.write.ts +4 -5
  296. package/packages/bundled-features/src/template-resolver/seeding.ts +4 -4
  297. package/packages/bundled-features/src/template-resolver/table.ts +13 -14
  298. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +2 -2
  299. package/packages/bundled-features/src/tenant/feature.ts +7 -7
  300. package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +1 -1
  301. package/packages/bundled-features/src/tenant/handlers/members.query.ts +1 -1
  302. package/packages/bundled-features/src/tenant/handlers/memberships.query.ts +1 -1
  303. package/packages/bundled-features/src/tenant/handlers/team-list.query.ts +1 -1
  304. package/packages/bundled-features/src/tenant/handlers/tenant-directory.query.ts +1 -1
  305. package/packages/bundled-features/src/tenant/invitation-table.ts +37 -40
  306. package/packages/bundled-features/src/tenant/membership-table.ts +3 -3
  307. package/packages/bundled-features/src/tenant/schema/tenant.ts +7 -9
  308. package/packages/bundled-features/src/tenant/screens.ts +1 -1
  309. package/packages/bundled-features/src/tenant/seeding.ts +19 -18
  310. package/packages/bundled-features/src/tenant/testing.ts +5 -6
  311. package/packages/bundled-features/src/tenant/web/constants.ts +2 -2
  312. package/packages/bundled-features/src/tenant-handover/events.ts +5 -7
  313. package/packages/bundled-features/src/tenant-handover/feature.ts +1 -1
  314. package/packages/bundled-features/src/tenant-handover/grant.ts +1 -1
  315. package/packages/bundled-features/src/tenant-handover/handlers/claim.write.ts +1 -1
  316. package/packages/bundled-features/src/tenant-handover/move-entity-graph.ts +8 -9
  317. package/packages/bundled-features/src/tenant-handover/signup-handover-provider.ts +1 -2
  318. package/packages/bundled-features/src/tenant-handover/transfer-graph.ts +4 -5
  319. package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +1 -1
  320. package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -1
  321. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +2 -2
  322. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +1 -1
  323. package/packages/bundled-features/src/tenant-settings/constants.ts +1 -1
  324. package/packages/bundled-features/src/tenant-settings/tenant-defaults.ts +12 -5
  325. package/packages/bundled-features/src/tier-engine/aggregate-id.ts +15 -16
  326. package/packages/bundled-features/src/tier-engine/compose-app.ts +14 -14
  327. package/packages/bundled-features/src/tier-engine/entity.ts +18 -19
  328. package/packages/bundled-features/src/tier-engine/feature.ts +88 -87
  329. package/packages/bundled-features/src/tier-engine/handlers/active-tier.query.ts +6 -7
  330. package/packages/bundled-features/src/tier-engine/handlers/get-tenant-tier.query.ts +4 -4
  331. package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +8 -8
  332. package/packages/bundled-features/src/tier-engine/tier-resolver.ts +2 -2
  333. package/packages/bundled-features/src/tier-engine/trial.ts +13 -13
  334. package/packages/bundled-features/src/tier-engine/web/index.ts +4 -4
  335. package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +8 -8
  336. package/packages/bundled-features/src/user/handlers/create.write.ts +4 -4
  337. package/packages/bundled-features/src/user/schema/user.ts +45 -44
  338. package/packages/bundled-features/src/user/seeding.ts +40 -40
  339. package/packages/bundled-features/src/user/testing.ts +3 -3
  340. package/packages/bundled-features/src/user-data-rights/audit-download.ts +27 -28
  341. package/packages/bundled-features/src/user-data-rights/boot-checks.ts +1 -1
  342. package/packages/bundled-features/src/user-data-rights/deletion-token.ts +1 -1
  343. package/packages/bundled-features/src/user-data-rights/feature.ts +112 -113
  344. package/packages/bundled-features/src/user-data-rights/handlers/cancel-deletion.write.ts +9 -9
  345. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +8 -8
  346. package/packages/bundled-features/src/user-data-rights/handlers/download-by-job.query.ts +29 -30
  347. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +40 -42
  348. package/packages/bundled-features/src/user-data-rights/handlers/export-status.query.ts +8 -9
  349. package/packages/bundled-features/src/user-data-rights/handlers/lift-restriction.write.ts +7 -8
  350. package/packages/bundled-features/src/user-data-rights/handlers/list-download-attempts.query.ts +2 -2
  351. package/packages/bundled-features/src/user-data-rights/handlers/my-audit-log.query.ts +4 -4
  352. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +30 -29
  353. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion.write.ts +15 -18
  354. package/packages/bundled-features/src/user-data-rights/handlers/request-export.write.ts +42 -41
  355. package/packages/bundled-features/src/user-data-rights/handlers/restrict-account.write.ts +22 -19
  356. package/packages/bundled-features/src/user-data-rights/handlers/run-forget-cleanup.write.ts +8 -8
  357. package/packages/bundled-features/src/user-data-rights/index.ts +8 -10
  358. package/packages/bundled-features/src/user-data-rights/lib/default-mailers.ts +3 -3
  359. package/packages/bundled-features/src/user-data-rights/lib/update-user-lifecycle.ts +24 -27
  360. package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +166 -276
  361. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +85 -107
  362. package/packages/bundled-features/src/user-data-rights/run-user-export.ts +67 -69
  363. package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +11 -11
  364. package/packages/bundled-features/src/user-data-rights/schema/download-token.ts +37 -41
  365. package/packages/bundled-features/src/user-data-rights/schema/export-job.ts +65 -67
  366. package/packages/bundled-features/src/user-data-rights/token-helpers.ts +21 -25
  367. package/packages/bundled-features/src/user-data-rights/web/client-plugin.tsx +6 -6
  368. package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +6 -5
  369. package/packages/bundled-features/src/user-data-rights/web/constants.ts +1 -1
  370. package/packages/bundled-features/src/user-data-rights/web/index.ts +5 -5
  371. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +14 -13
  372. package/packages/bundled-features/src/user-data-rights/web/public-deletion-gate.tsx +13 -12
  373. package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +6 -6
  374. package/packages/bundled-features/src/user-data-rights/zip-path.ts +41 -40
  375. package/packages/bundled-features/src/user-data-rights-defaults/feature.ts +15 -15
  376. package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +3 -5
  377. package/packages/bundled-features/src/user-data-rights-defaults/hooks/file-ref.userdata-hook.ts +45 -51
  378. package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -2
  379. package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +1 -1
  380. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +3 -3
  381. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user.userdata-hook.ts +32 -31
  382. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +13 -13
  383. package/packages/bundled-features/src/user-profile/index.ts +3 -3
  384. package/packages/bundled-features/src/user-profile/web/client-plugin.ts +1 -1
  385. package/packages/bundled-features/src/user-profile/web/constants.ts +1 -1
  386. package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +1 -1
  387. package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +1 -1
  388. package/packages/bundled-features/src/workflow-runner/event-subscriber.ts +4 -5
  389. package/packages/bundled-features/src/workflow-runner/event-trigger.ts +4 -15
  390. package/packages/bundled-features/src/workflow-runner/feature.ts +2 -2
  391. package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +4 -4
  392. package/packages/bundled-features/src/workflow-runner/pending-projection.ts +6 -7
  393. package/packages/bundled-features/src/workflow-runner/runner.ts +6 -6
  394. package/packages/bundled-features/src/workflow-runner/tables.ts +6 -6
  395. package/packages/bundled-features/src/workflow-runner/workflow-registry.ts +1 -1
@@ -1,23 +1,22 @@
1
- // Magic-Link-Signup, Step 2 (confirm).
1
+ // Magic-Link signup, step 2 (confirmation).
2
2
  //
3
- // Token aus URL + Password vom User → wir lösen den Token in Redis ein
4
- // und legen Tenant + User + TenantAdmin membership atomically. emailVerified
5
- // wird sofort auf true gesetzt — der Magic-Link IST der Beweis.
3
+ // Token from the URL + password from the user → redeem the token in Redis
4
+ // and atomically create the tenant, user, and TenantAdmin membership.
5
+ // emailVerified is set to true immediately—the magic link IS the proof.
6
6
  //
7
7
  // Pipeline:
8
8
  // 1. Redis check: token → email lookup
9
- // 2. Single-Use-Burn (SETNX) — gleichzeitiger Klick aus zwei Tabs
10
- // gewinnt nur einer
11
- // 3. Tenant-Key generieren (generateUniqueName mit DB-isAvailable-
12
- // check gegen tenants.key)
13
- // 4. provisionSignupAccount: Tenant + User + Membership in einem
14
- // Rutsch (durch event-store-executor; events + projection +
15
- // MSPs sehen das wie einen regulären create)
16
- // 5. Token-Keys löschen (burn-key bleibt für TTL-Replay-Protection)
9
+ // 2. Single-use burn (SETNX)—only one of two simultaneous tab clicks wins
10
+ // 3. Generate the tenant key (generateUniqueName with a DB isAvailable
11
+ // check against tenants.key)
12
+ // 4. provisionSignupAccount: create the tenant, user, and membership in one
13
+ // operation (through event-store-executor; events, projection, and MSPs
14
+ // see this as a regular create)
15
+ // 5. Delete the token keys (the burn key remains for TTL replay protection)
17
16
  //
18
- // Failure-Recovery: jeder Pfad nach dem burn checked `committed`-Flag;
19
- // bei !committed wird der burn released damit ein legitimer Retry
20
- // nicht durch einen stale Marker geblockt wird (wie reset/verify).
17
+ // Failure recovery: every path after the burn checks the `committed` flag;
18
+ // when !committed, the burn is released so a legitimate retry is not blocked
19
+ // by a stale marker, as with reset/verify.
21
20
 
22
21
  import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
23
22
  import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
@@ -155,21 +154,21 @@ export function createSignupConfirmHandler(opts: SignupConfirmOptions = {}) {
155
154
  );
156
155
  }
157
156
 
158
- // Token-Lookup: nicht-existent / abgelaufen / schon konsumiert →
159
- // alle collapsen auf invalid_signup_token. Anti-enumeration.
157
+ // Token lookup: nonexistent, expired, and already-consumed tokens all
158
+ // collapse to invalid_signup_token to prevent enumeration.
160
159
  const email = await getEmailForSignupToken(ctx.redis, event.payload.token);
161
160
  if (!email) return invalidSignupToken();
162
161
 
163
- // Single-Use-Burn: zwei parallele Confirms aus verschiedenen
164
- // Tabs — einer wins, der andere kriegt invalid_signup_token.
162
+ // Single-use burn: of two parallel confirmations from different tabs,
163
+ // one succeeds and the other receives invalid_signup_token.
165
164
  const burn = await burnSignupToken(ctx.redis, event.payload.token);
166
165
  if (burn === "already-used") return invalidSignupToken();
167
166
 
168
167
  let committed = false;
169
168
  try {
170
- // Tenant-Key: 2-Wort-Slug aus framework/random, mit DB-Conflict-
171
- // Check gegen tenants.key. 22.500 Default-Combos + Suffix-
172
- // Fallback bei Kollision (siehe generateUniqueName).
169
+ // Tenant key: a two-word slug from framework/random, with a DB conflict
170
+ // check against tenants.key. 22,500 default combinations plus a
171
+ // suffix fallback in case of collision (see generateUniqueName).
173
172
  // @cast-boundary db-runner — helpers use only the query API that
174
173
  // DbConnection and DbTx share.
175
174
  const dbConn = ctx.db.unsafeRaw() as DbConnection;
@@ -182,8 +181,8 @@ export function createSignupConfirmHandler(opts: SignupConfirmOptions = {}) {
182
181
  });
183
182
 
184
183
  const tenantId = generateId() as TenantId; // @cast-boundary engine-payload
185
- // Display-Name aus email-prefix als sinnvolles Default; User kann
186
- // den Tenant-Namen + sein eigenes displayName später ändern.
184
+ // Use the email prefix as a meaningful default display name; the user can
185
+ // change the tenant name and their own displayName later.
187
186
  const displayName = email.split("@")[0] ?? email;
188
187
 
189
188
  const registrationLocale = registrationLocaleFromRequest();
@@ -202,25 +201,24 @@ export function createSignupConfirmHandler(opts: SignupConfirmOptions = {}) {
202
201
  tenantName: tenantKey,
203
202
  ...registrationLocale,
204
203
  },
205
- // #1463: seedTenant's postSave hooks (tier-engine's auto-default-
204
+ // seedTenant's postSave hooks (tier-engine's auto-default-
206
205
  // tier, an app's auto-default-compliance) must fire on self-signup
207
206
  // exactly like they do on the regular TenantHandlers.create path.
208
207
  { registry: ctx.registry, context: ctx },
209
208
  );
210
209
  } catch (err) {
211
- // Email hat bereits ein Konto — provisionSignupAccount ist create-only
212
- // (#365): sauberer User-Fehler, KEINE Session für den fremden Account.
213
- // committed bleibt false → der burn wird im finally released (ein
214
- // Retry scheitert wieder gleich, kein stale-Marker-Block).
210
+ // The email already has an account—provisionSignupAccount is create-only:
211
+ // return a clean user error and never create a session for that account.
212
+ // committed remains false, so finally releases the burn; a retry fails
213
+ // the same way without being blocked by a stale marker.
215
214
  if (err instanceof ConflictError) return signupEmailAlreadyRegistered();
216
215
  throw err;
217
216
  }
218
217
 
219
- // SessionUser für JWT-Mint. Roles aus INITIAL_SIGNUP_ROLES
220
- // damit DB-write (provisionSignupAccount) und Session-claim
221
- // dieselbe Quelle teilen — sonst hätten zwei Stellen "TenantAdmin"
222
- // hardcoded und ein Refactor würde role-mismatch zwischen DB
223
- // und JWT erzeugen.
218
+ // Build the SessionUser for JWT minting. Use roles from INITIAL_SIGNUP_ROLES
219
+ // so the database write (provisionSignupAccount) and session claim share
220
+ // one source; otherwise two hardcoded "TenantAdmin" values could drift
221
+ // during a refactor and create a role mismatch between the DB and JWT.
224
222
  const session: SessionUser = {
225
223
  id: provisioned.userId,
226
224
  tenantId: provisioned.tenantId,
@@ -278,9 +276,8 @@ export function createSignupConfirmHandler(opts: SignupConfirmOptions = {}) {
278
276
  };
279
277
  } finally {
280
278
  if (!committed && ctx.redis) {
281
- // Burn-release damit ein retry nach DB-Hiccup nicht blockt.
282
- // Token-Lookup-Keys bleiben — der User kann seinen Mail-Link
283
- // erneut klicken.
279
+ // Release the burn so a retry after a DB hiccup is not blocked.
280
+ // Keep the token lookup keys so the user can click the email link again.
284
281
  await unburnSignupToken(ctx.redis, event.payload.token);
285
282
  }
286
283
  }
@@ -15,7 +15,7 @@
15
15
  // Always-200 (enumeration-safe): the response looks the same for every
16
16
  // email, whether it's already registered or not. An email CAN already have
17
17
  // an account (seeding or an earlier signup) — the actual gate sits
18
- // deliberately in the confirm step (#365): signup-confirm rejects an
18
+ // deliberately in the confirm step: signup-confirm rejects an
19
19
  // already-registered email instead of reusing the existing user. Here it
20
20
  // stays always-200 + resend-idempotent so the request path leaks nothing;
21
21
  // suppressing the link on the request side would be defense-in-depth, but
@@ -34,10 +34,9 @@ import { storeSignupHandover, takeOverSignupHandoverForResend } from "../signup-
34
34
 
35
35
  const SignupRequestSchema = z.object({
36
36
  email: z.email(),
37
- // Cross-device try-first handover (kumiko-framework#3035 follow-up,
38
- // offlot-app#454) — see shared/signup-handover.ts for why the grant is
39
- // verified here and rebound to the signup token instead of the client
40
- // carrying it through the activation link.
37
+ // Cross-device try-first handover: see shared/signup-handover.ts for why the
38
+ // grant is verified here and rebound to the signup token instead of the
39
+ // client carrying it through the activation link.
41
40
  handover: z
42
41
  .object({
43
42
  entityType: z.string().min(1),
@@ -96,8 +95,8 @@ export function createSignupRequestHandler(opts: SignupRequestOptions) {
96
95
  // ctx.hasFeature() is fail-closed for *unregistered* names the moment
97
96
  // feature-toggles/tier-engine is wired, which silently kills
98
97
  // self-signup for every existing app that mounts auth-email-password
99
- // without also composing createAuthSelfRegistrationToggleFeature()
100
- // (#1468). Only gate when the toggle actually exists.
98
+ // without also composing createAuthSelfRegistrationToggleFeature().
99
+ // Only gate when the toggle actually exists.
101
100
  const gated = ctx.registry.getFeature(AUTH_SELF_REGISTRATION_FEATURE) !== undefined;
102
101
  if (gated && !(await ctx.hasFeature(AUTH_SELF_REGISTRATION_FEATURE))) {
103
102
  // No email address here — this fires on every no-op request, PII
@@ -3,7 +3,6 @@ import {
3
3
  createSystemUser,
4
4
  defineWriteHandler,
5
5
  SYSTEM_ROLE,
6
- type TenantId,
7
6
  } from "@cosmicdrift/kumiko-framework/engine";
8
7
  import { parseRoles } from "@cosmicdrift/kumiko-framework/utils";
9
8
  import * as z from "zod";
@@ -14,10 +13,7 @@ import { gateEnforceMfa, type LoginHandlerOptions } from "./login.write.ts";
14
13
 
15
14
  const SwitchTenantMfaGateSchema = z.object({
16
15
  userId: z.string().min(1),
17
- tenantId: z
18
- .string()
19
- .min(1)
20
- .transform((id) => id as TenantId),
16
+ tenantId: z.string().min(1),
21
17
  });
22
18
 
23
19
  export type SwitchTenantMfaGateData =
@@ -35,11 +35,11 @@ export {
35
35
  AUTH_SELF_REGISTRATION_FEATURE,
36
36
  createAuthSelfRegistrationToggleFeature,
37
37
  } from "./self-registration-toggle.ts";
38
- // Generic HMAC-signed single-purpose token helpers. Re-exported damit
39
- // app-spezifische out-of-band-Flows (subscriber-confirm, magic-links,
40
- // invite-tokens) denselben battle-tested signer/verifier nutzen können
41
- // statt eigene HMAC-Logik zu duplizieren. Purpose-string diskriminiert
42
- // Cross-Replay zwischen Flows.
38
+ // Generic HMAC-signed single-purpose token helpers. Re-exported so
39
+ // app-specific out-of-band flows (subscriber-confirm, magic-links,
40
+ // invite-tokens) can use the same battle-tested signer/verifier
41
+ // instead of duplicating HMAC logic. The purpose string prevents
42
+ // cross-replay between flows.
43
43
  export { signToken, TokenPurpose, type VerifyResult, verifyToken } from "./signed-token.ts";
44
44
  export {
45
45
  type IssuedSignupActivation,
@@ -17,7 +17,7 @@
17
17
  // semantics) live in shared/lockout-counter.ts — this file only wires the
18
18
  // account-lockout key prefixes onto it. See that file for why a lock
19
19
  // re-arms immediately after expiry, and why a successful login (or the
20
- // account-unlock magic-link flow, #1266, see
20
+ // account-unlock magic-link flow in
21
21
  // handlers/confirm-account-unlock.write.ts) is what resets the streak.
22
22
 
23
23
  import { createLockoutCounter, type LockoutCounterState } from "../shared/index.ts";
@@ -1,16 +1,16 @@
1
- // Stable seeding helpers fürs auth-email-password-Feature. Liegen unter
2
- // `/seeding` (nicht `/testing`) damit der Vertrag klar ist: hier ist
3
- // non-test code der bei jedem Dev-Boot + jedem Integration-Test läuft.
4
- // Test-spezifische Variationen (account-locked-Setup, expired-token,
5
- // race-conditions) werden NICHT als Knöpfe an diesen Helpers angebaut —
6
- // sie kommen als neue Funktionen daneben oder inline ins Test-File.
1
+ // Stable seeding helpers for the auth-email-password feature. They live under
2
+ // `/seeding` rather than `/testing` to make the contract clear: this is
3
+ // non-test code that runs on every dev boot and integration test.
4
+ // Test-specific variations (account-locked setup, expired-token,
5
+ // race-conditions) are NOT added as options to these helpers —
6
+ // they belong in separate functions or inline in the test file.
7
7
  //
8
- // Bündelt drei Schritte in einem Aufruf:
9
- // 1. argon2-Hash des Plain-Passworts
10
- // 2. seedUser() aus user/seeding
11
- // 3. seedTenant + seedTenantMembership aus tenant/seeding
12
- // Damit Sample-Server und Tests keine drei sub-paths zusammensammeln
13
- // müssen.
8
+ // Bundles three steps into one call:
9
+ // 1. argon2 hash of the plaintext password
10
+ // 2. seedUser() from user/seeding
11
+ // 3. seedTenant + seedTenantMembership from tenant/seeding
12
+ // This keeps sample servers and tests from having to assemble three
13
+ // sub-paths themselves.
14
14
 
15
15
  import {
16
16
  configuredBlindIndexKey,
@@ -38,10 +38,10 @@ import {
38
38
 
39
39
  const log = createFallbackLogger("auth-email-password-seeding");
40
40
 
41
- // Re-export für ergonomische Single-Import-Site in tests/seed-scripts.
42
- // Das Auth-Feature ist der natürliche Aufrufer für "seed admin user mit
43
- // password + tenant + membership" — wer das nutzt soll nicht aus drei
44
- // verschiedenen sub-paths zusammensammeln müssen.
41
+ // Re-export for a convenient single import site in tests/seed-scripts.
42
+ // The auth feature is the natural caller for "seed admin user with
43
+ // password + tenant + membership", so consumers do not need to assemble
44
+ // these helpers from three different sub-paths.
45
45
  // kumiko-lint-ignore cross-feature-import re-export of test-helpers
46
46
  export { seedTenant, seedTenantMembership } from "../tenant/seeding.ts";
47
47
  // kumiko-lint-ignore cross-feature-import re-export of test-helpers
@@ -52,24 +52,24 @@ export type SeedUserWithPasswordOptions = {
52
52
  readonly password: string;
53
53
  readonly displayName: string;
54
54
  readonly locale?: string;
55
- /** Globale Rollen — siehe SeedUserOptions.roles. */
55
+ /** Global roles — see SeedUserOptions.roles. */
56
56
  readonly roles?: readonly string[];
57
- /** Initial-emailVerified-Flag. Default false (Verify-Flow läuft).
58
- * Magic-Link-Signup setzt true weil der Mail-Klick die Email-
59
- * Ownership beweist. Siehe SeedUserOptions.emailVerified. */
57
+ /** Initial emailVerified flag. Defaults to false (the verification flow runs).
58
+ * Magic-link signup sets it to true because clicking the email proves
59
+ * ownership. See SeedUserOptions.emailVerified. */
60
60
  readonly emailVerified?: boolean;
61
61
  readonly by?: SessionUser;
62
62
  };
63
63
 
64
64
  /**
65
- * Seed a user mit Plain-Password (wird vor dem Insert mit argon2
66
- * gehasht). Liefert die userId, idempotent über email.
65
+ * Seed a user with a plaintext password (hashed with argon2 before insertion).
66
+ * Returns the userId and is idempotent by email.
67
67
  */
68
68
  export async function seedUserWithPassword(
69
69
  db: DbConnection,
70
70
  options: SeedUserWithPasswordOptions,
71
71
  // Optional, append-only — same rationale as provisionSignupAccount's
72
- // hooks param (#1478): the self-signup path passes it through so `user`'s
72
+ // hooks param: the self-signup path passes it through so `user`'s
73
73
  // postSave hooks fire on self-signup same as on the regular create path.
74
74
  hooks?: SeedTenantHooks,
75
75
  ): Promise<{ id: string }> {
@@ -89,38 +89,36 @@ export async function seedUserWithPassword(
89
89
  );
90
90
  }
91
91
 
92
- /** Provisioning-Helper für Self-Signup-Confirm. Legt einen frischen
93
- * Tenant + Admin-User + Membership in einem Rutsch an — verwendet die
94
- * bestehende Event-Store-Pipeline (wie seedAdmin) und ist daher
95
- * konsistent mit dem regulären create-Pfad: events werden geschrieben,
96
- * Projections sind populated, MSPs/Audit sehen die neuen Rows.
92
+ /** Provisions a fresh tenant, admin user, and membership for self-signup
93
+ * confirmation in one operation. It uses the existing event-store pipeline
94
+ * (as seedAdmin), keeping it consistent with the regular create path:
95
+ * events are written, projections are populated, and MSPs/audit see the
96
+ * new rows.
97
97
  *
98
- * Naming-Hinweis: nutzt intern `seedTenant` / `seedUser*` —
99
- * diese Helpers sind production-grade (event-store-pipeline), das "seed"
100
- * im Namen ist historisch (zuerst für Tests + Bootstrap gebaut, dann
101
- * als General-Purpose-Helper exportiert). Rename `seed*` → `provision*`
102
- * ist als dedizierter Cleanup-PR geplant — disproportional zum Wert
103
- * innerhalb dieses Sprints, weil alle existing tests berührt würden.
98
+ * Naming note: internally uses `seedTenant` / `seedUser*`; these helpers are
99
+ * production-grade (event-store pipeline), and "seed" is historical because
100
+ * they were first built for tests and bootstrap before being exported as
101
+ * general-purpose helpers.
104
102
  *
105
- * Atomicity: läuft inside einer Drizzle-Tx wenn der Caller das angibt
106
- * (db.begin(tx => provisionSignupAccount(tx, ...)) — die seed-
107
- * helpers nehmen DbConnection|DbTx strukturell. Bei pure DbConnection
108
- * sind die 3 writes nicht atomic; bei Failure zwischen Schritten kann
109
- * ein orphan-Tenant zurückbleiben (Tenant ohne User → unused row;
110
- * User ohne Membership → "no_membership" beim ersten Login).
103
+ * Atomicity: runs inside a Drizzle transaction when the caller provides one
104
+ * (db.begin(tx => provisionSignupAccount(tx, ...)); the seed helpers accept
105
+ * DbConnection|DbTx structurally. With a plain DbConnection, the three writes
106
+ * are not atomic; a failure between steps can leave an orphan tenant (tenant
107
+ * without a user → unused row; user without a membership → "no_membership"
108
+ * on first login).
111
109
  *
112
- * Create-only: existiert bereits ein User mit dieser Email (Seeding oder
113
- * früherer Signup), wirft die Funktion einen ConflictError BEVOR ein Tenant
114
- * entsteht. Der Self-Signup-Pfad darf einen bestehenden User nicht still
115
- * wiederverwenden — sonst würde der Confirm-Schritt eine Session für ihn
116
- * minten (Account-Takeover, #365). `seedUser` selbst bleibt idempotent
117
- * add-only (für Bootstrap/Tests); die create-only-Garantie sitzt hier.
118
- * tenantKey-Kollisionen löst der Caller via generateUniqueName. */
110
+ * Create-only: if a user with this email already exists (from seeding or an
111
+ * earlier signup), the function throws a ConflictError BEFORE creating a
112
+ * tenant. The self-signup path must not silently reuse an existing user —
113
+ * otherwise the confirmation step could mint a session for that user
114
+ * (account takeover). `seedUser` itself remains idempotent and add-only
115
+ * (for bootstrap/tests); the create-only guarantee belongs here.
116
+ * The caller resolves tenantKey collisions via generateUniqueName. */
119
117
  /** Default membership roles for self-signup tenant owners. Shared between
120
- * provisionSignupAccount (DB-write) und signup-confirm-handler
121
- * (SessionUser-Konstruktion für JWT-Mint) — sonst hätten zwei
122
- * Stellen unabhängig "TenantAdmin" hardcoded und würden bei einem
123
- * Refactor zu role-mismatch zwischen DB und Session leiden. */
118
+ * provisionSignupAccount (DB write) and signup-confirm-handler
119
+ * (SessionUser construction for JWT minting); otherwise two locations would
120
+ * independently hardcode "TenantAdmin" and a refactor could cause a role
121
+ * mismatch between the database and the session. */
124
122
  // TenantAdmin is the canonical owner role; Admin stays for handlers that still
125
123
  // gate on the legacy literal until those call sites move to access.admin.
126
124
  export const INITIAL_SIGNUP_ROLES = ["TenantAdmin", "Admin"] as const;
@@ -142,17 +140,17 @@ export async function provisionSignupAccount(
142
140
  options: ProvisionSignupAccountOptions,
143
141
  // Optional, append-only — existing callers (tests, seed scripts) that
144
142
  // don't pass hooks keep today's behavior. The real signup-confirm
145
- // handler DOES pass it (#1463) so seedTenant/seedUserWithPassword/
143
+ // handler DOES pass it so seedTenant/seedUserWithPassword/
146
144
  // seedTenantMembership's postSave hooks (tier-engine's auto-default-tier,
147
145
  // app auto-default-compliance, a Welcome-notification hook, ...) fire on
148
146
  // self-signup for all three entities, same as they do on the regular
149
- // create paths (#1478 — this was only wired for tenant before).
147
+ // create paths — this was only wired for tenant before.
150
148
  hooks?: SeedTenantHooks,
151
149
  ): Promise<{ readonly userId: string; readonly tenantId: TenantId }> {
152
150
  // Create-only guard BEFORE seedTenant: hard-abort on an already-registered
153
151
  // email, otherwise an orphaned tenant would be created and seedUser
154
152
  // (idempotent add-only) would silently return the existing userId ->
155
- // confirm mints a session for the wrong account (#365).
153
+ // confirm mints a session for the wrong account.
156
154
  // isDeleted: false — the partial bidx unique index only covers live rows,
157
155
  // so a soft-deleted row must not block re-registering its email.
158
156
  const existingUser = await fetchOne(db, userTable, { email: options.email, isDeleted: false });
@@ -195,20 +193,19 @@ export type SeedAdminOptions = {
195
193
  readonly email: string;
196
194
  readonly password: string;
197
195
  readonly displayName: string;
198
- /** Tenants, in die der Admin als Mitglied eingetragen wird. Pro
199
- * Tenant kann eine eigene Rollenliste gesetzt werden — hilft beim
200
- * Sample-TenantSwitcher der pro Tenant unterschiedliche
201
- * Rollen-Listen zeigt. */
196
+ /** Tenants where the admin is added as a member. Each tenant can have
197
+ * its own role list, which lets the sample TenantSwitcher show different
198
+ * role lists for each tenant. */
202
199
  readonly memberships: ReadonlyArray<{
203
200
  readonly tenantId: TenantId;
204
201
  readonly tenantKey: string;
205
202
  readonly tenantName: string;
206
203
  readonly roles: readonly string[];
207
204
  }>;
208
- /** Globale Rollen die in users.roles landen — tenant-unabhängig.
209
- * Login-Handler mergt sie in jede Session parallel zu den tenant-
210
- * membership-Rollen. Typischer use-case: `["SystemAdmin"]` für
211
- * einen Plattform-Operator. Default: leer. */
205
+ /** Global roles stored in users.roles, independent of the tenant.
206
+ * The login handler merges them into every session alongside the tenant
207
+ * membership roles. Typical use case: `["SystemAdmin"]` for a platform
208
+ * operator. Default: empty. */
212
209
  readonly globalRoles?: readonly string[];
213
210
  /** Initial emailVerified state — defaults to false (unverified). Same
214
211
  * mechanism as seedUserWithPassword.emailVerified. Re-running the seed
@@ -219,9 +216,9 @@ export type SeedAdminOptions = {
219
216
  };
220
217
 
221
218
  /**
222
- * Seed-Convenience für Sample-Server: Admin-User mit gehashtem
223
- * Password + N Tenants + N Memberships. Alles idempotent (Re-Run im
224
- * persistent-DB-Modus läuft durch). Liefert die userId zurück.
219
+ * Seeding convenience for sample servers: an admin user with a hashed
220
+ * password, N tenants, and N memberships. Idempotent, so rerunning it in
221
+ * persistent-DB mode succeeds. Returns the userId.
225
222
  */
226
223
  export async function seedAdmin(
227
224
  db: DbConnection,
@@ -254,7 +251,7 @@ export async function seedAdmin(
254
251
  return { id: userId };
255
252
  }
256
253
 
257
- // offlot#114 — seedAdmin's idempotency check is a plain fetchOne(email),
254
+ // seedAdmin's idempotency check is a plain fetchOne(email),
258
255
  // which the query layer rewrites into `(email = $plaintext OR
259
256
  // email_bidx = $hmac)` once a blind-index key is configured. Under KMS
260
257
  // encryption `email` holds per-row ciphertext, so only the bidx arm can
@@ -79,14 +79,14 @@ export async function deleteSignupToken(
79
79
  * retry isn't blocked by a stale burn marker. */
80
80
  export const unburnSignupToken = store.unburn;
81
81
 
82
- // Cross-device try-first handover (kumiko-framework#3035 follow-up,
83
- // offlot-app#454): signup-request binds a verified tenant-handover grant to
84
- // its own signup token, in a SIBLING Redis namespace keyed the same way
85
- // (sha256(token)) so it stays byte-compatible with the token store above
86
- // without going through it — the binding has its own lifecycle (survives a
87
- // resend, is read once by signup-confirm) that doesn't fit the token↔email
88
- // pairing. Only {entityType, rowId, sourceTenantId} is ever stored — never
89
- // the grant token or the email (see shared/signup-handover.ts).
82
+ // Cross-device try-first handover:
83
+ // signup-request binds a verified tenant-handover grant to its own signup token,
84
+ // in a SIBLING Redis namespace keyed the same way (sha256(token)) so it stays
85
+ // byte-compatible with the token store above without going through it — the
86
+ // binding has its own lifecycle (survives a resend, is read once by
87
+ // signup-confirm) that doesn't fit the token↔email pairing. Only
88
+ // {entityType, rowId, sourceTenantId} is ever stored — never the grant token
89
+ // or the email (see shared/signup-handover.ts).
90
90
  const SIGNUP_HANDOVER_KEY_PREFIX = "signup:handover:";
91
91
 
92
92
  const signupHandoverBindingSchema = z.object({
@@ -1,5 +1,5 @@
1
- // /testing re-exportiert /seeding. Siehe ../tenant/testing.ts für die
2
- // Begründung — Helpers sind shared zwischen Tests und Dev-Server-
3
- // Bootstrap, /seeding ist die stabile Heimat.
1
+ // /testing re-exports /seeding. See ../tenant/testing.ts for the reason:
2
+ // Helpers are shared between tests and Dev-Server bootstrap, so /seeding is
3
+ // the stable home.
4
4
 
5
5
  export * from "./seeding.ts";