@tearleads/client-sdk 0.1.64 → 0.1.66
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/client/organizations/organizationAccessRestoration.js +1 -1
- package/data/containers/shared/mutationAcknowledgement.js +1 -1
- package/data/containers/shared/mutationAcknowledgement.js.map +1 -1
- package/data/documents/blob/shared/projection.js +3 -3
- package/data/documents/blob/shared/projection.js.map +1 -1
- package/data/documents/shared/{containerKekCurrency.d.ts → containerKek/containerKekCurrency.d.ts} +1 -1
- package/data/documents/shared/{containerKekEntryVerification.js → containerKek/containerKekEntryVerification.js} +1 -1
- package/data/documents/shared/{containerKekLogFetch.d.ts → containerKek/containerKekLogFetch.d.ts} +1 -1
- package/data/documents/shared/{containerKekLogFetch.js → containerKek/containerKekLogFetch.js} +1 -1
- package/data/documents/shared/{containerKekPath.js → containerKek/containerKekPath.js} +3 -3
- package/data/documents/shared/containerKek/containerKekPath.js.map +1 -0
- package/data/documents/shared/{containerKekPathHistory.d.ts → containerKek/containerKekPathHistory.d.ts} +3 -3
- package/data/documents/shared/{containerKekPathHistory.js → containerKek/containerKekPathHistory.js} +4 -4
- package/data/documents/shared/containerKek/containerKekPathHistory.js.map +1 -0
- package/data/documents/shared/{containerKekPathVerification.d.ts → containerKek/containerKekPathVerification.d.ts} +5 -5
- package/data/documents/shared/{containerKekPathVerification.js → containerKek/containerKekPathVerification.js} +2 -2
- package/data/documents/shared/containerKek/containerKekPathVerification.js.map +1 -0
- package/data/documents/shared/{containerKekWrapping.js → containerKek/containerKekWrapping.js} +3 -3
- package/data/documents/shared/containerKek/containerKekWrapping.js.map +1 -0
- package/data/documents/shared/{keyringLogWalk.d.ts → containerKek/keyringLogWalk.d.ts} +2 -2
- package/data/documents/shared/{keyringLogWalk.js → containerKek/keyringLogWalk.js} +1 -1
- package/data/documents/shared/{keyringRebuild.d.ts → containerKek/keyringRebuild.d.ts} +3 -3
- package/data/documents/shared/{keyringRebuild.js → containerKek/keyringRebuild.js} +3 -3
- package/data/documents/shared/containerKek/keyringRebuild.js.map +1 -0
- package/data/documents/shared/crypto.js +2 -2
- package/data/documents/shared/crypto.js.map +1 -1
- package/data/documents/shared/events.js +1 -1
- package/data/documents/shared/{projection.d.ts → projection/index.d.ts} +7 -7
- package/data/documents/shared/{projection.js → projection/index.js} +9 -9
- package/data/documents/shared/projection/index.js.map +1 -0
- package/data/documents/shared/{projectionContentKeys.d.ts → projection/projectionContentKeys.d.ts} +6 -6
- package/data/documents/shared/{projectionContentKeys.js → projection/projectionContentKeys.js} +9 -9
- package/data/documents/shared/projection/projectionContentKeys.js.map +1 -0
- package/data/documents/shared/{projectionTargets.d.ts → projection/projectionTargets.d.ts} +4 -4
- package/data/documents/shared/{projectionTargets.js → projection/projectionTargets.js} +3 -3
- package/data/documents/shared/projection/projectionTargets.js.map +1 -0
- package/data/documents/shared/responses.d.ts +1 -1
- package/data/documents/shared/responses.js +1 -1
- package/data/documents/shared/responses.js.map +1 -1
- package/data/documents/shared/{documentSyncUpdateDecryption.js → sync/documentSyncUpdateDecryption.js} +10 -10
- package/data/documents/shared/sync/documentSyncUpdateDecryption.js.map +1 -0
- package/data/documents/shared/{documentSyncUpdateIsolation.d.ts → sync/documentSyncUpdateIsolation.d.ts} +3 -3
- package/data/documents/shared/{documentSyncUpdateIsolation.js → sync/documentSyncUpdateIsolation.js} +1 -1
- package/data/documents/shared/sync/documentSyncUpdateIsolation.js.map +1 -0
- package/data/documents/shared/{mutationAcknowledgement.js → sync/mutationAcknowledgement.js} +1 -1
- package/data/documents/shared/sync/mutationAcknowledgement.js.map +1 -0
- package/data/documents/shared/{pullContinuation.js → sync/pullContinuation.js} +1 -1
- package/data/documents/shared/{syncPagination.d.ts → sync/syncPagination.d.ts} +2 -2
- package/data/documents/shared/{syncPagination.js → sync/syncPagination.js} +1 -1
- package/data/documents/shared/sync/syncPagination.js.map +1 -0
- package/data/documents/shared/{syncResponseAuthorization.js → sync/syncResponseAuthorization.js} +3 -3
- package/data/documents/shared/sync/syncResponseAuthorization.js.map +1 -0
- package/data/documents/shared/{syncResponses.d.ts → sync/syncResponses.d.ts} +2 -2
- package/data/documents/shared/{syncResponses.js → sync/syncResponses.js} +6 -6
- package/data/documents/shared/sync/syncResponses.js.map +1 -0
- package/data/documents/shared/{syncSubmitFailure.d.ts → sync/syncSubmitFailure.d.ts} +1 -1
- package/data/documents/shared/types.d.ts +3 -3
- package/data/documents/shared/types.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js +1 -1
- package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.d.ts +1 -1
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js +1 -1
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js +1 -1
- package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js +4 -4
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -1
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js +3 -3
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -1
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js +4 -4
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -1
- package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js +2 -2
- package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -1
- package/data/persistence/container-contents/containerContentsPersistence.js +3 -3
- package/data/persistence/container-contents/containerContentsPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerContentsPersistenceTypes.d.ts +2 -2
- package/data/persistence/container-contents/containerContentsPersistenceTypes.js.map +1 -1
- package/data/persistence/container-contents/containerCreateIntentSettlement.js +1 -1
- package/data/persistence/container-contents/containerDeletionPersistence.js +2 -2
- package/data/persistence/container-contents/containerDocumentReassignment.js +2 -2
- package/data/persistence/container-contents/containerDocumentReassignment.js.map +1 -1
- package/data/persistence/container-contents/containerHydrationPersistence.js +3 -3
- package/data/persistence/container-contents/containerHydrationPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerIntentPersistence.js +1 -1
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js +5 -5
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerMetadataPullContinuationPersistence.js +1 -1
- package/data/persistence/container-contents/containerMetadataRows.js +3 -3
- package/data/persistence/container-contents/containerMetadataRows.js.map +1 -1
- package/data/persistence/container-contents/containerMoveAbandonPersistence.js +1 -1
- package/data/persistence/container-contents/containerMoveIntentRows.js +1 -1
- package/data/persistence/container-contents/containerPendingUpdatePersistence.js +3 -3
- package/data/persistence/container-contents/containerPendingUpdatePersistence.js.map +1 -1
- package/data/persistence/container-contents/containerRebindPersistence.js +1 -1
- package/data/persistence/container-contents/containerReconcilePersistence.js +2 -2
- package/data/persistence/container-contents/containerRecoveryPersistence.js +1 -1
- package/data/persistence/container-contents/containerRemovalWork.js +3 -3
- package/data/persistence/container-contents/containerRemovalWork.js.map +1 -1
- package/data/persistence/container-contents/containerStructuralRepair.js +1 -1
- package/data/persistence/container-contents/documentLinkRemovalRepair.js +2 -2
- package/data/persistence/container-contents/documentLinkRemovalRepair.js.map +1 -1
- package/data/persistence/container-contents/documentMoveIntentPersistence.js +2 -2
- package/data/persistence/container-contents/documentMoveIntentPersistence.js.map +1 -1
- package/data/persistence/container-contents/documentPlacementIntentEnqueue.js +2 -2
- package/data/persistence/container-contents/documentPlacementIntentEnqueue.js.map +1 -1
- package/data/persistence/container-contents/documentPurgePlacement.js +14 -1
- package/data/persistence/container-contents/documentPurgePlacement.js.map +1 -1
- package/data/persistence/container-contents/dormantContainerMetadata.js +1 -1
- package/data/persistence/container-contents/dormantMetadataSweep.js +1 -1
- package/data/persistence/container-contents/pendingContainerCreate.js +1 -1
- package/data/persistence/container-contents/supersededContainerBindings.js +1 -1
- package/data/persistence/containers/containerPersistence.js +1 -1
- package/data/persistence/containers/containerSyncWatermarkPersistence.js +1 -1
- package/data/persistence/containers/documentContainerProjectionPersistence.js +1 -1
- package/data/persistence/containers/documentPlacement.js +1 -1
- package/data/persistence/documents/containerDocumentTombstoneHoldsPersistence.js +1 -1
- package/data/persistence/documents/documentDiscoveryEvidencePersistence.js +3 -3
- package/data/persistence/documents/documentDiscoveryEvidencePersistence.js.map +1 -1
- package/data/persistence/documents/documentDiscoveryReset.js +1 -1
- package/data/persistence/documents/documentDiscoveryReset.js.map +1 -1
- package/data/persistence/documents/documentsPersistence.js +3 -3
- package/data/persistence/documents/documentsPersistence.js.map +1 -1
- package/data/persistence/documents/internal/attachmentStagingPersistence.js +1 -1
- package/data/persistence/documents/internal/containerDocumentTombstoneHolds.js +1 -1
- package/data/persistence/documents/internal/containerDocumentTombstones.js +1 -1
- package/data/persistence/documents/internal/createDocumentWithHistoryCheckpoint.js +2 -2
- package/data/persistence/documents/internal/createDocumentWithHistoryCheckpoint.js.map +1 -1
- package/data/persistence/documents/internal/discardDocument.js +3 -3
- package/data/persistence/documents/internal/discardDocument.js.map +1 -1
- package/data/persistence/documents/internal/documentDeletionPersistence.js +4 -4
- package/data/persistence/documents/internal/documentDeletionPersistence.js.map +1 -1
- package/data/persistence/documents/internal/documentMutationPersistence.js +5 -5
- package/data/persistence/documents/internal/documentMutationPersistence.js.map +1 -1
- package/data/persistence/documents/internal/documentProjectionRows.js +1 -1
- package/data/persistence/documents/internal/documentPullContinuationPersistence.js +1 -1
- package/data/persistence/documents/internal/documentRows.js +2 -2
- package/data/persistence/documents/internal/documentRows.js.map +1 -1
- package/data/persistence/documents/internal/documentSummaryQueries.js +1 -1
- package/data/persistence/documents/internal/ensureDocumentsSchema.js +2 -2
- package/data/persistence/documents/internal/hydratedAttachmentPersistence.js +1 -1
- package/data/persistence/documents/internal/orphanSideRows.js +2 -2
- package/data/persistence/documents/internal/orphanSideRows.js.map +1 -1
- package/data/persistence/documents/internal/pendingCreateAdoption.js +1 -1
- package/data/persistence/documents/internal/rowQueryPersistence.js +2 -2
- package/data/persistence/documents/internal/syncQueuePersistence.js +3 -3
- package/data/persistence/documents/internal/syncQueuePersistence.js.map +1 -1
- package/data/persistence/documents/types.d.ts +3 -3
- package/data/persistence/documents/types.js.map +1 -1
- package/data/persistence/{documentPurgeCheckpointPersistence.d.ts → keyingCheckpoints/documentPurgeCheckpointPersistence.d.ts} +2 -2
- package/data/persistence/{documentPurgeCheckpointPersistence.js → keyingCheckpoints/documentPurgeCheckpointPersistence.js} +4 -4
- package/data/persistence/keyingCheckpoints/documentPurgeCheckpointPersistence.js.map +1 -0
- package/data/persistence/{keyingCheckpointAdvancePersistence.js → keyingCheckpoints/keyingCheckpointAdvancePersistence.js} +9 -9
- package/data/persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence.js.map +1 -0
- package/data/persistence/{keyingCheckpointEvidence.js → keyingCheckpoints/keyingCheckpointEvidence.js} +1 -1
- package/data/persistence/{keyingCheckpointPersistence.js → keyingCheckpoints/keyingCheckpointPersistence.js} +5 -5
- package/data/persistence/keyingCheckpoints/keyingCheckpointPersistence.js.map +1 -0
- package/data/persistence/{locallyAcknowledgedCheckpointPersistence.d.ts → keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.d.ts} +4 -4
- package/data/persistence/{locallyAcknowledgedCheckpointPersistence.js → keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.js} +7 -7
- package/data/persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.js.map +1 -0
- package/data/persistence/{organizationReplacementCheckpointPersistence.js → keyingCheckpoints/organizationReplacementCheckpointPersistence.js} +6 -6
- package/data/persistence/keyingCheckpoints/organizationReplacementCheckpointPersistence.js.map +1 -0
- package/data/persistence/{principalAuthorizationCheckpoints.js → keyingCheckpoints/principalAuthorizationCheckpoints.js} +1 -1
- package/data/persistence/keyingCheckpoints/principalAuthorizationCheckpoints.js.map +1 -0
- package/data/persistence/organizationFounderPersistence.js +2 -2
- package/data/persistence/organizationFounderPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationAccessRevocationPersistence.js +3 -3
- package/data/persistence/organizations/organizationAccessRevocationPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationDataUsagePersistence.js +2 -2
- package/data/persistence/organizations/organizationDataUsagePersistence.js.map +1 -1
- package/data/persistence/organizations/organizationGroupNamePersistence.js +2 -2
- package/data/persistence/organizations/organizationGroupNamePersistence.js.map +1 -1
- package/data/persistence/organizations/organizationPresentationDenialPersistence.js +2 -2
- package/data/persistence/organizations/organizationPresentationDenialPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationProfileDocumentPointers.js +2 -2
- package/data/persistence/organizations/organizationProfileDocumentPointers.js.map +1 -1
- package/data/persistence/organizations/organizationProvisioningAttemptPersistence.js +1 -1
- package/data/persistence/organizations/organizationProvisioningAttemptPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelGrantPersistence.js +1 -1
- package/data/persistence/organizations/organizationReadModelGrantPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelMemberLoad.js +1 -1
- package/data/persistence/organizations/organizationReadModelMemberLoad.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelMembershipPersistence.js +1 -1
- package/data/persistence/organizations/organizationReadModelMembershipPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelPersistence.js +3 -3
- package/data/persistence/organizations/organizationReadModelPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelProjection.js +1 -1
- package/data/persistence/organizations/organizationReadModelProjection.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelPurge.js +3 -3
- package/data/persistence/organizations/organizationReadModelPurge.js.map +1 -1
- package/data/persistence/principalCurrentAcknowledgementPersistence.d.ts +3 -3
- package/data/persistence/principalCurrentAcknowledgementPersistence.js +10 -10
- package/data/persistence/principalCurrentAcknowledgementPersistence.js.map +1 -1
- package/data/persistence/{principalHistoryEvidencePersistence.d.ts → principalHistory/principalHistoryEvidencePersistence.d.ts} +4 -4
- package/data/persistence/{principalHistoryEvidencePersistence.js → principalHistory/principalHistoryEvidencePersistence.js} +7 -7
- package/data/persistence/principalHistory/principalHistoryEvidencePersistence.js.map +1 -0
- package/data/persistence/{principalHistoryIncompleteRetention.js → principalHistory/principalHistoryIncompleteRetention.js} +1 -1
- package/data/persistence/principalHistory/principalHistoryIncompleteRetention.js.map +1 -0
- package/data/persistence/{principalHistoryNodeRetention.js → principalHistory/principalHistoryNodeRetention.js} +4 -4
- package/data/persistence/principalHistory/principalHistoryNodeRetention.js.map +1 -0
- package/data/persistence/{principalHistoryPrefixPersistence.d.ts → principalHistory/principalHistoryPrefixPersistence.d.ts} +2 -2
- package/data/persistence/{principalHistoryPrefixPersistence.js → principalHistory/principalHistoryPrefixPersistence.js} +6 -6
- package/data/persistence/principalHistory/principalHistoryPrefixPersistence.js.map +1 -0
- package/data/persistence/{principalHistoryRootOwnership.js → principalHistory/principalHistoryRootOwnership.js} +1 -1
- package/data/persistence/principalHistory/principalHistoryRootOwnership.js.map +1 -0
- package/data/persistence/{principalHistoryStagePersistence.d.ts → principalHistory/principalHistoryStagePersistence.d.ts} +2 -2
- package/data/persistence/{principalHistoryStagePersistence.js → principalHistory/principalHistoryStagePersistence.js} +6 -6
- package/data/persistence/principalHistory/principalHistoryStagePersistence.js.map +1 -0
- package/data/persistence/{principalHistoryStageRetention.js → principalHistory/principalHistoryStageRetention.js} +2 -2
- package/data/persistence/principalHistory/principalHistoryStageRetention.js.map +1 -0
- package/data/persistence/{principalHistoryUnpublishedRetention.js → principalHistory/principalHistoryUnpublishedRetention.js} +3 -3
- package/data/persistence/principalHistory/principalHistoryUnpublishedRetention.js.map +1 -0
- package/data/persistence/{principalGrantRetirementPersistence.d.ts → principalKeys/principalGrantRetirementPersistence.d.ts} +2 -2
- package/data/persistence/{principalGrantRetirementPersistence.js → principalKeys/principalGrantRetirementPersistence.js} +2 -2
- package/data/persistence/principalKeys/principalGrantRetirementPersistence.js.map +1 -0
- package/data/persistence/{principalKeyEnvelopeArchivePersistence.js → principalKeys/principalKeyEnvelopeArchivePersistence.js} +3 -3
- package/data/persistence/principalKeys/principalKeyEnvelopeArchivePersistence.js.map +1 -0
- package/data/persistence/{principalKeyEnvelopeCandidates.js → principalKeys/principalKeyEnvelopeCandidates.js} +9 -9
- package/data/persistence/principalKeys/principalKeyEnvelopeCandidates.js.map +1 -0
- package/data/persistence/principalMutationJournalPersistence.d.ts +1 -1
- package/data/persistence/principalMutationJournalPersistence.js +1 -1
- package/data/persistence/principalMutationJournalPersistence.js.map +1 -1
- package/data/persistence/{principalPolicyBundleIntegrity.js → principalPolicy/principalPolicyBundleIntegrity.js} +3 -3
- package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js.map +1 -0
- package/data/persistence/{principalPolicyCheckpointSelection.js → principalPolicy/principalPolicyCheckpointSelection.js} +2 -2
- package/data/persistence/principalPolicy/principalPolicyCheckpointSelection.js.map +1 -0
- package/data/persistence/{principalPolicyOrganizationPersistence.js → principalPolicy/principalPolicyOrganizationPersistence.js} +2 -2
- package/data/persistence/principalPolicy/principalPolicyOrganizationPersistence.js.map +1 -0
- package/data/persistence/{principalPolicyPersistence.js → principalPolicy/principalPolicyPersistence.js} +5 -5
- package/data/persistence/principalPolicy/principalPolicyPersistence.js.map +1 -0
- package/data/persistence/{principalPolicyReferenceCheckpoint.js → principalPolicy/principalPolicyReferenceCheckpoint.js} +3 -3
- package/data/persistence/principalPolicy/principalPolicyReferenceCheckpoint.js.map +1 -0
- package/data/persistence/{principalPolicyReferenceIndexPersistence.js → principalPolicy/principalPolicyReferenceIndexPersistence.js} +4 -4
- package/data/persistence/principalPolicy/principalPolicyReferenceIndexPersistence.js.map +1 -0
- package/data/persistence/{principalPolicyReferencePersistence.js → principalPolicy/principalPolicyReferencePersistence.js} +5 -5
- package/data/persistence/principalPolicy/principalPolicyReferencePersistence.js.map +1 -0
- package/data/persistence/{verifiedPrincipalPolicyBundle.js → principalPolicy/verifiedPrincipalPolicyBundle.js} +2 -2
- package/data/persistence/principalPolicy/verifiedPrincipalPolicyBundle.js.map +1 -0
- package/data/persistence/{verifiedPrincipalPolicyCurrent.js → principalPolicy/verifiedPrincipalPolicyCurrent.js} +2 -2
- package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js.map +1 -0
- package/data/persistence/{verifiedPrincipalPolicyRetentionPersistence.js → principalPolicy/verifiedPrincipalPolicyRetentionPersistence.js} +1 -1
- package/data/persistence/principalPolicy/verifiedPrincipalPolicyRetentionPersistence.js.map +1 -0
- package/data/persistence/securityIncidentPersistence.js +1 -1
- package/data/persistence/securityIncidentPersistence.js.map +1 -1
- package/data/persistence/trustedUserIdentityPinPersistence.js +1 -1
- package/data/persistence/verifiedManifestBundlePersistence.d.ts +1 -1
- package/data/persistence/verifiedManifestBundlePersistence.js +4 -4
- package/data/persistence/verifiedManifestBundlePersistence.js.map +1 -1
- package/data/principals/organizationGroupRoles.js +2 -2
- package/data/principals/organizationGroupRoles.js.map +1 -1
- package/data/principals/principalHistoryPrefixProtection.js.map +1 -1
- package/data/principals/principalHistoryStageProtection.js.map +1 -1
- package/data/principals/principalPolicyCrypto.js +1 -1
- package/data/principals/principalPolicyCrypto.js.map +1 -1
- package/data/sqlite/{documentHistoryPersistence.d.ts → documentPersistence/documentHistoryPersistence.d.ts} +1 -1
- package/data/sqlite/{documentHistoryPersistence.js → documentPersistence/documentHistoryPersistence.js} +5 -5
- package/data/sqlite/documentPersistence/documentHistoryPersistence.js.map +1 -0
- package/data/sqlite/{documentOrphanBlobReclaims.js → documentPersistence/documentOrphanBlobReclaims.js} +1 -1
- package/data/sqlite/documentPersistence/documentOrphanBlobReclaims.js.map +1 -0
- package/data/sqlite/{documentPendingUpdatePersistence.d.ts → documentPersistence/documentPendingUpdatePersistence.d.ts} +2 -2
- package/data/sqlite/{documentPendingUpdatePersistence.js → documentPersistence/documentPendingUpdatePersistence.js} +2 -2
- package/data/sqlite/documentPersistence/documentPendingUpdatePersistence.js.map +1 -0
- package/data/sqlite/{documentPersistenceTypes.d.ts → documentPersistence/documentPersistenceTypes.d.ts} +2 -2
- package/data/sqlite/documentPersistence/documentPersistenceTypes.js.map +1 -0
- package/data/sqlite/{documentRecordPersistence.d.ts → documentPersistence/documentRecordPersistence.d.ts} +1 -1
- package/data/sqlite/{documentRecordPersistence.js → documentPersistence/documentRecordPersistence.js} +4 -4
- package/data/sqlite/documentPersistence/documentRecordPersistence.js.map +1 -0
- package/data/sqlite/{documentSyncFailurePersistence.d.ts → documentPersistence/documentSyncFailurePersistence.d.ts} +2 -2
- package/data/sqlite/{documentSyncFailurePersistence.js → documentPersistence/documentSyncFailurePersistence.js} +3 -3
- package/data/sqlite/documentPersistence/documentSyncFailurePersistence.js.map +1 -0
- package/data/sqlite/{documentPersistence.d.ts → documentPersistence/index.d.ts} +2 -2
- package/data/sqlite/{documentPersistence.js → documentPersistence/index.js} +5 -5
- package/data/sqlite/documentPersistence/index.js.map +1 -0
- package/data/sqlite/{containerSchema.d.ts → schema/containerSchema.d.ts} +1 -1
- package/data/sqlite/{containerSchema.js → schema/containerSchema.js} +1 -1
- package/data/sqlite/schema/containerSchema.js.map +1 -0
- package/data/sqlite/{schema.d.ts → schema/index.d.ts} +1 -1
- package/data/sqlite/{schema.js → schema/index.js} +3 -3
- package/data/sqlite/schema/index.js.map +1 -0
- package/data/sqlite/{organizationDataUsageSchema.js → schema/organizationDataUsageSchema.js} +1 -1
- package/data/sqlite/schema/organizationDataUsageSchema.js.map +1 -0
- package/data/sqlite/{organizationProvisioningAttemptSchema.js → schema/organizationProvisioningAttemptSchema.js} +1 -1
- package/data/sqlite/schema/organizationProvisioningAttemptSchema.js.map +1 -0
- package/data/sqlite/{organizationReadModelTableRegistry.d.ts → schema/organizationReadModelTableRegistry.d.ts} +1 -1
- package/data/sqlite/{organizationReadModelTableRegistry.js → schema/organizationReadModelTableRegistry.js} +1 -1
- package/data/sqlite/schema/organizationReadModelTableRegistry.js.map +1 -0
- package/data/sqlite/{principalHistoryEvidenceSchema.d.ts → schema/principalHistoryEvidenceSchema.d.ts} +1 -1
- package/data/sqlite/{principalHistoryEvidenceSchema.js → schema/principalHistoryEvidenceSchema.js} +2 -2
- package/data/sqlite/schema/principalHistoryEvidenceSchema.js.map +1 -0
- package/data/sqlite/{principalHistoryNodeRetentionSchema.js → schema/principalHistoryNodeRetentionSchema.js} +1 -1
- package/data/sqlite/schema/principalHistoryNodeRetentionSchema.js.map +1 -0
- package/data/sqlite/{principalHistoryRetentionSchema.js → schema/principalHistoryRetentionSchema.js} +1 -1
- package/data/sqlite/{principalHistoryRetentionSchema.js.map → schema/principalHistoryRetentionSchema.js.map} +1 -1
- package/data/sqlite/{principalHistoryStageSchema.d.ts → schema/principalHistoryStageSchema.d.ts} +1 -1
- package/data/sqlite/{principalHistoryStageSchema.js → schema/principalHistoryStageSchema.js} +2 -2
- package/data/sqlite/schema/principalHistoryStageSchema.js.map +1 -0
- package/data/sqlite/{principalMutationJournalSchema.d.ts → schema/principalMutationJournalSchema.d.ts} +1 -1
- package/data/sqlite/{principalMutationJournalSchema.js → schema/principalMutationJournalSchema.js} +1 -1
- package/data/sqlite/{principalMutationJournalSchema.js.map → schema/principalMutationJournalSchema.js.map} +1 -1
- package/data/sqlite/{principalPolicySchema.js → schema/principalPolicySchema.js} +1 -1
- package/data/sqlite/schema/principalPolicySchema.js.map +1 -0
- package/data/sqlite/{securityIncidentSchema.d.ts → schema/securityIncidentSchema.d.ts} +1 -1
- package/data/sqlite/{securityIncidentSchema.js → schema/securityIncidentSchema.js} +1 -1
- package/data/sqlite/schema/securityIncidentSchema.js.map +1 -0
- package/data/sqlite/{verifiedManifestBundleSchema.d.ts → schema/verifiedManifestBundleSchema.d.ts} +1 -1
- package/data/sqlite/{verifiedManifestBundleSchema.js → schema/verifiedManifestBundleSchema.js} +1 -1
- package/data/sqlite/schema/verifiedManifestBundleSchema.js.map +1 -0
- package/data/sqlite/sqlitePersistenceRuntime.d.ts +1 -1
- package/data/sqlite/sqlitePersistenceRuntime.js +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/sqlite/index.d.ts +1 -1
- package/sqlite/index.js +1 -1
- package/stores/container-contents/containerContentsStore.js +3 -2
- package/stores/container-contents/containerContentsStore.js.map +1 -1
- package/stores/container-contents/index.d.ts +1 -1
- package/stores/container-contents/index.js.map +1 -1
- package/stores/container-contents/operations/purgeMoveSettlementOperation.js +71 -0
- package/stores/container-contents/operations/purgeMoveSettlementOperation.js.map +1 -0
- package/stores/documents/documentStore/history/historyRebuild.js +1 -1
- package/stores/documents/documentStore/history/historyRebuild.js.map +1 -1
- package/stores/documents/documentStore/state.js.map +1 -1
- package/stores/documents/documentStore/sync/syncFinalize.js +1 -1
- package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -1
- package/stores/documents/documentStore/sync/syncUpdateImport.js +1 -1
- package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -1
- package/workflows/blobs/detach.js +1 -1
- package/workflows/blobs/hydration/decrypt.js +1 -1
- package/workflows/blobs/upload/index.js +1 -1
- package/workflows/blobs/verification/retainedAttachmentVerification.js +1 -1
- package/workflows/blobs/verification/writerProjection.js +1 -1
- package/workflows/container-contents/container-state/create/createWithMetadata.js +2 -2
- package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -1
- package/workflows/container-contents/container-state/moveIntentSync.js +43 -5
- package/workflows/container-contents/container-state/moveIntentSync.js.map +1 -1
- package/workflows/container-contents/container-state/purge/purgeMoveSettlement.js +119 -0
- package/workflows/container-contents/container-state/purge/purgeMoveSettlement.js.map +1 -0
- package/workflows/container-contents/container-state/purge/purgeProgress.d.ts +8 -0
- package/workflows/container-contents/container-state/purge/purgeProgress.js.map +1 -1
- package/workflows/container-contents/container-state/remote.js +1 -0
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/share/index.js +1 -1
- package/workflows/container-contents/documentLinks/index.js +1 -1
- package/workflows/container-contents/documentMove/documentMoveVanishedRefresh.js +1 -1
- package/workflows/container-contents/documentPriming/documentHydrationProbe.js +1 -1
- package/workflows/container-contents/documentPriming/index.js +1 -1
- package/workflows/container-contents/documentQueries/index.js +1 -1
- package/workflows/container-contents/documentQueries/sql.js +1 -1
- package/workflows/container-contents/info/blobInfo.js +1 -1
- package/workflows/container-contents/info/containerInfo.js +1 -1
- package/workflows/container-contents/info/documentInfo.js +1 -1
- package/workflows/container-contents/metadata/index.js +1 -1
- package/workflows/container-contents/metadata/index.js.map +1 -1
- package/workflows/container-contents/metadata/metadataEvents.d.ts +1 -1
- package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js +2 -2
- package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js.map +1 -1
- package/workflows/container-contents/metadata/metadataMutationPreparation.js +1 -1
- package/workflows/container-contents/metadata/metadataMutationPreparation.js.map +1 -1
- package/workflows/container-contents/metadata/metadataPullContinuationInvalidation.js +1 -1
- package/workflows/container-contents/metadata/metadataPullContinuationInvalidation.js.map +1 -1
- package/workflows/container-contents/metadata/metadataRemoteSync.d.ts +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/metadata/metadataSyncSettlement.d.ts +1 -1
- package/workflows/container-contents/metadata/metadataSyncSettlement.js.map +1 -1
- package/workflows/container-contents/metadata/metadataTypes.d.ts +1 -1
- package/workflows/container-contents/metadata/metadataTypes.js.map +1 -1
- package/workflows/container-contents/pendingWrites/index.js +2 -2
- package/workflows/container-contents/pendingWrites/sources.js +1 -1
- package/workflows/container-contents/remoteHydration/destination/replacementBinding.js +1 -1
- package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -1
- package/workflows/container-contents/remoteHydration/reattachMetadata.js.map +1 -1
- package/workflows/container-contents/syncLane.d.ts +2 -0
- package/workflows/container-contents/syncLane.js +7 -0
- package/workflows/container-contents/syncLane.js.map +1 -1
- package/workflows/container-contents/tombstones/documentTombstoneEvidence.js +2 -2
- package/workflows/container-contents/tombstones/documentTombstoneEvidence.js.map +1 -1
- package/workflows/containers/child/create/index.js +2 -2
- package/workflows/containers/child/create/index.js.map +1 -1
- package/workflows/containers/child/move/index.d.ts +1 -0
- package/workflows/containers/child/move/index.js +2 -1
- package/workflows/containers/child/move/index.js.map +1 -1
- package/workflows/containers/child/move/moveRotation.js +1 -1
- package/workflows/containers/child/move/moveRotation.js.map +1 -1
- package/workflows/containers/child/move/moveWraps.js +1 -1
- package/workflows/containers/child/move/moveWraps.js.map +1 -1
- package/workflows/containers/child/mutationSubmit.js +3 -1
- package/workflows/containers/child/mutationSubmit.js.map +1 -1
- package/workflows/containers/child/recite.js +2 -2
- package/workflows/containers/child/recite.js.map +1 -1
- package/workflows/containers/child/rotation/rotationContext.js +3 -3
- package/workflows/containers/child/rotation/rotationContext.js.map +1 -1
- package/workflows/containers/child/share/currentSharePrincipalPolicy.js +1 -1
- package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -1
- package/workflows/containers/child/share/index.js +1 -1
- package/workflows/containers/child/share/index.js.map +1 -1
- package/workflows/containers/child/share/shareAncestorRepair.js +2 -2
- package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -1
- package/workflows/containers/child/share/shareMaterialization.js +1 -1
- package/workflows/containers/child/share/sharePrincipalPolicy.js +5 -5
- package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -1
- package/workflows/containers/index.d.ts +3 -3
- package/workflows/containers/index.js +2 -2
- package/workflows/containers/index.js.map +1 -1
- package/workflows/containers/writeRefusal.js +1 -1
- package/workflows/containers/writeRefusal.js.map +1 -1
- package/workflows/documents/create/createAdoption.js +1 -1
- package/workflows/documents/create/createResponse.js +2 -2
- package/workflows/documents/create/createResponse.js.map +1 -1
- package/workflows/documents/create/index.js +1 -1
- package/workflows/documents/documentMutationCommit.d.ts +1 -1
- package/workflows/documents/documentMutationPreparation.d.ts +1 -1
- package/workflows/documents/documentMutationPreparation.js +1 -1
- package/workflows/documents/documentMutationPreparation.js.map +1 -1
- package/workflows/documents/index.d.ts +5 -5
- package/workflows/documents/index.js +5 -5
- package/workflows/documents/index.js.map +1 -1
- package/workflows/documents/linkSet/index.js +2 -2
- package/workflows/documents/linkSet/index.js.map +1 -1
- package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
- package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
- package/workflows/documents/linkSet/linkSetRemote.js +1 -1
- package/workflows/documents/linkSet/linkSetRemote.js.map +1 -1
- package/workflows/documents/purge/index.js +1 -1
- package/workflows/documents/sync/index.js +2 -2
- package/workflows/documents/sync/index.js.map +1 -1
- package/workflows/documents/sync/initialSync.js +1 -1
- package/workflows/documents/sync/readOnlyProjectionFailure.js +1 -1
- package/workflows/documents/sync/readOnlyProjectionFailure.js.map +1 -1
- package/workflows/documents/sync/readOnlySync.d.ts +3 -3
- package/workflows/documents/sync/readOnlySync.js +1 -1
- package/workflows/documents/sync/readOnlySync.js.map +1 -1
- package/workflows/documents/sync/reportDocumentSyncQuarantine.js.map +1 -1
- package/workflows/documents/sync/syncAttemptPlanning.js +2 -2
- package/workflows/documents/sync/syncAttemptPlanning.js.map +1 -1
- package/workflows/documents/sync/syncAttemptState.d.ts +2 -2
- package/workflows/documents/sync/syncAttemptState.js.map +1 -1
- package/workflows/documents/sync/syncResponseResult.js +2 -2
- package/workflows/documents/sync/syncResponseResult.js.map +1 -1
- package/workflows/documents/syncFailures/index.js +1 -1
- package/workflows/documents/syncFailures/index.js.map +1 -1
- package/workflows/documents/syncFailures/syncAbandon.js.map +1 -1
- package/workflows/documents/syncFailures/syncFailureClassification.js +1 -1
- package/workflows/documents/syncFailures/syncFailureClassification.js.map +1 -1
- package/workflows/documents/syncPlan/syncContentKeys.d.ts +1 -1
- package/workflows/documents/syncPlan/syncContentKeys.js +3 -3
- package/workflows/documents/syncPlan/syncContentKeys.js.map +1 -1
- package/workflows/documents/syncPlan/syncPlanMaterial.js +2 -2
- package/workflows/documents/syncPlan/syncPlanMaterial.js.map +1 -1
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
- package/workflows/documents/syncRekeys/syncContainerRekeyPreparation.js +1 -1
- package/workflows/documents/syncRekeys/syncRecoveryRekey.d.ts +1 -1
- package/workflows/documents/syncRekeys/syncRecoveryRekey.js +1 -1
- package/workflows/organizations/currentOrganizationAuthority.js +2 -2
- package/workflows/organizations/currentOrganizationAuthority.js.map +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataAccess.js +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataAccess.js.map +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataContainerAuthority.js +1 -1
- package/workflows/organizations/groupMetadata/groupMetadataContainerAuthority.js.map +1 -1
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js +1 -1
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js.map +1 -1
- package/workflows/organizations/groupNames/groupNameUniqueness.js +3 -3
- package/workflows/organizations/groupNames/groupNameUniqueness.js.map +1 -1
- package/workflows/organizations/groupNames/organizationGroupNamePolicies.js +2 -2
- package/workflows/organizations/groupNames/organizationGroupNamePolicies.js.map +1 -1
- package/workflows/organizations/groupPolicy/currentGroupPolicyMutationContext.js +1 -1
- package/workflows/organizations/groupPolicy/currentGroupPolicyMutationContext.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyMutationContext.js +2 -2
- package/workflows/organizations/groupPolicy/groupPolicyMutationContext.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyMutationEvidence.js +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyMutationEvidence.js.map +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyVerification.js +1 -1
- package/workflows/organizations/groupPolicy/groupPolicyVerification.js.map +1 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js +1 -1
- package/workflows/organizations/groups/createCurrentOrganizationGroup.js.map +1 -1
- package/workflows/organizations/groups/deleteOrganizationGroup.js +1 -1
- package/workflows/organizations/groups/deleteOrganizationGroup.js.map +1 -1
- package/workflows/organizations/groups/organizationGroupDirectory.js +1 -1
- package/workflows/organizations/groups/organizationGroupDirectory.js.map +1 -1
- package/workflows/organizations/principalMutations/runtimeCurrentOrganizationMutation.js +1 -1
- package/workflows/organizations/principalMutations/runtimeCurrentOrganizationMutation.js.map +1 -1
- package/workflows/organizations/provisioning/organizationReplacementVerification.js +1 -1
- package/workflows/organizations/provisioning/organizationReplacementVerification.js.map +1 -1
- package/workflows/organizations/readModel/listLocalOrganizations.js +1 -1
- package/workflows/organizations/readModel/localReadModelDetails.js +1 -1
- package/workflows/organizations/readModel/localReadModelDetails.js.map +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js.map +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.d.ts +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.js +1 -1
- package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.js.map +1 -1
- package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js +1 -1
- package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js.map +1 -1
- package/workflows/principals/acknowledgements/reconcileAcknowledgedPrincipalCurrent.js +2 -2
- package/workflows/principals/acknowledgements/reconcileAcknowledgedPrincipalCurrent.js.map +1 -1
- package/workflows/principals/externalAdminPolicy.js +2 -2
- package/workflows/principals/externalAdminPolicy.js.map +1 -1
- package/workflows/principals/historyRecovery/loadRecoveredPrincipalHistoryPage.js +2 -2
- package/workflows/principals/historyRecovery/loadRecoveredPrincipalHistoryPage.js.map +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryPrefix.js +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryPrefix.js.map +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryReferences.js +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryReferences.js.map +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryStage.js +1 -1
- package/workflows/principals/historyRecovery/principalHistoryRecoveryStage.js.map +1 -1
- package/workflows/principals/historyRecovery/recoverPrincipalPolicyHistory.js +3 -3
- package/workflows/principals/historyRecovery/recoverPrincipalPolicyHistory.js.map +1 -1
- package/workflows/principals/policyCache/index.js +3 -3
- package/workflows/principals/policyCache/index.js.map +1 -1
- package/workflows/principals/policyCache/principalPolicyCacheAdvance.js +1 -1
- package/workflows/principals/policyCache/principalPolicyCacheAdvance.js.map +1 -1
- package/workflows/principals/policyCache/principalPolicyOrganizationScope.js +3 -3
- package/workflows/principals/policyCache/principalPolicyOrganizationScope.js.map +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryAuthority.js.map +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js +2 -2
- package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js.map +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryProgress.js +3 -3
- package/workflows/principals/publicHistory/publicPrincipalHistoryProgress.js.map +1 -1
- package/workflows/principals/publicHistory/publicPrincipalHistoryTypes.d.ts +2 -2
- package/workflows/principals/publicHistory/publicPrincipalHistoryTypes.js.map +1 -1
- package/workflows/principals/publicHistory/publicProjectionPrincipal.js +1 -1
- package/workflows/principals/publicHistory/publicProjectionPrincipal.js.map +1 -1
- package/workflows/principals/publicHistory/recoverPublicPrincipalHistory.js +1 -1
- package/workflows/principals/publicHistory/recoverPublicPrincipalHistory.js.map +1 -1
- package/workflows/principals/publicHistory/selectPublicPrincipalHistory.js +1 -1
- package/workflows/principals/publicHistory/selectPublicPrincipalHistory.js.map +1 -1
- package/workflows/principals/recoveryOperation/principalRecoveryDirectory.js +1 -1
- package/workflows/principals/recoveryOperation/principalRecoveryDirectory.js.map +1 -1
- package/workflows/principals/recoveryOperation/principalRecoveryMemoValidity.js +1 -1
- package/workflows/principals/recoveryOperation/principalRecoveryMemoValidity.js.map +1 -1
- package/workflows/registration/persistRegistrationBootstrap.d.ts +2 -2
- package/workflows/registration/persistRegistrationBootstrap.js +2 -2
- package/workflows/registration/persistRegistrationBootstrap.js.map +1 -1
- package/workflows/registration/provisioningAcknowledgement.js +1 -1
- package/workflows/registration/provisioningAcknowledgement.js.map +1 -1
- package/workflows/registration/registrationPrincipalPolicyPersistence.js +1 -1
- package/workflows/registration/registrationPrincipalPolicyPersistence.js.map +1 -1
- package/workflows/sync/remoteReset.js +7 -7
- package/workflows/sync/remoteReset.js.map +1 -1
- package/workflows/sync/remoteResetAttachments.js +1 -1
- package/workflows/sync/remoteResetCursorScope.js +1 -1
- package/workflows/sync/remoteResetPlans.js +1 -1
- package/workflows/sync/remoteResetPrincipalScope.js +5 -5
- package/workflows/sync/remoteResetPrincipalScope.js.map +1 -1
- package/workflows/sync/remoteResetScope.js +1 -1
- package/data/documents/shared/containerKekPath.js.map +0 -1
- package/data/documents/shared/containerKekPathHistory.js.map +0 -1
- package/data/documents/shared/containerKekPathVerification.js.map +0 -1
- package/data/documents/shared/containerKekWrapping.js.map +0 -1
- package/data/documents/shared/documentSyncUpdateDecryption.js.map +0 -1
- package/data/documents/shared/documentSyncUpdateIsolation.js.map +0 -1
- package/data/documents/shared/keyringRebuild.js.map +0 -1
- package/data/documents/shared/mutationAcknowledgement.js.map +0 -1
- package/data/documents/shared/projection.js.map +0 -1
- package/data/documents/shared/projectionContentKeys.js.map +0 -1
- package/data/documents/shared/projectionTargets.js.map +0 -1
- package/data/documents/shared/syncPagination.js.map +0 -1
- package/data/documents/shared/syncResponseAuthorization.js.map +0 -1
- package/data/documents/shared/syncResponses.js.map +0 -1
- package/data/persistence/documentPurgeCheckpointPersistence.js.map +0 -1
- package/data/persistence/keyingCheckpointAdvancePersistence.js.map +0 -1
- package/data/persistence/keyingCheckpointPersistence.js.map +0 -1
- package/data/persistence/locallyAcknowledgedCheckpointPersistence.js.map +0 -1
- package/data/persistence/organizationReplacementCheckpointPersistence.js.map +0 -1
- package/data/persistence/principalAuthorizationCheckpoints.js.map +0 -1
- package/data/persistence/principalGrantRetirementPersistence.js.map +0 -1
- package/data/persistence/principalHistoryEvidencePersistence.js.map +0 -1
- package/data/persistence/principalHistoryIncompleteRetention.js.map +0 -1
- package/data/persistence/principalHistoryNodeRetention.js.map +0 -1
- package/data/persistence/principalHistoryPrefixPersistence.js.map +0 -1
- package/data/persistence/principalHistoryRootOwnership.js.map +0 -1
- package/data/persistence/principalHistoryStagePersistence.js.map +0 -1
- package/data/persistence/principalHistoryStageRetention.js.map +0 -1
- package/data/persistence/principalHistoryUnpublishedRetention.js.map +0 -1
- package/data/persistence/principalKeyEnvelopeArchivePersistence.js.map +0 -1
- package/data/persistence/principalKeyEnvelopeCandidates.js.map +0 -1
- package/data/persistence/principalPolicyBundleIntegrity.js.map +0 -1
- package/data/persistence/principalPolicyCheckpointSelection.js.map +0 -1
- package/data/persistence/principalPolicyOrganizationPersistence.js.map +0 -1
- package/data/persistence/principalPolicyPersistence.js.map +0 -1
- package/data/persistence/principalPolicyReferenceCheckpoint.js.map +0 -1
- package/data/persistence/principalPolicyReferenceIndexPersistence.js.map +0 -1
- package/data/persistence/principalPolicyReferencePersistence.js.map +0 -1
- package/data/persistence/verifiedPrincipalPolicyBundle.js.map +0 -1
- package/data/persistence/verifiedPrincipalPolicyCurrent.js.map +0 -1
- package/data/persistence/verifiedPrincipalPolicyRetentionPersistence.js.map +0 -1
- package/data/sqlite/containerSchema.js.map +0 -1
- package/data/sqlite/documentHistoryPersistence.js.map +0 -1
- package/data/sqlite/documentOrphanBlobReclaims.js.map +0 -1
- package/data/sqlite/documentPendingUpdatePersistence.js.map +0 -1
- package/data/sqlite/documentPersistence.js.map +0 -1
- package/data/sqlite/documentPersistenceTypes.js.map +0 -1
- package/data/sqlite/documentRecordPersistence.js.map +0 -1
- package/data/sqlite/documentSyncFailurePersistence.js.map +0 -1
- package/data/sqlite/organizationDataUsageSchema.js.map +0 -1
- package/data/sqlite/organizationProvisioningAttemptSchema.js.map +0 -1
- package/data/sqlite/organizationReadModelTableRegistry.js.map +0 -1
- package/data/sqlite/principalHistoryEvidenceSchema.js.map +0 -1
- package/data/sqlite/principalHistoryNodeRetentionSchema.js.map +0 -1
- package/data/sqlite/principalHistoryStageSchema.js.map +0 -1
- package/data/sqlite/principalPolicySchema.js.map +0 -1
- package/data/sqlite/schema.js.map +0 -1
- package/data/sqlite/securityIncidentSchema.js.map +0 -1
- package/data/sqlite/verifiedManifestBundleSchema.js.map +0 -1
- /package/data/documents/shared/{containerKekCurrency.js → containerKek/containerKekCurrency.js} +0 -0
- /package/data/documents/shared/{containerKekCurrency.js.map → containerKek/containerKekCurrency.js.map} +0 -0
- /package/data/documents/shared/{containerKekEntryVerification.js.map → containerKek/containerKekEntryVerification.js.map} +0 -0
- /package/data/documents/shared/{containerKekLogFetch.js.map → containerKek/containerKekLogFetch.js.map} +0 -0
- /package/data/documents/shared/{containerKekPath.d.ts → containerKek/containerKekPath.d.ts} +0 -0
- /package/data/documents/shared/{keyringLogWalk.js.map → containerKek/keyringLogWalk.js.map} +0 -0
- /package/data/documents/shared/{pullContinuation.d.ts → sync/pullContinuation.d.ts} +0 -0
- /package/data/documents/shared/{pullContinuation.js.map → sync/pullContinuation.js.map} +0 -0
- /package/data/documents/shared/{syncSubmitFailure.js → sync/syncSubmitFailure.js} +0 -0
- /package/data/documents/shared/{syncSubmitFailure.js.map → sync/syncSubmitFailure.js.map} +0 -0
- /package/data/persistence/{keyingCheckpointEvidence.js.map → keyingCheckpoints/keyingCheckpointEvidence.js.map} +0 -0
- /package/data/persistence/{storedPrincipalPolicyBundle.js → principalPolicy/storedPrincipalPolicyBundle.js} +0 -0
- /package/data/persistence/{storedPrincipalPolicyBundle.js.map → principalPolicy/storedPrincipalPolicyBundle.js.map} +0 -0
- /package/data/sqlite/{documentPersistenceTypes.js → documentPersistence/documentPersistenceTypes.js} +0 -0
- /package/data/sqlite/{containerDocumentTombstoneHoldSchema.d.ts → schema/containerDocumentTombstoneHoldSchema.d.ts} +0 -0
- /package/data/sqlite/{containerDocumentTombstoneHoldSchema.js → schema/containerDocumentTombstoneHoldSchema.js} +0 -0
- /package/data/sqlite/{containerDocumentTombstoneHoldSchema.js.map → schema/containerDocumentTombstoneHoldSchema.js.map} +0 -0
- /package/data/sqlite/{documentAttachmentSchema.d.ts → schema/documentAttachmentSchema.d.ts} +0 -0
- /package/data/sqlite/{documentAttachmentSchema.js → schema/documentAttachmentSchema.js} +0 -0
- /package/data/sqlite/{documentAttachmentSchema.js.map → schema/documentAttachmentSchema.js.map} +0 -0
- /package/data/sqlite/{documentDiscoveryEvidenceSchema.js → schema/documentDiscoveryEvidenceSchema.js} +0 -0
- /package/data/sqlite/{documentDiscoveryEvidenceSchema.js.map → schema/documentDiscoveryEvidenceSchema.js.map} +0 -0
- /package/data/sqlite/{documentPlacementIntentSchema.js → schema/documentPlacementIntentSchema.js} +0 -0
- /package/data/sqlite/{documentPlacementIntentSchema.js.map → schema/documentPlacementIntentSchema.js.map} +0 -0
- /package/data/sqlite/{localIntentSchema.d.ts → schema/localIntentSchema.d.ts} +0 -0
- /package/data/sqlite/{localIntentSchema.js → schema/localIntentSchema.js} +0 -0
- /package/data/sqlite/{localIntentSchema.js.map → schema/localIntentSchema.js.map} +0 -0
- /package/data/sqlite/{organizationFounderSchema.js → schema/organizationFounderSchema.js} +0 -0
- /package/data/sqlite/{organizationFounderSchema.js.map → schema/organizationFounderSchema.js.map} +0 -0
- /package/data/sqlite/{organizationReadModelSchema.js → schema/organizationReadModelSchema.js} +0 -0
- /package/data/sqlite/{organizationReadModelSchema.js.map → schema/organizationReadModelSchema.js.map} +0 -0
- /package/data/sqlite/{principalGrantRetirementSchema.js → schema/principalGrantRetirementSchema.js} +0 -0
- /package/data/sqlite/{principalGrantRetirementSchema.js.map → schema/principalGrantRetirementSchema.js.map} +0 -0
- /package/data/sqlite/{principalPolicySchema.d.ts → schema/principalPolicySchema.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentSyncUpdateIsolation.js","sourceRoot":"","sources":["documentSyncUpdateIsolation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AAmBzB,MAAM,8BAA8B,GAAG,CAAC,CAAC;AACzC,MAAM,+BAA+B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAMxD,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAsC,EACtC,KAAa;IAEb,MAAM,MAAM,GAAG,MAAM,EAAE,WAAW,CAAC;IACnC,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QACzC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,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,EAAE,EAAE,CAAC,WAAW,KAAK,cAAc,CACnD,CAAC;QACF,IAAI,CAAC;YACH,MAAM,4BAA4B,CAAC;gBACjC,eAAe;gBACf,OAAO,EAAE,gBAAgB;aAC1B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;YACvE,0DAA0D;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CACF,CAAC;IACF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,8BAA8B,CAAC;YACnC,KAAK,EAAE,UAAU;YACjB,cAAc,EAAE,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YACnD,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,cAAc,CAAC,EAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,yEAAyE;IACzE,6EAA6E;IAC7E,wDAAwD;IACxD,MAAM,6BAA6B,CAAC;QAClC,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,aAAa;QACpB,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n createDocument,\n exportFullHistorySnapshot,\n importSnapshot,\n importUpdates,\n LoroImportUnresolvedDependenciesError,\n updateMatchesDocumentHistory,\n} from \"@tearleads/loro\";\nimport type { DocumentSyncResponse } from \"@tearleads/validators/response\";\nimport type {\n DecryptedDocumentSyncUpdate,\n SyncRemoteDocumentResult,\n} from \"../types\";\n\ntype DocumentSyncUpdateIsolationStage =\n | \"content_key\"\n | \"decrypt\"\n | \"encrypted_record\"\n | \"loro_import\"\n | \"loro_metadata\"\n | \"plaintext_integrity\"\n | \"write_header\";\n\ntype SyncResponseUpdate = DocumentSyncResponse[\"updates\"][number];\ntype SyncDocument = Awaited<ReturnType<typeof createDocument>>;\n\nconst MAX_EXACT_ISOLATION_CANDIDATES = 8;\nconst MAX_EXACT_ISOLATION_RETRY_BYTES = 8 * 1024 * 1024;\n\nexport type IncomingDocumentSyncUpdateValidator = (\n result: Pick<SyncRemoteDocumentResult, \"decryptedUpdates\" | \"response\">,\n) => void | Promise<void>;\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction optionalHeaderField(\n update: SyncResponseUpdate | undefined,\n field: string,\n): unknown {\n const header = update?.writeHeader;\n return header && typeof header === \"object\"\n ? Reflect.get(header, field)\n : undefined;\n}\n\nfunction optionalHeaderString(\n update: SyncResponseUpdate | undefined,\n field: string,\n): string | null {\n const value = optionalHeaderField(update, field);\n return typeof value === \"string\" ? value : null;\n}\n\nfunction optionalHeaderEpoch(\n update: SyncResponseUpdate | undefined,\n): number | null {\n const value = optionalHeaderField(update, \"contentKeyEpoch\");\n return typeof value === \"number\" && Number.isSafeInteger(value)\n ? value\n : null;\n}\n\nexport class DocumentSyncUpdateIsolationError extends Error {\n readonly attribution: \"batch\" | \"update\";\n readonly authorFingerprint: string | null;\n readonly batchUpdateIds: readonly string[];\n readonly checkpointKind: \"rotate_baseline\" | null;\n readonly ciphertextHash: string | null;\n readonly contentKeyEpoch: number | null;\n readonly documentId: string | null;\n readonly metadataHash: string | null;\n readonly stage: DocumentSyncUpdateIsolationStage;\n readonly updateId: string | null;\n readonly writerUserId: string | null;\n\n constructor(input: {\n batchUpdateIds?: readonly string[] | undefined;\n cause: unknown;\n responseUpdate?: SyncResponseUpdate | undefined;\n stage: DocumentSyncUpdateIsolationStage;\n updateId: string | null;\n }) {\n const causeMessage = errorMessage(input.cause);\n const writerUserId = optionalHeaderString(\n input.responseUpdate,\n \"writerUserId\",\n );\n const author =\n writerUserId ?? input.responseUpdate?.authorFingerprint ?? \"unknown\";\n const fingerprint = input.responseUpdate?.authorFingerprint ?? \"unknown\";\n const epoch = optionalHeaderEpoch(input.responseUpdate) ?? \"unknown\";\n const batchUpdateIds =\n input.updateId === null ? (input.batchUpdateIds ?? []) : [];\n const subject =\n input.updateId === null\n ? `response batch containing ${batchUpdateIds.length} updates; exact update and writer unknown`\n : `update ${input.updateId} from writer ${author} (fingerprint ${fingerprint}, epoch ${epoch})`;\n super(\n `Document sync quarantined ${subject} during ${input.stage}: ${causeMessage}`,\n { cause: input.cause },\n );\n this.name = \"DocumentSyncUpdateIsolationError\";\n this.attribution = input.updateId === null ? \"batch\" : \"update\";\n this.authorFingerprint = input.responseUpdate?.authorFingerprint ?? null;\n this.batchUpdateIds = [...batchUpdateIds];\n this.checkpointKind =\n input.responseUpdate?.checkpointKind === \"rotate_baseline\"\n ? \"rotate_baseline\"\n : null;\n this.ciphertextHash = optionalHeaderString(\n input.responseUpdate,\n \"ciphertextHash\",\n );\n this.contentKeyEpoch = optionalHeaderEpoch(input.responseUpdate);\n this.documentId = input.responseUpdate?.documentId ?? null;\n this.metadataHash = optionalHeaderString(\n input.responseUpdate,\n \"metadataHash\",\n );\n this.stage = input.stage;\n this.updateId = input.updateId;\n this.writerUserId = writerUserId;\n }\n}\n\nexport function isolateDocumentSyncBatchError(input: {\n cause: unknown;\n stage: DocumentSyncUpdateIsolationStage;\n updateIds: readonly string[];\n}): DocumentSyncUpdateIsolationError {\n return new DocumentSyncUpdateIsolationError({\n batchUpdateIds: input.updateIds,\n cause: input.cause,\n stage: input.stage,\n updateId: null,\n });\n}\n\nexport function isolateDocumentSyncUpdateError(input: {\n cause: unknown;\n responseUpdate?: SyncResponseUpdate | undefined;\n stage: DocumentSyncUpdateIsolationStage;\n updateId: string;\n}): DocumentSyncUpdateIsolationError {\n return input.cause instanceof DocumentSyncUpdateIsolationError\n ? input.cause\n : new DocumentSyncUpdateIsolationError(input);\n}\n\nexport function isDocumentSyncUpdateIsolationError(\n error: unknown,\n): error is DocumentSyncUpdateIsolationError {\n return error instanceof DocumentSyncUpdateIsolationError;\n}\n\nfunction responseUpdatesById(\n updates: readonly SyncResponseUpdate[] | undefined,\n): ReadonlyMap<string, SyncResponseUpdate> {\n return new Map((updates ?? []).map((update) => [update.id, update]));\n}\n\nfunction firstDuplicateUpdateId(\n updates: readonly { readonly id: string }[],\n): string | null {\n const seen = new Set<string>();\n for (const update of updates) {\n if (seen.has(update.id)) return update.id;\n seen.add(update.id);\n }\n return null;\n}\n\nfunction assertImportedUpdatesMatchValidatedHistory(input: {\n document: SyncDocument;\n responseById: ReadonlyMap<string, SyncResponseUpdate>;\n updates: readonly DecryptedDocumentSyncUpdate[];\n}): void {\n const collisions = input.updates.filter(\n (update) =>\n !updateMatchesDocumentHistory(input.document, update.updateData),\n );\n if (collisions.length === 0) return;\n const cause = new Error(\n \"incoming Loro update reuses an already-covered frontier with different operations\",\n );\n const [collision] = collisions;\n if (input.updates.length === 1 && collision) {\n throw isolateDocumentSyncUpdateError({\n cause,\n responseUpdate: input.responseById.get(collision.id),\n stage: \"loro_import\",\n updateId: collision.id,\n });\n }\n throw isolateDocumentSyncBatchError({\n cause,\n stage: \"loro_import\",\n updateIds: input.updates.map((update) => update.id),\n });\n}\n\nasync function createValidationDocument(snapshot: Uint8Array) {\n const document = await createDocument(crypto.randomUUID());\n try {\n importSnapshot(document, snapshot);\n return document;\n } catch (error) {\n document.free();\n throw error;\n }\n}\n\nfunction splitDocumentSyncUpdates(\n updates: readonly DecryptedDocumentSyncUpdate[],\n): {\n checkpoints: DecryptedDocumentSyncUpdate[];\n ordinaryUpdates: DecryptedDocumentSyncUpdate[];\n} {\n const checkpoints: DecryptedDocumentSyncUpdate[] = [];\n const ordinaryUpdates: DecryptedDocumentSyncUpdate[] = [];\n for (const update of updates) {\n if (\n update.checkpointKind === \"rotate_baseline\" &&\n update.checkpointPayloadKind === \"full_history_snapshot\"\n ) {\n checkpoints.push(update);\n } else {\n ordinaryUpdates.push(update);\n }\n }\n return { checkpoints, ordinaryUpdates };\n}\n\n/** Applies checkpoints with the snapshot API before batching ordinary deltas. */\nexport function importDecryptedDocumentSyncUpdates(\n document: SyncDocument,\n updates: readonly DecryptedDocumentSyncUpdate[],\n): void {\n const { checkpoints, ordinaryUpdates } = splitDocumentSyncUpdates(updates);\n for (const checkpoint of checkpoints) {\n importSnapshot(document, checkpoint.updateData);\n }\n if (ordinaryUpdates.length > 0) {\n importUpdates(\n document,\n ordinaryUpdates.map((update) => update.updateData),\n );\n }\n}\n\nasync function validateDecryptedUpdateBatch(input: {\n currentSnapshot: Uint8Array;\n responseById?: ReadonlyMap<string, SyncResponseUpdate> | undefined;\n updates: readonly DecryptedDocumentSyncUpdate[];\n}): Promise<void> {\n const document = await createValidationDocument(input.currentSnapshot);\n try {\n const { checkpoints, ordinaryUpdates } = splitDocumentSyncUpdates(\n input.updates,\n );\n for (const checkpoint of checkpoints) {\n importSnapshot(document, checkpoint.updateData);\n }\n if (ordinaryUpdates.length > 0) {\n importUpdates(\n document,\n ordinaryUpdates.map((update) => update.updateData),\n );\n }\n if (input.responseById) {\n // Validate against the completed scratch history, not only the live\n // pre-page frontier. If two updates in this page reuse one peer/counter\n // with different operations, Loro accepts one and treats the other as a\n // no-op; only the accepted history can match both when they are equal.\n assertImportedUpdatesMatchValidatedHistory({\n document,\n responseById: input.responseById,\n updates: input.updates,\n });\n }\n } finally {\n document.free();\n }\n}\n\nfunction exactIsolationRetryExceedsBudget(input: {\n candidates: readonly DecryptedDocumentSyncUpdate[];\n currentSnapshot: Uint8Array;\n}): boolean {\n if (input.candidates.length > MAX_EXACT_ISOLATION_CANDIDATES) return true;\n\n let retryBytes = 0;\n for (const candidateIndex of input.candidates.keys()) {\n if (\n input.currentSnapshot.byteLength >\n MAX_EXACT_ISOLATION_RETRY_BYTES - retryBytes\n ) {\n return true;\n }\n retryBytes += input.currentSnapshot.byteLength;\n for (const [updateIndex, update] of input.candidates.entries()) {\n if (updateIndex === candidateIndex) continue;\n if (\n update.updateData.byteLength >\n MAX_EXACT_ISOLATION_RETRY_BYTES - retryBytes\n ) {\n return true;\n }\n retryBytes += update.updateData.byteLength;\n }\n }\n return false;\n}\n\n/** @internal Exported only to exercise the bounded exact-attribution policy. */\nexport async function findUniqueRepairingCandidate<T>(\n candidates: readonly T[],\n repairsBatch: (candidate: T, candidateIndex: number) => Promise<boolean>,\n): Promise<T | null> {\n let repairingCandidate: T | null = null;\n let repairingCandidateCount = 0;\n for (const [candidateIndex, candidate] of candidates.entries()) {\n if (await repairsBatch(candidate, candidateIndex)) {\n repairingCandidate = candidate;\n repairingCandidateCount += 1;\n }\n }\n return repairingCandidateCount === 1 ? repairingCandidate : null;\n}\n\n/**\n * Proves that a decrypted response can be imported before the live document or\n * any durable sync frontier is mutated. On failure, retries the page without\n * each candidate so valid sibling dependencies remain in the same batch while\n * the update whose removal repairs the batch is attributed exactly.\n */\nexport async function validateDocumentSyncUpdateImports(input: {\n currentDocument: Awaited<ReturnType<typeof createDocument>>;\n decryptedUpdates: readonly DecryptedDocumentSyncUpdate[];\n responseUpdates?: readonly SyncResponseUpdate[] | undefined;\n}): Promise<void> {\n if (input.decryptedUpdates.length === 0) return;\n\n const duplicateUpdateId =\n firstDuplicateUpdateId(input.decryptedUpdates) ??\n firstDuplicateUpdateId(input.responseUpdates ?? []);\n if (duplicateUpdateId !== null) {\n throw isolateDocumentSyncBatchError({\n cause: new Error(\n `Document sync response update id is duplicated: ${duplicateUpdateId}`,\n ),\n stage: \"encrypted_record\",\n updateIds: (input.responseUpdates ?? input.decryptedUpdates).map(\n (update) => update.id,\n ),\n });\n }\n\n const currentSnapshot = exportFullHistorySnapshot(input.currentDocument);\n const responseById = responseUpdatesById(input.responseUpdates);\n let batchError: unknown;\n try {\n await validateDecryptedUpdateBatch({\n currentSnapshot,\n responseById,\n updates: input.decryptedUpdates,\n });\n return;\n } catch (error) {\n if (isDocumentSyncUpdateIsolationError(error)) throw error;\n batchError = error;\n }\n\n // A delta can be valid but depend on a parent omitted from this response\n // page. Removing that delta would make an empty retry succeed and falsely\n // identify its authenticated writer as poison, so dependency gaps remain\n // anonymous at batch scope.\n if (batchError instanceof LoroImportUnresolvedDependenciesError) {\n throw isolateDocumentSyncBatchError({\n cause: batchError,\n stage: \"loro_import\",\n updateIds: input.decryptedUpdates.map((update) => update.id),\n });\n }\n\n if (\n exactIsolationRetryExceedsBudget({\n candidates: input.decryptedUpdates,\n currentSnapshot,\n })\n ) {\n throw isolateDocumentSyncBatchError({\n cause: batchError,\n stage: \"loro_import\",\n updateIds: input.decryptedUpdates.map((update) => update.id),\n });\n }\n\n // Rebuild from the same immutable snapshot for every candidate: a failed\n // import may partially mutate its scratch document. Checkpoints participate\n // alongside ordinary updates so an incompatibility between the two kinds\n // cannot falsely blame the ordinary writer. Keeping every other update in\n // one batch also preserves out-of-order sibling dependencies.\n const isolatedUpdate = await findUniqueRepairingCandidate(\n input.decryptedUpdates,\n async (_update, candidateIndex) => {\n const withoutCandidate = input.decryptedUpdates.filter(\n (_, updateIndex) => updateIndex !== candidateIndex,\n );\n try {\n await validateDecryptedUpdateBatch({\n currentSnapshot,\n updates: withoutCandidate,\n });\n return true;\n } catch {\n // This candidate is either valid and required by a sibling, or another\n // poison update remains. Continue without attributing it.\n return false;\n }\n },\n );\n if (isolatedUpdate) {\n throw isolateDocumentSyncUpdateError({\n cause: batchError,\n responseUpdate: responseById.get(isolatedUpdate.id),\n stage: \"loro_import\",\n updateId: isolatedUpdate.id,\n });\n }\n\n // Multiple bad updates or a batch-level incompatibility may have zero or\n // multiple removals that repair the page. Fail closed without falsely naming\n // a valid writer; no live or durable state has changed.\n throw isolateDocumentSyncBatchError({\n cause: batchError,\n stage: \"loro_import\",\n updateIds: input.decryptedUpdates.map((update) => update.id),\n });\n}\n"]}
|
package/data/documents/shared/{mutationAcknowledgement.js → sync/mutationAcknowledgement.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { advanceLocallyAcknowledgedAccessManifestHeadsAtomically, locallyAuthoredAccessManifestHead, } from "
|
|
1
|
+
import { advanceLocallyAcknowledgedAccessManifestHeadsAtomically, locallyAuthoredAccessManifestHead, } from "../../../persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.js";
|
|
2
2
|
/** Advances a document head only after its response was matched to this plan. */
|
|
3
3
|
export async function acknowledgeDocumentMutation(input) {
|
|
4
4
|
await advanceLocallyAcknowledgedAccessManifestHeadsAtomically({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutationAcknowledgement.js","sourceRoot":"","sources":["mutationAcknowledgement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uDAAuD,EACvD,iCAAiC,GAClC,MAAM,iFAAiF,CAAC;AAGzF,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAIjD;IACC,MAAM,uDAAuD,CAAC;QAC5D,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,CAAC,iCAAiC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtD,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n advanceLocallyAcknowledgedAccessManifestHeadsAtomically,\n locallyAuthoredAccessManifestHead,\n} from \"../../../persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence\";\nimport type { ExecSql } from \"../../../sqlite/sqlSchema\";\n\n/** Advances a document head only after its response was matched to this plan. */\nexport async function acknowledgeDocumentMutation(input: {\n readonly execSql: ExecSql;\n readonly plan: Parameters<typeof locallyAuthoredAccessManifestHead>[0];\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<void> {\n await advanceLocallyAcknowledgedAccessManifestHeadsAtomically({\n execSql: input.execSql,\n heads: [locallyAuthoredAccessManifestHead(input.plan)],\n stillCurrent: input.stillCurrent,\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isWalLsnString, MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH, } from "
|
|
1
|
+
import { isWalLsnString, MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH, } from "../../../../internal/validators/util/index.js";
|
|
2
2
|
export function documentSyncPullContinuationsEqual(left, right) {
|
|
3
3
|
if (!left || !right)
|
|
4
4
|
return left == null && right == null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DocumentSyncResponse } from "
|
|
1
|
+
import type { DocumentSyncResponse } from "../../../../internal/validators/response/index.js";
|
|
2
|
+
import type { DocumentSyncApi, DocumentSyncPlan, DocumentSyncSubmitFailure } from "../types.js";
|
|
2
3
|
import type { DocumentSyncCommitLsnMode, DocumentSyncPullContinuation } from "./pullContinuation.js";
|
|
3
|
-
import type { DocumentSyncApi, DocumentSyncPlan, DocumentSyncSubmitFailure } from "./types.js";
|
|
4
4
|
export type { DocumentSyncCommitLsnMode, DocumentSyncPullContinuation, } from "./pullContinuation.js";
|
|
5
5
|
export { documentSyncPullContinuationsEqual } from "./pullContinuation.js";
|
|
6
6
|
export declare class InvalidDocumentSyncPullContinuationError extends Error {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseWalLsn } from "
|
|
1
|
+
import { parseWalLsn } from "../../../../internal/validators/util/index.js";
|
|
2
2
|
export { documentSyncPullContinuationsEqual } from "./pullContinuation.js";
|
|
3
3
|
export class InvalidDocumentSyncPullContinuationError extends Error {
|
|
4
4
|
constructor(message) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncPagination.js","sourceRoot":"","sources":["syncPagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAezD,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AAExE,MAAM,OAAO,wCAAyC,SAAQ,KAAK;IACjE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0CAA0C,CAAC;IACzD,CAAC;CACF;AAmBD,MAAM,UAAU,oBAAoB,CAClC,QAA8B;IAE9B,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,UAAU,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,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,CAAC;IACH,IAAI,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,IAAI,wCAAwC,CAChD,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxE,MAAM,IAAI,wCAAwC,CAChD,mDAAmD,CACpD,CAAC;IACJ,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,YAAY,EAAE,UAAU,KAAK,IAAI;QACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAIxC;IACC,OAAO,sBAAsB,CAAC;QAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;QAClD,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,kBAAkB,CACrD,KAAK,CAAC,IAAI,CAAC,UAAU,EACrB,KAAK,CAAC,IAAI,CAAC,OAAO,EAClB;gBACE,qCAAqC,EAAE,KAAK,CAAC,IAAI,CAAC,cAAc;gBAChE,YAAY,EAAE,KAAK;aACpB,CACF,CAAC;YACF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAClE,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DocumentSyncResponse } from \"@tearleads/validators/response\";\nimport { parseWalLsn } from \"@tearleads/validators/util\";\nimport type {\n DocumentSyncApi,\n DocumentSyncPlan,\n DocumentSyncSubmitFailure,\n} from \"../types\";\nimport type {\n DocumentSyncCommitLsnMode,\n DocumentSyncPullContinuation,\n} from \"./pullContinuation\";\n\nexport type {\n DocumentSyncCommitLsnMode,\n DocumentSyncPullContinuation,\n} from \"./pullContinuation\";\nexport { documentSyncPullContinuationsEqual } from \"./pullContinuation\";\n\nexport class InvalidDocumentSyncPullContinuationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidDocumentSyncPullContinuationError\";\n }\n}\n\ntype DocumentSyncPageSubmission =\n | {\n readonly ok: true;\n readonly response: DocumentSyncResponse;\n }\n | DocumentSyncSubmitFailure\n | null;\n\ntype DocumentSyncSubmission =\n | {\n readonly ok: true;\n readonly pullComplete: boolean;\n readonly response: DocumentSyncResponse;\n }\n | DocumentSyncSubmitFailure\n | null;\n\nexport function readPullContinuation(\n response: DocumentSyncResponse,\n): DocumentSyncPullContinuation | null {\n const cursor = requirePullPage(response).nextCursor;\n if (cursor === null) return null;\n if (response.commitLsn === null) {\n throw new Error(\n \"Document sync pull continuation is missing its checkpoint\",\n );\n }\n return {\n commitLsn: response.commitLsn,\n commitLsnMode: response.commitLsnMode,\n cursor,\n };\n}\n\nexport function resolvePullContinuationMinLsn(\n continuation: DocumentSyncPullContinuation | undefined,\n fallback: string | undefined,\n): string | undefined {\n if (!continuation) return fallback;\n if (continuation.commitLsnMode === \"untracked\" || fallback === undefined) {\n return continuation.commitLsn;\n }\n return parseWalLsn(continuation.commitLsn) >= parseWalLsn(fallback)\n ? continuation.commitLsn\n : fallback;\n}\n\nfunction assertPageCheckpoint(input: {\n readonly minLsn: string | undefined;\n readonly nextCursor: string | null;\n readonly response: DocumentSyncResponse;\n}): void {\n if (input.response.commitLsnMode === \"untracked\") {\n if (input.response.commitLsn !== \"0/0\") {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync continuation untracked LSN is invalid\",\n );\n }\n return;\n }\n if (input.response.commitLsn === null) {\n if (input.minLsn === undefined && input.nextCursor === null) return;\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync pull continuation is missing its checkpoint\",\n );\n }\n let responseLsn: bigint;\n try {\n responseLsn = parseWalLsn(input.response.commitLsn);\n } catch {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync continuation commit LSN is invalid\",\n );\n }\n if (input.minLsn === undefined) return;\n let minimumLsn: bigint;\n try {\n minimumLsn = parseWalLsn(input.minLsn);\n } catch {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync minimum commit LSN is invalid\",\n );\n }\n if (responseLsn < minimumLsn) {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync continuation commit LSN regressed\",\n );\n }\n}\n\nfunction requirePullPage(response: DocumentSyncResponse) {\n if (response.pullPage === undefined) {\n throw new Error(\"Document sync response is missing pull page metadata\");\n }\n return response.pullPage;\n}\n\nasync function submitDocumentSyncPage(input: {\n readonly expectedCommitLsnMode?: DocumentSyncCommitLsnMode | undefined;\n readonly plan: DocumentSyncPlan;\n readonly submit: () => Promise<DocumentSyncPageSubmission>;\n}): Promise<DocumentSyncSubmission> {\n const page = await input.submit();\n if (!page?.ok) return page;\n if (\n input.expectedCommitLsnMode !== undefined &&\n page.response.commitLsnMode !== input.expectedCommitLsnMode\n ) {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync continuation commit LSN mode changed\",\n );\n }\n const nextCursor = requirePullPage(page.response).nextCursor;\n assertPageCheckpoint({\n minLsn: input.plan.request.minLsn,\n nextCursor,\n response: page.response,\n });\n if (nextCursor !== null && page.response.commitLsn === null) {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync pull continuation is missing its checkpoint\",\n );\n }\n if (nextCursor !== null && nextCursor === input.plan.request.pullCursor) {\n throw new InvalidDocumentSyncPullContinuationError(\n \"Document sync continuation cursor did not advance\",\n );\n }\n return {\n ok: true,\n pullComplete: nextCursor === null,\n response: page.response,\n };\n}\n\nexport async function submitDocumentSync(input: {\n apiClient: DocumentSyncApi;\n expectedCommitLsnMode?: DocumentSyncCommitLsnMode | undefined;\n plan: DocumentSyncPlan;\n}): Promise<DocumentSyncSubmission> {\n return submitDocumentSyncPage({\n expectedCommitLsnMode: input.expectedCommitLsnMode,\n plan: input.plan,\n submit: async () => {\n const result = await input.apiClient.syncDocumentResult(\n input.plan.documentId,\n input.plan.request,\n {\n expectedPaymentRequiredOrganizationId: input.plan.organizationId,\n reportErrors: false,\n },\n );\n return result.ok ? { ok: true, response: result.data } : result;\n },\n });\n}\n"]}
|
package/data/documents/shared/{syncResponseAuthorization.js → sync/syncResponseAuthorization.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computeDocumentContentKeyTargetHash, makeVerifiedDocumentKekTargets, } from "
|
|
2
|
-
import { resolveEventContainerPaths } from "
|
|
3
|
-
import { sortDocumentTargets } from "
|
|
1
|
+
import { computeDocumentContentKeyTargetHash, makeVerifiedDocumentKekTargets, } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import { resolveEventContainerPaths } from "../../../keyingProjectionVerification/document/documentDependencyPaths.js";
|
|
3
|
+
import { sortDocumentTargets } from "../readers.js";
|
|
4
4
|
export async function documentWriteAuthorizationForHeader(input) {
|
|
5
5
|
const source = input.plan.documentWriterAuthorization;
|
|
6
6
|
if (!source) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncResponseAuthorization.js","sourceRoot":"","sources":["syncResponseAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EAEnC,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wEAAwE,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,KAWzD;IACC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACtD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,KAAK,C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entContentKeyTarget,\n makeVerifiedDocumentKekTargets,\n} from \"@tearleads/crypto\";\nimport type { DocumentSyncResponse } from \"@tearleads/validators/response\";\nimport { resolveEventContainerPaths } from \"../../../keyingProjectionVerification/document/documentDependencyPaths\";\nimport { sortDocumentTargets } from \"../readers\";\nimport type { DocumentSyncPlan } from \"../types\";\n\nexport async function documentWriteAuthorizationForHeader(input: {\n readonly allowMissingAuthorization: boolean;\n readonly dependencyManifestHashes: readonly string[];\n readonly authorizationTargets: readonly DocumentContentKeyTarget[];\n readonly contentKeyBundle: DocumentSyncResponse[\"contentKeyBundle\"];\n readonly manifestHash: string;\n readonly plan: Pick<\n DocumentSyncPlan,\n \"documentId\" | \"organizationId\" | \"documentWriterAuthorization\"\n >;\n readonly targetHash: string;\n}) {\n const source = input.plan.documentWriterAuthorization;\n if (!source) {\n if (input.allowMissingAuthorization) {\n return null;\n }\n throw new Error(\n \"Document sync response lacks verified writer-authorization material\",\n );\n }\n const documentManifest = source.documentManifestByHash.get(\n input.manifestHash,\n );\n if (!documentManifest) {\n throw new Error(\n \"Document sync response write manifest is not in verified history\",\n );\n }\n if (input.contentKeyBundle.documentId !== input.plan.documentId) {\n throw new Error(\n \"Document sync response content-key bundle belongs to another document\",\n );\n }\n\n const targets = sortDocumentTargets(input.authorizationTargets);\n if (\n (await computeDocumentContentKeyTargetHash(targets)) !== input.targetHash\n ) {\n throw new Error(\"Document sync response write targets are not canonical\");\n }\n const linkedContainerIds = new Set(documentManifest.state.linkedContainerIds);\n if (\n targets.length !== linkedContainerIds.size ||\n targets.some((target) => !linkedContainerIds.has(target.containerId))\n ) {\n throw new Error(\n \"Document sync response write targets do not match the signed link set\",\n );\n }\n\n const { dependencyContainerPaths } = resolveEventContainerPaths({\n containerPathByManifestHash: source.containerPathByManifestHash,\n dependencyManifestHashes: input.dependencyManifestHashes,\n });\n // A writer needs one committed target, and can be unable to read another\n // linked container. Validate the targets that are cited without inventing\n // paths for uncited targets or dropping signed ancestor evidence.\n for (const target of targets) {\n const path = dependencyContainerPaths.find(\n (candidate) =>\n candidate.at(-1)?.manifestHash === target.containerManifestHash,\n );\n if (!path) continue;\n const leaf = path.at(-1);\n if (\n !leaf ||\n leaf.state.containerId !== target.containerId ||\n leaf.state.organizationId !== input.plan.organizationId ||\n leaf.state.containerKeyEpochId !== target.containerKeyEpochId\n ) {\n throw new Error(\n \"Document sync response write target lacks a verified container path\",\n );\n }\n }\n const authorizingContainerPaths = dependencyContainerPaths;\n const documentKekTargets = makeVerifiedDocumentKekTargets({\n documentId: input.contentKeyBundle.documentId,\n documentKeyTargetHash: input.targetHash,\n linkedContainerKeyEpochIds: targets.map(\n (target) => target.containerKeyEpochId,\n ),\n linkedContainerManifestHashes: targets.map(\n (target) => target.containerManifestHash,\n ),\n linkSetManifestHash: input.manifestHash,\n targets,\n });\n return {\n authorizingContainerPaths,\n documentKekTargets,\n documentManifest,\n principalPolicies: source.principalPolicies,\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type DocumentSyncResponse } from "
|
|
1
|
+
import { type DocumentSyncResponse } from "../../../../internal/validators/response/index.js";
|
|
2
2
|
export { submitDocumentSync } from "./syncPagination.js";
|
|
3
|
-
import type { DocumentSyncPlan, DocumentSyncSubmitFailure, DocumentWriterPublicKeyResolver, PersistedDocumentSyncState } from "
|
|
3
|
+
import type { DocumentSyncPlan, DocumentSyncSubmitFailure, DocumentWriterPublicKeyResolver, PersistedDocumentSyncState } from "../types.js";
|
|
4
4
|
export declare class DocumentSyncResponseUpdateContentKeyError extends Error {
|
|
5
5
|
constructor(message: string);
|
|
6
6
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CONTENT_RECORD_ENCRYPTION_SUITE, computeContentRecordNonceDomainHash, computeDocumentContentRecordCiphertextHash, computeDocumentContentRecordMetadataHash, verifyWriteHeader, } from "
|
|
2
|
-
import { isPlainObject as isPlainRecord } from "
|
|
3
|
-
import { DOCUMENT_NOT_FOUND_ERROR_CODE, DOCUMENT_SYNC_ERROR_CODES, } from "
|
|
4
|
-
import { parseWalLsn } from "
|
|
5
|
-
import { throwKeyingVerificationShapeFailure } from "
|
|
6
|
-
import { readRecordPositiveInteger, readRecordString, readWriteHeader, serializeCanonical, serializedPersistedDocumentState, } from "
|
|
1
|
+
import { CONTENT_RECORD_ENCRYPTION_SUITE, computeContentRecordNonceDomainHash, computeDocumentContentRecordCiphertextHash, computeDocumentContentRecordMetadataHash, verifyWriteHeader, } from "../../../../internal/crypto/index.js";
|
|
2
|
+
import { isPlainObject as isPlainRecord } from "../../../../internal/validators/isPlainObject.js";
|
|
3
|
+
import { DOCUMENT_NOT_FOUND_ERROR_CODE, DOCUMENT_SYNC_ERROR_CODES, } from "../../../../internal/validators/response/index.js";
|
|
4
|
+
import { parseWalLsn } from "../../../../internal/validators/util/index.js";
|
|
5
|
+
import { throwKeyingVerificationShapeFailure } from "../../../keyingProjectionVerification/error.js";
|
|
6
|
+
import { readRecordPositiveInteger, readRecordString, readWriteHeader, serializeCanonical, serializedPersistedDocumentState, } from "../readers.js";
|
|
7
7
|
export { submitDocumentSync } from "./syncPagination.js";
|
|
8
8
|
import { documentWriteAuthorizationForHeader } from "./syncResponseAuthorization.js";
|
|
9
9
|
// Remote-primary databases without a portable WAL position use the zero LSN
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncResponses.js","sourceRoot":"","sources":["syncResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,0CAA0C,EAC1C,wCAAwC,EACxC,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,mCAAmC,EAAE,MAA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umentContentRecordCiphertextHash,\n computeDocumentContentRecordMetadataHash,\n verifyWriteHeader,\n type WriteHeader,\n} from \"@tearleads/crypto\";\nimport { isPlainObject as isPlainRecord } from \"@tearleads/validators/isPlainObject\";\nimport {\n DOCUMENT_NOT_FOUND_ERROR_CODE,\n DOCUMENT_SYNC_ERROR_CODES,\n type DocumentSyncResponse,\n} from \"@tearleads/validators/response\";\nimport { parseWalLsn } from \"@tearleads/validators/util\";\nimport { throwKeyingVerificationShapeFailure } from \"../../../keyingProjectionVerification/error\";\nimport {\n readRecordPositiveInteger,\n readRecordString,\n readWriteHeader,\n serializeCanonical,\n serializedPersistedDocumentState,\n} from \"../readers\";\n\nexport { submitDocumentSync } from \"./syncPagination\";\n\nimport type {\n DocumentSyncPlan,\n DocumentSyncSubmitFailure,\n DocumentWriterPublicKeyResolver,\n PersistedDocumentSyncState,\n} from \"../types\";\nimport { documentWriteAuthorizationForHeader } from \"./syncResponseAuthorization\";\n\n// Remote-primary databases without a portable WAL position use the zero LSN\n// as an explicit \"checkpoint not tracked\" sentinel. It is accepted only when\n// the response declares that mode, letting a local record carrying a checkpoint\n// from another backend move to that primary without weakening tracked checks.\n// This protects against replica lag, not a server that falsely declares its own\n// consistency capability; the authenticated server remains the source of data.\nconst UNTRACKED_COMMIT_LSN = \"0/0\";\n\nexport class DocumentSyncResponseUpdateContentKeyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DocumentSyncResponseUpdateContentKeyError\";\n }\n}\n\nfunction assertAcceptedOutgoingUpdateIdsMatchPlan(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n): void {\n const expected = plan.request.outgoingUpdates.map((update) => update.id);\n const accepted = response.acceptedOutgoingUpdateIds;\n const expectedSorted = [...expected].sort();\n const acceptedSorted = [...accepted].sort();\n if (\n expectedSorted.length !== acceptedSorted.length ||\n expectedSorted.some((id, index) => id !== acceptedSorted[index])\n ) {\n throw new Error(\"Document sync response accepted update mismatch\");\n }\n}\n\nasync function assertDocumentSyncResponseUpdateMatchesPlan(input: {\n contentKeyBundlesByEpoch: ReadonlyMap<\n number,\n DocumentSyncResponse[\"contentKeyBundle\"]\n >;\n plan: DocumentSyncPlan;\n update: DocumentSyncResponse[\"updates\"][number];\n resolveWriterPublicKey: DocumentWriterPublicKeyResolver;\n}): Promise<void> {\n const { plan, update } = input;\n if (update.documentId !== plan.documentId) {\n throw new Error(\"Document sync response update document mismatch\");\n }\n const header = readWriteHeader(\n update.writeHeader,\n \"Document sync response write header\",\n );\n await assertDocumentSyncResponseUpdateHashes({ update });\n const contentKeyBundle = assertDocumentSyncResponseUpdateContentKeyBundle({\n contentKeyBundlesByEpoch: input.contentKeyBundlesByEpoch,\n header,\n plan,\n });\n assertDocumentSyncResponseWriteHeaderFields({ header, plan, update });\n await assertDocumentSyncResponseNonceDomain({ header, plan });\n await assertDocumentSyncResponseWriteHeaderSignature({\n header,\n contentKeyBundle,\n plan,\n resolveWriterPublicKey: input.resolveWriterPublicKey,\n update,\n });\n}\n\nfunction assertDocumentSyncResponseUpdateContentKeyBundle(input: {\n contentKeyBundlesByEpoch: ReadonlyMap<\n number,\n DocumentSyncResponse[\"contentKeyBundle\"]\n >;\n header: WriteHeader;\n plan: DocumentSyncPlan;\n}): DocumentSyncResponse[\"contentKeyBundle\"] {\n const { header, plan } = input;\n if (header.contentKeyEpoch > plan.contentKeyEpoch) {\n throw new DocumentSyncResponseUpdateContentKeyError(\n \"Document sync response includes a future content-key epoch\",\n );\n }\n\n const bundle = input.contentKeyBundlesByEpoch.get(header.contentKeyEpoch);\n if (!bundle) {\n throw new DocumentSyncResponseUpdateContentKeyError(\n \"Document sync response content-key bundle missing\",\n );\n }\n if (\n bundle.documentId !== plan.documentId ||\n bundle.contentKeyEpoch !== header.contentKeyEpoch\n ) {\n throw new Error(\"Document sync response content-key bundle mismatch\");\n }\n return bundle;\n}\n\nasync function assertDocumentSyncResponseUpdateHashes(input: {\n update: DocumentSyncResponse[\"updates\"][number];\n}): Promise<void> {\n const { update } = input;\n const ciphertextHash = await computeDocumentContentRecordCiphertextHash(\n update.encryptedData,\n );\n if (\n ciphertextHash !==\n readRecordString(update.writeHeader, \"ciphertextHash\", \"write header\")\n ) {\n throw new Error(\"Document sync response ciphertext hash mismatch\");\n }\n const metadataHash = await computeDocumentContentRecordMetadataHash({\n ...(update.checkpointKind === undefined\n ? {}\n : { checkpointKind: update.checkpointKind }),\n ...(update.checkpointPayloadKind === undefined\n ? {}\n : { checkpointPayloadKind: update.checkpointPayloadKind }),\n documentId: update.documentId,\n partialEndVersionVector: update.partialEndVersionVector,\n partialStartVersionVector: update.partialStartVersionVector,\n plaintextHash: update.plaintextHash,\n ...(update.sourceVersionVector === undefined\n ? {}\n : { sourceVersionVector: update.sourceVersionVector }),\n updateId: update.id,\n });\n if (\n metadataHash !==\n readRecordString(update.writeHeader, \"metadataHash\", \"write header\")\n ) {\n throw new Error(\"Document sync response metadata hash mismatch\");\n }\n}\n\nfunction assertDocumentSyncResponseWriteHeaderFields(input: {\n header: WriteHeader;\n plan: DocumentSyncPlan;\n update: DocumentSyncResponse[\"updates\"][number];\n}): void {\n const { header, plan, update } = input;\n const mustMatchCurrentBoundary = isAcceptedOutgoingSyncUpdate(plan, update);\n\n if (\n header.version !== 1 ||\n header.objectKind !== \"document\" ||\n header.objectId !== plan.documentId ||\n header.organizationId !== plan.organizationId ||\n header.encryptionSuite !== CONTENT_RECORD_ENCRYPTION_SUITE ||\n header.writerKeyFingerprint !== update.authorFingerprint ||\n (mustMatchCurrentBoundary &&\n (header.contentKeyEpoch !== plan.contentKeyEpoch ||\n header.accessManifestHash !== plan.expectedLinkSetManifestHash ||\n header.targetHash !== plan.expectedTargetHash))\n ) {\n throw new Error(\"Document sync response write header mismatch\");\n }\n}\n\nfunction isAcceptedOutgoingSyncUpdate(\n plan: DocumentSyncPlan,\n update: DocumentSyncResponse[\"updates\"][number],\n): boolean {\n return plan.request.outgoingUpdates.some(\n (outgoingUpdate) => outgoingUpdate.id === update.id,\n );\n}\n\nasync function assertDocumentSyncResponseNonceDomain(input: {\n header: WriteHeader;\n plan: DocumentSyncPlan;\n}): Promise<void> {\n const { header, plan } = input;\n const nonceDomainHash = await computeContentRecordNonceDomainHash({\n version: 1,\n organizationId: plan.organizationId,\n objectKind: \"document\",\n objectId: plan.documentId,\n contentKeyEpoch: header.contentKeyEpoch,\n encryptionSuite: CONTENT_RECORD_ENCRYPTION_SUITE,\n contentRecordId: header.contentRecordId,\n });\n if (nonceDomainHash !== header.nonceDomainHash) {\n throw new Error(\"Document sync response nonce domain mismatch\");\n }\n}\n\nasync function assertDocumentSyncResponseWriteHeaderSignature(input: {\n contentKeyBundle: DocumentSyncResponse[\"contentKeyBundle\"];\n header: WriteHeader;\n plan: DocumentSyncPlan;\n resolveWriterPublicKey: DocumentWriterPublicKeyResolver;\n update: DocumentSyncResponse[\"updates\"][number];\n}): Promise<void> {\n const { header, plan, update } = input;\n const writerPublicKey = await input.resolveWriterPublicKey({\n writerSigningKeyFingerprint: header.writerKeyFingerprint,\n writerUserId: header.writerUserId,\n });\n if (!writerPublicKey) {\n throw new Error(\"Document sync response writer public key missing\");\n }\n\n const documentAuthorization = await documentWriteAuthorizationForHeader({\n allowMissingAuthorization: isAcceptedOutgoingSyncUpdate(plan, update),\n authorizationTargets: update.authorizationTargets,\n dependencyManifestHashes: header.dependencyManifestHashes,\n contentKeyBundle: input.contentKeyBundle,\n manifestHash: header.accessManifestHash,\n plan,\n targetHash: header.targetHash,\n });\n const verified = await verifyWriteHeader({\n authorizationMembership: \"referenced\",\n expectedAccessManifestHash: documentAuthorization\n ? header.accessManifestHash\n : plan.expectedLinkSetManifestHash,\n expectedObject: {\n objectKind: \"document\",\n objectId: plan.documentId,\n organizationId: plan.organizationId,\n },\n header,\n ...(documentAuthorization ? { documentAuthorization } : {}),\n expectedTargetHash: documentAuthorization\n ? header.targetHash\n : plan.expectedTargetHash,\n writerPublicKey,\n });\n if (!verified.ok) {\n throw verified.error;\n }\n}\n\nfunction assertDocumentSyncCommitCheckpointMatchesPlan(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n): void {\n if (\n response.commitLsnMode === \"untracked\" &&\n response.commitLsn !== UNTRACKED_COMMIT_LSN\n ) {\n throw new Error(\n \"Document sync response untracked commit LSN must use the 0/0 sentinel\",\n );\n }\n if (\n response.commitLsn === UNTRACKED_COMMIT_LSN &&\n response.commitLsnMode !== \"untracked\"\n ) {\n throw new Error(\n \"Document sync response 0/0 commit LSN must be declared untracked\",\n );\n }\n if (response.commitLsn !== null) {\n parseWalLsn(response.commitLsn, \"Document sync response commit LSN\");\n }\n if (plan.minLsn === undefined) {\n return;\n }\n const minLsn = parseWalLsn(\n plan.minLsn,\n \"Document sync requested minimum LSN\",\n );\n if (response.commitLsn === null) {\n throw new Error(\"Document sync response commit LSN is missing\");\n }\n if (\n !(\n response.commitLsn === UNTRACKED_COMMIT_LSN &&\n response.commitLsnMode === \"untracked\"\n ) &&\n parseWalLsn(response.commitLsn, \"Document sync response commit LSN\") <\n minLsn\n ) {\n throw new Error(\"Document sync response commit LSN is stale\");\n }\n}\n\nfunction documentSyncManifestEpoch(plan: DocumentSyncPlan): number {\n if (!isPlainRecord(plan.documentManifest.state)) {\n throw new Error(\"Document sync manifest state is invalid\");\n }\n\n return readRecordPositiveInteger(\n plan.documentManifest.state,\n \"epoch\",\n \"Document sync manifest state\",\n );\n}\n\n// The one load-bearing epoch check: no returned update may claim an\n// accessEpoch newer than the current manifest epoch.\nfunction assertDocumentSyncAccessEpochsNotInFuture(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n): void {\n const currentAccessEpoch = documentSyncManifestEpoch(plan);\n for (const update of response.updates) {\n if (update.accessEpoch > currentAccessEpoch) {\n throw new Error(\"Document sync response includes a future access epoch\");\n }\n }\n}\n\nfunction contentKeyBundleCanonical(\n bundle: DocumentSyncResponse[\"contentKeyBundle\"],\n): string {\n return serializeCanonical(bundle, \"content-key bundle\");\n}\n\nfunction documentSyncContentKeyBundlesByEpoch(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n): ReadonlyMap<number, DocumentSyncResponse[\"contentKeyBundle\"]> {\n if (\n contentKeyBundleCanonical(response.contentKeyBundle) !==\n contentKeyBundleCanonical(plan.sourceContentKeyBundle)\n ) {\n throw new Error(\"Document sync response content-key bundle mismatch\");\n }\n\n const bundleByEpoch = new Map<\n number,\n DocumentSyncResponse[\"contentKeyBundle\"]\n >();\n const bundles = [response.contentKeyBundle, ...response.contentKeyBundles];\n\n for (const bundle of bundles) {\n if (bundle.documentId !== plan.documentId) {\n throw new Error(\n \"Document sync response content-key bundle document mismatch\",\n );\n }\n if (\n !Number.isInteger(bundle.contentKeyEpoch) ||\n bundle.contentKeyEpoch <= 0\n ) {\n throw new Error(\n \"Document sync response content-key bundle epoch mismatch\",\n );\n }\n\n // The current epoch travels only as contentKeyBundle; the array carries\n // each older epoch once.\n if (bundleByEpoch.has(bundle.contentKeyEpoch)) {\n throw new Error(\"Document sync response repeats a content-key epoch\");\n }\n bundleByEpoch.set(bundle.contentKeyEpoch, bundle);\n }\n\n return bundleByEpoch;\n}\n\nasync function persistedDocumentSyncStateFromResponseInternal(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n options: {\n resolveWriterPublicKey: DocumentWriterPublicKeyResolver;\n },\n): Promise<PersistedDocumentSyncState> {\n if (response.documentId !== plan.documentId) {\n throw new Error(\"Document sync response document id mismatch\");\n }\n const contentKeyBundlesByEpoch = documentSyncContentKeyBundlesByEpoch(\n plan,\n response,\n );\n if (\n serializeCanonical(response.documentKekTargets, \"KEK targets\") !==\n serializeCanonical(plan.documentKekTargets, \"KEK targets\")\n ) {\n throw new Error(\"Document sync response KEK target mismatch\");\n }\n assertAcceptedOutgoingUpdateIdsMatchPlan(plan, response);\n assertDocumentSyncCommitCheckpointMatchesPlan(plan, response);\n assertDocumentSyncAccessEpochsNotInFuture(plan, response);\n\n await Promise.all(\n response.updates.map((update) =>\n assertDocumentSyncResponseUpdateMatchesPlan({\n contentKeyBundlesByEpoch,\n plan,\n resolveWriterPublicKey: options.resolveWriterPublicKey,\n update,\n }),\n ),\n );\n\n return serializedPersistedDocumentState({\n contentKeyBundle: response.contentKeyBundle,\n documentId: plan.documentId,\n documentKekTargets: response.documentKekTargets,\n documentManifestBundle: plan.documentManifest,\n });\n}\n\nexport async function persistedDocumentSyncStateFromResponse(\n plan: DocumentSyncPlan,\n response: DocumentSyncResponse,\n options: {\n resolveWriterPublicKey: DocumentWriterPublicKeyResolver;\n },\n): Promise<PersistedDocumentSyncState> {\n try {\n return await persistedDocumentSyncStateFromResponseInternal(\n plan,\n response,\n options,\n );\n } catch (error) {\n if (error instanceof DocumentSyncResponseUpdateContentKeyError) throw error;\n throwKeyingVerificationShapeFailure(error);\n }\n}\n\nexport function isRetryableDocumentSyncConflict(\n failure: DocumentSyncSubmitFailure,\n): boolean {\n return (\n failure.status === 409 &&\n failure.code === DOCUMENT_SYNC_ERROR_CODES.stateStale\n );\n}\n\n// The wipe gate is deliberately strict — coded 404s only, which is the right\n// failure mode for a destructive action. A bare 404 proves nothing about the\n// document: proxy/tunnel error pages, deploy-skew route misses, and\n// container-level lookups all produce one.\nexport function isUpstreamDeletedDocumentSyncFailure(\n failure: DocumentSyncSubmitFailure,\n): boolean {\n return (\n failure.status === 404 && failure.code === DOCUMENT_NOT_FOUND_ERROR_CODE\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReferencedPrincipalStateResponse } from "
|
|
1
|
+
import type { ReferencedPrincipalStateResponse } from "../../../../internal/validators/response/index.js";
|
|
2
2
|
export interface DocumentSyncSubmitFailure {
|
|
3
3
|
readonly code?: string | undefined;
|
|
4
4
|
readonly message: string;
|
|
@@ -4,10 +4,10 @@ import type { ContainerManifestRef, DocumentContentKeyTargetEnvelope, DocumentCr
|
|
|
4
4
|
import type { ContainerWriterProjectionResponse, DocumentCreateResponse, DocumentLinkSetMutationResponse, DocumentPurgeProofResponse, DocumentSyncResponse, DocumentWriterProjectionResponse, ListDocumentAttachmentsResponse } from "../../../internal/validators/response/index.js";
|
|
5
5
|
import type { ContainerMutationAuthor, ContainerRekeyApi } from "../../containers/shared/types.js";
|
|
6
6
|
import type { ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer, DocumentWriterProjectionAuthorization as WriterAuthorization } from "../../keyingProjectionVerification/index.js";
|
|
7
|
-
import type { DocumentRecord } from "../../sqlite/documentPersistence.js";
|
|
7
|
+
import type { DocumentRecord } from "../../sqlite/documentPersistence/index.js";
|
|
8
8
|
import type { ExecSql } from "../../sqlite/sqlSchema.js";
|
|
9
|
-
import type { DocumentSyncSubmitFailure } from "./syncSubmitFailure.js";
|
|
10
|
-
export type { DocumentSyncSubmitFailure } from "./syncSubmitFailure.js";
|
|
9
|
+
import type { DocumentSyncSubmitFailure } from "./sync/syncSubmitFailure.js";
|
|
10
|
+
export type { DocumentSyncSubmitFailure } from "./sync/syncSubmitFailure.js";
|
|
11
11
|
export declare const DOCUMENT_ENCRYPTED_LORO_UPDATE_FORMAT = "tearleads.document.loro-update";
|
|
12
12
|
export declare const DOCUMENT_CONTENT_RECORD_KEY_INFO_DOMAIN = "tearleads.document.content-record-key-info";
|
|
13
13
|
export declare const DOCUMENT_CONTENT_RECORD_PLAINTEXT_HASH_KEY_INFO_DOMAIN = "tearleads.document.content-record-plaintext-hash-key-info";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAOtF,MAAM,CAAC,MAAM,qCAAqC,GAChD,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,uCAAuC,GAClD,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,sDAAsD,GACjE,2DAA2D,CAAC;AAC9D,MAAM,CAAC,MAAM,kCAAkC,GAC7C,uCAAuC,CAAC;AAC1C,MAAM,CAAC,M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AAsB,KAAK,IAAI,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,MAAM;YACT,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;SACzD,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC,OAAO;YAClB,CAAC,CAAC;gBACE,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,MAAM;gBACT,sBAAsB,EAAE,IAAI;aAC7B;YACH,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;AACJ,CAAC","sourcesContent":["import type { BlobBytesResponse } from \"@tearleads/api-client\";\nimport type {\n AccessEvent,\n AccessManifest,\n DocumentContentKeyTarget,\n DocumentLinkAccessEventBody,\n DocumentLinkSetManifestState,\n DocumentUnlinkAccessEventBody,\n} from \"@tearleads/crypto\";\nimport type {\n ContainerManifestRef,\n DocumentContentKeyTargetEnvelope,\n DocumentCreateRequest,\n DocumentLinkSetMutationRequest,\n DocumentOutgoingUpdate,\n DocumentSyncRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n ContainerWriterProjectionResponse,\n DocumentCreateResponse,\n DocumentLinkSetMutationResponse,\n DocumentPurgeProofResponse,\n DocumentSyncResponse,\n DocumentWriterProjectionResponse,\n ListDocumentAttachmentsResponse,\n} from \"@tearleads/validators/response\";\nimport type {\n ContainerMutationAuthor,\n ContainerRekeyApi,\n} from \"../../containers/shared/types\";\nimport type {\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n DocumentWriterProjectionAuthorization as WriterAuthorization,\n} from \"../../keyingProjectionVerification\";\nimport { requireProjectionUserKeyResolver } from \"../../keyingProjectionVerification\";\nimport type { DocumentRecord } from \"../../sqlite/documentPersistence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport type { DocumentSyncSubmitFailure } from \"./syncSubmitFailure\";\n\nexport type { DocumentSyncSubmitFailure } from \"./syncSubmitFailure\";\n\nexport const DOCUMENT_ENCRYPTED_LORO_UPDATE_FORMAT =\n \"tearleads.document.loro-update\";\nexport const DOCUMENT_CONTENT_RECORD_KEY_INFO_DOMAIN =\n \"tearleads.document.content-record-key-info\";\nexport const DOCUMENT_CONTENT_RECORD_PLAINTEXT_HASH_KEY_INFO_DOMAIN =\n \"tearleads.document.content-record-plaintext-hash-key-info\";\nexport const DOCUMENT_CONTENT_RECORD_AAD_DOMAIN =\n \"tearleads.document.content-record-aad\";\nexport const DOCUMENT_CONTENT_RECORD_HKDF_SALT: Uint8Array<ArrayBuffer> =\n new TextEncoder().encode(\"tearleads.document.content-record-hkdf-salt\");\nexport const DOCUMENT_ENCRYPTED_UPDATE_KEYS = new Set([\n \"ciphertext\",\n \"contentKeyEpoch\",\n \"contentRecordId\",\n \"encryptionSuite\",\n \"format\",\n \"iv\",\n \"metadataHash\",\n \"nonceDomainHash\",\n \"version\",\n]);\nexport const TEXT_ENCODER = new TextEncoder();\ninterface ProjectionVerificationBase {\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}\n\nexport type ProjectionVerificationOptions = ProjectionVerificationBase &\n (\n | {\n readonly execSql: ExecSql;\n readonly resolveProjectionUserKey: ProjectionUserKeyResolver;\n readonly trustedLocalProjection?: undefined;\n }\n | {\n readonly execSql?: ExecSql | undefined;\n readonly resolveProjectionUserKey?: undefined;\n readonly trustedLocalProjection: true;\n }\n );\n\nexport function resolveProjectionVerifier(\n input: ProjectionVerificationOptions,\n label: string,\n): ProjectionUserKeyResolver | null {\n if (input.resolveProjectionUserKey) {\n if (input.trustedLocalProjection === true) {\n throw new Error(\n `${label} cannot combine projection key verification with local projection trust`,\n );\n }\n return requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n label,\n );\n }\n if (input.trustedLocalProjection === true) {\n return null;\n }\n throw new Error(\n `${label} requires projection key verification or an explicitly trusted local projection`,\n );\n}\n\nexport function projectionVerificationOptions(\n input: ProjectionVerificationOptions,\n): ProjectionVerificationOptions {\n const warm = input.warmReferencedPrincipalPolicies;\n const shared = {\n ...(input.stillCurrent ? { stillCurrent: input.stillCurrent } : {}),\n ...(warm ? { warmReferencedPrincipalPolicies: warm } : {}),\n };\n if (input.resolveProjectionUserKey) {\n if (input.trustedLocalProjection === true) {\n throw new Error(\n \"Projection use cannot combine key verification with local projection trust\",\n );\n }\n return {\n execSql: input.execSql,\n ...shared,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n };\n }\n if (input.trustedLocalProjection === true) {\n return input.execSql\n ? {\n execSql: input.execSql,\n ...shared,\n trustedLocalProjection: true,\n }\n : { ...shared, trustedLocalProjection: true };\n }\n\n throw new Error(\n \"Projection use requires key verification or an explicitly trusted local projection\",\n );\n}\n\nexport type DocumentCreateAuthor = ContainerMutationAuthor;\n\nexport interface BuildDocumentCreatePlanInput {\n author: DocumentCreateAuthor;\n containerProjection: ContainerWriterProjectionResponse;\n contentKeyEpoch?: number;\n documentId?: string;\n eventId?: string;\n signedAt?: string;\n targetEnvelopes: readonly DocumentContentKeyTargetEnvelope[];\n}\n\nexport interface DocumentCreatePlan {\n body: DocumentLinkAccessEventBody;\n documentId: string;\n event: AccessEvent;\n eventHash: string;\n manifest: AccessManifest;\n manifestHash: string;\n request: DocumentCreateRequest;\n state: DocumentLinkSetManifestState;\n targetHash: string;\n targets: DocumentContentKeyTarget[];\n}\n\nexport interface MaterializedDocumentCreatePlan {\n contentKey: Uint8Array;\n plan: DocumentCreatePlan;\n}\n\nexport interface DocumentCreateApi {\n // Lets idempotent create inspect an expected already-exists conflict.\n createDocumentResult(\n input: DocumentCreateRequest,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentCreateResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n getContainerWriterProjection(\n containerId: string,\n ): Promise<ContainerWriterProjectionResponse | null>;\n // Result-returning variant used by the create path so a terminal projection\n // fetch failure (e.g. a 402 billing block or a 403 after access revocation)\n // can be persisted to the write queue instead of collapsing to a silent\n // null.\n getContainerWriterProjectionResult(\n containerId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: ContainerWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n // Needed to adopt an existing remote document on a create conflict: the\n // committed manifest, content-key bundle and KEK targets are refetched here\n // (the create response that carried them was lost).\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n evictContainerWriterProjection(containerId: string): void;\n primeDocumentWriterProjection(\n documentId: string,\n projection: DocumentWriterProjectionResponse,\n ): void;\n}\n\nexport interface CreateRemoteDocumentResult {\n contentKey: Uint8Array;\n documentId: string;\n persistedState: PersistedDocumentCreateState;\n // `plan` and `response` are absent when the result was adopted from an\n // existing remote document on a create conflict: there is no fresh create\n // response, and the local plan does not match the committed manifest (the\n // first attempt used a different content key). Consumers read only\n // documentId/writerProjection/persistedState.\n plan?: DocumentCreatePlan | undefined;\n response?: DocumentCreateResponse | undefined;\n writerProjection: DocumentWriterProjectionResponse;\n}\n\nexport type DocumentLinkSetMutationOperation = \"link\" | \"unlink\";\nexport type DocumentLinkSetMutationBody =\n | DocumentLinkAccessEventBody\n | DocumentUnlinkAccessEventBody;\n\nexport interface DocumentLinkSetTargetState {\n readonly currentTargets: readonly DocumentContentKeyTarget[];\n readonly linkedContainerIds: readonly string[];\n readonly target: DocumentContentKeyTarget;\n readonly targets: readonly DocumentContentKeyTarget[];\n}\n\nexport interface BuildDocumentLinkSetMutationPlanInput {\n blobRewraps: DocumentLinkAccessEventBody[\"blobRewraps\"];\n author: DocumentCreateAuthor;\n contentKeyEpoch: number;\n eventId?: string | undefined;\n operation: DocumentLinkSetMutationOperation;\n signedAt?: string | undefined;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetEnvelopes: readonly DocumentContentKeyTargetEnvelope[];\n writerProjection: DocumentWriterProjectionResponse;\n}\n\nexport interface DocumentLinkSetMutationPlan {\n body: DocumentLinkSetMutationBody;\n contentKeyEpoch: number;\n documentId: string;\n event: AccessEvent;\n eventHash: string;\n manifest: AccessManifest;\n manifestHash: string;\n operation: DocumentLinkSetMutationOperation;\n request: DocumentLinkSetMutationRequest;\n state: DocumentLinkSetManifestState;\n targetHash: string;\n targets: DocumentContentKeyTarget[];\n}\n\nexport interface MaterializedDocumentLinkSetMutationPlan {\n contentKey: Uint8Array;\n contentKeyRotated: boolean;\n plan: DocumentLinkSetMutationPlan;\n}\n\nexport interface DocumentLinkSetEventPlan {\n authorizingContainerPathRefs: ContainerManifestRef[][];\n body: DocumentLinkSetMutationBody;\n event: AccessEvent;\n eventHash: string;\n}\n\n/**\n * What a failed link-set mutation could tell the caller: the HTTP status (or\n * null for network/local failures) and a short message. Threaded up to the\n * move-intent queue so a permission failure reads as one, instead of the\n * generic \"rejected or unavailable\".\n */\nexport type DocumentLinkSetMutationFailure = Pick<\n DocumentSyncSubmitFailure,\n \"code\" | \"message\" | \"status\"\n>;\n\nexport type DocumentLinkSetFailureHandler = (\n failure: DocumentLinkSetMutationFailure,\n) => void;\n\ntype DocumentLinkSetMutationResult =\n | { readonly data: DocumentLinkSetMutationResponse; readonly ok: true }\n | (DocumentLinkSetMutationFailure & { readonly ok: false });\n\nexport interface DocumentLinkSetMutationApi {\n getBlobBytes(blobId: string): Promise<BlobBytesResponse | null>;\n listDocumentAttachments(\n documentId: string,\n ): Promise<ListDocumentAttachmentsResponse | null>;\n getContainerWriterProjection(\n containerId: string,\n ): Promise<ContainerWriterProjectionResponse | null>;\n getContainerWriterProjectionResult(\n containerId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: ContainerWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n getDocumentWriterProjectionResult(\n documentId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n primeDocumentWriterProjection(\n documentId: string,\n projection: DocumentWriterProjectionResponse,\n ): void;\n linkDocumentResult(\n documentId: string,\n input: DocumentLinkSetMutationRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentLinkSetMutationResult>;\n unlinkDocumentResult(\n documentId: string,\n input: DocumentLinkSetMutationRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentLinkSetMutationResult>;\n}\n\nexport interface RelinkRemoteDocumentResult {\n contentKey: Uint8Array;\n contentKeyRotated: boolean;\n documentId: string;\n linkedContainerIds: readonly string[];\n persistedState: PersistedDocumentCreateState;\n plan: DocumentLinkSetMutationPlan;\n response: DocumentLinkSetMutationResponse;\n}\n\nexport interface DocumentSyncPreparedUpdate {\n checkpointKind?: DocumentOutgoingUpdate[\"checkpointKind\"] | undefined;\n checkpointPayloadKind?:\n | DocumentOutgoingUpdate[\"checkpointPayloadKind\"]\n | undefined;\n ciphertextHash: string;\n contentRecordId?: string | undefined;\n encryptedData: string;\n id: string;\n metadataHash: string;\n partialEndVersionVector: string;\n partialStartVersionVector: string;\n plaintextHash: string;\n signedAt?: string | undefined;\n sourceVersionVector?: string | undefined;\n}\n\nexport interface DocumentEncryptedPendingUpdate {\n contentRecordId: string;\n encryptedData: string;\n metadataHash: string;\n ciphertextHash: string;\n plaintextHash: string;\n}\n\nexport interface ParsedDocumentEncryptedUpdate {\n ciphertext: Uint8Array;\n contentKeyEpoch: number;\n contentRecordId: string;\n metadataHash: string;\n nonceDomainHash: string;\n iv: Uint8Array;\n}\n\nexport interface DecryptedDocumentSyncUpdate {\n checkpointKind?: \"rotate_baseline\";\n checkpointPayloadKind?: \"full_history_snapshot\";\n id: string;\n partialEndVersionVector: string;\n partialStartVersionVector: string;\n sourceVersionVector?: string;\n updateData: Uint8Array;\n}\n\nexport interface BuildDocumentSyncPlanInput {\n author: DocumentCreateAuthor;\n authorizingContainerPathRefs?: readonly (readonly ContainerManifestRef[])[];\n containerRekeys?: DocumentSyncRequest[\"containerRekeys\"];\n contentKeyBundle: DocumentCreateResponse[\"contentKeyBundle\"];\n documentId?: string | undefined;\n documentKekTargets: DocumentSyncResponse[\"documentKekTargets\"];\n documentManifest: DocumentCreateResponse[\"accessManifest\"];\n historyMode?: \"raw\" | undefined;\n inlineRekeyCommitId?: string | undefined;\n localVersionVector: string | null;\n minLsn?: string | undefined;\n outgoingUpdates?: readonly DocumentSyncPreparedUpdate[] | undefined;\n pullCursor?: string | undefined;\n signedAt?: string | undefined;\n}\n\nexport interface DocumentSyncPlan {\n contentKeyEpoch: number;\n documentId: string;\n documentKekTargets: DocumentSyncResponse[\"documentKekTargets\"];\n documentManifest: DocumentCreateResponse[\"accessManifest\"];\n documentWriterAuthorization?: WriterAuthorization | undefined;\n expectedLinkSetManifestHash: string;\n expectedTargetHash: string;\n minLsn?: string | undefined;\n organizationId: string;\n request: DocumentSyncRequest;\n sourceContentKeyBundle: DocumentCreateResponse[\"contentKeyBundle\"];\n}\n\nexport interface MaterializedDocumentSyncPlan {\n contentKey: Uint8Array;\n /**\n * True when the plan carries a re-wrapped content-key bundle at the next\n * epoch to heal a stale bundle (a linked container's KEK rotated under it).\n * On submit success the caller must evict this document's cached writer\n * projection so later passes see the healed state instead of re-healing.\n */\n healedStaleContentKeyBundle: boolean;\n /**\n * Pending-queue ids a heal deliberately did NOT submit (superseded rotation\n * checkpoints). On heal success they are reported as settled — the\n * committed covering baseline subsumes their content, and resubmitting them\n * post-heal could mask it as the latest baseline at the healed epoch.\n */\n heldBackPendingUpdateIds: readonly string[];\n plan: DocumentSyncPlan;\n writerProjection: DocumentWriterProjectionResponse;\n /** Synthetic baseline id; its ack does not settle a pending queue row. */\n staleRecoveryBaselineUpdateId?: string;\n}\n\nexport interface SyncRemoteDocumentResult {\n contentKey: Uint8Array;\n decryptedUpdates: DecryptedDocumentSyncUpdate[];\n /**\n * Pending updates whose persisted re-key bound is exhausted. Non-zero means\n * a terminal failure was just recorded for them — callers must not treat\n * the pass as clean and clear it.\n */\n exhaustedPendingUpdateCount: number;\n /**\n * True only when this bounded pass made durable progress but left pending\n * work. Headless hosts should refresh the queue and schedule another\n * pass. Terminal exhaustion reports false and uses the failure callback.\n */\n hasDeferredPendingUpdates: boolean;\n /** Verified page progress was persisted, but remote pages remain. */\n hasIncompletePull: boolean;\n persistedState: PersistedDocumentSyncState;\n plan: DocumentSyncPlan;\n rekeyedPendingUpdateIds: readonly string[];\n response: DocumentSyncResponse;\n settledPendingUpdateIds: readonly string[];\n acceptedRecoveryBaseline: boolean;\n writerProjection?: DocumentWriterProjectionResponse | undefined;\n}\n\nexport interface DocumentSyncRequestResultOptions {\n readonly expectedPaymentRequiredOrganizationId?: string | undefined;\n readonly reportErrors?: boolean | undefined;\n}\n\nexport interface DocumentSyncApi {\n rekeyContainer: ContainerRekeyApi[\"rekeyContainer\"];\n /**\n * Optional status-bearing rekey. Present on the real client; an adapter that\n * omits it still repairs, but a permanent refusal cannot then be told from a\n * transient one and is reported as a plain abandon.\n */\n rekeyContainerResult?: ContainerRekeyApi[\"rekeyContainerResult\"];\n /**\n * Optional. A repair that must carry descendant rekeys reads each one's\n * projection; without this such a repair is refused and the pass abandons.\n */\n getContainerWriterProjection?: ContainerRekeyApi[\"getContainerWriterProjection\"];\n clearWriterProjectionCaches?(): void;\n evictDocumentWriterProjection?(documentId: string): void;\n getDocumentPurgeProof?(\n documentId: string,\n options?: {\n readonly documentCheckpointManifestHash?: string;\n },\n requestOptions?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentPurgeProofResponse | null>;\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n getDocumentWriterProjectionResult(\n documentId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n syncDocumentResult(\n documentId: string,\n input: DocumentSyncRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<\n | {\n readonly data: DocumentSyncResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n}\n\nexport type DocumentWriterPublicKeyResolver = (input: {\n writerSigningKeyFingerprint: string;\n writerUserId: string;\n}) => Promise<Uint8Array | null>;\n\nexport type PersistedDocumentCreateState = Pick<\n DocumentRecord,\n | \"documentId\"\n | \"contentKeyBundle\"\n | \"documentKekTargets\"\n | \"documentManifestBundle\"\n>;\n\nexport type PersistedDocumentSyncState = PersistedDocumentCreateState;\n\nexport interface UnwrappedContainerKek {\n containerId: string;\n /**\n * Null for keyring-recovered historical keys, which carry key material and\n * the epoch id committing to it but no epoch record to hash.\n *\n * Such a key still satisfies a parent wrap: the epoch-record fingerprint is\n * a selector for choosing among envelopes, not the security boundary, so a\n * null hash falls back to selecting on the epoch id while AEAD authenticates\n * (see `containerKekPath.ts`). That is what lets a descendant pinned to a\n * rotated parent be opened rather than stranded.\n */\n keyEpochHash: string | null;\n keyMaterial: Uint8Array;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAOtF,MAAM,CAAC,MAAM,qCAAqC,GAChD,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,uCAAuC,GAClD,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,sDAAsD,GACjE,2DAA2D,CAAC;AAC9D,MAAM,CAAC,MAAM,kCAAkC,GAC7C,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E,CAAC;QACnC,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,MAAM;YACT,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;SACzD,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC,OAAO;YAClB,CAAC,CAAC;gBACE,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,MAAM;gBACT,sBAAsB,EAAE,IAAI;aAC7B;YACH,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;AACJ,CAAC","sourcesContent":["import type { BlobBytesResponse } from \"@tearleads/api-client\";\nimport type {\n AccessEvent,\n AccessManifest,\n DocumentContentKeyTarget,\n DocumentLinkAccessEventBody,\n DocumentLinkSetManifestState,\n DocumentUnlinkAccessEventBody,\n} from \"@tearleads/crypto\";\nimport type {\n ContainerManifestRef,\n DocumentContentKeyTargetEnvelope,\n DocumentCreateRequest,\n DocumentLinkSetMutationRequest,\n DocumentOutgoingUpdate,\n DocumentSyncRequest,\n} from \"@tearleads/validators/request\";\nimport type {\n ContainerWriterProjectionResponse,\n DocumentCreateResponse,\n DocumentLinkSetMutationResponse,\n DocumentPurgeProofResponse,\n DocumentSyncResponse,\n DocumentWriterProjectionResponse,\n ListDocumentAttachmentsResponse,\n} from \"@tearleads/validators/response\";\nimport type {\n ContainerMutationAuthor,\n ContainerRekeyApi,\n} from \"../../containers/shared/types\";\nimport type {\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n DocumentWriterProjectionAuthorization as WriterAuthorization,\n} from \"../../keyingProjectionVerification\";\nimport { requireProjectionUserKeyResolver } from \"../../keyingProjectionVerification\";\nimport type { DocumentRecord } from \"../../sqlite/documentPersistence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport type { DocumentSyncSubmitFailure } from \"./sync/syncSubmitFailure\";\n\nexport type { DocumentSyncSubmitFailure } from \"./sync/syncSubmitFailure\";\n\nexport const DOCUMENT_ENCRYPTED_LORO_UPDATE_FORMAT =\n \"tearleads.document.loro-update\";\nexport const DOCUMENT_CONTENT_RECORD_KEY_INFO_DOMAIN =\n \"tearleads.document.content-record-key-info\";\nexport const DOCUMENT_CONTENT_RECORD_PLAINTEXT_HASH_KEY_INFO_DOMAIN =\n \"tearleads.document.content-record-plaintext-hash-key-info\";\nexport const DOCUMENT_CONTENT_RECORD_AAD_DOMAIN =\n \"tearleads.document.content-record-aad\";\nexport const DOCUMENT_CONTENT_RECORD_HKDF_SALT: Uint8Array<ArrayBuffer> =\n new TextEncoder().encode(\"tearleads.document.content-record-hkdf-salt\");\nexport const DOCUMENT_ENCRYPTED_UPDATE_KEYS = new Set([\n \"ciphertext\",\n \"contentKeyEpoch\",\n \"contentRecordId\",\n \"encryptionSuite\",\n \"format\",\n \"iv\",\n \"metadataHash\",\n \"nonceDomainHash\",\n \"version\",\n]);\nexport const TEXT_ENCODER = new TextEncoder();\ninterface ProjectionVerificationBase {\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}\n\nexport type ProjectionVerificationOptions = ProjectionVerificationBase &\n (\n | {\n readonly execSql: ExecSql;\n readonly resolveProjectionUserKey: ProjectionUserKeyResolver;\n readonly trustedLocalProjection?: undefined;\n }\n | {\n readonly execSql?: ExecSql | undefined;\n readonly resolveProjectionUserKey?: undefined;\n readonly trustedLocalProjection: true;\n }\n );\n\nexport function resolveProjectionVerifier(\n input: ProjectionVerificationOptions,\n label: string,\n): ProjectionUserKeyResolver | null {\n if (input.resolveProjectionUserKey) {\n if (input.trustedLocalProjection === true) {\n throw new Error(\n `${label} cannot combine projection key verification with local projection trust`,\n );\n }\n return requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n label,\n );\n }\n if (input.trustedLocalProjection === true) {\n return null;\n }\n throw new Error(\n `${label} requires projection key verification or an explicitly trusted local projection`,\n );\n}\n\nexport function projectionVerificationOptions(\n input: ProjectionVerificationOptions,\n): ProjectionVerificationOptions {\n const warm = input.warmReferencedPrincipalPolicies;\n const shared = {\n ...(input.stillCurrent ? { stillCurrent: input.stillCurrent } : {}),\n ...(warm ? { warmReferencedPrincipalPolicies: warm } : {}),\n };\n if (input.resolveProjectionUserKey) {\n if (input.trustedLocalProjection === true) {\n throw new Error(\n \"Projection use cannot combine key verification with local projection trust\",\n );\n }\n return {\n execSql: input.execSql,\n ...shared,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n };\n }\n if (input.trustedLocalProjection === true) {\n return input.execSql\n ? {\n execSql: input.execSql,\n ...shared,\n trustedLocalProjection: true,\n }\n : { ...shared, trustedLocalProjection: true };\n }\n\n throw new Error(\n \"Projection use requires key verification or an explicitly trusted local projection\",\n );\n}\n\nexport type DocumentCreateAuthor = ContainerMutationAuthor;\n\nexport interface BuildDocumentCreatePlanInput {\n author: DocumentCreateAuthor;\n containerProjection: ContainerWriterProjectionResponse;\n contentKeyEpoch?: number;\n documentId?: string;\n eventId?: string;\n signedAt?: string;\n targetEnvelopes: readonly DocumentContentKeyTargetEnvelope[];\n}\n\nexport interface DocumentCreatePlan {\n body: DocumentLinkAccessEventBody;\n documentId: string;\n event: AccessEvent;\n eventHash: string;\n manifest: AccessManifest;\n manifestHash: string;\n request: DocumentCreateRequest;\n state: DocumentLinkSetManifestState;\n targetHash: string;\n targets: DocumentContentKeyTarget[];\n}\n\nexport interface MaterializedDocumentCreatePlan {\n contentKey: Uint8Array;\n plan: DocumentCreatePlan;\n}\n\nexport interface DocumentCreateApi {\n // Lets idempotent create inspect an expected already-exists conflict.\n createDocumentResult(\n input: DocumentCreateRequest,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentCreateResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n getContainerWriterProjection(\n containerId: string,\n ): Promise<ContainerWriterProjectionResponse | null>;\n // Result-returning variant used by the create path so a terminal projection\n // fetch failure (e.g. a 402 billing block or a 403 after access revocation)\n // can be persisted to the write queue instead of collapsing to a silent\n // null.\n getContainerWriterProjectionResult(\n containerId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: ContainerWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n // Needed to adopt an existing remote document on a create conflict: the\n // committed manifest, content-key bundle and KEK targets are refetched here\n // (the create response that carried them was lost).\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n evictContainerWriterProjection(containerId: string): void;\n primeDocumentWriterProjection(\n documentId: string,\n projection: DocumentWriterProjectionResponse,\n ): void;\n}\n\nexport interface CreateRemoteDocumentResult {\n contentKey: Uint8Array;\n documentId: string;\n persistedState: PersistedDocumentCreateState;\n // `plan` and `response` are absent when the result was adopted from an\n // existing remote document on a create conflict: there is no fresh create\n // response, and the local plan does not match the committed manifest (the\n // first attempt used a different content key). Consumers read only\n // documentId/writerProjection/persistedState.\n plan?: DocumentCreatePlan | undefined;\n response?: DocumentCreateResponse | undefined;\n writerProjection: DocumentWriterProjectionResponse;\n}\n\nexport type DocumentLinkSetMutationOperation = \"link\" | \"unlink\";\nexport type DocumentLinkSetMutationBody =\n | DocumentLinkAccessEventBody\n | DocumentUnlinkAccessEventBody;\n\nexport interface DocumentLinkSetTargetState {\n readonly currentTargets: readonly DocumentContentKeyTarget[];\n readonly linkedContainerIds: readonly string[];\n readonly target: DocumentContentKeyTarget;\n readonly targets: readonly DocumentContentKeyTarget[];\n}\n\nexport interface BuildDocumentLinkSetMutationPlanInput {\n blobRewraps: DocumentLinkAccessEventBody[\"blobRewraps\"];\n author: DocumentCreateAuthor;\n contentKeyEpoch: number;\n eventId?: string | undefined;\n operation: DocumentLinkSetMutationOperation;\n signedAt?: string | undefined;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetEnvelopes: readonly DocumentContentKeyTargetEnvelope[];\n writerProjection: DocumentWriterProjectionResponse;\n}\n\nexport interface DocumentLinkSetMutationPlan {\n body: DocumentLinkSetMutationBody;\n contentKeyEpoch: number;\n documentId: string;\n event: AccessEvent;\n eventHash: string;\n manifest: AccessManifest;\n manifestHash: string;\n operation: DocumentLinkSetMutationOperation;\n request: DocumentLinkSetMutationRequest;\n state: DocumentLinkSetManifestState;\n targetHash: string;\n targets: DocumentContentKeyTarget[];\n}\n\nexport interface MaterializedDocumentLinkSetMutationPlan {\n contentKey: Uint8Array;\n contentKeyRotated: boolean;\n plan: DocumentLinkSetMutationPlan;\n}\n\nexport interface DocumentLinkSetEventPlan {\n authorizingContainerPathRefs: ContainerManifestRef[][];\n body: DocumentLinkSetMutationBody;\n event: AccessEvent;\n eventHash: string;\n}\n\n/**\n * What a failed link-set mutation could tell the caller: the HTTP status (or\n * null for network/local failures) and a short message. Threaded up to the\n * move-intent queue so a permission failure reads as one, instead of the\n * generic \"rejected or unavailable\".\n */\nexport type DocumentLinkSetMutationFailure = Pick<\n DocumentSyncSubmitFailure,\n \"code\" | \"message\" | \"status\"\n>;\n\nexport type DocumentLinkSetFailureHandler = (\n failure: DocumentLinkSetMutationFailure,\n) => void;\n\ntype DocumentLinkSetMutationResult =\n | { readonly data: DocumentLinkSetMutationResponse; readonly ok: true }\n | (DocumentLinkSetMutationFailure & { readonly ok: false });\n\nexport interface DocumentLinkSetMutationApi {\n getBlobBytes(blobId: string): Promise<BlobBytesResponse | null>;\n listDocumentAttachments(\n documentId: string,\n ): Promise<ListDocumentAttachmentsResponse | null>;\n getContainerWriterProjection(\n containerId: string,\n ): Promise<ContainerWriterProjectionResponse | null>;\n getContainerWriterProjectionResult(\n containerId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: ContainerWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n getDocumentWriterProjectionResult(\n documentId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n primeDocumentWriterProjection(\n documentId: string,\n projection: DocumentWriterProjectionResponse,\n ): void;\n linkDocumentResult(\n documentId: string,\n input: DocumentLinkSetMutationRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentLinkSetMutationResult>;\n unlinkDocumentResult(\n documentId: string,\n input: DocumentLinkSetMutationRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentLinkSetMutationResult>;\n}\n\nexport interface RelinkRemoteDocumentResult {\n contentKey: Uint8Array;\n contentKeyRotated: boolean;\n documentId: string;\n linkedContainerIds: readonly string[];\n persistedState: PersistedDocumentCreateState;\n plan: DocumentLinkSetMutationPlan;\n response: DocumentLinkSetMutationResponse;\n}\n\nexport interface DocumentSyncPreparedUpdate {\n checkpointKind?: DocumentOutgoingUpdate[\"checkpointKind\"] | undefined;\n checkpointPayloadKind?:\n | DocumentOutgoingUpdate[\"checkpointPayloadKind\"]\n | undefined;\n ciphertextHash: string;\n contentRecordId?: string | undefined;\n encryptedData: string;\n id: string;\n metadataHash: string;\n partialEndVersionVector: string;\n partialStartVersionVector: string;\n plaintextHash: string;\n signedAt?: string | undefined;\n sourceVersionVector?: string | undefined;\n}\n\nexport interface DocumentEncryptedPendingUpdate {\n contentRecordId: string;\n encryptedData: string;\n metadataHash: string;\n ciphertextHash: string;\n plaintextHash: string;\n}\n\nexport interface ParsedDocumentEncryptedUpdate {\n ciphertext: Uint8Array;\n contentKeyEpoch: number;\n contentRecordId: string;\n metadataHash: string;\n nonceDomainHash: string;\n iv: Uint8Array;\n}\n\nexport interface DecryptedDocumentSyncUpdate {\n checkpointKind?: \"rotate_baseline\";\n checkpointPayloadKind?: \"full_history_snapshot\";\n id: string;\n partialEndVersionVector: string;\n partialStartVersionVector: string;\n sourceVersionVector?: string;\n updateData: Uint8Array;\n}\n\nexport interface BuildDocumentSyncPlanInput {\n author: DocumentCreateAuthor;\n authorizingContainerPathRefs?: readonly (readonly ContainerManifestRef[])[];\n containerRekeys?: DocumentSyncRequest[\"containerRekeys\"];\n contentKeyBundle: DocumentCreateResponse[\"contentKeyBundle\"];\n documentId?: string | undefined;\n documentKekTargets: DocumentSyncResponse[\"documentKekTargets\"];\n documentManifest: DocumentCreateResponse[\"accessManifest\"];\n historyMode?: \"raw\" | undefined;\n inlineRekeyCommitId?: string | undefined;\n localVersionVector: string | null;\n minLsn?: string | undefined;\n outgoingUpdates?: readonly DocumentSyncPreparedUpdate[] | undefined;\n pullCursor?: string | undefined;\n signedAt?: string | undefined;\n}\n\nexport interface DocumentSyncPlan {\n contentKeyEpoch: number;\n documentId: string;\n documentKekTargets: DocumentSyncResponse[\"documentKekTargets\"];\n documentManifest: DocumentCreateResponse[\"accessManifest\"];\n documentWriterAuthorization?: WriterAuthorization | undefined;\n expectedLinkSetManifestHash: string;\n expectedTargetHash: string;\n minLsn?: string | undefined;\n organizationId: string;\n request: DocumentSyncRequest;\n sourceContentKeyBundle: DocumentCreateResponse[\"contentKeyBundle\"];\n}\n\nexport interface MaterializedDocumentSyncPlan {\n contentKey: Uint8Array;\n /**\n * True when the plan carries a re-wrapped content-key bundle at the next\n * epoch to heal a stale bundle (a linked container's KEK rotated under it).\n * On submit success the caller must evict this document's cached writer\n * projection so later passes see the healed state instead of re-healing.\n */\n healedStaleContentKeyBundle: boolean;\n /**\n * Pending-queue ids a heal deliberately did NOT submit (superseded rotation\n * checkpoints). On heal success they are reported as settled — the\n * committed covering baseline subsumes their content, and resubmitting them\n * post-heal could mask it as the latest baseline at the healed epoch.\n */\n heldBackPendingUpdateIds: readonly string[];\n plan: DocumentSyncPlan;\n writerProjection: DocumentWriterProjectionResponse;\n /** Synthetic baseline id; its ack does not settle a pending queue row. */\n staleRecoveryBaselineUpdateId?: string;\n}\n\nexport interface SyncRemoteDocumentResult {\n contentKey: Uint8Array;\n decryptedUpdates: DecryptedDocumentSyncUpdate[];\n /**\n * Pending updates whose persisted re-key bound is exhausted. Non-zero means\n * a terminal failure was just recorded for them — callers must not treat\n * the pass as clean and clear it.\n */\n exhaustedPendingUpdateCount: number;\n /**\n * True only when this bounded pass made durable progress but left pending\n * work. Headless hosts should refresh the queue and schedule another\n * pass. Terminal exhaustion reports false and uses the failure callback.\n */\n hasDeferredPendingUpdates: boolean;\n /** Verified page progress was persisted, but remote pages remain. */\n hasIncompletePull: boolean;\n persistedState: PersistedDocumentSyncState;\n plan: DocumentSyncPlan;\n rekeyedPendingUpdateIds: readonly string[];\n response: DocumentSyncResponse;\n settledPendingUpdateIds: readonly string[];\n acceptedRecoveryBaseline: boolean;\n writerProjection?: DocumentWriterProjectionResponse | undefined;\n}\n\nexport interface DocumentSyncRequestResultOptions {\n readonly expectedPaymentRequiredOrganizationId?: string | undefined;\n readonly reportErrors?: boolean | undefined;\n}\n\nexport interface DocumentSyncApi {\n rekeyContainer: ContainerRekeyApi[\"rekeyContainer\"];\n /**\n * Optional status-bearing rekey. Present on the real client; an adapter that\n * omits it still repairs, but a permanent refusal cannot then be told from a\n * transient one and is reported as a plain abandon.\n */\n rekeyContainerResult?: ContainerRekeyApi[\"rekeyContainerResult\"];\n /**\n * Optional. A repair that must carry descendant rekeys reads each one's\n * projection; without this such a repair is refused and the pass abandons.\n */\n getContainerWriterProjection?: ContainerRekeyApi[\"getContainerWriterProjection\"];\n clearWriterProjectionCaches?(): void;\n evictDocumentWriterProjection?(documentId: string): void;\n getDocumentPurgeProof?(\n documentId: string,\n options?: {\n readonly documentCheckpointManifestHash?: string;\n },\n requestOptions?: DocumentSyncRequestResultOptions,\n ): Promise<DocumentPurgeProofResponse | null>;\n getDocumentWriterProjection(\n documentId: string,\n ): Promise<DocumentWriterProjectionResponse | null>;\n getDocumentWriterProjectionResult(\n documentId: string,\n options?: DocumentSyncRequestResultOptions | undefined,\n ): Promise<\n | {\n readonly data: DocumentWriterProjectionResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n syncDocumentResult(\n documentId: string,\n input: DocumentSyncRequest,\n options?: DocumentSyncRequestResultOptions,\n ): Promise<\n | {\n readonly data: DocumentSyncResponse;\n readonly ok: true;\n }\n | DocumentSyncSubmitFailure\n >;\n}\n\nexport type DocumentWriterPublicKeyResolver = (input: {\n writerSigningKeyFingerprint: string;\n writerUserId: string;\n}) => Promise<Uint8Array | null>;\n\nexport type PersistedDocumentCreateState = Pick<\n DocumentRecord,\n | \"documentId\"\n | \"contentKeyBundle\"\n | \"documentKekTargets\"\n | \"documentManifestBundle\"\n>;\n\nexport type PersistedDocumentSyncState = PersistedDocumentCreateState;\n\nexport interface UnwrappedContainerKek {\n containerId: string;\n /**\n * Null for keyring-recovered historical keys, which carry key material and\n * the epoch id committing to it but no epoch record to hash.\n *\n * Such a key still satisfies a parent wrap: the epoch-record fingerprint is\n * a selector for choosing among envelopes, not the security boundary, so a\n * null hash falls back to selecting on the epoch id while AEAD authenticates\n * (see `containerKekPath.ts`). That is what lets a descendant pinned to a\n * rotated parent be opened rather than stranded.\n */\n keyEpochHash: string | null;\n keyMaterial: Uint8Array;\n}\n"]}
|
package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
|
|
2
|
-
import { advanceKeyingCheckpointsAtomically, validateKeyingCheckpointsAtomically, } from "../../persistence/keyingCheckpointAdvancePersistence.js";
|
|
2
|
+
import { advanceKeyingCheckpointsAtomically, validateKeyingCheckpointsAtomically, } from "../../persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence.js";
|
|
3
3
|
function objectKey(manifest) {
|
|
4
4
|
const { objectKind, organizationId, objectId } = manifest.checkpoint;
|
|
5
5
|
return JSON.stringify([objectKind, organizationId, objectId]);
|
package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessManifestCheckpointEnforcement.js","sourceRoot":"","sources":["accessManifestCheckpointEnforcement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,
|
|
1
|
+
{"version":3,"file":"accessManifestCheckpointEnforcement.js","sourceRoot":"","sources":["accessManifestCheckpointEnforcement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wEAAwE,CAAC;AAKhF,SAAS,SAAS,CAAC,QAAkD;IACnE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC;IACrE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,iBAAiB,CACxB,SAA8D;IAE9D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAGrB,CAAC;IACJ,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACnB,QAA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AC/C,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;QAClD,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,eAAe,EAAE,KAAK,CAAC,eAAe;KACvC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,KAYtD;IACC,MAAM,kCAAkC,CAAC;QACvC,MAAM,EAAE,gCAAgC,CAAC,KAAK,CAAC;QAC/C,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;QACtD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;QAClD,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,eAAe,EAAE,KAAK,CAAC,eAAe;KACvC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type VerifiedAccessManifestCheckpointEvidence,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport type { DocumentPurgeCheckpoint } from \"../../persistence/keyingCheckpoints/documentPurgeCheckpointPersistence\";\nimport {\n type AccessManifestCheckpointAdvance,\n advanceKeyingCheckpointsAtomically,\n validateKeyingCheckpointsAtomically,\n} from \"../../persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence\";\nimport type { VerifiedManifestBundle } from \"../../persistence/verifiedManifestBundlePersistence\";\nimport type { PrincipalPolicyCheckpointEvidence } from \"../../principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\n\nfunction objectKey(manifest: VerifiedAccessManifestCheckpointEvidence): string {\n const { objectKind, organizationId, objectId } = manifest.checkpoint;\n return JSON.stringify([objectKind, organizationId, objectId]);\n}\n\nfunction manifestsByObject(\n manifests: readonly VerifiedAccessManifestCheckpointEvidence[],\n): Map<string, Map<string, VerifiedAccessManifestCheckpointEvidence>> {\n const byObject = new Map<\n string,\n Map<string, VerifiedAccessManifestCheckpointEvidence>\n >();\n for (const manifest of manifests) {\n const key = objectKey(manifest);\n let byHash = byObject.get(key);\n if (!byHash) {\n byHash = new Map();\n byObject.set(key, byHash);\n }\n byHash.set(manifest.manifestHash, manifest);\n }\n return byObject;\n}\n\nfunction accessManifestCheckpointAdvances(input: {\n readonly verifiedHeads: readonly VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: readonly VerifiedAccessManifestCheckpointEvidence[];\n}): AccessManifestCheckpointAdvance[] {\n const evidenceByObject = manifestsByObject(input.verifiedManifests);\n const headsByObject = manifestsByObject(input.verifiedHeads);\n const advances: AccessManifestCheckpointAdvance[] = [];\n\n for (const [key, headsByHash] of headsByObject) {\n if (headsByHash.size !== 1) {\n throw new KeyingVerificationError(\n \"equivocation\",\n `projection declares conflicting access manifest heads for ${key}`,\n );\n }\n const head = headsByHash.values().next().value;\n if (!head) {\n continue;\n }\n const predecessors = [\n ...(evidenceByObject.get(key)?.values() ?? []),\n ].filter((manifest) => manifest.manifestHash !== head.manifestHash);\n advances.push({ head, predecessors });\n }\n\n return advances;\n}\n\nexport async function validateAccessManifestCheckpoints(input: {\n readonly execSql: ExecSql;\n readonly policies: readonly PrincipalPolicyCheckpointEvidence[];\n readonly authorizationPolicies?:\n | readonly VerifiedPrincipalPolicySelection[]\n | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly verifiedBundles?: readonly VerifiedManifestBundle[] | undefined;\n readonly verifiedHeads: readonly VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: readonly VerifiedAccessManifestCheckpointEvidence[];\n}): Promise<void> {\n await validateKeyingCheckpointsAtomically({\n access: accessManifestCheckpointAdvances(input),\n execSql: input.execSql,\n policies: input.policies,\n authorizationPolicies: input.authorizationPolicies,\n stillCurrent: input.stillCurrent,\n verifiedBundles: input.verifiedBundles,\n });\n}\n\nexport async function enforceAccessManifestCheckpoints(input: {\n readonly execSql: ExecSql;\n readonly organizationId?: string | undefined;\n readonly documentPurgeCheckpoint?: DocumentPurgeCheckpoint | undefined;\n readonly policies: readonly PrincipalPolicyCheckpointEvidence[];\n readonly authorizationPolicies?:\n | readonly VerifiedPrincipalPolicySelection[]\n | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly verifiedBundles?: readonly VerifiedManifestBundle[] | undefined;\n readonly verifiedHeads: readonly VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: readonly VerifiedAccessManifestCheckpointEvidence[];\n}): Promise<void> {\n await advanceKeyingCheckpointsAtomically({\n access: accessManifestCheckpointAdvances(input),\n documentPurgeCheckpoint: input.documentPurgeCheckpoint,\n execSql: input.execSql,\n organizationId: input.organizationId,\n policies: input.policies,\n authorizationPolicies: input.authorizationPolicies,\n stillCurrent: input.stillCurrent,\n verifiedBundles: input.verifiedBundles,\n });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AccessManifestCheckpoint, type VerifiedAccessManifestCheckpointEvidence, type VerifiedContainerAccessManifest, type VerifiedPrincipalPolicySelection } from "../../../internal/crypto/index.js";
|
|
2
2
|
import type { AccessManifestBundleWireResponse } from "../../../internal/validators/response/index.js";
|
|
3
|
-
import type { DocumentPurgeCheckpoint } from "../../persistence/documentPurgeCheckpointPersistence.js";
|
|
3
|
+
import type { DocumentPurgeCheckpoint } from "../../persistence/keyingCheckpoints/documentPurgeCheckpointPersistence.js";
|
|
4
4
|
import type { VerifiedManifestBundle } from "../../persistence/verifiedManifestBundlePersistence.js";
|
|
5
5
|
import type { PrincipalPolicyCheckpointEvidence } from "../../principals/principalPolicyEvidence.js";
|
|
6
6
|
import type { ExecSql } from "../../sqlite/sqlSchema.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
|
|
2
2
|
import { rememberVerifiedContainerHeads } from "../../containers/shared/heldContainerHeads.js";
|
|
3
|
-
import { PrincipalAuthorizationCheckpointUnavailableError } from "../../persistence/principalAuthorizationCheckpoints.js";
|
|
3
|
+
import { PrincipalAuthorizationCheckpointUnavailableError } from "../../persistence/keyingCheckpoints/principalAuthorizationCheckpoints.js";
|
|
4
4
|
import { ProjectionDependencyUnavailableError } from "../dependencyUnavailable.js";
|
|
5
5
|
import { projectionLifetimeGuard } from "../projectionLifetimes.js";
|
|
6
6
|
import { assertProjectionVerificationCurrent } from "../types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpointContext.js","sourceRoot":"","sources":["checkpointContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,GAIxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAE5F,OAAO,EAAE,gDAAgD,EAAE,MAAM,qDAAqD,CAAC;AAIvH,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EACL,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,uCAAuC,CAAC;AAgB/C,MAAM,UAAU,iCAAiC,CAAC,KAGjD;IACC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO;QACL,kBAAkB,EAAE,EAAE;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,gBAAgB,EAAE,IAAI,GAAG,EAAE;QAC3B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,QAAQ,EAAE,EAAE;QACZ,qBAAqB,EAAE,EAAE;QACzB,eAAe,EAAE,EAAE;QACnB,aAAa,EAAE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C,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC1B,IAAI,KAAK,YAAY,gDAAgD;YACnE,MAAM,IAAI,oCAAoC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;IACH,mCAAmC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAoC,EACpC,KAIC;IAED,IAAI,KAAK,CAAC,8BAA8B,KAAK,KAAK,EAAE,CAAC;QACnD,MAAM,6BAA6B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IACD,MAAM,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO;IAC7C,MAAM,cAAc,GAClB,OAAO,CAAC,cAAc;QACtB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC;IACtD,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO;IACzC,IAAI,CAAC;QACH,8BAA8B,CAAC;YAC7B,cAAc;YACd,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO;YACzC,KAAK,EAAE,OAAO,CAAC,kBAAkB;YACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;QACxE,sEAAsE;IACxE,CAAC;AACH,CAAC","sourcesContent":["import {\n type AccessManifestCheckpoint,\n KeyingVerificationError,\n type VerifiedAccessManifestCheckpointEvidence,\n type VerifiedContainerAccessManifest,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport type { AccessManifestBundleWireResponse } from \"@tearleads/validators/response\";\nimport { rememberVerifiedContainerHeads } from \"../../containers/shared/heldContainerHeads\";\nimport type { DocumentPurgeCheckpoint } from \"../../persistence/documentPurgeCheckpointPersistence\";\nimport { PrincipalAuthorizationCheckpointUnavailableError } from \"../../persistence/principalAuthorizationCheckpoints\";\nimport type { VerifiedManifestBundle } from \"../../persistence/verifiedManifestBundlePersistence\";\nimport type { PrincipalPolicyCheckpointEvidence } from \"../../principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport { ProjectionDependencyUnavailableError } from \"../dependencyUnavailable\";\nimport { projectionLifetimeGuard } from \"../projectionLifetimes\";\nimport { assertProjectionVerificationCurrent } from \"../types\";\nimport {\n enforceAccessManifestCheckpoints,\n validateAccessManifestCheckpoints,\n} from \"./accessManifestCheckpointEnforcement\";\n\nexport interface ProjectionCheckpointContext {\n readonly heldContainerHeads: VerifiedContainerAccessManifest[];\n readonly execSql: ExecSql;\n // Local checkpoints read during this verification, one read per object.\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n organizationId?: string | undefined;\n readonly policies: PrincipalPolicyCheckpointEvidence[];\n readonly authorizationPolicies: VerifiedPrincipalPolicySelection[];\n // Served bundles whose manifests verified, stored at finalization.\n readonly verifiedBundles: VerifiedManifestBundle[];\n readonly verifiedHeads: VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: VerifiedAccessManifestCheckpointEvidence[];\n}\n\nexport function createProjectionCheckpointContext(input: {\n readonly execSql: ExecSql;\n readonly organizationId?: string | undefined;\n}): ProjectionCheckpointContext {\n if (typeof input.execSql !== \"function\") {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection verification requires durable keying checkpoint storage\",\n );\n }\n\n return {\n heldContainerHeads: [],\n execSql: input.execSql,\n localCheckpoints: new Map(),\n organizationId: input.organizationId,\n policies: [],\n authorizationPolicies: [],\n verifiedBundles: [],\n verifiedHeads: [],\n verifiedManifests: [],\n };\n}\n\nexport function observeAccessManifestCheckpoints(\n context: ProjectionCheckpointContext,\n input: {\n readonly verifiedHeads: readonly VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: readonly VerifiedAccessManifestCheckpointEvidence[];\n },\n): void {\n context.verifiedHeads.push(...input.verifiedHeads);\n context.verifiedManifests.push(...input.verifiedManifests);\n}\n\n/**\n * Records each served bundle whose manifest this verification produced, so\n * the transaction finalizing the checkpoints also stores it for later\n * citation. A bundle the projection carried but verification never reached\n * is skipped.\n */\nexport function observeVerifiedProjectionBundles(\n context: ProjectionCheckpointContext,\n bundlesByHash: ReadonlyMap<string, AccessManifestBundleWireResponse>,\n verifiedByHash: ReadonlyMap<\n string,\n { readonly checkpoint: AccessManifestCheckpoint }\n >,\n): void {\n for (const [manifestHash, bundle] of bundlesByHash) {\n const verified = verifiedByHash.get(manifestHash);\n if (verified)\n context.verifiedBundles.push({ bundle, checkpoint: verified.checkpoint });\n }\n}\n\nexport function observePrincipalPolicy(\n context: ProjectionCheckpointContext,\n policy: PrincipalPolicyCheckpointEvidence,\n organizationId?: string | undefined,\n): void {\n if (\n organizationId !== undefined &&\n context.organizationId !== undefined &&\n context.organizationId !== organizationId\n ) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"projection checkpoint batch crosses organization ownership\",\n );\n }\n context.organizationId ??= organizationId;\n context.policies.push(policy);\n}\n\nexport async function commitProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input?: {\n readonly documentPurgeCheckpoint?: DocumentPurgeCheckpoint | undefined;\n readonly execSql?: ExecSql | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n input = {\n ...input,\n stillCurrent: projectionLifetimeGuard(context, input?.stillCurrent),\n };\n assertProjectionVerificationCurrent(input?.stillCurrent);\n await enforceAccessManifestCheckpoints({\n documentPurgeCheckpoint: input?.documentPurgeCheckpoint,\n execSql: input?.execSql ?? context.execSql,\n organizationId: context.organizationId,\n policies: context.policies,\n authorizationPolicies: context.authorizationPolicies,\n stillCurrent: input?.stillCurrent,\n verifiedBundles: context.verifiedBundles,\n verifiedHeads: context.verifiedHeads,\n verifiedManifests: context.verifiedManifests,\n }).catch((error: unknown) => {\n if (error instanceof PrincipalAuthorizationCheckpointUnavailableError)\n throw new ProjectionDependencyUnavailableError(error.message);\n throw error;\n });\n assertProjectionVerificationCurrent(input?.stillCurrent);\n}\n\n/** Validates against the latest durable pins without persisting new heads. */\nasync function validateProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input?: {\n readonly execSql?: ExecSql | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n input = {\n ...input,\n stillCurrent: projectionLifetimeGuard(context, input?.stillCurrent),\n };\n assertProjectionVerificationCurrent(input?.stillCurrent);\n await validateAccessManifestCheckpoints({\n execSql: input?.execSql ?? context.execSql,\n policies: context.policies,\n authorizationPolicies: context.authorizationPolicies,\n stillCurrent: input?.stillCurrent,\n verifiedBundles: context.verifiedBundles,\n verifiedHeads: context.verifiedHeads,\n verifiedManifests: context.verifiedManifests,\n }).catch((error: unknown) => {\n if (error instanceof PrincipalAuthorizationCheckpointUnavailableError)\n throw new ProjectionDependencyUnavailableError(error.message);\n throw error;\n });\n assertProjectionVerificationCurrent(input?.stillCurrent);\n}\n\nexport async function finalizeProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input: {\n readonly execSql?: ExecSql | undefined;\n readonly persistVerificationCheckpoints?: boolean | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n if (input.persistVerificationCheckpoints === false) {\n await validateProjectionCheckpoints(context, input);\n return;\n }\n await commitProjectionCheckpoints(context, input);\n if (input.stillCurrent?.() === false) return;\n const organizationId =\n context.organizationId ??\n context.heldContainerHeads[0]?.state.organizationId;\n if (organizationId === undefined) return;\n try {\n rememberVerifiedContainerHeads({\n organizationId,\n execSql: input.execSql ?? context.execSql,\n heads: context.heldContainerHeads,\n policies: context.policies,\n });\n } catch {\n // Checkpoints are already committed. Optional re-citation evidence must\n // never change successful verification into a caller-visible refusal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KAAK,CAAC,8BAA8B,KAAK,KAAK,EAAE,CAAC;QACnD,MAAM,6BAA6B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IACD,MAAM,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO;IAC7C,MAAM,cAAc,GAClB,OAAO,CAAC,cAAc;QACtB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC;IACtD,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO;IACzC,IAAI,CAAC;QACH,8BAA8B,CAAC;YAC7B,cAAc;YACd,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO;YACzC,KAAK,EAAE,OAAO,CAAC,kBAAkB;YACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;QACxE,sEAAsE;IACxE,CAAC;AACH,CAAC","sourcesContent":["import {\n type AccessManifestCheckpoint,\n KeyingVerificationError,\n type VerifiedAccessManifestCheckpointEvidence,\n type VerifiedContainerAccessManifest,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport type { AccessManifestBundleWireResponse } from \"@tearleads/validators/response\";\nimport { rememberVerifiedContainerHeads } from \"../../containers/shared/heldContainerHeads\";\nimport type { DocumentPurgeCheckpoint } from \"../../persistence/keyingCheckpoints/documentPurgeCheckpointPersistence\";\nimport { PrincipalAuthorizationCheckpointUnavailableError } from \"../../persistence/keyingCheckpoints/principalAuthorizationCheckpoints\";\nimport type { VerifiedManifestBundle } from \"../../persistence/verifiedManifestBundlePersistence\";\nimport type { PrincipalPolicyCheckpointEvidence } from \"../../principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport { ProjectionDependencyUnavailableError } from \"../dependencyUnavailable\";\nimport { projectionLifetimeGuard } from \"../projectionLifetimes\";\nimport { assertProjectionVerificationCurrent } from \"../types\";\nimport {\n enforceAccessManifestCheckpoints,\n validateAccessManifestCheckpoints,\n} from \"./accessManifestCheckpointEnforcement\";\n\nexport interface ProjectionCheckpointContext {\n readonly heldContainerHeads: VerifiedContainerAccessManifest[];\n readonly execSql: ExecSql;\n // Local checkpoints read during this verification, one read per object.\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n organizationId?: string | undefined;\n readonly policies: PrincipalPolicyCheckpointEvidence[];\n readonly authorizationPolicies: VerifiedPrincipalPolicySelection[];\n // Served bundles whose manifests verified, stored at finalization.\n readonly verifiedBundles: VerifiedManifestBundle[];\n readonly verifiedHeads: VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: VerifiedAccessManifestCheckpointEvidence[];\n}\n\nexport function createProjectionCheckpointContext(input: {\n readonly execSql: ExecSql;\n readonly organizationId?: string | undefined;\n}): ProjectionCheckpointContext {\n if (typeof input.execSql !== \"function\") {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection verification requires durable keying checkpoint storage\",\n );\n }\n\n return {\n heldContainerHeads: [],\n execSql: input.execSql,\n localCheckpoints: new Map(),\n organizationId: input.organizationId,\n policies: [],\n authorizationPolicies: [],\n verifiedBundles: [],\n verifiedHeads: [],\n verifiedManifests: [],\n };\n}\n\nexport function observeAccessManifestCheckpoints(\n context: ProjectionCheckpointContext,\n input: {\n readonly verifiedHeads: readonly VerifiedAccessManifestCheckpointEvidence[];\n readonly verifiedManifests: readonly VerifiedAccessManifestCheckpointEvidence[];\n },\n): void {\n context.verifiedHeads.push(...input.verifiedHeads);\n context.verifiedManifests.push(...input.verifiedManifests);\n}\n\n/**\n * Records each served bundle whose manifest this verification produced, so\n * the transaction finalizing the checkpoints also stores it for later\n * citation. A bundle the projection carried but verification never reached\n * is skipped.\n */\nexport function observeVerifiedProjectionBundles(\n context: ProjectionCheckpointContext,\n bundlesByHash: ReadonlyMap<string, AccessManifestBundleWireResponse>,\n verifiedByHash: ReadonlyMap<\n string,\n { readonly checkpoint: AccessManifestCheckpoint }\n >,\n): void {\n for (const [manifestHash, bundle] of bundlesByHash) {\n const verified = verifiedByHash.get(manifestHash);\n if (verified)\n context.verifiedBundles.push({ bundle, checkpoint: verified.checkpoint });\n }\n}\n\nexport function observePrincipalPolicy(\n context: ProjectionCheckpointContext,\n policy: PrincipalPolicyCheckpointEvidence,\n organizationId?: string | undefined,\n): void {\n if (\n organizationId !== undefined &&\n context.organizationId !== undefined &&\n context.organizationId !== organizationId\n ) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"projection checkpoint batch crosses organization ownership\",\n );\n }\n context.organizationId ??= organizationId;\n context.policies.push(policy);\n}\n\nexport async function commitProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input?: {\n readonly documentPurgeCheckpoint?: DocumentPurgeCheckpoint | undefined;\n readonly execSql?: ExecSql | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n input = {\n ...input,\n stillCurrent: projectionLifetimeGuard(context, input?.stillCurrent),\n };\n assertProjectionVerificationCurrent(input?.stillCurrent);\n await enforceAccessManifestCheckpoints({\n documentPurgeCheckpoint: input?.documentPurgeCheckpoint,\n execSql: input?.execSql ?? context.execSql,\n organizationId: context.organizationId,\n policies: context.policies,\n authorizationPolicies: context.authorizationPolicies,\n stillCurrent: input?.stillCurrent,\n verifiedBundles: context.verifiedBundles,\n verifiedHeads: context.verifiedHeads,\n verifiedManifests: context.verifiedManifests,\n }).catch((error: unknown) => {\n if (error instanceof PrincipalAuthorizationCheckpointUnavailableError)\n throw new ProjectionDependencyUnavailableError(error.message);\n throw error;\n });\n assertProjectionVerificationCurrent(input?.stillCurrent);\n}\n\n/** Validates against the latest durable pins without persisting new heads. */\nasync function validateProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input?: {\n readonly execSql?: ExecSql | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n input = {\n ...input,\n stillCurrent: projectionLifetimeGuard(context, input?.stillCurrent),\n };\n assertProjectionVerificationCurrent(input?.stillCurrent);\n await validateAccessManifestCheckpoints({\n execSql: input?.execSql ?? context.execSql,\n policies: context.policies,\n authorizationPolicies: context.authorizationPolicies,\n stillCurrent: input?.stillCurrent,\n verifiedBundles: context.verifiedBundles,\n verifiedHeads: context.verifiedHeads,\n verifiedManifests: context.verifiedManifests,\n }).catch((error: unknown) => {\n if (error instanceof PrincipalAuthorizationCheckpointUnavailableError)\n throw new ProjectionDependencyUnavailableError(error.message);\n throw error;\n });\n assertProjectionVerificationCurrent(input?.stillCurrent);\n}\n\nexport async function finalizeProjectionCheckpoints(\n context: ProjectionCheckpointContext,\n input: {\n readonly execSql?: ExecSql | undefined;\n readonly persistVerificationCheckpoints?: boolean | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n },\n): Promise<void> {\n if (input.persistVerificationCheckpoints === false) {\n await validateProjectionCheckpoints(context, input);\n return;\n }\n await commitProjectionCheckpoints(context, input);\n if (input.stillCurrent?.() === false) return;\n const organizationId =\n context.organizationId ??\n context.heldContainerHeads[0]?.state.organizationId;\n if (organizationId === undefined) return;\n try {\n rememberVerifiedContainerHeads({\n organizationId,\n execSql: input.execSql ?? context.execSql,\n heads: context.heldContainerHeads,\n policies: context.policies,\n });\n } catch {\n // Checkpoints are already committed. Optional re-citation evidence must\n // never change successful verification into a caller-visible refusal.\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { verifyAccessManifestLocalCheckpoint, } from "../../../internal/crypto/index.js";
|
|
2
|
-
import { loadAccessManifestCheckpoint } from "../../persistence/keyingCheckpointPersistence.js";
|
|
2
|
+
import { loadAccessManifestCheckpoint } from "../../persistence/keyingCheckpoints/keyingCheckpointPersistence.js";
|
|
3
3
|
/**
|
|
4
4
|
* The local checkpoint for one object, read once per verification: every
|
|
5
5
|
* checkpoint-enforced element of a served path reads its own checkpoint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifestCheckpointVerification.js","sourceRoot":"","sources":["manifestCheckpointVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mCAAmC,GACpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"manifestCheckpointVerification.js","sourceRoot":"","sources":["manifestCheckpointVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mCAAmC,GACpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iEAAiE,CAAC;AAG/G;;;;GAIG;AACH,KAAK,UAAU,iCAAiC,CAAC,KAMhD;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,KAAK,CAAC,UAAU;QAChB,KAAK,CAAC,cAAc;QACpB,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,4BAA4B,CAC/C,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,QAAQ,CACf,CAAC;IACF,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AASD,SAAS,uBAAuB,CAAC,KAIhC;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC;IAC7C,OAAO,CACL,SAAS,CAAC,UAAU,KAAK,KAAK,CAAC,OAAO,CAAC,UAAU;QACjD,SAAS,CAAC,cAAc,KAAK,KAAK,CAAC,OAAO,CAAC,cAAc;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BAAgB;QACxC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAC;IACH,mCAAmC,CAAC;QAClC,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;QACzD,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU;YAC3B,oBAAoB,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;SAClE;QACD,eAAe,EAAE,UAAU,CAAC,eAAe;KAC5C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type AccessManifest,\n type AccessManifestCheckpoint,\n type VerifiedAccessManifestCheckpointEvidence,\n verifyAccessManifestLocalCheckpoint,\n} from \"@tearleads/crypto\";\nimport { loadAccessManifestCheckpoint } from \"../../persistence/keyingCheckpoints/keyingCheckpointPersistence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\n\n/**\n * The local checkpoint for one object, read once per verification: every\n * checkpoint-enforced element of a served path reads its own checkpoint,\n * and the atomic advance re-validates every checkpoint at commit.\n */\nasync function loadLocalAccessManifestCheckpoint(input: {\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly objectId: string;\n readonly objectKind: AccessManifest[\"objectKind\"];\n readonly organizationId: string;\n}): Promise<AccessManifestCheckpoint | null> {\n const key = JSON.stringify([\n input.objectKind,\n input.organizationId,\n input.objectId,\n ]);\n const cached = input.localCheckpoints.get(key);\n if (cached !== undefined) return cached;\n const loaded = await loadAccessManifestCheckpoint(\n input.execSql,\n input.objectKind,\n input.organizationId,\n input.objectId,\n );\n input.localCheckpoints.set(key, loaded);\n return loaded;\n}\n\ninterface ManifestCheckpointVerificationInput<\n TManifest extends VerifiedAccessManifestCheckpointEvidence,\n> {\n readonly checkpointPredecessors: readonly TManifest[];\n readonly localCheckpoint: AccessManifestCheckpoint | null;\n}\n\nfunction isCheckpointPredecessor(input: {\n readonly candidate: VerifiedAccessManifestCheckpointEvidence;\n readonly current: AccessManifest;\n readonly localCheckpoint: AccessManifestCheckpoint;\n}): boolean {\n const candidate = input.candidate.checkpoint;\n return (\n candidate.objectKind === input.current.objectKind &&\n candidate.organizationId === input.current.organizationId &&\n candidate.objectId === input.current.objectId &&\n candidate.epoch > input.localCheckpoint.epoch &&\n candidate.epoch < input.current.epoch\n );\n}\n\nexport async function loadManifestCheckpointVerification<\n TManifest extends VerifiedAccessManifestCheckpointEvidence,\n>(input: {\n readonly current: AccessManifest;\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly verifiedManifests: ReadonlyMap<string, TManifest>;\n}): Promise<ManifestCheckpointVerificationInput<TManifest>> {\n const localCheckpoint = await loadLocalAccessManifestCheckpoint({\n execSql: input.execSql,\n localCheckpoints: input.localCheckpoints,\n objectId: input.current.objectId,\n objectKind: input.current.objectKind,\n organizationId: input.current.organizationId,\n });\n const checkpointPredecessors = localCheckpoint\n ? [...input.verifiedManifests.values()]\n .filter((candidate) =>\n isCheckpointPredecessor({\n candidate,\n current: input.current,\n localCheckpoint,\n }),\n )\n .sort((left, right) => left.checkpoint.epoch - right.checkpoint.epoch)\n : [];\n return { checkpointPredecessors, localCheckpoint };\n}\n\nexport async function verifyCachedManifestCheckpoint(input: {\n readonly current: VerifiedAccessManifestCheckpointEvidence;\n readonly execSql: ExecSql;\n readonly localCheckpoints: Map<string, AccessManifestCheckpoint | null>;\n readonly verifiedManifests: ReadonlyMap<\n string,\n VerifiedAccessManifestCheckpointEvidence\n >;\n}): Promise<void> {\n const checkpoint = await loadManifestCheckpointVerification({\n current: input.current.manifest,\n execSql: input.execSql,\n localCheckpoints: input.localCheckpoints,\n verifiedManifests: input.verifiedManifests,\n });\n verifyAccessManifestLocalCheckpoint({\n checkpointPredecessors: checkpoint.checkpointPredecessors,\n current: {\n ...input.current.checkpoint,\n previousManifestHash: input.current.manifest.previousManifestHash,\n },\n localCheckpoint: checkpoint.localCheckpoint,\n });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { validateAccessManifestCheckpointEvidence } from "../../persistence/keyingCheckpointEvidence.js";
|
|
2
|
-
import { accessManifestObjectKey, loadAccessManifestCheckpoint, } from "../../persistence/keyingCheckpointPersistence.js";
|
|
3
|
-
import { PrincipalAuthorizationCheckpointUnavailableError, validatePrincipalAuthorizationCheckpoints, } from "../../persistence/principalAuthorizationCheckpoints.js";
|
|
4
|
-
import { ensurePrincipalPolicyTables } from "../../persistence/principalPolicyPersistence.js";
|
|
1
|
+
import { validateAccessManifestCheckpointEvidence } from "../../persistence/keyingCheckpoints/keyingCheckpointEvidence.js";
|
|
2
|
+
import { accessManifestObjectKey, loadAccessManifestCheckpoint, } from "../../persistence/keyingCheckpoints/keyingCheckpointPersistence.js";
|
|
3
|
+
import { PrincipalAuthorizationCheckpointUnavailableError, validatePrincipalAuthorizationCheckpoints, } from "../../persistence/keyingCheckpoints/principalAuthorizationCheckpoints.js";
|
|
4
|
+
import { ensurePrincipalPolicyTables } from "../../persistence/principalPolicy/principalPolicyPersistence.js";
|
|
5
5
|
import { registerClientSQLiteCommitGuard } from "../../sqlite/sqliteCommitGuards.js";
|
|
6
6
|
import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
|
|
7
7
|
import { runSerializedSqlMutation } from "../../sqlite/sqlSchema.js";
|