@tearleads/client-sdk 0.1.63 → 0.1.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. package/data/documents/blob/shared/projection.js +1 -1
  2. package/data/documents/blob/shared/projection.js.map +1 -1
  3. package/data/documents/shared/projectionContentKeys.js +1 -1
  4. package/data/documents/shared/projectionContentKeys.js.map +1 -1
  5. package/data/documents/shared/syncResponseAuthorization.js +1 -1
  6. package/data/documents/shared/syncResponseAuthorization.js.map +1 -1
  7. package/data/keyingProjectionVerification/{accessManifestCheckpointEnforcement.js → checkpoints/accessManifestCheckpointEnforcement.js} +2 -2
  8. package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
  9. package/data/keyingProjectionVerification/{bundleVerification.js → checkpoints/bundleVerification.js} +5 -5
  10. package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
  11. package/data/keyingProjectionVerification/{checkpointContext.d.ts → checkpoints/checkpointContext.d.ts} +6 -6
  12. package/data/keyingProjectionVerification/{checkpointContext.js → checkpoints/checkpointContext.js} +6 -6
  13. package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
  14. package/data/keyingProjectionVerification/{manifestCheckpointVerification.js → checkpoints/manifestCheckpointVerification.js} +2 -2
  15. package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
  16. package/data/keyingProjectionVerification/{containerAncestorCitations.js → container/containerAncestorCitations.js} +4 -4
  17. package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
  18. package/data/keyingProjectionVerification/{containerCreateManifest.js → container/containerCreateManifest.js} +1 -1
  19. package/data/keyingProjectionVerification/{containerDestinationVerification.js → container/containerDestinationVerification.js} +4 -4
  20. package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
  21. package/data/keyingProjectionVerification/{containerManifestVerification.js → container/containerManifestVerification.js} +7 -7
  22. package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
  23. package/data/keyingProjectionVerification/{containerPathVerification.js → container/containerPathVerification.js} +2 -2
  24. package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
  25. package/data/keyingProjectionVerification/{containerProjectionVerification.d.ts → container/containerProjectionVerification.d.ts} +7 -7
  26. package/data/keyingProjectionVerification/{containerProjectionVerification.js → container/containerProjectionVerification.js} +9 -9
  27. package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
  28. package/data/keyingProjectionVerification/{documentDependencyPaths.d.ts → document/documentDependencyPaths.d.ts} +1 -1
  29. package/data/keyingProjectionVerification/{documentDependencyPaths.js → document/documentDependencyPaths.js} +3 -3
  30. package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
  31. package/data/keyingProjectionVerification/{documentManifestPolicies.js → document/documentManifestPolicies.js} +2 -2
  32. package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
  33. package/data/keyingProjectionVerification/{documentManifestPredecessor.js → document/documentManifestPredecessor.js} +1 -1
  34. package/data/keyingProjectionVerification/{documentManifestVerification.js → document/documentManifestVerification.js} +5 -5
  35. package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
  36. package/data/keyingProjectionVerification/{documentProjectionVerification.d.ts → document/documentProjectionVerification.d.ts} +4 -4
  37. package/data/keyingProjectionVerification/{documentProjectionVerification.js → document/documentProjectionVerification.js} +9 -9
  38. package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
  39. package/data/keyingProjectionVerification/{documentPurgeCheckpointCurrency.js → documentPurge/documentPurgeCheckpointCurrency.js} +12 -12
  40. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
  41. package/data/keyingProjectionVerification/{documentPurgeCheckpointEnforcement.js → documentPurge/documentPurgeCheckpointEnforcement.js} +2 -2
  42. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
  43. package/data/keyingProjectionVerification/{documentPurgeDocumentChainVerification.js → documentPurge/documentPurgeDocumentChainVerification.js} +8 -8
  44. package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
  45. package/data/keyingProjectionVerification/{documentPurgePolicyCheckpoints.js → documentPurge/documentPurgePolicyCheckpoints.js} +2 -2
  46. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
  47. package/data/keyingProjectionVerification/{documentPurgePolicyCurrency.js → documentPurge/documentPurgePolicyCurrency.js} +4 -4
  48. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
  49. package/data/keyingProjectionVerification/{documentPurgePrincipalEvidence.js → documentPurge/documentPurgePrincipalEvidence.js} +3 -3
  50. package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
  51. package/data/keyingProjectionVerification/{documentPurgeProofVerification.d.ts → documentPurge/documentPurgeProofVerification.d.ts} +5 -5
  52. package/data/keyingProjectionVerification/{documentPurgeProofVerification.js → documentPurge/documentPurgeProofVerification.js} +10 -10
  53. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
  54. package/data/keyingProjectionVerification/index.d.ts +4 -4
  55. package/data/keyingProjectionVerification/index.js +4 -4
  56. package/data/keyingProjectionVerification/index.js.map +1 -1
  57. package/data/keyingProjectionVerification/{mergeProjectionPolicyEvidence.js → principalPolicy/mergeProjectionPolicyEvidence.js} +2 -2
  58. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
  59. package/data/keyingProjectionVerification/{organizationFounderBinding.js → principalPolicy/organizationFounderBinding.js} +3 -3
  60. package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
  61. package/data/keyingProjectionVerification/{principalPolicyCache.js → principalPolicy/principalPolicyCache.js} +6 -6
  62. package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
  63. package/data/keyingProjectionVerification/{principalPolicyVerification.js → principalPolicy/principalPolicyVerification.js} +12 -12
  64. package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
  65. package/data/keyingProjectionVerification/{projectionAuthorizationEvidence.js → principalPolicy/projectionAuthorizationEvidence.js} +3 -3
  66. package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
  67. package/data/keyingProjectionVerification/{projectionPolicyEvidence.js → principalPolicy/projectionPolicyEvidence.js} +3 -3
  68. package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
  69. package/data/keyingProjectionVerification/{resolvedPrincipalPolicy.js → principalPolicy/resolvedPrincipalPolicy.js} +6 -6
  70. package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
  71. package/package.json +1 -1
  72. package/stores/container-contents/accessRestorationSweep.js +1 -1
  73. package/stores/container-contents/accessRestorationSweep.js.map +1 -1
  74. package/stores/container-contents/containerContentsStore.d.ts +1 -1
  75. package/stores/container-contents/containerContentsStore.js +12 -12
  76. package/stores/container-contents/containerContentsStore.js.map +1 -1
  77. package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
  78. package/stores/container-contents/{containerStatePersistence.js → containerState/containerStatePersistence.js} +2 -2
  79. package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
  80. package/stores/container-contents/{missingContainerState.js → containerState/missingContainerState.js} +1 -1
  81. package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
  82. package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
  83. package/stores/container-contents/{reconcilableContainer.d.ts → containerState/reconcilableContainer.d.ts} +1 -1
  84. package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
  85. package/stores/container-contents/{documentRecovery.js → documentWork/documentRecovery.js} +6 -6
  86. package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
  87. package/stores/container-contents/{documentRotation.js → documentWork/documentRotation.js} +2 -2
  88. package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
  89. package/stores/container-contents/{documentWork.js → documentWork/index.js} +1 -1
  90. package/stores/container-contents/documentWork/index.js.map +1 -0
  91. package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js} +3 -3
  92. package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
  93. package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js} +3 -3
  94. package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
  95. package/stores/container-contents/{startupHydration.js → hydration/startupHydration.js} +3 -3
  96. package/stores/container-contents/hydration/startupHydration.js.map +1 -0
  97. package/stores/container-contents/index.d.ts +3 -3
  98. package/stores/container-contents/index.js +2 -2
  99. package/stores/container-contents/index.js.map +1 -1
  100. package/stores/container-contents/localRefresh.js +2 -2
  101. package/stores/container-contents/localRefresh.js.map +1 -1
  102. package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js} +4 -4
  103. package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
  104. package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
  105. package/stores/container-contents/{groupRewrapOperation.js → operations/groupRewrapOperation.js} +2 -2
  106. package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
  107. package/stores/container-contents/{operations.js → operations/index.js} +18 -18
  108. package/stores/container-contents/operations/index.js.map +1 -0
  109. package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
  110. package/stores/container-contents/{reportShareFailure.js → operations/reportShareFailure.js} +4 -4
  111. package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
  112. package/stores/container-contents/{setContainerIconOperation.js → operations/setContainerIconOperation.js} +6 -6
  113. package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
  114. package/stores/container-contents/{shareOperations.js → operations/shareOperations.js} +6 -6
  115. package/stores/container-contents/operations/shareOperations.js.map +1 -0
  116. package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
  117. package/stores/container-contents/{remoteContainerIngestion.js → remoteEvents/remoteContainerIngestion.js} +4 -4
  118. package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
  119. package/stores/container-contents/{remoteEventProjectionInvalidation.js → remoteEvents/remoteEventProjectionInvalidation.js} +1 -1
  120. package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
  121. package/stores/container-contents/{remoteEventSync.js → remoteEvents/remoteEventSync.js} +4 -4
  122. package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
  123. package/stores/container-contents/{remoteWriteGuards.js → remoteWrites/remoteWriteGuards.js} +2 -2
  124. package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
  125. package/stores/container-contents/{remoteWriteQueue.js → remoteWrites/remoteWriteQueue.js} +1 -1
  126. package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
  127. package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
  128. package/stores/container-contents/state.d.ts +1 -1
  129. package/stores/container-contents/state.js +2 -2
  130. package/stores/container-contents/state.js.map +1 -1
  131. package/stores/container-contents/{syncAgent.d.ts → syncAgent/index.d.ts} +2 -2
  132. package/stores/container-contents/{syncAgent.js → syncAgent/index.js} +14 -14
  133. package/stores/container-contents/syncAgent/index.js.map +1 -0
  134. package/stores/container-contents/{metadataSyncSignal.js → syncAgent/metadataSyncSignal.js} +1 -1
  135. package/stores/container-contents/{metadataSyncSignal.js.map → syncAgent/metadataSyncSignal.js.map} +1 -1
  136. package/stores/container-contents/{syncAgentTypes.d.ts → syncAgent/syncAgentTypes.d.ts} +5 -5
  137. package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
  138. package/stores/container-contents/{syncLaneIteration.js → syncAgent/syncLaneIteration.js} +11 -11
  139. package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
  140. package/stores/container-contents/{existingSystemContainer.js → systemContainers/existingSystemContainer.js} +4 -4
  141. package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
  142. package/stores/container-contents/{organizationMetadataSystemContainer.js → systemContainers/organizationMetadataSystemContainer.js} +2 -2
  143. package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
  144. package/stores/container-contents/{systemContainerHydration.js → systemContainers/systemContainerHydration.js} +3 -3
  145. package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
  146. package/stores/container-contents/{systemContainerIcon.js → systemContainers/systemContainerIcon.js} +5 -5
  147. package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
  148. package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
  149. package/stores/container-contents/{systemContainerPostCreate.js → systemContainers/systemContainerPostCreate.js} +2 -2
  150. package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
  151. package/stores/container-contents/{systemContainerPromotion.js → systemContainers/systemContainerPromotion.js} +1 -1
  152. package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
  153. package/stores/container-contents/types.d.ts +2 -2
  154. package/stores/container-contents/types.js.map +1 -1
  155. package/stores/documents/documentStore/{attachmentSourceUpload.js → attachmentUpload/attachmentSourceUpload.js} +4 -4
  156. package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
  157. package/stores/documents/documentStore/{attachmentStaging.js → attachmentUpload/attachmentStaging.js} +5 -5
  158. package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
  159. package/stores/documents/documentStore/{attachmentUploadAttempt.js → attachmentUpload/attachmentUploadAttempt.js} +2 -2
  160. package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
  161. package/stores/documents/documentStore/{attachmentUploadLane.js → attachmentUpload/attachmentUploadLane.js} +1 -1
  162. package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
  163. package/stores/documents/documentStore/{attachmentUploadResume.js → attachmentUpload/attachmentUploadResume.js} +4 -4
  164. package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
  165. package/stores/documents/documentStore/{attachmentDetachState.js → attachments/attachmentDetachState.js} +1 -1
  166. package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
  167. package/stores/documents/documentStore/{attachmentHydration.js → attachments/attachmentHydration.js} +5 -5
  168. package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
  169. package/stores/documents/documentStore/{attachmentHydrationCommit.js → attachments/attachmentHydrationCommit.js} +3 -3
  170. package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
  171. package/stores/documents/documentStore/{attachmentIntents.js → attachments/attachmentIntents.js} +2 -2
  172. package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
  173. package/stores/documents/documentStore/{attachmentMutationPersistence.js → attachments/attachmentMutationPersistence.js} +4 -4
  174. package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
  175. package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
  176. package/stores/documents/documentStore/{attachmentPersistence.js → attachments/attachmentPersistence.js} +4 -4
  177. package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
  178. package/stores/documents/documentStore/{attachmentRemoval.js → attachments/attachmentRemoval.js} +11 -11
  179. package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
  180. package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
  181. package/stores/documents/documentStore/{attachmentWriteGeneration.js → attachments/attachmentWriteGeneration.js} +2 -2
  182. package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
  183. package/stores/documents/documentStore/{attachments.js → attachments/index.js} +11 -11
  184. package/stores/documents/documentStore/attachments/index.js.map +1 -0
  185. package/stores/documents/documentStore/{documentHistoryCompaction.js → history/documentHistoryCompaction.js} +4 -4
  186. package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
  187. package/stores/documents/documentStore/{durableDocumentReload.js → history/durableDocumentReload.js} +6 -6
  188. package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
  189. package/stores/documents/documentStore/{historyRebuild.js → history/historyRebuild.js} +6 -6
  190. package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
  191. package/stores/documents/{documentStore.d.ts → documentStore/index.d.ts} +5 -5
  192. package/stores/documents/{documentStore.js → documentStore/index.js} +18 -18
  193. package/stores/documents/documentStore/index.js.map +1 -0
  194. package/stores/documents/documentStore/{deferredInitialUpdate.js → initialization/deferredInitialUpdate.js} +9 -9
  195. package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
  196. package/stores/documents/documentStore/{initialization.js → initialization/index.js} +14 -14
  197. package/stores/documents/documentStore/initialization/index.js.map +1 -0
  198. package/stores/documents/documentStore/{initializationAttachments.js → initialization/initializationAttachments.js} +1 -1
  199. package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
  200. package/stores/documents/documentStore/{initializationHistory.js → initialization/initializationHistory.js} +3 -3
  201. package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
  202. package/stores/documents/documentStore/{initializationRecovery.js → initialization/initializationRecovery.js} +7 -7
  203. package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
  204. package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
  205. package/stores/documents/documentStore/mutations.js +2 -2
  206. package/stores/documents/documentStore/mutations.js.map +1 -1
  207. package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
  208. package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
  209. package/stores/documents/documentStore/persistence.js +3 -3
  210. package/stores/documents/documentStore/persistence.js.map +1 -1
  211. package/stores/documents/documentStore/{rotation.js → rotation/index.js} +14 -14
  212. package/stores/documents/documentStore/rotation/index.js.map +1 -0
  213. package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js} +2 -2
  214. package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
  215. package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js} +9 -9
  216. package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
  217. package/stores/documents/documentStore/rows.js +2 -2
  218. package/stores/documents/documentStore/rows.js.map +1 -1
  219. package/stores/documents/documentStore/state.js +1 -1
  220. package/stores/documents/documentStore/state.js.map +1 -1
  221. package/stores/documents/documentStore/{sync.js → sync/index.js} +7 -7
  222. package/stores/documents/documentStore/sync/index.js.map +1 -0
  223. package/stores/documents/documentStore/{pullContinuationInvalidation.js → sync/pullContinuationInvalidation.js} +3 -3
  224. package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
  225. package/stores/documents/documentStore/{remoteRevalidationTelemetry.js → sync/remoteRevalidationTelemetry.js} +1 -1
  226. package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
  227. package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
  228. package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
  229. package/stores/documents/documentStore/{syncAttachmentSettlement.js → sync/syncAttachmentSettlement.js} +3 -3
  230. package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
  231. package/stores/documents/documentStore/{syncAttachments.js → sync/syncAttachments.js} +7 -7
  232. package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
  233. package/stores/documents/documentStore/{syncDetachedAttachments.js → sync/syncDetachedAttachments.js} +7 -7
  234. package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
  235. package/stores/documents/documentStore/{syncFinalize.js → sync/syncFinalize.js} +9 -9
  236. package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
  237. package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
  238. package/stores/documents/documentStore/{syncOutgoingCoverage.js → sync/syncOutgoingCoverage.js} +4 -4
  239. package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
  240. package/stores/documents/documentStore/{syncRemoteSignals.js → sync/syncRemoteSignals.js} +4 -4
  241. package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
  242. package/stores/documents/documentStore/{syncRequest.js → sync/syncRequest.js} +8 -8
  243. package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
  244. package/stores/documents/documentStore/{syncShared.js → sync/syncShared.js} +8 -8
  245. package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
  246. package/stores/documents/documentStore/{syncUpdateImport.js → sync/syncUpdateImport.js} +3 -3
  247. package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
  248. package/stores/documents/documentStore/{versionCoverage.js → sync/versionCoverage.js} +1 -1
  249. package/stores/documents/index.d.ts +1 -1
  250. package/stores/documents/index.js +1 -1
  251. package/stores/local-projection/localProjectionStore.d.ts +1 -1
  252. package/stores/local-projection/localProjectionStore.js +1 -1
  253. package/stores/local-projection/localProjectionStore.js.map +1 -1
  254. package/stores/local-projection/registry.d.ts +1 -1
  255. package/stores/local-projection/types.d.ts +1 -1
  256. package/workflows/blobs/hydration/decrypt.js +1 -1
  257. package/workflows/blobs/hydration/decrypt.js.map +1 -1
  258. package/workflows/container-contents/container-state/{createAdoption.js → create/createAdoption.js} +6 -6
  259. package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
  260. package/workflows/container-contents/container-state/{createChild.js → create/createChild.js} +7 -7
  261. package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
  262. package/workflows/container-contents/container-state/{createIntentDepth.js → create/createIntentDepth.js} +2 -2
  263. package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
  264. package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
  265. package/workflows/container-contents/container-state/{createIntentSync.js → create/createIntentSync.js} +7 -7
  266. package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
  267. package/workflows/container-contents/container-state/{createTerminalFailure.js → create/createTerminalFailure.js} +2 -2
  268. package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
  269. package/workflows/container-contents/container-state/{createWithMetadata.js → create/createWithMetadata.js} +9 -9
  270. package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
  271. package/workflows/container-contents/container-state/{createWithMetadataPlan.js → create/createWithMetadataPlan.js} +4 -4
  272. package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
  273. package/workflows/container-contents/container-state/{localPurgeScope.js → purge/localPurgeScope.js} +1 -1
  274. package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
  275. package/workflows/container-contents/container-state/{purgeTree.js → purge/purgeTree.js} +5 -5
  276. package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
  277. package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
  278. package/workflows/container-contents/container-state/{purgeTreeContainerDeletion.js → purge/purgeTreeContainerDeletion.js} +1 -1
  279. package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
  280. package/workflows/container-contents/container-state/{purgeTreeScope.js → purge/purgeTreeScope.js} +8 -8
  281. package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
  282. package/workflows/container-contents/container-state/{readLocalPurgeScope.js → purge/readLocalPurgeScope.js} +3 -3
  283. package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
  284. package/workflows/container-contents/container-state/remote.js +2 -2
  285. package/workflows/container-contents/container-state/remote.js.map +1 -1
  286. package/workflows/container-contents/container-state/{groupGrantVerification.js → share/groupGrantVerification.js} +8 -8
  287. package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
  288. package/workflows/container-contents/container-state/{groupShareEpoch.js → share/groupShareEpoch.js} +2 -2
  289. package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
  290. package/workflows/container-contents/container-state/{share.js → share/index.js} +8 -8
  291. package/workflows/container-contents/container-state/share/index.js.map +1 -0
  292. package/workflows/container-contents/container-state/{sharePersistence.js → share/sharePersistence.js} +3 -3
  293. package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
  294. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
  295. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
  296. package/workflows/container-contents/documentDiscovery/index.js +1 -1
  297. package/workflows/container-contents/documentDiscovery/index.js.map +1 -1
  298. package/workflows/container-contents/metadata/metadataSyncErrors.js +1 -1
  299. package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
  300. package/workflows/container-contents/remoteHydration/destination/destinationPrefetch.js.map +1 -0
  301. package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
  302. package/workflows/container-contents/remoteHydration/{destinationRootReload.js → destination/destinationRootReload.js} +1 -1
  303. package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
  304. package/workflows/container-contents/remoteHydration/{replacementBinding.js → destination/replacementBinding.js} +5 -5
  305. package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
  306. package/workflows/container-contents/remoteHydration/{verifiedDestination.js → destination/verifiedDestination.js} +9 -9
  307. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
  308. package/workflows/container-contents/remoteHydration/index.js +4 -4
  309. package/workflows/container-contents/remoteHydration/index.js.map +1 -1
  310. package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
  311. package/workflows/container-contents/remoteHydration/{laneFetchMarkers.js → lanes/laneFetchMarkers.js} +1 -1
  312. package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
  313. package/workflows/container-contents/remoteHydration/{parentLaneFetch.js → lanes/parentLaneFetch.js} +2 -2
  314. package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
  315. package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
  316. package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
  317. package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
  318. package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
  319. package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
  320. package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
  321. package/workflows/container-contents/remoteHydration/{insertRemoteContainer.js → remoteContainers/insertRemoteContainer.js} +6 -6
  322. package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
  323. package/workflows/container-contents/remoteHydration/{remoteContainerPageHydration.js → remoteContainers/remoteContainerPageHydration.js} +7 -7
  324. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
  325. package/workflows/container-contents/remoteHydration/{remoteContainerState.js → remoteContainers/remoteContainerState.js} +9 -9
  326. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
  327. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
  328. package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
  329. package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
  330. package/workflows/containers/child/{createProjection.d.ts → create/createProjection.d.ts} +2 -2
  331. package/workflows/containers/child/{createProjection.js → create/createProjection.js} +2 -2
  332. package/workflows/containers/child/create/createProjection.js.map +1 -0
  333. package/workflows/containers/child/{createSubmission.d.ts → create/createSubmission.d.ts} +7 -7
  334. package/workflows/containers/child/{createSubmission.js → create/createSubmission.js} +2 -2
  335. package/workflows/containers/child/create/createSubmission.js.map +1 -0
  336. package/workflows/containers/child/{create.d.ts → create/index.d.ts} +5 -5
  337. package/workflows/containers/child/{create.js → create/index.js} +15 -15
  338. package/workflows/containers/child/create/index.js.map +1 -0
  339. package/workflows/containers/child/{move.d.ts → move/index.d.ts} +5 -5
  340. package/workflows/containers/child/{move.js → move/index.js} +12 -12
  341. package/workflows/containers/child/move/index.js.map +1 -0
  342. package/workflows/containers/child/{moveArtifacts.js → move/moveArtifacts.js} +3 -3
  343. package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
  344. package/workflows/containers/child/{moveRotation.js → move/moveRotation.js} +3 -3
  345. package/workflows/containers/child/move/moveRotation.js.map +1 -0
  346. package/workflows/containers/child/{moveWraps.js → move/moveWraps.js} +5 -5
  347. package/workflows/containers/child/move/moveWraps.js.map +1 -0
  348. package/workflows/containers/child/mutationSubmit.js +1 -1
  349. package/workflows/containers/child/mutationSubmit.js.map +1 -1
  350. package/workflows/containers/child/{carriedDescendantRekeys.js → rekey/carriedDescendantRekeys.js} +4 -4
  351. package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
  352. package/workflows/containers/child/{rekey.d.ts → rekey/index.d.ts} +6 -6
  353. package/workflows/containers/child/{rekey.js → rekey/index.js} +13 -13
  354. package/workflows/containers/child/rekey/index.js.map +1 -0
  355. package/workflows/containers/child/{keyringOverrideLineage.d.ts → rekey/keyringOverrideLineage.d.ts} +1 -1
  356. package/workflows/containers/child/{keyringOverrideLineage.js → rekey/keyringOverrideLineage.js} +1 -1
  357. package/workflows/containers/child/{rekeyProjection.d.ts → rekey/rekeyProjection.d.ts} +2 -2
  358. package/workflows/containers/child/{rekeyProjection.js → rekey/rekeyProjection.js} +3 -3
  359. package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
  360. package/workflows/containers/child/{rekeyRemote.d.ts → rekey/rekeyRemote.d.ts} +6 -6
  361. package/workflows/containers/child/{rekeyRemote.js → rekey/rekeyRemote.js} +2 -2
  362. package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
  363. package/workflows/containers/child/revoke.js +5 -5
  364. package/workflows/containers/child/revoke.js.map +1 -1
  365. package/workflows/containers/child/{replacementPrincipalPolicyReferences.js → rotation/replacementPrincipalPolicyReferences.js} +2 -2
  366. package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
  367. package/workflows/containers/child/{rotationContext.js → rotation/rotationContext.js} +5 -5
  368. package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
  369. package/workflows/containers/child/{rotationPrincipalPolicies.js → rotation/rotationPrincipalPolicies.js} +2 -2
  370. package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
  371. package/workflows/containers/child/{rotationWraps.js → rotation/rotationWraps.js} +1 -1
  372. package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
  373. package/workflows/containers/child/{currentShareGrantMutation.js → share/currentShareGrantMutation.js} +6 -6
  374. package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
  375. package/workflows/containers/child/{currentSharePrincipalPolicy.js → share/currentSharePrincipalPolicy.js} +10 -10
  376. package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
  377. package/workflows/containers/child/{share.d.ts → share/index.d.ts} +8 -8
  378. package/workflows/containers/child/{share.js → share/index.js} +10 -10
  379. package/workflows/containers/child/share/index.js.map +1 -0
  380. package/workflows/containers/child/{runtimeCurrentGroupShare.js → share/runtimeCurrentGroupShare.js} +6 -6
  381. package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
  382. package/workflows/containers/child/{shareAncestorRepair.js → share/shareAncestorRepair.js} +4 -4
  383. package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
  384. package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts} +5 -5
  385. package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js} +7 -7
  386. package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
  387. package/workflows/containers/child/{sharePlanCore.d.ts → share/sharePlanCore.d.ts} +7 -7
  388. package/workflows/containers/child/{sharePlanCore.js → share/sharePlanCore.js} +6 -6
  389. package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
  390. package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts} +9 -9
  391. package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js} +13 -13
  392. package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
  393. package/workflows/containers/child/share/shareProjection.js.map +1 -0
  394. package/workflows/containers/index.d.ts +10 -10
  395. package/workflows/containers/index.js +10 -10
  396. package/workflows/containers/index.js.map +1 -1
  397. package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
  398. package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
  399. package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
  400. package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
  401. package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
  402. package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
  403. package/workflows/documents/purge/index.js +1 -1
  404. package/workflows/documents/purge/index.js.map +1 -1
  405. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
  406. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
  407. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
  408. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
  409. package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
  410. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
  411. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
  412. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
  413. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
  414. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
  415. package/workflows/principals/policyCache/index.js +1 -1
  416. package/workflows/principals/policyCache/index.js.map +1 -1
  417. package/workflows/principals/policyRepair.js +1 -1
  418. package/workflows/principals/policyRepair.js.map +1 -1
  419. package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
  420. package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
  421. package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
  422. package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
  423. package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
  424. package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
  425. package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
  426. package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
  427. package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
  428. package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
  429. package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
  430. package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
  431. package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
  432. package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
  433. package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
  434. package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
  435. package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
  436. package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
  437. package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
  438. package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
  439. package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
  440. package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
  441. package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
  442. package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
  443. package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
  444. package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
  445. package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
  446. package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
  447. package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
  448. package/stores/container-contents/backgroundHydration.js.map +0 -1
  449. package/stores/container-contents/containerPurgeCore.js.map +0 -1
  450. package/stores/container-contents/containerStateMap.js.map +0 -1
  451. package/stores/container-contents/containerStatePersistence.js.map +0 -1
  452. package/stores/container-contents/documentRecovery.js.map +0 -1
  453. package/stores/container-contents/documentRotation.js.map +0 -1
  454. package/stores/container-contents/documentWork.js.map +0 -1
  455. package/stores/container-contents/emptyTrashOperation.js.map +0 -1
  456. package/stores/container-contents/existingSystemContainer.js.map +0 -1
  457. package/stores/container-contents/groupRewrapOperation.js.map +0 -1
  458. package/stores/container-contents/missingContainerState.js.map +0 -1
  459. package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
  460. package/stores/container-contents/operations.js.map +0 -1
  461. package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
  462. package/stores/container-contents/purgeContainerOperation.js.map +0 -1
  463. package/stores/container-contents/reconcilableContainer.js.map +0 -1
  464. package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
  465. package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
  466. package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
  467. package/stores/container-contents/remoteEventSync.js.map +0 -1
  468. package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
  469. package/stores/container-contents/remoteWriteGuards.js.map +0 -1
  470. package/stores/container-contents/remoteWriteQueue.js.map +0 -1
  471. package/stores/container-contents/reportShareFailure.js.map +0 -1
  472. package/stores/container-contents/setContainerIconOperation.js.map +0 -1
  473. package/stores/container-contents/shareOperations.js.map +0 -1
  474. package/stores/container-contents/startupHydration.js.map +0 -1
  475. package/stores/container-contents/syncAgent.js.map +0 -1
  476. package/stores/container-contents/syncAgentTypes.js.map +0 -1
  477. package/stores/container-contents/syncLaneIteration.js.map +0 -1
  478. package/stores/container-contents/systemContainerHydration.js.map +0 -1
  479. package/stores/container-contents/systemContainerIcon.js.map +0 -1
  480. package/stores/container-contents/systemContainerLookup.js.map +0 -1
  481. package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
  482. package/stores/container-contents/systemContainerPromotion.js.map +0 -1
  483. package/stores/container-contents/writeGeneration.js.map +0 -1
  484. package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
  485. package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
  486. package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
  487. package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
  488. package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
  489. package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
  490. package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
  491. package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
  492. package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
  493. package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
  494. package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
  495. package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
  496. package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
  497. package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
  498. package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
  499. package/stores/documents/documentStore/attachments.js.map +0 -1
  500. package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
  501. package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
  502. package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
  503. package/stores/documents/documentStore/historyRebuild.js.map +0 -1
  504. package/stores/documents/documentStore/initialization.js.map +0 -1
  505. package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
  506. package/stores/documents/documentStore/initializationHistory.js.map +0 -1
  507. package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
  508. package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
  509. package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
  510. package/stores/documents/documentStore/remoteWork.js.map +0 -1
  511. package/stores/documents/documentStore/rotation.js.map +0 -1
  512. package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
  513. package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
  514. package/stores/documents/documentStore/sync.js.map +0 -1
  515. package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
  516. package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
  517. package/stores/documents/documentStore/syncAttachments.js.map +0 -1
  518. package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
  519. package/stores/documents/documentStore/syncFinalize.js.map +0 -1
  520. package/stores/documents/documentStore/syncGeneration.js.map +0 -1
  521. package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
  522. package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
  523. package/stores/documents/documentStore/syncRequest.js.map +0 -1
  524. package/stores/documents/documentStore/syncShared.js.map +0 -1
  525. package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
  526. package/stores/documents/documentStore.js.map +0 -1
  527. package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
  528. package/workflows/container-contents/container-state/createChild.js.map +0 -1
  529. package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
  530. package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
  531. package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
  532. package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
  533. package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
  534. package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
  535. package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
  536. package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
  537. package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
  538. package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
  539. package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
  540. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
  541. package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
  542. package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
  543. package/workflows/container-contents/container-state/share.js.map +0 -1
  544. package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
  545. package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
  546. package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
  547. package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
  548. package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
  549. package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
  550. package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
  551. package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
  552. package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
  553. package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
  554. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
  555. package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
  556. package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
  557. package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
  558. package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
  559. package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
  560. package/workflows/containers/child/create.js.map +0 -1
  561. package/workflows/containers/child/createProjection.js.map +0 -1
  562. package/workflows/containers/child/createSubmission.js.map +0 -1
  563. package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
  564. package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
  565. package/workflows/containers/child/move.js.map +0 -1
  566. package/workflows/containers/child/moveArtifacts.js.map +0 -1
  567. package/workflows/containers/child/moveRotation.js.map +0 -1
  568. package/workflows/containers/child/moveWraps.js.map +0 -1
  569. package/workflows/containers/child/rekey.js.map +0 -1
  570. package/workflows/containers/child/rekeyProjection.js.map +0 -1
  571. package/workflows/containers/child/rekeyRemote.js.map +0 -1
  572. package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
  573. package/workflows/containers/child/rotationContext.js.map +0 -1
  574. package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
  575. package/workflows/containers/child/rotationWraps.js.map +0 -1
  576. package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
  577. package/workflows/containers/child/share.js.map +0 -1
  578. package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
  579. package/workflows/containers/child/shareMaterialization.js.map +0 -1
  580. package/workflows/containers/child/sharePlanCore.js.map +0 -1
  581. package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
  582. package/workflows/containers/child/shareProjection.js.map +0 -1
  583. /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
  584. /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
  585. /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
  586. /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
  587. /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
  588. /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
  589. /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
  590. /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
  591. /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
  592. /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
  593. /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
  594. /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
  595. /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
  596. /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
  597. /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
  598. /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
  599. /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
  600. /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
  601. /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
  602. /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
  603. /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
  604. /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
  605. /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
  606. /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
  607. /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
  608. /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
  609. /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
  610. /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
  611. /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
  612. /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
  613. /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
  614. /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
  615. /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
  616. /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
@@ -1,7 +1,7 @@
1
- import { KeyingVerificationError, } from "../../internal/crypto/index.js";
1
+ import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
+ import { rememberRootBoundOrganizationFounder } from "../principalPolicy/organizationFounderBinding.js";
2
3
  import { assertServedAncestorsDescendFromCitations } from "./containerAncestorCitations.js";
3
4
  import { verifyContainerManifestBundle } from "./containerManifestVerification.js";
4
- import { rememberRootBoundOrganizationFounder } from "./organizationFounderBinding.js";
5
5
  export async function verifyContainerManifestPath(input) {
6
6
  // Historical signer membership and current-path freshness are independent:
7
7
  // current heads may have been signed before a group member was removed.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerPathVerification.js","sourceRoot":"","sources":["containerPathVerification.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAMrG,OAAO,EAAE,yCAAyC,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAkBjD;IACC,2EAA2E;IAC3E,wEAAwE;IACxE,MAAM,YAAY,GAAsC,EAAE,CAAC;IAC3D,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,6BAA6B,CAAC;YACnD,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;YACtD,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;YAClD,MAAM;YACN,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,sBAAsB,EAAE,KAAK,CAAC,uBAAuB;YACrD,KAAK;YACL,UAAU,EAAE,YAAY;YACxB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;YAChD,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,4BAA4B,EAAE,KAAK,CAAC,4BAA4B;YAChE,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;SACvE,CAAC,CAAC;QACH,wEAAwE;QACxE,0EAA0E;QAC1E,+CAA+C;QAC/C,MAAM,gBAAgB,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC;QACxE,IAAI,QAAQ,CAAC,KAAK,CAAC,iBAAiB,KAAK,gBAAgB,EAAE,CAAC;YAC1D,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,GAAG,KAAK,mDAAmD,CAC5D,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,yCAAyC,CAAC;gBACxC,IAAI,EAAE,QAAQ;gBACd,KAAK;gBACL,eAAe,EAAE,YAAY;gBAC7B,cAAc,EAAE,KAAK,CAAC,cAAc;aACrC,CAAC,CAAC;QACL,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,oCAAoC,CAAC;QACzC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO;QACxC,QAAQ,EAAE,KAAK,CAAC,qBAAqB;QACrC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;QACrB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n KeyingVerificationError,\n type VerifiedContainerAccessManifest,\n} from \"@tearleads/crypto\";\nimport type { AccessManifestBundleWireResponse } from \"@tearleads/validators/response\";\nimport type { ProjectionCheckpointContext } from \"../checkpoints/checkpointContext\";\nimport { rememberRootBoundOrganizationFounder } from \"../principalPolicy/organizationFounderBinding\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\nimport { assertServedAncestorsDescendFromCitations } from \"./containerAncestorCitations\";\nimport { verifyContainerManifestBundle } from \"./containerManifestVerification\";\n\nexport async function verifyContainerManifestPath(input: {\n readonly authorizationMembership?: \"current\" | \"referenced\" | undefined;\n readonly authorizationEvidence?:\n | readonly PrincipalPolicyAuthorization[]\n | undefined;\n readonly bundlesByHash: ReadonlyMap<string, AccessManifestBundleWireResponse>;\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly enforceLocalCheckpoints: boolean;\n readonly servedAsCurrent: boolean;\n readonly label: string;\n readonly path: readonly AccessManifestBundleWireResponse[];\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly requireAuthorizationEvidence?: boolean | undefined;\n readonly verifiedByHash: Map<string, VerifiedContainerAccessManifest>;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}): Promise<VerifiedContainerAccessManifest[]> {\n // Historical signer membership and current-path freshness are independent:\n // current heads may have been signed before a group member was removed.\n const verifiedPath: VerifiedContainerAccessManifest[] = [];\n for (const [index, bundle] of input.path.entries()) {\n const label = `${input.label}[${index}]`;\n const verified = await verifyContainerManifestBundle({\n authorizationMembership: input.authorizationMembership,\n authorizationEvidence: input.authorizationEvidence,\n bundle,\n bundlesByHash: input.bundlesByHash,\n checkpointContext: input.checkpointContext,\n enforceLocalCheckpoint: input.enforceLocalCheckpoints,\n label,\n parentPath: verifiedPath,\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n requireAuthorizationEvidence: input.requireAuthorizationEvidence,\n verifiedByHash: input.verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n // Access along a path is the union of its elements' grants, so a served\n // path must be a genuine root-to-leaf ancestor chain: each element is the\n // parent of the next, and the first is a root.\n const expectedParentId = verifiedPath.at(-1)?.state.containerId ?? null;\n if (verified.state.parentContainerId !== expectedParentId) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n `${label} parent container does not precede it in the path`,\n );\n }\n if (input.servedAsCurrent) {\n assertServedAncestorsDescendFromCitations({\n head: verified,\n label,\n servedAncestors: verifiedPath,\n verifiedByHash: input.verifiedByHash,\n });\n }\n verifiedPath.push(verified);\n }\n\n await rememberRootBoundOrganizationFounder({\n execSql: input.checkpointContext.execSql,\n policies: input.authorizationEvidence,\n root: verifiedPath[0],\n verifiedByHash: input.verifiedByHash,\n });\n return verifiedPath;\n}\n"]}
@@ -1,10 +1,10 @@
1
- import type { PrincipalPolicyAuthorization } from "../../internal/crypto/index.js";
2
- import { type VerifiedContainerAccessManifest } from "../../internal/crypto/index.js";
3
- import type { AccessManifestBundleWireResponse, ContainerWriterProjectionResponse } from "../../internal/validators/response/index.js";
4
- import type { PrincipalPolicyCurrentEvidence } from "../principals/principalPolicyEvidence.js";
5
- import type { ExecSql } from "../sqlite/sqlSchema.js";
6
- import { type ProjectionCheckpointContext } from "./checkpointContext.js";
7
- import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "./types.js";
1
+ import type { PrincipalPolicyAuthorization } from "../../../internal/crypto/index.js";
2
+ import { type VerifiedContainerAccessManifest } from "../../../internal/crypto/index.js";
3
+ import type { AccessManifestBundleWireResponse, ContainerWriterProjectionResponse } from "../../../internal/validators/response/index.js";
4
+ import type { PrincipalPolicyCurrentEvidence } from "../../principals/principalPolicyEvidence.js";
5
+ import type { ExecSql } from "../../sqlite/sqlSchema.js";
6
+ import { type ProjectionCheckpointContext } from "../checkpoints/checkpointContext.js";
7
+ import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "../types.js";
8
8
  interface ContainerWriterProjectionVerificationInput {
9
9
  readonly execSql: ExecSql;
10
10
  readonly persistVerificationCheckpoints?: boolean | undefined;
@@ -1,14 +1,14 @@
1
- import { computeContainerKekRecipientTargetHash, computeContainerKeyEpochHash, toFingerprint, verifyContainerKekState, } from "../../internal/crypto/index.js";
2
- import { addBundleByHash } from "./bundleVerification.js";
3
- import { createProjectionCheckpointContext, finalizeProjectionCheckpoints, observeAccessManifestCheckpoints, observeVerifiedProjectionBundles, } from "./checkpointContext.js";
1
+ import { computeContainerKekRecipientTargetHash, computeContainerKeyEpochHash, toFingerprint, verifyContainerKekState, } from "../../../internal/crypto/index.js";
2
+ import { addBundleByHash } from "../checkpoints/bundleVerification.js";
3
+ import { createProjectionCheckpointContext, finalizeProjectionCheckpoints, observeAccessManifestCheckpoints, observeVerifiedProjectionBundles, } from "../checkpoints/checkpointContext.js";
4
+ import { ProjectionDependencyUnavailableError } from "../dependencyUnavailable.js";
5
+ import { throwKeyingVerificationShapeFailure } from "../error.js";
6
+ import { collectReferencedPrincipalPolicies } from "../principalPolicy/principalPolicyVerification.js";
7
+ import { verifyProjectionAuthorizationEvidence } from "../principalPolicy/projectionAuthorizationEvidence.js";
8
+ import { readContainerKekRecipientTarget, readContainerKeyEpoch, readContainerKeyWrap, } from "../readers.js";
9
+ import { assertProjectionVerificationCurrent, generationGuardedPrincipalPolicyWarmer, withGenerationGuardedPolicyWarmer, } from "../types.js";
4
10
  import { verifyContainerManifestBundle } from "./containerManifestVerification.js";
5
11
  import { verifyContainerManifestPath } from "./containerPathVerification.js";
6
- import { ProjectionDependencyUnavailableError } from "./dependencyUnavailable.js";
7
- import { throwKeyingVerificationShapeFailure } from "./error.js";
8
- import { collectReferencedPrincipalPolicies } from "./principalPolicyVerification.js";
9
- import { verifyProjectionAuthorizationEvidence } from "./projectionAuthorizationEvidence.js";
10
- import { readContainerKekRecipientTarget, readContainerKeyEpoch, readContainerKeyWrap, } from "./readers.js";
11
- import { assertProjectionVerificationCurrent, generationGuardedPrincipalPolicyWarmer, withGenerationGuardedPolicyWarmer, } from "./types.js";
12
12
  async function collectContainerUserRecipientKeys(input) {
13
13
  const userIds = [
14
14
  ...new Set(input.containerManifest.state.directGrants
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerProjectionVerification.js","sourceRoot":"","sources":["containerProjectionVerification.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sCAAsC,EACtC,4BAA4B,EAC5B,aAAa,EAGb,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EACL,iCAAiC,EACjC,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,GAEjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,kCAAkC,EAAE,MAAM,gDAAgD,CAAC;AACpG,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,mCAAmC,EACnC,sCAAsC,EACtC,iCAAiC,GAClC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE1E,KAAK,UAAU,iCAAiC,CAAC,KAGhD;IACC,MAAM,OAAO,GAAG;QACd,GAAG,IAAI,GAAG,CACR,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,YAAY;aACvC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC;aAC/C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,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AE,KAAK,CAAC,iBAAiB;QAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,UAAU,EAAE,wBAAwB;QACpC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;KACvE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n type ContainerUserRecipientKey,\n computeContainerKekRecipientTargetHash,\n computeContainerKeyEpochHash,\n toFingerprint,\n type VerifiedContainerAccessManifest,\n type VerifiedContainerKekState,\n verifyContainerKekState,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport type { PrincipalPolicyCurrentEvidence } from \"../../principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport { addBundleByHash } from \"../checkpoints/bundleVerification\";\nimport {\n createProjectionCheckpointContext,\n finalizeProjectionCheckpoints,\n observeAccessManifestCheckpoints,\n observeVerifiedProjectionBundles,\n type ProjectionCheckpointContext,\n} from \"../checkpoints/checkpointContext\";\nimport { ProjectionDependencyUnavailableError } from \"../dependencyUnavailable\";\nimport { throwKeyingVerificationShapeFailure } from \"../error\";\nimport { collectReferencedPrincipalPolicies } from \"../principalPolicy/principalPolicyVerification\";\nimport { verifyProjectionAuthorizationEvidence } from \"../principalPolicy/projectionAuthorizationEvidence\";\nimport {\n readContainerKekRecipientTarget,\n readContainerKeyEpoch,\n readContainerKeyWrap,\n} from \"../readers\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\nimport {\n assertProjectionVerificationCurrent,\n generationGuardedPrincipalPolicyWarmer,\n withGenerationGuardedPolicyWarmer,\n} from \"../types\";\nimport { verifyContainerManifestBundle } from \"./containerManifestVerification\";\nimport { verifyContainerManifestPath } from \"./containerPathVerification\";\n\nasync function collectContainerUserRecipientKeys(input: {\n readonly containerManifest: VerifiedContainerAccessManifest;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n}): Promise<ContainerUserRecipientKey[]> {\n const userIds = [\n ...new Set(\n input.containerManifest.state.directGrants\n .filter((grant) => grant.subjectType === \"user\")\n .map((grant) => grant.subjectId),\n ),\n ].sort();\n const userRecipientKeys: ContainerUserRecipientKey[] = [];\n\n for (const userId of userIds) {\n const userKey = await input.resolveUserKey(userId);\n if (!userKey) {\n throw new ProjectionDependencyUnavailableError(\n `Container writer projection recipient key could not be resolved for ${userId}`,\n );\n }\n const recipientKeyFingerprint = await toFingerprint(\n userKey.encapsulationPublicKey,\n );\n userRecipientKeys.push({\n userId,\n recipientKeyEpochId: `user:${userId}:encapsulation:${recipientKeyFingerprint}`,\n recipientKeyFingerprint,\n });\n }\n\n return userRecipientKeys;\n}\n\nfunction containerKekManifestHistory(input: {\n readonly history: readonly VerifiedContainerAccessManifest[];\n readonly verifiedManifest: VerifiedContainerAccessManifest;\n}): VerifiedContainerAccessManifest[] {\n const historyByHash = new Map<string, VerifiedContainerAccessManifest>();\n\n for (const manifest of input.history) {\n if (\n manifest.state.containerId === input.verifiedManifest.state.containerId &&\n manifest.manifestHash !== input.verifiedManifest.manifestHash\n ) {\n historyByHash.set(manifest.manifestHash, manifest);\n }\n }\n\n return [...historyByHash.values()];\n}\n\nasync function verifyContainerKekProjection(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly kek: ContainerWriterProjectionResponse[\"containerKeks\"][number];\n readonly label: string;\n readonly parentKekState: VerifiedContainerKekState | null;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly verifiedManifest: VerifiedContainerAccessManifest;\n readonly verifiedManifestHistory: readonly VerifiedContainerAccessManifest[];\n readonly parentManifestHistory: readonly VerifiedContainerAccessManifest[];\n}): Promise<VerifiedContainerKekState> {\n if (input.verifiedManifest.state.parentContainerId && !input.parentKekState) {\n throw new Error(`${input.label} requires verified parent KEK state`);\n }\n\n const keyEpoch = readContainerKeyEpoch(\n input.kek.keyEpoch,\n `${input.label} key epoch`,\n );\n const wraps = input.kek.wraps.map((wrap, index) =>\n readContainerKeyWrap(wrap, `${input.label} wrap[${index}]`),\n );\n const userRecipientKeys = await collectContainerUserRecipientKeys({\n containerManifest: input.verifiedManifest,\n resolveUserKey: input.resolveUserKey,\n });\n const verifiedKekManifestHistory = containerKekManifestHistory({\n history: input.verifiedManifestHistory,\n verifiedManifest: input.verifiedManifest,\n });\n const verified = await verifyContainerKekState({\n allowHistoricalParentEpoch: true,\n containerManifest: input.verifiedManifest,\n containerManifestHistory: verifiedKekManifestHistory,\n parentManifestHistory: input.parentManifestHistory,\n keyEpoch,\n parentKekState: input.parentKekState,\n principalPolicies: input.authorizationEvidence,\n userRecipientKeys,\n wraps,\n });\n if (!verified.ok) {\n throw new Error(`${input.label} KEK verification failed`);\n }\n\n const keyEpochHash = await computeContainerKeyEpochHash(keyEpoch);\n if (keyEpochHash !== input.kek.keyEpochHash) {\n throw new Error(`${input.label} key epoch hash mismatch`);\n }\n const recipientTargets = input.kek.recipientTargets.map((target, index) =>\n readContainerKekRecipientTarget(\n target,\n `${input.label} recipient target[${index}]`,\n ),\n );\n const keyTargetHash =\n await computeContainerKekRecipientTargetHash(recipientTargets);\n if (\n keyTargetHash !== input.kek.keyTargetHash ||\n keyTargetHash !== verified.value.keyTargetHash\n ) {\n throw new Error(`${input.label} target hash mismatch`);\n }\n if (\n verified.value.containerKeyEpochId !== input.kek.containerKeyEpochId ||\n verified.value.containerKeyEpoch !== input.kek.containerKeyEpoch ||\n verified.value.accessManifestHash !== input.kek.accessManifestHash ||\n verified.value.parentContainerKeyEpochId !==\n input.kek.parentContainerKeyEpochId\n ) {\n throw new Error(`${input.label} identity mismatch`);\n }\n\n return verified.value;\n}\n\ninterface ContainerWriterProjectionVerificationInput {\n readonly execSql: ExecSql;\n readonly persistVerificationCheckpoints?: boolean | undefined;\n readonly principalPolicyCache?: PrincipalPolicyCache | undefined;\n readonly projection: ContainerWriterProjectionResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly verifiedByHash?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}\n\nexport function verifiedContainerManifestsForBundles(\n bundlesByHash: ReadonlyMap<string, AccessManifestBundleWireResponse>,\n verifiedByHash: ReadonlyMap<string, VerifiedContainerAccessManifest>,\n): VerifiedContainerAccessManifest[] {\n return [...bundlesByHash.keys()].flatMap((manifestHash) => {\n const verified = verifiedByHash.get(manifestHash);\n return verified ? [verified] : [];\n });\n}\n\nfunction collectContainerProjectionBundles(\n projection: ContainerWriterProjectionResponse,\n): Map<string, AccessManifestBundleWireResponse> {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n addContainerWriterProjectionBundles(\n bundlesByHash,\n projection,\n \"Container writer projection\",\n );\n return bundlesByHash;\n}\n\nexport async function verifyContainerWriterProjectionWithContext(\n input: Omit<ContainerWriterProjectionVerificationInput, \"execSql\"> & {\n readonly authorizationEvidence?: readonly PrincipalPolicyAuthorization[];\n },\n checkpointContext: ProjectionCheckpointContext,\n): Promise<VerifiedContainerAccessManifest[]> {\n if (input.projection.path.length !== input.projection.containerKeks.length) {\n throw new Error(\n \"Container writer projection path and KEKs are inconsistent\",\n );\n }\n\n const bundlesByHash = collectContainerProjectionBundles(input.projection);\n\n const verifiedByHash =\n input.verifiedByHash ?? new Map<string, VerifiedContainerAccessManifest>();\n const principalPolicyCache: PrincipalPolicyCache =\n input.principalPolicyCache ?? new Map();\n const verification = {\n checkpointContext,\n principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n };\n const authorizationEvidence =\n input.authorizationEvidence ??\n (await verifyProjectionAuthorizationEvidence({\n ...verification,\n bundles: [...bundlesByHash.values()],\n policyEvidence: input.projection.policyEvidence,\n organizationId: input.projection.organizationId,\n stillCurrent: input.stillCurrent,\n }));\n const verifiedPath = await verifyContainerManifestPath({\n ...verification,\n authorizationEvidence,\n requireAuthorizationEvidence: true,\n servedAsCurrent: true,\n bundlesByHash,\n enforceLocalCheckpoints: true,\n label: \"Container writer projection path\",\n path: input.projection.path,\n verifiedByHash,\n });\n\n const verifiedKekStates: VerifiedContainerKekState[] = [];\n for (const [index, kek] of input.projection.containerKeks.entries()) {\n const verifiedManifest = verifiedPath[index];\n if (!verifiedManifest) {\n throw new Error(`Container writer projection KEK[${index}] is missing`);\n }\n const verifiedManifestHistory: VerifiedContainerAccessManifest[] = [];\n for (const [\n historyIndex,\n bundle,\n ] of kek.containerManifestHistory.entries()) {\n verifiedManifestHistory.push(\n await verifyContainerManifestBundle({\n ...verification,\n authorizationEvidence,\n requireAuthorizationEvidence: true,\n bundle,\n bundlesByHash,\n enforceLocalCheckpoint: false,\n label: `Container writer projection KEK[${index}] history[${historyIndex}]`,\n parentPath: verifiedPath.slice(0, index),\n verifiedByHash,\n }),\n );\n }\n\n const verifiedKekState = await verifyContainerKekProjection({\n authorizationEvidence,\n kek,\n label: `Container writer projection KEK[${index}]`,\n parentKekState: index > 0 ? (verifiedKekStates[index - 1] ?? null) : null,\n resolveUserKey: input.resolveUserKey,\n verifiedManifest,\n verifiedManifestHistory,\n parentManifestHistory: [...verifiedByHash.values()],\n });\n verifiedKekStates.push(verifiedKekState);\n }\n\n observeAccessManifestCheckpoints(checkpointContext, {\n verifiedHeads: verifiedPath,\n verifiedManifests: verifiedContainerManifestsForBundles(\n bundlesByHash,\n verifiedByHash,\n ),\n });\n\n checkpointContext.heldContainerHeads.push(...verifiedPath);\n return verifiedPath;\n}\n\nexport async function verifyContainerWriterProjection(\n input: ContainerWriterProjectionVerificationInput,\n): Promise<VerifiedContainerAccessManifest[]> {\n try {\n assertProjectionVerificationCurrent(input.stillCurrent);\n const verifiedByHash =\n input.verifiedByHash ??\n new Map<string, VerifiedContainerAccessManifest>();\n const guardedInput = {\n ...withGenerationGuardedPolicyWarmer(input),\n verifiedByHash,\n };\n const checkpointContext = createProjectionCheckpointContext({\n execSql: input.execSql,\n organizationId: input.projection.organizationId,\n });\n const verifiedPath = await verifyContainerWriterProjectionWithContext(\n guardedInput,\n checkpointContext,\n );\n assertProjectionVerificationCurrent(input.stillCurrent);\n observeVerifiedProjectionBundles(\n checkpointContext,\n collectContainerProjectionBundles(input.projection),\n verifiedByHash,\n );\n await finalizeProjectionCheckpoints(checkpointContext, input);\n assertProjectionVerificationCurrent(input.stillCurrent);\n return verifiedPath;\n } catch (error) {\n throwKeyingVerificationShapeFailure(error);\n }\n}\n\nexport async function collectContainerWriterProjectionPrincipalPolicies(\n input: ContainerWriterProjectionVerificationInput,\n): Promise<PrincipalPolicyCurrentEvidence[]> {\n try {\n assertProjectionVerificationCurrent(input.stillCurrent);\n const warmReferencedPrincipalPolicies =\n generationGuardedPrincipalPolicyWarmer(\n input.warmReferencedPrincipalPolicies,\n input.stillCurrent,\n );\n const principalPolicyCache: PrincipalPolicyCache =\n input.principalPolicyCache ?? new Map();\n const verifiedByHash =\n input.verifiedByHash ??\n new Map<string, VerifiedContainerAccessManifest>();\n const checkpointContext = createProjectionCheckpointContext({\n execSql: input.execSql,\n organizationId: input.projection.organizationId,\n });\n const verifiedPath = await verifyContainerWriterProjectionWithContext(\n {\n principalPolicyCache,\n projection: input.projection,\n verifiedByHash,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies,\n },\n checkpointContext,\n );\n assertProjectionVerificationCurrent(input.stillCurrent);\n\n const policies = await collectPrincipalPoliciesForContainerPaths({\n checkpointContext,\n organizationId: input.projection.organizationId,\n paths: [verifiedPath],\n principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies,\n });\n assertProjectionVerificationCurrent(input.stillCurrent);\n observeVerifiedProjectionBundles(\n checkpointContext,\n collectContainerProjectionBundles(input.projection),\n verifiedByHash,\n );\n await finalizeProjectionCheckpoints(checkpointContext, input);\n assertProjectionVerificationCurrent(input.stillCurrent);\n return policies;\n } catch (error) {\n throwKeyingVerificationShapeFailure(error);\n }\n}\n\nexport function addContainerWriterProjectionBundles(\n bundlesByHash: Map<string, AccessManifestBundleWireResponse>,\n projection: ContainerWriterProjectionResponse,\n label: string,\n): void {\n for (const [index, bundle] of projection.path.entries()) {\n addBundleByHash(bundlesByHash, bundle, `${label} path[${index}]`);\n }\n for (const [kekIndex, kek] of projection.containerKeks.entries()) {\n for (const [\n historyIndex,\n bundle,\n ] of kek.containerManifestHistory.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `${label} KEK[${kekIndex}] history[${historyIndex}]`,\n );\n }\n }\n}\n\nasync function collectPrincipalPoliciesForContainerPaths(input: {\n checkpointContext: ProjectionCheckpointContext;\n organizationId: string;\n paths: readonly (readonly VerifiedContainerAccessManifest[] | undefined)[];\n principalPolicyCache: PrincipalPolicyCache;\n resolveUserKey: ProjectionUserKeyResolver;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}): Promise<PrincipalPolicyCurrentEvidence[]> {\n const referencedPrincipalHeads = input.paths.flatMap((path) =>\n (path ?? []).flatMap((manifest) => manifest.state.referencedPrincipalHeads),\n );\n\n return collectReferencedPrincipalPolicies({\n checkpointContext: input.checkpointContext,\n organizationId: input.organizationId,\n principalPolicyCache: input.principalPolicyCache,\n references: referencedPrincipalHeads,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type VerifiedContainerAccessManifest } from "../../internal/crypto/index.js";
1
+ import { type VerifiedContainerAccessManifest } from "../../../internal/crypto/index.js";
2
2
  /**
3
3
  * Rebuild historical authorization from the event's signed heads, not from
4
4
  * creation-time parent pins or the server's grouping of dependency paths.
@@ -1,6 +1,6 @@
1
- import { KeyingVerificationError, } from "../../internal/crypto/index.js";
2
- import { MAX_CONTAINER_PATH_LENGTH } from "../../internal/validators/util/index.js";
3
- import { assertCitedAncestorsDoNotRegress } from "./containerAncestorCitations.js";
1
+ import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
+ import { MAX_CONTAINER_PATH_LENGTH } from "../../../internal/validators/util/index.js";
3
+ import { assertCitedAncestorsDoNotRegress } from "../container/containerAncestorCitations.js";
4
4
  /**
5
5
  * Rebuild historical authorization from the event's signed heads, not from
6
6
  * creation-time parent pins or the server's grouping of dependency paths.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentDependencyPaths.js","sourceRoot":"","sources":["documentDependencyPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAO1C;IAIC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;IACrE,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,2BAA2B,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9D,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC5B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2C,CAAC;IACjE,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,wBAAwB,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,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C,QAAQ,CAAC,CAAC;YACxB,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC;QACjD,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QAChC,sEAAsE;QACtE,sEAAsE;QACtE,kEAAkE;QAClE,gCAAgC,CAAC;YAC/B,aAAa,EAAE,IAAI,GAAG,EAAE;YACxB,KAAK,EAAE,gBAAgB;YACvB,cAAc,EAAE,SAAS;YACzB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACjC,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO;QACL,wBAAwB;QACxB,mBAAmB,EACjB,KAAK,CAAC,kBAAkB,KAAK,SAAS;YACpC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAC3B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,KAAK,KAAK,CAAC,kBAAkB,CACjE;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type VerifiedContainerAccessManifest,\n} from \"@tearleads/crypto\";\nimport { MAX_CONTAINER_PATH_LENGTH } from \"@tearleads/validators/util\";\nimport { assertCitedAncestorsDoNotRegress } from \"../container/containerAncestorCitations\";\n\n/**\n * Rebuild historical authorization from the event's signed heads, not from\n * creation-time parent pins or the server's grouping of dependency paths.\n * Paths in the evidence index only supply verified manifests. Authorization\n * uses exactly the ancestor heads this event signed, regardless of grouping.\n * Prefix paths are evidence too; crypto authorization admits only leaves named\n * by the signed document link set or committed content target set.\n */\nexport function resolveEventContainerPaths(input: {\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly dependencyManifestHashes: readonly string[];\n readonly targetManifestHash?: string;\n}): {\n dependencyContainerPaths: VerifiedContainerAccessManifest[][];\n targetContainerPath: readonly VerifiedContainerAccessManifest[] | undefined;\n} {\n const manifests = new Map<string, VerifiedContainerAccessManifest>();\n for (const path of input.containerPathByManifestHash.values()) {\n for (const manifest of path) {\n manifests.set(manifest.manifestHash, manifest);\n }\n }\n const cited = new Map<string, VerifiedContainerAccessManifest>();\n for (const hash of input.dependencyManifestHashes) {\n const manifest = manifests.get(hash);\n if (!manifest) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Document event cites an unavailable container manifest\",\n );\n }\n if (cited.has(manifest.state.containerId)) {\n throw new KeyingVerificationError(\n \"duplicate_entry\",\n \"Document event cites two heads of one container\",\n );\n }\n cited.set(manifest.state.containerId, manifest);\n }\n const dependencyContainerPaths = [...cited.values()].map((leaf) => {\n const reversed: VerifiedContainerAccessManifest[] = [];\n const seen = new Set<string>();\n let containerId: string | null = leaf.state.containerId;\n while (containerId !== null) {\n if (\n seen.has(containerId) ||\n reversed.length >= MAX_CONTAINER_PATH_LENGTH\n ) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Document event cited container path is cyclic or too deep\",\n );\n }\n seen.add(containerId);\n const ancestor = cited.get(containerId);\n if (!ancestor) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n `Document event does not cite ancestor ${containerId}`,\n );\n }\n if (ancestor.state.organizationId !== leaf.state.organizationId) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Document event cited container path crosses organizations\",\n );\n }\n reversed.push(ancestor);\n containerId = ancestor.state.parentContainerId;\n }\n const path = reversed.reverse();\n // The cited descendant is itself an earlier signed statement. Its own\n // citations establish floors for every ancestor, even when the server\n // supplied these verified manifests in separate projection paths.\n assertCitedAncestorsDoNotRegress({\n bundlesByHash: new Map(),\n label: \"Document event\",\n verifiedByHash: manifests,\n citedAncestors: path.slice(0, -1),\n previousManifest: leaf,\n });\n return path;\n });\n return {\n dependencyContainerPaths,\n targetContainerPath:\n input.targetManifestHash === undefined\n ? undefined\n : dependencyContainerPaths.find(\n (path) => path.at(-1)?.manifestHash === input.targetManifestHash,\n ),\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../internal/crypto/index.js";
2
- import { collectReferencedPrincipalPolicies } from "./principalPolicyVerification.js";
1
+ import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../../internal/crypto/index.js";
2
+ import { collectReferencedPrincipalPolicies } from "../principalPolicy/principalPolicyVerification.js";
3
3
  export async function collectDocumentManifestPrincipalPolicies(input) {
4
4
  const authorizationEvidence = input.authorizationEvidence ?? [];
5
5
  const references = input.paths
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentManifestPolicies.js","sourceRoot":"","sources":["documentManifestPolicies.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAEhC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kCAAkC,EAAE,MAAM,gDAAgD,CAAC;AAYpG,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAAC,KAgB9D;IACC,MAAM,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAChE,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK;SAC3B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAChB,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAClB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CACtD,CACF;SACA,MAAM,CACL,CAAC,SAAS,EAAE,EAAE,CACZ,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACrC,+BAA+B,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CACvD,CACJ,CAAC;IACJ,IAAI,KAAK,CAAC,4BAA4B,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,qDAAqD,CACtD,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,4BAA4B;QAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,CAAC;IAC1E,OAAO;QACL,GAAG,qBAAqB;QACxB,GAAG,CAAC,MAAM,kCAAkC,CAAC;YAC3C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;YAChD,UAAU;YACV,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;SACvE,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oCAAoC,CAAC,KAMpD;IACC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n type VerifiedContainerAccessManifest,\n} from \"@tearleads/crypto\";\nimport type { ProjectionCheckpointContext } from \"../checkpoints/checkpointContext\";\nimport { collectReferencedPrincipalPolicies } from \"../principalPolicy/principalPolicyVerification\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\n\nexport type UsedDocumentContainerManifests = Map<\n string,\n VerifiedContainerAccessManifest\n>;\n\nexport async function collectDocumentManifestPrincipalPolicies(input: {\n readonly authorizationEvidence?:\n | readonly PrincipalPolicyAuthorization[]\n | undefined;\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly organizationId: string;\n readonly paths: readonly (\n | readonly VerifiedContainerAccessManifest[]\n | undefined\n )[];\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly requireAuthorizationEvidence?: boolean | undefined;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n}): Promise<PrincipalPolicyAuthorization[]> {\n const authorizationEvidence = input.authorizationEvidence ?? [];\n const references = input.paths\n .flatMap((path) =>\n (path ?? []).flatMap(\n (manifest) => manifest.state.referencedPrincipalHeads,\n ),\n )\n .filter(\n (reference) =>\n !authorizationEvidence.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n ),\n );\n if (input.requireAuthorizationEvidence && references.length > 0) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Projection omits required principal policy evidence\",\n );\n }\n if (input.requireAuthorizationEvidence) return [...authorizationEvidence];\n return [\n ...authorizationEvidence,\n ...(await collectReferencedPrincipalPolicies({\n checkpointContext: input.checkpointContext,\n organizationId: input.organizationId,\n principalPolicyCache: input.principalPolicyCache,\n references,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n })),\n ];\n}\n\nexport function recordUsedDocumentContainerManifests(input: {\n readonly paths: readonly (\n | readonly VerifiedContainerAccessManifest[]\n | undefined\n )[];\n readonly used?: UsedDocumentContainerManifests | undefined;\n}): void {\n for (const path of input.paths) {\n for (const manifest of path ?? []) {\n input.used?.set(manifest.manifestHash, manifest);\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { KeyingVerificationError, } from "../../internal/crypto/index.js";
1
+ import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
2
  export function requireVerifiedDocumentPredecessor(input) {
3
3
  if (input.previousManifestHash === null)
4
4
  return null;
@@ -1,11 +1,11 @@
1
- import { KeyingVerificationError, verifyDocumentLinkSetManifest, } from "../../internal/crypto/index.js";
2
- import { readCanonicalJson } from "../keying/canonicalJson.js";
3
- import { addBundleByHash, assertCanonicalEqual, verifyAccessEventBundle, } from "./bundleVerification.js";
1
+ import { KeyingVerificationError, verifyDocumentLinkSetManifest, } from "../../../internal/crypto/index.js";
2
+ import { readCanonicalJson } from "../../keying/canonicalJson.js";
3
+ import { addBundleByHash, assertCanonicalEqual, verifyAccessEventBundle, } from "../checkpoints/bundleVerification.js";
4
+ import { loadManifestCheckpointVerification, verifyCachedManifestCheckpoint, } from "../checkpoints/manifestCheckpointVerification.js";
5
+ import { readAccessManifest, readDocumentAccessEventBody } from "../readers.js";
4
6
  import { resolveEventContainerPaths } from "./documentDependencyPaths.js";
5
7
  import { collectDocumentManifestPrincipalPolicies, recordUsedDocumentContainerManifests, } from "./documentManifestPolicies.js";
6
8
  import { requireVerifiedDocumentPredecessor } from "./documentManifestPredecessor.js";
7
- import { loadManifestCheckpointVerification, verifyCachedManifestCheckpoint, } from "./manifestCheckpointVerification.js";
8
- import { readAccessManifest, readDocumentAccessEventBody } from "./readers.js";
9
9
  export async function verifyDocumentManifestBundle(input) {
10
10
  const cached = input.verifiedByHash.get(input.bundle.manifestHash);
11
11
  if (cached) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentManifestVerification.js","sourceRoot":"","sources":["documentManifestVerification.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAIvB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAM7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,wCAAwC,EACxC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1C,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;QAC9D,sBAAsB,EAAE,IAAI;QAC5B,KAAK,EAAE,4BAA4B;QACnC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,cAAc;QACd,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;KACvE,CAAC,CAAC;IACH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type { PrincipalPolicyAuthorization } from \"@tearleads/crypto\";\nimport {\n KeyingVerificationError,\n type VerifiedContainerAccessManifest,\n type VerifiedDocumentLinkSetManifest,\n type VerifiedDocumentLinkSetSnapshot,\n verifyDocumentLinkSetManifest,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { readCanonicalJson } from \"../../keying/canonicalJson\";\nimport {\n addBundleByHash,\n assertCanonicalEqual,\n verifyAccessEventBundle,\n} from \"../checkpoints/bundleVerification\";\nimport type { ProjectionCheckpointContext } from \"../checkpoints/checkpointContext\";\nimport {\n loadManifestCheckpointVerification,\n verifyCachedManifestCheckpoint,\n} from \"../checkpoints/manifestCheckpointVerification\";\nimport { readAccessManifest, readDocumentAccessEventBody } from \"../readers\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\nimport { resolveEventContainerPaths } from \"./documentDependencyPaths\";\nimport {\n collectDocumentManifestPrincipalPolicies,\n recordUsedDocumentContainerManifests,\n type UsedDocumentContainerManifests,\n} from \"./documentManifestPolicies\";\nimport { requireVerifiedDocumentPredecessor } from \"./documentManifestPredecessor\";\n\ntype PolicyWarmer = ReferencedPrincipalPolicyWarmer | undefined;\n\nexport async function verifyDocumentManifestBundle(input: {\n readonly authorizationMembership?: \"current\" | \"referenced\" | undefined;\n readonly authorizationEvidence?:\n | readonly PrincipalPolicyAuthorization[]\n | undefined;\n readonly bundle: AccessManifestBundleWireResponse;\n readonly bundlesByHash: ReadonlyMap<string, AccessManifestBundleWireResponse>;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly enforceLocalCheckpoint: boolean;\n readonly label: string;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly requireAuthorizationEvidence?: boolean | undefined;\n readonly trustedPredecessorByHash?:\n | ReadonlyMap<string, VerifiedDocumentLinkSetSnapshot>\n | undefined;\n readonly usedContainerManifests?: UsedDocumentContainerManifests | undefined;\n readonly verifiedByHash: Map<string, VerifiedDocumentLinkSetManifest>;\n readonly warmReferencedPrincipalPolicies?: PolicyWarmer;\n}): Promise<VerifiedDocumentLinkSetManifest> {\n const cached = input.verifiedByHash.get(input.bundle.manifestHash);\n if (cached) {\n if (input.enforceLocalCheckpoint) {\n await verifyCachedManifestCheckpoint({\n current: cached,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: input.verifiedByHash,\n });\n }\n return cached;\n }\n\n const event = await verifyAccessEventBundle(input);\n const manifest = readAccessManifest(\n input.bundle.manifest,\n `${input.label} manifest`,\n );\n const previousManifest = requireVerifiedDocumentPredecessor({\n label: input.label,\n previousManifestHash: event.event.previousManifestHash,\n trustedPredecessorByHash: input.trustedPredecessorByHash,\n verifiedByHash: input.verifiedByHash,\n });\n const body = readDocumentAccessEventBody(\n event.body,\n `${input.label} event body`,\n );\n const { dependencyContainerPaths, targetContainerPath } =\n resolveEventContainerPaths({\n containerPathByManifestHash: input.containerPathByManifestHash,\n dependencyManifestHashes: event.event.dependencyManifestHashes,\n targetManifestHash: body.containerManifestHash,\n });\n const principalPolicies = await collectDocumentManifestPrincipalPolicies({\n authorizationEvidence: input.authorizationEvidence,\n checkpointContext: input.checkpointContext,\n organizationId: event.event.organizationId,\n paths: [...dependencyContainerPaths, targetContainerPath],\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n requireAuthorizationEvidence: input.requireAuthorizationEvidence,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n const checkpointVerification = input.enforceLocalCheckpoint\n ? await loadManifestCheckpointVerification({\n current: manifest,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: input.verifiedByHash,\n })\n : null;\n const verified = await verifyDocumentLinkSetManifest({\n // Served heads and history were committed under the group membership their\n // cited container heads referenced; a signer removed since must still\n // verify on a cold device. The API verifier gates new writes at current.\n authorizationMembership: input.authorizationMembership ?? \"referenced\",\n authorizingContainerPaths: dependencyContainerPaths,\n event,\n expectedManifestHash: input.bundle.manifestHash,\n manifest,\n previousManifest,\n principalPolicies,\n ...(checkpointVerification ?? {}),\n ...(targetContainerPath ? { targetContainerPath } : {}),\n });\n if (!verified.ok) {\n throw new KeyingVerificationError(\n verified.error.code,\n `${input.label} manifest verification failed: ${verified.error.message}`,\n );\n }\n\n recordUsedDocumentContainerManifests({\n paths: [...dependencyContainerPaths, targetContainerPath],\n used: input.usedContainerManifests,\n });\n assertCanonicalEqual({\n actual: input.bundle.state,\n expected: readCanonicalJson(verified.value.state, `${input.label} state`),\n label: `${input.label} state`,\n });\n input.verifiedByHash.set(input.bundle.manifestHash, verified.value);\n\n return verified.value;\n}\n\nexport async function verifyDocumentProjectionManifests(\n input: Omit<\n Parameters<typeof verifyDocumentManifestBundle>[0],\n | \"bundle\"\n | \"bundlesByHash\"\n | \"enforceLocalCheckpoint\"\n | \"label\"\n | \"verifiedByHash\"\n > & { readonly projection: DocumentWriterProjectionResponse },\n) {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n addBundleByHash(\n bundlesByHash,\n input.projection.documentManifest,\n \"Document writer projection manifest\",\n );\n const history = input.projection.documentManifestHistory;\n for (const [index, bundle] of history.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document writer projection manifest history[${index}]`,\n );\n }\n // An honest API never lists the head in its own history (it seeds the walk\n // with the head), so a repeat is a malformed or tampered projection and is\n // refused as such, rather than letting the head reach its verification\n // through the history cache and relying on the cached branch to re-run\n // every check the fresh path would.\n if (\n history.some(\n (bundle) =>\n bundle.manifestHash === input.projection.documentManifest.manifestHash,\n )\n ) {\n throw new KeyingVerificationError(\n \"duplicate_entry\",\n \"Document writer projection history repeats the current head\",\n );\n }\n\n const verifiedByHash = new Map<string, VerifiedDocumentLinkSetManifest>();\n for (let index = history.length - 1; index >= 0; index -= 1) {\n const bundle = history[index];\n if (!bundle) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n `Document writer projection manifest history[${index}] is missing`,\n );\n }\n await verifyDocumentManifestBundle({\n authorizationEvidence: input.authorizationEvidence,\n requireAuthorizationEvidence: true,\n bundle,\n bundlesByHash,\n checkpointContext: input.checkpointContext,\n containerPathByManifestHash: input.containerPathByManifestHash,\n enforceLocalCheckpoint: false,\n label: `Document writer projection manifest history[${index}]`,\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n }\n\n const headManifest = await verifyDocumentManifestBundle({\n authorizationEvidence: input.authorizationEvidence,\n requireAuthorizationEvidence: true,\n bundle: input.projection.documentManifest,\n bundlesByHash,\n checkpointContext: input.checkpointContext,\n containerPathByManifestHash: input.containerPathByManifestHash,\n enforceLocalCheckpoint: true,\n label: \"Document writer projection\",\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n return { headManifest, verifiedByHash };\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { PrincipalPolicyAuthorization, VerifiedContainerAccessManifest, VerifiedDocumentLinkSetManifest } from "../../internal/crypto/index.js";
2
- import type { DocumentWriterProjectionResponse } from "../../internal/validators/response/index.js";
3
- import type { ExecSql } from "../sqlite/sqlSchema.js";
4
- import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "./types.js";
1
+ import type { PrincipalPolicyAuthorization, VerifiedContainerAccessManifest, VerifiedDocumentLinkSetManifest } from "../../../internal/crypto/index.js";
2
+ import type { DocumentWriterProjectionResponse } from "../../../internal/validators/response/index.js";
3
+ import type { ExecSql } from "../../sqlite/sqlSchema.js";
4
+ import type { PrincipalPolicyCache, ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "../types.js";
5
5
  type VerifiedManifestMap = Map<string, VerifiedContainerAccessManifest>;
6
6
  type PolicyWarmer = ReferencedPrincipalPolicyWarmer | undefined;
7
7
  interface DocumentWriterProjectionVerificationInput {
@@ -1,14 +1,14 @@
1
- import { addBundleByHash } from "./bundleVerification.js";
2
- import { createProjectionCheckpointContext, finalizeProjectionCheckpoints, observeAccessManifestCheckpoints, observeVerifiedProjectionBundles, } from "./checkpointContext.js";
3
- import { verifyContainerManifestPath } from "./containerPathVerification.js";
4
- import { addContainerWriterProjectionBundles, verifiedContainerManifestsForBundles, verifyContainerWriterProjectionWithContext, } from "./containerProjectionVerification.js";
1
+ import { addBundleByHash } from "../checkpoints/bundleVerification.js";
2
+ import { createProjectionCheckpointContext, finalizeProjectionCheckpoints, observeAccessManifestCheckpoints, observeVerifiedProjectionBundles, } from "../checkpoints/checkpointContext.js";
3
+ import { verifyContainerManifestPath } from "../container/containerPathVerification.js";
4
+ import { addContainerWriterProjectionBundles, verifiedContainerManifestsForBundles, verifyContainerWriterProjectionWithContext, } from "../container/containerProjectionVerification.js";
5
+ import { rejectPurgedDocumentProjection } from "../documentPurge/documentPurgeCheckpointEnforcement.js";
6
+ import { throwKeyingVerificationShapeFailure } from "../error.js";
7
+ import { verifyProjectionAuthorizationEvidence } from "../principalPolicy/projectionAuthorizationEvidence.js";
8
+ import { readAccessManifest } from "../readers.js";
9
+ import { withGenerationGuardedPolicyWarmer } from "../types.js";
5
10
  import { documentContainerProjections } from "./documentContainerProjections.js";
6
11
  import { verifyDocumentProjectionManifests } from "./documentManifestVerification.js";
7
- import { rejectPurgedDocumentProjection } from "./documentPurgeCheckpointEnforcement.js";
8
- import { throwKeyingVerificationShapeFailure } from "./error.js";
9
- import { verifyProjectionAuthorizationEvidence } from "./projectionAuthorizationEvidence.js";
10
- import { readAccessManifest } from "./readers.js";
11
- import { withGenerationGuardedPolicyWarmer } from "./types.js";
12
12
  function readDocumentProjectionContainerPaths(projection) {
13
13
  return [
14
14
  ...projection.documentManifestContainerPaths,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentProjectionVerification.js","sourceRoot":"","sources":["documentProjectionVerification.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EACL,iCAAiC,EACjC,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,GAEjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,0CAA0C,GAC3C,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AACrG,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAMhD,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AAKnF,SAAS,oCAAoC,CAC3C,UAA4C;IAE5C,OAAO;QACL,GAAG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tC,iBAAiB,EACjB,KAAK,CAAC,UAAU,EAChB,QAAQ,CAAC,aAAa,CACvB,CAAC;QACF,MAAM,6BAA6B,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;QAC9D,OAAO,QAAQ,CAAC,aAAa,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mCAAmC,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import type {\n PrincipalPolicyAuthorization,\n VerifiedContainerAccessManifest,\n VerifiedDocumentLinkSetManifest,\n VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport { addBundleByHash } from \"../checkpoints/bundleVerification\";\nimport {\n createProjectionCheckpointContext,\n finalizeProjectionCheckpoints,\n observeAccessManifestCheckpoints,\n observeVerifiedProjectionBundles,\n type ProjectionCheckpointContext,\n} from \"../checkpoints/checkpointContext\";\nimport { verifyContainerManifestPath } from \"../container/containerPathVerification\";\nimport {\n addContainerWriterProjectionBundles,\n verifiedContainerManifestsForBundles,\n verifyContainerWriterProjectionWithContext,\n} from \"../container/containerProjectionVerification\";\nimport { rejectPurgedDocumentProjection } from \"../documentPurge/documentPurgeCheckpointEnforcement\";\nimport { throwKeyingVerificationShapeFailure } from \"../error\";\nimport { verifyProjectionAuthorizationEvidence } from \"../principalPolicy/projectionAuthorizationEvidence\";\nimport { readAccessManifest } from \"../readers\";\nimport type {\n PrincipalPolicyCache,\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\nimport { withGenerationGuardedPolicyWarmer } from \"../types\";\nimport { documentContainerProjections } from \"./documentContainerProjections\";\nimport { verifyDocumentProjectionManifests } from \"./documentManifestVerification\";\n\ntype VerifiedManifestMap = Map<string, VerifiedContainerAccessManifest>;\ntype PolicyWarmer = ReferencedPrincipalPolicyWarmer | undefined;\n\nfunction readDocumentProjectionContainerPaths(\n projection: DocumentWriterProjectionResponse,\n): AccessManifestBundleWireResponse[][] {\n return [\n ...projection.documentManifestContainerPaths,\n ...projection.authorizingContainerPaths.map((path) => path.path),\n ];\n}\n\nfunction collectDocumentProjectionContainerBundles(\n projection: DocumentWriterProjectionResponse,\n): Map<string, AccessManifestBundleWireResponse> {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n for (const [index, authorizing] of documentContainerProjections(\n projection,\n ).entries()) {\n addContainerWriterProjectionBundles(\n bundlesByHash,\n authorizing,\n `Document writer projection authorizing path[${index}]`,\n );\n }\n for (const [index, path] of readDocumentProjectionContainerPaths(\n projection,\n ).entries()) {\n for (const [pathIndex, bundle] of path.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document writer projection dependency path[${index}][${pathIndex}]`,\n );\n }\n }\n for (const [\n index,\n bundle,\n ] of projection.documentContainerManifestHistory.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document writer projection container history[${index}]`,\n );\n }\n return bundlesByHash;\n}\n\nasync function verifyProjectionContainerPaths(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly projection: DocumentWriterProjectionResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly verifiedByHash?: VerifiedManifestMap | undefined;\n readonly warmReferencedPrincipalPolicies?: PolicyWarmer;\n}): Promise<Map<string, readonly VerifiedContainerAccessManifest[]>> {\n const bundlesByHash = collectDocumentProjectionContainerBundles(\n input.projection,\n );\n const containerPathByManifestHash = new Map<\n string,\n readonly VerifiedContainerAccessManifest[]\n >();\n // Reuse a caller-supplied cache when provided so a later unwrap pass over the\n // same authorizing container paths does not re-verify identical manifests.\n const verifiedByHash =\n input.verifiedByHash ?? new Map<string, VerifiedContainerAccessManifest>();\n for (const projection of documentContainerProjections(input.projection)) {\n const path = await verifyContainerWriterProjectionWithContext(\n {\n authorizationEvidence: input.authorizationEvidence,\n principalPolicyCache: input.principalPolicyCache,\n projection,\n resolveUserKey: input.resolveUserKey,\n verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n },\n input.checkpointContext,\n );\n const leaf = path.at(-1);\n if (leaf) {\n containerPathByManifestHash.set(leaf.manifestHash, path);\n }\n for (const manifest of path) {\n verifiedByHash.set(manifest.manifestHash, manifest);\n }\n }\n // Grouping supplies evidence only; each signed artifact selects its citations.\n for (const [\n index,\n path,\n ] of input.projection.documentManifestContainerPaths.entries()) {\n // Historical dependency evidence is verified without current checkpoint\n // enforcement. Its grouping cannot substitute an uncited ancestor into\n // document or content-write authorization.\n const verifiedPath = await verifyContainerManifestPath({\n authorizationEvidence: input.authorizationEvidence,\n requireAuthorizationEvidence: true,\n servedAsCurrent: false,\n authorizationMembership: \"referenced\",\n bundlesByHash,\n checkpointContext: input.checkpointContext,\n enforceLocalCheckpoints: false,\n label: `Document writer projection dependency path[${index}]`,\n path,\n principalPolicyCache: input.principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n // The authorizing path recorded for the same leaf takes precedence.\n const leaf = verifiedPath.at(-1);\n if (leaf && !containerPathByManifestHash.has(leaf.manifestHash)) {\n containerPathByManifestHash.set(leaf.manifestHash, verifiedPath);\n }\n }\n\n // Keep every verified head as evidence. Events and content headers select\n // their own signed paths through resolveEventContainerPaths.\n for (const [hash, manifest] of verifiedByHash) {\n if (!containerPathByManifestHash.has(hash))\n containerPathByManifestHash.set(hash, [manifest]);\n }\n\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: [],\n verifiedManifests: verifiedContainerManifestsForBundles(\n bundlesByHash,\n verifiedByHash,\n ),\n });\n\n return containerPathByManifestHash;\n}\n\ninterface DocumentWriterProjectionVerificationInput {\n readonly execSql: ExecSql;\n readonly persistVerificationCheckpoints?: boolean | undefined;\n readonly principalPolicyCache?: PrincipalPolicyCache | undefined;\n readonly projection: DocumentWriterProjectionResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly verifiedByHash?: VerifiedManifestMap | undefined;\n readonly warmReferencedPrincipalPolicies?: PolicyWarmer;\n}\nexport interface DocumentWriterProjectionAuthorization {\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly documentManifestByHash: ReadonlyMap<\n string,\n VerifiedDocumentLinkSetManifest\n >;\n readonly principalPolicies: readonly PrincipalPolicyAuthorization[];\n}\n\ninterface VerifiedDocumentWriterProjectionResult {\n readonly authorization: DocumentWriterProjectionAuthorization;\n readonly headManifest: VerifiedDocumentLinkSetManifest;\n}\n\nasync function verifyDocumentWriterProjectionWithContext(\n input: Omit<DocumentWriterProjectionVerificationInput, \"execSql\">,\n checkpointContext: ProjectionCheckpointContext,\n): Promise<VerifiedDocumentWriterProjectionResult> {\n const principalPolicyCache =\n input.principalPolicyCache ?? new Map<string, VerifiedPrincipalPolicy>();\n const authorizationEvidence = await verifyProjectionAuthorizationEvidence({\n bundles: [\n input.projection.documentManifest,\n ...input.projection.documentManifestHistory,\n ...collectDocumentProjectionContainerBundles(input.projection).values(),\n ],\n checkpointContext,\n policyEvidence: input.projection.policyEvidence,\n organizationId: readAccessManifest(\n input.projection.documentManifest.manifest,\n \"Document projection manifest\",\n ).organizationId,\n principalPolicyCache,\n resolveUserKey: input.resolveUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n const containerPathByManifestHash = await verifyProjectionContainerPaths({\n authorizationEvidence,\n checkpointContext,\n principalPolicyCache,\n projection: input.projection,\n resolveUserKey: input.resolveUserKey,\n verifiedByHash: input.verifiedByHash,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n const { headManifest, verifiedByHash } =\n await verifyDocumentProjectionManifests({\n authorizationEvidence,\n checkpointContext,\n containerPathByManifestHash,\n principalPolicyCache,\n projection: input.projection,\n resolveUserKey: input.resolveUserKey,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n await rejectPurgedDocumentProjection(\n headManifest.state.documentId,\n checkpointContext.execSql,\n );\n\n observeAccessManifestCheckpoints(checkpointContext, {\n verifiedHeads: [headManifest],\n verifiedManifests: [...verifiedByHash.values()],\n });\n\n return {\n authorization: {\n containerPathByManifestHash,\n documentManifestByHash: verifiedByHash,\n principalPolicies: authorizationEvidence,\n },\n headManifest,\n };\n}\n\n/** Each served bundle, document and container, whose manifest verified. */\nfunction observeVerifiedDocumentProjectionBundles(\n checkpointContext: ProjectionCheckpointContext,\n projection: DocumentWriterProjectionResponse,\n authorization: DocumentWriterProjectionAuthorization,\n): void {\n observeVerifiedProjectionBundles(\n checkpointContext,\n new Map(\n [projection.documentManifest, ...projection.documentManifestHistory].map(\n (bundle) => [bundle.manifestHash, bundle],\n ),\n ),\n authorization.documentManifestByHash,\n );\n observeVerifiedProjectionBundles(\n checkpointContext,\n collectDocumentProjectionContainerBundles(projection),\n new Map(\n [...authorization.containerPathByManifestHash.values()]\n .flat()\n .map((manifest) => [manifest.manifestHash, manifest]),\n ),\n );\n}\n\nexport async function verifyDocumentWriterProjection(\n input: DocumentWriterProjectionVerificationInput,\n): Promise<VerifiedDocumentLinkSetManifest> {\n const checkpointContext = createProjectionCheckpointContext({\n execSql: input.execSql,\n });\n const verified = await verifyDocumentWriterProjectionWithContext(\n withGenerationGuardedPolicyWarmer(input),\n checkpointContext,\n );\n observeVerifiedDocumentProjectionBundles(\n checkpointContext,\n input.projection,\n verified.authorization,\n );\n await finalizeProjectionCheckpoints(checkpointContext, input);\n return verified.headManifest;\n}\n\nexport async function verifyDocumentWriterProjectionAuthorization(\n input: DocumentWriterProjectionVerificationInput,\n): Promise<DocumentWriterProjectionAuthorization> {\n try {\n const checkpointContext = createProjectionCheckpointContext({\n execSql: input.execSql,\n });\n const verified = await verifyDocumentWriterProjectionWithContext(\n withGenerationGuardedPolicyWarmer(input),\n checkpointContext,\n );\n observeVerifiedDocumentProjectionBundles(\n checkpointContext,\n input.projection,\n verified.authorization,\n );\n await finalizeProjectionCheckpoints(checkpointContext, input);\n return verified.authorization;\n } catch (error) {\n throwKeyingVerificationShapeFailure(error);\n }\n}\n"]}
@@ -1,16 +1,16 @@
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";
5
- import { registerClientSQLiteCommitGuard } from "../sqlite/sqliteCommitGuards.js";
6
- import { getClientSQLitePersistenceRuntime } from "../sqlite/sqlitePersistenceRuntime.js";
7
- import { runSerializedSqlMutation } from "../sqlite/sqlSchema.js";
8
- import { validateAccessManifestCheckpoints } from "./accessManifestCheckpointEnforcement.js";
9
- import { commitProjectionCheckpoints, } from "./checkpointContext.js";
10
- import { ProjectionDependencyUnavailableError } from "./dependencyUnavailable.js";
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";
5
+ import { registerClientSQLiteCommitGuard } from "../../sqlite/sqliteCommitGuards.js";
6
+ import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
7
+ import { runSerializedSqlMutation } from "../../sqlite/sqlSchema.js";
8
+ import { validateAccessManifestCheckpoints } from "../checkpoints/accessManifestCheckpointEnforcement.js";
9
+ import { commitProjectionCheckpoints, } from "../checkpoints/checkpointContext.js";
10
+ import { ProjectionDependencyUnavailableError } from "../dependencyUnavailable.js";
11
+ import { projectionLifetimeGuard } from "../projectionLifetimes.js";
12
+ import { assertProjectionVerificationCurrent } from "../types.js";
11
13
  import { admitDocumentPurgePolicyCheckpoints } from "./documentPurgePolicyCheckpoints.js";
12
- import { projectionLifetimeGuard } from "./projectionLifetimes.js";
13
- import { assertProjectionVerificationCurrent } from "./types.js";
14
14
  /** All artifacts must already be authenticated before currency is considered. */
15
15
  async function currentContainerHeads(input) {
16
16
  const current = [];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgeCheckpointCurrency.js","sourceRoot":"","sources":["documentPurgeCheckpointCurrency.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EACL,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,gDAAgD,EAChD,yCAAyC,GAC1C,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAgB,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iCAAiC,EAAE,MAAM,oDAAoD,CAAC;AACvG,OAAO,EACL,2BAA2B,GAE5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE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A2B,CAC/B;oBACE,GAAG,KAAK,CAAC,OAAO;oBAChB,QAAQ,EAAE,EAAE;oBACZ,iEAAiE;oBACjE,iEAAiE;oBACjE,qBAAqB,EAAE,EAAE;iBAC1B,EACD;oBACE,uBAAuB;oBACvB,OAAO;iBACR,CACF,CAAC;YACJ,CAAC;QACH,CAAC,EACD,EAAE,QAAQ,EAAE,WAAW,EAAE,CAC1B,CAAC;IACJ,CAAC,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;AACL,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,KAA2B;IAE3B,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,KAEC;IAED,OAAO,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type {\n ReferencedPrincipalHead,\n VerifiedAccessManifestCheckpointEvidence,\n VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport type { DocumentPurgeCheckpoint } from \"../../persistence/documentPurgeCheckpointPersistence\";\nimport { validateAccessManifestCheckpointEvidence } from \"../../persistence/keyingCheckpointEvidence\";\nimport {\n accessManifestObjectKey,\n loadAccessManifestCheckpoint,\n} from \"../../persistence/keyingCheckpointPersistence\";\nimport {\n PrincipalAuthorizationCheckpointUnavailableError,\n validatePrincipalAuthorizationCheckpoints,\n} from \"../../persistence/principalAuthorizationCheckpoints\";\nimport { ensurePrincipalPolicyTables } from \"../../persistence/principalPolicyPersistence\";\nimport { registerClientSQLiteCommitGuard } from \"../../sqlite/sqliteCommitGuards\";\nimport { getClientSQLitePersistenceRuntime } from \"../../sqlite/sqlitePersistenceRuntime\";\nimport { type ExecSql, runSerializedSqlMutation } from \"../../sqlite/sqlSchema\";\nimport { validateAccessManifestCheckpoints } from \"../checkpoints/accessManifestCheckpointEnforcement\";\nimport {\n commitProjectionCheckpoints,\n type ProjectionCheckpointContext,\n} from \"../checkpoints/checkpointContext\";\nimport { ProjectionDependencyUnavailableError } from \"../dependencyUnavailable\";\nimport { projectionLifetimeGuard } from \"../projectionLifetimes\";\nimport { assertProjectionVerificationCurrent } from \"../types\";\nimport { admitDocumentPurgePolicyCheckpoints } from \"./documentPurgePolicyCheckpoints\";\nimport type { PurgePolicyCurrencyEvidence } from \"./documentPurgePolicyCurrency\";\n\ninterface PurgeCheckpointInput {\n readonly context: ProjectionCheckpointContext;\n readonly execSql: ExecSql;\n readonly principalPolicies: readonly VerifiedPrincipalPolicySelection[];\n readonly currencyPolicies: readonly PurgePolicyCurrencyEvidence[];\n readonly observedPrincipalHeads: readonly ReferencedPrincipalHead[];\n}\n\n/** All artifacts must already be authenticated before currency is considered. */\nasync function currentContainerHeads(input: PurgeCheckpointInput) {\n const current: VerifiedAccessManifestCheckpointEvidence[] = [];\n let superseded = false;\n for (const head of input.context.verifiedHeads) {\n const checkpoint = head.checkpoint;\n const local =\n checkpoint.objectKind === \"container\"\n ? await loadAccessManifestCheckpoint(\n input.execSql,\n \"container\",\n checkpoint.organizationId,\n checkpoint.objectId,\n )\n : null;\n if (!local || checkpoint.epoch >= local.epoch) {\n current.push(head);\n continue;\n }\n // A newer head does not order this separately signed purge event. Still\n // reject signed forks visible in the supplied evidence before deferring.\n const key = accessManifestObjectKey(checkpoint);\n validateAccessManifestCheckpointEvidence({\n head,\n localCheckpoint: local,\n predecessors: input.context.verifiedManifests.filter(\n (evidence) =>\n accessManifestObjectKey(evidence.checkpoint) === key &&\n evidence.manifestHash !== head.manifestHash,\n ),\n });\n superseded = true;\n }\n return { current, superseded };\n}\n\nasync function checkPurgeCheckpointCurrency(\n input: PurgeCheckpointInput,\n documentPurgeCheckpoint?: DocumentPurgeCheckpoint,\n): Promise<void> {\n // Keep comparison and optional advancement in the same immediate transaction.\n // Pass the locked executor through nested readers and checkpoint commits.\n await runSerializedSqlMutation(input.execSql, async (execSql) => {\n await getClientSQLitePersistenceRuntime(execSql).transaction(\n async (transaction) => {\n const stillCurrent = projectionLifetimeGuard(input.context);\n registerClientSQLiteCommitGuard(execSql, () =>\n assertProjectionVerificationCurrent(stillCurrent),\n );\n const { current, superseded } = await currentContainerHeads({\n ...input,\n execSql,\n });\n // An older container must not conceal a document fork, a policy fork, or\n // conflicting current evidence for another container in the same proof.\n await validateAccessManifestCheckpoints({\n execSql,\n policies: [],\n verifiedHeads: current,\n verifiedManifests: input.context.verifiedManifests,\n });\n if (input.currencyPolicies.length) {\n await ensurePrincipalPolicyTables(execSql);\n await validatePrincipalAuthorizationCheckpoints(\n transaction,\n input.currencyPolicies,\n );\n }\n if (superseded) {\n throw new ProjectionDependencyUnavailableError(\n \"Document purge cannot be ordered against a newer container checkpoint\",\n );\n }\n if (documentPurgeCheckpoint) {\n // Only the complete authenticated terminal proof admits these public\n // observations. Page recovery and baseline verification never pin.\n await admitDocumentPurgePolicyCheckpoints({\n transaction,\n organizationId: input.context.organizationId,\n policies: input.principalPolicies,\n heads: input.observedPrincipalHeads,\n });\n assertProjectionVerificationCurrent(stillCurrent);\n await commitProjectionCheckpoints(\n {\n ...input.context,\n policies: [],\n // Currency was rechecked above in this same transaction. Private\n // ancestry bridges must never become newly admitted purge heads.\n authorizationPolicies: [],\n },\n {\n documentPurgeCheckpoint,\n execSql,\n },\n );\n }\n },\n { behavior: \"immediate\" },\n );\n }).catch((error: unknown) => {\n if (error instanceof PrincipalAuthorizationCheckpointUnavailableError)\n throw new ProjectionDependencyUnavailableError(error.message);\n throw error;\n });\n}\n\nexport function validateDocumentPurgeCheckpoints(\n input: PurgeCheckpointInput,\n): Promise<void> {\n return checkPurgeCheckpointCurrency(input);\n}\n\nexport function commitDocumentPurgeCheckpoints(\n input: PurgeCheckpointInput & {\n readonly documentPurgeCheckpoint: DocumentPurgeCheckpoint;\n },\n): Promise<void> {\n return checkPurgeCheckpointCurrency(input, input.documentPurgeCheckpoint);\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { KeyingVerificationError } from "../../internal/crypto/index.js";
2
- import { loadDocumentPurgeCheckpoint } from "../persistence/documentPurgeCheckpointPersistence.js";
1
+ import { KeyingVerificationError } from "../../../internal/crypto/index.js";
2
+ import { loadDocumentPurgeCheckpoint } from "../../persistence/documentPurgeCheckpointPersistence.js";
3
3
  export async function rejectPurgedDocumentProjection(documentId, execSql) {
4
4
  if (await loadDocumentPurgeCheckpoint(execSql, documentId)) {
5
5
  throw new KeyingVerificationError("rollback", "Document writer projection targets a permanently purged document");
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgeCheckpointEnforcement.js","sourceRoot":"","sources":["documentPurgeCheckpointEnforcement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AAGnG,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,UAAkB,EAClB,OAAgB;IAEhB,IAAI,MAAM,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,uBAAuB,CAC/B,UAAU,EACV,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport { loadDocumentPurgeCheckpoint } from \"../../persistence/documentPurgeCheckpointPersistence\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\n\nexport async function rejectPurgedDocumentProjection(\n documentId: string,\n execSql: ExecSql,\n): Promise<void> {\n if (await loadDocumentPurgeCheckpoint(execSql, documentId)) {\n throw new KeyingVerificationError(\n \"rollback\",\n \"Document writer projection targets a permanently purged document\",\n );\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
- import { KeyingVerificationError, verifyDocumentLinkSetSnapshot, } from "../../internal/crypto/index.js";
2
- import { readCanonicalJson } from "../keying/canonicalJson.js";
3
- import { addBundleByHash, assertCanonicalEqual, verifyAccessEventBundle, } from "./bundleVerification.js";
4
- import { observeAccessManifestCheckpoints, } from "./checkpointContext.js";
5
- import { ProjectionDependencyUnavailableError } from "./dependencyUnavailable.js";
6
- import { verifyDocumentManifestBundle } from "./documentManifestVerification.js";
7
- import { loadManifestCheckpointVerification } from "./manifestCheckpointVerification.js";
8
- import { readAccessManifest, readDocumentAccessEventBody } from "./readers.js";
1
+ import { KeyingVerificationError, verifyDocumentLinkSetSnapshot, } from "../../../internal/crypto/index.js";
2
+ import { readCanonicalJson } from "../../keying/canonicalJson.js";
3
+ import { addBundleByHash, assertCanonicalEqual, verifyAccessEventBundle, } from "../checkpoints/bundleVerification.js";
4
+ import { observeAccessManifestCheckpoints, } from "../checkpoints/checkpointContext.js";
5
+ import { loadManifestCheckpointVerification } from "../checkpoints/manifestCheckpointVerification.js";
6
+ import { ProjectionDependencyUnavailableError } from "../dependencyUnavailable.js";
7
+ import { verifyDocumentManifestBundle } from "../document/documentManifestVerification.js";
8
+ import { readAccessManifest, readDocumentAccessEventBody } from "../readers.js";
9
9
  async function verifyPinnedChainEndpoint(input) {
10
10
  const manifest = readAccessManifest(input.bundle.manifest, "Document purge predecessor endpoint manifest");
11
11
  const checkpointVerification = await loadManifestCheckpointVerification({
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgeDocumentChainVerification.js","sourceRoot":"","sources":["documentPurgeDocumentChainVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAMvB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,gCAAgC,GAEjC,MA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AAC,YAAY;QAC/D,QAAQ;QACR,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK;KAC1C,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;IACvC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,KAAK,CAAC;IACxC,MAAM,+BAA+B,CAAC;QACpC,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;QAC9D,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;KACrD,CAAC,CAAC;IACH,gCAAgC,CAAC,KAAK,CAAC,iBAAiB,EAAE;QACxD,aAAa,EAAE,CAAC,gBAAgB,CAAC;QACjC,iBAAiB,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;KAChD,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyAuthorization,\n type VerifiedAccessManifestSnapshot,\n type VerifiedContainerAccessManifest,\n type VerifiedDocumentLinkSetManifest,\n type VerifiedDocumentLinkSetSnapshot,\n verifyDocumentLinkSetSnapshot,\n} from \"@tearleads/crypto\";\nimport type {\n AccessManifestBundleWireResponse,\n DocumentPurgeProofResponse,\n} from \"@tearleads/validators/response\";\nimport { readCanonicalJson } from \"../../keying/canonicalJson\";\nimport {\n addBundleByHash,\n assertCanonicalEqual,\n verifyAccessEventBundle,\n} from \"../checkpoints/bundleVerification\";\nimport {\n observeAccessManifestCheckpoints,\n type ProjectionCheckpointContext,\n} from \"../checkpoints/checkpointContext\";\nimport { loadManifestCheckpointVerification } from \"../checkpoints/manifestCheckpointVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../dependencyUnavailable\";\nimport { verifyDocumentManifestBundle } from \"../document/documentManifestVerification\";\nimport { readAccessManifest, readDocumentAccessEventBody } from \"../readers\";\nimport type { PrincipalPolicyCache, ProjectionUserKeyResolver } from \"../types\";\n\nasync function verifyPinnedChainEndpoint(input: {\n readonly bundle: AccessManifestBundleWireResponse;\n readonly checkpointContext: ProjectionCheckpointContext;\n}): Promise<VerifiedDocumentLinkSetSnapshot> {\n const manifest = readAccessManifest(\n input.bundle.manifest,\n \"Document purge predecessor endpoint manifest\",\n );\n const checkpointVerification = await loadManifestCheckpointVerification({\n current: manifest,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: new Map(),\n });\n const localCheckpoint = checkpointVerification.localCheckpoint;\n if (!localCheckpoint) {\n throw new ProjectionDependencyUnavailableError(\n \"Document purge history needs a local checkpoint or signed genesis\",\n );\n }\n if (\n localCheckpoint.epoch !== manifest.epoch ||\n localCheckpoint.manifestHash !== input.bundle.manifestHash\n ) {\n throw new KeyingVerificationError(\n localCheckpoint.epoch > manifest.epoch ? \"rollback\" : \"stale_predecessor\",\n \"Document purge predecessor chain does not start at the local checkpoint\",\n );\n }\n const verified = await verifyDocumentLinkSetSnapshot({\n ...checkpointVerification,\n expectedManifestHash: input.bundle.manifestHash,\n manifest,\n state: input.bundle.state,\n });\n if (!verified.ok) throw verified.error;\n assertCanonicalEqual({\n actual: input.bundle.state,\n expected: readCanonicalJson(\n verified.value.state,\n \"Document purge predecessor endpoint state\",\n ),\n label: \"Document purge predecessor endpoint state\",\n });\n return verified.value;\n}\n\nasync function recordSnapshotContainerEvidence(input: {\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly manifest: VerifiedDocumentLinkSetSnapshot;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<void> {\n if (!input.usedContainerManifests) return;\n const event = await verifyAccessEventBundle({\n bundle: input.proof.documentManifest,\n label: \"Document purge manifest snapshot\",\n resolveUserKey: input.resolveUserKey,\n });\n if (event.eventHash !== input.manifest.manifest.eventHash) {\n throw new KeyingVerificationError(\n \"hash_mismatch\",\n \"Document purge manifest snapshot event is not bound to its manifest\",\n );\n }\n const body = readDocumentAccessEventBody(\n event.body,\n \"Document purge manifest snapshot event body\",\n );\n const manifestHashes = [\n ...event.event.dependencyManifestHashes,\n body.containerManifestHash,\n ];\n for (const manifestHash of manifestHashes) {\n for (const containerManifest of input.containerPathByManifestHash.get(\n manifestHash,\n ) ?? []) {\n input.usedContainerManifests.set(\n containerManifest.manifestHash,\n containerManifest,\n );\n }\n }\n}\n\nasync function verifyPurgeChainEndpoint(\n input: Parameters<typeof verifySignedPurgeDocumentManifestChain>[0] & {\n readonly endpoint: AccessManifestBundleWireResponse;\n readonly bundlesByHash: ReadonlyMap<\n string,\n AccessManifestBundleWireResponse\n >;\n readonly verifiedByHash: Map<string, VerifiedDocumentLinkSetManifest>;\n },\n): Promise<VerifiedDocumentLinkSetSnapshot | null> {\n const endpointManifest = readAccessManifest(\n input.endpoint.manifest,\n \"Document purge chain endpoint\",\n );\n if (endpointManifest.previousManifestHash === null) {\n await verifyDocumentManifestBundle({\n ...input,\n authorizationMembership: \"referenced\",\n bundle: input.endpoint,\n enforceLocalCheckpoint: false,\n label: \"Document purge genesis\",\n requireAuthorizationEvidence: true,\n });\n return null;\n }\n if (!input.enforceLocalCheckpoints) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Initial document purge history does not reach signed genesis\",\n );\n }\n return verifyPinnedChainEndpoint({\n bundle: input.endpoint,\n checkpointContext: input.checkpointContext,\n });\n}\n\nasync function verifySignedPurgeDocumentManifestChain(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<VerifiedDocumentLinkSetManifest> {\n const bundlesByHash = new Map<string, AccessManifestBundleWireResponse>();\n addBundleByHash(\n bundlesByHash,\n input.proof.documentManifest,\n \"Document purge manifest\",\n );\n for (const [\n index,\n bundle,\n ] of input.proof.documentManifestPredecessors.entries()) {\n addBundleByHash(\n bundlesByHash,\n bundle,\n `Document purge predecessor[${index}]`,\n );\n }\n\n const endpoint =\n input.proof.documentManifestPredecessors.at(-1) ??\n input.proof.documentManifest;\n const verifiedByHash = new Map<string, VerifiedDocumentLinkSetManifest>();\n const trustedPredecessorByHash = new Map<\n string,\n VerifiedDocumentLinkSetSnapshot\n >();\n const verifiedEndpoint = await verifyPurgeChainEndpoint({\n ...input,\n endpoint,\n bundlesByHash,\n verifiedByHash,\n });\n if (verifiedEndpoint) {\n trustedPredecessorByHash.set(\n verifiedEndpoint.manifestHash,\n verifiedEndpoint,\n );\n }\n\n const verificationInput = {\n ...input,\n authorizationMembership: \"referenced\" as const,\n bundlesByHash,\n requireAuthorizationEvidence: true,\n trustedPredecessorByHash,\n verifiedByHash,\n };\n for (\n let index = input.proof.documentManifestPredecessors.length - 2;\n index >= 0;\n index -= 1\n ) {\n const bundle = input.proof.documentManifestPredecessors[index];\n if (!bundle) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n `Document purge predecessor[${index}] is missing`,\n );\n }\n await verifyDocumentManifestBundle({\n ...verificationInput,\n bundle,\n enforceLocalCheckpoint: false,\n label: `Document purge predecessor[${index}]`,\n });\n }\n const head = await verifyDocumentManifestBundle({\n ...verificationInput,\n bundle: input.proof.documentManifest,\n enforceLocalCheckpoint: input.enforceLocalCheckpoints,\n label: \"Document purge manifest\",\n });\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: [head],\n verifiedManifests: [...verifiedByHash.values()],\n });\n return head;\n}\n\nexport async function verifyPurgeDocumentManifest(input: {\n readonly authorizationEvidence: readonly PrincipalPolicyAuthorization[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly usedContainerManifests?:\n | Map<string, VerifiedContainerAccessManifest>\n | undefined;\n}): Promise<VerifiedDocumentLinkSetManifest | VerifiedDocumentLinkSetSnapshot> {\n const verifiedByHash = new Map<string, VerifiedAccessManifestSnapshot>();\n const manifest = readAccessManifest(\n input.proof.documentManifest.manifest,\n \"Document purge manifest snapshot\",\n );\n const checkpointVerification = input.enforceLocalCheckpoints\n ? await loadManifestCheckpointVerification({\n current: manifest,\n execSql: input.checkpointContext.execSql,\n localCheckpoints: input.checkpointContext.localCheckpoints,\n verifiedManifests: verifiedByHash,\n })\n : undefined;\n const localCheckpoint = checkpointVerification?.localCheckpoint;\n const isPinnedHead =\n localCheckpoint?.epoch === manifest.epoch &&\n localCheckpoint.manifestHash === input.proof.documentManifest.manifestHash;\n // Baseline inspection may read a hash-only snapshot. Committing a purge\n // requires an exact existing pin or verified signed transitions from\n // that pin (or signed genesis for a fresh device).\n if (\n input.proof.documentManifestPredecessors.length > 0 ||\n (input.enforceLocalCheckpoints && !isPinnedHead)\n ) {\n return verifySignedPurgeDocumentManifestChain(input);\n }\n const verified = await verifyDocumentLinkSetSnapshot({\n ...(checkpointVerification ?? {}),\n expectedManifestHash: input.proof.documentManifest.manifestHash,\n manifest,\n state: input.proof.documentManifest.state,\n });\n if (!verified.ok) throw verified.error;\n const documentManifest = verified.value;\n await recordSnapshotContainerEvidence({\n containerPathByManifestHash: input.containerPathByManifestHash,\n manifest: documentManifest,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n usedContainerManifests: input.usedContainerManifests,\n });\n observeAccessManifestCheckpoints(input.checkpointContext, {\n verifiedHeads: [documentManifest],\n verifiedManifests: [...verifiedByHash.values()],\n });\n return documentManifest;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../internal/crypto/index.js";
2
- import { loadStoredPrincipalPolicyCheckpoint, upsertPrincipalPolicyCheckpointInTransaction, } from "../persistence/keyingCheckpointPersistence.js";
1
+ import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../../internal/crypto/index.js";
2
+ import { loadStoredPrincipalPolicyCheckpoint, upsertPrincipalPolicyCheckpointInTransaction, } from "../../persistence/keyingCheckpointPersistence.js";
3
3
  /** After complete terminal-proof currency validation, admit only its bound sources. */
4
4
  export async function admitDocumentPurgePolicyCheckpoints(input) {
5
5
  const updatedAt = new Date().toISOString();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgePolicyCheckpoints.js","sourceRoot":"","sources":["documentPurgePolicyCheckpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,mCAAmC,EACnC,4CAA4C,GAC7C,MAAM,+CAA+C,CAAC;AAGvD,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,KAKzD;IACC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACpC,IACE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9B,+BAA+B,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CACvD;YAED,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,uCAAuC,CACxC,CAAC;QACJ,MAAM,UAAU,GAAG,MAAM,mCAAmC,CAC1D,KAAK,CAAC,WAAW,EACjB,SAAS,CACV,CAAC;QACF,2EAA2E;QAC3E,uEAAuE;QACvE,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO;YAAE,SAAS;QACpE,MAAM,4CAA4C,CAChD,KAAK,CAAC,WAAW,EACjB,SAAS,EACT,SAAS,EACT,KAAK,CAAC,cAAc,CACrB,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport {\n loadStoredPrincipalPolicyCheckpoint,\n upsertPrincipalPolicyCheckpointInTransaction,\n} from \"../../persistence/keyingCheckpointPersistence\";\nimport type { ClientSQLiteTransactionScope } from \"../../sqlite/sqlitePersistenceRuntime\";\n\n/** After complete terminal-proof currency validation, admit only its bound sources. */\nexport async function admitDocumentPurgePolicyCheckpoints(input: {\n readonly transaction: ClientSQLiteTransactionScope;\n readonly organizationId: string | undefined;\n readonly policies: readonly VerifiedPrincipalPolicySelection[];\n readonly heads: readonly ReferencedPrincipalHead[];\n}): Promise<void> {\n const updatedAt = new Date().toISOString();\n for (const reference of input.heads) {\n if (\n !input.policies.some((policy) =>\n principalPolicyMatchesReference({ policy, reference }),\n )\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Purge source lacks verified inclusion\",\n );\n const checkpoint = await loadStoredPrincipalPolicyCheckpoint(\n input.transaction,\n reference,\n );\n // A newer privately authenticated prefix can prove ancestry, but is not an\n // observation admitted by this terminal proof. Preserve any newer pin.\n if (checkpoint && checkpoint.version >= reference.version) continue;\n await upsertPrincipalPolicyCheckpointInTransaction(\n input.transaction,\n reference,\n updatedAt,\n input.organizationId,\n );\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../internal/crypto/index.js";
2
- import { loadPrincipalPolicyCheckpoint } from "../persistence/keyingCheckpointPersistence.js";
3
- import { observeProjectionLifetime, projectionLifetimeGuard, } from "./projectionLifetimes.js";
4
- import { assertProjectionVerificationCurrent, } from "./types.js";
1
+ import { KeyingVerificationError, principalPolicyMatchesReference, } from "../../../internal/crypto/index.js";
2
+ import { loadPrincipalPolicyCheckpoint } from "../../persistence/keyingCheckpointPersistence.js";
3
+ import { observeProjectionLifetime, projectionLifetimeGuard, } from "../projectionLifetimes.js";
4
+ import { assertProjectionVerificationCurrent, } from "../types.js";
5
5
  /** Authenticate connections to newer device pins without extending terminal grants or admitting heads. */
6
6
  export async function recoverDocumentPurgePolicyCurrency(input) {
7
7
  const resolve = input.warmer?.resolveReference;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgePolicyCurrency.js","sourceRoot":"","sources":["documentPurgePolicyCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAE9F,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,mCAAmC,GAEpC,MAAM,UAAU,CAAC;AAMlB,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,kCAAkC,CAAC,KAMxD;IACC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC/C,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0C,CAAC;IACpE,MAAM,QAAQ,GAAkC,EAAE,CAAC;IACnD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpC,wEAAwE;QACxE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AC,cAAc;gBAC9C,CAAC,+BAA+B,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;gBAEtE,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,6DAA6D,CAC9D,CAAC;YACJ,yBAAyB,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YACvB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,mCAAmC,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n principalPolicyMatchesReference,\n type VerifiedPrincipalPolicyCurrent,\n type VerifiedPrincipalPolicySelection,\n} from \"@tearleads/crypto\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../persistence/keyingCheckpointPersistence\";\nimport type { ProjectionCheckpointContext } from \"../checkpoints/checkpointContext\";\nimport {\n observeProjectionLifetime,\n projectionLifetimeGuard,\n} from \"../projectionLifetimes\";\nimport {\n assertProjectionVerificationCurrent,\n type ReferencedPrincipalPolicyWarmer,\n} from \"../types\";\n\nexport type PurgePolicyCurrencyEvidence =\n | VerifiedPrincipalPolicySelection\n | VerifiedPrincipalPolicyCurrent;\n\n/** Authenticate connections to newer device pins without extending terminal grants or admitting heads. */\nexport async function recoverDocumentPurgePolicyCurrency(input: {\n readonly context: ProjectionCheckpointContext;\n readonly organizationId: string;\n readonly policies: readonly VerifiedPrincipalPolicySelection[];\n readonly warmer: ReferencedPrincipalPolicyWarmer | undefined;\n readonly stillCurrent: () => boolean;\n}): Promise<PurgePolicyCurrencyEvidence[]> {\n const resolve = input.warmer?.resolveReference;\n if (!resolve) return [...input.policies];\n const recoveryBatch = {};\n const recovered = new Map<string, VerifiedPrincipalPolicyCurrent>();\n const policies: PurgePolicyCurrencyEvidence[] = [];\n for (const policy of input.policies) {\n // Returned leases may include their caller predicate. Pass the original\n // lifetime, not the growing context guard, to avoid a recursive guard graph.\n const stillCurrent = input.stillCurrent;\n assertProjectionVerificationCurrent(projectionLifetimeGuard(input.context));\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n input.context.execSql,\n policy.principalType,\n policy.principalId,\n );\n if (!checkpoint || checkpoint.version <= policy.version) {\n policies.push(policy);\n continue;\n }\n const key = `${policy.principalType}:${policy.principalId}:${policy.stateHash}`;\n let bridge = recovered.get(key);\n if (!bridge) {\n const reference = {\n principalType: policy.principalType,\n principalId: policy.principalId,\n version: policy.version,\n stateHash: policy.stateHash,\n keyEpoch: policy.keyEpoch,\n keyFingerprint: policy.state.keyFingerprint,\n };\n const result = await resolve({\n organizationId: input.organizationId,\n reference,\n recoveryBatch,\n preferLocalHistory: true,\n stillCurrent,\n });\n assertProjectionVerificationCurrent(\n projectionLifetimeGuard(input.context),\n );\n assertProjectionVerificationCurrent(result.stillCurrent);\n if (\n result.organizationId !== input.organizationId ||\n !principalPolicyMatchesReference({ policy: result.policy, reference })\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Purge currency recovery does not bind its historical policy\",\n );\n observeProjectionLifetime(input.context, result.stillCurrent);\n bridge = result.policy;\n recovered.set(key, bridge);\n }\n policies.push(bridge);\n }\n assertProjectionVerificationCurrent(projectionLifetimeGuard(input.context));\n return policies;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { KeyingVerificationError, principalPolicyMatchesReference, verifyDocumentPurgeEvent, } from "../../internal/crypto/index.js";
2
- import { parseOrganizationAuthorityDescriptor } from "../principals/organizationAuthorityDescriptor.js";
3
- import { verifyStandaloneAccessEventBundle } from "./bundleVerification.js";
1
+ import { KeyingVerificationError, principalPolicyMatchesReference, verifyDocumentPurgeEvent, } from "../../../internal/crypto/index.js";
2
+ import { parseOrganizationAuthorityDescriptor } from "../../principals/organizationAuthorityDescriptor.js";
3
+ import { verifyStandaloneAccessEventBundle } from "../checkpoints/bundleVerification.js";
4
4
  import { verifyPurgeDocumentManifest } from "./documentPurgeDocumentChainVerification.js";
5
5
  function principalIdentity(input) {
6
6
  return `${input.principalType}:${input.principalId}`;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPurgePrincipalEvidence.js","sourceRoot":"","sources":["documentPurgePrincipalEvidence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,+BAA+B,EAM/B,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oCAAoC,EAAE,MAAM,kDAAkD,CAAC;AACxG,OAAO,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AAGtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF,SAAS,iBAAiB,CAAC,KAG1B;IACC,OAAO,GAAG,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,iCAAiC,CAAC,KAG1C;IACC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2C,CAAC;IACpE,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,SAAS;QAC/D,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC9C,KAAK,MAAM,cAAc,IAAI;YAC3B,QAAQ,CAAC,QAAQ,CAAC,oBAAoB;YACtC,QAAQ,CAAC,KAAK,CAAC,kBAAkB;SAClC,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EAAE;gBACtB,GAAG,KAAK,CAAC,wBAAwB;gBACjC,GAAG,sBAAsB,CAAC,MAAM,EAAE;aACnC;YACD,0BAA0B,EAAE,KAAK,CAAC,0BAA0B;SAC7D,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyAuthorization,\n principalPolicyMatchesReference,\n type ReferencedPrincipalHead,\n type VerifiedContainerAccessManifest,\n type VerifiedDocumentLinkSetManifest,\n type VerifiedDocumentLinkSetSnapshot,\n type VerifiedPrincipalPolicySelection,\n verifyDocumentPurgeEvent,\n} from \"@tearleads/crypto\";\nimport type { DocumentPurgeProofResponse } from \"@tearleads/validators/response\";\nimport { parseOrganizationAuthorityDescriptor } from \"../../principals/organizationAuthorityDescriptor\";\nimport { verifyStandaloneAccessEventBundle } from \"../checkpoints/bundleVerification\";\nimport type { ProjectionCheckpointContext } from \"../checkpoints/checkpointContext\";\nimport type { PrincipalPolicyCache, ProjectionUserKeyResolver } from \"../types\";\nimport { verifyPurgeDocumentManifest } from \"./documentPurgeDocumentChainVerification\";\n\nfunction principalIdentity(input: {\n readonly principalId: string;\n readonly principalType: string;\n}): string {\n return `${input.principalType}:${input.principalId}`;\n}\n\nfunction collectEvidenceContainerManifests(input: {\n readonly roots: readonly VerifiedContainerAccessManifest[];\n readonly verifiedByHash: ReadonlyMap<string, VerifiedContainerAccessManifest>;\n}): VerifiedContainerAccessManifest[] {\n const selected = new Map<string, VerifiedContainerAccessManifest>();\n const pending = [...input.roots];\n while (pending.length > 0) {\n const manifest = pending.shift();\n if (!manifest || selected.has(manifest.manifestHash)) continue;\n selected.set(manifest.manifestHash, manifest);\n for (const dependencyHash of [\n manifest.manifest.previousManifestHash,\n manifest.state.parentManifestHash,\n ]) {\n if (!dependencyHash) continue;\n const dependency = input.verifiedByHash.get(dependencyHash);\n if (dependency) pending.push(dependency);\n }\n }\n return [...selected.values()];\n}\n\nfunction requireExactPurgePrincipalEvidence<\n TPolicy extends PrincipalPolicyAuthorization,\n>(input: {\n readonly authorizationEvidence: readonly TPolicy[];\n readonly verifiedContainerManifests: readonly VerifiedContainerAccessManifest[];\n readonly policyEvidence: DocumentPurgeProofResponse[\"policyEvidence\"];\n}): TPolicy[] {\n const references: ReferencedPrincipalHead[] =\n input.verifiedContainerManifests.flatMap(\n (manifest) => manifest.state.referencedPrincipalHeads,\n );\n const requiredByPrincipal = new Set<string>();\n\n for (const reference of references) {\n const policy = input.authorizationEvidence.find((candidate) =>\n principalPolicyMatchesReference({ policy: candidate, reference }),\n );\n if (!policy) {\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Document purge proof omits referenced principal policy evidence\",\n );\n }\n const identity = principalIdentity(policy);\n requiredByPrincipal.add(identity);\n // External authority is verified incrementally by paged recovery. Its\n // historical entries need not be copied into this returned selection.\n }\n\n const allowed = new Set(requiredByPrincipal);\n // Paged recovery has authenticated these payloads against their signed\n // organization states and verified their exact group-head bindings. This\n // identity allow-list cannot authenticate an unverified directory payload.\n for (const { payload } of input.policyEvidence.organizationPayloads) {\n const directory = parseOrganizationAuthorityDescriptor(payload.ciphertext);\n if (\n directory.groupHeads.some((head) => allowed.has(principalIdentity(head)))\n ) {\n allowed.add(`group:${directory.adminGroupId}`);\n allowed.add(`organization:${directory.organizationId}`);\n }\n }\n if (\n input.authorizationEvidence.some(\n (policy) => !allowed.has(principalIdentity(policy)),\n )\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Document purge proof includes unrelated principal policy evidence\",\n );\n return input.authorizationEvidence.filter((policy) =>\n requiredByPrincipal.has(principalIdentity(policy)),\n );\n}\n\nasync function authenticateDocumentPurgeEvent(input: {\n readonly authorizationEvidence: readonly VerifiedPrincipalPolicySelection[];\n readonly authorizingContainerPath: readonly VerifiedContainerAccessManifest[];\n readonly documentManifest:\n | VerifiedDocumentLinkSetManifest\n | VerifiedDocumentLinkSetSnapshot;\n readonly expectedDocumentId: string;\n readonly purgeEvent: DocumentPurgeProofResponse[\"purgeEvent\"];\n readonly policyEvidence: DocumentPurgeProofResponse[\"policyEvidence\"];\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly rootContainerManifests: readonly VerifiedContainerAccessManifest[];\n readonly verifiedContainerManifests: ReadonlyMap<\n string,\n VerifiedContainerAccessManifest\n >;\n}): Promise<{\n readonly principalPolicies: VerifiedPrincipalPolicySelection[];\n readonly purgeEventHash: string;\n}> {\n const event = await verifyStandaloneAccessEventBundle({\n bundle: input.purgeEvent,\n label: \"Document purge event\",\n resolveUserKey: input.resolveUserKey,\n });\n const evidenceContainerManifests = collectEvidenceContainerManifests({\n roots: input.rootContainerManifests,\n verifiedByHash: input.verifiedContainerManifests,\n });\n const principalPolicies = requireExactPurgePrincipalEvidence({\n authorizationEvidence: input.authorizationEvidence,\n verifiedContainerManifests: evidenceContainerManifests,\n policyEvidence: input.policyEvidence,\n });\n const verified = await verifyDocumentPurgeEvent({\n authorizingContainerPath: input.authorizingContainerPath,\n documentManifest: input.documentManifest,\n event,\n expectedDocumentId: input.expectedDocumentId,\n principalPolicies,\n });\n if (!verified.ok) throw verified.error;\n return {\n principalPolicies: [...input.authorizationEvidence],\n purgeEventHash: verified.value.eventHash,\n };\n}\n\nexport async function authenticateDocumentPurgeArtifacts(input: {\n readonly authorizationEvidence: readonly VerifiedPrincipalPolicySelection[];\n readonly authorizingContainerPath: readonly VerifiedContainerAccessManifest[];\n readonly checkpointContext: ProjectionCheckpointContext;\n readonly containerPathByManifestHash: ReadonlyMap<\n string,\n readonly VerifiedContainerAccessManifest[]\n >;\n readonly enforceLocalCheckpoints: boolean;\n readonly expectedDocumentId: string;\n readonly principalPolicyCache: PrincipalPolicyCache;\n readonly proof: DocumentPurgeProofResponse;\n readonly resolveUserKey: ProjectionUserKeyResolver;\n readonly verifiedContainerManifests: ReadonlyMap<\n string,\n VerifiedContainerAccessManifest\n >;\n}) {\n const usedContainerManifests = new Map<\n string,\n VerifiedContainerAccessManifest\n >();\n const documentManifest = await verifyPurgeDocumentManifest({\n authorizationEvidence: input.authorizationEvidence,\n checkpointContext: input.checkpointContext,\n containerPathByManifestHash: input.containerPathByManifestHash,\n enforceLocalCheckpoints: input.enforceLocalCheckpoints,\n principalPolicyCache: input.principalPolicyCache,\n proof: input.proof,\n resolveUserKey: input.resolveUserKey,\n usedContainerManifests,\n });\n return {\n documentManifest,\n ...(await authenticateDocumentPurgeEvent({\n authorizationEvidence: input.authorizationEvidence,\n authorizingContainerPath: input.authorizingContainerPath,\n documentManifest,\n expectedDocumentId: input.expectedDocumentId,\n purgeEvent: input.proof.purgeEvent,\n policyEvidence: input.proof.policyEvidence,\n resolveUserKey: input.resolveUserKey,\n rootContainerManifests: [\n ...input.authorizingContainerPath,\n ...usedContainerManifests.values(),\n ],\n verifiedContainerManifests: input.verifiedContainerManifests,\n })),\n };\n}\n"]}