@tearleads/client-sdk 0.1.226 → 0.1.231
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/Tearleads.js +1 -1
- package/Tearleads.js.map +1 -1
- package/client/containerContents/documentDiscovery.js +4 -1
- package/client/containerContents/documentDiscovery.js.map +1 -1
- package/client/containerContents/index.d.ts +1 -1
- package/client/containerContents/index.js +4 -2
- package/client/containerContents/index.js.map +1 -1
- package/client/deviceFirst/index.js +1 -1
- package/client/deviceFirst/index.js.map +1 -1
- package/client/documents/index.js +6 -2
- package/client/documents/index.js.map +1 -1
- package/client/identity/index.js +1 -1
- package/client/identity/index.js.map +1 -1
- package/client/identity/userIdentities.d.ts +1 -1
- package/client/identity/userIdentities.js +1 -1
- package/client/identity/userIdentities.js.map +1 -1
- package/client/index.d.ts +2 -0
- package/client/index.js +2 -0
- package/client/index.js.map +1 -1
- package/client/organizations/index.js +1 -1
- package/client/organizations/index.js.map +1 -1
- package/client/organizations/organizationMemberships.d.ts +1 -1
- package/client/organizations/organizationMemberships.js +1 -1
- package/client/organizations/organizationMemberships.js.map +1 -1
- package/client/organizations/principalMutations.js +1 -1
- package/client/organizations/principalMutations.js.map +1 -1
- package/client/organizations/recipientAdmission.d.ts +1 -1
- package/client/organizations/recipientAdmission.js +1 -1
- package/client/organizations/recipientAdmission.js.map +1 -1
- package/client/runtime/apiVersion.js +1 -1
- package/client/runtime/apiVersion.js.map +1 -1
- package/client/runtime/containerContentsRuntime.d.ts +8 -0
- package/client/runtime/containerContentsRuntime.js +14 -0
- package/client/runtime/containerContentsRuntime.js.map +1 -0
- package/client/runtime/database.js +1 -1
- package/client/runtime/database.js.map +1 -1
- package/client/runtime/documentsRuntime.d.ts +5 -0
- package/client/runtime/documentsRuntime.js +10 -0
- package/client/runtime/documentsRuntime.js.map +1 -0
- package/client/runtime/events.js +1 -1
- package/client/runtime/events.js.map +1 -1
- package/client/runtime/network.js +1 -1
- package/client/runtime/network.js.map +1 -1
- package/client/runtime/runtimeIdentityResolution.js +1 -1
- package/client/runtime/runtimeIdentityResolution.js.map +1 -1
- package/client/runtime/syncBillingGate.js +1 -1
- package/client/runtime/syncBillingGate.js.map +1 -1
- package/client/runtime/workflowRuntime.d.ts +5 -2
- package/client/runtime/workflowRuntime.js +6 -2
- package/client/runtime/workflowRuntime.js.map +1 -1
- package/client/securityIncidents/index.d.ts +1 -1
- package/client/securityIncidents/index.js +2 -2
- package/client/securityIncidents/index.js.map +1 -1
- package/client/session/index.js +1 -1
- package/client/session/index.js.map +1 -1
- package/client/session/sessionLoginRefusal.js +1 -1
- package/client/session/sessionLoginRefusal.js.map +1 -1
- package/client/session/sessionRootAuthority.js +1 -1
- package/client/session/sessionRootAuthority.js.map +1 -1
- package/data/documents/shared/projection/freshProjectionRetry.js +1 -1
- package/data/documents/shared/projection/freshProjectionRetry.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js +1 -1
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/heldContainerHeads.js.map +1 -0
- package/data/keyingProjectionVerification/error.js +1 -57
- package/data/keyingProjectionVerification/error.js.map +1 -1
- package/data/persistence/container-contents/documentContainerProjectionPersistence.d.ts +6 -2
- package/data/persistence/container-contents/documentContainerProjectionPersistence.js +10 -1
- package/data/persistence/container-contents/documentContainerProjectionPersistence.js.map +1 -1
- package/data/persistence/documents/documentDeletionPort.d.ts +28 -0
- package/data/persistence/documents/documentDeletionPort.js +2 -0
- package/data/persistence/documents/documentDeletionPort.js.map +1 -0
- package/data/persistence/documents/documentsPersistence.d.ts +1 -0
- package/data/persistence/documents/documentsPersistence.js.map +1 -1
- package/data/persistence/documents/internal/documentDeletionPersistence.js +7 -7
- package/data/persistence/documents/internal/documentDeletionPersistence.js.map +1 -1
- package/data/persistence/documents/types.d.ts +2 -15
- package/data/persistence/documents/types.js.map +1 -1
- package/data/principals/organizationPolicyRequest.d.ts +12 -0
- package/data/principals/organizationPolicyRequest.js +71 -0
- package/data/principals/organizationPolicyRequest.js.map +1 -0
- package/{workflows/organizations/principalPolicy → data/principals}/principalPolicyRequest.d.ts +3 -3
- package/{workflows/organizations/principalPolicy → data/principals}/principalPolicyRequest.js +3 -3
- package/data/principals/principalPolicyRequest.js.map +1 -0
- package/{workflows/principals/policyVerification.js → data/principals/principalPolicyVerification.js} +4 -4
- package/data/principals/principalPolicyVerification.js.map +1 -0
- package/data/shared/securityIncidents.d.ts +18 -1
- package/data/shared/securityIncidents.js +58 -1
- package/data/shared/securityIncidents.js.map +1 -1
- package/index.d.ts +5 -5
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/stores/container-contents/hydration/backgroundHydration.js +1 -1
- package/stores/container-contents/hydration/backgroundHydration.js.map +1 -1
- package/stores/container-contents/operations/reportShareFailure.js +1 -1
- package/stores/container-contents/operations/reportShareFailure.js.map +1 -1
- package/stores/container-contents/operations/shareOperations.js +1 -1
- package/stores/container-contents/operations/shareOperations.js.map +1 -1
- package/stores/container-contents/systemContainers/systemContainerHydration.js +1 -1
- package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -1
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js +1 -1
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -1
- package/stores/documents/documentStore/persistence.js +1 -0
- package/stores/documents/documentStore/persistence.js.map +1 -1
- package/stores/documents/documentStore/sync/index.js +1 -1
- package/stores/documents/documentStore/sync/index.js.map +1 -1
- package/stores/documents/documentStore/sync/syncRequest.js +1 -0
- package/stores/documents/documentStore/sync/syncRequest.js.map +1 -1
- package/workflows/blobs/hydration/hydrationResults.js +2 -1
- package/workflows/blobs/hydration/hydrationResults.js.map +1 -1
- package/workflows/blobs/verification/attachmentDecryptor.js +1 -1
- package/workflows/blobs/verification/attachmentDecryptor.js.map +1 -1
- package/workflows/container-contents/container-state/create/createAdoption.js +1 -1
- package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -1
- package/workflows/container-contents/container-state/create/createIntentSync.js +1 -1
- package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -1
- package/workflows/container-contents/container-state/move/moveIntentSync.js +1 -1
- package/workflows/container-contents/container-state/move/moveIntentSync.js.map +1 -1
- package/workflows/container-contents/container-state/organizationHost.d.ts +54 -0
- package/workflows/container-contents/container-state/organizationHost.js +2 -0
- package/workflows/container-contents/container-state/organizationHost.js.map +1 -0
- package/workflows/container-contents/container-state/purge/purgeTreeScope.js +1 -1
- package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -1
- package/workflows/container-contents/container-state/remote.js +2 -4
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/share/groupGrantVerification.js +1 -2
- package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -1
- package/workflows/container-contents/container-state/share/groupShareEpoch.js +1 -2
- package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -1
- package/workflows/container-contents/container-state/types.js.map +1 -1
- package/workflows/container-contents/documentLinks/index.js +1 -1
- package/workflows/container-contents/documentLinks/index.js.map +1 -1
- package/workflows/container-contents/documentMove/documentMoveIntentSync.js +1 -1
- package/workflows/container-contents/documentMove/documentMoveIntentSync.js.map +1 -1
- package/workflows/container-contents/index.d.ts +1 -0
- package/workflows/container-contents/index.js.map +1 -1
- package/workflows/container-contents/info/documentInfo.d.ts +1 -1
- package/workflows/container-contents/info/documentInfo.js +1 -1
- package/workflows/container-contents/info/documentInfo.js.map +1 -1
- package/workflows/container-contents/metadata/metadataSyncErrors.js +1 -1
- package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
- package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js +1 -2
- package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -1
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js +3 -4
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -1
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js +1 -1
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -1
- package/workflows/container-contents/remoteHydration/types.d.ts +1 -1
- package/workflows/container-contents/remoteHydration/types.js.map +1 -1
- package/workflows/container-contents/runtime.d.ts +5 -0
- package/workflows/container-contents/runtime.js +3 -0
- package/workflows/container-contents/runtime.js.map +1 -1
- package/workflows/container-contents/syncPause/documentRemoval.js +2 -0
- package/workflows/container-contents/syncPause/documentRemoval.js.map +1 -1
- package/workflows/container-contents/tombstones/documentPurge.js +5 -2
- package/workflows/container-contents/tombstones/documentPurge.js.map +1 -1
- package/workflows/container-contents/tombstones/documentTombstoneEvidence.js +1 -1
- package/workflows/container-contents/tombstones/documentTombstoneEvidence.js.map +1 -1
- package/workflows/containers/child/mutationSubmit.js +1 -1
- package/workflows/containers/child/mutationSubmit.js.map +1 -1
- package/workflows/containers/child/recite.js +1 -1
- package/workflows/containers/child/recite.js.map +1 -1
- package/workflows/containers/child/recitePlan.js.map +1 -1
- package/workflows/containers/rematerialization/acknowledgePrincipalContainerRematerialization.js +1 -1
- package/workflows/containers/rematerialization/acknowledgePrincipalContainerRematerialization.js.map +1 -1
- package/workflows/documents/documentMutationCommit.d.ts +2 -1
- package/workflows/documents/documentMutationCommit.js +1 -0
- package/workflows/documents/documentMutationCommit.js.map +1 -1
- package/workflows/documents/documentPersistGuards.js +2 -1
- package/workflows/documents/documentPersistGuards.js.map +1 -1
- package/workflows/documents/purge/persistedDocumentRemoval.d.ts +2 -1
- package/workflows/documents/purge/persistedDocumentRemoval.js +2 -2
- package/workflows/documents/purge/persistedDocumentRemoval.js.map +1 -1
- package/workflows/documents/runtime.d.ts +5 -0
- package/workflows/documents/runtime.js +1 -0
- package/workflows/documents/runtime.js.map +1 -1
- package/workflows/documents/sync/syncSubmittedResult.js +1 -1
- package/workflows/documents/sync/syncSubmittedResult.js.map +1 -1
- package/workflows/documents/syncPlan/syncContentKeys.js +1 -1
- package/workflows/documents/syncPlan/syncContentKeys.js.map +1 -1
- package/workflows/organizations/containerContentsHost.js +14 -0
- package/workflows/organizations/containerContentsHost.js.map +1 -0
- package/workflows/organizations/groupMetadata/groupMetadataAccess.d.ts +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataAccess.js.map +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataRuntime.d.ts +1 -1
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js +1 -1
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js.map +1 -1
- package/workflows/organizations/groupNames/groupMembershipName.d.ts +1 -1
- package/workflows/organizations/groupNames/groupMembershipName.js +1 -1
- package/workflows/organizations/groupNames/groupMembershipName.js.map +1 -1
- package/workflows/organizations/groupNames/groupNameUniqueness.js +2 -2
- package/workflows/organizations/groupNames/groupNameUniqueness.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyRequests.js +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyRequests.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyVerification.js +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyVerification.js.map +1 -1
- package/workflows/organizations/groupShare/currentShareGrantMutation.js +1 -1
- package/workflows/organizations/groupShare/currentShareGrantMutation.js.map +1 -1
- package/workflows/organizations/groupShare/currentSharePrincipalPolicy.d.ts +1 -1
- package/workflows/organizations/groupShare/currentSharePrincipalPolicy.js +1 -1
- package/workflows/organizations/groupShare/currentSharePrincipalPolicy.js.map +1 -1
- package/workflows/organizations/groupShare/sharePrincipalPolicy.d.ts +1 -1
- package/workflows/organizations/groupShare/sharePrincipalPolicy.js +2 -2
- package/workflows/organizations/groupShare/sharePrincipalPolicy.js.map +1 -1
- package/workflows/organizations/groupShare/shareWithGroup.d.ts +1 -1
- package/workflows/organizations/groupShare/shareWithGroup.js.map +1 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js +1 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js.map +1 -1
- package/workflows/organizations/groups/groupCreation.js +1 -1
- package/workflows/organizations/groups/groupCreation.js.map +1 -1
- package/workflows/organizations/groups/organizationGroupDirectory.js.map +1 -1
- package/workflows/organizations/policyHistory/loadPolicyHistoryDetails.js +1 -1
- package/workflows/organizations/policyHistory/loadPolicyHistoryDetails.js.map +1 -1
- package/workflows/organizations/principalPolicy/index.d.ts +2 -2
- package/workflows/organizations/principalPolicy/index.js +1 -1
- package/workflows/organizations/principalPolicy/index.js.map +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js.map +1 -1
- package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js +1 -1
- package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js.map +1 -1
- package/workflows/principals/externalAdminPolicy.js +1 -1
- package/workflows/principals/externalAdminPolicy.js.map +1 -1
- package/workflows/principals/historyRecovery/principalHistoryPageAppend.js +1 -1
- package/workflows/principals/historyRecovery/principalHistoryPageAppend.js.map +1 -1
- package/workflows/principals/policyCache/index.d.ts +1 -1
- package/workflows/principals/policyCache/index.js +3 -2
- package/workflows/principals/policyCache/index.js.map +1 -1
- package/workflows/principals/policyCache/principalPolicyCacheValidation.js +1 -1
- package/workflows/principals/policyCache/principalPolicyCacheValidation.js.map +1 -1
- package/workflows/principals/policyCache/principalPolicyOrganizationScope.js +1 -1
- package/workflows/principals/policyCache/principalPolicyOrganizationScope.js.map +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js.map +1 -1
- package/workflows/principals/runtimePolicyRecovery.d.ts +1 -1
- package/workflows/principals/runtimePolicyRecovery.js +1 -1
- package/workflows/principals/runtimePolicyRecovery.js.map +1 -1
- package/workflows/principals/runtimeProjectionPolicyRecovery.js +1 -1
- package/workflows/principals/runtimeProjectionPolicyRecovery.js.map +1 -1
- package/workflows/registration/index.d.ts +2 -1
- package/workflows/registration/index.js +1 -1
- package/workflows/registration/index.js.map +1 -1
- package/workflows/registration/organizationProvisioning.d.ts +1 -12
- package/workflows/registration/organizationProvisioning.js +2 -70
- package/workflows/registration/organizationProvisioning.js.map +1 -1
- package/workflows/registration/persistRegistrationBootstrap.js +2 -0
- package/workflows/registration/persistRegistrationBootstrap.js.map +1 -1
- package/data/containers/shared/heldContainerHeads.js.map +0 -1
- package/workflows/organizations/principalPolicy/principalPolicyRequest.js.map +0 -1
- package/workflows/principals/policyVerification.js.map +0 -1
- /package/data/{containers/shared → keyingProjectionVerification/checkpoints}/heldContainerHeads.js +0 -0
- /package/{client/runtime → data/shared}/listenerSet.js +0 -0
- /package/{client/runtime → data/shared}/listenerSet.js.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipientAdmission.js","sourceRoot":"","sources":["recipientAdmission.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAE/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAE9F,OAAO,EAGL,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,GAGzB,MAAM,kEAAkE,CAAC;AAE1E,OAAO,EACL,2BAA2B,EAC3B,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAOrE,+EAA+E;AAC/E,MAAM,mBAAoB,SAAQ,KAAK;CAAG;AAE1C,KAAK,UAAU,SAAS,CACtB,SAAuE;IAEvE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SAAS,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type {\n ContainerAccessLevel,\n ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport { computeUserIdentityBundleFingerprint } from \"@tearleads/crypto\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { runWithSecurityIncidentReporting } from \"../../data/keyingProjectionVerification/error\";\nimport { principalHeadMatchesReference } from \"../../data/principalContracts/organizationAuthorityDescriptor\";\nimport { ProjectionDependencyUnavailableError } from \"../../data/shared/dependencyUnavailable\";\nimport type { SecurityIncidentReporter } from \"../../data/shared/securityIncidents\";\nimport { DatabaseUnavailableError } from \"../../data/sqlite/availability/databaseUnavailable\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n type StagedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n UnverifiedUserIdentityError,\n} from \"../../data/trustedUserIdentity\";\nimport {\n isRosterVouchedRecipient,\n type RosterAdmissionEvidence,\n type RosterAdmissionPin,\n} from \"../../workflows/organizations/memberships/rosterVouchedAdmission\";\nimport type { InternalRuntime } from \"../runtime/workflowRuntime\";\nimport {\n currentOrganizationMutation,\n currentOrganizationSigningMutation,\n} from \"./principalMutationScope\";\nimport { createRosterAdmissionEvidence } from \"./rosterAdmissionEvidence\";\n\nexport { loadServedStateEnvelopes } from \"./rosterAdmissionEvidence\";\n\ntype AdmissionRuntimeService = Pick<\n InternalRuntime,\n \"identityLinks\" | \"sessionGeneration\" | \"workflowInput\"\n>;\n\n/** Thrown inside the staged scope so a refused recipient publishes nothing. */\nclass RecipientNotVouched extends Error {}\n\nasync function stagedPin(\n candidate: NonNullable<Awaited<ReturnType<StagedUserIdentityResolver>>>,\n): Promise<RosterAdmissionPin> {\n return {\n encapsulationKeyFingerprint: candidate.encapsulationKeyFingerprint,\n identityBundleFingerprint:\n await computeUserIdentityBundleFingerprint(candidate),\n signingKeyFingerprint: candidate.signingKeyFingerprint,\n verified: false,\n };\n}\n\n/**\n * Admit against the server's first answers without pinning them: the\n * recipient's answer, and that of any historical signer the chain needs but\n * this device has not pinned (a departed admin seen only in older Members\n * states), are staged. Each is checked against its committed Members bundle,\n * and all are pinned as observed only once the signed roster vouches for the\n * recipient's exact identity bundle. A substituted answer leaves no pin, so a\n * corrected retry or the honest identity link still succeeds.\n */\nasync function isStagedRosterVouchedRecipient(\n userId: string,\n evidence: RosterAdmissionEvidence,\n resolver: TrustedUserIdentityResolver,\n assertCurrent: (() => void) | undefined,\n): Promise<boolean> {\n // Without staging, admit only a durable pin: never pin before the roster.\n if (!resolver.withPinnedIdentities)\n return isRosterVouchedRecipient(userId, evidence);\n try {\n return await resolver.withPinnedIdentities(\n [userId],\n async (resolve) => {\n const candidate = await resolve(userId);\n const vouched =\n candidate !== null &&\n (await isRosterVouchedRecipient(userId, {\n ...evidence,\n loadPin: async (id) => {\n const pin = await evidence.loadPin(id);\n if (pin) return pin;\n const staged = id === userId ? candidate : await resolve(id);\n return staged ? stagedPin(staged) : null;\n },\n }));\n if (!vouched) throw new RecipientNotVouched();\n return true;\n },\n { publish: true, assertCurrent },\n );\n } catch (error) {\n if (error instanceof RecipientNotVouched) return false;\n throw error;\n }\n}\n\n/**\n * Whether the signed roster vouches for `userId` on this device, for exactly\n * the domain-scoped signing and encapsulation identity bundle the server\n * serves. Served material that fails verification is recorded as a security\n * incident before the error propagates.\n */\nexport function isReportedRosterVouchedRecipient(input: {\n readonly evidence: RosterAdmissionEvidence;\n readonly organizationId: string;\n readonly reportSecurityIncident: SecurityIncidentReporter;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n readonly userId: string;\n /** The admission's lifetime, checked inside every pin write. */\n readonly assertCurrent?: (() => void) | undefined;\n}): Promise<boolean> {\n const { evidence, userId } = input;\n return runWithSecurityIncidentReporting(\n input.reportSecurityIncident,\n {\n objectId: userId,\n objectKind: \"user\",\n operation: \"container.share.roster_vouch\",\n organizationId: input.organizationId,\n },\n () =>\n isStagedRosterVouchedRecipient(\n userId,\n evidence,\n input.resolveTrustedUserIdentity,\n input.assertCurrent,\n ),\n );\n}\n\ntype RecipientAdmission =\n | { readonly status: \"verified\" }\n | { readonly status: \"roster\"; readonly head: ReferencedPrincipalHead };\n\nasync function requireOrganizationRecipient(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n): Promise<RecipientAdmission> {\n try {\n await service.identityLinks.requireVerified(userId, admittingExecSql);\n return { status: \"verified\" };\n } catch (error) {\n const runtime = service.workflowInput();\n const organizationId = runtime.auth.organizationId;\n if (!(error instanceof UnverifiedUserIdentityError) || !organizationId)\n throw error;\n const evidence = createRosterAdmissionEvidence(\n service,\n admittingExecSql,\n organizationId,\n );\n if (!evidence) throw error;\n let head: ReferencedPrincipalHead | undefined;\n const vouched = await isReportedRosterVouchedRecipient({\n assertCurrent: admissionLifetime(service, admittingExecSql),\n evidence: {\n ...evidence,\n async loadCurrentMembers() {\n const members = await evidence.loadCurrentMembers();\n head = members.head;\n return members;\n },\n },\n organizationId,\n reportSecurityIncident: runtime.util.reportSecurityIncident,\n resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,\n userId,\n });\n if (!vouched || !head) throw error;\n return { status: \"roster\", head };\n }\n}\n\nfunction admissionLifetime(service: AdmissionRuntimeService, execSql: ExecSql) {\n const scope = currentOrganizationMutation(service);\n return () => {\n if (scope.runtime.infra.execSql !== execSql || !scope.stillCurrent())\n throw new DatabaseUnavailableError(\n \"The active identity or database changed while admitting this user. Try again.\",\n );\n };\n}\n\n/** Full-bundle roster authentication admits read, write, and admin shares. */\nexport async function requireShareRecipient(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n _accessLevel: ContainerAccessLevel,\n): Promise<void> {\n const assertCurrent = admissionLifetime(service, admittingExecSql);\n assertCurrent();\n await requireOrganizationRecipient(service, admittingExecSql, userId);\n assertCurrent();\n}\n\nexport type GroupMemberAdmission = (\n members: Pick<\n PrincipalPolicyBundleResponse,\n \"currentState\" | \"currentProjection\"\n >,\n) => Promise<void>;\n\n/** The proof is usable only at its exact Members head, within this runtime. */\nexport async function requireGroupMemberAdmission(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n): Promise<GroupMemberAdmission> {\n const assertCurrent = admissionLifetime(service, admittingExecSql);\n assertCurrent();\n const admission = await requireOrganizationRecipient(\n service,\n admittingExecSql,\n userId,\n );\n assertCurrent();\n return async (members) => {\n assertCurrent();\n if (!members.currentProjection.some((member) => member.userId === userId)) {\n // A retry may find the user removed since the proof. Enrollment still\n // requires this device's self/link anchor, never an earlier roster proof.\n await service.identityLinks.requireVerified(userId, admittingExecSql);\n } else if (\n admission.status === \"roster\" &&\n !principalHeadMatchesReference(members.currentState, admission.head)\n ) {\n throw new ProjectionDependencyUnavailableError(\n \"Members changed while admitting this user. Try again.\",\n );\n }\n assertCurrent();\n };\n}\n\n/** Capture the mutation scope before obtaining its head-bound admission proof. */\nexport async function admitGroupMutation(\n service: AdmissionRuntimeService &\n Pick<InternalRuntime, \"identityTrustDomain\">,\n userId: string,\n) {\n const mutation = currentOrganizationSigningMutation(service);\n const admission = await requireGroupMemberAdmission(\n service,\n mutation.runtime.infra.execSql,\n userId,\n );\n if (!mutation.stillCurrent())\n throw new DatabaseUnavailableError(\n \"The active database changed while admitting this user. Try again.\",\n );\n return { ...mutation, admission };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recipientAdmission.js","sourceRoot":"","sources":["recipientAdmission.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EACL,gCAAgC,GAEjC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAE9F,OAAO,EAGL,2BAA2B,GAC5B,MAA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AkB,CACtC,OAC8C,EAC9C,MAAc;IAEd,MAAM,QAAQ,GAAG,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,2BAA2B,CACjD,OAAO,EACP,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC9B,MAAM,CACP,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;QAC1B,MAAM,IAAI,wBAAwB,CAChC,mEAAmE,CACpE,CAAC;IACJ,OAAO,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type {\n ContainerAccessLevel,\n ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport { computeUserIdentityBundleFingerprint } from \"@tearleads/crypto\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { principalHeadMatchesReference } from \"../../data/principalContracts/organizationAuthorityDescriptor\";\nimport { ProjectionDependencyUnavailableError } from \"../../data/shared/dependencyUnavailable\";\nimport {\n runWithSecurityIncidentReporting,\n type SecurityIncidentReporter,\n} from \"../../data/shared/securityIncidents\";\nimport { DatabaseUnavailableError } from \"../../data/sqlite/availability/databaseUnavailable\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n type StagedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n UnverifiedUserIdentityError,\n} from \"../../data/trustedUserIdentity\";\nimport {\n isRosterVouchedRecipient,\n type RosterAdmissionEvidence,\n type RosterAdmissionPin,\n} from \"../../workflows/organizations/memberships/rosterVouchedAdmission\";\nimport type { InternalRuntime } from \"../runtime/workflowRuntime\";\nimport {\n currentOrganizationMutation,\n currentOrganizationSigningMutation,\n} from \"./principalMutationScope\";\nimport { createRosterAdmissionEvidence } from \"./rosterAdmissionEvidence\";\n\nexport { loadServedStateEnvelopes } from \"./rosterAdmissionEvidence\";\n\ntype AdmissionRuntimeService = Pick<\n InternalRuntime,\n \"identityLinks\" | \"sessionGeneration\" | \"workflowInput\"\n>;\n\n/** Thrown inside the staged scope so a refused recipient publishes nothing. */\nclass RecipientNotVouched extends Error {}\n\nasync function stagedPin(\n candidate: NonNullable<Awaited<ReturnType<StagedUserIdentityResolver>>>,\n): Promise<RosterAdmissionPin> {\n return {\n encapsulationKeyFingerprint: candidate.encapsulationKeyFingerprint,\n identityBundleFingerprint:\n await computeUserIdentityBundleFingerprint(candidate),\n signingKeyFingerprint: candidate.signingKeyFingerprint,\n verified: false,\n };\n}\n\n/**\n * Admit against the server's first answers without pinning them: the\n * recipient's answer, and that of any historical signer the chain needs but\n * this device has not pinned (a departed admin seen only in older Members\n * states), are staged. Each is checked against its committed Members bundle,\n * and all are pinned as observed only once the signed roster vouches for the\n * recipient's exact identity bundle. A substituted answer leaves no pin, so a\n * corrected retry or the honest identity link still succeeds.\n */\nasync function isStagedRosterVouchedRecipient(\n userId: string,\n evidence: RosterAdmissionEvidence,\n resolver: TrustedUserIdentityResolver,\n assertCurrent: (() => void) | undefined,\n): Promise<boolean> {\n // Without staging, admit only a durable pin: never pin before the roster.\n if (!resolver.withPinnedIdentities)\n return isRosterVouchedRecipient(userId, evidence);\n try {\n return await resolver.withPinnedIdentities(\n [userId],\n async (resolve) => {\n const candidate = await resolve(userId);\n const vouched =\n candidate !== null &&\n (await isRosterVouchedRecipient(userId, {\n ...evidence,\n loadPin: async (id) => {\n const pin = await evidence.loadPin(id);\n if (pin) return pin;\n const staged = id === userId ? candidate : await resolve(id);\n return staged ? stagedPin(staged) : null;\n },\n }));\n if (!vouched) throw new RecipientNotVouched();\n return true;\n },\n { publish: true, assertCurrent },\n );\n } catch (error) {\n if (error instanceof RecipientNotVouched) return false;\n throw error;\n }\n}\n\n/**\n * Whether the signed roster vouches for `userId` on this device, for exactly\n * the domain-scoped signing and encapsulation identity bundle the server\n * serves. Served material that fails verification is recorded as a security\n * incident before the error propagates.\n */\nexport function isReportedRosterVouchedRecipient(input: {\n readonly evidence: RosterAdmissionEvidence;\n readonly organizationId: string;\n readonly reportSecurityIncident: SecurityIncidentReporter;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n readonly userId: string;\n /** The admission's lifetime, checked inside every pin write. */\n readonly assertCurrent?: (() => void) | undefined;\n}): Promise<boolean> {\n const { evidence, userId } = input;\n return runWithSecurityIncidentReporting(\n input.reportSecurityIncident,\n {\n objectId: userId,\n objectKind: \"user\",\n operation: \"container.share.roster_vouch\",\n organizationId: input.organizationId,\n },\n () =>\n isStagedRosterVouchedRecipient(\n userId,\n evidence,\n input.resolveTrustedUserIdentity,\n input.assertCurrent,\n ),\n );\n}\n\ntype RecipientAdmission =\n | { readonly status: \"verified\" }\n | { readonly status: \"roster\"; readonly head: ReferencedPrincipalHead };\n\nasync function requireOrganizationRecipient(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n): Promise<RecipientAdmission> {\n try {\n await service.identityLinks.requireVerified(userId, admittingExecSql);\n return { status: \"verified\" };\n } catch (error) {\n const runtime = service.workflowInput();\n const organizationId = runtime.auth.organizationId;\n if (!(error instanceof UnverifiedUserIdentityError) || !organizationId)\n throw error;\n const evidence = createRosterAdmissionEvidence(\n service,\n admittingExecSql,\n organizationId,\n );\n if (!evidence) throw error;\n let head: ReferencedPrincipalHead | undefined;\n const vouched = await isReportedRosterVouchedRecipient({\n assertCurrent: admissionLifetime(service, admittingExecSql),\n evidence: {\n ...evidence,\n async loadCurrentMembers() {\n const members = await evidence.loadCurrentMembers();\n head = members.head;\n return members;\n },\n },\n organizationId,\n reportSecurityIncident: runtime.util.reportSecurityIncident,\n resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,\n userId,\n });\n if (!vouched || !head) throw error;\n return { status: \"roster\", head };\n }\n}\n\nfunction admissionLifetime(service: AdmissionRuntimeService, execSql: ExecSql) {\n const scope = currentOrganizationMutation(service);\n return () => {\n if (scope.runtime.infra.execSql !== execSql || !scope.stillCurrent())\n throw new DatabaseUnavailableError(\n \"The active identity or database changed while admitting this user. Try again.\",\n );\n };\n}\n\n/** Full-bundle roster authentication admits read, write, and admin shares. */\nexport async function requireShareRecipient(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n _accessLevel: ContainerAccessLevel,\n): Promise<void> {\n const assertCurrent = admissionLifetime(service, admittingExecSql);\n assertCurrent();\n await requireOrganizationRecipient(service, admittingExecSql, userId);\n assertCurrent();\n}\n\nexport type GroupMemberAdmission = (\n members: Pick<\n PrincipalPolicyBundleResponse,\n \"currentState\" | \"currentProjection\"\n >,\n) => Promise<void>;\n\n/** The proof is usable only at its exact Members head, within this runtime. */\nexport async function requireGroupMemberAdmission(\n service: AdmissionRuntimeService,\n admittingExecSql: ExecSql,\n userId: string,\n): Promise<GroupMemberAdmission> {\n const assertCurrent = admissionLifetime(service, admittingExecSql);\n assertCurrent();\n const admission = await requireOrganizationRecipient(\n service,\n admittingExecSql,\n userId,\n );\n assertCurrent();\n return async (members) => {\n assertCurrent();\n if (!members.currentProjection.some((member) => member.userId === userId)) {\n // A retry may find the user removed since the proof. Enrollment still\n // requires this device's self/link anchor, never an earlier roster proof.\n await service.identityLinks.requireVerified(userId, admittingExecSql);\n } else if (\n admission.status === \"roster\" &&\n !principalHeadMatchesReference(members.currentState, admission.head)\n ) {\n throw new ProjectionDependencyUnavailableError(\n \"Members changed while admitting this user. Try again.\",\n );\n }\n assertCurrent();\n };\n}\n\n/** Capture the mutation scope before obtaining its head-bound admission proof. */\nexport async function admitGroupMutation(\n service: AdmissionRuntimeService &\n Pick<InternalRuntime, \"identityTrustDomain\">,\n userId: string,\n) {\n const mutation = currentOrganizationSigningMutation(service);\n const admission = await requireGroupMemberAdmission(\n service,\n mutation.runtime.infra.execSql,\n userId,\n );\n if (!mutation.stillCurrent())\n throw new DatabaseUnavailableError(\n \"The active database changed while admitting this user. Try again.\",\n );\n return { ...mutation, admission };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createListenerSet } from "
|
|
1
|
+
import { createListenerSet } from "../../data/shared/listenerSet.js";
|
|
2
2
|
/**
|
|
3
3
|
* The API build that served this client's latest response, as named by the
|
|
4
4
|
* API's version header: the commit count of the default branch it was built
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiVersion.js","sourceRoot":"","sources":["apiVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"apiVersion.js","sourceRoot":"","sources":["apiVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IACJ,SAAS,GAAG,iBAAiB,EAAY,CAAC;IACnD,YAAY,GAAkB,IAAI,CAAC;IAE3C,6CAA6C;IAC7C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,GAAG,CAAC,QAAmC,EAAgB,EAAE,CAChE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CACtC","sourcesContent":["import { createListenerSet } from \"../../data/shared/listenerSet\";\n\n/**\n * The API build that served this client's latest response, as named by the\n * API's version header: the commit count of the default branch it was built\n * from, so a later deploy always reads higher.\n *\n * Held in memory only. It describes the server answering right now, so a value\n * persisted across launches would misattribute the first failures after a\n * redeploy, and the first response of every session replaces it anyway.\n */\nexport class ApiVersion {\n private readonly listeners = createListenerSet<[number]>();\n private currentValue: number | null = null;\n\n /** Null until a response names its build. */\n get current(): number | null {\n return this.currentValue;\n }\n\n observe(version: number): void {\n if (this.currentValue === version) {\n return;\n }\n this.currentValue = version;\n this.listeners.notify(version);\n }\n\n subscribe = (listener: (version: number) => void): (() => void) =>\n this.listeners.subscribe(listener);\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ContainerContentsRootAdopter, type ContainerContentsStoreWorkflowRuntime, type ContainerContentsWorkflowRuntime, type ContainerContentsWorkflowRuntimeInput, createContainerContentsStoreWorkflowRuntime as createStoreRuntimeWithHost } from "../../workflows/container-contents/index.js";
|
|
2
|
+
type StandaloneContainerContentsWorkflowRuntimeInput = Omit<ContainerContentsWorkflowRuntimeInput, "organizations">;
|
|
3
|
+
type StoreRecipientGuard = Parameters<typeof createStoreRuntimeWithHost>[2];
|
|
4
|
+
/** A standalone runtime, bound to the organization workflows' operations. */
|
|
5
|
+
export declare function createContainerContentsWorkflowRuntime(input: StandaloneContainerContentsWorkflowRuntimeInput): ContainerContentsWorkflowRuntime;
|
|
6
|
+
/** A standalone store runtime, bound to the organization workflows' operations. */
|
|
7
|
+
export declare function createContainerContentsStoreWorkflowRuntime(input: StandaloneContainerContentsWorkflowRuntimeInput, adoptRootContainer: ContainerContentsRootAdopter, requireVerifiedRecipient: StoreRecipientGuard): ContainerContentsStoreWorkflowRuntime;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContainerContentsWorkflowRuntime as createRuntimeWithHost, createContainerContentsStoreWorkflowRuntime as createStoreRuntimeWithHost, } from "../../workflows/container-contents/index.js";
|
|
2
|
+
import { containerContentsOrganizationHost } from "../../workflows/organizations/containerContentsHost.js";
|
|
3
|
+
/** A standalone runtime, bound to the organization workflows' operations. */
|
|
4
|
+
export function createContainerContentsWorkflowRuntime(input) {
|
|
5
|
+
return createRuntimeWithHost({
|
|
6
|
+
...input,
|
|
7
|
+
organizations: containerContentsOrganizationHost,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/** A standalone store runtime, bound to the organization workflows' operations. */
|
|
11
|
+
export function createContainerContentsStoreWorkflowRuntime(input, adoptRootContainer, requireVerifiedRecipient) {
|
|
12
|
+
return createStoreRuntimeWithHost({ ...input, organizations: containerContentsOrganizationHost }, adoptRootContainer, requireVerifiedRecipient);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=containerContentsRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerContentsRuntime.js","sourceRoot":"","sources":["containerContentsRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,sCAAsC,IAAI,qBAAqB,EAC/D,2CAA2C,IAAI,0BAA0B,GAC1E,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,qDAAqD,CAAC;AASxG,6EAA6E;AAC7E,MAAM,UAAU,sCAAsC,CACpD,KAAsD;IAEtD,OAAO,qBAAqB,CAAC;QAC3B,GAAG,KAAK;QACR,aAAa,EAAE,iCAAiC;KACjD,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,2CAA2C,CACzD,KAAsD,EACtD,kBAAgD,EAChD,wBAA6C;IAE7C,OAAO,0BAA0B,CAC/B,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,iCAAiC,EAAE,EAC9D,kBAAkB,EAClB,wBAAwB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type ContainerContentsRootAdopter,\n type ContainerContentsStoreWorkflowRuntime,\n type ContainerContentsWorkflowRuntime,\n type ContainerContentsWorkflowRuntimeInput,\n createContainerContentsWorkflowRuntime as createRuntimeWithHost,\n createContainerContentsStoreWorkflowRuntime as createStoreRuntimeWithHost,\n} from \"../../workflows/container-contents\";\nimport { containerContentsOrganizationHost } from \"../../workflows/organizations/containerContentsHost\";\n\ntype StandaloneContainerContentsWorkflowRuntimeInput = Omit<\n ContainerContentsWorkflowRuntimeInput,\n \"organizations\"\n>;\n\ntype StoreRecipientGuard = Parameters<typeof createStoreRuntimeWithHost>[2];\n\n/** A standalone runtime, bound to the organization workflows' operations. */\nexport function createContainerContentsWorkflowRuntime(\n input: StandaloneContainerContentsWorkflowRuntimeInput,\n): ContainerContentsWorkflowRuntime {\n return createRuntimeWithHost({\n ...input,\n organizations: containerContentsOrganizationHost,\n });\n}\n\n/** A standalone store runtime, bound to the organization workflows' operations. */\nexport function createContainerContentsStoreWorkflowRuntime(\n input: StandaloneContainerContentsWorkflowRuntimeInput,\n adoptRootContainer: ContainerContentsRootAdopter,\n requireVerifiedRecipient: StoreRecipientGuard,\n): ContainerContentsStoreWorkflowRuntime {\n return createStoreRuntimeWithHost(\n { ...input, organizations: containerContentsOrganizationHost },\n adoptRootContainer,\n requireVerifiedRecipient,\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createListenerSet } from "../../data/shared/listenerSet.js";
|
|
1
2
|
import { createExecSql, } from "../../data/sqlite/sqlSchema.js";
|
|
2
|
-
import { createListenerSet } from "./listenerSet.js";
|
|
3
3
|
export class Database {
|
|
4
4
|
listeners = createListenerSet();
|
|
5
5
|
snapshotValue = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["database.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,aAAa,GAGd,MAAM,6BAA6B,CAAC;AAoBrC,MAAM,OAAO,QAAQ;IACF,SAAS,GAAG,iBAAiB,EAAE,CAAC;IACzC,aAAa,GAAqB;QACxC,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;QACb,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,MAAM;KACf,CAAC;IAEF,YAAY,OAAqC;QAC/C,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC1B,C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O,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,yCAAyC,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACpC,CAAC;IAED,SAAS,CACP,MAAyB,EACzB,UAAuD,EAAE;QAEzD,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,UAAU,CACR,OAAgB,EAChB,UAAuD,EAAE;QAEzD,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,SAAS,GAAG,CAAC,QAA0B,EAAgB,EAAE,CACvD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE7B,WAAW,CAAC,IAAsB;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC;QACpC,IACE,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;YAC/B,QAAQ,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO;YACjC,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE;YACvB,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAC/B,CAAC;YACD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { createListenerSet } from \"../../data/shared/listenerSet\";\nimport {\n createExecSql,\n type ExecSql,\n type ExecSqlClientLike,\n} from \"../../data/sqlite/sqlSchema\";\n\nexport type DatabaseStatus = \"idle\" | \"ready\" | \"error\" | \"terminated\";\n\nexport interface DatabaseSnapshot {\n client: ExecSqlClientLike | null;\n execSql: ExecSql | null;\n id: string | null;\n status: DatabaseStatus;\n}\n\nexport type DatabaseListener = () => void;\n\nexport interface DatabaseOptions {\n client?: ExecSqlClientLike | null | undefined;\n execSql?: ExecSql | null | undefined;\n id?: string | null | undefined;\n status?: DatabaseStatus | undefined;\n}\n\nexport class Database {\n private readonly listeners = createListenerSet();\n private snapshotValue: DatabaseSnapshot = {\n client: null,\n execSql: null,\n id: null,\n status: \"idle\",\n };\n\n constructor(options?: DatabaseOptions | undefined) {\n if (options) {\n this.configure(options);\n }\n }\n\n get client(): ExecSqlClientLike | null {\n return this.snapshotValue.client;\n }\n\n get execSql(): ExecSql | null {\n return this.snapshotValue.execSql;\n }\n\n get id(): string | null {\n return this.snapshotValue.id;\n }\n\n get snapshot(): DatabaseSnapshot {\n return this.snapshotValue;\n }\n\n get status(): DatabaseStatus {\n return this.snapshotValue.status;\n }\n\n clear(status: DatabaseStatus = \"idle\"): void {\n this.setSnapshot({\n client: null,\n execSql: null,\n id: null,\n status,\n });\n }\n\n configure(options: DatabaseOptions): void {\n const client = options.client ?? null;\n const execSql = options.execSql ?? (client ? createExecSql(client) : null);\n if (options.status === \"ready\" && !execSql) {\n throw new Error(\n \"A ready SQLite database requires a configured executor or client.\",\n );\n }\n\n this.setSnapshot({\n client,\n execSql,\n id: options.id ?? null,\n status: options.status ?? (execSql ? \"ready\" : \"idle\"),\n });\n }\n\n requireExecSql(operation = \"This operation\"): ExecSql {\n if (!this.snapshotValue.execSql) {\n throw new Error(`${operation} requires a configured SQLite executor.`);\n }\n\n return this.snapshotValue.execSql;\n }\n\n setClient(\n client: ExecSqlClientLike,\n options: Omit<DatabaseOptions, \"client\" | \"execSql\"> = {},\n ): void {\n this.configure({ ...options, client });\n }\n\n setExecSql(\n execSql: ExecSql,\n options: Omit<DatabaseOptions, \"client\" | \"execSql\"> = {},\n ): void {\n this.configure({ ...options, execSql });\n }\n\n subscribe = (listener: DatabaseListener): (() => void) =>\n this.listeners.subscribe(listener);\n\n private setSnapshot(next: DatabaseSnapshot): void {\n const previous = this.snapshotValue;\n if (\n previous.client === next.client &&\n previous.execSql === next.execSql &&\n previous.id === next.id &&\n previous.status === next.status\n ) {\n return;\n }\n\n this.snapshotValue = next;\n this.listeners.notify();\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DocumentsWorkflowRuntime, type DocumentsWorkflowRuntimeInput as DocumentsWorkflowRuntimeHostInput } from "../../workflows/documents/index.js";
|
|
2
|
+
/** A standalone host's input; the runtime binds placement cleanup itself. */
|
|
3
|
+
export type DocumentsWorkflowRuntimeInput = Omit<DocumentsWorkflowRuntimeHostInput, "deleteDocumentPlacements">;
|
|
4
|
+
/** A standalone runtime, bound to Container Contents' placement cleanup. */
|
|
5
|
+
export declare function createDocumentsWorkflowRuntime(input: DocumentsWorkflowRuntimeInput): DocumentsWorkflowRuntime;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { deleteDocumentPlacements } from "../../data/persistence/container-contents/documentContainerProjectionPersistence.js";
|
|
2
|
+
import { createDocumentsWorkflowRuntime as createRuntimeWithPlacementCleanup, } from "../../workflows/documents/index.js";
|
|
3
|
+
/** A standalone runtime, bound to Container Contents' placement cleanup. */
|
|
4
|
+
export function createDocumentsWorkflowRuntime(input) {
|
|
5
|
+
return createRuntimeWithPlacementCleanup({
|
|
6
|
+
...input,
|
|
7
|
+
deleteDocumentPlacements,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=documentsRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentsRuntime.js","sourceRoot":"","sources":["documentsRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kFAAkF,CAAC;AAC5H,OAAO,EACL,8BAA8B,IAAI,iCAAiC,GAGpE,MAAM,2BAA2B,CAAC;AAQnC,4EAA4E;AAC5E,MAAM,UAAU,8BAA8B,CAC5C,KAAoC;IAEpC,OAAO,iCAAiC,CAAC;QACvC,GAAG,KAAK;QACR,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { deleteDocumentPlacements } from \"../../data/persistence/container-contents/documentContainerProjectionPersistence\";\nimport {\n createDocumentsWorkflowRuntime as createRuntimeWithPlacementCleanup,\n type DocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntimeInput as DocumentsWorkflowRuntimeHostInput,\n} from \"../../workflows/documents\";\n\n/** A standalone host's input; the runtime binds placement cleanup itself. */\nexport type DocumentsWorkflowRuntimeInput = Omit<\n DocumentsWorkflowRuntimeHostInput,\n \"deleteDocumentPlacements\"\n>;\n\n/** A standalone runtime, bound to Container Contents' placement cleanup. */\nexport function createDocumentsWorkflowRuntime(\n input: DocumentsWorkflowRuntimeInput,\n): DocumentsWorkflowRuntime {\n return createRuntimeWithPlacementCleanup({\n ...input,\n deleteDocumentPlacements,\n });\n}\n"]}
|
package/client/runtime/events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAQlE,MAAM,OAAO,MAAM;IAUE;IATX,cAAc,GAAG,KAAK,CAAC;IACvB,yBAAyB,GAAG,CAAC,CAAC;IAC9B,mBAAmB,GAAG,CAAC,CAAC;IACxB,0BAA0B,GAAuB,SAAS,CAAC;IAClD,SAAS,GAAG,iBAAiB,EAAE,CAAC;IACzC,aAAa,CAAiB;IAEtC,YACE,SAAiC,EAAE,EAClB,yBAAqC,GAAG,EAAE,CAAC,SAAS;QAApD,2BAAsB,GAAtB,sBAAsB,CAA8B;QAErE,IAAI,CAAC,aAAa,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,cAAc,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AC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;YAChC,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,yBAAyB,IAAI,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,0BAA0B,GAAG,SAAS,CAAC;QAC5C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,MAA8B;QACtC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,GAAG,CAAC,QAAwB,EAAgB,EAAE,CACrD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE7B,cAAc,CAAC,MAA8B;QACnD,IAAI,CAAC,aAAa,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { createListenerSet } from \"../../data/shared/listenerSet\";\nexport interface EventsSnapshot {\n connected: boolean;\n events: ReadonlyArray<unknown>;\n}\n\nexport type EventsListener = () => void;\n\nexport class Events {\n private connectedValue = false;\n private connectionGenerationValue = 0;\n private connectAttemptValue = 0;\n private pendingConnectAttemptValue: number | undefined = undefined;\n private readonly listeners = createListenerSet();\n private snapshotValue: EventsSnapshot;\n\n constructor(\n events: ReadonlyArray<unknown> = [],\n private readonly invalidateAccessCaches: () => void = () => undefined,\n ) {\n this.snapshotValue = { connected: this.connectedValue, events };\n }\n\n get connected(): boolean {\n return this.connectedValue;\n }\n\n get connectionGeneration(): number {\n return this.connectionGenerationValue;\n }\n\n get events(): ReadonlyArray<unknown> {\n return this.snapshotValue.events;\n }\n\n get snapshot(): EventsSnapshot {\n return this.snapshotValue;\n }\n\n clear(): void {\n this.setEvents([]);\n }\n\n push(event: unknown): void {\n this.setEvents([...this.events, event]);\n }\n\n /**\n * Drop HTTP writer projections after an access/keying control signal or an\n * event-stream gap. A peer re-key can make an otherwise-valid cached\n * projection stale even when no local mutation touched the cache.\n */\n invalidateAccessState(): void {\n this.invalidateAccessCaches();\n }\n\n /**\n * The connect attempt whose interest acknowledgement is still outstanding,\n * or undefined. Document stores opened meanwhile defer their startup probe\n * to that acknowledgement's reconnect probe; an attempt that ends without\n * one releases the deferral, so each attempt gets its own id.\n */\n get pendingConnectAttempt(): number | undefined {\n return this.pendingConnectAttemptValue;\n }\n\n /** A connect attempt started: its acknowledgement will arm probes. */\n beginConnectAttempt(): number {\n this.connectAttemptValue += 1;\n this.pendingConnectAttemptValue = this.connectAttemptValue;\n this.updateSnapshot(this.events);\n return this.connectAttemptValue;\n }\n\n /** The attempt can no longer deliver an acknowledgement. */\n endConnectAttempt(attempt: number): void {\n if (this.pendingConnectAttemptValue !== attempt) {\n return;\n }\n this.pendingConnectAttemptValue = undefined;\n this.updateSnapshot(this.events);\n }\n\n setConnected(connected: boolean): void {\n if (\n this.connectedValue === connected &&\n this.pendingConnectAttemptValue === undefined\n ) {\n return;\n }\n\n if (this.connectedValue !== connected) {\n this.connectedValue = connected;\n if (connected) {\n this.connectionGenerationValue += 1;\n }\n }\n this.pendingConnectAttemptValue = undefined;\n this.updateSnapshot(this.events);\n }\n\n setEvents(events: ReadonlyArray<unknown>): void {\n if (this.events === events) {\n return;\n }\n\n this.updateSnapshot(events);\n }\n\n subscribe = (listener: EventsListener): (() => void) =>\n this.listeners.subscribe(listener);\n\n private updateSnapshot(events: ReadonlyArray<unknown>): void {\n this.snapshotValue = { connected: this.connectedValue, events };\n this.listeners.notify();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["network.ts"],"names":[],"mappings":"AAAA,OAAO,E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ACtD,CAAC;IAED,mFAAmF;IACnF,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,8BAA8B;YACxC,CAAC,CAAC,IAAI,CAAC,mBAAmB;YAC1B,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED;;;;;;;;OAQG;IACH,kBAAkB,CAAC,MAAe;QAChC,IAAI,IAAI,CAAC,8BAA8B,IAAI,CAAC,MAAM,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,SAAS,GAAG,CAAC,QAAyB,EAAgB,EAAE,CACtD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CACtC","sourcesContent":["import { createListenerSet } from \"../../data/shared/listenerSet\";\nexport type NetworkListener = (online: boolean) => void;\nexport type NetworkMode = \"automatic\" | \"online\" | \"offline\";\n\nfunction defaultOnline(): boolean {\n return typeof navigator === \"object\" && typeof navigator.onLine === \"boolean\"\n ? navigator.onLine\n : true;\n}\n\n/**\n * Platform-agnostic source of connectivity status. The default browser\n * implementation reads `navigator.onLine` and the window `online`/`offline`\n * events, which is accurate on real browsers. Native shells supply their own\n * implementation backed by the OS connectivity API — most importantly the\n * Capacitor Android WebView, where `navigator.onLine` is unreliable and often\n * reports offline while the device is genuinely connected.\n *\n * The contract is deliberately small so a host adapter can satisfy it: a\n * synchronous best-known read for seeding, plus a push subscription for\n * changes. A source that can only read connectivity asynchronously returns an\n * optimistic value from {@link getOnline} and corrects it through the first\n * emission to a subscriber.\n */\nexport interface NetworkStatusSource {\n /**\n * Whether this source continuously governs device connectivity. Browser\n * `online`/`offline` events and native OS-backed sources set this so the SDK\n * treats them as the sole source of offline transitions: a backend request\n * that fails to reach the server then means the backend is unreachable, not\n * that the device went offline, and must not stop recovery retries (see\n * {@link Network.reportReachability}). A successful backend request still\n * proves connectivity and can correct a stale offline signal. Sources that\n * omit this flag let both request outcomes act as connectivity hints, which is\n * useful for headless hosts that have no independent connectivity signal.\n */\n readonly authoritative?: boolean;\n /**\n * Best-known connectivity, read synchronously so the SDK can seed its state\n * without waiting on an async native round-trip.\n */\n getOnline(): boolean;\n /**\n * Subscribe to connectivity changes; returns an unsubscribe function. A\n * source whose underlying read is asynchronous should emit the resolved\n * value as soon as it is known so the seeded value is corrected promptly.\n */\n subscribe(listener: NetworkListener): () => void;\n /** Release any platform resources (event handlers, native listeners). */\n dispose?(): void;\n /**\n * Optional one-line diagnostic snapshot for the support log — how the source\n * is reading connectivity (e.g. which native plugin, the raw status, the\n * WebView's `navigator.onLine`). Purely informational; a source that has\n * nothing platform-specific to report omits it.\n */\n diagnose?(): Promise<string>;\n}\n\n/**\n * The default {@link NetworkStatusSource}: `navigator.onLine` for the seed and\n * the window `online`/`offline` events for changes. Safe to construct in a\n * non-DOM context (SSR, tests) — it reports online and never registers a\n * listener when `window` is absent.\n */\nexport function createBrowserNetworkStatusSource(): NetworkStatusSource {\n return {\n // Keep backend failures distinct from device connectivity. If a failed\n // request flipped this source offline while the browser remained connected,\n // no later `online` event would fire and the WebSocket retry loop would stay\n // disabled after the backend recovered.\n authoritative: true,\n getOnline: defaultOnline,\n subscribe(listener: NetworkListener): () => void {\n if (typeof window === \"undefined\") {\n return () => {};\n }\n const goOnline = () => listener(true);\n const goOffline = () => listener(false);\n window.addEventListener(\"online\", goOnline);\n window.addEventListener(\"offline\", goOffline);\n return () => {\n window.removeEventListener(\"online\", goOnline);\n window.removeEventListener(\"offline\", goOffline);\n };\n },\n };\n}\n\nfunction resolveOnline(mode: NetworkMode, detectedOnline: boolean): boolean {\n if (mode === \"online\") {\n return true;\n }\n\n if (mode === \"offline\") {\n return false;\n }\n\n return detectedOnline;\n}\n\nexport class Network {\n private readonly listeners = createListenerSet<[boolean]>();\n private detectedOnlineValue: boolean;\n private modeValue: NetworkMode = \"automatic\";\n private connectivityAuthoritativeValue = false;\n\n constructor(online: boolean = defaultOnline()) {\n this.detectedOnlineValue = online;\n }\n\n get online(): boolean {\n return resolveOnline(this.modeValue, this.detectedOnlineValue);\n }\n\n get detectedOnline(): boolean {\n return this.detectedOnlineValue;\n }\n\n get mode(): NetworkMode {\n return this.modeValue;\n }\n\n setOnline(online: boolean): void {\n const previousOnline = this.online;\n if (this.detectedOnlineValue === online) {\n return;\n }\n\n this.detectedOnlineValue = online;\n if (this.online !== previousOnline) {\n this.listeners.notify(this.online);\n }\n }\n\n setMode(mode: NetworkMode): void {\n if (this.modeValue === mode) {\n return;\n }\n\n this.modeValue = mode;\n this.listeners.notify(this.online);\n }\n\n /**\n * Declares whether an independent {@link NetworkStatusSource} is governing\n * connectivity. When set, failed-request reachability signals\n * ({@link reportReachability}) no longer touch `online`; successful requests\n * may still repair a stale offline signal.\n */\n setConnectivityAuthoritative(authoritative: boolean): void {\n this.connectivityAuthoritativeValue = authoritative;\n }\n\n /** The independent source's reading; null when request outcomes drive `online`. */\n get authoritativeOnline(): boolean | null {\n return this.connectivityAuthoritativeValue\n ? this.detectedOnlineValue\n : null;\n }\n\n /**\n * Reports the outcome of a backend request as a connectivity hint. Without an\n * authoritative source, it drives `online` exactly like a detected change.\n * With an authoritative browser or OS source, a failed request means the\n * backend is unreachable — not that the device lost its network — so a\n * negative hint is ignored. A successful request is conclusive evidence of\n * connectivity and can repair a stale source reading. Backend failures still\n * surface downstream while connection retries remain live.\n */\n reportReachability(online: boolean): void {\n if (this.connectivityAuthoritativeValue && !online) {\n return;\n }\n\n this.setOnline(online);\n }\n\n subscribe = (listener: NetworkListener): (() => void) =>\n this.listeners.subscribe(listener);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runWithSecurityIncidentReporting } from "../../data/
|
|
1
|
+
import { runWithSecurityIncidentReporting, } from "../../data/shared/securityIncidents.js";
|
|
2
2
|
import { createApiUserIdentitySource, createTrustedUserIdentityService, } from "../../data/trustedUserIdentity/index.js";
|
|
3
3
|
/** Compose both direct resolution and scoped structural pin reads with reporting. */
|
|
4
4
|
export function createRuntimeIdentityResolution(dependencies, getExecSql, getScopeGeneration) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeIdentityResolution.js","sourceRoot":"","sources":["runtimeIdentityResolution.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtimeIdentityResolution.js","sourceRoot":"","sources":["runtimeIdentityResolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,GAEjC,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,GAIjC,MAAM,gCAAgC,CAAC;AAIxC,qFAAqF;AACrF,MAAM,UAAU,+BAA+B,CAC7C,YASC,EACD,UAAgC,EAChC,kBAAiC;IAEjC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;QAClE,UAAU;QACV,kBAAkB;QAClB,gBAAgB,EAAE,GAAG,EAAE;YACrB,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAChE,YAAY,CAAC,QAAQ,CAAC;YACxB,OAAO,oBAAoB,IAAI,cAAc;gBAC3C,CAAC,CAAC;oBACE,sBAAsB,EAAE,oBAAoB,CAAC,SAAS;oBACtD,gBAAgB,EAAE,cAAc,CAAC,gBAAgB;oBACjD,qBAAqB,EAAE,kBAAkB;iBAC1C;gBACH,CAAC,CAAC,IAAI,CAAC;QACX,CAAC;QACD,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM;QACjD,mBAAmB,EAAE,YAAY,CAAC,mBAAmB;QACrD,YAAY,EAAE,2BAA2B,CAAC,YAAY,CAAC,GAAG,CAAC;KAC5D,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,CAAI,MAAc,EAAE,SAA2B,EAAE,EAAE,CAChE,gCAAgC,CAC9B,YAAY,CAAC,sBAAsB,EACnC;QACE,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,uBAAuB;QAClC,cAAc,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc;KACpD,EACD,SAAS,CACV,CAAC;IACJ,MAAM,0BAA0B,GAAgC,MAAM,CAAC,MAAM,CAC3E,CAAC,MAAc,EAAE,EAAE,CACjB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAClE;QACE,oBAAoB,EAAE,CACpB,OAA0B,EAC1B,MAA2D,EAC3D,OAAkC,EAClC,EAAE;YACF,MAAM,oBAAoB,GACxB,0BAA0B,CAAC,OAAO,CAAC,oBAAoB,CAAC;YAC1D,IAAI,CAAC,oBAAoB;gBACvB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAClE,OAAO,oBAAoB,CACzB,OAAO,EACP,CAAC,OAAO,EAAE,EAAE,CACV,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAC3D,OAAO,CACR,CAAC;QACJ,CAAC;KACF,CACF,CAAC;IACF,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import {\n runWithSecurityIncidentReporting,\n type SecurityIncidentReporter,\n} from \"../../data/shared/securityIncidents\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n createApiUserIdentitySource,\n createTrustedUserIdentityService,\n type StagedUserIdentityOptions,\n type StagedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n} from \"../../data/trustedUserIdentity\";\nimport type { Identity } from \"../identity\";\nimport type { Session } from \"../session/sessionTypes\";\n\n/** Compose both direct resolution and scoped structural pin reads with reporting. */\nexport function createRuntimeIdentityResolution(\n dependencies: {\n readonly api: Parameters<typeof createApiUserIdentitySource>[0];\n readonly identity: Pick<\n Identity,\n \"encapsulationKeyPair\" | \"signingKeyPair\" | \"signingFingerprint\"\n >;\n readonly identityTrustDomain: string | null;\n readonly reportSecurityIncident: SecurityIncidentReporter;\n readonly session: Pick<Session, \"userId\" | \"organizationId\">;\n },\n getExecSql: () => ExecSql | null,\n getScopeGeneration: () => unknown,\n) {\n const trustedUserIdentityService = createTrustedUserIdentityService({\n getExecSql,\n getScopeGeneration,\n getLocalIdentity: () => {\n const { encapsulationKeyPair, signingKeyPair, signingFingerprint } =\n dependencies.identity;\n return encapsulationKeyPair && signingKeyPair\n ? {\n encapsulationPublicKey: encapsulationKeyPair.publicKey,\n signingPublicKey: signingKeyPair.signingPublicKey,\n signingKeyFingerprint: signingFingerprint,\n }\n : null;\n },\n getLocalUserId: () => dependencies.session.userId,\n identityTrustDomain: dependencies.identityTrustDomain,\n remoteSource: createApiUserIdentitySource(dependencies.api),\n });\n const report = <T>(userId: string, operation: () => Promise<T>) =>\n runWithSecurityIncidentReporting(\n dependencies.reportSecurityIncident,\n {\n objectId: userId,\n objectKind: \"user\",\n operation: \"user.identity.resolve\",\n organizationId: dependencies.session.organizationId,\n },\n operation,\n );\n const resolveTrustedUserIdentity: TrustedUserIdentityResolver = Object.assign(\n (userId: string) =>\n report(userId, () => trustedUserIdentityService.resolve(userId)),\n {\n withPinnedIdentities: <T>(\n userIds: readonly string[],\n verify: (resolve: StagedUserIdentityResolver) => Promise<T>,\n options: StagedUserIdentityOptions,\n ) => {\n const withPinnedIdentities =\n trustedUserIdentityService.resolve.withPinnedIdentities;\n if (!withPinnedIdentities)\n throw new Error(\"Trusted identity batch reader is unavailable\");\n return withPinnedIdentities(\n userIds,\n (resolve) =>\n verify((userId) => report(userId, () => resolve(userId))),\n options,\n );\n },\n },\n );\n return { trustedUserIdentityService, resolveTrustedUserIdentity };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createListenerSet } from "
|
|
1
|
+
import { createListenerSet } from "../../data/shared/listenerSet.js";
|
|
2
2
|
/**
|
|
3
3
|
* Signals that a sync write was rejected because its target organization cannot
|
|
4
4
|
* sync (HTTP 402). Identified blocks are retained independently per org; a 402
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncBillingGate.js","sourceRoot":"","sources":["syncBillingGate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"syncBillingGate.js","sourceRoot":"","sources":["syncBillingGate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACT,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3C,SAAS,GAAG,iBAAiB,EAAmB,CAAC;IACjD,iCAAiC,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/D,2BAA2B,GAAG,KAAK,CAAC;IACpC,8BAA8B,CAA4B;IAElE,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,8BAA8B,IAAI,IAAI,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,CACL,IAAI,CAAC,2BAA2B,IAAI,IAAI,CAAC,sBAAsB,CAAC,IAAI,GAAG,CAAC,CACzE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,wBAAwB,CAAC,cAA6B;QACpD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;QAC1C,CAAC;QAED,OAAO,CACL,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC;YAC/C,CAAC,IAAI,CAAC,2BAA2B;gBAC/B,CAAC,IAAI,CAAC,iCAAiC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,6BAA6B,CAC3B,cAA6B;QAE7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CACn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cAAc,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACrC,IAAI,CAAC,iCAAiC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,IAAI,CAAC,gCAAgC,EAAE,CAAC;IAC1C,CAAC;IAEO,gCAAgC;QACtC,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACrC,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC;YAC3C,OAAO;QACT,CAAC;QAED,IAAI,CAAC,8BAA8B,GAAG,KAAK,CAAC,IAAI,CAC9C,IAAI,CAAC,sBAAsB,CAC5B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;IAED,SAAS,GAAG,CAAC,QAAiC,EAAgB,EAAE,CAC9D,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CACtC","sourcesContent":["import { createListenerSet } from \"../../data/shared/listenerSet\";\nexport type SyncBillingGateListener = (organizationId: string | null) => void;\n\n/**\n * Signals that a sync write was rejected because its target organization cannot\n * sync (HTTP 402). Identified blocks are retained independently per org; a 402\n * without an org id is a conservative wildcard. Repeated signals for an already\n * blocked org are coalesced so they do not fan out into a refresh storm.\n */\nexport class SyncBillingGate {\n private readonly blockedOrganizationIds = new Set<string>();\n private readonly listeners = createListenerSet<[string | null]>();\n private readonly unknownBlockExemptOrganizationIds = new Set<string>();\n private hasUnknownOrganizationBlock = false;\n private lastBlockedOrganizationIdValue: string | null | undefined;\n\n get blockedOrganizationId(): string | null {\n return this.lastBlockedOrganizationIdValue ?? null;\n }\n\n /**\n * Whether a block is currently in effect — true even when the block carries an\n * unknown/omitted org (`null`), which `blockedOrganizationId` cannot distinguish\n * from the never-signalled state.\n */\n get isBlocked(): boolean {\n return (\n this.hasUnknownOrganizationBlock || this.blockedOrganizationIds.size > 0\n );\n }\n\n /**\n * Whether remote sync is blocked for a specific organization. An unattributed 402\n * without an organization id is treated conservatively as applying to every\n * organization, while an identified block remains isolated to its target.\n */\n isBlockedForOrganization(organizationId: string | null): boolean {\n if (organizationId === null) {\n return this.hasUnknownOrganizationBlock;\n }\n\n return (\n this.blockedOrganizationIds.has(organizationId) ||\n (this.hasUnknownOrganizationBlock &&\n !this.unknownBlockExemptOrganizationIds.has(organizationId))\n );\n }\n\n /**\n * The identified organizations *other than* `organizationId` that are\n * currently blocked — the footer sync indicator's \"some other org cannot\n * sync\" signal, since the shared billing snapshot only covers the active\n * organization. Passing `null` (no active org) lists every identified block.\n *\n * Unknown-org wildcard blocks are deliberately omitted: a caller that needs\n * to tell a lapsed organization apart from a free `local` one has to resolve\n * the org's billing, which an anonymous block gives it no way to do. Use\n * {@link isBlocked} for the conservative gate-everything reading.\n */\n listBlocksOutsideOrganization(\n organizationId: string | null,\n ): readonly string[] {\n return Array.from(this.blockedOrganizationIds).filter(\n (blockedId) => blockedId !== organizationId,\n );\n }\n\n notifyPaymentRequired(organizationId: string | null): void {\n if (organizationId === null) {\n if (\n this.hasUnknownOrganizationBlock &&\n this.unknownBlockExemptOrganizationIds.size === 0\n ) {\n return;\n }\n this.hasUnknownOrganizationBlock = true;\n this.unknownBlockExemptOrganizationIds.clear();\n } else {\n if (this.blockedOrganizationIds.has(organizationId)) {\n return;\n }\n this.blockedOrganizationIds.add(organizationId);\n this.unknownBlockExemptOrganizationIds.delete(organizationId);\n }\n this.lastBlockedOrganizationIdValue = organizationId;\n this.listeners.notify(organizationId);\n }\n\n /**\n * Clear one recovered organization without disturbing other org blocks. A\n * named recovery exempts only that org from an unattributed unknown-org wildcard;\n * unrelated orgs remain conservatively blocked. Omitting the argument retains\n * the public clear-all behavior. Recovery does not notify subscribers because\n * the billing refetch that observed it already represents the state change.\n */\n clearBlock(organizationId?: string | null): void {\n if (organizationId === undefined) {\n this.blockedOrganizationIds.clear();\n this.hasUnknownOrganizationBlock = false;\n this.unknownBlockExemptOrganizationIds.clear();\n this.lastBlockedOrganizationIdValue = undefined;\n return;\n }\n\n if (organizationId === null) {\n this.hasUnknownOrganizationBlock = false;\n this.unknownBlockExemptOrganizationIds.clear();\n } else {\n this.blockedOrganizationIds.delete(organizationId);\n if (this.hasUnknownOrganizationBlock) {\n this.unknownBlockExemptOrganizationIds.add(organizationId);\n }\n }\n this.refreshLastBlockedOrganizationId();\n }\n\n private refreshLastBlockedOrganizationId(): void {\n if (this.hasUnknownOrganizationBlock) {\n this.lastBlockedOrganizationIdValue = null;\n return;\n }\n\n this.lastBlockedOrganizationIdValue = Array.from(\n this.blockedOrganizationIds,\n ).at(-1);\n }\n\n subscribe = (listener: SyncBillingGateListener): (() => void) =>\n this.listeners.subscribe(listener);\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ApiClient } from "../../internal/api-client/index.js";
|
|
2
2
|
import type { DocumentProjectorRegistry } from "../../data/documents/documentKinds.js";
|
|
3
|
+
import type { DocumentPlacementCleanup } from "../../data/persistence/documents/documentsPersistence.js";
|
|
3
4
|
import type { DomainScope } from "../../data/shared/domainScope.js";
|
|
4
|
-
import type
|
|
5
|
+
import { type SecurityIncidentReporter } from "../../data/shared/securityIncidents.js";
|
|
5
6
|
import { type LocalUserIdentityCandidate, type TrustedUserIdentityResolver, type TrustedUserIdentityService } from "../../data/trustedUserIdentity/index.js";
|
|
6
|
-
import type { ContainerContentsRootAdopter } from "../../workflows/container-contents/index.js";
|
|
7
|
+
import type { ContainerContentsOrganizationHost, ContainerContentsRootAdopter } from "../../workflows/container-contents/index.js";
|
|
7
8
|
import { PrincipalPolicyService } from "../../workflows/principals/principalPolicyService.js";
|
|
8
9
|
import { type ProvisionedStatePrimer } from "../../workflows/registration/provisionedStatePrimer.js";
|
|
9
10
|
import type { WorkflowRuntimeGroups, WorkflowRuntimeUtilInput } from "../../workflows/shared/runtimeInput.js";
|
|
@@ -39,6 +40,8 @@ export interface InternalRuntime {
|
|
|
39
40
|
retirePrincipalHistoryProtection(): void;
|
|
40
41
|
readonly sessionGeneration: number;
|
|
41
42
|
readonly adoptRootContainer: ContainerContentsRootAdopter;
|
|
43
|
+
readonly deleteDocumentPlacements: DocumentPlacementCleanup;
|
|
44
|
+
readonly containerContentsOrganizations: ContainerContentsOrganizationHost;
|
|
42
45
|
readonly publicRuntime: Runtime;
|
|
43
46
|
boundUserId(signingKeyFingerprint: string): Promise<string | null>;
|
|
44
47
|
pinLocalUserIdentity(userId: string, candidate: LocalUserIdentityCandidate): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deleteDocumentPlacements } from "../../data/persistence/container-contents/documentContainerProjectionPersistence.js";
|
|
2
|
+
import { createListenerSet } from "../../data/shared/listenerSet.js";
|
|
3
|
+
import { runWithSecurityIncidentReporting, } from "../../data/shared/securityIncidents.js";
|
|
2
4
|
import { unavailableExecSql } from "../../data/sqlite/sqlSchema.js";
|
|
3
5
|
import { loadPinnedUserIdentity, } from "../../data/trustedUserIdentity/index.js";
|
|
6
|
+
import { containerContentsOrganizationHost } from "../../workflows/organizations/containerContentsHost.js";
|
|
4
7
|
import { PrincipalPolicyService } from "../../workflows/principals/principalPolicyService.js";
|
|
5
8
|
import { createProvisionedStatePrimer, } from "../../workflows/registration/provisionedStatePrimer.js";
|
|
6
9
|
import { acknowledgedSessionRoot } from "../session/sessionRootAuthority.js";
|
|
7
|
-
import { createListenerSet } from "./listenerSet.js";
|
|
8
10
|
import { createPrincipalHistoryProtectionCustody, } from "./principalHistoryProtection.js";
|
|
9
11
|
import { createPrincipalMutationApiCustody, } from "./principalMutationApi.js";
|
|
10
12
|
import { adoptSessionRootContainer } from "./rootContainerAdoption.js";
|
|
@@ -85,6 +87,8 @@ export function createRuntime(dependencies) {
|
|
|
85
87
|
return runtimeSubscription.sessionGeneration;
|
|
86
88
|
},
|
|
87
89
|
adoptRootContainer: (input) => adoptSessionRootContainer(dependencies, input),
|
|
90
|
+
deleteDocumentPlacements,
|
|
91
|
+
containerContentsOrganizations: containerContentsOrganizationHost,
|
|
88
92
|
boundUserId: (signingKeyFingerprint) => trustedUserIdentityService.boundUserId(signingKeyFingerprint),
|
|
89
93
|
async pinLocalUserIdentity(userId, candidate) {
|
|
90
94
|
await runWithSecurityIncidentReporting(dependencies.reportSecurityIncident, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflowRuntime.js","sourceRoot":"","sources":["workflowRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AAIjG,OAAO,EAAgB,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAEL,sBAAsB,GAGvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,OAAO,EACL,4BAA4B,GAE7B,MAAM,qDAAqD,CAAC;AAW7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAI1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EACL,uCAAuC,GAExC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iCAAiC,GAElC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AA4E1D,SAAS,wBAAwB,CAC/B,YAAyC,EACzC,cAA4B;IAE5B,OAAO,iCAAiC,CAAC;QACvC,GAAG,EAAE,YAAY,CAAC,GAAG;QACrB,0BAA0B,EAAE,YAAY,CAAC,0BAA0B;QACnE,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC;YACrE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC,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B,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,EAAE;gBACvC,mBAAmB,EAAE,YAAY,CAAC,mBAAmB;gBACrD,GAAG,EAAE,YAAY,CAAC,GAAG;gBACrB,QAAQ,EAAE,YAAY,CAAC,QAAQ;aAChC,CAAC,CAAC;YACH,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACtC,CAAC;QACD,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["import type { ApiClient } from \"@tearleads/api-client\";\nimport type { DocumentProjectorRegistry } from \"../../data/documents/documentKinds\";\nimport { runWithSecurityIncidentReporting } from \"../../data/keyingProjectionVerification/error\";\nimport type { PrincipalHistoryProtectionLease } from \"../../data/principals/principalHistoryProtection\";\nimport type { DomainScope } from \"../../data/shared/domainScope\";\nimport type { SecurityIncidentReporter } from \"../../data/shared/securityIncidents\";\nimport { type ExecSql, unavailableExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n type LocalUserIdentityCandidate,\n loadPinnedUserIdentity,\n type TrustedUserIdentityResolver,\n type TrustedUserIdentityService,\n} from \"../../data/trustedUserIdentity\";\nimport type { ContainerContentsRootAdopter } from \"../../workflows/container-contents\";\nimport { PrincipalPolicyService } from \"../../workflows/principals/principalPolicyService\";\nimport {\n createProvisionedStatePrimer,\n type ProvisionedStatePrimer,\n} from \"../../workflows/registration/provisionedStatePrimer\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeGroups,\n WorkflowRuntimeInfraInput,\n WorkflowRuntimeStateInput,\n WorkflowRuntimeUtilInput,\n} from \"../../workflows/shared/runtimeInput\";\nimport type { Blobs } from \"../blobs\";\nimport type { Identity } from \"../identity\";\nimport { acknowledgedSessionRoot } from \"../session/sessionRootAuthority\";\nimport type { Session, SessionSnapshot } from \"../session/sessionTypes\";\nimport type { Database } from \"./database\";\nimport type { Events } from \"./events\";\nimport { createListenerSet } from \"./listenerSet\";\nimport type { Network } from \"./network\";\nimport {\n createPrincipalHistoryProtectionCustody,\n type PrincipalHistoryKeyProvider,\n} from \"./principalHistoryProtection\";\nimport {\n createPrincipalMutationApiCustody,\n type PrincipalMutationApi,\n} from \"./principalMutationApi\";\nimport { adoptSessionRootContainer } from \"./rootContainerAdoption\";\nimport { createRuntimeIdentityResolution } from \"./runtimeIdentityResolution\";\nimport { reuseIfShallowEqual } from \"./runtimeInputReuse\";\nimport type { SyncBillingGate } from \"./syncBillingGate\";\n\ntype HostWorkflowRuntimeUtilInput = Omit<\n WorkflowRuntimeUtilInput,\n \"reportSecurityIncident\"\n>;\n\nexport interface WorkflowRuntimeInput\n extends Omit<WorkflowRuntimeGroups, \"util\"> {\n readonly util: HostWorkflowRuntimeUtilInput;\n}\n\nexport type RuntimeListener = () => void;\n\nexport interface Runtime {\n readonly version: number;\n input(containerId?: string | null | undefined): WorkflowRuntimeInput;\n subscribe(listener: RuntimeListener): () => void;\n}\n\nexport interface InternalWorkflowRuntimeInput extends WorkflowRuntimeGroups {\n readonly apiClient: PrincipalMutationApi;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n /** Bound to this snapshot's API client, executor, and history custody. */\n readonly principalPolicies: PrincipalPolicyService;\n}\n\nexport interface InternalRuntime {\n /** Resolved once by the composition root; constant for the client's life. */\n readonly identityTrustDomain: string | null;\n identityLinks: Pick<\n TrustedUserIdentityService,\n | \"createLink\"\n | \"createLinkFor\"\n | \"verifyLink\"\n | \"loadAdmissionPin\"\n | \"resolvePinned\"\n | \"resolveVerified\"\n | \"requireVerified\"\n >;\n retirePrincipalHistoryProtection(): void;\n readonly sessionGeneration: number;\n readonly adoptRootContainer: ContainerContentsRootAdopter;\n readonly publicRuntime: Runtime;\n boundUserId(signingKeyFingerprint: string): Promise<string | null>;\n pinLocalUserIdentity(\n userId: string,\n candidate: LocalUserIdentityCandidate,\n ): Promise<void>;\n readonly primeProvisionedState: ProvisionedStatePrimer;\n workflowInput(\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput;\n}\n\ninterface WorkflowRuntimeDependencies {\n api: ApiClient;\n blobs: Blobs;\n database: Database;\n documentProjectors: DocumentProjectorRegistry;\n events: Events;\n getDomainScope: () => DomainScope;\n identity: Identity;\n identityTrustDomain: string | null;\n log: (message: string) => void;\n logError: (message: string | Error, cause?: unknown) => void;\n network: Network;\n peerScope?: string | null;\n principalHistoryKeyProvider?: PrincipalHistoryKeyProvider | undefined;\n principalMutationTimeoutMs?: number | undefined;\n reportSecurityIncident: SecurityIncidentReporter;\n session: Session;\n syncBillingGate?: SyncBillingGate | undefined;\n}\n\nfunction createRuntimeMutationApi(\n dependencies: WorkflowRuntimeDependencies,\n readGeneration: () => number,\n) {\n return createPrincipalMutationApiCustody({\n api: dependencies.api,\n principalMutationTimeoutMs: dependencies.principalMutationTimeoutMs,\n readScope: () => {\n const { signingKeyPair, signingFingerprint } = dependencies.identity;\n const { userId, isAuthenticated } = dependencies.session;\n const identityTrustDomain = dependencies.identityTrustDomain;\n if (\n !isAuthenticated ||\n !userId ||\n !signingKeyPair ||\n !signingFingerprint ||\n !identityTrustDomain ||\n dependencies.database.status !== \"ready\"\n )\n return null;\n return {\n database: dependencies.getDomainScope(),\n execSql: dependencies.database.requireExecSql(\"principal mutation\"),\n generation: readGeneration(),\n identityTrustDomain,\n signingFingerprint,\n signingKeyPair,\n userId,\n };\n },\n });\n}\n\n/** Priming reads the runtime's database, identity and trust pins; it pins nothing. */\nfunction createRuntimeProvisioningPrimer(\n dependencies: WorkflowRuntimeDependencies,\n bindLease: () => PrincipalHistoryProtectionLease | undefined,\n readyExecSql: () => ExecSql | null,\n): ProvisionedStatePrimer {\n return createProvisionedStatePrimer({\n bindLease,\n execSqlFor: (database) =>\n dependencies.database.client === database ? readyExecSql() : null,\n loadPinnedIdentity: async (execSql, userId) =>\n dependencies.identityTrustDomain\n ? loadPinnedUserIdentity({\n execSql,\n identityTrustDomain: dependencies.identityTrustDomain,\n userId,\n })\n : null,\n logError: dependencies.logError,\n signingFingerprint: () => dependencies.identity.signingFingerprint,\n });\n}\n\nexport function createRuntime(\n dependencies: WorkflowRuntimeDependencies,\n): InternalRuntime {\n const readyExecSql = () =>\n dependencies.database.status === \"ready\"\n ? dependencies.database.requireExecSql(\"trusted user identity\")\n : null;\n const runtimeSubscription = createRuntimeSubscription(dependencies);\n const { trustedUserIdentityService, resolveTrustedUserIdentity } =\n createRuntimeIdentityResolution(\n dependencies,\n readyExecSql,\n () => runtimeSubscription.recoveryGeneration,\n );\n const historyProtection = createPrincipalHistoryProtectionCustody({\n keyProvider: dependencies.principalHistoryKeyProvider,\n readScope: () => {\n const signingFingerprint = dependencies.identity.signingFingerprint;\n const identityTrustDomain = dependencies.identityTrustDomain;\n if (\n !signingFingerprint ||\n !identityTrustDomain ||\n dependencies.database.status !== \"ready\"\n )\n return null;\n return {\n signingFingerprint,\n identityTrustDomain,\n database: dependencies.getDomainScope(),\n generation: runtimeSubscription.recoveryGeneration,\n };\n },\n });\n const runtimeInput = createRuntimeInputFactory(\n dependencies,\n resolveTrustedUserIdentity,\n historyProtection.bind,\n createRuntimeMutationApi(\n dependencies,\n () => runtimeSubscription.mutationGeneration,\n ).bind,\n );\n\n return {\n identityTrustDomain: dependencies.identityTrustDomain,\n identityLinks: trustedUserIdentityService,\n retirePrincipalHistoryProtection: historyProtection.retire,\n get sessionGeneration() {\n return runtimeSubscription.sessionGeneration;\n },\n adoptRootContainer: (input) =>\n adoptSessionRootContainer(dependencies, input),\n boundUserId: (signingKeyFingerprint) =>\n trustedUserIdentityService.boundUserId(signingKeyFingerprint),\n async pinLocalUserIdentity(userId, candidate) {\n await runWithSecurityIncidentReporting(\n dependencies.reportSecurityIncident,\n {\n objectId: userId,\n objectKind: \"user\",\n operation: \"user.identity.pin_local\",\n organizationId: dependencies.session.organizationId,\n },\n () => trustedUserIdentityService.pinLocal(userId, candidate),\n );\n },\n primeProvisionedState: createRuntimeProvisioningPrimer(\n dependencies,\n historyProtection.bind,\n readyExecSql,\n ),\n publicRuntime: {\n get version() {\n return runtimeSubscription.version;\n },\n input: runtimeInput.hostInput,\n subscribe: runtimeSubscription.subscribe,\n },\n workflowInput: runtimeInput.workflowInput,\n };\n}\n\nfunction createRuntimeSubscription(dependencies: WorkflowRuntimeDependencies) {\n const listeners = createListenerSet();\n let version = 0;\n let sessionGeneration = 0;\n let recoveryGeneration = 0;\n let mutationGeneration = 0;\n let sessionSnapshot = dependencies.session.snapshot;\n const notifyListeners = () => {\n version += 1;\n listeners.notify();\n };\n\n const notifyAuthority = () => {\n recoveryGeneration += 1;\n mutationGeneration += 1;\n notifyListeners();\n };\n dependencies.database.subscribe(notifyAuthority);\n dependencies.events.subscribe(notifyListeners);\n dependencies.identity.subscribe(notifyAuthority);\n dependencies.network.subscribe(() => notifyListeners());\n dependencies.session.subscribe(() => {\n const next = dependencies.session.snapshot;\n if (sessionAuthorityChanged(sessionSnapshot, next)) {\n sessionGeneration += 1;\n recoveryGeneration += 1;\n }\n if (sessionScopeChanged(sessionSnapshot, next)) mutationGeneration += 1;\n sessionSnapshot = next;\n notifyListeners();\n });\n dependencies.syncBillingGate?.subscribe(notifyListeners);\n\n return {\n get mutationGeneration() {\n return mutationGeneration;\n },\n get recoveryGeneration() {\n return recoveryGeneration;\n },\n get sessionGeneration() {\n return sessionGeneration;\n },\n get version() {\n return version;\n },\n subscribe(listener: RuntimeListener): () => void {\n return listeners.subscribe(listener);\n },\n };\n}\n\ninterface RuntimeInputFactory {\n hostInput(containerId?: string | null | undefined): WorkflowRuntimeInput;\n workflowInput(\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput;\n}\n\nfunction sessionAuthInput({\n session,\n identity,\n}: WorkflowRuntimeDependencies): WorkflowRuntimeAuthInput {\n const signingFingerprint = identity.snapshot.signingFingerprint;\n return {\n defaultOrganizationId: session.defaultOrganizationId,\n rootContainerId: acknowledgedSessionRoot(session, signingFingerprint),\n isAuthenticated: session.isAuthenticated,\n isRoot: session.isRoot,\n organizationId: session.organizationId,\n userId: session.userId,\n };\n}\n\n/** Fields whose change invalidates work keyed on the session's authority. */\nfunction sessionAuthorityChanged(\n previous: SessionSnapshot,\n next: SessionSnapshot,\n): boolean {\n return (\n next.authToken !== previous.authToken || sessionScopeChanged(previous, next)\n );\n}\n\n// A transport token renewal cannot turn a definite write refusal into saved work.\n// Journal custody still expires on every change to its identity or storage scope.\nfunction sessionScopeChanged(\n previous: SessionSnapshot,\n next: SessionSnapshot,\n): boolean {\n return (\n next.isAuthenticated !== previous.isAuthenticated ||\n next.isRoot !== previous.isRoot ||\n next.organizationId !== previous.organizationId ||\n next.userId !== previous.userId\n );\n}\n\nfunction runtimeInputUtilities(\n dependencies: WorkflowRuntimeDependencies,\n util: WorkflowRuntimeUtilInput | undefined,\n): WorkflowRuntimeUtilInput {\n if (\n !util ||\n util.log !== dependencies.log ||\n util.logError !== dependencies.logError ||\n util.reportSecurityIncident !== dependencies.reportSecurityIncident\n ) {\n util = {\n isRemoteSyncBlocked: (organizationId) =>\n dependencies.syncBillingGate?.isBlockedForOrganization(\n organizationId,\n ) ?? false,\n log: dependencies.log,\n logError: dependencies.logError,\n reportSecurityIncident: dependencies.reportSecurityIncident,\n };\n }\n return util;\n}\n\nfunction createRuntimeInputFactory(\n dependencies: WorkflowRuntimeDependencies,\n resolveTrustedUserIdentity: TrustedUserIdentityResolver,\n bindHistoryProtection: () => PrincipalHistoryProtectionLease | undefined,\n bindMutationApi: () => PrincipalMutationApi,\n): RuntimeInputFactory {\n let auth: WorkflowRuntimeAuthInput | undefined;\n let crypto: WorkflowRuntimeCryptoInput | undefined;\n let infra: WorkflowRuntimeInfraInput | undefined;\n let state: WorkflowRuntimeStateInput | undefined;\n let util: WorkflowRuntimeUtilInput | undefined;\n let hostUtil: HostWorkflowRuntimeUtilInput | undefined;\n\n const workflowInput = (\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput => {\n const dbStatus = dependencies.database.status;\n const execSql =\n dbStatus === \"ready\"\n ? dependencies.database.requireExecSql(\"tearleads.runtime.input\")\n : unavailableExecSql;\n const nextContainerId =\n (containerId === undefined\n ? dependencies.session.containerId\n : containerId) ?? null;\n\n auth = reuseIfShallowEqual(auth, sessionAuthInput(dependencies));\n crypto = reuseIfShallowEqual(crypto, {\n encapsulationKeyPair: dependencies.identity.encapsulationKeyPair,\n signingFingerprint: dependencies.identity.signingFingerprint,\n signingKeyPair: dependencies.identity.signingKeyPair,\n });\n infra = reuseIfShallowEqual(infra, {\n blobStore: dependencies.blobs.store,\n dbStatus,\n documentProjectors: dependencies.documentProjectors,\n // Runtime consumers branch on dbStatus before touching SQLite. The\n // fallback preserves the runtime shape and catches lifecycle bugs.\n execSql,\n });\n state = reuseIfShallowEqual(state, {\n containerId: nextContainerId,\n domainScope: dependencies.getDomainScope(),\n events: dependencies.events.events,\n // Resolved sync-online: workflows treat local-only mode exactly like being\n // offline (no server I/O), while `tearleads.network` stays the truthful\n // connectivity signal for host/UI. See Session.syncEnabled.\n online: dependencies.network.online && dependencies.session.syncEnabled,\n peerScope: dependencies.peerScope ?? null,\n serverEventsConnectionGeneration:\n dependencies.events.connectionGeneration,\n serverEventsPendingConnectAttempt:\n dependencies.events.pendingConnectAttempt,\n });\n util = runtimeInputUtilities(dependencies, util);\n\n const apiClient = bindMutationApi();\n return {\n apiClient,\n auth,\n crypto,\n infra,\n state,\n util,\n resolveTrustedUserIdentity,\n // Binds this snapshot's lease now; work on an older snapshot keeps its own.\n principalPolicies: new PrincipalPolicyService({\n apiClient,\n infra,\n state,\n util,\n resolveTrustedUserIdentity,\n withPrincipalHistoryProtection: bindHistoryProtection(),\n }),\n };\n };\n\n return {\n hostInput(containerId) {\n const {\n apiClient: _apiClient,\n resolveTrustedUserIdentity: _resolveTrustedUserIdentity,\n principalPolicies: _principalPolicies,\n util: workflowUtil,\n ...input\n } = workflowInput(containerId);\n hostUtil = reuseIfShallowEqual(hostUtil, {\n isRemoteSyncBlocked: workflowUtil.isRemoteSyncBlocked,\n log: workflowUtil.log,\n logError: workflowUtil.logError,\n });\n return { ...input, util: hostUtil };\n },\n workflowInput,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflowRuntime.js","sourceRoot":"","sources":["workflowRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kFAAkF,CAAC;AAI5H,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,gCAAgC,GAEjC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAgB,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAEL,sBAAsB,GAGvB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qDAAqD,CAAC;AACxG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,OAAO,EACL,4BAA4B,GAE7B,MAAM,qDAAqD,CAAC;AAW7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAK1E,OAAO,EACL,uCAAuC,GAExC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iCAAiC,GAElC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AA8E1D,SAAS,wBAAwB,CAC/B,YAAyC,EACzC,cAA4B;IAE5B,OAAO,iCAAiC,CAAC;QACvC,GAAG,EAAE,YAAY,CAAC,GAAG;QACrB,0BAA0B,EAAE,YAAY,CAAC,0BAA0B;QACnE,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC;YACrE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC,OAAO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AG,aAAa,CAAC,WAAW,CAAC,CAAC;YAC/B,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,EAAE;gBACvC,mBAAmB,EAAE,YAAY,CAAC,mBAAmB;gBACrD,GAAG,EAAE,YAAY,CAAC,GAAG;gBACrB,QAAQ,EAAE,YAAY,CAAC,QAAQ;aAChC,CAAC,CAAC;YACH,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACtC,CAAC;QACD,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["import type { ApiClient } from \"@tearleads/api-client\";\nimport type { DocumentProjectorRegistry } from \"../../data/documents/documentKinds\";\nimport { deleteDocumentPlacements } from \"../../data/persistence/container-contents/documentContainerProjectionPersistence\";\nimport type { DocumentPlacementCleanup } from \"../../data/persistence/documents/documentsPersistence\";\nimport type { PrincipalHistoryProtectionLease } from \"../../data/principals/principalHistoryProtection\";\nimport type { DomainScope } from \"../../data/shared/domainScope\";\nimport { createListenerSet } from \"../../data/shared/listenerSet\";\nimport {\n runWithSecurityIncidentReporting,\n type SecurityIncidentReporter,\n} from \"../../data/shared/securityIncidents\";\nimport { type ExecSql, unavailableExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n type LocalUserIdentityCandidate,\n loadPinnedUserIdentity,\n type TrustedUserIdentityResolver,\n type TrustedUserIdentityService,\n} from \"../../data/trustedUserIdentity\";\nimport type {\n ContainerContentsOrganizationHost,\n ContainerContentsRootAdopter,\n} from \"../../workflows/container-contents\";\nimport { containerContentsOrganizationHost } from \"../../workflows/organizations/containerContentsHost\";\nimport { PrincipalPolicyService } from \"../../workflows/principals/principalPolicyService\";\nimport {\n createProvisionedStatePrimer,\n type ProvisionedStatePrimer,\n} from \"../../workflows/registration/provisionedStatePrimer\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeGroups,\n WorkflowRuntimeInfraInput,\n WorkflowRuntimeStateInput,\n WorkflowRuntimeUtilInput,\n} from \"../../workflows/shared/runtimeInput\";\nimport type { Blobs } from \"../blobs\";\nimport type { Identity } from \"../identity\";\nimport { acknowledgedSessionRoot } from \"../session/sessionRootAuthority\";\nimport type { Session, SessionSnapshot } from \"../session/sessionTypes\";\nimport type { Database } from \"./database\";\nimport type { Events } from \"./events\";\nimport type { Network } from \"./network\";\nimport {\n createPrincipalHistoryProtectionCustody,\n type PrincipalHistoryKeyProvider,\n} from \"./principalHistoryProtection\";\nimport {\n createPrincipalMutationApiCustody,\n type PrincipalMutationApi,\n} from \"./principalMutationApi\";\nimport { adoptSessionRootContainer } from \"./rootContainerAdoption\";\nimport { createRuntimeIdentityResolution } from \"./runtimeIdentityResolution\";\nimport { reuseIfShallowEqual } from \"./runtimeInputReuse\";\nimport type { SyncBillingGate } from \"./syncBillingGate\";\n\ntype HostWorkflowRuntimeUtilInput = Omit<\n WorkflowRuntimeUtilInput,\n \"reportSecurityIncident\"\n>;\n\nexport interface WorkflowRuntimeInput\n extends Omit<WorkflowRuntimeGroups, \"util\"> {\n readonly util: HostWorkflowRuntimeUtilInput;\n}\n\nexport type RuntimeListener = () => void;\n\nexport interface Runtime {\n readonly version: number;\n input(containerId?: string | null | undefined): WorkflowRuntimeInput;\n subscribe(listener: RuntimeListener): () => void;\n}\n\nexport interface InternalWorkflowRuntimeInput extends WorkflowRuntimeGroups {\n readonly apiClient: PrincipalMutationApi;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n /** Bound to this snapshot's API client, executor, and history custody. */\n readonly principalPolicies: PrincipalPolicyService;\n}\n\nexport interface InternalRuntime {\n /** Resolved once by the composition root; constant for the client's life. */\n readonly identityTrustDomain: string | null;\n identityLinks: Pick<\n TrustedUserIdentityService,\n | \"createLink\"\n | \"createLinkFor\"\n | \"verifyLink\"\n | \"loadAdmissionPin\"\n | \"resolvePinned\"\n | \"resolveVerified\"\n | \"requireVerified\"\n >;\n retirePrincipalHistoryProtection(): void;\n readonly sessionGeneration: number;\n readonly adoptRootContainer: ContainerContentsRootAdopter;\n readonly deleteDocumentPlacements: DocumentPlacementCleanup;\n readonly containerContentsOrganizations: ContainerContentsOrganizationHost;\n readonly publicRuntime: Runtime;\n boundUserId(signingKeyFingerprint: string): Promise<string | null>;\n pinLocalUserIdentity(\n userId: string,\n candidate: LocalUserIdentityCandidate,\n ): Promise<void>;\n readonly primeProvisionedState: ProvisionedStatePrimer;\n workflowInput(\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput;\n}\n\ninterface WorkflowRuntimeDependencies {\n api: ApiClient;\n blobs: Blobs;\n database: Database;\n documentProjectors: DocumentProjectorRegistry;\n events: Events;\n getDomainScope: () => DomainScope;\n identity: Identity;\n identityTrustDomain: string | null;\n log: (message: string) => void;\n logError: (message: string | Error, cause?: unknown) => void;\n network: Network;\n peerScope?: string | null;\n principalHistoryKeyProvider?: PrincipalHistoryKeyProvider | undefined;\n principalMutationTimeoutMs?: number | undefined;\n reportSecurityIncident: SecurityIncidentReporter;\n session: Session;\n syncBillingGate?: SyncBillingGate | undefined;\n}\n\nfunction createRuntimeMutationApi(\n dependencies: WorkflowRuntimeDependencies,\n readGeneration: () => number,\n) {\n return createPrincipalMutationApiCustody({\n api: dependencies.api,\n principalMutationTimeoutMs: dependencies.principalMutationTimeoutMs,\n readScope: () => {\n const { signingKeyPair, signingFingerprint } = dependencies.identity;\n const { userId, isAuthenticated } = dependencies.session;\n const identityTrustDomain = dependencies.identityTrustDomain;\n if (\n !isAuthenticated ||\n !userId ||\n !signingKeyPair ||\n !signingFingerprint ||\n !identityTrustDomain ||\n dependencies.database.status !== \"ready\"\n )\n return null;\n return {\n database: dependencies.getDomainScope(),\n execSql: dependencies.database.requireExecSql(\"principal mutation\"),\n generation: readGeneration(),\n identityTrustDomain,\n signingFingerprint,\n signingKeyPair,\n userId,\n };\n },\n });\n}\n\n/** Priming reads the runtime's database, identity and trust pins; it pins nothing. */\nfunction createRuntimeProvisioningPrimer(\n dependencies: WorkflowRuntimeDependencies,\n bindLease: () => PrincipalHistoryProtectionLease | undefined,\n readyExecSql: () => ExecSql | null,\n): ProvisionedStatePrimer {\n return createProvisionedStatePrimer({\n bindLease,\n execSqlFor: (database) =>\n dependencies.database.client === database ? readyExecSql() : null,\n loadPinnedIdentity: async (execSql, userId) =>\n dependencies.identityTrustDomain\n ? loadPinnedUserIdentity({\n execSql,\n identityTrustDomain: dependencies.identityTrustDomain,\n userId,\n })\n : null,\n logError: dependencies.logError,\n signingFingerprint: () => dependencies.identity.signingFingerprint,\n });\n}\n\nexport function createRuntime(\n dependencies: WorkflowRuntimeDependencies,\n): InternalRuntime {\n const readyExecSql = () =>\n dependencies.database.status === \"ready\"\n ? dependencies.database.requireExecSql(\"trusted user identity\")\n : null;\n const runtimeSubscription = createRuntimeSubscription(dependencies);\n const { trustedUserIdentityService, resolveTrustedUserIdentity } =\n createRuntimeIdentityResolution(\n dependencies,\n readyExecSql,\n () => runtimeSubscription.recoveryGeneration,\n );\n const historyProtection = createPrincipalHistoryProtectionCustody({\n keyProvider: dependencies.principalHistoryKeyProvider,\n readScope: () => {\n const signingFingerprint = dependencies.identity.signingFingerprint;\n const identityTrustDomain = dependencies.identityTrustDomain;\n if (\n !signingFingerprint ||\n !identityTrustDomain ||\n dependencies.database.status !== \"ready\"\n )\n return null;\n return {\n signingFingerprint,\n identityTrustDomain,\n database: dependencies.getDomainScope(),\n generation: runtimeSubscription.recoveryGeneration,\n };\n },\n });\n const runtimeInput = createRuntimeInputFactory(\n dependencies,\n resolveTrustedUserIdentity,\n historyProtection.bind,\n createRuntimeMutationApi(\n dependencies,\n () => runtimeSubscription.mutationGeneration,\n ).bind,\n );\n\n return {\n identityTrustDomain: dependencies.identityTrustDomain,\n identityLinks: trustedUserIdentityService,\n retirePrincipalHistoryProtection: historyProtection.retire,\n get sessionGeneration() {\n return runtimeSubscription.sessionGeneration;\n },\n adoptRootContainer: (input) =>\n adoptSessionRootContainer(dependencies, input),\n deleteDocumentPlacements,\n containerContentsOrganizations: containerContentsOrganizationHost,\n boundUserId: (signingKeyFingerprint) =>\n trustedUserIdentityService.boundUserId(signingKeyFingerprint),\n async pinLocalUserIdentity(userId, candidate) {\n await runWithSecurityIncidentReporting(\n dependencies.reportSecurityIncident,\n {\n objectId: userId,\n objectKind: \"user\",\n operation: \"user.identity.pin_local\",\n organizationId: dependencies.session.organizationId,\n },\n () => trustedUserIdentityService.pinLocal(userId, candidate),\n );\n },\n primeProvisionedState: createRuntimeProvisioningPrimer(\n dependencies,\n historyProtection.bind,\n readyExecSql,\n ),\n publicRuntime: {\n get version() {\n return runtimeSubscription.version;\n },\n input: runtimeInput.hostInput,\n subscribe: runtimeSubscription.subscribe,\n },\n workflowInput: runtimeInput.workflowInput,\n };\n}\n\nfunction createRuntimeSubscription(dependencies: WorkflowRuntimeDependencies) {\n const listeners = createListenerSet();\n let version = 0;\n let sessionGeneration = 0;\n let recoveryGeneration = 0;\n let mutationGeneration = 0;\n let sessionSnapshot = dependencies.session.snapshot;\n const notifyListeners = () => {\n version += 1;\n listeners.notify();\n };\n\n const notifyAuthority = () => {\n recoveryGeneration += 1;\n mutationGeneration += 1;\n notifyListeners();\n };\n dependencies.database.subscribe(notifyAuthority);\n dependencies.events.subscribe(notifyListeners);\n dependencies.identity.subscribe(notifyAuthority);\n dependencies.network.subscribe(() => notifyListeners());\n dependencies.session.subscribe(() => {\n const next = dependencies.session.snapshot;\n if (sessionAuthorityChanged(sessionSnapshot, next)) {\n sessionGeneration += 1;\n recoveryGeneration += 1;\n }\n if (sessionScopeChanged(sessionSnapshot, next)) mutationGeneration += 1;\n sessionSnapshot = next;\n notifyListeners();\n });\n dependencies.syncBillingGate?.subscribe(notifyListeners);\n\n return {\n get mutationGeneration() {\n return mutationGeneration;\n },\n get recoveryGeneration() {\n return recoveryGeneration;\n },\n get sessionGeneration() {\n return sessionGeneration;\n },\n get version() {\n return version;\n },\n subscribe(listener: RuntimeListener): () => void {\n return listeners.subscribe(listener);\n },\n };\n}\n\ninterface RuntimeInputFactory {\n hostInput(containerId?: string | null | undefined): WorkflowRuntimeInput;\n workflowInput(\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput;\n}\n\nfunction sessionAuthInput({\n session,\n identity,\n}: WorkflowRuntimeDependencies): WorkflowRuntimeAuthInput {\n const signingFingerprint = identity.snapshot.signingFingerprint;\n return {\n defaultOrganizationId: session.defaultOrganizationId,\n rootContainerId: acknowledgedSessionRoot(session, signingFingerprint),\n isAuthenticated: session.isAuthenticated,\n isRoot: session.isRoot,\n organizationId: session.organizationId,\n userId: session.userId,\n };\n}\n\n/** Fields whose change invalidates work keyed on the session's authority. */\nfunction sessionAuthorityChanged(\n previous: SessionSnapshot,\n next: SessionSnapshot,\n): boolean {\n return (\n next.authToken !== previous.authToken || sessionScopeChanged(previous, next)\n );\n}\n\n// A transport token renewal cannot turn a definite write refusal into saved work.\n// Journal custody still expires on every change to its identity or storage scope.\nfunction sessionScopeChanged(\n previous: SessionSnapshot,\n next: SessionSnapshot,\n): boolean {\n return (\n next.isAuthenticated !== previous.isAuthenticated ||\n next.isRoot !== previous.isRoot ||\n next.organizationId !== previous.organizationId ||\n next.userId !== previous.userId\n );\n}\n\nfunction runtimeInputUtilities(\n dependencies: WorkflowRuntimeDependencies,\n util: WorkflowRuntimeUtilInput | undefined,\n): WorkflowRuntimeUtilInput {\n if (\n !util ||\n util.log !== dependencies.log ||\n util.logError !== dependencies.logError ||\n util.reportSecurityIncident !== dependencies.reportSecurityIncident\n ) {\n util = {\n isRemoteSyncBlocked: (organizationId) =>\n dependencies.syncBillingGate?.isBlockedForOrganization(\n organizationId,\n ) ?? false,\n log: dependencies.log,\n logError: dependencies.logError,\n reportSecurityIncident: dependencies.reportSecurityIncident,\n };\n }\n return util;\n}\n\nfunction createRuntimeInputFactory(\n dependencies: WorkflowRuntimeDependencies,\n resolveTrustedUserIdentity: TrustedUserIdentityResolver,\n bindHistoryProtection: () => PrincipalHistoryProtectionLease | undefined,\n bindMutationApi: () => PrincipalMutationApi,\n): RuntimeInputFactory {\n let auth: WorkflowRuntimeAuthInput | undefined;\n let crypto: WorkflowRuntimeCryptoInput | undefined;\n let infra: WorkflowRuntimeInfraInput | undefined;\n let state: WorkflowRuntimeStateInput | undefined;\n let util: WorkflowRuntimeUtilInput | undefined;\n let hostUtil: HostWorkflowRuntimeUtilInput | undefined;\n\n const workflowInput = (\n containerId?: string | null | undefined,\n ): InternalWorkflowRuntimeInput => {\n const dbStatus = dependencies.database.status;\n const execSql =\n dbStatus === \"ready\"\n ? dependencies.database.requireExecSql(\"tearleads.runtime.input\")\n : unavailableExecSql;\n const nextContainerId =\n (containerId === undefined\n ? dependencies.session.containerId\n : containerId) ?? null;\n\n auth = reuseIfShallowEqual(auth, sessionAuthInput(dependencies));\n crypto = reuseIfShallowEqual(crypto, {\n encapsulationKeyPair: dependencies.identity.encapsulationKeyPair,\n signingFingerprint: dependencies.identity.signingFingerprint,\n signingKeyPair: dependencies.identity.signingKeyPair,\n });\n infra = reuseIfShallowEqual(infra, {\n blobStore: dependencies.blobs.store,\n dbStatus,\n documentProjectors: dependencies.documentProjectors,\n // Runtime consumers branch on dbStatus before touching SQLite. The\n // fallback preserves the runtime shape and catches lifecycle bugs.\n execSql,\n });\n state = reuseIfShallowEqual(state, {\n containerId: nextContainerId,\n domainScope: dependencies.getDomainScope(),\n events: dependencies.events.events,\n // Resolved sync-online: workflows treat local-only mode exactly like being\n // offline (no server I/O), while `tearleads.network` stays the truthful\n // connectivity signal for host/UI. See Session.syncEnabled.\n online: dependencies.network.online && dependencies.session.syncEnabled,\n peerScope: dependencies.peerScope ?? null,\n serverEventsConnectionGeneration:\n dependencies.events.connectionGeneration,\n serverEventsPendingConnectAttempt:\n dependencies.events.pendingConnectAttempt,\n });\n util = runtimeInputUtilities(dependencies, util);\n\n const apiClient = bindMutationApi();\n return {\n apiClient,\n auth,\n crypto,\n infra,\n state,\n util,\n resolveTrustedUserIdentity,\n // Binds this snapshot's lease now; work on an older snapshot keeps its own.\n principalPolicies: new PrincipalPolicyService({\n apiClient,\n infra,\n state,\n util,\n resolveTrustedUserIdentity,\n withPrincipalHistoryProtection: bindHistoryProtection(),\n }),\n };\n };\n\n return {\n hostInput(containerId) {\n const {\n apiClient: _apiClient,\n resolveTrustedUserIdentity: _resolveTrustedUserIdentity,\n principalPolicies: _principalPolicies,\n util: workflowUtil,\n ...input\n } = workflowInput(containerId);\n hostUtil = reuseIfShallowEqual(hostUtil, {\n isRemoteSyncBlocked: workflowUtil.isRemoteSyncBlocked,\n log: workflowUtil.log,\n logError: workflowUtil.logError,\n });\n return { ...input, util: hostUtil };\n },\n workflowInput,\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type KeyingVerificationError } from "../../internal/crypto/index.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type SecurityIncident, type SecurityIncidentContext, type SecurityIncidentObjectKind, type SecurityIncidentReporter } from "../../data/shared/securityIncidents.js";
|
|
3
3
|
import type { Database } from "../runtime/database.js";
|
|
4
4
|
export type { SecurityIncident, SecurityIncidentObjectKind };
|
|
5
5
|
export type SecurityIncidentListener = (incident: SecurityIncident) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compareCanonicalStrings, isKeyingVerificationCode, } from "../../internal/crypto/index.js";
|
|
2
|
-
import { isKeyingVerificationError } from "../../data/keyingProjectionVerification/error.js";
|
|
3
2
|
import { appendSecurityIncident, listSecurityIncidents, } from "../../data/persistence/securityIncidentPersistence.js";
|
|
4
|
-
import { createListenerSet } from "
|
|
3
|
+
import { createListenerSet } from "../../data/shared/listenerSet.js";
|
|
4
|
+
import { isKeyingVerificationError, } from "../../data/shared/securityIncidents.js";
|
|
5
5
|
const MAX_BUFFERED_SECURITY_INCIDENTS = 100;
|
|
6
6
|
const MAX_EVIDENCE_HASH_COUNT = 32;
|
|
7
7
|
const MAX_EVIDENCE_HASH_KEY_LENGTH = 64;
|