@tearleads/client-sdk 0.1.63 → 0.1.65

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 (1432) hide show
  1. package/client/organizations/organizationAccessRestoration.js +1 -1
  2. package/data/containers/shared/mutationAcknowledgement.js +1 -1
  3. package/data/containers/shared/mutationAcknowledgement.js.map +1 -1
  4. package/data/documents/blob/shared/projection.js +4 -4
  5. package/data/documents/blob/shared/projection.js.map +1 -1
  6. package/data/documents/shared/containerKek/containerKekCurrency.d.ts +22 -0
  7. package/data/documents/shared/containerKek/containerKekEntryVerification.js +15 -0
  8. package/data/documents/shared/containerKek/containerKekLogFetch.d.ts +18 -0
  9. package/data/documents/shared/containerKek/containerKekLogFetch.js +76 -0
  10. package/data/documents/shared/containerKek/containerKekPath.js +265 -0
  11. package/data/documents/shared/containerKek/containerKekPath.js.map +1 -0
  12. package/data/documents/shared/containerKek/containerKekPathHistory.d.ts +61 -0
  13. package/data/documents/shared/containerKek/containerKekPathHistory.js +223 -0
  14. package/data/documents/shared/containerKek/containerKekPathHistory.js.map +1 -0
  15. package/data/documents/shared/containerKek/containerKekPathVerification.d.ts +15 -0
  16. package/data/documents/shared/containerKek/containerKekPathVerification.js +23 -0
  17. package/data/documents/shared/containerKek/containerKekPathVerification.js.map +1 -0
  18. package/data/documents/shared/containerKek/containerKekWrapping.js +61 -0
  19. package/data/documents/shared/containerKek/containerKekWrapping.js.map +1 -0
  20. package/data/documents/shared/containerKek/keyringLogWalk.d.ts +45 -0
  21. package/data/documents/shared/containerKek/keyringLogWalk.js +204 -0
  22. package/data/documents/shared/containerKek/keyringRebuild.d.ts +60 -0
  23. package/data/documents/shared/containerKek/keyringRebuild.js +242 -0
  24. package/data/documents/shared/containerKek/keyringRebuild.js.map +1 -0
  25. package/data/documents/shared/crypto.js +2 -2
  26. package/data/documents/shared/crypto.js.map +1 -1
  27. package/data/documents/shared/events.js +1 -1
  28. package/data/documents/shared/projection/index.d.ts +25 -0
  29. package/data/documents/shared/projection/index.js +132 -0
  30. package/data/documents/shared/projection/index.js.map +1 -0
  31. package/data/documents/shared/projection/projectionContentKeys.d.ts +90 -0
  32. package/data/documents/shared/projection/projectionContentKeys.js +262 -0
  33. package/data/documents/shared/projection/projectionContentKeys.js.map +1 -0
  34. package/data/documents/shared/projection/projectionTargets.d.ts +38 -0
  35. package/data/documents/shared/projection/projectionTargets.js +164 -0
  36. package/data/documents/shared/projection/projectionTargets.js.map +1 -0
  37. package/data/documents/shared/responses.d.ts +1 -1
  38. package/data/documents/shared/responses.js +1 -1
  39. package/data/documents/shared/responses.js.map +1 -1
  40. package/data/documents/shared/sync/documentSyncUpdateDecryption.js +238 -0
  41. package/data/documents/shared/sync/documentSyncUpdateDecryption.js.map +1 -0
  42. package/data/documents/shared/sync/documentSyncUpdateIsolation.d.ts +55 -0
  43. package/data/documents/shared/sync/documentSyncUpdateIsolation.js +298 -0
  44. package/data/documents/shared/sync/documentSyncUpdateIsolation.js.map +1 -0
  45. package/data/documents/shared/sync/mutationAcknowledgement.js +10 -0
  46. package/data/documents/shared/sync/mutationAcknowledgement.js.map +1 -0
  47. package/data/documents/shared/sync/pullContinuation.js +53 -0
  48. package/data/documents/shared/sync/syncPagination.d.ts +20 -0
  49. package/data/documents/shared/sync/syncPagination.js +109 -0
  50. package/data/documents/shared/sync/syncPagination.js.map +1 -0
  51. package/data/documents/shared/sync/syncResponseAuthorization.js +63 -0
  52. package/data/documents/shared/sync/syncResponseAuthorization.js.map +1 -0
  53. package/data/documents/shared/sync/syncResponses.d.ts +11 -0
  54. package/data/documents/shared/sync/syncResponses.js +285 -0
  55. package/data/documents/shared/sync/syncResponses.js.map +1 -0
  56. package/data/documents/shared/sync/syncSubmitFailure.d.ts +9 -0
  57. package/data/documents/shared/types.d.ts +3 -3
  58. package/data/documents/shared/types.js.map +1 -1
  59. package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js +61 -0
  60. package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
  61. package/data/keyingProjectionVerification/checkpoints/bundleVerification.js +61 -0
  62. package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
  63. package/data/keyingProjectionVerification/checkpoints/checkpointContext.d.ts +45 -0
  64. package/data/keyingProjectionVerification/checkpoints/checkpointContext.js +120 -0
  65. package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
  66. package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js +64 -0
  67. package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
  68. package/data/keyingProjectionVerification/container/containerAncestorCitations.js +164 -0
  69. package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
  70. package/data/keyingProjectionVerification/container/containerCreateManifest.js +28 -0
  71. package/data/keyingProjectionVerification/container/containerDestinationVerification.js +51 -0
  72. package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
  73. package/data/keyingProjectionVerification/container/containerManifestVerification.js +285 -0
  74. package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
  75. package/data/keyingProjectionVerification/container/containerPathVerification.js +51 -0
  76. package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
  77. package/data/keyingProjectionVerification/container/containerProjectionVerification.d.ts +25 -0
  78. package/data/keyingProjectionVerification/container/containerProjectionVerification.js +254 -0
  79. package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
  80. package/data/keyingProjectionVerification/document/documentDependencyPaths.d.ts +17 -0
  81. package/data/keyingProjectionVerification/document/documentDependencyPaths.js +70 -0
  82. package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
  83. package/data/keyingProjectionVerification/document/documentManifestPolicies.js +32 -0
  84. package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
  85. package/data/keyingProjectionVerification/document/documentManifestPredecessor.js +12 -0
  86. package/data/keyingProjectionVerification/document/documentManifestVerification.js +135 -0
  87. package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
  88. package/data/keyingProjectionVerification/document/documentProjectionVerification.d.ts +24 -0
  89. package/data/keyingProjectionVerification/document/documentProjectionVerification.js +172 -0
  90. package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
  91. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js +100 -0
  92. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
  93. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js +8 -0
  94. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
  95. package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js +177 -0
  96. package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
  97. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js +17 -0
  98. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
  99. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js +55 -0
  100. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
  101. package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js +116 -0
  102. package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
  103. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.d.ts +34 -0
  104. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js +208 -0
  105. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
  106. package/data/keyingProjectionVerification/index.d.ts +4 -4
  107. package/data/keyingProjectionVerification/index.js +4 -4
  108. package/data/keyingProjectionVerification/index.js.map +1 -1
  109. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js +45 -0
  110. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
  111. package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js +41 -0
  112. package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
  113. package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js +76 -0
  114. package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
  115. package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js +252 -0
  116. package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
  117. package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js +63 -0
  118. package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
  119. package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js +23 -0
  120. package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
  121. package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js +72 -0
  122. package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
  123. package/data/persistence/container-contents/containerContentsPersistence.js +3 -3
  124. package/data/persistence/container-contents/containerContentsPersistence.js.map +1 -1
  125. package/data/persistence/container-contents/containerContentsPersistenceTypes.d.ts +2 -2
  126. package/data/persistence/container-contents/containerContentsPersistenceTypes.js.map +1 -1
  127. package/data/persistence/container-contents/containerCreateIntentSettlement.js +1 -1
  128. package/data/persistence/container-contents/containerDeletionPersistence.js +2 -2
  129. package/data/persistence/container-contents/containerDocumentReassignment.js +2 -2
  130. package/data/persistence/container-contents/containerDocumentReassignment.js.map +1 -1
  131. package/data/persistence/container-contents/containerHydrationPersistence.js +3 -3
  132. package/data/persistence/container-contents/containerHydrationPersistence.js.map +1 -1
  133. package/data/persistence/container-contents/containerIntentPersistence.js +1 -1
  134. package/data/persistence/container-contents/containerMetadataMutationPersistence.js +5 -5
  135. package/data/persistence/container-contents/containerMetadataMutationPersistence.js.map +1 -1
  136. package/data/persistence/container-contents/containerMetadataPullContinuationPersistence.js +1 -1
  137. package/data/persistence/container-contents/containerMetadataRows.js +3 -3
  138. package/data/persistence/container-contents/containerMetadataRows.js.map +1 -1
  139. package/data/persistence/container-contents/containerMoveAbandonPersistence.js +1 -1
  140. package/data/persistence/container-contents/containerMoveIntentRows.js +1 -1
  141. package/data/persistence/container-contents/containerPendingUpdatePersistence.js +3 -3
  142. package/data/persistence/container-contents/containerPendingUpdatePersistence.js.map +1 -1
  143. package/data/persistence/container-contents/containerRebindPersistence.js +1 -1
  144. package/data/persistence/container-contents/containerReconcilePersistence.js +2 -2
  145. package/data/persistence/container-contents/containerRecoveryPersistence.js +1 -1
  146. package/data/persistence/container-contents/containerRemovalWork.js +3 -3
  147. package/data/persistence/container-contents/containerRemovalWork.js.map +1 -1
  148. package/data/persistence/container-contents/containerStructuralRepair.js +1 -1
  149. package/data/persistence/container-contents/documentLinkRemovalRepair.js +2 -2
  150. package/data/persistence/container-contents/documentLinkRemovalRepair.js.map +1 -1
  151. package/data/persistence/container-contents/documentMoveIntentPersistence.js +2 -2
  152. package/data/persistence/container-contents/documentMoveIntentPersistence.js.map +1 -1
  153. package/data/persistence/container-contents/documentPlacementIntentEnqueue.js +2 -2
  154. package/data/persistence/container-contents/documentPlacementIntentEnqueue.js.map +1 -1
  155. package/data/persistence/container-contents/documentPurgePlacement.js +1 -1
  156. package/data/persistence/container-contents/dormantContainerMetadata.js +1 -1
  157. package/data/persistence/container-contents/dormantMetadataSweep.js +1 -1
  158. package/data/persistence/container-contents/pendingContainerCreate.js +1 -1
  159. package/data/persistence/container-contents/supersededContainerBindings.js +1 -1
  160. package/data/persistence/containers/containerPersistence.js +1 -1
  161. package/data/persistence/containers/containerSyncWatermarkPersistence.js +1 -1
  162. package/data/persistence/containers/documentContainerProjectionPersistence.js +1 -1
  163. package/data/persistence/containers/documentPlacement.js +1 -1
  164. package/data/persistence/documents/containerDocumentTombstoneHoldsPersistence.js +1 -1
  165. package/data/persistence/documents/documentDiscoveryEvidencePersistence.js +3 -3
  166. package/data/persistence/documents/documentDiscoveryEvidencePersistence.js.map +1 -1
  167. package/data/persistence/documents/documentDiscoveryReset.js +1 -1
  168. package/data/persistence/documents/documentDiscoveryReset.js.map +1 -1
  169. package/data/persistence/documents/documentsPersistence.js +3 -3
  170. package/data/persistence/documents/documentsPersistence.js.map +1 -1
  171. package/data/persistence/documents/internal/attachmentStagingPersistence.js +1 -1
  172. package/data/persistence/documents/internal/containerDocumentTombstoneHolds.js +1 -1
  173. package/data/persistence/documents/internal/containerDocumentTombstones.js +1 -1
  174. package/data/persistence/documents/internal/createDocumentWithHistoryCheckpoint.js +2 -2
  175. package/data/persistence/documents/internal/createDocumentWithHistoryCheckpoint.js.map +1 -1
  176. package/data/persistence/documents/internal/discardDocument.js +3 -3
  177. package/data/persistence/documents/internal/discardDocument.js.map +1 -1
  178. package/data/persistence/documents/internal/documentDeletionPersistence.js +4 -4
  179. package/data/persistence/documents/internal/documentDeletionPersistence.js.map +1 -1
  180. package/data/persistence/documents/internal/documentMutationPersistence.js +5 -5
  181. package/data/persistence/documents/internal/documentMutationPersistence.js.map +1 -1
  182. package/data/persistence/documents/internal/documentProjectionRows.js +1 -1
  183. package/data/persistence/documents/internal/documentPullContinuationPersistence.js +1 -1
  184. package/data/persistence/documents/internal/documentRows.js +2 -2
  185. package/data/persistence/documents/internal/documentRows.js.map +1 -1
  186. package/data/persistence/documents/internal/documentSummaryQueries.js +1 -1
  187. package/data/persistence/documents/internal/ensureDocumentsSchema.js +2 -2
  188. package/data/persistence/documents/internal/hydratedAttachmentPersistence.js +1 -1
  189. package/data/persistence/documents/internal/orphanSideRows.js +2 -2
  190. package/data/persistence/documents/internal/orphanSideRows.js.map +1 -1
  191. package/data/persistence/documents/internal/pendingCreateAdoption.js +1 -1
  192. package/data/persistence/documents/internal/rowQueryPersistence.js +2 -2
  193. package/data/persistence/documents/internal/syncQueuePersistence.js +3 -3
  194. package/data/persistence/documents/internal/syncQueuePersistence.js.map +1 -1
  195. package/data/persistence/documents/types.d.ts +3 -3
  196. package/data/persistence/documents/types.js.map +1 -1
  197. package/data/persistence/keyingCheckpoints/documentPurgeCheckpointPersistence.d.ts +10 -0
  198. package/data/persistence/keyingCheckpoints/documentPurgeCheckpointPersistence.js +43 -0
  199. package/data/persistence/keyingCheckpoints/documentPurgeCheckpointPersistence.js.map +1 -0
  200. package/data/persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence.js +222 -0
  201. package/data/persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence.js.map +1 -0
  202. package/data/persistence/keyingCheckpoints/keyingCheckpointEvidence.js +32 -0
  203. package/data/persistence/keyingCheckpoints/keyingCheckpointPersistence.js +133 -0
  204. package/data/persistence/keyingCheckpoints/keyingCheckpointPersistence.js.map +1 -0
  205. package/data/persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.d.ts +53 -0
  206. package/data/persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.js +167 -0
  207. package/data/persistence/keyingCheckpoints/locallyAcknowledgedCheckpointPersistence.js.map +1 -0
  208. package/data/persistence/keyingCheckpoints/organizationReplacementCheckpointPersistence.js +72 -0
  209. package/data/persistence/keyingCheckpoints/organizationReplacementCheckpointPersistence.js.map +1 -0
  210. package/data/persistence/keyingCheckpoints/principalAuthorizationCheckpoints.js +29 -0
  211. package/data/persistence/keyingCheckpoints/principalAuthorizationCheckpoints.js.map +1 -0
  212. package/data/persistence/organizationFounderPersistence.js +2 -2
  213. package/data/persistence/organizationFounderPersistence.js.map +1 -1
  214. package/data/persistence/organizations/organizationAccessRevocationPersistence.js +3 -3
  215. package/data/persistence/organizations/organizationAccessRevocationPersistence.js.map +1 -1
  216. package/data/persistence/organizations/organizationDataUsagePersistence.js +2 -2
  217. package/data/persistence/organizations/organizationDataUsagePersistence.js.map +1 -1
  218. package/data/persistence/organizations/organizationGroupNamePersistence.js +2 -2
  219. package/data/persistence/organizations/organizationGroupNamePersistence.js.map +1 -1
  220. package/data/persistence/organizations/organizationPresentationDenialPersistence.js +2 -2
  221. package/data/persistence/organizations/organizationPresentationDenialPersistence.js.map +1 -1
  222. package/data/persistence/organizations/organizationProfileDocumentPointers.js +2 -2
  223. package/data/persistence/organizations/organizationProfileDocumentPointers.js.map +1 -1
  224. package/data/persistence/organizations/organizationProvisioningAttemptPersistence.js +1 -1
  225. package/data/persistence/organizations/organizationProvisioningAttemptPersistence.js.map +1 -1
  226. package/data/persistence/organizations/organizationReadModelGrantPersistence.js +1 -1
  227. package/data/persistence/organizations/organizationReadModelGrantPersistence.js.map +1 -1
  228. package/data/persistence/organizations/organizationReadModelMemberLoad.js +1 -1
  229. package/data/persistence/organizations/organizationReadModelMemberLoad.js.map +1 -1
  230. package/data/persistence/organizations/organizationReadModelMembershipPersistence.js +1 -1
  231. package/data/persistence/organizations/organizationReadModelMembershipPersistence.js.map +1 -1
  232. package/data/persistence/organizations/organizationReadModelPersistence.js +3 -3
  233. package/data/persistence/organizations/organizationReadModelPersistence.js.map +1 -1
  234. package/data/persistence/organizations/organizationReadModelProjection.js +1 -1
  235. package/data/persistence/organizations/organizationReadModelProjection.js.map +1 -1
  236. package/data/persistence/organizations/organizationReadModelPurge.js +3 -3
  237. package/data/persistence/organizations/organizationReadModelPurge.js.map +1 -1
  238. package/data/persistence/principalCurrentAcknowledgementPersistence.d.ts +3 -3
  239. package/data/persistence/principalCurrentAcknowledgementPersistence.js +10 -10
  240. package/data/persistence/principalCurrentAcknowledgementPersistence.js.map +1 -1
  241. package/data/persistence/principalHistory/principalHistoryEvidencePersistence.d.ts +32 -0
  242. package/data/persistence/principalHistory/principalHistoryEvidencePersistence.js +92 -0
  243. package/data/persistence/principalHistory/principalHistoryEvidencePersistence.js.map +1 -0
  244. package/data/persistence/principalHistory/principalHistoryIncompleteRetention.js +26 -0
  245. package/data/persistence/principalHistory/principalHistoryIncompleteRetention.js.map +1 -0
  246. package/data/persistence/principalHistory/principalHistoryNodeRetention.js +201 -0
  247. package/data/persistence/principalHistory/principalHistoryNodeRetention.js.map +1 -0
  248. package/data/persistence/principalHistory/principalHistoryPrefixPersistence.d.ts +29 -0
  249. package/data/persistence/principalHistory/principalHistoryPrefixPersistence.js +102 -0
  250. package/data/persistence/principalHistory/principalHistoryPrefixPersistence.js.map +1 -0
  251. package/data/persistence/principalHistory/principalHistoryRootOwnership.js +71 -0
  252. package/data/persistence/principalHistory/principalHistoryRootOwnership.js.map +1 -0
  253. package/data/persistence/principalHistory/principalHistoryStagePersistence.d.ts +15 -0
  254. package/data/persistence/principalHistory/principalHistoryStagePersistence.js +96 -0
  255. package/data/persistence/principalHistory/principalHistoryStagePersistence.js.map +1 -0
  256. package/data/persistence/principalHistory/principalHistoryStageRetention.js +45 -0
  257. package/data/persistence/principalHistory/principalHistoryStageRetention.js.map +1 -0
  258. package/data/persistence/principalHistory/principalHistoryUnpublishedRetention.js +64 -0
  259. package/data/persistence/principalHistory/principalHistoryUnpublishedRetention.js.map +1 -0
  260. package/data/persistence/principalKeys/principalGrantRetirementPersistence.d.ts +9 -0
  261. package/data/persistence/principalKeys/principalGrantRetirementPersistence.js +43 -0
  262. package/data/persistence/principalKeys/principalGrantRetirementPersistence.js.map +1 -0
  263. package/data/persistence/principalKeys/principalKeyEnvelopeArchivePersistence.js +63 -0
  264. package/data/persistence/principalKeys/principalKeyEnvelopeArchivePersistence.js.map +1 -0
  265. package/data/persistence/principalKeys/principalKeyEnvelopeCandidates.js +87 -0
  266. package/data/persistence/principalKeys/principalKeyEnvelopeCandidates.js.map +1 -0
  267. package/data/persistence/principalMutationJournalPersistence.d.ts +1 -1
  268. package/data/persistence/principalMutationJournalPersistence.js +1 -1
  269. package/data/persistence/principalMutationJournalPersistence.js.map +1 -1
  270. package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js +49 -0
  271. package/data/persistence/principalPolicy/principalPolicyBundleIntegrity.js.map +1 -0
  272. package/data/persistence/principalPolicy/principalPolicyCheckpointSelection.js +26 -0
  273. package/data/persistence/principalPolicy/principalPolicyCheckpointSelection.js.map +1 -0
  274. package/data/persistence/principalPolicy/principalPolicyOrganizationPersistence.js +42 -0
  275. package/data/persistence/principalPolicy/principalPolicyOrganizationPersistence.js.map +1 -0
  276. package/data/persistence/principalPolicy/principalPolicyPersistence.js +279 -0
  277. package/data/persistence/principalPolicy/principalPolicyPersistence.js.map +1 -0
  278. package/data/persistence/principalPolicy/principalPolicyReferenceCheckpoint.js +27 -0
  279. package/data/persistence/principalPolicy/principalPolicyReferenceCheckpoint.js.map +1 -0
  280. package/data/persistence/principalPolicy/principalPolicyReferenceIndexPersistence.js +115 -0
  281. package/data/persistence/principalPolicy/principalPolicyReferenceIndexPersistence.js.map +1 -0
  282. package/data/persistence/principalPolicy/principalPolicyReferencePersistence.js +215 -0
  283. package/data/persistence/principalPolicy/principalPolicyReferencePersistence.js.map +1 -0
  284. package/data/persistence/principalPolicy/verifiedPrincipalPolicyBundle.js +33 -0
  285. package/data/persistence/principalPolicy/verifiedPrincipalPolicyBundle.js.map +1 -0
  286. package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js +56 -0
  287. package/data/persistence/principalPolicy/verifiedPrincipalPolicyCurrent.js.map +1 -0
  288. package/data/persistence/principalPolicy/verifiedPrincipalPolicyRetentionPersistence.js +18 -0
  289. package/data/persistence/principalPolicy/verifiedPrincipalPolicyRetentionPersistence.js.map +1 -0
  290. package/data/persistence/securityIncidentPersistence.js +1 -1
  291. package/data/persistence/securityIncidentPersistence.js.map +1 -1
  292. package/data/persistence/trustedUserIdentityPinPersistence.js +1 -1
  293. package/data/persistence/verifiedManifestBundlePersistence.d.ts +1 -1
  294. package/data/persistence/verifiedManifestBundlePersistence.js +4 -4
  295. package/data/persistence/verifiedManifestBundlePersistence.js.map +1 -1
  296. package/data/principals/organizationGroupRoles.js +2 -2
  297. package/data/principals/organizationGroupRoles.js.map +1 -1
  298. package/data/principals/principalHistoryPrefixProtection.js.map +1 -1
  299. package/data/principals/principalHistoryStageProtection.js.map +1 -1
  300. package/data/principals/principalPolicyCrypto.js +1 -1
  301. package/data/principals/principalPolicyCrypto.js.map +1 -1
  302. package/data/sqlite/documentPersistence/documentHistoryPersistence.d.ts +86 -0
  303. package/data/sqlite/documentPersistence/documentHistoryPersistence.js +304 -0
  304. package/data/sqlite/documentPersistence/documentHistoryPersistence.js.map +1 -0
  305. package/data/sqlite/documentPersistence/documentOrphanBlobReclaims.js +6 -0
  306. package/data/sqlite/documentPersistence/documentOrphanBlobReclaims.js.map +1 -0
  307. package/data/sqlite/documentPersistence/documentPendingUpdatePersistence.d.ts +103 -0
  308. package/data/sqlite/documentPersistence/documentPendingUpdatePersistence.js +243 -0
  309. package/data/sqlite/documentPersistence/documentPendingUpdatePersistence.js.map +1 -0
  310. package/data/sqlite/documentPersistence/documentPersistenceTypes.d.ts +79 -0
  311. package/data/sqlite/documentPersistence/documentPersistenceTypes.js.map +1 -0
  312. package/data/sqlite/documentPersistence/documentRecordPersistence.d.ts +275 -0
  313. package/data/sqlite/documentPersistence/documentRecordPersistence.js +103 -0
  314. package/data/sqlite/documentPersistence/documentRecordPersistence.js.map +1 -0
  315. package/data/sqlite/documentPersistence/documentSyncFailurePersistence.d.ts +39 -0
  316. package/data/sqlite/documentPersistence/documentSyncFailurePersistence.js +81 -0
  317. package/data/sqlite/documentPersistence/documentSyncFailurePersistence.js.map +1 -0
  318. package/data/sqlite/documentPersistence/index.d.ts +22 -0
  319. package/data/sqlite/documentPersistence/index.js +35 -0
  320. package/data/sqlite/documentPersistence/index.js.map +1 -0
  321. package/data/sqlite/schema/containerSchema.d.ts +1193 -0
  322. package/data/sqlite/schema/containerSchema.js +103 -0
  323. package/data/sqlite/schema/containerSchema.js.map +1 -0
  324. package/data/sqlite/schema/index.d.ts +8055 -0
  325. package/data/sqlite/schema/index.js +525 -0
  326. package/data/sqlite/schema/index.js.map +1 -0
  327. package/data/sqlite/schema/organizationDataUsageSchema.js +34 -0
  328. package/data/sqlite/schema/organizationDataUsageSchema.js.map +1 -0
  329. package/data/sqlite/schema/organizationProvisioningAttemptSchema.js +23 -0
  330. package/data/sqlite/schema/organizationProvisioningAttemptSchema.js.map +1 -0
  331. package/data/sqlite/schema/organizationReadModelTableRegistry.d.ts +1332 -0
  332. package/data/sqlite/schema/organizationReadModelTableRegistry.js +31 -0
  333. package/data/sqlite/schema/organizationReadModelTableRegistry.js.map +1 -0
  334. package/data/sqlite/schema/principalHistoryEvidenceSchema.d.ts +308 -0
  335. package/data/sqlite/schema/principalHistoryEvidenceSchema.js +48 -0
  336. package/data/sqlite/schema/principalHistoryEvidenceSchema.js.map +1 -0
  337. package/data/sqlite/schema/principalHistoryNodeRetentionSchema.js +30 -0
  338. package/data/sqlite/schema/principalHistoryNodeRetentionSchema.js.map +1 -0
  339. package/data/sqlite/schema/principalHistoryRetentionSchema.js +25 -0
  340. package/data/sqlite/schema/principalHistoryRetentionSchema.js.map +1 -0
  341. package/data/sqlite/schema/principalHistoryStageSchema.d.ts +161 -0
  342. package/data/sqlite/schema/principalHistoryStageSchema.js +34 -0
  343. package/data/sqlite/schema/principalHistoryStageSchema.js.map +1 -0
  344. package/data/sqlite/schema/principalMutationJournalSchema.d.ts +85 -0
  345. package/data/sqlite/schema/principalMutationJournalSchema.js +13 -0
  346. package/data/sqlite/schema/principalMutationJournalSchema.js.map +1 -0
  347. package/data/sqlite/schema/principalPolicySchema.js +72 -0
  348. package/data/sqlite/schema/principalPolicySchema.js.map +1 -0
  349. package/data/sqlite/schema/securityIncidentSchema.d.ts +224 -0
  350. package/data/sqlite/schema/securityIncidentSchema.js +28 -0
  351. package/data/sqlite/schema/securityIncidentSchema.js.map +1 -0
  352. package/data/sqlite/schema/verifiedManifestBundleSchema.d.ts +174 -0
  353. package/data/sqlite/schema/verifiedManifestBundleSchema.js +36 -0
  354. package/data/sqlite/schema/verifiedManifestBundleSchema.js.map +1 -0
  355. package/data/sqlite/sqlitePersistenceRuntime.d.ts +1 -1
  356. package/data/sqlite/sqlitePersistenceRuntime.js +1 -1
  357. package/package.json +1 -1
  358. package/sqlite/index.d.ts +1 -1
  359. package/sqlite/index.js +1 -1
  360. package/stores/container-contents/accessRestorationSweep.js +1 -1
  361. package/stores/container-contents/accessRestorationSweep.js.map +1 -1
  362. package/stores/container-contents/containerContentsStore.d.ts +1 -1
  363. package/stores/container-contents/containerContentsStore.js +12 -12
  364. package/stores/container-contents/containerContentsStore.js.map +1 -1
  365. package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
  366. package/stores/container-contents/containerState/containerStatePersistence.js +57 -0
  367. package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
  368. package/stores/container-contents/containerState/missingContainerState.js +10 -0
  369. package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
  370. package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
  371. package/stores/container-contents/containerState/reconcilableContainer.d.ts +48 -0
  372. package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
  373. package/stores/container-contents/documentWork/documentRecovery.js +114 -0
  374. package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
  375. package/stores/container-contents/documentWork/documentRotation.js +13 -0
  376. package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
  377. package/stores/container-contents/documentWork/index.js +29 -0
  378. package/stores/container-contents/documentWork/index.js.map +1 -0
  379. package/stores/container-contents/hydration/backgroundHydration.js +32 -0
  380. package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
  381. package/stores/container-contents/hydration/remoteHydrationRequest.js +245 -0
  382. package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
  383. package/stores/container-contents/hydration/startupHydration.js +110 -0
  384. package/stores/container-contents/hydration/startupHydration.js.map +1 -0
  385. package/stores/container-contents/index.d.ts +3 -3
  386. package/stores/container-contents/index.js +2 -2
  387. package/stores/container-contents/index.js.map +1 -1
  388. package/stores/container-contents/localRefresh.js +2 -2
  389. package/stores/container-contents/localRefresh.js.map +1 -1
  390. package/stores/container-contents/operations/containerPurgeCore.js +98 -0
  391. package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
  392. package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
  393. package/stores/container-contents/operations/groupRewrapOperation.js +52 -0
  394. package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
  395. package/stores/container-contents/operations/index.js +301 -0
  396. package/stores/container-contents/operations/index.js.map +1 -0
  397. package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
  398. package/stores/container-contents/operations/reportShareFailure.js +44 -0
  399. package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
  400. package/stores/container-contents/operations/setContainerIconOperation.js +47 -0
  401. package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
  402. package/stores/container-contents/operations/shareOperations.js +90 -0
  403. package/stores/container-contents/operations/shareOperations.js.map +1 -0
  404. package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
  405. package/stores/container-contents/remoteEvents/remoteContainerIngestion.js +59 -0
  406. package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
  407. package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js +36 -0
  408. package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
  409. package/stores/container-contents/remoteEvents/remoteEventSync.js +38 -0
  410. package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
  411. package/stores/container-contents/remoteWrites/remoteWriteGuards.js +54 -0
  412. package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
  413. package/stores/container-contents/remoteWrites/remoteWriteQueue.js +51 -0
  414. package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
  415. package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
  416. package/stores/container-contents/state.d.ts +1 -1
  417. package/stores/container-contents/state.js +2 -2
  418. package/stores/container-contents/state.js.map +1 -1
  419. package/stores/container-contents/syncAgent/index.d.ts +8 -0
  420. package/stores/container-contents/syncAgent/index.js +241 -0
  421. package/stores/container-contents/syncAgent/index.js.map +1 -0
  422. package/stores/container-contents/syncAgent/metadataSyncSignal.js +37 -0
  423. package/stores/container-contents/syncAgent/metadataSyncSignal.js.map +1 -0
  424. package/stores/container-contents/syncAgent/syncAgentTypes.d.ts +81 -0
  425. package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
  426. package/stores/container-contents/syncAgent/syncLaneIteration.js +237 -0
  427. package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
  428. package/stores/container-contents/systemContainers/existingSystemContainer.js +58 -0
  429. package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
  430. package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js +44 -0
  431. package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
  432. package/stores/container-contents/systemContainers/systemContainerHydration.js +30 -0
  433. package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
  434. package/stores/container-contents/systemContainers/systemContainerIcon.js +42 -0
  435. package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
  436. package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
  437. package/stores/container-contents/systemContainers/systemContainerPostCreate.js +109 -0
  438. package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
  439. package/stores/container-contents/systemContainers/systemContainerPromotion.js +49 -0
  440. package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
  441. package/stores/container-contents/types.d.ts +2 -2
  442. package/stores/container-contents/types.js.map +1 -1
  443. package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js +39 -0
  444. package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
  445. package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js +84 -0
  446. package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
  447. package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js +97 -0
  448. package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
  449. package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js +49 -0
  450. package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
  451. package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js +95 -0
  452. package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
  453. package/stores/documents/documentStore/attachments/attachmentDetachState.js +54 -0
  454. package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
  455. package/stores/documents/documentStore/attachments/attachmentHydration.js +90 -0
  456. package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
  457. package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js +53 -0
  458. package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
  459. package/stores/documents/documentStore/attachments/attachmentIntents.js +39 -0
  460. package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
  461. package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js +37 -0
  462. package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
  463. package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
  464. package/stores/documents/documentStore/attachments/attachmentPersistence.js +106 -0
  465. package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
  466. package/stores/documents/documentStore/attachments/attachmentRemoval.js +136 -0
  467. package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
  468. package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
  469. package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js +32 -0
  470. package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
  471. package/stores/documents/documentStore/attachments/index.js +241 -0
  472. package/stores/documents/documentStore/attachments/index.js.map +1 -0
  473. package/stores/documents/documentStore/history/documentHistoryCompaction.js +67 -0
  474. package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
  475. package/stores/documents/documentStore/history/durableDocumentReload.js +79 -0
  476. package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
  477. package/stores/documents/documentStore/history/historyRebuild.js +75 -0
  478. package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
  479. package/stores/documents/documentStore/index.d.ts +8 -0
  480. package/stores/documents/documentStore/index.js +215 -0
  481. package/stores/documents/documentStore/index.js.map +1 -0
  482. package/stores/documents/documentStore/initialization/deferredInitialUpdate.js +116 -0
  483. package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
  484. package/stores/documents/documentStore/initialization/index.js +330 -0
  485. package/stores/documents/documentStore/initialization/index.js.map +1 -0
  486. package/stores/documents/documentStore/initialization/initializationAttachments.js +9 -0
  487. package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
  488. package/stores/documents/documentStore/initialization/initializationHistory.js +33 -0
  489. package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
  490. package/stores/documents/documentStore/initialization/initializationRecovery.js +107 -0
  491. package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
  492. package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
  493. package/stores/documents/documentStore/mutations.js +2 -2
  494. package/stores/documents/documentStore/mutations.js.map +1 -1
  495. package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
  496. package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
  497. package/stores/documents/documentStore/persistence.js +3 -3
  498. package/stores/documents/documentStore/persistence.js.map +1 -1
  499. package/stores/documents/documentStore/rotation/index.js +307 -0
  500. package/stores/documents/documentStore/rotation/index.js.map +1 -0
  501. package/stores/documents/documentStore/rotation/rotationProvenance.js +52 -0
  502. package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
  503. package/stores/documents/documentStore/rotation/rotationSettlement.js +222 -0
  504. package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
  505. package/stores/documents/documentStore/rows.js +2 -2
  506. package/stores/documents/documentStore/rows.js.map +1 -1
  507. package/stores/documents/documentStore/state.js +1 -1
  508. package/stores/documents/documentStore/state.js.map +1 -1
  509. package/stores/documents/documentStore/sync/index.js +299 -0
  510. package/stores/documents/documentStore/sync/index.js.map +1 -0
  511. package/stores/documents/documentStore/sync/pullContinuationInvalidation.js +61 -0
  512. package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
  513. package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js +15 -0
  514. package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
  515. package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
  516. package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
  517. package/stores/documents/documentStore/sync/syncAttachmentSettlement.js +72 -0
  518. package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
  519. package/stores/documents/documentStore/sync/syncAttachments.js +323 -0
  520. package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
  521. package/stores/documents/documentStore/sync/syncDetachedAttachments.js +129 -0
  522. package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
  523. package/stores/documents/documentStore/sync/syncFinalize.js +204 -0
  524. package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
  525. package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
  526. package/stores/documents/documentStore/sync/syncOutgoingCoverage.js +96 -0
  527. package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
  528. package/stores/documents/documentStore/sync/syncRemoteSignals.js +67 -0
  529. package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
  530. package/stores/documents/documentStore/sync/syncRequest.js +157 -0
  531. package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
  532. package/stores/documents/documentStore/sync/syncShared.js +211 -0
  533. package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
  534. package/stores/documents/documentStore/sync/syncUpdateImport.js +62 -0
  535. package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
  536. package/stores/documents/documentStore/sync/versionCoverage.js +45 -0
  537. package/stores/documents/index.d.ts +1 -1
  538. package/stores/documents/index.js +1 -1
  539. package/stores/local-projection/localProjectionStore.d.ts +1 -1
  540. package/stores/local-projection/localProjectionStore.js +1 -1
  541. package/stores/local-projection/localProjectionStore.js.map +1 -1
  542. package/stores/local-projection/registry.d.ts +1 -1
  543. package/stores/local-projection/types.d.ts +1 -1
  544. package/workflows/blobs/detach.js +1 -1
  545. package/workflows/blobs/hydration/decrypt.js +2 -2
  546. package/workflows/blobs/hydration/decrypt.js.map +1 -1
  547. package/workflows/blobs/upload/index.js +1 -1
  548. package/workflows/blobs/verification/retainedAttachmentVerification.js +1 -1
  549. package/workflows/blobs/verification/writerProjection.js +1 -1
  550. package/workflows/container-contents/container-state/create/createAdoption.js +193 -0
  551. package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
  552. package/workflows/container-contents/container-state/create/createChild.js +217 -0
  553. package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
  554. package/workflows/container-contents/container-state/create/createIntentDepth.js +36 -0
  555. package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
  556. package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
  557. package/workflows/container-contents/container-state/create/createIntentSync.js +354 -0
  558. package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
  559. package/workflows/container-contents/container-state/create/createTerminalFailure.js +19 -0
  560. package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
  561. package/workflows/container-contents/container-state/create/createWithMetadata.js +270 -0
  562. package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
  563. package/workflows/container-contents/container-state/create/createWithMetadataPlan.js +68 -0
  564. package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
  565. package/workflows/container-contents/container-state/purge/localPurgeScope.js +49 -0
  566. package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
  567. package/workflows/container-contents/container-state/purge/purgeTree.js +298 -0
  568. package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
  569. package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
  570. package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js +75 -0
  571. package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
  572. package/workflows/container-contents/container-state/purge/purgeTreeScope.js +175 -0
  573. package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
  574. package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js +18 -0
  575. package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
  576. package/workflows/container-contents/container-state/remote.js +2 -2
  577. package/workflows/container-contents/container-state/remote.js.map +1 -1
  578. package/workflows/container-contents/container-state/share/groupGrantVerification.js +71 -0
  579. package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
  580. package/workflows/container-contents/container-state/share/groupShareEpoch.js +16 -0
  581. package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
  582. package/workflows/container-contents/container-state/share/index.js +283 -0
  583. package/workflows/container-contents/container-state/share/index.js.map +1 -0
  584. package/workflows/container-contents/container-state/share/sharePersistence.js +136 -0
  585. package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
  586. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
  587. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
  588. package/workflows/container-contents/documentDiscovery/index.js +1 -1
  589. package/workflows/container-contents/documentDiscovery/index.js.map +1 -1
  590. package/workflows/container-contents/documentLinks/index.js +1 -1
  591. package/workflows/container-contents/documentMove/documentMoveVanishedRefresh.js +1 -1
  592. package/workflows/container-contents/documentPriming/documentHydrationProbe.js +1 -1
  593. package/workflows/container-contents/documentPriming/index.js +1 -1
  594. package/workflows/container-contents/documentQueries/index.js +1 -1
  595. package/workflows/container-contents/documentQueries/sql.js +1 -1
  596. package/workflows/container-contents/info/blobInfo.js +1 -1
  597. package/workflows/container-contents/info/containerInfo.js +1 -1
  598. package/workflows/container-contents/info/documentInfo.js +1 -1
  599. package/workflows/container-contents/metadata/index.js +1 -1
  600. package/workflows/container-contents/metadata/index.js.map +1 -1
  601. package/workflows/container-contents/metadata/metadataEvents.d.ts +1 -1
  602. package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js +2 -2
  603. package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js.map +1 -1
  604. package/workflows/container-contents/metadata/metadataMutationPreparation.js +1 -1
  605. package/workflows/container-contents/metadata/metadataMutationPreparation.js.map +1 -1
  606. package/workflows/container-contents/metadata/metadataPullContinuationInvalidation.js +1 -1
  607. package/workflows/container-contents/metadata/metadataPullContinuationInvalidation.js.map +1 -1
  608. package/workflows/container-contents/metadata/metadataRemoteSync.d.ts +1 -1
  609. package/workflows/container-contents/metadata/metadataSyncErrors.js +2 -2
  610. package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
  611. package/workflows/container-contents/metadata/metadataSyncSettlement.d.ts +1 -1
  612. package/workflows/container-contents/metadata/metadataSyncSettlement.js.map +1 -1
  613. package/workflows/container-contents/metadata/metadataTypes.d.ts +1 -1
  614. package/workflows/container-contents/metadata/metadataTypes.js.map +1 -1
  615. package/workflows/container-contents/pendingWrites/index.js +2 -2
  616. package/workflows/container-contents/pendingWrites/sources.js +1 -1
  617. package/workflows/container-contents/remoteHydration/destination/destinationPrefetch.js.map +1 -0
  618. package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
  619. package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js +10 -0
  620. package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
  621. package/workflows/container-contents/remoteHydration/destination/replacementBinding.js +75 -0
  622. package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
  623. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js +296 -0
  624. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
  625. package/workflows/container-contents/remoteHydration/index.js +4 -4
  626. package/workflows/container-contents/remoteHydration/index.js.map +1 -1
  627. package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
  628. package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js +21 -0
  629. package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
  630. package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js +61 -0
  631. package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
  632. package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
  633. package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
  634. package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
  635. package/workflows/container-contents/remoteHydration/reattachMetadata.js.map +1 -1
  636. package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
  637. package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
  638. package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
  639. package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js +135 -0
  640. package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
  641. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js +244 -0
  642. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
  643. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js +263 -0
  644. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
  645. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
  646. package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
  647. package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
  648. package/workflows/container-contents/tombstones/documentTombstoneEvidence.js +2 -2
  649. package/workflows/container-contents/tombstones/documentTombstoneEvidence.js.map +1 -1
  650. package/workflows/containers/child/create/createProjection.d.ts +6 -0
  651. package/workflows/containers/child/create/createProjection.js +43 -0
  652. package/workflows/containers/child/create/createProjection.js.map +1 -0
  653. package/workflows/containers/child/create/createSubmission.d.ts +56 -0
  654. package/workflows/containers/child/create/createSubmission.js +43 -0
  655. package/workflows/containers/child/create/createSubmission.js.map +1 -0
  656. package/workflows/containers/child/create/index.d.ts +24 -0
  657. package/workflows/containers/child/create/index.js +335 -0
  658. package/workflows/containers/child/create/index.js.map +1 -0
  659. package/workflows/containers/child/move/index.d.ts +23 -0
  660. package/workflows/containers/child/move/index.js +268 -0
  661. package/workflows/containers/child/move/index.js.map +1 -0
  662. package/workflows/containers/child/move/moveArtifacts.js +102 -0
  663. package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
  664. package/workflows/containers/child/move/moveRotation.js +88 -0
  665. package/workflows/containers/child/move/moveRotation.js.map +1 -0
  666. package/workflows/containers/child/move/moveWraps.js +49 -0
  667. package/workflows/containers/child/move/moveWraps.js.map +1 -0
  668. package/workflows/containers/child/mutationSubmit.js +1 -1
  669. package/workflows/containers/child/mutationSubmit.js.map +1 -1
  670. package/workflows/containers/child/recite.js +2 -2
  671. package/workflows/containers/child/recite.js.map +1 -1
  672. package/workflows/containers/child/rekey/carriedDescendantRekeys.js +126 -0
  673. package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
  674. package/workflows/containers/child/rekey/index.d.ts +32 -0
  675. package/workflows/containers/child/rekey/index.js +227 -0
  676. package/workflows/containers/child/rekey/index.js.map +1 -0
  677. package/workflows/containers/child/rekey/keyringOverrideLineage.d.ts +22 -0
  678. package/workflows/containers/child/rekey/keyringOverrideLineage.js +39 -0
  679. package/workflows/containers/child/rekey/rekeyProjection.d.ts +46 -0
  680. package/workflows/containers/child/rekey/rekeyProjection.js +151 -0
  681. package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
  682. package/workflows/containers/child/rekey/rekeyRemote.d.ts +24 -0
  683. package/workflows/containers/child/rekey/rekeyRemote.js +64 -0
  684. package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
  685. package/workflows/containers/child/revoke.js +5 -5
  686. package/workflows/containers/child/revoke.js.map +1 -1
  687. package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js +19 -0
  688. package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
  689. package/workflows/containers/child/rotation/rotationContext.js +64 -0
  690. package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
  691. package/workflows/containers/child/rotation/rotationPrincipalPolicies.js +19 -0
  692. package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
  693. package/workflows/containers/child/rotation/rotationWraps.js +85 -0
  694. package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
  695. package/workflows/containers/child/share/currentShareGrantMutation.js +82 -0
  696. package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
  697. package/workflows/containers/child/share/currentSharePrincipalPolicy.js +83 -0
  698. package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
  699. package/workflows/containers/child/share/index.d.ts +65 -0
  700. package/workflows/containers/child/share/index.js +256 -0
  701. package/workflows/containers/child/share/index.js.map +1 -0
  702. package/workflows/containers/child/share/runtimeCurrentGroupShare.js +79 -0
  703. package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
  704. package/workflows/containers/child/share/shareAncestorRepair.js +95 -0
  705. package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
  706. package/workflows/containers/child/share/shareMaterialization.d.ts +25 -0
  707. package/workflows/containers/child/share/shareMaterialization.js +164 -0
  708. package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
  709. package/workflows/containers/child/share/sharePlanCore.d.ts +82 -0
  710. package/workflows/containers/child/share/sharePlanCore.js +191 -0
  711. package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
  712. package/workflows/containers/child/share/sharePrincipalPolicy.d.ts +51 -0
  713. package/workflows/containers/child/share/sharePrincipalPolicy.js +194 -0
  714. package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
  715. package/workflows/containers/child/share/shareProjection.js.map +1 -0
  716. package/workflows/containers/index.d.ts +13 -13
  717. package/workflows/containers/index.js +12 -12
  718. package/workflows/containers/index.js.map +1 -1
  719. package/workflows/containers/writeRefusal.js +1 -1
  720. package/workflows/containers/writeRefusal.js.map +1 -1
  721. package/workflows/documents/create/createAdoption.js +1 -1
  722. package/workflows/documents/create/createResponse.js +2 -2
  723. package/workflows/documents/create/createResponse.js.map +1 -1
  724. package/workflows/documents/create/index.js +1 -1
  725. package/workflows/documents/documentMutationCommit.d.ts +1 -1
  726. package/workflows/documents/documentMutationPreparation.d.ts +1 -1
  727. package/workflows/documents/documentMutationPreparation.js +1 -1
  728. package/workflows/documents/documentMutationPreparation.js.map +1 -1
  729. package/workflows/documents/index.d.ts +5 -5
  730. package/workflows/documents/index.js +5 -5
  731. package/workflows/documents/index.js.map +1 -1
  732. package/workflows/documents/linkSet/index.js +2 -2
  733. package/workflows/documents/linkSet/index.js.map +1 -1
  734. package/workflows/documents/linkSet/linkSetAuthority.js +2 -2
  735. package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
  736. package/workflows/documents/linkSet/linkSetBlobRewraps.js +2 -2
  737. package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
  738. package/workflows/documents/linkSet/linkSetProjectionSeed.js +2 -2
  739. package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
  740. package/workflows/documents/linkSet/linkSetRemote.js +1 -1
  741. package/workflows/documents/linkSet/linkSetRemote.js.map +1 -1
  742. package/workflows/documents/purge/index.js +2 -2
  743. package/workflows/documents/purge/index.js.map +1 -1
  744. package/workflows/documents/sync/index.js +2 -2
  745. package/workflows/documents/sync/index.js.map +1 -1
  746. package/workflows/documents/sync/initialSync.js +1 -1
  747. package/workflows/documents/sync/readOnlyProjectionFailure.js +1 -1
  748. package/workflows/documents/sync/readOnlyProjectionFailure.js.map +1 -1
  749. package/workflows/documents/sync/readOnlySync.d.ts +3 -3
  750. package/workflows/documents/sync/readOnlySync.js +1 -1
  751. package/workflows/documents/sync/readOnlySync.js.map +1 -1
  752. package/workflows/documents/sync/reportDocumentSyncQuarantine.js.map +1 -1
  753. package/workflows/documents/sync/syncAttemptPlanning.js +2 -2
  754. package/workflows/documents/sync/syncAttemptPlanning.js.map +1 -1
  755. package/workflows/documents/sync/syncAttemptState.d.ts +2 -2
  756. package/workflows/documents/sync/syncAttemptState.js.map +1 -1
  757. package/workflows/documents/sync/syncResponseResult.js +2 -2
  758. package/workflows/documents/sync/syncResponseResult.js.map +1 -1
  759. package/workflows/documents/syncFailures/index.js +1 -1
  760. package/workflows/documents/syncFailures/index.js.map +1 -1
  761. package/workflows/documents/syncFailures/syncAbandon.js.map +1 -1
  762. package/workflows/documents/syncFailures/syncFailureClassification.js +1 -1
  763. package/workflows/documents/syncFailures/syncFailureClassification.js.map +1 -1
  764. package/workflows/documents/syncPlan/syncContentKeys.d.ts +1 -1
  765. package/workflows/documents/syncPlan/syncContentKeys.js +3 -3
  766. package/workflows/documents/syncPlan/syncContentKeys.js.map +1 -1
  767. package/workflows/documents/syncPlan/syncPlanMaterial.js +2 -2
  768. package/workflows/documents/syncPlan/syncPlanMaterial.js.map +1 -1
  769. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +4 -4
  770. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
  771. package/workflows/documents/syncRekeys/syncContainerRekeyPreparation.js +1 -1
  772. package/workflows/documents/syncRekeys/syncRecoveryRekey.d.ts +1 -1
  773. package/workflows/documents/syncRekeys/syncRecoveryRekey.js +1 -1
  774. package/workflows/organizations/currentOrganizationAuthority.js +2 -2
  775. package/workflows/organizations/currentOrganizationAuthority.js.map +1 -1
  776. package/workflows/organizations/groupMetadata/groupMetadataAccess.js +1 -1
  777. package/workflows/organizations/groupMetadata/groupMetadataAccess.js.map +1 -1
  778. package/workflows/organizations/groupMetadata/groupMetadataContainerAuthority.js +1 -1
  779. package/workflows/organizations/groupMetadata/groupMetadataContainerAuthority.js.map +1 -1
  780. package/workflows/organizations/groupNames/currentOrganizationGroupNames.js +1 -1
  781. package/workflows/organizations/groupNames/currentOrganizationGroupNames.js.map +1 -1
  782. package/workflows/organizations/groupNames/groupNameUniqueness.js +3 -3
  783. package/workflows/organizations/groupNames/groupNameUniqueness.js.map +1 -1
  784. package/workflows/organizations/groupNames/organizationGroupNamePolicies.js +2 -2
  785. package/workflows/organizations/groupNames/organizationGroupNamePolicies.js.map +1 -1
  786. package/workflows/organizations/groupPolicy/currentGroupPolicyMutationContext.js +1 -1
  787. package/workflows/organizations/groupPolicy/currentGroupPolicyMutationContext.js.map +1 -1
  788. package/workflows/organizations/groupPolicy/groupPolicyMutationContext.js +2 -2
  789. package/workflows/organizations/groupPolicy/groupPolicyMutationContext.js.map +1 -1
  790. package/workflows/organizations/groupPolicy/groupPolicyMutationEvidence.js +1 -1
  791. package/workflows/organizations/groupPolicy/groupPolicyMutationEvidence.js.map +1 -1
  792. package/workflows/organizations/groupPolicy/groupPolicyVerification.js +1 -1
  793. package/workflows/organizations/groupPolicy/groupPolicyVerification.js.map +1 -1
  794. package/workflows/organizations/groups/createCurrentOrganizationGroup.js +1 -1
  795. package/workflows/organizations/groups/createCurrentOrganizationGroup.js.map +1 -1
  796. package/workflows/organizations/groups/deleteOrganizationGroup.js +1 -1
  797. package/workflows/organizations/groups/deleteOrganizationGroup.js.map +1 -1
  798. package/workflows/organizations/groups/organizationGroupDirectory.js +1 -1
  799. package/workflows/organizations/groups/organizationGroupDirectory.js.map +1 -1
  800. package/workflows/organizations/principalMutations/runtimeCurrentOrganizationMutation.js +1 -1
  801. package/workflows/organizations/principalMutations/runtimeCurrentOrganizationMutation.js.map +1 -1
  802. package/workflows/organizations/provisioning/organizationReplacementVerification.js +1 -1
  803. package/workflows/organizations/provisioning/organizationReplacementVerification.js.map +1 -1
  804. package/workflows/organizations/readModel/listLocalOrganizations.js +1 -1
  805. package/workflows/organizations/readModel/localReadModelDetails.js +1 -1
  806. package/workflows/organizations/readModel/localReadModelDetails.js.map +1 -1
  807. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
  808. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
  809. package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
  810. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
  811. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
  812. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
  813. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
  814. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
  815. package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js +1 -1
  816. package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js.map +1 -1
  817. package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.d.ts +1 -1
  818. package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.js +1 -1
  819. package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.js.map +1 -1
  820. package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js +1 -1
  821. package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js.map +1 -1
  822. package/workflows/principals/acknowledgements/reconcileAcknowledgedPrincipalCurrent.js +2 -2
  823. package/workflows/principals/acknowledgements/reconcileAcknowledgedPrincipalCurrent.js.map +1 -1
  824. package/workflows/principals/externalAdminPolicy.js +2 -2
  825. package/workflows/principals/externalAdminPolicy.js.map +1 -1
  826. package/workflows/principals/historyRecovery/loadRecoveredPrincipalHistoryPage.js +2 -2
  827. package/workflows/principals/historyRecovery/loadRecoveredPrincipalHistoryPage.js.map +1 -1
  828. package/workflows/principals/historyRecovery/principalHistoryRecoveryPrefix.js +1 -1
  829. package/workflows/principals/historyRecovery/principalHistoryRecoveryPrefix.js.map +1 -1
  830. package/workflows/principals/historyRecovery/principalHistoryRecoveryReferences.js +1 -1
  831. package/workflows/principals/historyRecovery/principalHistoryRecoveryReferences.js.map +1 -1
  832. package/workflows/principals/historyRecovery/principalHistoryRecoveryStage.js +1 -1
  833. package/workflows/principals/historyRecovery/principalHistoryRecoveryStage.js.map +1 -1
  834. package/workflows/principals/historyRecovery/recoverPrincipalPolicyHistory.js +3 -3
  835. package/workflows/principals/historyRecovery/recoverPrincipalPolicyHistory.js.map +1 -1
  836. package/workflows/principals/policyCache/index.js +4 -4
  837. package/workflows/principals/policyCache/index.js.map +1 -1
  838. package/workflows/principals/policyCache/principalPolicyCacheAdvance.js +1 -1
  839. package/workflows/principals/policyCache/principalPolicyCacheAdvance.js.map +1 -1
  840. package/workflows/principals/policyCache/principalPolicyOrganizationScope.js +3 -3
  841. package/workflows/principals/policyCache/principalPolicyOrganizationScope.js.map +1 -1
  842. package/workflows/principals/policyRepair.js +1 -1
  843. package/workflows/principals/policyRepair.js.map +1 -1
  844. package/workflows/principals/publicHistory/publicPrincipalHistoryAuthority.js.map +1 -1
  845. package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js +2 -2
  846. package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js.map +1 -1
  847. package/workflows/principals/publicHistory/publicPrincipalHistoryProgress.js +3 -3
  848. package/workflows/principals/publicHistory/publicPrincipalHistoryProgress.js.map +1 -1
  849. package/workflows/principals/publicHistory/publicPrincipalHistoryTypes.d.ts +2 -2
  850. package/workflows/principals/publicHistory/publicPrincipalHistoryTypes.js.map +1 -1
  851. package/workflows/principals/publicHistory/publicProjectionPrincipal.js +1 -1
  852. package/workflows/principals/publicHistory/publicProjectionPrincipal.js.map +1 -1
  853. package/workflows/principals/publicHistory/recoverPublicPrincipalHistory.js +1 -1
  854. package/workflows/principals/publicHistory/recoverPublicPrincipalHistory.js.map +1 -1
  855. package/workflows/principals/publicHistory/selectPublicPrincipalHistory.js +1 -1
  856. package/workflows/principals/publicHistory/selectPublicPrincipalHistory.js.map +1 -1
  857. package/workflows/principals/recoveryOperation/principalRecoveryDirectory.js +1 -1
  858. package/workflows/principals/recoveryOperation/principalRecoveryDirectory.js.map +1 -1
  859. package/workflows/principals/recoveryOperation/principalRecoveryMemoValidity.js +1 -1
  860. package/workflows/principals/recoveryOperation/principalRecoveryMemoValidity.js.map +1 -1
  861. package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
  862. package/workflows/registration/persistRegistrationBootstrap.d.ts +2 -2
  863. package/workflows/registration/persistRegistrationBootstrap.js +2 -2
  864. package/workflows/registration/persistRegistrationBootstrap.js.map +1 -1
  865. package/workflows/registration/provisioningAcknowledgement.js +1 -1
  866. package/workflows/registration/provisioningAcknowledgement.js.map +1 -1
  867. package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
  868. package/workflows/registration/registrationPrincipalPolicyPersistence.js +1 -1
  869. package/workflows/registration/registrationPrincipalPolicyPersistence.js.map +1 -1
  870. package/workflows/sync/remoteReset.js +7 -7
  871. package/workflows/sync/remoteReset.js.map +1 -1
  872. package/workflows/sync/remoteResetAttachments.js +1 -1
  873. package/workflows/sync/remoteResetCursorScope.js +1 -1
  874. package/workflows/sync/remoteResetPlans.js +1 -1
  875. package/workflows/sync/remoteResetPrincipalScope.js +5 -5
  876. package/workflows/sync/remoteResetPrincipalScope.js.map +1 -1
  877. package/workflows/sync/remoteResetScope.js +1 -1
  878. package/data/documents/shared/containerKekCurrency.d.ts +0 -22
  879. package/data/documents/shared/containerKekEntryVerification.js +0 -15
  880. package/data/documents/shared/containerKekLogFetch.d.ts +0 -18
  881. package/data/documents/shared/containerKekLogFetch.js +0 -76
  882. package/data/documents/shared/containerKekPath.js +0 -265
  883. package/data/documents/shared/containerKekPath.js.map +0 -1
  884. package/data/documents/shared/containerKekPathHistory.d.ts +0 -61
  885. package/data/documents/shared/containerKekPathHistory.js +0 -223
  886. package/data/documents/shared/containerKekPathHistory.js.map +0 -1
  887. package/data/documents/shared/containerKekPathVerification.d.ts +0 -15
  888. package/data/documents/shared/containerKekPathVerification.js +0 -23
  889. package/data/documents/shared/containerKekPathVerification.js.map +0 -1
  890. package/data/documents/shared/containerKekWrapping.js +0 -61
  891. package/data/documents/shared/containerKekWrapping.js.map +0 -1
  892. package/data/documents/shared/documentSyncUpdateDecryption.js +0 -238
  893. package/data/documents/shared/documentSyncUpdateDecryption.js.map +0 -1
  894. package/data/documents/shared/documentSyncUpdateIsolation.d.ts +0 -55
  895. package/data/documents/shared/documentSyncUpdateIsolation.js +0 -298
  896. package/data/documents/shared/documentSyncUpdateIsolation.js.map +0 -1
  897. package/data/documents/shared/keyringLogWalk.d.ts +0 -45
  898. package/data/documents/shared/keyringLogWalk.js +0 -204
  899. package/data/documents/shared/keyringRebuild.d.ts +0 -60
  900. package/data/documents/shared/keyringRebuild.js +0 -242
  901. package/data/documents/shared/keyringRebuild.js.map +0 -1
  902. package/data/documents/shared/mutationAcknowledgement.js +0 -10
  903. package/data/documents/shared/mutationAcknowledgement.js.map +0 -1
  904. package/data/documents/shared/projection.d.ts +0 -25
  905. package/data/documents/shared/projection.js +0 -132
  906. package/data/documents/shared/projection.js.map +0 -1
  907. package/data/documents/shared/projectionContentKeys.d.ts +0 -90
  908. package/data/documents/shared/projectionContentKeys.js +0 -262
  909. package/data/documents/shared/projectionContentKeys.js.map +0 -1
  910. package/data/documents/shared/projectionTargets.d.ts +0 -38
  911. package/data/documents/shared/projectionTargets.js +0 -164
  912. package/data/documents/shared/projectionTargets.js.map +0 -1
  913. package/data/documents/shared/pullContinuation.js +0 -53
  914. package/data/documents/shared/syncPagination.d.ts +0 -20
  915. package/data/documents/shared/syncPagination.js +0 -109
  916. package/data/documents/shared/syncPagination.js.map +0 -1
  917. package/data/documents/shared/syncResponseAuthorization.js +0 -63
  918. package/data/documents/shared/syncResponseAuthorization.js.map +0 -1
  919. package/data/documents/shared/syncResponses.d.ts +0 -11
  920. package/data/documents/shared/syncResponses.js +0 -285
  921. package/data/documents/shared/syncResponses.js.map +0 -1
  922. package/data/documents/shared/syncSubmitFailure.d.ts +0 -9
  923. package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js +0 -61
  924. package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
  925. package/data/keyingProjectionVerification/bundleVerification.js +0 -61
  926. package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
  927. package/data/keyingProjectionVerification/checkpointContext.d.ts +0 -45
  928. package/data/keyingProjectionVerification/checkpointContext.js +0 -120
  929. package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
  930. package/data/keyingProjectionVerification/containerAncestorCitations.js +0 -164
  931. package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
  932. package/data/keyingProjectionVerification/containerCreateManifest.js +0 -28
  933. package/data/keyingProjectionVerification/containerDestinationVerification.js +0 -51
  934. package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
  935. package/data/keyingProjectionVerification/containerManifestVerification.js +0 -285
  936. package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
  937. package/data/keyingProjectionVerification/containerPathVerification.js +0 -51
  938. package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
  939. package/data/keyingProjectionVerification/containerProjectionVerification.d.ts +0 -25
  940. package/data/keyingProjectionVerification/containerProjectionVerification.js +0 -254
  941. package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
  942. package/data/keyingProjectionVerification/documentDependencyPaths.d.ts +0 -17
  943. package/data/keyingProjectionVerification/documentDependencyPaths.js +0 -70
  944. package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
  945. package/data/keyingProjectionVerification/documentManifestPolicies.js +0 -32
  946. package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
  947. package/data/keyingProjectionVerification/documentManifestPredecessor.js +0 -12
  948. package/data/keyingProjectionVerification/documentManifestVerification.js +0 -135
  949. package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
  950. package/data/keyingProjectionVerification/documentProjectionVerification.d.ts +0 -24
  951. package/data/keyingProjectionVerification/documentProjectionVerification.js +0 -172
  952. package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
  953. package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js +0 -100
  954. package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
  955. package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js +0 -8
  956. package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
  957. package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js +0 -177
  958. package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
  959. package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js +0 -17
  960. package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
  961. package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js +0 -55
  962. package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
  963. package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js +0 -116
  964. package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
  965. package/data/keyingProjectionVerification/documentPurgeProofVerification.d.ts +0 -34
  966. package/data/keyingProjectionVerification/documentPurgeProofVerification.js +0 -208
  967. package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
  968. package/data/keyingProjectionVerification/manifestCheckpointVerification.js +0 -64
  969. package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
  970. package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js +0 -45
  971. package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
  972. package/data/keyingProjectionVerification/organizationFounderBinding.js +0 -41
  973. package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
  974. package/data/keyingProjectionVerification/principalPolicyCache.js +0 -76
  975. package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
  976. package/data/keyingProjectionVerification/principalPolicyVerification.js +0 -252
  977. package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
  978. package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js +0 -63
  979. package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
  980. package/data/keyingProjectionVerification/projectionPolicyEvidence.js +0 -23
  981. package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
  982. package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js +0 -72
  983. package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
  984. package/data/persistence/documentPurgeCheckpointPersistence.d.ts +0 -10
  985. package/data/persistence/documentPurgeCheckpointPersistence.js +0 -43
  986. package/data/persistence/documentPurgeCheckpointPersistence.js.map +0 -1
  987. package/data/persistence/keyingCheckpointAdvancePersistence.js +0 -222
  988. package/data/persistence/keyingCheckpointAdvancePersistence.js.map +0 -1
  989. package/data/persistence/keyingCheckpointEvidence.js +0 -32
  990. package/data/persistence/keyingCheckpointPersistence.js +0 -133
  991. package/data/persistence/keyingCheckpointPersistence.js.map +0 -1
  992. package/data/persistence/locallyAcknowledgedCheckpointPersistence.d.ts +0 -53
  993. package/data/persistence/locallyAcknowledgedCheckpointPersistence.js +0 -167
  994. package/data/persistence/locallyAcknowledgedCheckpointPersistence.js.map +0 -1
  995. package/data/persistence/organizationReplacementCheckpointPersistence.js +0 -72
  996. package/data/persistence/organizationReplacementCheckpointPersistence.js.map +0 -1
  997. package/data/persistence/principalAuthorizationCheckpoints.js +0 -29
  998. package/data/persistence/principalAuthorizationCheckpoints.js.map +0 -1
  999. package/data/persistence/principalGrantRetirementPersistence.d.ts +0 -9
  1000. package/data/persistence/principalGrantRetirementPersistence.js +0 -43
  1001. package/data/persistence/principalGrantRetirementPersistence.js.map +0 -1
  1002. package/data/persistence/principalHistoryEvidencePersistence.d.ts +0 -32
  1003. package/data/persistence/principalHistoryEvidencePersistence.js +0 -92
  1004. package/data/persistence/principalHistoryEvidencePersistence.js.map +0 -1
  1005. package/data/persistence/principalHistoryIncompleteRetention.js +0 -26
  1006. package/data/persistence/principalHistoryIncompleteRetention.js.map +0 -1
  1007. package/data/persistence/principalHistoryNodeRetention.js +0 -201
  1008. package/data/persistence/principalHistoryNodeRetention.js.map +0 -1
  1009. package/data/persistence/principalHistoryPrefixPersistence.d.ts +0 -29
  1010. package/data/persistence/principalHistoryPrefixPersistence.js +0 -102
  1011. package/data/persistence/principalHistoryPrefixPersistence.js.map +0 -1
  1012. package/data/persistence/principalHistoryRootOwnership.js +0 -71
  1013. package/data/persistence/principalHistoryRootOwnership.js.map +0 -1
  1014. package/data/persistence/principalHistoryStagePersistence.d.ts +0 -15
  1015. package/data/persistence/principalHistoryStagePersistence.js +0 -96
  1016. package/data/persistence/principalHistoryStagePersistence.js.map +0 -1
  1017. package/data/persistence/principalHistoryStageRetention.js +0 -45
  1018. package/data/persistence/principalHistoryStageRetention.js.map +0 -1
  1019. package/data/persistence/principalHistoryUnpublishedRetention.js +0 -64
  1020. package/data/persistence/principalHistoryUnpublishedRetention.js.map +0 -1
  1021. package/data/persistence/principalKeyEnvelopeArchivePersistence.js +0 -63
  1022. package/data/persistence/principalKeyEnvelopeArchivePersistence.js.map +0 -1
  1023. package/data/persistence/principalKeyEnvelopeCandidates.js +0 -87
  1024. package/data/persistence/principalKeyEnvelopeCandidates.js.map +0 -1
  1025. package/data/persistence/principalPolicyBundleIntegrity.js +0 -49
  1026. package/data/persistence/principalPolicyBundleIntegrity.js.map +0 -1
  1027. package/data/persistence/principalPolicyCheckpointSelection.js +0 -26
  1028. package/data/persistence/principalPolicyCheckpointSelection.js.map +0 -1
  1029. package/data/persistence/principalPolicyOrganizationPersistence.js +0 -42
  1030. package/data/persistence/principalPolicyOrganizationPersistence.js.map +0 -1
  1031. package/data/persistence/principalPolicyPersistence.js +0 -279
  1032. package/data/persistence/principalPolicyPersistence.js.map +0 -1
  1033. package/data/persistence/principalPolicyReferenceCheckpoint.js +0 -27
  1034. package/data/persistence/principalPolicyReferenceCheckpoint.js.map +0 -1
  1035. package/data/persistence/principalPolicyReferenceIndexPersistence.js +0 -115
  1036. package/data/persistence/principalPolicyReferenceIndexPersistence.js.map +0 -1
  1037. package/data/persistence/principalPolicyReferencePersistence.js +0 -215
  1038. package/data/persistence/principalPolicyReferencePersistence.js.map +0 -1
  1039. package/data/persistence/verifiedPrincipalPolicyBundle.js +0 -33
  1040. package/data/persistence/verifiedPrincipalPolicyBundle.js.map +0 -1
  1041. package/data/persistence/verifiedPrincipalPolicyCurrent.js +0 -56
  1042. package/data/persistence/verifiedPrincipalPolicyCurrent.js.map +0 -1
  1043. package/data/persistence/verifiedPrincipalPolicyRetentionPersistence.js +0 -18
  1044. package/data/persistence/verifiedPrincipalPolicyRetentionPersistence.js.map +0 -1
  1045. package/data/sqlite/containerSchema.d.ts +0 -1193
  1046. package/data/sqlite/containerSchema.js +0 -103
  1047. package/data/sqlite/containerSchema.js.map +0 -1
  1048. package/data/sqlite/documentHistoryPersistence.d.ts +0 -86
  1049. package/data/sqlite/documentHistoryPersistence.js +0 -304
  1050. package/data/sqlite/documentHistoryPersistence.js.map +0 -1
  1051. package/data/sqlite/documentOrphanBlobReclaims.js +0 -6
  1052. package/data/sqlite/documentOrphanBlobReclaims.js.map +0 -1
  1053. package/data/sqlite/documentPendingUpdatePersistence.d.ts +0 -103
  1054. package/data/sqlite/documentPendingUpdatePersistence.js +0 -243
  1055. package/data/sqlite/documentPendingUpdatePersistence.js.map +0 -1
  1056. package/data/sqlite/documentPersistence.d.ts +0 -22
  1057. package/data/sqlite/documentPersistence.js +0 -35
  1058. package/data/sqlite/documentPersistence.js.map +0 -1
  1059. package/data/sqlite/documentPersistenceTypes.d.ts +0 -79
  1060. package/data/sqlite/documentPersistenceTypes.js.map +0 -1
  1061. package/data/sqlite/documentRecordPersistence.d.ts +0 -275
  1062. package/data/sqlite/documentRecordPersistence.js +0 -103
  1063. package/data/sqlite/documentRecordPersistence.js.map +0 -1
  1064. package/data/sqlite/documentSyncFailurePersistence.d.ts +0 -39
  1065. package/data/sqlite/documentSyncFailurePersistence.js +0 -81
  1066. package/data/sqlite/documentSyncFailurePersistence.js.map +0 -1
  1067. package/data/sqlite/organizationDataUsageSchema.js +0 -34
  1068. package/data/sqlite/organizationDataUsageSchema.js.map +0 -1
  1069. package/data/sqlite/organizationProvisioningAttemptSchema.js +0 -23
  1070. package/data/sqlite/organizationProvisioningAttemptSchema.js.map +0 -1
  1071. package/data/sqlite/organizationReadModelTableRegistry.d.ts +0 -1332
  1072. package/data/sqlite/organizationReadModelTableRegistry.js +0 -31
  1073. package/data/sqlite/organizationReadModelTableRegistry.js.map +0 -1
  1074. package/data/sqlite/principalHistoryEvidenceSchema.d.ts +0 -308
  1075. package/data/sqlite/principalHistoryEvidenceSchema.js +0 -48
  1076. package/data/sqlite/principalHistoryEvidenceSchema.js.map +0 -1
  1077. package/data/sqlite/principalHistoryNodeRetentionSchema.js +0 -30
  1078. package/data/sqlite/principalHistoryNodeRetentionSchema.js.map +0 -1
  1079. package/data/sqlite/principalHistoryRetentionSchema.js +0 -25
  1080. package/data/sqlite/principalHistoryRetentionSchema.js.map +0 -1
  1081. package/data/sqlite/principalHistoryStageSchema.d.ts +0 -161
  1082. package/data/sqlite/principalHistoryStageSchema.js +0 -34
  1083. package/data/sqlite/principalHistoryStageSchema.js.map +0 -1
  1084. package/data/sqlite/principalMutationJournalSchema.d.ts +0 -85
  1085. package/data/sqlite/principalMutationJournalSchema.js +0 -13
  1086. package/data/sqlite/principalMutationJournalSchema.js.map +0 -1
  1087. package/data/sqlite/principalPolicySchema.js +0 -72
  1088. package/data/sqlite/principalPolicySchema.js.map +0 -1
  1089. package/data/sqlite/schema.d.ts +0 -8055
  1090. package/data/sqlite/schema.js +0 -525
  1091. package/data/sqlite/schema.js.map +0 -1
  1092. package/data/sqlite/securityIncidentSchema.d.ts +0 -224
  1093. package/data/sqlite/securityIncidentSchema.js +0 -28
  1094. package/data/sqlite/securityIncidentSchema.js.map +0 -1
  1095. package/data/sqlite/verifiedManifestBundleSchema.d.ts +0 -174
  1096. package/data/sqlite/verifiedManifestBundleSchema.js +0 -36
  1097. package/data/sqlite/verifiedManifestBundleSchema.js.map +0 -1
  1098. package/stores/container-contents/backgroundHydration.js +0 -32
  1099. package/stores/container-contents/backgroundHydration.js.map +0 -1
  1100. package/stores/container-contents/containerPurgeCore.js +0 -98
  1101. package/stores/container-contents/containerPurgeCore.js.map +0 -1
  1102. package/stores/container-contents/containerStateMap.js.map +0 -1
  1103. package/stores/container-contents/containerStatePersistence.js +0 -57
  1104. package/stores/container-contents/containerStatePersistence.js.map +0 -1
  1105. package/stores/container-contents/documentRecovery.js +0 -114
  1106. package/stores/container-contents/documentRecovery.js.map +0 -1
  1107. package/stores/container-contents/documentRotation.js +0 -13
  1108. package/stores/container-contents/documentRotation.js.map +0 -1
  1109. package/stores/container-contents/documentWork.js +0 -29
  1110. package/stores/container-contents/documentWork.js.map +0 -1
  1111. package/stores/container-contents/emptyTrashOperation.js.map +0 -1
  1112. package/stores/container-contents/existingSystemContainer.js +0 -58
  1113. package/stores/container-contents/existingSystemContainer.js.map +0 -1
  1114. package/stores/container-contents/groupRewrapOperation.js +0 -52
  1115. package/stores/container-contents/groupRewrapOperation.js.map +0 -1
  1116. package/stores/container-contents/metadataSyncSignal.js +0 -37
  1117. package/stores/container-contents/metadataSyncSignal.js.map +0 -1
  1118. package/stores/container-contents/missingContainerState.js +0 -10
  1119. package/stores/container-contents/missingContainerState.js.map +0 -1
  1120. package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
  1121. package/stores/container-contents/operations.js +0 -301
  1122. package/stores/container-contents/operations.js.map +0 -1
  1123. package/stores/container-contents/organizationMetadataSystemContainer.js +0 -44
  1124. package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
  1125. package/stores/container-contents/purgeContainerOperation.js.map +0 -1
  1126. package/stores/container-contents/reconcilableContainer.d.ts +0 -48
  1127. package/stores/container-contents/reconcilableContainer.js.map +0 -1
  1128. package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
  1129. package/stores/container-contents/remoteContainerIngestion.js +0 -59
  1130. package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
  1131. package/stores/container-contents/remoteEventProjectionInvalidation.js +0 -36
  1132. package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
  1133. package/stores/container-contents/remoteEventSync.js +0 -38
  1134. package/stores/container-contents/remoteEventSync.js.map +0 -1
  1135. package/stores/container-contents/remoteHydrationRequest.js +0 -245
  1136. package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
  1137. package/stores/container-contents/remoteWriteGuards.js +0 -54
  1138. package/stores/container-contents/remoteWriteGuards.js.map +0 -1
  1139. package/stores/container-contents/remoteWriteQueue.js +0 -51
  1140. package/stores/container-contents/remoteWriteQueue.js.map +0 -1
  1141. package/stores/container-contents/reportShareFailure.js +0 -44
  1142. package/stores/container-contents/reportShareFailure.js.map +0 -1
  1143. package/stores/container-contents/setContainerIconOperation.js +0 -47
  1144. package/stores/container-contents/setContainerIconOperation.js.map +0 -1
  1145. package/stores/container-contents/shareOperations.js +0 -90
  1146. package/stores/container-contents/shareOperations.js.map +0 -1
  1147. package/stores/container-contents/startupHydration.js +0 -110
  1148. package/stores/container-contents/startupHydration.js.map +0 -1
  1149. package/stores/container-contents/syncAgent.d.ts +0 -8
  1150. package/stores/container-contents/syncAgent.js +0 -241
  1151. package/stores/container-contents/syncAgent.js.map +0 -1
  1152. package/stores/container-contents/syncAgentTypes.d.ts +0 -81
  1153. package/stores/container-contents/syncAgentTypes.js.map +0 -1
  1154. package/stores/container-contents/syncLaneIteration.js +0 -237
  1155. package/stores/container-contents/syncLaneIteration.js.map +0 -1
  1156. package/stores/container-contents/systemContainerHydration.js +0 -30
  1157. package/stores/container-contents/systemContainerHydration.js.map +0 -1
  1158. package/stores/container-contents/systemContainerIcon.js +0 -42
  1159. package/stores/container-contents/systemContainerIcon.js.map +0 -1
  1160. package/stores/container-contents/systemContainerLookup.js.map +0 -1
  1161. package/stores/container-contents/systemContainerPostCreate.js +0 -109
  1162. package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
  1163. package/stores/container-contents/systemContainerPromotion.js +0 -49
  1164. package/stores/container-contents/systemContainerPromotion.js.map +0 -1
  1165. package/stores/container-contents/writeGeneration.js.map +0 -1
  1166. package/stores/documents/documentStore/attachmentDetachState.js +0 -54
  1167. package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
  1168. package/stores/documents/documentStore/attachmentHydration.js +0 -90
  1169. package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
  1170. package/stores/documents/documentStore/attachmentHydrationCommit.js +0 -53
  1171. package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
  1172. package/stores/documents/documentStore/attachmentIntents.js +0 -39
  1173. package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
  1174. package/stores/documents/documentStore/attachmentMutationPersistence.js +0 -37
  1175. package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
  1176. package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
  1177. package/stores/documents/documentStore/attachmentPersistence.js +0 -106
  1178. package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
  1179. package/stores/documents/documentStore/attachmentRemoval.js +0 -136
  1180. package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
  1181. package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
  1182. package/stores/documents/documentStore/attachmentSourceUpload.js +0 -39
  1183. package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
  1184. package/stores/documents/documentStore/attachmentStaging.js +0 -84
  1185. package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
  1186. package/stores/documents/documentStore/attachmentUploadAttempt.js +0 -97
  1187. package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
  1188. package/stores/documents/documentStore/attachmentUploadLane.js +0 -49
  1189. package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
  1190. package/stores/documents/documentStore/attachmentUploadResume.js +0 -95
  1191. package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
  1192. package/stores/documents/documentStore/attachmentWriteGeneration.js +0 -32
  1193. package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
  1194. package/stores/documents/documentStore/attachments.js +0 -241
  1195. package/stores/documents/documentStore/attachments.js.map +0 -1
  1196. package/stores/documents/documentStore/deferredInitialUpdate.js +0 -116
  1197. package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
  1198. package/stores/documents/documentStore/documentHistoryCompaction.js +0 -67
  1199. package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
  1200. package/stores/documents/documentStore/durableDocumentReload.js +0 -79
  1201. package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
  1202. package/stores/documents/documentStore/historyRebuild.js +0 -75
  1203. package/stores/documents/documentStore/historyRebuild.js.map +0 -1
  1204. package/stores/documents/documentStore/initialization.js +0 -330
  1205. package/stores/documents/documentStore/initialization.js.map +0 -1
  1206. package/stores/documents/documentStore/initializationAttachments.js +0 -9
  1207. package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
  1208. package/stores/documents/documentStore/initializationHistory.js +0 -33
  1209. package/stores/documents/documentStore/initializationHistory.js.map +0 -1
  1210. package/stores/documents/documentStore/initializationRecovery.js +0 -107
  1211. package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
  1212. package/stores/documents/documentStore/pullContinuationInvalidation.js +0 -61
  1213. package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
  1214. package/stores/documents/documentStore/remoteRevalidationTelemetry.js +0 -15
  1215. package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
  1216. package/stores/documents/documentStore/remoteWork.js.map +0 -1
  1217. package/stores/documents/documentStore/rotation.js +0 -307
  1218. package/stores/documents/documentStore/rotation.js.map +0 -1
  1219. package/stores/documents/documentStore/rotationProvenance.js +0 -52
  1220. package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
  1221. package/stores/documents/documentStore/rotationSettlement.js +0 -222
  1222. package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
  1223. package/stores/documents/documentStore/sync.js +0 -299
  1224. package/stores/documents/documentStore/sync.js.map +0 -1
  1225. package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
  1226. package/stores/documents/documentStore/syncAttachmentSettlement.js +0 -72
  1227. package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
  1228. package/stores/documents/documentStore/syncAttachments.js +0 -323
  1229. package/stores/documents/documentStore/syncAttachments.js.map +0 -1
  1230. package/stores/documents/documentStore/syncDetachedAttachments.js +0 -129
  1231. package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
  1232. package/stores/documents/documentStore/syncFinalize.js +0 -204
  1233. package/stores/documents/documentStore/syncFinalize.js.map +0 -1
  1234. package/stores/documents/documentStore/syncGeneration.js.map +0 -1
  1235. package/stores/documents/documentStore/syncOutgoingCoverage.js +0 -96
  1236. package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
  1237. package/stores/documents/documentStore/syncRemoteSignals.js +0 -67
  1238. package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
  1239. package/stores/documents/documentStore/syncRequest.js +0 -157
  1240. package/stores/documents/documentStore/syncRequest.js.map +0 -1
  1241. package/stores/documents/documentStore/syncShared.js +0 -211
  1242. package/stores/documents/documentStore/syncShared.js.map +0 -1
  1243. package/stores/documents/documentStore/syncUpdateImport.js +0 -62
  1244. package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
  1245. package/stores/documents/documentStore/versionCoverage.js +0 -45
  1246. package/stores/documents/documentStore.d.ts +0 -8
  1247. package/stores/documents/documentStore.js +0 -215
  1248. package/stores/documents/documentStore.js.map +0 -1
  1249. package/workflows/container-contents/container-state/createAdoption.js +0 -193
  1250. package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
  1251. package/workflows/container-contents/container-state/createChild.js +0 -217
  1252. package/workflows/container-contents/container-state/createChild.js.map +0 -1
  1253. package/workflows/container-contents/container-state/createIntentDepth.js +0 -36
  1254. package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
  1255. package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
  1256. package/workflows/container-contents/container-state/createIntentSync.js +0 -354
  1257. package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
  1258. package/workflows/container-contents/container-state/createTerminalFailure.js +0 -19
  1259. package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
  1260. package/workflows/container-contents/container-state/createWithMetadata.js +0 -270
  1261. package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
  1262. package/workflows/container-contents/container-state/createWithMetadataPlan.js +0 -68
  1263. package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
  1264. package/workflows/container-contents/container-state/groupGrantVerification.js +0 -71
  1265. package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
  1266. package/workflows/container-contents/container-state/groupShareEpoch.js +0 -16
  1267. package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
  1268. package/workflows/container-contents/container-state/localPurgeScope.js +0 -49
  1269. package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
  1270. package/workflows/container-contents/container-state/purgeTree.js +0 -298
  1271. package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
  1272. package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
  1273. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js +0 -75
  1274. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
  1275. package/workflows/container-contents/container-state/purgeTreeScope.js +0 -175
  1276. package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
  1277. package/workflows/container-contents/container-state/readLocalPurgeScope.js +0 -18
  1278. package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
  1279. package/workflows/container-contents/container-state/share.js +0 -283
  1280. package/workflows/container-contents/container-state/share.js.map +0 -1
  1281. package/workflows/container-contents/container-state/sharePersistence.js +0 -136
  1282. package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
  1283. package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
  1284. package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
  1285. package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
  1286. package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
  1287. package/workflows/container-contents/remoteHydration/destinationRootReload.js +0 -10
  1288. package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
  1289. package/workflows/container-contents/remoteHydration/insertRemoteContainer.js +0 -135
  1290. package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
  1291. package/workflows/container-contents/remoteHydration/laneFetchMarkers.js +0 -21
  1292. package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
  1293. package/workflows/container-contents/remoteHydration/parentLaneFetch.js +0 -61
  1294. package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
  1295. package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
  1296. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js +0 -244
  1297. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
  1298. package/workflows/container-contents/remoteHydration/remoteContainerState.js +0 -263
  1299. package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
  1300. package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
  1301. package/workflows/container-contents/remoteHydration/replacementBinding.js +0 -75
  1302. package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
  1303. package/workflows/container-contents/remoteHydration/verifiedDestination.js +0 -296
  1304. package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
  1305. package/workflows/containers/child/carriedDescendantRekeys.js +0 -126
  1306. package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
  1307. package/workflows/containers/child/create.d.ts +0 -24
  1308. package/workflows/containers/child/create.js +0 -335
  1309. package/workflows/containers/child/create.js.map +0 -1
  1310. package/workflows/containers/child/createProjection.d.ts +0 -6
  1311. package/workflows/containers/child/createProjection.js +0 -43
  1312. package/workflows/containers/child/createProjection.js.map +0 -1
  1313. package/workflows/containers/child/createSubmission.d.ts +0 -56
  1314. package/workflows/containers/child/createSubmission.js +0 -43
  1315. package/workflows/containers/child/createSubmission.js.map +0 -1
  1316. package/workflows/containers/child/currentShareGrantMutation.js +0 -82
  1317. package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
  1318. package/workflows/containers/child/currentSharePrincipalPolicy.js +0 -83
  1319. package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
  1320. package/workflows/containers/child/keyringOverrideLineage.d.ts +0 -22
  1321. package/workflows/containers/child/keyringOverrideLineage.js +0 -39
  1322. package/workflows/containers/child/move.d.ts +0 -23
  1323. package/workflows/containers/child/move.js +0 -268
  1324. package/workflows/containers/child/move.js.map +0 -1
  1325. package/workflows/containers/child/moveArtifacts.js +0 -102
  1326. package/workflows/containers/child/moveArtifacts.js.map +0 -1
  1327. package/workflows/containers/child/moveRotation.js +0 -88
  1328. package/workflows/containers/child/moveRotation.js.map +0 -1
  1329. package/workflows/containers/child/moveWraps.js +0 -49
  1330. package/workflows/containers/child/moveWraps.js.map +0 -1
  1331. package/workflows/containers/child/rekey.d.ts +0 -32
  1332. package/workflows/containers/child/rekey.js +0 -227
  1333. package/workflows/containers/child/rekey.js.map +0 -1
  1334. package/workflows/containers/child/rekeyProjection.d.ts +0 -46
  1335. package/workflows/containers/child/rekeyProjection.js +0 -151
  1336. package/workflows/containers/child/rekeyProjection.js.map +0 -1
  1337. package/workflows/containers/child/rekeyRemote.d.ts +0 -24
  1338. package/workflows/containers/child/rekeyRemote.js +0 -64
  1339. package/workflows/containers/child/rekeyRemote.js.map +0 -1
  1340. package/workflows/containers/child/replacementPrincipalPolicyReferences.js +0 -19
  1341. package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
  1342. package/workflows/containers/child/rotationContext.js +0 -64
  1343. package/workflows/containers/child/rotationContext.js.map +0 -1
  1344. package/workflows/containers/child/rotationPrincipalPolicies.js +0 -19
  1345. package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
  1346. package/workflows/containers/child/rotationWraps.js +0 -85
  1347. package/workflows/containers/child/rotationWraps.js.map +0 -1
  1348. package/workflows/containers/child/runtimeCurrentGroupShare.js +0 -79
  1349. package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
  1350. package/workflows/containers/child/share.d.ts +0 -65
  1351. package/workflows/containers/child/share.js +0 -256
  1352. package/workflows/containers/child/share.js.map +0 -1
  1353. package/workflows/containers/child/shareAncestorRepair.js +0 -95
  1354. package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
  1355. package/workflows/containers/child/shareMaterialization.d.ts +0 -25
  1356. package/workflows/containers/child/shareMaterialization.js +0 -164
  1357. package/workflows/containers/child/shareMaterialization.js.map +0 -1
  1358. package/workflows/containers/child/sharePlanCore.d.ts +0 -82
  1359. package/workflows/containers/child/sharePlanCore.js +0 -191
  1360. package/workflows/containers/child/sharePlanCore.js.map +0 -1
  1361. package/workflows/containers/child/sharePrincipalPolicy.d.ts +0 -51
  1362. package/workflows/containers/child/sharePrincipalPolicy.js +0 -194
  1363. package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
  1364. package/workflows/containers/child/shareProjection.js.map +0 -1
  1365. /package/data/documents/shared/{containerKekCurrency.js → containerKek/containerKekCurrency.js} +0 -0
  1366. /package/data/documents/shared/{containerKekCurrency.js.map → containerKek/containerKekCurrency.js.map} +0 -0
  1367. /package/data/documents/shared/{containerKekEntryVerification.js.map → containerKek/containerKekEntryVerification.js.map} +0 -0
  1368. /package/data/documents/shared/{containerKekLogFetch.js.map → containerKek/containerKekLogFetch.js.map} +0 -0
  1369. /package/data/documents/shared/{containerKekPath.d.ts → containerKek/containerKekPath.d.ts} +0 -0
  1370. /package/data/documents/shared/{keyringLogWalk.js.map → containerKek/keyringLogWalk.js.map} +0 -0
  1371. /package/data/documents/shared/{pullContinuation.d.ts → sync/pullContinuation.d.ts} +0 -0
  1372. /package/data/documents/shared/{pullContinuation.js.map → sync/pullContinuation.js.map} +0 -0
  1373. /package/data/documents/shared/{syncSubmitFailure.js → sync/syncSubmitFailure.js} +0 -0
  1374. /package/data/documents/shared/{syncSubmitFailure.js.map → sync/syncSubmitFailure.js.map} +0 -0
  1375. /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
  1376. /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
  1377. /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
  1378. /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
  1379. /package/data/persistence/{keyingCheckpointEvidence.js.map → keyingCheckpoints/keyingCheckpointEvidence.js.map} +0 -0
  1380. /package/data/persistence/{storedPrincipalPolicyBundle.js → principalPolicy/storedPrincipalPolicyBundle.js} +0 -0
  1381. /package/data/persistence/{storedPrincipalPolicyBundle.js.map → principalPolicy/storedPrincipalPolicyBundle.js.map} +0 -0
  1382. /package/data/sqlite/{documentPersistenceTypes.js → documentPersistence/documentPersistenceTypes.js} +0 -0
  1383. /package/data/sqlite/{containerDocumentTombstoneHoldSchema.d.ts → schema/containerDocumentTombstoneHoldSchema.d.ts} +0 -0
  1384. /package/data/sqlite/{containerDocumentTombstoneHoldSchema.js → schema/containerDocumentTombstoneHoldSchema.js} +0 -0
  1385. /package/data/sqlite/{containerDocumentTombstoneHoldSchema.js.map → schema/containerDocumentTombstoneHoldSchema.js.map} +0 -0
  1386. /package/data/sqlite/{documentAttachmentSchema.d.ts → schema/documentAttachmentSchema.d.ts} +0 -0
  1387. /package/data/sqlite/{documentAttachmentSchema.js → schema/documentAttachmentSchema.js} +0 -0
  1388. /package/data/sqlite/{documentAttachmentSchema.js.map → schema/documentAttachmentSchema.js.map} +0 -0
  1389. /package/data/sqlite/{documentDiscoveryEvidenceSchema.js → schema/documentDiscoveryEvidenceSchema.js} +0 -0
  1390. /package/data/sqlite/{documentDiscoveryEvidenceSchema.js.map → schema/documentDiscoveryEvidenceSchema.js.map} +0 -0
  1391. /package/data/sqlite/{documentPlacementIntentSchema.js → schema/documentPlacementIntentSchema.js} +0 -0
  1392. /package/data/sqlite/{documentPlacementIntentSchema.js.map → schema/documentPlacementIntentSchema.js.map} +0 -0
  1393. /package/data/sqlite/{localIntentSchema.d.ts → schema/localIntentSchema.d.ts} +0 -0
  1394. /package/data/sqlite/{localIntentSchema.js → schema/localIntentSchema.js} +0 -0
  1395. /package/data/sqlite/{localIntentSchema.js.map → schema/localIntentSchema.js.map} +0 -0
  1396. /package/data/sqlite/{organizationFounderSchema.js → schema/organizationFounderSchema.js} +0 -0
  1397. /package/data/sqlite/{organizationFounderSchema.js.map → schema/organizationFounderSchema.js.map} +0 -0
  1398. /package/data/sqlite/{organizationReadModelSchema.js → schema/organizationReadModelSchema.js} +0 -0
  1399. /package/data/sqlite/{organizationReadModelSchema.js.map → schema/organizationReadModelSchema.js.map} +0 -0
  1400. /package/data/sqlite/{principalGrantRetirementSchema.js → schema/principalGrantRetirementSchema.js} +0 -0
  1401. /package/data/sqlite/{principalGrantRetirementSchema.js.map → schema/principalGrantRetirementSchema.js.map} +0 -0
  1402. /package/data/sqlite/{principalPolicySchema.d.ts → schema/principalPolicySchema.d.ts} +0 -0
  1403. /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
  1404. /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
  1405. /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
  1406. /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
  1407. /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
  1408. /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
  1409. /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
  1410. /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
  1411. /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
  1412. /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
  1413. /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
  1414. /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
  1415. /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
  1416. /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
  1417. /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
  1418. /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
  1419. /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
  1420. /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
  1421. /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
  1422. /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
  1423. /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
  1424. /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
  1425. /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
  1426. /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
  1427. /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
  1428. /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
  1429. /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
  1430. /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
  1431. /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
  1432. /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"principalPolicyCacheAdvance.js","sourceRoot":"","sources":["principalPolicyCacheAdvance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,+CAA+C,EAAE,MAAM,8DAA8D,CAAC;AAE/H,MAAM,sBAAuB,SAAQ,KAAK;IACnB;IAArB,YAAqB,iBAA0C;QAC7D,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QADd,sBAAiB,GAAjB,iBAAiB,CAAyB;IAE/D,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,KAA4E;IAE5E,IAAI,CAAC;QACH,MAAM,+CAA+C,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,uBAAuB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;YACvE,MAAM,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,SAA8C;IAE9C,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,sBAAsB,CAAC;YAAE,MAAM,KAAK,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,YAAY,sBAAsB;YAC3C,CAAC,CAAC,KAAK,CAAC,iBAAiB;YACzB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport { persistVerifiedPrincipalPolicyBundlesAtomically } from \"../../../data/persistence/keyingCheckpointAdvancePersistence\";\n\nclass PolicyCacheAdvanceRace extends Error {\n constructor(readonly verificationError: KeyingVerificationError) {\n super(verificationError.message);\n }\n}\n\n/** Only a fully verified candidate losing the atomic commit race can retry. */\nexport async function persistPrincipalPolicyCacheEntries(\n input: Parameters<typeof persistVerifiedPrincipalPolicyBundlesAtomically>[0],\n): Promise<void> {\n try {\n await persistVerifiedPrincipalPolicyBundlesAtomically(input);\n } catch (error) {\n if (error instanceof KeyingVerificationError && error.code === \"rollback\")\n throw new PolicyCacheAdvanceRace(error);\n throw error;\n }\n}\n\n/** Discard stale snapshots once; the replacement must pass every normal check. */\nexport async function retryPrincipalPolicyCacheAdvance<Result>(\n operation: (fresh: boolean) => Promise<Result>,\n): Promise<Result> {\n try {\n return await operation(false);\n } catch (error) {\n if (!(error instanceof PolicyCacheAdvanceRace)) throw error;\n }\n try {\n return await operation(true);\n } catch (error) {\n throw error instanceof PolicyCacheAdvanceRace\n ? error.verificationError\n : error;\n }\n}\n"]}
1
+ {"version":3,"file":"principalPolicyCacheAdvance.js","sourceRoot":"","sources":["principalPolicyCacheAdvance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,+CAA+C,EAAE,MAAM,gFAAgF,CAAC;AAEjJ,MAAM,sBAAuB,SAAQ,KAAK;IACnB;IAArB,YAAqB,iBAA0C;QAC7D,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QADd,sBAAiB,GAAjB,iBAAiB,CAAyB;IAE/D,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,KAA4E;IAE5E,IAAI,CAAC;QACH,MAAM,+CAA+C,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,uBAAuB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;YACvE,MAAM,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,SAA8C;IAE9C,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,sBAAsB,CAAC;YAAE,MAAM,KAAK,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,YAAY,sBAAsB;YAC3C,CAAC,CAAC,KAAK,CAAC,iBAAiB;YACzB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport { persistVerifiedPrincipalPolicyBundlesAtomically } from \"../../../data/persistence/keyingCheckpoints/keyingCheckpointAdvancePersistence\";\n\nclass PolicyCacheAdvanceRace extends Error {\n constructor(readonly verificationError: KeyingVerificationError) {\n super(verificationError.message);\n }\n}\n\n/** Only a fully verified candidate losing the atomic commit race can retry. */\nexport async function persistPrincipalPolicyCacheEntries(\n input: Parameters<typeof persistVerifiedPrincipalPolicyBundlesAtomically>[0],\n): Promise<void> {\n try {\n await persistVerifiedPrincipalPolicyBundlesAtomically(input);\n } catch (error) {\n if (error instanceof KeyingVerificationError && error.code === \"rollback\")\n throw new PolicyCacheAdvanceRace(error);\n throw error;\n }\n}\n\n/** Discard stale snapshots once; the replacement must pass every normal check. */\nexport async function retryPrincipalPolicyCacheAdvance<Result>(\n operation: (fresh: boolean) => Promise<Result>,\n): Promise<Result> {\n try {\n return await operation(false);\n } catch (error) {\n if (!(error instanceof PolicyCacheAdvanceRace)) throw error;\n }\n try {\n return await operation(true);\n } catch (error) {\n throw error instanceof PolicyCacheAdvanceRace\n ? error.verificationError\n : error;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
- import { loadPrincipalPolicyCheckpoint } from "../../../data/persistence/keyingCheckpointPersistence.js";
3
- import { principalPolicyHeadMeetsCheckpoint } from "../../../data/persistence/principalPolicyCheckpointSelection.js";
4
- import { loadPrincipalPolicyBundle } from "../../../data/persistence/principalPolicyPersistence.js";
2
+ import { loadPrincipalPolicyCheckpoint } from "../../../data/persistence/keyingCheckpoints/keyingCheckpointPersistence.js";
3
+ import { principalPolicyHeadMeetsCheckpoint } from "../../../data/persistence/principalPolicy/principalPolicyCheckpointSelection.js";
4
+ import { loadPrincipalPolicyBundle } from "../../../data/persistence/principalPolicy/principalPolicyPersistence.js";
5
5
  import { parseOrganizationAuthorityDescriptor, principalHeadMatchesReference, } from "../../../data/principals/organizationAuthorityDescriptor.js";
6
6
  import { verifyOrganizationAdminPolicy } from "../../../data/principals/principalPolicyAdminSigners.js";
7
7
  import { collectPrincipalPolicySignerPublicKeys } from "../policyVerification.js";
@@ -1 +1 @@
1
- {"version":3,"file":"principalPolicy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,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,uBAAuB,CAC/B,eAAe,EACf,2CAA2C,CAC5C,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;YACpD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,6CAA6C,CAC9C,CAAC;QACJ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IACxD,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../../data/persistence/keyingCheckpointPersistence\";\nimport { principalPolicyHeadMeetsCheckpoint } from \"../../../data/persistence/principalPolicyCheckpointSelection\";\nimport { loadPrincipalPolicyBundle } from \"../../../data/persistence/principalPolicyPersistence\";\nimport {\n type OrganizationAuthorityDescriptor,\n parseOrganizationAuthorityDescriptor,\n principalHeadMatchesReference,\n} from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { verifyOrganizationAdminPolicy } from \"../../../data/principals/principalPolicyAdminSigners\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../data/trustedUserIdentity\";\nimport type { CurrentPrincipalPolicyReader } from \"../currentPrincipalPolicyReader\";\nimport { collectPrincipalPolicySignerPublicKeys } from \"../policyVerification\";\n\nexport interface VerifiedPolicyDirectory {\n readonly bundle: PrincipalPolicyBundleResponse;\n readonly policy: VerifiedPrincipalPolicy;\n readonly descriptor: OrganizationAuthorityDescriptor;\n}\n\nexport type PolicyDirectoryLoader = (\n remote: boolean,\n) => Promise<VerifiedPolicyDirectory | null>;\n\nexport function directoryBindsGroupReference(\n directory: VerifiedPolicyDirectory | null,\n policy: VerifiedPrincipalPolicy,\n reference: ReferencedPrincipalHead,\n): boolean {\n const head = directory?.descriptor.groupHeads.find(\n (head) => head.principalId === reference.principalId,\n );\n // A newer directory head authenticates its verified predecessors too.\n // Requiring equality with a historical manifest citation bricks old reads.\n return (\n !!head &&\n head.version >= reference.version &&\n head.version === policy.version &&\n [policy.state, ...(policy.history ?? []).map((entry) => entry.state)].some(\n (state) => principalHeadMatchesReference(state, head),\n )\n );\n}\n\nexport function createPolicyDirectoryLoader(input: {\n readonly execSql: ExecSql;\n readonly organizationId: string;\n readonly currentPolicyReader: CurrentPrincipalPolicyReader;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}): PolicyDirectoryLoader {\n const memo = new Map<boolean, Promise<VerifiedPolicyDirectory | null>>();\n const load = async (\n remote: boolean,\n ): Promise<VerifiedPolicyDirectory | null> => {\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n input.execSql,\n \"organization\",\n input.organizationId,\n );\n let bundle = remote\n ? null\n : await loadPrincipalPolicyBundle(\n input.execSql,\n \"organization\",\n input.organizationId,\n );\n if (\n bundle &&\n !principalPolicyHeadMeetsCheckpoint(bundle.currentState, checkpoint)\n )\n bundle = null;\n bundle ??= await input.currentPolicyReader.getCurrentPrincipalPolicy(\n \"organization\",\n input.organizationId,\n );\n if (!bundle) return null;\n const signers = await collectPrincipalPolicySignerPublicKeys({\n bundle,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n });\n if (\"error\" in signers) {\n if (signers.error === \"fingerprint-mismatch\")\n throw new KeyingVerificationError(\n \"signer_mismatch\",\n \"organization directory signer fingerprint does not match\",\n );\n return null;\n }\n const verified = await verifyOrganizationAdminPolicy({\n bundle,\n localCheckpoint: checkpoint,\n organizationId: input.organizationId,\n signerPublicKeys: signers.signerPublicKeys,\n });\n if (!verified.ok) throw verified.error;\n let descriptor: OrganizationAuthorityDescriptor;\n try {\n descriptor = parseOrganizationAuthorityDescriptor(\n bundle.currentPayload.ciphertext,\n );\n } catch {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"organization directory payload is invalid\",\n );\n }\n if (descriptor.organizationId !== input.organizationId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"organization directory scope does not match\",\n );\n return { bundle, policy: verified.value, descriptor };\n };\n return (remote) => {\n let pending = memo.get(remote);\n if (!pending) {\n pending = load(remote);\n memo.set(remote, pending);\n }\n return pending;\n };\n}\n"]}
1
+ {"version":3,"file":"principalPolicyOrganizationScope.js","sourceRoot":"","sources":["principalPolicyOrganizationScope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,yEAAyE,CAAC;AACxH,OAAO,EAAE,kCAAkC,EAAE,MAAM,8EAA8E,CAAC;AAClI,OAAO,EAAE,yBAAyB,EAAE,MAAM,sEAAsE,CAAC;AACjH,OAAO,EAEL,oCAAoC,EACpC,6BAA6B,GAC9B,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sDAAsD,CAAC;AAIrG,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAY/E,MAAM,UAAU,4BAA4B,CAC1C,SAAyC,EACzC,MAA+B,EAC/B,SAAkC;IAElC,MAAM,IAAI,GAAG,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI,CAChD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,KA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cesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n type VerifiedPrincipalPolicy,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicyBundleResponse } from \"@tearleads/validators/response\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../../data/persistence/keyingCheckpoints/keyingCheckpointPersistence\";\nimport { principalPolicyHeadMeetsCheckpoint } from \"../../../data/persistence/principalPolicy/principalPolicyCheckpointSelection\";\nimport { loadPrincipalPolicyBundle } from \"../../../data/persistence/principalPolicy/principalPolicyPersistence\";\nimport {\n type OrganizationAuthorityDescriptor,\n parseOrganizationAuthorityDescriptor,\n principalHeadMatchesReference,\n} from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { verifyOrganizationAdminPolicy } from \"../../../data/principals/principalPolicyAdminSigners\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../data/trustedUserIdentity\";\nimport type { CurrentPrincipalPolicyReader } from \"../currentPrincipalPolicyReader\";\nimport { collectPrincipalPolicySignerPublicKeys } from \"../policyVerification\";\n\nexport interface VerifiedPolicyDirectory {\n readonly bundle: PrincipalPolicyBundleResponse;\n readonly policy: VerifiedPrincipalPolicy;\n readonly descriptor: OrganizationAuthorityDescriptor;\n}\n\nexport type PolicyDirectoryLoader = (\n remote: boolean,\n) => Promise<VerifiedPolicyDirectory | null>;\n\nexport function directoryBindsGroupReference(\n directory: VerifiedPolicyDirectory | null,\n policy: VerifiedPrincipalPolicy,\n reference: ReferencedPrincipalHead,\n): boolean {\n const head = directory?.descriptor.groupHeads.find(\n (head) => head.principalId === reference.principalId,\n );\n // A newer directory head authenticates its verified predecessors too.\n // Requiring equality with a historical manifest citation bricks old reads.\n return (\n !!head &&\n head.version >= reference.version &&\n head.version === policy.version &&\n [policy.state, ...(policy.history ?? []).map((entry) => entry.state)].some(\n (state) => principalHeadMatchesReference(state, head),\n )\n );\n}\n\nexport function createPolicyDirectoryLoader(input: {\n readonly execSql: ExecSql;\n readonly organizationId: string;\n readonly currentPolicyReader: CurrentPrincipalPolicyReader;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}): PolicyDirectoryLoader {\n const memo = new Map<boolean, Promise<VerifiedPolicyDirectory | null>>();\n const load = async (\n remote: boolean,\n ): Promise<VerifiedPolicyDirectory | null> => {\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n input.execSql,\n \"organization\",\n input.organizationId,\n );\n let bundle = remote\n ? null\n : await loadPrincipalPolicyBundle(\n input.execSql,\n \"organization\",\n input.organizationId,\n );\n if (\n bundle &&\n !principalPolicyHeadMeetsCheckpoint(bundle.currentState, checkpoint)\n )\n bundle = null;\n bundle ??= await input.currentPolicyReader.getCurrentPrincipalPolicy(\n \"organization\",\n input.organizationId,\n );\n if (!bundle) return null;\n const signers = await collectPrincipalPolicySignerPublicKeys({\n bundle,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n });\n if (\"error\" in signers) {\n if (signers.error === \"fingerprint-mismatch\")\n throw new KeyingVerificationError(\n \"signer_mismatch\",\n \"organization directory signer fingerprint does not match\",\n );\n return null;\n }\n const verified = await verifyOrganizationAdminPolicy({\n bundle,\n localCheckpoint: checkpoint,\n organizationId: input.organizationId,\n signerPublicKeys: signers.signerPublicKeys,\n });\n if (!verified.ok) throw verified.error;\n let descriptor: OrganizationAuthorityDescriptor;\n try {\n descriptor = parseOrganizationAuthorityDescriptor(\n bundle.currentPayload.ciphertext,\n );\n } catch {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"organization directory payload is invalid\",\n );\n }\n if (descriptor.organizationId !== input.organizationId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"organization directory scope does not match\",\n );\n return { bundle, policy: verified.value, descriptor };\n };\n return (remote) => {\n let pending = memo.get(remote);\n if (!pending) {\n pending = load(remote);\n memo.set(remote, pending);\n }\n return pending;\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { KeyingVerificationError } from "../../internal/crypto/index.js";
2
2
  import { PRINCIPAL_POLICY_REPAIR_HEAD_LIMIT } from "../../internal/validators/util/index.js";
3
- import { verifiedPrincipalPolicyContainsReference } from "../../data/keyingProjectionVerification/principalPolicyCache.js";
3
+ import { verifiedPrincipalPolicyContainsReference } from "../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js";
4
4
  import { assertProjectionVerificationCurrent, } from "../../data/keyingProjectionVerification/types.js";
5
5
  /** Recover advisory repair heads; the consuming mutation still admits its pins. */
6
6
  export async function recoverPrincipalPolicyRepair(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"policyRepair.js","sourceRoot":"","sources":["policyRepair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,8DAA8D,CAAC;AACxH,OAAO,EACL,mCAAmC,GAGpC,MAAM,+CAA+C,CAAC;AAEvD,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,KAOlD;IACC,6EAA6E;IAC7E,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,KAAK,CAAC,+BAA+B,EAAE,gBAAgB,CAAC;IACxE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QACtE,OAAO,KAAK,CAAC;IACf,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,kCAAkC;QACzD,MAAM,IAAI,UAAU,CAAC,6CAA6C,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,MAAM,SAAS,GAAsC,EAAE,CAAC;IACxD,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,KAAK,MAAM,MAAM,IAAI,SAAS;YAC5B,mCAAmC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC7D,CAAC,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,aAAa,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC3B,aAAa;YACb,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,SAAS,EAAE,EAAE,GAAG,SAAS,EAAE;YAC3B,YAAY,EAAE,KAAK,CAAC,YAAY;SACjC,CAAC,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,aAAa,EAAE,CAAC;QAChB,IACE,MAAM,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;YAC9C,CAAC,wCAAwC,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;YAEnE,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,sEAAsE,CACvE,CAAC;IACN,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport type { ReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport { PRINCIPAL_POLICY_REPAIR_HEAD_LIMIT } from \"@tearleads/validators/util\";\nimport { verifiedPrincipalPolicyContainsReference } from \"../../data/keyingProjectionVerification/principalPolicyCache\";\nimport {\n assertProjectionVerificationCurrent,\n type ReferencedPrincipalPolicyWarmer,\n type ResolvedPrincipalPolicyEvidence,\n} from \"../../data/keyingProjectionVerification/types\";\n\n/** Recover advisory repair heads; the consuming mutation still admits its pins. */\nexport async function recoverPrincipalPolicyRepair(input: {\n readonly heads: readonly ReferencedPrincipalStateResponse[] | undefined;\n readonly organizationId: string;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<boolean> {\n // Keep the requested organization and lifetime stable across host callbacks.\n input = { ...input };\n const resolve = input.warmReferencedPrincipalPolicies?.resolveReference;\n if (!input.heads?.length || !resolve || input.stillCurrent?.() === false)\n return false;\n if (input.heads.length > PRINCIPAL_POLICY_REPAIR_HEAD_LIMIT)\n throw new RangeError(\"Principal policy repair head limit exceeded\");\n const heads = input.heads.map((head) => ({ ...head }));\n const recoveryBatch = {};\n const recovered: ResolvedPrincipalPolicyEvidence[] = [];\n const assertCurrent = () => {\n assertProjectionVerificationCurrent(input.stillCurrent);\n for (const result of recovered)\n assertProjectionVerificationCurrent(result.stillCurrent);\n };\n for (const reference of heads) {\n assertCurrent();\n const result = await resolve({\n recoveryBatch,\n organizationId: input.organizationId,\n reference: { ...reference },\n stillCurrent: input.stillCurrent,\n });\n recovered.push(result);\n assertCurrent();\n if (\n result.organizationId !== input.organizationId ||\n !verifiedPrincipalPolicyContainsReference(result.policy, reference)\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Recovered repair evidence does not contain the requested scoped head\",\n );\n }\n return true;\n}\n"]}
1
+ {"version":3,"file":"policyRepair.js","sourceRoot":"","sources":["policyRepair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,8EAA8E,CAAC;AACxI,OAAO,EACL,mCAAmC,GAGpC,MAAM,+CAA+C,CAAC;AAEvD,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,KAOlD;IACC,6EAA6E;IAC7E,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,KAAK,CAA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AACd,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport type { ReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport { PRINCIPAL_POLICY_REPAIR_HEAD_LIMIT } from \"@tearleads/validators/util\";\nimport { verifiedPrincipalPolicyContainsReference } from \"../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache\";\nimport {\n assertProjectionVerificationCurrent,\n type ReferencedPrincipalPolicyWarmer,\n type ResolvedPrincipalPolicyEvidence,\n} from \"../../data/keyingProjectionVerification/types\";\n\n/** Recover advisory repair heads; the consuming mutation still admits its pins. */\nexport async function recoverPrincipalPolicyRepair(input: {\n readonly heads: readonly ReferencedPrincipalStateResponse[] | undefined;\n readonly organizationId: string;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<boolean> {\n // Keep the requested organization and lifetime stable across host callbacks.\n input = { ...input };\n const resolve = input.warmReferencedPrincipalPolicies?.resolveReference;\n if (!input.heads?.length || !resolve || input.stillCurrent?.() === false)\n return false;\n if (input.heads.length > PRINCIPAL_POLICY_REPAIR_HEAD_LIMIT)\n throw new RangeError(\"Principal policy repair head limit exceeded\");\n const heads = input.heads.map((head) => ({ ...head }));\n const recoveryBatch = {};\n const recovered: ResolvedPrincipalPolicyEvidence[] = [];\n const assertCurrent = () => {\n assertProjectionVerificationCurrent(input.stillCurrent);\n for (const result of recovered)\n assertProjectionVerificationCurrent(result.stillCurrent);\n };\n for (const reference of heads) {\n assertCurrent();\n const result = await resolve({\n recoveryBatch,\n organizationId: input.organizationId,\n reference: { ...reference },\n stillCurrent: input.stillCurrent,\n });\n recovered.push(result);\n assertCurrent();\n if (\n result.organizationId !== input.organizationId ||\n !verifiedPrincipalPolicyContainsReference(result.policy, reference)\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Recovered repair evidence does not contain the requested scoped head\",\n );\n }\n return true;\n}\n"]}
@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FX,YACW,iBAA0C,EAC1C,cAA6C;QAEtD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAHxB,sBAAiB,GAAjB,iBAAiB,CAAyB;QAC1C,mBAAc,GAAd,cAAc,CAA+B;QAGtD,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;IACvD,CAAC;CACF","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n serializeKeyingCanonicalJson,\n} from \"@tearleads/crypto\";\nimport { isReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistoryPrefixPersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport type { PublicPrincipalHistoryOptions } from \"./publicPrincipalHistoryTypes\";\n\n/** The greatest cited Admins head commits to the lineage of every earlier citation. */\nexport function publicHistoryAuthorityReference(\n previous: ReferencedPrincipalHead | null,\n references: readonly ReferencedPrincipalHead[],\n) {\n return references.reduce<ReferencedPrincipalHead | null>(\n (head, reference) =>\n !head || reference.version > head.version ? reference : head,\n previous,\n );\n}\n\nexport function publicHistoryAuthorityJson(\n reference: ReferencedPrincipalHead | null,\n) {\n return serializeKeyingCanonicalJson(reference ? { ...reference } : null);\n}\n\nexport function parsePublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n json: string,\n): ReferencedPrincipalHead | null | undefined {\n try {\n const value: unknown = JSON.parse(json);\n if (value === null) return null;\n if (\n isReferencedPrincipalStateResponse(value) &&\n value.principalType === \"group\" &&\n value.principalId === input.authorityGroupId\n )\n return value;\n } catch {\n /* Invalid disposable metadata cannot restore verified progress. */\n }\n return undefined;\n}\n\nexport async function loadPublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n references: readonly ReferencedPrincipalHead[],\n cachedPrefix = false,\n) {\n if (!references.length) return undefined;\n const authority = await input.loadExternalAuthority?.(\n references,\n cachedPrefix,\n );\n if (\n authority &&\n (authority.currentHead.principalId !== input.authorityGroupId ||\n authority.states.some(\n ({ head }) => head.principalId !== input.authorityGroupId,\n ))\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Authority callback differs from the directory binding\",\n );\n if (\n references.some(\n (reference) =>\n !authority?.states.some(({ head }) =>\n principalHeadMatchesReference(head, reference),\n ),\n )\n )\n throw new KeyingVerificationError(\n \"stale_predecessor\",\n \"Public history authority differs from its verified Admins lineage\",\n );\n return authority;\n}\n\nexport async function validatePublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n reference: ReferencedPrincipalHead | null,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<void> {\n try {\n if (reference) await loadPublicHistoryAuthority(input, [reference], true);\n } catch (error) {\n if (error instanceof KeyingVerificationError)\n throw new PublicHistoryAuthorityUnavailableError(error, rejectedPrefix);\n throw error;\n }\n}\n\n/** Only cache restoration can request a replay after an authority mismatch. */\nexport class PublicHistoryAuthorityUnavailableError extends Error {\n constructor(\n readonly verificationError: KeyingVerificationError,\n readonly rejectedPrefix: PrincipalHistoryPrefix | null,\n ) {\n super(verificationError.message);\n this.name = \"PublicHistoryAuthorityUnavailableError\";\n }\n}\n"]}
1
+ {"version":3,"file":"publicPrincipalHistoryAuthority.js","sourceRoot":"","sources":["publicPrincipalHistoryAuthority.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AAGzG,uFAAuF;AACvF,MAAM,UAAU,+BAA+B,CAC7C,QAAwC,EACxC,UAA8C;IAE9C,OAAO,UAAU,CAAC,MAAM,CACtB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAClB,CAAC,IAAI,IAAI,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,C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CACb,CAAC,SAAS,EAAE,EAAE,CACZ,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACnC,6BAA6B,CAAC,IAAI,EAAE,SAAS,CAAC,CAC/C,CACJ;QAED,MAAM,IAAI,uBAAuB,CAC/B,mBAAmB,EACnB,mEAAmE,CACpE,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,KAAoC,EACpC,SAAyC,EACzC,iBAAgD,IAAI;IAEpD,IAAI,CAAC;QACH,IAAI,SAAS;YAAE,MAAM,0BAA0B,CAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,uBAAuB;YAC1C,MAAM,IAAI,sCAAsC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC1E,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAEpD;IACA;IAFX,YACW,iBAA0C,EAC1C,cAA6C;QAEtD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAHxB,sBAAiB,GAAjB,iBAAiB,CAAyB;QAC1C,mBAAc,GAAd,cAAc,CAA+B;QAGtD,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;IACvD,CAAC;CACF","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n serializeKeyingCanonicalJson,\n} from \"@tearleads/crypto\";\nimport { isReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistory/principalHistoryPrefixPersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport type { PublicPrincipalHistoryOptions } from \"./publicPrincipalHistoryTypes\";\n\n/** The greatest cited Admins head commits to the lineage of every earlier citation. */\nexport function publicHistoryAuthorityReference(\n previous: ReferencedPrincipalHead | null,\n references: readonly ReferencedPrincipalHead[],\n) {\n return references.reduce<ReferencedPrincipalHead | null>(\n (head, reference) =>\n !head || reference.version > head.version ? reference : head,\n previous,\n );\n}\n\nexport function publicHistoryAuthorityJson(\n reference: ReferencedPrincipalHead | null,\n) {\n return serializeKeyingCanonicalJson(reference ? { ...reference } : null);\n}\n\nexport function parsePublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n json: string,\n): ReferencedPrincipalHead | null | undefined {\n try {\n const value: unknown = JSON.parse(json);\n if (value === null) return null;\n if (\n isReferencedPrincipalStateResponse(value) &&\n value.principalType === \"group\" &&\n value.principalId === input.authorityGroupId\n )\n return value;\n } catch {\n /* Invalid disposable metadata cannot restore verified progress. */\n }\n return undefined;\n}\n\nexport async function loadPublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n references: readonly ReferencedPrincipalHead[],\n cachedPrefix = false,\n) {\n if (!references.length) return undefined;\n const authority = await input.loadExternalAuthority?.(\n references,\n cachedPrefix,\n );\n if (\n authority &&\n (authority.currentHead.principalId !== input.authorityGroupId ||\n authority.states.some(\n ({ head }) => head.principalId !== input.authorityGroupId,\n ))\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Authority callback differs from the directory binding\",\n );\n if (\n references.some(\n (reference) =>\n !authority?.states.some(({ head }) =>\n principalHeadMatchesReference(head, reference),\n ),\n )\n )\n throw new KeyingVerificationError(\n \"stale_predecessor\",\n \"Public history authority differs from its verified Admins lineage\",\n );\n return authority;\n}\n\nexport async function validatePublicHistoryAuthority(\n input: PublicPrincipalHistoryOptions,\n reference: ReferencedPrincipalHead | null,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<void> {\n try {\n if (reference) await loadPublicHistoryAuthority(input, [reference], true);\n } catch (error) {\n if (error instanceof KeyingVerificationError)\n throw new PublicHistoryAuthorityUnavailableError(error, rejectedPrefix);\n throw error;\n }\n}\n\n/** Only cache restoration can request a replay after an authority mismatch. */\nexport class PublicHistoryAuthorityUnavailableError extends Error {\n constructor(\n readonly verificationError: KeyingVerificationError,\n readonly rejectedPrefix: PrincipalHistoryPrefix | null,\n ) {\n super(verificationError.message);\n this.name = \"PublicHistoryAuthorityUnavailableError\";\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
2
  import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
3
- import { preparePrincipalHistoryEvidencePage } from "../../../data/persistence/principalHistoryEvidencePersistence.js";
4
- import { savePrincipalHistoryStage } from "../../../data/persistence/principalHistoryStagePersistence.js";
3
+ import { preparePrincipalHistoryEvidencePage } from "../../../data/persistence/principalHistory/principalHistoryEvidencePersistence.js";
4
+ import { savePrincipalHistoryStage } from "../../../data/persistence/principalHistory/principalHistoryStagePersistence.js";
5
5
  import { principalHistoryStageProtection } from "../../../data/principals/principalHistoryStageProtection.js";
6
6
  import { collectPrincipalPolicySignerPublicKeys } from "../policyVerification.js";
7
7
  import { loadPublicHistoryAuthority, publicHistoryAuthorityJson, publicHistoryAuthorityReference, } from "./publicPrincipalHistoryAuthority.js";
@@ -1 +1 @@
1
- {"version":3,"file":"publicPrincipalHistoryPage.js","sourceRoot":"","sources":["publicPrincipalHistoryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,mCAAmC,EAAE,MAAM,+DAA+D,CAAC;AACpH,OAAO,EAAE,yBAAyB,EAAE,MAAM,4DAA4D,CAAC;AACvG,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAC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AG,CAAC,YAAY;QAC9B,KAAK;QACL,kBAAkB,EAAE,+BAA+B,CACjD,QAAQ,CAAC,kBAAkB,EAC3B,UAAU,CACX;QACD,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyStateChainEntry,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicySnapshotPageResponse } from \"@tearleads/validators/response\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { preparePrincipalHistoryEvidencePage } from \"../../../data/persistence/principalHistoryEvidencePersistence\";\nimport { savePrincipalHistoryStage } from \"../../../data/persistence/principalHistoryStagePersistence\";\nimport { principalHistoryStageProtection } from \"../../../data/principals/principalHistoryStageProtection\";\nimport { collectPrincipalPolicySignerPublicKeys } from \"../policyVerification\";\nimport {\n loadPublicHistoryAuthority,\n publicHistoryAuthorityJson,\n publicHistoryAuthorityReference,\n} from \"./publicPrincipalHistoryAuthority\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryTypes\";\n\nexport class PublicPrincipalHistoryPrefixDisconnectedError extends Error {\n constructor(readonly verificationError: KeyingVerificationError) {\n super(verificationError.message);\n this.name = \"PublicPrincipalHistoryPrefixDisconnectedError\";\n }\n}\n\nfunction assertPublicAuthorityScope(\n input: PublicPrincipalHistoryOptions,\n entries: readonly PrincipalPolicyStateChainEntry[],\n): void {\n if (\n input.strictAdmins &&\n entries.some(\n (entry) =>\n entry.projection.length === 0 ||\n entry.projection.some((member) => member.role !== \"admin\"),\n )\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Public Admins history must contain only direct admin users\",\n );\n if (\n entries.some(\n ({ state }) =>\n state.externalAuthority &&\n state.externalAuthority.principalId !== input.authorityGroupId,\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history cites an authority outside its directory binding\",\n );\n}\n\nexport async function appendPublicPrincipalHistoryPage(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n page: PrincipalPolicySnapshotPageResponse,\n): Promise<PublicPrincipalHistoryProgress> {\n const stillCurrent = () => !input.signal?.aborted && input.stillCurrent();\n const complete = page.historyPage.nextAfterVersion === null;\n const entries = [...page.previousStates];\n if (complete)\n entries.push({\n state: page.currentState,\n projection: page.currentProjection,\n grants: page.currentGrants,\n });\n assertPublicAuthorityScope(input, entries);\n const keys = await collectPrincipalPolicySignerPublicKeys({\n bundle: page,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n });\n if (\"error\" in keys)\n throw new KeyingVerificationError(\n keys.error === \"not-found\" ? \"missing_dependency\" : \"signer_mismatch\",\n \"Public history signer identity is unavailable or mismatched\",\n );\n const references = entries.flatMap(({ state }) =>\n state.externalAuthority ? [state.externalAuthority] : [],\n );\n const externalAuthority = await loadPublicHistoryAuthority(input, references);\n assertProjectionVerificationCurrent(stillCurrent);\n const appended = await progress.verifier.append({\n entries,\n signerPublicKeys: keys.signerPublicKeys,\n ...(externalAuthority ? { externalAuthority } : {}),\n });\n if (!appended.ok) {\n if (appended.error.code === \"stale_predecessor\")\n throw new PublicPrincipalHistoryPrefixDisconnectedError(appended.error);\n throw appended.error;\n }\n const row = {\n id: progress.id,\n organizationId: input.organizationId,\n currentJson: publicHistoryAuthorityJson(\n publicHistoryAuthorityReference(progress.authorityReference, references),\n ),\n afterVersion: appended.value.throughVersion - (complete ? 1 : 0),\n complete,\n };\n const sealed = await progress.verifier.exportProgress(\n await principalHistoryStageProtection(\n input.protection,\n input.source.head,\n row,\n ),\n );\n if (!sealed.ok) throw sealed.error;\n const saved = { ...row, progress: sealed.value };\n await savePrincipalHistoryStage({\n execSql: input.execSql,\n stage: saved,\n evidence: await preparePrincipalHistoryEvidencePage({\n indexRootHash: appended.value.indexRootHash,\n scopeId: progress.scopeId,\n organizationId: input.organizationId,\n entries,\n nodes: appended.value.indexNodes,\n }),\n previousProgress: progress.saved?.progress ?? null,\n stillCurrent,\n });\n assertProjectionVerificationCurrent(stillCurrent);\n return {\n ...progress,\n afterVersion: row.afterVersion,\n saved,\n authorityReference: publicHistoryAuthorityReference(\n progress.authorityReference,\n references,\n ),\n completedHead: complete ? input.source.head : null,\n };\n}\n"]}
1
+ {"version":3,"file":"publicPrincipalHistoryPage.js","sourceRoot":"","sources":["publicPrincipalHistoryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,mCAAmC,EAAE,MAAM,gFAAgF,CAAC;AACrI,OAAO,EAAE,yBAAyB,EAAE,MAAM,6EAA6E,CAAC;AACxH,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,mCAAmC,CAAC;AAM3C,MAAM,OAAO,6CAA8C,SAAQ,KAAK;IACjD;IAArB,YAAqB,iBAA0C;QAC7D,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QADd,sBAAiB,GAAjB,iBAAiB,CAAyB;QAE7D,IAAI,CAAC,IAAI,GAAG,+CAA+C,CAAC;IAC9D,CAAC;CACF;AAED,SAAS,0BAA0B,CACjC,KAAoC,EACpC,OAAkD;IAElD,IACE,KAAK,CAAC,YAAY;QAClB,OAAO,CAAC,IAAI,CACV,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAC7B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,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,CACF,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,MAAM,KAAK,GAAG,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACjD,MAAM,yBAAyB,CAAC;QAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,MAAM,mCAAmC,CAAC;YAClD,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa;YAC3C,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,OAAO;YACP,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;SACjC,CAAC;QACF,gBAAgB,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,IAAI,IAAI;QAClD,YAAY;KACb,CAAC,CAAC;IACH,mCAAmC,CAAC,YAAY,CAAC,CAAC;IAClD,OAAO;QACL,GAAG,QAAQ;QACX,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,KAAK;QACL,kBAAkB,EAAE,+BAA+B,CACjD,QAAQ,CAAC,kBAAkB,EAC3B,UAAU,CACX;QACD,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type PrincipalPolicyStateChainEntry,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicySnapshotPageResponse } from \"@tearleads/validators/response\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { preparePrincipalHistoryEvidencePage } from \"../../../data/persistence/principalHistory/principalHistoryEvidencePersistence\";\nimport { savePrincipalHistoryStage } from \"../../../data/persistence/principalHistory/principalHistoryStagePersistence\";\nimport { principalHistoryStageProtection } from \"../../../data/principals/principalHistoryStageProtection\";\nimport { collectPrincipalPolicySignerPublicKeys } from \"../policyVerification\";\nimport {\n loadPublicHistoryAuthority,\n publicHistoryAuthorityJson,\n publicHistoryAuthorityReference,\n} from \"./publicPrincipalHistoryAuthority\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryTypes\";\n\nexport class PublicPrincipalHistoryPrefixDisconnectedError extends Error {\n constructor(readonly verificationError: KeyingVerificationError) {\n super(verificationError.message);\n this.name = \"PublicPrincipalHistoryPrefixDisconnectedError\";\n }\n}\n\nfunction assertPublicAuthorityScope(\n input: PublicPrincipalHistoryOptions,\n entries: readonly PrincipalPolicyStateChainEntry[],\n): void {\n if (\n input.strictAdmins &&\n entries.some(\n (entry) =>\n entry.projection.length === 0 ||\n entry.projection.some((member) => member.role !== \"admin\"),\n )\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Public Admins history must contain only direct admin users\",\n );\n if (\n entries.some(\n ({ state }) =>\n state.externalAuthority &&\n state.externalAuthority.principalId !== input.authorityGroupId,\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history cites an authority outside its directory binding\",\n );\n}\n\nexport async function appendPublicPrincipalHistoryPage(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n page: PrincipalPolicySnapshotPageResponse,\n): Promise<PublicPrincipalHistoryProgress> {\n const stillCurrent = () => !input.signal?.aborted && input.stillCurrent();\n const complete = page.historyPage.nextAfterVersion === null;\n const entries = [...page.previousStates];\n if (complete)\n entries.push({\n state: page.currentState,\n projection: page.currentProjection,\n grants: page.currentGrants,\n });\n assertPublicAuthorityScope(input, entries);\n const keys = await collectPrincipalPolicySignerPublicKeys({\n bundle: page,\n resolveTrustedUserIdentity: input.resolveTrustedUserIdentity,\n });\n if (\"error\" in keys)\n throw new KeyingVerificationError(\n keys.error === \"not-found\" ? \"missing_dependency\" : \"signer_mismatch\",\n \"Public history signer identity is unavailable or mismatched\",\n );\n const references = entries.flatMap(({ state }) =>\n state.externalAuthority ? [state.externalAuthority] : [],\n );\n const externalAuthority = await loadPublicHistoryAuthority(input, references);\n assertProjectionVerificationCurrent(stillCurrent);\n const appended = await progress.verifier.append({\n entries,\n signerPublicKeys: keys.signerPublicKeys,\n ...(externalAuthority ? { externalAuthority } : {}),\n });\n if (!appended.ok) {\n if (appended.error.code === \"stale_predecessor\")\n throw new PublicPrincipalHistoryPrefixDisconnectedError(appended.error);\n throw appended.error;\n }\n const row = {\n id: progress.id,\n organizationId: input.organizationId,\n currentJson: publicHistoryAuthorityJson(\n publicHistoryAuthorityReference(progress.authorityReference, references),\n ),\n afterVersion: appended.value.throughVersion - (complete ? 1 : 0),\n complete,\n };\n const sealed = await progress.verifier.exportProgress(\n await principalHistoryStageProtection(\n input.protection,\n input.source.head,\n row,\n ),\n );\n if (!sealed.ok) throw sealed.error;\n const saved = { ...row, progress: sealed.value };\n await savePrincipalHistoryStage({\n execSql: input.execSql,\n stage: saved,\n evidence: await preparePrincipalHistoryEvidencePage({\n indexRootHash: appended.value.indexRootHash,\n scopeId: progress.scopeId,\n organizationId: input.organizationId,\n entries,\n nodes: appended.value.indexNodes,\n }),\n previousProgress: progress.saved?.progress ?? null,\n stillCurrent,\n });\n assertProjectionVerificationCurrent(stillCurrent);\n return {\n ...progress,\n afterVersion: row.afterVersion,\n saved,\n authorityReference: publicHistoryAuthorityReference(\n progress.authorityReference,\n references,\n ),\n completedHead: complete ? input.source.head : null,\n };\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { createPrincipalPolicyHistoryVerifier, KeyingVerificationError, restorePrincipalPolicyHistoryVerifier, serializeKeyingCanonicalJson, verifyPrincipalPolicyHistoryReferences, } from "../../../internal/crypto/index.js";
2
2
  import { isReferencedPrincipalStateResponse } from "../../../internal/validators/response/index.js";
3
- import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistoryEvidencePersistence.js";
4
- import { discardPrincipalHistoryPrefix, loadPrincipalHistoryPrefix, savePrincipalHistoryPrefix, } from "../../../data/persistence/principalHistoryPrefixPersistence.js";
5
- import { discardPrincipalHistoryStage, loadPrincipalHistoryStage, } from "../../../data/persistence/principalHistoryStagePersistence.js";
3
+ import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistory/principalHistoryEvidencePersistence.js";
4
+ import { discardPrincipalHistoryPrefix, loadPrincipalHistoryPrefix, savePrincipalHistoryPrefix, } from "../../../data/persistence/principalHistory/principalHistoryPrefixPersistence.js";
5
+ import { discardPrincipalHistoryStage, loadPrincipalHistoryStage, } from "../../../data/persistence/principalHistory/principalHistoryStagePersistence.js";
6
6
  import { principalHeadMatchesReference } from "../../../data/principals/organizationAuthorityDescriptor.js";
7
7
  import { principalHistoryEvidenceScopeId, principalHistoryPrefixProtection, } from "../../../data/principals/principalHistoryPrefixProtection.js";
8
8
  import { principalHistoryStageId, principalHistoryStageProtection, } from "../../../data/principals/principalHistoryStageProtection.js";
@@ -1 +1 @@
1
- {"version":3,"file":"publicPrincipalHistoryProgress.js","sourceRoot":"","sources":["publicPrincipalHistoryProgress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,qCAAqC,EACrC,4BAA4B,EAE5B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAE1B,0BAA0B,GAC3B,MAAM,6DAA6D,CAAC;AACrE,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,4DAA4D,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,+BAA+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AW,EAAE,0BAA0B,CAAC,QAAQ,CAAC,kBAAkB,CAAC;KACrE,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,cAAc,CACnD,MAAM,gCAAgC,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CACjE,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,MAAM,QAAQ,GACZ,cAAc;QACd,CAAC,QAAQ,CAAC,YAAY;YACpB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,MAAM,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;IAC1E,MAAM,0BAA0B,CAAC;QAC/B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;QAC7C,YAAY;QACZ,cAAc,EAAE,QAAQ;KACzB,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,KAAK;QAChB,MAAM,4BAA4B,CAChC,KAAK,CAAC,OAAO,EACb,QAAQ,CAAC,KAAK,EACd,YAAY,CACb,CAAC;AACN,CAAC","sourcesContent":["import {\n createPrincipalPolicyHistoryVerifier,\n KeyingVerificationError,\n restorePrincipalPolicyHistoryVerifier,\n serializeKeyingCanonicalJson,\n type VerifiedPrincipalPolicyHistory,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { isReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistoryEvidencePersistence\";\nimport {\n discardPrincipalHistoryPrefix,\n loadPrincipalHistoryPrefix,\n type PrincipalHistoryPrefix,\n savePrincipalHistoryPrefix,\n} from \"../../../data/persistence/principalHistoryPrefixPersistence\";\nimport {\n discardPrincipalHistoryStage,\n loadPrincipalHistoryStage,\n} from \"../../../data/persistence/principalHistoryStagePersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport {\n principalHistoryEvidenceScopeId,\n principalHistoryPrefixProtection,\n} from \"../../../data/principals/principalHistoryPrefixProtection\";\nimport {\n principalHistoryStageId,\n principalHistoryStageProtection,\n} from \"../../../data/principals/principalHistoryStageProtection\";\nimport {\n PublicHistoryAuthorityUnavailableError,\n parsePublicHistoryAuthority,\n publicHistoryAuthorityJson,\n validatePublicHistoryAuthority,\n} from \"./publicPrincipalHistoryAuthority\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryTypes\";\n\nasync function restorePublicPrefix(\n input: PublicPrincipalHistoryOptions,\n scopeId: string,\n id: string,\n prefix: PrincipalHistoryPrefix | null,\n): Promise<PublicPrincipalHistoryProgress | null> {\n const head = input.source.head;\n const historyInput = {\n principalType: head.principalType,\n principalId: head.principalId,\n };\n const current = () => !input.signal?.aborted && input.stillCurrent();\n if (prefix) {\n const authorityReference = parsePublicHistoryAuthority(\n input,\n prefix.currentJson,\n );\n let prefixHead: unknown;\n try {\n prefixHead = JSON.parse(prefix.headJson);\n } catch {\n prefixHead = null;\n }\n if (\n prefix.organizationId === input.organizationId &&\n authorityReference !== undefined &&\n isReferencedPrincipalStateResponse(prefixHead) &&\n prefixHead.principalId === head.principalId &&\n prefixHead.principalType === head.principalType &&\n prefixHead.version === prefix.version\n ) {\n const restored = await restorePrincipalPolicyHistoryVerifier(\n historyInput,\n prefix.progress,\n await principalHistoryPrefixProtection(input.protection, prefix),\n );\n if (restored.ok && restored.value.finish(prefixHead).ok) {\n await validatePublicHistoryAuthority(input, authorityReference, prefix);\n return {\n id,\n scopeId,\n verifier: restored.value,\n completedHead: prefixHead.version >= head.version ? prefixHead : null,\n afterVersion: Math.min(prefixHead.version, head.version - 1),\n saved: null,\n cachedPrefix: prefix,\n authorityReference,\n };\n }\n }\n if (!input.offline)\n await discardPrincipalHistoryPrefix({\n execSql: input.execSql,\n prefix,\n stillCurrent: current,\n });\n }\n return null;\n}\n\nexport async function restorePublicPrincipalHistoryProgress(\n input: PublicPrincipalHistoryOptions,\n allowReuse: boolean,\n): Promise<PublicPrincipalHistoryProgress> {\n const head = input.source.head;\n const historyInput = {\n principalType: head.principalType,\n principalId: head.principalId,\n };\n const scopeId = await principalHistoryEvidenceScopeId({\n organizationId: input.organizationId,\n head,\n protection: input.protection,\n });\n const id = await principalHistoryStageId(\n input.organizationId,\n head,\n input.protection.context,\n );\n const current = () => !input.signal?.aborted && input.stillCurrent();\n const saved = await loadPrincipalHistoryStage(input.execSql, id);\n if (saved) {\n const authorityReference = parsePublicHistoryAuthority(\n input,\n saved.currentJson,\n );\n if (\n allowReuse &&\n saved.organizationId === input.organizationId &&\n authorityReference !== undefined\n ) {\n const restored = await restorePrincipalPolicyHistoryVerifier(\n historyInput,\n saved.progress,\n await principalHistoryStageProtection(input.protection, head, saved),\n );\n if (restored.ok && (!saved.complete || restored.value.finish(head).ok)) {\n await validatePublicHistoryAuthority(input, authorityReference);\n return {\n id,\n scopeId,\n verifier: restored.value,\n completedHead: saved.complete ? head : null,\n afterVersion: saved.afterVersion,\n saved,\n cachedPrefix: null,\n authorityReference,\n };\n }\n }\n if (!input.offline)\n await discardPrincipalHistoryStage(input.execSql, saved, current);\n }\n if (allowReuse) {\n const prefix = await restorePublicPrefix(\n input,\n scopeId,\n id,\n await loadPrincipalHistoryPrefix(input.execSql, scopeId),\n );\n if (prefix) return prefix;\n }\n return {\n id,\n scopeId,\n verifier: createPrincipalPolicyHistoryVerifier(historyInput),\n completedHead: null,\n afterVersion: 0,\n saved: null,\n cachedPrefix: null,\n authorityReference: null,\n };\n}\n\n/** A resumed stage may finish after the reader that rejected the prefix exits. */\nasync function rejectedCompletedPrefix(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n history: VerifiedPrincipalPolicyHistory,\n): Promise<PrincipalHistoryPrefix | null> {\n const candidate = await loadPrincipalHistoryPrefix(\n input.execSql,\n progress.scopeId,\n );\n if (!candidate || candidate.version <= history.currentEntry.state.version)\n return null;\n try {\n const cached = await restorePublicPrefix(\n input,\n progress.scopeId,\n progress.id,\n candidate,\n );\n if (!cached?.completedHead) return null;\n const finished = cached.verifier.finish(cached.completedHead);\n if (!finished.ok) throw finished.error;\n const proof = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId: progress.scopeId,\n history: finished.value,\n version: input.source.head.version,\n });\n const verified = await verifyPrincipalPolicyHistoryReferences({\n history: finished.value,\n references: [proof],\n });\n if (!verified.ok) throw verified.error;\n return principalHeadMatchesReference(proof.entry.state, input.source.head)\n ? null\n : candidate;\n } catch (error) {\n if (\n error instanceof KeyingVerificationError ||\n error instanceof PublicHistoryAuthorityUnavailableError\n )\n return candidate;\n throw error;\n }\n}\n\nexport async function publishPublicPrincipalHistoryPrefix(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n history: VerifiedPrincipalPolicyHistory,\n rejectedPrefix: PrincipalHistoryPrefix | null,\n): Promise<void> {\n const state = history.currentEntry.state;\n const head = {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n };\n const prefix = {\n scopeId: progress.scopeId,\n organizationId: input.organizationId,\n version: head.version,\n headJson: serializeKeyingCanonicalJson(head),\n currentJson: publicHistoryAuthorityJson(progress.authorityReference),\n };\n const sealed = await progress.verifier.exportProgress(\n await principalHistoryPrefixProtection(input.protection, prefix),\n );\n if (!sealed.ok) throw sealed.error;\n const rejected =\n rejectedPrefix ??\n (progress.cachedPrefix\n ? null\n : await rejectedCompletedPrefix(input, progress, history));\n const stillCurrent = () => !input.signal?.aborted && input.stillCurrent();\n await savePrincipalHistoryPrefix({\n indexRootHash: history.indexRootHash,\n execSql: input.execSql,\n prefix: { ...prefix, progress: sealed.value },\n stillCurrent,\n rejectedPrefix: rejected,\n });\n if (progress.saved)\n await discardPrincipalHistoryStage(\n input.execSql,\n progress.saved,\n stillCurrent,\n );\n}\n"]}
1
+ {"version":3,"file":"publicPrincipalHistoryProgress.js","sourceRoot":"","sources":["publicPrincipalHistoryProgress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,qCAAqC,EACrC,4BAA4B,EAE5B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gFAAgF,CAAC;AAC/H,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAE1B,0BAA0B,GAC3B,MAAM,8EAA8E,CAAC;AACtF,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,6EAA6E,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAChC,MAAM,0DAA0D,CAAC;AAClE,OAAO,EACL,sCAAsC,EACtC,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAM3C,KAAK,UAAU,mBAAmB,CAChC,KAAoC,EACpC,OAAe,EACf,EAAU,EACV,MAAqC;IAErC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAC/B,MAAM,YAAY,GAAG;QACnB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,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AAC,MAAM,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;IAC1E,MAAM,0BAA0B,CAAC;QAC/B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;QAC7C,YAAY;QACZ,cAAc,EAAE,QAAQ;KACzB,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,KAAK;QAChB,MAAM,4BAA4B,CAChC,KAAK,CAAC,OAAO,EACb,QAAQ,CAAC,KAAK,EACd,YAAY,CACb,CAAC;AACN,CAAC","sourcesContent":["import {\n createPrincipalPolicyHistoryVerifier,\n KeyingVerificationError,\n restorePrincipalPolicyHistoryVerifier,\n serializeKeyingCanonicalJson,\n type VerifiedPrincipalPolicyHistory,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { isReferencedPrincipalStateResponse } from \"@tearleads/validators/response\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistory/principalHistoryEvidencePersistence\";\nimport {\n discardPrincipalHistoryPrefix,\n loadPrincipalHistoryPrefix,\n type PrincipalHistoryPrefix,\n savePrincipalHistoryPrefix,\n} from \"../../../data/persistence/principalHistory/principalHistoryPrefixPersistence\";\nimport {\n discardPrincipalHistoryStage,\n loadPrincipalHistoryStage,\n} from \"../../../data/persistence/principalHistory/principalHistoryStagePersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport {\n principalHistoryEvidenceScopeId,\n principalHistoryPrefixProtection,\n} from \"../../../data/principals/principalHistoryPrefixProtection\";\nimport {\n principalHistoryStageId,\n principalHistoryStageProtection,\n} from \"../../../data/principals/principalHistoryStageProtection\";\nimport {\n PublicHistoryAuthorityUnavailableError,\n parsePublicHistoryAuthority,\n publicHistoryAuthorityJson,\n validatePublicHistoryAuthority,\n} from \"./publicPrincipalHistoryAuthority\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryTypes\";\n\nasync function restorePublicPrefix(\n input: PublicPrincipalHistoryOptions,\n scopeId: string,\n id: string,\n prefix: PrincipalHistoryPrefix | null,\n): Promise<PublicPrincipalHistoryProgress | null> {\n const head = input.source.head;\n const historyInput = {\n principalType: head.principalType,\n principalId: head.principalId,\n };\n const current = () => !input.signal?.aborted && input.stillCurrent();\n if (prefix) {\n const authorityReference = parsePublicHistoryAuthority(\n input,\n prefix.currentJson,\n );\n let prefixHead: unknown;\n try {\n prefixHead = JSON.parse(prefix.headJson);\n } catch {\n prefixHead = null;\n }\n if (\n prefix.organizationId === input.organizationId &&\n authorityReference !== undefined &&\n isReferencedPrincipalStateResponse(prefixHead) &&\n prefixHead.principalId === head.principalId &&\n prefixHead.principalType === head.principalType &&\n prefixHead.version === prefix.version\n ) {\n const restored = await restorePrincipalPolicyHistoryVerifier(\n historyInput,\n prefix.progress,\n await principalHistoryPrefixProtection(input.protection, prefix),\n );\n if (restored.ok && restored.value.finish(prefixHead).ok) {\n await validatePublicHistoryAuthority(input, authorityReference, prefix);\n return {\n id,\n scopeId,\n verifier: restored.value,\n completedHead: prefixHead.version >= head.version ? prefixHead : null,\n afterVersion: Math.min(prefixHead.version, head.version - 1),\n saved: null,\n cachedPrefix: prefix,\n authorityReference,\n };\n }\n }\n if (!input.offline)\n await discardPrincipalHistoryPrefix({\n execSql: input.execSql,\n prefix,\n stillCurrent: current,\n });\n }\n return null;\n}\n\nexport async function restorePublicPrincipalHistoryProgress(\n input: PublicPrincipalHistoryOptions,\n allowReuse: boolean,\n): Promise<PublicPrincipalHistoryProgress> {\n const head = input.source.head;\n const historyInput = {\n principalType: head.principalType,\n principalId: head.principalId,\n };\n const scopeId = await principalHistoryEvidenceScopeId({\n organizationId: input.organizationId,\n head,\n protection: input.protection,\n });\n const id = await principalHistoryStageId(\n input.organizationId,\n head,\n input.protection.context,\n );\n const current = () => !input.signal?.aborted && input.stillCurrent();\n const saved = await loadPrincipalHistoryStage(input.execSql, id);\n if (saved) {\n const authorityReference = parsePublicHistoryAuthority(\n input,\n saved.currentJson,\n );\n if (\n allowReuse &&\n saved.organizationId === input.organizationId &&\n authorityReference !== undefined\n ) {\n const restored = await restorePrincipalPolicyHistoryVerifier(\n historyInput,\n saved.progress,\n await principalHistoryStageProtection(input.protection, head, saved),\n );\n if (restored.ok && (!saved.complete || restored.value.finish(head).ok)) {\n await validatePublicHistoryAuthority(input, authorityReference);\n return {\n id,\n scopeId,\n verifier: restored.value,\n completedHead: saved.complete ? head : null,\n afterVersion: saved.afterVersion,\n saved,\n cachedPrefix: null,\n authorityReference,\n };\n }\n }\n if (!input.offline)\n await discardPrincipalHistoryStage(input.execSql, saved, current);\n }\n if (allowReuse) {\n const prefix = await restorePublicPrefix(\n input,\n scopeId,\n id,\n await loadPrincipalHistoryPrefix(input.execSql, scopeId),\n );\n if (prefix) return prefix;\n }\n return {\n id,\n scopeId,\n verifier: createPrincipalPolicyHistoryVerifier(historyInput),\n completedHead: null,\n afterVersion: 0,\n saved: null,\n cachedPrefix: null,\n authorityReference: null,\n };\n}\n\n/** A resumed stage may finish after the reader that rejected the prefix exits. */\nasync function rejectedCompletedPrefix(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n history: VerifiedPrincipalPolicyHistory,\n): Promise<PrincipalHistoryPrefix | null> {\n const candidate = await loadPrincipalHistoryPrefix(\n input.execSql,\n progress.scopeId,\n );\n if (!candidate || candidate.version <= history.currentEntry.state.version)\n return null;\n try {\n const cached = await restorePublicPrefix(\n input,\n progress.scopeId,\n progress.id,\n candidate,\n );\n if (!cached?.completedHead) return null;\n const finished = cached.verifier.finish(cached.completedHead);\n if (!finished.ok) throw finished.error;\n const proof = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId: progress.scopeId,\n history: finished.value,\n version: input.source.head.version,\n });\n const verified = await verifyPrincipalPolicyHistoryReferences({\n history: finished.value,\n references: [proof],\n });\n if (!verified.ok) throw verified.error;\n return principalHeadMatchesReference(proof.entry.state, input.source.head)\n ? null\n : candidate;\n } catch (error) {\n if (\n error instanceof KeyingVerificationError ||\n error instanceof PublicHistoryAuthorityUnavailableError\n )\n return candidate;\n throw error;\n }\n}\n\nexport async function publishPublicPrincipalHistoryPrefix(\n input: PublicPrincipalHistoryOptions,\n progress: PublicPrincipalHistoryProgress,\n history: VerifiedPrincipalPolicyHistory,\n rejectedPrefix: PrincipalHistoryPrefix | null,\n): Promise<void> {\n const state = history.currentEntry.state;\n const head = {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n };\n const prefix = {\n scopeId: progress.scopeId,\n organizationId: input.organizationId,\n version: head.version,\n headJson: serializeKeyingCanonicalJson(head),\n currentJson: publicHistoryAuthorityJson(progress.authorityReference),\n };\n const sealed = await progress.verifier.exportProgress(\n await principalHistoryPrefixProtection(input.protection, prefix),\n );\n if (!sealed.ok) throw sealed.error;\n const rejected =\n rejectedPrefix ??\n (progress.cachedPrefix\n ? null\n : await rejectedCompletedPrefix(input, progress, history));\n const stillCurrent = () => !input.signal?.aborted && input.stillCurrent();\n await savePrincipalHistoryPrefix({\n indexRootHash: history.indexRootHash,\n execSql: input.execSql,\n prefix: { ...prefix, progress: sealed.value },\n stillCurrent,\n rejectedPrefix: rejected,\n });\n if (progress.saved)\n await discardPrincipalHistoryStage(\n input.execSql,\n progress.saved,\n stillCurrent,\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { PrincipalPolicyExternalAuthority, PrincipalPolicyHistoryProgressOptions, PrincipalPolicyHistoryVerifier, ReferencedPrincipalHead, VerifiedPrincipalPolicyHistory } from "../../../internal/crypto/index.js";
2
2
  import type { PrincipalPolicyHistorySourceResponse } from "../../../internal/validators/response/index.js";
3
- import type { PrincipalHistoryPrefix } from "../../../data/persistence/principalHistoryPrefixPersistence.js";
4
- import type { PrincipalHistoryStage } from "../../../data/persistence/principalHistoryStagePersistence.js";
3
+ import type { PrincipalHistoryPrefix } from "../../../data/persistence/principalHistory/principalHistoryPrefixPersistence.js";
4
+ import type { PrincipalHistoryStage } from "../../../data/persistence/principalHistory/principalHistoryStagePersistence.js";
5
5
  import type { ExecSql } from "../../../data/sqlite/sqlSchema.js";
6
6
  import type { TrustedUserIdentityResolver } from "../../../data/trustedUserIdentity/index.js";
7
7
  import type { ProjectionPolicyHistoryReader } from "../principalPolicyHistoryReader.js";
@@ -1 +1 @@
1
- {"version":3,"file":"publicPrincipalHistoryTypes.js","sourceRoot":"","sources":["publicPrincipalHistoryTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n PrincipalPolicyExternalAuthority,\n PrincipalPolicyHistoryProgressOptions,\n PrincipalPolicyHistoryVerifier,\n ReferencedPrincipalHead,\n VerifiedPrincipalPolicyHistory,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicyHistorySourceResponse } from \"@tearleads/validators/response\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistoryPrefixPersistence\";\nimport type { PrincipalHistoryStage } from \"../../../data/persistence/principalHistoryStagePersistence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../data/trustedUserIdentity\";\nimport type { ProjectionPolicyHistoryReader } from \"../principalPolicyHistoryReader\";\n\nexport interface PublicPrincipalHistoryOptions {\n readonly historyReader: ProjectionPolicyHistoryReader;\n /** Terminal proof verification defers durable currency until all artifacts authenticate. */\n readonly historicalProof?: boolean | undefined;\n readonly source: PrincipalPolicyHistorySourceResponse;\n readonly organizationId: string;\n readonly execSql: ExecSql;\n readonly protection: PrincipalPolicyHistoryProgressOptions;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n readonly stillCurrent: () => boolean;\n readonly signal?: AbortSignal | undefined;\n readonly offline?: boolean | undefined;\n /** Retry disposable evidence loss once from signatures, without reusing hints. */\n readonly replay?: boolean | undefined;\n readonly strictAdmins?: boolean | undefined;\n /** Already verified organization binding; included in the protected cache scope. */\n readonly authorityGroupId?: string | undefined;\n readonly loadExternalAuthority?:\n | ((\n references: readonly ReferencedPrincipalHead[],\n cachedPrefix?: boolean,\n ) => Promise<PrincipalPolicyExternalAuthority | undefined>)\n | undefined;\n}\n\nexport interface PublicPrincipalHistoryProgress {\n readonly id: string;\n readonly scopeId: string;\n readonly verifier: PrincipalPolicyHistoryVerifier;\n readonly completedHead: ReferencedPrincipalHead | null;\n readonly afterVersion: number;\n readonly saved: PrincipalHistoryStage | null;\n readonly cachedPrefix: PrincipalHistoryPrefix | null;\n readonly authorityReference: ReferencedPrincipalHead | null;\n}\n\n/** Public authorization only; caller must check directory binding and local pins. */\nexport interface RecoveredPublicPrincipalHistory {\n readonly scopeId: string;\n readonly history: VerifiedPrincipalPolicyHistory;\n}\n"]}
1
+ {"version":3,"file":"publicPrincipalHistoryTypes.js","sourceRoot":"","sources":["publicPrincipalHistoryTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n PrincipalPolicyExternalAuthority,\n PrincipalPolicyHistoryProgressOptions,\n PrincipalPolicyHistoryVerifier,\n ReferencedPrincipalHead,\n VerifiedPrincipalPolicyHistory,\n} from \"@tearleads/crypto\";\nimport type { PrincipalPolicyHistorySourceResponse } from \"@tearleads/validators/response\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistory/principalHistoryPrefixPersistence\";\nimport type { PrincipalHistoryStage } from \"../../../data/persistence/principalHistory/principalHistoryStagePersistence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../data/trustedUserIdentity\";\nimport type { ProjectionPolicyHistoryReader } from \"../principalPolicyHistoryReader\";\n\nexport interface PublicPrincipalHistoryOptions {\n readonly historyReader: ProjectionPolicyHistoryReader;\n /** Terminal proof verification defers durable currency until all artifacts authenticate. */\n readonly historicalProof?: boolean | undefined;\n readonly source: PrincipalPolicyHistorySourceResponse;\n readonly organizationId: string;\n readonly execSql: ExecSql;\n readonly protection: PrincipalPolicyHistoryProgressOptions;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n readonly stillCurrent: () => boolean;\n readonly signal?: AbortSignal | undefined;\n readonly offline?: boolean | undefined;\n /** Retry disposable evidence loss once from signatures, without reusing hints. */\n readonly replay?: boolean | undefined;\n readonly strictAdmins?: boolean | undefined;\n /** Already verified organization binding; included in the protected cache scope. */\n readonly authorityGroupId?: string | undefined;\n readonly loadExternalAuthority?:\n | ((\n references: readonly ReferencedPrincipalHead[],\n cachedPrefix?: boolean,\n ) => Promise<PrincipalPolicyExternalAuthority | undefined>)\n | undefined;\n}\n\nexport interface PublicPrincipalHistoryProgress {\n readonly id: string;\n readonly scopeId: string;\n readonly verifier: PrincipalPolicyHistoryVerifier;\n readonly completedHead: ReferencedPrincipalHead | null;\n readonly afterVersion: number;\n readonly saved: PrincipalHistoryStage | null;\n readonly cachedPrefix: PrincipalHistoryPrefix | null;\n readonly authorityReference: ReferencedPrincipalHead | null;\n}\n\n/** Public authorization only; caller must check directory binding and local pins. */\nexport interface RecoveredPublicPrincipalHistory {\n readonly scopeId: string;\n readonly history: VerifiedPrincipalPolicyHistory;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { KeyingVerificationError, } from "../../../internal/crypto/index.js";
2
2
  import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
3
- import { loadPrincipalPolicyCheckpoint } from "../../../data/persistence/keyingCheckpointPersistence.js";
3
+ import { loadPrincipalPolicyCheckpoint } from "../../../data/persistence/keyingCheckpoints/keyingCheckpointPersistence.js";
4
4
  import { PrincipalHistoryEvidenceUnavailableError } from "../historyRecovery/principalHistoryRecoveryReferences.js";
5
5
  import { recoverPublicPrincipalHistory } from "./recoverPublicPrincipalHistory.js";
6
6
  import { selectPublicPrincipalHistory } from "./selectPublicPrincipalHistory.js";
@@ -1 +1 @@
1
- {"version":3,"file":"publicProjectionPrincipal.js","sourceRoot":"","sources":["publicProjectionPrincipal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,EAAE,wCAAwC,EAAE,MAAM,uDAAuD,CAAC;AAKjH,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAS9E,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,SAAoC,EACpC,aAAiD,SAAS,CAAC,UAAU;IAErE,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;IAC9B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IACzE,mCAAmC,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,MAAM,6BAA6B,CACpD,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EACjC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAChC,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,4BAA4B,CAAC;YACxC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,CA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K;KAChB,CAAC;IACF,MAAM,+BAA+B,CAAC,SAAS,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,8BAA8B,OAAO,EAAE,CACxC,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../../data/persistence/keyingCheckpointPersistence\";\nimport { PrincipalHistoryEvidenceUnavailableError } from \"../historyRecovery/principalHistoryRecoveryReferences\";\nimport type {\n PublicPrincipalHistoryOptions,\n RecoveredPublicPrincipalHistory,\n} from \"./publicPrincipalHistoryTypes\";\nimport { recoverPublicPrincipalHistory } from \"./recoverPublicPrincipalHistory\";\nimport { selectPublicPrincipalHistory } from \"./selectPublicPrincipalHistory\";\n\nexport interface PublicProjectionPrincipal {\n readonly options: PublicPrincipalHistoryOptions;\n readonly references: readonly ReferencedPrincipalHead[];\n recovered: RecoveredPublicPrincipalHistory;\n replayed: boolean;\n}\n\n/** The source head and every citation remain bound independently of a newer prefix. */\nexport async function selectPublicProjectionPrincipal(\n principal: PublicProjectionPrincipal,\n references: readonly ReferencedPrincipalHead[] = principal.references,\n) {\n const { options } = principal;\n const current = () => !options.signal?.aborted && options.stillCurrent();\n assertProjectionVerificationCurrent(current);\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n options.execSql,\n options.source.head.principalType,\n options.source.head.principalId,\n );\n try {\n return await selectPublicPrincipalHistory({\n execSql: options.execSql,\n recovered: principal.recovered,\n references: [options.source.head, ...references],\n checkpoint,\n deferCheckpointCheck: options.historicalProof,\n includeGenesis: options.source.head.principalType === \"organization\",\n stillCurrent: current,\n });\n } catch (error) {\n if (!(error instanceof PrincipalHistoryEvidenceUnavailableError))\n throw error;\n if (options.offline || principal.replayed) throw error.verificationError;\n principal.replayed = true;\n principal.recovered = await recoverPublicPrincipalHistory({\n ...options,\n replay: true,\n });\n return selectPublicProjectionPrincipal(principal, references);\n }\n}\n\nexport async function recoverPublicProjectionPrincipal(\n options: PublicPrincipalHistoryOptions,\n references: readonly ReferencedPrincipalHead[],\n): Promise<PublicProjectionPrincipal> {\n const selected = references.filter(\n (head) =>\n head.principalType === options.source.head.principalType &&\n head.principalId === options.source.head.principalId,\n );\n if (selected.some((head) => head.version > options.source.head.version))\n rejectPublicProjection(\"citation exceeds its supplied source head\");\n const principal = {\n options,\n references: structuredClone(selected),\n recovered: await recoverPublicPrincipalHistory(options),\n replayed: false,\n };\n await selectPublicProjectionPrincipal(principal);\n return principal;\n}\n\nexport function rejectPublicProjection(message: string): never {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n `Public projection history: ${message}`,\n );\n}\n"]}
1
+ {"version":3,"file":"publicProjectionPrincipal.js","sourceRoot":"","sources":["publicProjectionPrincipal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yEAAyE,CAAC;AACxH,OAAO,EAAE,wCAAwC,EAAE,MAAM,uDAAuD,CAAC;AAKjH,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAS9E,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,SAAoC,EACpC,aAAiD,SAAS,CAAC,UAAU;IAErE,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;IAC9B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAC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CAAC,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CACvD,CAAC;IACF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACrE,sBAAsB,CAAC,2CAA2C,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG;QAChB,OAAO;QACP,UAAU,EAAE,eAAe,CAAC,QAAQ,CAAC;QACrC,SAAS,EAAE,MAAM,6BAA6B,CAAC,OAAO,CAAC;QACvD,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,MAAM,+BAA+B,CAAC,SAAS,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,8BAA8B,OAAO,EAAE,CACxC,CAAC;AACJ,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalPolicyCheckpoint } from \"../../../data/persistence/keyingCheckpoints/keyingCheckpointPersistence\";\nimport { PrincipalHistoryEvidenceUnavailableError } from \"../historyRecovery/principalHistoryRecoveryReferences\";\nimport type {\n PublicPrincipalHistoryOptions,\n RecoveredPublicPrincipalHistory,\n} from \"./publicPrincipalHistoryTypes\";\nimport { recoverPublicPrincipalHistory } from \"./recoverPublicPrincipalHistory\";\nimport { selectPublicPrincipalHistory } from \"./selectPublicPrincipalHistory\";\n\nexport interface PublicProjectionPrincipal {\n readonly options: PublicPrincipalHistoryOptions;\n readonly references: readonly ReferencedPrincipalHead[];\n recovered: RecoveredPublicPrincipalHistory;\n replayed: boolean;\n}\n\n/** The source head and every citation remain bound independently of a newer prefix. */\nexport async function selectPublicProjectionPrincipal(\n principal: PublicProjectionPrincipal,\n references: readonly ReferencedPrincipalHead[] = principal.references,\n) {\n const { options } = principal;\n const current = () => !options.signal?.aborted && options.stillCurrent();\n assertProjectionVerificationCurrent(current);\n const checkpoint = await loadPrincipalPolicyCheckpoint(\n options.execSql,\n options.source.head.principalType,\n options.source.head.principalId,\n );\n try {\n return await selectPublicPrincipalHistory({\n execSql: options.execSql,\n recovered: principal.recovered,\n references: [options.source.head, ...references],\n checkpoint,\n deferCheckpointCheck: options.historicalProof,\n includeGenesis: options.source.head.principalType === \"organization\",\n stillCurrent: current,\n });\n } catch (error) {\n if (!(error instanceof PrincipalHistoryEvidenceUnavailableError))\n throw error;\n if (options.offline || principal.replayed) throw error.verificationError;\n principal.replayed = true;\n principal.recovered = await recoverPublicPrincipalHistory({\n ...options,\n replay: true,\n });\n return selectPublicProjectionPrincipal(principal, references);\n }\n}\n\nexport async function recoverPublicProjectionPrincipal(\n options: PublicPrincipalHistoryOptions,\n references: readonly ReferencedPrincipalHead[],\n): Promise<PublicProjectionPrincipal> {\n const selected = references.filter(\n (head) =>\n head.principalType === options.source.head.principalType &&\n head.principalId === options.source.head.principalId,\n );\n if (selected.some((head) => head.version > options.source.head.version))\n rejectPublicProjection(\"citation exceeds its supplied source head\");\n const principal = {\n options,\n references: structuredClone(selected),\n recovered: await recoverPublicPrincipalHistory(options),\n replayed: false,\n };\n await selectPublicProjectionPrincipal(principal);\n return principal;\n}\n\nexport function rejectPublicProjection(message: string): never {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n `Public projection history: ${message}`,\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { createPrincipalPolicyHistoryVerifier, KeyingVerificationError, serializeKeyingCanonicalJson, verifyPrincipalPolicyHistoryReferences, } from "../../../internal/crypto/index.js";
2
2
  import { isPrincipalPolicySnapshotPageResponse, } from "../../../internal/validators/response/index.js";
3
3
  import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
4
- import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistoryEvidencePersistence.js";
4
+ import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistory/principalHistoryEvidencePersistence.js";
5
5
  import { principalHeadMatchesReference } from "../../../data/principals/organizationAuthorityDescriptor.js";
6
6
  import { ownPrincipalHistoryProtection } from "../../../data/principals/principalHistoryProtection.js";
7
7
  import { PrincipalPolicyHistoryReadError } from "../historyRecovery/principalHistoryRecoveryTypes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"recoverPublicPrincipalHistory.js","sourceRoot":"","sources":["recoverPublicPrincipalHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAEvB,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qCAAqC,GAEtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAE9G,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EAAE,sCAAsC,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EACL,gCAAgC,EAChC,6CAA6C,GAC9C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,kCAAkC,CAAC;AAO1C,SAAS,UAAU,CACjB,KAAoC,EACpC,IAAyC,EACzC,KAAa;IAEb,IACE,CAAC,qCAAqC,CAAC,IAAI,CAAC;QAC5C,CAAC,6BAA6B,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QACpE,IAAI,CAAC,WAAW,CAAC,YAAY,KAAK,KAAK;QAEvC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a,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa;QAChD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW;QAC5C,kBAAkB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;KAC1C,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,6BAA6B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrE,UAAU,CAAC,OAAO,GAAG,4BAA4B,CAAC;QAChD,2CAA2C;QAC3C,UAAU,CAAC,OAAO;QAClB,OAAO,CAAC,YAAY,KAAK,IAAI;QAC7B,OAAO,CAAC,gBAAgB,IAAI,IAAI;KACjC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG;QACZ,GAAG,OAAO;QACV,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC;QACvC,UAAU;KACX,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC","sourcesContent":["import {\n createPrincipalPolicyHistoryVerifier,\n KeyingVerificationError,\n type PrincipalPolicyHistoryReferenceProof,\n serializeKeyingCanonicalJson,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport {\n isPrincipalPolicySnapshotPageResponse,\n type PrincipalPolicySnapshotPageResponse,\n} from \"@tearleads/validators/response\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistoryEvidencePersistence\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistoryPrefixPersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { ownPrincipalHistoryProtection } from \"../../../data/principals/principalHistoryProtection\";\nimport { PrincipalPolicyHistoryReadError } from \"../historyRecovery/principalHistoryRecoveryTypes\";\nimport { PublicHistoryAuthorityUnavailableError } from \"./publicPrincipalHistoryAuthority\";\nimport {\n appendPublicPrincipalHistoryPage,\n PublicPrincipalHistoryPrefixDisconnectedError,\n} from \"./publicPrincipalHistoryPage\";\nimport {\n publishPublicPrincipalHistoryPrefix,\n restorePublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryProgress\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n RecoveredPublicPrincipalHistory,\n} from \"./publicPrincipalHistoryTypes\";\n\nfunction assertPage(\n input: PublicPrincipalHistoryOptions,\n page: PrincipalPolicySnapshotPageResponse,\n after: number,\n): void {\n if (\n !isPrincipalPolicySnapshotPageResponse(page) ||\n !principalHeadMatchesReference(page.currentState, input.source.head) ||\n page.historyPage.afterVersion !== after\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history page does not match its requested head and cursor\",\n );\n const through = after + page.previousStates.length;\n if (\n page.previousStates.some(\n ({ state }, index) => state.version !== after + index + 1,\n ) ||\n through >= input.source.head.version ||\n (page.historyPage.nextAfterVersion === null\n ? through !== input.source.head.version - 1\n : through <= after || page.historyPage.nextAfterVersion !== through)\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Public history page has a gap or invalid continuation\",\n );\n}\n\nasync function readPublicPages(\n input: PublicPrincipalHistoryOptions,\n initial: PublicPrincipalHistoryProgress,\n) {\n const current = () => !input.signal?.aborted && input.stillCurrent();\n let progress = initial;\n let lastPage: PrincipalPolicySnapshotPageResponse | undefined;\n // Completed progress already verified every signed entry through the cited\n // head; a read pinned to that head could only repeat it or refuse.\n if (!input.offline && !progress.completedHead) {\n for await (const result of input.historyReader.getProjectionPolicyHistoryPages(\n input.source,\n { afterVersion: progress.afterVersion, signal: input.signal },\n )) {\n assertProjectionVerificationCurrent(current);\n if (!result.ok) throw new PrincipalPolicyHistoryReadError(result);\n const page = result.data;\n assertPage(input, page, progress.afterVersion);\n if (progress.completedHead)\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Completed public history returned additional entries\",\n );\n progress = await appendPublicPrincipalHistoryPage(input, progress, page);\n lastPage = page;\n }\n if (lastPage?.historyPage.nextAfterVersion !== null)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Public history transport did not complete\",\n );\n }\n return { progress, lastPage };\n}\n\nfunction finishPublicProgress(progress: PublicPrincipalHistoryProgress) {\n if (!progress.completedHead)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Completed public history is unavailable\",\n );\n const finished = progress.verifier.finish(progress.completedHead);\n if (!finished.ok) throw finished.error;\n return finished.value;\n}\n\nasync function recoverAttempt(\n input: PublicPrincipalHistoryOptions,\n allowReuse = true,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<RecoveredPublicPrincipalHistory> {\n const current = () => !input.signal?.aborted && input.stillCurrent();\n assertProjectionVerificationCurrent(current);\n const mayReplay = allowReuse && !input.offline;\n const initial = await restorePublicPrincipalHistoryProgress(\n input,\n allowReuse,\n );\n let pages: Awaited<ReturnType<typeof readPublicPages>>;\n try {\n pages = await readPublicPages(input, initial);\n } catch (error) {\n if (!(error instanceof PublicPrincipalHistoryPrefixDisconnectedError))\n throw error;\n // A signed cached candidate need not belong to this requested chain. Only\n // reused progress permits one replay; a fresh disconnected chain fails.\n if (mayReplay && initial.afterVersion > 0)\n return recover(input, false, initial.cachedPrefix);\n throw error.verificationError;\n }\n const { progress, lastPage } = pages;\n const history = finishPublicProgress(progress);\n let proof: PrincipalPolicyHistoryReferenceProof;\n try {\n proof = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId: progress.scopeId,\n history,\n version: input.source.head.version,\n });\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history,\n references: [proof],\n });\n if (!selected.ok) throw selected.error;\n } catch (error) {\n if (error instanceof KeyingVerificationError && mayReplay)\n return recover(input, false, initial.cachedPrefix);\n throw error;\n }\n // Public prefixes memoize signatures; they are not admitted trust pins. A\n // rejected projection may have left a valid but unrelated signed candidate.\n // Rebuild the requested chain once online; callers still check durable pins\n // and object authority before accepting it. Never reuse a mismatch offline.\n if (!principalHeadMatchesReference(proof.entry.state, input.source.head)) {\n if (mayReplay) return recover(input, false, initial.cachedPrefix);\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history source differs from the verified prefix\",\n );\n }\n if (lastPage) {\n const currentProof = {\n ...proof,\n entry: {\n state: lastPage.currentState,\n projection: lastPage.currentProjection,\n grants: lastPage.currentGrants,\n },\n };\n const checked = await verifyPrincipalPolicyHistoryReferences({\n history,\n references: [currentProof],\n });\n if (!checked.ok) throw checked.error;\n }\n assertProjectionVerificationCurrent(current);\n if (!input.offline)\n await publishPublicPrincipalHistoryPrefix(\n input,\n progress,\n history,\n rejectedPrefix,\n );\n assertProjectionVerificationCurrent(current);\n return { scopeId: progress.scopeId, history };\n}\n\nasync function recover(\n input: PublicPrincipalHistoryOptions,\n allowReuse = true,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<RecoveredPublicPrincipalHistory> {\n try {\n return await recoverAttempt(input, allowReuse, rejectedPrefix);\n } catch (error) {\n if (!(error instanceof PublicHistoryAuthorityUnavailableError)) throw error;\n if (allowReuse && !input.offline)\n return recoverAttempt(input, false, error.rejectedPrefix);\n throw error.verificationError;\n }\n}\n\n/** Private-key-backed public history recovery; never admits a current policy pin. */\nexport async function recoverPublicPrincipalHistory(\n options: PublicPrincipalHistoryOptions,\n): Promise<RecoveredPublicPrincipalHistory> {\n if (\n !options.organizationId ||\n (options.historicalProof !== undefined &&\n typeof options.historicalProof !== \"boolean\") ||\n (options.offline !== undefined && typeof options.offline !== \"boolean\") ||\n (options.strictAdmins !== undefined &&\n typeof options.strictAdmins !== \"boolean\") ||\n (options.strictAdmins &&\n (options.source.head.principalType !== \"group\" ||\n options.loadExternalAuthority))\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Invalid public history verification scope\",\n );\n if (\n options.source.head.principalType === \"organization\" &&\n options.source.head.principalId !== options.organizationId\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public organization history is outside its scope\",\n );\n // Validate the caller's pinned head before any cache or transport access.\n createPrincipalPolicyHistoryVerifier({\n principalType: options.source.head.principalType,\n principalId: options.source.head.principalId,\n retainedReferences: [options.source.head],\n });\n const protection = ownPrincipalHistoryProtection(options.protection);\n protection.context = serializeKeyingCanonicalJson([\n \"tearleads.sdk.public-principal-history.v2\",\n protection.context,\n options.strictAdmins === true,\n options.authorityGroupId ?? null,\n ]);\n const input = {\n ...options,\n source: structuredClone(options.source),\n protection,\n };\n try {\n return await recover(input, options.replay !== true);\n } finally {\n protection.localKey.fill(0);\n }\n}\n"]}
1
+ {"version":3,"file":"recoverPublicPrincipalHistory.js","sourceRoot":"","sources":["recoverPublicPrincipalHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAEvB,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qCAAqC,GAEtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gFAAgF,CAAC;AAE/H,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EAAE,sCAAsC,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EACL,gCAAgC,EAChC,6CAA6C,GAC9C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,kCAAkC,CAAC;AAO1C,SAAS,UAAU,CACj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C,IAAI,CAAC,aAAa,KAAK,cAAc;QACpD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,KAAK,OAAO,CAAC,cAAc;QAE1D,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,kDAAkD,CACnD,CAAC;IACJ,0EAA0E;IAC1E,oCAAoC,CAAC;QACnC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa;QAChD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW;QAC5C,kBAAkB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;KAC1C,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,6BAA6B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrE,UAAU,CAAC,OAAO,GAAG,4BAA4B,CAAC;QAChD,2CAA2C;QAC3C,UAAU,CAAC,OAAO;QAClB,OAAO,CAAC,YAAY,KAAK,IAAI;QAC7B,OAAO,CAAC,gBAAgB,IAAI,IAAI;KACjC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG;QACZ,GAAG,OAAO;QACV,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC;QACvC,UAAU;KACX,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC","sourcesContent":["import {\n createPrincipalPolicyHistoryVerifier,\n KeyingVerificationError,\n type PrincipalPolicyHistoryReferenceProof,\n serializeKeyingCanonicalJson,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport {\n isPrincipalPolicySnapshotPageResponse,\n type PrincipalPolicySnapshotPageResponse,\n} from \"@tearleads/validators/response\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistory/principalHistoryEvidencePersistence\";\nimport type { PrincipalHistoryPrefix } from \"../../../data/persistence/principalHistory/principalHistoryPrefixPersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { ownPrincipalHistoryProtection } from \"../../../data/principals/principalHistoryProtection\";\nimport { PrincipalPolicyHistoryReadError } from \"../historyRecovery/principalHistoryRecoveryTypes\";\nimport { PublicHistoryAuthorityUnavailableError } from \"./publicPrincipalHistoryAuthority\";\nimport {\n appendPublicPrincipalHistoryPage,\n PublicPrincipalHistoryPrefixDisconnectedError,\n} from \"./publicPrincipalHistoryPage\";\nimport {\n publishPublicPrincipalHistoryPrefix,\n restorePublicPrincipalHistoryProgress,\n} from \"./publicPrincipalHistoryProgress\";\nimport type {\n PublicPrincipalHistoryOptions,\n PublicPrincipalHistoryProgress,\n RecoveredPublicPrincipalHistory,\n} from \"./publicPrincipalHistoryTypes\";\n\nfunction assertPage(\n input: PublicPrincipalHistoryOptions,\n page: PrincipalPolicySnapshotPageResponse,\n after: number,\n): void {\n if (\n !isPrincipalPolicySnapshotPageResponse(page) ||\n !principalHeadMatchesReference(page.currentState, input.source.head) ||\n page.historyPage.afterVersion !== after\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history page does not match its requested head and cursor\",\n );\n const through = after + page.previousStates.length;\n if (\n page.previousStates.some(\n ({ state }, index) => state.version !== after + index + 1,\n ) ||\n through >= input.source.head.version ||\n (page.historyPage.nextAfterVersion === null\n ? through !== input.source.head.version - 1\n : through <= after || page.historyPage.nextAfterVersion !== through)\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Public history page has a gap or invalid continuation\",\n );\n}\n\nasync function readPublicPages(\n input: PublicPrincipalHistoryOptions,\n initial: PublicPrincipalHistoryProgress,\n) {\n const current = () => !input.signal?.aborted && input.stillCurrent();\n let progress = initial;\n let lastPage: PrincipalPolicySnapshotPageResponse | undefined;\n // Completed progress already verified every signed entry through the cited\n // head; a read pinned to that head could only repeat it or refuse.\n if (!input.offline && !progress.completedHead) {\n for await (const result of input.historyReader.getProjectionPolicyHistoryPages(\n input.source,\n { afterVersion: progress.afterVersion, signal: input.signal },\n )) {\n assertProjectionVerificationCurrent(current);\n if (!result.ok) throw new PrincipalPolicyHistoryReadError(result);\n const page = result.data;\n assertPage(input, page, progress.afterVersion);\n if (progress.completedHead)\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Completed public history returned additional entries\",\n );\n progress = await appendPublicPrincipalHistoryPage(input, progress, page);\n lastPage = page;\n }\n if (lastPage?.historyPage.nextAfterVersion !== null)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Public history transport did not complete\",\n );\n }\n return { progress, lastPage };\n}\n\nfunction finishPublicProgress(progress: PublicPrincipalHistoryProgress) {\n if (!progress.completedHead)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Completed public history is unavailable\",\n );\n const finished = progress.verifier.finish(progress.completedHead);\n if (!finished.ok) throw finished.error;\n return finished.value;\n}\n\nasync function recoverAttempt(\n input: PublicPrincipalHistoryOptions,\n allowReuse = true,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<RecoveredPublicPrincipalHistory> {\n const current = () => !input.signal?.aborted && input.stillCurrent();\n assertProjectionVerificationCurrent(current);\n const mayReplay = allowReuse && !input.offline;\n const initial = await restorePublicPrincipalHistoryProgress(\n input,\n allowReuse,\n );\n let pages: Awaited<ReturnType<typeof readPublicPages>>;\n try {\n pages = await readPublicPages(input, initial);\n } catch (error) {\n if (!(error instanceof PublicPrincipalHistoryPrefixDisconnectedError))\n throw error;\n // A signed cached candidate need not belong to this requested chain. Only\n // reused progress permits one replay; a fresh disconnected chain fails.\n if (mayReplay && initial.afterVersion > 0)\n return recover(input, false, initial.cachedPrefix);\n throw error.verificationError;\n }\n const { progress, lastPage } = pages;\n const history = finishPublicProgress(progress);\n let proof: PrincipalPolicyHistoryReferenceProof;\n try {\n proof = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId: progress.scopeId,\n history,\n version: input.source.head.version,\n });\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history,\n references: [proof],\n });\n if (!selected.ok) throw selected.error;\n } catch (error) {\n if (error instanceof KeyingVerificationError && mayReplay)\n return recover(input, false, initial.cachedPrefix);\n throw error;\n }\n // Public prefixes memoize signatures; they are not admitted trust pins. A\n // rejected projection may have left a valid but unrelated signed candidate.\n // Rebuild the requested chain once online; callers still check durable pins\n // and object authority before accepting it. Never reuse a mismatch offline.\n if (!principalHeadMatchesReference(proof.entry.state, input.source.head)) {\n if (mayReplay) return recover(input, false, initial.cachedPrefix);\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history source differs from the verified prefix\",\n );\n }\n if (lastPage) {\n const currentProof = {\n ...proof,\n entry: {\n state: lastPage.currentState,\n projection: lastPage.currentProjection,\n grants: lastPage.currentGrants,\n },\n };\n const checked = await verifyPrincipalPolicyHistoryReferences({\n history,\n references: [currentProof],\n });\n if (!checked.ok) throw checked.error;\n }\n assertProjectionVerificationCurrent(current);\n if (!input.offline)\n await publishPublicPrincipalHistoryPrefix(\n input,\n progress,\n history,\n rejectedPrefix,\n );\n assertProjectionVerificationCurrent(current);\n return { scopeId: progress.scopeId, history };\n}\n\nasync function recover(\n input: PublicPrincipalHistoryOptions,\n allowReuse = true,\n rejectedPrefix: PrincipalHistoryPrefix | null = null,\n): Promise<RecoveredPublicPrincipalHistory> {\n try {\n return await recoverAttempt(input, allowReuse, rejectedPrefix);\n } catch (error) {\n if (!(error instanceof PublicHistoryAuthorityUnavailableError)) throw error;\n if (allowReuse && !input.offline)\n return recoverAttempt(input, false, error.rejectedPrefix);\n throw error.verificationError;\n }\n}\n\n/** Private-key-backed public history recovery; never admits a current policy pin. */\nexport async function recoverPublicPrincipalHistory(\n options: PublicPrincipalHistoryOptions,\n): Promise<RecoveredPublicPrincipalHistory> {\n if (\n !options.organizationId ||\n (options.historicalProof !== undefined &&\n typeof options.historicalProof !== \"boolean\") ||\n (options.offline !== undefined && typeof options.offline !== \"boolean\") ||\n (options.strictAdmins !== undefined &&\n typeof options.strictAdmins !== \"boolean\") ||\n (options.strictAdmins &&\n (options.source.head.principalType !== \"group\" ||\n options.loadExternalAuthority))\n )\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Invalid public history verification scope\",\n );\n if (\n options.source.head.principalType === \"organization\" &&\n options.source.head.principalId !== options.organizationId\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public organization history is outside its scope\",\n );\n // Validate the caller's pinned head before any cache or transport access.\n createPrincipalPolicyHistoryVerifier({\n principalType: options.source.head.principalType,\n principalId: options.source.head.principalId,\n retainedReferences: [options.source.head],\n });\n const protection = ownPrincipalHistoryProtection(options.protection);\n protection.context = serializeKeyingCanonicalJson([\n \"tearleads.sdk.public-principal-history.v2\",\n protection.context,\n options.strictAdmins === true,\n options.authorityGroupId ?? null,\n ]);\n const input = {\n ...options,\n source: structuredClone(options.source),\n protection,\n };\n try {\n return await recover(input, options.replay !== true);\n } finally {\n protection.localKey.fill(0);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { KeyingVerificationError, PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT, selectPrincipalPolicyAuthorization, verifyPrincipalPolicyCheckpoint, verifyPrincipalPolicyHistoryReferences, } from "../../../internal/crypto/index.js";
2
2
  import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
3
- import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistoryEvidencePersistence.js";
3
+ import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistory/principalHistoryEvidencePersistence.js";
4
4
  import { principalHeadMatchesReference } from "../../../data/principals/organizationAuthorityDescriptor.js";
5
5
  import { PrincipalHistoryEvidenceUnavailableError } from "../historyRecovery/principalHistoryRecoveryReferences.js";
6
6
  async function selectBatch(input, versions, checkpointReference) {
@@ -1 +1 @@
1
- {"version":3,"file":"selectPublicPrincipalHistory.js","sourceRoot":"","sources":["selectPublicPrincipalHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,kCAAkC,EAIlC,kCAAkC,EAElC,+BAA+B,EAC/B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AAEzG,OAAO,EAAE,wCAAwC,EAAE,MAAM,uDAAuD,CAAC;AAajH,KAAK,UAAU,WAAW,CACxB,KAAkC,EAClC,QAA2B,EAC3B,mBAAqE;IAErE,MAAM,MAAM,GAA2C,EAAE,CAAC;IAC1D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CACT,MAAM,6BAA6B,CAAC;YAClC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,KAAK,CAAC,SAAS;YAClB,OAAO;SACR,CAAC,CACH,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,sCAAsC,CAAC;QAC5D,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO;QAChC,UAAU,EAAE,MAAM;QAClB,mBAAmB;KACpB,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;IACvC,OAAO,QAAQ,CAAC,KAAK,CAAC;AACxB,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,KAAkC,EAClC,UAA4C;IAE5C,IAAI,mBAAqE,CAAC;IAC1E,IAAI,CAAC;QACH,IAAI,UAAU;YACZ,mBAAmB,GAAG,MAAM,6BAA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M,GAAG,CAAC,EACd,MAAM,GAAG,QAAQ,CAAC,MAAM,EACxB,MAAM,IAAI,kCAAkC,EAC5C,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAC1B,MAAM,EACN,MAAM,GAAG,kCAAkC,CAC5C,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,KAAK,CACzE,CAAC,KAAc,EAAE,EAAE;YACjB,IAAI,KAAK,YAAY,uBAAuB;gBAC1C,MAAM,IAAI,wCAAwC,CAAC,KAAK,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;QACd,CAAC,CACF,CAAC;QACF,uBAAuB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,MAAM,kCAAkC,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,MAAM,CAAC,KAAK,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACxD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT,\n type PrincipalPolicyCheckpoint,\n type PrincipalPolicyHistoryReferenceProof,\n type ReferencedPrincipalHead,\n selectPrincipalPolicyAuthorization,\n type VerifiedPrincipalPolicySelection,\n verifyPrincipalPolicyCheckpoint,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistoryEvidencePersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { PrincipalHistoryEvidenceUnavailableError } from \"../historyRecovery/principalHistoryRecoveryReferences\";\nimport type { RecoveredPublicPrincipalHistory } from \"./publicPrincipalHistoryTypes\";\n\ninterface PublicHistorySelectionInput {\n readonly execSql: ExecSql;\n readonly recovered: RecoveredPublicPrincipalHistory;\n readonly references: readonly ReferencedPrincipalHead[];\n readonly checkpoint: PrincipalPolicyCheckpoint | null;\n readonly deferCheckpointCheck?: boolean | undefined;\n readonly includeGenesis?: boolean;\n readonly stillCurrent: () => boolean;\n}\n\nasync function selectBatch(\n input: PublicHistorySelectionInput,\n versions: readonly number[],\n checkpointReference: PrincipalPolicyHistoryReferenceProof | undefined,\n) {\n const proofs: PrincipalPolicyHistoryReferenceProof[] = [];\n for (const version of versions) {\n assertProjectionVerificationCurrent(input.stillCurrent);\n proofs.push(\n await loadPrincipalHistoryReference({\n execSql: input.execSql,\n ...input.recovered,\n version,\n }),\n );\n }\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history: input.recovered.history,\n references: proofs,\n checkpointReference,\n });\n if (!selected.ok) throw selected.error;\n return selected.value;\n}\n\nasync function loadCheckpointProof(\n input: PublicHistorySelectionInput,\n checkpoint: PrincipalPolicyCheckpoint | null,\n): Promise<PrincipalPolicyHistoryReferenceProof | undefined> {\n let checkpointReference: PrincipalPolicyHistoryReferenceProof | undefined;\n try {\n if (checkpoint)\n checkpointReference = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n ...input.recovered,\n version: checkpoint.version,\n });\n } catch (error) {\n if (error instanceof KeyingVerificationError)\n throw new PrincipalHistoryEvidenceUnavailableError(error);\n throw error;\n }\n return checkpointReference;\n}\n\nfunction checkSelectedReferences(\n input: PublicHistorySelectionInput,\n references: readonly ReferencedPrincipalHead[],\n batch: readonly number[],\n selected: Awaited<ReturnType<typeof selectBatch>>,\n checkpoint: PrincipalPolicyCheckpoint | null,\n) {\n // Authenticate the disposable proof before comparing caller citations or pins.\n for (const reference of references.filter(({ version }) =>\n batch.includes(version),\n ))\n if (\n !selected.retainedEntries.some(({ state }) =>\n principalHeadMatchesReference(state, reference),\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history citation differs from its verified entry\",\n );\n if (!input.deferCheckpointCheck)\n verifyPrincipalPolicyCheckpoint({\n chain: selected.retainedEntries.map((entry) => ({\n ...entry,\n projection: [...entry.projection],\n grants: [...entry.grants],\n })),\n currentState: selected.currentEntry.state,\n localCheckpoint: checkpoint,\n });\n}\n\n/** Select bounded proof batches without admitting or advancing durable pins. */\nexport async function selectPublicPrincipalHistory(\n input: PublicHistorySelectionInput,\n): Promise<VerifiedPrincipalPolicySelection[]> {\n const references = structuredClone(input.references);\n const checkpoint = input.checkpoint && { ...input.checkpoint };\n const head = input.recovered.history.currentEntry.state;\n if (\n !input.deferCheckpointCheck &&\n checkpoint &&\n checkpoint.version > head.version\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Public history cannot connect to the newer durable checkpoint\",\n );\n if (\n references.some(\n (reference) =>\n reference.principalType !== head.principalType ||\n reference.principalId !== head.principalId ||\n reference.version > head.version,\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history reference is outside the verified prefix\",\n );\n const versions = [\n ...new Set([\n ...(input.includeGenesis ? [1] : []),\n ...references.map(({ version }) => version),\n head.version,\n ]),\n ];\n const policies: VerifiedPrincipalPolicySelection[] = [];\n const checkpointReference = await loadCheckpointProof(\n input,\n checkpoint && checkpoint.version <= head.version ? checkpoint : null,\n );\n for (\n let offset = 0;\n offset < versions.length;\n offset += PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT\n ) {\n const batch = versions.slice(\n offset,\n offset + PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT,\n );\n const selected = await selectBatch(input, batch, checkpointReference).catch(\n (error: unknown) => {\n if (error instanceof KeyingVerificationError)\n throw new PrincipalHistoryEvidenceUnavailableError(error);\n throw error;\n },\n );\n checkSelectedReferences(input, references, batch, selected, checkpoint);\n const policy = await selectPrincipalPolicyAuthorization(selected);\n if (!policy.ok) throw policy.error;\n policies.push(policy.value);\n }\n assertProjectionVerificationCurrent(input.stillCurrent);\n return policies;\n}\n"]}
1
+ {"version":3,"file":"selectPublicPrincipalHistory.js","sourceRoot":"","sources":["selectPublicPrincipalHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,kCAAkC,EAIlC,kCAAkC,EAElC,+BAA+B,EAC/B,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gFAAgF,CAAC;AAC/H,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC;AAEzG,OAAO,EAAE,wCAAwC,EAAE,MAAM,uDAAuD,CAAC;AAajH,KAAK,UAAU,WAAW,CACxB,KAAkC,EAClC,QAA2B,EAC3B,mBAAqE;IAErE,MAAM,MAAM,GAA2C,EAAE,CAAC;IAC1D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CACT,MAAM,6BAA6B,CAAC;YAClC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,KAAK,CAAC,SAAS;YAClB,OAAO;SACR,CAAC,CACH,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,sCAAsC,CAAC;QAC5D,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO;QAChC,UAAU,EAAE,MAAM;QAClB,mBAAmB;KACpB,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;IACvC,OAAO,QAAQ,CAAC,KAAK,CAAC;AACxB,CAAC;AAED,KAAK,UAAU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AU,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACrE,CAAC;IACF,KACE,IAAI,MAAM,GAAG,CAAC,EACd,MAAM,GAAG,QAAQ,CAAC,MAAM,EACxB,MAAM,IAAI,kCAAkC,EAC5C,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAC1B,MAAM,EACN,MAAM,GAAG,kCAAkC,CAC5C,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,KAAK,CACzE,CAAC,KAAc,EAAE,EAAE;YACjB,IAAI,KAAK,YAAY,uBAAuB;gBAC1C,MAAM,IAAI,wCAAwC,CAAC,KAAK,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;QACd,CAAC,CACF,CAAC;QACF,uBAAuB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,MAAM,kCAAkC,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,MAAM,CAAC,KAAK,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,mCAAmC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACxD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT,\n type PrincipalPolicyCheckpoint,\n type PrincipalPolicyHistoryReferenceProof,\n type ReferencedPrincipalHead,\n selectPrincipalPolicyAuthorization,\n type VerifiedPrincipalPolicySelection,\n verifyPrincipalPolicyCheckpoint,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistory/principalHistoryEvidencePersistence\";\nimport { principalHeadMatchesReference } from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { PrincipalHistoryEvidenceUnavailableError } from \"../historyRecovery/principalHistoryRecoveryReferences\";\nimport type { RecoveredPublicPrincipalHistory } from \"./publicPrincipalHistoryTypes\";\n\ninterface PublicHistorySelectionInput {\n readonly execSql: ExecSql;\n readonly recovered: RecoveredPublicPrincipalHistory;\n readonly references: readonly ReferencedPrincipalHead[];\n readonly checkpoint: PrincipalPolicyCheckpoint | null;\n readonly deferCheckpointCheck?: boolean | undefined;\n readonly includeGenesis?: boolean;\n readonly stillCurrent: () => boolean;\n}\n\nasync function selectBatch(\n input: PublicHistorySelectionInput,\n versions: readonly number[],\n checkpointReference: PrincipalPolicyHistoryReferenceProof | undefined,\n) {\n const proofs: PrincipalPolicyHistoryReferenceProof[] = [];\n for (const version of versions) {\n assertProjectionVerificationCurrent(input.stillCurrent);\n proofs.push(\n await loadPrincipalHistoryReference({\n execSql: input.execSql,\n ...input.recovered,\n version,\n }),\n );\n }\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history: input.recovered.history,\n references: proofs,\n checkpointReference,\n });\n if (!selected.ok) throw selected.error;\n return selected.value;\n}\n\nasync function loadCheckpointProof(\n input: PublicHistorySelectionInput,\n checkpoint: PrincipalPolicyCheckpoint | null,\n): Promise<PrincipalPolicyHistoryReferenceProof | undefined> {\n let checkpointReference: PrincipalPolicyHistoryReferenceProof | undefined;\n try {\n if (checkpoint)\n checkpointReference = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n ...input.recovered,\n version: checkpoint.version,\n });\n } catch (error) {\n if (error instanceof KeyingVerificationError)\n throw new PrincipalHistoryEvidenceUnavailableError(error);\n throw error;\n }\n return checkpointReference;\n}\n\nfunction checkSelectedReferences(\n input: PublicHistorySelectionInput,\n references: readonly ReferencedPrincipalHead[],\n batch: readonly number[],\n selected: Awaited<ReturnType<typeof selectBatch>>,\n checkpoint: PrincipalPolicyCheckpoint | null,\n) {\n // Authenticate the disposable proof before comparing caller citations or pins.\n for (const reference of references.filter(({ version }) =>\n batch.includes(version),\n ))\n if (\n !selected.retainedEntries.some(({ state }) =>\n principalHeadMatchesReference(state, reference),\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history citation differs from its verified entry\",\n );\n if (!input.deferCheckpointCheck)\n verifyPrincipalPolicyCheckpoint({\n chain: selected.retainedEntries.map((entry) => ({\n ...entry,\n projection: [...entry.projection],\n grants: [...entry.grants],\n })),\n currentState: selected.currentEntry.state,\n localCheckpoint: checkpoint,\n });\n}\n\n/** Select bounded proof batches without admitting or advancing durable pins. */\nexport async function selectPublicPrincipalHistory(\n input: PublicHistorySelectionInput,\n): Promise<VerifiedPrincipalPolicySelection[]> {\n const references = structuredClone(input.references);\n const checkpoint = input.checkpoint && { ...input.checkpoint };\n const head = input.recovered.history.currentEntry.state;\n if (\n !input.deferCheckpointCheck &&\n checkpoint &&\n checkpoint.version > head.version\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Public history cannot connect to the newer durable checkpoint\",\n );\n if (\n references.some(\n (reference) =>\n reference.principalType !== head.principalType ||\n reference.principalId !== head.principalId ||\n reference.version > head.version,\n )\n )\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Public history reference is outside the verified prefix\",\n );\n const versions = [\n ...new Set([\n ...(input.includeGenesis ? [1] : []),\n ...references.map(({ version }) => version),\n head.version,\n ]),\n ];\n const policies: VerifiedPrincipalPolicySelection[] = [];\n const checkpointReference = await loadCheckpointProof(\n input,\n checkpoint && checkpoint.version <= head.version ? checkpoint : null,\n );\n for (\n let offset = 0;\n offset < versions.length;\n offset += PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT\n ) {\n const batch = versions.slice(\n offset,\n offset + PRINCIPAL_HISTORY_PAGE_ENTRY_LIMIT,\n );\n const selected = await selectBatch(input, batch, checkpointReference).catch(\n (error: unknown) => {\n if (error instanceof KeyingVerificationError)\n throw new PrincipalHistoryEvidenceUnavailableError(error);\n throw error;\n },\n );\n checkSelectedReferences(input, references, batch, selected, checkpoint);\n const policy = await selectPrincipalPolicyAuthorization(selected);\n if (!policy.ok) throw policy.error;\n policies.push(policy.value);\n }\n assertProjectionVerificationCurrent(input.stillCurrent);\n return policies;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { KeyingVerificationError, verifyPrincipalPolicyHistoryReferences, } from "../../../internal/crypto/index.js";
2
2
  import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
3
- import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistoryEvidencePersistence.js";
3
+ import { loadPrincipalHistoryReference } from "../../../data/persistence/principalHistory/principalHistoryEvidencePersistence.js";
4
4
  import { parseOrganizationAuthorityDescriptor, } from "../../../data/principals/organizationAuthorityDescriptor.js";
5
5
  import { principalHistoryEvidenceScopeId } from "../../../data/principals/principalHistoryPrefixProtection.js";
6
6
  import { directoryHistoryProtection } from "../../../data/principals/principalHistoryScopeProtection.js";
@@ -1 +1 @@
1
- {"version":3,"file":"principalRecoveryDirectory.js","sourceRoot":"","sources":["principalRecoveryDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAEL,oCAAoC,GACrC,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,kCAAkC,EAAE,MAAM,mDAAmD,CAAC;AACvG,O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,CAAC,CAAC,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,OAAO,EAAE,OAAO,KAAK,CAAC;QACxB,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,2DAA2D,CAC5D,CAAC;IACJ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;QAC1E,MAAM,IAAI,kCAAkC,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,6BAA6B,CAAC;QACpD,GAAG,MAAM;QACT,aAAa;QACb,YAAY;QACZ,kBAAkB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,CAAC,CAAC;YACzE,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;KACxC,CAAC,CAAC;IACH,IAAI,UAA2C,CAAC;IAChD,IAAI,CAAC;QACH,UAAU,GAAG,oCAAoC,CAC/C,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAC5C,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,uBAAuB,CAC/B,eAAe,EACf,2CAA2C,CAC5C,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;QACpD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,6CAA6C,CAC9C,CAAC;IACJ,OAAO,EAAE,GAAG,SAAS,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistoryEvidencePersistence\";\nimport {\n type OrganizationAuthorityDescriptor,\n parseOrganizationAuthorityDescriptor,\n} from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { principalHistoryEvidenceScopeId } from \"../../../data/principals/principalHistoryPrefixProtection\";\nimport { directoryHistoryProtection } from \"../../../data/principals/principalHistoryScopeProtection\";\nimport { loadVerifiedPrincipalHistoryPrefix } from \"../historyRecovery/principalHistoryRecoveryPrefix\";\nimport {\n PrincipalPolicyHistoryReadError,\n type RecoveredPrincipalPolicyHistory,\n type RecoverPrincipalPolicyHistoryOptions,\n} from \"../historyRecovery/principalHistoryRecoveryTypes\";\nimport { recoverPrincipalPolicyHistory } from \"../historyRecovery/recoverPrincipalPolicyHistory\";\nimport { reusePrincipalDiscoveryPage } from \"./principalRecoveryDiscoveryPage\";\n\nexport type PrincipalRecoveryContext = Omit<\n RecoverPrincipalPolicyHistoryOptions,\n | \"expectedHead\"\n | \"retainedReferences\"\n | \"historyVerification\"\n | \"loadExternalAuthority\"\n>;\n\nexport interface RecoveredPolicyDirectory\n extends RecoveredPrincipalPolicyHistory {\n readonly descriptor: OrganizationAuthorityDescriptor;\n}\n\nexport class PrincipalRecoveryDirectoryAdvanced extends Error {}\n\nfunction exactHead(state: ReferencedPrincipalHead): ReferencedPrincipalHead {\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n };\n}\n\n/** An unverified discovery read chooses a pin; recovery must authenticate it. */\nasync function discoverDirectoryHead(input: PrincipalRecoveryContext): Promise<{\n head: ReferencedPrincipalHead;\n genesis: ReferencedPrincipalHead;\n historyReader: PrincipalRecoveryContext[\"historyReader\"];\n}> {\n assertProjectionVerificationCurrent(\n () => !input.signal?.aborted && input.stillCurrent(),\n );\n if (input.offline) {\n const principal = {\n principalType: \"organization\" as const,\n principalId: input.organizationId,\n };\n const scopeId = await principalHistoryEvidenceScopeId({\n organizationId: input.organizationId,\n head: principal,\n protection: input.protection,\n });\n const prefix = await loadVerifiedPrincipalHistoryPrefix(\n input,\n principal,\n scopeId,\n );\n if (!prefix)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory is unavailable offline\",\n );\n const history = prefix.verifier.finish(prefix.head);\n if (!history.ok) throw history.error;\n const genesis = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId,\n history: history.value,\n version: 1,\n });\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history: history.value,\n references: [genesis],\n });\n if (!selected.ok) throw selected.error;\n return {\n head: prefix.head,\n genesis: genesis.reference,\n historyReader: input.historyReader,\n };\n }\n for await (const result of input.historyReader.getPrincipalPolicyPages(\n \"organization\",\n input.organizationId,\n { signal: input.signal },\n )) {\n if (!result.ok) throw new PrincipalPolicyHistoryReadError(result);\n assertProjectionVerificationCurrent(\n () => !input.signal?.aborted && input.stillCurrent(),\n );\n const state = result.data.currentState;\n const first = result.data.previousStates[0]?.state ?? state;\n if (\n first.version !== 1 ||\n first.principalType !== \"organization\" ||\n first.principalId !== input.organizationId\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory discovery requires genesis\",\n );\n return {\n historyReader: reusePrincipalDiscoveryPage(input.historyReader, result),\n genesis: {\n principalType: first.principalType,\n principalId: first.principalId,\n version: first.version,\n stateHash: first.stateHash,\n keyEpoch: first.keyEpoch,\n keyFingerprint: first.keyFingerprint,\n },\n head: {\n principalType: \"organization\",\n principalId: input.organizationId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n },\n };\n }\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory head is unavailable\",\n );\n}\n\nexport async function recoverPolicyDirectory(\n input: PrincipalRecoveryContext,\n references: readonly ReferencedPrincipalHead[],\n selected?: RecoveredPolicyDirectory,\n): Promise<RecoveredPolicyDirectory> {\n const scoped = {\n ...input,\n protection: directoryHistoryProtection(input.protection),\n };\n const {\n head: expectedHead,\n genesis,\n historyReader,\n } = selected\n ? {\n head: exactHead(selected.policy.state),\n genesis: selected.policy.retainedHistory[0]?.state,\n historyReader: input.historyReader,\n }\n : await discoverDirectoryHead(scoped);\n if (genesis?.version !== 1)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory recovery requires verified genesis\",\n );\n if (references.some((reference) => reference.version > expectedHead.version))\n throw new PrincipalRecoveryDirectoryAdvanced();\n const recovered = await recoverPrincipalPolicyHistory({\n ...scoped,\n historyReader,\n expectedHead,\n retainedReferences: references.some((reference) => reference.version === 1)\n ? references\n : [exactHead(genesis), ...references],\n });\n let descriptor: OrganizationAuthorityDescriptor;\n try {\n descriptor = parseOrganizationAuthorityDescriptor(\n recovered.current.currentPayload.ciphertext,\n );\n } catch {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Organization directory payload is invalid\",\n );\n }\n if (descriptor.organizationId !== input.organizationId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Organization directory scope does not match\",\n );\n return { ...recovered, descriptor };\n}\n"]}
1
+ {"version":3,"file":"principalRecoveryDirectory.js","sourceRoot":"","sources":["principalRecoveryDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gFAAgF,CAAC;AAC/H,OAAO,EAEL,oCAAoC,GACrC,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,kCAAkC,EAAE,MAAM,mDAAmD,CAAC;AACvG,OAAO,EACL,+BAA+B,GAGhC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,6BAA6B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AE,OAAO,KAAK,CAAC;QACxB,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,2DAA2D,CAC5D,CAAC;IACJ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;QAC1E,MAAM,IAAI,kCAAkC,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,6BAA6B,CAAC;QACpD,GAAG,MAAM;QACT,aAAa;QACb,YAAY;QACZ,kBAAkB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,CAAC,CAAC;YACzE,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;KACxC,CAAC,CAAC;IACH,IAAI,UAA2C,CAAC;IAChD,IAAI,CAAC;QACH,UAAU,GAAG,oCAAoC,CAC/C,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAC5C,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,uBAAuB,CAC/B,eAAe,EACf,2CAA2C,CAC5C,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;QACpD,MAAM,IAAI,uBAAuB,CAC/B,iBAAiB,EACjB,6CAA6C,CAC9C,CAAC;IACJ,OAAO,EAAE,GAAG,SAAS,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import {\n KeyingVerificationError,\n type ReferencedPrincipalHead,\n verifyPrincipalPolicyHistoryReferences,\n} from \"@tearleads/crypto\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport { loadPrincipalHistoryReference } from \"../../../data/persistence/principalHistory/principalHistoryEvidencePersistence\";\nimport {\n type OrganizationAuthorityDescriptor,\n parseOrganizationAuthorityDescriptor,\n} from \"../../../data/principals/organizationAuthorityDescriptor\";\nimport { principalHistoryEvidenceScopeId } from \"../../../data/principals/principalHistoryPrefixProtection\";\nimport { directoryHistoryProtection } from \"../../../data/principals/principalHistoryScopeProtection\";\nimport { loadVerifiedPrincipalHistoryPrefix } from \"../historyRecovery/principalHistoryRecoveryPrefix\";\nimport {\n PrincipalPolicyHistoryReadError,\n type RecoveredPrincipalPolicyHistory,\n type RecoverPrincipalPolicyHistoryOptions,\n} from \"../historyRecovery/principalHistoryRecoveryTypes\";\nimport { recoverPrincipalPolicyHistory } from \"../historyRecovery/recoverPrincipalPolicyHistory\";\nimport { reusePrincipalDiscoveryPage } from \"./principalRecoveryDiscoveryPage\";\n\nexport type PrincipalRecoveryContext = Omit<\n RecoverPrincipalPolicyHistoryOptions,\n | \"expectedHead\"\n | \"retainedReferences\"\n | \"historyVerification\"\n | \"loadExternalAuthority\"\n>;\n\nexport interface RecoveredPolicyDirectory\n extends RecoveredPrincipalPolicyHistory {\n readonly descriptor: OrganizationAuthorityDescriptor;\n}\n\nexport class PrincipalRecoveryDirectoryAdvanced extends Error {}\n\nfunction exactHead(state: ReferencedPrincipalHead): ReferencedPrincipalHead {\n return {\n principalType: state.principalType,\n principalId: state.principalId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n };\n}\n\n/** An unverified discovery read chooses a pin; recovery must authenticate it. */\nasync function discoverDirectoryHead(input: PrincipalRecoveryContext): Promise<{\n head: ReferencedPrincipalHead;\n genesis: ReferencedPrincipalHead;\n historyReader: PrincipalRecoveryContext[\"historyReader\"];\n}> {\n assertProjectionVerificationCurrent(\n () => !input.signal?.aborted && input.stillCurrent(),\n );\n if (input.offline) {\n const principal = {\n principalType: \"organization\" as const,\n principalId: input.organizationId,\n };\n const scopeId = await principalHistoryEvidenceScopeId({\n organizationId: input.organizationId,\n head: principal,\n protection: input.protection,\n });\n const prefix = await loadVerifiedPrincipalHistoryPrefix(\n input,\n principal,\n scopeId,\n );\n if (!prefix)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory is unavailable offline\",\n );\n const history = prefix.verifier.finish(prefix.head);\n if (!history.ok) throw history.error;\n const genesis = await loadPrincipalHistoryReference({\n execSql: input.execSql,\n scopeId,\n history: history.value,\n version: 1,\n });\n const selected = await verifyPrincipalPolicyHistoryReferences({\n history: history.value,\n references: [genesis],\n });\n if (!selected.ok) throw selected.error;\n return {\n head: prefix.head,\n genesis: genesis.reference,\n historyReader: input.historyReader,\n };\n }\n for await (const result of input.historyReader.getPrincipalPolicyPages(\n \"organization\",\n input.organizationId,\n { signal: input.signal },\n )) {\n if (!result.ok) throw new PrincipalPolicyHistoryReadError(result);\n assertProjectionVerificationCurrent(\n () => !input.signal?.aborted && input.stillCurrent(),\n );\n const state = result.data.currentState;\n const first = result.data.previousStates[0]?.state ?? state;\n if (\n first.version !== 1 ||\n first.principalType !== \"organization\" ||\n first.principalId !== input.organizationId\n )\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory discovery requires genesis\",\n );\n return {\n historyReader: reusePrincipalDiscoveryPage(input.historyReader, result),\n genesis: {\n principalType: first.principalType,\n principalId: first.principalId,\n version: first.version,\n stateHash: first.stateHash,\n keyEpoch: first.keyEpoch,\n keyFingerprint: first.keyFingerprint,\n },\n head: {\n principalType: \"organization\",\n principalId: input.organizationId,\n version: state.version,\n stateHash: state.stateHash,\n keyEpoch: state.keyEpoch,\n keyFingerprint: state.keyFingerprint,\n },\n };\n }\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory head is unavailable\",\n );\n}\n\nexport async function recoverPolicyDirectory(\n input: PrincipalRecoveryContext,\n references: readonly ReferencedPrincipalHead[],\n selected?: RecoveredPolicyDirectory,\n): Promise<RecoveredPolicyDirectory> {\n const scoped = {\n ...input,\n protection: directoryHistoryProtection(input.protection),\n };\n const {\n head: expectedHead,\n genesis,\n historyReader,\n } = selected\n ? {\n head: exactHead(selected.policy.state),\n genesis: selected.policy.retainedHistory[0]?.state,\n historyReader: input.historyReader,\n }\n : await discoverDirectoryHead(scoped);\n if (genesis?.version !== 1)\n throw new KeyingVerificationError(\n \"missing_dependency\",\n \"Organization directory recovery requires verified genesis\",\n );\n if (references.some((reference) => reference.version > expectedHead.version))\n throw new PrincipalRecoveryDirectoryAdvanced();\n const recovered = await recoverPrincipalPolicyHistory({\n ...scoped,\n historyReader,\n expectedHead,\n retainedReferences: references.some((reference) => reference.version === 1)\n ? references\n : [exactHead(genesis), ...references],\n });\n let descriptor: OrganizationAuthorityDescriptor;\n try {\n descriptor = parseOrganizationAuthorityDescriptor(\n recovered.current.currentPayload.ciphertext,\n );\n } catch {\n throw new KeyingVerificationError(\n \"invalid_shape\",\n \"Organization directory payload is invalid\",\n );\n }\n if (descriptor.organizationId !== input.organizationId)\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Organization directory scope does not match\",\n );\n return { ...recovered, descriptor };\n}\n"]}