@noy-db/hub 0.2.0-pre.9 → 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 (615) hide show
  1. package/README.md +129 -3
  2. package/dist/aggregate/index.d.ts +5 -2
  3. package/dist/aggregate/index.js +25 -16
  4. package/dist/aggregate/index.js.map +1 -1
  5. package/dist/api-TX2EX2FX.js +20 -0
  6. package/dist/as/index.d.ts +6 -0
  7. package/dist/as/index.js +30 -0
  8. package/dist/at/index.d.ts +4 -0
  9. package/dist/at/index.js +1 -0
  10. package/dist/attestation/index.d.ts +14 -47
  11. package/dist/attestation/index.js +60 -10
  12. package/dist/attestation/index.js.map +1 -1
  13. package/dist/backup-R7NTDFKY.js +225 -0
  14. package/dist/backup-R7NTDFKY.js.map +1 -0
  15. package/dist/blobs/index.d.ts +5 -8
  16. package/dist/blobs/index.js +25 -12
  17. package/dist/blobs/index.js.map +1 -1
  18. package/dist/bundle/index.d.ts +15 -70
  19. package/dist/bundle/index.js +45 -476
  20. package/dist/bundle/index.js.map +1 -1
  21. package/dist/{ulid-CJ8RzRrm.d.ts → bundle-D6GxiUfq.d.ts} +31 -86
  22. package/dist/by/index.d.ts +1 -0
  23. package/dist/by/index.js +11 -0
  24. package/dist/cargo/index.d.ts +7 -0
  25. package/dist/cargo/index.js +95 -0
  26. package/dist/chunk-2OV5NVE7.js +95 -0
  27. package/dist/chunk-2OV5NVE7.js.map +1 -0
  28. package/dist/chunk-2OZXVKVP.js +367 -0
  29. package/dist/chunk-2OZXVKVP.js.map +1 -0
  30. package/dist/{chunk-HNRHLRDC.js → chunk-2REPHKET.js} +6 -5
  31. package/dist/chunk-2REPHKET.js.map +1 -0
  32. package/dist/{chunk-PE2FR4J3.js → chunk-3JXPAHOZ.js} +17 -17
  33. package/dist/chunk-3JXPAHOZ.js.map +1 -0
  34. package/dist/{chunk-H2X3ISXG.js → chunk-3MATJ6O4.js} +7 -7
  35. package/dist/chunk-3MATJ6O4.js.map +1 -0
  36. package/dist/{chunk-PP6W64Y3.js → chunk-3OPY6MK2.js} +132 -3
  37. package/dist/chunk-3OPY6MK2.js.map +1 -0
  38. package/dist/{chunk-T7JEBOGN.js → chunk-3QSIU3UT.js} +49 -71
  39. package/dist/chunk-3QSIU3UT.js.map +1 -0
  40. package/dist/{chunk-ZYWZWG6G.js → chunk-4OMCIY6F.js} +32 -12
  41. package/dist/chunk-4OMCIY6F.js.map +1 -0
  42. package/dist/chunk-4Q6HSHHL.js +90 -0
  43. package/dist/chunk-4Q6HSHHL.js.map +1 -0
  44. package/dist/chunk-5I35DOHK.js +94 -0
  45. package/dist/chunk-5I35DOHK.js.map +1 -0
  46. package/dist/chunk-5VG4IJR7.js +235 -0
  47. package/dist/chunk-5VG4IJR7.js.map +1 -0
  48. package/dist/chunk-5YESYH2C.js +155 -0
  49. package/dist/chunk-5YESYH2C.js.map +1 -0
  50. package/dist/chunk-6G5ORS5D.js +202 -0
  51. package/dist/chunk-6G5ORS5D.js.map +1 -0
  52. package/dist/{chunk-VTKGMEPP.js → chunk-6P5XCKSD.js} +13 -3
  53. package/dist/chunk-6P5XCKSD.js.map +1 -0
  54. package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
  55. package/dist/chunk-6S7T6WC4.js.map +1 -0
  56. package/dist/{chunk-U26HQ6KJ.js → chunk-7BWJHO2A.js} +4 -4
  57. package/dist/chunk-7BWJHO2A.js.map +1 -0
  58. package/dist/chunk-7P2SDJG3.js +279 -0
  59. package/dist/chunk-7P2SDJG3.js.map +1 -0
  60. package/dist/chunk-ANB77BVV.js +150 -0
  61. package/dist/chunk-ANB77BVV.js.map +1 -0
  62. package/dist/chunk-AURFOK3D.js +35 -0
  63. package/dist/chunk-AURFOK3D.js.map +1 -0
  64. package/dist/chunk-BKARNZJN.js +382 -0
  65. package/dist/chunk-BKARNZJN.js.map +1 -0
  66. package/dist/{chunk-3BFJOWSU.js → chunk-BQISD5ZV.js} +35 -7
  67. package/dist/chunk-BQISD5ZV.js.map +1 -0
  68. package/dist/{chunk-2GLDA55J.js → chunk-BUAQ7YI3.js} +260 -135
  69. package/dist/chunk-BUAQ7YI3.js.map +1 -0
  70. package/dist/{chunk-2WUSG3IT.js → chunk-CB7CWSKW.js} +5 -5
  71. package/dist/chunk-CB7CWSKW.js.map +1 -0
  72. package/dist/chunk-CHFZDSE4.js +1 -0
  73. package/dist/{aggregate/index.cjs → chunk-DFVUTGT2.js} +206 -222
  74. package/dist/chunk-DFVUTGT2.js.map +1 -0
  75. package/dist/chunk-DJ7KIPLV.js +23 -0
  76. package/dist/chunk-DJ7KIPLV.js.map +1 -0
  77. package/dist/chunk-DSKDQP3G.js +14066 -0
  78. package/dist/chunk-DSKDQP3G.js.map +1 -0
  79. package/dist/{chunk-5T22KDPN.js → chunk-DV4HUP5G.js} +10 -8
  80. package/dist/chunk-DV4HUP5G.js.map +1 -0
  81. package/dist/chunk-EOXAAJTY.js +621 -0
  82. package/dist/chunk-EOXAAJTY.js.map +1 -0
  83. package/dist/chunk-ET67AY6B.js +74 -0
  84. package/dist/chunk-ET67AY6B.js.map +1 -0
  85. package/dist/chunk-F4CEK5YM.js +123 -0
  86. package/dist/chunk-F4CEK5YM.js.map +1 -0
  87. package/dist/chunk-FORYWFN6.js +130 -0
  88. package/dist/chunk-FORYWFN6.js.map +1 -0
  89. package/dist/{chunk-JWRVQKRZ.js → chunk-FRP6D2DM.js} +21 -20
  90. package/dist/chunk-FRP6D2DM.js.map +1 -0
  91. package/dist/chunk-FUOE7UUV.js +341 -0
  92. package/dist/chunk-FUOE7UUV.js.map +1 -0
  93. package/dist/chunk-G4JYND6L.js +42 -0
  94. package/dist/chunk-G4JYND6L.js.map +1 -0
  95. package/dist/{chunk-53XBRIRT.js → chunk-G6XV4H65.js} +9 -9
  96. package/dist/chunk-G6XV4H65.js.map +1 -0
  97. package/dist/chunk-GHVIKOHT.js +1 -0
  98. package/dist/{chunk-PX35GA7L.js → chunk-GNMXXTMN.js} +11 -9
  99. package/dist/chunk-GNMXXTMN.js.map +1 -0
  100. package/dist/chunk-GYGLAVCX.js +19 -0
  101. package/dist/chunk-GYGLAVCX.js.map +1 -0
  102. package/dist/chunk-HPWKV3YB.js +21 -0
  103. package/dist/chunk-HPWKV3YB.js.map +1 -0
  104. package/dist/chunk-HY3AUMFI.js +41 -0
  105. package/dist/chunk-HY3AUMFI.js.map +1 -0
  106. package/dist/chunk-HYR4WZZ3.js +69 -0
  107. package/dist/chunk-HYR4WZZ3.js.map +1 -0
  108. package/dist/chunk-I7FD46FF.js +9 -0
  109. package/dist/chunk-I7FD46FF.js.map +1 -0
  110. package/dist/{chunk-TFBP23BX.js → chunk-ICXIFFYZ.js} +66 -7
  111. package/dist/chunk-ICXIFFYZ.js.map +1 -0
  112. package/dist/{chunk-TV3YZ35S.js → chunk-IGJCYUT5.js} +17 -8
  113. package/dist/chunk-IGJCYUT5.js.map +1 -0
  114. package/dist/{chunk-F3GDRNUT.js → chunk-IVLTXX4W.js} +36 -68
  115. package/dist/chunk-IVLTXX4W.js.map +1 -0
  116. package/dist/{chunk-DONMZAD2.js → chunk-J4LPNIGK.js} +62 -169
  117. package/dist/chunk-J4LPNIGK.js.map +1 -0
  118. package/dist/chunk-JJZ2LW6T.js +36 -0
  119. package/dist/chunk-JJZ2LW6T.js.map +1 -0
  120. package/dist/chunk-JK733I5V.js +23 -0
  121. package/dist/chunk-JK733I5V.js.map +1 -0
  122. package/dist/{chunk-3YPCK6JX.js → chunk-KJ2BCBTL.js} +181 -422
  123. package/dist/chunk-KJ2BCBTL.js.map +1 -0
  124. package/dist/chunk-KNZB6JMR.js +129 -0
  125. package/dist/chunk-KNZB6JMR.js.map +1 -0
  126. package/dist/{chunk-OIF6LZUR.js → chunk-KPZS5QAQ.js} +30 -11
  127. package/dist/chunk-KPZS5QAQ.js.map +1 -0
  128. package/dist/chunk-LB7FD65R.js +163 -0
  129. package/dist/chunk-LB7FD65R.js.map +1 -0
  130. package/dist/{chunk-DO7C2TOG.js → chunk-LEJIKBBB.js} +3 -3
  131. package/dist/{chunk-DO7C2TOG.js.map → chunk-LEJIKBBB.js.map} +1 -1
  132. package/dist/{chunk-O3VZPBZG.js → chunk-LL2NIVUR.js} +56 -13
  133. package/dist/chunk-LL2NIVUR.js.map +1 -0
  134. package/dist/chunk-LP7BEXCT.js +32 -0
  135. package/dist/chunk-LP7BEXCT.js.map +1 -0
  136. package/dist/chunk-MCHVVJIA.js +968 -0
  137. package/dist/chunk-MCHVVJIA.js.map +1 -0
  138. package/dist/chunk-NO272T7Q.js +194 -0
  139. package/dist/chunk-NO272T7Q.js.map +1 -0
  140. package/dist/{chunk-22DWZL57.js → chunk-NUEQU36L.js} +70 -267
  141. package/dist/chunk-NUEQU36L.js.map +1 -0
  142. package/dist/chunk-O45M6LDB.js +38 -0
  143. package/dist/chunk-O45M6LDB.js.map +1 -0
  144. package/dist/chunk-OBKWYKYC.js +117 -0
  145. package/dist/chunk-OBKWYKYC.js.map +1 -0
  146. package/dist/{chunk-DJHHA6XH.js → chunk-OHHKHSJP.js} +50 -20
  147. package/dist/chunk-OHHKHSJP.js.map +1 -0
  148. package/dist/chunk-OT76OZL6.js +45 -0
  149. package/dist/chunk-OT76OZL6.js.map +1 -0
  150. package/dist/chunk-OVYRLHPE.js +150 -0
  151. package/dist/chunk-OVYRLHPE.js.map +1 -0
  152. package/dist/{chunk-ML236QKC.js → chunk-OXCSVM3B.js} +5 -5
  153. package/dist/chunk-OXCSVM3B.js.map +1 -0
  154. package/dist/chunk-P33LUIML.js +205 -0
  155. package/dist/chunk-P33LUIML.js.map +1 -0
  156. package/dist/{chunk-DL3HWOQ5.js → chunk-PLS64NCS.js} +10 -8
  157. package/dist/chunk-PLS64NCS.js.map +1 -0
  158. package/dist/{chunk-SYMWGEET.js → chunk-PS2NEWEX.js} +3 -3
  159. package/dist/chunk-PS2NEWEX.js.map +1 -0
  160. package/dist/chunk-PY4KJPYU.js +9 -0
  161. package/dist/chunk-PY4KJPYU.js.map +1 -0
  162. package/dist/chunk-PZ5AY32C.js +10 -0
  163. package/dist/chunk-QA2KUPCP.js +45 -0
  164. package/dist/chunk-QA2KUPCP.js.map +1 -0
  165. package/dist/chunk-QOC3VYL2.js +30 -0
  166. package/dist/chunk-QOC3VYL2.js.map +1 -0
  167. package/dist/{chunk-BVRYKATC.js → chunk-QSFOZUYL.js} +62 -34
  168. package/dist/chunk-QSFOZUYL.js.map +1 -0
  169. package/dist/chunk-RHK32N73.js +30 -0
  170. package/dist/chunk-RHK32N73.js.map +1 -0
  171. package/dist/{chunk-K3DK3NU5.js → chunk-RW3Y22MW.js} +20 -5
  172. package/dist/chunk-RW3Y22MW.js.map +1 -0
  173. package/dist/{chunk-B6PB7JLN.js → chunk-S7VFUQM2.js} +541 -6
  174. package/dist/chunk-S7VFUQM2.js.map +1 -0
  175. package/dist/chunk-SVLR4POP.js +64 -0
  176. package/dist/chunk-SVLR4POP.js.map +1 -0
  177. package/dist/chunk-T7WSLRAU.js +49 -0
  178. package/dist/chunk-T7WSLRAU.js.map +1 -0
  179. package/dist/{chunk-WPLVTJ5D.js → chunk-TAKWLZZX.js} +285 -63
  180. package/dist/chunk-TAKWLZZX.js.map +1 -0
  181. package/dist/chunk-THNJ3IKU.js +17 -0
  182. package/dist/chunk-THNJ3IKU.js.map +1 -0
  183. package/dist/{chunk-XJFLDA7A.js → chunk-TMBXVJKT.js} +9 -6
  184. package/dist/chunk-TMBXVJKT.js.map +1 -0
  185. package/dist/chunk-TWKKOM55.js +54 -0
  186. package/dist/chunk-TWKKOM55.js.map +1 -0
  187. package/dist/chunk-U3WZCU7E.js +14 -0
  188. package/dist/chunk-U3WZCU7E.js.map +1 -0
  189. package/dist/{chunk-Z6FNBOTC.js → chunk-UF362QVH.js} +15 -17
  190. package/dist/chunk-UF362QVH.js.map +1 -0
  191. package/dist/chunk-UN4FVIBH.js +135 -0
  192. package/dist/chunk-UN4FVIBH.js.map +1 -0
  193. package/dist/chunk-VEAVKDDB.js +29 -0
  194. package/dist/chunk-VEAVKDDB.js.map +1 -0
  195. package/dist/chunk-VEPTFUJY.js +29 -0
  196. package/dist/chunk-VEPTFUJY.js.map +1 -0
  197. package/dist/chunk-VJV7GKQK.js +662 -0
  198. package/dist/chunk-VJV7GKQK.js.map +1 -0
  199. package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
  200. package/dist/chunk-VQNJ7UZL.js.map +1 -0
  201. package/dist/chunk-VQRAIPYF.js +50 -0
  202. package/dist/chunk-VQRAIPYF.js.map +1 -0
  203. package/dist/{chunk-DFMLEQZB.js → chunk-VRIYFLBA.js} +5 -10
  204. package/dist/chunk-VRIYFLBA.js.map +1 -0
  205. package/dist/chunk-VWM3DAVB.js +265 -0
  206. package/dist/chunk-VWM3DAVB.js.map +1 -0
  207. package/dist/{chunk-NONAAENK.js → chunk-VWRRVE6D.js} +11 -4
  208. package/dist/chunk-VWRRVE6D.js.map +1 -0
  209. package/dist/chunk-VYYM3MEN.js +98 -0
  210. package/dist/chunk-VYYM3MEN.js.map +1 -0
  211. package/dist/chunk-WBJIQSLL.js +167 -0
  212. package/dist/chunk-WBJIQSLL.js.map +1 -0
  213. package/dist/chunk-WIGQB62E.js +164 -0
  214. package/dist/chunk-WIGQB62E.js.map +1 -0
  215. package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
  216. package/dist/chunk-WXSYDNBT.js.map +1 -0
  217. package/dist/chunk-WZSCE6RM.js +466 -0
  218. package/dist/chunk-WZSCE6RM.js.map +1 -0
  219. package/dist/chunk-XGDAPN6M.js +255 -0
  220. package/dist/chunk-XGDAPN6M.js.map +1 -0
  221. package/dist/{chunk-QODLLGQ7.js → chunk-XH7XP3OL.js} +372 -37
  222. package/dist/chunk-XH7XP3OL.js.map +1 -0
  223. package/dist/chunk-XREOISSI.js +40 -0
  224. package/dist/chunk-XREOISSI.js.map +1 -0
  225. package/dist/chunk-XUBPSPKD.js +164 -0
  226. package/dist/chunk-XUBPSPKD.js.map +1 -0
  227. package/dist/chunk-Y3A5CB5G.js +247 -0
  228. package/dist/chunk-Y3A5CB5G.js.map +1 -0
  229. package/dist/{chunk-I5FOWO4J.js → chunk-YCXCR7VG.js} +52 -73
  230. package/dist/chunk-YCXCR7VG.js.map +1 -0
  231. package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
  232. package/dist/chunk-YMUGBZN2.js.map +1 -0
  233. package/dist/chunk-YMVQD5Q5.js +453 -0
  234. package/dist/chunk-YMVQD5Q5.js.map +1 -0
  235. package/dist/chunk-YN5IAHN6.js +32 -0
  236. package/dist/chunk-YN5IAHN6.js.map +1 -0
  237. package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
  238. package/dist/chunk-ZJADGNYF.js.map +1 -0
  239. package/dist/chunk-ZYJ55N7N.js +86 -0
  240. package/dist/chunk-ZYJ55N7N.js.map +1 -0
  241. package/dist/classified/index.d.ts +16 -0
  242. package/dist/classified/index.js +40 -0
  243. package/dist/classified-marker-H6YSHYNK.js +24 -0
  244. package/dist/classified-marker-H6YSHYNK.js.map +1 -0
  245. package/dist/collection-facade-LVD22JLM.js +39 -0
  246. package/dist/computed-EXDMQODG.js +11 -0
  247. package/dist/consent/index.d.ts +4 -7
  248. package/dist/consent/index.js +13 -5
  249. package/dist/consent/index.js.map +1 -1
  250. package/dist/crdt/index.d.ts +5 -2
  251. package/dist/crdt/index.js +3 -2
  252. package/dist/crdt/index.js.map +1 -1
  253. package/dist/dead-filter-HQIE2YG7.js +28 -0
  254. package/dist/dead-filter-HQIE2YG7.js.map +1 -0
  255. package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
  256. package/dist/delegation-BJP73GAP.js +25 -0
  257. package/dist/derivations/index.d.ts +6 -9
  258. package/dist/derivations/index.js +18 -6
  259. package/dist/derive-BME7HDWO.js +21 -0
  260. package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-Bmm2pgJ0.d.ts} +1 -1
  261. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  262. package/dist/enclave-NHORSWSF.js +125 -0
  263. package/dist/executor-FE6X4LFX.js +9 -0
  264. package/dist/executor-KSHKRJXP.js +25 -0
  265. package/dist/executor-ZHTJJICG.js +9 -0
  266. package/dist/export-accessible-DACHM5VT.js +23 -0
  267. package/dist/extract-partition-RNENZZ4T.js +36 -0
  268. package/dist/fanout-sidecar-OFWN3NM7.js +74 -0
  269. package/dist/fanout-sidecar-OFWN3NM7.js.map +1 -0
  270. package/dist/fence-watcher-DHQ775JB.js +69 -0
  271. package/dist/fence-watcher-DHQ775JB.js.map +1 -0
  272. package/dist/find-BNGBJNKP.js +11 -0
  273. package/dist/forget/index.d.ts +36 -0
  274. package/dist/forget/index.js +25 -0
  275. package/dist/forget/index.js.map +1 -0
  276. package/dist/guards/index.d.ts +12 -9
  277. package/dist/guards/index.js +12 -5
  278. package/dist/{hash-DdpVypUp.d.cts → hash-DAJjMsCE.d.ts} +10 -1
  279. package/dist/history/index.d.ts +5 -8
  280. package/dist/history/index.js +25 -12
  281. package/dist/history/index.js.map +1 -1
  282. package/dist/i18n/index.d.ts +25 -8
  283. package/dist/i18n/index.js +137 -29
  284. package/dist/i18n/index.js.map +1 -1
  285. package/dist/in/index.d.ts +4 -0
  286. package/dist/in/index.js +1 -0
  287. package/dist/in/index.js.map +1 -0
  288. package/dist/index-B9QdHytu.d.ts +123 -0
  289. package/dist/index-DjWbxsjb.d.ts +23579 -0
  290. package/dist/index-qwuNvO2B.d.ts +144 -0
  291. package/dist/index.d.ts +1179 -449
  292. package/dist/index.js +2524 -312
  293. package/dist/index.js.map +1 -1
  294. package/dist/indexing/index.d.ts +5 -3
  295. package/dist/indexing/index.js +6 -5
  296. package/dist/indexing/index.js.map +1 -1
  297. package/dist/issue-NDI4CVZU.js +19 -0
  298. package/dist/issue-NDI4CVZU.js.map +1 -0
  299. package/dist/json-schema-I22JCYCG.js +44 -0
  300. package/dist/json-schema-I22JCYCG.js.map +1 -0
  301. package/dist/lazy/index.d.ts +20 -0
  302. package/dist/lazy/index.js +12 -0
  303. package/dist/lazy/index.js.map +1 -0
  304. package/dist/ledger-6NDS2EO4.js +42 -0
  305. package/dist/ledger-6NDS2EO4.js.map +1 -0
  306. package/dist/liberate-HN3RIGIP.js +24 -0
  307. package/dist/liberate-HN3RIGIP.js.map +1 -0
  308. package/dist/link-set-SJB2MVJV.js +31 -0
  309. package/dist/link-set-SJB2MVJV.js.map +1 -0
  310. package/dist/materialized-views/index.d.ts +23 -20
  311. package/dist/materialized-views/index.js +26 -12
  312. package/dist/mime-magic-bBj5OgUC.d.ts +103 -0
  313. package/dist/noydb-BWF6EPIR.js +66 -0
  314. package/dist/noydb-BWF6EPIR.js.map +1 -0
  315. package/dist/on/index.d.ts +4 -0
  316. package/dist/on/index.js +17 -0
  317. package/dist/on/index.js.map +1 -0
  318. package/dist/overlay-views/index.d.ts +26 -11
  319. package/dist/overlay-views/index.js +7 -6
  320. package/dist/periods/index.d.ts +4 -7
  321. package/dist/periods/index.js +27 -9
  322. package/dist/pod/index.d.ts +62 -0
  323. package/dist/pod/index.js +67 -0
  324. package/dist/pod/index.js.map +1 -0
  325. package/dist/policy-WGNAG5H6.js +41 -0
  326. package/dist/policy-WGNAG5H6.js.map +1 -0
  327. package/dist/portability/index.d.ts +19 -0
  328. package/dist/portability/index.js +43 -0
  329. package/dist/portability/index.js.map +1 -0
  330. package/dist/post-register-CWKBQRC7.js +55 -0
  331. package/dist/post-register-CWKBQRC7.js.map +1 -0
  332. package/dist/{public-envelope-BW6OXORV.js → public-envelope-EJLVIFX7.js} +6 -5
  333. package/dist/public-envelope-EJLVIFX7.js.map +1 -0
  334. package/dist/query/index.d.ts +4 -3
  335. package/dist/query/index.js +24 -13
  336. package/dist/read-only-facade-CHCKSEPD.js +8 -0
  337. package/dist/read-only-facade-CHCKSEPD.js.map +1 -0
  338. package/dist/register-SBIX7TVV.js +23 -0
  339. package/dist/register-SBIX7TVV.js.map +1 -0
  340. package/dist/registry-3EQG6OOE.js +18 -0
  341. package/dist/registry-3EQG6OOE.js.map +1 -0
  342. package/dist/registry-CA327ACV.js +9 -0
  343. package/dist/registry-CA327ACV.js.map +1 -0
  344. package/dist/registry-E7OXOTSV.js +19 -0
  345. package/dist/registry-E7OXOTSV.js.map +1 -0
  346. package/dist/registry-VW6P6A3J.js +8 -0
  347. package/dist/registry-VW6P6A3J.js.map +1 -0
  348. package/dist/request-withdrawal-KAH2AAXC.js +31 -0
  349. package/dist/request-withdrawal-KAH2AAXC.js.map +1 -0
  350. package/dist/reveal-R3JLHMUF.js +38 -0
  351. package/dist/reveal-R3JLHMUF.js.map +1 -0
  352. package/dist/revoke-IXLOJ3IH.js +24 -0
  353. package/dist/revoke-IXLOJ3IH.js.map +1 -0
  354. package/dist/satellites/index.d.ts +4 -0
  355. package/dist/satellites/index.js +8 -0
  356. package/dist/satellites/index.js.map +1 -0
  357. package/dist/sealed-record/index.d.ts +68 -0
  358. package/dist/sealed-record/index.js +71 -0
  359. package/dist/sealed-record/index.js.map +1 -0
  360. package/dist/session/index.d.ts +5 -8
  361. package/dist/session/index.js +13 -5
  362. package/dist/session/index.js.map +1 -1
  363. package/dist/shadow/index.d.ts +4 -7
  364. package/dist/shadow/index.js +4 -3
  365. package/dist/shadow/index.js.map +1 -1
  366. package/dist/signer-Y46N2GJ3.js +25 -0
  367. package/dist/signer-Y46N2GJ3.js.map +1 -0
  368. package/dist/snapshots/index.d.ts +5 -8
  369. package/dist/snapshots/index.js +19 -11
  370. package/dist/snapshots/index.js.map +1 -1
  371. package/dist/{stale-6ZDBTQT7.js → stale-Z7IW6RIL.js} +3 -2
  372. package/dist/stale-Z7IW6RIL.js.map +1 -0
  373. package/dist/storage-ADNP2UWI.js +23 -0
  374. package/dist/storage-ADNP2UWI.js.map +1 -0
  375. package/dist/store-coordination-provider-DTDMI6VL.js +142 -0
  376. package/dist/store-coordination-provider-DTDMI6VL.js.map +1 -0
  377. package/dist/subject-index-CyOgGMJL.d.ts +380 -0
  378. package/dist/sync/index.d.ts +3 -6
  379. package/dist/sync/index.js +13 -6
  380. package/dist/sync/index.js.map +1 -1
  381. package/dist/team/index.d.ts +46 -10
  382. package/dist/team/index.js +35 -18
  383. package/dist/tiers/index.d.ts +4 -0
  384. package/dist/tiers/index.js +39 -0
  385. package/dist/tiers/index.js.map +1 -0
  386. package/dist/to/index.d.ts +4 -0
  387. package/dist/to/index.js +16 -0
  388. package/dist/to/index.js.map +1 -0
  389. package/dist/transition-guard-DI-krBsZ.d.ts +165 -0
  390. package/dist/tx/index.d.ts +22 -9
  391. package/dist/tx/index.js +13 -8
  392. package/dist/tx/index.js.map +1 -1
  393. package/dist/ui/index.d.ts +4 -0
  394. package/dist/ui/index.js +1 -0
  395. package/dist/ui/index.js.map +1 -0
  396. package/dist/ulid-DRH25k3y.d.ts +66 -0
  397. package/dist/ulid-PTAIMDG4.js +10 -0
  398. package/dist/ulid-PTAIMDG4.js.map +1 -0
  399. package/dist/util/index.d.ts +2 -0
  400. package/dist/util/index.js +7 -2
  401. package/dist/util/index.js.map +1 -1
  402. package/dist/validators-BUcli5Nh.d.ts +101 -0
  403. package/dist/vault-diff-Z2DUayMe.d.ts +147 -0
  404. package/dist/verify-JPF2YR5E.js +139 -0
  405. package/dist/verify-JPF2YR5E.js.map +1 -0
  406. package/dist/walk-XYA2O3LW.js +241 -0
  407. package/dist/walk-XYA2O3LW.js.map +1 -0
  408. package/dist/with/index.d.ts +37 -0
  409. package/dist/with/index.js +31 -0
  410. package/dist/with/index.js.map +1 -0
  411. package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-BUmzlXue.d.ts} +1 -1
  412. package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-m4FaXXTO.d.ts} +2 -3
  413. package/dist/with-rollup-DEKGI9vb.d.ts +47 -0
  414. package/dist/withdraw-accessible-WLV4MTEN.js +28 -0
  415. package/dist/withdraw-accessible-WLV4MTEN.js.map +1 -0
  416. package/dist/zod-HAJM7LMS.js +14763 -0
  417. package/dist/zod-HAJM7LMS.js.map +1 -0
  418. package/package.json +122 -202
  419. package/dist/aggregate/index.cjs.map +0 -1
  420. package/dist/aggregate/index.d.cts +0 -38
  421. package/dist/attestation/index.cjs +0 -305
  422. package/dist/attestation/index.cjs.map +0 -1
  423. package/dist/attestation/index.d.cts +0 -52
  424. package/dist/blobs/index.cjs +0 -1480
  425. package/dist/blobs/index.cjs.map +0 -1
  426. package/dist/blobs/index.d.cts +0 -46
  427. package/dist/bundle/index.cjs +0 -19264
  428. package/dist/bundle/index.cjs.map +0 -1
  429. package/dist/bundle/index.d.cts +0 -176
  430. package/dist/chunk-22DWZL57.js.map +0 -1
  431. package/dist/chunk-2GLDA55J.js.map +0 -1
  432. package/dist/chunk-2QR2PQTT.js.map +0 -1
  433. package/dist/chunk-2WUSG3IT.js.map +0 -1
  434. package/dist/chunk-3BFJOWSU.js.map +0 -1
  435. package/dist/chunk-3YPCK6JX.js.map +0 -1
  436. package/dist/chunk-53XBRIRT.js.map +0 -1
  437. package/dist/chunk-5T22KDPN.js.map +0 -1
  438. package/dist/chunk-5XHKQ56N.js +0 -340
  439. package/dist/chunk-5XHKQ56N.js.map +0 -1
  440. package/dist/chunk-6CME4UEK.js +0 -10329
  441. package/dist/chunk-6CME4UEK.js.map +0 -1
  442. package/dist/chunk-6STK5TQP.js +0 -139
  443. package/dist/chunk-6STK5TQP.js.map +0 -1
  444. package/dist/chunk-A3JMGXPG.js.map +0 -1
  445. package/dist/chunk-B6PB7JLN.js.map +0 -1
  446. package/dist/chunk-BVRYKATC.js.map +0 -1
  447. package/dist/chunk-DE6GKS6G.js +0 -79
  448. package/dist/chunk-DE6GKS6G.js.map +0 -1
  449. package/dist/chunk-DFMLEQZB.js.map +0 -1
  450. package/dist/chunk-DJHHA6XH.js.map +0 -1
  451. package/dist/chunk-DL3HWOQ5.js.map +0 -1
  452. package/dist/chunk-DONMZAD2.js.map +0 -1
  453. package/dist/chunk-EMIGCR7X.js.map +0 -1
  454. package/dist/chunk-F3GDRNUT.js.map +0 -1
  455. package/dist/chunk-FZU343FL.js.map +0 -1
  456. package/dist/chunk-H2X3ISXG.js.map +0 -1
  457. package/dist/chunk-HNRHLRDC.js.map +0 -1
  458. package/dist/chunk-I5FOWO4J.js.map +0 -1
  459. package/dist/chunk-J66GRPNH.js.map +0 -1
  460. package/dist/chunk-JWRVQKRZ.js.map +0 -1
  461. package/dist/chunk-K3DK3NU5.js.map +0 -1
  462. package/dist/chunk-ML236QKC.js.map +0 -1
  463. package/dist/chunk-NONAAENK.js.map +0 -1
  464. package/dist/chunk-O3VZPBZG.js.map +0 -1
  465. package/dist/chunk-OIF6LZUR.js.map +0 -1
  466. package/dist/chunk-OQ6PIGHA.js +0 -19
  467. package/dist/chunk-OQ6PIGHA.js.map +0 -1
  468. package/dist/chunk-PE2FR4J3.js.map +0 -1
  469. package/dist/chunk-PP6W64Y3.js.map +0 -1
  470. package/dist/chunk-PX35GA7L.js.map +0 -1
  471. package/dist/chunk-QEILDE6R.js +0 -793
  472. package/dist/chunk-QEILDE6R.js.map +0 -1
  473. package/dist/chunk-QODLLGQ7.js.map +0 -1
  474. package/dist/chunk-RAZ4OVLL.js +0 -51
  475. package/dist/chunk-RAZ4OVLL.js.map +0 -1
  476. package/dist/chunk-SYMWGEET.js.map +0 -1
  477. package/dist/chunk-T7JEBOGN.js.map +0 -1
  478. package/dist/chunk-TFBP23BX.js.map +0 -1
  479. package/dist/chunk-TV3YZ35S.js.map +0 -1
  480. package/dist/chunk-U26HQ6KJ.js.map +0 -1
  481. package/dist/chunk-UF3BUNQZ.js +0 -1
  482. package/dist/chunk-UMLVJTYV.js +0 -20
  483. package/dist/chunk-UMLVJTYV.js.map +0 -1
  484. package/dist/chunk-VTKGMEPP.js.map +0 -1
  485. package/dist/chunk-W6EQLGMB.js +0 -100
  486. package/dist/chunk-W6EQLGMB.js.map +0 -1
  487. package/dist/chunk-WIRRPTFH.js +0 -17
  488. package/dist/chunk-WIRRPTFH.js.map +0 -1
  489. package/dist/chunk-WPLVTJ5D.js.map +0 -1
  490. package/dist/chunk-XJFLDA7A.js.map +0 -1
  491. package/dist/chunk-Z6FNBOTC.js.map +0 -1
  492. package/dist/chunk-ZYWZWG6G.js.map +0 -1
  493. package/dist/consent/index.cjs +0 -204
  494. package/dist/consent/index.cjs.map +0 -1
  495. package/dist/consent/index.d.cts +0 -25
  496. package/dist/crdt/index.cjs +0 -152
  497. package/dist/crdt/index.cjs.map +0 -1
  498. package/dist/crdt/index.d.cts +0 -30
  499. package/dist/crypto-HTZ4FJOP.js +0 -44
  500. package/dist/delegation-RI54P6I5.js +0 -17
  501. package/dist/derivations/index.cjs +0 -351
  502. package/dist/derivations/index.cjs.map +0 -1
  503. package/dist/derivations/index.d.cts +0 -72
  504. package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
  505. package/dist/executor-5PNY7LGW.js +0 -8
  506. package/dist/executor-B4QIYGZX.js +0 -8
  507. package/dist/executor-BWXXDQ7K.js +0 -11
  508. package/dist/fanout-sidecar-OKPMMPLG.js +0 -51
  509. package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
  510. package/dist/guards/index.cjs +0 -322
  511. package/dist/guards/index.cjs.map +0 -1
  512. package/dist/guards/index.d.cts +0 -31
  513. package/dist/hash-HJqD14vS.d.ts +0 -63
  514. package/dist/history/index.cjs +0 -1222
  515. package/dist/history/index.cjs.map +0 -1
  516. package/dist/history/index.d.cts +0 -63
  517. package/dist/i18n/index.cjs +0 -1100
  518. package/dist/i18n/index.cjs.map +0 -1
  519. package/dist/i18n/index.d.cts +0 -39
  520. package/dist/index-4fBVt8j9.d.cts +0 -2387
  521. package/dist/index-D8I_pyJD.d.ts +0 -2387
  522. package/dist/index.cjs +0 -24487
  523. package/dist/index.cjs.map +0 -1
  524. package/dist/index.d.cts +0 -776
  525. package/dist/indexing/index.cjs +0 -742
  526. package/dist/indexing/index.cjs.map +0 -1
  527. package/dist/indexing/index.d.cts +0 -36
  528. package/dist/issue-VGDPP4B5.js +0 -12
  529. package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
  530. package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
  531. package/dist/ledger-TMRZYNVJ.js +0 -33
  532. package/dist/materialized-views/index.cjs +0 -854
  533. package/dist/materialized-views/index.cjs.map +0 -1
  534. package/dist/materialized-views/index.d.cts +0 -186
  535. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  536. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  537. package/dist/noydb-G725ZSZG.js +0 -34
  538. package/dist/overlay-views/index.cjs +0 -359
  539. package/dist/overlay-views/index.cjs.map +0 -1
  540. package/dist/overlay-views/index.d.cts +0 -82
  541. package/dist/periods/index.cjs +0 -1041
  542. package/dist/periods/index.cjs.map +0 -1
  543. package/dist/periods/index.d.cts +0 -22
  544. package/dist/predicate-BSAGEyu5.d.cts +0 -209
  545. package/dist/predicate-BSAGEyu5.d.ts +0 -209
  546. package/dist/query/index.cjs +0 -2375
  547. package/dist/query/index.cjs.map +0 -1
  548. package/dist/query/index.d.cts +0 -3
  549. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  550. package/dist/registry-3QP3YKQS.js +0 -8
  551. package/dist/registry-DKEXOJVO.js +0 -7
  552. package/dist/registry-OJIOSBV6.js +0 -10
  553. package/dist/registry-USRVT6YF.js +0 -8
  554. package/dist/revoke-JCC7N56X.js +0 -17
  555. package/dist/session/index.cjs +0 -495
  556. package/dist/session/index.cjs.map +0 -1
  557. package/dist/session/index.d.cts +0 -46
  558. package/dist/shadow/index.cjs +0 -133
  559. package/dist/shadow/index.cjs.map +0 -1
  560. package/dist/shadow/index.d.cts +0 -17
  561. package/dist/signer-72QAUSVW.js +0 -18
  562. package/dist/snapshots/index.cjs +0 -937
  563. package/dist/snapshots/index.cjs.map +0 -1
  564. package/dist/snapshots/index.d.cts +0 -28
  565. package/dist/store/index.cjs +0 -1083
  566. package/dist/store/index.cjs.map +0 -1
  567. package/dist/store/index.d.cts +0 -492
  568. package/dist/store/index.d.ts +0 -492
  569. package/dist/store/index.js +0 -37
  570. package/dist/strategy-BSxFXGzb.d.cts +0 -110
  571. package/dist/strategy-BSxFXGzb.d.ts +0 -110
  572. package/dist/strategy-DSTrsZ8t.d.cts +0 -601
  573. package/dist/strategy-DSTrsZ8t.d.ts +0 -601
  574. package/dist/sync/index.cjs +0 -1062
  575. package/dist/sync/index.cjs.map +0 -1
  576. package/dist/sync/index.d.cts +0 -43
  577. package/dist/team/index.cjs +0 -2798
  578. package/dist/team/index.cjs.map +0 -1
  579. package/dist/team/index.d.cts +0 -118
  580. package/dist/tx/index.cjs +0 -544
  581. package/dist/tx/index.cjs.map +0 -1
  582. package/dist/tx/index.d.cts +0 -21
  583. package/dist/types-Df28QFKb.d.ts +0 -12818
  584. package/dist/types-DyXYr8rE.d.cts +0 -12818
  585. package/dist/ulid-COREQ2RQ.js +0 -9
  586. package/dist/ulid-Drr7ykr6.d.cts +0 -603
  587. package/dist/util/index.cjs +0 -230
  588. package/dist/util/index.cjs.map +0 -1
  589. package/dist/util/index.d.cts +0 -77
  590. package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
  591. package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
  592. package/dist/with-guard-ByyxmEe7.d.cts +0 -18
  593. package/dist/with-guard-qube6BMI.d.ts +0 -18
  594. package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
  595. package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
  596. /package/dist/{chunk-UF3BUNQZ.js.map → api-TX2EX2FX.js.map} +0 -0
  597. /package/dist/{store → as}/index.js.map +0 -0
  598. /package/dist/{crypto-HTZ4FJOP.js.map → at/index.js.map} +0 -0
  599. /package/dist/{delegation-RI54P6I5.js.map → by/index.js.map} +0 -0
  600. /package/dist/{executor-5PNY7LGW.js.map → cargo/index.js.map} +0 -0
  601. /package/dist/{executor-B4QIYGZX.js.map → chunk-CHFZDSE4.js.map} +0 -0
  602. /package/dist/{executor-BWXXDQ7K.js.map → chunk-GHVIKOHT.js.map} +0 -0
  603. /package/dist/{issue-VGDPP4B5.js.map → chunk-PZ5AY32C.js.map} +0 -0
  604. /package/dist/{ledger-TMRZYNVJ.js.map → classified/index.js.map} +0 -0
  605. /package/dist/{noydb-G725ZSZG.js.map → collection-facade-LVD22JLM.js.map} +0 -0
  606. /package/dist/{public-envelope-BW6OXORV.js.map → computed-EXDMQODG.js.map} +0 -0
  607. /package/dist/{read-only-facade-ITU6L7BL.js.map → delegation-BJP73GAP.js.map} +0 -0
  608. /package/dist/{registry-3QP3YKQS.js.map → derive-BME7HDWO.js.map} +0 -0
  609. /package/dist/{registry-DKEXOJVO.js.map → enclave-NHORSWSF.js.map} +0 -0
  610. /package/dist/{registry-OJIOSBV6.js.map → executor-FE6X4LFX.js.map} +0 -0
  611. /package/dist/{registry-USRVT6YF.js.map → executor-KSHKRJXP.js.map} +0 -0
  612. /package/dist/{revoke-JCC7N56X.js.map → executor-ZHTJJICG.js.map} +0 -0
  613. /package/dist/{signer-72QAUSVW.js.map → export-accessible-DACHM5VT.js.map} +0 -0
  614. /package/dist/{stale-6ZDBTQT7.js.map → extract-partition-RNENZZ4T.js.map} +0 -0
  615. /package/dist/{ulid-COREQ2RQ.js.map → find-BNGBJNKP.js.map} +0 -0
@@ -0,0 +1,968 @@
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";
36
+ import {
37
+ NOYDB_FORMAT_VERSION,
38
+ SealedHandle
39
+ } from "./chunk-YN5IAHN6.js";
40
+ import {
41
+ ClassifiedConfigError,
42
+ ClassifiedRotationError,
43
+ DebugReservedFieldError,
44
+ RecordCekNotFoundError,
45
+ SchemaValidationError,
46
+ TamperedError,
47
+ ValidationError
48
+ } from "./chunk-S7VFUQM2.js";
49
+
50
+ // src/kernel/enclave/record-keys/lifecycle.ts
51
+ async function resolveStableCek(deps, id) {
52
+ const cached = deps.cache?.get(id);
53
+ if (cached) return cached;
54
+ const live = await deps.getLive(id);
55
+ if (live?._cek !== void 0) {
56
+ const cek = await unwrapCek(live._cek, await deps.getDEK());
57
+ deps.cache?.set(id, cek, 1);
58
+ return cek;
59
+ }
60
+ const fresh = await generateDEK();
61
+ deps.cache?.set(id, fresh, 1);
62
+ return fresh;
63
+ }
64
+ async function rewrapBodyToDek(envelope, fromDek, toDek) {
65
+ if (envelope._cek !== void 0) {
66
+ const cek = await unwrapCek(envelope._cek, fromDek);
67
+ const plaintext2 = await decrypt(envelope._iv, envelope._data, cek);
68
+ const { iv: iv2, data: data2 } = await encrypt(plaintext2, cek);
69
+ return { _iv: iv2, _data: data2, _cek: await wrapCek(cek, toDek), cek };
70
+ }
71
+ const plaintext = await decrypt(envelope._iv, envelope._data, fromDek);
72
+ const { iv, data } = await encrypt(plaintext, toDek);
73
+ return { _iv: iv, _data: data, cek: null };
74
+ }
75
+
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();
121
+ return {
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
+ }
136
+ };
137
+ }
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
+ };
170
+ }
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) {
177
+ try {
178
+ prev = await openVdigPayload(prevBlob, cek, collection, recordId, field);
179
+ } catch {
180
+ throw new TamperedError();
181
+ }
182
+ if (!Number.isInteger(prev.iter) || prev.iter < 1) {
183
+ throw new TamperedError();
184
+ }
185
+ }
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);
206
+ }
207
+
208
+ // src/kernel/schema.ts
209
+ async function validateSchemaInput(schema, value, context) {
210
+ const result = await schema["~standard"].validate(value);
211
+ if (result.issues !== void 0 && result.issues.length > 0) {
212
+ throw new SchemaValidationError(
213
+ `Schema validation failed on ${context}: ${summarizeIssues(result.issues)}`,
214
+ result.issues,
215
+ "input"
216
+ );
217
+ }
218
+ return result.value;
219
+ }
220
+ async function validateSchemaOutput(schema, value, context) {
221
+ const result = await schema["~standard"].validate(value);
222
+ if (result.issues !== void 0 && result.issues.length > 0) {
223
+ throw new SchemaValidationError(
224
+ `Stored data for ${context} does not match the current schema \u2014 schema drift? ${summarizeIssues(result.issues)}`,
225
+ result.issues,
226
+ "output"
227
+ );
228
+ }
229
+ return result.value;
230
+ }
231
+ function summarizeIssues(issues) {
232
+ const shown = issues.slice(0, 3).map((issue) => {
233
+ const pathStr = formatPath(issue.path);
234
+ return `${pathStr}: ${issue.message}`;
235
+ });
236
+ const suffix = issues.length > 3 ? ` (+${issues.length - 3} more)` : "";
237
+ return shown.join("; ") + suffix;
238
+ }
239
+ function formatPath(path) {
240
+ if (!path || path.length === 0) return "root";
241
+ return path.map(
242
+ (segment) => typeof segment === "object" && segment !== null ? String(segment.key) : String(segment)
243
+ ).join(".");
244
+ }
245
+
246
+ // src/kernel/enclave/record-keys/record-codec.ts
247
+ var RecordCodec = class _RecordCodec {
248
+ constructor(ctx) {
249
+ this.ctx = ctx;
250
+ }
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
+ }
288
+ // ──────────────────────────────────────────────────────────────────────
289
+ // Low-level literal builders
290
+ // ──────────────────────────────────────────────────────────────────────
291
+ /**
292
+ * Assemble a canonical ciphertext body envelope literal from already-computed
293
+ * parts. Pure, no crypto. Each call stamps its own `_ts` — provenance carries
294
+ * a SEPARATE timestamp (computed by the caller), so the two never share one.
295
+ */
296
+ static buildEnvelope(p) {
297
+ return {
298
+ _noydb: NOYDB_FORMAT_VERSION,
299
+ _v: p.version,
300
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
301
+ _iv: p.iv,
302
+ _data: p.data,
303
+ ...p.by !== void 0 ? { _by: p.by } : {},
304
+ ...p.cek !== void 0 ? { _cek: p.cek } : {},
305
+ ...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {},
306
+ ...p.extra ?? {}
307
+ };
308
+ }
309
+ /** Plaintext (`_iv:''`) body envelope — the `!storeCiphertext` shape. */
310
+ static buildPlaintextEnvelope(p) {
311
+ return {
312
+ _noydb: NOYDB_FORMAT_VERSION,
313
+ _v: p.version,
314
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
315
+ _iv: "",
316
+ _data: p.data,
317
+ ...p.by !== void 0 ? { _by: p.by } : {},
318
+ ...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {}
319
+ };
320
+ }
321
+ // ──────────────────────────────────────────────────────────────────────
322
+ // Write path
323
+ // ──────────────────────────────────────────────────────────────────────
324
+ /**
325
+ * Build a debug-plaintext envelope: the record's own fields inlined as
326
+ * top-level keys beside the reserved `_`-metadata, with `_debug: 1` and an
327
+ * empty `_data`. Lets native store tooling read the record without
328
+ * unwrapping. Only reached for user collections under `debugPlaintext`
329
+ * (see {@link encryptRecord}). Rejects `_`-prefixed record fields, which
330
+ * would collide with the reserved metadata namespace.
331
+ */
332
+ buildDebugEnvelope(record, version, source, sourceTs) {
333
+ const rec = record;
334
+ for (const key of Object.keys(rec)) {
335
+ if (key.startsWith("_")) throw new DebugReservedFieldError(this.ctx.name, key);
336
+ }
337
+ return {
338
+ _noydb: NOYDB_FORMAT_VERSION,
339
+ _v: version,
340
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
341
+ _iv: "",
342
+ _data: "",
343
+ _by: this.ctx.actor,
344
+ _debug: NOYDB_FORMAT_VERSION,
345
+ ...this.ctx.provenance && source !== void 0 ? { _source: source, _sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } : {},
346
+ ...rec
347
+ };
348
+ }
349
+ /**
350
+ * Encrypt a JSON body into an envelope.
351
+ *
352
+ * When `cek` is supplied (per-record CEK collections), the body is
353
+ * encrypted under the CEK and the CEK is AES-KW-wrapped under the
354
+ * collection DEK and stamped on `_cek`. When `cek` is omitted, the legacy
355
+ * path encrypts the body directly under the collection DEK — byte-identical
356
+ * to pre-CEK behaviour, so non-adopting collections pay nothing.
357
+ */
358
+ async encryptJsonString(json, version, cek, source, sourceTs) {
359
+ const by = this.ctx.actor;
360
+ const provenance = this.ctx.provenance && source !== void 0 ? { source, sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } : void 0;
361
+ if (!this.ctx.storeCiphertext) {
362
+ return _RecordCodec.buildPlaintextEnvelope({ version, data: json, by, provenance });
363
+ }
364
+ const dek = await this.ctx.getDEK();
365
+ if (cek !== void 0) {
366
+ const { iv: iv2, data: data2 } = await encrypt(json, cek);
367
+ const wrapped = await wrapCek(cek, dek);
368
+ return _RecordCodec.buildEnvelope({ version, iv: iv2, data: data2, by, cek: wrapped, provenance });
369
+ }
370
+ const { iv, data } = await encrypt(json, dek);
371
+ return _RecordCodec.buildEnvelope({ version, iv, data, by, provenance });
372
+ }
373
+ async encryptRecord(record, version, cek, source, sourceTs, vdig, id) {
374
+ if (!this.ctx.storeCiphertext && this.ctx.debugPlaintext && !this.ctx.name.startsWith("_")) {
375
+ return this.buildDebugEnvelope(record, version, source, sourceTs);
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
+ }
399
+ let openRecord = record;
400
+ let sealed;
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
+ }
407
+ const src = record;
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}`;
413
+ }
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];
472
+ }
473
+ openRecord = open;
474
+ if (Object.keys(out).length > 0) vdigOut = out;
475
+ if (Object.keys(bidxOut).length > 0) bidxOutMap = bidxOut;
476
+ }
477
+ const base = await this.encryptJsonString(JSON.stringify(openRecord), version, cek, source, sourceTs);
478
+ const withSealed = sealed ? { ...base, _sealed: sealed } : base;
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;
482
+ const dek = await this.ctx.getDEK();
483
+ const detKey = await deriveDeterministicKey(dek);
484
+ const rec = record;
485
+ const det = {};
486
+ for (const field of this.ctx.deterministicFields) {
487
+ if (this.ctx.sensitiveFields.has(field)) continue;
488
+ if (this.ctx.vdigFields?.has(field)) continue;
489
+ const value = rec[field];
490
+ if (value === void 0 || value === null) continue;
491
+ const plaintext = typeof value === "string" ? value : JSON.stringify(value);
492
+ const { iv, data } = await encryptDeterministic(plaintext, detKey, `${this.ctx.name}/${field}`);
493
+ det[field] = `${iv}:${data}`;
494
+ }
495
+ if (Object.keys(det).length === 0) return withBidx;
496
+ return { ...withBidx, _det: det };
497
+ }
498
+ // ──────────────────────────────────────────────────────────────────────
499
+ // Read path
500
+ // ──────────────────────────────────────────────────────────────────────
501
+ /**
502
+ * Resolve the per-record CEK for a stored envelope, or `undefined` for a
503
+ * legacy (`_cek`-absent) envelope. Unwraps `_cek` under the collection DEK and
504
+ * memoises it in the CEK cache under `id` (when supplied) so repeated reads of
505
+ * the same record skip the unwrap. Shared by the body-decrypt path
506
+ * ({@link decryptJsonString}) and the sealed-field path ({@link decryptRecord}
507
+ * / {@link toCacheRecord}) so both agree on the record's key.
508
+ */
509
+ async resolveEnvelopeCek(envelope, id) {
510
+ if (envelope._cek === void 0) return void 0;
511
+ const cached = id !== void 0 ? this.ctx.cekCache?.get(id) : void 0;
512
+ if (cached !== void 0) return cached;
513
+ const dek = await this.ctx.getDEK();
514
+ const cek = await unwrapCek(envelope._cek, dek);
515
+ if (id !== void 0) this.ctx.cekCache?.set(id, cek, 1);
516
+ return cek;
517
+ }
518
+ /**
519
+ * Low-level: decrypt an envelope and return the raw JSON string.
520
+ *
521
+ * `_cek` presence is the format discriminant (NOT `this.perRecordCek`),
522
+ * so a mixed vault — and a recipient that never opted into
523
+ * `perRecordKeys` — decrypts both legacy and CEK records:
524
+ * - `_cek` present → unwrap the CEK under the collection DEK, decrypt the
525
+ * body under the CEK (cache the unwrapped CEK so repeated reads skip it).
526
+ * - `_cek` absent → legacy path, body decrypts directly under the
527
+ * collection DEK.
528
+ *
529
+ * The optional `id` lets reads populate the CEK cache; it is omitted by
530
+ * callers (history, conflict merge) that have only the envelope.
531
+ */
532
+ async decryptJsonString(envelope, id) {
533
+ if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
534
+ if (!this.ctx.storeCiphertext) {
535
+ if (envelope._debug !== void 0) {
536
+ const rec = {};
537
+ for (const [key, value] of Object.entries(envelope)) {
538
+ if (!key.startsWith("_")) rec[key] = value;
539
+ }
540
+ return JSON.stringify(rec);
541
+ }
542
+ return envelope._data === "" ? null : envelope._data;
543
+ }
544
+ const cek = await this.resolveEnvelopeCek(envelope, id);
545
+ if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek);
546
+ const dek = await this.ctx.getDEK();
547
+ return decrypt(envelope._iv, envelope._data, dek);
548
+ }
549
+ /**
550
+ * Unseal a single `_sealed[field]` slot to its plaintext value: derive the
551
+ * per-field key off the collection DEK, AES-GCM-decrypt the `iv:data` blob,
552
+ * and JSON-parse the result. Shared by both the inline-decrypt path and a
553
+ * {@link Sealed} handle's `reveal()` — so the on-demand reveal and the eager
554
+ * materialisation always agree byte-for-byte.
555
+ */
556
+ async unsealField(field, blob, cek) {
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));
567
+ }
568
+ /**
569
+ * Classify a live envelope's `_sealed` slots for crypto-shred completeness.
570
+ * `forget()` drops `_cek`/`_sealed` but
571
+ * RETAINS the collection DEK, so only a slot keyed off the per-record CEK is
572
+ * genuinely shredded by the tombstone; a legacy slot keyed off the
573
+ * collection DEK survives in any synced/backup copy.
574
+ *
575
+ * Mirrors {@link unsealField}'s dual-read split: try the CEK-derived key per
576
+ * slot — success → `shreddable`, AES-GCM auth failure → `dekResidue`. With no
577
+ * `_cek` (pure legacy collection-DEK sealing) ALL slots are residue.
578
+ */
579
+ async classifySealedShred(live) {
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
+ }
589
+ const sealed = live._sealed;
590
+ if (sealed === void 0) return { slots };
591
+ const cek = await this.resolveEnvelopeCek(live);
592
+ for (const [field, blob] of Object.entries(sealed)) {
593
+ if (cek === void 0) {
594
+ slots.push({ field, class: "dekResidue" });
595
+ continue;
596
+ }
597
+ const { iv, data } = parseSealedSlot(blob);
598
+ try {
599
+ await decrypt(iv, data, await deriveSealedFieldKeyFromCek(cek, this.ctx.name, field));
600
+ slots.push({ field, class: "shreddable" });
601
+ } catch {
602
+ slots.push({ field, class: "dekResidue" });
603
+ }
604
+ }
605
+ return { slots };
606
+ }
607
+ /**
608
+ * Build a non-leaking {@link Sealed} handle over a sealed field's ciphertext.
609
+ * The handle captures only the ciphertext `blob` and a closure to
610
+ * {@link unsealField}; the plaintext is never stored on it — so the handle
611
+ * may sit in the working-set cache (or be logged/serialised) without
612
+ * exposing the value, which decrypts only on `reveal()`.
613
+ */
614
+ makeSealedHandle(field, blob, cek) {
615
+ return makeHandleProducer(this.sealKeyMaterial(cek))(field, blob);
616
+ }
617
+ /**
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.
631
+ */
632
+ async toCacheRecord(record, envelope, id) {
633
+ const sealed = envelope._sealed;
634
+ if (sealed === void 0 || !this.ctx.storeCiphertext) {
635
+ return record;
636
+ }
637
+ const cek = await this.resolveEnvelopeCek(envelope, id);
638
+ const clone = { ...record };
639
+ for (const [field, blob] of Object.entries(sealed)) {
640
+ clone[field] = this.makeSealedHandle(field, blob, cek);
641
+ }
642
+ return clone;
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
+ }
695
+ /**
696
+ * Decrypt an envelope into a record of type `T`.
697
+ *
698
+ * When a schema is attached, the decrypted value is validated before
699
+ * being returned. A divergence between the stored bytes and the
700
+ * current schema throws `SchemaValidationError` with
701
+ * `direction: 'output'` — silently returning drifted data would
702
+ * propagate garbage into the UI and break the whole point of having
703
+ * a schema.
704
+ *
705
+ * `skipValidation` exists for history reads: when calling
706
+ * `getVersion()` the caller is explicitly asking for an old snapshot
707
+ * that may predate a schema change, so validating it would be a
708
+ * false positive. Every non-history read leaves this flag `false`.
709
+ */
710
+ async decryptRecord(envelope, opts = {}) {
711
+ const json = await this.decryptJsonString(envelope, opts.id);
712
+ if (json === null) return null;
713
+ let parsed = JSON.parse(json);
714
+ if (this.ctx.crdtMode && parsed !== null && typeof parsed === "object" && "_crdt" in parsed) {
715
+ parsed = this.ctx.crdtStrategy.resolveCrdtSnapshot(parsed);
716
+ }
717
+ let record = parsed;
718
+ if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
719
+ const sealedCek = await this.resolveEnvelopeCek(envelope, opts.id);
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
+ });
724
+ }
725
+ const sealedAsHandles = opts.sealedAsHandles === true && envelope._sealed !== void 0;
726
+ if (this.ctx.schema !== void 0 && !opts.skipValidation && !sealedAsHandles) {
727
+ record = await validateSchemaOutput(
728
+ this.ctx.schema,
729
+ record,
730
+ `${this.ctx.name}@v${envelope._v}`
731
+ );
732
+ }
733
+ return record;
734
+ }
735
+ };
736
+
737
+ // src/kernel/enclave/record-keys/sealing.ts
738
+ var subtle = globalThis.crypto.subtle;
739
+ var SEALED_CEK_NS = "_sealed_cek";
740
+ async function sealRecordToHost(ctx, collection, id, hostSealer, opts) {
741
+ if (collection.includes("/")) throw new ValidationError(`sealRecordToHost: collection "${collection}" must not contain "/"`);
742
+ if (id.includes("/")) throw new ValidationError(`sealRecordToHost: id "${id}" must not contain "/"`);
743
+ if (Number.isNaN(Date.parse(opts.expiresAt))) {
744
+ throw new ValidationError(`sealRecordToHost: expiresAt "${opts.expiresAt}" is not a valid ISO 8601 timestamp`);
745
+ }
746
+ const live = await ctx.adapter.get(ctx.vault, collection, id);
747
+ if (!live || live._cek === void 0) {
748
+ throw new RecordCekNotFoundError(collection, id);
749
+ }
750
+ const dek = await ctx.getDEK(collection);
751
+ const cek = await unwrapCek(live._cek, dek);
752
+ const rawCek = await subtle.exportKey("raw", cek);
753
+ const cekB64 = bufferToBase64(rawCek);
754
+ const hint = await hostSealer.publishRecipientHint();
755
+ if (hint.pid.includes("/")) throw new ValidationError(`sealRecordToHost: recipient pid "${hint.pid}" must not contain "/"`);
756
+ const binding = {
757
+ collection,
758
+ id,
759
+ cek: cekB64,
760
+ expiresAt: opts.expiresAt
761
+ };
762
+ const sealed = await hostSealer.sealForRecipient(
763
+ new TextEncoder().encode(JSON.stringify(binding)),
764
+ hint
765
+ );
766
+ const delivery = {
767
+ v: 1,
768
+ _noydb_sealed_cek: 1,
769
+ pid: hint.pid,
770
+ payload: bufferToBase64(sealed),
771
+ expiresAt: opts.expiresAt
772
+ };
773
+ const envelopeKey = `${collection}/${id}/${hint.pid}`;
774
+ const prior = await ctx.adapter.get(ctx.vault, SEALED_CEK_NS, envelopeKey);
775
+ const env = {
776
+ _noydb: NOYDB_FORMAT_VERSION,
777
+ _v: (prior?._v ?? 0) + 1,
778
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
779
+ // AES-GCM bypassed — the sealing layer is the security boundary, exactly
780
+ // like the managed-passphrase `_meta/sealed-passphrase` envelope.
781
+ _iv: "",
782
+ _data: JSON.stringify(delivery),
783
+ ...ctx.actor ? { _by: ctx.actor } : {}
784
+ };
785
+ await ctx.adapter.put(ctx.vault, SEALED_CEK_NS, envelopeKey, env);
786
+ return { pid: hint.pid, envelopeKey };
787
+ }
788
+ async function revokeSealedRecord(ctx, collection, id, pid, opts) {
789
+ if (opts?.hard === true) {
790
+ await rotateRecordCek(ctx, collection, id);
791
+ return;
792
+ }
793
+ await ctx.adapter.delete(ctx.vault, SEALED_CEK_NS, `${collection}/${id}/${pid}`);
794
+ }
795
+ async function rotateRecordCek(ctx, collection, id) {
796
+ const live = await ctx.adapter.get(ctx.vault, collection, id);
797
+ if (!live || live._cek === void 0) {
798
+ throw new RecordCekNotFoundError(collection, id);
799
+ }
800
+ const dek = await ctx.getDEK(collection);
801
+ const oldCek = await unwrapCek(live._cek, dek);
802
+ const json = await decrypt(live._iv, live._data, oldCek);
803
+ const newCek = await generateDEK();
804
+ const { iv, data } = await encrypt(json, newCek);
805
+ let sealedOut;
806
+ if (live._sealed !== void 0) {
807
+ const out = {};
808
+ for (const [field, slot] of Object.entries(live._sealed)) {
809
+ const plaintext = await dualReadSealedSlot(slot, field, collection, oldCek, dek);
810
+ const resealed = await encrypt(plaintext, await deriveSealedFieldKeyFromCek(newCek, collection, field));
811
+ out[field] = `${resealed.iv}:${resealed.data}`;
812
+ }
813
+ sealedOut = out;
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
+ }
824
+ const env = {
825
+ _noydb: NOYDB_FORMAT_VERSION,
826
+ _v: live._v + 1,
827
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
828
+ _iv: iv,
829
+ _data: data,
830
+ _cek: await wrapCek(newCek, dek),
831
+ ...ctx.actor ? { _by: ctx.actor } : {},
832
+ ...live._tier !== void 0 ? { _tier: live._tier } : {},
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 } : {},
840
+ // Re-encrypt sealed (`sensitive`) fields under the new CEK. Sealed
841
+ // keys derive off the per-record CEK, so the rotated record's old CEK is
842
+ // destroyed here — carrying the old `_sealed` slots forward verbatim would
843
+ // orphan them (unreadable under the new CEK). `sealedOut` holds the slots
844
+ // dual-read from the old CEK (or the legacy DEK) and re-sealed under newCek.
845
+ ...sealedOut !== void 0 ? { _sealed: sealedOut } : {},
846
+ ...vdigOut !== void 0 ? { _vdig: vdigOut } : {}
847
+ };
848
+ await ctx.adapter.put(ctx.vault, collection, id, env);
849
+ await ctx.invalidateRecordCaches(collection, id);
850
+ const prefix = `${collection}/${id}/`;
851
+ const keys = await ctx.adapter.list(ctx.vault, SEALED_CEK_NS);
852
+ for (const key of keys) {
853
+ if (key.startsWith(prefix)) {
854
+ await ctx.adapter.delete(ctx.vault, SEALED_CEK_NS, key);
855
+ }
856
+ }
857
+ }
858
+
859
+ // src/kernel/enclave/record-keys/deterministic.ts
860
+ async function detTargets(ctx, field, value) {
861
+ const dek = await ctx.getDEK();
862
+ const detKey = await deriveDeterministicKey(dek);
863
+ const plaintext = typeof value === "string" ? value : JSON.stringify(value);
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}`];
870
+ }
871
+ function assertDetField(ctx, field, method) {
872
+ if (!ctx.deterministicFields || !ctx.deterministicFields.has(field)) {
873
+ throw new Error(
874
+ `Collection "${ctx.name}": field "${field}" is not declared in deterministicFields`
875
+ );
876
+ }
877
+ if (!ctx.storeCiphertext) {
878
+ throw new Error(
879
+ `Collection "${ctx.name}": ${method} is only meaningful on encrypted collections`
880
+ );
881
+ }
882
+ }
883
+ async function findByDet(ctx, field, value) {
884
+ assertDetField(ctx, field, "findByDet");
885
+ const [target, legacyTarget] = await detTargets(ctx, field, value);
886
+ const ids = await ctx.adapter.list(ctx.vault, ctx.name);
887
+ for (const id of ids) {
888
+ const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
889
+ if (!env || !env._det) continue;
890
+ if (env._det[field] === target || env._det[field] === legacyTarget) {
891
+ return ctx.codec.decryptRecord(env, { id });
892
+ }
893
+ }
894
+ return null;
895
+ }
896
+ async function queryByDet(ctx, field, value) {
897
+ assertDetField(ctx, field, "queryByDet");
898
+ const [target, legacyTarget] = await detTargets(ctx, field, value);
899
+ const ids = await ctx.adapter.list(ctx.vault, ctx.name);
900
+ const matches = [];
901
+ for (const id of ids) {
902
+ const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
903
+ if (!env || !env._det) continue;
904
+ if (env._det[field] === target || env._det[field] === legacyTarget) {
905
+ const rec = await ctx.codec.decryptRecord(env, { id });
906
+ if (rec !== null) matches.push(rec);
907
+ }
908
+ }
909
+ return matches;
910
+ }
911
+
912
+ // src/kernel/enclave/record-keys/envelope-body.ts
913
+ async function openEnvelopeJson(env, key, opts) {
914
+ if (opts?.encrypted === false) return env._data;
915
+ if (env._cek !== void 0) {
916
+ const cek = await unwrapCek(env._cek, key);
917
+ return decrypt(env._iv, env._data, cek);
918
+ }
919
+ return decrypt(env._iv, env._data, key);
920
+ }
921
+ async function writeEnvelopeBody(json, key, opts) {
922
+ if (opts?.encrypted === false) return { _iv: "", _data: json };
923
+ if (opts?.perRecordKey === true) {
924
+ const cek = await generateDEK();
925
+ const { iv: iv2, data: data2 } = await encrypt(json, cek);
926
+ const wrapped = await wrapCek(cek, key);
927
+ return { _iv: iv2, _data: data2, _cek: wrapped };
928
+ }
929
+ const { iv, data } = await encrypt(json, key);
930
+ return { _iv: iv, _data: data };
931
+ }
932
+ function hasPerRecordKey(env) {
933
+ return env._cek !== void 0;
934
+ }
935
+ function envelopeBodyForHash(env) {
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(",")}}`;
948
+ }
949
+
950
+ export {
951
+ resolveStableCek,
952
+ rewrapBodyToDek,
953
+ makeReservedEnvelopes,
954
+ validateSchemaInput,
955
+ validateSchemaOutput,
956
+ RecordCodec,
957
+ SEALED_CEK_NS,
958
+ sealRecordToHost,
959
+ revokeSealedRecord,
960
+ rotateRecordCek,
961
+ findByDet,
962
+ queryByDet,
963
+ openEnvelopeJson,
964
+ writeEnvelopeBody,
965
+ hasPerRecordKey,
966
+ envelopeBodyForHash
967
+ };
968
+ //# sourceMappingURL=chunk-MCHVVJIA.js.map