@tearleads/client-sdk 0.1.63 → 0.1.64
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/data/documents/blob/shared/projection.js +1 -1
- package/data/documents/blob/shared/projection.js.map +1 -1
- package/data/documents/shared/projectionContentKeys.js +1 -1
- package/data/documents/shared/projectionContentKeys.js.map +1 -1
- package/data/documents/shared/syncResponseAuthorization.js +1 -1
- package/data/documents/shared/syncResponseAuthorization.js.map +1 -1
- package/data/keyingProjectionVerification/{accessManifestCheckpointEnforcement.js → checkpoints/accessManifestCheckpointEnforcement.js} +2 -2
- package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
- package/data/keyingProjectionVerification/{bundleVerification.js → checkpoints/bundleVerification.js} +5 -5
- package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{checkpointContext.d.ts → checkpoints/checkpointContext.d.ts} +6 -6
- package/data/keyingProjectionVerification/{checkpointContext.js → checkpoints/checkpointContext.js} +6 -6
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
- package/data/keyingProjectionVerification/{manifestCheckpointVerification.js → checkpoints/manifestCheckpointVerification.js} +2 -2
- package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerAncestorCitations.js → container/containerAncestorCitations.js} +4 -4
- package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
- package/data/keyingProjectionVerification/{containerCreateManifest.js → container/containerCreateManifest.js} +1 -1
- package/data/keyingProjectionVerification/{containerDestinationVerification.js → container/containerDestinationVerification.js} +4 -4
- package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerManifestVerification.js → container/containerManifestVerification.js} +7 -7
- package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerPathVerification.js → container/containerPathVerification.js} +2 -2
- package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerProjectionVerification.d.ts → container/containerProjectionVerification.d.ts} +7 -7
- package/data/keyingProjectionVerification/{containerProjectionVerification.js → container/containerProjectionVerification.js} +9 -9
- package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentDependencyPaths.d.ts → document/documentDependencyPaths.d.ts} +1 -1
- package/data/keyingProjectionVerification/{documentDependencyPaths.js → document/documentDependencyPaths.js} +3 -3
- package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
- package/data/keyingProjectionVerification/{documentManifestPolicies.js → document/documentManifestPolicies.js} +2 -2
- package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
- package/data/keyingProjectionVerification/{documentManifestPredecessor.js → document/documentManifestPredecessor.js} +1 -1
- package/data/keyingProjectionVerification/{documentManifestVerification.js → document/documentManifestVerification.js} +5 -5
- package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentProjectionVerification.d.ts → document/documentProjectionVerification.d.ts} +4 -4
- package/data/keyingProjectionVerification/{documentProjectionVerification.js → document/documentProjectionVerification.js} +9 -9
- package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeCheckpointCurrency.js → documentPurge/documentPurgeCheckpointCurrency.js} +12 -12
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeCheckpointEnforcement.js → documentPurge/documentPurgeCheckpointEnforcement.js} +2 -2
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeDocumentChainVerification.js → documentPurge/documentPurgeDocumentChainVerification.js} +8 -8
- package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePolicyCheckpoints.js → documentPurge/documentPurgePolicyCheckpoints.js} +2 -2
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePolicyCurrency.js → documentPurge/documentPurgePolicyCurrency.js} +4 -4
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePrincipalEvidence.js → documentPurge/documentPurgePrincipalEvidence.js} +3 -3
- package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeProofVerification.d.ts → documentPurge/documentPurgeProofVerification.d.ts} +5 -5
- package/data/keyingProjectionVerification/{documentPurgeProofVerification.js → documentPurge/documentPurgeProofVerification.js} +10 -10
- package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
- package/data/keyingProjectionVerification/index.d.ts +4 -4
- package/data/keyingProjectionVerification/index.js +4 -4
- package/data/keyingProjectionVerification/index.js.map +1 -1
- package/data/keyingProjectionVerification/{mergeProjectionPolicyEvidence.js → principalPolicy/mergeProjectionPolicyEvidence.js} +2 -2
- package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{organizationFounderBinding.js → principalPolicy/organizationFounderBinding.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
- package/data/keyingProjectionVerification/{principalPolicyCache.js → principalPolicy/principalPolicyCache.js} +6 -6
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
- package/data/keyingProjectionVerification/{principalPolicyVerification.js → principalPolicy/principalPolicyVerification.js} +12 -12
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{projectionAuthorizationEvidence.js → principalPolicy/projectionAuthorizationEvidence.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{projectionPolicyEvidence.js → principalPolicy/projectionPolicyEvidence.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{resolvedPrincipalPolicy.js → principalPolicy/resolvedPrincipalPolicy.js} +6 -6
- package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
- package/package.json +1 -1
- package/stores/container-contents/accessRestorationSweep.js +1 -1
- package/stores/container-contents/accessRestorationSweep.js.map +1 -1
- package/stores/container-contents/containerContentsStore.d.ts +1 -1
- package/stores/container-contents/containerContentsStore.js +12 -12
- package/stores/container-contents/containerContentsStore.js.map +1 -1
- package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
- package/stores/container-contents/{containerStatePersistence.js → containerState/containerStatePersistence.js} +2 -2
- package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
- package/stores/container-contents/{missingContainerState.js → containerState/missingContainerState.js} +1 -1
- package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
- package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
- package/stores/container-contents/{reconcilableContainer.d.ts → containerState/reconcilableContainer.d.ts} +1 -1
- package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
- package/stores/container-contents/{documentRecovery.js → documentWork/documentRecovery.js} +6 -6
- package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
- package/stores/container-contents/{documentRotation.js → documentWork/documentRotation.js} +2 -2
- package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
- package/stores/container-contents/{documentWork.js → documentWork/index.js} +1 -1
- package/stores/container-contents/documentWork/index.js.map +1 -0
- package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js} +3 -3
- package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
- package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js} +3 -3
- package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
- package/stores/container-contents/{startupHydration.js → hydration/startupHydration.js} +3 -3
- package/stores/container-contents/hydration/startupHydration.js.map +1 -0
- package/stores/container-contents/index.d.ts +3 -3
- package/stores/container-contents/index.js +2 -2
- package/stores/container-contents/index.js.map +1 -1
- package/stores/container-contents/localRefresh.js +2 -2
- package/stores/container-contents/localRefresh.js.map +1 -1
- package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js} +4 -4
- package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
- package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
- package/stores/container-contents/{groupRewrapOperation.js → operations/groupRewrapOperation.js} +2 -2
- package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
- package/stores/container-contents/{operations.js → operations/index.js} +18 -18
- package/stores/container-contents/operations/index.js.map +1 -0
- package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
- package/stores/container-contents/{reportShareFailure.js → operations/reportShareFailure.js} +4 -4
- package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
- package/stores/container-contents/{setContainerIconOperation.js → operations/setContainerIconOperation.js} +6 -6
- package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
- package/stores/container-contents/{shareOperations.js → operations/shareOperations.js} +6 -6
- package/stores/container-contents/operations/shareOperations.js.map +1 -0
- package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
- package/stores/container-contents/{remoteContainerIngestion.js → remoteEvents/remoteContainerIngestion.js} +4 -4
- package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
- package/stores/container-contents/{remoteEventProjectionInvalidation.js → remoteEvents/remoteEventProjectionInvalidation.js} +1 -1
- package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
- package/stores/container-contents/{remoteEventSync.js → remoteEvents/remoteEventSync.js} +4 -4
- package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
- package/stores/container-contents/{remoteWriteGuards.js → remoteWrites/remoteWriteGuards.js} +2 -2
- package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
- package/stores/container-contents/{remoteWriteQueue.js → remoteWrites/remoteWriteQueue.js} +1 -1
- package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
- package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
- package/stores/container-contents/state.d.ts +1 -1
- package/stores/container-contents/state.js +2 -2
- package/stores/container-contents/state.js.map +1 -1
- package/stores/container-contents/{syncAgent.d.ts → syncAgent/index.d.ts} +2 -2
- package/stores/container-contents/{syncAgent.js → syncAgent/index.js} +14 -14
- package/stores/container-contents/syncAgent/index.js.map +1 -0
- package/stores/container-contents/{metadataSyncSignal.js → syncAgent/metadataSyncSignal.js} +1 -1
- package/stores/container-contents/{metadataSyncSignal.js.map → syncAgent/metadataSyncSignal.js.map} +1 -1
- package/stores/container-contents/{syncAgentTypes.d.ts → syncAgent/syncAgentTypes.d.ts} +5 -5
- package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
- package/stores/container-contents/{syncLaneIteration.js → syncAgent/syncLaneIteration.js} +11 -11
- package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
- package/stores/container-contents/{existingSystemContainer.js → systemContainers/existingSystemContainer.js} +4 -4
- package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
- package/stores/container-contents/{organizationMetadataSystemContainer.js → systemContainers/organizationMetadataSystemContainer.js} +2 -2
- package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
- package/stores/container-contents/{systemContainerHydration.js → systemContainers/systemContainerHydration.js} +3 -3
- package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
- package/stores/container-contents/{systemContainerIcon.js → systemContainers/systemContainerIcon.js} +5 -5
- package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
- package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
- package/stores/container-contents/{systemContainerPostCreate.js → systemContainers/systemContainerPostCreate.js} +2 -2
- package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
- package/stores/container-contents/{systemContainerPromotion.js → systemContainers/systemContainerPromotion.js} +1 -1
- package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
- package/stores/container-contents/types.d.ts +2 -2
- package/stores/container-contents/types.js.map +1 -1
- package/stores/documents/documentStore/{attachmentSourceUpload.js → attachmentUpload/attachmentSourceUpload.js} +4 -4
- package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
- package/stores/documents/documentStore/{attachmentStaging.js → attachmentUpload/attachmentStaging.js} +5 -5
- package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadAttempt.js → attachmentUpload/attachmentUploadAttempt.js} +2 -2
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadLane.js → attachmentUpload/attachmentUploadLane.js} +1 -1
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadResume.js → attachmentUpload/attachmentUploadResume.js} +4 -4
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
- package/stores/documents/documentStore/{attachmentDetachState.js → attachments/attachmentDetachState.js} +1 -1
- package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
- package/stores/documents/documentStore/{attachmentHydration.js → attachments/attachmentHydration.js} +5 -5
- package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
- package/stores/documents/documentStore/{attachmentHydrationCommit.js → attachments/attachmentHydrationCommit.js} +3 -3
- package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
- package/stores/documents/documentStore/{attachmentIntents.js → attachments/attachmentIntents.js} +2 -2
- package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
- package/stores/documents/documentStore/{attachmentMutationPersistence.js → attachments/attachmentMutationPersistence.js} +4 -4
- package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
- package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
- package/stores/documents/documentStore/{attachmentPersistence.js → attachments/attachmentPersistence.js} +4 -4
- package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
- package/stores/documents/documentStore/{attachmentRemoval.js → attachments/attachmentRemoval.js} +11 -11
- package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
- package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
- package/stores/documents/documentStore/{attachmentWriteGeneration.js → attachments/attachmentWriteGeneration.js} +2 -2
- package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
- package/stores/documents/documentStore/{attachments.js → attachments/index.js} +11 -11
- package/stores/documents/documentStore/attachments/index.js.map +1 -0
- package/stores/documents/documentStore/{documentHistoryCompaction.js → history/documentHistoryCompaction.js} +4 -4
- package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
- package/stores/documents/documentStore/{durableDocumentReload.js → history/durableDocumentReload.js} +6 -6
- package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
- package/stores/documents/documentStore/{historyRebuild.js → history/historyRebuild.js} +6 -6
- package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
- package/stores/documents/{documentStore.d.ts → documentStore/index.d.ts} +5 -5
- package/stores/documents/{documentStore.js → documentStore/index.js} +18 -18
- package/stores/documents/documentStore/index.js.map +1 -0
- package/stores/documents/documentStore/{deferredInitialUpdate.js → initialization/deferredInitialUpdate.js} +9 -9
- package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
- package/stores/documents/documentStore/{initialization.js → initialization/index.js} +14 -14
- package/stores/documents/documentStore/initialization/index.js.map +1 -0
- package/stores/documents/documentStore/{initializationAttachments.js → initialization/initializationAttachments.js} +1 -1
- package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
- package/stores/documents/documentStore/{initializationHistory.js → initialization/initializationHistory.js} +3 -3
- package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
- package/stores/documents/documentStore/{initializationRecovery.js → initialization/initializationRecovery.js} +7 -7
- package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
- package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
- package/stores/documents/documentStore/mutations.js +2 -2
- package/stores/documents/documentStore/mutations.js.map +1 -1
- package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
- package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
- package/stores/documents/documentStore/persistence.js +3 -3
- package/stores/documents/documentStore/persistence.js.map +1 -1
- package/stores/documents/documentStore/{rotation.js → rotation/index.js} +14 -14
- package/stores/documents/documentStore/rotation/index.js.map +1 -0
- package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js} +2 -2
- package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
- package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js} +9 -9
- package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
- package/stores/documents/documentStore/rows.js +2 -2
- package/stores/documents/documentStore/rows.js.map +1 -1
- package/stores/documents/documentStore/state.js +1 -1
- package/stores/documents/documentStore/state.js.map +1 -1
- package/stores/documents/documentStore/{sync.js → sync/index.js} +7 -7
- package/stores/documents/documentStore/sync/index.js.map +1 -0
- package/stores/documents/documentStore/{pullContinuationInvalidation.js → sync/pullContinuationInvalidation.js} +3 -3
- package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
- package/stores/documents/documentStore/{remoteRevalidationTelemetry.js → sync/remoteRevalidationTelemetry.js} +1 -1
- package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
- package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
- package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
- package/stores/documents/documentStore/{syncAttachmentSettlement.js → sync/syncAttachmentSettlement.js} +3 -3
- package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
- package/stores/documents/documentStore/{syncAttachments.js → sync/syncAttachments.js} +7 -7
- package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
- package/stores/documents/documentStore/{syncDetachedAttachments.js → sync/syncDetachedAttachments.js} +7 -7
- package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
- package/stores/documents/documentStore/{syncFinalize.js → sync/syncFinalize.js} +9 -9
- package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
- package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
- package/stores/documents/documentStore/{syncOutgoingCoverage.js → sync/syncOutgoingCoverage.js} +4 -4
- package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
- package/stores/documents/documentStore/{syncRemoteSignals.js → sync/syncRemoteSignals.js} +4 -4
- package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
- package/stores/documents/documentStore/{syncRequest.js → sync/syncRequest.js} +8 -8
- package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
- package/stores/documents/documentStore/{syncShared.js → sync/syncShared.js} +8 -8
- package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
- package/stores/documents/documentStore/{syncUpdateImport.js → sync/syncUpdateImport.js} +3 -3
- package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
- package/stores/documents/documentStore/{versionCoverage.js → sync/versionCoverage.js} +1 -1
- package/stores/documents/index.d.ts +1 -1
- package/stores/documents/index.js +1 -1
- package/stores/local-projection/localProjectionStore.d.ts +1 -1
- package/stores/local-projection/localProjectionStore.js +1 -1
- package/stores/local-projection/localProjectionStore.js.map +1 -1
- package/stores/local-projection/registry.d.ts +1 -1
- package/stores/local-projection/types.d.ts +1 -1
- package/workflows/blobs/hydration/decrypt.js +1 -1
- package/workflows/blobs/hydration/decrypt.js.map +1 -1
- package/workflows/container-contents/container-state/{createAdoption.js → create/createAdoption.js} +6 -6
- package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
- package/workflows/container-contents/container-state/{createChild.js → create/createChild.js} +7 -7
- package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
- package/workflows/container-contents/container-state/{createIntentDepth.js → create/createIntentDepth.js} +2 -2
- package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
- package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
- package/workflows/container-contents/container-state/{createIntentSync.js → create/createIntentSync.js} +7 -7
- package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
- package/workflows/container-contents/container-state/{createTerminalFailure.js → create/createTerminalFailure.js} +2 -2
- package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
- package/workflows/container-contents/container-state/{createWithMetadata.js → create/createWithMetadata.js} +9 -9
- package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
- package/workflows/container-contents/container-state/{createWithMetadataPlan.js → create/createWithMetadataPlan.js} +4 -4
- package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
- package/workflows/container-contents/container-state/{localPurgeScope.js → purge/localPurgeScope.js} +1 -1
- package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTree.js → purge/purgeTree.js} +5 -5
- package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
- package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTreeContainerDeletion.js → purge/purgeTreeContainerDeletion.js} +1 -1
- package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTreeScope.js → purge/purgeTreeScope.js} +8 -8
- package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
- package/workflows/container-contents/container-state/{readLocalPurgeScope.js → purge/readLocalPurgeScope.js} +3 -3
- package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
- package/workflows/container-contents/container-state/remote.js +2 -2
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/{groupGrantVerification.js → share/groupGrantVerification.js} +8 -8
- package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
- package/workflows/container-contents/container-state/{groupShareEpoch.js → share/groupShareEpoch.js} +2 -2
- package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
- package/workflows/container-contents/container-state/{share.js → share/index.js} +8 -8
- package/workflows/container-contents/container-state/share/index.js.map +1 -0
- package/workflows/container-contents/container-state/{sharePersistence.js → share/sharePersistence.js} +3 -3
- package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
- package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
- package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
- package/workflows/container-contents/documentDiscovery/index.js +1 -1
- package/workflows/container-contents/documentDiscovery/index.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/destinationPrefetch.js.map +1 -0
- package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{destinationRootReload.js → destination/destinationRootReload.js} +1 -1
- package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{replacementBinding.js → destination/replacementBinding.js} +5 -5
- package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{verifiedDestination.js → destination/verifiedDestination.js} +9 -9
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
- package/workflows/container-contents/remoteHydration/index.js +4 -4
- package/workflows/container-contents/remoteHydration/index.js.map +1 -1
- package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{laneFetchMarkers.js → lanes/laneFetchMarkers.js} +1 -1
- package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{parentLaneFetch.js → lanes/parentLaneFetch.js} +2 -2
- package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
- package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
- package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
- package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
- package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
- package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
- package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{insertRemoteContainer.js → remoteContainers/insertRemoteContainer.js} +6 -6
- package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{remoteContainerPageHydration.js → remoteContainers/remoteContainerPageHydration.js} +7 -7
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{remoteContainerState.js → remoteContainers/remoteContainerState.js} +9 -9
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
- package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
- package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
- package/workflows/containers/child/{createProjection.d.ts → create/createProjection.d.ts} +2 -2
- package/workflows/containers/child/{createProjection.js → create/createProjection.js} +2 -2
- package/workflows/containers/child/create/createProjection.js.map +1 -0
- package/workflows/containers/child/{createSubmission.d.ts → create/createSubmission.d.ts} +7 -7
- package/workflows/containers/child/{createSubmission.js → create/createSubmission.js} +2 -2
- package/workflows/containers/child/create/createSubmission.js.map +1 -0
- package/workflows/containers/child/{create.d.ts → create/index.d.ts} +5 -5
- package/workflows/containers/child/{create.js → create/index.js} +15 -15
- package/workflows/containers/child/create/index.js.map +1 -0
- package/workflows/containers/child/{move.d.ts → move/index.d.ts} +5 -5
- package/workflows/containers/child/{move.js → move/index.js} +12 -12
- package/workflows/containers/child/move/index.js.map +1 -0
- package/workflows/containers/child/{moveArtifacts.js → move/moveArtifacts.js} +3 -3
- package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
- package/workflows/containers/child/{moveRotation.js → move/moveRotation.js} +3 -3
- package/workflows/containers/child/move/moveRotation.js.map +1 -0
- package/workflows/containers/child/{moveWraps.js → move/moveWraps.js} +5 -5
- package/workflows/containers/child/move/moveWraps.js.map +1 -0
- package/workflows/containers/child/mutationSubmit.js +1 -1
- package/workflows/containers/child/mutationSubmit.js.map +1 -1
- package/workflows/containers/child/{carriedDescendantRekeys.js → rekey/carriedDescendantRekeys.js} +4 -4
- package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
- package/workflows/containers/child/{rekey.d.ts → rekey/index.d.ts} +6 -6
- package/workflows/containers/child/{rekey.js → rekey/index.js} +13 -13
- package/workflows/containers/child/rekey/index.js.map +1 -0
- package/workflows/containers/child/{keyringOverrideLineage.d.ts → rekey/keyringOverrideLineage.d.ts} +1 -1
- package/workflows/containers/child/{keyringOverrideLineage.js → rekey/keyringOverrideLineage.js} +1 -1
- package/workflows/containers/child/{rekeyProjection.d.ts → rekey/rekeyProjection.d.ts} +2 -2
- package/workflows/containers/child/{rekeyProjection.js → rekey/rekeyProjection.js} +3 -3
- package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
- package/workflows/containers/child/{rekeyRemote.d.ts → rekey/rekeyRemote.d.ts} +6 -6
- package/workflows/containers/child/{rekeyRemote.js → rekey/rekeyRemote.js} +2 -2
- package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
- package/workflows/containers/child/revoke.js +5 -5
- package/workflows/containers/child/revoke.js.map +1 -1
- package/workflows/containers/child/{replacementPrincipalPolicyReferences.js → rotation/replacementPrincipalPolicyReferences.js} +2 -2
- package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
- package/workflows/containers/child/{rotationContext.js → rotation/rotationContext.js} +5 -5
- package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
- package/workflows/containers/child/{rotationPrincipalPolicies.js → rotation/rotationPrincipalPolicies.js} +2 -2
- package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
- package/workflows/containers/child/{rotationWraps.js → rotation/rotationWraps.js} +1 -1
- package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
- package/workflows/containers/child/{currentShareGrantMutation.js → share/currentShareGrantMutation.js} +6 -6
- package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
- package/workflows/containers/child/{currentSharePrincipalPolicy.js → share/currentSharePrincipalPolicy.js} +10 -10
- package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
- package/workflows/containers/child/{share.d.ts → share/index.d.ts} +8 -8
- package/workflows/containers/child/{share.js → share/index.js} +10 -10
- package/workflows/containers/child/share/index.js.map +1 -0
- package/workflows/containers/child/{runtimeCurrentGroupShare.js → share/runtimeCurrentGroupShare.js} +6 -6
- package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
- package/workflows/containers/child/{shareAncestorRepair.js → share/shareAncestorRepair.js} +4 -4
- package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
- package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts} +5 -5
- package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js} +7 -7
- package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
- package/workflows/containers/child/{sharePlanCore.d.ts → share/sharePlanCore.d.ts} +7 -7
- package/workflows/containers/child/{sharePlanCore.js → share/sharePlanCore.js} +6 -6
- package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
- package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts} +9 -9
- package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js} +13 -13
- package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
- package/workflows/containers/child/share/shareProjection.js.map +1 -0
- package/workflows/containers/index.d.ts +10 -10
- package/workflows/containers/index.js +10 -10
- package/workflows/containers/index.js.map +1 -1
- package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
- package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
- package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
- package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
- package/workflows/documents/purge/index.js +1 -1
- package/workflows/documents/purge/index.js.map +1 -1
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
- package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
- package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
- package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
- package/workflows/principals/policyCache/index.js +1 -1
- package/workflows/principals/policyCache/index.js.map +1 -1
- package/workflows/principals/policyRepair.js +1 -1
- package/workflows/principals/policyRepair.js.map +1 -1
- package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
- package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
- package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
- package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
- package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
- package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
- package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
- package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
- package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
- package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
- package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
- package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
- package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
- package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
- package/stores/container-contents/backgroundHydration.js.map +0 -1
- package/stores/container-contents/containerPurgeCore.js.map +0 -1
- package/stores/container-contents/containerStateMap.js.map +0 -1
- package/stores/container-contents/containerStatePersistence.js.map +0 -1
- package/stores/container-contents/documentRecovery.js.map +0 -1
- package/stores/container-contents/documentRotation.js.map +0 -1
- package/stores/container-contents/documentWork.js.map +0 -1
- package/stores/container-contents/emptyTrashOperation.js.map +0 -1
- package/stores/container-contents/existingSystemContainer.js.map +0 -1
- package/stores/container-contents/groupRewrapOperation.js.map +0 -1
- package/stores/container-contents/missingContainerState.js.map +0 -1
- package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
- package/stores/container-contents/operations.js.map +0 -1
- package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
- package/stores/container-contents/purgeContainerOperation.js.map +0 -1
- package/stores/container-contents/reconcilableContainer.js.map +0 -1
- package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
- package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
- package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
- package/stores/container-contents/remoteEventSync.js.map +0 -1
- package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
- package/stores/container-contents/remoteWriteGuards.js.map +0 -1
- package/stores/container-contents/remoteWriteQueue.js.map +0 -1
- package/stores/container-contents/reportShareFailure.js.map +0 -1
- package/stores/container-contents/setContainerIconOperation.js.map +0 -1
- package/stores/container-contents/shareOperations.js.map +0 -1
- package/stores/container-contents/startupHydration.js.map +0 -1
- package/stores/container-contents/syncAgent.js.map +0 -1
- package/stores/container-contents/syncAgentTypes.js.map +0 -1
- package/stores/container-contents/syncLaneIteration.js.map +0 -1
- package/stores/container-contents/systemContainerHydration.js.map +0 -1
- package/stores/container-contents/systemContainerIcon.js.map +0 -1
- package/stores/container-contents/systemContainerLookup.js.map +0 -1
- package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
- package/stores/container-contents/systemContainerPromotion.js.map +0 -1
- package/stores/container-contents/writeGeneration.js.map +0 -1
- package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
- package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
- package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
- package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
- package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
- package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
- package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
- package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
- package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
- package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
- package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
- package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
- package/stores/documents/documentStore/attachments.js.map +0 -1
- package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
- package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
- package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
- package/stores/documents/documentStore/historyRebuild.js.map +0 -1
- package/stores/documents/documentStore/initialization.js.map +0 -1
- package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
- package/stores/documents/documentStore/initializationHistory.js.map +0 -1
- package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
- package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
- package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
- package/stores/documents/documentStore/remoteWork.js.map +0 -1
- package/stores/documents/documentStore/rotation.js.map +0 -1
- package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
- package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
- package/stores/documents/documentStore/sync.js.map +0 -1
- package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
- package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
- package/stores/documents/documentStore/syncAttachments.js.map +0 -1
- package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
- package/stores/documents/documentStore/syncFinalize.js.map +0 -1
- package/stores/documents/documentStore/syncGeneration.js.map +0 -1
- package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
- package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
- package/stores/documents/documentStore/syncRequest.js.map +0 -1
- package/stores/documents/documentStore/syncShared.js.map +0 -1
- package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
- package/stores/documents/documentStore.js.map +0 -1
- package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
- package/workflows/container-contents/container-state/createChild.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
- package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
- package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
- package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
- package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
- package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
- package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
- package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
- package/workflows/container-contents/container-state/share.js.map +0 -1
- package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
- package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
- package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
- package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
- package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
- package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
- package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
- package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
- package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
- package/workflows/containers/child/create.js.map +0 -1
- package/workflows/containers/child/createProjection.js.map +0 -1
- package/workflows/containers/child/createSubmission.js.map +0 -1
- package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
- package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
- package/workflows/containers/child/move.js.map +0 -1
- package/workflows/containers/child/moveArtifacts.js.map +0 -1
- package/workflows/containers/child/moveRotation.js.map +0 -1
- package/workflows/containers/child/moveWraps.js.map +0 -1
- package/workflows/containers/child/rekey.js.map +0 -1
- package/workflows/containers/child/rekeyProjection.js.map +0 -1
- package/workflows/containers/child/rekeyRemote.js.map +0 -1
- package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
- package/workflows/containers/child/rotationContext.js.map +0 -1
- package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
- package/workflows/containers/child/rotationWraps.js.map +0 -1
- package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
- package/workflows/containers/child/share.js.map +0 -1
- package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
- package/workflows/containers/child/shareMaterialization.js.map +0 -1
- package/workflows/containers/child/sharePlanCore.js.map +0 -1
- package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
- package/workflows/containers/child/shareProjection.js.map +0 -1
- /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
- /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
- /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
- /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
- /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
- /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
- /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
- /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
- /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
- /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
- /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
- /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
- /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
- /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
- /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
- /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
- /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
- /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
- /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
- /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
- /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
- /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
- /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
- /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
- /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentPurgeCheckpointEnforcement.js","sourceRoot":"","sources":["documentPurgeCheckpointEnforcement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAGhG,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,UAAkB,EAClB,OAAgB;IAEhB,IAAI,MAAM,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,uBAAuB,CAC/B,UAAU,EACV,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport { loadDocumentPurgeCheckpoint } from \"../persistence/documentPurgeCheckpointPersistence\";\nimport type { ExecSql } from \"../sqlite/sqlSchema\";\n\nexport async function rejectPurgedDocumentProjection(\n documentId: string,\n execSql: ExecSql,\n): Promise<void> {\n if (await loadDocumentPurgeCheckpoint(execSql, documentId)) {\n throw new KeyingVerificationError(\n \"rollback\",\n \"Document writer projection targets a permanently purged document\",\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentPurgeDocumentChainVerification.js","sourceRoot":"","sources":["documentPurgeDocumentChainVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAMvB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gCAAgC,GAEjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAG5E,KAAK,UAAU,yBAAyB,CAAC,KAGxC;IACC,MAAM,QAAQ,GAAG,kBAAkB,CACjC,KAAK,CAAC,MAAM,CAAC,QAAQ,EACrB,8CAA8C,CAC/C,CAA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AE,KAAK,CAAC,cAAc;QACpC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;KACrD,CAAC,CAAC;IACH,gCAAgC,CAAC,KAAK,CAAC,iBAAiB,EAAE;QACxD,aAAa,EAAE,CAAC,gBAAgB,CAAC;QACjC,iBAAiB,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;KAChD,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyAuthorization,\n type VerifiedAccessManifestSnapshot,\n type VerifiedContainerAccessManifest,\n type VerifiedDocumentLinkSetManifest,\n type VerifiedDocumentLinkSetSnapshot,\n verifyDocumentLinkSetSnapshot,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n DocumentPurgeProofResponse,\n} from \"@tearleads/validators/response\";\nimport { readCanonicalJson } from \"../keying/canonicalJson\";\nimport {\n addBundleByHash,\n assertCanonicalEqual,\n verifyAccessEventBundle,\n} from \"./bundleVerification\";\nimport {\n observeAccessManifestCheckpoints,\n type ProjectionCheckpointContext,\n} from \"./checkpointContext\";\nimport { ProjectionDependencyUnavailableError } from \"./dependencyUnavailable\";\nimport { verifyDocumentManifestBundle } from \"./documentManifestVerification\";\nimport { loadManifestCheckpointVerification } from \"./manifestCheckpointVerification\";\nimport { readAccessManifest, readDocumentAccessEventBody } from \"./readers\";\nimport type { PrincipalPolicyCache, ProjectionUserKeyResolver } from \"./types\";\n\nasync function verifyPinnedChainEndpoint(input: {\n readonly bundle: AccessManifestBundleWireResponse;\n readonly checkpointContext: ProjectionCheckpointContext;\n}): Promise<VerifiedDocumentLinkSetSnapshot> {\n const manifest = readAccessManifest(\n input.bundle.manifest,\n \"Document purge predecessor endpoint manifest\",\n );\n const checkpointVerification = await loadManifestCheckpointVerification({\n current: manifest,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: new Map(),\n });\n const localCheckpoint = checkpointVerification.localCheckpoint;\n if (!localCheckpoint) {\n throw new ProjectionDependencyUnavailableError(\n \"Document purge history needs a local checkpoint or signed genesis\",\n );\n }\n if (\n localCheckpoint.epoch !== manifest.epoch ||\n localCheckpoint.manifestHash !== input.bundle.manifestHash\n ) {\n throw new KeyingVerificationError(\n localCheckpoint.epoch > manifest.epoch ? \"rollback\" : \"stale_predecessor\",\n \"Document purge predecessor chain does not start at the local checkpoint\",\n );\n }\n const verified = await verifyDocumentLinkSetSnapshot({\n ...checkpointVerification,\n expectedManifestHash: input.bundle.manifestHash,\n manifest,\n state: input.bundle.state,\n });\n if (!verified.ok) throw verified.error;\n assertCanonicalEqual({\n actual: input.bundle.state,\n expected: readCanonicalJson(\n verified.value.state,\n \"Document purge predecessor endpoint state\",\n ),\n label: \"Document purge predecessor endpoint state\",\n });\n return verified.value;\n}\n\nasync function recordSnapshotContainerEvidence(input: {\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly manifest: VerifiedDocumentLinkSetSnapshot;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<void> {\n if (!input.usedContainerManifests) return;\n const event = await verifyAccessEventBundle({\n bundle: input.proof.documentManifest,\n label: \"Document purge manifest snapshot\",\n resolveUserKey: input.resolveUserKey,\n });\n if (event.eventHash !== input.manifest.manifest.eventHash) {\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"Document purge manifest snapshot event is not bound to its manifest\",\n );\n }\n const body = readDocumentAccessEventBody(\n event.body,\n \"Document purge manifest snapshot event body\",\n );\n const manifestHashes = [\n ...event.event.dependencyManifestHashes,\n body.containerManifestHash,\n ];\n for (const manifestHash of manifestHashes) {\n for (const containerManifest of input.containerPathByManifestHash.get(\n manifestHash,\n ) ?? []) {\n input.usedContainerManifests.set(\n containerManifest.manifestHash,\n containerManifest,\n );\n }\n }\n}\n\nasync function verifyPurgeChainEndpoint(\n input: Parameters<typeof verifySignedPurgeDocumentManifestChain>[0] & {\n readonly endpoint: AccessManifestBundleWireResponse;\n readonly bundlesByHash: ReadonlyMap<\n string,\n AccessManifestBundleWireResponse\n >;\n readonly verifiedByHash: Map<string, VerifiedDocumentLinkSetManifest>;\n },\n): Promise<VerifiedDocumentLinkSetSnapshot | null> {\n const endpointManifest = readAccessManifest(\n input.endpoint.manifest,\n \"Document purge chain endpoint\",\n );\n if (endpointManifest.previousManifestHash === null) {\n await verifyDocumentManifestBundle({\n ...input,\n authorizationMembership: \"referenced\",\n bundle: input.endpoint,\n enforceLocalCheckpoint: false,\n label: \"Document purge genesis\",\n requireAuthorizationEvidence: true,\n });\n return null;\n }\n if (!input.enforceLocalCheckpoints) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Initial document purge history does not reach signed genesis\",\n );\n }\n return verifyPinnedChainEndpoint({\n bundle: input.endpoint,\n checkpointContext: input.checkpointContext,\n });\n}\n\nasync function verifySignedPurgeDocumentManifestChain(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<VerifiedDocumentLinkSetManifest> {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n addBundleByHash(\n bundlesByHash,\n input.proof.documentManifest,\n \"Document purge manifest\",\n );\n for (const [\n index,\n bundle,\n ] of input.proof.documentManifestPredecessors.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document purge predecessor[${index}]`,\n );\n }\n\n const endpoint =\n input.proof.documentManifestPredecessors.at(-1) ??\n input.proof.documentManifest;\n const verifiedByHash = new Map<string, VerifiedDocumentLinkSetManifest>();\n const trustedPredecessorByHash = new Map<\n string,\n VerifiedDocumentLinkSetSnapshot\n >();\n const verifiedEndpoint = await verifyPurgeChainEndpoint({\n ...input,\n endpoint,\n bundlesByHash,\n verifiedByHash,\n });\n if (verifiedEndpoint) {\n trustedPredecessorByHash.set(\n verifiedEndpoint.manifestHash,\n verifiedEndpoint,\n );\n }\n\n const verificationInput = {\n ...input,\n authorizationMembership: \"referenced\" as const,\n bundlesByHash,\n requireAuthorizationEvidence: true,\n trustedPredecessorByHash,\n verifiedByHash,\n };\n for (\n let index = input.proof.documentManifestPredecessors.length - 2;\n index >= 0;\n index -= 1\n ) {\n const bundle = input.proof.documentManifestPredecessors[index];\n if (!bundle) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n `Document purge predecessor[${index}] is missing`,\n );\n }\n await verifyDocumentManifestBundle({\n ...verificationInput,\n bundle,\n enforceLocalCheckpoint: false,\n label: `Document purge predecessor[${index}]`,\n });\n }\n const head = await verifyDocumentManifestBundle({\n ...verificationInput,\n bundle: input.proof.documentManifest,\n enforceLocalCheckpoint: input.enforceLocalCheckpoints,\n label: \"Document purge manifest\",\n });\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: [head],\n verifiedManifests: [...verifiedByHash.values()],\n });\n return head;\n}\n\nexport async function verifyPurgeDocumentManifest(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<VerifiedDocumentLinkSetManifest | VerifiedDocumentLinkSetSnapshot> {\n const verifiedByHash = new Map<string, VerifiedAccessManifestSnapshot>();\n const manifest = readAccessManifest(\n input.proof.documentManifest.manifest,\n \"Document purge manifest snapshot\",\n );\n const checkpointVerification = input.enforceLocalCheckpoints\n ? await loadManifestCheckpointVerification({\n current: manifest,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: verifiedByHash,\n })\n : undefined;\n const localCheckpoint = checkpointVerification?.localCheckpoint;\n const isPinnedHead =\n localCheckpoint?.epoch === manifest.epoch &&\n localCheckpoint.manifestHash === input.proof.documentManifest.manifestHash;\n // Baseline inspection may read a hash-only snapshot. Committing a purge\n // requires an exact existing pin or verified signed transitions from\n // that pin (or signed genesis for a fresh device).\n if (\n input.proof.documentManifestPredecessors.length > 0 ||\n (input.enforceLocalCheckpoints && !isPinnedHead)\n ) {\n return verifySignedPurgeDocumentManifestChain(input);\n }\n const verified = await verifyDocumentLinkSetSnapshot({\n ...(checkpointVerification ?? {}),\n expectedManifestHash: input.proof.documentManifest.manifestHash,\n manifest,\n state: input.proof.documentManifest.state,\n });\n if (!verified.ok) throw verified.error;\n const documentManifest = verified.value;\n await recordSnapshotContainerEvidence({\n containerPathByManifestHash: input.containerPathByManifestHash,\n manifest: documentManifest,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n usedContainerManifests: input.usedContainerManifests,\n });\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: [documentManifest],\n verifiedManifests: [...verifiedByHash.values()],\n });\n return documentManifest;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentPurgePolicyCheckpoints.js","sourceRoot":"","sources":["documentPurgePolicyCheckpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,mCAAmC,EACnC,4CAA4C,GAC7C,MAAM,4CAA4C,CAAC;AAGpD,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,KAKzD;IACC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACpC,IACE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9B,+BAA+B,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CACvD;YAED,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,uCAAuC,CACxC,CAAC;QACJ,MAAM,UAAU,GAAG,MAAM,mCAAmC,CAC1D,KAAK,CAAC,WAAW,EACjB,SAAS,CACV,CAAC;QACF,2EAA2E;QAC3E,uEAAuE;QACvE,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO;YAAE,SAAS;QACpE,MAAM,4CAA4C,CAChD,KAAK,CAAC,WAAW,EACjB,SAAS,EACT,SAAS,EACT,KAAK,CAAC,cAAc,CACrB,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport {\n loadStoredPrincipalPolicyCheckpoint,\n upsertPrincipalPolicyCheckpointInTransaction,\n} from \"../persistence/keyingCheckpointPersistence\";\nimport type { ClientSQLiteTransactionScope } from \"../sqlite/sqlitePersistenceRuntime\";\n\n/** After complete terminal-proof currency validation, admit only its bound sources. */\nexport async function admitDocumentPurgePolicyCheckpoints(input: {\n readonly transaction: ClientSQLiteTransactionScope;\n readonly organizationId: string | undefined;\n readonly policies: readonly VerifiedPrincipalPolicySelection[];\n readonly heads: readonly ReferencedPrincipalHead[];\n}): Promise<void> {\n const updatedAt = new Date().toISOString();\n for (const reference of input.heads) {\n if (\n !input.policies.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n )\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Purge source lacks verified inclusion\",\n );\n const checkpoint = await loadStoredPrincipalPolicyCheckpoint(\n input.transaction,\n reference,\n );\n // A newer privately authenticated prefix can prove ancestry, but is not an\n // observation admitted by this terminal proof. Preserve any newer pin.\n if (checkpoint && checkpoint.version >= reference.version) continue;\n await upsertPrincipalPolicyCheckpointInTransaction(\n input.transaction,\n reference,\n updatedAt,\n input.organizationId,\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentPurgePolicyCurrency.js","sourceRoot":"","sources":["documentPurgePolicyCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAE3F,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mCAAmC,GAEpC,MAAM,SAAS,CAAC;AAMjB,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,kCAAkC,CAAC,KAMxD;IACC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC/C,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0C,CAAC;IACpE,MAAM,QAAQ,GAAkC,EAAE,CAAC;IACnD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpC,wEAAwE;QACxE,6EAA6E;QAC7E,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,mCAAmC,CAAC,uBAAuB,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AAE,CAAC;gBAEtE,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,6DAA6D,CAC9D,CAAC;YACJ,yBAAyB,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YACvB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,mCAAmC,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n type VerifiedPrincipalPolicyCurrent,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport { loadPrincipalPolicyCheckpoint } from \"../persistence/keyingCheckpointPersistence\";\nimport type { ProjectionCheckpointContext } from \"./checkpointContext\";\nimport {\n observeProjectionLifetime,\n projectionLifetimeGuard,\n} from \"./projectionLifetimes\";\nimport {\n assertProjectionVerificationCurrent,\n type ReferencedPrincipalPolicyWarmer,\n} from \"./types\";\n\nexport type PurgePolicyCurrencyEvidence =\n | VerifiedPrincipalPolicySelection\n | VerifiedPrincipalPolicyCurrent;\n\n/** Authenticate connections to newer device pins without extending terminal grants or admitting heads. */\nexport async function recoverDocumentPurgePolicyCurrency(input: {\n readonly context: ProjectionCheckpointContext;\n readonly organizationId: string;\n readonly policies: readonly VerifiedPrincipalPolicySelection[];\n readonly warmer: ReferencedPrincipalPolicyWarmer | undefined;\n readonly stillCurrent: () => boolean;\n}): Promise<PurgePolicyCurrencyEvidence[]> {\n const resolve = input.warmer?.resolveReference;\n if (!resolve) return [...input.policies];\n const recoveryBatch = {};\n const recovered = new Map<string, VerifiedPrincipalPolicyCurrent>();\n const policies: PurgePolicyCurrencyEvidence[] = [];\n for (const policy of input.policies) {\n // Returned leases may include their caller predicate. Pass the original\n // lifetime, not the growing context guard, to avoid a recursive guard graph.\n const stillCurrent = input.stillCurrent;\n assertProjectionVerificationCurrent(projectionLifetimeGuard(input.context));\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n input.context.execSql,\n policy.principalType,\n policy.principalId,\n );\n if (!checkpoint || checkpoint.version <= policy.version) {\n policies.push(policy);\n continue;\n }\n const key = `${policy.principalType}:${policy.principalId}:${policy.stateHash}`;\n let bridge = recovered.get(key);\n if (!bridge) {\n const reference = {\n principalType: policy.principalType,\n principalId: policy.principalId,\n version: policy.version,\n stateHash: policy.stateHash,\n keyEpoch: policy.keyEpoch,\n keyFingerprint: policy.state.keyFingerprint,\n };\n const result = await resolve({\n organizationId: input.organizationId,\n reference,\n recoveryBatch,\n preferLocalHistory: true,\n stillCurrent,\n });\n assertProjectionVerificationCurrent(\n projectionLifetimeGuard(input.context),\n );\n assertProjectionVerificationCurrent(result.stillCurrent);\n if (\n result.organizationId !== input.organizationId ||\n !principalPolicyMatchesReference({ policy: result.policy, reference })\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Purge currency recovery does not bind its historical policy\",\n );\n observeProjectionLifetime(input.context, result.stillCurrent);\n bridge = result.policy;\n recovered.set(key, bridge);\n }\n policies.push(bridge);\n }\n assertProjectionVerificationCurrent(projectionLifetimeGuard(input.context));\n return policies;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentPurgePrincipalEvidence.js","sourceRoot":"","sources":["documentPurgePrincipalEvidence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,+BAA+B,EAM/B,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0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2BAA2B,CAAC;QACzD,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;QAClD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;QAC9D,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;QACtD,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,sBAAsB;KACvB,CAAC,CAAC;IACH,OAAO;QACL,gBAAgB;QAChB,GAAG,CAAC,MAAM,8BAA8B,CAAC;YACvC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;YAClD,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;YACxD,gBAAgB;YAChB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU;YAClC,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,sBAAsB,EAAE;gBACtB,GAAG,KAAK,CAAC,wBAAwB;gBACjC,GAAG,sBAAsB,CAAC,MAAM,EAAE;aACnC;YACD,0BAA0B,EAAE,KAAK,CAAC,0BAA0B;SAC7D,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyAuthorization,\n principalPolicyMatchesReference,\n type ReferencedPrincipalHead,\n type VerifiedContainerAccessManifest,\n type VerifiedDocumentLinkSetManifest,\n type VerifiedDocumentLinkSetSnapshot,\n type VerifiedPrincipalPolicySelection,\n verifyDocumentPurgeEvent,\n} from \"@tearleads/crypto\";\nimport type { DocumentPurgeProofResponse } from \"@tearleads/validators/response\";\nimport { parseOrganizationAuthorityDescriptor } from \"../principals/organizationAuthorityDescriptor\";\nimport { verifyStandaloneAccessEventBundle } from \"./bundleVerification\";\nimport type { ProjectionCheckpointContext } from \"./checkpointContext\";\nimport { verifyPurgeDocumentManifest } from \"./documentPurgeDocumentChainVerification\";\nimport type { PrincipalPolicyCache, ProjectionUserKeyResolver } from \"./types\";\n\nfunction principalIdentity(input: {\n readonly principalId: string;\n readonly principalType: string;\n}): string {\n return `${input.principalType}:${input.principalId}`;\n}\n\nfunction collectEvidenceContainerManifests(input: {\n readonly roots: readonly VerifiedContainerAccessManifest[];\n readonly verifiedByHash: ReadonlyMap<string, VerifiedContainerAccessManifest>;\n}): VerifiedContainerAccessManifest[] {\n const selected = new Map<string, VerifiedContainerAccessManifest>();\n const pending = [...input.roots];\n while (pending.length > 0) {\n const manifest = pending.shift();\n if (!manifest || selected.has(manifest.manifestHash)) continue;\n selected.set(manifest.manifestHash, manifest);\n for (const dependencyHash of [\n manifest.manifest.previousManifestHash,\n manifest.state.parentManifestHash,\n ]) {\n if (!dependencyHash) continue;\n const dependency = input.verifiedByHash.get(dependencyHash);\n if (dependency) pending.push(dependency);\n }\n }\n return [...selected.values()];\n}\n\nfunction requireExactPurgePrincipalEvidence<\n TPolicy extends PrincipalPolicyAuthorization,\n>(input: {\n readonly authorizationEvidence: readonly TPolicy[];\n readonly verifiedContainerManifests: readonly VerifiedContainerAccessManifest[];\n readonly policyEvidence: DocumentPurgeProofResponse[\"policyEvidence\"];\n}): TPolicy[] {\n const references: ReferencedPrincipalHead[] =\n input.verifiedContainerManifests.flatMap(\n (manifest) => manifest.state.referencedPrincipalHeads,\n );\n const requiredByPrincipal = new Set<string>();\n\n for (const reference of references) {\n const policy = input.authorizationEvidence.find((candidate) =>\n principalPolicyMatchesReference({ policy: candidate, reference }),\n );\n if (!policy) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Document purge proof omits referenced principal policy evidence\",\n );\n }\n const identity = principalIdentity(policy);\n requiredByPrincipal.add(identity);\n // External authority is verified incrementally by paged recovery. Its\n // historical entries need not be copied into this returned selection.\n }\n\n const allowed = new Set(requiredByPrincipal);\n // Paged recovery has authenticated these payloads against their signed\n // organization states and verified their exact group-head bindings. This\n // identity allow-list cannot authenticate an unverified directory payload.\n for (const { payload } of input.policyEvidence.organizationPayloads) {\n const directory = parseOrganizationAuthorityDescriptor(payload.ciphertext);\n if (\n directory.groupHeads.some((head) => allowed.has(principalIdentity(head)))\n ) {\n allowed.add(`group:${directory.adminGroupId}`);\n allowed.add(`organization:${directory.organizationId}`);\n }\n }\n if (\n input.authorizationEvidence.some(\n (policy) => !allowed.has(principalIdentity(policy)),\n )\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Document purge proof includes unrelated principal policy evidence\",\n );\n return input.authorizationEvidence.filter((policy) =>\n requiredByPrincipal.has(principalIdentity(policy)),\n );\n}\n\nasync function authenticateDocumentPurgeEvent(input: {\n readonly authorizationEvidence: readonly VerifiedPrincipalPolicySelection[];\n readonly authorizingContainerPath: readonly VerifiedContainerAccessManifest[];\n readonly documentManifest:\n | VerifiedDocumentLinkSetManifest\n | VerifiedDocumentLinkSetSnapshot;\n readonly expectedDocumentId: string;\n readonly purgeEvent: DocumentPurgeProofResponse[\"purgeEvent\"];\n readonly policyEvidence: DocumentPurgeProofResponse[\"policyEvidence\"];\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly rootContainerManifests: readonly VerifiedContainerAccessManifest[];\n readonly verifiedContainerManifests: ReadonlyMap<\n string,\n VerifiedContainerAccessManifest\n >;\n}): Promise<{\n readonly principalPolicies: VerifiedPrincipalPolicySelection[];\n readonly purgeEventHash: string;\n}> {\n const event = await verifyStandaloneAccessEventBundle({\n bundle: input.purgeEvent,\n label: \"Document purge event\",\n resolveUserKey: input.resolveUserKey,\n });\n const evidenceContainerManifests = collectEvidenceContainerManifests({\n roots: input.rootContainerManifests,\n verifiedByHash: input.verifiedContainerManifests,\n });\n const principalPolicies = requireExactPurgePrincipalEvidence({\n authorizationEvidence: input.authorizationEvidence,\n verifiedContainerManifests: evidenceContainerManifests,\n policyEvidence: input.policyEvidence,\n });\n const verified = await verifyDocumentPurgeEvent({\n authorizingContainerPath: input.authorizingContainerPath,\n documentManifest: input.documentManifest,\n event,\n expectedDocumentId: input.expectedDocumentId,\n principalPolicies,\n });\n if (!verified.ok) throw verified.error;\n return {\n principalPolicies: [...input.authorizationEvidence],\n purgeEventHash: verified.value.eventHash,\n };\n}\n\nexport async function authenticateDocumentPurgeArtifacts(input: {\n readonly authorizationEvidence: readonly VerifiedPrincipalPolicySelection[];\n readonly authorizingContainerPath: readonly VerifiedContainerAccessManifest[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly expectedDocumentId: string;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly verifiedContainerManifests: ReadonlyMap<\n string,\n VerifiedContainerAccessManifest\n >;\n}) {\n const usedContainerManifests = new Map<\n string,\n VerifiedContainerAccessManifest\n >();\n const documentManifest = await verifyPurgeDocumentManifest({\n authorizationEvidence: input.authorizationEvidence,\n checkpointContext: input.checkpointContext,\n containerPathByManifestHash: input.containerPathByManifestHash,\n enforceLocalCheckpoints: input.enforceLocalCheckpoints,\n principalPolicyCache: input.principalPolicyCache,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n usedContainerManifests,\n });\n return {\n documentManifest,\n ...(await authenticateDocumentPurgeEvent({\n authorizationEvidence: input.authorizationEvidence,\n authorizingContainerPath: input.authorizingContainerPath,\n documentManifest,\n expectedDocumentId: input.expectedDocumentId,\n purgeEvent: input.proof.purgeEvent,\n policyEvidence: input.proof.policyEvidence,\n resolveUserKey: input.resolveUserKey,\n rootContainerManifests: [\n ...input.authorizingContainerPath,\n ...usedContainerManifests.values(),\n ],\n verifiedContainerManifests: input.verifiedContainerManifests,\n })),\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docum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,UAAU,EAAE,KAAK,CAAC,kBAAkB;QACpC,oBAAoB,EAAE,gBAAgB,CAAC,YAAY;QACnD,cAAc,EAAE,gBAAgB,CAAC,KAAK,CAAC,cAAc;QACrD,cAAc;KACf,CAAC;IACF,OAAO;QACL,iBAAiB,EAAE,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,CAC7C,8BAA8B,CAAC;YAC7B,OAAO,EAAE,iBAAiB;YAC1B,uBAAuB;YACvB,OAAO;YACP,iBAAiB;YACjB,gBAAgB;YAChB,sBAAsB;SACvB,CAAC;QACJ,kBAAkB,EAAE,gBAAgB,CAAC,UAAU;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,KAAoC;IAEpC,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,gCAAgC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtE,OAAO;QACL,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAoC;IAEpC,OAAO,gCAAgC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import {\n type AccessManifestCheckpoint,\n KeyingVerificationError,\n type PrincipalPolicyAuthorization,\n type VerifiedContainerAccessManifest,\n type VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n DocumentPurgeProofResponse,\n} from \"@tearleads/validators/response\";\nimport { isDocumentPurgeProofResponse } from \"@tearleads/validators/response\";\nimport type { ExecSql } from \"../sqlite/sqlSchema\";\nimport { addBundleByHash } from \"./bundleVerification\";\nimport {\n createProjectionCheckpointContext,\n observeAccessManifestCheckpoints,\n} from \"./checkpointContext\";\nimport { verifyContainerManifestPath } from \"./containerPathVerification\";\nimport { verifiedContainerManifestsForBundles } from \"./containerProjectionVerification\";\nimport {\n commitDocumentPurgeCheckpoints,\n validateDocumentPurgeCheckpoints,\n} from \"./documentPurgeCheckpointCurrency\";\nimport { recoverDocumentPurgePolicyCurrency } from \"./documentPurgePolicyCurrency\";\nimport { authenticateDocumentPurgeArtifacts } from \"./documentPurgePrincipalEvidence\";\nimport { observeProjectionLifetime } from \"./projectionLifetimes\";\nimport { verifyProjectionPolicyEvidence } from \"./projectionPolicyEvidence\";\nimport { readAccessManifest } from \"./readers\";\nimport {\n assertProjectionVerificationCurrent,\n type PrincipalPolicyCache,\n type ProjectionUserKeyResolver,\n type ReferencedPrincipalPolicyWarmer,\n} from \"./types\";\n\ninterface VerifyDocumentPurgeProofInput {\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n readonly execSql: ExecSql;\n readonly expectedDocumentId: string;\n readonly expectedOrganizationId: string;\n readonly principalPolicyCache?: PrincipalPolicyCache | undefined;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n}\n\ninterface VerifiedDocumentPurgeProofCommit {\n readonly commitCheckpoints: (execSql?: ExecSql) => Promise<void>;\n readonly documentCheckpoint: AccessManifestCheckpoint;\n}\n\ntype PurgeContainerEvidence = Pick<\n DocumentPurgeProofResponse,\n | \"authorizingContainerPath\"\n | \"documentContainerManifestHistory\"\n | \"documentManifestContainerPaths\"\n>;\n\nfunction collectContainerBundles(\n proof: PurgeContainerEvidence,\n): Map<string, AccessManifestBundleWireResponse> {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n for (const [index, bundle] of proof.authorizingContainerPath.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document purge authorizing container path[${index}]`,\n );\n }\n for (const [\n index,\n bundle,\n ] of proof.documentContainerManifestHistory.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document purge container history[${index}]`,\n );\n }\n for (const [\n pathIndex,\n path,\n ] of proof.documentManifestContainerPaths.entries()) {\n for (const [bundleIndex, bundle] of path.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document purge dependency path[${pathIndex}][${bundleIndex}]`,\n );\n }\n }\n return bundlesByHash;\n}\n\nexport async function verifyPurgeContainerPaths(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ReturnType<\n typeof createProjectionCheckpointContext\n >;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: PurgeContainerEvidence;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n}) {\n const bundlesByHash = collectContainerBundles(input.proof);\n const verifiedByHash = new Map<string, VerifiedContainerAccessManifest>();\n const authorizingContainerPath = await verifyContainerManifestPath({\n servedAsCurrent: false,\n authorizationMembership: \"referenced\",\n authorizationEvidence: input.authorizationEvidence,\n bundlesByHash,\n checkpointContext: input.checkpointContext,\n // Authenticate the signed path here; the complete purge's local currency\n // is checked after its event and document evidence have authenticated.\n enforceLocalCheckpoints: false,\n label: \"Document purge authorizing container path\",\n path: input.proof.authorizingContainerPath,\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n requireAuthorizationEvidence: true,\n verifiedByHash,\n });\n const authorizingLeaf = authorizingContainerPath.at(-1);\n if (!authorizingLeaf) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Document purge authorizing container path is empty\",\n );\n }\n const containerPathByManifestHash = new Map<\n string,\n readonly VerifiedContainerAccessManifest[]\n >();\n containerPathByManifestHash.set(authorizingLeaf.manifestHash, [\n ...authorizingContainerPath,\n ]);\n for (const [\n index,\n path,\n ] of input.proof.documentManifestContainerPaths.entries()) {\n const verifiedPath = await verifyContainerManifestPath({\n servedAsCurrent: false,\n authorizationMembership: \"referenced\",\n authorizationEvidence: input.authorizationEvidence,\n bundlesByHash,\n checkpointContext: input.checkpointContext,\n enforceLocalCheckpoints: false,\n label: `Document purge dependency path[${index}]`,\n path,\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n requireAuthorizationEvidence: true,\n verifiedByHash,\n });\n const leaf = verifiedPath.at(-1);\n if (leaf && !containerPathByManifestHash.has(leaf.manifestHash)) {\n containerPathByManifestHash.set(leaf.manifestHash, verifiedPath);\n }\n }\n // Purge verification consumes event citations only, never content-write\n // headers, so historical evidence needs no pinned target-path grouping.\n for (const [hash, manifest] of verifiedByHash) {\n if (!containerPathByManifestHash.has(hash)) {\n containerPathByManifestHash.set(hash, [manifest]);\n }\n }\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: authorizingContainerPath,\n verifiedManifests: verifiedContainerManifestsForBundles(\n bundlesByHash,\n verifiedByHash,\n ),\n });\n return {\n authorizingContainerPath,\n containerPathByManifestHash,\n verifiedContainerManifests: new Map(verifiedByHash),\n };\n}\n\nfunction requirePurgeProofShape(\n proof: unknown,\n): asserts proof is DocumentPurgeProofResponse {\n if (!isDocumentPurgeProofResponse(proof)) {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Document purge proof has an invalid shape\",\n );\n }\n}\n\nfunction requirePurgeOrganization(actual: string, expected: string): void {\n if (actual !== expected)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Document purge proof belongs to another organization\",\n );\n}\n\nasync function recoverPurgePolicyEvidence(\n input: VerifyDocumentPurgeProofInput,\n) {\n const references = [...collectContainerBundles(input.proof).values()].flatMap(\n (bundle) =>\n readAccessManifest(bundle.manifest, \"Purge container manifest\")\n .referencedPrincipalHeads,\n );\n if (\n !references.length &&\n (input.proof.policyEvidence.organization ||\n input.proof.policyEvidence.groups.length ||\n input.proof.policyEvidence.organizationPayloads.length)\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Document purge proof includes unrelated principal policy evidence\",\n );\n return verifyProjectionPolicyEvidence({\n evidence: input.proof.policyEvidence,\n organizationId: input.expectedOrganizationId,\n references,\n historicalProof: true,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n}\n\nfunction purgePrincipalSourceHeads(proof: DocumentPurgeProofResponse) {\n return [\n proof.policyEvidence.organization,\n ...proof.policyEvidence.groups,\n ].flatMap((source) => (source ? [source.head] : []));\n}\n\nasync function verifyDocumentPurgeProofWithMode(\n input: VerifyDocumentPurgeProofInput,\n enforceLocalCheckpoints: boolean,\n): Promise<VerifiedDocumentPurgeProofCommit> {\n requirePurgeProofShape(input.proof);\n input = { ...input, proof: structuredClone(input.proof) };\n if (\n input.proof.documentId !== input.expectedDocumentId ||\n input.proof.documentManifest.manifestHash.length === 0\n ) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Document purge proof targets the wrong document\",\n );\n }\n const checkpointContext = createProjectionCheckpointContext({\n execSql: input.execSql,\n organizationId: input.expectedOrganizationId,\n });\n const principalPolicyCache =\n input.principalPolicyCache ?? new Map<string, VerifiedPrincipalPolicy>();\n const recovered = await recoverPurgePolicyEvidence(input);\n observeProjectionLifetime(checkpointContext, recovered.stillCurrent);\n const authorizationEvidence = recovered.policies;\n const {\n authorizingContainerPath,\n containerPathByManifestHash,\n verifiedContainerManifests,\n } = await verifyPurgeContainerPaths({\n authorizationEvidence,\n checkpointContext,\n principalPolicyCache,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n });\n const { documentManifest, principalPolicies, purgeEventHash } =\n await authenticateDocumentPurgeArtifacts({\n authorizationEvidence,\n authorizingContainerPath,\n checkpointContext,\n containerPathByManifestHash,\n enforceLocalCheckpoints,\n expectedDocumentId: input.expectedDocumentId,\n principalPolicyCache,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n verifiedContainerManifests,\n });\n requirePurgeOrganization(\n documentManifest.state.organizationId,\n input.expectedOrganizationId,\n );\n const observedPrincipalHeads = purgePrincipalSourceHeads(input.proof);\n assertProjectionVerificationCurrent(recovered.stillCurrent);\n const currencyPolicies = enforceLocalCheckpoints\n ? await recoverDocumentPurgePolicyCurrency({\n context: checkpointContext,\n organizationId: input.expectedOrganizationId,\n policies: principalPolicies,\n warmer: input.warmReferencedPrincipalPolicies,\n stillCurrent: recovered.stillCurrent,\n })\n : principalPolicies;\n if (enforceLocalCheckpoints) {\n await validateDocumentPurgeCheckpoints({\n context: checkpointContext,\n execSql: input.execSql,\n principalPolicies,\n currencyPolicies,\n observedPrincipalHeads,\n });\n }\n const documentPurgeCheckpoint = {\n documentId: input.expectedDocumentId,\n documentManifestHash: documentManifest.manifestHash,\n organizationId: documentManifest.state.organizationId,\n purgeEventHash,\n };\n return {\n commitCheckpoints: (execSql = input.execSql) =>\n commitDocumentPurgeCheckpoints({\n context: checkpointContext,\n documentPurgeCheckpoint,\n execSql,\n principalPolicies,\n currencyPolicies,\n observedPrincipalHeads,\n }),\n documentCheckpoint: documentManifest.checkpoint,\n };\n}\n\nexport async function verifyDocumentPurgeProofBaseline(\n input: VerifyDocumentPurgeProofInput,\n): Promise<Pick<VerifiedDocumentPurgeProofCommit, \"documentCheckpoint\">> {\n requirePurgeProofShape(input.proof);\n const verified = await verifyDocumentPurgeProofWithMode(input, false);\n return {\n documentCheckpoint: verified.documentCheckpoint,\n };\n}\n\nexport function verifyDocumentPurgeProof(\n input: VerifyDocumentPurgeProofInput,\n): Promise<VerifiedDocumentPurgeProofCommit> {\n return verifyDocumentPurgeProofWithMode(input, true);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifestCheckpointVerification.js","sourceRoot":"","sources":["manifestCheckpointVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mCAAmC,GACpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAG1F;;;;GAIG;AACH,KAAK,UAAU,iCAAiC,CAAC,KAMhD;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,KAAK,CAAC,UAAU;QAChB,KAAK,CAAC,cAAc;QACpB,KAAK,CAAC,QAA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,CAAC,GAAG,KAAK,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;aAClC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CACpB,uBAAuB,CAAC;YACtB,SAAS;YACT,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,eAAe;SAChB,CAAC,CACH;aACA,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAC1E,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,KAQpD;IACC,MAAM,UAAU,GAAG,MAAM,kCAAkC,CAAC;QAC1D,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAC;IACH,mCAAmC,CAAC;QAClC,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;QACzD,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU;YAC3B,oBAAoB,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;SAClE;QACD,eAAe,EAAE,UAAU,CAAC,eAAe;KAC5C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type AccessManifest,\n type AccessManifestCheckpoint,\n type VerifiedAccessManifestCheckpointEvidence,\n verifyAccessManifestLocalCheckpoint,\n} from \"@tearleads/crypto\";\nimport { loadAccessManifestCheckpoint } from \"../persistence/keyingCheckpointPersistence\";\nimport type { ExecSql } from \"../sqlite/sqlSchema\";\n\n/**\n * The local checkpoint for one object, read once per verification: every\n * checkpoint-enforced element of a served path reads its own checkpoint,\n * and the atomic advance re-validates every checkpoint at commit.\n */\nasync function loadLocalAccessManifestCheckpoint(input: {\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly objectId: string;\n readonly objectKind: AccessManifest[\"objectKind\"];\n readonly organizationId: string;\n}): Promise<AccessManifestCheckpoint | null> {\n const key = JSON.stringify([\n input.objectKind,\n input.organizationId,\n input.objectId,\n ]);\n const cached = input.localCheckpoints.get(key);\n if (cached !== undefined) return cached;\n const loaded = await loadAccessManifestCheckpoint(\n input.execSql,\n input.objectKind,\n input.organizationId,\n input.objectId,\n );\n input.localCheckpoints.set(key, loaded);\n return loaded;\n}\n\ninterface ManifestCheckpointVerificationInput<\n TManifest extends VerifiedAccessManifestCheckpointEvidence,\n> {\n readonly checkpointPredecessors: readonly TManifest[];\n readonly localCheckpoint: AccessManifestCheckpoint | null;\n}\n\nfunction isCheckpointPredecessor(input: {\n readonly candidate: VerifiedAccessManifestCheckpointEvidence;\n readonly current: AccessManifest;\n readonly localCheckpoint: AccessManifestCheckpoint;\n}): boolean {\n const candidate = input.candidate.checkpoint;\n return (\n candidate.objectKind === input.current.objectKind &&\n candidate.organizationId === input.current.organizationId &&\n candidate.objectId === input.current.objectId &&\n candidate.epoch > input.localCheckpoint.epoch &&\n candidate.epoch < input.current.epoch\n );\n}\n\nexport async function loadManifestCheckpointVerification<\n TManifest extends VerifiedAccessManifestCheckpointEvidence,\n>(input: {\n readonly current: AccessManifest;\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly verifiedManifests: ReadonlyMap<string, TManifest>;\n}): Promise<ManifestCheckpointVerificationInput<TManifest>> {\n const localCheckpoint = await loadLocalAccessManifestCheckpoint({\n execSql: input.execSql,\n localCheckpoints: input.localCheckpoints,\n objectId: input.current.objectId,\n objectKind: input.current.objectKind,\n organizationId: input.current.organizationId,\n });\n const checkpointPredecessors = localCheckpoint\n ? [...input.verifiedManifests.values()]\n .filter((candidate) =>\n isCheckpointPredecessor({\n candidate,\n current: input.current,\n localCheckpoint,\n }),\n )\n .sort((left, right) => left.checkpoint.epoch - right.checkpoint.epoch)\n : [];\n return { checkpointPredecessors, localCheckpoint };\n}\n\nexport async function verifyCachedManifestCheckpoint(input: {\n readonly current: VerifiedAccessManifestCheckpointEvidence;\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly verifiedManifests: ReadonlyMap<\n string,\n VerifiedAccessManifestCheckpointEvidence\n >;\n}): Promise<void> {\n const checkpoint = await loadManifestCheckpointVerification({\n current: input.current.manifest,\n execSql: input.execSql,\n localCheckpoints: input.localCheckpoints,\n verifiedManifests: input.verifiedManifests,\n });\n verifyAccessManifestLocalCheckpoint({\n checkpointPredecessors: checkpoint.checkpointPredecessors,\n current: {\n ...input.current.checkpoint,\n previousManifestHash: input.current.manifest.previousManifestHash,\n },\n localCheckpoint: checkpoint.localCheckpoint,\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeProjectionPolicyEvidence.js","sourceRoot":"","sources":["mergeProjectionPolicyEvidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAE9F,SAAS,KAAK,CACZ,QAAiE,EACjE,IAA0C;IAE1C,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW;QACrD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,wCAAwC,CACzC,CAAC;IACJ,IACE,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO;QAC3C,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI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CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO;QACL,YAAY,EAAE,SAAS,EAAE,YAAY,IAAI,IAAI;QAC7C,oBAAoB,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC5C,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport type {\n PrincipalPolicyHistorySourceResponse,\n ProjectionPolicyEvidenceResponse,\n} from \"@tearleads/validators/response\";\nimport { principalHeadMatchesReference } from \"../principals/organizationAuthorityDescriptor\";\n\nfunction newer(\n previous: PrincipalPolicyHistorySourceResponse | null | undefined,\n next: PrincipalPolicyHistorySourceResponse,\n): boolean {\n if (!previous) return true;\n if (previous.head.principalId !== next.head.principalId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Projection evidence crosses principals\",\n );\n if (\n previous.head.version === next.head.version &&\n !principalHeadMatchesReference(previous.head, next.head)\n )\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"Projection evidence contains conflicting heads\",\n );\n return previous.head.version < next.head.version;\n}\n\n/** Combine proof material when locally composing projections; verification follows. */\nexport function mergeProjectionPolicyEvidence(\n evidence: readonly ProjectionPolicyEvidenceResponse[],\n): ProjectionPolicyEvidenceResponse {\n let directory: ProjectionPolicyEvidenceResponse | undefined;\n const groups = new Map<string, PrincipalPolicyHistorySourceResponse>();\n const payloads = new Map<\n string,\n ProjectionPolicyEvidenceResponse[\"organizationPayloads\"][number]\n >();\n for (const proof of evidence) {\n const organization = proof.organization;\n if (organization && newer(directory?.organization, organization))\n directory = proof;\n for (const payload of proof.organizationPayloads) {\n const previous = payloads.get(payload.reference.stateHash);\n if (\n previous &&\n (!principalHeadMatchesReference(\n previous.reference,\n payload.reference,\n ) ||\n previous.payload.principalId !== payload.payload.principalId ||\n previous.payload.principalType !== payload.payload.principalType ||\n previous.payload.ciphertext !== payload.payload.ciphertext ||\n previous.payload.ciphertextHash !== payload.payload.ciphertextHash)\n )\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"Projection evidence contains conflicting directory payloads\",\n );\n payloads.set(payload.reference.stateHash, payload);\n }\n for (const group of proof.groups) {\n const prior = groups.get(group.head.principalId);\n if (newer(prior, group)) groups.set(group.head.principalId, group);\n }\n }\n return {\n organization: directory?.organization ?? null,\n organizationPayloads: [...payloads.values()],\n groups: [...groups.values()],\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationFounderBinding.js","sourceRoot":"","sources":["organizationFounderBinding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAE5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oCAAoC,CAAC,KAK1D;IACC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO;IACpD,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,CACvC,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,aAAa,KAAK,cAAc;QACvC,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,CAAC,cAAc,CACnD,CAAC;IACF,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,MAAM,OAAO,GACX,iBAAiB,IAAI,YAAY;QAC/B,CAAC,CAAC,YAAY,CAAC,eAAe;QAC9B,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;IACxE,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,gDAAgD,CACjD,CAAC;IACJ,MAAM,OAAO,GAAG,+BAA+B,CAAC;QAC9C,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,2BAA2B;QAClC,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;IACH,IACE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY;QAC1D,OAAO,CAAC,wBAAwB;YAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB;QAE1C,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,0EAA0E,CAC3E,CAAC;IACJ,MAAM,2BAA2B,CAAC;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY;KACb,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n KeyingVerificationError,\n type VerifiedContainerAccessManifest,\n} from \"@tearleads/crypto\";\nimport { rememberOrganizationFounder } from \"../persistence/organizationFounderPersistence\";\nimport type { ExecSql } from \"../sqlite/sqlSchema\";\nimport { verifiedContainerCreateManifest } from \"./containerCreateManifest\";\n\n/**\n * A directory can cite someone else's public policies. Bind its founder to the\n * verified personal root's creator before trusting it to authorize a rehome.\n * Metadata roots can be created by later admins and cannot establish this pin.\n * This immutable identity anchor survives read-only verification and canceled\n * views; it neither advances nor replaces a current-policy checkpoint.\n */\nexport async function rememberRootBoundOrganizationFounder(input: {\n readonly execSql: ExecSql;\n readonly policies: readonly PrincipalPolicyAuthorization[] | undefined;\n readonly root: VerifiedContainerAccessManifest | undefined;\n readonly verifiedByHash: ReadonlyMap<string, VerifiedContainerAccessManifest>;\n}): Promise<void> {\n const { root } = input;\n if (!root || root.state.systemSlot !== null) return;\n const organization = input.policies?.find(\n (policy) =>\n policy.principalType === \"organization\" &&\n policy.principalId === root.state.organizationId,\n );\n if (!organization) return;\n const entries =\n \"retainedHistory\" in organization\n ? organization.retainedHistory\n : organization.history;\n if (!entries) return;\n const genesis = entries.find(({ state }) => state.version === 1)?.state;\n if (!genesis)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization founder requires verified genesis\",\n );\n const created = verifiedContainerCreateManifest({\n head: root,\n label: \"Organization founder root\",\n verifiedByHash: input.verifiedByHash,\n });\n if (\n genesis?.signerUserId !== created.event.event.signerUserId ||\n genesis.signerUserKeyFingerprint !==\n created.event.event.signerKeyFingerprint\n )\n throw new KeyingVerificationError(\n \"signer_mismatch\",\n \"Organization founder does not match its verified personal root's creator\",\n );\n await rememberOrganizationFounder({\n execSql: input.execSql,\n organization,\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"principalPolicyCache.js","sourceRoot":"","sources":["principalPolicyCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,sCAAsC,EAAE,MAAM,mDAAmD,CAAC;AAC3G,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EAEL,8BAA8B,GAC/B,MAAM,uCA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AAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACnC,CAAC,CAAC,CACH,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,SAAS,EAAwC,EAAE,CAAC,SAAS,KAAK,IAAI,CACxE,CAAC;AACJ,CAAC","sourcesContent":["import type { ReferencedPrincipalHead } from \"@tearleads/crypto\";\nimport { KeyingVerificationError } from \"@tearleads/crypto\";\nimport { loadPrincipalPolicyCheckpoint } from \"../persistence/keyingCheckpointPersistence\";\nimport { verifiedPrincipalPolicyMeetsCheckpoint } from \"../persistence/principalPolicyCheckpointSelection\";\nimport { loadPrincipalPolicyBundleForReference } from \"../persistence/principalPolicyReferencePersistence\";\nimport {\n type PrincipalPolicyCurrentEvidence,\n principalPolicyEvidenceEntries,\n} from \"../principals/principalPolicyEvidence\";\nimport { principalStateMatchesReference } from \"../principals/principalPolicyStates\";\nimport type { ExecSql } from \"../sqlite/sqlSchema\";\n\n/**\n * Cache key for a referenced principal policy. The in-memory principal-policy\n * cache is populated and read from several call sites; they must agree on this\n * format byte-for-byte or a populated entry looks uncached (extra warm fetches)\n * — so this is the single source of truth, imported rather than re-declared.\n */\nexport function referencedPrincipalPolicyKey(\n reference: ReferencedPrincipalHead,\n): string {\n return JSON.stringify([\n reference.principalType,\n reference.principalId,\n reference.version,\n reference.stateHash,\n reference.keyEpoch,\n reference.keyFingerprint,\n ]);\n}\n\n/**\n * Dedupes references by their exact head identity, keyed with\n * {@link referencedPrincipalPolicyKey} so every consumer agrees on what\n * \"the same reference\" means. Later duplicates win, preserving each\n * caller's original last-wins behavior.\n */\nexport function dedupeReferencedPrincipalStates<\n TReference extends ReferencedPrincipalHead,\n>(references: ReadonlyArray<TReference>): TReference[] {\n const referencesByState = new Map<string, TReference>();\n for (const reference of references) {\n referencesByState.set(referencedPrincipalPolicyKey(reference), reference);\n }\n return Array.from(referencesByState.values());\n}\n\nexport function principalPolicyCacheForVerifiedPolicies(\n policies: readonly PrincipalPolicyCurrentEvidence[],\n): Map<string, PrincipalPolicyCurrentEvidence> {\n const cache = new Map<string, PrincipalPolicyCurrentEvidence>();\n for (const policy of policies) {\n const states = principalPolicyEvidenceEntries(policy).map(\n (entry) => entry.state,\n );\n for (const state of states) {\n cache.set(\n referencedPrincipalPolicyKey({\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n keyEpoch: state.keyEpoch,\n stateHash: state.stateHash,\n keyFingerprint: state.keyFingerprint,\n }),\n policy,\n );\n }\n }\n return cache;\n}\n\nexport function verifiedPrincipalPolicyContainsReference(\n policy: PrincipalPolicyCurrentEvidence,\n reference: ReferencedPrincipalHead,\n): boolean {\n const states = principalPolicyEvidenceEntries(policy).map(\n ({ state }) => state,\n );\n return states.some((state) =>\n principalStateMatchesReference(state, reference),\n );\n}\n\n// Identify which referenced policies are absent from both the in-memory cache\n// and local storage, so the warmer fetches only what is genuinely missing.\nexport async function filterUncachedPrincipalPolicyReferences(input: {\n execSql: ExecSql;\n principalPolicyCache: ReadonlyMap<string, PrincipalPolicyCurrentEvidence>;\n references: readonly ReferencedPrincipalHead[];\n}): Promise<ReferencedPrincipalHead[]> {\n const results = await Promise.all(\n input.references.map(async (reference) => {\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n input.execSql,\n reference.principalType,\n reference.principalId,\n );\n const cachedPolicy = input.principalPolicyCache.get(\n referencedPrincipalPolicyKey(reference),\n );\n if (cachedPolicy) {\n if (\n !verifiedPrincipalPolicyContainsReference(cachedPolicy, reference)\n ) {\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"in-memory principal policy cache does not match its exact reference\",\n );\n }\n if (verifiedPrincipalPolicyMeetsCheckpoint(cachedPolicy, checkpoint)) {\n return null;\n }\n }\n const bundle = await loadPrincipalPolicyBundleForReference(\n input.execSql,\n reference,\n checkpoint,\n );\n return bundle ? null : reference;\n }),\n );\n return results.filter(\n (reference): reference is ReferencedPrincipalHead => reference !== null,\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"principalPolicyVerification.js","sourceRoot":"","sources":["principalPolicyVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAGvB,aAAa,EAEb,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EACL,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,6BAA6B,EAC7B,yDAAyD,GAC1D,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EACL,sBAAsB,GAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,0CAA0C,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EACL,uCAAuC,EACvC,4BAA4B,EAC5B,wCAAwC,GACzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAM7E,OAAO,EACL,mCAAmC,EACnC,sCAAsC,GACvC,MAAM,SAAS,CAAC;AAEjB,SAAS,6BAA6B,CACpC,SAAkC;IAElC,OAAO,GAAG,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;AACpF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,YAAY,cAAsB;QAChC,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CAAC;YACxB,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACxD,MAAM,+BAA+B,CAAC;gBACpC,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,UAAU,EAAE,QAAQ;aACrB,CAAC,CAAC;YACH,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,OAAO,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAC3B,+BAA+B,CAAC;QAC9B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,SAAS;QACT,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,+BAA+B;KAChC,CAAC,CACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicySignerPublicKey,\n type ReferencedPrincipalHead,\n toFingerprint,\n type VerifiedPrincipalPolicy,\n verifyPrincipalPolicyBundle,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { loadPrincipalPolicyCheckpoint } from \"../persistence/keyingCheckpointPersistence\";\nimport {\n principalPolicyHeadMeetsCheckpoint,\n verifiedPrincipalPolicyMeetsCheckpoint,\n} from \"../persistence/principalPolicyCheckpointSelection\";\nimport { loadPrincipalPolicyBundle } from \"../persistence/principalPolicyPersistence\";\nimport { loadPrincipalPolicyBundleForReference } from \"../persistence/principalPolicyReferencePersistence\";\nimport {\n parseOrganizationAuthorityDescriptor,\n principalHeadMatchesReference,\n requireOrganizationGroupHead,\n} from \"../principals/organizationAuthorityDescriptor\";\nimport {\n organizationAdminExternalAuthority,\n principalPolicyReferenceFromBundle,\n verifyOrganizationAdminPolicy,\n verifyPrincipalPolicyBundleWithExternalOrganizationAdmins,\n} from \"../principals/principalPolicyAdminSigners\";\nimport type { PrincipalPolicyCurrentEvidence } from \"../principals/principalPolicyEvidence\";\nimport { principalPolicyBundleStates } from \"../principals/principalPolicyStates\";\nimport {\n observePrincipalPolicy,\n type ProjectionCheckpointContext,\n} from \"./checkpointContext\";\nimport { ProjectionDependencyUnavailableError } from \"./dependencyUnavailable\";\nimport { rethrowProjectionVerificationBoundaryError } from \"./error\";\nimport {\n filterUncachedPrincipalPolicyReferences,\n referencedPrincipalPolicyKey,\n verifiedPrincipalPolicyContainsReference,\n} from \"./principalPolicyCache\";\nimport { resolveReferencedPrincipalPolicy } from \"./resolvedPrincipalPolicy\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"./types\";\nimport {\n assertProjectionVerificationCurrent,\n generationGuardedPrincipalPolicyWarmer,\n} from \"./types\";\n\nfunction principalPolicyReferenceLabel(\n reference: ReferencedPrincipalHead,\n): string {\n return `${reference.principalType}:${reference.principalId}@${reference.version}`;\n}\n\n/**\n * A referenced principal policy is not in the local store and warming could\n * not fetch it this pass — a transient cold-cache condition, typical for a\n * member whose access arrives via a group policy the device has not hydrated\n * yet. Sync passes discriminate on this type to defer the affected container\n * and retry on a later trigger, rather than failing the whole pass.\n */\nexport class PrincipalPolicyNotCachedError extends Error {\n constructor(referenceLabel: string) {\n super(`Principal policy ${referenceLabel} is not cached`);\n this.name = \"PrincipalPolicyNotCachedError\";\n }\n}\n\nexport function isPrincipalPolicyNotCachedError(error: unknown): boolean {\n return (\n error instanceof PrincipalPolicyNotCachedError ||\n (error instanceof Error && error.name === \"PrincipalPolicyNotCachedError\")\n );\n}\n\nasync function collectPrincipalPolicySignerPublicKeys(input: {\n bundle: PrincipalPolicyBundleResponse;\n label: string;\n resolveUserKey: ProjectionUserKeyResolver;\n}): Promise<PrincipalPolicySignerPublicKey[]> {\n const signerPublicKeysByKey = new Map<\n string,\n PrincipalPolicySignerPublicKey\n >();\n\n for (const state of principalPolicyBundleStates(input.bundle)) {\n const cacheKey = `${state.signerUserId}:${state.signerUserKeyFingerprint}`;\n if (signerPublicKeysByKey.has(cacheKey)) {\n continue;\n }\n\n const signerKey = await input.resolveUserKey(state.signerUserId);\n if (!signerKey) {\n throw new ProjectionDependencyUnavailableError(\n `${input.label} signer key could not be resolved for ${state.signerUserId}`,\n );\n }\n\n const signingKeyFingerprint = await toFingerprint(\n signerKey.signingPublicKey,\n );\n if (signingKeyFingerprint !== state.signerUserKeyFingerprint) {\n throw new KeyingVerificationError(\n \"signer_mismatch\",\n `${input.label} signer key fingerprint mismatch`,\n );\n }\n\n signerPublicKeysByKey.set(cacheKey, {\n userId: state.signerUserId,\n signingKeyFingerprint,\n signingPublicKey: signerKey.signingPublicKey,\n });\n }\n\n return [...signerPublicKeysByKey.values()];\n}\n\ntype OrganizationAdminPolicyInput = {\n checkpointContext: ProjectionCheckpointContext;\n organizationId: string;\n resolveUserKey: ProjectionUserKeyResolver;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n};\n\nasync function loadOrganizationPolicyForVerification(\n input: OrganizationAdminPolicyInput,\n): Promise<\n | {\n bundle: PrincipalPolicyBundleResponse;\n localCheckpoint: Awaited<\n ReturnType<typeof loadPrincipalPolicyCheckpoint>\n >;\n }\n | undefined\n> {\n const execSql = input.checkpointContext.execSql;\n let bundle = await loadPrincipalPolicyBundle(\n execSql,\n \"organization\",\n input.organizationId,\n );\n if (!bundle) {\n return undefined;\n }\n let localCheckpoint = await loadPrincipalPolicyCheckpoint(\n execSql,\n \"organization\",\n input.organizationId,\n );\n if (\n !principalPolicyHeadMeetsCheckpoint(bundle.currentState, localCheckpoint) &&\n input.warmReferencedPrincipalPolicies\n ) {\n await input.warmReferencedPrincipalPolicies({\n organizationId: input.organizationId,\n references: [principalPolicyReferenceFromBundle(bundle)],\n });\n bundle = await loadPrincipalPolicyBundle(\n execSql,\n \"organization\",\n input.organizationId,\n );\n localCheckpoint = await loadPrincipalPolicyCheckpoint(\n execSql,\n \"organization\",\n input.organizationId,\n );\n if (!bundle) {\n return undefined;\n }\n }\n\n return { bundle, localCheckpoint };\n}\n\nfunction assertReservedAdminsPolicyShape(\n policy: VerifiedPrincipalPolicy,\n): void {\n const history = policy.history ?? [{ projection: policy.projection }];\n if (\n history.some(\n (entry) =>\n entry.projection.length === 0 ||\n entry.projection.some((member) => member.role !== \"admin\"),\n )\n ) {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"reserved Admins policy must contain only direct admin users\",\n );\n }\n}\n\nasync function verifyOrganizationAdminsPolicy(input: {\n adminGroupId: string;\n execSql: ProjectionCheckpointContext[\"execSql\"];\n expectedHead: ReferencedPrincipalHead;\n resolveUserKey: ProjectionUserKeyResolver;\n}): Promise<VerifiedPrincipalPolicy | undefined> {\n const adminBundle = await loadPrincipalPolicyBundle(\n input.execSql,\n \"group\",\n input.adminGroupId,\n );\n if (!adminBundle) {\n return undefined;\n }\n if (\n !principalHeadMatchesReference(\n principalPolicyReferenceFromBundle(adminBundle),\n input.expectedHead,\n )\n ) {\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"Admins policy does not match the signed organization directory\",\n );\n }\n const adminCheckpoint = await loadPrincipalPolicyCheckpoint(\n input.execSql,\n \"group\",\n input.adminGroupId,\n );\n const signerPublicKeys = await collectPrincipalPolicySignerPublicKeys({\n bundle: adminBundle,\n label: `Admins policy ${input.adminGroupId}`,\n resolveUserKey: input.resolveUserKey,\n });\n const verified = await verifyPrincipalPolicyBundle({\n bundle: adminBundle,\n expectedReference: input.expectedHead,\n localCheckpoint: adminCheckpoint,\n signerPublicKeys,\n });\n if (!verified.ok) {\n throw verified.error;\n }\n assertReservedAdminsPolicyShape(verified.value);\n return verified.value;\n}\n\nasync function loadOrganizationExternalAuthority(\n input: OrganizationAdminPolicyInput,\n): Promise<ReturnType<typeof organizationAdminExternalAuthority> | null> {\n const organizationPolicy = await loadOrganizationPolicyForVerification(input);\n if (!organizationPolicy) {\n return null;\n }\n\n try {\n const signerPublicKeys = await collectPrincipalPolicySignerPublicKeys({\n bundle: organizationPolicy.bundle,\n label: `Organization policy ${input.organizationId}`,\n resolveUserKey: input.resolveUserKey,\n });\n const verified = await verifyOrganizationAdminPolicy({\n bundle: organizationPolicy.bundle,\n localCheckpoint: organizationPolicy.localCheckpoint,\n organizationId: input.organizationId,\n signerPublicKeys,\n });\n if (!verified.ok) {\n throw verified.error;\n }\n const descriptor = parseOrganizationAuthorityDescriptor(\n organizationPolicy.bundle.currentPayload.ciphertext,\n );\n if (descriptor.organizationId !== input.organizationId) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"organization authority descriptor scope does not match\",\n );\n }\n const verifiedAdmins = await verifyOrganizationAdminsPolicy({\n adminGroupId: descriptor.adminGroupId,\n execSql: input.checkpointContext.execSql,\n expectedHead: requireOrganizationGroupHead(\n descriptor,\n descriptor.adminGroupId,\n ),\n resolveUserKey: input.resolveUserKey,\n });\n if (!verifiedAdmins) {\n return null;\n }\n observePrincipalPolicy(\n input.checkpointContext,\n verified.value,\n input.organizationId,\n );\n observePrincipalPolicy(\n input.checkpointContext,\n verifiedAdmins,\n input.organizationId,\n );\n return organizationAdminExternalAuthority(verifiedAdmins);\n } catch (error) {\n rethrowProjectionVerificationBoundaryError(error);\n if (error instanceof KeyingVerificationError) {\n throw error;\n }\n return null;\n }\n}\n\nasync function verifyReferencedPrincipalPolicy(input: {\n checkpointContext: ProjectionCheckpointContext;\n organizationId: string;\n principalPolicyCache: PrincipalPolicyCache;\n reference: ReferencedPrincipalHead;\n stillCurrent?: (() => boolean) | undefined;\n resolveUserKey: ProjectionUserKeyResolver;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<PrincipalPolicyCurrentEvidence> {\n // Scoped recovery carries organization, dependency and lifetime bindings.\n // A bare policy cache entry cannot replace those bindings.\n const recovered = await resolveReferencedPrincipalPolicy(input);\n if (recovered) return recovered;\n const cacheKey = referencedPrincipalPolicyKey(input.reference);\n const cachedPolicy = input.principalPolicyCache.get(cacheKey);\n const execSql = input.checkpointContext.execSql;\n const localCheckpoint = await loadPrincipalPolicyCheckpoint(\n execSql,\n input.reference.principalType,\n input.reference.principalId,\n );\n if (cachedPolicy && !(\"retainedHistory\" in cachedPolicy)) {\n if (\n !verifiedPrincipalPolicyContainsReference(cachedPolicy, input.reference)\n ) {\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"in-memory principal policy cache does not match its exact reference\",\n );\n }\n if (verifiedPrincipalPolicyMeetsCheckpoint(cachedPolicy, localCheckpoint)) {\n observePrincipalPolicy(\n input.checkpointContext,\n cachedPolicy,\n input.organizationId,\n );\n return cachedPolicy;\n }\n }\n\n const referenceLabel = principalPolicyReferenceLabel(input.reference);\n let bundle = await loadPrincipalPolicyBundleForReference(\n execSql,\n input.reference,\n localCheckpoint,\n );\n if (!bundle && input.warmReferencedPrincipalPolicies) {\n // The reference is not cached locally — the common case for a member who\n // gained access via another org's group grant and never hydrated that\n // group's policy. Fetch+verify+persist it, then re-read from the cache.\n await input.warmReferencedPrincipalPolicies({\n organizationId: input.organizationId,\n references: [input.reference],\n });\n bundle = await loadPrincipalPolicyBundleForReference(\n execSql,\n input.reference,\n localCheckpoint,\n );\n }\n if (!bundle) {\n throw new PrincipalPolicyNotCachedError(referenceLabel);\n }\n\n const signerPublicKeys = await collectPrincipalPolicySignerPublicKeys({\n bundle,\n label: `Principal policy ${referenceLabel}`,\n resolveUserKey: input.resolveUserKey,\n });\n const verified =\n await verifyPrincipalPolicyBundleWithExternalOrganizationAdmins({\n bundle,\n expectedReference: input.reference,\n loadExternalAuthority: () =>\n loadOrganizationExternalAuthority({\n checkpointContext: input.checkpointContext,\n organizationId: input.organizationId,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies:\n input.warmReferencedPrincipalPolicies,\n }),\n localCheckpoint,\n signerPublicKeys,\n });\n if (!verified.ok) {\n throw verified.error;\n }\n\n observePrincipalPolicy(\n input.checkpointContext,\n verified.value,\n input.organizationId,\n );\n input.principalPolicyCache.set(cacheKey, verified.value);\n return verified.value;\n}\n\nexport async function collectReferencedPrincipalPolicies(input: {\n checkpointContext: ProjectionCheckpointContext;\n organizationId: string;\n principalPolicyCache: PrincipalPolicyCache;\n references: readonly ReferencedPrincipalHead[];\n resolveUserKey: ProjectionUserKeyResolver;\n stillCurrent?: (() => boolean) | undefined;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<PrincipalPolicyCurrentEvidence[]> {\n const warmReferencedPrincipalPolicies =\n generationGuardedPrincipalPolicyWarmer(\n input.warmReferencedPrincipalPolicies,\n input.stillCurrent,\n );\n const uniqueReferences = new Map<string, ReferencedPrincipalHead>();\n for (const reference of input.references) {\n uniqueReferences.set(referencedPrincipalPolicyKey(reference), reference);\n }\n\n const references = [...uniqueReferences.values()];\n // Warm every missing reference in one batched fetch before verifying, so a\n // path that references several uncached policies makes a single round of\n // requests rather than one per reference.\n if (\n warmReferencedPrincipalPolicies &&\n !warmReferencedPrincipalPolicies.resolveReference\n ) {\n const uncached = await filterUncachedPrincipalPolicyReferences({\n execSql: input.checkpointContext.execSql,\n principalPolicyCache: input.principalPolicyCache,\n references,\n });\n if (uncached.length > 0) {\n assertProjectionVerificationCurrent(input.stillCurrent);\n await warmReferencedPrincipalPolicies({\n organizationId: input.organizationId,\n references: uncached,\n });\n assertProjectionVerificationCurrent(input.stillCurrent);\n }\n }\n\n // The warmer's operation shares one recovery view across its collections.\n return Promise.all(\n references.map((reference) =>\n verifyReferencedPrincipalPolicy({\n checkpointContext: input.checkpointContext,\n organizationId: input.organizationId,\n principalPolicyCache: input.principalPolicyCache,\n reference,\n stillCurrent: input.stillCurrent,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies,\n }),\n ),\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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SAAS,GAAG,MAAM,8BAA8B,CAAC;QACrD,QAAQ,EAAE,KAAK,CAAC,cAAc;QAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,UAAU;QACV,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;KACvE,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,cAAc,CAAC,YAAY;QACnC,yBAAyB,CAAC,KAAK,CAAC,iBAAiB,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IAC7E,KAAK,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC1E,OAAO,sCAAsC,CAAC;QAC5C,GAAG,KAAK;QACR,QAAQ,EAAE,SAAS,CAAC,QAAQ;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n ProjectionPolicyEvidenceResponse,\n} from \"@tearleads/validators/response\";\nimport type { ProjectionCheckpointContext } from \"./checkpointContext\";\nimport { collectReferencedPrincipalPolicies } from \"./principalPolicyVerification\";\nimport { observeProjectionLifetime } from \"./projectionLifetimes\";\nimport { verifyProjectionPolicyEvidence } from \"./projectionPolicyEvidence\";\nimport { readAccessManifest } from \"./readers\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"./types\";\n\n/** Locally planned successors may cite an already verified, uncommitted policy. */\nasync function resolveProjectionAuthorizationEvidence(input: {\n readonly bundles: readonly AccessManifestBundleWireResponse[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly evidence: readonly PrincipalPolicyAuthorization[];\n readonly organizationId: string;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}): Promise<PrincipalPolicyAuthorization[]> {\n const references = input.bundles\n .flatMap(\n (bundle) =>\n readAccessManifest(bundle.manifest, \"Projection manifest\")\n .referencedPrincipalHeads,\n )\n .filter(\n (reference) =>\n !input.evidence.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n ),\n );\n const known = [...input.principalPolicyCache.values()];\n if (\n references.some(\n (reference) =>\n !known.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n ),\n )\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection omits required principal policy evidence\",\n );\n return [\n ...input.evidence,\n ...(await collectReferencedPrincipalPolicies({\n checkpointContext: input.checkpointContext,\n organizationId: input.organizationId,\n principalPolicyCache: input.principalPolicyCache,\n references,\n resolveUserKey: input.resolveUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n })),\n ];\n}\n\nexport async function verifyProjectionAuthorizationEvidence(\n input: Omit<\n Parameters<typeof resolveProjectionAuthorizationEvidence>[0],\n \"evidence\"\n > & { readonly policyEvidence: ProjectionPolicyEvidenceResponse },\n) {\n const sources = [\n input.policyEvidence.organization,\n ...input.policyEvidence.groups,\n ];\n const known = [...input.principalPolicyCache.values()];\n const references = input.bundles\n .flatMap(\n (bundle) =>\n readAccessManifest(bundle.manifest, \"Projection manifest\")\n .referencedPrincipalHeads,\n )\n .filter((reference) => {\n if (\n sources.some(\n (source) =>\n source &&\n source.head.principalType === reference.principalType &&\n source.head.principalId === reference.principalId &&\n source.head.version >= reference.version,\n )\n )\n return true;\n // Locally planned successors are verified below through the current-policy path.\n if (\n known.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n )\n )\n return false;\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection omits required principal policy evidence\",\n );\n });\n const recovered = await verifyProjectionPolicyEvidence({\n evidence: input.policyEvidence,\n organizationId: input.organizationId,\n references,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n if (input.policyEvidence.organization)\n observeProjectionLifetime(input.checkpointContext, recovered.stillCurrent);\n input.checkpointContext.authorizationPolicies.push(...recovered.policies);\n return resolveProjectionAuthorizationEvidence({\n ...input,\n evidence: recovered.policies,\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectionPolicyEvidence.js","sourceRoot":"","sources":["projectionPolicyEvidence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EACL,mCAAmC,GAGpC,MAAM,SAAS,CAAC;AAEjB,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,KASpD;IACC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,CAAC;IAC5D,mCAAmC,CAAC,YAAY,CAAC,CAAC;IAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;QACjC,IACE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM;YAC5B,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC1C,KAAK,CAAC,UAAU,CAAC,MAAM;YAEvB,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,gDAAgD,CACjD,CAAC;QACJ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,OAAO,GACX,KAAK,CAAC,+BAA+B,EAAE,wBAAwB,CAAC;IAClE,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,oCAAoC,CAC5C,oDAAoD,CACrD,CAAC;IACJ,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACzD,mCAAmC,CAAC,YAAY,CAAC,CAAC;IAClD,mCAAmC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport type { ProjectionPolicyEvidenceResponse } from \"@tearleads/validators/response\";\nimport { ProjectionDependencyUnavailableError } from \"./dependencyUnavailable\";\nimport {\n assertProjectionVerificationCurrent,\n type ReferencedPrincipalPolicyWarmer,\n type ResolvedProjectionPolicyHistory,\n} from \"./types\";\n\n/** Recover public authorization without admitting historical heads as current policy. */\nexport async function verifyProjectionPolicyEvidence(input: {\n readonly historicalProof?: boolean | undefined;\n readonly evidence: ProjectionPolicyEvidenceResponse;\n readonly organizationId: string;\n readonly references: readonly ReferencedPrincipalHead[];\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}): Promise<ResolvedProjectionPolicyHistory> {\n const stillCurrent = () => input.stillCurrent?.() !== false;\n assertProjectionVerificationCurrent(stillCurrent);\n if (!input.evidence.organization) {\n if (\n input.evidence.groups.length ||\n input.evidence.organizationPayloads.length ||\n input.references.length\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection omits required organization history\",\n );\n return { policies: [], stillCurrent };\n }\n const resolve =\n input.warmReferencedPrincipalPolicies?.resolveProjectionHistory;\n if (!resolve)\n throw new ProjectionDependencyUnavailableError(\n \"Private projection history recovery is unavailable\",\n );\n const result = await resolve({ ...input, stillCurrent });\n assertProjectionVerificationCurrent(stillCurrent);\n assertProjectionVerificationCurrent(result.stillCurrent);\n return result;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvedPrincipal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AAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC;IAC5C,2EAA2E;IAC3E,mEAAmE;IACnE,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,IAAI,eAAe,EAAE,CAAC;IAC7E,mCAAmC,CAAC,QAAQ,CAAC,CAAC;IAC9C,yBAAyB,CAAC,KAAK,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAI,MAAM,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;QAChD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,8DAA8D,CAC/D,CAAC;IACJ,IAAI,CAAC,wCAAwC,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3E,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,kEAAkE,CACnE,CAAC;IACJ,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC;QAC1D,sBAAsB,CACpB,KAAK,CAAC,iBAAiB,EACvB,MAAM,EACN,KAAK,CAAC,cAAc,CACrB,CAAC;IACJ,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicyCurrent,\n} from \"@tearleads/crypto\";\nimport { loadPrincipalPolicyCheckpoint } from \"../persistence/keyingCheckpointPersistence\";\nimport { verifiedPrincipalPolicyMeetsCheckpoint } from \"../persistence/principalPolicyCheckpointSelection\";\nimport {\n observePrincipalPolicy,\n type ProjectionCheckpointContext,\n} from \"./checkpointContext\";\nimport {\n referencedPrincipalPolicyKey,\n verifiedPrincipalPolicyContainsReference,\n} from \"./principalPolicyCache\";\nimport { observeProjectionLifetime } from \"./projectionLifetimes\";\nimport {\n assertProjectionVerificationCurrent,\n type PrincipalPolicyCache,\n type ReferencedPrincipalPolicyWarmer,\n type ResolvedPrincipalPolicyEvidence,\n} from \"./types\";\n\n// Scoped evidence is always resolved through the warmer: its operation memo is\n// the only reuse of recovered directory and Admins evidence, with one set of\n// validity rules. The caller's policy cache keeps bare verified policies; it\n// never stands in for organization, dependency or lifetime bindings.\nasync function meetsCheckpoints(\n context: ProjectionCheckpointContext,\n result: ResolvedPrincipalPolicyEvidence,\n refreshMissing: boolean,\n): Promise<boolean> {\n for (const policy of [...result.dependencies, result.policy]) {\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n context.execSql,\n policy.principalType,\n policy.principalId,\n );\n if (\n refreshMissing &&\n checkpoint &&\n (policy.version < checkpoint.version ||\n (policy.version > checkpoint.version &&\n !policy.retainedHistory.some(\n (entry) => entry.state.version === checkpoint.version,\n )))\n )\n return false;\n if (!verifiedPrincipalPolicyMeetsCheckpoint(policy, checkpoint))\n throw new KeyingVerificationError(\n \"rollback\",\n \"Recovered principal evidence predates the durable checkpoint\",\n );\n }\n return true;\n}\n\ninterface ResolveReferencedPrincipalPolicyInput {\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly organizationId: string;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly reference: ReferencedPrincipalHead;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}\n\nasync function recoverEvidence(\n input: ResolveReferencedPrincipalPolicyInput,\n resolve: NonNullable<ReferencedPrincipalPolicyWarmer[\"resolveReference\"]>,\n): Promise<ResolvedPrincipalPolicyEvidence> {\n const read = async (recoveryBatch?: object) => {\n assertProjectionVerificationCurrent(input.stillCurrent);\n const recovered = await resolve({\n recoveryBatch,\n organizationId: input.organizationId,\n reference: input.reference,\n stillCurrent: input.stillCurrent,\n });\n assertProjectionVerificationCurrent(input.stillCurrent);\n assertProjectionVerificationCurrent(recovered.stillCurrent);\n return recovered;\n };\n let result = await read();\n // A concurrent admission may advance a pin after recovery verified it.\n // Refresh once outside the operation's directory view; the fresh\n // recovery and final checkpoint check still reject rollback/equivocation.\n if (!(await meetsCheckpoints(input.checkpointContext, result, true))) {\n assertProjectionVerificationCurrent(result.stillCurrent);\n result = await read({});\n await meetsCheckpoints(input.checkpointContext, result, false);\n }\n return result;\n}\n\nexport async function resolveReferencedPrincipalPolicy(\n input: ResolveReferencedPrincipalPolicyInput,\n): Promise<VerifiedPrincipalPolicyCurrent | null> {\n assertProjectionVerificationCurrent(input.stillCurrent);\n const key = referencedPrincipalPolicyKey(input.reference);\n const resolve = input.warmReferencedPrincipalPolicies?.resolveReference;\n if (!resolve) return null;\n const result = await recoverEvidence(input, resolve);\n const evidenceCurrent = result.stillCurrent;\n // The consumer's and every producer's lifetime guard the evidence where it\n // is used: projection admission rechecks them through the context.\n const lifetime = () => input.stillCurrent?.() !== false && evidenceCurrent();\n assertProjectionVerificationCurrent(lifetime);\n observeProjectionLifetime(input.checkpointContext, lifetime);\n if (result.organizationId !== input.organizationId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Recovered principal evidence belongs to another organization\",\n );\n if (!verifiedPrincipalPolicyContainsReference(result.policy, input.reference))\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Recovered principal evidence does not contain the exact citation\",\n );\n for (const policy of [...result.dependencies, result.policy])\n observePrincipalPolicy(\n input.checkpointContext,\n policy,\n input.organizationId,\n );\n input.principalPolicyCache.set(key, result.policy);\n return result.policy;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backgroundHydration.js","sourceRoot":"","sources":["backgroundHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,+CAA+C,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAGzF,4EAA4E;AAC5E,MAAM,UAAU,mCAAmC,CACjD,KAAsC,EACtC,SAAwB;IAExB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,KAAK,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAc,EAAE,EAAE;QAC5C,IACE,KAAK,CAAC,mBAAmB,KAAK,UAAU;YACxC,0BAA0B,CAAC,KAAK,CAAC;YAEjC,OAAO;QAET,MAAM,yCAAyC,CAC7C,KAAK,EACL,OAAO,CAAC,IAAI,CAAC,sBAAsB,EACnC;YACE,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,WAAW;YACvB,SAAS,EAAE,gCAAgC;YAC3C,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc;SAC5C,CACF,CAAC;QACF,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,uCAAuC,CAAC;YACxD,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,wEAAwE;QAC1E,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { reportKeyingVerificationErrorInCauseChain } from \"../../data/keyingProjectionVerification/error\";\nimport { errorMessage } from \"../../data/shared/errorMessage\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport type { ContainerContentsStoreSyncState } from \"./syncAgentTypes\";\n\n/** Observe a background refresh without changing the caller's rejection. */\nexport function observeContainerBackgroundHydration(\n state: ContainerContentsStoreSyncState,\n hydration: Promise<void>,\n): void {\n const generation = state.lifecycleGeneration;\n const runtime = state.runtime;\n void hydration.catch(async (error: unknown) => {\n if (\n state.lifecycleGeneration !== generation ||\n isDatabaseUnavailableError(error)\n )\n return;\n\n await reportKeyingVerificationErrorInCauseChain(\n error,\n runtime.util.reportSecurityIncident,\n {\n objectId: null,\n objectKind: \"container\",\n operation: \"container.hydration.background\",\n organizationId: runtime.auth.organizationId,\n },\n );\n try {\n const message = \"Container background hydration failed\";\n if (runtime.util.logError) {\n await runtime.util.logError(message, error);\n } else {\n await runtime.util.log(`${message}: ${errorMessage(error)}`);\n }\n } catch {\n // A host logger must not turn an observed refusal into a new rejection.\n }\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerPurgeCore.js","sourceRoot":"","sources":["containerPurgeCore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EAAE,wCAAwC,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAY1D,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAO5C;IACC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiB,CAAC;IACjD,KAAK,MAAM,wBAAwB,IAAI,KAAK,CAAC,yBAAyB,EAAE,CAAC;QACvE,MAAM,WAAW,GAAG,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAClD,wBAAwB,CACzB,CAAC;QACF,IAAI,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;YACnC,eAAe,CAAC,GAAG,CAAC,WAAW,CAA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,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAC9D,MAAM,wBAAwB,GAAG,MAAM,CAAC,yBAAyB,CAAC,IAAI,CACpE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CACtD,CAAC;IACF,IAAI,CAAC,SAAS,EAAE,IAAI,wBAAwB,EAAE,CAAC;QAC7C,MAAM,sBAAsB,CAAC;YAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,sBAAsB;YACtB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,yBAAyB,EAAE,MAAM,CAAC,yBAAyB;YAC3D,KAAK;YACL,SAAS;SACV,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC1D,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACjD,CAAC;IACD,0EAA0E;IAC1E,6CAA6C;IAC7C,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAChG,CAAC;IACF,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { PurgeOptions } from \"../../workflows/container-contents/container-state/purgeProgress\";\nimport { purgeContainerTree } from \"../../workflows/container-contents/container-state/purgeTree\";\nimport { prepareContainerDocumentRotationSnapshot } from \"./documentRotation\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\ntype ContainerPurgeResult = NonNullable<\n Awaited<ReturnType<typeof purgeContainerTree>>\n>;\n\n/** @internal Reconciles any completed destructive prefix after expiry. */\nexport async function refreshAfterStalePurge(input: {\n completedCount: number;\n containerStatesAtStart: ReadonlyMap<string, ContainerState>;\n purgedContainerIds: readonly string[];\n remoteDeletedContainerIds: readonly string[];\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n}): Promise<void> {\n const remoteParentIds = new Set<string | null>();\n for (const remoteDeletedContainerId of input.remoteDeletedContainerIds) {\n const purgedState = input.containerStatesAtStart.get(\n remoteDeletedContainerId,\n );\n if (purgedState?.record.documentId) {\n remoteParentIds.add(purgedState.container.parentId);\n }\n }\n\n input.state.localContainersNeedRefresh = true;\n await input.syncAgent.refreshLocalContainers();\n let removedState = false;\n for (const purgedContainerId of input.purgedContainerIds) {\n const deletedState = input.containerStatesAtStart.get(purgedContainerId);\n if (\n deletedState &&\n input.state.containersById.get(purgedContainerId) === deletedState\n ) {\n input.state.containersById.delete(purgedContainerId);\n removedState = true;\n }\n }\n input.state.documentStoresNeedPriming = true;\n if (removedState && input.state.initialized) {\n updateContainerContentsSnapshot(input.state);\n }\n if (remoteParentIds.size > 0) {\n await input.syncAgent.requestRemoteHydration({\n followDiscoveredParentLanes: false,\n parentIds: [...remoteParentIds],\n resetAllLaneWatermarks: true,\n });\n }\n}\n\n// Shared core of the two recursive purge operations (purgeContainer and\n// emptyTrash): guard readiness and the remote-authority gate, run the\n// recursive purge engine, drop the purged containers from the tree, and log\n// the outcome. The operations differ only in target validation, whether the\n// root container itself survives, and how the result is described/judged.\nexport async function runContainerPurge(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n options: PurgeOptions | undefined,\n isCurrent: ContainerWriteGuard,\n operation: {\n describeResult: (\n target: ContainerState,\n result: ContainerPurgeResult,\n ) => string;\n didSucceed: (result: ContainerPurgeResult) => boolean;\n keepRootContainer?: boolean | undefined;\n validateTarget: (target: ContainerState) => boolean;\n },\n): Promise<boolean> {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return false;\n }\n\n const targetState = state.containersById.get(containerId);\n if (!targetState || !operation.validateTarget(targetState)) {\n return false;\n }\n\n // Any remote container or document in the subtree needs the server, so require\n // auth + online when the target itself is remote (a local-only subtree can be\n // torn down offline, matching deleteContainer's gate).\n const isRemoteContainer = Boolean(targetState.record.documentId);\n if (\n isRemoteContainer &&\n (!state.runtime.auth.isAuthenticated || !state.runtime.state.online)\n ) {\n return false;\n }\n const containerStatesAtStart = new Map(state.containersById);\n\n const result = await purgeContainerTree({\n containersById: state.containersById,\n keepRootContainer: operation.keepRootContainer ?? false,\n onProgress: options?.onProgress,\n persistence: state.persistence,\n prepareDocumentRotationSnapshot: (document) =>\n prepareContainerDocumentRotationSnapshot(state.runtime, document),\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n rootContainerId: containerId,\n runtime: state.runtime,\n signal: options?.signal,\n stillCurrent: isCurrent,\n });\n if (!result) {\n return false;\n }\n const purgedContainerIds = new Set(result.purgedContainerIds);\n const hasUnsettledRemoteDelete = result.remoteDeletedContainerIds.some(\n (containerId) => !purgedContainerIds.has(containerId),\n );\n if (!isCurrent() || hasUnsettledRemoteDelete) {\n await refreshAfterStalePurge({\n completedCount: result.completedCount,\n containerStatesAtStart,\n purgedContainerIds: result.purgedContainerIds,\n remoteDeletedContainerIds: result.remoteDeletedContainerIds,\n state,\n syncAgent,\n });\n return false;\n }\n\n for (const purgedContainerId of result.purgedContainerIds) {\n state.containersById.delete(purgedContainerId);\n }\n // Only re-render when something actually left the tree; a fully-failed or\n // immediately-cancelled run changed nothing.\n if (result.purgedContainerIds.length > 0) {\n updateContainerContentsSnapshot(state);\n }\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${operation.describeResult(targetState, result)}`,\n );\n return operation.didSucceed(result);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerStateMap.js","sourceRoot":"","sources":["containerStateMap.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAkB,SAAQ,GAA2B;IACvD,uBAAuB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7D,uBAAuB,GAAG,CAAC,CAAC;IAE5B,YAAY,OAA6C;QACvD,KAAK,EAAE,CAAC;QACR,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;YACjD,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAEQ,KAAK;QACZ,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAEQ,MAAM,CAAC,WAAmB;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1C,sEAAsE;QACtE,0EAA0E;QAC1E,sEAAsE;QACtE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,GAAG,CAAC,WAAmB,EAAE,KAAqB;QACrD,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,0BAA0B;QACxB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IAED,gBAAgB,CACd,WAAmB,EACnB,QAAqC;QAErC,OAAO,CACL,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpD,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CACjC,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,WAAmB;QACxC,IAAI,CAAC,uBAAuB,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC9E,CAAC;CACF;AAED,MAAM,UAAU,wCAAwC,CACtD,MAAmC;IAEnC,OAAO,MAAM,YAAY,iBAAiB;QACxC,CAAC,CAAC,MAAM,CAAC,0BAA0B,EAAE;QACrC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,MAAmC,EACnC,WAAmB,EACnB,QAAqC;IAErC,OAAO,CACL,MAAM,YAAY,iBAAiB;QACnC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\n\nexport class ContainerStateMap extends Map<string, ContainerState> {\n readonly #mutationGenerationById = new Map<string, number>();\n #nextMutationGeneration = 0;\n\n constructor(entries?: ReadonlyMap<string, ContainerState>) {\n super();\n for (const [containerId, state] of entries ?? []) {\n super.set(containerId, state);\n }\n }\n\n override clear(): void {\n for (const containerId of this.keys()) {\n this.recordMutation(containerId);\n }\n super.clear();\n }\n\n override delete(containerId: string): boolean {\n const deleted = super.delete(containerId);\n // An absent delete is still an authoritative tombstone observation. A\n // local-refresh query that started before it must not install a stale row\n // merely because no in-memory value existed for Map.delete to remove.\n this.recordMutation(containerId);\n return deleted;\n }\n\n override set(containerId: string, state: ContainerState): this {\n this.recordMutation(containerId);\n return super.set(containerId, state);\n }\n\n captureMutationGenerations(): ReadonlyMap<string, number> {\n return new Map(this.#mutationGenerationById);\n }\n\n hasMutationAfter(\n containerId: string,\n baseline: ReadonlyMap<string, number>,\n ): boolean {\n return (\n (this.#mutationGenerationById.get(containerId) ?? 0) !==\n (baseline.get(containerId) ?? 0)\n );\n }\n\n private recordMutation(containerId: string): void {\n this.#nextMutationGeneration += 1;\n this.#mutationGenerationById.set(containerId, this.#nextMutationGeneration);\n }\n}\n\nexport function captureContainerStateMutationGenerations(\n states: Map<string, ContainerState>,\n): ReadonlyMap<string, number> {\n return states instanceof ContainerStateMap\n ? states.captureMutationGenerations()\n : new Map();\n}\n\nexport function containerStateMutatedAfter(\n states: Map<string, ContainerState>,\n containerId: string,\n baseline: ReadonlyMap<string, number>,\n): boolean {\n return (\n states instanceof ContainerStateMap &&\n states.hasMutationAfter(containerId, baseline)\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerStatePersistence.js","sourceRoot":"","sources":["containerStatePersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GACzC,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAwB1D,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAkC,EAClC,cAA8B,EAC9B,UAAwC,EAAE;IAE1C,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC3E,MAAM,SAAS,GAAG,MAAM,wCAAwC,CAAC;QAC/D,aAAa,EAAE,cAAc;QAC7B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,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ACvC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,MAAM,EAAE,WAAW;QACnB,GAAG,CAAC,SAAS,CAAC,mBAAmB;YAC/B,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAa,EAAE;YACxC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,SAAS,CAAC,iBAAiB;YAC7B,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAa,EAAE;YACtC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n installContainerMetadataRecord,\n persistContainerMetadataStateFromRuntime,\n} from \"../../workflows/container-contents/metadata\";\nimport type { PersistContainerStateResult } from \"../../workflows/container-contents/remoteHydration\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type { ContainerState } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\ntype MetadataPersistenceInput = Parameters<\n typeof persistContainerMetadataStateFromRuntime\n>[0];\n\ninterface PersistContainerStateOptions\n extends Pick<\n MetadataPersistenceInput,\n | \"patch\"\n | \"saveOptions\"\n | \"localMetadataPatch\"\n | \"localUpdate\"\n | \"createIntentSettlement\"\n | \"moveIntentSettlement\"\n | \"preserveDurableStructureWhenPending\"\n > {\n expectedStateWhenMissing?: ContainerState | undefined;\n isCurrent?: (() => boolean) | undefined;\n updateView?: boolean | undefined;\n}\n\nexport async function persistContainerState(\n state: ContainerContentsStoreState,\n containerState: ContainerState,\n options: PersistContainerStateOptions = {},\n): Promise<PersistContainerStateResult> {\n const { expectedStateWhenMissing, isCurrent, updateView = true } = options;\n const persisted = await persistContainerMetadataStateFromRuntime({\n metadataState: containerState,\n localMetadataPatch: options.localMetadataPatch,\n localUpdate: options.localUpdate,\n patch: options.patch ?? {},\n persistence: state.persistence,\n createIntentSettlement: options.createIntentSettlement,\n moveIntentSettlement: options.moveIntentSettlement,\n preserveDurableStructureWhenPending:\n options.preserveDurableStructureWhenPending,\n runtime: state.runtime,\n saveOptions: options.saveOptions,\n stillCurrent: isCurrent,\n });\n if (isCurrent?.() === false) {\n return { status: \"stale-generation\" };\n }\n if (!persisted) {\n removeMissingContainerState(\n state,\n expectedStateWhenMissing ?? containerState,\n );\n return { status: \"missing\" };\n }\n containerState.container = persisted.container;\n installContainerMetadataRecord(containerState, persisted.record);\n if (persisted.mutationSuperseded || persisted.syncIdentitySuperseded) {\n const cachedState = state.containersById.get(containerState.container.id);\n if (cachedState && cachedState !== containerState) {\n cachedState.container = containerState.container;\n cachedState.doc = containerState.doc;\n cachedState.metadataWriterProjection =\n containerState.metadataWriterProjection;\n installContainerMetadataRecord(cachedState, persisted.record);\n }\n // The requested structural mutation was not applied. Refresh from the\n // authoritative state installed above, but make the caller fail explicitly\n // so it cannot schedule sync or report the dropped mutation as successful.\n updateContainerContentsSnapshot(state);\n return { record: persisted.record, status: \"identity-superseded\" };\n }\n if (updateView) {\n updateContainerContentsSnapshot(state);\n }\n return {\n record: persisted.record,\n status: \"persisted\",\n ...(persisted.createIntentSettled\n ? { createIntentSettled: true as const }\n : {}),\n ...(persisted.moveIntentSettled\n ? { moveIntentSettled: true as const }\n : {}),\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentRecovery.js","sourceRoot":"","sources":["documentRecovery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,oDAAoD,CAAC;AAM5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AAExG,OAAO,EAEL,uCAAuC,GACxC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,0BAA0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,CAAC;aAAM,IAAI,CAAC,eAAe,GAAG,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,gBAAgB,eAAe,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACxC,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import type { ContainerContentsPersistence } from \"../../workflows/container-contents/containerPersistence\";\nimport {\n primeDocumentsForContainerSubtree,\n primeDocumentsForLoadedRoots,\n} from \"../../workflows/container-contents/documentPriming\";\nimport type {\n ContainerDocumentPrimeHost,\n ContainerDocumentPrimeStore,\n} from \"../../workflows/container-contents/documentQueries/types\";\nimport type { StaleRootRecoveryStatus } from \"../../workflows/container-contents/recovery/staleRootRecovery\";\nimport { recoverStaleSessionRoot } from \"../../workflows/container-contents/recovery/staleRootRecovery\";\nimport type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nimport {\n type ContainerContentsStoreWorkflowRuntime,\n createContainerContentsDocumentsRuntime,\n} from \"../../workflows/container-contents/runtime\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport { openDocumentStore } from \"../documents\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\n\ntype PrimeDocumentRuntime = ReturnType<\n typeof createContainerContentsDocumentsRuntime\n>;\n\ninterface DocumentRecoveryStoreState {\n readonly containersById: Map<string, ContainerState>;\n documentStoresNeedPriming: boolean;\n readonly logLabel?: string | undefined;\n readonly persistence: ContainerContentsPersistence;\n readonly rootLaneHydrated: boolean;\n readonly runtime: ContainerContentsStoreWorkflowRuntime;\n}\n\ninterface StaleRootRecoveryLogState {\n readonly message: string;\n readonly occurrenceCount: number;\n}\n\nconst staleRootRecoveryLogState = new WeakMap<\n DocumentRecoveryStoreState,\n StaleRootRecoveryLogState\n>();\nconst rejectedAdoptionRuntime = new WeakMap<\n DocumentRecoveryStoreState,\n ContainerContentsStoreWorkflowRuntime\n>();\n\nfunction createPrimeHost(\n runtime: ContainerContentsStoreWorkflowRuntime,\n): ContainerDocumentPrimeHost<PrimeDocumentRuntime> {\n return {\n documentWorkflowRuntime: (containerId) =>\n createContainerContentsDocumentsRuntime(runtime, containerId),\n openDocumentStore: ({\n documentId,\n localId,\n runtime,\n }): ContainerDocumentPrimeStore =>\n openDocumentStore(\n runtime.state.domainScope,\n localId,\n runtime,\n documentId,\n ),\n };\n}\n\nexport async function primeStoreDocumentSubtree(\n state: DocumentRecoveryStoreState,\n rootContainerId: string,\n isCurrent: () => boolean = () => true,\n): Promise<void> {\n if (!isCurrent()) return;\n const runtime = state.runtime;\n await primeDocumentsForContainerSubtree({\n containersById: state.containersById,\n host: createPrimeHost(runtime),\n isCurrent,\n rootContainerId,\n runtime,\n });\n}\n\nexport async function primeStoreDocuments(\n state: DocumentRecoveryStoreState,\n isCurrent: () => boolean = () => true,\n): Promise<void> {\n if (!isCurrent()) return;\n const runtime = state.runtime;\n // Consume the current signal before scanning. A topology/root reconciliation\n // that lands during an awaited query can then re-arm the next pass without\n // this pass erasing that newer signal when it completes.\n state.documentStoresNeedPriming = false;\n try {\n const result = await primeDocumentsForLoadedRoots({\n containersById: state.containersById,\n host: createPrimeHost(runtime),\n isCurrent,\n organizationId: runtime.auth?.organizationId ?? null,\n runtime,\n });\n if (!isCurrent()) {\n state.documentStoresNeedPriming = true;\n return;\n }\n runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: document priming candidates=${result.candidateCount} roots=${result.rootCount} primed=${result.primedCount} orphaned=${result.orphanPrimedCount} unroutable=${result.unroutableCount}`,\n );\n } catch (error) {\n if (!isCurrent()) {\n state.documentStoresNeedPriming = true;\n return;\n }\n state.documentStoresNeedPriming = true;\n throw error;\n }\n}\n\nexport async function recoverStoreStaleRoot(\n state: DocumentRecoveryStoreState,\n isCurrent: () => boolean = () => true,\n): Promise<StaleRootRecoveryStatus> {\n if (!isCurrent()) {\n return \"context-changed\";\n }\n const runtime = state.runtime;\n if (rejectedAdoptionRuntime.get(state) === runtime) {\n return \"not-needed\";\n }\n\n let result: Awaited<ReturnType<typeof recoverStaleSessionRoot>>;\n try {\n result = await recoverStaleSessionRoot({ ...state, runtime }, isCurrent);\n } catch (error) {\n if (!isCurrent()) {\n return \"context-changed\";\n }\n if (isDatabaseUnavailableError(error)) {\n throw error;\n }\n const message = `${getContainerContentsStoreLogLabel(state)}: stale root recovery failed`;\n if (state.runtime.util.logError) {\n state.runtime.util.logError(message, error);\n } else {\n state.runtime.util.log(message);\n }\n return \"not-needed\";\n }\n if (!isCurrent()) {\n return \"context-changed\";\n }\n const message = `${getContainerContentsStoreLogLabel(state)}: stale root recovery status=${result.status} candidates=${result.candidateCount}`;\n const previousLogState = staleRootRecoveryLogState.get(state);\n const occurrenceCount =\n previousLogState?.message === message\n ? previousLogState.occurrenceCount + 1\n : 1;\n staleRootRecoveryLogState.set(state, { message, occurrenceCount });\n if (result.status !== \"not-needed\") {\n if (occurrenceCount === 1) {\n runtime.util.log(message);\n } else if ((occurrenceCount & (occurrenceCount - 1)) === 0) {\n runtime.util.log(`${message} occurrences=${occurrenceCount}`);\n }\n }\n if (result.status === \"context-changed\") {\n rejectedAdoptionRuntime.set(state, runtime);\n } else {\n rejectedAdoptionRuntime.delete(state);\n }\n if (result.reassigned) {\n state.documentStoresNeedPriming = true;\n }\n return result.status;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentRotation.js","sourceRoot":"","sources":["documentRotation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,uCAAuC,GACxC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,OAAyC,EACzC,QAAyB;IAEzB,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAC7B,OAAO,CAAC,KAAK,CAAC,WAAW,EACzB,QAAQ,CAAC,EAAE,EACX,uCAAuC,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EACtE,QAAQ,CAAC,UAAU,CACpB,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,yBAAyB,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import type { DocumentSummary } from \"../../data/documents/documentSummary\";\nimport {\n type ContainerContentsWorkflowRuntime,\n createContainerContentsDocumentsRuntime,\n} from \"../../workflows/container-contents/runtime\";\nimport { openDocumentStore } from \"../documents\";\n\nexport async function prepareContainerDocumentRotationSnapshot(\n runtime: ContainerContentsWorkflowRuntime,\n document: DocumentSummary,\n): Promise<Uint8Array | null> {\n if (!document.documentId || !document.containerId) {\n return null;\n }\n const store = openDocumentStore(\n runtime.state.domainScope,\n document.id,\n createContainerContentsDocumentsRuntime(runtime, document.containerId),\n document.documentId,\n );\n if (!(await store.ensureInitialized())) {\n return null;\n }\n return store.assertCanRotateContentKey();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentWork.js","sourceRoot":"","sources":["documentWork.ts"],"names":[],"mappings":"AAYA,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAiC;IAEjC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;QACzC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,KAAK,CAAC,wBAAwB,EAAE,CAAC;IAClE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,kBAAkB,GAAG,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IACD,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACjC,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type { StaleRootRecoveryStatus } from \"../../workflows/container-contents/recovery/staleRootRecovery\";\n\ninterface ContainerDocumentWorkInput {\n readonly isCurrent: () => boolean;\n readonly onContextChanged: () => void;\n readonly onDocumentsMoved: () => void;\n readonly primeDocuments: () => Promise<void>;\n readonly recoverStaleRoot: () => Promise<StaleRootRecoveryStatus>;\n readonly shouldPrimeDocuments: () => boolean;\n readonly syncPendingDocumentMoves: () => Promise<number>;\n}\n\n/** Runs root repair before any work that consumes its rewritten projections. */\nexport async function runContainerDocumentWork(\n input: ContainerDocumentWorkInput,\n): Promise<\"abandoned\" | \"completed\" | \"context-changed\"> {\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n const recoveryStatus = await input.recoverStaleRoot();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n if (recoveryStatus === \"context-changed\") {\n input.onContextChanged();\n return \"context-changed\";\n }\n\n const movedDocumentCount = await input.syncPendingDocumentMoves();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n if (movedDocumentCount > 0) {\n input.onDocumentsMoved();\n }\n if (input.shouldPrimeDocuments()) {\n await input.primeDocuments();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n }\n return \"completed\";\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emptyTrashOperation.js","sourceRoot":"","sources":["emptyTrashOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKzD,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,kFAAkF;AAClF,iFAAiF;AACjF,gFAAgF;AAChF,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAAkC,EAClC,SAA0C,EAC1C,gBAAwB,EACxB,OAAsB,EACtB,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,OAAO,iBAAiB,CACtB,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT;QACE,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAClC,kBAAkB,MAAM,CAAC,kBAAkB,CAAC,MAAM,0BAA0B,MAAM,CAAC,WAAW,UAAU;QAC1G,0DAA0D;QAC1D,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,WAAW,KAAK,CAAC;QACnE,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CACzB,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,IAAI;KACjD,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PurgeOptions } from \"../../workflows/container-contents/container-state/purgeProgress\";\nimport { runContainerPurge } from \"./containerPurgeCore\";\nimport type { ContainerContentsStoreSyncAgent } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\n// Permanently destroy EVERYTHING under the Trash bin — every trashed folder's\n// whole subtree and every document deleted straight into Trash — while leaving\n// the Trash system container itself in place. This is \"Empty Trash\": it reuses\n// the recursive purge engine with keepRootContainer so the bin survives, and it\n// inherits that engine's semantics — documents also linked outside Trash are\n// unlinked (not destroyed), containers are torn down leaf-first, a failed item is\n// skipped rather than aborting the sweep, and an optional signal cancels between\n// items. The target must be a real system container (the Trash bin); like every\n// purge it is online-only when any of its contents are remote.\nexport async function emptyTrash(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n trashContainerId: string,\n options?: PurgeOptions,\n isCurrent: ContainerWriteGuard = () => true,\n): Promise<boolean> {\n return runContainerPurge(\n state,\n syncAgent,\n trashContainerId,\n options,\n isCurrent,\n {\n describeResult: (_target, result) =>\n `emptied trash (${result.purgedContainerIds.length} container(s) removed, ${result.failedCount} failed)`,\n // A clean empty: nothing failed and it ran to completion.\n didSucceed: (result) => !result.aborted && result.failedCount === 0,\n keepRootContainer: true,\n validateTarget: (target) =>\n (target.container.systemSlot ?? null) !== null,\n },\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"existingSystemContainer.js","sourceRoot":"","sources":["existingSystemContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO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,QAAQ,EAAE,iCAAiC,CAAC,KAAK,CAAC;QAClD,OAAO;QACP,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE;YACpD,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACjC,+BAA+B,CAAC,KAAK,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YACxE,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,cAAc,EAAE;gBAChE,WAAW,EAAE,SAAS,CAAC,iBAAiB;oBACtC,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,EAAE,EAAE;oBACtE,CAAC,CAAC,SAAS;gBACb,WAAW,EAAE,SAAS,CAAC,cAAc;gBACrC,SAAS;aACV,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC;QACvC,CAAC;QACD,SAAS,EAAE,sBAAsB,CAAC,KAAK,CAAC;QACxC,KAAK;QACL,SAAS;QACT,SAAS;KACV,CAAC,CAAC;IACH,OAAO,QAAQ,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC","sourcesContent":["import { persistContainerState } from \"./containerStatePersistence\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { invalidateRemoteContainerWrites } from \"./remoteWriteGuards\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport { applySystemContainerIcon } from \"./systemContainerIcon\";\nimport { findRootContainerState } from \"./systemContainerLookup\";\nimport { promoteExistingLocalSystemContainerSync } from \"./systemContainerPromotion\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"./types\";\nimport { toContainerNode } from \"./utils\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nexport async function updateExistingSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n existing: ContainerState,\n options: EnsureSystemContainerOptions,\n isCurrent: ContainerWriteGuard,\n) {\n if (\"icon\" in options) {\n const iconApplied = await applySystemContainerIcon({\n containerState: existing,\n icon: options.icon,\n persistIcon: async (containerState, icon, update) => {\n if (options.deferRemoteBootstrap) {\n invalidateRemoteContainerWrites(state, [containerState.container.id]);\n }\n const result = await persistContainerState(state, containerState, {\n patch: { icon },\n updateView: false,\n localMetadataPatch: { icon },\n localUpdate: update,\n isCurrent,\n });\n return result.status;\n },\n state,\n syncAgent,\n isCurrent,\n });\n if (!iconApplied || !isCurrent()) {\n return null;\n }\n }\n const promoted = await promoteExistingLocalSystemContainerSync({\n containerState: existing,\n logLabel: getContainerContentsStoreLogLabel(state),\n options,\n persistPromotion: async (containerState, promotion) => {\n if (options.deferRemoteBootstrap) {\n invalidateRemoteContainerWrites(state, [containerState.container.id]);\n }\n const result = await persistContainerState(state, containerState, {\n saveOptions: promotion.queueCreateIntent\n ? { createIntent: { parentContainerId: promotion.parentContainerId } }\n : undefined,\n localUpdate: promotion.metadataUpdate,\n isCurrent,\n });\n return result.status === \"persisted\";\n },\n rootState: findRootContainerState(state),\n state,\n syncAgent,\n isCurrent,\n });\n return promoted && isCurrent() ? toContainerNode(existing) : null;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupRewrapOperation.js","sourceRoot":"","sources":["groupRewrapOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,2EAA2E,CAAC;AAC/H,OAAO,EAAE,gCAAgC,EAAE,MAAM,0DAA0D,CAAC;AAO5G,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,KAAkC,EAClC,WAAmB,EACnB,OAAe,EACf,WAA8C,EAC9C,OAAwD,EACxD,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,IACE,KAAK,CAAC,O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;IACD,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACrE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,kCAAkC,CAAC;QACvD,WAAW;QACX,cAAc;QACd,mBAAmB;QACnB,iBAAiB;QACjB,sBAAsB;QACtB,OAAO;QACP,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;QACxD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY,EAAE,SAAS;KACxB,CAAC,CAAC;IACH,OAAO,SAAS,EAAE,IAAI,OAAO,CAAC;AAChC,CAAC","sourcesContent":["import type { ReferencedPrincipalHead } from \"@tearleads/crypto\";\nimport { containerStateHasCurrentGroupGrant } from \"../../workflows/container-contents/container-state/groupGrantVerification\";\nimport { prepareContainerStateGroupRewrap } from \"../../workflows/container-contents/container-state/share\";\nimport type {\n ContainerContentsShareAccessLevel,\n ContainerContentsStoreState,\n} from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nexport async function prepareContainerGroupRewrap(\n state: ContainerContentsStoreState,\n containerId: string,\n groupId: string,\n accessLevel: ContainerContentsShareAccessLevel,\n options?: { requireExistingGrant?: boolean } | undefined,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n return null;\n }\n const containerState = state.containersById.get(containerId);\n if (!containerState) {\n return null;\n }\n\n const preparation = await prepareContainerStateGroupRewrap({\n accessLevel,\n containerState,\n groupId,\n requireExistingGrant: options?.requireExistingGrant,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n return isCurrent() ? preparation : null;\n}\n\nexport async function verifyContainerGroupRewrapCurrent(\n state: ContainerContentsStoreState,\n containerId: string,\n groupId: string,\n accessLevel: ContainerContentsShareAccessLevel,\n expectedGroupHead: ReferencedPrincipalHead,\n expectedContainerId: string,\n expectedOrganizationId: string,\n isCurrent: ContainerWriteGuard = () => true,\n): Promise<boolean> {\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n return false;\n }\n if (containerId !== expectedContainerId) {\n return false;\n }\n const containerState = state.containersById.get(expectedContainerId);\n if (!containerState) {\n return false;\n }\n\n const current = await containerStateHasCurrentGroupGrant({\n accessLevel,\n containerState,\n expectedContainerId,\n expectedGroupHead,\n expectedOrganizationId,\n groupId,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n return isCurrent() && current;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"missingContainerState.js","sourceRoot":"","sources":["missingContainerState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAG1D,MAAM,UAAU,2BAA2B,CACzC,KAAkC,EAClC,aAA6B;IAE7B,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,aAAa,EAAE,CAAC;QAC5D,OAAO;IACT,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,+BAA+B,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\nexport function removeMissingContainerState(\n state: ContainerContentsStoreState,\n expectedState: ContainerState,\n): void {\n const containerId = expectedState.container.id;\n if (state.containersById.get(containerId) !== expectedState) {\n return;\n }\n state.containersById.delete(containerId);\n updateContainerContentsSnapshot(state);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"missingSyncedContainerState.js","sourceRoot":"","sources":["missingSyncedContainerState.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iCAAiC,CAC/C,KAAsC,EACtC,aAA6B,EAC7B,cAA0B;IAE1B,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,aAAa,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,cAAc,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nimport type { ContainerContentsStoreSyncState } from \"./syncAgentTypes\";\n\nexport function removeMissingSyncedContainerState(\n state: ContainerContentsStoreSyncState,\n expectedState: ContainerState,\n updateSnapshot: () => void,\n): boolean {\n const containerId = expectedState.container.id;\n if (state.containersById.get(containerId) !== expectedState) {\n return false;\n }\n\n state.containersById.delete(containerId);\n updateSnapshot();\n return true;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAC;AACjG,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mEAAmE,CAAC;AAC3E,OAAO,EACL,8BAA8B,EAC9B,uCAAuC,GACxC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,oEAAoE,CAAC;AAC5E,OAAO,E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AI,CAAC;IACd,CAAC;IAED,IAAI,aAAa,CAAC,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;IACD,uBAAuB,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAErE,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC;YACE,UAAU,EAAE;gBACV,iBAAiB,EAAE,QAAQ;gBAC3B,yBAAyB,EAAE,aAAa,CAAC,SAAS,CAAC,QAAQ;aAC5D;SACF;QACH,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE;QAClE,KAAK,EAAE,EAAE,QAAQ,EAAE;QACnB,WAAW;QACX,SAAS;KACV,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,IAAI,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,iBAAiB;QAC9B,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,iBAAiB,CAAC;IACtB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,MAAM,IAAI,WAAW,UAAU,QAAQ,EAAE,CAC1F,CAAC;IACF,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport { createChildContainerState } from \"../../workflows/container-contents/container-state/createChild\";\nimport { deleteContainerState } from \"../../workflows/container-contents/container-state/delete\";\nimport {\n assertLocalChildPathFits,\n assertLocalMovePathFits,\n} from \"../../workflows/container-contents/container-state/localPathDepth\";\nimport {\n installContainerMetadataRecord,\n renameContainerMetadataStateFromRuntime,\n} from \"../../workflows/container-contents/metadata\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../workflows/container-contents/metadata/metadataStateIsolation\";\nimport { persistContainerState } from \"./containerStatePersistence\";\nimport { updateExistingSystemContainer } from \"./existingSystemContainer\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\nimport { ensureOrganizationMetadataSystemContainer } from \"./organizationMetadataSystemContainer\";\nimport {\n invalidateRemoteContainerWrites,\n invalidateRemoteSystemContainerWrite,\n} from \"./remoteWriteGuards\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport { probeExistingSystemContainer } from \"./systemContainerHydration\";\nimport {\n findRootContainerState,\n findSystemContainerStateForRoot,\n} from \"./systemContainerLookup\";\nimport { finalizeCreatedSystemContainer } from \"./systemContainerPostCreate\";\nimport { hasAdvancedManagedPrincipalReference } from \"./systemContainerPromotion\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"./types\";\nimport { isContainerInSubtree, toContainerNode } from \"./utils\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nexport async function createChildContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n parentId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const parentState = state.containersById.get(parentId);\n if (!parentState) {\n return null;\n }\n assertLocalChildPathFits(state.containersById, parentId);\n\n const created = await createChildContainerState({\n createRemote: false,\n name: trimmedName,\n parentState,\n persistence: state.persistence,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!created || !isCurrent()) return null;\n\n state.containersById.set(\n created.containerState.container.id,\n created.containerState,\n );\n updateContainerContentsSnapshot(state);\n if (created.shouldRequestSync) {\n syncAgent.scheduleSync();\n }\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: created container \"${trimmedName}\"`,\n );\n return toContainerNode(created.containerState);\n}\n\nfunction canEnsureSystemContainer(\n state: ContainerContentsStoreState,\n name: string,\n): boolean {\n return (\n state.runtime.infra.dbStatus === \"ready\" && state.snapshot.ready && !!name\n );\n}\n\nasync function findOrHydrateSystemContainer(input: {\n isCurrent: ContainerWriteGuard;\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n systemSlot: ContainerSystemSlot;\n}): Promise<ContainerState | null> {\n const { isCurrent, state, syncAgent, systemSlot } = input;\n const existing = findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (\n existing ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n return existing;\n }\n await probeExistingSystemContainer({\n logLabel: getContainerContentsStoreLogLabel(state),\n rootState: findRootContainerState(state),\n state,\n syncAgent,\n systemSlot,\n });\n return isCurrent()\n ? findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n )\n : null;\n}\n\nfunction canCreateSystemContainer(\n state: ContainerContentsStoreState,\n rootState: ContainerState,\n systemSlot: ContainerSystemSlot,\n options: EnsureSystemContainerOptions,\n): boolean {\n if (\n options.skipAdvancedManagedRoot &&\n hasAdvancedManagedPrincipalReference(rootState)\n ) {\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: skipped background system container \"${systemSlot}\" because the root has advanced managed-principal references`,\n );\n return false;\n }\n\n return true;\n}\n\nexport async function ensureSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n name: string,\n options: EnsureSystemContainerOptions = {},\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (!canEnsureSystemContainer(state, trimmedName)) {\n return null;\n }\n\n const metadata = await ensureOrganizationMetadataSystemContainer({\n state,\n syncAgent,\n systemSlot,\n options,\n isCurrent,\n });\n if (!isCurrent()) return null;\n if (metadata.handled) return metadata.container;\n\n return ensureChildSystemContainer(\n state,\n syncAgent,\n systemSlot,\n trimmedName,\n options,\n isCurrent,\n );\n}\n\nasync function ensureChildSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n trimmedName: string,\n options: EnsureSystemContainerOptions,\n isCurrent: ContainerWriteGuard,\n) {\n const allowSynchronousRemoteBootstrap = !options.deferRemoteBootstrap;\n const existing = allowSynchronousRemoteBootstrap\n ? await findOrHydrateSystemContainer({\n isCurrent,\n state,\n syncAgent,\n systemSlot,\n })\n : findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (!isCurrent()) return null;\n if (existing) {\n return updateExistingSystemContainer(\n state,\n syncAgent,\n existing,\n options,\n isCurrent,\n );\n }\n\n const rootState = findRootContainerState(state);\n if (!rootState) {\n return null;\n }\n if (!canCreateSystemContainer(state, rootState, systemSlot, options))\n return null;\n\n if (options.deferRemoteBootstrap) {\n invalidateRemoteSystemContainerWrite(\n state,\n rootState.container.id,\n systemSlot,\n );\n invalidateRemoteContainerWrites(state, [rootState.container.id]);\n }\n const createRemote =\n allowSynchronousRemoteBootstrap &&\n state.runtime.auth.isAuthenticated &&\n Boolean(state.runtime.crypto.encapsulationKeyPair);\n const created = await createChildContainerState({\n systemSlot,\n createRemote,\n icon: options.icon,\n name: trimmedName,\n parentState: rootState,\n persistence: state.persistence,\n queueRemoteSync: !options.deferRemoteSync,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!created || !isCurrent()) {\n if (createRemote && !isCurrent()) {\n state.containerParentIdsNeedingHydration.add(rootState.container.id);\n syncAgent.scheduleRemoteHydration();\n }\n return null;\n }\n\n const finalized = await finalizeCreatedSystemContainer({\n created,\n logLabel: getContainerContentsStoreLogLabel(state),\n state,\n syncAgent,\n systemSlot,\n isCurrent,\n });\n if (!finalized || !isCurrent()) return null;\n if (finalized.adopted) {\n const updated = await updateExistingSystemContainer(\n state,\n syncAgent,\n finalized.containerState,\n options,\n isCurrent,\n );\n if (!updated) return null;\n }\n return toContainerNode(finalized.containerState);\n}\n\nexport async function deleteContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n if (\n !existingState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n Array.from(state.containersById.values()).some(\n (containerState) => containerState.container.parentId === containerId,\n )\n ) {\n return null;\n }\n\n const isRemoteContainer = Boolean(existingState.record.documentId);\n if (isRemoteContainer) {\n if (!state.runtime.auth.isAuthenticated || !state.runtime.state.online) {\n return null;\n }\n }\n\n const deletedNode = toContainerNode(existingState);\n const deleted = await deleteContainerState({\n containerState: existingState,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (deleted === \"remote-failed\") {\n return null;\n }\n if (\n deleted === \"local-conflict\" ||\n deleted === \"remote-deleted\" ||\n !isCurrent()\n ) {\n state.localContainersNeedRefresh = true;\n await syncAgent.refreshLocalContainers();\n // The delete committed before this operation lost its generation. Evict\n // only the exact state it deleted: a concurrent replacement with the same\n // id owns a different object and must survive.\n if (\n deleted === \"deleted\" &&\n state.containersById.get(existingState.container.id) === existingState\n ) {\n state.containersById.delete(existingState.container.id);\n state.documentStoresNeedPriming = true;\n if (state.initialized) {\n updateContainerContentsSnapshot(state);\n }\n }\n if (isRemoteContainer) {\n await syncAgent.requestRemoteHydration({\n followDiscoveredParentLanes: false,\n parentIds: [existingState.container.parentId],\n resetAllLaneWatermarks: true,\n });\n }\n return null;\n }\n\n state.containersById.delete(existingState.container.id);\n // The persistence cascade may have orphaned descendant documents (row 3);\n // re-arm document priming and nudge the lane so their null-scoped passes\n // run now rather than on the next unrelated trigger.\n state.documentStoresNeedPriming = true;\n syncAgent.scheduleSync();\n updateContainerContentsSnapshot(state);\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: deleted container \"${existingState.container.name}\"`,\n );\n return deletedNode;\n}\n\nexport async function renameContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n if (!existingState) {\n return null;\n }\n\n if (existingState.container.name === trimmedName) {\n return toContainerNode(existingState);\n }\n\n const detachedState =\n await createDetachedContainerMetadataState(existingState);\n if (!isCurrent()) return null;\n const renamed = await renameContainerMetadataStateFromRuntime({\n metadataState: detachedState,\n name: trimmedName,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!isCurrent()) return null;\n if (!renamed) {\n removeMissingContainerState(state, existingState);\n return null;\n }\n\n detachedState.container = renamed.container;\n installContainerMetadataRecord(detachedState, renamed.record);\n installDetachedContainerMetadataState(existingState, detachedState);\n updateContainerContentsSnapshot(state);\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: renamed container to \"${trimmedName}\"`,\n );\n return toContainerNode(existingState);\n}\n\nexport async function moveContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n parentId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n const targetParentState = state.containersById.get(parentId);\n if (\n !existingState ||\n !targetParentState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n isContainerInSubtree(state.containersById, parentId, containerId)\n ) {\n return null;\n }\n\n if (existingState.container.parentId === parentId) {\n return toContainerNode(existingState);\n }\n assertLocalMovePathFits(state.containersById, containerId, parentId);\n\n const isRemoteContainer = Boolean(existingState.record.documentId);\n const saveOptions = isRemoteContainer\n ? {\n moveIntent: {\n parentContainerId: parentId,\n previousParentContainerId: existingState.container.parentId,\n },\n }\n : { createIntent: { parentContainerId: parentId } };\n const persisted = await persistContainerState(state, existingState, {\n patch: { parentId },\n saveOptions,\n isCurrent,\n });\n if (persisted.status !== \"persisted\" || !isCurrent()) return null;\n syncAgent.scheduleSync();\n const action = isRemoteContainer\n ? \"queued container move\"\n : \"moved container\";\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${action} ${containerId} under ${parentId}`,\n );\n return toContainerNode(existingState);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationMetadataSystemContainer.js","sourceRoot":"","sources":["organizationMetadataSystemContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6CAA6C,GAC9C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAO1E,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAAC,KAM/D;IACC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE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ACjB,CAAC,CAAC,MAAM,6BAA6B,CACjC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,OAAO,EACP,SAAS,CACV;YACH,CAAC,CAAC,IAAI;KACA,CAAC;AACb,CAAC","sourcesContent":["import {\n type ContainerSystemSlot,\n deriveOrganizationMetadataContainerSystemSlot,\n} from \"@tearleads/validators/containerSystemSlot\";\nimport { updateExistingSystemContainer } from \"./existingSystemContainer\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport type { ContainerContentsStoreSyncAgent } from \"./syncAgent\";\nimport { probeExistingSystemContainer } from \"./systemContainerHydration\";\nimport { findOrganizationSystemRootState } from \"./systemContainerLookup\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\n/** Metadata is provisioned with reserved grants; generic ensure cannot create it. */\nexport async function ensureOrganizationMetadataSystemContainer(input: {\n readonly state: ContainerContentsStoreState;\n readonly syncAgent: ContainerContentsStoreSyncAgent;\n readonly systemSlot: ContainerSystemSlot;\n readonly options: EnsureSystemContainerOptions;\n readonly isCurrent: ContainerWriteGuard;\n}) {\n const { state, syncAgent, systemSlot, options } = input;\n const organizationId = state.runtime.auth.organizationId;\n if (!organizationId) return { handled: false } as const;\n const metadataSlot = await deriveOrganizationMetadataContainerSystemSlot({\n organizationId,\n });\n const isCurrent = () =>\n input.isCurrent() && state.runtime.auth.organizationId === organizationId;\n if (!isCurrent()) return { handled: true, container: null } as const;\n if (systemSlot !== metadataSlot) return { handled: false } as const;\n\n let existing = findOrganizationSystemRootState(\n state,\n organizationId,\n systemSlot,\n );\n if (\n !existing &&\n !options.deferRemoteBootstrap &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n ) {\n await probeExistingSystemContainer({\n logLabel: getContainerContentsStoreLogLabel(state),\n rootState: null,\n state,\n syncAgent,\n systemSlot,\n independentRoot: true,\n });\n if (!isCurrent()) return { handled: true, container: null } as const;\n existing = findOrganizationSystemRootState(\n state,\n organizationId,\n systemSlot,\n );\n }\n return {\n handled: true,\n container: existing\n ? await updateExistingSystemContainer(\n state,\n syncAgent,\n existing,\n options,\n isCurrent,\n )\n : null,\n } as const;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"purgeContainerOperation.js","sourceRoot":"","sources":["purgeContainerOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKzD,oEAAoE;AACpE,iFAAiF;AACjF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,gFAAgF;AAChF,4CAA4C;AAC5C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAAkC,EAClC,SAA0C,EAC1C,WAAmB,EACnB,OAAsB,EACtB,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,OAAO,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE;QAC1E,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACjC,qBAAqB,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,MAAM,CAAC,kBAAkB,CAAC,MAAM,0BAA0B,MAAM,CAAC,WAAW,UAAU;QACxI,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvE,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CACzB,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,IAAI;YAClC,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,IAAI;KACjD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PurgeOptions } from \"../../workflows/container-contents/container-state/purgeProgress\";\nimport { runContainerPurge } from \"./containerPurgeCore\";\nimport type { ContainerContentsStoreSyncAgent } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\n// Permanently destroy a container and everything beneath it. Unlike\n// deleteContainer (a leaf-only hard delete), this cascades: documents whose last\n// link is inside the subtree are purged, multi-folder documents are unlinked\n// from the subtree only, and descendant containers are deleted leaf-first. The\n// caller (the trash \"Delete Forever\" action) restricts this to folders under\n// trash; here we keep the same structural guards deleteContainer uses — never a\n// root and never a system container itself.\nexport async function purgeContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n options?: PurgeOptions,\n isCurrent: ContainerWriteGuard = () => true,\n): Promise<boolean> {\n return runContainerPurge(state, syncAgent, containerId, options, isCurrent, {\n describeResult: (target, result) =>\n `purged container \"${target.container.name}\" (${result.purgedContainerIds.length} container(s) removed, ${result.failedCount} failed)`,\n didSucceed: (result) => result.purgedContainerIds.includes(containerId),\n validateTarget: (target) =>\n target.container.parentId !== null &&\n (target.container.systemSlot ?? null) === null,\n });\n}\n"]}
|