@sentropic/cluster-mesh 0.24.0 → 0.26.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/README.md +5 -0
- package/dist/comments/storage-schema.d.ts +1 -1
- package/dist/comments/transport-contracts.d.ts +1 -1
- package/dist/compile/contract/diagnostics.d.ts +9 -0
- package/dist/compile/contract/diagnostics.d.ts.map +1 -0
- package/dist/compile/contract/diagnostics.js +82 -0
- package/dist/compile/contract/diagnostics.js.map +1 -0
- package/dist/compile/contract/encoding.d.ts +12 -0
- package/dist/compile/contract/encoding.d.ts.map +1 -0
- package/dist/compile/contract/encoding.js +95 -0
- package/dist/compile/contract/encoding.js.map +1 -0
- package/dist/compile/contract/index.d.ts +9 -0
- package/dist/compile/contract/index.d.ts.map +1 -0
- package/dist/compile/contract/index.js +9 -0
- package/dist/compile/contract/index.js.map +1 -0
- package/dist/compile/contract/json.d.ts +3 -0
- package/dist/compile/contract/json.d.ts.map +1 -0
- package/dist/compile/contract/json.js +75 -0
- package/dist/compile/contract/json.js.map +1 -0
- package/dist/compile/contract/output.d.ts +5 -0
- package/dist/compile/contract/output.d.ts.map +1 -0
- package/dist/compile/contract/output.js +57 -0
- package/dist/compile/contract/output.js.map +1 -0
- package/dist/compile/contract/recipe.d.ts +5 -0
- package/dist/compile/contract/recipe.d.ts.map +1 -0
- package/dist/compile/contract/recipe.js +86 -0
- package/dist/compile/contract/recipe.js.map +1 -0
- package/dist/compile/contract/schema.d.ts +26 -0
- package/dist/compile/contract/schema.d.ts.map +1 -0
- package/dist/compile/contract/schema.js +92 -0
- package/dist/compile/contract/schema.js.map +1 -0
- package/dist/compile/contract/types.d.ts +166 -0
- package/dist/compile/contract/types.d.ts.map +1 -0
- package/dist/compile/contract/types.js +21 -0
- package/dist/compile/contract/types.js.map +1 -0
- package/dist/compile/contract/vectors.d.ts +38 -0
- package/dist/compile/contract/vectors.d.ts.map +1 -0
- package/dist/compile/contract/vectors.js +29 -0
- package/dist/compile/contract/vectors.js.map +1 -0
- package/dist/engram-memory/wire-adaptation.d.ts +1 -1
- package/dist/engram-memory/wire-adaptation.d.ts.map +1 -1
- package/dist/engram-memory/wire-adaptation.js +24 -8
- package/dist/engram-memory/wire-adaptation.js.map +1 -1
- package/dist/forge/contracts.d.ts +60 -0
- package/dist/forge/contracts.d.ts.map +1 -0
- package/dist/forge/contracts.js +19 -0
- package/dist/forge/contracts.js.map +1 -0
- package/dist/forge/custody.d.ts +7 -0
- package/dist/forge/custody.d.ts.map +1 -0
- package/dist/forge/custody.js +76 -0
- package/dist/forge/custody.js.map +1 -0
- package/dist/forge/enrollment.d.ts +151 -0
- package/dist/forge/enrollment.d.ts.map +1 -0
- package/dist/forge/enrollment.js +98 -0
- package/dist/forge/enrollment.js.map +1 -0
- package/dist/forge/github-api.d.ts +6 -0
- package/dist/forge/github-api.d.ts.map +1 -0
- package/dist/forge/github-api.js +131 -0
- package/dist/forge/github-api.js.map +1 -0
- package/dist/forge/hono.d.ts +14 -0
- package/dist/forge/hono.d.ts.map +1 -0
- package/dist/forge/hono.js +141 -0
- package/dist/forge/hono.js.map +1 -0
- package/dist/forge/lifecycle.d.ts +108 -0
- package/dist/forge/lifecycle.d.ts.map +1 -0
- package/dist/forge/lifecycle.js +160 -0
- package/dist/forge/lifecycle.js.map +1 -0
- package/dist/forge/records.d.ts +70 -0
- package/dist/forge/records.d.ts.map +1 -0
- package/dist/forge/records.js +2 -0
- package/dist/forge/records.js.map +1 -0
- package/dist/forge/rotation.d.ts +46 -0
- package/dist/forge/rotation.d.ts.map +1 -0
- package/dist/forge/rotation.js +62 -0
- package/dist/forge/rotation.js.map +1 -0
- package/dist/identity/auth-abort.d.ts +9 -0
- package/dist/identity/auth-abort.d.ts.map +1 -0
- package/dist/identity/auth-abort.js +59 -0
- package/dist/identity/auth-abort.js.map +1 -0
- package/dist/identity/auth-binding.d.ts +3 -0
- package/dist/identity/auth-binding.d.ts.map +1 -0
- package/dist/identity/auth-binding.js +87 -0
- package/dist/identity/auth-binding.js.map +1 -0
- package/dist/identity/auth-boundary.d.ts +11 -0
- package/dist/identity/auth-boundary.d.ts.map +1 -0
- package/dist/identity/auth-boundary.js +73 -0
- package/dist/identity/auth-boundary.js.map +1 -0
- package/dist/identity/auth-completion.d.ts +9 -0
- package/dist/identity/auth-completion.d.ts.map +1 -0
- package/dist/identity/auth-completion.js +24 -0
- package/dist/identity/auth-completion.js.map +1 -0
- package/dist/identity/auth-credentials.d.ts +5 -0
- package/dist/identity/auth-credentials.d.ts.map +1 -0
- package/dist/identity/auth-credentials.js +82 -0
- package/dist/identity/auth-credentials.js.map +1 -0
- package/dist/identity/auth-email.d.ts +8 -0
- package/dist/identity/auth-email.d.ts.map +1 -0
- package/dist/identity/auth-email.js +104 -0
- package/dist/identity/auth-email.js.map +1 -0
- package/dist/identity/auth-hono.d.ts +5 -0
- package/dist/identity/auth-hono.d.ts.map +1 -0
- package/dist/identity/auth-hono.js +10 -0
- package/dist/identity/auth-hono.js.map +1 -0
- package/dist/identity/auth-proofs.d.ts +11 -0
- package/dist/identity/auth-proofs.d.ts.map +1 -0
- package/dist/identity/auth-proofs.js +107 -0
- package/dist/identity/auth-proofs.js.map +1 -0
- package/dist/identity/auth-service-tenant.d.ts +4 -0
- package/dist/identity/auth-service-tenant.d.ts.map +1 -0
- package/dist/identity/auth-service-tenant.js +54 -0
- package/dist/identity/auth-service-tenant.js.map +1 -0
- package/dist/identity/auth-sessions.d.ts +8 -0
- package/dist/identity/auth-sessions.d.ts.map +1 -0
- package/dist/identity/auth-sessions.js +141 -0
- package/dist/identity/auth-sessions.js.map +1 -0
- package/dist/identity/auth-social.d.ts +4 -0
- package/dist/identity/auth-social.d.ts.map +1 -0
- package/dist/identity/auth-social.js +82 -0
- package/dist/identity/auth-social.js.map +1 -0
- package/dist/identity/auth-users.d.ts +9 -0
- package/dist/identity/auth-users.d.ts.map +1 -0
- package/dist/identity/auth-users.js +116 -0
- package/dist/identity/auth-users.js.map +1 -0
- package/dist/identity/auth-webauthn.d.ts +22 -0
- package/dist/identity/auth-webauthn.d.ts.map +1 -0
- package/dist/identity/auth-webauthn.js +108 -0
- package/dist/identity/auth-webauthn.js.map +1 -0
- package/dist/identity/cascade.d.ts +12 -0
- package/dist/identity/cascade.d.ts.map +1 -0
- package/dist/identity/cascade.js +19 -0
- package/dist/identity/cascade.js.map +1 -0
- package/dist/identity/connector-custody.d.ts +85 -0
- package/dist/identity/connector-custody.d.ts.map +1 -0
- package/dist/identity/connector-custody.js +288 -0
- package/dist/identity/connector-custody.js.map +1 -0
- package/dist/identity/conversation.d.ts +50 -0
- package/dist/identity/conversation.d.ts.map +1 -0
- package/dist/identity/conversation.js +102 -0
- package/dist/identity/conversation.js.map +1 -0
- package/dist/identity/custody-crypto.d.ts +37 -0
- package/dist/identity/custody-crypto.d.ts.map +1 -0
- package/dist/identity/custody-crypto.js +173 -0
- package/dist/identity/custody-crypto.js.map +1 -0
- package/dist/identity/decision.d.ts +28 -0
- package/dist/identity/decision.d.ts.map +1 -0
- package/dist/identity/decision.js +97 -0
- package/dist/identity/decision.js.map +1 -0
- package/dist/identity/index.d.ts +9 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +13 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/ledger.d.ts +120 -0
- package/dist/identity/ledger.d.ts.map +1 -0
- package/dist/identity/ledger.js +226 -0
- package/dist/identity/ledger.js.map +1 -0
- package/dist/identity/postgres.d.ts +13 -0
- package/dist/identity/postgres.d.ts.map +1 -0
- package/dist/identity/postgres.js +207 -0
- package/dist/identity/postgres.js.map +1 -0
- package/dist/identity/sqlite.d.ts +14 -0
- package/dist/identity/sqlite.d.ts.map +1 -0
- package/dist/identity/sqlite.js +193 -0
- package/dist/identity/sqlite.js.map +1 -0
- package/dist/identity-contracts/access.d.ts +54 -0
- package/dist/identity-contracts/access.d.ts.map +1 -0
- package/dist/identity-contracts/access.js +168 -0
- package/dist/identity-contracts/access.js.map +1 -0
- package/dist/identity-contracts/accounts.d.ts +44 -0
- package/dist/identity-contracts/accounts.d.ts.map +1 -0
- package/dist/identity-contracts/accounts.js +150 -0
- package/dist/identity-contracts/accounts.js.map +1 -0
- package/dist/identity-contracts/boundary-resolution.d.ts +31 -0
- package/dist/identity-contracts/boundary-resolution.d.ts.map +1 -0
- package/dist/identity-contracts/boundary-resolution.js +56 -0
- package/dist/identity-contracts/boundary-resolution.js.map +1 -0
- package/dist/identity-contracts/composition-descriptors.d.ts +17 -0
- package/dist/identity-contracts/composition-descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/composition-descriptors.js +77 -0
- package/dist/identity-contracts/composition-descriptors.js.map +1 -0
- package/dist/identity-contracts/custody-auth.d.ts +122 -0
- package/dist/identity-contracts/custody-auth.d.ts.map +1 -0
- package/dist/identity-contracts/custody-auth.js +2 -0
- package/dist/identity-contracts/custody-auth.js.map +1 -0
- package/dist/identity-contracts/custody-descriptors.d.ts +18 -0
- package/dist/identity-contracts/custody-descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/custody-descriptors.js +83 -0
- package/dist/identity-contracts/custody-descriptors.js.map +1 -0
- package/dist/identity-contracts/custody-errors.d.ts +21 -0
- package/dist/identity-contracts/custody-errors.d.ts.map +1 -0
- package/dist/identity-contracts/custody-errors.js +80 -0
- package/dist/identity-contracts/custody-errors.js.map +1 -0
- package/dist/identity-contracts/custody-operations.d.ts +79 -0
- package/dist/identity-contracts/custody-operations.d.ts.map +1 -0
- package/dist/identity-contracts/custody-operations.js +2 -0
- package/dist/identity-contracts/custody-operations.js.map +1 -0
- package/dist/identity-contracts/custody.d.ts +587 -0
- package/dist/identity-contracts/custody.d.ts.map +1 -0
- package/dist/identity-contracts/custody.js +7 -0
- package/dist/identity-contracts/custody.js.map +1 -0
- package/dist/identity-contracts/descriptors.d.ts +12 -0
- package/dist/identity-contracts/descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/descriptors.js +57 -0
- package/dist/identity-contracts/descriptors.js.map +1 -0
- package/dist/identity-contracts/doubles.d.ts +124 -0
- package/dist/identity-contracts/doubles.d.ts.map +1 -0
- package/dist/identity-contracts/doubles.js +360 -0
- package/dist/identity-contracts/doubles.js.map +1 -0
- package/dist/identity-contracts/enforcement.d.ts +27 -0
- package/dist/identity-contracts/enforcement.d.ts.map +1 -0
- package/dist/identity-contracts/enforcement.js +155 -0
- package/dist/identity-contracts/enforcement.js.map +1 -0
- package/dist/identity-contracts/errors.d.ts +71 -0
- package/dist/identity-contracts/errors.d.ts.map +1 -0
- package/dist/identity-contracts/errors.js +129 -0
- package/dist/identity-contracts/errors.js.map +1 -0
- package/dist/identity-contracts/index.d.ts +22 -0
- package/dist/identity-contracts/index.d.ts.map +1 -0
- package/dist/identity-contracts/index.js +23 -0
- package/dist/identity-contracts/index.js.map +1 -0
- package/dist/identity-contracts/oauth-reads.d.ts +42 -0
- package/dist/identity-contracts/oauth-reads.d.ts.map +1 -0
- package/dist/identity-contracts/oauth-reads.js +38 -0
- package/dist/identity-contracts/oauth-reads.js.map +1 -0
- package/dist/identity-contracts/ports.d.ts +116 -0
- package/dist/identity-contracts/ports.d.ts.map +1 -0
- package/dist/identity-contracts/ports.js +7 -0
- package/dist/identity-contracts/ports.js.map +1 -0
- package/dist/identity-contracts/replica-sync.d.ts +89 -0
- package/dist/identity-contracts/replica-sync.d.ts.map +1 -0
- package/dist/identity-contracts/replica-sync.js +7 -0
- package/dist/identity-contracts/replica-sync.js.map +1 -0
- package/dist/identity-contracts/resolution.d.ts +56 -0
- package/dist/identity-contracts/resolution.d.ts.map +1 -0
- package/dist/identity-contracts/resolution.js +87 -0
- package/dist/identity-contracts/resolution.js.map +1 -0
- package/dist/identity-contracts/service-tenancy.d.ts +43 -0
- package/dist/identity-contracts/service-tenancy.d.ts.map +1 -0
- package/dist/identity-contracts/service-tenancy.js +75 -0
- package/dist/identity-contracts/service-tenancy.js.map +1 -0
- package/dist/identity-contracts/tenancy.d.ts +52 -0
- package/dist/identity-contracts/tenancy.d.ts.map +1 -0
- package/dist/identity-contracts/tenancy.js +171 -0
- package/dist/identity-contracts/tenancy.js.map +1 -0
- package/dist/identity-contracts/types.d.ts +253 -0
- package/dist/identity-contracts/types.d.ts.map +1 -0
- package/dist/identity-contracts/types.js +7 -0
- package/dist/identity-contracts/types.js.map +1 -0
- package/dist/identity-contracts/workspace-deletion.d.ts +56 -0
- package/dist/identity-contracts/workspace-deletion.d.ts.map +1 -0
- package/dist/identity-contracts/workspace-deletion.js +7 -0
- package/dist/identity-contracts/workspace-deletion.js.map +1 -0
- package/dist/identity-contracts/workspaces.d.ts +37 -0
- package/dist/identity-contracts/workspaces.d.ts.map +1 -0
- package/dist/identity-contracts/workspaces.js +118 -0
- package/dist/identity-contracts/workspaces.js.map +1 -0
- package/dist/identity-stores/index.d.ts +4 -0
- package/dist/identity-stores/index.d.ts.map +1 -0
- package/dist/identity-stores/index.js +7 -0
- package/dist/identity-stores/index.js.map +1 -0
- package/dist/identity-stores/tenancy-postgres.d.ts +23 -0
- package/dist/identity-stores/tenancy-postgres.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-postgres.js +294 -0
- package/dist/identity-stores/tenancy-postgres.js.map +1 -0
- package/dist/identity-stores/tenancy-schema.d.ts +11 -0
- package/dist/identity-stores/tenancy-schema.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-schema.js +74 -0
- package/dist/identity-stores/tenancy-schema.js.map +1 -0
- package/dist/identity-stores/tenancy-sqlite.d.ts +24 -0
- package/dist/identity-stores/tenancy-sqlite.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-sqlite.js +288 -0
- package/dist/identity-stores/tenancy-sqlite.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/mcp/memory-compose.d.ts +11 -0
- package/dist/integrations/mcp/memory-compose.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-compose.js +79 -0
- package/dist/integrations/mcp/memory-compose.js.map +1 -0
- package/dist/integrations/mcp/memory-definition.d.ts +28 -0
- package/dist/integrations/mcp/memory-definition.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-definition.js +2 -0
- package/dist/integrations/mcp/memory-definition.js.map +1 -0
- package/dist/integrations/mcp/memory-manifest.d.ts +4 -0
- package/dist/integrations/mcp/memory-manifest.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-manifest.js +9 -0
- package/dist/integrations/mcp/memory-manifest.js.map +1 -0
- package/dist/integrations/mcp/memory-transport.d.ts +21 -0
- package/dist/integrations/mcp/memory-transport.d.ts.map +1 -0
- package/dist/integrations/mcp/memory-transport.js +47 -0
- package/dist/integrations/mcp/memory-transport.js.map +1 -0
- package/dist/integrations/mcp/memory.d.ts +19 -0
- package/dist/integrations/mcp/memory.d.ts.map +1 -0
- package/dist/integrations/mcp/memory.js +40 -0
- package/dist/integrations/mcp/memory.js.map +1 -0
- package/dist/loaders/mcp/index.d.ts +1 -0
- package/dist/loaders/mcp/index.d.ts.map +1 -1
- package/dist/loaders/mcp/index.js +1 -0
- package/dist/loaders/mcp/index.js.map +1 -1
- package/dist/loaders/mcp/memory.d.ts +6 -0
- package/dist/loaders/mcp/memory.d.ts.map +1 -0
- package/dist/loaders/mcp/memory.js +9 -0
- package/dist/loaders/mcp/memory.js.map +1 -0
- package/dist/loaders/notifications/index.d.ts +5 -0
- package/dist/loaders/notifications/index.d.ts.map +1 -0
- package/dist/loaders/notifications/index.js +6 -0
- package/dist/loaders/notifications/index.js.map +1 -0
- package/dist/mcp/stateful-preflight.d.ts +1 -1
- package/dist/messaging/email-port.d.ts +49 -0
- package/dist/messaging/email-port.d.ts.map +1 -0
- package/dist/messaging/email-port.js +92 -0
- package/dist/messaging/email-port.js.map +1 -0
- package/dist/messaging/index.d.ts +1 -0
- package/dist/messaging/index.d.ts.map +1 -1
- package/dist/messaging/index.js +1 -0
- package/dist/messaging/index.js.map +1 -1
- package/dist/modules/catalog.d.ts +7 -4
- package/dist/modules/catalog.d.ts.map +1 -1
- package/dist/modules/catalog.js +24 -5
- package/dist/modules/catalog.js.map +1 -1
- package/dist/modules/contracts.d.ts +1 -1
- package/dist/modules/contracts.d.ts.map +1 -1
- package/dist/modules/contracts.js +3 -0
- package/dist/modules/contracts.js.map +1 -1
- package/dist/notifications/incident-policy.d.ts +6 -0
- package/dist/notifications/incident-policy.d.ts.map +1 -0
- package/dist/notifications/incident-policy.js +119 -0
- package/dist/notifications/incident-policy.js.map +1 -0
- package/dist/notifications/incident-schedule.d.ts +14 -0
- package/dist/notifications/incident-schedule.d.ts.map +1 -0
- package/dist/notifications/incident-schedule.js +36 -0
- package/dist/notifications/incident-schedule.js.map +1 -0
- package/dist/notifications/incident-state.d.ts +72 -0
- package/dist/notifications/incident-state.d.ts.map +1 -0
- package/dist/notifications/incident-state.js +72 -0
- package/dist/notifications/incident-state.js.map +1 -0
- package/dist/notifications/index.d.ts +9 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +9 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/ops-job-failure-contract.d.ts +19 -0
- package/dist/notifications/ops-job-failure-contract.d.ts.map +1 -0
- package/dist/notifications/ops-job-failure-contract.js +183 -0
- package/dist/notifications/ops-job-failure-contract.js.map +1 -0
- package/dist/notifications/ops-job-failure-types.d.ts +81 -0
- package/dist/notifications/ops-job-failure-types.d.ts.map +1 -0
- package/dist/notifications/ops-job-failure-types.js +73 -0
- package/dist/notifications/ops-job-failure-types.js.map +1 -0
- package/dist/notifications/recipients-http.d.ts +66 -0
- package/dist/notifications/recipients-http.d.ts.map +1 -0
- package/dist/notifications/recipients-http.js +148 -0
- package/dist/notifications/recipients-http.js.map +1 -0
- package/dist/notifications/recipients.d.ts +50 -0
- package/dist/notifications/recipients.d.ts.map +1 -0
- package/dist/notifications/recipients.js +59 -0
- package/dist/notifications/recipients.js.map +1 -0
- package/dist/prompts/registry.d.ts +55 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +76 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/runtime/heavy-phase-queue.d.ts +101 -0
- package/dist/runtime/heavy-phase-queue.d.ts.map +1 -0
- package/dist/runtime/heavy-phase-queue.js +129 -0
- package/dist/runtime/heavy-phase-queue.js.map +1 -0
- package/dist/sessions/content-policy.d.ts +55 -0
- package/dist/sessions/content-policy.d.ts.map +1 -0
- package/dist/sessions/content-policy.js +133 -0
- package/dist/sessions/content-policy.js.map +1 -0
- package/dist/sessions/registry-admin.d.ts +19 -0
- package/dist/sessions/registry-admin.d.ts.map +1 -0
- package/dist/sessions/registry-admin.js +42 -0
- package/dist/sessions/registry-admin.js.map +1 -0
- package/dist/sessions/registry-freshness.d.ts +8 -0
- package/dist/sessions/registry-freshness.d.ts.map +1 -0
- package/dist/sessions/registry-freshness.js +108 -0
- package/dist/sessions/registry-freshness.js.map +1 -0
- package/dist/sessions/registry-ingest.d.ts +5 -0
- package/dist/sessions/registry-ingest.d.ts.map +1 -0
- package/dist/sessions/registry-ingest.js +113 -0
- package/dist/sessions/registry-ingest.js.map +1 -0
- package/dist/sessions/registry-publish.d.ts +18 -0
- package/dist/sessions/registry-publish.d.ts.map +1 -0
- package/dist/sessions/registry-publish.js +134 -0
- package/dist/sessions/registry-publish.js.map +1 -0
- package/dist/sessions/registry-store.d.ts +51 -0
- package/dist/sessions/registry-store.d.ts.map +1 -0
- package/dist/sessions/registry-store.js +134 -0
- package/dist/sessions/registry-store.js.map +1 -0
- package/dist/sessions/registry-types.d.ts +180 -0
- package/dist/sessions/registry-types.d.ts.map +1 -0
- package/dist/sessions/registry-types.js +32 -0
- package/dist/sessions/registry-types.js.map +1 -0
- package/dist/sessions/registry.d.ts +45 -0
- package/dist/sessions/registry.d.ts.map +1 -0
- package/dist/sessions/registry.js +74 -0
- package/dist/sessions/registry.js.map +1 -0
- package/dist/sessions/relay-bind.d.ts +38 -0
- package/dist/sessions/relay-bind.d.ts.map +1 -0
- package/dist/sessions/relay-bind.js +74 -0
- package/dist/sessions/relay-bind.js.map +1 -0
- package/dist/sessions/relay-brand.d.ts +2 -0
- package/dist/sessions/relay-brand.d.ts.map +1 -0
- package/dist/sessions/relay-brand.js +7 -0
- package/dist/sessions/relay-brand.js.map +1 -0
- package/dist/sessions/relay-capsule.d.ts +50 -0
- package/dist/sessions/relay-capsule.d.ts.map +1 -0
- package/dist/sessions/relay-capsule.js +72 -0
- package/dist/sessions/relay-capsule.js.map +1 -0
- package/dist/sessions/relay-chain-failure.d.ts +25 -0
- package/dist/sessions/relay-chain-failure.d.ts.map +1 -0
- package/dist/sessions/relay-chain-failure.js +23 -0
- package/dist/sessions/relay-chain-failure.js.map +1 -0
- package/dist/sessions/relay-chain.d.ts +74 -0
- package/dist/sessions/relay-chain.d.ts.map +1 -0
- package/dist/sessions/relay-chain.js +71 -0
- package/dist/sessions/relay-chain.js.map +1 -0
- package/dist/sessions/relay-composition.d.ts +8 -0
- package/dist/sessions/relay-composition.d.ts.map +1 -0
- package/dist/sessions/relay-composition.js +65 -0
- package/dist/sessions/relay-composition.js.map +1 -0
- package/dist/sessions/relay-credit.d.ts +40 -0
- package/dist/sessions/relay-credit.d.ts.map +1 -0
- package/dist/sessions/relay-credit.js +68 -0
- package/dist/sessions/relay-credit.js.map +1 -0
- package/dist/sessions/relay-engine.d.ts +19 -0
- package/dist/sessions/relay-engine.d.ts.map +1 -0
- package/dist/sessions/relay-engine.js +34 -0
- package/dist/sessions/relay-engine.js.map +1 -0
- package/dist/sessions/relay-frames.d.ts +28 -0
- package/dist/sessions/relay-frames.d.ts.map +1 -0
- package/dist/sessions/relay-frames.js +72 -0
- package/dist/sessions/relay-frames.js.map +1 -0
- package/dist/sessions/relay-lane-client.d.ts +7 -0
- package/dist/sessions/relay-lane-client.d.ts.map +1 -0
- package/dist/sessions/relay-lane-client.js +137 -0
- package/dist/sessions/relay-lane-client.js.map +1 -0
- package/dist/sessions/relay-lane-lease.d.ts +20 -0
- package/dist/sessions/relay-lane-lease.d.ts.map +1 -0
- package/dist/sessions/relay-lane-lease.js +74 -0
- package/dist/sessions/relay-lane-lease.js.map +1 -0
- package/dist/sessions/relay-lane-record.d.ts +28 -0
- package/dist/sessions/relay-lane-record.d.ts.map +1 -0
- package/dist/sessions/relay-lane-record.js +28 -0
- package/dist/sessions/relay-lane-record.js.map +1 -0
- package/dist/sessions/relay-lane-stream.d.ts +13 -0
- package/dist/sessions/relay-lane-stream.d.ts.map +1 -0
- package/dist/sessions/relay-lane-stream.js +148 -0
- package/dist/sessions/relay-lane-stream.js.map +1 -0
- package/dist/sessions/relay-routes.d.ts +368 -0
- package/dist/sessions/relay-routes.d.ts.map +1 -0
- package/dist/sessions/relay-routes.js +46 -0
- package/dist/sessions/relay-routes.js.map +1 -0
- package/dist/sessions/relay-skeleton.d.ts +4 -0
- package/dist/sessions/relay-skeleton.d.ts.map +1 -0
- package/dist/sessions/relay-skeleton.js +85 -0
- package/dist/sessions/relay-skeleton.js.map +1 -0
- package/dist/sessions/relay-types.d.ts +107 -0
- package/dist/sessions/relay-types.d.ts.map +1 -0
- package/dist/sessions/relay-types.js +2 -0
- package/dist/sessions/relay-types.js.map +1 -0
- package/dist/sessions/relay-validate.d.ts +8 -0
- package/dist/sessions/relay-validate.d.ts.map +1 -0
- package/dist/sessions/relay-validate.js +169 -0
- package/dist/sessions/relay-validate.js.map +1 -0
- package/dist/sessions/relay-wire.d.ts +8 -0
- package/dist/sessions/relay-wire.d.ts.map +1 -0
- package/dist/sessions/relay-wire.js +37 -0
- package/dist/sessions/relay-wire.js.map +1 -0
- package/dist/sessions/relay-wiring.d.ts +26 -0
- package/dist/sessions/relay-wiring.d.ts.map +1 -0
- package/dist/sessions/relay-wiring.js +13 -0
- package/dist/sessions/relay-wiring.js.map +1 -0
- package/dist/sessions/relay.d.ts +11 -0
- package/dist/sessions/relay.d.ts.map +1 -0
- package/dist/sessions/relay.js +71 -0
- package/dist/sessions/relay.js.map +1 -0
- package/dist/storage/descriptor.d.ts +1 -1
- package/dist/storage/errors.d.ts +1 -1
- package/dist/storage/identity/atomic-deletion.d.ts +4 -0
- package/dist/storage/identity/atomic-deletion.d.ts.map +1 -0
- package/dist/storage/identity/atomic-deletion.js +235 -0
- package/dist/storage/identity/atomic-deletion.js.map +1 -0
- package/dist/storage/identity/custody-composition.d.ts +9 -0
- package/dist/storage/identity/custody-composition.d.ts.map +1 -0
- package/dist/storage/identity/custody-composition.js +31 -0
- package/dist/storage/identity/custody-composition.js.map +1 -0
- package/dist/storage/identity/custody-delivery-record.d.ts +4 -0
- package/dist/storage/identity/custody-delivery-record.d.ts.map +1 -0
- package/dist/storage/identity/custody-delivery-record.js +11 -0
- package/dist/storage/identity/custody-delivery-record.js.map +1 -0
- package/dist/storage/identity/custody-host.d.ts +16 -0
- package/dist/storage/identity/custody-host.d.ts.map +1 -0
- package/dist/storage/identity/custody-host.js +5 -0
- package/dist/storage/identity/custody-host.js.map +1 -0
- package/dist/storage/identity/custody-import-deliveries.d.ts +6 -0
- package/dist/storage/identity/custody-import-deliveries.d.ts.map +1 -0
- package/dist/storage/identity/custody-import-deliveries.js +46 -0
- package/dist/storage/identity/custody-import-deliveries.js.map +1 -0
- package/dist/storage/identity/custody-import.d.ts +4 -0
- package/dist/storage/identity/custody-import.d.ts.map +1 -0
- package/dist/storage/identity/custody-import.js +364 -0
- package/dist/storage/identity/custody-import.js.map +1 -0
- package/dist/storage/identity/custody-journal-postgres.d.ts +125 -0
- package/dist/storage/identity/custody-journal-postgres.d.ts.map +1 -0
- package/dist/storage/identity/custody-journal-postgres.js +428 -0
- package/dist/storage/identity/custody-journal-postgres.js.map +1 -0
- package/dist/storage/identity/custody-journal-sqlite.d.ts +121 -0
- package/dist/storage/identity/custody-journal-sqlite.d.ts.map +1 -0
- package/dist/storage/identity/custody-journal-sqlite.js +345 -0
- package/dist/storage/identity/custody-journal-sqlite.js.map +1 -0
- package/dist/storage/identity/custody-lifecycle.d.ts +4 -0
- package/dist/storage/identity/custody-lifecycle.d.ts.map +1 -0
- package/dist/storage/identity/custody-lifecycle.js +42 -0
- package/dist/storage/identity/custody-lifecycle.js.map +1 -0
- package/dist/storage/identity/custody-postgres.d.ts +96 -0
- package/dist/storage/identity/custody-postgres.d.ts.map +1 -0
- package/dist/storage/identity/custody-postgres.js +726 -0
- package/dist/storage/identity/custody-postgres.js.map +1 -0
- package/dist/storage/identity/custody-records.d.ts +17 -0
- package/dist/storage/identity/custody-records.d.ts.map +1 -0
- package/dist/storage/identity/custody-records.js +260 -0
- package/dist/storage/identity/custody-records.js.map +1 -0
- package/dist/storage/identity/custody-shared.d.ts +28 -0
- package/dist/storage/identity/custody-shared.d.ts.map +1 -0
- package/dist/storage/identity/custody-shared.js +24 -0
- package/dist/storage/identity/custody-shared.js.map +1 -0
- package/dist/storage/identity/custody-sqlite.d.ts +93 -0
- package/dist/storage/identity/custody-sqlite.d.ts.map +1 -0
- package/dist/storage/identity/custody-sqlite.js +568 -0
- package/dist/storage/identity/custody-sqlite.js.map +1 -0
- package/dist/storage/identity/custody-tombstone-record.d.ts +3 -0
- package/dist/storage/identity/custody-tombstone-record.d.ts.map +1 -0
- package/dist/storage/identity/custody-tombstone-record.js +8 -0
- package/dist/storage/identity/custody-tombstone-record.js.map +1 -0
- package/dist/storage/identity/custody-transaction-guards.d.ts +16 -0
- package/dist/storage/identity/custody-transaction-guards.d.ts.map +1 -0
- package/dist/storage/identity/custody-transaction-guards.js +64 -0
- package/dist/storage/identity/custody-transaction-guards.js.map +1 -0
- package/dist/storage/identity/custody-transaction-ports.d.ts +9 -0
- package/dist/storage/identity/custody-transaction-ports.d.ts.map +1 -0
- package/dist/storage/identity/custody-transaction-ports.js +106 -0
- package/dist/storage/identity/custody-transaction-ports.js.map +1 -0
- package/dist/storage/identity/deletion-planes.d.ts +10 -0
- package/dist/storage/identity/deletion-planes.d.ts.map +1 -0
- package/dist/storage/identity/deletion-planes.js +54 -0
- package/dist/storage/identity/deletion-planes.js.map +1 -0
- package/dist/storage/identity/index.d.ts +18 -0
- package/dist/storage/identity/index.d.ts.map +1 -0
- package/dist/storage/identity/index.js +22 -0
- package/dist/storage/identity/index.js.map +1 -0
- package/dist/storage/identity/postgres.d.ts +16 -0
- package/dist/storage/identity/postgres.d.ts.map +1 -0
- package/dist/storage/identity/postgres.js +345 -0
- package/dist/storage/identity/postgres.js.map +1 -0
- package/dist/storage/identity/records.d.ts +12 -0
- package/dist/storage/identity/records.d.ts.map +1 -0
- package/dist/storage/identity/records.js +84 -0
- package/dist/storage/identity/records.js.map +1 -0
- package/dist/storage/identity/replica-sync.d.ts +4 -0
- package/dist/storage/identity/replica-sync.d.ts.map +1 -0
- package/dist/storage/identity/replica-sync.js +402 -0
- package/dist/storage/identity/replica-sync.js.map +1 -0
- package/dist/storage/identity/schema.d.ts +13 -0
- package/dist/storage/identity/schema.d.ts.map +1 -0
- package/dist/storage/identity/schema.js +418 -0
- package/dist/storage/identity/schema.js.map +1 -0
- package/dist/storage/identity/sqlite-schema.d.ts +4 -0
- package/dist/storage/identity/sqlite-schema.d.ts.map +1 -0
- package/dist/storage/identity/sqlite-schema.js +17 -0
- package/dist/storage/identity/sqlite-schema.js.map +1 -0
- package/dist/storage/identity/sqlite.d.ts +25 -0
- package/dist/storage/identity/sqlite.d.ts.map +1 -0
- package/dist/storage/identity/sqlite.js +233 -0
- package/dist/storage/identity/sqlite.js.map +1 -0
- package/dist/storage/identity/stores.d.ts +10 -0
- package/dist/storage/identity/stores.d.ts.map +1 -0
- package/dist/storage/identity/stores.js +5 -0
- package/dist/storage/identity/stores.js.map +1 -0
- package/dist/storage/identity/wiring.d.ts +20 -0
- package/dist/storage/identity/wiring.d.ts.map +1 -0
- package/dist/storage/identity/wiring.js +26 -0
- package/dist/storage/identity/wiring.js.map +1 -0
- package/dist/storage/identity/workspace-deletion.d.ts +3 -0
- package/dist/storage/identity/workspace-deletion.d.ts.map +1 -0
- package/dist/storage/identity/workspace-deletion.js +100 -0
- package/dist/storage/identity/workspace-deletion.js.map +1 -0
- package/dist/storage/postgres/journal.d.ts +1 -1
- package/dist/storage/postgres/profiles.d.ts +2 -2
- package/dist/storage/postgres/scope.d.ts +1 -1
- package/dist/storage/root-facade.d.ts +1 -1
- package/dist/storage/root-journal.d.ts +1 -1
- package/dist/storage/root-profiles.d.ts +1 -1
- package/docs/memory-mcp-candidate.md +46 -0
- package/docs/memory-mcp.md +98 -0
- package/examples/memory-mcp-stdio.mjs +42 -0
- package/package.json +66 -5
- package/ui/AdminUsersScreen.svelte +197 -0
- package/ui/AdminUsersScreen.svelte.d.ts +4 -0
- package/ui/LoginScreen.svelte +15 -0
- package/ui/LoginScreen.svelte.d.ts +4 -0
- package/ui/MembershipDecisionsScreen.svelte +76 -0
- package/ui/MembershipDecisionsScreen.svelte.d.ts +4 -0
- package/ui/RegistrationScreen.svelte +15 -0
- package/ui/RegistrationScreen.svelte.d.ts +4 -0
- package/ui/WorkspaceMembersScreen.svelte +86 -0
- package/ui/WorkspaceMembersScreen.svelte.d.ts +4 -0
- package/ui/auth-flow.ts +44 -0
- package/ui/management-ports.ts +36 -0
- package/ui/management-transport.ts +29 -0
- package/contracts/engram-memory-neutral-contract-v1.d.ts +0 -367
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
// A2.0b deletion journal, revocation outbox and core-table transaction layer
|
|
2
|
+
// on the SQLite local profile. Shares the caller's connection — and therefore
|
|
3
|
+
// the exclusive transaction — with the custody stores.
|
|
4
|
+
import { decodeRevocationDelivery, sameRevocationTarget } from './custody-delivery-record.js';
|
|
5
|
+
import { decodeLegacyConnectorTombstone } from './custody-tombstone-record.js';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { IdentityCustodyErrorV1 } from '../../identity-contracts/custody-errors.js';
|
|
8
|
+
import { IdentityEmailCreateCollision } from './custody-shared.js';
|
|
9
|
+
export class SqliteCustodyJournal {
|
|
10
|
+
connection;
|
|
11
|
+
constructor(connection) {
|
|
12
|
+
this.connection = connection;
|
|
13
|
+
}
|
|
14
|
+
one = async (decode, text, values) => {
|
|
15
|
+
const row = this.connection.prepare(text).get(...values);
|
|
16
|
+
return row === undefined ? null : decode(row);
|
|
17
|
+
};
|
|
18
|
+
// -- Subject fences -------------------------------------------------------
|
|
19
|
+
async ensureLiveFence(userId, at) {
|
|
20
|
+
this.connection.prepare(`INSERT INTO "identity_subject_fences" ("user_id","revision","updated_at","retired_at") VALUES (?,0,?,NULL) ON CONFLICT("user_id") DO NOTHING`).run(userId, at);
|
|
21
|
+
const fence = await this.one((row) => ({ retiredAt: row['retired_at'] ?? null }), `SELECT "retired_at" FROM "identity_subject_fences" WHERE "user_id" = ?`, [userId]);
|
|
22
|
+
if (fence?.retiredAt !== null && fence?.retiredAt !== undefined)
|
|
23
|
+
throw new IdentityCustodyErrorV1('identity_subject_retired');
|
|
24
|
+
}
|
|
25
|
+
async retireFence(userId, at) {
|
|
26
|
+
const changed = Number(this.connection.prepare(`UPDATE "identity_subject_fences" SET "retired_at" = ?, "revision" = "revision" + 1, "updated_at" = ? WHERE "user_id" = ? AND "retired_at" IS NULL`).run(at, at, userId).changes);
|
|
27
|
+
if (changed === 0)
|
|
28
|
+
throw new IdentityCustodyErrorV1('identity_subject_retired');
|
|
29
|
+
}
|
|
30
|
+
// -- Deletion operations --------------------------------------------------
|
|
31
|
+
static requestDigestV1(userId, actorId, handlerId, operationId) {
|
|
32
|
+
return createHash('sha256').update(JSON.stringify(['A2.0b', '2.0.0', userId, actorId, handlerId]), 'utf8').digest('hex');
|
|
33
|
+
}
|
|
34
|
+
async reserveOperation(op) {
|
|
35
|
+
try {
|
|
36
|
+
this.connection.prepare(`INSERT INTO "identity_deletion_operations" ("operation_id","user_id","actor_id","handler_id","request_digest","state","created_at","committed_at","committed_receipt_json") VALUES (?,?,?,?,?,'queued',?,NULL,NULL)`).run(op.operationId, op.userId, op.actorId, op.handlerId, op.requestDigest, op.createdAt);
|
|
37
|
+
return 'reserved';
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!(error instanceof Error) || !error.message.includes('UNIQUE constraint failed'))
|
|
41
|
+
throw error;
|
|
42
|
+
const existing = await this.findOperation(op.operationId);
|
|
43
|
+
if (!existing)
|
|
44
|
+
throw new IdentityCustodyErrorV1('identity_transaction_indeterminate');
|
|
45
|
+
if (existing.requestDigest !== op.requestDigest || existing.userId !== op.userId || existing.actorId !== op.actorId || existing.handlerId !== op.handlerId) {
|
|
46
|
+
throw new IdentityCustodyErrorV1('identity_operation_conflict');
|
|
47
|
+
}
|
|
48
|
+
return existing.state === 'committed' ? 'committed' : 'reserved';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
findOperation = (operationId) => this.one((row) => ({
|
|
52
|
+
operationId: String(row['operation_id']),
|
|
53
|
+
userId: String(row['user_id']),
|
|
54
|
+
actorId: String(row['actor_id']),
|
|
55
|
+
handlerId: row['handler_id'],
|
|
56
|
+
requestDigest: String(row['request_digest']),
|
|
57
|
+
state: row['state'],
|
|
58
|
+
createdAt: String(row['created_at']),
|
|
59
|
+
committedAt: row['committed_at'] ?? null,
|
|
60
|
+
committedReceipt: row['committed_receipt_json'] ? JSON.parse(String(row['committed_receipt_json'])) : null,
|
|
61
|
+
}), `SELECT * FROM "identity_deletion_operations" WHERE "operation_id" = ?`, [operationId]);
|
|
62
|
+
async markOperationCommitted(operationId, receipt, at) {
|
|
63
|
+
const changed = Number(this.connection.prepare(`UPDATE "identity_deletion_operations" SET "state" = 'committed', "committed_at" = ?, "committed_receipt_json" = ? WHERE "operation_id" = ? AND "state" = 'queued'`).run(at, JSON.stringify(receipt), operationId).changes);
|
|
64
|
+
if (changed === 0)
|
|
65
|
+
throw new IdentityCustodyErrorV1('identity_operation_conflict');
|
|
66
|
+
}
|
|
67
|
+
async appendAttempt(attempt) {
|
|
68
|
+
if (attempt.receipt.transaction !== 'rolled_back')
|
|
69
|
+
throw new IdentityCustodyErrorV1('identity_material_invalid');
|
|
70
|
+
this.connection.prepare(`INSERT INTO "identity_deletion_attempts" ("attempt_id","operation_id","at","receipt_json") VALUES (?,?,?,?)`).run(attempt.attemptId, attempt.operationId, attempt.at, JSON.stringify(attempt.receipt));
|
|
71
|
+
}
|
|
72
|
+
latestReceipt = async (operationId) => {
|
|
73
|
+
const committed = await this.one((row) => row['committed_receipt_json'] ?? null, `SELECT "committed_receipt_json" FROM "identity_deletion_operations" WHERE "operation_id" = ? AND "state" = 'committed'`, [operationId]);
|
|
74
|
+
if (committed)
|
|
75
|
+
return JSON.parse(committed);
|
|
76
|
+
const attempt = await this.one((row) => String(row['receipt_json']), `SELECT "receipt_json" FROM "identity_deletion_attempts" WHERE "operation_id" = ? ORDER BY "at" DESC, "attempt_id" DESC LIMIT 1`, [operationId]);
|
|
77
|
+
return attempt ? JSON.parse(attempt) : null;
|
|
78
|
+
};
|
|
79
|
+
// -- Revocation outbox ----------------------------------------------------
|
|
80
|
+
async enqueueDelivery(delivery) {
|
|
81
|
+
this.connection.prepare(`INSERT INTO "identity_revocation_outbox" ("delivery_id","operation_id","step","subject_id","target_kind","target_ref","state","created_at","next_attempt_at","custody_ref","delivered_at","claim_owner","lease_until","claim_version","attempt_count") VALUES (?,?,?,?,?,?,'pending',?,?,?,NULL,NULL,NULL,0,0) ON CONFLICT ("delivery_id") DO NOTHING`).run(delivery.deliveryId, delivery.operationId, delivery.step, delivery.subjectId, delivery.targetKind, delivery.targetRef, delivery.createdAt, delivery.nextAttemptAt, delivery.custodyRef);
|
|
82
|
+
const existing = await this.findDelivery(delivery.deliveryId);
|
|
83
|
+
if (!existing || !sameRevocationTarget(existing, delivery))
|
|
84
|
+
throw new IdentityCustodyErrorV1('identity_operation_conflict');
|
|
85
|
+
}
|
|
86
|
+
findDelivery = (deliveryId) => this.one(decodeRevocationDelivery, `SELECT * FROM "identity_revocation_outbox" WHERE "delivery_id" = ?`, [deliveryId]);
|
|
87
|
+
async claimPending(now, owner, leaseUntil, limit) {
|
|
88
|
+
if (!Number.isInteger(limit) || limit <= 0)
|
|
89
|
+
throw new IdentityCustodyErrorV1('identity_material_invalid');
|
|
90
|
+
if (!(leaseUntil > now))
|
|
91
|
+
throw new IdentityCustodyErrorV1('identity_material_invalid');
|
|
92
|
+
const candidates = this.connection.prepare(`SELECT "delivery_id" FROM "identity_revocation_outbox" WHERE "state" = 'pending' AND "next_attempt_at" <= ? AND ("lease_until" IS NULL OR "lease_until" <= ?) ORDER BY "next_attempt_at", "created_at", "delivery_id" LIMIT ?`).all(now, now, limit);
|
|
93
|
+
const claimed = [];
|
|
94
|
+
for (const candidate of candidates) {
|
|
95
|
+
const deliveryId = String(candidate['delivery_id']);
|
|
96
|
+
const updated = await this.one((row) => ({ version: Number(row['claim_version']), row }), `UPDATE "identity_revocation_outbox" SET "claim_owner" = ?, "lease_until" = ?, "claim_version" = "claim_version" + 1, "attempt_count" = "attempt_count" + 1 WHERE "delivery_id" = ? AND "state" = 'pending' AND ("lease_until" IS NULL OR "lease_until" <= ?) RETURNING *`, [owner, leaseUntil, deliveryId, now]);
|
|
97
|
+
if (!updated)
|
|
98
|
+
continue;
|
|
99
|
+
claimed.push(decodeRevocationDelivery(updated.row));
|
|
100
|
+
}
|
|
101
|
+
return claimed;
|
|
102
|
+
}
|
|
103
|
+
async acknowledgeDelivery(deliveryId, owner, version, at) {
|
|
104
|
+
const changed = Number(this.connection.prepare(`UPDATE "identity_revocation_outbox" SET "state" = 'delivered', "delivered_at" = ?, "claim_owner" = NULL, "lease_until" = NULL WHERE "delivery_id" = ? AND "state" = 'pending' AND "claim_owner" = ? AND "claim_version" = ? AND "lease_until" > ?`).run(at, deliveryId, owner, version, at).changes);
|
|
105
|
+
if (changed === 0 && (await this.findDelivery(deliveryId))?.state !== 'delivered')
|
|
106
|
+
throw new IdentityCustodyErrorV1('identity_delivery_claim_conflict');
|
|
107
|
+
}
|
|
108
|
+
async releaseClaim(deliveryId, owner, version, nextAttemptAt) {
|
|
109
|
+
const changed = Number(this.connection.prepare(`UPDATE "identity_revocation_outbox" SET "claim_owner" = NULL, "lease_until" = NULL, "next_attempt_at" = ? WHERE "delivery_id" = ? AND "state" = 'pending' AND "claim_owner" = ? AND "claim_version" = ?`).run(nextAttemptAt, deliveryId, owner, version).changes);
|
|
110
|
+
if (changed === 0)
|
|
111
|
+
throw new IdentityCustodyErrorV1('identity_delivery_claim_conflict');
|
|
112
|
+
}
|
|
113
|
+
listPendingByOperation = async (operationId) => {
|
|
114
|
+
const rows = this.connection.prepare(`SELECT * FROM "identity_revocation_outbox" WHERE "operation_id" = ? ORDER BY "next_attempt_at", "created_at", "delivery_id"`).all(operationId);
|
|
115
|
+
return rows.map(decodeRevocationDelivery);
|
|
116
|
+
};
|
|
117
|
+
findLegacyConnectorTombstone = (sourceEventId) => this.one(decodeLegacyConnectorTombstone, `SELECT * FROM "identity_legacy_connector_tombstones" WHERE "source_event_id" = ?`, [sourceEventId]);
|
|
118
|
+
async insertLegacyConnectorTombstone(record) {
|
|
119
|
+
this.connection.prepare(`INSERT INTO "identity_legacy_connector_tombstones" ("source_event_id","connector_account_id","provider","subject_id","disposition","delivery_id","evidence_ref","imported_at") VALUES (?,?,?,?,?,?,?,?)`).run(record.sourceEventId, record.connectorAccountId, record.provider, record.subjectId, record.disposition, record.deliveryId, record.evidenceRef, record.importedAt);
|
|
120
|
+
}
|
|
121
|
+
// -- Import receipts ------------------------------------------------------
|
|
122
|
+
findImportReceipt = (migrationId) => this.one((row) => JSON.parse(String(row['receipt_json'])), `SELECT "receipt_json" FROM "identity_import_receipts" WHERE "migration_id" = ?`, [migrationId]);
|
|
123
|
+
async insertImportReceipt(migrationId, row, receipt) {
|
|
124
|
+
this.connection.prepare(`INSERT INTO "identity_import_receipts" ("migration_id","source_snapshot_ref","source_snapshot_digest","manifest_digest","contract_version","imported_at","receipt_json") VALUES (?,?,?,?,'1.1.0',?,?)`).run(migrationId, row.sourceSnapshotRef, row.sourceSnapshotDigest, row.manifestDigest, row.importedAt, JSON.stringify(receipt));
|
|
125
|
+
}
|
|
126
|
+
// -- Core account rows (import + deletion) --------------------------------
|
|
127
|
+
async insertAccountCore(record) {
|
|
128
|
+
try {
|
|
129
|
+
this.connection.prepare(`INSERT INTO "identity_user_accounts" ("user_id","email","account_status","global_role","created_at","updated_at") VALUES (?,?,?,?,?,?)`).run(record.userId, record.email, record.accountStatus, record.globalRole, record.createdAt, record.updatedAt);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof Error && error.message.includes('UNIQUE constraint failed: identity_user_accounts.email'))
|
|
133
|
+
throw new IdentityEmailCreateCollision();
|
|
134
|
+
if (error instanceof Error && error.message.includes('UNIQUE constraint failed'))
|
|
135
|
+
throw new IdentityCustodyErrorV1('identity_record_conflict');
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
findAccountCore = (userId) => this.one((row) => ({
|
|
140
|
+
userId: String(row['user_id']),
|
|
141
|
+
email: String(row['email']),
|
|
142
|
+
accountStatus: row['account_status'],
|
|
143
|
+
globalRole: row['global_role'],
|
|
144
|
+
createdAt: String(row['created_at']),
|
|
145
|
+
updatedAt: String(row['updated_at']),
|
|
146
|
+
}), `SELECT * FROM "identity_user_accounts" WHERE "user_id" = ?`, [userId]);
|
|
147
|
+
async deleteAccountCore(userId) {
|
|
148
|
+
this.connection.prepare(`DELETE FROM "identity_user_accounts" WHERE "user_id" = ?`).run(userId);
|
|
149
|
+
}
|
|
150
|
+
// -- Tenancy / workspace rows (import + deletion) --------------------------
|
|
151
|
+
async insertTenantCore(tenant) {
|
|
152
|
+
this.connection.prepare(`INSERT INTO "cm_tenants" ("tenant_id","slug","status","created_at") VALUES (?,?,?,?) ON CONFLICT("tenant_id") DO NOTHING`).run(tenant.tenantId, tenant.slug, tenant.status, tenant.createdAt);
|
|
153
|
+
}
|
|
154
|
+
async insertMembershipCore(membership) {
|
|
155
|
+
this.connection.prepare(`INSERT INTO "cm_tenant_memberships" ("user_id","tenant_id","status","tenant_role","decided_by","decided_at","updated_at") VALUES (?,?,?,?,?,?,?) ON CONFLICT("user_id","tenant_id") DO NOTHING`).run(membership.userId, membership.tenantId, membership.status, membership.tenantRole, membership.decidedBy ?? null, membership.decidedAt ?? null, membership.updatedAt);
|
|
156
|
+
}
|
|
157
|
+
async insertWorkspaceCore(workspace) {
|
|
158
|
+
this.connection.prepare(`INSERT INTO "cm_workspaces" ("workspace_id","tenant_id","repo_identity","aliases","enrolled_at") VALUES (?,?,?,?,?) ON CONFLICT("workspace_id") DO NOTHING`).run(workspace.workspaceId, workspace.tenantId, workspace.repoIdentity, JSON.stringify(workspace.aliases), workspace.enrolledAt);
|
|
159
|
+
}
|
|
160
|
+
async insertWorkspaceMemberCore(member) {
|
|
161
|
+
this.connection.prepare(`INSERT INTO "cm_workspace_members" ("workspace_id","user_id","role") VALUES (?,?,?) ON CONFLICT("workspace_id","user_id") DO NOTHING`).run(member.workspaceId, member.userId, member.role);
|
|
162
|
+
}
|
|
163
|
+
findTenantCore = (tenantId) => this.one((row) => ({ tenantId: String(row['tenant_id']), slug: String(row['slug']), status: String(row['status']), createdAt: String(row['created_at']) }), `SELECT * FROM "cm_tenants" WHERE "tenant_id" = ?`, [tenantId]);
|
|
164
|
+
findWorkspaceCore = (workspaceId) => this.one((row) => ({
|
|
165
|
+
workspaceId: String(row['workspace_id']),
|
|
166
|
+
tenantId: String(row['tenant_id']),
|
|
167
|
+
repoIdentity: row['repo_identity'] ?? null,
|
|
168
|
+
aliases: JSON.parse(String(row['aliases'] ?? '[]')),
|
|
169
|
+
enrolledAt: String(row['enrolled_at']),
|
|
170
|
+
}), `SELECT * FROM "cm_workspaces" WHERE "workspace_id" = ?`, [workspaceId]);
|
|
171
|
+
async setImportedSessionBase(sessionId, status, revokedAt) {
|
|
172
|
+
const changed = Number(this.connection.prepare(`UPDATE "identity_login_sessions" SET "status" = ?, "revoked_at" = ? WHERE "session_id" = ?`).run(status, revokedAt, sessionId).changes);
|
|
173
|
+
if (changed === 0)
|
|
174
|
+
throw new IdentityCustodyErrorV1('identity_material_missing');
|
|
175
|
+
}
|
|
176
|
+
async insertConsentCore(consent) {
|
|
177
|
+
this.connection.prepare(`INSERT INTO "cm_oauth_consents" ("consent_id","tenant_id","user_id","client_id","granted_at","revoked_at") VALUES (?,?,?,?,?,?) ON CONFLICT("consent_id") DO NOTHING`).run(consent.consentId, consent.tenantId, consent.userId, consent.clientId, consent.grantedAt, consent.revokedAt ?? null);
|
|
178
|
+
}
|
|
179
|
+
findConsentCore = (consentId) => this.one((row) => ({
|
|
180
|
+
consentId: String(row['consent_id']),
|
|
181
|
+
tenantId: String(row['tenant_id']),
|
|
182
|
+
userId: String(row['user_id']),
|
|
183
|
+
clientId: String(row['client_id']),
|
|
184
|
+
grantedAt: String(row['granted_at']),
|
|
185
|
+
...(row['revoked_at'] === null || row['revoked_at'] === undefined ? {} : { revokedAt: String(row['revoked_at']) }),
|
|
186
|
+
}), `SELECT * FROM "cm_oauth_consents" WHERE "consent_id" = ?`, [consentId]);
|
|
187
|
+
listConsentsForUserCore = async (userId) => {
|
|
188
|
+
const rows = this.connection.prepare(`SELECT * FROM "cm_oauth_consents" WHERE "user_id" = ? ORDER BY "granted_at", "consent_id"`).all(userId);
|
|
189
|
+
return rows.map((row) => ({
|
|
190
|
+
consentId: String(row['consent_id']),
|
|
191
|
+
tenantId: String(row['tenant_id']),
|
|
192
|
+
userId: String(row['user_id']),
|
|
193
|
+
clientId: String(row['client_id']),
|
|
194
|
+
grantedAt: String(row['granted_at']),
|
|
195
|
+
...(row['revoked_at'] === null || row['revoked_at'] === undefined ? {} : { revokedAt: String(row['revoked_at']) }),
|
|
196
|
+
}));
|
|
197
|
+
};
|
|
198
|
+
// -- Subject cleanup (CM-owned, both handlers) ------------------------------
|
|
199
|
+
listMembershipsForUser = async (userId) => {
|
|
200
|
+
const rows = this.connection.prepare(`SELECT "user_id","tenant_id","status","tenant_role","decided_by","decided_at","updated_at" FROM "cm_tenant_memberships" WHERE "user_id" = ?`).all(userId);
|
|
201
|
+
return rows.map((row) => ({
|
|
202
|
+
userId: String(row['user_id']),
|
|
203
|
+
tenantId: String(row['tenant_id']),
|
|
204
|
+
status: String(row['status']),
|
|
205
|
+
tenantRole: String(row['tenant_role']),
|
|
206
|
+
...(row['decided_by'] === null || row['decided_by'] === undefined ? {} : { decidedBy: String(row['decided_by']) }),
|
|
207
|
+
...(row['decided_at'] === null || row['decided_at'] === undefined ? {} : { decidedAt: String(row['decided_at']) }),
|
|
208
|
+
updatedAt: String(row['updated_at']),
|
|
209
|
+
}));
|
|
210
|
+
};
|
|
211
|
+
listWorkspaceIdsForUser = async (userId) => {
|
|
212
|
+
const rows = this.connection.prepare(`SELECT "workspace_id" FROM "cm_workspace_members" WHERE "user_id" = ?`).all(userId);
|
|
213
|
+
return rows.map((row) => String(row['workspace_id']));
|
|
214
|
+
};
|
|
215
|
+
countAdminsInWorkspace = async (workspaceId) => {
|
|
216
|
+
const row = this.connection.prepare(`SELECT COUNT(*) AS "count" FROM "cm_workspace_members" WHERE "workspace_id" = ? AND "role" = 'admin'`).get(workspaceId);
|
|
217
|
+
return Number(row['count'] ?? 0);
|
|
218
|
+
};
|
|
219
|
+
roleInWorkspace = async (workspaceId, userId) => {
|
|
220
|
+
const row = await this.one((r) => String(r['role']), `SELECT "role" FROM "cm_workspace_members" WHERE "workspace_id" = ? AND "user_id" = ?`, [workspaceId, userId]);
|
|
221
|
+
return row;
|
|
222
|
+
};
|
|
223
|
+
async deleteMembershipsForUser(userId) {
|
|
224
|
+
return Number(this.connection.prepare(`DELETE FROM "cm_tenant_memberships" WHERE "user_id" = ?`).run(userId).changes);
|
|
225
|
+
}
|
|
226
|
+
async deleteWorkspaceMembersForUser(userId) {
|
|
227
|
+
return Number(this.connection.prepare(`DELETE FROM "cm_workspace_members" WHERE "user_id" = ?`).run(userId).changes);
|
|
228
|
+
}
|
|
229
|
+
async deleteWorkspaceMembersIn(workspaceIds) {
|
|
230
|
+
let total = 0;
|
|
231
|
+
for (const workspaceId of workspaceIds) {
|
|
232
|
+
total += Number(this.connection.prepare(`DELETE FROM "cm_workspace_members" WHERE "workspace_id" = ?`).run(workspaceId).changes);
|
|
233
|
+
}
|
|
234
|
+
return total;
|
|
235
|
+
}
|
|
236
|
+
async deleteWorkspace(workspaceId) {
|
|
237
|
+
this.connection.prepare(`DELETE FROM "cm_workspaces" WHERE "workspace_id" = ?`).run(workspaceId);
|
|
238
|
+
}
|
|
239
|
+
async deleteConsentsForUser(userId) {
|
|
240
|
+
return Number(this.connection.prepare(`DELETE FROM "cm_oauth_consents" WHERE "user_id" = ?`).run(userId).changes);
|
|
241
|
+
}
|
|
242
|
+
async deleteConversationsForUser(userId) {
|
|
243
|
+
return Number(this.connection.prepare(`DELETE FROM "cm_identity_conversation_sessions" WHERE "user_id" = ?`).run(userId).changes);
|
|
244
|
+
}
|
|
245
|
+
async deleteProofsForUser(userId) {
|
|
246
|
+
return Number(this.connection.prepare(`DELETE FROM "identity_proofs" WHERE "user_id" = ?`).run(userId).changes);
|
|
247
|
+
}
|
|
248
|
+
async deleteDeviceCodesForUser(userId) {
|
|
249
|
+
return Number(this.connection.prepare(`DELETE FROM "identity_device_codes" WHERE "approved_user_id" = ?`).run(userId).changes);
|
|
250
|
+
}
|
|
251
|
+
async deleteSessionsForUser(userId) {
|
|
252
|
+
const ids = this.connection.prepare(`SELECT "session_id" FROM "identity_login_sessions" WHERE "user_id" = ?`).all(userId);
|
|
253
|
+
let total = 0;
|
|
254
|
+
for (const row of ids) {
|
|
255
|
+
const sessionId = String(row['session_id']);
|
|
256
|
+
this.connection.prepare(`DELETE FROM "identity_login_token_bindings" WHERE "session_id" = ?`).run(sessionId);
|
|
257
|
+
total += Number(this.connection.prepare(`DELETE FROM "identity_login_sessions" WHERE "session_id" = ?`).run(sessionId).changes);
|
|
258
|
+
}
|
|
259
|
+
return total;
|
|
260
|
+
}
|
|
261
|
+
/** Deletes every custody row bound to the subject; returns per-table counts. */
|
|
262
|
+
async cleanupCustodyForUser(userId, email) {
|
|
263
|
+
const counts = {};
|
|
264
|
+
const remove = (table, where, values) => {
|
|
265
|
+
const changed = Number(this.connection.prepare(`DELETE FROM "${table}" WHERE ${where}`).run(...values).changes);
|
|
266
|
+
counts[table] = (counts[table] ?? 0) + changed;
|
|
267
|
+
};
|
|
268
|
+
remove('identity_webauthn_credentials', '"user_id" = ?', [userId]);
|
|
269
|
+
remove('identity_email_registration_tickets', '"user_id" = ?', [userId]);
|
|
270
|
+
remove('identity_email_registration_tickets', '"user_id" IS NULL AND "email" = ?', [email]);
|
|
271
|
+
remove('identity_single_use_proofs', '"user_id" = ?', [userId]);
|
|
272
|
+
remove('identity_single_use_proofs', '"user_id" IS NULL AND "email" = ?', [email]);
|
|
273
|
+
remove('identity_social_links', '"user_id" = ?', [userId]);
|
|
274
|
+
remove('identity_account_profiles', '"user_id" = ?', [userId]);
|
|
275
|
+
return counts;
|
|
276
|
+
}
|
|
277
|
+
async revokePendingInvitationsForEmail(email) {
|
|
278
|
+
return Number(this.connection.prepare(`UPDATE "identity_invitation_digests" SET "status" = 'revoked', "revision" = "revision" + 1 WHERE "email" = ? AND "status" = 'pending'`).run(email).changes);
|
|
279
|
+
}
|
|
280
|
+
async detachInvitationConsumer(userId) {
|
|
281
|
+
return Number(this.connection.prepare(`UPDATE "identity_invitation_digests" SET "consumed_by_user_id" = NULL WHERE "consumed_by_user_id" = ?`).run(userId).changes);
|
|
282
|
+
}
|
|
283
|
+
async detachInvitationWorkspace(workspaceId) {
|
|
284
|
+
const pending = Number(this.connection.prepare(`UPDATE "identity_invitation_digests" SET "status" = 'revoked', "revision" = "revision" + 1 WHERE "workspace_id" = ? AND "status" = 'pending'`).run(workspaceId).changes);
|
|
285
|
+
const detached = Number(this.connection.prepare(`UPDATE "identity_invitation_digests" SET "workspace_id" = NULL WHERE "workspace_id" = ?`).run(workspaceId).changes);
|
|
286
|
+
return pending + detached;
|
|
287
|
+
}
|
|
288
|
+
/** Zero live identity/business references may remain after deletion. */
|
|
289
|
+
async assertNoLiveReferences(input) {
|
|
290
|
+
const count = (text, values) => {
|
|
291
|
+
const row = this.connection.prepare(text).get(...values);
|
|
292
|
+
return Number(row['count'] ?? 0);
|
|
293
|
+
};
|
|
294
|
+
const orphans = [];
|
|
295
|
+
const check = (name, text, values) => {
|
|
296
|
+
if (count(text, values) > 0)
|
|
297
|
+
orphans.push(name);
|
|
298
|
+
};
|
|
299
|
+
check('identity_proofs', `SELECT COUNT(*) AS "count" FROM "identity_proofs" WHERE "user_id" = ?`, [input.userId]);
|
|
300
|
+
check('identity_webauthn_credentials', `SELECT COUNT(*) AS "count" FROM "identity_webauthn_credentials" WHERE "user_id" = ?`, [input.userId]);
|
|
301
|
+
check('identity_single_use_proofs', `SELECT COUNT(*) AS "count" FROM "identity_single_use_proofs" WHERE "user_id" = ?`, [input.userId]);
|
|
302
|
+
check('identity_unbound_proofs', `SELECT COUNT(*) AS "count" FROM "identity_single_use_proofs" WHERE "user_id" IS NULL AND "email" = ?`, [input.accountEmail]);
|
|
303
|
+
check('identity_email_tickets', `SELECT COUNT(*) AS "count" FROM "identity_email_registration_tickets" WHERE "user_id" = ? OR ("user_id" IS NULL AND "email" = ?)`, [input.userId, input.accountEmail]);
|
|
304
|
+
check('identity_social_links', `SELECT COUNT(*) AS "count" FROM "identity_social_links" WHERE "user_id" = ?`, [input.userId]);
|
|
305
|
+
check('identity_login_sessions', `SELECT COUNT(*) AS "count" FROM "identity_login_sessions" WHERE "user_id" = ?`, [input.userId]);
|
|
306
|
+
check('identity_login_token_bindings', `SELECT COUNT(*) AS "count" FROM "identity_login_token_bindings" WHERE "session_id" IN (SELECT "session_id" FROM "identity_login_sessions" WHERE "user_id" = ?)`, [input.userId]);
|
|
307
|
+
check('identity_account_profiles', `SELECT COUNT(*) AS "count" FROM "identity_account_profiles" WHERE "user_id" = ?`, [input.userId]);
|
|
308
|
+
check('cm_tenant_memberships', `SELECT COUNT(*) AS "count" FROM "cm_tenant_memberships" WHERE "user_id" = ?`, [input.userId]);
|
|
309
|
+
check('cm_workspace_members', `SELECT COUNT(*) AS "count" FROM "cm_workspace_members" WHERE "user_id" = ?`, [input.userId]);
|
|
310
|
+
check('cm_oauth_consents', `SELECT COUNT(*) AS "count" FROM "cm_oauth_consents" WHERE "user_id" = ?`, [input.userId]);
|
|
311
|
+
check('cm_identity_conversation_sessions', `SELECT COUNT(*) AS "count" FROM "cm_identity_conversation_sessions" WHERE "user_id" = ?`, [input.userId]);
|
|
312
|
+
check('identity_device_codes', `SELECT COUNT(*) AS "count" FROM "identity_device_codes" WHERE "approved_user_id" = ?`, [input.userId]);
|
|
313
|
+
for (const workspaceId of input.deletedWorkspaceIds) {
|
|
314
|
+
check(`cm_workspace:${workspaceId}`, `SELECT COUNT(*) AS "count" FROM "cm_workspaces" WHERE "workspace_id" = ?`, [workspaceId]);
|
|
315
|
+
check(`cm_workspace_members:${workspaceId}`, `SELECT COUNT(*) AS "count" FROM "cm_workspace_members" WHERE "workspace_id" = ?`, [workspaceId]);
|
|
316
|
+
}
|
|
317
|
+
if (orphans.length > 0)
|
|
318
|
+
throw new IdentityCustodyErrorV1('identity_orphan_detected');
|
|
319
|
+
}
|
|
320
|
+
static rollbackReceipt(input) {
|
|
321
|
+
const order = ['login_sessions', 'remote_reader_sessions', 'connector_grants', 'tenant_memberships', 'agent_plane', 'purpose_grants', 'catalogue', 'account'];
|
|
322
|
+
const failedIndex = order.indexOf(input.failedStep);
|
|
323
|
+
const steps = order.map((step, index) => {
|
|
324
|
+
if (step === input.failedStep)
|
|
325
|
+
return { step, outcome: 'queued', detailCode: 'required_local_step_failed' };
|
|
326
|
+
if (index < failedIndex && input.completedBeforeFailure.has(step)) {
|
|
327
|
+
return { step, outcome: 'rolled_back', detailCode: 'transaction_rolled_back' };
|
|
328
|
+
}
|
|
329
|
+
return { step, outcome: 'queued', detailCode: 'not_attempted_after_failure' };
|
|
330
|
+
});
|
|
331
|
+
return {
|
|
332
|
+
contractVersion: '2.0.0', operationId: input.operationId, deliveryIds: [],
|
|
333
|
+
userId: input.userId,
|
|
334
|
+
mode: 'delete',
|
|
335
|
+
transaction: 'rolled_back',
|
|
336
|
+
resultCode: 'identity_cascade_rolled_back',
|
|
337
|
+
complete: false,
|
|
338
|
+
steps,
|
|
339
|
+
business: null,
|
|
340
|
+
cleanup: null,
|
|
341
|
+
at: input.at,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=custody-journal-sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-journal-sqlite.js","sourceRoot":"","sources":["../../../src/storage/identity/custody-journal-sqlite.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,uDAAuD;AAEvD,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAInE,MAAM,OAAO,oBAAoB;IACV;IAArB,YAAqB,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;IAAG,CAAC;IAEpC,GAAG,GAAG,KAAK,EAAK,MAA2C,EAAE,IAAY,EAAE,MAA8B,EAAqB,EAAE;QAC/I,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAwC,CAAC;QAChG,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC,CAAC;IAEF,4EAA4E;IAE5E,KAAK,CAAC,eAAe,CAAC,MAAc,EAAE,EAAU;QAC9C,IAAI,CAAC,UAAU,CAAC,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EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE;YACzE,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,aAAa;YAC1B,UAAU,EAAE,8BAA8B;YAC1C,QAAQ,EAAE,KAAK;YACf,KAAK;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,EAAE,EAAE,KAAK,CAAC,EAAE;SACb,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IdentitySubjectLifecyclePortV1 } from '../../identity-contracts/custody-operations.js';
|
|
2
|
+
import type { CustodyOpHost } from './custody-host.js';
|
|
3
|
+
export declare const subjectLifecycle: (host: CustodyOpHost) => IdentitySubjectLifecyclePortV1;
|
|
4
|
+
//# sourceMappingURL=custody-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/storage/identity/custody-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAIrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,eAAO,MAAM,gBAAgB,SAAU,aAAa,KAAG,8BA+BtD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IdentityCustodyErrorV1 } from '../../identity-contracts/custody-errors.js';
|
|
2
|
+
import { IdentityNotFoundError } from '../../identity-contracts/errors.js';
|
|
3
|
+
import { assertCanonicalEmailV1 } from '../../identity/custody-crypto.js';
|
|
4
|
+
import { boundIdentitySql } from './custody-transaction-ports.js';
|
|
5
|
+
export const subjectLifecycle = (host) => {
|
|
6
|
+
const sql = boundIdentitySql(host);
|
|
7
|
+
const lock = async (kind, id) => {
|
|
8
|
+
if (host.profile === 'postgres')
|
|
9
|
+
await sql.query('SELECT pg_advisory_xact_lock(hashtextextended(?, 0))', [JSON.stringify([kind, id])]);
|
|
10
|
+
};
|
|
11
|
+
const checkFence = async (userId) => {
|
|
12
|
+
const [fence] = await sql.query(`SELECT retired_at FROM ${sql.table('identity_subject_fences')} WHERE user_id = ?`, [userId]);
|
|
13
|
+
if (fence?.retired_at != null)
|
|
14
|
+
throw new IdentityCustodyErrorV1('identity_subject_retired');
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
register: async (account, profile) => {
|
|
18
|
+
assertCanonicalEmailV1(account.email);
|
|
19
|
+
if (!account.userId || profile.userId !== account.userId)
|
|
20
|
+
throw new IdentityCustodyErrorV1('identity_material_invalid');
|
|
21
|
+
await lock('subject', account.userId);
|
|
22
|
+
await checkFence(account.userId);
|
|
23
|
+
await lock('email', account.email);
|
|
24
|
+
await host.journal.insertAccountCore(account);
|
|
25
|
+
await host.journal.ensureLiveFence(account.userId, account.createdAt);
|
|
26
|
+
await host.stores.profiles.put(profile);
|
|
27
|
+
},
|
|
28
|
+
updateEmail: async (userId, email, at) => {
|
|
29
|
+
assertCanonicalEmailV1(email);
|
|
30
|
+
await lock('subject', userId);
|
|
31
|
+
await checkFence(userId);
|
|
32
|
+
const account = await host.journal.findAccountCore(userId);
|
|
33
|
+
if (!account)
|
|
34
|
+
throw new IdentityNotFoundError('user', userId);
|
|
35
|
+
for (const key of [...new Set([account.email, email])].sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b))))
|
|
36
|
+
await lock('email', key);
|
|
37
|
+
await sql.query(`UPDATE ${sql.table('identity_user_accounts')} SET email = ?, updated_at = ? WHERE user_id = ? RETURNING user_id`, [email, at, userId]);
|
|
38
|
+
return { ...account, email, updatedAt: at };
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=custody-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-lifecycle.js","sourceRoot":"","sources":["../../../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AAC,wBAAwB,CAAC,oEAAoE,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;YACxJ,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { BoundLoginSessionStoreV1, DigestInvitationStoreV1, EmailRegistrationTicketStoreV1, IdentityAccountProfileStoreV1, IdentityCustodyStoresV1, IdentityRunOptionsV1, IdentityHostRunOptionsV1, IdentityTransactionV1, IdentityUnitOfWorkV1, SingleUseProofStoreV1, SocialIdentityStoreV1, WebAuthnCredentialStoreV1 } from '../../identity-contracts/custody.js';
|
|
2
|
+
import type { InjectedPgDriver, PgSession } from '../postgres/protocol.js';
|
|
3
|
+
import { type IdentityTableName } from './schema.js';
|
|
4
|
+
import { type IdentityCustodySchemaReceiptV1 } from './custody-shared.js';
|
|
5
|
+
import { PostgresCustodyJournal } from './custody-journal-postgres.js';
|
|
6
|
+
export declare const CUSTODY_TX_DEADLINE_MS = 5000;
|
|
7
|
+
export interface PostgresCustodyOptions {
|
|
8
|
+
readonly driver: InjectedPgDriver;
|
|
9
|
+
readonly schema: string;
|
|
10
|
+
readonly deadlineMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const custodyTable: (schema: string, table: IdentityTableName) => string;
|
|
13
|
+
export declare const requireWriteOptions: (options: IdentityRunOptionsV1) => void;
|
|
14
|
+
/** Transaction-scoped custody bundle: all SQL runs on the bound session. */
|
|
15
|
+
export declare class PostgresCustodyTx implements IdentityCustodyStoresV1 {
|
|
16
|
+
readonly schema: string;
|
|
17
|
+
readonly session: PgSession;
|
|
18
|
+
readonly subjects: IdentityCustodyStoresV1['subjects'];
|
|
19
|
+
readonly profiles: IdentityAccountProfileStoreV1;
|
|
20
|
+
readonly credentials: WebAuthnCredentialStoreV1;
|
|
21
|
+
readonly singleUseProofs: SingleUseProofStoreV1;
|
|
22
|
+
readonly emailTickets: EmailRegistrationTicketStoreV1;
|
|
23
|
+
readonly invitations: DigestInvitationStoreV1;
|
|
24
|
+
readonly sessions: BoundLoginSessionStoreV1;
|
|
25
|
+
readonly social: SocialIdentityStoreV1;
|
|
26
|
+
constructor(schema: string, session: PgSession);
|
|
27
|
+
readonly t: (table: IdentityTableName) => string;
|
|
28
|
+
private readonly one;
|
|
29
|
+
private readonly all;
|
|
30
|
+
private readonly casCounter;
|
|
31
|
+
private readonly proofColumns;
|
|
32
|
+
private readonly proofValues;
|
|
33
|
+
private readonly insertProof;
|
|
34
|
+
private readonly findProof;
|
|
35
|
+
private readonly findChallengeRow;
|
|
36
|
+
private readonly findLatestEmailCodeRow;
|
|
37
|
+
private readonly findMagicLinkRow;
|
|
38
|
+
private readonly consumeProof;
|
|
39
|
+
private readonly exchangeCode;
|
|
40
|
+
private readonly consumeTicket;
|
|
41
|
+
private readonly consumeInvitation;
|
|
42
|
+
private readonly baseSessionColumns;
|
|
43
|
+
private readonly readBoundSession;
|
|
44
|
+
private readonly insertBoundSession;
|
|
45
|
+
private readonly findBoundSession;
|
|
46
|
+
private readonly findBoundSessionByHash;
|
|
47
|
+
private readonly listBoundSessions;
|
|
48
|
+
private readonly rotateBoundSession;
|
|
49
|
+
private readonly revokeBoundSession;
|
|
50
|
+
}
|
|
51
|
+
export interface PostgresIdentityBindingV1<H> {
|
|
52
|
+
readonly transactionId: string;
|
|
53
|
+
readonly hostTransaction: H;
|
|
54
|
+
readonly session: PgSession;
|
|
55
|
+
readonly readOnly: boolean;
|
|
56
|
+
}
|
|
57
|
+
export type PostgresCustodyBindingV1<H> = PostgresIdentityBindingV1<H>;
|
|
58
|
+
export interface PostgresIdentityHostV1<H> {
|
|
59
|
+
runSerializable<T>(options: IdentityHostRunOptionsV1, operation: (binding: PostgresCustodyBindingV1<H>) => Promise<T>): Promise<T>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Combined custody handle: the transaction-scoped stores plus the deletion
|
|
63
|
+
* journal/outbox over the same session. One object joins every callback.
|
|
64
|
+
*/
|
|
65
|
+
export declare class PostgresCustodyHandle extends PostgresCustodyTx {
|
|
66
|
+
readonly journal: PostgresCustodyJournal;
|
|
67
|
+
constructor(schema: string, session: PgSession);
|
|
68
|
+
get stores(): IdentityCustodyStoresV1;
|
|
69
|
+
get profile(): 'postgres';
|
|
70
|
+
get raw(): PgSession;
|
|
71
|
+
}
|
|
72
|
+
/** Host-owned serializable unit of work over one control schema. */
|
|
73
|
+
export declare const createPostgresIdentityUnitOfWorkV1: <H>(input: {
|
|
74
|
+
readonly schema: string;
|
|
75
|
+
readonly host: PostgresIdentityHostV1<H>;
|
|
76
|
+
readonly maxAttempts?: number;
|
|
77
|
+
}) => IdentityUnitOfWorkV1<H>;
|
|
78
|
+
export declare const createPostgresIdentityHostV1: (options: PostgresCustodyOptions) => PostgresIdentityHostV1<PostgresCustodyHandle>;
|
|
79
|
+
/** Idempotent custody DDL; safe to call concurrently. */
|
|
80
|
+
export declare const applyPostgresIdentityCoreSchemaIfNeeded: (options: PostgresCustodyOptions) => Promise<void>;
|
|
81
|
+
/** Standalone per-method custody stores for direct store tests. */
|
|
82
|
+
export declare const createPostgresCustodyStores: (options: PostgresCustodyOptions) => IdentityCustodyStoresV1;
|
|
83
|
+
/** Applies the custody asset on the caller's active binding; never begins or commits. */
|
|
84
|
+
export declare const applyPostgresIdentityCustodySchemaV1: (input: {
|
|
85
|
+
readonly schema: string;
|
|
86
|
+
readonly binding: PostgresCustodyBindingV1<unknown>;
|
|
87
|
+
readonly expectedAssetSha256: string;
|
|
88
|
+
readonly appliedAt: string;
|
|
89
|
+
}) => Promise<IdentityCustodySchemaReceiptV1>;
|
|
90
|
+
export declare const bindPostgresIdentityTransactionV1: <H>(input: {
|
|
91
|
+
readonly schema: string;
|
|
92
|
+
readonly binding: PostgresIdentityBindingV1<H>;
|
|
93
|
+
}) => IdentityTransactionV1<H>;
|
|
94
|
+
/** V1 factory name for the standalone PostgreSQL custody stores. */
|
|
95
|
+
export declare const createPostgresIdentityCustodyStoresV1: (options: PostgresCustodyOptions) => IdentityCustodyStoresV1;
|
|
96
|
+
//# sourceMappingURL=custody-postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-postgres.d.ts","sourceRoot":"","sources":["../../../src/storage/identity/custody-postgres.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,wBAAwB,EAExB,uBAAuB,EAGvB,8BAA8B,EAE9B,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EAIpB,qBAAqB,EAErB,qBAAqB,EAGrB,yBAAyB,EAE1B,MAAM,qCAAqC,CAAC;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAY,MAAM,yBAAyB,CAAC;AAGrF,OAAO,EAA4D,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,EAIL,KAAK,8BAA8B,EACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAWvE,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,YAAY,WAAY,MAAM,SAAS,iBAAiB,KAAG,MAC9B,CAAC;AAc3C,eAAO,MAAM,mBAAmB,YAAa,oBAAoB,KAAG,IAOnE,CAAC;AAIF,4EAA4E;AAC5E,qBAAa,iBAAkB,YAAW,uBAAuB;IAW7D,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS;IAX7B,QA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