@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeCurrentGroupShare.js","sourceRoot":"","sources":["runtimeCurrentGroupShare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wCAAwC,EACxC,gCAAgC,GACjC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,uCAAuC,EAAE,MAAM,oFAAoF,CAAC;AAC7I,OAAO,EAAE,iCAAiC,EAAE,MA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MAAM;oBACvB,SAAS,EAAE,KAAK,CAAC,gBAAgB;oBACjC,WAAW,EAAE,OAAO;iBACrB;gBACD,wBAAwB;aACzB,CAAC,CAAC;YACH,OAAO,mCAAmC,CAAC;gBACzC,GAAG,KAAK;gBACR,kBAAkB,EAAE,kBAAkB;gBACtC,sBAAsB;gBACtB,YAAY,EAAE,YAAY,CAAC,YAAY;gBACvC,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,MAAM,EAAE,GAAG,EAAE,CACX,4BAA4B,CAAC,GAAG,EAAE,CAChC,KAAK,CAAC,SAAS,CAAC,cAAc,CAC5B,KAAK,CAAC,WAAW,EACjB,YAAY,CAAC,IAAI,CAAC,OAAO,EACzB;oBACE,qCAAqC,EACnC,KAAK,CAAC,MAAM,CAAC,cAAc;iBAC9B,CACF,CACF;aACJ,CAAC,CAAC;QACL,CAAC,CACF,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n nullOnProjectionVerificationCancellation,\n requireProjectionUserKeyResolver,\n} from \"../../../../data/keyingProjectionVerification\";\nimport { principalPolicyCacheForVerifiedPolicies } from \"../../../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache\";\nimport { inheritPrincipalHistoryProtection } from \"../../../../data/principals/principalHistoryRuntime\";\nimport { createRuntimeCurrentGroupMutation } from \"../../../organizations/principalMutations/runtimeCurrentGroupMutation\";\nimport {\n apiPrincipalPolicyPageReader,\n apiProjectionPolicyHistoryReader,\n} from \"../../../principals/principalPolicyHistoryReader\";\nimport {\n submitAcknowledgedContainerMutation,\n submitPlainContainerMutation,\n} from \"../mutationSubmit\";\nimport { commitCurrentShareGrant } from \"./currentShareGrantMutation\";\nimport { createRuntimeCurrentSharePrincipalPolicy } from \"./currentSharePrincipalPolicy\";\nimport type { shareRemoteContainerWithGroup } from \"./index\";\nimport { buildMaterializedContainerSharePlan } from \"./shareMaterialization\";\nimport { resolveShareProjection } from \"./shareProjection\";\n\n/** Current evidence covers planning, any compound grant mint, and acknowledgement. */\nexport function createRuntimeCurrentGroupShare(\n runtime: Parameters<typeof createRuntimeCurrentSharePrincipalPolicy>[0],\n): typeof shareRemoteContainerWithGroup | undefined {\n const readCurrent = createRuntimeCurrentSharePrincipalPolicy(runtime);\n const api = runtime.apiClient;\n const historyReader = apiPrincipalPolicyPageReader(api);\n if (!readCurrent || !historyReader) return undefined;\n const mutate = createRuntimeCurrentGroupMutation(\n inheritPrincipalHistoryProtection(runtime, {\n ...runtime,\n apiClient: {\n ...historyReader,\n ...apiProjectionPolicyHistoryReader(api),\n recoverPendingPrincipalMutation: async (organizationId: string) => {\n // Built-in clients supply journal recovery; standalone hosts retain\n // responsibility for transport and exact-outcome recovery.\n await api.recoverPendingPrincipalMutation?.(organizationId);\n },\n },\n }),\n );\n if (!mutate) throw new Error(\"Current group mutation custody is unavailable\");\n return async (input) => {\n if (input.stillCurrent?.() === false) return null;\n const recitationStillCurrent = input.stillCurrent ?? (() => true);\n return nullOnProjectionVerificationCancellation(() =>\n readCurrent(\n {\n expectedGroupName: input.expectedGroupName ?? undefined,\n groupId: input.recipientGroupId,\n organizationId: input.author.organizationId,\n stillCurrent: input.stillCurrent ?? (() => true),\n },\n async ({ policy, checkpointPolicies, stillCurrent }) => {\n const share = { ...input, stillCurrent };\n const resolveProjectionUserKey = requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Remote container share\",\n );\n const previousProjection = await resolveShareProjection(\n share,\n resolveProjectionUserKey,\n );\n if (!previousProjection) return null;\n const grant = policy.grants.find(\n (candidate) => candidate.containerId === input.containerId,\n );\n if (!grant || grant.accessLevel !== input.accessLevel)\n return commitCurrentShareGrant({\n runtime,\n share,\n mutate,\n recitationStillCurrent,\n });\n const materialized = await buildMaterializedContainerSharePlan({\n ...share,\n previousProjection,\n principalPolicyCache:\n principalPolicyCacheForVerifiedPolicies(checkpointPolicies),\n recipient: {\n principalPolicy: policy,\n subjectId: input.recipientGroupId,\n subjectType: \"group\",\n },\n resolveProjectionUserKey,\n });\n return submitAcknowledgedContainerMutation({\n ...share,\n recitationPolicies: checkpointPolicies,\n recitationStillCurrent,\n containerKey: materialized.containerKey,\n plan: materialized.plan,\n submit: () =>\n submitPlainContainerMutation(() =>\n input.apiClient.shareContainer(\n input.containerId,\n materialized.plan.request,\n {\n expectedPaymentRequiredOrganizationId:\n input.author.organizationId,\n },\n ),\n ),\n });\n },\n ),\n );\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContainerAuthorAccessError } from "
|
|
2
|
-
import { ContainerKekRepairInaccessibleError } from "
|
|
3
|
-
import { ContainerKekTargetUnreachableError } from "
|
|
4
|
-
import { rekeyRemoteContainer } from "
|
|
1
|
+
import { ContainerAuthorAccessError } from "../../../../data/containers/shared/authorAccess.js";
|
|
2
|
+
import { ContainerKekRepairInaccessibleError } from "../../../../data/documents/shared/containerKekCurrency.js";
|
|
3
|
+
import { ContainerKekTargetUnreachableError } from "../../../../data/documents/shared/containerKekPath.js";
|
|
4
|
+
import { rekeyRemoteContainer } from "../rekey/rekeyRemote.js";
|
|
5
5
|
function carriesDirectGrant(projection) {
|
|
6
6
|
const directGrants = Reflect.get(Object(projection.path.at(-1)?.state), "directGrants");
|
|
7
7
|
return Array.isArray(directGrants) && directGrants.length > 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shareAncestorRepair.js","sourceRoot":"","sources":["shareAncestorRepair.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAM7F,OAAO,EAAE,mCAAmC,EAAE,MAAM,wDAAwD,CAAC;AAC7G,OAAO,EAAE,kCAAkC,EAAE,MAAM,oDAAoD,CAAC;AAOxG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,SAAS,kBAAkB,CACzB,UAA6C;IAE7C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAC9B,MAAM,CAAC,UAAU,CAAC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C,CAAC;QACH,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;QAClD,IAAI,CAAC,QAAQ;YAAE,OAAO,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,CAClE,KAAK,CAAC,WAAW,CAClB,CAAC;QACF,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAC5B,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;IACD,OAAO,iBAAiB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC","sourcesContent":["import type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport { ContainerAuthorAccessError } from \"../../../../data/containers/shared/authorAccess\";\nimport type {\n ContainerMutationAuthor,\n ContainerRekeyApi,\n ContainerShareApi,\n} from \"../../../../data/containers/shared/types\";\nimport { ContainerKekRepairInaccessibleError } from \"../../../../data/documents/shared/containerKekCurrency\";\nimport { ContainerKekTargetUnreachableError } from \"../../../../data/documents/shared/containerKekPath\";\nimport type {\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../../../../data/keyingProjectionVerification\";\nimport type { SecurityIncidentReporter } from \"../../../../data/shared/securityIncidents\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport { rekeyRemoteContainer } from \"../rekey/rekeyRemote\";\n\nfunction carriesDirectGrant(\n projection: ContainerWriterProjectionResponse,\n): boolean {\n const directGrants = Reflect.get(\n Object(projection.path.at(-1)?.state),\n \"directGrants\",\n );\n return Array.isArray(directGrants) && directGrants.length > 0;\n}\n\n/** The first level on the path, the container included, pinning a retired epoch. */\nfunction firstStaleLevelId(\n projection: ContainerWriterProjectionResponse,\n): string | null {\n const keks = projection.containerKeks;\n for (let index = 1; index < keks.length; index += 1) {\n const kek = keks[index];\n if (\n kek &&\n kek.parentContainerKeyEpochId !== keks[index - 1]?.containerKeyEpochId\n ) {\n return kek.containerId;\n }\n }\n return null;\n}\n\n/**\n * Repair a stale path down to and including a container before granting on it\n * (#2340).\n *\n * A chain with no grant beneath it may sit lazily stale after an ancestor\n * rotation, since nobody's writes depend on it. The first grant changes that:\n * its grantee could never re-key the levels above its container, so the server\n * refuses a first grant below a stale chain. The container's own edge must be\n * current too, because a grant cites the parent's current epoch and the\n * container's key epoch has to pin it. The sharer administers the container\n * through a grant at or above it, and the levels above that grant are already\n * current, so every stale level here is one the sharer can re-key. These\n * repairs are standalone and need not be atomic with the grant: a repair never\n * strands anyone.\n *\n * Every share does this, not only a first grant, which is all the server\n * insists on. A container that already carries a grant is stale only past the\n * carried-rekey cap, and its grantees are then parked behind exactly these\n * levels; the sharer is already here and able.\n */\nexport async function projectionWithCurrentAncestors(input: {\n apiClient: ContainerShareApi &\n Partial<Pick<ContainerRekeyApi, \"rekeyContainer\" | \"rekeyContainerResult\">>;\n author: ContainerMutationAuthor;\n containerId: string;\n execSql: ExecSql;\n previousProjection: ContainerWriterProjectionResponse;\n reportSecurityIncident: SecurityIncidentReporter;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n stillCurrent?: (() => boolean) | undefined;\n targetSecretKey: Uint8Array;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<ContainerWriterProjectionResponse | null> {\n const { rekeyContainer, rekeyContainerResult } = input.apiClient;\n let projection = input.previousProjection;\n // Each round repairs one level, and a path has a bounded number of them.\n for (let round = 0; round < projection.containerKeks.length; round += 1) {\n const staleLevelId = firstStaleLevelId(projection);\n if (staleLevelId === null) return projection;\n if (!rekeyContainer) {\n // Not a repair someone else owes: the adapter simply cannot make one.\n throw new Error(\n \"Container share must re-key a stale path, which needs rekeyContainer\",\n );\n }\n // This sharer may be unable to re-key a level above a container that\n // already carries a grant, stale past the carried-rekey cap. The server\n // asks a current chain only of a first grant, so it decides rather than\n // this blocking a grant it would accept.\n const serverDecides =\n staleLevelId !== input.containerId && carriesDirectGrant(projection);\n const repaired = await rekeyRemoteContainer({\n apiClient: {\n getContainerWriterProjection: (containerId) =>\n input.apiClient.getContainerWriterProjection(containerId),\n reciteContainer: (...args) => input.apiClient.reciteContainer(...args),\n rekeyContainer: rekeyContainer.bind(input.apiClient),\n ...(rekeyContainerResult\n ? { rekeyContainerResult: rekeyContainerResult.bind(input.apiClient) }\n : {}),\n },\n author: input.author,\n containerId: staleLevelId,\n execSql: input.execSql,\n reportSecurityIncident: input.reportSecurityIncident,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n targetSecretKey: input.targetSecretKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n }).catch((error: unknown) => {\n const outOfReach =\n error instanceof ContainerAuthorAccessError ||\n error instanceof ContainerKekTargetUnreachableError;\n if (outOfReach && serverDecides) return null;\n throw outOfReach\n ? new ContainerKekRepairInaccessibleError(staleLevelId)\n : error;\n });\n if (input.stillCurrent?.() === false) return null;\n if (!repaired) return serverDecides ? projection : null;\n const refreshed = await input.apiClient.getContainerWriterProjection(\n input.containerId,\n );\n if (!refreshed) return null;\n projection = refreshed;\n }\n return firstStaleLevelId(projection) === null ? projection : null;\n}\n"]}
|
package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ContainerAccessLevel } from "
|
|
2
|
-
import type { ContainerWriterProjectionResponse } from "
|
|
3
|
-
import type { ContainerMutationAuthor, MaterializedContainerSharePlan } from "
|
|
4
|
-
import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "
|
|
5
|
-
import type { ExecSql } from "
|
|
1
|
+
import type { ContainerAccessLevel } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
|
|
3
|
+
import type { ContainerMutationAuthor, MaterializedContainerSharePlan } from "../../../../data/containers/shared/types.js";
|
|
4
|
+
import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
|
|
5
|
+
import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
|
|
6
6
|
import { type ContainerShareRecipient } from "./sharePlanCore.js";
|
|
7
7
|
interface BuildMaterializedContainerSharePlanInput {
|
|
8
8
|
accessLevel: ContainerAccessLevel;
|
package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { assertContainerAuthorAccess } from "
|
|
2
|
-
import { signContainerMutationEvent } from "
|
|
3
|
-
import { asContainerManifestBundle, getTargetContainerContext, readContainerState, uniqueSortedManifestHashes, wrapContainerKeyToManagedPrincipal, wrapContainerKeyToRootUser, } from "
|
|
4
|
-
import { readContainerKeyWraps } from "
|
|
5
|
-
import { unwrapContainerKekPath } from "
|
|
6
|
-
import { projectionVerificationOptions } from "
|
|
7
|
-
import { requireUnwrappedKek } from "
|
|
1
|
+
import { assertContainerAuthorAccess } from "../../../../data/containers/shared/authorAccess.js";
|
|
2
|
+
import { signContainerMutationEvent } from "../../../../data/containers/shared/events.js";
|
|
3
|
+
import { asContainerManifestBundle, getTargetContainerContext, readContainerState, uniqueSortedManifestHashes, wrapContainerKeyToManagedPrincipal, wrapContainerKeyToRootUser, } from "../../../../data/containers/shared/projection.js";
|
|
4
|
+
import { readContainerKeyWraps } from "../../../../data/containers/shared/readers.js";
|
|
5
|
+
import { unwrapContainerKekPath } from "../../../../data/documents/shared/projection.js";
|
|
6
|
+
import { projectionVerificationOptions } from "../../../../data/documents/shared/types.js";
|
|
7
|
+
import { requireUnwrappedKek } from "../rotation/rotationContext.js";
|
|
8
8
|
import { buildContainerSharePlanResult, collectContainerSharePrincipalPolicies, collectShareUserRecipientKeys, deriveContainerShareManifest, referencedPrincipalHeadFromPolicy, replaceContainerWrap, shareManifestHistory, } from "./sharePlanCore.js";
|
|
9
9
|
async function materializeRecipientWrap(input) {
|
|
10
10
|
if (input.recipient.subjectType === "user") {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shareMaterialization.js","sourceRoot":"","sources":["shareMaterialization.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,0BAA0B,EAC1B,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAKnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAOxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,6BAA6B,EAE7B,sCAAsC,EACtC,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,EACjC,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,UAAU,wBAAwB,CAAC,KAOvC;IAKC,IAAI,KAAK,CAAC,SAAS,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAG,MAAM,0BAA0B,CAAC;YACtD,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;YAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,+BAA+B,EAC7B,KAAK,CAAC,SAAS,CAAC,+BAA+B;YACjD,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS;SAClC,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B,CAAC,aAAa,EAAE,IAAI,CAAC;KACjD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n ContainerAccessLevel,\n ContainerAccessManifestState,\n ContainerDirectGrant,\n ContainerGrantAccessEventBody,\n ContainerKekRecipientTarget,\n ContainerKeyWrap,\n ContainerUserRecipientKey,\n} from \"@tearleads/crypto\";\nimport type {\n ContainerKekResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { assertContainerAuthorAccess } from \"../../../../data/containers/shared/authorAccess\";\nimport { signContainerMutationEvent } from \"../../../../data/containers/shared/events\";\nimport {\n asContainerManifestBundle,\n getTargetContainerContext,\n readContainerState,\n uniqueSortedManifestHashes,\n wrapContainerKeyToManagedPrincipal,\n wrapContainerKeyToRootUser,\n} from \"../../../../data/containers/shared/projection\";\nimport { readContainerKeyWraps } from \"../../../../data/containers/shared/readers\";\nimport type {\n ContainerMutationAuthor,\n MaterializedContainerSharePlan,\n} from \"../../../../data/containers/shared/types\";\nimport { unwrapContainerKekPath } from \"../../../../data/documents/shared/projection\";\nimport { projectionVerificationOptions } from \"../../../../data/documents/shared/types\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../../../../data/keyingProjectionVerification\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport { requireUnwrappedKek } from \"../rotation/rotationContext\";\nimport {\n buildContainerSharePlanResult,\n type ContainerShareRecipient,\n collectContainerSharePrincipalPolicies,\n collectShareUserRecipientKeys,\n deriveContainerShareManifest,\n referencedPrincipalHeadFromPolicy,\n replaceContainerWrap,\n shareManifestHistory,\n} from \"./sharePlanCore\";\n\nasync function materializeRecipientWrap(input: {\n containerKey: Uint8Array;\n containerKeyEpochId: string;\n manifestHash: string;\n recipient: ContainerShareRecipient;\n state: ContainerAccessManifestState;\n targetKek: ContainerKekResponse;\n}): Promise<{\n recipientTarget: ContainerKekRecipientTarget;\n userRecipientKeys: ContainerUserRecipientKey[];\n wrap: ContainerKeyWrap;\n}> {\n if (input.recipient.subjectType === \"user\") {\n const shareRecipient = await wrapContainerKeyToRootUser({\n containerKey: input.containerKey,\n containerKeyEpochId: input.containerKeyEpochId,\n manifestHash: input.manifestHash,\n recipientEncapsulationPublicKey:\n input.recipient.recipientEncapsulationPublicKey,\n userId: input.recipient.subjectId,\n });\n return {\n recipientTarget: shareRecipient.recipientTarget,\n userRecipientKeys: collectShareUserRecipientKeys({\n newUserRecipientKey: shareRecipient.userRecipientKey,\n state: input.state,\n targetKek: input.targetKek,\n }),\n wrap: shareRecipient.wrap,\n };\n }\n\n const shareRecipient = await wrapContainerKeyToManagedPrincipal({\n containerKey: input.containerKey,\n containerKeyEpochId: input.containerKeyEpochId,\n manifestHash: input.manifestHash,\n principalEncapsulationPublicKey:\n input.recipient.principalPolicy.state.encapsulationPublicKey,\n principalHead: referencedPrincipalHeadFromPolicy(\n input.recipient.principalPolicy,\n ),\n });\n return {\n recipientTarget: shareRecipient.recipientTarget,\n userRecipientKeys: collectShareUserRecipientKeys({\n state: input.state,\n targetKek: input.targetKek,\n }),\n wrap: shareRecipient.wrap,\n };\n}\n\ninterface BuildMaterializedContainerSharePlanInput {\n accessLevel: ContainerAccessLevel;\n author: ContainerMutationAuthor;\n eventId?: string | undefined;\n execSql: ExecSql;\n knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;\n /** False for a projection re-rooted on rotations not yet acknowledged. */\n persistVerificationCheckpoints?: boolean | undefined;\n principalPolicyCache?: PrincipalPolicyCache | undefined;\n previousProjection: ContainerWriterProjectionResponse;\n recipient: ContainerShareRecipient;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n signedAt?: string | undefined;\n stillCurrent?: (() => boolean) | undefined;\n targetSecretKey: Uint8Array;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}\n\nasync function buildShareTransition(input: {\n accessLevel: ContainerAccessLevel;\n author: ContainerMutationAuthor;\n eventId?: string | undefined;\n previousProjection: ContainerWriterProjectionResponse;\n recipient: ContainerShareRecipient;\n signedAt?: string | undefined;\n targetManifest: ContainerWriterProjectionResponse[\"path\"][number];\n}) {\n const previousState = readContainerState(input.targetManifest);\n if (previousState.organizationId !== input.author.organizationId) {\n throw new Error(\"Container share author organization mismatch\");\n }\n const grant: ContainerDirectGrant = {\n accessLevel: input.accessLevel,\n subjectId: input.recipient.subjectId,\n subjectType: input.recipient.subjectType,\n };\n const referencedPrincipalHead =\n input.recipient.subjectType === \"user\"\n ? null\n : referencedPrincipalHeadFromPolicy(input.recipient.principalPolicy);\n const body: ContainerGrantAccessEventBody = {\n eventType: \"container.grant\",\n containerKeyEpochId: previousState.containerKeyEpochId,\n containerKeyPublicKey: previousState.containerKeyPublicKey,\n grant,\n referencedPrincipalHead,\n };\n const { event, eventHash } = await signContainerMutationEvent({\n author: input.author,\n body,\n containerId: previousState.containerId,\n dependencyManifestHashes: uniqueSortedManifestHashes(\n input.previousProjection.path,\n ),\n eventId: input.eventId ?? crypto.randomUUID(),\n previousManifestHash: input.targetManifest.manifestHash,\n signedAt: input.signedAt ?? new Date().toISOString(),\n });\n const manifestTransition = await deriveContainerShareManifest({\n eventHash,\n grant,\n previousManifest: input.targetManifest,\n referencedPrincipalHead,\n });\n return {\n body,\n event,\n eventHash,\n grant,\n previousState,\n ...manifestTransition,\n };\n}\n\nasync function collectAuthorizedSharePolicies(\n input: BuildMaterializedContainerSharePlanInput,\n) {\n const principalPolicies = await collectContainerSharePrincipalPolicies({\n execSql: input.execSql,\n persistVerificationCheckpoints: input.persistVerificationCheckpoints,\n principalPolicyCache: input.principalPolicyCache,\n previousProjection: input.previousProjection,\n ...(input.recipient.subjectType === \"user\"\n ? {}\n : { recipientPolicy: input.recipient.principalPolicy }),\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n assertContainerAuthorAccess({\n author: input.author,\n projection: input.previousProjection,\n principalPolicies,\n minimumAccess: \"admin\",\n });\n return principalPolicies;\n}\n\nexport async function buildMaterializedContainerSharePlan(\n input: BuildMaterializedContainerSharePlanInput,\n): Promise<MaterializedContainerSharePlan> {\n const keksByEpochId = await unwrapContainerKekPath({\n execSql: input.execSql,\n knownContainerKeks: input.knownContainerKeks,\n persistVerificationCheckpoints: input.persistVerificationCheckpoints,\n principalPolicyCache: input.principalPolicyCache,\n projection: input.previousProjection,\n secretKey: input.targetSecretKey,\n ...projectionVerificationOptions(input),\n });\n const principalPolicies = await collectAuthorizedSharePolicies(input);\n const target = getTargetContainerContext(input.previousProjection);\n const {\n body,\n event,\n eventHash,\n grant,\n manifest,\n manifestHash,\n previousState,\n state,\n } = await buildShareTransition({\n accessLevel: input.accessLevel,\n author: input.author,\n eventId: input.eventId,\n previousProjection: input.previousProjection,\n recipient: input.recipient,\n signedAt: input.signedAt,\n targetManifest: target.manifest,\n });\n const containerKey = requireUnwrappedKek(\n keksByEpochId,\n target.kek,\n \"Container share target\",\n );\n const { recipientTarget, userRecipientKeys, wrap } =\n await materializeRecipientWrap({\n containerKey,\n containerKeyEpochId: target.kek.containerKeyEpochId,\n manifestHash,\n recipient: input.recipient,\n state,\n targetKek: target.kek,\n });\n const previousWraps = readContainerKeyWraps(\n target.kek.wraps,\n \"Container share previous wraps\",\n );\n\n return buildContainerSharePlanResult({\n body,\n containerManifestHistory: shareManifestHistory({\n containerId: previousState.containerId,\n targetKek: target.kek,\n targetManifest: target.manifest,\n }),\n containerKey,\n containerId: previousState.containerId,\n event,\n eventHash,\n grant,\n manifest,\n manifestHash,\n previousManifest: asContainerManifestBundle(target.manifest),\n previousProjection: input.previousProjection,\n principalPolicies,\n recipientTarget,\n state,\n targetKek: target.kek,\n userRecipientKeys,\n wraps: replaceContainerWrap(previousWraps, wrap),\n });\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type AccessEvent, type AccessManifest, type ContainerAccessManifestState, type ContainerDirectGrant, type ContainerGrantAccessEventBody, type ContainerGrantPrincipalHead, type ContainerKekRecipientTarget, type ContainerKeyWrap, type ContainerUserRecipientKey } from "
|
|
2
|
-
import type { AccessManifestBundleWire } from "
|
|
3
|
-
import type { ContainerKekResponse, ContainerWriterProjectionResponse } from "
|
|
4
|
-
import type { ContainerSharePlan, MaterializedContainerSharePlan } from "
|
|
5
|
-
import { type PrincipalPolicyCache, type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "
|
|
6
|
-
import type { PrincipalPolicyCurrentEvidence } from "
|
|
7
|
-
import type { ExecSql } from "
|
|
1
|
+
import { type AccessEvent, type AccessManifest, type ContainerAccessManifestState, type ContainerDirectGrant, type ContainerGrantAccessEventBody, type ContainerGrantPrincipalHead, type ContainerKekRecipientTarget, type ContainerKeyWrap, type ContainerUserRecipientKey } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import type { AccessManifestBundleWire } from "../../../../internal/validators/request/index.js";
|
|
3
|
+
import type { ContainerKekResponse, ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
|
|
4
|
+
import type { ContainerSharePlan, MaterializedContainerSharePlan } from "../../../../data/containers/shared/types.js";
|
|
5
|
+
import { type PrincipalPolicyCache, type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
|
|
6
|
+
import type { PrincipalPolicyCurrentEvidence } from "../../../../data/principals/principalPolicyEvidence.js";
|
|
7
|
+
import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
|
|
8
8
|
export type ContainerShareRecipient = {
|
|
9
9
|
readonly recipientEncapsulationPublicKey: Uint8Array;
|
|
10
10
|
readonly subjectId: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { computeAccessManifestHash, deriveContainerAccessManifest, } from "
|
|
2
|
-
import { uniquePrincipalPolicies } from "
|
|
3
|
-
import { asContainerManifestBundle, containerManifestRef, getParentKekForTarget, readContainerState, } from "
|
|
4
|
-
import { readContainerKekRecipientTargets, readContainerKeyEpoch, } from "
|
|
5
|
-
import { collectContainerWriterProjectionPrincipalPolicies, } from "
|
|
6
|
-
import { containerMutationRequestCore, previousPathRequestFields, readCanonicalRecordOrNull, } from "
|
|
1
|
+
import { computeAccessManifestHash, deriveContainerAccessManifest, } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import { uniquePrincipalPolicies } from "../../../../data/containers/shared/principalPolicies.js";
|
|
3
|
+
import { asContainerManifestBundle, containerManifestRef, getParentKekForTarget, readContainerState, } from "../../../../data/containers/shared/projection.js";
|
|
4
|
+
import { readContainerKekRecipientTargets, readContainerKeyEpoch, } from "../../../../data/containers/shared/readers.js";
|
|
5
|
+
import { collectContainerWriterProjectionPrincipalPolicies, } from "../../../../data/keyingProjectionVerification/index.js";
|
|
6
|
+
import { containerMutationRequestCore, previousPathRequestFields, readCanonicalRecordOrNull, } from "../mutationRequestCore.js";
|
|
7
7
|
function grantKey(grant) {
|
|
8
8
|
return `${grant.subjectType}:${grant.subjectId}`;
|
|
9
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharePlanCore.js","sourceRoot":"","sources":["sharePlanCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4CAA4C,CAAC;AAKpD,OAAO,EACL,iDAAiD,GAIlD,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAchC,SAAS,QAAQ,CACf,KAA8D;IAE9D,OAAO,GAA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vE,CAAC,CAAC;IACL,OAAO,0BAA0B,CAAC;QAChC,gBAAgB;QAChB,0BAA0B,EAAE,KAAK,CAAC,eAAe;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type AccessEvent,\n type AccessManifest,\n type ContainerAccessManifestState,\n type ContainerDirectGrant,\n type ContainerGrantAccessEventBody,\n type ContainerGrantPrincipalHead,\n type ContainerKekRecipientTarget,\n type ContainerKeyEpoch,\n type ContainerKeyWrap,\n type ContainerUserRecipientKey,\n computeAccessManifestHash,\n deriveContainerAccessManifest,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWire,\n ContainerMutationRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n ContainerKekResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { uniquePrincipalPolicies } from \"../../../../data/containers/shared/principalPolicies\";\nimport {\n asContainerManifestBundle,\n containerManifestRef,\n getParentKekForTarget,\n readContainerState,\n} from \"../../../../data/containers/shared/projection\";\nimport {\n readContainerKekRecipientTargets,\n readContainerKeyEpoch,\n} from \"../../../../data/containers/shared/readers\";\nimport type {\n ContainerSharePlan,\n MaterializedContainerSharePlan,\n} from \"../../../../data/containers/shared/types\";\nimport {\n collectContainerWriterProjectionPrincipalPolicies,\n type PrincipalPolicyCache,\n type ProjectionUserKeyResolver,\n type ReferencedPrincipalPolicyWarmer,\n} from \"../../../../data/keyingProjectionVerification\";\nimport type { PrincipalPolicyCurrentEvidence } from \"../../../../data/principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport {\n containerMutationRequestCore,\n previousPathRequestFields,\n readCanonicalRecordOrNull,\n} from \"../mutationRequestCore\";\n\nexport type ContainerShareRecipient =\n | {\n readonly recipientEncapsulationPublicKey: Uint8Array;\n readonly subjectId: string;\n readonly subjectType: \"user\";\n }\n | {\n readonly principalPolicy: PrincipalPolicyCurrentEvidence;\n readonly subjectId: string;\n readonly subjectType: \"group\";\n };\n\nfunction grantKey(\n grant: Pick<ContainerDirectGrant, \"subjectId\" | \"subjectType\">,\n): string {\n return `${grant.subjectType}:${grant.subjectId}`;\n}\n\nfunction upsertContainerGrant(\n grants: readonly ContainerDirectGrant[],\n grant: ContainerDirectGrant,\n): ContainerDirectGrant[] {\n return [\n ...grants.filter(\n (existingGrant) => grantKey(existingGrant) !== grantKey(grant),\n ),\n grant,\n ].sort((left, right) => grantKey(left).localeCompare(grantKey(right)));\n}\n\nfunction referencedPrincipalKey(reference: {\n readonly principalId: string;\n readonly principalType: \"group\";\n}): string {\n return `${reference.principalType}:${reference.principalId}`;\n}\n\nexport function referencedPrincipalHeadFromPolicy(\n policy: PrincipalPolicyCurrentEvidence,\n): ContainerGrantPrincipalHead {\n if (policy.principalType !== \"group\") {\n throw new Error(\"Container grants can reference only group policies\");\n }\n return {\n principalType: \"group\",\n principalId: policy.principalId,\n version: policy.version,\n keyEpoch: policy.keyEpoch,\n stateHash: policy.stateHash,\n keyFingerprint: policy.state.keyFingerprint,\n };\n}\n\nfunction upsertReferencedPrincipalHead(\n references: readonly ContainerGrantPrincipalHead[],\n reference: ContainerGrantPrincipalHead,\n): ContainerGrantPrincipalHead[] {\n return [\n ...references.filter(\n (existingReference) =>\n referencedPrincipalKey(existingReference) !==\n referencedPrincipalKey(reference),\n ),\n reference,\n ].sort((left, right) =>\n referencedPrincipalKey(left).localeCompare(referencedPrincipalKey(right)),\n );\n}\n\n/**\n * The previous manifest's referenced principal heads with the replacement\n * policy's head upserted in place of any stale head for the same principal.\n * A rekey substitutes references and never adds one: a manifest may reference\n * only principals it grants, so a replacement for one it does not grant —\n * a carried rekey below the container the policy is granted on — is left out.\n */\nexport function refreshedPrincipalReferences(input: {\n readonly previousState: ContainerAccessManifestState;\n readonly replacementPrincipalPolicy?:\n | PrincipalPolicyCurrentEvidence\n | undefined;\n}): ContainerGrantPrincipalHead[] {\n const replacement = input.replacementPrincipalPolicy;\n if (\n !replacement ||\n !input.previousState.directGrants.some(\n (grant) =>\n grant.subjectType === replacement.principalType &&\n grant.subjectId === replacement.principalId,\n )\n ) {\n return [...input.previousState.referencedPrincipalHeads];\n }\n return upsertReferencedPrincipalHead(\n input.previousState.referencedPrincipalHeads,\n referencedPrincipalHeadFromPolicy(replacement),\n );\n}\n\n/**\n * The previous policies with the replacement policy substituted for any\n * existing policy of the same principal identity.\n */\nexport function refreshedPrincipalPolicies(input: {\n readonly previousPolicies: readonly PrincipalPolicyCurrentEvidence[];\n readonly replacementPrincipalPolicy?:\n | PrincipalPolicyCurrentEvidence\n | undefined;\n}): PrincipalPolicyCurrentEvidence[] {\n const replacement = input.replacementPrincipalPolicy;\n if (!replacement) {\n return uniquePrincipalPolicies(input.previousPolicies);\n }\n return uniquePrincipalPolicies([\n ...input.previousPolicies.filter(\n (policy) =>\n policy.principalType !== replacement.principalType ||\n policy.principalId !== replacement.principalId,\n ),\n replacement,\n ]);\n}\n\nexport async function deriveContainerShareManifest(input: {\n eventHash: string;\n grant: ContainerDirectGrant;\n previousManifest: ContainerWriterProjectionResponse[\"path\"][number];\n referencedPrincipalHead: ContainerGrantPrincipalHead | null;\n}): Promise<Pick<ContainerSharePlan, \"manifest\" | \"manifestHash\" | \"state\">> {\n const previousState = readContainerState(input.previousManifest);\n const state: ContainerAccessManifestState = {\n ...previousState,\n epoch: previousState.epoch + 1,\n previousManifestHash: input.previousManifest.manifestHash,\n eventHash: input.eventHash,\n directGrants: upsertContainerGrant(previousState.directGrants, input.grant),\n referencedPrincipalHeads: input.referencedPrincipalHead\n ? upsertReferencedPrincipalHead(\n previousState.referencedPrincipalHeads,\n input.referencedPrincipalHead,\n )\n : previousState.referencedPrincipalHeads,\n };\n const manifest = await deriveContainerAccessManifest(state);\n\n return {\n manifest,\n manifestHash: await computeAccessManifestHash(manifest),\n state,\n };\n}\n\nfunction buildContainerShareRequest(input: {\n body: ContainerGrantAccessEventBody;\n containerManifestHistory: readonly AccessManifestBundleWire[];\n event: AccessEvent;\n keyEpoch: ContainerKeyEpoch;\n manifest: AccessManifest;\n manifestHash: string;\n parentKek: ContainerKekResponse | null;\n previousManifest: AccessManifestBundleWire;\n previousProjection: ContainerWriterProjectionResponse;\n principalPolicies: readonly PrincipalPolicyCurrentEvidence[];\n userRecipientKeys: readonly ContainerUserRecipientKey[];\n wraps: readonly ContainerKeyWrap[];\n}): ContainerMutationRequest {\n return {\n ...containerMutationRequestCore(\"share\", input),\n ...previousPathRequestFields(\n input.previousManifest,\n input.previousProjection,\n ),\n containerManifestHistoryRefs:\n input.containerManifestHistory.map(containerManifestRef),\n predecessorBridge: null,\n keyring: null,\n parentKekState: readCanonicalRecordOrNull(\n input.parentKek,\n \"Container share parent KEK state\",\n ),\n };\n}\n\nexport function replaceContainerWrap(\n wraps: readonly ContainerKeyWrap[],\n nextWrap: ContainerKeyWrap,\n): ContainerKeyWrap[] {\n return [\n ...wraps.filter(\n (wrap) =>\n !(\n wrap.recipientKind === nextWrap.recipientKind &&\n wrap.recipientId === nextWrap.recipientId\n ),\n ),\n nextWrap,\n ];\n}\n\nexport function shareManifestHistory(input: {\n readonly containerId: string;\n readonly targetKek: ContainerKekResponse;\n readonly targetManifest: ContainerWriterProjectionResponse[\"path\"][number];\n}): AccessManifestBundleWire[] {\n const byHash = new Map<string, AccessManifestBundleWire>();\n for (const bundle of [\n input.targetManifest,\n ...input.targetKek.containerManifestHistory,\n ]) {\n if (\n readContainerState(bundle).containerId === input.containerId &&\n !byHash.has(bundle.manifestHash)\n ) {\n byHash.set(bundle.manifestHash, asContainerManifestBundle(bundle));\n }\n }\n return [...byHash.values()];\n}\n\nexport function buildContainerSharePlanResult(input: {\n body: ContainerGrantAccessEventBody;\n containerManifestHistory: readonly AccessManifestBundleWire[];\n containerId: string;\n containerKey: Uint8Array;\n event: AccessEvent;\n eventHash: string;\n grant: ContainerDirectGrant;\n manifest: AccessManifest;\n manifestHash: string;\n previousManifest: AccessManifestBundleWire;\n previousProjection: ContainerWriterProjectionResponse;\n principalPolicies: readonly PrincipalPolicyCurrentEvidence[];\n recipientTarget: ContainerKekRecipientTarget;\n state: ContainerAccessManifestState;\n targetKek: ContainerKekResponse;\n userRecipientKeys: ContainerUserRecipientKey[];\n wraps: ContainerKeyWrap[];\n}): MaterializedContainerSharePlan {\n const keyEpoch = readContainerKeyEpoch(\n input.targetKek.keyEpoch,\n \"Container share key epoch\",\n );\n const plan: ContainerSharePlan = {\n body: input.body,\n containerId: input.containerId,\n event: input.event,\n eventHash: input.eventHash,\n grant: input.grant,\n keyEpoch,\n manifest: input.manifest,\n manifestHash: input.manifestHash,\n previousKeyring: readCanonicalRecordOrNull(\n input.previousProjection.containerKeks.at(-1)?.keyring ?? null,\n \"Container share previous keyring\",\n ),\n previousManifest: input.previousManifest,\n recipientTarget: input.recipientTarget,\n request: buildContainerShareRequest({\n body: input.body,\n containerManifestHistory: input.containerManifestHistory,\n event: input.event,\n keyEpoch,\n manifest: input.manifest,\n manifestHash: input.manifestHash,\n parentKek: getParentKekForTarget(input.previousProjection),\n previousManifest: input.previousManifest,\n previousProjection: input.previousProjection,\n principalPolicies: input.principalPolicies,\n userRecipientKeys: input.userRecipientKeys,\n wraps: input.wraps,\n }),\n state: input.state,\n userRecipientKeys: input.userRecipientKeys,\n wraps: input.wraps,\n };\n\n return { containerKey: input.containerKey, plan };\n}\n\nexport function collectShareUserRecipientKeys(input: {\n newUserRecipientKey?: ContainerUserRecipientKey | undefined;\n state: ContainerAccessManifestState;\n targetKek: ContainerKekResponse;\n}): ContainerUserRecipientKey[] {\n const directUserIds = new Set(\n input.state.directGrants.flatMap((grant) =>\n grant.subjectType === \"user\" ? [grant.subjectId] : [],\n ),\n );\n const userRecipientKeyByUserId = new Map<string, ContainerUserRecipientKey>();\n\n for (const target of readContainerKekRecipientTargets(\n input.targetKek.recipientTargets,\n \"Container share target KEK recipient targets\",\n )) {\n if (\n target.recipientKind !== \"user\" ||\n !directUserIds.has(target.recipientId)\n ) {\n continue;\n }\n userRecipientKeyByUserId.set(target.recipientId, {\n userId: target.recipientId,\n recipientKeyEpochId: target.recipientKeyEpochId,\n recipientKeyFingerprint: target.recipientKeyFingerprint,\n });\n }\n\n if (input.newUserRecipientKey) {\n userRecipientKeyByUserId.set(\n input.newUserRecipientKey.userId,\n input.newUserRecipientKey,\n );\n }\n\n const missingUserId = [...directUserIds].find(\n (userId) => !userRecipientKeyByUserId.has(userId),\n );\n if (missingUserId) {\n throw new Error(\n `Container share recipient key is missing for direct user grant ${missingUserId}`,\n );\n }\n\n return [...userRecipientKeyByUserId.values()].sort((left, right) =>\n left.userId.localeCompare(right.userId),\n );\n}\n\nexport async function collectContainerSharePrincipalPolicies(input: {\n execSql: ExecSql;\n persistVerificationCheckpoints?: boolean | undefined;\n principalPolicyCache?: PrincipalPolicyCache | undefined;\n previousProjection: ContainerWriterProjectionResponse;\n recipientPolicy?: PrincipalPolicyCurrentEvidence | undefined;\n resolveUserKey: ProjectionUserKeyResolver;\n stillCurrent?: (() => boolean) | undefined;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<PrincipalPolicyCurrentEvidence[]> {\n const previousPolicies =\n await collectContainerWriterProjectionPrincipalPolicies({\n execSql: input.execSql,\n persistVerificationCheckpoints: input.persistVerificationCheckpoints,\n principalPolicyCache: input.principalPolicyCache,\n projection: input.previousProjection,\n resolveUserKey: input.resolveUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n return refreshedPrincipalPolicies({\n previousPolicies,\n replacementPrincipalPolicy: input.recipientPolicy,\n });\n}\n"]}
|
package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ApiClient } from "
|
|
2
|
-
import { KeyingVerificationError, type ReferencedPrincipalHead, type VerifiedPrincipalPolicy } from "
|
|
3
|
-
import type { CommitOrganizationGroupPolicyRequest } from "
|
|
4
|
-
import type { CommitOrganizationGroupPolicyResponse, PrincipalPolicyBundleResponse } from "
|
|
5
|
-
import type { ContainerShareApi } from "
|
|
6
|
-
import type { ExecSql } from "
|
|
7
|
-
import type { TrustedUserIdentityResolver } from "
|
|
8
|
-
import { type GroupPolicyNameReader } from "
|
|
9
|
-
import type { CurrentPrincipalPolicyReader } from "
|
|
1
|
+
import type { ApiClient } from "../../../../internal/api-client/index.js";
|
|
2
|
+
import { KeyingVerificationError, type ReferencedPrincipalHead, type VerifiedPrincipalPolicy } from "../../../../internal/crypto/index.js";
|
|
3
|
+
import type { CommitOrganizationGroupPolicyRequest } from "../../../../internal/validators/request/index.js";
|
|
4
|
+
import type { CommitOrganizationGroupPolicyResponse, PrincipalPolicyBundleResponse } from "../../../../internal/validators/response/index.js";
|
|
5
|
+
import type { ContainerShareApi } from "../../../../data/containers/shared/types.js";
|
|
6
|
+
import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
|
|
7
|
+
import type { TrustedUserIdentityResolver } from "../../../../data/trustedUserIdentity/index.js";
|
|
8
|
+
import { type GroupPolicyNameReader } from "../../../organizations/principalPolicy/principalPolicyRequest.js";
|
|
9
|
+
import type { CurrentPrincipalPolicyReader } from "../../../principals/currentPrincipalPolicyReader.js";
|
|
10
10
|
export interface ContainerManagedPrincipalShareApi extends ContainerShareApi, CurrentPrincipalPolicyReader, Pick<ApiClient, "evictContainerWriterProjection" | "getContainerWriterProjectionResult"> {
|
|
11
11
|
readonly recoverPendingPrincipalMutation?: ((organizationId: string) => Promise<void>) | undefined;
|
|
12
12
|
commitOrganizationGroupPolicy: (organizationId: string, groupId: string, input: CommitOrganizationGroupPolicyRequest) => Promise<CommitOrganizationGroupPolicyResponse | null>;
|
package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js}
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { KeyingVerificationError, } from "
|
|
2
|
-
import { throwKeyingVerificationErrorWithContext } from "
|
|
3
|
-
import { advanceKeyingCheckpointsAtomically } from "
|
|
4
|
-
import { loadPrincipalPolicyCheckpoint } from "
|
|
5
|
-
import { savePrincipalPolicyBundle } from "
|
|
6
|
-
import { loadPrincipalPolicyBundleForReference } from "
|
|
7
|
-
import { retainVerifiedPrincipalPolicyBundle } from "
|
|
8
|
-
import { principalHeadMatchesReference, requireOrganizationGroupHead, } from "
|
|
9
|
-
import { principalPolicyReferenceFromBundle, verifyPrincipalPolicyBundleWithExternalOrganizationAdmins, } from "
|
|
10
|
-
import { assertGroupMetadataBinding } from "
|
|
11
|
-
import { groupPolicyNameMismatch, } from "
|
|
12
|
-
import { externalAdminPolicyPersistenceEntries, loadOrganizationExternalAdminPolicy, } from "
|
|
13
|
-
import { collectPrincipalPolicySignerPublicKeys, } from "
|
|
1
|
+
import { KeyingVerificationError, } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import { throwKeyingVerificationErrorWithContext } from "../../../../data/keyingProjectionVerification/error.js";
|
|
3
|
+
import { advanceKeyingCheckpointsAtomically } from "../../../../data/persistence/keyingCheckpointAdvancePersistence.js";
|
|
4
|
+
import { loadPrincipalPolicyCheckpoint } from "../../../../data/persistence/keyingCheckpointPersistence.js";
|
|
5
|
+
import { savePrincipalPolicyBundle } from "../../../../data/persistence/principalPolicyPersistence.js";
|
|
6
|
+
import { loadPrincipalPolicyBundleForReference } from "../../../../data/persistence/principalPolicyReferencePersistence.js";
|
|
7
|
+
import { retainVerifiedPrincipalPolicyBundle } from "../../../../data/persistence/verifiedPrincipalPolicyRetentionPersistence.js";
|
|
8
|
+
import { principalHeadMatchesReference, requireOrganizationGroupHead, } from "../../../../data/principals/organizationAuthorityDescriptor.js";
|
|
9
|
+
import { principalPolicyReferenceFromBundle, verifyPrincipalPolicyBundleWithExternalOrganizationAdmins, } from "../../../../data/principals/principalPolicyAdminSigners.js";
|
|
10
|
+
import { assertGroupMetadataBinding } from "../../../organizations/groupMetadata/groupMetadataBinding.js";
|
|
11
|
+
import { groupPolicyNameMismatch, } from "../../../organizations/principalPolicy/principalPolicyRequest.js";
|
|
12
|
+
import { externalAdminPolicyPersistenceEntries, loadOrganizationExternalAdminPolicy, } from "../../../principals/externalAdminPolicy.js";
|
|
13
|
+
import { collectPrincipalPolicySignerPublicKeys, } from "../../../principals/policyVerification.js";
|
|
14
14
|
async function retainVerifiedSharePolicies(input) {
|
|
15
15
|
const retainedAt = new Date().toISOString();
|
|
16
16
|
if (input.organizationPolicy) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharePrincipalPolicy.js","sourceRoot":"","sources":["sharePrincipalPolicy.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,GAIxB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qDAAqD,CAAC;AAC9G,OAAO,EAAE,kCAAkC,EAAE,MAAM,iEAAiE,CAAC;AACrH,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AACpG,OAAO,EAAE,qCAAqC,EAAE,MAAM,kEAAkE,CAAC;AACzH,OAAO,EAAE,mCAAmC,EAAE,MAAM,0EAA0E,CAAC;AAC/H,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,6DAA6D,CAAC;AACrE,OAAO,EACL,kCAAkC,EAClC,yDAAyD,GAC1D,MAAM,yDAAyD,CAAC;AAGjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AACvG,OAAO,EAEL,uBAAuB,GACxB,MAAM,+DAA+D,CAAC;AAEvE,OAAO,EACL,qCAAqC,EACrC,mCAAmC,GAEpC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sCAAsC,GAEvC,MAAM,wCAAwC,CAAC;AA2BhD,KAAK,UAAU,2BAA2B,CAAC,KAO1C;IACC,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;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CACrC,QAAQ,CAAC,KAAK,EACd,sDAAsD,CACvD,CAAC;IACJ,CAAC;IACD,0BAA0B,CAAC,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,oBAAoB,CAAC;YACzB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,MAAM;YACN,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;SAC3C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,2BAA2B,CAAC;QAC3D,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,kBAAkB,EAAE,uBAAuB;QAC3C,MAAM,EAAE,QAAQ,CAAC,KAAK;QACtB,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC;IACH,OAAO;QACL,MAAM;QACN,kBAAkB;QAClB,iBAAiB,EAAE,qCAAqC,CACtD,uBAAuB,CACxB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,MAAM,EAAE,QAAQ,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import type { ApiClient } from \"@tearleads/api-client\";\nimport {\n KeyingVerificationError,\n type PrincipalPolicyCheckpoint,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type { CommitOrganizationGroupPolicyRequest } from \"@tearleads/validators/request\";\nimport type {\n CommitOrganizationGroupPolicyResponse,\n PrincipalPolicyBundleResponse,\n} from \"@tearleads/validators/response\";\nimport type { ContainerShareApi } from \"../../../../data/containers/shared/types\";\nimport { throwKeyingVerificationErrorWithContext } from \"../../../../data/keyingProjectionVerification/error\";\nimport { advanceKeyingCheckpointsAtomically } from \"../../../../data/persistence/keyingCheckpointAdvancePersistence\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../../../data/persistence/keyingCheckpointPersistence\";\nimport { savePrincipalPolicyBundle } from \"../../../../data/persistence/principalPolicyPersistence\";\nimport { loadPrincipalPolicyBundleForReference } from \"../../../../data/persistence/principalPolicyReferencePersistence\";\nimport { retainVerifiedPrincipalPolicyBundle } from \"../../../../data/persistence/verifiedPrincipalPolicyRetentionPersistence\";\nimport {\n principalHeadMatchesReference,\n requireOrganizationGroupHead,\n} from \"../../../../data/principals/organizationAuthorityDescriptor\";\nimport {\n principalPolicyReferenceFromBundle,\n verifyPrincipalPolicyBundleWithExternalOrganizationAdmins,\n} from \"../../../../data/principals/principalPolicyAdminSigners\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../../data/trustedUserIdentity\";\nimport { assertGroupMetadataBinding } from \"../../../organizations/groupMetadata/groupMetadataBinding\";\nimport {\n type GroupPolicyNameReader,\n groupPolicyNameMismatch,\n} from \"../../../organizations/principalPolicy/principalPolicyRequest\";\nimport type { CurrentPrincipalPolicyReader } from \"../../../principals/currentPrincipalPolicyReader\";\nimport {\n externalAdminPolicyPersistenceEntries,\n loadOrganizationExternalAdminPolicy,\n type VerifiedExternalAdminPolicy,\n} from \"../../../principals/externalAdminPolicy\";\nimport {\n collectPrincipalPolicySignerPublicKeys,\n type PrincipalPolicySignerPublicKeyLoadErrorCode,\n} from \"../../../principals/policyVerification\";\n\nexport interface ContainerManagedPrincipalShareApi\n extends ContainerShareApi,\n CurrentPrincipalPolicyReader,\n Pick<\n ApiClient,\n \"evictContainerWriterProjection\" | \"getContainerWriterProjectionResult\"\n > {\n readonly recoverPendingPrincipalMutation?:\n | ((organizationId: string) => Promise<void>)\n | undefined;\n commitOrganizationGroupPolicy: (\n organizationId: string,\n groupId: string,\n input: CommitOrganizationGroupPolicyRequest,\n ) => Promise<CommitOrganizationGroupPolicyResponse | null>;\n}\n\nexport interface VerifiedSharePrincipalPolicy {\n readonly bundle: PrincipalPolicyBundleResponse;\n readonly checkpointPolicies: readonly VerifiedPrincipalPolicy[];\n readonly dependencyBundles: readonly PrincipalPolicyBundleResponse[];\n readonly organizationId: string;\n readonly policy: VerifiedPrincipalPolicy;\n}\n\nasync function retainVerifiedSharePolicies(input: {\n bundle: PrincipalPolicyBundleResponse;\n execSql: ExecSql;\n organizationId: string;\n organizationPolicy: VerifiedExternalAdminPolicy | null;\n policy: VerifiedPrincipalPolicy;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<VerifiedPrincipalPolicy[]> {\n const retainedAt = new Date().toISOString();\n if (input.organizationPolicy) {\n for (const entry of externalAdminPolicyPersistenceEntries(\n input.organizationPolicy,\n )) {\n await retainVerifiedPrincipalPolicyBundle({\n ...entry,\n execSql: input.execSql,\n organizationId: input.organizationId,\n stillCurrent: input.stillCurrent,\n updatedAt: retainedAt,\n });\n }\n }\n await retainVerifiedPrincipalPolicyBundle({\n bundle: input.bundle,\n execSql: input.execSql,\n organizationId: input.organizationId,\n policy: input.policy,\n stillCurrent: input.stillCurrent,\n updatedAt: retainedAt,\n });\n return [\n ...(input.organizationPolicy\n ? externalAdminPolicyPersistenceEntries(input.organizationPolicy).map(\n (entry) => entry.policy,\n )\n : []),\n input.policy,\n ];\n}\n\n/**\n * Commits the verification a loadVerifiedGroupSharePrincipalPolicy call\n * deferred: advances the keying checkpoints for the verified policies and\n * caches the dependency bundles they were verified against.\n */\nexport async function advanceVerifiedSharePolicies(\n execSql: ExecSql,\n verified: Pick<\n VerifiedSharePrincipalPolicy,\n \"checkpointPolicies\" | \"dependencyBundles\" | \"organizationId\"\n >,\n stillCurrent?: (() => boolean) | undefined,\n): Promise<void> {\n await advanceKeyingCheckpointsAtomically({\n access: [],\n execSql,\n organizationId: verified.organizationId,\n policies: verified.checkpointPolicies,\n stillCurrent,\n });\n if (stillCurrent?.() === false) return;\n for (const bundle of verified.dependencyBundles) {\n await savePrincipalPolicyBundle(\n execSql,\n bundle,\n new Date().toISOString(),\n verified.organizationId,\n { stillCurrent },\n );\n if (stillCurrent?.() === false) return;\n }\n}\n\nfunction assertGroupPolicyTarget(\n bundle: PrincipalPolicyBundleResponse,\n groupId: string,\n): void {\n if (\n bundle.currentState.principalType !== \"group\" ||\n bundle.currentState.principalId !== groupId\n ) {\n throw new Error(\"Container share principal policy target mismatch\");\n }\n}\n\nfunction signerPublicKeyLoadErrorMessage(\n code: PrincipalPolicySignerPublicKeyLoadErrorCode,\n): string {\n switch (code) {\n case \"fingerprint-mismatch\":\n return \"principal policy signer key fingerprint mismatch\";\n case \"not-found\":\n return \"principal policy signer key could not be loaded\";\n }\n}\n\nasync function loadGroupSharePolicyBundle(input: {\n apiClient: ContainerManagedPrincipalShareApi;\n execSql: ExecSql;\n expectedGroupHead?: ReferencedPrincipalHead | undefined;\n groupId: string;\n localCheckpoint: PrincipalPolicyCheckpoint | null;\n}): Promise<PrincipalPolicyBundleResponse> {\n if (\n input.expectedGroupHead &&\n (input.expectedGroupHead.principalType !== \"group\" ||\n input.expectedGroupHead.principalId !== input.groupId)\n ) {\n throw new Error(\"Container share expected group policy target mismatch\");\n }\n const bundleFromCache = input.expectedGroupHead\n ? await loadPrincipalPolicyBundleForReference(\n input.execSql,\n input.expectedGroupHead,\n input.localCheckpoint,\n )\n : null;\n let bundle = bundleFromCache;\n bundle ??= await input.apiClient.getCurrentPrincipalPolicy(\n \"group\",\n input.groupId,\n );\n if (!bundle) {\n throw new Error(\"Container share principal policy could not be loaded\");\n }\n assertGroupPolicyTarget(bundle, input.groupId);\n if (\n input.expectedGroupHead &&\n !principalHeadMatchesReference(\n principalPolicyReferenceFromBundle(bundle),\n input.expectedGroupHead,\n )\n ) {\n throw new Error(\n \"Container share group policy does not match the signed organization directory\",\n );\n }\n return bundle;\n}\n\n/**\n * The chosen group label does not match the name in the group's verified\n * policy. A KeyingVerificationError (so it is reported as an incident), with\n * its own class so a caller can tell this refusal from every other\n * `object_mismatch` and say what happened.\n */\nexport class GroupShareNameMismatchError extends KeyingVerificationError {\n constructor(message: string) {\n super(\"object_mismatch\", message);\n this.name = \"GroupShareNameMismatchError\";\n }\n}\n\n/**\n * The share picker labels groups from the organization read model, which a\n * compromised server can relabel, so the name the user chose must equal the\n * name committed in the target's verified policy. Names compare by their\n * canonical key so look-alike spellings count as the same name. Uniqueness of\n * signed names within an organization is enforced where names enter — group\n * creation verifies every group in the signed directory — so a single\n * verified match identifies the group.\n */\nasync function assertShareGroupName(input: {\n readEncryptedName?: GroupPolicyNameReader | undefined;\n bundle: PrincipalPolicyBundleResponse;\n expectedGroupName: string;\n}): Promise<void> {\n // The label comes from the untrusted read model. Signed names never carry\n // an invisible code point, so a label that does is a look-alike that would\n // only match after canonicalization strips it; refuse it outright.\n const mismatch = await groupPolicyNameMismatch(\n input.bundle,\n input.expectedGroupName,\n input.readEncryptedName,\n );\n if (mismatch === \"forbidden_characters\") {\n throw new GroupShareNameMismatchError(\n \"Container share group name contains control or format characters\",\n );\n }\n if (mismatch === \"name_mismatch\") {\n throw new GroupShareNameMismatchError(\n \"Container share group name does not match the signed group policy\",\n );\n }\n}\n\nexport async function loadVerifiedGroupSharePrincipalPolicy(input: {\n readEncryptedName?: GroupPolicyNameReader | undefined;\n apiClient: ContainerManagedPrincipalShareApi;\n execSql: ExecSql;\n expectedGroupHead?: ReferencedPrincipalHead | undefined;\n /**\n * The display name the user chose the group by. The read model that labels\n * groups is a server projection; only the name committed in the signed\n * group payload can confirm the share lands on the group the user saw.\n */\n expectedGroupName?: string | undefined;\n groupId: string;\n organizationId: string;\n resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<VerifiedSharePrincipalPolicy> {\n const organizationAdminPolicy = await loadOrganizationExternalAdminPolicy({\n currentPolicyReader: input.apiClient,\n execSql: input.execSql,\n organizationId: input.organizationId,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n stillCurrent: input.stillCurrent,\n });\n if (!organizationAdminPolicy) {\n throw new Error(\"Organization admin authority could not be verified\");\n }\n const committedGroupHead = requireOrganizationGroupHead(\n organizationAdminPolicy.descriptor,\n input.groupId,\n );\n if (\n input.expectedGroupHead &&\n !principalHeadMatchesReference(input.expectedGroupHead, committedGroupHead)\n ) {\n throw new Error(\n \"Container share expected group head conflicts with the signed organization directory\",\n );\n }\n const localCheckpoint = await loadPrincipalPolicyCheckpoint(\n input.execSql,\n \"group\",\n input.groupId,\n );\n const bundle = await loadGroupSharePolicyBundle({\n ...input,\n expectedGroupHead: committedGroupHead,\n localCheckpoint,\n });\n const signerPublicKeys = await collectPrincipalPolicySignerPublicKeys({\n bundle,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n });\n if (\"error\" in signerPublicKeys) {\n throw new Error(signerPublicKeyLoadErrorMessage(signerPublicKeys.error));\n }\n\n const verified =\n await verifyPrincipalPolicyBundleWithExternalOrganizationAdmins({\n bundle,\n expectedReference: committedGroupHead,\n loadExternalAuthority: async () =>\n organizationAdminPolicy.externalAuthority,\n localCheckpoint,\n signerPublicKeys: signerPublicKeys.signerPublicKeys,\n });\n if (!verified.ok) {\n throwKeyingVerificationErrorWithContext(\n verified.error,\n \"Container share principal policy verification failed\",\n );\n }\n assertGroupMetadataBinding(bundle, organizationAdminPolicy.descriptor);\n if (input.expectedGroupName !== undefined) {\n await assertShareGroupName({\n readEncryptedName: input.readEncryptedName,\n bundle,\n expectedGroupName: input.expectedGroupName,\n });\n }\n\n const checkpointPolicies = await retainVerifiedSharePolicies({\n bundle,\n execSql: input.execSql,\n organizationId: input.organizationId,\n organizationPolicy: organizationAdminPolicy,\n policy: verified.value,\n stillCurrent: input.stillCurrent,\n });\n return {\n bundle,\n checkpointPolicies,\n dependencyBundles: externalAdminPolicyPersistenceEntries(\n organizationAdminPolicy,\n ).map((entry) => entry.bundle),\n organizationId: input.organizationId,\n policy: verified.value,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shareProjection.js","sourceRoot":"","sources":["shareProjection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEvE,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAG0E,EAC1E,wBAAmD;IAEnD,MAAM,gBAAgB,GACpB,KAAK,CAAC,kBAAkB;QACxB,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1E,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACvE,MAAM,kBAAkB,GAAG,MAAM,8BAA8B,CAAC;QAC9D,GAAG,KAAK;QACR,kBAAkB,EAAE,gBAAgB;QACpC,wBAAwB;KACzB,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC;AACtE,CAAC","sourcesContent":["import type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport type { ProjectionUserKeyResolver } from \"../../../../data/keyingProjectionVerification\";\nimport { projectionWithCurrentAncestors } from \"./shareAncestorRepair\";\n\n/** The container's projection, with any lazily stale chain above it repaired. */\nexport async function resolveShareProjection(\n input: Omit<\n Parameters<typeof projectionWithCurrentAncestors>[0],\n \"previousProjection\" | \"resolveProjectionUserKey\"\n > & { previousProjection?: ContainerWriterProjectionResponse | undefined },\n resolveProjectionUserKey: ProjectionUserKeyResolver,\n): Promise<ContainerWriterProjectionResponse | null> {\n const servedProjection =\n input.previousProjection ??\n (await input.apiClient.getContainerWriterProjection(input.containerId));\n if (!servedProjection || input.stillCurrent?.() === false) return null;\n const previousProjection = await projectionWithCurrentAncestors({\n ...input,\n previousProjection: servedProjection,\n resolveProjectionUserKey,\n });\n return input.stillCurrent?.() === false ? null : previousProjection;\n}\n"]}
|
|
@@ -6,17 +6,17 @@ export { ContainerKekRepairInaccessibleError, ContainerKekRepairRequiredError, }
|
|
|
6
6
|
export type { AggregatedContainerKekLog, KeyringRebuildResult, } from "../../data/documents/shared/keyringRebuild.js";
|
|
7
7
|
export { fetchContainerKekLog, HistoricalWrapUnavailableError, type HistoricalWrapUnavailableReason, rebuildKeyringEntriesFromLog, recoverKeyringEntryFromWraps, } from "../../data/documents/shared/keyringRebuild.js";
|
|
8
8
|
export { isProjectionVerificationCancelledError } from "../../data/keyingProjectionVerification/types.js";
|
|
9
|
-
export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create.js";
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { containerWriterProjectionFromRekeyPlan } from "./child/rekeyProjection.js";
|
|
14
|
-
export { rekeyRemoteContainer } from "./child/rekeyRemote.js";
|
|
9
|
+
export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create/index.js";
|
|
10
|
+
export { moveRemoteContainer } from "./child/move/index.js";
|
|
11
|
+
export { buildMaterializedContainerRekeyPlan } from "./child/rekey/index.js";
|
|
12
|
+
export { ContainerKeyringOverrideStaleError } from "./child/rekey/keyringOverrideLineage.js";
|
|
13
|
+
export { containerWriterProjectionFromRekeyPlan } from "./child/rekey/rekeyProjection.js";
|
|
14
|
+
export { rekeyRemoteContainer } from "./child/rekey/rekeyRemote.js";
|
|
15
15
|
export { buildMaterializedContainerRevokePlan, revokeRemoteContainer, } from "./child/revoke.js";
|
|
16
|
-
export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share.js";
|
|
17
|
-
export { buildMaterializedContainerSharePlan } from "./child/shareMaterialization.js";
|
|
18
|
-
export { referencedPrincipalHeadFromPolicy } from "./child/sharePlanCore.js";
|
|
19
|
-
export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, type VerifiedSharePrincipalPolicy, } from "./child/sharePrincipalPolicy.js";
|
|
16
|
+
export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share/index.js";
|
|
17
|
+
export { buildMaterializedContainerSharePlan } from "./child/share/shareMaterialization.js";
|
|
18
|
+
export { referencedPrincipalHeadFromPolicy } from "./child/share/sharePlanCore.js";
|
|
19
|
+
export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, type VerifiedSharePrincipalPolicy, } from "./child/share/sharePrincipalPolicy.js";
|
|
20
20
|
export { readContainerMutationMetadataDocumentId, referencedPrincipalHeadsFromContainerMutationResponse, } from "./mutationResponse.js";
|
|
21
21
|
export { buildRootContainerCreatePlan, rootContainerWriterProjectionFromCreatePlan, } from "./root/create.js";
|
|
22
22
|
export { type ContainerWriteRefusal, classifyContainerWriteRefusal, } from "./writeRefusal.js";
|
|
@@ -9,18 +9,18 @@ export { fetchContainerKekLog, HistoricalWrapUnavailableError, rebuildKeyringEnt
|
|
|
9
9
|
// A share's projection verification can be cancelled by a newer generation
|
|
10
10
|
// underneath the caller; hosts filter that outcome from their own reporting.
|
|
11
11
|
export { isProjectionVerificationCancelledError } from "../../data/keyingProjectionVerification/types.js";
|
|
12
|
-
export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create.js";
|
|
12
|
+
export { buildContainerCreatePlan, buildMaterializedContainerCreatePlan, childContainerWriterProjectionFromCreatePlan, createRemoteContainer, } from "./child/create/index.js";
|
|
13
|
+
export { moveRemoteContainer } from "./child/move/index.js";
|
|
14
|
+
export { buildMaterializedContainerRekeyPlan } from "./child/rekey/index.js";
|
|
13
15
|
// A rebuilt keyring override that a concurrent rotation outdated: rebuild it.
|
|
14
|
-
export { ContainerKeyringOverrideStaleError } from "./child/keyringOverrideLineage.js";
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export { containerWriterProjectionFromRekeyPlan } from "./child/rekeyProjection.js";
|
|
18
|
-
export { rekeyRemoteContainer } from "./child/rekeyRemote.js";
|
|
16
|
+
export { ContainerKeyringOverrideStaleError } from "./child/rekey/keyringOverrideLineage.js";
|
|
17
|
+
export { containerWriterProjectionFromRekeyPlan } from "./child/rekey/rekeyProjection.js";
|
|
18
|
+
export { rekeyRemoteContainer } from "./child/rekey/rekeyRemote.js";
|
|
19
19
|
export { buildMaterializedContainerRevokePlan, revokeRemoteContainer, } from "./child/revoke.js";
|
|
20
|
-
export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share.js";
|
|
21
|
-
export { buildMaterializedContainerSharePlan } from "./child/shareMaterialization.js";
|
|
22
|
-
export { referencedPrincipalHeadFromPolicy } from "./child/sharePlanCore.js";
|
|
23
|
-
export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, } from "./child/sharePrincipalPolicy.js";
|
|
20
|
+
export { shareRemoteContainer, shareRemoteContainerWithGroup, } from "./child/share/index.js";
|
|
21
|
+
export { buildMaterializedContainerSharePlan } from "./child/share/shareMaterialization.js";
|
|
22
|
+
export { referencedPrincipalHeadFromPolicy } from "./child/share/sharePlanCore.js";
|
|
23
|
+
export { advanceVerifiedSharePolicies, GroupShareNameMismatchError, loadVerifiedGroupSharePrincipalPolicy, } from "./child/share/sharePrincipalPolicy.js";
|
|
24
24
|
export { readContainerMutationMetadataDocumentId, referencedPrincipalHeadsFromContainerMutationResponse, } from "./mutationResponse.js";
|
|
25
25
|
export { buildRootContainerCreatePlan, rootContainerWriterProjectionFromCreatePlan, } from "./root/create.js";
|
|
26
26
|
export { classifyContainerWriteRefusal, } from "./writeRefusal.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,iEAA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AAsC,CAAC;AAC1F,OAAO,EAAE,sCAAsC,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,qCAAqC,GAEtC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,uCAAuC,EACvC,qDAAqD,GACtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,4BAA4B,EAC5B,2CAA2C,GAC5C,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC","sourcesContent":["// Refusals the SDK raises before it encrypts or sends a container-scoped\n// write; hosts classify them with classifyContainerWriteRefusal.\nexport { ContainerAuthorAccessError } from \"../../data/containers/shared/authorAccess\";\n// A create or move past the readable path length; `code` is\n// `container_path_too_deep`. Queued moves are abandoned, queued creates wait.\nexport { ContainerPathTooDeepError } from \"../../data/containers/shared/containerPathLimits\";\nexport type { ContainerReciteApi } from \"../../data/containers/shared/reciteApi\";\nexport type {\n ContainerMutationAuthor,\n MaterializedContainerRekeyPlan,\n} from \"../../data/containers/shared/types\";\nexport {\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n} from \"../../data/documents/shared/containerKekCurrency\";\nexport type {\n AggregatedContainerKekLog,\n KeyringRebuildResult,\n} from \"../../data/documents/shared/keyringRebuild\";\nexport {\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n} from \"../../data/documents/shared/keyringRebuild\";\n// A share's projection verification can be cancelled by a newer generation\n// underneath the caller; hosts filter that outcome from their own reporting.\nexport { isProjectionVerificationCancelledError } from \"../../data/keyingProjectionVerification/types\";\nexport {\n buildContainerCreatePlan,\n buildMaterializedContainerCreatePlan,\n childContainerWriterProjectionFromCreatePlan,\n createRemoteContainer,\n} from \"./child/create\";\nexport { moveRemoteContainer } from \"./child/move\";\nexport { buildMaterializedContainerRekeyPlan } from \"./child/rekey\";\n// A rebuilt keyring override that a concurrent rotation outdated: rebuild it.\nexport { ContainerKeyringOverrideStaleError } from \"./child/rekey/keyringOverrideLineage\";\nexport { containerWriterProjectionFromRekeyPlan } from \"./child/rekey/rekeyProjection\";\nexport { rekeyRemoteContainer } from \"./child/rekey/rekeyRemote\";\nexport {\n buildMaterializedContainerRevokePlan,\n revokeRemoteContainer,\n} from \"./child/revoke\";\nexport {\n shareRemoteContainer,\n shareRemoteContainerWithGroup,\n} from \"./child/share\";\nexport { buildMaterializedContainerSharePlan } from \"./child/share/shareMaterialization\";\nexport { referencedPrincipalHeadFromPolicy } from \"./child/share/sharePlanCore\";\nexport {\n advanceVerifiedSharePolicies,\n GroupShareNameMismatchError,\n loadVerifiedGroupSharePrincipalPolicy,\n type VerifiedSharePrincipalPolicy,\n} from \"./child/share/sharePrincipalPolicy\";\nexport {\n readContainerMutationMetadataDocumentId,\n referencedPrincipalHeadsFromContainerMutationResponse,\n} from \"./mutationResponse\";\nexport {\n buildRootContainerCreatePlan,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./root/create\";\nexport {\n type ContainerWriteRefusal,\n classifyContainerWriteRefusal,\n} from \"./writeRefusal\";\n"]}
|
|
@@ -2,7 +2,7 @@ import { assertContainerAuthorAccess, ContainerAuthorAccessError, } from "../../
|
|
|
2
2
|
import { readLinkedContainerIdsFromDocumentManifest } from "../../../data/documents/shared/projection.js";
|
|
3
3
|
import { resolveProjectionVerifier, } from "../../../data/documents/shared/types.js";
|
|
4
4
|
import { collectContainerWriterProjectionPrincipalPolicies, } from "../../../data/keyingProjectionVerification/index.js";
|
|
5
|
-
import { documentContainerProjections } from "../../../data/keyingProjectionVerification/documentContainerProjections.js";
|
|
5
|
+
import { documentContainerProjections } from "../../../data/keyingProjectionVerification/document/documentContainerProjections.js";
|
|
6
6
|
import { throwKeyingVerificationErrorWithContext } from "../../../data/keyingProjectionVerification/error.js";
|
|
7
7
|
/** Both paths have been verified; a readable proof does not authorize a link. */
|
|
8
8
|
export function assertDocumentLinkAuthorAccess(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkSetAuthority.js","sourceRoot":"","sources":["linkSetAuthority.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0CAA0C,EAAE,MAAM,2CAA2C,CAAC;AAEvG,OAAO,EAEL,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,iDAAiD,GAElD,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"linkSetAuthority.js","sourceRoot":"","sources":["linkSetAuthority.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0CAA0C,EAAE,MAAM,2CAA2C,CAAC;AAEvG,OAAO,EAEL,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,iDAAiD,GAElD,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kFAAkF,CAAC;AAChI,OAAO,EAAE,uCAAuC,EAAE,MAAM,kDAAkD,CAAC;AAI3G,iFAAiF;AACjF,MAAM,UAAU,8BAA8B,CAAC,KAK9C;IACC,MAAM,MAAM,GAAG;QACb,GAAG,KAAK,CAAC,MAAM;QAC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D,UAAU;gBACV,cAAc,EAAE,KAAK,CAAC,wBAAwB;gBAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;aACvE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uCAAuC,CACrC,KAAK,EACL,sDAAsD,CACvD,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type {\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n assertContainerAuthorAccess,\n ContainerAuthorAccessError,\n} from \"../../../data/containers/shared/authorAccess\";\nimport { readLinkedContainerIdsFromDocumentManifest } from \"../../../data/documents/shared/projection\";\nimport type { DocumentCreateAuthor } from \"../../../data/documents/shared/types\";\nimport {\n type ProjectionVerificationOptions,\n resolveProjectionVerifier,\n} from \"../../../data/documents/shared/types\";\nimport {\n collectContainerWriterProjectionPrincipalPolicies,\n type PrincipalPolicyCache,\n} from \"../../../data/keyingProjectionVerification\";\nimport { documentContainerProjections } from \"../../../data/keyingProjectionVerification/document/documentContainerProjections\";\nimport { throwKeyingVerificationErrorWithContext } from \"../../../data/keyingProjectionVerification/error\";\nimport type { PrincipalPolicyCheckpointEvidence } from \"../../../data/principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\n\n/** Both paths have been verified; a readable proof does not authorize a link. */\nexport function assertDocumentLinkAuthorAccess(input: {\n author: DocumentCreateAuthor;\n principalPolicies: readonly PrincipalPolicyCheckpointEvidence[];\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n}): void {\n const author = {\n ...input.author,\n organizationId: input.targetContainerProjection.organizationId,\n };\n const permission = {\n author,\n minimumAccess: \"write\" as const,\n principalPolicies: input.principalPolicies,\n };\n assertContainerAuthorAccess({\n ...permission,\n projection: input.targetContainerProjection,\n });\n const linked = readLinkedContainerIdsFromDocumentManifest(\n input.writerProjection,\n );\n for (const projection of documentContainerProjections(\n input.writerProjection,\n )) {\n if (!linked.includes(projection.containerId)) continue;\n try {\n assertContainerAuthorAccess({ ...permission, projection });\n return;\n } catch (error) {\n if (!(error instanceof ContainerAuthorAccessError)) throw error;\n }\n }\n throw new ContainerAuthorAccessError(\n \"Document signer lacks write access through a linked container\",\n );\n}\n\n/** Current write authorization needs full policies for the readable paths. */\nexport async function verifyDocumentLinkSetCurrentPolicies(\n input: {\n execSql?: ExecSql | undefined;\n principalPolicyCache: PrincipalPolicyCache;\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<void> {\n resolveProjectionVerifier(input, \"Document link-set current policies\");\n if (input.trustedLocalProjection === true) return;\n try {\n for (const projection of [\n input.targetContainerProjection,\n ...documentContainerProjections(input.writerProjection),\n ]) {\n await collectContainerWriterProjectionPrincipalPolicies({\n execSql: input.execSql,\n principalPolicyCache: input.principalPolicyCache,\n projection,\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n }\n } catch (error) {\n throwKeyingVerificationErrorWithContext(\n error,\n \"Document link-set current policy verification failed\",\n );\n }\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { projectionVerificationOptions } from "../../../data/documents/shared/ty
|
|
|
6
6
|
import { readCanonicalJson } from "../../../data/keying/canonicalJson.js";
|
|
7
7
|
import { requireProjectionUserKeyResolver } from "../../../data/keyingProjectionVerification/index.js";
|
|
8
8
|
import { ProjectionDependencyUnavailableError } from "../../../data/keyingProjectionVerification/dependencyUnavailable.js";
|
|
9
|
-
import { documentContainerProjections } from "../../../data/keyingProjectionVerification/documentContainerProjections.js";
|
|
9
|
+
import { documentContainerProjections } from "../../../data/keyingProjectionVerification/document/documentContainerProjections.js";
|
|
10
10
|
import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
|
|
11
11
|
import { createAttachmentProofReader } from "../../blobs/verification/attachmentDecryptor.js";
|
|
12
12
|
import { createAttachmentKeyAuthenticator } from "../../blobs/verification/attachmentKeyAuthenticator.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkSetBlobRewraps.js","sourceRoot":"","sources":["linkSetBlobRewraps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAG3B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EACL,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,SAAS,GACV,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC9F,OAAO,EAAE,oCAAoC,EAAE,MAAM,kEAAkE,CAAC;AACxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,yEAAyE,CAAC;AACvH,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AAEvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AACvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAC;AAQnG,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,KAOiC;IAEjC,MAAM,UAAU,GAAG,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC3E,2EAA2E;IAC3E,0EAA0E;IA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AAED,SAAS,cAAc,CAAC,CAAqB,EAAE,CAAqB;IAClE,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import {\n BLOB_CONTENT_KEY_WRAP_SUITE,\n type DocumentContentKeyTarget,\n type DocumentLinkAccessEventBody,\n wrapContentKey,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport type {\n BlobAttachmentSummary,\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n deriveDocumentTargetFromProjection,\n unwrapContainerKekPath,\n} from \"../../../data/documents/shared/projection\";\nimport {\n assertEqualBytes,\n targetKey,\n} from \"../../../data/documents/shared/readers\";\nimport type {\n DocumentLinkSetMutationApi,\n ProjectionVerificationOptions,\n} from \"../../../data/documents/shared/types\";\nimport { projectionVerificationOptions } from \"../../../data/documents/shared/types\";\nimport { readCanonicalJson } from \"../../../data/keying/canonicalJson\";\nimport { requireProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { documentContainerProjections } from \"../../../data/keyingProjectionVerification/documentContainerProjections\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { createAttachmentProofReader } from \"../../blobs/verification/attachmentDecryptor\";\nimport { createAttachmentKeyAuthenticator } from \"../../blobs/verification/attachmentKeyAuthenticator\";\nimport { verifyRetainedAttachment } from \"../../blobs/verification/retainedAttachmentVerification\";\n\ninterface BlobRewrap {\n blobId: string;\n contentKeyEpoch: number;\n targets: DocumentLinkAccessEventBody[\"blobRewraps\"][number][\"targets\"][number][];\n}\n\n/** Authenticate the existing bytes before propagating their DEK to a new scope. */\nexport async function prepareDocumentLinkBlobRewraps(\n input: {\n apiClient: DocumentLinkSetMutationApi;\n execSql: ExecSql;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetSecretKey: Uint8Array;\n targets: readonly DocumentContentKeyTarget[];\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<DocumentLinkAccessEventBody[\"blobRewraps\"]> {\n const documentId = input.writerProjection.documentId;\n const bindings = await input.apiClient.listDocumentAttachments(documentId);\n // The API refuses the link unless every active binding is rewrapped, so an\n // unavailable listing (offline, or a 409 while a bind is mid-flight) is a\n // retryable availability failure of this mutation, not integrity evidence.\n if (!bindings)\n throw new ProjectionDependencyUnavailableError(\n \"Document attachments are unavailable for relinking\",\n );\n assertProjectionVerificationCurrent(input.stillCurrent);\n if (bindings.length === 0) return [];\n const keks = await collectRelinkKeks(input);\n const authenticateKey = createAttachmentKeyAuthenticator(\n input.apiClient,\n documentId,\n );\n const verifyRetained = createAttachmentProofReader(\n input.apiClient,\n documentId,\n verifyRetainedAttachment,\n );\n const rewrapByBlob = new Map<string, BlobRewrap>();\n for (const binding of bindings) {\n const verification = {\n binding,\n expectedDocumentId: documentId,\n expectedSlotId: binding.slotId,\n execSql: input.execSql,\n resolveProjectionUserKey: requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Attachment relink\",\n ),\n targetSecretKey: input.targetSecretKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n writerProjection: input.writerProjection,\n };\n const needsKey = input.targets.some(\n (target) => !retainedTarget(binding, target, documentId),\n );\n const contentKey = needsKey ? await authenticateKey(verification) : null;\n if (!needsKey) await verifyRetained(verification);\n const targets = await Promise.all(\n input.targets.map(async (target) => {\n const previous = retainedTarget(binding, target, documentId);\n if (previous)\n return {\n ...previous,\n ...target,\n wrappingMetadata: readCanonicalJson(\n previous.wrappingMetadata,\n \"Attachment wrap metadata\",\n ),\n };\n const kek = keks.get(targetKey(target));\n if (!kek)\n throw new Error(\n \"Attachment destination is not a verified current container head\",\n );\n if (!contentKey)\n throw new Error(\"Attachment content key is unavailable\");\n return wrapBlobKeyForTarget({\n binding,\n contentKey,\n documentId,\n kek,\n target,\n });\n }),\n );\n const rewrap = rewrapByBlob.get(binding.blobId) ?? {\n blobId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n targets: [],\n };\n if (rewrap.contentKeyEpoch !== binding.contentKeyBundle.contentKeyEpoch)\n throw new Error(\"Attachment content epoch changed during relinking\");\n rewrap.targets.push(...targets);\n rewrapByBlob.set(binding.blobId, rewrap);\n assertProjectionVerificationCurrent(input.stillCurrent);\n }\n return [...rewrapByBlob.values()].sort(compareBlobIds);\n}\n\nasync function wrapBlobKeyForTarget(input: {\n binding: BlobAttachmentSummary;\n contentKey: Uint8Array;\n documentId: string;\n kek: Uint8Array;\n target: DocumentContentKeyTarget;\n}) {\n const { binding, target } = input;\n const wrapped = await wrapContentKey(input.contentKey, input.kek, {\n kind: \"Blob\",\n objectId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n containerId: target.containerId,\n containerKeyEpochId: target.containerKeyEpochId,\n });\n return {\n ...target,\n bindingId: binding.bindingId,\n documentId: input.documentId,\n wrappedKey: bytesToBase64(wrapped.ciphertext),\n wrappingMetadata: {\n suite: BLOB_CONTENT_KEY_WRAP_SUITE,\n iv: bytesToBase64(wrapped.iv),\n },\n };\n}\n\nfunction retainedTarget(\n binding: BlobAttachmentSummary,\n target: DocumentContentKeyTarget,\n documentId: string,\n) {\n return binding.contentKeyBundle.targets.find(\n (candidate) =>\n candidate.bindingId === binding.bindingId &&\n candidate.documentId === documentId &&\n candidate.containerId === target.containerId &&\n candidate.containerKeyEpochId === target.containerKeyEpochId,\n );\n}\n\nasync function collectRelinkKeks(\n input: Parameters<typeof prepareDocumentLinkBlobRewraps>[0],\n): Promise<Map<string, Uint8Array>> {\n const keks = new Map<string, Uint8Array>();\n for (const projection of [\n ...documentContainerProjections(input.writerProjection),\n input.targetContainerProjection,\n ]) {\n const keys = await unwrapContainerKekPath({\n projection,\n secretKey: input.targetSecretKey,\n execSql: input.execSql,\n ...projectionVerificationOptions(input),\n });\n // Every node of this verified path has a current signed head. Historical\n // keyring entries may open source bytes, but never enter the destination map.\n for (const [index, head] of projection.containerKeks.entries()) {\n const target = deriveDocumentTargetFromProjection({\n ...projection,\n containerId: head.containerId,\n path: projection.path.slice(0, index + 1),\n containerKeks: projection.containerKeks.slice(0, index + 1),\n });\n const key = keys.get(target.containerKeyEpochId);\n // A direct child grantee need not possess any ancestor secret.\n if (!key) continue;\n const id = targetKey(target);\n const previous = keks.get(id);\n if (previous)\n assertEqualBytes(\n previous,\n key,\n \"Attachment link projections contain conflicting KEKs\",\n );\n keks.set(id, key);\n }\n }\n return keks;\n}\n\nfunction compareBlobIds(a: { blobId: string }, b: { blobId: string }): number {\n return a.blobId < b.blobId ? -1 : a.blobId > b.blobId ? 1 : 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"linkSetBlobRewraps.js","sourceRoot":"","sources":["linkSetBlobRewraps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAG3B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EACL,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,SAAS,GACV,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC9F,OAAO,EAAE,oCA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AAE,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;aAC5D,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACjD,+DAA+D;YAC/D,IAAI,CAAC,GAAG;gBAAE,SAAS;YACnB,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9B,IAAI,QAAQ;gBACV,gBAAgB,CACd,QAAQ,EACR,GAAG,EACH,sDAAsD,CACvD,CAAC;YACJ,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,CAAqB,EAAE,CAAqB;IAClE,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import {\n BLOB_CONTENT_KEY_WRAP_SUITE,\n type DocumentContentKeyTarget,\n type DocumentLinkAccessEventBody,\n wrapContentKey,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport type {\n BlobAttachmentSummary,\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n deriveDocumentTargetFromProjection,\n unwrapContainerKekPath,\n} from \"../../../data/documents/shared/projection\";\nimport {\n assertEqualBytes,\n targetKey,\n} from \"../../../data/documents/shared/readers\";\nimport type {\n DocumentLinkSetMutationApi,\n ProjectionVerificationOptions,\n} from \"../../../data/documents/shared/types\";\nimport { projectionVerificationOptions } from \"../../../data/documents/shared/types\";\nimport { readCanonicalJson } from \"../../../data/keying/canonicalJson\";\nimport { requireProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { documentContainerProjections } from \"../../../data/keyingProjectionVerification/document/documentContainerProjections\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { createAttachmentProofReader } from \"../../blobs/verification/attachmentDecryptor\";\nimport { createAttachmentKeyAuthenticator } from \"../../blobs/verification/attachmentKeyAuthenticator\";\nimport { verifyRetainedAttachment } from \"../../blobs/verification/retainedAttachmentVerification\";\n\ninterface BlobRewrap {\n blobId: string;\n contentKeyEpoch: number;\n targets: DocumentLinkAccessEventBody[\"blobRewraps\"][number][\"targets\"][number][];\n}\n\n/** Authenticate the existing bytes before propagating their DEK to a new scope. */\nexport async function prepareDocumentLinkBlobRewraps(\n input: {\n apiClient: DocumentLinkSetMutationApi;\n execSql: ExecSql;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetSecretKey: Uint8Array;\n targets: readonly DocumentContentKeyTarget[];\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<DocumentLinkAccessEventBody[\"blobRewraps\"]> {\n const documentId = input.writerProjection.documentId;\n const bindings = await input.apiClient.listDocumentAttachments(documentId);\n // The API refuses the link unless every active binding is rewrapped, so an\n // unavailable listing (offline, or a 409 while a bind is mid-flight) is a\n // retryable availability failure of this mutation, not integrity evidence.\n if (!bindings)\n throw new ProjectionDependencyUnavailableError(\n \"Document attachments are unavailable for relinking\",\n );\n assertProjectionVerificationCurrent(input.stillCurrent);\n if (bindings.length === 0) return [];\n const keks = await collectRelinkKeks(input);\n const authenticateKey = createAttachmentKeyAuthenticator(\n input.apiClient,\n documentId,\n );\n const verifyRetained = createAttachmentProofReader(\n input.apiClient,\n documentId,\n verifyRetainedAttachment,\n );\n const rewrapByBlob = new Map<string, BlobRewrap>();\n for (const binding of bindings) {\n const verification = {\n binding,\n expectedDocumentId: documentId,\n expectedSlotId: binding.slotId,\n execSql: input.execSql,\n resolveProjectionUserKey: requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Attachment relink\",\n ),\n targetSecretKey: input.targetSecretKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n writerProjection: input.writerProjection,\n };\n const needsKey = input.targets.some(\n (target) => !retainedTarget(binding, target, documentId),\n );\n const contentKey = needsKey ? await authenticateKey(verification) : null;\n if (!needsKey) await verifyRetained(verification);\n const targets = await Promise.all(\n input.targets.map(async (target) => {\n const previous = retainedTarget(binding, target, documentId);\n if (previous)\n return {\n ...previous,\n ...target,\n wrappingMetadata: readCanonicalJson(\n previous.wrappingMetadata,\n \"Attachment wrap metadata\",\n ),\n };\n const kek = keks.get(targetKey(target));\n if (!kek)\n throw new Error(\n \"Attachment destination is not a verified current container head\",\n );\n if (!contentKey)\n throw new Error(\"Attachment content key is unavailable\");\n return wrapBlobKeyForTarget({\n binding,\n contentKey,\n documentId,\n kek,\n target,\n });\n }),\n );\n const rewrap = rewrapByBlob.get(binding.blobId) ?? {\n blobId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n targets: [],\n };\n if (rewrap.contentKeyEpoch !== binding.contentKeyBundle.contentKeyEpoch)\n throw new Error(\"Attachment content epoch changed during relinking\");\n rewrap.targets.push(...targets);\n rewrapByBlob.set(binding.blobId, rewrap);\n assertProjectionVerificationCurrent(input.stillCurrent);\n }\n return [...rewrapByBlob.values()].sort(compareBlobIds);\n}\n\nasync function wrapBlobKeyForTarget(input: {\n binding: BlobAttachmentSummary;\n contentKey: Uint8Array;\n documentId: string;\n kek: Uint8Array;\n target: DocumentContentKeyTarget;\n}) {\n const { binding, target } = input;\n const wrapped = await wrapContentKey(input.contentKey, input.kek, {\n kind: \"Blob\",\n objectId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n containerId: target.containerId,\n containerKeyEpochId: target.containerKeyEpochId,\n });\n return {\n ...target,\n bindingId: binding.bindingId,\n documentId: input.documentId,\n wrappedKey: bytesToBase64(wrapped.ciphertext),\n wrappingMetadata: {\n suite: BLOB_CONTENT_KEY_WRAP_SUITE,\n iv: bytesToBase64(wrapped.iv),\n },\n };\n}\n\nfunction retainedTarget(\n binding: BlobAttachmentSummary,\n target: DocumentContentKeyTarget,\n documentId: string,\n) {\n return binding.contentKeyBundle.targets.find(\n (candidate) =>\n candidate.bindingId === binding.bindingId &&\n candidate.documentId === documentId &&\n candidate.containerId === target.containerId &&\n candidate.containerKeyEpochId === target.containerKeyEpochId,\n );\n}\n\nasync function collectRelinkKeks(\n input: Parameters<typeof prepareDocumentLinkBlobRewraps>[0],\n): Promise<Map<string, Uint8Array>> {\n const keks = new Map<string, Uint8Array>();\n for (const projection of [\n ...documentContainerProjections(input.writerProjection),\n input.targetContainerProjection,\n ]) {\n const keys = await unwrapContainerKekPath({\n projection,\n secretKey: input.targetSecretKey,\n execSql: input.execSql,\n ...projectionVerificationOptions(input),\n });\n // Every node of this verified path has a current signed head. Historical\n // keyring entries may open source bytes, but never enter the destination map.\n for (const [index, head] of projection.containerKeks.entries()) {\n const target = deriveDocumentTargetFromProjection({\n ...projection,\n containerId: head.containerId,\n path: projection.path.slice(0, index + 1),\n containerKeks: projection.containerKeks.slice(0, index + 1),\n });\n const key = keys.get(target.containerKeyEpochId);\n // A direct child grantee need not possess any ancestor secret.\n if (!key) continue;\n const id = targetKey(target);\n const previous = keks.get(id);\n if (previous)\n assertEqualBytes(\n previous,\n key,\n \"Attachment link projections contain conflicting KEKs\",\n );\n keks.set(id, key);\n }\n }\n return keks;\n}\n\nfunction compareBlobIds(a: { blobId: string }, b: { blobId: string }): number {\n return a.blobId < b.blobId ? -1 : a.blobId > b.blobId ? 1 : 0;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertDocumentWriterProjectionConsistent } from "../../../data/documents/shared/projection.js";
|
|
2
|
-
import { mergeProjectionPolicyEvidence } from "../../../data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js";
|
|
2
|
+
import { mergeProjectionPolicyEvidence } from "../../../data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js";
|
|
3
3
|
function uniqueManifestBundles(bundles) {
|
|
4
4
|
const byHash = new Map();
|
|
5
5
|
for (const bundle of bundles) {
|