@cosmicdrift/kumiko-samples 0.413.0 → 0.414.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/package.json +1 -1
- package/packages/bundled-features/package.json +16 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
- package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +6 -0
- package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -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/reset-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
- package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
- package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
- package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
- package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
- package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
- package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
- package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
- package/packages/bundled-features/src/cap-overview/changes.json +6 -0
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
- package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
- package/packages/bundled-features/src/cap-overview/index.ts +1 -0
- package/packages/bundled-features/src/cap-overview/types.ts +11 -1
- package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
- package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
- package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
- package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
- package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
- package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
- package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
- package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
- package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
- package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
- package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
- package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
- package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +12 -0
- package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
- package/packages/bundled-features/src/config/index.ts +1 -0
- package/packages/bundled-features/src/config/read-redaction.ts +6 -3
- package/packages/bundled-features/src/config/table.ts +1 -0
- package/packages/bundled-features/src/config/write-helpers.ts +3 -2
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
- package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
- package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
- package/packages/bundled-features/src/data-retention/changes.json +18 -0
- package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
- package/packages/bundled-features/src/data-retention/feature.ts +4 -7
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
- package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
- package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
- package/packages/bundled-features/src/delivery/changes.json +6 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
- package/packages/bundled-features/src/delivery/feature.ts +4 -13
- package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
- package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
- package/packages/bundled-features/src/delivery/index.ts +3 -1
- package/packages/bundled-features/src/delivery/options.ts +11 -0
- package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
- package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
- package/packages/bundled-features/src/delivery/testing.ts +3 -1
- package/packages/bundled-features/src/delivery/types.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
- package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
- package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +18 -0
- package/packages/bundled-features/src/documents/constants.ts +10 -2
- package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
- package/packages/bundled-features/src/documents/feature.ts +28 -6
- package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
- package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
- package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
- package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
- package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
- package/packages/bundled-features/src/documents/screens.ts +8 -3
- package/packages/bundled-features/src/documents/tab.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
- package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
- package/packages/bundled-features/src/files/changes.json +7 -0
- package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
- package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
- package/packages/bundled-features/src/helpdesk/changes.json +62 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
- package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
- package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
- package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
- package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
- package/packages/bundled-features/src/helpdesk/index.ts +1 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
- package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
- package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
- package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
- package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
- package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
- package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
- package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
- package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
- package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
- package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
- package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
- package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
- package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
- package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
- package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
- package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
- package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
- package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/jobs/events.ts +10 -0
- package/packages/bundled-features/src/jobs/feature.ts +2 -0
- package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
- package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
- package/packages/bundled-features/src/managed-pages/changes.json +12 -0
- package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
- package/packages/bundled-features/src/managed-pages/table.ts +1 -0
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
- package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
- package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
- package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
- package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
- package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
- package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
- package/packages/bundled-features/src/presence/changes.json +6 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
- package/packages/bundled-features/src/presence/room.ts +21 -7
- package/packages/bundled-features/src/presence/store.ts +79 -21
- package/packages/bundled-features/src/readiness/changes.json +25 -0
- package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
- package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
- package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
- package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
- package/packages/bundled-features/src/readiness/screens.ts +4 -4
- package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
- package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
- package/packages/bundled-features/src/secrets/changes.json +7 -0
- package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
- package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
- package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
- package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
- package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
- package/packages/bundled-features/src/shared/changes.json +6 -0
- package/packages/bundled-features/src/shared/index.ts +6 -1
- package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
- package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
- package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
- package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
- package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
- package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
- package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
- package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
- package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
- package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
- package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
- package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
- package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
- package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
- package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
- package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
- package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/api.ts +6 -13
- package/packages/bundled-features/src/template-resolver/changes.json +36 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
- package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
- package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
- package/packages/bundled-features/src/template-resolver/table.ts +1 -0
- package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
- package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
- package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
- package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
- package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
- package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
- package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
- package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
- package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
- package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
- package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
- package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
- package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
- package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
- package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
- package/packages/bundled-features/src/tenant/seeding.ts +4 -2
- package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
- package/packages/bundled-features/src/tenant/testing.ts +1 -1
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
- package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
- package/packages/bundled-features/src/user/index.ts +1 -0
- package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
- package/packages/bundled-features/src/waitlist/lib.ts +2 -7
- package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
- package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
- package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
- package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
- package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
- package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
- package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
- package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
- package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
- package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
- package/samples/recipes/chat-channels/README.md +2 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- package/samples/recipes/helpdesk/README.md +9 -5
- package/samples/recipes/helpdesk/src/feature.ts +6 -3
- package/samples/recipes/managed-pages/README.md +5 -1
- package/samples/recipes/managed-pages/package.json +3 -2
- package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
- package/samples/recipes/managed-pages/tsconfig.json +8 -0
- package/samples/recipes/pwa-shell/README.md +52 -0
- package/samples/recipes/pwa-shell/bin/server.ts +12 -0
- package/samples/recipes/pwa-shell/package.json +13 -0
- package/samples/recipes/pwa-shell/src/app.ts +34 -0
- package/samples/recipes/rate-limiting/README.md +3 -3
- package/samples/recipes/record-detail-layout/README.md +33 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
|
@@ -8,7 +8,6 @@ export type VerifyResult =
|
|
|
8
8
|
| { readonly ok: true; readonly userId: string; readonly expiresAtMs: number }
|
|
9
9
|
| { readonly ok: false; readonly reason: "malformed" | "bad_signature" | "expired" };
|
|
10
10
|
|
|
11
|
-
// @wrapper-known semantic-alias
|
|
12
11
|
export function signUnlockToken(
|
|
13
12
|
userId: string,
|
|
14
13
|
ttlMinutes: number,
|
|
@@ -18,7 +17,6 @@ export function signUnlockToken(
|
|
|
18
17
|
return signToken(userId, TokenPurpose.accountUnlock, ttlMinutes, secret, now);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
// @wrapper-known semantic-alias
|
|
22
20
|
export function verifyUnlockToken(
|
|
23
21
|
token: string,
|
|
24
22
|
secret: string,
|
|
@@ -9,7 +9,6 @@ export type VerifyResult =
|
|
|
9
9
|
| { readonly ok: true; readonly userId: string; readonly expiresAtMs: number }
|
|
10
10
|
| { readonly ok: false; readonly reason: "malformed" | "bad_signature" | "expired" };
|
|
11
11
|
|
|
12
|
-
// @wrapper-known semantic-alias
|
|
13
12
|
export function signVerificationToken(
|
|
14
13
|
userId: string,
|
|
15
14
|
ttlMinutes: number,
|
|
@@ -19,7 +18,6 @@ export function signVerificationToken(
|
|
|
19
18
|
return signToken(userId, TokenPurpose.emailVerification, ttlMinutes, secret, now);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
// @wrapper-known semantic-alias
|
|
23
21
|
export function verifyVerificationToken(
|
|
24
22
|
token: string,
|
|
25
23
|
secret: string,
|
|
@@ -52,7 +52,7 @@ export type AuthCardProps = {
|
|
|
52
52
|
readonly children: ReactNode;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
//
|
|
55
|
+
// biome-ignore lint/plugin: Wraps usePrimitives().Card, pure domain name for the auth-screen chrome, not a primitive reimplementation
|
|
56
56
|
export function AuthCard({
|
|
57
57
|
title,
|
|
58
58
|
subtitle,
|
|
@@ -113,7 +113,7 @@ export function parseUrlToken(paramName = "token"): string {
|
|
|
113
113
|
// (server-injected token) short-circuits both the URL read and the scrub.
|
|
114
114
|
export function useUrlToken(override?: string, paramName = "token"): string {
|
|
115
115
|
const [token] = useState(() => override ?? parseUrlToken(paramName));
|
|
116
|
-
//
|
|
116
|
+
// biome-ignore lint/plugin: DOM integration: history.replaceState scrubs the token from browser history once, no framework query/mutation equivalent
|
|
117
117
|
useEffect(() => {
|
|
118
118
|
if (override !== undefined) return;
|
|
119
119
|
if (typeof window === "undefined") return;
|
|
@@ -86,7 +86,7 @@ export function createLoginRoute(
|
|
|
86
86
|
readonly accountLabel: string;
|
|
87
87
|
} | null>(null);
|
|
88
88
|
|
|
89
|
-
//
|
|
89
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
90
90
|
useEffect(() => {
|
|
91
91
|
if (status === "authenticated") onAuthenticated?.();
|
|
92
92
|
}, [status]);
|
|
@@ -238,7 +238,7 @@ export function makeAuthGate(opts: AuthGateOptions = {}): ComponentType<{
|
|
|
238
238
|
[status, locale, origin, pathname, search, hash],
|
|
239
239
|
);
|
|
240
240
|
const redirectUrl = loginRedirect?.kind === "redirect" ? loginRedirect.url : null;
|
|
241
|
-
//
|
|
241
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
242
242
|
useEffect(() => {
|
|
243
243
|
if (redirectUrl !== null) window.location.replace(redirectUrl);
|
|
244
244
|
}, [redirectUrl]);
|
|
@@ -19,6 +19,11 @@ export function readReturnToFromWindow(): string | null {
|
|
|
19
19
|
return typeof window === "undefined" ? null : readReturnToFromSearch(window.location.search);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// A safe prop wins over the returnTo of this page's own URL.
|
|
23
|
+
export function resolveReturnTo(prop: string | undefined): string | undefined {
|
|
24
|
+
return (isSafeReturnPath(prop) ? prop : readReturnToFromWindow()) ?? undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
// The safe `next` of this page's URL; null on native, where there is no window.
|
|
23
28
|
export function readNextFromWindow(): string | null {
|
|
24
29
|
return typeof window === "undefined" ? null : readNextFromSearch(window.location.search);
|
|
@@ -12,8 +12,7 @@ import { usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
|
12
12
|
import { type FormEvent, type ReactNode, useState } from "react";
|
|
13
13
|
import { requestPasswordReset } from "./auth-client.ts";
|
|
14
14
|
import { AuthCard } from "./auth-form-primitives.tsx";
|
|
15
|
-
import {
|
|
16
|
-
import { isSafeReturnPath } from "./return-path.ts";
|
|
15
|
+
import { resolveReturnTo } from "./auth-redirect.ts";
|
|
17
16
|
|
|
18
17
|
export type ForgotPasswordScreenProps = {
|
|
19
18
|
readonly title?: string;
|
|
@@ -26,10 +25,6 @@ export type ForgotPasswordScreenProps = {
|
|
|
26
25
|
readonly returnTo?: string;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
function resolveReturnTo(prop: string | undefined): string | undefined {
|
|
30
|
-
return (isSafeReturnPath(prop) ? prop : readReturnToFromWindow()) ?? undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
28
|
export function ForgotPasswordScreen({
|
|
34
29
|
title,
|
|
35
30
|
subtitle,
|
|
@@ -112,7 +112,7 @@ export function InviteAcceptScreen({
|
|
|
112
112
|
const postInviteAccept = async (path: string, body: Record<string, string>): Promise<void> => {
|
|
113
113
|
setSubmitting(true);
|
|
114
114
|
setError(null);
|
|
115
|
-
//
|
|
115
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
116
116
|
const res = await fetch(path, {
|
|
117
117
|
method: "POST",
|
|
118
118
|
credentials: "same-origin",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Shared by the server (mail link) and the web pages (landing page), so it is plain string logic:
|
|
2
2
|
// no DOM, no window, no `new URL` (React Native's URL getters throw).
|
|
3
3
|
|
|
4
|
+
import { MAX_RETURN_PATH_LENGTH } from "@cosmicdrift/kumiko-framework/utils";
|
|
4
5
|
import { readPathParam } from "./read-path-param.ts";
|
|
5
6
|
|
|
6
7
|
export const RETURN_TO_QUERY_PARAM = "returnTo";
|
|
7
|
-
export
|
|
8
|
+
export { MAX_RETURN_PATH_LENGTH };
|
|
8
9
|
|
|
9
10
|
const DOT_SEGMENTS = new Set([".", "..", ".%2e", "%2e.", "%2e%2e", "%2e"]);
|
|
10
11
|
|
|
@@ -185,7 +185,7 @@ export function SessionProvider({
|
|
|
185
185
|
}
|
|
186
186
|
}, []);
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
189
189
|
useEffect(() => {
|
|
190
190
|
void doRefresh();
|
|
191
191
|
}, [doRefresh]);
|
|
@@ -193,7 +193,7 @@ export function SessionProvider({
|
|
|
193
193
|
const sessionEndedSignal = useSessionEndedSignal();
|
|
194
194
|
// Only an authenticated session can "end": an anonymous 401 on a public
|
|
195
195
|
// surface must not show the hint.
|
|
196
|
-
//
|
|
196
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
197
197
|
useEffect(() => {
|
|
198
198
|
return sessionEndedSignal?.subscribe(() => {
|
|
199
199
|
setState((prev) =>
|
|
@@ -219,18 +219,16 @@ export function SessionProvider({
|
|
|
219
219
|
await logoutApi();
|
|
220
220
|
// The reload below would hide the identity change from the list-state boot.
|
|
221
221
|
clearRememberedListState();
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
// with loginUrl race this navigation to its own redirect.
|
|
225
|
-
window.location.assign(postLogoutUrl);
|
|
222
|
+
if (typeof window === "undefined") {
|
|
223
|
+
setState(UNAUTHENTICATED);
|
|
226
224
|
return;
|
|
227
225
|
}
|
|
228
|
-
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
// State stays untouched in the browser: flipping to unauthenticated would let an
|
|
227
|
+
// AuthGate with loginUrl race this single navigation to its own redirect. The
|
|
228
|
+
// reload also resets the React tree, live caches and EventSource.
|
|
229
|
+
if (postLogoutUrl !== undefined) {
|
|
230
|
+
window.location.assign(postLogoutUrl);
|
|
231
|
+
} else {
|
|
234
232
|
window.location.reload();
|
|
235
233
|
}
|
|
236
234
|
}, [postLogoutUrl]);
|
|
@@ -21,9 +21,8 @@ import { type FormEvent, type ReactNode, useState } from "react";
|
|
|
21
21
|
import { requestSignup } from "./auth-client.ts";
|
|
22
22
|
import { retryAfterMinutes } from "./auth-form-logic.ts";
|
|
23
23
|
import { AuthCard } from "./auth-form-primitives.tsx";
|
|
24
|
-
import {
|
|
24
|
+
import { resolveReturnTo } from "./auth-redirect.ts";
|
|
25
25
|
import { AuthQueries } from "./constants.ts";
|
|
26
|
-
import { isSafeReturnPath } from "./return-path.ts";
|
|
27
26
|
|
|
28
27
|
export type SignupScreenProps = {
|
|
29
28
|
readonly title?: string;
|
|
@@ -36,10 +35,6 @@ export type SignupScreenProps = {
|
|
|
36
35
|
readonly returnTo?: string;
|
|
37
36
|
};
|
|
38
37
|
|
|
39
|
-
function resolveReturnTo(prop: string | undefined): string | undefined {
|
|
40
|
-
return (isSafeReturnPath(prop) ? prop : readReturnToFromWindow()) ?? undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
function SignupScreenBody({
|
|
44
39
|
title,
|
|
45
40
|
subtitle,
|
|
@@ -132,7 +132,12 @@ async function postInviteAccept(
|
|
|
132
132
|
if (result.kind === "failure") return result;
|
|
133
133
|
const body = result.data;
|
|
134
134
|
const tenantId = body["tenantId"];
|
|
135
|
-
if (typeof tenantId !== "string")
|
|
135
|
+
if (typeof tenantId !== "string") {
|
|
136
|
+
const isMfaGate = body["mfaRequired"] === true || body["mfaSetupRequired"] === true;
|
|
137
|
+
return isMfaGate
|
|
138
|
+
? staticSuccess({ status: "mfa-pending" })
|
|
139
|
+
: staticFailure(UNEXPECTED_RESPONSE_REASON);
|
|
140
|
+
}
|
|
136
141
|
const landingPath = body["landingPath"];
|
|
137
142
|
return staticSuccess({
|
|
138
143
|
status: "accepted",
|
|
@@ -68,7 +68,7 @@ export function TenantSwitcher({ tenantName }: TenantSwitcherProps): ReactNode {
|
|
|
68
68
|
return (
|
|
69
69
|
<DropdownMenu>
|
|
70
70
|
<DropdownMenuTrigger asChild>
|
|
71
|
-
{/*
|
|
71
|
+
{/* biome-ignore lint/plugin: radix-asChild requires a DOM element as the trigger; Native has its own .native.tsx variant with ActionSheet */}
|
|
72
72
|
<button
|
|
73
73
|
type="button"
|
|
74
74
|
className={cn(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// Reads `?token=...` from the URL, auto-posts it on mount and shows success/error.
|
|
2
|
-
// side is idempotent, so a repeated call is safe.
|
|
1
|
+
// Reads `?token=...` from the URL, auto-posts it on mount and shows success/error.
|
|
3
2
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Tokens can be single-use server-side (verify-email), so the once-guard keeps Strict Mode's
|
|
4
|
+
// double effect from showing an invalid-token error after a successful first call.
|
|
6
5
|
|
|
7
6
|
import { usePrimitives } from "@cosmicdrift/kumiko-renderer";
|
|
8
7
|
import { type ReactNode, useEffect, useRef, useState } from "react";
|
|
@@ -40,7 +39,7 @@ export function TokenConfirmScreen({
|
|
|
40
39
|
const [status, setStatus] = useState<Status>(token === "" ? "missing-token" : "verifying");
|
|
41
40
|
const startedRef = useRef(false);
|
|
42
41
|
|
|
43
|
-
//
|
|
42
|
+
// biome-ignore lint/plugin: not yet converted to the framework hook set
|
|
44
43
|
useEffect(() => {
|
|
45
44
|
if (status !== "verifying") return;
|
|
46
45
|
if (startedRef.current) return;
|
|
@@ -122,7 +122,7 @@ export function UserMenu({ children, variant = "pill" }: UserMenuProps): ReactNo
|
|
|
122
122
|
return (
|
|
123
123
|
<DropdownMenu>
|
|
124
124
|
<DropdownMenuTrigger asChild>
|
|
125
|
-
{/*
|
|
125
|
+
{/* biome-ignore lint/plugin: radix-asChild requires a DOM element as the trigger; the native version in .native.tsx uses ActionSheet */}
|
|
126
126
|
<button
|
|
127
127
|
type="button"
|
|
128
128
|
className={cn(
|
|
@@ -9,6 +9,11 @@ export type MfaCodeOrRecoveryFieldProps = {
|
|
|
9
9
|
readonly useRecovery: boolean;
|
|
10
10
|
readonly onUseRecoveryChange: (useRecovery: boolean) => void;
|
|
11
11
|
readonly disabled?: boolean;
|
|
12
|
+
readonly required?: boolean;
|
|
13
|
+
readonly hasError?: boolean;
|
|
14
|
+
/** Remounts the input, e.g. to regain focus after a disabled submit. */
|
|
15
|
+
readonly inputKey?: string;
|
|
16
|
+
readonly onComplete?: (code: string) => void;
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
export function MfaCodeOrRecoveryField({
|
|
@@ -19,6 +24,10 @@ export function MfaCodeOrRecoveryField({
|
|
|
19
24
|
useRecovery,
|
|
20
25
|
onUseRecoveryChange,
|
|
21
26
|
disabled,
|
|
27
|
+
required,
|
|
28
|
+
hasError,
|
|
29
|
+
inputKey,
|
|
30
|
+
onComplete,
|
|
22
31
|
}: MfaCodeOrRecoveryFieldProps): ReactNode {
|
|
23
32
|
const t = useTranslation();
|
|
24
33
|
const { Button, Field, Input } = usePrimitives();
|
|
@@ -28,24 +37,31 @@ export function MfaCodeOrRecoveryField({
|
|
|
28
37
|
<Field id={id} label={useRecovery ? t("auth.mfa.verify.recoveryCode") : codeLabel} required>
|
|
29
38
|
{useRecovery ? (
|
|
30
39
|
<Input
|
|
40
|
+
key={inputKey}
|
|
31
41
|
kind="text"
|
|
32
42
|
id={id}
|
|
33
43
|
name={id}
|
|
34
44
|
value={code}
|
|
35
|
-
|
|
45
|
+
// Pasted recovery codes often carry a trailing space or newline; the server rejects them by length.
|
|
46
|
+
onChange={(next) => onCodeChange(next.trim())}
|
|
36
47
|
disabled={disabled}
|
|
48
|
+
required={required}
|
|
37
49
|
autoFocus
|
|
38
50
|
autoComplete="off"
|
|
39
51
|
/>
|
|
40
52
|
) : (
|
|
41
53
|
<Input
|
|
54
|
+
key={inputKey}
|
|
42
55
|
kind="code"
|
|
43
56
|
length={6}
|
|
44
57
|
id={id}
|
|
45
58
|
name={id}
|
|
46
59
|
value={code}
|
|
47
60
|
onChange={onCodeChange}
|
|
61
|
+
onComplete={onComplete}
|
|
48
62
|
disabled={disabled}
|
|
63
|
+
hasError={hasError}
|
|
64
|
+
required={required}
|
|
49
65
|
autoFocus
|
|
50
66
|
/>
|
|
51
67
|
)}
|
|
@@ -21,7 +21,7 @@ export type MfaDisableDialogProps = {
|
|
|
21
21
|
readonly onError: (i18nKey: string) => void;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// biome-ignore lint/plugin: Uses usePrimitives().Dialog internally, name is an MFA domain action, not a primitive reimplementation
|
|
25
25
|
export function MfaDisableDialog({
|
|
26
26
|
open,
|
|
27
27
|
onOpenChange,
|
|
@@ -18,7 +18,7 @@ export type MfaRegenerateRecoveryDialogProps = {
|
|
|
18
18
|
readonly onError: (i18nKey: string) => void;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// biome-ignore lint/plugin: Uses usePrimitives().Dialog internally, name is an MFA domain action, not a primitive reimplementation
|
|
22
22
|
export function MfaRegenerateRecoveryDialog({
|
|
23
23
|
open,
|
|
24
24
|
onOpenChange,
|
|
@@ -10,6 +10,7 @@ import { type FormEvent, type ReactNode, useState } from "react";
|
|
|
10
10
|
// kumiko-lint-ignore cross-feature-import client-only barrel, the feature's server barrel has no web/ re-export
|
|
11
11
|
import { AuthCard, useSession } from "../../auth-email-password/web/index.ts";
|
|
12
12
|
import { verifyMfaChallenge } from "./mfa-client.ts";
|
|
13
|
+
import { MfaCodeOrRecoveryField } from "./mfa-code-or-recovery-field.tsx";
|
|
13
14
|
|
|
14
15
|
export type MfaVerifyScreenProps = {
|
|
15
16
|
readonly challengeToken: string;
|
|
@@ -29,8 +30,6 @@ export type MfaVerifyScreenProps = {
|
|
|
29
30
|
|
|
30
31
|
type CodeEntryMode = "authenticator" | "recovery";
|
|
31
32
|
|
|
32
|
-
const MFA_CODE_LENGTH = 6;
|
|
33
|
-
|
|
34
33
|
function reasonToKey(reason: string): string {
|
|
35
34
|
switch (reason) {
|
|
36
35
|
case "invalid_totp_code":
|
|
@@ -58,7 +57,7 @@ export function MfaVerifyScreen({
|
|
|
58
57
|
onCancel,
|
|
59
58
|
}: MfaVerifyScreenProps): ReactNode {
|
|
60
59
|
const t = useTranslation();
|
|
61
|
-
const { Form,
|
|
60
|
+
const { Form, Button, Banner } = usePrimitives();
|
|
62
61
|
const session = useSession();
|
|
63
62
|
const [mode, setMode] = useState<CodeEntryMode>("authenticator");
|
|
64
63
|
const [code, setCode] = useState("");
|
|
@@ -89,12 +88,6 @@ export function MfaVerifyScreen({
|
|
|
89
88
|
void doSubmit(code);
|
|
90
89
|
};
|
|
91
90
|
|
|
92
|
-
const toggleMode = (): void => {
|
|
93
|
-
setMode(mode === "authenticator" ? "recovery" : "authenticator");
|
|
94
|
-
setCode("");
|
|
95
|
-
setError(null);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
91
|
const isRecovery = mode === "recovery";
|
|
99
92
|
const fieldId = isRecovery ? "mfa-verify-recovery-code" : "mfa-verify-code";
|
|
100
93
|
const defaultSubtitle = isRecovery
|
|
@@ -104,52 +97,28 @@ export function MfaVerifyScreen({
|
|
|
104
97
|
return (
|
|
105
98
|
<AuthCard title={title ?? t("auth.mfa.verify.title")} subtitle={subtitle ?? defaultSubtitle}>
|
|
106
99
|
<Form onSubmit={onSubmit}>
|
|
107
|
-
<
|
|
100
|
+
<MfaCodeOrRecoveryField
|
|
108
101
|
id={fieldId}
|
|
109
|
-
|
|
102
|
+
codeLabel={t("auth.mfa.verify.code")}
|
|
103
|
+
code={code}
|
|
104
|
+
onCodeChange={setCode}
|
|
105
|
+
useRecovery={isRecovery}
|
|
106
|
+
onUseRecoveryChange={(useRecovery) => {
|
|
107
|
+
setMode(useRecovery ? "recovery" : "authenticator");
|
|
108
|
+
setError(null);
|
|
109
|
+
}}
|
|
110
|
+
disabled={submitting}
|
|
110
111
|
required
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
kind="text"
|
|
116
|
-
id={fieldId}
|
|
117
|
-
name={fieldId}
|
|
118
|
-
value={code}
|
|
119
|
-
onChange={setCode}
|
|
120
|
-
disabled={submitting}
|
|
121
|
-
required
|
|
122
|
-
autoFocus
|
|
123
|
-
autoComplete="off"
|
|
124
|
-
/>
|
|
125
|
-
) : (
|
|
126
|
-
<Input
|
|
127
|
-
key={`${mode}-${attempt}`}
|
|
128
|
-
kind="code"
|
|
129
|
-
length={MFA_CODE_LENGTH}
|
|
130
|
-
id={fieldId}
|
|
131
|
-
name={fieldId}
|
|
132
|
-
value={code}
|
|
133
|
-
onChange={setCode}
|
|
134
|
-
onComplete={(next) => void doSubmit(next)}
|
|
135
|
-
disabled={submitting}
|
|
136
|
-
hasError={error !== null}
|
|
137
|
-
required
|
|
138
|
-
autoFocus
|
|
139
|
-
/>
|
|
140
|
-
)}
|
|
141
|
-
</Field>
|
|
112
|
+
hasError={error !== null}
|
|
113
|
+
inputKey={`${mode}-${attempt}`}
|
|
114
|
+
onComplete={(next) => void doSubmit(next)}
|
|
115
|
+
/>
|
|
142
116
|
{error !== null ? <Banner variant="error">{t(reasonToKey(error))}</Banner> : null}
|
|
143
117
|
<Button type="submit" loading={submitting} disabled={submitting}>
|
|
144
118
|
{submitting
|
|
145
119
|
? t("auth.mfa.verify.submitting")
|
|
146
120
|
: (submitLabel ?? t("auth.mfa.verify.submit"))}
|
|
147
121
|
</Button>
|
|
148
|
-
<Button type="button" variant="link" onClick={toggleMode} disabled={submitting}>
|
|
149
|
-
{isRecovery
|
|
150
|
-
? t("auth.mfa.verify.useAuthenticatorCode")
|
|
151
|
-
: t("auth.mfa.verify.useRecoveryCode")}
|
|
152
|
-
</Button>
|
|
153
122
|
{onCancel ? (
|
|
154
123
|
<Button type="button" variant="secondary" onClick={onCancel} disabled={submitting}>
|
|
155
124
|
{t("auth.mfa.verify.backToLogin")}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// consumers without the user-data-rights stack don't pull a hard dependency.
|
|
6
6
|
// Mirrors folders-user-data.
|
|
7
7
|
|
|
8
|
-
import { defineFeature
|
|
8
|
+
import { defineFeature } from "@cosmicdrift/kumiko-framework/engine";
|
|
9
|
+
import { registerUserDataHooks } from "../shared/index.ts";
|
|
9
10
|
import { userMfaDeleteHook, userMfaExportHook } from "./hooks.ts";
|
|
10
11
|
|
|
11
12
|
export function createAuthMfaUserDataFeature() {
|
|
@@ -15,11 +16,9 @@ export function createAuthMfaUserDataFeature() {
|
|
|
15
16
|
r.describe(
|
|
16
17
|
"GDPR (Art. 20 export / Art. 17 erasure) coverage for the `auth-mfa` feature's `user-mfa` entity. Mounts the EXT_USER_DATA export + delete hooks so 2FA enrollment status is included in the user-data export bundle and a user's TOTP secret + recovery codes are hard-deleted (via executor.forget, rebuild-safe) on a data-subject erasure request. Kept separate from `auth-mfa` so consumers without the user-data-rights pipeline don't pull a hard dependency — requires `user-data-rights`, optionalRequires `auth-mfa`.",
|
|
17
18
|
);
|
|
18
|
-
r
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export: userMfaExportHook,
|
|
22
|
-
delete: userMfaDeleteHook,
|
|
19
|
+
registerUserDataHooks(r, {
|
|
20
|
+
sourceFeature: "auth-mfa",
|
|
21
|
+
entities: [{ entity: "user-mfa", export: userMfaExportHook, delete: userMfaDeleteHook }],
|
|
23
22
|
});
|
|
24
23
|
},
|
|
25
24
|
{ dedupeOptions: {} },
|
|
@@ -31,7 +31,6 @@ const TERMINATION_UNMATCHED_NAMESPACE = "7e2f4b9a-3c1d-4a68-8d05-b6c9e1f27a34";
|
|
|
31
31
|
* Stripe→Mollie migration, appends a new event to the same stream because
|
|
32
32
|
* the tenant and aggregate stream remain the same.
|
|
33
33
|
*/
|
|
34
|
-
// @wrapper-known uuid-domain
|
|
35
34
|
export function subscriptionAggregateId(tenantId: string): string {
|
|
36
35
|
return uuidv5(tenantId, SUBSCRIPTION_NAMESPACE);
|
|
37
36
|
}
|
|
@@ -43,7 +42,6 @@ export function subscriptionAggregateId(tenantId: string): string {
|
|
|
43
42
|
* stream); the read_payments-projection creates its own row per event
|
|
44
43
|
* (PK = paymentRowId(...), not aggregateId).
|
|
45
44
|
*/
|
|
46
|
-
// @wrapper-known uuid-domain
|
|
47
45
|
export function paymentAggregateId(tenantId: string): string {
|
|
48
46
|
return uuidv5(tenantId, PAYMENT_NAMESPACE);
|
|
49
47
|
}
|
|
@@ -51,7 +49,6 @@ export function paymentAggregateId(tenantId: string): string {
|
|
|
51
49
|
/** Deterministic `read_payments` row-id — keyed off `(tenantId, providerName,
|
|
52
50
|
* providerEventId)` rather than the event-store's bigserial `event.id` (not
|
|
53
51
|
* a UUID) or the shared per-tenant aggregateId (one row per payment). */
|
|
54
|
-
// @wrapper-known uuid-domain
|
|
55
52
|
export function paymentRowId(
|
|
56
53
|
tenantId: string,
|
|
57
54
|
providerName: string,
|
|
@@ -67,7 +64,6 @@ export function paymentRowId(
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
/** Stream id of one unmatched termination declaration, derived from its request id. */
|
|
70
|
-
// @wrapper-known uuid-domain
|
|
71
67
|
export function terminationUnmatchedAggregateId(requestId: string): string {
|
|
72
68
|
return uuidv5(requestId, TERMINATION_UNMATCHED_NAMESPACE);
|
|
73
69
|
}
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "breaking",
|
|
5
|
+
"title": "Billing webhooks are accepted only for checkouts the server opened",
|
|
6
|
+
"detail": "A tenant member could replay the tenant binding of their own checkout and open checkouts of their own at the provider, which skipped the consent step, the oneOffPriceIds allowlist, the role checks and billingLive. `createCheckoutSession` of a provider plugin now returns `{ url, providerCheckoutId }`, the new SystemAdmin handler `billing-foundation:write:record-checkout-opened` records that id in a checkout ledger on the tenant's subscription or payment stream, and `process-event` and `process-payment-event` ignore (HTTP 200 with `ignored: true`) any event whose checkout is not in the ledger or whose price does not match the ledgered price. A created subscription needs a ledgered checkout for its tier; later events of that subscription are admitted by the subscription itself. The consent of a plan switch comes from the newest unconsumed recorded checkout consent instead of a `consentId` in the provider payload, so `SubscriptionEvent.consentId` and the `consentId` in provider metadata are gone and `SubscriptionEvent` and `PaymentEvent` may carry `providerCheckoutId`. A non-created subscription event for a tenant without any subscription answers a retryable 503 (`subscription_event_redeliver`) instead of 200, so an `updated` that beats its `created` is redelivered by the provider; an event of another subscription than the held one stays a 200 ignore. `SubscriptionProviderPlugin` gains the optional `shouldRedeliverIgnoredEvent`, asked when an event is ignored as `checkout_not_in_ledger`; true makes the route answer 503.",
|
|
7
|
+
"migration": "Custom subscription provider plugins: return `{ url, providerCheckoutId }` from `createCheckoutSession`, put the id of the provider checkout (Stripe session, Mollie first payment, Paddle transaction) on `SubscriptionEvent.providerCheckoutId` and `PaymentEvent.providerCheckoutId` for the created and payment events, and stop reading or writing a `consentId` in provider metadata or webhook payloads. Checkouts opened before the upgrade have no ledger entry: Paddle ones are taken over by the new job (see subscription-paddle), Stripe and Mollie ones are ignored by the webhook, so let open sessions finish or expire before upgrading."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"version": "0.414.0",
|
|
11
|
+
"type": "improvement",
|
|
12
|
+
"title": "providerTexts take a refund link per provider",
|
|
13
|
+
"detail": "`consumerProtection.providerTexts[provider].refundLink` (one link, or one per consent locale) replaces `legalLinks.refund` for that provider; a provider without it falls back to `legalLinks.refund`. It is validated like `legalLinks`, shown next to the other links while that provider is selected in the checkout dialog, and with `documentsAcknowledgement` it selects the text variant and the consent text version of that provider. `billing-plans` lists the override under `providers[].consumerProtection`."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"version": "0.414.0",
|
|
17
|
+
"type": "fix",
|
|
18
|
+
"title": "PII ciphertext limits on the provider ids of the billing events",
|
|
19
|
+
"detail": "`providerCustomerId` and `providerSubscriptionId` of the subscription and payment event payloads hold PII ciphertext of an id of up to 200 characters; their limit of 1000 was a rough guess and now comes from `piiCiphertextMaxLengthFor` in `@cosmicdrift/kumiko-framework/crypto`."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"version": "0.414.0",
|
|
23
|
+
"type": "fix",
|
|
24
|
+
"title": "Provider cancel and resume in contract termination time out",
|
|
25
|
+
"detail": "The provider cancel (record) and resume (revoke) calls run while the tenant's advisory lock is held and are now bounded to 20 seconds. A hanging provider is reported like any provider error (operator notice provider_error or revocation_resume_failed) instead of pinning the transaction, its pool connection and the public withdrawal requests. subscription-paddle and subscription-stripe now share one isBillingLive check with assertBillingLive."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"version": "0.414.0",
|
|
29
|
+
"type": "fix",
|
|
30
|
+
"title": "Pending in-app plan switch blocks a second one",
|
|
31
|
+
"detail": "A second in-app plan switch is refused until the provider's webhook confirmed the first one (30 minute window)."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"version": "0.414.0",
|
|
35
|
+
"type": "fix",
|
|
36
|
+
"title": "The legacy rawPayload header is removed from subscription and invoice events at boot",
|
|
37
|
+
"detail": "Earlier billing events carried the provider webhook body in the event header `rawPayload`, outside the PII-encrypted payload. The new boot job `billing-foundation:job:scrub-raw-payload-headers` (`runOnBoot`, idempotent) removes that header from the subscription created/updated/canceled and invoice paid/payment-failed events via `scrubEventHeaderKeys`; events without it are untouched and a second run changes nothing. The job declares an `escapeHatch` because the scrub spans every tenant. Framework: `scrubEventHeaderKeys` accepts any `DbRunner`."
|
|
38
|
+
},
|
|
2
39
|
{
|
|
3
40
|
"version": "0.405.0",
|
|
4
41
|
"type": "improvement",
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
UnconfiguredError,
|
|
12
12
|
UnprocessableError,
|
|
13
13
|
} from "@cosmicdrift/kumiko-framework/errors";
|
|
14
|
+
import { appendCheckoutOpened } from "./checkout-ledger.ts";
|
|
14
15
|
import { getSubscriptionForTenant } from "./get-subscription-for-tenant.ts";
|
|
15
16
|
import { assertOneOffAuthorized, assertOneOffPriceAllowed } from "./one-off-checkout-gate.ts";
|
|
16
17
|
import type {
|
|
@@ -398,10 +399,16 @@ export async function startProviderCheckout(
|
|
|
398
399
|
// pre-hardening wire-contract for callers that never sent `mode`
|
|
399
400
|
// (create-checkout-session's own regression pin).
|
|
400
401
|
...(input.mode && { mode: input.mode }),
|
|
401
|
-
...(input.consentId && { consentId: input.consentId }),
|
|
402
402
|
...(input.locale && { locale: input.locale }),
|
|
403
403
|
...(input.submitMessage && { submitMessage: input.submitMessage }),
|
|
404
404
|
});
|
|
405
|
+
await appendCheckoutOpened(ctx, ctx.user.tenantId, {
|
|
406
|
+
providerName: input.providerName,
|
|
407
|
+
providerCheckoutId: result.providerCheckoutId,
|
|
408
|
+
priceId: input.priceId,
|
|
409
|
+
mode: input.mode ?? "subscription",
|
|
410
|
+
...(input.consentId && { consentId: input.consentId }),
|
|
411
|
+
});
|
|
405
412
|
return { url: result.url, providerName: input.providerName };
|
|
406
413
|
}
|
|
407
414
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The server's checkout ledger: one `checkout-opened` event per checkout the
|
|
2
|
+
// server itself opened at a provider. process-event / process-payment-event
|
|
3
|
+
// accept a webhook only when it names a checkout found here.
|
|
4
|
+
|
|
5
|
+
import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { paymentAggregateId, subscriptionAggregateId } from "./aggregate-id.ts";
|
|
7
|
+
import {
|
|
8
|
+
CHECKOUT_OPENED_EVENT_QN,
|
|
9
|
+
type CheckoutOpenedPayload,
|
|
10
|
+
checkoutOpenedPayloadSchema,
|
|
11
|
+
PAYMENT_AGGREGATE_TYPE,
|
|
12
|
+
SUBSCRIPTION_AGGREGATE_TYPE,
|
|
13
|
+
} from "./events.ts";
|
|
14
|
+
|
|
15
|
+
type CheckoutMode = CheckoutOpenedPayload["mode"];
|
|
16
|
+
|
|
17
|
+
export type CheckoutLookup = {
|
|
18
|
+
readonly providerName: string;
|
|
19
|
+
readonly providerCheckoutId: string;
|
|
20
|
+
readonly mode?: CheckoutMode;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function ledgerAggregateId(tenantId: string, mode: CheckoutMode): string {
|
|
24
|
+
return mode === "subscription" ? subscriptionAggregateId(tenantId) : paymentAggregateId(tenantId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function appendCheckoutOpened(
|
|
28
|
+
ctx: HandlerContext,
|
|
29
|
+
tenantId: string,
|
|
30
|
+
entry: CheckoutOpenedPayload,
|
|
31
|
+
): Promise<void> {
|
|
32
|
+
await ctx.events.unsafeAppend({
|
|
33
|
+
aggregateId: ledgerAggregateId(tenantId, entry.mode),
|
|
34
|
+
aggregateType:
|
|
35
|
+
entry.mode === "subscription" ? SUBSCRIPTION_AGGREGATE_TYPE : PAYMENT_AGGREGATE_TYPE,
|
|
36
|
+
type: CHECKOUT_OPENED_EVENT_QN,
|
|
37
|
+
payload: entry,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function findCheckoutOpened(
|
|
42
|
+
storedEvents: readonly { readonly type: string; readonly payload: unknown }[],
|
|
43
|
+
lookup: CheckoutLookup,
|
|
44
|
+
): CheckoutOpenedPayload | undefined {
|
|
45
|
+
for (const stored of storedEvents) {
|
|
46
|
+
if (stored.type !== CHECKOUT_OPENED_EVENT_QN) continue;
|
|
47
|
+
const parsed = checkoutOpenedPayloadSchema.safeParse(stored.payload);
|
|
48
|
+
if (!parsed.success) continue;
|
|
49
|
+
const entry = parsed.data;
|
|
50
|
+
if (
|
|
51
|
+
entry.providerName === lookup.providerName &&
|
|
52
|
+
entry.providerCheckoutId === lookup.providerCheckoutId &&
|
|
53
|
+
(lookup.mode === undefined || entry.mode === lookup.mode)
|
|
54
|
+
) {
|
|
55
|
+
return entry;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|