@cosmicdrift/kumiko-bundled-features 0.367.0 → 0.368.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/dist/audit/handlers/details.query.js +1 -1
- package/dist/audit/handlers/list.query.js +1 -1
- package/dist/audit/run-escape-hatch-retention.js +1 -1
- package/dist/auth-email-password/bootstrap.js +1 -1
- package/dist/auth-email-password/handlers/invite-accept-with-login.write.js +6 -3
- package/dist/auth-email-password/handlers/invite-accept.write.js +6 -3
- package/dist/auth-email-password/handlers/invite-info.query.js +1 -1
- package/dist/auth-email-password/handlers/invite-signup-complete.write.js +6 -3
- package/dist/auth-email-password/handlers/signup-confirm.write.js +1 -1
- package/dist/auth-email-password/seeding.js +2 -2
- package/dist/auth-foundation/feature.d.ts +4 -0
- package/dist/auth-foundation/feature.js +37 -33
- package/dist/auth-foundation/index.d.ts +1 -1
- package/dist/auth-foundation/index.js +1 -1
- package/dist/auth-mfa/db/queries.js +1 -2
- package/dist/auth-mfa/handlers/enable-confirm-preauth.write.js +1 -1
- package/dist/auth-mfa/handlers/enable-start-preauth.write.js +1 -1
- package/dist/auth-mfa/handlers/reencrypt.job.js +2 -3
- package/dist/auth-mfa/handlers/status.query.js +1 -1
- package/dist/auth-mfa/handlers/verify.write.js +1 -1
- package/dist/auth-mfa/mfa-code-verifier.js +1 -1
- package/dist/auth-mfa/mfa-status-checker.js +1 -1
- package/dist/auth-mfa-user-data/index.d.ts +4 -0
- package/dist/auth-mfa-user-data/index.js +13 -9
- package/dist/billing-foundation/billing-info-query.js +1 -1
- package/dist/billing-foundation/feature.d.ts +1 -0
- package/dist/billing-foundation/feature.js +5 -6
- package/dist/billing-foundation/handlers/create-portal-session.write.js +1 -1
- package/dist/billing-foundation/projection.js +1 -2
- package/dist/cap-counter/calendar-cap-usage-reservation.d.ts +7 -0
- package/dist/cap-counter/calendar-cap-usage-reservation.js +28 -2
- package/dist/cap-counter/cap-reservation.d.ts +16 -0
- package/dist/cap-counter/cap-reservation.js +144 -14
- package/dist/cap-counter/feature.d.ts +4 -0
- package/dist/cap-counter/feature.js +74 -68
- package/dist/cap-counter/handlers/increment-rolling.write.js +3 -4
- package/dist/cap-counter/index.d.ts +3 -2
- package/dist/cap-counter/index.js +3 -2
- package/dist/cap-counter/tables.js +10 -3
- package/dist/cap-overview/handlers/caps-usage.query.js +1 -2
- package/dist/cap-overview/handlers/tenant-caps-list.query.js +1 -2
- package/dist/cap-overview/handlers/tenant-options.query.js +1 -1
- package/dist/channel-in-app/handlers/inbox.query.js +1 -1
- package/dist/channel-in-app/handlers/mark-all-read.write.js +1 -1
- package/dist/channel-in-app/handlers/mark-read.write.js +1 -1
- package/dist/channel-in-app/handlers/unread-count.query.js +1 -1
- package/dist/channel-in-app/tables.js +1 -2
- package/dist/compliance-profiles/handlers/for-tenant.query.js +1 -1
- package/dist/compliance-profiles/handlers/needs-profile.query.js +1 -1
- package/dist/compliance-profiles/handlers/set-profile.write.js +1 -2
- package/dist/compliance-profiles/resolve-for-tenant.js +1 -1
- package/dist/compliance-profiles/seeding.js +3 -5
- package/dist/compliance-profiles-ops/index.d.ts +8 -0
- package/dist/compliance-profiles-ops/index.js +19 -15
- package/dist/config/db/queries/resolver.js +1 -1
- package/dist/config/handlers/reencrypt.job.js +2 -2
- package/dist/config/resolver.js +1 -1
- package/dist/config/write-helpers.js +1 -1
- package/dist/crypto-shredding/handlers/forget-subject.write.js +6 -3
- package/dist/custom-fields/db/queries/field-access.js +1 -1
- package/dist/custom-fields/db/queries/projection.js +1 -1
- package/dist/custom-fields/db/queries/quota.js +1 -1
- package/dist/custom-fields/db/queries/retention.js +1 -2
- package/dist/custom-fields/db/queries/user-data-rights.js +1 -1
- package/dist/custom-fields/feature.d.ts +20 -2
- package/dist/custom-fields/feature.js +9 -13
- package/dist/custom-fields/handlers/clear-custom-field.write.js +2 -2
- package/dist/custom-fields/handlers/delete-system-field.write.js +2 -2
- package/dist/custom-fields/handlers/delete-tenant-field.write.js +2 -2
- package/dist/custom-fields/handlers/set-custom-field.write.js +2 -2
- package/dist/custom-fields/wire-for-entity.js +4 -4
- package/dist/data-retention/resolve-for-tenant.js +1 -1
- package/dist/data-retention/run-retention-cleanup.js +17 -13
- package/dist/delivery/address-opt-out.js +1 -2
- package/dist/delivery/attempt-log-retention.js +1 -1
- package/dist/delivery/channel-context.js +1 -1
- package/dist/delivery/db/queries/address-opt-outs.js +1 -1
- package/dist/delivery/db/queries/preferences.js +1 -1
- package/dist/delivery/delivery-service.js +16 -7
- package/dist/delivery/feature.js +1 -1
- package/dist/delivery/handlers/log.query.js +2 -3
- package/dist/delivery/handlers/preferences.query.js +1 -1
- package/dist/delivery/upsert-preference.js +1 -2
- package/dist/derivatives-sharp/feature.d.ts +4 -0
- package/dist/derivatives-sharp/feature.js +15 -11
- package/dist/derivatives-sharp/index.d.ts +1 -1
- package/dist/derivatives-sharp/index.js +1 -1
- package/dist/document-ingest-foundation/feature.d.ts +7 -0
- package/dist/document-ingest-foundation/feature.js +94 -90
- package/dist/document-ingest-foundation/forget-extract-with-file-ref.js +3 -3
- package/dist/document-ingest-foundation/index.d.ts +1 -1
- package/dist/document-ingest-foundation/index.js +1 -1
- package/dist/feature-toggles/global-feature-state-table.js +1 -2
- package/dist/feature-toggles/handlers/set.write.js +3 -5
- package/dist/feature-toggles/toggle-runtime.js +1 -1
- package/dist/file-derivatives/feature.d.ts +1 -0
- package/dist/file-derivatives/feature.js +2 -1
- package/dist/file-derivatives/handlers/public-variant-by-file-ref.query.js +1 -1
- package/dist/file-derivatives/handlers/public-variant.query.js +1 -1
- package/dist/file-foundation/feature.d.ts +6 -0
- package/dist/file-foundation/feature.js +29 -25
- package/dist/file-foundation/index.d.ts +1 -1
- package/dist/file-foundation/index.js +1 -1
- package/dist/file-foundation/read-file-ref-content.js +1 -1
- package/dist/file-provider-inmemory/feature.d.ts +4 -0
- package/dist/file-provider-inmemory/feature.js +24 -20
- package/dist/file-provider-inmemory/index.d.ts +1 -1
- package/dist/file-provider-inmemory/index.js +1 -1
- package/dist/file-provider-s3/env-feature.d.ts +3 -0
- package/dist/file-provider-s3/env-feature.js +46 -0
- package/dist/file-provider-s3/feature.d.ts +26 -0
- package/dist/file-provider-s3/feature.js +84 -72
- package/dist/file-provider-s3/index.d.ts +1 -1
- package/dist/file-provider-s3/index.js +1 -1
- package/dist/file-provider-s3/lib/index.d.ts +3 -0
- package/dist/file-provider-s3/lib/index.js +2 -0
- package/dist/{files-provider-s3 → file-provider-s3/lib}/s3-provider.js +19 -19
- package/dist/file-provider-s3-env/index.d.ts +8 -1
- package/dist/file-provider-s3-env/index.js +7 -2
- package/dist/files-provider-s3/index.d.ts +5 -3
- package/dist/files-provider-s3/index.js +5 -2
- package/dist/files-tenant-data/handlers/sweep-orphaned-derivatives.job.js +1 -1
- package/dist/files-tenant-data/hooks.js +1 -2
- package/dist/folders/feature.d.ts +6 -2
- package/dist/folders/feature.js +4 -2
- package/dist/folders-user-data/index.d.ts +4 -0
- package/dist/folders-user-data/index.js +21 -17
- package/dist/form-draft/db/queries/cleanup.js +1 -1
- package/dist/form-draft/db/queries/draft-count.js +1 -1
- package/dist/form-draft/db/queries/owned-file-refs.js +1 -2
- package/dist/form-draft/feature.d.ts +4 -0
- package/dist/form-draft/feature.js +5 -1
- package/dist/form-draft/handlers/cleanup.job.js +2 -2
- package/dist/form-draft/index.d.ts +1 -1
- package/dist/form-draft/index.js +1 -1
- package/dist/form-draft/lookup.js +1 -1
- package/dist/form-draft-user-data/index.d.ts +4 -0
- package/dist/form-draft-user-data/index.js +13 -9
- package/dist/inbound-mail-foundation/feature.d.ts +4 -0
- package/dist/inbound-mail-foundation/feature.js +151 -147
- package/dist/inbound-mail-foundation/handlers/ingest-message.write.js +1 -2
- package/dist/inbound-mail-foundation/index.d.ts +1 -1
- package/dist/inbound-mail-foundation/index.js +1 -1
- package/dist/inbound-mail-foundation/oauth-access-token.js +1 -2
- package/dist/inbound-mail-foundation/projection.js +1 -2
- package/dist/inbound-mail-foundation/watch-supervisor.js +1 -1
- package/dist/inbound-provider-imap/feature.d.ts +4 -0
- package/dist/inbound-provider-imap/feature.js +16 -12
- package/dist/inbound-provider-imap/index.d.ts +1 -1
- package/dist/inbound-provider-imap/index.js +1 -1
- package/dist/inbound-provider-inmemory/feature.d.ts +4 -0
- package/dist/inbound-provider-inmemory/feature.js +14 -10
- package/dist/inbound-provider-inmemory/index.d.ts +1 -1
- package/dist/inbound-provider-inmemory/index.js +1 -1
- package/dist/jobs/db/queries/retention.js +1 -1
- package/dist/jobs/db/queries/stale-run-sweep.js +1 -1
- package/dist/jobs/handlers/detail.query.js +1 -1
- package/dist/jobs/handlers/list.query.js +1 -2
- package/dist/jobs/handlers/retry.write.js +1 -1
- package/dist/jobs/handlers/tenant-failures.query.js +1 -1
- package/dist/jobs/handlers/tenant-runs.query.js +1 -1
- package/dist/jobs/job-run-logger.js +1 -2
- package/dist/jobs/tenant-job-failure-table.js +1 -2
- package/dist/jobs/tenant-job-run-table.js +1 -2
- package/dist/ledger/feature.d.ts +6 -2
- package/dist/ledger/feature.js +4 -2
- package/dist/mail-foundation/feature.d.ts +7 -0
- package/dist/mail-foundation/feature.js +48 -42
- package/dist/mail-foundation/index.d.ts +1 -1
- package/dist/mail-foundation/index.js +1 -1
- package/dist/mail-transport-inmemory/feature.d.ts +4 -0
- package/dist/mail-transport-inmemory/feature.js +20 -16
- package/dist/mail-transport-inmemory/index.d.ts +1 -1
- package/dist/mail-transport-inmemory/index.js +1 -1
- package/dist/mail-transport-smtp/feature.d.ts +16 -0
- package/dist/mail-transport-smtp/feature.js +85 -79
- package/dist/mail-transport-smtp/index.d.ts +1 -1
- package/dist/mail-transport-smtp/index.js +1 -1
- package/dist/managed-pages/handlers/by-slug.query.js +1 -1
- package/dist/managed-pages/handlers/by-tenant-published.query.js +1 -2
- package/dist/managed-pages/handlers/set.write.js +1 -2
- package/dist/managed-pages/seeding.js +3 -5
- package/dist/metrics/compute.d.ts +1 -1
- package/dist/metrics/filters.d.ts +1 -1
- package/dist/metrics/filters.js +1 -1
- package/dist/metrics/validate.js +1 -1
- package/dist/notes-history/feature.d.ts +7 -2
- package/dist/notes-history/feature.js +4 -2
- package/dist/notes-history/handlers/add-note.write.js +1 -1
- package/dist/notes-history-user-data/hooks.js +1 -1
- package/dist/notes-history-user-data/index.d.ts +4 -0
- package/dist/notes-history-user-data/index.js +21 -17
- package/dist/personal-access-tokens/feature.d.ts +4 -1
- package/dist/personal-access-tokens/feature.js +10 -2
- package/dist/personal-access-tokens/handlers/create.write.js +1 -1
- package/dist/personal-access-tokens/handlers/list.query.js +2 -2
- package/dist/personal-access-tokens/handlers/revoke.write.js +1 -1
- package/dist/personal-access-tokens/resolver.js +1 -1
- package/dist/personal-access-tokens/revoke-for-user.js +1 -1
- package/dist/personal-access-tokens/roles.js +3 -5
- package/dist/personal-access-tokens/screens.js +2 -0
- package/dist/readiness/feature.d.ts +8 -0
- package/dist/readiness/feature.js +18 -14
- package/dist/readiness/index.d.ts +1 -1
- package/dist/readiness/index.js +1 -1
- package/dist/secrets/db/queries/read.js +1 -1
- package/dist/secrets/feature.d.ts +3 -0
- package/dist/secrets/feature.js +3 -2
- package/dist/secrets/handlers/rotate.job.js +2 -3
- package/dist/secrets/secrets-context.js +3 -4
- package/dist/sessions/db/queries/cleanup.js +1 -1
- package/dist/sessions/handlers/detail.query.js +1 -1
- package/dist/sessions/handlers/list.query.js +2 -2
- package/dist/sessions/handlers/mine.query.js +1 -1
- package/dist/sessions/handlers/revoke-all-for-user.write.js +1 -1
- package/dist/sessions/handlers/revoke-all-others.write.js +1 -1
- package/dist/sessions/handlers/revoke.write.js +1 -1
- package/dist/sessions/session-callbacks.js +4 -6
- package/dist/sessions/testing.d.ts +1 -1
- package/dist/tags/feature.d.ts +6 -2
- package/dist/tags/feature.js +4 -2
- package/dist/template-resolver/api.js +1 -1
- package/dist/template-resolver/handlers/bundle-import.js +1 -1
- package/dist/template-resolver/handlers/by-slug.query.js +1 -1
- package/dist/template-resolver/handlers/by-tenant.query.js +1 -2
- package/dist/template-resolver/handlers/collection-item.query.js +1 -1
- package/dist/template-resolver/handlers/collection-list.query.js +1 -2
- package/dist/template-resolver/handlers/collection-set.write.js +1 -1
- package/dist/template-resolver/handlers/copy-locale.write.js +1 -1
- package/dist/template-resolver/handlers/diff-to-system.query.js +1 -1
- package/dist/template-resolver/handlers/export-bundle.query.js +1 -1
- package/dist/template-resolver/handlers/find-by-id.query.js +1 -1
- package/dist/template-resolver/handlers/layout-source.query.js +1 -1
- package/dist/template-resolver/handlers/list.query.js +1 -1
- package/dist/template-resolver/handlers/overview.query.js +1 -1
- package/dist/template-resolver/handlers/reset-to-system.write.js +1 -1
- package/dist/template-resolver/handlers/resource-remove.write.js +1 -1
- package/dist/template-resolver/handlers/set.write.js +1 -1
- package/dist/template-resolver/handlers/template-write.js +1 -1
- package/dist/template-resolver/handlers/tenant-overrides.query.js +1 -1
- package/dist/template-resolver/handlers/toggle-status.write.js +1 -1
- package/dist/template-resolver/handlers/usage.query.js +1 -1
- package/dist/template-resolver/handlers/validate.query.js +1 -1
- package/dist/template-resolver/seeding.js +3 -4
- package/dist/template-resolver/store-template-resource.js +1 -1
- package/dist/template-resolver/template-preview.js +1 -1
- package/dist/template-resolver/template-resources.js +1 -1
- package/dist/template-resolver/testing.js +1 -1
- package/dist/template-resolver-user-data/index.d.ts +4 -0
- package/dist/template-resolver-user-data/index.js +17 -13
- package/dist/tenant/handlers/active-tenant-ids.query.js +1 -1
- package/dist/tenant/handlers/add-member.write.js +1 -2
- package/dist/tenant/handlers/cancel-invitation.write.js +1 -1
- package/dist/tenant/handlers/invitations.query.js +1 -1
- package/dist/tenant/handlers/me.query.js +1 -1
- package/dist/tenant/handlers/member-directory.query.js +1 -1
- package/dist/tenant/handlers/members.query.js +1 -1
- package/dist/tenant/handlers/memberships.query.js +1 -1
- package/dist/tenant/handlers/remove-member.write.js +1 -2
- package/dist/tenant/handlers/resolve-user-ids.query.js +1 -1
- package/dist/tenant/handlers/team-list.query.js +1 -1
- package/dist/tenant/handlers/tenant-directory.query.js +1 -1
- package/dist/tenant/handlers/update-member-roles.write.js +1 -2
- package/dist/tenant/invited-membership.js +2 -3
- package/dist/tenant/last-tenant-admin.js +1 -2
- package/dist/tenant/seeding.js +12 -6
- package/dist/tenant-lifecycle/handlers/cancel-destruction.write.js +1 -2
- package/dist/tenant-lifecycle/handlers/request-destruction.write.js +1 -2
- package/dist/tenant-lifecycle/lib/revoke-tenant-sessions.js +1 -1
- package/dist/tenant-lifecycle/lifecycle-gate.js +1 -1
- package/dist/tenant-lifecycle/run-tenant-destroy.js +3 -5
- package/dist/tenant-lifecycle/stages.js +10 -6
- package/dist/tenant-lifecycle/testing.d.ts +1 -1
- package/dist/tenant-lifecycle/testing.js +2 -2
- package/dist/tenant-settings/feature.d.ts +1 -0
- package/dist/tenant-settings/feature.js +2 -1
- package/dist/tier-engine/feature.d.ts +1 -8
- package/dist/tier-engine/feature.js +71 -78
- package/dist/tier-engine/handlers/get-tenant-tier.query.js +2 -3
- package/dist/tier-engine/handlers/set-tenant-tier.write.js +1 -2
- package/dist/user/db/queries/stream-tenant-backfill.js +1 -1
- package/dist/user/handlers/create.write.js +1 -2
- package/dist/user/handlers/find-for-auth.query.js +1 -1
- package/dist/user/handlers/list.query.js +1 -1
- package/dist/user/handlers/update-roles.js +1 -2
- package/dist/user/index.d.ts +1 -1
- package/dist/user/index.js +1 -1
- package/dist/user/invited-global-roles.js +2 -3
- package/dist/user/principal-status.d.ts +4 -0
- package/dist/user/principal-status.js +9 -3
- package/dist/user/resolve-display-names.js +1 -1
- package/dist/user/seeding.js +5 -6
- package/dist/user-data-rights/audit-download.js +2 -2
- package/dist/user-data-rights/db/queries/export-jobs.js +1 -1
- package/dist/user-data-rights/db/queries/forget-cleanup.js +1 -1
- package/dist/user-data-rights/handlers/download-by-job.query.js +1 -1
- package/dist/user-data-rights/handlers/download-by-token.query.js +1 -1
- package/dist/user-data-rights/handlers/export-status.query.js +1 -1
- package/dist/user-data-rights/handlers/list-download-attempts.query.js +1 -1
- package/dist/user-data-rights/handlers/my-audit-log.query.js +1 -1
- package/dist/user-data-rights/handlers/request-export.write.js +1 -2
- package/dist/user-data-rights/handlers/run-forget-cleanup.write.js +3 -3
- package/dist/user-data-rights/lib/deny-if-target-outside-admin-tenant.d.ts +1 -1
- package/dist/user-data-rights/lib/deny-if-target-outside-admin-tenant.js +1 -1
- package/dist/user-data-rights/lib/update-user-lifecycle.d.ts +1 -0
- package/dist/user-data-rights/lib/update-user-lifecycle.js +3 -3
- package/dist/user-data-rights/run-export-jobs.js +2 -3
- package/dist/user-data-rights/run-forget-cleanup.js +9 -5
- package/dist/user-data-rights/run-user-export.js +9 -5
- package/dist/waitlist/handlers/invite.write.js +1 -2
- package/dist/waitlist/handlers/reject.write.js +1 -1
- package/dist/waitlist/lib.js +1 -2
- package/dist/workflow-runner/event-subscriber.js +1 -1
- package/dist/workflow-runner/feature.d.ts +4 -0
- package/dist/workflow-runner/feature.js +44 -40
- package/dist/workflow-runner/handlers/resume-run.write.js +1 -1
- package/dist/workflow-runner/index.d.ts +1 -1
- package/dist/workflow-runner/index.js +1 -1
- package/dist/workflow-runner/pending-projection.js +1 -1
- package/package.json +28 -11
- package/src/cap-counter/changes.json +13 -0
- package/src/crypto-shredding/changes.json +6 -0
- package/src/file-provider-s3/changes.json +10 -1
- package/src/personal-access-tokens/changes.json +6 -0
- package/src/user/changes.json +6 -0
- package/dist/file-provider-s3-env/feature.d.ts +0 -3
- package/dist/file-provider-s3-env/feature.js +0 -46
- /package/dist/{files-provider-s3 → file-provider-s3/lib}/env-helper.d.ts +0 -0
- /package/dist/{files-provider-s3 → file-provider-s3/lib}/env-helper.js +0 -0
- /package/dist/{files-provider-s3 → file-provider-s3/lib}/s3-provider.d.ts +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// screen. Tenant-isolated at the WHERE level like list.query, so a caller
|
|
3
3
|
// can only read events in their own tenant; a SystemAdmin can pass scope
|
|
4
4
|
// "system" to read app-instance system events (e.g. app.started).
|
|
5
|
-
import { selectMany } from "@cosmicdrift/kumiko-framework/
|
|
5
|
+
import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
6
6
|
import { access, defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
7
7
|
import { eventsTable } from "@cosmicdrift/kumiko-framework/event-store";
|
|
8
8
|
import * as z from "zod";
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
//
|
|
12
12
|
// Event payloads hold PII as subject-KMS ciphertext; it is replaced by
|
|
13
13
|
// REDACTED_PII_PLACEHOLDER before returning, since the API leak guard refuses ciphertext.
|
|
14
|
-
import { selectMany } from "@cosmicdrift/kumiko-framework/
|
|
14
|
+
import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
15
15
|
import { access, defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
16
16
|
import { eventsTable } from "@cosmicdrift/kumiko-framework/event-store";
|
|
17
17
|
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aggregateWhere, runnerCanBeginTransaction, selectMany, } from "@cosmicdrift/kumiko-framework/bun-db";
|
|
2
1
|
import { COMPLIANCE_PROFILES, subtractRetentionSpec, } from "@cosmicdrift/kumiko-framework/compliance";
|
|
2
|
+
import { aggregateWhere, runnerCanBeginTransaction, selectMany, } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import { parseTenantId, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
4
|
import { eventsTable } from "@cosmicdrift/kumiko-framework/event-store";
|
|
5
5
|
import { pruneEvents } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// invitation row holds membership role + global roles until the invitee
|
|
6
6
|
// accepts through the regular invite-accept routes.
|
|
7
7
|
import { makeDispatchSystemWrite, makeDispatchWriteAs, } from "@cosmicdrift/kumiko-framework/api";
|
|
8
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
8
|
+
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
9
9
|
import { ConfigScopes, createSystemUser, } from "@cosmicdrift/kumiko-framework/engine";
|
|
10
10
|
import { parseRoles } from "@cosmicdrift/kumiko-framework/utils";
|
|
11
11
|
// kumiko-lint-ignore cross-feature-import bootstrap sets per-tenant config through the config feature's write handler
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
// Unlike signup-confirm: no new tenant is created, no new user is created —
|
|
21
21
|
// both already exist. The magic is the combined login+accept operation in
|
|
22
22
|
// one round trip.
|
|
23
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
24
|
-
import { createEventStoreExecutor, createTenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
23
|
+
import { createEventStoreExecutor, createTenantDb, fetchOne, } from "@cosmicdrift/kumiko-framework/db";
|
|
25
24
|
import { buildSessionRoles, createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
|
|
26
25
|
import { InternalError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
27
26
|
import * as z from "zod";
|
|
@@ -128,7 +127,11 @@ export function createInviteAcceptWithLoginHandler(opts = {}) {
|
|
|
128
127
|
if (!globalGrant.isSuccess)
|
|
129
128
|
return globalGrant;
|
|
130
129
|
// Invitation → accepted: TenantDb for the invitation's tenant.
|
|
131
|
-
const invitationTdb = createTenantDb(
|
|
130
|
+
const invitationTdb = createTenantDb({
|
|
131
|
+
db: dbConn,
|
|
132
|
+
tenantId: invitationTenantId,
|
|
133
|
+
mode: "system",
|
|
134
|
+
});
|
|
132
135
|
const updateResult = await invitationExecutor.update({
|
|
133
136
|
id: invitationId,
|
|
134
137
|
version: invitationVersion,
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
// Branch 1 ist der klassische "shared workspace bei eingeloggter
|
|
15
15
|
// Session"-Flow. Branch 2 (anon + existing email) und Branch 3 (anon +
|
|
16
16
|
// new email) kommen als separate Handler.
|
|
17
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
18
|
-
import { createEventStoreExecutor, createTenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
17
|
+
import { createEventStoreExecutor, createTenantDb, fetchOne, } from "@cosmicdrift/kumiko-framework/db";
|
|
19
18
|
import { createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
|
|
20
19
|
import { InternalError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
21
20
|
import * as z from "zod";
|
|
@@ -108,7 +107,11 @@ export function createInviteAcceptHandler() {
|
|
|
108
107
|
// Tenant-scoping: ctx.db ist auf event.user.tenantId gescopt
|
|
109
108
|
// (= NICHT der invitation-tenant). Eigene TenantDb für den
|
|
110
109
|
// invitation-tenant bauen damit der executor die row findet.
|
|
111
|
-
const invitationTdb = createTenantDb(
|
|
110
|
+
const invitationTdb = createTenantDb({
|
|
111
|
+
db: dbConn,
|
|
112
|
+
tenantId: invitationTenantId,
|
|
113
|
+
mode: "system",
|
|
114
|
+
});
|
|
112
115
|
const updateResult = await invitationExecutor.update({
|
|
113
116
|
id: invitationId,
|
|
114
117
|
version: invitationVersion,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// the user submits anything. Unlike the accept handlers, this never touches
|
|
5
5
|
// the token store — the token is not burned and stays usable for the
|
|
6
6
|
// actual accept call.
|
|
7
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
7
|
+
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
8
8
|
import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
9
9
|
import { UnprocessableError } from "@cosmicdrift/kumiko-framework/errors";
|
|
10
10
|
import * as z from "zod";
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
// d. Add membership im invited Tenant
|
|
17
17
|
// e. Invitation → accepted, Token gelöscht
|
|
18
18
|
// 5. Response: SessionUser + tenantId für Auto-Login
|
|
19
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
20
|
-
import { createEventStoreExecutor, createTenantDb, } from "@cosmicdrift/kumiko-framework/db";
|
|
19
|
+
import { createEventStoreExecutor, createTenantDb, fetchOne, } from "@cosmicdrift/kumiko-framework/db";
|
|
21
20
|
import { buildSessionRoles, createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
|
|
22
21
|
import { InternalError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
23
22
|
import * as z from "zod";
|
|
@@ -114,7 +113,11 @@ export function createInviteSignupCompleteHandler(opts = {}) {
|
|
|
114
113
|
roles: [invitationRole],
|
|
115
114
|
});
|
|
116
115
|
// Invitation → accepted: TenantDb für invitation-tenant
|
|
117
|
-
const invitationTdb = createTenantDb(
|
|
116
|
+
const invitationTdb = createTenantDb({
|
|
117
|
+
db: dbConn,
|
|
118
|
+
tenantId: invitationTenantId,
|
|
119
|
+
mode: "system",
|
|
120
|
+
});
|
|
118
121
|
const updateResult = await invitationExecutor.update({
|
|
119
122
|
id: invitationId,
|
|
120
123
|
version: invitationVersion,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// Failure-Recovery: jeder Pfad nach dem burn checked `committed`-Flag;
|
|
19
19
|
// bei !committed wird der burn released damit ein legitimer Retry
|
|
20
20
|
// nicht durch einen stale Marker geblockt wird (wie reset/verify).
|
|
21
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
21
|
+
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
22
22
|
import { defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
|
|
23
23
|
import { ConflictError, InternalError, reraiseAsKumikoError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
|
|
24
24
|
import { generateUniqueName } from "@cosmicdrift/kumiko-framework/random";
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
// 3. seedTenant + seedTenantMembership aus tenant/seeding
|
|
12
12
|
// Damit Sample-Server und Tests keine drei sub-paths zusammensammeln
|
|
13
13
|
// müssen.
|
|
14
|
-
import { fetchOne, selectMany } from "@cosmicdrift/kumiko-framework/bun-db";
|
|
15
14
|
import { configuredBlindIndexKey, configuredPiiSubjectKms, decryptPiiFieldValues, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
15
|
+
import { fetchOne, selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
16
16
|
import { ConflictError } from "@cosmicdrift/kumiko-framework/errors";
|
|
17
17
|
import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
|
|
18
|
-
import { TestUsers } from "@cosmicdrift/kumiko-framework/
|
|
18
|
+
import { TestUsers } from "@cosmicdrift/kumiko-framework/seeding";
|
|
19
19
|
import { hashPassword } from "../shared/index.js";
|
|
20
20
|
// kumiko-lint-ignore cross-feature-import auth-tests need user+tenant seed-helpers
|
|
21
21
|
import { seedTenant, seedTenantMembership } from "../tenant/seeding.js";
|
|
@@ -2,6 +2,10 @@ import type { SessionUser } from "@cosmicdrift/kumiko-framework/engine";
|
|
|
2
2
|
import { type Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { type AuthProviderBuildDeps, type SessionStore, type TenantExistsFn, type TenantResolverFn, type TenantResolverTrust } from "./types.js";
|
|
4
4
|
export { EXT_SESSION_STORE, EXT_TENANT_EXISTENCE, EXT_TENANT_RESOLVER, EXT_TOKEN_VERIFIER, } from "./types.js";
|
|
5
|
+
export declare function createAuthFoundationFeature(): import("@cosmicdrift/kumiko-types/feature").FeatureDefinition & {
|
|
6
|
+
readonly exports: void;
|
|
7
|
+
};
|
|
8
|
+
/** @deprecated Use createAuthFoundationFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
5
9
|
export declare const authFoundationFeature: import("@cosmicdrift/kumiko-types/feature").FeatureDefinition & {
|
|
6
10
|
readonly exports: void;
|
|
7
11
|
};
|
|
@@ -14,39 +14,43 @@ import { validateSessionStoreMultiplicity, validateTenantExistenceMultiplicity,
|
|
|
14
14
|
import { EXT_SESSION_STORE, EXT_TENANT_EXISTENCE, EXT_TENANT_RESOLVER, EXT_TOKEN_VERIFIER, isAuthProviderPlugin, isSessionStoreProvider, isTenantExistenceProvider, isTenantResolverProvider, tokenShapeMatches, } from "./types.js";
|
|
15
15
|
export { EXT_SESSION_STORE, EXT_TENANT_EXISTENCE, EXT_TENANT_RESOLVER, EXT_TOKEN_VERIFIER, } from "./types.js";
|
|
16
16
|
const FEATURE_NAME = "auth-foundation";
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
17
|
+
export function createAuthFoundationFeature() {
|
|
18
|
+
return defineFeature(FEATURE_NAME, (r) => {
|
|
19
|
+
r.describe("Declares auth-middleware extension points: `tokenVerifier` (Bearer), `sessionStore` (revocable JWT sid), optional `tenantResolver` + `tenantExistence` for anonymous multi-tenant. Provider-features register via r.useExtension; mount auth-foundation with the matching provider features.");
|
|
20
|
+
r.uiHints({
|
|
21
|
+
displayLabel: "Auth Provider Foundation",
|
|
22
|
+
category: "identity",
|
|
23
|
+
recommended: false,
|
|
24
|
+
});
|
|
25
|
+
r.extendsRegistrar(EXT_TOKEN_VERIFIER, {
|
|
26
|
+
onRegister: () => {
|
|
27
|
+
// No side-effects at register-time — registry stores the usage,
|
|
28
|
+
// resolveTokenVerifier looks it up at request-time.
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
r.bootCheck(({ features }) => validateTokenVerifierMultiplicity(features));
|
|
32
|
+
r.extendsRegistrar(EXT_SESSION_STORE, {
|
|
33
|
+
onRegister: () => {
|
|
34
|
+
// No side-effects at register-time — resolveSessionStore at boot/request.
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
r.bootCheck(({ features }) => validateSessionStoreMultiplicity(features));
|
|
38
|
+
r.extendsRegistrar(EXT_TENANT_RESOLVER, {
|
|
39
|
+
onRegister: () => {
|
|
40
|
+
// Optional — zero providers is fine (single-tenant / header-cookie).
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
r.bootCheck(({ features }) => validateTenantResolverMultiplicity(features));
|
|
44
|
+
r.extendsRegistrar(EXT_TENANT_EXISTENCE, {
|
|
45
|
+
onRegister: () => {
|
|
46
|
+
// Optional — zero providers skips the existence check.
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
r.bootCheck(({ features }) => validateTenantExistenceMultiplicity(features));
|
|
50
|
+
}, { dedupeOptions: {} });
|
|
51
|
+
}
|
|
52
|
+
/** @deprecated Use createAuthFoundationFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
53
|
+
export const authFoundationFeature = createAuthFoundationFeature();
|
|
50
54
|
/**
|
|
51
55
|
* Tries every registered tokenVerifier provider's shape against `rawToken`
|
|
52
56
|
* in registration order and calls the first match's verifier. Returns null
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { authFoundationFeature, type ResolvedTenantResolver, resolveSessionStore, resolveTenantExistence, resolveTenantResolver, resolveTokenVerifier, } from "./feature.js";
|
|
1
|
+
export { authFoundationFeature, createAuthFoundationFeature, type ResolvedTenantResolver, resolveSessionStore, resolveTenantExistence, resolveTenantResolver, resolveTokenVerifier, } from "./feature.js";
|
|
2
2
|
export { resolveAnonymousAccessFromRegistry } from "./resolve-anonymous-access.js";
|
|
3
3
|
export { type AuthProviderBuildDeps, type AuthProviderPlugin, type AuthVerifier, EXT_SESSION_STORE, EXT_TENANT_EXISTENCE, EXT_TENANT_RESOLVER, EXT_TOKEN_VERIFIER, isAuthProviderPlugin, isSessionStoreProvider, isTenantExistenceProvider, isTenantResolverProvider, isTenantResolverTrust, isValidTokenShape, type SessionMassRevoker, type SessionStore, type SessionStoreProvider, type TenantExistenceProvider, type TenantExistsFn, type TenantResolverFn, type TenantResolverProvider, type TenantResolverTrust, type TokenShape, tokenShapeKey, tokenShapeMatches, } from "./types.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Public API of the auth-foundation bundled-feature.
|
|
2
|
-
export { authFoundationFeature, resolveSessionStore, resolveTenantExistence, resolveTenantResolver, resolveTokenVerifier, } from "./feature.js";
|
|
2
|
+
export { authFoundationFeature, createAuthFoundationFeature, resolveSessionStore, resolveTenantExistence, resolveTenantResolver, resolveTokenVerifier, } from "./feature.js";
|
|
3
3
|
export { resolveAnonymousAccessFromRegistry } from "./resolve-anonymous-access.js";
|
|
4
4
|
export { EXT_SESSION_STORE, EXT_TENANT_EXISTENCE, EXT_TENANT_RESOLVER, EXT_TOKEN_VERIFIER, isAuthProviderPlugin, isSessionStoreProvider, isTenantExistenceProvider, isTenantResolverProvider, isTenantResolverTrust, isValidTokenShape, tokenShapeKey, tokenShapeMatches, } from "./types.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
2
|
-
import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
1
|
+
import { createEventStoreExecutor, fetchOne, } from "@cosmicdrift/kumiko-framework/db";
|
|
3
2
|
import { parseJsonOrThrow } from "@cosmicdrift/kumiko-framework/utils";
|
|
4
3
|
import { userMfaEntity, userMfaTable } from "../schema/user-mfa.js";
|
|
5
4
|
const executor = createEventStoreExecutor(userMfaTable, userMfaEntity, {
|
|
@@ -92,7 +92,7 @@ export function createEnableConfirmPreauthHandler(opts) {
|
|
|
92
92
|
return invalidSetupToken();
|
|
93
93
|
// "system" mode: no session exists yet, tenantId comes from the
|
|
94
94
|
// verified token, mirroring enable-start-preauth.write.ts.
|
|
95
|
-
const scopedDb = createTenantDb(ctx.db.unsafeRaw(), tenantId, "system");
|
|
95
|
+
const scopedDb = createTenantDb({ db: ctx.db.unsafeRaw(), tenantId, mode: "system" });
|
|
96
96
|
const scopedUser = { id: userId, tenantId, roles: ["User"] };
|
|
97
97
|
const existing = await findUserMfaRow(scopedDb, scopedUser);
|
|
98
98
|
if (existing)
|
|
@@ -44,7 +44,7 @@ export function createEnableStartPreauthHandler(opts) {
|
|
|
44
44
|
// "system" mode: the guest dispatch identity's own tenantId is
|
|
45
45
|
// meaningless here — the preauthSetupToken is the source of truth
|
|
46
46
|
// for which tenant's row to read, mirroring verify.write.ts.
|
|
47
|
-
const scopedDb = createTenantDb(ctx.db.unsafeRaw(), tenantId, "system");
|
|
47
|
+
const scopedDb = createTenantDb({ db: ctx.db.unsafeRaw(), tenantId, mode: "system" });
|
|
48
48
|
const scopedUser = { id: userId, tenantId, roles: ["User"] };
|
|
49
49
|
const existing = await findUserMfaRow(scopedDb, scopedUser);
|
|
50
50
|
if (existing)
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
// (the very risk this job's plan entry called out: a rebuild resurrecting
|
|
23
23
|
// an old-KEK wrap would happen if rotation only touched the read-side
|
|
24
24
|
// projection instead of appending a real `.updated` event).
|
|
25
|
-
import { selectMany } from "@cosmicdrift/kumiko-framework/bun-db";
|
|
26
25
|
import { collectPiiSubjectFields, configuredPiiSubjectKms, decryptPiiFieldValues, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
27
|
-
import { configuredEntityFieldEncryption, createEventStoreExecutor, createTenantDb, } from "@cosmicdrift/kumiko-framework/db";
|
|
26
|
+
import { configuredEntityFieldEncryption, createEventStoreExecutor, createTenantDb, selectMany, } from "@cosmicdrift/kumiko-framework/db";
|
|
28
27
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
29
28
|
import { classifyStoredEnvelope, runChunkedMigration, } from "../../shared/index.js";
|
|
30
29
|
import { userMfaEntity, userMfaTable } from "../schema/user-mfa.js";
|
|
@@ -66,7 +65,7 @@ export async function mfaReencryptJob(rawPayload, ctx, db) {
|
|
|
66
65
|
function tdbFor(tenantId) {
|
|
67
66
|
let existing = tdbCache.get(tenantId);
|
|
68
67
|
if (!existing) {
|
|
69
|
-
existing = createTenantDb(db, tenantId, "system");
|
|
68
|
+
existing = createTenantDb({ db, tenantId, mode: "system" });
|
|
70
69
|
tdbCache.set(tenantId, existing);
|
|
71
70
|
}
|
|
72
71
|
return existing;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
1
|
+
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { userMfaTable } from "../schema/user-mfa.js";
|
|
@@ -69,7 +69,7 @@ export function createMfaVerifyHandler(opts) {
|
|
|
69
69
|
// "system" mode: this handler runs with a guest identity whose own
|
|
70
70
|
// tenantId is meaningless here — the challenge token is the source
|
|
71
71
|
// of truth for which tenant's row to read.
|
|
72
|
-
const scopedDb = createTenantDb(ctx.db.unsafeRaw(), tenantId, "system");
|
|
72
|
+
const scopedDb = createTenantDb({ db: ctx.db.unsafeRaw(), tenantId, mode: "system" });
|
|
73
73
|
const scopedUser = { id: userId, tenantId, roles: ["User"] };
|
|
74
74
|
const row = await findUserMfaRow(scopedDb, scopedUser);
|
|
75
75
|
// MFA got disabled between login and verify (race, or a stale
|
|
@@ -14,7 +14,7 @@ export function createMfaCodeVerifier() {
|
|
|
14
14
|
declareEscapeHatch({
|
|
15
15
|
reason: "reads the MFA enrollment of the user being re-authenticated on the caller's handler context; the calling handler declares its own escapeHatch",
|
|
16
16
|
});
|
|
17
|
-
const scopedDb = createTenantDb(ctx.db.unsafeRaw(), tenantId, "system");
|
|
17
|
+
const scopedDb = createTenantDb({ db: ctx.db.unsafeRaw(), tenantId, mode: "system" });
|
|
18
18
|
const row = await findUserMfaRow(scopedDb, { id: userId, tenantId, roles: [] });
|
|
19
19
|
if (!row)
|
|
20
20
|
return { enrolled: false, ok: false };
|
|
@@ -10,7 +10,7 @@ export function createMfaStatusChecker(opts) {
|
|
|
10
10
|
declareEscapeHatch({
|
|
11
11
|
reason: "reads the MFA enrollment of the tenant named in the signed login/setup token, not the guest dispatch tenant, on the caller's handler context; the calling handler declares its own escapeHatch",
|
|
12
12
|
});
|
|
13
|
-
const scopedDb = createTenantDb(ctx.db.unsafeRaw(), tenantId, "system");
|
|
13
|
+
const scopedDb = createTenantDb({ db: ctx.db.unsafeRaw(), tenantId, mode: "system" });
|
|
14
14
|
const scopedUser = { id: userId, tenantId, roles: ["User"] };
|
|
15
15
|
const row = await findUserMfaRow(scopedDb, scopedUser);
|
|
16
16
|
if (row) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare function createAuthMfaUserDataFeature(): import("@cosmicdrift/kumiko-types/feature").FeatureDefinition & {
|
|
2
|
+
readonly exports: void;
|
|
3
|
+
};
|
|
4
|
+
/** @deprecated Use createAuthMfaUserDataFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
1
5
|
export declare const authMfaUserDataFeature: import("@cosmicdrift/kumiko-types/feature").FeatureDefinition & {
|
|
2
6
|
readonly exports: void;
|
|
3
7
|
};
|
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
// Mirrors folders-user-data.
|
|
7
7
|
import { defineFeature, EXT_USER_DATA } from "@cosmicdrift/kumiko-framework/engine";
|
|
8
8
|
import { userMfaDeleteHook, userMfaExportHook } from "./hooks.js";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
9
|
+
export function createAuthMfaUserDataFeature() {
|
|
10
|
+
return defineFeature("auth-mfa-user-data", (r) => {
|
|
11
|
+
r.describe("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`.");
|
|
12
|
+
r.requires({ features: ["user-data-rights"] });
|
|
13
|
+
r.optionalRequires("auth-mfa");
|
|
14
|
+
r.useExtension(EXT_USER_DATA, "user-mfa", {
|
|
15
|
+
export: userMfaExportHook,
|
|
16
|
+
delete: userMfaDeleteHook,
|
|
17
|
+
});
|
|
18
|
+
}, { dedupeOptions: {} });
|
|
19
|
+
}
|
|
20
|
+
/** @deprecated Use createAuthMfaUserDataFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
21
|
+
export const authMfaUserDataFeature = createAuthMfaUserDataFeature();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// off the app's extraContext.
|
|
6
6
|
//
|
|
7
7
|
// Deliberately does NOT call defineQueryHandler itself: apps use different
|
|
8
|
-
// wrappers around it (publicstatus's
|
|
8
|
+
// wrappers around it (publicstatus's own wrapper, which adds
|
|
9
9
|
// `agent: { expose: false }`; show-pony's plain framework
|
|
10
10
|
// `defineQueryHandler`). Calling defineQueryHandler here would bypass
|
|
11
11
|
// whatever an app's own wrapper does. Instead this factory returns just the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import type { BillingFoundationOptions } from "./types.js";
|
|
3
3
|
export declare function createBillingFoundationFeature<TTier extends string = string>(options?: BillingFoundationOptions<TTier>): FeatureDefinition;
|
|
4
|
+
/** @deprecated Use createBillingFoundationFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
4
5
|
export declare const billingFoundationFeature: FeatureDefinition;
|
|
@@ -111,7 +111,9 @@ export function createBillingFoundationFeature(options = {}) {
|
|
|
111
111
|
r.defineEvent(SUBSCRIPTION_CANCELED_EVENT_SHORT, subscriptionEventPayloadSchema, {
|
|
112
112
|
piiFields: "none",
|
|
113
113
|
});
|
|
114
|
-
r.defineEvent(INVOICE_PAID_EVENT_SHORT, subscriptionEventPayloadSchema, {
|
|
114
|
+
r.defineEvent(INVOICE_PAID_EVENT_SHORT, subscriptionEventPayloadSchema, {
|
|
115
|
+
piiFields: "none",
|
|
116
|
+
});
|
|
115
117
|
r.defineEvent(INVOICE_PAYMENT_FAILED_EVENT_SHORT, subscriptionEventPayloadSchema, {
|
|
116
118
|
piiFields: "none",
|
|
117
119
|
});
|
|
@@ -215,10 +217,7 @@ export function createBillingFoundationFeature(options = {}) {
|
|
|
215
217
|
destroy: paymentTenantDestroyHook,
|
|
216
218
|
escapeHatch: { reason: PAYMENT_TENANT_DESTROY_ARCHIVE_REASON },
|
|
217
219
|
});
|
|
218
|
-
});
|
|
220
|
+
}, Object.keys(options).length === 0 ? { dedupeOptions: {} } : undefined);
|
|
219
221
|
}
|
|
220
|
-
|
|
221
|
-
// unchanged (no baseUrl/catalog — create-checkout-session's redirect-origin
|
|
222
|
-
// check then rejects every call as UnconfiguredError, matching the
|
|
223
|
-
// changes.json migration note).
|
|
222
|
+
/** @deprecated Use createBillingFoundationFeature(). Run `bun kumiko-upgrade --apply`. Removed in the first release after 2026-10-29. */
|
|
224
223
|
export const billingFoundationFeature = createBillingFoundationFeature();
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// **returnUrl:** computed server-side via `portalReturnUrl` (catalog's
|
|
13
13
|
// returnPath, or baseUrl itself) — the client no longer supplies one, so
|
|
14
14
|
// there is no client-controlled redirect to harden against.
|
|
15
|
-
import { selectMany } from "@cosmicdrift/kumiko-framework/bun-db";
|
|
16
15
|
import { configuredPiiSubjectKms, decryptPiiFieldValues, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
16
|
+
import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
17
17
|
import * as z from "zod";
|
|
18
18
|
import { subscriptionAggregateId } from "../aggregate-id.js";
|
|
19
19
|
import { portalReturnUrl, resolveProviderPlugin } from "../checkout-core.js";
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
// foundation production mounten müssen die Tabelle in ihre eigene
|
|
14
14
|
// `drizzle/generate.ts` ergänzen (= via subscriptionsProjectionTable-
|
|
15
15
|
// import). setupTestStack pusht sie automatisch via r.projection.table.
|
|
16
|
-
import { insertOnConflictDoNothing, requireEntityTableMeta, upsertOnConflict, } from "@cosmicdrift/kumiko-framework/
|
|
17
|
-
import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
|
|
16
|
+
import { buildEntityTable, insertOnConflictDoNothing, requireEntityTableMeta, upsertOnConflict, } from "@cosmicdrift/kumiko-framework/db";
|
|
18
17
|
import { defineApply } from "@cosmicdrift/kumiko-framework/engine";
|
|
19
18
|
import { paymentRowId } from "./aggregate-id.js";
|
|
20
19
|
import { paymentEntity, subscriptionEntity } from "./entities.js";
|
|
@@ -8,6 +8,7 @@ export type CalendarCapUsageReservationSpec = Omit<CalendarCapDef, "amount" | "n
|
|
|
8
8
|
readonly outsideTransaction?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export type CalendarCapUsageReservation = {
|
|
11
|
+
readonly reservationId: string;
|
|
11
12
|
readonly amount: number;
|
|
12
13
|
readonly counterValue: number;
|
|
13
14
|
settle(actualAmount: number): Promise<void>;
|
|
@@ -15,3 +16,9 @@ export type CalendarCapUsageReservation = {
|
|
|
15
16
|
};
|
|
16
17
|
export declare function reserveEnforcedCalendarCap(ctx: CapCounterContext, cap: CalendarCapUsageReservationSpec): Promise<CalendarCapReservation>;
|
|
17
18
|
export declare function reserveCalendarCapUsage(ctx: CapCounterContext, spec: CalendarCapUsageReservationSpec): Promise<CalendarCapUsageReservation>;
|
|
19
|
+
export type CalendarCapReservationHandleSpec = Pick<CalendarCapUsageReservationSpec, "capName" | "periodStartIso" | "outsideTransaction">;
|
|
20
|
+
export type CalendarCapReservationHandle = {
|
|
21
|
+
consume(units: number): Promise<void>;
|
|
22
|
+
release(): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export declare function calendarCapReservationHandle(ctx: CapCounterContext, reservationId: string, spec: CalendarCapReservationHandleSpec): CalendarCapReservationHandle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { releaseExpiredCapReservations, reserveCalendarCap, settleCalendarCapReservation, } from "./cap-reservation.js";
|
|
1
|
+
import { consumeCalendarCapReservation, releaseCapReservation, releaseExpiredCapReservations, reserveCalendarCap, settleCalendarCapReservation, } from "./cap-reservation.js";
|
|
2
2
|
import { assertBelowHardCap, enforceCapAndMaybeNotify, } from "./enforce-cap.js";
|
|
3
3
|
// Shared by withCapEnforcement and the public reservation API so both enforce identically.
|
|
4
4
|
export async function reserveEnforcedCalendarCap(ctx, cap) {
|
|
@@ -29,6 +29,7 @@ export async function reserveCalendarCapUsage(ctx, spec) {
|
|
|
29
29
|
const reservation = await reserveEnforcedCalendarCap(ctx, spec);
|
|
30
30
|
let state = "open";
|
|
31
31
|
return {
|
|
32
|
+
reservationId: reservation.reservationId,
|
|
32
33
|
amount: spec.amount,
|
|
33
34
|
counterValue: reservation.counterValue,
|
|
34
35
|
async settle(actualAmount) {
|
|
@@ -37,7 +38,11 @@ export async function reserveCalendarCapUsage(ctx, spec) {
|
|
|
37
38
|
}
|
|
38
39
|
state = "settled";
|
|
39
40
|
try {
|
|
40
|
-
await settleCalendarCapReservation(ctx, reservation.reservationId, {
|
|
41
|
+
await settleCalendarCapReservation(ctx, reservation.reservationId, {
|
|
42
|
+
capName: spec.capName,
|
|
43
|
+
periodStartIso: spec.periodStartIso,
|
|
44
|
+
actualAmount,
|
|
45
|
+
}, outsideTransaction);
|
|
41
46
|
}
|
|
42
47
|
catch (error) {
|
|
43
48
|
state = "open";
|
|
@@ -53,3 +58,24 @@ export async function reserveCalendarCapUsage(ctx, spec) {
|
|
|
53
58
|
},
|
|
54
59
|
};
|
|
55
60
|
}
|
|
61
|
+
// Addresses a reservation by id so a job can consume it per unit; capName and period are needed
|
|
62
|
+
// because the row may already be swept, in which case consume books the units directly.
|
|
63
|
+
export function calendarCapReservationHandle(ctx, reservationId, spec) {
|
|
64
|
+
const outsideTransaction = spec.outsideTransaction ?? true;
|
|
65
|
+
let released = false;
|
|
66
|
+
return {
|
|
67
|
+
async consume(units) {
|
|
68
|
+
if (released) {
|
|
69
|
+
throw new Error(`cap-counter: reservation for "${spec.capName}" is already released`);
|
|
70
|
+
}
|
|
71
|
+
await consumeCalendarCapReservation(ctx, reservationId, { capName: spec.capName, periodStartIso: spec.periodStartIso, units }, outsideTransaction);
|
|
72
|
+
},
|
|
73
|
+
async release() {
|
|
74
|
+
// skip: release is idempotent, a second call has nothing left to give back
|
|
75
|
+
if (released)
|
|
76
|
+
return;
|
|
77
|
+
await releaseCapReservation(ctx, reservationId, outsideTransaction);
|
|
78
|
+
released = true;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UnprocessableError } from "@cosmicdrift/kumiko-framework/errors";
|
|
1
2
|
import type { ReservationHandle } from "@cosmicdrift/kumiko-types/handlers";
|
|
2
3
|
import { type BookCapUsageOptions, type CapCounterContext, type ReadRollingCapUsageOptions } from "./book-cap-usage.js";
|
|
3
4
|
export type CalendarCapReservation = ReservationHandle & {
|
|
@@ -17,5 +18,20 @@ export type SettleCalendarCapOptions = {
|
|
|
17
18
|
readonly periodStartIso: string;
|
|
18
19
|
readonly actualAmount: number;
|
|
19
20
|
};
|
|
21
|
+
export declare class CapSettleBelowConsumedError extends UnprocessableError {
|
|
22
|
+
constructor(capName: string, consumed: number, actualAmount: number);
|
|
23
|
+
}
|
|
24
|
+
export declare class CapReservationSettledError extends UnprocessableError {
|
|
25
|
+
constructor(capName: string);
|
|
26
|
+
}
|
|
20
27
|
export declare function settleCalendarCapReservation(ctx: CapCounterContext, id: string, options: SettleCalendarCapOptions, outsideTransaction?: boolean): Promise<void>;
|
|
28
|
+
export type ConsumeCalendarCapOptions = {
|
|
29
|
+
readonly capName: string;
|
|
30
|
+
readonly periodStartIso: string;
|
|
31
|
+
readonly units: number;
|
|
32
|
+
};
|
|
33
|
+
export declare class CapReservationOverConsumedError extends UnprocessableError {
|
|
34
|
+
constructor(capName: string, remaining: number, requested: number);
|
|
35
|
+
}
|
|
36
|
+
export declare function consumeCalendarCapReservation(ctx: CapCounterContext, id: string, options: ConsumeCalendarCapOptions, outsideTransaction?: boolean): Promise<void>;
|
|
21
37
|
export declare function releaseExpiredCapReservations(ctx: CapCounterContext, capName: string, outsideTransaction?: boolean): Promise<void>;
|