@noy-db/hub 0.3.0-pre.1 → 0.3.0-pre.10

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 (435) hide show
  1. package/dist/aggregate/index.d.ts +3 -4
  2. package/dist/aggregate/index.js +9 -8
  3. package/dist/aggregate/index.js.map +1 -1
  4. package/dist/api-TX2EX2FX.js +20 -0
  5. package/dist/as/index.d.ts +4 -5
  6. package/dist/as/index.js +12 -6
  7. package/dist/at/index.d.ts +2 -3
  8. package/dist/attestation/index.d.ts +3 -4
  9. package/dist/attestation/index.js +19 -13
  10. package/dist/attestation/index.js.map +1 -1
  11. package/dist/{backup-XV3IOEGB.js → backup-R7NTDFKY.js} +14 -6
  12. package/dist/backup-R7NTDFKY.js.map +1 -0
  13. package/dist/blobs/index.d.ts +4 -5
  14. package/dist/blobs/index.js +12 -6
  15. package/dist/blobs/index.js.map +1 -1
  16. package/dist/bundle/index.d.ts +5 -6
  17. package/dist/bundle/index.js +21 -15
  18. package/dist/bundle/index.js.map +1 -1
  19. package/dist/{bundle-CH-H06dp.d.ts → bundle-D6GxiUfq.d.ts} +1 -1
  20. package/dist/by/index.js +2 -2
  21. package/dist/cargo/index.d.ts +4 -6
  22. package/dist/cargo/index.js +27 -21
  23. package/dist/chunk-2OV5NVE7.js +95 -0
  24. package/dist/chunk-2OV5NVE7.js.map +1 -0
  25. package/dist/{chunk-5N6CZTCY.js → chunk-2OZXVKVP.js} +3 -3
  26. package/dist/{chunk-BG3SPSR4.js → chunk-2REPHKET.js} +5 -4
  27. package/dist/chunk-2REPHKET.js.map +1 -0
  28. package/dist/{chunk-LXQT4WMP.js → chunk-3JXPAHOZ.js} +8 -6
  29. package/dist/{chunk-LXQT4WMP.js.map → chunk-3JXPAHOZ.js.map} +1 -1
  30. package/dist/{chunk-UAG5KWVA.js → chunk-3MATJ6O4.js} +3 -3
  31. package/dist/chunk-3OPY6MK2.js +404 -0
  32. package/dist/chunk-3OPY6MK2.js.map +1 -0
  33. package/dist/{chunk-62QYRORB.js → chunk-3QSIU3UT.js} +34 -63
  34. package/dist/chunk-3QSIU3UT.js.map +1 -0
  35. package/dist/{chunk-DGDI2D4M.js → chunk-4OMCIY6F.js} +29 -9
  36. package/dist/chunk-4OMCIY6F.js.map +1 -0
  37. package/dist/chunk-5I35DOHK.js +94 -0
  38. package/dist/chunk-5I35DOHK.js.map +1 -0
  39. package/dist/{chunk-2P2HZEXU.js → chunk-5VG4IJR7.js} +11 -9
  40. package/dist/{chunk-2P2HZEXU.js.map → chunk-5VG4IJR7.js.map} +1 -1
  41. package/dist/{chunk-AZAOEIKW.js → chunk-5YESYH2C.js} +2 -2
  42. package/dist/{chunk-GYGWYIOZ.js → chunk-6G5ORS5D.js} +7 -5
  43. package/dist/{chunk-GYGWYIOZ.js.map → chunk-6G5ORS5D.js.map} +1 -1
  44. package/dist/{chunk-VCTFO5CO.js → chunk-6P5XCKSD.js} +2 -2
  45. package/dist/{chunk-IO6GRPT6.js → chunk-7BWJHO2A.js} +2 -2
  46. package/dist/{chunk-IPB7FTQX.js → chunk-7P2SDJG3.js} +15 -9
  47. package/dist/chunk-7P2SDJG3.js.map +1 -0
  48. package/dist/{chunk-SRB2XEWB.js → chunk-ANB77BVV.js} +6 -4
  49. package/dist/chunk-ANB77BVV.js.map +1 -0
  50. package/dist/{chunk-UDRIWL7A.js → chunk-BKARNZJN.js} +3 -3
  51. package/dist/{chunk-Y22T3KQE.js → chunk-BQISD5ZV.js} +3 -3
  52. package/dist/chunk-BQISD5ZV.js.map +1 -0
  53. package/dist/{chunk-UIU2THRG.js → chunk-BUAQ7YI3.js} +138 -378
  54. package/dist/chunk-BUAQ7YI3.js.map +1 -0
  55. package/dist/{chunk-V7RWQRG7.js → chunk-CB7CWSKW.js} +3 -3
  56. package/dist/{chunk-LV7M27WM.js → chunk-DFVUTGT2.js} +14 -201
  57. package/dist/chunk-DFVUTGT2.js.map +1 -0
  58. package/dist/{chunk-CWPPNPOH.js → chunk-DJ7KIPLV.js} +2 -2
  59. package/dist/{chunk-5R5JW2JT.js → chunk-DSKDQP3G.js} +3480 -1916
  60. package/dist/chunk-DSKDQP3G.js.map +1 -0
  61. package/dist/{chunk-VFQGRQIH.js → chunk-DV4HUP5G.js} +7 -5
  62. package/dist/{chunk-VFQGRQIH.js.map → chunk-DV4HUP5G.js.map} +1 -1
  63. package/dist/{chunk-5LUY7UTV.js → chunk-EOXAAJTY.js} +289 -48
  64. package/dist/chunk-EOXAAJTY.js.map +1 -0
  65. package/dist/chunk-ET67AY6B.js +74 -0
  66. package/dist/chunk-ET67AY6B.js.map +1 -0
  67. package/dist/{chunk-TA66UMI4.js → chunk-F4CEK5YM.js} +2 -2
  68. package/dist/chunk-FORYWFN6.js +130 -0
  69. package/dist/chunk-FORYWFN6.js.map +1 -0
  70. package/dist/{chunk-IELYAOGG.js → chunk-FRP6D2DM.js} +19 -6
  71. package/dist/chunk-FRP6D2DM.js.map +1 -0
  72. package/dist/chunk-FUOE7UUV.js +341 -0
  73. package/dist/chunk-FUOE7UUV.js.map +1 -0
  74. package/dist/{chunk-SM3AVUHC.js → chunk-G4JYND6L.js} +2 -2
  75. package/dist/{chunk-AXRXJTE2.js → chunk-G6XV4H65.js} +5 -5
  76. package/dist/{chunk-I2NOIW44.js → chunk-GNMXXTMN.js} +8 -6
  77. package/dist/{chunk-I2NOIW44.js.map → chunk-GNMXXTMN.js.map} +1 -1
  78. package/dist/chunk-GYGLAVCX.js +19 -0
  79. package/dist/chunk-GYGLAVCX.js.map +1 -0
  80. package/dist/{chunk-UV5MFVO3.js → chunk-HPWKV3YB.js} +2 -2
  81. package/dist/chunk-HY3AUMFI.js +41 -0
  82. package/dist/chunk-HY3AUMFI.js.map +1 -0
  83. package/dist/chunk-HYR4WZZ3.js +69 -0
  84. package/dist/chunk-HYR4WZZ3.js.map +1 -0
  85. package/dist/{chunk-SKF73JOP.js → chunk-ICXIFFYZ.js} +3 -3
  86. package/dist/chunk-IGJCYUT5.js +99 -0
  87. package/dist/chunk-IGJCYUT5.js.map +1 -0
  88. package/dist/{chunk-MD3Y6J3L.js → chunk-IVLTXX4W.js} +7 -5
  89. package/dist/{chunk-MD3Y6J3L.js.map → chunk-IVLTXX4W.js.map} +1 -1
  90. package/dist/{chunk-WWGT2MDV.js → chunk-J4LPNIGK.js} +26 -11
  91. package/dist/chunk-J4LPNIGK.js.map +1 -0
  92. package/dist/chunk-JJZ2LW6T.js +36 -0
  93. package/dist/chunk-JJZ2LW6T.js.map +1 -0
  94. package/dist/{chunk-RUIMKQTA.js → chunk-JK733I5V.js} +1 -1
  95. package/dist/chunk-JK733I5V.js.map +1 -0
  96. package/dist/{chunk-UPJNJGGA.js → chunk-KJ2BCBTL.js} +25 -8
  97. package/dist/chunk-KJ2BCBTL.js.map +1 -0
  98. package/dist/{chunk-LMTH2RM6.js → chunk-KNZB6JMR.js} +2 -2
  99. package/dist/{chunk-I3TIKTJO.js → chunk-KPZS5QAQ.js} +29 -10
  100. package/dist/chunk-KPZS5QAQ.js.map +1 -0
  101. package/dist/{chunk-PKHL44ER.js → chunk-LEJIKBBB.js} +2 -2
  102. package/dist/{chunk-AQTBSL7R.js → chunk-LL2NIVUR.js} +14 -7
  103. package/dist/chunk-LL2NIVUR.js.map +1 -0
  104. package/dist/chunk-LP7BEXCT.js +32 -0
  105. package/dist/chunk-LP7BEXCT.js.map +1 -0
  106. package/dist/{chunk-5O3AOPDT.js → chunk-MCHVVJIA.js} +443 -467
  107. package/dist/chunk-MCHVVJIA.js.map +1 -0
  108. package/dist/chunk-NO272T7Q.js +194 -0
  109. package/dist/chunk-NO272T7Q.js.map +1 -0
  110. package/dist/{chunk-LFLXAY2W.js → chunk-NUEQU36L.js} +71 -93
  111. package/dist/chunk-NUEQU36L.js.map +1 -0
  112. package/dist/chunk-O45M6LDB.js +38 -0
  113. package/dist/chunk-O45M6LDB.js.map +1 -0
  114. package/dist/{chunk-PSMV73A5.js → chunk-OBKWYKYC.js} +5 -5
  115. package/dist/{chunk-CMGR4ZEW.js → chunk-OHHKHSJP.js} +2 -2
  116. package/dist/{chunk-HCIPRAGS.js → chunk-OT76OZL6.js} +2 -2
  117. package/dist/{chunk-ITNUCOXM.js → chunk-OVYRLHPE.js} +7 -5
  118. package/dist/{chunk-ITNUCOXM.js.map → chunk-OVYRLHPE.js.map} +1 -1
  119. package/dist/{chunk-SMXWYP24.js → chunk-OXCSVM3B.js} +3 -3
  120. package/dist/{chunk-IGUYVGGI.js → chunk-P33LUIML.js} +3 -3
  121. package/dist/{chunk-JNUWZ6D3.js → chunk-PLS64NCS.js} +7 -5
  122. package/dist/{chunk-JNUWZ6D3.js.map → chunk-PLS64NCS.js.map} +1 -1
  123. package/dist/{chunk-EIZUR2XW.js → chunk-PS2NEWEX.js} +2 -2
  124. package/dist/chunk-QA2KUPCP.js +45 -0
  125. package/dist/chunk-QA2KUPCP.js.map +1 -0
  126. package/dist/{chunk-WYSO2NIH.js → chunk-QOC3VYL2.js} +2 -2
  127. package/dist/{chunk-FISN7WE4.js → chunk-QSFOZUYL.js} +30 -5
  128. package/dist/{chunk-FISN7WE4.js.map → chunk-QSFOZUYL.js.map} +1 -1
  129. package/dist/{chunk-KVOXU4T5.js → chunk-RHK32N73.js} +2 -2
  130. package/dist/{chunk-3YFXJ3ZP.js → chunk-RW3Y22MW.js} +2 -2
  131. package/dist/{chunk-ZYUC53LT.js → chunk-S7VFUQM2.js} +117 -3
  132. package/dist/chunk-S7VFUQM2.js.map +1 -0
  133. package/dist/chunk-T7WSLRAU.js +49 -0
  134. package/dist/chunk-T7WSLRAU.js.map +1 -0
  135. package/dist/{chunk-IUEN57TV.js → chunk-TAKWLZZX.js} +280 -58
  136. package/dist/chunk-TAKWLZZX.js.map +1 -0
  137. package/dist/chunk-THNJ3IKU.js +17 -0
  138. package/dist/chunk-THNJ3IKU.js.map +1 -0
  139. package/dist/{chunk-MTMJVJ5W.js → chunk-TMBXVJKT.js} +5 -3
  140. package/dist/chunk-TMBXVJKT.js.map +1 -0
  141. package/dist/{chunk-QHJW5EXU.js → chunk-TWKKOM55.js} +2 -2
  142. package/dist/{chunk-M6OST55S.js → chunk-U3WZCU7E.js} +2 -2
  143. package/dist/{chunk-AIWULCUO.js → chunk-UF362QVH.js} +5 -3
  144. package/dist/{chunk-AIWULCUO.js.map → chunk-UF362QVH.js.map} +1 -1
  145. package/dist/{chunk-KXGNJJXB.js → chunk-UN4FVIBH.js} +7 -7
  146. package/dist/chunk-VEAVKDDB.js +29 -0
  147. package/dist/chunk-VEAVKDDB.js.map +1 -0
  148. package/dist/chunk-VEPTFUJY.js +29 -0
  149. package/dist/chunk-VEPTFUJY.js.map +1 -0
  150. package/dist/{chunk-TEILUWOI.js → chunk-VJV7GKQK.js} +10 -12
  151. package/dist/chunk-VJV7GKQK.js.map +1 -0
  152. package/dist/chunk-VQRAIPYF.js +50 -0
  153. package/dist/chunk-VQRAIPYF.js.map +1 -0
  154. package/dist/{chunk-NF5JWERG.js → chunk-VRIYFLBA.js} +2 -2
  155. package/dist/chunk-VWM3DAVB.js +265 -0
  156. package/dist/chunk-VWM3DAVB.js.map +1 -0
  157. package/dist/{chunk-RUEKROOS.js → chunk-VWRRVE6D.js} +2 -2
  158. package/dist/chunk-VYYM3MEN.js +98 -0
  159. package/dist/chunk-VYYM3MEN.js.map +1 -0
  160. package/dist/chunk-WBJIQSLL.js +167 -0
  161. package/dist/chunk-WBJIQSLL.js.map +1 -0
  162. package/dist/{chunk-XXYIOFUB.js → chunk-WIGQB62E.js} +5 -5
  163. package/dist/chunk-WZSCE6RM.js +466 -0
  164. package/dist/chunk-WZSCE6RM.js.map +1 -0
  165. package/dist/{chunk-5R3ERCDH.js → chunk-XGDAPN6M.js} +25 -9
  166. package/dist/{chunk-5R3ERCDH.js.map → chunk-XGDAPN6M.js.map} +1 -1
  167. package/dist/{chunk-DFEMTNPJ.js → chunk-XH7XP3OL.js} +8 -6
  168. package/dist/{chunk-DFEMTNPJ.js.map → chunk-XH7XP3OL.js.map} +1 -1
  169. package/dist/{chunk-IAGBDSCS.js → chunk-XREOISSI.js} +2 -2
  170. package/dist/chunk-XUBPSPKD.js +164 -0
  171. package/dist/chunk-XUBPSPKD.js.map +1 -0
  172. package/dist/chunk-Y3A5CB5G.js +247 -0
  173. package/dist/chunk-Y3A5CB5G.js.map +1 -0
  174. package/dist/{chunk-ZCGAHGUS.js → chunk-YCXCR7VG.js} +2 -2
  175. package/dist/{chunk-76722EBH.js → chunk-YMVQD5Q5.js} +11 -9
  176. package/dist/{chunk-76722EBH.js.map → chunk-YMVQD5Q5.js.map} +1 -1
  177. package/dist/{chunk-5TDJ56JE.js → chunk-YN5IAHN6.js} +1 -1
  178. package/dist/chunk-YN5IAHN6.js.map +1 -0
  179. package/dist/{chunk-TJYQIGAP.js → chunk-ZYJ55N7N.js} +9 -5
  180. package/dist/chunk-ZYJ55N7N.js.map +1 -0
  181. package/dist/classified/index.d.ts +16 -0
  182. package/dist/classified/index.js +40 -0
  183. package/dist/classified-marker-H6YSHYNK.js +24 -0
  184. package/dist/classified-marker-H6YSHYNK.js.map +1 -0
  185. package/dist/collection-facade-LVD22JLM.js +39 -0
  186. package/dist/computed-EXDMQODG.js +11 -0
  187. package/dist/consent/index.d.ts +3 -4
  188. package/dist/consent/index.js +10 -4
  189. package/dist/consent/index.js.map +1 -1
  190. package/dist/crdt/index.d.ts +3 -4
  191. package/dist/dead-filter-HQIE2YG7.js +28 -0
  192. package/dist/dead-filter-HQIE2YG7.js.map +1 -0
  193. package/dist/delegation-BJP73GAP.js +25 -0
  194. package/dist/derivations/index.d.ts +4 -5
  195. package/dist/derivations/index.js +13 -6
  196. package/dist/derive-BME7HDWO.js +21 -0
  197. package/dist/{dev-unlock-C9Ro3v_O.d.ts → dev-unlock-Bmm2pgJ0.d.ts} +1 -1
  198. package/dist/{enclave-UL5LW66V.js → enclave-NHORSWSF.js} +55 -18
  199. package/dist/executor-FE6X4LFX.js +9 -0
  200. package/dist/executor-KSHKRJXP.js +25 -0
  201. package/dist/executor-ZHTJJICG.js +9 -0
  202. package/dist/export-accessible-DACHM5VT.js +23 -0
  203. package/dist/extract-partition-RNENZZ4T.js +36 -0
  204. package/dist/{fanout-sidecar-GF3DJ6KR.js → fanout-sidecar-OFWN3NM7.js} +17 -14
  205. package/dist/fanout-sidecar-OFWN3NM7.js.map +1 -0
  206. package/dist/fence-watcher-DHQ775JB.js +69 -0
  207. package/dist/fence-watcher-DHQ775JB.js.map +1 -0
  208. package/dist/find-BNGBJNKP.js +11 -0
  209. package/dist/forget/index.d.ts +2 -2
  210. package/dist/forget/index.js +10 -4
  211. package/dist/forget/index.js.map +1 -1
  212. package/dist/guards/index.d.ts +4 -5
  213. package/dist/guards/index.js +4 -4
  214. package/dist/{hash-Cp5uwiox.d.ts → hash-DAJjMsCE.d.ts} +7 -2
  215. package/dist/history/index.d.ts +4 -5
  216. package/dist/history/index.js +12 -6
  217. package/dist/history/index.js.map +1 -1
  218. package/dist/i18n/index.d.ts +24 -5
  219. package/dist/i18n/index.js +50 -31
  220. package/dist/i18n/index.js.map +1 -1
  221. package/dist/in/index.d.ts +2 -3
  222. package/dist/{index-BzUo1B6n.d.ts → index-DjWbxsjb.d.ts} +8596 -5747
  223. package/dist/{index-BF9_96A5.d.ts → index-qwuNvO2B.d.ts} +26 -5
  224. package/dist/index.d.ts +116 -24
  225. package/dist/index.js +1479 -139
  226. package/dist/index.js.map +1 -1
  227. package/dist/indexing/index.d.ts +3 -4
  228. package/dist/indexing/index.js +4 -4
  229. package/dist/issue-NDI4CVZU.js +19 -0
  230. package/dist/json-schema-I22JCYCG.js +44 -0
  231. package/dist/json-schema-I22JCYCG.js.map +1 -0
  232. package/dist/lazy/index.d.ts +20 -0
  233. package/dist/lazy/index.js +12 -0
  234. package/dist/{ledger-RYI35CDS.js → ledger-6NDS2EO4.js} +12 -6
  235. package/dist/liberate-HN3RIGIP.js +24 -0
  236. package/dist/link-set-SJB2MVJV.js +31 -0
  237. package/dist/materialized-views/index.d.ts +22 -6
  238. package/dist/materialized-views/index.js +20 -10
  239. package/dist/{mime-magic-CGhw37_E.d.ts → mime-magic-bBj5OgUC.d.ts} +1 -1
  240. package/dist/noydb-BWF6EPIR.js +66 -0
  241. package/dist/on/index.d.ts +2 -3
  242. package/dist/on/index.js +10 -4
  243. package/dist/overlay-views/index.d.ts +4 -5
  244. package/dist/overlay-views/index.js +4 -4
  245. package/dist/periods/index.d.ts +3 -4
  246. package/dist/periods/index.js +21 -7
  247. package/dist/pod/index.d.ts +3 -4
  248. package/dist/pod/index.js +12 -6
  249. package/dist/{policy-IXK4FVXP.js → policy-WGNAG5H6.js} +5 -5
  250. package/dist/portability/index.d.ts +3 -4
  251. package/dist/portability/index.js +8 -8
  252. package/dist/post-register-CWKBQRC7.js +55 -0
  253. package/dist/post-register-CWKBQRC7.js.map +1 -0
  254. package/dist/{public-envelope-JHDQCPSX.js → public-envelope-EJLVIFX7.js} +4 -4
  255. package/dist/query/index.d.ts +2 -3
  256. package/dist/query/index.js +9 -6
  257. package/dist/{read-only-facade-5ADRJVTM.js → read-only-facade-CHCKSEPD.js} +2 -2
  258. package/dist/register-SBIX7TVV.js +23 -0
  259. package/dist/registry-3EQG6OOE.js +18 -0
  260. package/dist/registry-CA327ACV.js +9 -0
  261. package/dist/registry-E7OXOTSV.js +19 -0
  262. package/dist/request-withdrawal-KAH2AAXC.js +31 -0
  263. package/dist/reveal-R3JLHMUF.js +38 -0
  264. package/dist/reveal-R3JLHMUF.js.map +1 -0
  265. package/dist/revoke-IXLOJ3IH.js +24 -0
  266. package/dist/satellites/index.d.ts +4 -0
  267. package/dist/satellites/index.js +8 -0
  268. package/dist/sealed-record/index.d.ts +3 -4
  269. package/dist/sealed-record/index.js +13 -7
  270. package/dist/sealed-record/index.js.map +1 -1
  271. package/dist/session/index.d.ts +4 -5
  272. package/dist/session/index.js +10 -4
  273. package/dist/session/index.js.map +1 -1
  274. package/dist/shadow/index.d.ts +3 -4
  275. package/dist/shadow/index.js +2 -2
  276. package/dist/signer-Y46N2GJ3.js +25 -0
  277. package/dist/signer-Y46N2GJ3.js.map +1 -0
  278. package/dist/snapshots/index.d.ts +3 -4
  279. package/dist/snapshots/index.js +11 -5
  280. package/dist/snapshots/index.js.map +1 -1
  281. package/dist/{stale-3JWHNDIY.js → stale-Z7IW6RIL.js} +2 -2
  282. package/dist/stale-Z7IW6RIL.js.map +1 -0
  283. package/dist/storage-ADNP2UWI.js +23 -0
  284. package/dist/storage-ADNP2UWI.js.map +1 -0
  285. package/dist/{store-coordination-provider-3I7XWZZK.js → store-coordination-provider-DTDMI6VL.js} +3 -3
  286. package/dist/{subject-index-O75wKshW.d.ts → subject-index-CyOgGMJL.d.ts} +18 -0
  287. package/dist/sync/index.d.ts +2 -3
  288. package/dist/sync/index.js +10 -4
  289. package/dist/sync/index.js.map +1 -1
  290. package/dist/team/index.d.ts +45 -7
  291. package/dist/team/index.js +25 -12
  292. package/dist/tiers/index.d.ts +2 -3
  293. package/dist/tiers/index.js +11 -5
  294. package/dist/to/index.d.ts +2 -3
  295. package/dist/to/index.js +1 -2
  296. package/dist/{transition-guard-C7ol6oPw.d.ts → transition-guard-DI-krBsZ.d.ts} +1 -1
  297. package/dist/tx/index.d.ts +3 -4
  298. package/dist/tx/index.js +3 -3
  299. package/dist/ui/index.d.ts +4 -1
  300. package/dist/util/index.js +1 -1
  301. package/dist/validators-BUcli5Nh.d.ts +101 -0
  302. package/dist/{vault-diff-B5fYNBL7.d.ts → vault-diff-Z2DUayMe.d.ts} +1 -1
  303. package/dist/verify-JPF2YR5E.js +139 -0
  304. package/dist/verify-JPF2YR5E.js.map +1 -0
  305. package/dist/walk-XYA2O3LW.js +241 -0
  306. package/dist/walk-XYA2O3LW.js.map +1 -0
  307. package/dist/with/index.d.ts +3 -4
  308. package/dist/with/index.js +12 -6
  309. package/dist/{with-materialized-view-6p0Fk8bL.d.ts → with-materialized-view-BUmzlXue.d.ts} +1 -1
  310. package/dist/{with-overlayed-view-BJ6mXGMd.d.ts → with-overlayed-view-m4FaXXTO.d.ts} +1 -1
  311. package/dist/{with-rollup-BvQo3ROo.d.ts → with-rollup-DEKGI9vb.d.ts} +1 -1
  312. package/dist/withdraw-accessible-WLV4MTEN.js +28 -0
  313. package/dist/withdraw-accessible-WLV4MTEN.js.map +1 -0
  314. package/package.json +16 -16
  315. package/dist/adapter/index.d.ts +0 -5
  316. package/dist/adapter/index.js +0 -15
  317. package/dist/api-RW3KP7WU.js +0 -14
  318. package/dist/backup-XV3IOEGB.js.map +0 -1
  319. package/dist/chunk-26LGBE4T.js +0 -42
  320. package/dist/chunk-26LGBE4T.js.map +0 -1
  321. package/dist/chunk-5LUY7UTV.js.map +0 -1
  322. package/dist/chunk-5O3AOPDT.js.map +0 -1
  323. package/dist/chunk-5R5JW2JT.js.map +0 -1
  324. package/dist/chunk-5TDJ56JE.js.map +0 -1
  325. package/dist/chunk-62QYRORB.js.map +0 -1
  326. package/dist/chunk-AQTBSL7R.js.map +0 -1
  327. package/dist/chunk-BG3SPSR4.js.map +0 -1
  328. package/dist/chunk-BGIZAFY7.js +0 -1
  329. package/dist/chunk-DGDI2D4M.js.map +0 -1
  330. package/dist/chunk-I3TIKTJO.js.map +0 -1
  331. package/dist/chunk-IELYAOGG.js.map +0 -1
  332. package/dist/chunk-IPB7FTQX.js.map +0 -1
  333. package/dist/chunk-IUEN57TV.js.map +0 -1
  334. package/dist/chunk-K2WCO3NX.js +0 -1
  335. package/dist/chunk-LFLXAY2W.js.map +0 -1
  336. package/dist/chunk-LV7M27WM.js.map +0 -1
  337. package/dist/chunk-M2YKN37S.js +0 -524
  338. package/dist/chunk-M2YKN37S.js.map +0 -1
  339. package/dist/chunk-MTMJVJ5W.js.map +0 -1
  340. package/dist/chunk-Q7SS3IME.js +0 -120
  341. package/dist/chunk-Q7SS3IME.js.map +0 -1
  342. package/dist/chunk-RUIMKQTA.js.map +0 -1
  343. package/dist/chunk-SRB2XEWB.js.map +0 -1
  344. package/dist/chunk-TEILUWOI.js.map +0 -1
  345. package/dist/chunk-TJYQIGAP.js.map +0 -1
  346. package/dist/chunk-UIU2THRG.js.map +0 -1
  347. package/dist/chunk-UPJNJGGA.js.map +0 -1
  348. package/dist/chunk-WWGT2MDV.js.map +0 -1
  349. package/dist/chunk-Y22T3KQE.js.map +0 -1
  350. package/dist/chunk-ZYUC53LT.js.map +0 -1
  351. package/dist/collection-facade-GQAOGJP2.js +0 -33
  352. package/dist/delegation-UL5HKLER.js +0 -19
  353. package/dist/describe/index.d.ts +0 -1
  354. package/dist/describe/index.js +0 -1
  355. package/dist/describe-aBkJR2sd.d.ts +0 -131
  356. package/dist/executor-2FWQRLMG.js +0 -15
  357. package/dist/executor-QZ7BXICW.js +0 -9
  358. package/dist/executor-Z5ZLJVTV.js +0 -9
  359. package/dist/export-accessible-KRV5W4GH.js +0 -17
  360. package/dist/extract-partition-GLKBOXFQ.js +0 -30
  361. package/dist/fanout-sidecar-GF3DJ6KR.js.map +0 -1
  362. package/dist/issue-Y6UVIR43.js +0 -13
  363. package/dist/kernel/index.d.ts +0 -32
  364. package/dist/kernel/index.js +0 -53
  365. package/dist/liberate-CRPZEV7O.js +0 -18
  366. package/dist/noydb-367AM4HT.js +0 -50
  367. package/dist/registry-45RJNWGU.js +0 -9
  368. package/dist/registry-5GRV5VXI.js +0 -13
  369. package/dist/registry-WEUCHBO4.js +0 -11
  370. package/dist/request-withdrawal-GBPH2FDY.js +0 -25
  371. package/dist/revoke-TUFRGI6S.js +0 -18
  372. package/dist/signer-PNKTBVF7.js +0 -19
  373. package/dist/withdraw-accessible-FFS46EOD.js +0 -22
  374. /package/dist/{adapter/index.js.map → api-TX2EX2FX.js.map} +0 -0
  375. /package/dist/{chunk-5N6CZTCY.js.map → chunk-2OZXVKVP.js.map} +0 -0
  376. /package/dist/{chunk-UAG5KWVA.js.map → chunk-3MATJ6O4.js.map} +0 -0
  377. /package/dist/{chunk-AZAOEIKW.js.map → chunk-5YESYH2C.js.map} +0 -0
  378. /package/dist/{chunk-VCTFO5CO.js.map → chunk-6P5XCKSD.js.map} +0 -0
  379. /package/dist/{chunk-IO6GRPT6.js.map → chunk-7BWJHO2A.js.map} +0 -0
  380. /package/dist/{chunk-UDRIWL7A.js.map → chunk-BKARNZJN.js.map} +0 -0
  381. /package/dist/{chunk-V7RWQRG7.js.map → chunk-CB7CWSKW.js.map} +0 -0
  382. /package/dist/{chunk-CWPPNPOH.js.map → chunk-DJ7KIPLV.js.map} +0 -0
  383. /package/dist/{chunk-TA66UMI4.js.map → chunk-F4CEK5YM.js.map} +0 -0
  384. /package/dist/{chunk-SM3AVUHC.js.map → chunk-G4JYND6L.js.map} +0 -0
  385. /package/dist/{chunk-AXRXJTE2.js.map → chunk-G6XV4H65.js.map} +0 -0
  386. /package/dist/{chunk-UV5MFVO3.js.map → chunk-HPWKV3YB.js.map} +0 -0
  387. /package/dist/{chunk-SKF73JOP.js.map → chunk-ICXIFFYZ.js.map} +0 -0
  388. /package/dist/{chunk-LMTH2RM6.js.map → chunk-KNZB6JMR.js.map} +0 -0
  389. /package/dist/{chunk-PKHL44ER.js.map → chunk-LEJIKBBB.js.map} +0 -0
  390. /package/dist/{chunk-PSMV73A5.js.map → chunk-OBKWYKYC.js.map} +0 -0
  391. /package/dist/{chunk-CMGR4ZEW.js.map → chunk-OHHKHSJP.js.map} +0 -0
  392. /package/dist/{chunk-HCIPRAGS.js.map → chunk-OT76OZL6.js.map} +0 -0
  393. /package/dist/{chunk-SMXWYP24.js.map → chunk-OXCSVM3B.js.map} +0 -0
  394. /package/dist/{chunk-IGUYVGGI.js.map → chunk-P33LUIML.js.map} +0 -0
  395. /package/dist/{chunk-EIZUR2XW.js.map → chunk-PS2NEWEX.js.map} +0 -0
  396. /package/dist/{chunk-WYSO2NIH.js.map → chunk-QOC3VYL2.js.map} +0 -0
  397. /package/dist/{chunk-KVOXU4T5.js.map → chunk-RHK32N73.js.map} +0 -0
  398. /package/dist/{chunk-3YFXJ3ZP.js.map → chunk-RW3Y22MW.js.map} +0 -0
  399. /package/dist/{chunk-QHJW5EXU.js.map → chunk-TWKKOM55.js.map} +0 -0
  400. /package/dist/{chunk-M6OST55S.js.map → chunk-U3WZCU7E.js.map} +0 -0
  401. /package/dist/{chunk-KXGNJJXB.js.map → chunk-UN4FVIBH.js.map} +0 -0
  402. /package/dist/{chunk-NF5JWERG.js.map → chunk-VRIYFLBA.js.map} +0 -0
  403. /package/dist/{chunk-RUEKROOS.js.map → chunk-VWRRVE6D.js.map} +0 -0
  404. /package/dist/{chunk-XXYIOFUB.js.map → chunk-WIGQB62E.js.map} +0 -0
  405. /package/dist/{chunk-IAGBDSCS.js.map → chunk-XREOISSI.js.map} +0 -0
  406. /package/dist/{chunk-ZCGAHGUS.js.map → chunk-YCXCR7VG.js.map} +0 -0
  407. /package/dist/{describe → classified}/index.js.map +0 -0
  408. /package/dist/{api-RW3KP7WU.js.map → collection-facade-LVD22JLM.js.map} +0 -0
  409. /package/dist/{chunk-BGIZAFY7.js.map → computed-EXDMQODG.js.map} +0 -0
  410. /package/dist/{chunk-K2WCO3NX.js.map → delegation-BJP73GAP.js.map} +0 -0
  411. /package/dist/{collection-facade-GQAOGJP2.js.map → derive-BME7HDWO.js.map} +0 -0
  412. /package/dist/{delegation-UL5HKLER.js.map → enclave-NHORSWSF.js.map} +0 -0
  413. /package/dist/{enclave-UL5LW66V.js.map → executor-FE6X4LFX.js.map} +0 -0
  414. /package/dist/{executor-2FWQRLMG.js.map → executor-KSHKRJXP.js.map} +0 -0
  415. /package/dist/{executor-QZ7BXICW.js.map → executor-ZHTJJICG.js.map} +0 -0
  416. /package/dist/{executor-Z5ZLJVTV.js.map → export-accessible-DACHM5VT.js.map} +0 -0
  417. /package/dist/{export-accessible-KRV5W4GH.js.map → extract-partition-RNENZZ4T.js.map} +0 -0
  418. /package/dist/{extract-partition-GLKBOXFQ.js.map → find-BNGBJNKP.js.map} +0 -0
  419. /package/dist/{issue-Y6UVIR43.js.map → issue-NDI4CVZU.js.map} +0 -0
  420. /package/dist/{kernel → lazy}/index.js.map +0 -0
  421. /package/dist/{ledger-RYI35CDS.js.map → ledger-6NDS2EO4.js.map} +0 -0
  422. /package/dist/{liberate-CRPZEV7O.js.map → liberate-HN3RIGIP.js.map} +0 -0
  423. /package/dist/{noydb-367AM4HT.js.map → link-set-SJB2MVJV.js.map} +0 -0
  424. /package/dist/{policy-IXK4FVXP.js.map → noydb-BWF6EPIR.js.map} +0 -0
  425. /package/dist/{public-envelope-JHDQCPSX.js.map → policy-WGNAG5H6.js.map} +0 -0
  426. /package/dist/{read-only-facade-5ADRJVTM.js.map → public-envelope-EJLVIFX7.js.map} +0 -0
  427. /package/dist/{registry-45RJNWGU.js.map → read-only-facade-CHCKSEPD.js.map} +0 -0
  428. /package/dist/{registry-5GRV5VXI.js.map → register-SBIX7TVV.js.map} +0 -0
  429. /package/dist/{registry-WEUCHBO4.js.map → registry-3EQG6OOE.js.map} +0 -0
  430. /package/dist/{request-withdrawal-GBPH2FDY.js.map → registry-CA327ACV.js.map} +0 -0
  431. /package/dist/{revoke-TUFRGI6S.js.map → registry-E7OXOTSV.js.map} +0 -0
  432. /package/dist/{signer-PNKTBVF7.js.map → request-withdrawal-KAH2AAXC.js.map} +0 -0
  433. /package/dist/{stale-3JWHNDIY.js.map → revoke-IXLOJ3IH.js.map} +0 -0
  434. /package/dist/{withdraw-accessible-FFS46EOD.js.map → satellites/index.js.map} +0 -0
  435. /package/dist/{store-coordination-provider-3I7XWZZK.js.map → store-coordination-provider-DTDMI6VL.js.map} +0 -0
@@ -1,367 +1,51 @@
1
+ import {
2
+ isDeleteMarker,
3
+ isTombstone
4
+ } from "./chunk-QA2KUPCP.js";
5
+ import {
6
+ blindedEqual,
7
+ openVdigPayload,
8
+ sealVdigPayload
9
+ } from "./chunk-2OV5NVE7.js";
10
+ import {
11
+ dualReadSealedSlot,
12
+ parseSealedSlot
13
+ } from "./chunk-VEPTFUJY.js";
14
+ import {
15
+ mintBidxTag
16
+ } from "./chunk-HYR4WZZ3.js";
17
+ import {
18
+ VDIG_ITERATIONS,
19
+ normalizeForVerify,
20
+ pbkdf2VerifyDigest
21
+ } from "./chunk-LP7BEXCT.js";
22
+ import {
23
+ base64ToBuffer,
24
+ bufferToBase64,
25
+ decrypt,
26
+ deriveDeterministicKey,
27
+ deriveSealedFieldKey,
28
+ deriveSealedFieldKeyFromCek,
29
+ encrypt,
30
+ encryptDeterministic,
31
+ generateDEK,
32
+ generateSalt,
33
+ unwrapCek,
34
+ wrapCek
35
+ } from "./chunk-3OPY6MK2.js";
1
36
  import {
2
37
  NOYDB_FORMAT_VERSION,
3
38
  SealedHandle
4
- } from "./chunk-5TDJ56JE.js";
39
+ } from "./chunk-YN5IAHN6.js";
5
40
  import {
41
+ ClassifiedConfigError,
42
+ ClassifiedRotationError,
6
43
  DebugReservedFieldError,
7
- DecryptionError,
8
- InvalidKeyError,
9
44
  RecordCekNotFoundError,
10
45
  SchemaValidationError,
11
46
  TamperedError,
12
47
  ValidationError
13
- } from "./chunk-ZYUC53LT.js";
14
-
15
- // src/kernel/enclave/crypto.ts
16
- var PBKDF2_ITERATIONS = 6e5;
17
- var SALT_BYTES = 32;
18
- var IV_BYTES = 12;
19
- var KEY_BITS = 256;
20
- var subtle = globalThis.crypto.subtle;
21
- async function deriveKey(passphrase, salt) {
22
- const keyMaterial = await subtle.importKey(
23
- "raw",
24
- new TextEncoder().encode(passphrase),
25
- "PBKDF2",
26
- false,
27
- ["deriveKey"]
28
- );
29
- return subtle.deriveKey(
30
- {
31
- name: "PBKDF2",
32
- salt,
33
- iterations: PBKDF2_ITERATIONS,
34
- hash: "SHA-256"
35
- },
36
- keyMaterial,
37
- { name: "AES-KW", length: KEY_BITS },
38
- false,
39
- ["wrapKey", "unwrapKey"]
40
- );
41
- }
42
- async function derivePassphraseKey(passphrase, salt, params) {
43
- const keyMaterial = await subtle.importKey(
44
- "raw",
45
- new TextEncoder().encode(passphrase),
46
- "PBKDF2",
47
- false,
48
- ["deriveKey"]
49
- );
50
- return params.keyUsage === "aes-gcm" ? subtle.deriveKey(
51
- {
52
- name: "PBKDF2",
53
- salt,
54
- iterations: params.iterations,
55
- hash: "SHA-256"
56
- },
57
- keyMaterial,
58
- { name: "AES-GCM", length: KEY_BITS },
59
- false,
60
- ["encrypt", "decrypt"]
61
- ) : subtle.deriveKey(
62
- {
63
- name: "PBKDF2",
64
- salt,
65
- iterations: params.iterations,
66
- hash: "SHA-256"
67
- },
68
- keyMaterial,
69
- { name: "AES-KW", length: KEY_BITS },
70
- false,
71
- ["wrapKey", "unwrapKey"]
72
- );
73
- }
74
- async function generateDEK() {
75
- return subtle.generateKey(
76
- { name: "AES-GCM", length: KEY_BITS },
77
- true,
78
- // extractable — needed for AES-KW wrapping
79
- ["encrypt", "decrypt"]
80
- );
81
- }
82
- async function wrapKey(dek, kek) {
83
- const wrapped = await subtle.wrapKey("raw", dek, kek, "AES-KW");
84
- return bufferToBase64(wrapped);
85
- }
86
- async function unwrapKey(wrappedBase64, kek) {
87
- try {
88
- return await subtle.unwrapKey(
89
- "raw",
90
- base64ToBuffer(wrappedBase64),
91
- kek,
92
- "AES-KW",
93
- { name: "AES-GCM", length: KEY_BITS },
94
- true,
95
- ["encrypt", "decrypt"]
96
- );
97
- } catch {
98
- throw new InvalidKeyError();
99
- }
100
- }
101
- async function asKwKey(dek) {
102
- const rawDek = await subtle.exportKey("raw", dek);
103
- const hkdfKey = await subtle.importKey("raw", rawDek, "HKDF", false, ["deriveBits"]);
104
- const salt = new TextEncoder().encode("noydb-cek-wrap");
105
- const info = new TextEncoder().encode("v1");
106
- const bits = await subtle.deriveBits(
107
- { name: "HKDF", hash: "SHA-256", salt, info },
108
- hkdfKey,
109
- KEY_BITS
110
- );
111
- return subtle.importKey("raw", bits, "AES-KW", false, ["wrapKey", "unwrapKey"]);
112
- }
113
- async function wrapCek(cek, dek) {
114
- const kw = await asKwKey(dek);
115
- const wrapped = await subtle.wrapKey("raw", cek, kw, "AES-KW");
116
- return bufferToBase64(wrapped);
117
- }
118
- async function unwrapCek(wrappedBase64, dek) {
119
- const kw = await asKwKey(dek);
120
- try {
121
- return await subtle.unwrapKey(
122
- "raw",
123
- base64ToBuffer(wrappedBase64),
124
- kw,
125
- "AES-KW",
126
- { name: "AES-GCM", length: KEY_BITS },
127
- true,
128
- ["encrypt", "decrypt"]
129
- );
130
- } catch {
131
- throw new InvalidKeyError();
132
- }
133
- }
134
- async function importCek(rawKey) {
135
- return subtle.importKey("raw", rawKey, { name: "AES-GCM", length: KEY_BITS }, false, ["decrypt"]);
136
- }
137
- async function encrypt(plaintext, dek) {
138
- const iv = generateIV();
139
- const encoded = new TextEncoder().encode(plaintext);
140
- const ciphertext = await subtle.encrypt(
141
- { name: "AES-GCM", iv },
142
- dek,
143
- encoded
144
- );
145
- return {
146
- iv: bufferToBase64(iv),
147
- data: bufferToBase64(ciphertext)
148
- };
149
- }
150
- async function decrypt(ivBase64, dataBase64, dek) {
151
- const iv = base64ToBuffer(ivBase64);
152
- const ciphertext = base64ToBuffer(dataBase64);
153
- try {
154
- const plaintext = await subtle.decrypt(
155
- { name: "AES-GCM", iv },
156
- dek,
157
- ciphertext
158
- );
159
- return new TextDecoder().decode(plaintext);
160
- } catch (err) {
161
- if (err instanceof Error && err.name === "OperationError") {
162
- throw new TamperedError();
163
- }
164
- throw new DecryptionError(
165
- err instanceof Error ? err.message : "Decryption failed"
166
- );
167
- }
168
- }
169
- async function encryptBytes(data, dek) {
170
- const iv = generateIV();
171
- const ciphertext = await subtle.encrypt(
172
- { name: "AES-GCM", iv },
173
- dek,
174
- data
175
- );
176
- return {
177
- iv: bufferToBase64(iv),
178
- data: bufferToBase64(ciphertext)
179
- };
180
- }
181
- async function decryptBytes(ivBase64, dataBase64, dek) {
182
- const iv = base64ToBuffer(ivBase64);
183
- const ciphertext = base64ToBuffer(dataBase64);
184
- try {
185
- const plaintext = await subtle.decrypt(
186
- { name: "AES-GCM", iv },
187
- dek,
188
- ciphertext
189
- );
190
- return new Uint8Array(plaintext);
191
- } catch (err) {
192
- if (err instanceof Error && err.name === "OperationError") {
193
- throw new TamperedError();
194
- }
195
- throw new DecryptionError(
196
- err instanceof Error ? err.message : "Decryption failed"
197
- );
198
- }
199
- }
200
- async function sha256Hex(data) {
201
- const hash = await subtle.digest("SHA-256", data);
202
- return Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
203
- }
204
- async function hmacSha256Hex(key, data) {
205
- const rawKey = await subtle.exportKey("raw", key);
206
- const hmacKey = await subtle.importKey(
207
- "raw",
208
- rawKey,
209
- { name: "HMAC", hash: "SHA-256" },
210
- false,
211
- ["sign"]
212
- );
213
- const sig = await subtle.sign("HMAC", hmacKey, data);
214
- return Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
215
- }
216
- async function encryptBytesWithAAD(data, dek, aad) {
217
- const iv = generateIV();
218
- const ciphertext = await subtle.encrypt(
219
- {
220
- name: "AES-GCM",
221
- iv,
222
- additionalData: aad
223
- },
224
- dek,
225
- data
226
- );
227
- return {
228
- iv: bufferToBase64(iv),
229
- data: bufferToBase64(ciphertext)
230
- };
231
- }
232
- async function decryptBytesWithAAD(ivBase64, dataBase64, dek, aad) {
233
- const iv = base64ToBuffer(ivBase64);
234
- const ciphertext = base64ToBuffer(dataBase64);
235
- try {
236
- const plaintext = await subtle.decrypt(
237
- {
238
- name: "AES-GCM",
239
- iv,
240
- additionalData: aad
241
- },
242
- dek,
243
- ciphertext
244
- );
245
- return new Uint8Array(plaintext);
246
- } catch (err) {
247
- if (err instanceof Error && err.name === "OperationError") {
248
- throw new TamperedError();
249
- }
250
- throw new DecryptionError(
251
- err instanceof Error ? err.message : "Decryption failed"
252
- );
253
- }
254
- }
255
- async function derivePresenceKey(dek, collectionName) {
256
- const rawDek = await subtle.exportKey("raw", dek);
257
- const hkdfKey = await subtle.importKey(
258
- "raw",
259
- rawDek,
260
- "HKDF",
261
- false,
262
- ["deriveBits"]
263
- );
264
- const salt = new TextEncoder().encode("noydb-presence");
265
- const info = new TextEncoder().encode(collectionName);
266
- const bits = await subtle.deriveBits(
267
- { name: "HKDF", hash: "SHA-256", salt, info },
268
- hkdfKey,
269
- KEY_BITS
270
- );
271
- return subtle.importKey(
272
- "raw",
273
- bits,
274
- { name: "AES-GCM", length: KEY_BITS },
275
- false,
276
- ["encrypt", "decrypt"]
277
- );
278
- }
279
- async function deriveSealedFieldKey(dek, collectionName, field) {
280
- const rawDek = await subtle.exportKey("raw", dek);
281
- const hkdfKey = await subtle.importKey("raw", rawDek, "HKDF", false, ["deriveBits"]);
282
- const salt = new TextEncoder().encode("noydb-sealed");
283
- const info = new TextEncoder().encode(JSON.stringify(["noydb-sealed", collectionName, field]));
284
- const bits = await subtle.deriveBits(
285
- { name: "HKDF", hash: "SHA-256", salt, info },
286
- hkdfKey,
287
- KEY_BITS
288
- );
289
- return subtle.importKey(
290
- "raw",
291
- bits,
292
- { name: "AES-GCM", length: KEY_BITS },
293
- false,
294
- ["encrypt", "decrypt"]
295
- );
296
- }
297
- async function deriveSealedFieldKeyFromCek(cek, collectionName, field) {
298
- const rawCek = await subtle.exportKey("raw", cek);
299
- const hkdfKey = await subtle.importKey("raw", rawCek, "HKDF", false, ["deriveBits"]);
300
- const salt = new TextEncoder().encode("noydb-sealed-cek");
301
- const info = new TextEncoder().encode(JSON.stringify(["noydb-sealed-cek", collectionName, field]));
302
- const bits = await subtle.deriveBits(
303
- { name: "HKDF", hash: "SHA-256", salt, info },
304
- hkdfKey,
305
- KEY_BITS
306
- );
307
- return subtle.importKey(
308
- "raw",
309
- bits,
310
- { name: "AES-GCM", length: KEY_BITS },
311
- false,
312
- ["encrypt", "decrypt"]
313
- );
314
- }
315
- async function deriveDeterministicIV(dek, context, plaintext) {
316
- const rawDek = await subtle.exportKey("raw", dek);
317
- const hkdfKey = await subtle.importKey("raw", rawDek, "HKDF", false, ["deriveBits"]);
318
- const salt = new TextEncoder().encode("noydb-deterministic-v1");
319
- const info = new TextEncoder().encode(`${context}\0${plaintext}`);
320
- const bits = await subtle.deriveBits(
321
- { name: "HKDF", hash: "SHA-256", salt, info },
322
- hkdfKey,
323
- IV_BYTES * 8
324
- );
325
- return new Uint8Array(bits);
326
- }
327
- async function encryptDeterministic(plaintext, dek, context) {
328
- const iv = await deriveDeterministicIV(dek, context, plaintext);
329
- const encoded = new TextEncoder().encode(plaintext);
330
- const ciphertext = await subtle.encrypt(
331
- { name: "AES-GCM", iv },
332
- dek,
333
- encoded
334
- );
335
- return {
336
- iv: bufferToBase64(iv),
337
- data: bufferToBase64(ciphertext)
338
- };
339
- }
340
- async function decryptDeterministic(ivBase64, dataBase64, dek) {
341
- return decrypt(ivBase64, dataBase64, dek);
342
- }
343
- function generateIV() {
344
- return globalThis.crypto.getRandomValues(new Uint8Array(IV_BYTES));
345
- }
346
- function generateSalt() {
347
- return globalThis.crypto.getRandomValues(new Uint8Array(SALT_BYTES));
348
- }
349
- function bufferToBase64(buffer) {
350
- const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
351
- let binary = "";
352
- for (let i = 0; i < bytes.length; i++) {
353
- binary += String.fromCharCode(bytes[i]);
354
- }
355
- return btoa(binary);
356
- }
357
- function base64ToBuffer(base64) {
358
- const binary = atob(base64);
359
- const bytes = new Uint8Array(binary.length);
360
- for (let i = 0; i < binary.length; i++) {
361
- bytes[i] = binary.charCodeAt(i);
362
- }
363
- return bytes;
364
- }
48
+ } from "./chunk-S7VFUQM2.js";
365
49
 
366
50
  // src/kernel/enclave/record-keys/lifecycle.ts
367
51
  async function resolveStableCek(deps, id) {
@@ -389,38 +73,136 @@ async function rewrapBodyToDek(envelope, fromDek, toDek) {
389
73
  return { _iv: iv, _data: data, cek: null };
390
74
  }
391
75
 
392
- // src/kernel/enclave/record-keys/tombstone.ts
393
- function isTombstone(envelope, encrypted) {
394
- if (!encrypted) return false;
395
- return !envelope._data && envelope._cek === void 0;
396
- }
397
- function buildTombstone(version, actor) {
76
+ // src/kernel/enclave/record-keys/sealed-slots.ts
77
+ async function sealOneFieldWithDek(field, value, dek, keyMaterial) {
78
+ const fieldKey = keyMaterial.cek !== void 0 ? await deriveSealedFieldKeyFromCek(keyMaterial.cek, keyMaterial.collection, field) : await deriveSealedFieldKey(dek, keyMaterial.collection, field);
79
+ return encrypt(JSON.stringify(value), fieldKey);
80
+ }
81
+ async function sealOneField(field, value, keyMaterial) {
82
+ const dek = await keyMaterial.getDEK();
83
+ return sealOneFieldWithDek(field, value, dek, keyMaterial);
84
+ }
85
+ async function sealFields(record, sensitiveFields, keyMaterial) {
86
+ const dek = await keyMaterial.getDEK();
87
+ const open = { ...record };
88
+ const slots = {};
89
+ for (const field of sensitiveFields) {
90
+ if (!(field in record)) continue;
91
+ const value = record[field];
92
+ if (value === void 0) continue;
93
+ const { iv, data } = await sealOneFieldWithDek(field, value, dek, keyMaterial);
94
+ slots[field] = `${iv}:${data}`;
95
+ delete open[field];
96
+ }
97
+ if (Object.keys(slots).length === 0) return { openRecord: record, sealed: void 0 };
98
+ return { openRecord: open, sealed: slots };
99
+ }
100
+ async function unsealOneField(field, blob, keyMaterial) {
101
+ const dek = await keyMaterial.getDEK();
102
+ return JSON.parse(await dualReadSealedSlot(blob, field, keyMaterial.collection, keyMaterial.cek, dek));
103
+ }
104
+ function makeHandleProducer(keyMaterial) {
105
+ return (field, blob) => new SealedHandle(() => unsealOneField(field, blob, keyMaterial));
106
+ }
107
+ async function unsealFields(record, sealed, keyMaterial, opts) {
108
+ const makeHandle = opts?.asHandles === true ? makeHandleProducer(keyMaterial) : void 0;
109
+ for (const [field, blob] of Object.entries(sealed)) {
110
+ record[field] = makeHandle !== void 0 ? makeHandle(field, blob) : await unsealOneField(field, blob, keyMaterial);
111
+ }
112
+ return record;
113
+ }
114
+ function makeSealedSlotCapability(ctx, recordId, cek) {
115
+ const keyMaterial = {
116
+ collection: ctx.name,
117
+ ...cek !== void 0 ? { cek } : {},
118
+ getDEK: () => ctx.getDEK()
119
+ };
120
+ const deletedFields = /* @__PURE__ */ new Set();
398
121
  return {
399
- _noydb: NOYDB_FORMAT_VERSION,
400
- _v: version,
401
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
402
- _iv: "",
403
- _data: "",
404
- ...actor ? { _by: actor } : {}
122
+ async seal(field, plaintext) {
123
+ const ref = await sealOneField(field, plaintext, keyMaterial);
124
+ deletedFields.delete(field);
125
+ return ref;
126
+ },
127
+ async unseal(field, ref) {
128
+ if (deletedFields.has(field)) {
129
+ throw new ValidationError(`sealedSlots.unseal: field "${field}" on record "${recordId}" was deleted from this capability`);
130
+ }
131
+ return unsealOneField(field, `${ref.iv}:${ref.data}`, keyMaterial);
132
+ },
133
+ async delete(field) {
134
+ deletedFields.add(field);
135
+ }
405
136
  };
406
137
  }
407
-
408
- // src/kernel/enclave/record-keys/sealed-slot.ts
409
- function parseSealedSlot(blob) {
410
- const sep = blob.indexOf(":");
411
- return { iv: blob.slice(0, sep), data: blob.slice(sep + 1) };
138
+ function makeReservedEnvelopes(dekResolver, declaredPrefixes) {
139
+ const declared = new Set(declaredPrefixes);
140
+ return (prefix) => {
141
+ if (!declared.has(prefix)) {
142
+ throw new ValidationError(`reservedEnvelopes: prefix "${prefix}" is not declared by this binding's reservedPrefixes`);
143
+ }
144
+ const assertPrefixed = (collection, method) => {
145
+ if (!collection.startsWith(prefix)) {
146
+ throw new ValidationError(
147
+ `reservedEnvelopes('${prefix}').${method}: collection "${collection}" does not start with "${prefix}"`
148
+ );
149
+ }
150
+ };
151
+ const encryptForPrefix = async (collection, json, v) => {
152
+ assertPrefixed(collection, "encrypt");
153
+ const dek = await dekResolver(collection);
154
+ const { iv, data } = await encrypt(json, dek);
155
+ return {
156
+ _noydb: NOYDB_FORMAT_VERSION,
157
+ _v: v,
158
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
159
+ _iv: iv,
160
+ _data: data
161
+ };
162
+ };
163
+ const decryptForPrefix = async (collection, env) => {
164
+ assertPrefixed(collection, "decrypt");
165
+ const dek = await dekResolver(collection);
166
+ return decrypt(env._iv, env._data, dek);
167
+ };
168
+ return { encrypt: encryptForPrefix, decrypt: decryptForPrefix };
169
+ };
412
170
  }
413
- async function dualReadSealedSlot(blob, field, collection, cek, dek) {
414
- const { iv, data } = parseSealedSlot(blob);
415
- if (cek !== void 0) {
171
+
172
+ // src/kernel/enclave/classify/write.ts
173
+ async function mintVdigSlot(rawValue, policy, prevBlob, cek, collection, recordId, field) {
174
+ const normalized = normalizeForVerify(policy.normalize, rawValue);
175
+ let prev = null;
176
+ if (prevBlob !== void 0) {
416
177
  try {
417
- const fieldKey2 = await deriveSealedFieldKeyFromCek(cek, collection, field);
418
- return await decrypt(iv, data, fieldKey2);
178
+ prev = await openVdigPayload(prevBlob, cek, collection, recordId, field);
419
179
  } catch {
180
+ throw new TamperedError();
181
+ }
182
+ if (!Number.isInteger(prev.iter) || prev.iter < 1) {
183
+ throw new TamperedError();
420
184
  }
421
185
  }
422
- const fieldKey = await deriveSealedFieldKey(dek, collection, field);
423
- return decrypt(iv, data, fieldKey);
186
+ if (prev !== null && policy.notLastN > 0) {
187
+ const history = [prev.cur, ...prev.ring ?? []];
188
+ for (const entry of history) {
189
+ const digest = await pbkdf2VerifyDigest(normalized, base64ToBuffer(entry.salt), prev.iter);
190
+ if (await blindedEqual(digest, base64ToBuffer(entry.hash))) {
191
+ throw new ClassifiedRotationError(collection, field, "password was used recently");
192
+ }
193
+ }
194
+ }
195
+ const salt = generateSalt();
196
+ const hash = await pbkdf2VerifyDigest(normalized, salt, VDIG_ITERATIONS);
197
+ const ring = prev !== null && policy.notLastN > 0 ? [...prev.ring ?? [], { salt: prev.cur.salt, hash: prev.cur.hash }].slice(-policy.notLastN) : void 0;
198
+ const payload = {
199
+ v: 1,
200
+ alg: "PBKDF2-SHA256",
201
+ iter: VDIG_ITERATIONS,
202
+ cur: { salt: bufferToBase64(salt), hash: bufferToBase64(hash), at: (/* @__PURE__ */ new Date()).toISOString() },
203
+ ...ring !== void 0 && ring.length > 0 ? { ring } : {}
204
+ };
205
+ return sealVdigPayload(payload, cek, collection, recordId, field);
424
206
  }
425
207
 
426
208
  // src/kernel/schema.ts
@@ -467,6 +249,42 @@ var RecordCodec = class _RecordCodec {
467
249
  this.ctx = ctx;
468
250
  }
469
251
  ctx;
252
+ /**
253
+ * @internal Update the live Via pipeline this codec's at-rest hooks read
254
+ * (#638 Task 3) — called by `via/graph-wiring.ts#applyTaintOverlay` right
255
+ * after it reassigns `Collection.via`, so `hasAtRestHooks`/`encodeAtRest`/
256
+ * `decodeAtRest` see the newly-added `taint` binding instead of the
257
+ * pipeline snapshot captured when this codec was constructed.
258
+ */
259
+ setVia(via) {
260
+ this.ctx.via = via;
261
+ }
262
+ /** Sealed-slot key material for this codec's collection, for a given per-record CEK (or none). */
263
+ sealKeyMaterial(cek) {
264
+ return {
265
+ collection: this.ctx.name,
266
+ ...cek !== void 0 ? { cek } : {},
267
+ getDEK: () => this.ctx.getDEK()
268
+ };
269
+ }
270
+ /**
271
+ * Build the `ViaCryptoCtx` handed to a binding's `encodeAtRest`/
272
+ * `decodeAtRest` hook: `sealedSlots` pre-bound to `(this.ctx.name,
273
+ * recordId)` — always threading `cek` when the caller has one, so the
274
+ * capability's record-binding stays cryptographic rather than degrading
275
+ * to collection-scope. `reservedEnvelopes`'s DEK resolver forwards its
276
+ * `collection` argument straight to `this.ctx.getDEK` (#629 Task 4) — it
277
+ * resolves the RESERVED collection's own DEK (e.g. `_dict_status`), never
278
+ * `this.ctx.name`'s, matching `Vault.getDEK`'s per-collection-name
279
+ * resolution (the same resolver `DictionaryHandle` used pre-cutover).
280
+ */
281
+ viaCryptoCtx(recordId, cek) {
282
+ const declaredPrefixes = this.ctx.via?.bindings.flatMap((b) => b.reservedPrefixes ?? []) ?? [];
283
+ return {
284
+ sealedSlots: makeSealedSlotCapability(this.ctx, recordId, cek),
285
+ reservedEnvelopes: makeReservedEnvelopes((collection) => this.ctx.getDEK(collection), declaredPrefixes)
286
+ };
287
+ }
470
288
  // ──────────────────────────────────────────────────────────────────────
471
289
  // Low-level literal builders
472
290
  // ──────────────────────────────────────────────────────────────────────
@@ -552,47 +370,130 @@ var RecordCodec = class _RecordCodec {
552
370
  const { iv, data } = await encrypt(json, dek);
553
371
  return _RecordCodec.buildEnvelope({ version, iv, data, by, provenance });
554
372
  }
555
- async encryptRecord(record, version, cek, source, sourceTs) {
373
+ async encryptRecord(record, version, cek, source, sourceTs, vdig, id) {
556
374
  if (!this.ctx.storeCiphertext && this.ctx.debugPlaintext && !this.ctx.name.startsWith("_")) {
557
375
  return this.buildDebugEnvelope(record, version, source, sourceTs);
558
376
  }
377
+ if (this.ctx.storeCiphertext) {
378
+ const declared = this.ctx.vdigFields;
379
+ const storedClassified = /* @__PURE__ */ new Set();
380
+ if (vdig?.prev?._vdig) for (const k of Object.keys(vdig.prev._vdig)) storedClassified.add(k);
381
+ if (vdig?.prev?._bidx) for (const k of Object.keys(vdig.prev._bidx)) storedClassified.add(k);
382
+ if (this.ctx.classifiedMarkerDigestOnly !== void 0) {
383
+ for (const k of await this.ctx.classifiedMarkerDigestOnly()) storedClassified.add(k);
384
+ }
385
+ let undeclared;
386
+ for (const field of storedClassified) {
387
+ if (declared === null || !declared.has(field)) {
388
+ undeclared = field;
389
+ break;
390
+ }
391
+ }
392
+ if (undeclared !== void 0) {
393
+ throw new ClassifiedConfigError(
394
+ this.ctx.name,
395
+ `this collection has classified digest-only field "${undeclared}" but this handle does not declare it \u2014 refusing to write (would drop its tag or serialize the secret as plaintext)`
396
+ );
397
+ }
398
+ }
559
399
  let openRecord = record;
560
400
  let sealed;
561
- if (this.ctx.storeCiphertext && this.ctx.sensitiveFields.size > 0) {
401
+ if (this.ctx.storeCiphertext && this.ctx.via?.hasAtRestHooks) {
402
+ if (id === void 0) {
403
+ throw new Error(
404
+ `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.`
405
+ );
406
+ }
562
407
  const src = record;
563
- const dek2 = await this.ctx.getDEK();
564
- const open = { ...src };
565
- const slots = {};
566
- for (const field of this.ctx.sensitiveFields) {
567
- if (!(field in src)) continue;
568
- const value = src[field];
569
- if (value === void 0) continue;
570
- const fieldKey = cek !== void 0 ? await deriveSealedFieldKeyFromCek(cek, this.ctx.name, field) : await deriveSealedFieldKey(dek2, this.ctx.name, field);
571
- const { iv, data } = await encrypt(JSON.stringify(value), fieldKey);
572
- slots[field] = `${iv}:${data}`;
573
- delete open[field];
408
+ const result = await this.ctx.via.encodeAtRest(src, this.viaCryptoCtx(id, cek));
409
+ openRecord = result.record;
410
+ if (result.sealed !== void 0) {
411
+ sealed = {};
412
+ for (const [field, ref] of Object.entries(result.sealed)) sealed[field] = `${ref.iv}:${ref.data}`;
574
413
  }
575
- if (Object.keys(slots).length > 0) {
576
- sealed = slots;
577
- openRecord = open;
414
+ } else if (this.ctx.storeCiphertext && this.ctx.sensitiveFields.size > 0) {
415
+ const src = record;
416
+ const result = await sealFields(src, this.ctx.sensitiveFields, this.sealKeyMaterial(cek));
417
+ if (result.sealed !== void 0) {
418
+ sealed = result.sealed;
419
+ openRecord = result.openRecord;
420
+ }
421
+ }
422
+ let vdigOut;
423
+ let bidxOutMap;
424
+ if (this.ctx.vdigFields !== null && this.ctx.vdigFields.size > 0 && this.ctx.storeCiphertext) {
425
+ if (vdig === void 0) {
426
+ throw new Error(
427
+ `RecordCodec.encryptRecord: collection "${this.ctx.name}" declares digest-only classified fields but this write path supplied no { id, prev } context \u2014 it would silently destroy _vdig (C6). Caller bug.`
428
+ );
429
+ }
430
+ if (cek === void 0) {
431
+ throw new Error(
432
+ `RecordCodec.encryptRecord: digest-only fields require a per-record CEK (R1 invariant) \u2014 collection "${this.ctx.name}" wrote without one. Caller bug.`
433
+ );
434
+ }
435
+ const open = { ...openRecord };
436
+ const out = {};
437
+ const bidxOut = {};
438
+ let bidxDek;
439
+ for (const [field, policy] of this.ctx.vdigFields) {
440
+ const value = open[field];
441
+ const prevBlob = vdig.prev?._vdig?.[field];
442
+ if (vdig.prev?._sealed?.[field] !== void 0) {
443
+ throw new ClassifiedConfigError(
444
+ this.ctx.name,
445
+ `field "${field}" carries a recoverable _sealed slot from a previous storage form \u2014 recoverable \u2194 digest-only transitions are refused (R6); migrate explicitly`
446
+ );
447
+ }
448
+ if (value === void 0) {
449
+ if (prevBlob !== void 0) {
450
+ out[field] = prevBlob;
451
+ const prevTag = vdig.prev?._bidx?.[field];
452
+ if (prevTag !== void 0) bidxOut[field] = prevTag;
453
+ }
454
+ continue;
455
+ }
456
+ if (value === null) {
457
+ delete open[field];
458
+ continue;
459
+ }
460
+ if (typeof value !== "string") {
461
+ throw new ValidationError(
462
+ `digest-only classified field "${field}" in "${this.ctx.name}" must be a string (rotate) or null (clear), got ${typeof value}`
463
+ );
464
+ }
465
+ out[field] = await mintVdigSlot(value, policy, prevBlob, cek, this.ctx.name, vdig.id, field);
466
+ if (policy.equatable === true) {
467
+ if (bidxDek === void 0) bidxDek = await this.ctx.getDEK();
468
+ const normalized = normalizeForVerify(policy.normalize, value);
469
+ bidxOut[field] = await mintBidxTag(normalized, bidxDek, this.ctx.name, field);
470
+ }
471
+ delete open[field];
578
472
  }
473
+ openRecord = open;
474
+ if (Object.keys(out).length > 0) vdigOut = out;
475
+ if (Object.keys(bidxOut).length > 0) bidxOutMap = bidxOut;
579
476
  }
580
477
  const base = await this.encryptJsonString(JSON.stringify(openRecord), version, cek, source, sourceTs);
581
478
  const withSealed = sealed ? { ...base, _sealed: sealed } : base;
582
- if (!this.ctx.deterministicFields || !this.ctx.storeCiphertext) return withSealed;
479
+ const withVdig = vdigOut ? { ...withSealed, _vdig: vdigOut } : withSealed;
480
+ const withBidx = bidxOutMap ? { ...withVdig, _bidx: bidxOutMap } : withVdig;
481
+ if (!this.ctx.deterministicFields || !this.ctx.storeCiphertext) return withBidx;
583
482
  const dek = await this.ctx.getDEK();
483
+ const detKey = await deriveDeterministicKey(dek);
584
484
  const rec = record;
585
485
  const det = {};
586
486
  for (const field of this.ctx.deterministicFields) {
587
487
  if (this.ctx.sensitiveFields.has(field)) continue;
488
+ if (this.ctx.vdigFields?.has(field)) continue;
588
489
  const value = rec[field];
589
490
  if (value === void 0 || value === null) continue;
590
491
  const plaintext = typeof value === "string" ? value : JSON.stringify(value);
591
- const { iv, data } = await encryptDeterministic(plaintext, dek, `${this.ctx.name}/${field}`);
492
+ const { iv, data } = await encryptDeterministic(plaintext, detKey, `${this.ctx.name}/${field}`);
592
493
  det[field] = `${iv}:${data}`;
593
494
  }
594
- if (Object.keys(det).length === 0) return withSealed;
595
- return { ...withSealed, _det: det };
495
+ if (Object.keys(det).length === 0) return withBidx;
496
+ return { ...withBidx, _det: det };
596
497
  }
597
498
  // ──────────────────────────────────────────────────────────────────────
598
499
  // Read path
@@ -629,7 +530,7 @@ var RecordCodec = class _RecordCodec {
629
530
  * callers (history, conflict merge) that have only the envelope.
630
531
  */
631
532
  async decryptJsonString(envelope, id) {
632
- if (isTombstone(envelope, this.ctx.storeCiphertext)) return null;
533
+ if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
633
534
  if (!this.ctx.storeCiphertext) {
634
535
  if (envelope._debug !== void 0) {
635
536
  const rec = {};
@@ -638,7 +539,7 @@ var RecordCodec = class _RecordCodec {
638
539
  }
639
540
  return JSON.stringify(rec);
640
541
  }
641
- return envelope._data;
542
+ return envelope._data === "" ? null : envelope._data;
642
543
  }
643
544
  const cek = await this.resolveEnvelopeCek(envelope, id);
644
545
  if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek);
@@ -653,8 +554,16 @@ var RecordCodec = class _RecordCodec {
653
554
  * materialisation always agree byte-for-byte.
654
555
  */
655
556
  async unsealField(field, blob, cek) {
656
- const dek = await this.ctx.getDEK();
657
- return JSON.parse(await dualReadSealedSlot(blob, field, this.ctx.name, cek, dek));
557
+ return unsealOneField(field, blob, this.sealKeyMaterial(cek));
558
+ }
559
+ /**
560
+ * Build the `ViaCryptoCtx` for forget()'s per-ref via-erase fold (#629
561
+ * Task 10) — resolves the live envelope's CEK exactly like
562
+ * `decryptRecord` does, then delegates to the same capability factory
563
+ * `encodeAtRest`/`decodeAtRest` use.
564
+ */
565
+ async eraseCryptoCtx(id, live) {
566
+ return this.viaCryptoCtx(id, await this.resolveEnvelopeCek(live, id));
658
567
  }
659
568
  /**
660
569
  * Classify a live envelope's `_sealed` slots for crypto-shred completeness.
@@ -668,25 +577,32 @@ var RecordCodec = class _RecordCodec {
668
577
  * `_cek` (pure legacy collection-DEK sealing) ALL slots are residue.
669
578
  */
670
579
  async classifySealedShred(live) {
671
- const shreddable = [];
672
- const dekResidue = [];
580
+ const slots = [];
581
+ if (live._vdig !== void 0 && live._cek !== void 0) {
582
+ for (const field of Object.keys(live._vdig)) {
583
+ slots.push({
584
+ field,
585
+ class: live._bidx?.[field] !== void 0 ? "live-shreddable+dekResidue-in-backups" : "shreddable"
586
+ });
587
+ }
588
+ }
673
589
  const sealed = live._sealed;
674
- if (sealed === void 0) return { shreddable, dekResidue };
590
+ if (sealed === void 0) return { slots };
675
591
  const cek = await this.resolveEnvelopeCek(live);
676
592
  for (const [field, blob] of Object.entries(sealed)) {
677
593
  if (cek === void 0) {
678
- dekResidue.push(field);
594
+ slots.push({ field, class: "dekResidue" });
679
595
  continue;
680
596
  }
681
597
  const { iv, data } = parseSealedSlot(blob);
682
598
  try {
683
599
  await decrypt(iv, data, await deriveSealedFieldKeyFromCek(cek, this.ctx.name, field));
684
- shreddable.push(field);
600
+ slots.push({ field, class: "shreddable" });
685
601
  } catch {
686
- dekResidue.push(field);
602
+ slots.push({ field, class: "dekResidue" });
687
603
  }
688
604
  }
689
- return { shreddable, dekResidue };
605
+ return { slots };
690
606
  }
691
607
  /**
692
608
  * Build a non-leaking {@link Sealed} handle over a sealed field's ciphertext.
@@ -696,18 +612,26 @@ var RecordCodec = class _RecordCodec {
696
612
  * exposing the value, which decrypts only on `reveal()`.
697
613
  */
698
614
  makeSealedHandle(field, blob, cek) {
699
- return new SealedHandle(() => this.unsealField(field, blob, cek));
615
+ return makeHandleProducer(this.sealKeyMaterial(cek))(field, blob);
700
616
  }
701
617
  /**
702
- * Replace a record's declared sensitive fields with {@link Sealed} handles
703
- * built from the just-written envelope's `_sealed` slots, leaving every
704
- * other field as its plaintext value. Used to populate the cache on the
705
- * write path without ever materialising sealed plaintext into it. Returns
706
- * `record` untouched when the collection seals nothing.
618
+ * Replace every field the just-written envelope actually sealed with a
619
+ * {@link Sealed} handle, leaving every other field as its plaintext value.
620
+ * Used to populate the cache on the write path without ever materialising
621
+ * sealed plaintext into it. Returns `record` untouched when nothing was
622
+ * sealed. Keys off `envelope._sealed` itself (#642 fix) — NOT
623
+ * `this.ctx.sensitiveFields`, which only names the inline `sensitive:[...]`/
624
+ * classified-recoverable field set: a collection whose sealing comes
625
+ * entirely from the `taint` via-binding (a derivation/MV output or rollup
626
+ * target folded sealed from a classified SOURCE collection, #642) declares
627
+ * no local `sensitiveFields` at all, so that stale gate skipped this
628
+ * conversion and left a just-written taint-sealed field as cached
629
+ * plaintext — read back correctly ONLY after a cold cache miss (`get()`'s
630
+ * own `decodeAtRest` call, unaffected by this gate) forced a fresh decrypt.
707
631
  */
708
632
  async toCacheRecord(record, envelope, id) {
709
633
  const sealed = envelope._sealed;
710
- if (sealed === void 0 || !this.ctx.storeCiphertext || this.ctx.sensitiveFields.size === 0) {
634
+ if (sealed === void 0 || !this.ctx.storeCiphertext) {
711
635
  return record;
712
636
  }
713
637
  const cek = await this.resolveEnvelopeCek(envelope, id);
@@ -717,6 +641,57 @@ var RecordCodec = class _RecordCodec {
717
641
  }
718
642
  return clone;
719
643
  }
644
+ /**
645
+ * Apply `_sealed`-slot post-processing to an ALREADY-DECRYPTED `record`:
646
+ * restore each `_sealed[field]` blob inline (`sealedAsHandles` falsy) or
647
+ * as an opaque {@link Sealed} handle (`sealedAsHandles: true`), routing
648
+ * through a via pipeline's `decodeAtRest` hook when one is declared.
649
+ * Extracted byte-parity from `decryptRecord`'s inline block (#635) so a
650
+ * caller that resolves its OWN per-record CEK under a DIFFERENT DEK than
651
+ * this codec's `this.ctx.getDEK()` — namely the tier>0 `getAtTier` leg in
652
+ * `with-audit/tiers/index.ts`, whose `_cek` is wrapped under the TIER DEK,
653
+ * not the collection DEK `decryptRecord`/`resolveEnvelopeCek` always
654
+ * unwrap under — can still get correct sealed-slot handling without
655
+ * routing its whole read through `decryptRecord` (which would resolve the
656
+ * wrong DEK for it).
657
+ *
658
+ * Zero-knowledge: takes only the already-resolved per-record `cek` (or
659
+ * `undefined` for a legacy/no-CEK record) — the same shape `makeSealedHandle`
660
+ * already takes above. Never the keyring, never a raw DEK: the legacy
661
+ * fallback key stays fully internal to `sealKeyMaterial`/`viaCryptoCtx`,
662
+ * which close over THIS codec's own `getDEK` (permanently bound to
663
+ * `this.ctx.name`'s tier-0 DEK at construction) — so even when called from
664
+ * a tier>0 context, the legacy-fallback key resolution is correct: sealed
665
+ * fields are always sealed under the CEK or the collection's tier-0 DEK,
666
+ * never a tier DEK (tier writes don't seal fields; `_sealed` reaches a
667
+ * tiered envelope only via a tier-0 write later elevated).
668
+ */
669
+ async applySealedSlots(record, sealed, cek, opts = {}) {
670
+ if (this.ctx.via?.hasAtRestHooks) {
671
+ if (opts.id === void 0) {
672
+ throw new Error(
673
+ `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.`
674
+ );
675
+ }
676
+ const sealedRefs = {};
677
+ for (const [field, blob] of Object.entries(sealed)) {
678
+ const { iv, data } = parseSealedSlot(blob);
679
+ sealedRefs[field] = { iv, data };
680
+ }
681
+ return await this.ctx.via.decodeAtRest(
682
+ record,
683
+ sealedRefs,
684
+ this.viaCryptoCtx(opts.id, cek),
685
+ { asHandles: opts.sealedAsHandles === true }
686
+ );
687
+ }
688
+ return await unsealFields(
689
+ record,
690
+ sealed,
691
+ this.sealKeyMaterial(cek),
692
+ { asHandles: opts.sealedAsHandles === true }
693
+ );
694
+ }
720
695
  /**
721
696
  * Decrypt an envelope into a record of type `T`.
722
697
  *
@@ -742,10 +717,10 @@ var RecordCodec = class _RecordCodec {
742
717
  let record = parsed;
743
718
  if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
744
719
  const sealedCek = await this.resolveEnvelopeCek(envelope, opts.id);
745
- const target = record;
746
- for (const [field, blob] of Object.entries(envelope._sealed)) {
747
- target[field] = opts.sealedAsHandles ? this.makeSealedHandle(field, blob, sealedCek) : await this.unsealField(field, blob, sealedCek);
748
- }
720
+ record = await this.applySealedSlots(record, envelope._sealed, sealedCek, {
721
+ ...opts.id !== void 0 ? { id: opts.id } : {},
722
+ ...opts.sealedAsHandles !== void 0 ? { sealedAsHandles: opts.sealedAsHandles } : {}
723
+ });
749
724
  }
750
725
  const sealedAsHandles = opts.sealedAsHandles === true && envelope._sealed !== void 0;
751
726
  if (this.ctx.schema !== void 0 && !opts.skipValidation && !sealedAsHandles) {
@@ -760,7 +735,7 @@ var RecordCodec = class _RecordCodec {
760
735
  };
761
736
 
762
737
  // src/kernel/enclave/record-keys/sealing.ts
763
- var subtle2 = globalThis.crypto.subtle;
738
+ var subtle = globalThis.crypto.subtle;
764
739
  var SEALED_CEK_NS = "_sealed_cek";
765
740
  async function sealRecordToHost(ctx, collection, id, hostSealer, opts) {
766
741
  if (collection.includes("/")) throw new ValidationError(`sealRecordToHost: collection "${collection}" must not contain "/"`);
@@ -774,7 +749,7 @@ async function sealRecordToHost(ctx, collection, id, hostSealer, opts) {
774
749
  }
775
750
  const dek = await ctx.getDEK(collection);
776
751
  const cek = await unwrapCek(live._cek, dek);
777
- const rawCek = await subtle2.exportKey("raw", cek);
752
+ const rawCek = await subtle.exportKey("raw", cek);
778
753
  const cekB64 = bufferToBase64(rawCek);
779
754
  const hint = await hostSealer.publishRecipientHint();
780
755
  if (hint.pid.includes("/")) throw new ValidationError(`sealRecordToHost: recipient pid "${hint.pid}" must not contain "/"`);
@@ -837,6 +812,15 @@ async function rotateRecordCek(ctx, collection, id) {
837
812
  }
838
813
  sealedOut = out;
839
814
  }
815
+ let vdigOut;
816
+ if (live._vdig !== void 0) {
817
+ const out = {};
818
+ for (const [field, blob] of Object.entries(live._vdig)) {
819
+ const payload = await openVdigPayload(blob, oldCek, collection, id, field);
820
+ out[field] = await sealVdigPayload(payload, newCek, collection, id, field);
821
+ }
822
+ vdigOut = out;
823
+ }
840
824
  const env = {
841
825
  _noydb: NOYDB_FORMAT_VERSION,
842
826
  _v: live._v + 1,
@@ -847,12 +831,19 @@ async function rotateRecordCek(ctx, collection, id) {
847
831
  ...ctx.actor ? { _by: ctx.actor } : {},
848
832
  ...live._tier !== void 0 ? { _tier: live._tier } : {},
849
833
  ...live._det !== void 0 ? { _det: live._det } : {},
834
+ // `_bidx` (equality-index tag) is DEK-rooted and CEK-independent, so it is
835
+ // carried forward VERBATIM — not recomputed — unlike `_vdig`/`_sealed`
836
+ // below, which are CEK-bound and must be re-sealed under the new CEK.
837
+ // Dropping this line would silently orphan the equality index on rotation
838
+ // (the #306 Slice-A data-loss bug, replayed on the index).
839
+ ...live._bidx !== void 0 ? { _bidx: live._bidx } : {},
850
840
  // Re-encrypt sealed (`sensitive`) fields under the new CEK. Sealed
851
841
  // keys derive off the per-record CEK, so the rotated record's old CEK is
852
842
  // destroyed here — carrying the old `_sealed` slots forward verbatim would
853
843
  // orphan them (unreadable under the new CEK). `sealedOut` holds the slots
854
844
  // dual-read from the old CEK (or the legacy DEK) and re-sealed under newCek.
855
- ...sealedOut !== void 0 ? { _sealed: sealedOut } : {}
845
+ ...sealedOut !== void 0 ? { _sealed: sealedOut } : {},
846
+ ...vdigOut !== void 0 ? { _vdig: vdigOut } : {}
856
847
  };
857
848
  await ctx.adapter.put(ctx.vault, collection, id, env);
858
849
  await ctx.invalidateRecordCaches(collection, id);
@@ -866,11 +857,16 @@ async function rotateRecordCek(ctx, collection, id) {
866
857
  }
867
858
 
868
859
  // src/kernel/enclave/record-keys/deterministic.ts
869
- async function detTarget(ctx, field, value) {
860
+ async function detTargets(ctx, field, value) {
870
861
  const dek = await ctx.getDEK();
862
+ const detKey = await deriveDeterministicKey(dek);
871
863
  const plaintext = typeof value === "string" ? value : JSON.stringify(value);
872
- const { iv, data } = await encryptDeterministic(plaintext, dek, `${ctx.name}/${field}`);
873
- return `${iv}:${data}`;
864
+ const context = `${ctx.name}/${field}`;
865
+ const [current, legacy] = await Promise.all([
866
+ encryptDeterministic(plaintext, detKey, context),
867
+ encryptDeterministic(plaintext, dek, context)
868
+ ]);
869
+ return [`${current.iv}:${current.data}`, `${legacy.iv}:${legacy.data}`];
874
870
  }
875
871
  function assertDetField(ctx, field, method) {
876
872
  if (!ctx.deterministicFields || !ctx.deterministicFields.has(field)) {
@@ -886,27 +882,27 @@ function assertDetField(ctx, field, method) {
886
882
  }
887
883
  async function findByDet(ctx, field, value) {
888
884
  assertDetField(ctx, field, "findByDet");
889
- const target = await detTarget(ctx, field, value);
885
+ const [target, legacyTarget] = await detTargets(ctx, field, value);
890
886
  const ids = await ctx.adapter.list(ctx.vault, ctx.name);
891
887
  for (const id of ids) {
892
888
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
893
889
  if (!env || !env._det) continue;
894
- if (env._det[field] === target) {
895
- return ctx.codec.decryptRecord(env);
890
+ if (env._det[field] === target || env._det[field] === legacyTarget) {
891
+ return ctx.codec.decryptRecord(env, { id });
896
892
  }
897
893
  }
898
894
  return null;
899
895
  }
900
896
  async function queryByDet(ctx, field, value) {
901
897
  assertDetField(ctx, field, "queryByDet");
902
- const target = await detTarget(ctx, field, value);
898
+ const [target, legacyTarget] = await detTargets(ctx, field, value);
903
899
  const ids = await ctx.adapter.list(ctx.vault, ctx.name);
904
900
  const matches = [];
905
901
  for (const id of ids) {
906
902
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
907
903
  if (!env || !env._det) continue;
908
- if (env._det[field] === target) {
909
- const rec = await ctx.codec.decryptRecord(env);
904
+ if (env._det[field] === target || env._det[field] === legacyTarget) {
905
+ const rec = await ctx.codec.decryptRecord(env, { id });
910
906
  if (rec !== null) matches.push(rec);
911
907
  }
912
908
  }
@@ -937,44 +933,24 @@ function hasPerRecordKey(env) {
937
933
  return env._cek !== void 0;
938
934
  }
939
935
  function envelopeBodyForHash(env) {
940
- if (env._sealed === void 0) return env._data;
941
- const sealedKeys = Object.keys(env._sealed).sort();
942
- const sealedParts = sealedKeys.map(
943
- (k) => `${JSON.stringify(k)}:${JSON.stringify(env._sealed[k])}`
944
- );
945
- return `{"_data":${JSON.stringify(env._data)},"_sealed":{${sealedParts.join(",")}}}`;
936
+ if (env._sealed === void 0 && env._vdig === void 0 && env._bidx === void 0) return env._data;
937
+ const mapPart = (key, map) => {
938
+ const parts = Object.keys(map).sort().map(
939
+ (k) => `${JSON.stringify(k)}:${JSON.stringify(map[k])}`
940
+ );
941
+ return `${JSON.stringify(key)}:{${parts.join(",")}}`;
942
+ };
943
+ const segments = [`"_data":${JSON.stringify(env._data)}`];
944
+ if (env._sealed !== void 0) segments.push(mapPart("_sealed", env._sealed));
945
+ if (env._vdig !== void 0) segments.push(mapPart("_vdig", env._vdig));
946
+ if (env._bidx !== void 0) segments.push(mapPart("_bidx", env._bidx));
947
+ return `{${segments.join(",")}}`;
946
948
  }
947
949
 
948
950
  export {
949
- deriveKey,
950
- derivePassphraseKey,
951
- generateDEK,
952
- wrapKey,
953
- unwrapKey,
954
- wrapCek,
955
- unwrapCek,
956
- importCek,
957
- encrypt,
958
- decrypt,
959
- encryptBytes,
960
- decryptBytes,
961
- sha256Hex,
962
- hmacSha256Hex,
963
- encryptBytesWithAAD,
964
- decryptBytesWithAAD,
965
- derivePresenceKey,
966
- deriveSealedFieldKey,
967
- deriveSealedFieldKeyFromCek,
968
- encryptDeterministic,
969
- decryptDeterministic,
970
- generateIV,
971
- generateSalt,
972
- bufferToBase64,
973
- base64ToBuffer,
974
951
  resolveStableCek,
975
952
  rewrapBodyToDek,
976
- isTombstone,
977
- buildTombstone,
953
+ makeReservedEnvelopes,
978
954
  validateSchemaInput,
979
955
  validateSchemaOutput,
980
956
  RecordCodec,
@@ -989,4 +965,4 @@ export {
989
965
  hasPerRecordKey,
990
966
  envelopeBodyForHash
991
967
  };
992
- //# sourceMappingURL=chunk-5O3AOPDT.js.map
968
+ //# sourceMappingURL=chunk-MCHVVJIA.js.map