@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.
- package/LICENSE +21 -57
- package/README.md +1 -1
- package/package.json +2 -2
- package/packages/bundled-features/package.json +2 -2
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -1
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +0 -2
- package/packages/bundled-features/src/audit/screens.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/auth-user-row.ts +10 -10
- package/packages/bundled-features/src/auth-email-password/feature.ts +6 -6
- package/packages/bundled-features/src/auth-email-password/handlers/change-password.write.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/handlers/confirm-token-flow.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept-with-login.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept.write.ts +18 -18
- package/packages/bundled-features/src/auth-email-password/handlers/invite-create.write.ts +12 -12
- package/packages/bundled-features/src/auth-email-password/handlers/invite-info.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +24 -26
- package/packages/bundled-features/src/auth-email-password/handlers/login.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/signup-confirm.write.ts +34 -37
- package/packages/bundled-features/src/auth-email-password/handlers/signup-request.write.ts +6 -7
- package/packages/bundled-features/src/auth-email-password/handlers/switch-tenant-mfa-gate.write.ts +1 -5
- package/packages/bundled-features/src/auth-email-password/index.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/lockout-store.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/seeding.ts +63 -66
- package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +8 -8
- package/packages/bundled-features/src/auth-email-password/testing.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +57 -57
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +15 -16
- package/packages/bundled-features/src/auth-email-password/web/client-plugin.ts +11 -12
- package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/constants.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/web/default-topbar-actions.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +11 -11
- package/packages/bundled-features/src/auth-email-password/web/index.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +17 -17
- package/packages/bundled-features/src/auth-email-password/web/login-screen.tsx +3 -4
- package/packages/bundled-features/src/auth-email-password/web/reset-password-screen.tsx +16 -17
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +34 -34
- package/packages/bundled-features/src/auth-email-password/web/signup-complete-screen.tsx +3 -3
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +26 -27
- package/packages/bundled-features/src/auth-email-password/web/use-shell-user.ts +12 -13
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +17 -18
- package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +11 -12
- package/packages/bundled-features/src/auth-foundation/boot-checks.ts +4 -4
- package/packages/bundled-features/src/auth-foundation/resolve-anonymous-access.ts +4 -4
- package/packages/bundled-features/src/auth-foundation/types.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/handlers/disable.write.ts +3 -3
- package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm-preauth.write.ts +4 -4
- package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm.write.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/handlers/enable-start-preauth.write.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/handlers/reencrypt.job.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/handlers/regenerate-recovery.write.ts +5 -5
- package/packages/bundled-features/src/auth-mfa/handlers/verify.write.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/token-secrets.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/web/client-plugin.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/web/i18n.ts +3 -3
- package/packages/bundled-features/src/auth-mfa/web/index.ts +4 -4
- package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +17 -16
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +6 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +10 -11
- package/packages/bundled-features/src/billing-foundation/entities.ts +27 -27
- package/packages/bundled-features/src/billing-foundation/events.ts +22 -21
- package/packages/bundled-features/src/billing-foundation/feature.ts +42 -43
- package/packages/bundled-features/src/billing-foundation/get-subscription-for-tenant.ts +3 -5
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +18 -17
- package/packages/bundled-features/src/billing-foundation/handlers/create-portal-session.write.ts +11 -12
- package/packages/bundled-features/src/billing-foundation/handlers/list-subscriptions.query.ts +4 -4
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +20 -20
- package/packages/bundled-features/src/billing-foundation/projection.ts +38 -37
- package/packages/bundled-features/src/billing-foundation/subscription-tier-sync.ts +3 -3
- package/packages/bundled-features/src/billing-foundation/tenant-destroy-hook.ts +7 -8
- package/packages/bundled-features/src/billing-foundation/types.ts +64 -65
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +4 -4
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +1 -1
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +8 -9
- package/packages/bundled-features/src/cap-counter/constants.ts +11 -12
- package/packages/bundled-features/src/cap-counter/enforce-cap.ts +64 -67
- package/packages/bundled-features/src/cap-counter/entity.ts +29 -29
- package/packages/bundled-features/src/cap-counter/feature.ts +34 -35
- package/packages/bundled-features/src/cap-counter/handlers/increment-rolling.write.ts +31 -31
- package/packages/bundled-features/src/cap-counter/handlers/mark-soft-warned.write.ts +4 -5
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -1
- package/packages/bundled-features/src/cap-counter/with-cap-enforcement.ts +3 -5
- package/packages/bundled-features/src/cap-overview/handlers/caps-usage.query.ts +1 -3
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +1 -1
- package/packages/bundled-features/src/channel-email/smtp-transport.ts +34 -31
- package/packages/bundled-features/src/channel-in-app/handlers/unread-count.query.ts +3 -4
- package/packages/bundled-features/src/compliance-profiles/feature.ts +15 -16
- package/packages/bundled-features/src/compliance-profiles/handlers/for-tenant.query.ts +3 -6
- package/packages/bundled-features/src/compliance-profiles/handlers/list-profiles.query.ts +5 -5
- package/packages/bundled-features/src/compliance-profiles/handlers/needs-profile.query.ts +4 -4
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +13 -14
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +9 -11
- package/packages/bundled-features/src/compliance-profiles/resolve-for-tenant.ts +7 -7
- package/packages/bundled-features/src/compliance-profiles/schema/profile-selection.ts +18 -23
- package/packages/bundled-features/src/compliance-profiles/seeding.ts +14 -15
- package/packages/bundled-features/src/compliance-profiles-ops/handlers/tenants-missing-profile.query.ts +3 -3
- package/packages/bundled-features/src/compliance-profiles-ops/index.ts +2 -2
- package/packages/bundled-features/src/config/handlers/readiness.query.ts +7 -7
- package/packages/bundled-features/src/config/handlers/reencrypt.job.ts +4 -5
- package/packages/bundled-features/src/config/handlers/set.write.ts +4 -4
- package/packages/bundled-features/src/config/resolver.ts +4 -4
- package/packages/bundled-features/src/config/table.ts +10 -10
- package/packages/bundled-features/src/config/write-helpers.ts +1 -1
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +13 -12
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +16 -17
- package/packages/bundled-features/src/custom-fields/entity.ts +49 -47
- package/packages/bundled-features/src/custom-fields/events.ts +7 -8
- package/packages/bundled-features/src/custom-fields/feature.ts +70 -72
- package/packages/bundled-features/src/custom-fields/handlers/clear-custom-field.write.ts +9 -8
- package/packages/bundled-features/src/custom-fields/handlers/define-tenant-field.write.ts +28 -26
- package/packages/bundled-features/src/custom-fields/handlers/delete-system-field.write.ts +6 -7
- package/packages/bundled-features/src/custom-fields/handlers/delete-tenant-field.write.ts +12 -13
- package/packages/bundled-features/src/custom-fields/handlers/set-custom-field.write.ts +25 -28
- package/packages/bundled-features/src/custom-fields/handlers/update-tenant-field.write.ts +6 -6
- package/packages/bundled-features/src/custom-fields/lib/field-access.ts +2 -2
- package/packages/bundled-features/src/custom-fields/lib/parse-serialized-field.ts +1 -1
- package/packages/bundled-features/src/custom-fields/lib/quota.ts +1 -1
- package/packages/bundled-features/src/custom-fields/lib/value-schema.ts +10 -12
- package/packages/bundled-features/src/custom-fields/run-retention.ts +3 -3
- package/packages/bundled-features/src/custom-fields/schemas.ts +14 -14
- package/packages/bundled-features/src/custom-fields/web/client-plugin.tsx +2 -5
- package/packages/bundled-features/src/custom-fields/web/constants.ts +2 -2
- package/packages/bundled-features/src/custom-fields/web/custom-fields-form-section.tsx +26 -26
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +65 -67
- package/packages/bundled-features/src/custom-fields/wire-user-data-rights.ts +3 -3
- package/packages/bundled-features/src/data-retention/_internal/parse-override.ts +2 -3
- package/packages/bundled-features/src/data-retention/feature.ts +11 -18
- package/packages/bundled-features/src/data-retention/handlers/policy-for.query.ts +6 -6
- package/packages/bundled-features/src/data-retention/keep-for.ts +17 -17
- package/packages/bundled-features/src/data-retention/override-schema.ts +13 -15
- package/packages/bundled-features/src/data-retention/presets.ts +18 -23
- package/packages/bundled-features/src/data-retention/resolve-for-tenant.ts +1 -1
- package/packages/bundled-features/src/data-retention/resolve-tenant-preset.ts +17 -16
- package/packages/bundled-features/src/data-retention/resolver.ts +33 -32
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +71 -58
- package/packages/bundled-features/src/data-retention/schema/tenant-retention-override.ts +13 -11
- package/packages/bundled-features/src/delivery/feature.ts +3 -3
- package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
- package/packages/bundled-features/src/delivery/tables.ts +9 -8
- package/packages/bundled-features/src/delivery/unsubscribe.ts +4 -4
- package/packages/bundled-features/src/delivery/upsert-preference.ts +3 -4
- package/packages/bundled-features/src/document-ingest-foundation/entity.ts +5 -5
- package/packages/bundled-features/src/document-ingest-foundation/events.ts +2 -2
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +2 -2
- package/packages/bundled-features/src/document-ingest-foundation/pages.ts +1 -1
- package/packages/bundled-features/src/document-ingest-foundation/tenant-destroy-hook.ts +4 -4
- package/packages/bundled-features/src/feature-toggles/compose-tier-resolver.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/feature.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/global-feature-state-table.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/handlers/registered.query.ts +5 -5
- package/packages/bundled-features/src/feature-toggles/toggle-runtime.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/web/constants.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/feature.ts +2 -2
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/presets.ts +1 -1
- package/packages/bundled-features/src/file-foundation/feature.ts +6 -6
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +16 -16
- package/packages/bundled-features/src/file-provider-s3/feature.ts +16 -16
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +6 -6
- package/packages/bundled-features/src/files/feature.ts +6 -6
- package/packages/bundled-features/src/files-tenant-data/handlers/sweep-orphaned-derivatives.job.ts +5 -5
- package/packages/bundled-features/src/files-tenant-data/hooks.ts +24 -26
- package/packages/bundled-features/src/files-tenant-data/index.ts +1 -1
- package/packages/bundled-features/src/folders/feature.ts +1 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +2 -2
- package/packages/bundled-features/src/folders/web/tree.ts +5 -5
- package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +1 -1
- package/packages/bundled-features/src/form-draft/db/queries/owned-file-refs.ts +1 -1
- package/packages/bundled-features/src/form-draft/entity.ts +3 -3
- package/packages/bundled-features/src/form-draft/feature.ts +4 -5
- package/packages/bundled-features/src/form-draft/handlers/discard.write.ts +1 -1
- package/packages/bundled-features/src/form-draft/release-file-refs.ts +6 -6
- package/packages/bundled-features/src/form-draft/schemas.ts +3 -3
- package/packages/bundled-features/src/form-draft/web/constants.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +19 -19
- package/packages/bundled-features/src/inbound-mail-foundation/connect-routes.ts +4 -3
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +30 -33
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +47 -48
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +54 -50
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +39 -39
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-state.ts +8 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +25 -26
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/disconnect-account.write.ts +7 -7
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +50 -51
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-accounts.query.ts +8 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +10 -10
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/scope-visibility.ts +3 -4
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/update-account.write.ts +11 -11
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-state.ts +16 -15
- package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +31 -29
- package/packages/bundled-features/src/inbound-mail-foundation/provider-factory.ts +9 -9
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +45 -41
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -16
- package/packages/bundled-features/src/inbound-mail-foundation/types.ts +66 -67
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +69 -68
- package/packages/bundled-features/src/inbound-provider-imap/credential-document.ts +13 -13
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +42 -40
- package/packages/bundled-features/src/inbound-provider-imap/imap-client.ts +20 -19
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +21 -21
- package/packages/bundled-features/src/jobs/db/queries/retention.ts +2 -2
- package/packages/bundled-features/src/jobs/db/queries/stale-run-sweep.ts +3 -3
- package/packages/bundled-features/src/jobs/events.ts +1 -1
- package/packages/bundled-features/src/jobs/feature.ts +6 -7
- package/packages/bundled-features/src/jobs/handlers/detail.query.ts +4 -4
- package/packages/bundled-features/src/jobs/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/projection-rebuild.job.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/reindex-entity.job.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/retry.write.ts +1 -1
- package/packages/bundled-features/src/jobs/job-instant.ts +1 -1
- package/packages/bundled-features/src/jobs/job-run-logger.ts +14 -15
- package/packages/bundled-features/src/jobs/job-run-table.ts +3 -3
- package/packages/bundled-features/src/jobs/screens.ts +1 -1
- package/packages/bundled-features/src/jobs/tenant-job-failure-table.ts +1 -1
- package/packages/bundled-features/src/jobs/tenant-job-run-table.ts +1 -1
- package/packages/bundled-features/src/ledger/entity.ts +5 -5
- package/packages/bundled-features/src/ledger/feature.ts +3 -3
- package/packages/bundled-features/src/ledger/handlers/confirm-schedule-period.write.ts +3 -3
- package/packages/bundled-features/src/ledger/recurring.ts +12 -12
- package/packages/bundled-features/src/ledger/schemas.ts +1 -1
- package/packages/bundled-features/src/ledger/web/constants.ts +2 -2
- package/packages/bundled-features/src/ledger/web/index.ts +7 -7
- package/packages/bundled-features/src/legal-pages/feature.ts +40 -41
- package/packages/bundled-features/src/legal-pages/markdown.ts +3 -3
- package/packages/bundled-features/src/legal-pages/web/client-plugin.ts +23 -24
- package/packages/bundled-features/src/legal-pages/web/index.ts +0 -2
- package/packages/bundled-features/src/mail-foundation/feature.ts +26 -27
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +27 -28
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +20 -20
- package/packages/bundled-features/src/managed-pages/branding.ts +6 -6
- package/packages/bundled-features/src/managed-pages/feature.ts +62 -62
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +5 -6
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +8 -8
- package/packages/bundled-features/src/managed-pages/handlers/set.write.ts +5 -7
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +11 -11
- package/packages/bundled-features/src/managed-pages/seeding.ts +8 -8
- package/packages/bundled-features/src/managed-pages/table.ts +16 -15
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +6 -6
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +1 -1
- package/packages/bundled-features/src/notes-history/entity.ts +4 -4
- package/packages/bundled-features/src/notes-history/feature.ts +2 -2
- package/packages/bundled-features/src/notes-history-user-data/hooks.ts +1 -1
- package/packages/bundled-features/src/page-render/layout.ts +9 -9
- package/packages/bundled-features/src/page-render/markdown.ts +11 -11
- package/packages/bundled-features/src/page-render/security-headers.ts +7 -6
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -5
- package/packages/bundled-features/src/personal-access-tokens/roles.ts +2 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +3 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +12 -13
- package/packages/bundled-features/src/renderer-foundation/constants.ts +2 -2
- package/packages/bundled-features/src/renderer-foundation/feature.ts +7 -7
- package/packages/bundled-features/src/renderer-foundation/types.ts +11 -12
- package/packages/bundled-features/src/secrets/feature.ts +9 -9
- package/packages/bundled-features/src/secrets/web/constants.ts +2 -2
- package/packages/bundled-features/src/seo/feature.ts +3 -3
- package/packages/bundled-features/src/sessions/constants.ts +1 -1
- package/packages/bundled-features/src/sessions/feature.ts +9 -9
- package/packages/bundled-features/src/sessions/handlers/revoke-all-for-user.write.ts +2 -2
- package/packages/bundled-features/src/sessions/handlers/revoke-all-others.write.ts +2 -2
- package/packages/bundled-features/src/sessions/handlers/revoke.write.ts +1 -1
- package/packages/bundled-features/src/sessions/schema/user-session.ts +4 -4
- package/packages/bundled-features/src/sessions/screens.ts +2 -2
- package/packages/bundled-features/src/sessions/session-callbacks.ts +2 -2
- package/packages/bundled-features/src/sessions/session-revoked-event.ts +2 -2
- package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +1 -1
- package/packages/bundled-features/src/shared/decrypt-stored-pii.ts +1 -1
- package/packages/bundled-features/src/shared/encrypt-for-direct-write.ts +1 -1
- package/packages/bundled-features/src/shared/map-with-concurrency.ts +5 -4
- package/packages/bundled-features/src/shared/parent-visibility.ts +2 -2
- package/packages/bundled-features/src/shared/password-hashing.ts +1 -1
- package/packages/bundled-features/src/shared/signup-handover.ts +1 -2
- package/packages/bundled-features/src/shared/single-use-token-store.ts +1 -1
- package/packages/bundled-features/src/subscription-mollie/constants.ts +15 -17
- package/packages/bundled-features/src/subscription-mollie/feature.ts +41 -42
- package/packages/bundled-features/src/subscription-mollie/index.ts +3 -3
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +17 -16
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +34 -34
- package/packages/bundled-features/src/subscription-stripe/constants.ts +4 -6
- package/packages/bundled-features/src/subscription-stripe/feature.ts +44 -43
- package/packages/bundled-features/src/subscription-stripe/index.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +22 -27
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +2 -2
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +62 -64
- package/packages/bundled-features/src/tags/feature.ts +3 -3
- package/packages/bundled-features/src/tags/screens.ts +1 -1
- package/packages/bundled-features/src/template-resolver/api.ts +10 -10
- package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +5 -5
- package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/shared.ts +2 -2
- package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +3 -3
- package/packages/bundled-features/src/template-resolver/handlers/upsert-system.write.ts +3 -4
- package/packages/bundled-features/src/template-resolver/handlers/upsert-tenant.write.ts +4 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +4 -4
- package/packages/bundled-features/src/template-resolver/table.ts +13 -14
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +2 -2
- package/packages/bundled-features/src/tenant/feature.ts +7 -7
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/members.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/memberships.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/team-list.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/tenant-directory.query.ts +1 -1
- package/packages/bundled-features/src/tenant/invitation-table.ts +37 -40
- package/packages/bundled-features/src/tenant/membership-table.ts +3 -3
- package/packages/bundled-features/src/tenant/schema/tenant.ts +7 -9
- package/packages/bundled-features/src/tenant/screens.ts +1 -1
- package/packages/bundled-features/src/tenant/seeding.ts +19 -18
- package/packages/bundled-features/src/tenant/testing.ts +5 -6
- package/packages/bundled-features/src/tenant/web/constants.ts +2 -2
- package/packages/bundled-features/src/tenant-handover/events.ts +5 -7
- package/packages/bundled-features/src/tenant-handover/feature.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/grant.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/handlers/claim.write.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/move-entity-graph.ts +8 -9
- package/packages/bundled-features/src/tenant-handover/signup-handover-provider.ts +1 -2
- package/packages/bundled-features/src/tenant-handover/transfer-graph.ts +4 -5
- package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +2 -2
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +1 -1
- package/packages/bundled-features/src/tenant-settings/constants.ts +1 -1
- package/packages/bundled-features/src/tenant-settings/tenant-defaults.ts +12 -5
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +15 -16
- package/packages/bundled-features/src/tier-engine/compose-app.ts +14 -14
- package/packages/bundled-features/src/tier-engine/entity.ts +18 -19
- package/packages/bundled-features/src/tier-engine/feature.ts +88 -87
- package/packages/bundled-features/src/tier-engine/handlers/active-tier.query.ts +6 -7
- package/packages/bundled-features/src/tier-engine/handlers/get-tenant-tier.query.ts +4 -4
- package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +8 -8
- package/packages/bundled-features/src/tier-engine/tier-resolver.ts +2 -2
- package/packages/bundled-features/src/tier-engine/trial.ts +13 -13
- package/packages/bundled-features/src/tier-engine/web/index.ts +4 -4
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +8 -8
- package/packages/bundled-features/src/user/handlers/create.write.ts +4 -4
- package/packages/bundled-features/src/user/schema/user.ts +45 -44
- package/packages/bundled-features/src/user/seeding.ts +40 -40
- package/packages/bundled-features/src/user/testing.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/audit-download.ts +27 -28
- package/packages/bundled-features/src/user-data-rights/boot-checks.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/deletion-token.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/feature.ts +112 -113
- package/packages/bundled-features/src/user-data-rights/handlers/cancel-deletion.write.ts +9 -9
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +8 -8
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-job.query.ts +29 -30
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +40 -42
- package/packages/bundled-features/src/user-data-rights/handlers/export-status.query.ts +8 -9
- package/packages/bundled-features/src/user-data-rights/handlers/lift-restriction.write.ts +7 -8
- package/packages/bundled-features/src/user-data-rights/handlers/list-download-attempts.query.ts +2 -2
- package/packages/bundled-features/src/user-data-rights/handlers/my-audit-log.query.ts +4 -4
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +30 -29
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion.write.ts +15 -18
- package/packages/bundled-features/src/user-data-rights/handlers/request-export.write.ts +42 -41
- package/packages/bundled-features/src/user-data-rights/handlers/restrict-account.write.ts +22 -19
- package/packages/bundled-features/src/user-data-rights/handlers/run-forget-cleanup.write.ts +8 -8
- package/packages/bundled-features/src/user-data-rights/index.ts +8 -10
- package/packages/bundled-features/src/user-data-rights/lib/default-mailers.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/lib/update-user-lifecycle.ts +24 -27
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +166 -276
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +85 -107
- package/packages/bundled-features/src/user-data-rights/run-user-export.ts +67 -69
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +11 -11
- package/packages/bundled-features/src/user-data-rights/schema/download-token.ts +37 -41
- package/packages/bundled-features/src/user-data-rights/schema/export-job.ts +65 -67
- package/packages/bundled-features/src/user-data-rights/token-helpers.ts +21 -25
- package/packages/bundled-features/src/user-data-rights/web/client-plugin.tsx +6 -6
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +6 -5
- package/packages/bundled-features/src/user-data-rights/web/constants.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/web/index.ts +5 -5
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +14 -13
- package/packages/bundled-features/src/user-data-rights/web/public-deletion-gate.tsx +13 -12
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +6 -6
- package/packages/bundled-features/src/user-data-rights/zip-path.ts +41 -40
- package/packages/bundled-features/src/user-data-rights-defaults/feature.ts +15 -15
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +3 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/file-ref.userdata-hook.ts +45 -51
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -2
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +3 -3
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user.userdata-hook.ts +32 -31
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +13 -13
- package/packages/bundled-features/src/user-profile/index.ts +3 -3
- package/packages/bundled-features/src/user-profile/web/client-plugin.ts +1 -1
- package/packages/bundled-features/src/user-profile/web/constants.ts +1 -1
- package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +1 -1
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +1 -1
- package/packages/bundled-features/src/workflow-runner/event-subscriber.ts +4 -5
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +4 -15
- package/packages/bundled-features/src/workflow-runner/feature.ts +2 -2
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +4 -4
- package/packages/bundled-features/src/workflow-runner/pending-projection.ts +6 -7
- package/packages/bundled-features/src/workflow-runner/runner.ts +6 -6
- package/packages/bundled-features/src/workflow-runner/tables.ts +6 -6
- package/packages/bundled-features/src/workflow-runner/workflow-registry.ts +1 -1
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
// Magic-Link
|
|
1
|
+
// Magic-Link signup, step 2 (confirmation).
|
|
2
2
|
//
|
|
3
|
-
// Token
|
|
4
|
-
//
|
|
5
|
-
//
|
|
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-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
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
|
|
19
|
-
//
|
|
20
|
-
//
|
|
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
|
|
159
|
-
//
|
|
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-
|
|
164
|
-
//
|
|
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
|
|
171
|
-
//
|
|
172
|
-
//
|
|
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
|
-
//
|
|
186
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
212
|
-
//
|
|
213
|
-
// committed
|
|
214
|
-
//
|
|
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
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
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
|
-
//
|
|
282
|
-
//
|
|
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
|
|
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
|
|
38
|
-
//
|
|
39
|
-
//
|
|
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
|
-
//
|
|
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
|
package/packages/bundled-features/src/auth-email-password/handlers/switch-tenant-mfa-gate.write.ts
CHANGED
|
@@ -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
|
|
39
|
-
// app-
|
|
40
|
-
// invite-tokens)
|
|
41
|
-
//
|
|
42
|
-
//
|
|
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
|
|
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
|
|
2
|
-
// `/seeding`
|
|
3
|
-
// non-test code
|
|
4
|
-
// Test-
|
|
5
|
-
// race-conditions)
|
|
6
|
-
//
|
|
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
|
-
//
|
|
9
|
-
// 1. argon2
|
|
10
|
-
// 2. seedUser()
|
|
11
|
-
// 3. seedTenant + seedTenantMembership
|
|
12
|
-
//
|
|
13
|
-
//
|
|
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
|
|
42
|
-
//
|
|
43
|
-
// password + tenant + membership"
|
|
44
|
-
//
|
|
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
|
-
/**
|
|
55
|
+
/** Global roles — see SeedUserOptions.roles. */
|
|
56
56
|
readonly roles?: readonly string[];
|
|
57
|
-
/** Initial
|
|
58
|
-
* Magic-
|
|
59
|
-
*
|
|
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
|
|
66
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
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
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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:
|
|
106
|
-
* (db.begin(tx => provisionSignupAccount(tx, ...))
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
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:
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
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
|
|
121
|
-
* (SessionUser
|
|
122
|
-
*
|
|
123
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
199
|
-
*
|
|
200
|
-
*
|
|
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
|
-
/**
|
|
209
|
-
*
|
|
210
|
-
* membership
|
|
211
|
-
*
|
|
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
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* persistent-DB
|
|
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
|
-
//
|
|
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
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
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-
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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";
|