@noy-db/hub 0.6.0-pre.16 → 0.6.0-pre.18

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 (307) hide show
  1. package/dist/{api-NAY63UIE.js → api-FRFEJ6WR.js} +6 -6
  2. package/dist/attestation/index.js +12 -12
  3. package/dist/{backup-M2VND2VS.js → backup-OLBRFYY7.js} +10 -10
  4. package/dist/{backup-M2VND2VS.js.map → backup-OLBRFYY7.js.map} +1 -1
  5. package/dist/blobs/index.js +8 -8
  6. package/dist/broker/index.js +6 -6
  7. package/dist/cargo/index.js +26 -26
  8. package/dist/{chunk-4CSG6KBX.js → chunk-2ION5ZRH.js} +17 -14
  9. package/dist/chunk-2ION5ZRH.js.map +1 -0
  10. package/dist/{chunk-466KGOQB.js → chunk-2NE7ILO7.js} +2 -2
  11. package/dist/{chunk-CZV57HHC.js → chunk-3KXIGMZ4.js} +2 -2
  12. package/dist/{chunk-5CH4DWQA.js → chunk-3ODOWQMV.js} +13 -14
  13. package/dist/chunk-3ODOWQMV.js.map +1 -0
  14. package/dist/{chunk-3OEWD45V.js → chunk-3RZ7QLJ4.js} +5 -5
  15. package/dist/{chunk-SFY6NT7D.js → chunk-3Y4OFWQJ.js} +1 -1
  16. package/dist/chunk-3Y4OFWQJ.js.map +1 -0
  17. package/dist/{chunk-FZ2SSI5R.js → chunk-6AL6O4CS.js} +2 -2
  18. package/dist/{chunk-4XEUSZWN.js → chunk-6D3CN2JR.js} +2 -2
  19. package/dist/{chunk-6UAVKAG6.js → chunk-6QCXMCLZ.js} +3 -3
  20. package/dist/{chunk-B4G3JPH5.js → chunk-7EH322GJ.js} +14 -7
  21. package/dist/chunk-7EH322GJ.js.map +1 -0
  22. package/dist/{chunk-AMKCY454.js → chunk-7WD2G6K4.js} +7 -2
  23. package/dist/{chunk-AMKCY454.js.map → chunk-7WD2G6K4.js.map} +1 -1
  24. package/dist/{chunk-VUUUIKRG.js → chunk-A5QQKWCK.js} +14 -23
  25. package/dist/chunk-A5QQKWCK.js.map +1 -0
  26. package/dist/{chunk-RRMXMJUP.js → chunk-AA2WWTS3.js} +9 -7
  27. package/dist/chunk-AA2WWTS3.js.map +1 -0
  28. package/dist/{chunk-WMUN7ZUD.js → chunk-AA7LM2A3.js} +2 -2
  29. package/dist/{chunk-PJGMBELR.js → chunk-AIZNLHKN.js} +4 -4
  30. package/dist/chunk-AIZNLHKN.js.map +1 -0
  31. package/dist/{chunk-MKSTUVMJ.js → chunk-AMMYIT7F.js} +35 -31
  32. package/dist/chunk-AMMYIT7F.js.map +1 -0
  33. package/dist/{chunk-TWPTRJEU.js → chunk-BBU3OD3D.js} +2 -2
  34. package/dist/{chunk-OJEDR25M.js → chunk-BVIGGV6D.js} +33 -45
  35. package/dist/chunk-BVIGGV6D.js.map +1 -0
  36. package/dist/{chunk-IQGIPRSE.js → chunk-CFTPERGL.js} +14 -11
  37. package/dist/chunk-CFTPERGL.js.map +1 -0
  38. package/dist/{chunk-T6CCRXD3.js → chunk-CGQUSSW7.js} +26 -142
  39. package/dist/chunk-CGQUSSW7.js.map +1 -0
  40. package/dist/{chunk-4JDTLWUZ.js → chunk-DFFSCYIW.js} +9 -9
  41. package/dist/{chunk-JZVXGOJE.js → chunk-DKYEVHZH.js} +7 -10
  42. package/dist/chunk-DKYEVHZH.js.map +1 -0
  43. package/dist/{chunk-YVOW35HH.js → chunk-DL4GDOWL.js} +4 -6
  44. package/dist/chunk-DL4GDOWL.js.map +1 -0
  45. package/dist/{chunk-LGGLPURL.js → chunk-DWO55ZWE.js} +13 -22
  46. package/dist/chunk-DWO55ZWE.js.map +1 -0
  47. package/dist/{chunk-MKV2KYRV.js → chunk-ER3BQCCE.js} +2 -2
  48. package/dist/{chunk-JU3JKOY5.js → chunk-EWAGI3EM.js} +2 -2
  49. package/dist/{chunk-WMZQCXZ5.js → chunk-EZ3UHHND.js} +13 -15
  50. package/dist/chunk-EZ3UHHND.js.map +1 -0
  51. package/dist/{chunk-5TF5DUQ5.js → chunk-FDIZHZ3C.js} +29 -47
  52. package/dist/chunk-FDIZHZ3C.js.map +1 -0
  53. package/dist/{chunk-56W3T5O2.js → chunk-FOABWV7L.js} +45 -18
  54. package/dist/chunk-FOABWV7L.js.map +1 -0
  55. package/dist/{chunk-H5U4T6JK.js → chunk-FRGF56PD.js} +11 -14
  56. package/dist/chunk-FRGF56PD.js.map +1 -0
  57. package/dist/{chunk-53PWELSC.js → chunk-FY33DKPH.js} +2 -2
  58. package/dist/{chunk-KKRFL5E2.js → chunk-GSRW5MTU.js} +220 -169
  59. package/dist/chunk-GSRW5MTU.js.map +1 -0
  60. package/dist/{chunk-4VRZDYRE.js → chunk-HJRTFXAA.js} +7 -10
  61. package/dist/chunk-HJRTFXAA.js.map +1 -0
  62. package/dist/chunk-HK67PX4J.js +27 -0
  63. package/dist/chunk-HK67PX4J.js.map +1 -0
  64. package/dist/{chunk-A3WHDOWI.js → chunk-IN5EZWYQ.js} +13 -14
  65. package/dist/chunk-IN5EZWYQ.js.map +1 -0
  66. package/dist/{chunk-PZLIA5R3.js → chunk-ITXPKEDP.js} +23 -29
  67. package/dist/chunk-ITXPKEDP.js.map +1 -0
  68. package/dist/{chunk-343FH4S5.js → chunk-JYFJNSTW.js} +9 -9
  69. package/dist/chunk-JYFJNSTW.js.map +1 -0
  70. package/dist/{chunk-35RIRCGW.js → chunk-KLVGF2D4.js} +11 -9
  71. package/dist/{chunk-35RIRCGW.js.map → chunk-KLVGF2D4.js.map} +1 -1
  72. package/dist/{chunk-7LLKPODL.js → chunk-LPAGIMXJ.js} +2 -2
  73. package/dist/{chunk-3JQVA527.js → chunk-LU6NPJWN.js} +3 -3
  74. package/dist/{chunk-UVFO25FJ.js → chunk-NAAPSNCS.js} +90 -33
  75. package/dist/chunk-NAAPSNCS.js.map +1 -0
  76. package/dist/{chunk-OPGKH5RD.js → chunk-NFPSC2HL.js} +3 -3
  77. package/dist/{chunk-55B3KHZW.js → chunk-NRNTXBHT.js} +7 -10
  78. package/dist/chunk-NRNTXBHT.js.map +1 -0
  79. package/dist/{chunk-I5OLA3H6.js → chunk-O4QDBAB6.js} +7 -10
  80. package/dist/{chunk-I5OLA3H6.js.map → chunk-O4QDBAB6.js.map} +1 -1
  81. package/dist/{chunk-4DJQU3PH.js → chunk-OCCNYGKG.js} +7 -7
  82. package/dist/{chunk-76FBDG6M.js → chunk-OZD3D2DZ.js} +10 -13
  83. package/dist/chunk-OZD3D2DZ.js.map +1 -0
  84. package/dist/{chunk-YX6J3Z3Z.js → chunk-PBPYQZDW.js} +2 -2
  85. package/dist/{chunk-TTAND7MR.js → chunk-PBRIHUQ5.js} +5 -5
  86. package/dist/{chunk-TTAND7MR.js.map → chunk-PBRIHUQ5.js.map} +1 -1
  87. package/dist/{chunk-NBLLQOMR.js → chunk-Q67P7S2I.js} +14 -15
  88. package/dist/chunk-Q67P7S2I.js.map +1 -0
  89. package/dist/{chunk-NY6RQBUN.js → chunk-RAYGDC4A.js} +50 -63
  90. package/dist/chunk-RAYGDC4A.js.map +1 -0
  91. package/dist/{chunk-RVTOCAHQ.js → chunk-SQSZRCYT.js} +1 -1
  92. package/dist/chunk-SQSZRCYT.js.map +1 -0
  93. package/dist/{chunk-JN64WH3U.js → chunk-T7IR4N2S.js} +1 -1
  94. package/dist/{chunk-JN64WH3U.js.map → chunk-T7IR4N2S.js.map} +1 -1
  95. package/dist/{chunk-THUITYH7.js → chunk-TNOQNU3R.js} +5 -4
  96. package/dist/{chunk-THUITYH7.js.map → chunk-TNOQNU3R.js.map} +1 -1
  97. package/dist/{chunk-TY6N3PAC.js → chunk-TXDOMADN.js} +9 -6
  98. package/dist/chunk-TXDOMADN.js.map +1 -0
  99. package/dist/{chunk-6EF3N2MH.js → chunk-U6D5XTI5.js} +13 -13
  100. package/dist/{chunk-6EF3N2MH.js.map → chunk-U6D5XTI5.js.map} +1 -1
  101. package/dist/{chunk-HNX47VTC.js → chunk-UE72AQDZ.js} +6 -6
  102. package/dist/chunk-UIYZ5SOU.js +190 -0
  103. package/dist/chunk-UIYZ5SOU.js.map +1 -0
  104. package/dist/{chunk-IGE6XWKK.js → chunk-VXVKEWYC.js} +3 -3
  105. package/dist/{chunk-LTVETWDH.js → chunk-X3AXSYBL.js} +217 -123
  106. package/dist/chunk-X3AXSYBL.js.map +1 -0
  107. package/dist/{chunk-AD2PJGSS.js → chunk-ZDATYUYG.js} +2 -2
  108. package/dist/{chunk-LJDW6LQJ.js → chunk-ZSOTZ2RZ.js} +41 -24
  109. package/dist/chunk-ZSOTZ2RZ.js.map +1 -0
  110. package/dist/{chunk-6E2JZRBD.js → chunk-ZVAFJQZB.js} +25 -19
  111. package/dist/chunk-ZVAFJQZB.js.map +1 -0
  112. package/dist/classified/index.js +4 -4
  113. package/dist/{classified-marker-L7LXKS6Q.js → classified-marker-GWQTNDSL.js} +3 -3
  114. package/dist/{collection-facade-KN3UFKZ4.js → collection-facade-56RTPO4G.js} +12 -12
  115. package/dist/consent/index.js +4 -4
  116. package/dist/cover/index.js +9 -2
  117. package/dist/custody/index.js +6 -6
  118. package/dist/{dead-filter-6HG5FP3I.js → dead-filter-XP7MPHCJ.js} +2 -2
  119. package/dist/{delegation-7EGBYBRN.js → delegation-Q3HEAVLA.js} +18 -19
  120. package/dist/delegation-Q3HEAVLA.js.map +1 -0
  121. package/dist/derivations/index.js +3 -3
  122. package/dist/{derive-XKAYJ2OA.js → derive-SVDY36ER.js} +4 -4
  123. package/dist/directory/index.js +5 -5
  124. package/dist/{dispatch-56T7VPGE.js → dispatch-MG5KNMWG.js} +5 -5
  125. package/dist/{dispatch-BM5GNCE2.js → dispatch-RVJQ4BOL.js} +11 -11
  126. package/dist/{enclave-KDLGVX5Z.js → enclave-AOZTWFZK.js} +16 -4
  127. package/dist/{executor-LFHRV6JH.js → executor-FRUVM36Q.js} +12 -12
  128. package/dist/{export-accessible-HFBJ4JJY.js → export-accessible-HDDHZYPM.js} +7 -7
  129. package/dist/{extract-partition-7ZRFN6QP.js → extract-partition-TRADP234.js} +12 -12
  130. package/dist/{fanout-sidecar-MT2OBMZB.js → fanout-sidecar-NZA6J7QB.js} +13 -22
  131. package/dist/fanout-sidecar-NZA6J7QB.js.map +1 -0
  132. package/dist/forget/index.js +4 -4
  133. package/dist/history/index.js +18 -15
  134. package/dist/history/index.js.map +1 -1
  135. package/dist/i18n/index.js +9 -9
  136. package/dist/index.d.ts +16 -0
  137. package/dist/index.js +129 -127
  138. package/dist/index.js.map +1 -1
  139. package/dist/introspection/index.js +5 -5
  140. package/dist/{issue-LCOOEH45.js → issue-GZQDW5TQ.js} +6 -6
  141. package/dist/kernel/enclave/index.d.ts +7 -5
  142. package/dist/kernel/enclave/record-aad.d.ts +79 -7
  143. package/dist/kernel/enclave/record-envelope.d.ts +54 -7
  144. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  145. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  146. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  147. package/dist/kernel/enclave/record-keys/rekey.d.ts +68 -0
  148. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -3
  149. package/dist/kernel/merge-authority.d.ts +25 -0
  150. package/dist/kernel/tier-visibility.d.ts +15 -0
  151. package/dist/kernel/types.d.ts +23 -0
  152. package/dist/kernel/vault.d.ts +1 -1
  153. package/dist/kernel/via/index.d.ts +11 -2
  154. package/dist/{ledger-6IHXJHDD.js → ledger-KQAJPEMZ.js} +6 -6
  155. package/dist/liberate-Z2EXJY2S.js +24 -0
  156. package/dist/{link-set-XRVHGYWC.js → link-set-XKN5V7VM.js} +5 -5
  157. package/dist/{managed-secret-IDAOXSSX.js → managed-secret-7WIIVMJ5.js} +11 -3
  158. package/dist/materialized-views/index.js +14 -14
  159. package/dist/money/index.js +3 -3
  160. package/dist/{noydb-M5WII7RP.js → noydb-NPW3C2EX.js} +39 -38
  161. package/dist/periods/index.js +6 -6
  162. package/dist/pod/index.js +42 -41
  163. package/dist/{pod-handle-BYUSBXCT.js → pod-handle-SKDKRPOR.js} +6 -6
  164. package/dist/{pod-handle-BYUSBXCT.js.map → pod-handle-SKDKRPOR.js.map} +1 -1
  165. package/dist/policy/index.js +10 -3
  166. package/dist/port/with/merge-authority.d.ts +52 -0
  167. package/dist/port/with/strategies.d.ts +2 -0
  168. package/dist/portability/index.js +6 -6
  169. package/dist/{post-register-O3YW6CGS.js → post-register-CVS7CCJE.js} +4 -4
  170. package/dist/reduce/index.js +3 -3
  171. package/dist/{register-XHOOX37G.js → register-GJ6PW4KP.js} +10 -10
  172. package/dist/{registry-OFMM4WAC.js → registry-6LUJ5IJW.js} +4 -4
  173. package/dist/{registry-CYAFB35H.js → registry-KI77RVK7.js} +4 -4
  174. package/dist/{request-withdrawal-GCE2SLNW.js → request-withdrawal-LICOUGXG.js} +9 -9
  175. package/dist/{reveal-UHBP5IH3.js → reveal-PWM47FQN.js} +3 -3
  176. package/dist/{revoke-6KY4VGZY.js → revoke-AWZKZLZB.js} +6 -6
  177. package/dist/sealed-record/index.js +14 -7
  178. package/dist/sealed-record/index.js.map +1 -1
  179. package/dist/search/index.js +3 -3
  180. package/dist/{seed-DGLQTCIO.js → seed-LNTLU2A3.js} +14 -17
  181. package/dist/seed-LNTLU2A3.js.map +1 -0
  182. package/dist/sequence/index.js +4 -4
  183. package/dist/session/index.js +3 -3
  184. package/dist/{signer-SLOMB6HS.js → signer-JE6NEURY.js} +5 -5
  185. package/dist/snapshots/index.js +5 -5
  186. package/dist/{stale-26ZJLNLG.js → stale-ZWTKUVZX.js} +5 -5
  187. package/dist/{storage-N3IMFNGS.js → storage-WCZOCA46.js} +5 -5
  188. package/dist/{store-coordination-provider-RGHCIRWV.js → store-coordination-provider-7H62VO2C.js} +18 -12
  189. package/dist/store-coordination-provider-7H62VO2C.js.map +1 -0
  190. package/dist/sync/index.js +5 -5
  191. package/dist/team/index.js +10 -9
  192. package/dist/tiers/index.js +6 -5
  193. package/dist/vault-head/index.js +111 -0
  194. package/dist/vault-head/index.js.map +1 -0
  195. package/dist/{walk-B4YFJJ7S.js → walk-HSS3NLQ3.js} +6 -6
  196. package/dist/with-audit/periods/periods.d.ts +1 -1
  197. package/dist/with-audit/periods/strategy.d.ts +1 -1
  198. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  199. package/dist/with-audit/tiers/index.d.ts +17 -2
  200. package/dist/with-commit/history/history.d.ts +26 -0
  201. package/dist/with-commit/history/index.d.ts +2 -1
  202. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  203. package/dist/with-commit/history/strategy.d.ts +11 -1
  204. package/dist/with-commit/vault-head/active.d.ts +2 -0
  205. package/dist/with-commit/vault-head/head.d.ts +28 -0
  206. package/dist/with-commit/vault-head/index.d.ts +10 -0
  207. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  208. package/dist/with-commit/vault-head/verify.d.ts +50 -0
  209. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  210. package/dist/with-party/directory/storage.d.ts +0 -11
  211. package/dist/with-party/directory/visibility.d.ts +0 -21
  212. package/dist/with-party/policy/storage.d.ts +0 -10
  213. package/dist/with-party/team/keyring.d.ts +5 -0
  214. package/dist/with-party/team/tiers.d.ts +2 -1
  215. package/dist/with-sync/engine.d.ts +33 -5
  216. package/dist/with-sync/strategy.d.ts +3 -0
  217. package/dist/{withdraw-accessible-OYG7YZUR.js → withdraw-accessible-GHBA4DAA.js} +8 -8
  218. package/package.json +7 -3
  219. package/dist/chunk-343FH4S5.js.map +0 -1
  220. package/dist/chunk-4CSG6KBX.js.map +0 -1
  221. package/dist/chunk-4VRZDYRE.js.map +0 -1
  222. package/dist/chunk-55B3KHZW.js.map +0 -1
  223. package/dist/chunk-56W3T5O2.js.map +0 -1
  224. package/dist/chunk-5CH4DWQA.js.map +0 -1
  225. package/dist/chunk-5TF5DUQ5.js.map +0 -1
  226. package/dist/chunk-6E2JZRBD.js.map +0 -1
  227. package/dist/chunk-76FBDG6M.js.map +0 -1
  228. package/dist/chunk-A3WHDOWI.js.map +0 -1
  229. package/dist/chunk-AFHQATY4.js +0 -47
  230. package/dist/chunk-AFHQATY4.js.map +0 -1
  231. package/dist/chunk-B4G3JPH5.js.map +0 -1
  232. package/dist/chunk-H5U4T6JK.js.map +0 -1
  233. package/dist/chunk-IQGIPRSE.js.map +0 -1
  234. package/dist/chunk-JZVXGOJE.js.map +0 -1
  235. package/dist/chunk-KKRFL5E2.js.map +0 -1
  236. package/dist/chunk-LGGLPURL.js.map +0 -1
  237. package/dist/chunk-LJDW6LQJ.js.map +0 -1
  238. package/dist/chunk-LTVETWDH.js.map +0 -1
  239. package/dist/chunk-MKSTUVMJ.js.map +0 -1
  240. package/dist/chunk-NBLLQOMR.js.map +0 -1
  241. package/dist/chunk-NY6RQBUN.js.map +0 -1
  242. package/dist/chunk-OJEDR25M.js.map +0 -1
  243. package/dist/chunk-PJGMBELR.js.map +0 -1
  244. package/dist/chunk-PZLIA5R3.js.map +0 -1
  245. package/dist/chunk-RRMXMJUP.js.map +0 -1
  246. package/dist/chunk-RVTOCAHQ.js.map +0 -1
  247. package/dist/chunk-SFY6NT7D.js.map +0 -1
  248. package/dist/chunk-T6CCRXD3.js.map +0 -1
  249. package/dist/chunk-TY6N3PAC.js.map +0 -1
  250. package/dist/chunk-UVFO25FJ.js.map +0 -1
  251. package/dist/chunk-VUUUIKRG.js.map +0 -1
  252. package/dist/chunk-WMZQCXZ5.js.map +0 -1
  253. package/dist/chunk-YVOW35HH.js.map +0 -1
  254. package/dist/delegation-7EGBYBRN.js.map +0 -1
  255. package/dist/fanout-sidecar-MT2OBMZB.js.map +0 -1
  256. package/dist/liberate-UEYC4QLJ.js +0 -24
  257. package/dist/seed-DGLQTCIO.js.map +0 -1
  258. package/dist/store-coordination-provider-RGHCIRWV.js.map +0 -1
  259. /package/dist/{api-NAY63UIE.js.map → api-FRFEJ6WR.js.map} +0 -0
  260. /package/dist/{chunk-466KGOQB.js.map → chunk-2NE7ILO7.js.map} +0 -0
  261. /package/dist/{chunk-CZV57HHC.js.map → chunk-3KXIGMZ4.js.map} +0 -0
  262. /package/dist/{chunk-3OEWD45V.js.map → chunk-3RZ7QLJ4.js.map} +0 -0
  263. /package/dist/{chunk-FZ2SSI5R.js.map → chunk-6AL6O4CS.js.map} +0 -0
  264. /package/dist/{chunk-4XEUSZWN.js.map → chunk-6D3CN2JR.js.map} +0 -0
  265. /package/dist/{chunk-6UAVKAG6.js.map → chunk-6QCXMCLZ.js.map} +0 -0
  266. /package/dist/{chunk-WMUN7ZUD.js.map → chunk-AA7LM2A3.js.map} +0 -0
  267. /package/dist/{chunk-TWPTRJEU.js.map → chunk-BBU3OD3D.js.map} +0 -0
  268. /package/dist/{chunk-4JDTLWUZ.js.map → chunk-DFFSCYIW.js.map} +0 -0
  269. /package/dist/{chunk-MKV2KYRV.js.map → chunk-ER3BQCCE.js.map} +0 -0
  270. /package/dist/{chunk-JU3JKOY5.js.map → chunk-EWAGI3EM.js.map} +0 -0
  271. /package/dist/{chunk-53PWELSC.js.map → chunk-FY33DKPH.js.map} +0 -0
  272. /package/dist/{chunk-7LLKPODL.js.map → chunk-LPAGIMXJ.js.map} +0 -0
  273. /package/dist/{chunk-3JQVA527.js.map → chunk-LU6NPJWN.js.map} +0 -0
  274. /package/dist/{chunk-OPGKH5RD.js.map → chunk-NFPSC2HL.js.map} +0 -0
  275. /package/dist/{chunk-4DJQU3PH.js.map → chunk-OCCNYGKG.js.map} +0 -0
  276. /package/dist/{chunk-YX6J3Z3Z.js.map → chunk-PBPYQZDW.js.map} +0 -0
  277. /package/dist/{chunk-HNX47VTC.js.map → chunk-UE72AQDZ.js.map} +0 -0
  278. /package/dist/{chunk-IGE6XWKK.js.map → chunk-VXVKEWYC.js.map} +0 -0
  279. /package/dist/{chunk-AD2PJGSS.js.map → chunk-ZDATYUYG.js.map} +0 -0
  280. /package/dist/{classified-marker-L7LXKS6Q.js.map → classified-marker-GWQTNDSL.js.map} +0 -0
  281. /package/dist/{collection-facade-KN3UFKZ4.js.map → collection-facade-56RTPO4G.js.map} +0 -0
  282. /package/dist/{dead-filter-6HG5FP3I.js.map → dead-filter-XP7MPHCJ.js.map} +0 -0
  283. /package/dist/{derive-XKAYJ2OA.js.map → derive-SVDY36ER.js.map} +0 -0
  284. /package/dist/{dispatch-56T7VPGE.js.map → dispatch-MG5KNMWG.js.map} +0 -0
  285. /package/dist/{dispatch-BM5GNCE2.js.map → dispatch-RVJQ4BOL.js.map} +0 -0
  286. /package/dist/{enclave-KDLGVX5Z.js.map → enclave-AOZTWFZK.js.map} +0 -0
  287. /package/dist/{executor-LFHRV6JH.js.map → executor-FRUVM36Q.js.map} +0 -0
  288. /package/dist/{export-accessible-HFBJ4JJY.js.map → export-accessible-HDDHZYPM.js.map} +0 -0
  289. /package/dist/{extract-partition-7ZRFN6QP.js.map → extract-partition-TRADP234.js.map} +0 -0
  290. /package/dist/{issue-LCOOEH45.js.map → issue-GZQDW5TQ.js.map} +0 -0
  291. /package/dist/{ledger-6IHXJHDD.js.map → ledger-KQAJPEMZ.js.map} +0 -0
  292. /package/dist/{liberate-UEYC4QLJ.js.map → liberate-Z2EXJY2S.js.map} +0 -0
  293. /package/dist/{link-set-XRVHGYWC.js.map → link-set-XKN5V7VM.js.map} +0 -0
  294. /package/dist/{managed-secret-IDAOXSSX.js.map → managed-secret-7WIIVMJ5.js.map} +0 -0
  295. /package/dist/{noydb-M5WII7RP.js.map → noydb-NPW3C2EX.js.map} +0 -0
  296. /package/dist/{post-register-O3YW6CGS.js.map → post-register-CVS7CCJE.js.map} +0 -0
  297. /package/dist/{register-XHOOX37G.js.map → register-GJ6PW4KP.js.map} +0 -0
  298. /package/dist/{registry-CYAFB35H.js.map → registry-6LUJ5IJW.js.map} +0 -0
  299. /package/dist/{registry-OFMM4WAC.js.map → registry-KI77RVK7.js.map} +0 -0
  300. /package/dist/{request-withdrawal-GCE2SLNW.js.map → request-withdrawal-LICOUGXG.js.map} +0 -0
  301. /package/dist/{reveal-UHBP5IH3.js.map → reveal-PWM47FQN.js.map} +0 -0
  302. /package/dist/{revoke-6KY4VGZY.js.map → revoke-AWZKZLZB.js.map} +0 -0
  303. /package/dist/{signer-SLOMB6HS.js.map → signer-JE6NEURY.js.map} +0 -0
  304. /package/dist/{stale-26ZJLNLG.js.map → stale-ZWTKUVZX.js.map} +0 -0
  305. /package/dist/{storage-N3IMFNGS.js.map → storage-WCZOCA46.js.map} +0 -0
  306. /package/dist/{walk-B4YFJJ7S.js.map → walk-HSS3NLQ3.js.map} +0 -0
  307. /package/dist/{withdraw-accessible-OYG7YZUR.js.map → withdraw-accessible-GHBA4DAA.js.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  buildRecordEnvelope,
3
3
  isDeleteMarker,
4
4
  isTombstone
5
- } from "./chunk-6E2JZRBD.js";
5
+ } from "./chunk-ZVAFJQZB.js";
6
6
  import {
7
7
  blindedEqual,
8
8
  openVdigPayload,
@@ -37,7 +37,7 @@ import {
37
37
  import {
38
38
  NOYDB_FORMAT_VERSION,
39
39
  SealedHandle
40
- } from "./chunk-SFY6NT7D.js";
40
+ } from "./chunk-3Y4OFWQJ.js";
41
41
  import {
42
42
  ClassifiedConfigError,
43
43
  ClassifiedRotationError,
@@ -48,6 +48,47 @@ import {
48
48
  ValidationError
49
49
  } from "./chunk-I64WQSN3.js";
50
50
 
51
+ // src/kernel/enclave/record-aad.ts
52
+ var SCHEME = "noydb-aad/2";
53
+ var encoder = new TextEncoder();
54
+ function buildRecordAad(identity) {
55
+ if (!Number.isFinite(identity.version)) {
56
+ throw new TypeError(
57
+ `record AAD: version must be a finite number for "${identity.collection}/${identity.id}", received ${String(identity.version)}. Sealing without one produces a record no reader can open.`
58
+ );
59
+ }
60
+ const parts = [encoder.encode(SCHEME)];
61
+ const pushField = (value) => {
62
+ const bytes = encoder.encode(value);
63
+ const len = new Uint8Array(4);
64
+ new DataView(len.buffer).setUint32(0, bytes.length, false);
65
+ parts.push(len, bytes);
66
+ };
67
+ pushField(identity.collection);
68
+ pushField(identity.id);
69
+ pushField(String(identity.tier ?? 0));
70
+ parts.push(new Uint8Array([identity.by === void 0 ? 0 : 1]));
71
+ if (identity.by !== void 0) pushField(identity.by);
72
+ pushField(String(identity.version));
73
+ const total = parts.reduce((n, p) => n + p.length, 0);
74
+ const out = new Uint8Array(total);
75
+ let offset = 0;
76
+ for (const p of parts) {
77
+ out.set(p, offset);
78
+ offset += p.length;
79
+ }
80
+ return out;
81
+ }
82
+ function recordAadFor(ref, envelope) {
83
+ return buildRecordAad({
84
+ collection: ref.collection,
85
+ id: ref.id,
86
+ version: envelope._v,
87
+ tier: envelope._tier,
88
+ by: envelope._by
89
+ });
90
+ }
91
+
51
92
  // src/kernel/enclave/record-keys/lifecycle.ts
52
93
  async function resolveStableCek(deps, id) {
53
94
  const cached = deps.cache?.get(id);
@@ -62,15 +103,17 @@ async function resolveStableCek(deps, id) {
62
103
  deps.cache?.set(id, fresh, 1);
63
104
  return fresh;
64
105
  }
65
- async function rewrapBodyToDek(envelope, fromDek, toDek) {
106
+ async function rewrapBodyToDek(from, to, envelope, fromDek, toDek) {
107
+ const openAad = buildRecordAad(from);
108
+ const sealAad = buildRecordAad(to);
66
109
  if (envelope._cek !== void 0) {
67
110
  const cek = await unwrapCek(envelope._cek, fromDek);
68
- const plaintext2 = await decrypt(envelope._iv, envelope._data, cek);
69
- const { iv: iv2, data: data2 } = await encrypt(plaintext2, cek);
111
+ const plaintext2 = await decrypt(envelope._iv, envelope._data, cek, openAad);
112
+ const { iv: iv2, data: data2 } = await encrypt(plaintext2, cek, sealAad);
70
113
  return { _iv: iv2, _data: data2, _cek: await wrapCek(cek, toDek), cek };
71
114
  }
72
- const plaintext = await decrypt(envelope._iv, envelope._data, fromDek);
73
- const { iv, data } = await encrypt(plaintext, toDek);
115
+ const plaintext = await decrypt(envelope._iv, envelope._data, fromDek, openAad);
116
+ const { iv, data } = await encrypt(plaintext, toDek, sealAad);
74
117
  return { _iv: iv, _data: data, cek: null };
75
118
  }
76
119
  function applyRewrappedBody(envelope, body) {
@@ -85,15 +128,15 @@ function applyRewrappedBody(envelope, body) {
85
128
  }
86
129
  return next;
87
130
  }
88
- async function rewrapEnvelope(envelope, fromDek, toDek) {
89
- return applyRewrappedBody(envelope, await rewrapBodyToDek(envelope, fromDek, toDek));
131
+ async function rewrapEnvelope(identity, envelope, fromDek, toDek) {
132
+ return applyRewrappedBody(envelope, await rewrapBodyToDek(identity, identity, envelope, fromDek, toDek));
90
133
  }
91
- async function isRewrappedUnder(envelope, dek) {
134
+ async function isRewrappedUnder(identity, envelope, dek) {
92
135
  try {
93
136
  if (envelope._cek !== void 0) {
94
137
  await unwrapCek(envelope._cek, dek);
95
138
  } else {
96
- await decrypt(envelope._iv, envelope._data, dek);
139
+ await decrypt(envelope._iv, envelope._data, dek, buildRecordAad(identity));
97
140
  }
98
141
  return true;
99
142
  } catch {
@@ -101,30 +144,31 @@ async function isRewrappedUnder(envelope, dek) {
101
144
  }
102
145
  }
103
146
 
104
- // src/kernel/enclave/record-aad.ts
105
- var SCHEME = "noydb-aad/1";
106
- var encoder = new TextEncoder();
107
- function buildRecordAad(identity) {
108
- const parts = [encoder.encode(SCHEME)];
109
- const pushField = (value) => {
110
- const bytes = encoder.encode(value);
111
- const len = new Uint8Array(4);
112
- new DataView(len.buffer).setUint32(0, bytes.length, false);
113
- parts.push(len, bytes);
114
- };
115
- pushField(identity.collection);
116
- pushField(identity.id);
117
- pushField(String(identity.tier ?? 0));
118
- parts.push(new Uint8Array([identity.by === void 0 ? 0 : 1]));
119
- if (identity.by !== void 0) pushField(identity.by);
120
- const total = parts.reduce((n, p) => n + p.length, 0);
121
- const out = new Uint8Array(total);
122
- let offset = 0;
123
- for (const p of parts) {
124
- out.set(p, offset);
125
- offset += p.length;
147
+ // src/kernel/enclave/record-keys/rekey.ts
148
+ async function rekeyEnvelopeToDek(ref, envelope, oldDek, newDek) {
149
+ const aad = recordAadFor(ref, envelope);
150
+ const { _bidx, ...carried } = envelope;
151
+ void _bidx;
152
+ if (envelope._cek !== void 0) {
153
+ const cek = await unwrapCek(envelope._cek, oldDek);
154
+ return { ...carried, _cek: await wrapCek(cek, newDek) };
155
+ }
156
+ const plaintext = await decrypt(envelope._iv, envelope._data, oldDek, aad);
157
+ const { iv, data } = await encrypt(plaintext, newDek, aad);
158
+ return { ...carried, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data };
159
+ }
160
+ async function rekeyEnvelopeIfNeeded(ref, envelope, oldDek, newDek) {
161
+ try {
162
+ return await rekeyEnvelopeToDek(ref, envelope, oldDek, newDek);
163
+ } catch (errUnderOld) {
164
+ try {
165
+ if (envelope._cek !== void 0) await unwrapCek(envelope._cek, newDek);
166
+ else await decrypt(envelope._iv, envelope._data, newDek, recordAadFor(ref, envelope));
167
+ return null;
168
+ } catch {
169
+ throw errUnderOld;
170
+ }
126
171
  }
127
- return out;
128
172
  }
129
173
 
130
174
  // src/kernel/enclave/record-keys/sealed-slots.ts
@@ -202,22 +246,17 @@ function makeReservedEnvelopes(dekResolver, declaredPrefixes) {
202
246
  );
203
247
  }
204
248
  };
205
- const encryptForPrefix = async (collection, json, v) => {
206
- assertPrefixed(collection, "encrypt");
207
- const dek = await dekResolver(collection);
208
- const { iv, data } = await encrypt(json, dek);
209
- return {
210
- _noydb: NOYDB_FORMAT_VERSION,
211
- _v: v,
212
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
213
- _iv: iv,
214
- _data: data
215
- };
249
+ const encryptForPrefix = async (ref, json, v) => {
250
+ assertPrefixed(ref.collection, "encrypt");
251
+ const dek = await dekResolver(ref.collection);
252
+ const identity = { ...ref, version: v };
253
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(identity));
254
+ return buildRecordEnvelope(identity, { iv, data });
216
255
  };
217
- const decryptForPrefix = async (collection, env) => {
256
+ const decryptForPrefix = async (collection, id, env) => {
218
257
  assertPrefixed(collection, "decrypt");
219
258
  const dek = await dekResolver(collection);
220
- return decrypt(env._iv, env._data, dek);
259
+ return decrypt(env._iv, env._data, dek, recordAadFor({ collection, id }, env));
221
260
  };
222
261
  return { encrypt: encryptForPrefix, decrypt: decryptForPrefix };
223
262
  };
@@ -347,30 +386,12 @@ var RecordCodec = class _RecordCodec {
347
386
  * parts. Pure, no crypto. Each call stamps its own `_ts` — provenance carries
348
387
  * a SEPARATE timestamp (computed by the caller), so the two never share one.
349
388
  */
350
- static buildEnvelope(p) {
351
- return {
352
- _noydb: NOYDB_FORMAT_VERSION,
353
- _v: p.version,
354
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
355
- _iv: p.iv,
356
- _data: p.data,
357
- ...p.by !== void 0 ? { _by: p.by } : {},
358
- ...p.cek !== void 0 ? { _cek: p.cek } : {},
359
- ...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {},
360
- ...p.extra ?? {}
361
- };
389
+ static buildEnvelope(identity, p) {
390
+ return buildRecordEnvelope(identity, p);
362
391
  }
363
392
  /** Plaintext (`_iv:''`) body envelope — the `!storeCiphertext` shape. */
364
- static buildPlaintextEnvelope(p) {
365
- return {
366
- _noydb: NOYDB_FORMAT_VERSION,
367
- _v: p.version,
368
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
369
- _iv: "",
370
- _data: p.data,
371
- ...p.by !== void 0 ? { _by: p.by } : {},
372
- ...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {}
373
- };
393
+ static buildPlaintextEnvelope(identity, p) {
394
+ return buildRecordEnvelope(identity, { ...p, iv: "" });
374
395
  }
375
396
  // ──────────────────────────────────────────────────────────────────────
376
397
  // Write path
@@ -383,22 +404,20 @@ var RecordCodec = class _RecordCodec {
383
404
  * (see {@link encryptRecord}). Rejects `_`-prefixed record fields, which
384
405
  * would collide with the reserved metadata namespace.
385
406
  */
386
- buildDebugEnvelope(record, version, source, sourceTs) {
407
+ buildDebugEnvelope(id, record, version, source, sourceTs) {
387
408
  const rec = record;
388
409
  for (const key of Object.keys(rec)) {
389
410
  if (key.startsWith("_")) throw new DebugReservedFieldError(this.ctx.name, key);
390
411
  }
391
- return {
392
- _noydb: NOYDB_FORMAT_VERSION,
393
- _v: version,
394
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
395
- _iv: "",
396
- _data: "",
397
- _by: this.ctx.actor,
398
- _debug: NOYDB_FORMAT_VERSION,
399
- ...this.ctx.provenance && source !== void 0 ? { _source: source, _sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } : {},
400
- ...rec
401
- };
412
+ const base = buildRecordEnvelope(
413
+ { collection: this.ctx.name, id, by: this.ctx.actor, version },
414
+ {
415
+ iv: "",
416
+ data: "",
417
+ ...this.ctx.provenance && source !== void 0 ? { provenance: { source, sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } } : {}
418
+ }
419
+ );
420
+ return { ...base, _debug: NOYDB_FORMAT_VERSION, ...rec };
402
421
  }
403
422
  /**
404
423
  * Encrypt a JSON body into an envelope.
@@ -409,24 +428,56 @@ var RecordCodec = class _RecordCodec {
409
428
  * path encrypts the body directly under the collection DEK — byte-identical
410
429
  * to pre-CEK behaviour, so non-adopting collections pay nothing.
411
430
  */
412
- async encryptJsonString(json, version, cek, source, sourceTs) {
413
- const by = this.ctx.actor;
431
+ /**
432
+ * `ref` is the identity the envelope is sealed against, and it is **the
433
+ * location the bytes are stored at** — not necessarily this codec's own
434
+ * collection (#1051).
435
+ *
436
+ * That distinction was discovered here rather than assumed. Several callers
437
+ * put the result somewhere else entirely: search's vector sidecar lands in
438
+ * `_vec` under `encodeVecId(name, id)`, the lexical index under `_ft/<name>`,
439
+ * indexing's entries under a synthetic `idxId`. A codec that supplied
440
+ * `this.ctx.name` for those would seal them against a collection they are not
441
+ * in, and once AAD binds identity every one of them would fail to verify.
442
+ *
443
+ * ⚠️ **`_history` is the open case, and it is #1041's to settle.** Snapshots
444
+ * are produced with the LIVE record's identity here and then re-homed by
445
+ * `saveHistory` into `_history/<historyId(collection,id,_v)>`. Both readings
446
+ * are defensible — bind where it lives, or bind what it is a copy of — and
447
+ * the choice must be made before AAD is switched on, not inferred from this
448
+ * migration.
449
+ */
450
+ async encryptJsonString(ref, json, version, cek, source, sourceTs) {
451
+ const identity = { ...ref, version, by: this.ctx.actor };
414
452
  const provenance = this.ctx.provenance && source !== void 0 ? { source, sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } : void 0;
415
453
  if (!this.ctx.storeCiphertext) {
416
- return _RecordCodec.buildPlaintextEnvelope({ version, data: json, by, provenance });
454
+ return _RecordCodec.buildPlaintextEnvelope(identity, { data: json, provenance });
417
455
  }
418
456
  const dek = await this.ctx.getDEK();
457
+ const aad = buildRecordAad(identity);
419
458
  if (cek !== void 0) {
420
- const { iv: iv2, data: data2 } = await encrypt(json, cek);
459
+ const { iv: iv2, data: data2 } = await encrypt(json, cek, aad);
421
460
  const wrapped = await wrapCek(cek, dek);
422
- return _RecordCodec.buildEnvelope({ version, iv: iv2, data: data2, by, cek: wrapped, provenance });
461
+ return _RecordCodec.buildEnvelope(identity, { iv: iv2, data: data2, cek: wrapped, provenance });
423
462
  }
424
- const { iv, data } = await encrypt(json, dek);
425
- return _RecordCodec.buildEnvelope({ version, iv, data, by, provenance });
463
+ const { iv, data } = await encrypt(json, dek, aad);
464
+ return _RecordCodec.buildEnvelope(identity, { iv, data, provenance });
426
465
  }
427
- async encryptRecord(record, version, cek, source, sourceTs, vdig, id) {
466
+ /**
467
+ * `ref` is FIRST and required (#1051). It was previously a trailing optional
468
+ * `id?: string`, which TypeScript cannot promote to required because it sits
469
+ * after other optionals — so the migration would have needed an `id ?? ''`
470
+ * fallback. That is exactly the silent default this issue exists to remove:
471
+ * once identity is bound into the AEAD, every record written with an empty id
472
+ * binds to the SAME identity and becomes interchangeable with the others.
473
+ * An object, not a bare string, so a swap with `version`/`source` cannot
474
+ * compile on the hottest write path. Carries the collection too — see
475
+ * {@link encryptJsonString} for why the codec must not assume its own.
476
+ */
477
+ async encryptRecord(ref, record, version, cek, source, sourceTs, vdig) {
478
+ const id = ref.id;
428
479
  if (!this.ctx.storeCiphertext && this.ctx.debugPlaintext && !this.ctx.name.startsWith("_")) {
429
- return this.buildDebugEnvelope(record, version, source, sourceTs);
480
+ return this.buildDebugEnvelope(id, record, version, source, sourceTs);
430
481
  }
431
482
  if (this.ctx.storeCiphertext) {
432
483
  const declared = this.ctx.vdigFields;
@@ -453,9 +504,9 @@ var RecordCodec = class _RecordCodec {
453
504
  let openRecord = record;
454
505
  let sealed;
455
506
  if (this.ctx.storeCiphertext && this.ctx.via?.hasAtRestHooks) {
456
- if (id === void 0) {
507
+ if (id === "") {
457
508
  throw new Error(
458
- `RecordCodec.encryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this write path supplied no record id (needed to scope the sealed-slot capability) \u2014 caller bug.`
509
+ `RecordCodec.encryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this write path supplied an empty record id (needed to scope the sealed-slot capability) \u2014 caller bug.`
459
510
  );
460
511
  }
461
512
  const src = record;
@@ -463,7 +514,7 @@ var RecordCodec = class _RecordCodec {
463
514
  openRecord = result.record;
464
515
  if (result.sealed !== void 0) {
465
516
  sealed = {};
466
- for (const [field, ref] of Object.entries(result.sealed)) sealed[field] = `${ref.iv}:${ref.data}`;
517
+ for (const [field, ref2] of Object.entries(result.sealed)) sealed[field] = `${ref2.iv}:${ref2.data}`;
467
518
  }
468
519
  } else if (this.ctx.storeCiphertext && this.ctx.sensitiveFields.size > 0) {
469
520
  const src = record;
@@ -528,7 +579,7 @@ var RecordCodec = class _RecordCodec {
528
579
  if (Object.keys(out).length > 0) vdigOut = out;
529
580
  if (Object.keys(bidxOut).length > 0) bidxOutMap = bidxOut;
530
581
  }
531
- const base = await this.encryptJsonString(JSON.stringify(openRecord), version, cek, source, sourceTs);
582
+ const base = await this.encryptJsonString(ref, JSON.stringify(openRecord), version, cek, source, sourceTs);
532
583
  const withSealed = sealed ? { ...base, _sealed: sealed } : base;
533
584
  const withVdig = vdigOut ? { ...withSealed, _vdig: vdigOut } : withSealed;
534
585
  const withBidx = bidxOutMap ? { ...withVdig, _bidx: bidxOutMap } : withVdig;
@@ -583,7 +634,15 @@ var RecordCodec = class _RecordCodec {
583
634
  * The optional `id` lets reads populate the CEK cache; it is omitted by
584
635
  * callers (history, conflict merge) that have only the envelope.
585
636
  */
586
- async decryptJsonString(envelope, id) {
637
+ /**
638
+ * `ref` must be the SAME identity the writer sealed against — which is the
639
+ * storage address, not necessarily this codec's own collection. Search's
640
+ * vector sidecar lives in `_vec`, its lexical index in `_ft`; passing
641
+ * `this.ctx.name` for those would recompute the wrong AAD and fail to open a
642
+ * perfectly good record (#1041).
643
+ */
644
+ async decryptJsonString(ref, envelope) {
645
+ const id = ref.id;
587
646
  if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
588
647
  if (!this.ctx.storeCiphertext) {
589
648
  if (envelope._debug !== void 0) {
@@ -595,10 +654,11 @@ var RecordCodec = class _RecordCodec {
595
654
  }
596
655
  return envelope._data === "" ? null : envelope._data;
597
656
  }
657
+ const aad = recordAadFor(ref, envelope);
598
658
  const cek = await this.resolveEnvelopeCek(envelope, id);
599
- if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek);
659
+ if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek, aad);
600
660
  const dek = await this.ctx.getDEK();
601
- return decrypt(envelope._iv, envelope._data, dek);
661
+ return decrypt(envelope._iv, envelope._data, dek, aad);
602
662
  }
603
663
  /**
604
664
  * Unseal a single `_sealed[field]` slot to its plaintext value: derive the
@@ -722,7 +782,7 @@ var RecordCodec = class _RecordCodec {
722
782
  */
723
783
  async applySealedSlots(record, sealed, cek, opts = {}) {
724
784
  if (this.ctx.via?.hasAtRestHooks) {
725
- if (opts.id === void 0) {
785
+ if (opts.id === void 0 || opts.id === "") {
726
786
  throw new Error(
727
787
  `RecordCodec.decryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this read path supplied no record id (needed to scope the sealed-slot capability) \u2014 caller bug.`
728
788
  );
@@ -772,15 +832,17 @@ var RecordCodec = class _RecordCodec {
772
832
  * output-recompute path, not the public per-record read surface schema
773
833
  * validation guards.
774
834
  */
775
- async decryptRecordAtDek(envelope, dek, id) {
835
+ async decryptRecordAtDek(ref, envelope, dek) {
836
+ const id = ref.id;
776
837
  if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
777
838
  let plaintext;
778
839
  let cek;
840
+ const aad = recordAadFor(ref, envelope);
779
841
  if (envelope._cek !== void 0) {
780
842
  cek = await unwrapCek(envelope._cek, dek);
781
- plaintext = await decrypt(envelope._iv, envelope._data, cek);
843
+ plaintext = await decrypt(envelope._iv, envelope._data, cek, aad);
782
844
  } else {
783
- plaintext = await decrypt(envelope._iv, envelope._data, dek);
845
+ plaintext = await decrypt(envelope._iv, envelope._data, dek, aad);
784
846
  }
785
847
  let record = JSON.parse(plaintext);
786
848
  if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
@@ -803,8 +865,8 @@ var RecordCodec = class _RecordCodec {
803
865
  * that may predate a schema change, so validating it would be a
804
866
  * false positive. Every non-history read leaves this flag `false`.
805
867
  */
806
- async decryptRecord(envelope, opts = {}) {
807
- const json = await this.decryptJsonString(envelope, opts.id);
868
+ async decryptRecord(ref, envelope, opts = {}) {
869
+ const json = await this.decryptJsonString(ref, envelope);
808
870
  if (json === null) return null;
809
871
  let parsed = JSON.parse(json);
810
872
  if (this.ctx.crdtMode && parsed !== null && typeof parsed === "object" && "_crdt" in parsed) {
@@ -812,9 +874,9 @@ var RecordCodec = class _RecordCodec {
812
874
  }
813
875
  let record = parsed;
814
876
  if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
815
- const sealedCek = await this.resolveEnvelopeCek(envelope, opts.id);
877
+ const sealedCek = await this.resolveEnvelopeCek(envelope, ref.id);
816
878
  record = await this.applySealedSlots(record, envelope._sealed, sealedCek, {
817
- ...opts.id !== void 0 ? { id: opts.id } : {},
879
+ id: ref.id,
818
880
  ...opts.sealedAsHandles !== void 0 ? { sealedAsHandles: opts.sealedAsHandles } : {}
819
881
  });
820
882
  }
@@ -869,9 +931,8 @@ async function sealRecordToHost(ctx, collection, id, hostSealer, opts) {
869
931
  const envelopeKey = `${collection}/${id}/${hint.pid}`;
870
932
  const prior = await ctx.adapter.get(ctx.vault, SEALED_CEK_NS, envelopeKey);
871
933
  const env = buildRecordEnvelope(
872
- { collection: SEALED_CEK_NS, id: envelopeKey },
934
+ { collection: SEALED_CEK_NS, id: envelopeKey, version: (prior?._v ?? 0) + 1 },
873
935
  {
874
- version: (prior?._v ?? 0) + 1,
875
936
  // AES-GCM bypassed — the sealing layer is the security boundary, exactly
876
937
  // like the managed-secret `_meta/sealed-secret` envelope.
877
938
  iv: "",
@@ -896,9 +957,26 @@ async function rotateRecordCek(ctx, collection, id) {
896
957
  }
897
958
  const dek = await ctx.getDEK(collection);
898
959
  const oldCek = await unwrapCek(live._cek, dek);
899
- const json = await decrypt(live._iv, live._data, oldCek);
960
+ const openAad = recordAadFor({ collection, id }, live);
961
+ const json = await decrypt(live._iv, live._data, oldCek, openAad);
962
+ const rotatedIdentity = {
963
+ // A CEK rotation DOES bump `_v` (asserted in `record-scoped-cek-sealing`:
964
+ // "the live envelope was re-keyed — new `_cek`, bumped `_v`"), so it seals
965
+ // at the new version, not the one it just opened.
966
+ //
967
+ // ⚠️ Do not confuse this with `rekeyEnvelopeToDek`, the DEK-rotation helper,
968
+ // which PRESERVES `_v` (#1074) because it re-keys a record without writing
969
+ // one. Two rotations, opposite answers — and with `_v` bound (#1093) getting
970
+ // it backwards no longer produces a wrong number, it produces an
971
+ // unreadable record.
972
+ collection,
973
+ id,
974
+ version: live._v + 1,
975
+ ...live._tier !== void 0 ? { tier: live._tier } : {},
976
+ ...ctx.actor ? { by: ctx.actor } : live._by !== void 0 ? { by: live._by } : {}
977
+ };
900
978
  const newCek = await generateDEK();
901
- const { iv, data } = await encrypt(json, newCek);
979
+ const { iv, data } = await encrypt(json, newCek, buildRecordAad(rotatedIdentity));
902
980
  let sealedOut;
903
981
  if (live._sealed !== void 0) {
904
982
  const out = {};
@@ -918,14 +996,11 @@ async function rotateRecordCek(ctx, collection, id) {
918
996
  }
919
997
  vdigOut = out;
920
998
  }
921
- const env = buildRecordEnvelope({ collection, id }, {
922
- version: live._v + 1,
999
+ const env = buildRecordEnvelope(rotatedIdentity, {
923
1000
  iv,
924
1001
  data,
925
1002
  cek: await wrapCek(newCek, dek),
926
- ...ctx.actor ? { by: ctx.actor } : {},
927
1003
  extra: {
928
- ...live._tier !== void 0 ? { _tier: live._tier } : {},
929
1004
  ...live._det !== void 0 ? { _det: live._det } : {},
930
1005
  // `_bidx` (equality-index tag) is DEK-rooted and CEK-independent, so it is
931
1006
  // carried forward VERBATIM — not recomputed — unlike `_vdig`/`_sealed`
@@ -985,7 +1060,7 @@ async function findByDet(ctx, field, value) {
985
1060
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
986
1061
  if (!env || !env._det || (env._tier ?? 0) > 0) continue;
987
1062
  if (env._det[field] === target || env._det[field] === legacyTarget) {
988
- return ctx.codec.decryptRecord(env, { id });
1063
+ return ctx.codec.decryptRecord({ collection: ctx.name, id }, env);
989
1064
  }
990
1065
  }
991
1066
  return null;
@@ -999,7 +1074,7 @@ async function queryByDet(ctx, field, value) {
999
1074
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
1000
1075
  if (!env || !env._det || (env._tier ?? 0) > 0) continue;
1001
1076
  if (env._det[field] === target || env._det[field] === legacyTarget) {
1002
- const rec = await ctx.codec.decryptRecord(env, { id });
1077
+ const rec = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env);
1003
1078
  if (rec !== null) matches.push(rec);
1004
1079
  }
1005
1080
  }
@@ -1007,23 +1082,25 @@ async function queryByDet(ctx, field, value) {
1007
1082
  }
1008
1083
 
1009
1084
  // src/kernel/enclave/record-keys/envelope-body.ts
1010
- async function openEnvelopeJson(env, key, opts) {
1085
+ async function openEnvelopeJson(ref, env, key, opts) {
1011
1086
  if (opts?.encrypted === false) return env._data;
1087
+ const aad = recordAadFor(ref, env);
1012
1088
  if (env._cek !== void 0) {
1013
1089
  const cek = await unwrapCek(env._cek, key);
1014
- return decrypt(env._iv, env._data, cek);
1090
+ return decrypt(env._iv, env._data, cek, aad);
1015
1091
  }
1016
- return decrypt(env._iv, env._data, key);
1092
+ return decrypt(env._iv, env._data, key, aad);
1017
1093
  }
1018
- async function writeEnvelopeBody(json, key, opts) {
1094
+ async function writeEnvelopeBody(identity, json, key, opts) {
1019
1095
  if (opts?.encrypted === false) return { _iv: "", _data: json };
1096
+ const aad = buildRecordAad(identity);
1020
1097
  if (opts?.perRecordKey === true) {
1021
1098
  const cek = await generateDEK();
1022
- const { iv: iv2, data: data2 } = await encrypt(json, cek);
1099
+ const { iv: iv2, data: data2 } = await encrypt(json, cek, aad);
1023
1100
  const wrapped = await wrapCek(cek, key);
1024
1101
  return { _iv: iv2, _data: data2, _cek: wrapped };
1025
1102
  }
1026
- const { iv, data } = await encrypt(json, key);
1103
+ const { iv, data } = await encrypt(json, key, aad);
1027
1104
  return { _iv: iv, _data: data };
1028
1105
  }
1029
1106
  function envelopeBodySize(env) {
@@ -1046,6 +1123,18 @@ function envelopeBodyForHash(env) {
1046
1123
  if (env._bidx !== void 0) segments.push(mapPart("_bidx", env._bidx));
1047
1124
  return `{${segments.join(",")}}`;
1048
1125
  }
1126
+ function hasSealedBody(env) {
1127
+ return env._iv !== "";
1128
+ }
1129
+ async function verifyRecordIdentity(ref, env, key) {
1130
+ if (!hasSealedBody(env)) return true;
1131
+ try {
1132
+ await openEnvelopeJson(ref, env, key);
1133
+ return true;
1134
+ } catch {
1135
+ return false;
1136
+ }
1137
+ }
1049
1138
 
1050
1139
  // src/kernel/enclave/broker/proof.ts
1051
1140
  var subtle2 = globalThis.crypto.subtle;
@@ -1131,12 +1220,15 @@ async function verifyBrokerProof(args) {
1131
1220
  }
1132
1221
 
1133
1222
  export {
1223
+ buildRecordAad,
1224
+ recordAadFor,
1134
1225
  resolveStableCek,
1135
1226
  rewrapBodyToDek,
1136
1227
  applyRewrappedBody,
1137
1228
  rewrapEnvelope,
1138
1229
  isRewrappedUnder,
1139
- buildRecordAad,
1230
+ rekeyEnvelopeToDek,
1231
+ rekeyEnvelopeIfNeeded,
1140
1232
  makeReservedEnvelopes,
1141
1233
  validateSchemaInput,
1142
1234
  validateSchemaOutput,
@@ -1152,10 +1244,12 @@ export {
1152
1244
  envelopeBodySize,
1153
1245
  hasPerRecordKey,
1154
1246
  envelopeBodyForHash,
1247
+ hasSealedBody,
1248
+ verifyRecordIdentity,
1155
1249
  deriveBrokerProofBits,
1156
1250
  deriveBrokerProofKey,
1157
1251
  computeBrokerProof,
1158
1252
  issueChallenge,
1159
1253
  verifyBrokerProof
1160
1254
  };
1161
- //# sourceMappingURL=chunk-LTVETWDH.js.map
1255
+ //# sourceMappingURL=chunk-X3AXSYBL.js.map