@noy-db/hub 0.2.0-pre.16 → 0.2.0-pre.17

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 (286) hide show
  1. package/dist/aggregate/index.cjs.map +1 -1
  2. package/dist/aggregate/index.d.cts +3 -2
  3. package/dist/aggregate/index.d.ts +3 -2
  4. package/dist/aggregate/index.js +4 -4
  5. package/dist/attestation/index.cjs.map +1 -1
  6. package/dist/attestation/index.d.cts +5 -3
  7. package/dist/attestation/index.d.ts +5 -3
  8. package/dist/attestation/index.js +6 -6
  9. package/dist/blobs/index.cjs +226 -11
  10. package/dist/blobs/index.cjs.map +1 -1
  11. package/dist/blobs/index.d.cts +6 -4
  12. package/dist/blobs/index.d.ts +6 -4
  13. package/dist/blobs/index.js +6 -5
  14. package/dist/blobs/index.js.map +1 -1
  15. package/dist/bundle/index.cjs +1087 -95
  16. package/dist/bundle/index.cjs.map +1 -1
  17. package/dist/bundle/index.d.cts +7 -5
  18. package/dist/bundle/index.d.ts +7 -5
  19. package/dist/bundle/index.js +21 -10
  20. package/dist/bundle/index.js.map +1 -1
  21. package/dist/{chunk-G4SCICH5.js → chunk-2FU2FTXD.js} +2 -2
  22. package/dist/{chunk-JD3OZAI4.js → chunk-3G3W65EQ.js} +2 -2
  23. package/dist/{chunk-XWH4MXIU.js → chunk-5AXTH4QZ.js} +2 -2
  24. package/dist/{chunk-4TBBMHVC.js → chunk-5LIROIDM.js} +2 -2
  25. package/dist/{chunk-L2BNJ6HM.js → chunk-7H2GEJ3O.js} +3 -3
  26. package/dist/{chunk-GNI5STXQ.js → chunk-AEIKD3PP.js} +52 -38
  27. package/dist/chunk-AEIKD3PP.js.map +1 -0
  28. package/dist/{chunk-QSUK7YWK.js → chunk-BH3X5L6A.js} +4 -4
  29. package/dist/{chunk-BQ65SS5A.js → chunk-BJSLBUJ7.js} +2 -2
  30. package/dist/{chunk-FFXM3ZIF.js → chunk-BL5GYANC.js} +3 -3
  31. package/dist/{chunk-6H2ZUNR7.js → chunk-BSZOCSDZ.js} +4 -4
  32. package/dist/{chunk-ZNQYHJXX.js → chunk-C3HYQPV4.js} +2 -2
  33. package/dist/{chunk-E2CDVKMH.js → chunk-CD2AVTEM.js} +5 -5
  34. package/dist/{chunk-667MB6AH.js → chunk-D77ZQSQQ.js} +769 -131
  35. package/dist/chunk-D77ZQSQQ.js.map +1 -0
  36. package/dist/{chunk-BR3AMFGS.js → chunk-DWEBTE2W.js} +5 -5
  37. package/dist/{chunk-Z4DO7YSI.js → chunk-DYYYUW5D.js} +2 -2
  38. package/dist/{chunk-SCJPI4Z5.js → chunk-E77UKJYL.js} +5 -5
  39. package/dist/{chunk-OMAMZKKD.js → chunk-F4G63NTZ.js} +2 -2
  40. package/dist/{chunk-TKIY625R.js → chunk-FEJDVE3Z.js} +2 -2
  41. package/dist/{chunk-7Z7KSVA5.js → chunk-GP3SDSH2.js} +2 -2
  42. package/dist/{chunk-IQLVUT37.js → chunk-H2MRGONI.js} +2 -2
  43. package/dist/{chunk-DUREQF5W.js → chunk-HGVSHKZW.js} +8 -5
  44. package/dist/chunk-HGVSHKZW.js.map +1 -0
  45. package/dist/chunk-I5IUYN7B.js +125 -0
  46. package/dist/chunk-I5IUYN7B.js.map +1 -0
  47. package/dist/{chunk-CJORTUJ2.js → chunk-J7RWBXFY.js} +2 -2
  48. package/dist/{chunk-AAVWKNZW.js → chunk-JDWE6JMX.js} +2 -2
  49. package/dist/{chunk-XL35NSEN.js → chunk-KCEHMDZF.js} +3 -3
  50. package/dist/{chunk-TS26M2SB.js → chunk-M476FOQ7.js} +2 -2
  51. package/dist/{chunk-F4OJZIWQ.js → chunk-NBBMMJ2H.js} +4 -4
  52. package/dist/{chunk-CZI2A4MQ.js → chunk-NYSYPFXJ.js} +3 -3
  53. package/dist/{chunk-OQSRJG6A.js → chunk-PDULVIBY.js} +2 -2
  54. package/dist/{chunk-Z6FNBOTC.js → chunk-PDVP3C2I.js} +1 -1
  55. package/dist/{chunk-Z6FNBOTC.js.map → chunk-PDVP3C2I.js.map} +1 -1
  56. package/dist/{chunk-DLZ2ONOD.js → chunk-QHM6XEAH.js} +6 -6
  57. package/dist/{chunk-HBXJ37ZY.js → chunk-QO6RGLLD.js} +4 -4
  58. package/dist/{chunk-7BQ4QWYX.js → chunk-ROPJVUG3.js} +23 -6
  59. package/dist/chunk-ROPJVUG3.js.map +1 -0
  60. package/dist/{chunk-42FEUPZQ.js → chunk-ROVO6NPJ.js} +2 -2
  61. package/dist/{chunk-6RR3MNMG.js → chunk-SHX5QBCI.js} +3 -3
  62. package/dist/{chunk-F3BPIPLS.js → chunk-SISBMAPO.js} +1 -1
  63. package/dist/chunk-SISBMAPO.js.map +1 -0
  64. package/dist/{chunk-3YWP3WBP.js → chunk-SNMJ7SB3.js} +5 -5
  65. package/dist/{chunk-IXBIFDEW.js → chunk-TIDXB5DF.js} +4 -4
  66. package/dist/chunk-U5QCMH3W.js +151 -0
  67. package/dist/chunk-U5QCMH3W.js.map +1 -0
  68. package/dist/{chunk-YULZKK4F.js → chunk-UNTGHX5A.js} +37 -2
  69. package/dist/chunk-UNTGHX5A.js.map +1 -0
  70. package/dist/{chunk-FWPKCXTN.js → chunk-WIAOUFFB.js} +2 -2
  71. package/dist/{chunk-KABJXG2F.js → chunk-WV7WV6JO.js} +195 -17
  72. package/dist/chunk-WV7WV6JO.js.map +1 -0
  73. package/dist/{chunk-X73VS74Y.js → chunk-XJV6OB4D.js} +2 -2
  74. package/dist/{chunk-VLMPU56Q.js → chunk-XMHUK5PN.js} +2 -2
  75. package/dist/{chunk-BI6ETQPF.js → chunk-XMVHEWF6.js} +4 -4
  76. package/dist/{chunk-HOR4R722.js → chunk-XPIHJ34I.js} +30 -4
  77. package/dist/chunk-XPIHJ34I.js.map +1 -0
  78. package/dist/{chunk-OB2ZJQ2D.js → chunk-YYVZYTWW.js} +3 -3
  79. package/dist/{chunk-535SSHBS.js → chunk-ZEGSDPB7.js} +81 -2
  80. package/dist/chunk-ZEGSDPB7.js.map +1 -0
  81. package/dist/{chunk-QVIEAYTP.js → chunk-ZNGPEV5J.js} +3 -3
  82. package/dist/consent/index.cjs.map +1 -1
  83. package/dist/consent/index.d.cts +6 -4
  84. package/dist/consent/index.d.ts +6 -4
  85. package/dist/consent/index.js +3 -3
  86. package/dist/{crypto-QXQOHMHF.js → crypto-7BN2HDWG.js} +7 -3
  87. package/dist/{delegation-NIQ43IPU.js → delegation-MGH5SODX.js} +5 -5
  88. package/dist/derivations/index.cjs.map +1 -1
  89. package/dist/derivations/index.d.cts +7 -5
  90. package/dist/derivations/index.d.ts +7 -5
  91. package/dist/derivations/index.js +4 -4
  92. package/dist/{dev-unlock-DR3upLd1.d.ts → dev-unlock-CI1ijTML.d.ts} +1 -1
  93. package/dist/{dev-unlock-8XzcD2Z4.d.cts → dev-unlock-iXbYFAWl.d.cts} +1 -1
  94. package/dist/{strategy-BtW8fAjz.d.ts → errors-Dz64FA65.d.cts} +98 -727
  95. package/dist/{strategy-BtW8fAjz.d.cts → errors-Dz64FA65.d.ts} +98 -727
  96. package/dist/executor-3W63Y44O.js +11 -0
  97. package/dist/executor-CFFWPWBJ.js +8 -0
  98. package/dist/executor-VDQQOR4F.js +8 -0
  99. package/dist/{fanout-sidecar-67CMI3UT.js → fanout-sidecar-FIJJ46YG.js} +2 -2
  100. package/dist/forget/index.cjs +43 -0
  101. package/dist/forget/index.cjs.map +1 -0
  102. package/dist/forget/index.d.cts +1 -0
  103. package/dist/forget/index.d.ts +1 -0
  104. package/dist/forget/index.js +14 -0
  105. package/dist/guards/index.cjs.map +1 -1
  106. package/dist/guards/index.d.cts +7 -5
  107. package/dist/guards/index.d.ts +7 -5
  108. package/dist/guards/index.js +6 -6
  109. package/dist/{hash-CDjye9KV.d.ts → hash-blk7Bkes.d.ts} +1 -1
  110. package/dist/{hash-DuQ88_5W.d.cts → hash-tEcM5fnv.d.cts} +1 -1
  111. package/dist/history/index.cjs +27 -4
  112. package/dist/history/index.cjs.map +1 -1
  113. package/dist/history/index.d.cts +7 -5
  114. package/dist/history/index.d.ts +7 -5
  115. package/dist/history/index.js +9 -7
  116. package/dist/history/index.js.map +1 -1
  117. package/dist/i18n/index.cjs +53 -0
  118. package/dist/i18n/index.cjs.map +1 -1
  119. package/dist/i18n/index.d.cts +6 -4
  120. package/dist/i18n/index.d.ts +6 -4
  121. package/dist/i18n/index.js +16 -8
  122. package/dist/i18n/index.js.map +1 -1
  123. package/dist/{immutable-guard-Dov3WvwF.d.ts → immutable-guard-B5M95nbq.d.ts} +1 -1
  124. package/dist/{immutable-guard-CRPvu24K.d.cts → immutable-guard-qN3zF8o1.d.cts} +1 -1
  125. package/dist/index-C-SSRIxP.d.cts +348 -0
  126. package/dist/index-C-SSRIxP.d.ts +348 -0
  127. package/dist/{index-nP99bXLg.d.ts → index-DpU6KWof.d.ts} +9 -1
  128. package/dist/{index-C8Bk3-VF.d.cts → index-u-kWzSrL.d.cts} +9 -1
  129. package/dist/index.cjs +7271 -6079
  130. package/dist/index.cjs.map +1 -1
  131. package/dist/index.d.cts +15 -12
  132. package/dist/index.d.ts +15 -12
  133. package/dist/index.js +130 -106
  134. package/dist/index.js.map +1 -1
  135. package/dist/indexing/index.cjs.map +1 -1
  136. package/dist/indexing/index.js +4 -4
  137. package/dist/issue-TTMGHQ2J.js +12 -0
  138. package/dist/{ledger-A3LL253R.js → ledger-LFVLHE5H.js} +6 -6
  139. package/dist/materialized-views/index.cjs.map +1 -1
  140. package/dist/materialized-views/index.d.cts +7 -5
  141. package/dist/materialized-views/index.d.ts +7 -5
  142. package/dist/materialized-views/index.js +12 -12
  143. package/dist/noydb-36S6GQNC.js +37 -0
  144. package/dist/overlay-views/index.cjs.map +1 -1
  145. package/dist/overlay-views/index.d.cts +7 -5
  146. package/dist/overlay-views/index.d.ts +7 -5
  147. package/dist/overlay-views/index.js +4 -4
  148. package/dist/periods/index.cjs.map +1 -1
  149. package/dist/periods/index.d.cts +6 -4
  150. package/dist/periods/index.d.ts +6 -4
  151. package/dist/periods/index.js +6 -6
  152. package/dist/{public-envelope-YP2UWMLG.js → public-envelope-RXZNP3V6.js} +4 -4
  153. package/dist/query/index.cjs +4 -1
  154. package/dist/query/index.cjs.map +1 -1
  155. package/dist/query/index.d.cts +3 -2
  156. package/dist/query/index.d.ts +3 -2
  157. package/dist/query/index.js +6 -6
  158. package/dist/registry-3YFLZ7WD.js +8 -0
  159. package/dist/{registry-UTA4CLQS.js → registry-SECUWSGY.js} +3 -3
  160. package/dist/registry-TGZISEWC.js +8 -0
  161. package/dist/{revoke-HNMQZSCL.js → revoke-B54H2S2W.js} +6 -6
  162. package/dist/sealed-record/index.cjs +139 -0
  163. package/dist/sealed-record/index.cjs.map +1 -0
  164. package/dist/sealed-record/index.d.cts +123 -0
  165. package/dist/sealed-record/index.d.ts +123 -0
  166. package/dist/sealed-record/index.js +42 -0
  167. package/dist/sealed-record/index.js.map +1 -0
  168. package/dist/session/index.cjs.map +1 -1
  169. package/dist/session/index.d.cts +7 -5
  170. package/dist/session/index.d.ts +7 -5
  171. package/dist/session/index.js +3 -3
  172. package/dist/shadow/index.cjs.map +1 -1
  173. package/dist/shadow/index.d.cts +6 -4
  174. package/dist/shadow/index.d.ts +6 -4
  175. package/dist/shadow/index.js +2 -2
  176. package/dist/{signer-DCMNKXSF.js → signer-YSXZT574.js} +5 -5
  177. package/dist/snapshots/index.cjs.map +1 -1
  178. package/dist/snapshots/index.d.cts +6 -4
  179. package/dist/snapshots/index.d.ts +6 -4
  180. package/dist/snapshots/index.js +4 -4
  181. package/dist/{stale-W5PQTRYH.js → stale-TOA36SRK.js} +2 -2
  182. package/dist/stale-TOA36SRK.js.map +1 -0
  183. package/dist/{state-vault-TMXZRTY5.js → state-vault-W2OEABNO.js} +3 -3
  184. package/dist/store/index.cjs.map +1 -1
  185. package/dist/store/index.d.cts +6 -4
  186. package/dist/store/index.d.ts +6 -4
  187. package/dist/store/index.js +2 -2
  188. package/dist/strategy-4M9jo172.d.ts +739 -0
  189. package/dist/strategy-CLC1j79g.d.cts +739 -0
  190. package/dist/sync/index.cjs.map +1 -1
  191. package/dist/sync/index.d.cts +5 -3
  192. package/dist/sync/index.d.ts +5 -3
  193. package/dist/sync/index.js +4 -4
  194. package/dist/team/index.cjs.map +1 -1
  195. package/dist/team/index.d.cts +6 -4
  196. package/dist/team/index.d.ts +6 -4
  197. package/dist/team/index.js +8 -8
  198. package/dist/tx/index.cjs.map +1 -1
  199. package/dist/tx/index.d.cts +6 -4
  200. package/dist/tx/index.d.ts +6 -4
  201. package/dist/tx/index.js +3 -3
  202. package/dist/{types-DrmBTscX.d.ts → types-CljIHm_J.d.ts} +789 -500
  203. package/dist/{types-Bze6vkwm.d.cts → types-CrSpRDuG.d.cts} +789 -500
  204. package/dist/{ulid-DbBVrNSt.d.ts → ulid-CWfL2Vfv.d.ts} +1 -1
  205. package/dist/{ulid-DfZlAh0u.d.cts → ulid-CrI7PPbA.d.cts} +1 -1
  206. package/dist/util/index.cjs.map +1 -1
  207. package/dist/util/index.js +1 -1
  208. package/dist/{vault-group-DX2HFQMX.js → vault-group-DHAHFX2A.js} +4 -4
  209. package/dist/{with-derivation-_lySGdlm.d.ts → with-derivation-BZ2y4bzF.d.ts} +1 -1
  210. package/dist/{with-derivation-CCqAchD5.d.cts → with-derivation-Bozs8DmD.d.cts} +1 -1
  211. package/dist/{with-materialized-view-QT1Tp7NO.d.ts → with-materialized-view-B892zYZV.d.ts} +1 -1
  212. package/dist/{with-materialized-view--4PsvMDu.d.cts → with-materialized-view-NzF71cG_.d.cts} +1 -1
  213. package/dist/{with-overlayed-view-BEXfpzSb.d.ts → with-overlayed-view-CR6m7CHe.d.ts} +1 -1
  214. package/dist/{with-overlayed-view-DlH5qmeB.d.cts → with-overlayed-view-UI8qSGL4.d.cts} +1 -1
  215. package/package.json +23 -3
  216. package/dist/chunk-535SSHBS.js.map +0 -1
  217. package/dist/chunk-667MB6AH.js.map +0 -1
  218. package/dist/chunk-7BQ4QWYX.js.map +0 -1
  219. package/dist/chunk-DUREQF5W.js.map +0 -1
  220. package/dist/chunk-F3BPIPLS.js.map +0 -1
  221. package/dist/chunk-GNI5STXQ.js.map +0 -1
  222. package/dist/chunk-HOR4R722.js.map +0 -1
  223. package/dist/chunk-KABJXG2F.js.map +0 -1
  224. package/dist/chunk-YULZKK4F.js.map +0 -1
  225. package/dist/executor-6ZDSDZ6V.js +0 -8
  226. package/dist/executor-AZLS3KBK.js +0 -11
  227. package/dist/executor-IDZDAFNH.js +0 -8
  228. package/dist/issue-RZP3VI6O.js +0 -12
  229. package/dist/noydb-WCMY2ZOW.js +0 -35
  230. package/dist/registry-EB6SISTA.js +0 -8
  231. package/dist/registry-IUZQVVBB.js +0 -8
  232. /package/dist/{chunk-G4SCICH5.js.map → chunk-2FU2FTXD.js.map} +0 -0
  233. /package/dist/{chunk-JD3OZAI4.js.map → chunk-3G3W65EQ.js.map} +0 -0
  234. /package/dist/{chunk-XWH4MXIU.js.map → chunk-5AXTH4QZ.js.map} +0 -0
  235. /package/dist/{chunk-4TBBMHVC.js.map → chunk-5LIROIDM.js.map} +0 -0
  236. /package/dist/{chunk-L2BNJ6HM.js.map → chunk-7H2GEJ3O.js.map} +0 -0
  237. /package/dist/{chunk-QSUK7YWK.js.map → chunk-BH3X5L6A.js.map} +0 -0
  238. /package/dist/{chunk-BQ65SS5A.js.map → chunk-BJSLBUJ7.js.map} +0 -0
  239. /package/dist/{chunk-FFXM3ZIF.js.map → chunk-BL5GYANC.js.map} +0 -0
  240. /package/dist/{chunk-6H2ZUNR7.js.map → chunk-BSZOCSDZ.js.map} +0 -0
  241. /package/dist/{chunk-ZNQYHJXX.js.map → chunk-C3HYQPV4.js.map} +0 -0
  242. /package/dist/{chunk-E2CDVKMH.js.map → chunk-CD2AVTEM.js.map} +0 -0
  243. /package/dist/{chunk-BR3AMFGS.js.map → chunk-DWEBTE2W.js.map} +0 -0
  244. /package/dist/{chunk-Z4DO7YSI.js.map → chunk-DYYYUW5D.js.map} +0 -0
  245. /package/dist/{chunk-SCJPI4Z5.js.map → chunk-E77UKJYL.js.map} +0 -0
  246. /package/dist/{chunk-OMAMZKKD.js.map → chunk-F4G63NTZ.js.map} +0 -0
  247. /package/dist/{chunk-TKIY625R.js.map → chunk-FEJDVE3Z.js.map} +0 -0
  248. /package/dist/{chunk-7Z7KSVA5.js.map → chunk-GP3SDSH2.js.map} +0 -0
  249. /package/dist/{chunk-IQLVUT37.js.map → chunk-H2MRGONI.js.map} +0 -0
  250. /package/dist/{chunk-CJORTUJ2.js.map → chunk-J7RWBXFY.js.map} +0 -0
  251. /package/dist/{chunk-AAVWKNZW.js.map → chunk-JDWE6JMX.js.map} +0 -0
  252. /package/dist/{chunk-XL35NSEN.js.map → chunk-KCEHMDZF.js.map} +0 -0
  253. /package/dist/{chunk-TS26M2SB.js.map → chunk-M476FOQ7.js.map} +0 -0
  254. /package/dist/{chunk-F4OJZIWQ.js.map → chunk-NBBMMJ2H.js.map} +0 -0
  255. /package/dist/{chunk-CZI2A4MQ.js.map → chunk-NYSYPFXJ.js.map} +0 -0
  256. /package/dist/{chunk-OQSRJG6A.js.map → chunk-PDULVIBY.js.map} +0 -0
  257. /package/dist/{chunk-DLZ2ONOD.js.map → chunk-QHM6XEAH.js.map} +0 -0
  258. /package/dist/{chunk-HBXJ37ZY.js.map → chunk-QO6RGLLD.js.map} +0 -0
  259. /package/dist/{chunk-42FEUPZQ.js.map → chunk-ROVO6NPJ.js.map} +0 -0
  260. /package/dist/{chunk-6RR3MNMG.js.map → chunk-SHX5QBCI.js.map} +0 -0
  261. /package/dist/{chunk-3YWP3WBP.js.map → chunk-SNMJ7SB3.js.map} +0 -0
  262. /package/dist/{chunk-IXBIFDEW.js.map → chunk-TIDXB5DF.js.map} +0 -0
  263. /package/dist/{chunk-FWPKCXTN.js.map → chunk-WIAOUFFB.js.map} +0 -0
  264. /package/dist/{chunk-X73VS74Y.js.map → chunk-XJV6OB4D.js.map} +0 -0
  265. /package/dist/{chunk-VLMPU56Q.js.map → chunk-XMHUK5PN.js.map} +0 -0
  266. /package/dist/{chunk-BI6ETQPF.js.map → chunk-XMVHEWF6.js.map} +0 -0
  267. /package/dist/{chunk-OB2ZJQ2D.js.map → chunk-YYVZYTWW.js.map} +0 -0
  268. /package/dist/{chunk-QVIEAYTP.js.map → chunk-ZNGPEV5J.js.map} +0 -0
  269. /package/dist/{crypto-QXQOHMHF.js.map → crypto-7BN2HDWG.js.map} +0 -0
  270. /package/dist/{delegation-NIQ43IPU.js.map → delegation-MGH5SODX.js.map} +0 -0
  271. /package/dist/{executor-6ZDSDZ6V.js.map → executor-3W63Y44O.js.map} +0 -0
  272. /package/dist/{executor-AZLS3KBK.js.map → executor-CFFWPWBJ.js.map} +0 -0
  273. /package/dist/{executor-IDZDAFNH.js.map → executor-VDQQOR4F.js.map} +0 -0
  274. /package/dist/{fanout-sidecar-67CMI3UT.js.map → fanout-sidecar-FIJJ46YG.js.map} +0 -0
  275. /package/dist/{issue-RZP3VI6O.js.map → forget/index.js.map} +0 -0
  276. /package/dist/{ledger-A3LL253R.js.map → issue-TTMGHQ2J.js.map} +0 -0
  277. /package/dist/{noydb-WCMY2ZOW.js.map → ledger-LFVLHE5H.js.map} +0 -0
  278. /package/dist/{public-envelope-YP2UWMLG.js.map → noydb-36S6GQNC.js.map} +0 -0
  279. /package/dist/{registry-EB6SISTA.js.map → public-envelope-RXZNP3V6.js.map} +0 -0
  280. /package/dist/{registry-IUZQVVBB.js.map → registry-3YFLZ7WD.js.map} +0 -0
  281. /package/dist/{registry-UTA4CLQS.js.map → registry-SECUWSGY.js.map} +0 -0
  282. /package/dist/{revoke-HNMQZSCL.js.map → registry-TGZISEWC.js.map} +0 -0
  283. /package/dist/{signer-DCMNKXSF.js.map → revoke-B54H2S2W.js.map} +0 -0
  284. /package/dist/{stale-W5PQTRYH.js.map → signer-YSXZT574.js.map} +0 -0
  285. /package/dist/{state-vault-TMXZRTY5.js.map → state-vault-W2OEABNO.js.map} +0 -0
  286. /package/dist/{vault-group-DX2HFQMX.js.map → vault-group-DHAHFX2A.js.map} +0 -0
@@ -0,0 +1,125 @@
1
+ import {
2
+ NOYDB_FORMAT_VERSION
3
+ } from "./chunk-SISBMAPO.js";
4
+ import {
5
+ decrypt,
6
+ encrypt
7
+ } from "./chunk-UNTGHX5A.js";
8
+
9
+ // src/forget/strategy.ts
10
+ var NO_FORGET = { subjects: {} };
11
+ function withForgetCascade(opts) {
12
+ return { subjects: { ...opts.subjects } };
13
+ }
14
+
15
+ // src/forget/subject-index.ts
16
+ var SUBJECT_INDEX_COLLECTION = "_subject_index";
17
+ async function sha256HexString(input) {
18
+ const bytes = new TextEncoder().encode(input);
19
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
20
+ return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
21
+ }
22
+ async function subjectKey(subjectId) {
23
+ return sha256HexString(subjectId);
24
+ }
25
+ async function readRefs(adapter, vault, getDEK, encrypted, key) {
26
+ const env = await adapter.get(vault, SUBJECT_INDEX_COLLECTION, key);
27
+ if (!env || !env._data) return [];
28
+ if (!encrypted) return JSON.parse(env._data);
29
+ const dek = await getDEK(SUBJECT_INDEX_COLLECTION);
30
+ const json = await decrypt(env._iv, env._data, dek);
31
+ return JSON.parse(json);
32
+ }
33
+ async function writeRefs(adapter, vault, getDEK, encrypted, key, refs) {
34
+ const json = JSON.stringify(refs);
35
+ let env;
36
+ if (!encrypted) {
37
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json };
38
+ } else {
39
+ const dek = await getDEK(SUBJECT_INDEX_COLLECTION);
40
+ const { iv, data } = await encrypt(json, dek);
41
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data };
42
+ }
43
+ await adapter.put(vault, SUBJECT_INDEX_COLLECTION, key, env);
44
+ }
45
+ async function addSubjectRef(adapter, vault, getDEK, encrypted, subjectId, ref) {
46
+ const key = await subjectKey(subjectId);
47
+ const refs = await readRefs(adapter, vault, getDEK, encrypted, key);
48
+ if (refs.some((r) => r.collection === ref.collection && r.id === ref.id)) return;
49
+ refs.push(ref);
50
+ await writeRefs(adapter, vault, getDEK, encrypted, key, refs);
51
+ }
52
+ async function removeSubjectRef(adapter, vault, getDEK, encrypted, subjectId, ref) {
53
+ const key = await subjectKey(subjectId);
54
+ const refs = await readRefs(adapter, vault, getDEK, encrypted, key);
55
+ const next = refs.filter((r) => !(r.collection === ref.collection && r.id === ref.id));
56
+ if (next.length === refs.length) return;
57
+ if (next.length === 0) {
58
+ await adapter.delete(vault, SUBJECT_INDEX_COLLECTION, key);
59
+ return;
60
+ }
61
+ await writeRefs(adapter, vault, getDEK, encrypted, key, next);
62
+ }
63
+ async function lookupSubject(adapter, vault, getDEK, encrypted, subjectId) {
64
+ const key = await subjectKey(subjectId);
65
+ return readRefs(adapter, vault, getDEK, encrypted, key);
66
+ }
67
+ async function rebuildSubjectIndex(adapter, vault, getDEK, encrypted, subjects, decodeRecord) {
68
+ const existing = await adapter.list(vault, SUBJECT_INDEX_COLLECTION);
69
+ for (const k of existing) {
70
+ await adapter.delete(vault, SUBJECT_INDEX_COLLECTION, k);
71
+ }
72
+ const bySubject = /* @__PURE__ */ new Map();
73
+ for (const [collection, field] of Object.entries(subjects)) {
74
+ const ids = await adapter.list(vault, collection);
75
+ for (const id of ids) {
76
+ if (id.startsWith("_")) continue;
77
+ const env = await adapter.get(vault, collection, id);
78
+ if (!env || !env._data) continue;
79
+ const record = await decodeRecord(collection, id, env);
80
+ if (record === null) continue;
81
+ const subjectValue = readDottedPath(record, field);
82
+ if (subjectValue === void 0 || subjectValue === null) continue;
83
+ const subjectId = coerceSubjectId(subjectValue);
84
+ const list = bySubject.get(subjectId) ?? [];
85
+ list.push({ collection, id });
86
+ bySubject.set(subjectId, list);
87
+ }
88
+ }
89
+ let entries = 0;
90
+ for (const [subjectId, refs] of bySubject) {
91
+ const key = await subjectKey(subjectId);
92
+ await writeRefs(adapter, vault, getDEK, encrypted, key, refs);
93
+ entries++;
94
+ }
95
+ return entries;
96
+ }
97
+ function coerceSubjectId(value) {
98
+ if (typeof value === "string") return value;
99
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
100
+ return String(value);
101
+ }
102
+ return JSON.stringify(value);
103
+ }
104
+ function readDottedPath(record, field) {
105
+ if (!field.includes(".")) return record[field];
106
+ let cursor = record;
107
+ for (const segment of field.split(".")) {
108
+ if (cursor === null || cursor === void 0) return void 0;
109
+ cursor = cursor[segment];
110
+ }
111
+ return cursor;
112
+ }
113
+
114
+ export {
115
+ NO_FORGET,
116
+ withForgetCascade,
117
+ SUBJECT_INDEX_COLLECTION,
118
+ addSubjectRef,
119
+ removeSubjectRef,
120
+ lookupSubject,
121
+ rebuildSubjectIndex,
122
+ coerceSubjectId,
123
+ readDottedPath
124
+ };
125
+ //# sourceMappingURL=chunk-I5IUYN7B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/forget/strategy.ts","../src/forget/subject-index.ts"],"sourcesContent":["/**\n * `withForgetCascade` — declaration surface for GDPR right-to-erasure via\n * per-record CEK crypto-shred (#304, step 2 of the CEK security epic).\n *\n * This file holds only the *declaration* shape and the disabled sentinel.\n * The actual erasure machinery lives in:\n * - `subject-index.ts` — the encrypted `_subject_index` reserved collection\n * - `vault.ts` `forget()` — the per-record tombstone + ledger flow\n * - `collection.ts` `_writeTombstone` — the envelope rewrite\n *\n * A `ForgetStrategy` declares which collections carry erasable subject data\n * and the (dotted-path) field on each record that names the data subject.\n * Declaring a collection here ALSO forces `perRecordKeys: true` for it (a\n * shred can only erase a record whose body is keyed off a per-record CEK),\n * so adopters opt into the CEK foundation transitively.\n *\n * @module\n */\nimport type { LedgerEntry } from '../history/ledger/entry.js'\n\n/**\n * User-supplied declaration passed to {@link withForgetCascade}. Maps a\n * collection name to the record field (dotted path supported, e.g.\n * `'billing.buyerId'`) that identifies the data subject for erasure.\n *\n * ```ts\n * withForgetCascade({ subjects: { invoices: 'buyerId', contacts: 'id' } })\n * ```\n */\nexport interface SubjectDeclaration {\n readonly subjects: Record<string, string>\n}\n\n/**\n * Resolved forget strategy threaded through Noydb → every Vault. Carries\n * the same `subjects` map the user declared. `NO_FORGET` (empty map) is the\n * off-by-default sentinel; `vault.forget()` throws\n * `ForgetStrategyNotConfiguredError` when the map is empty.\n */\nexport interface ForgetStrategy {\n /** Collection → subject-field (dotted path). Empty under `NO_FORGET`. */\n readonly subjects: Readonly<Record<string, string>>\n}\n\n/**\n * Disabled sentinel — no collections declare a subject field. `vault.forget()`\n * refuses with `ForgetStrategyNotConfiguredError`; no write hooks register; no\n * collection is forced into `perRecordKeys`. Non-adopters pay nothing.\n */\nexport const NO_FORGET: ForgetStrategy = { subjects: {} }\n\n/**\n * Declare GDPR crypto-shred for one or more collections.\n *\n * Each declared collection is forced to `perRecordKeys: true` (a shred can\n * only guarantee erasure of a record whose body is keyed off a per-record\n * CEK). On write, Noydb extracts `record[subjectField]` and maintains an\n * encrypted `_subject_index` mapping `subject → [{collection, id}]`, so\n * `vault.forget(subjectId)` can find every record for a subject and rewrite\n * each to a tombstone (body + history permanently undecryptable) while the\n * collection DEK and every other record stay intact.\n *\n * @example\n * ```ts\n * createNoydb({\n * secret, user,\n * forgetStrategy: withForgetCascade({ subjects: { invoices: 'buyerId' } }),\n * })\n * const result = await vault.forget('buyer-123')\n * // → { subject, recordsShredded, historyVersionsShredded, collections, … }\n * ```\n */\nexport function withForgetCascade(opts: SubjectDeclaration): ForgetStrategy {\n return { subjects: { ...opts.subjects } }\n}\n\n/**\n * The outcome of a `vault.forget(subjectId)` call.\n *\n * `unmigratedRecords` lists `collection:id` pairs that were tombstoned but\n * whose body had NOT been migrated to a per-record CEK at shred time (legacy\n * body still under the shared collection DEK). Those records are tombstoned\n * (live envelope + history stripped) but their pre-shred ciphertext, if it\n * leaked into a backup before migration, remains decryptable under the\n * collection DEK — so erasure-completeness is NOT guaranteed for them. Run\n * the per-record-CEK migration pass, then re-forget, to close the gap.\n *\n * Blob attachments (#365): a shredded record's **erasable** blobs (on a\n * `perRecordKeys` collection) are crypto-shredded inline — `blobsShredded`\n * counts those taken to refCount 0 (BlobObject deleted → chunks permanently\n * undecryptable), `blobsRetainedShared` counts those still referenced by\n * another record (shared content legitimately persists for its other owner).\n * `blobResidueCollections` now lists only collections with blobs that could\n * NOT be crypto-shredded: **legacy** blobs (no per-blob `_cek`, chunks under\n * the shared `_blob` DEK — migrate them), or a session without the blob\n * subsystem loaded. An all-erasable subject yields an empty residue list.\n */\nexport interface ForgetResult {\n /** The subject id passed to `forget()`. Echoed for caller convenience. */\n readonly subject: string\n /** Count of live records rewritten to a tombstone. */\n readonly recordsShredded: number\n /** Count of `_history` envelopes tombstoned across all shredded records. */\n readonly historyVersionsShredded: number\n /** Distinct collections that had at least one record shredded. */\n readonly collections: readonly string[]\n /** `collection:id` pairs shredded while still un-migrated (see type docs). */\n readonly unmigratedRecords: readonly string[]\n /** Count of erasable blobs crypto-shredded (refCount → 0, BlobObject deleted). */\n readonly blobsShredded: number\n /** Count of erasable blobs retained because still referenced elsewhere (shared). */\n readonly blobsRetainedShared: number\n /** Collections with blobs that could NOT be crypto-shredded — legacy (no `_cek`) or blobs disabled (see type docs). */\n readonly blobResidueCollections: readonly string[]\n /** The single `op:'forget'` ledger entry appended for this erasure. */\n readonly ledgerEntry: LedgerEntry\n}\n","/**\n * The encrypted subject index (#304).\n *\n * GDPR crypto-shred needs to answer \"which records belong to data subject\n * X?\" portably (the index must travel with the vault/bundle) WITHOUT leaking\n * subject-equivalence to the store. The rejected alternative — an unencrypted\n * subject tag in envelope metadata — would let anyone with store access see\n * which records share a subject. Instead we keep a reserved `_subject_index`\n * collection, encrypted under its OWN DEK (`getDEK('_subject_index')`):\n *\n * - record id = `sha256Hex(subjectId)` — the raw subject id never appears\n * as a key, so the store can't correlate index entries to a known subject.\n * - record body = AES-GCM(JSON `[{ collection, id }]`) under the index DEK.\n *\n * ## Concurrency (RISK #3 — known v1 limitation)\n *\n * `addSubjectRef` / `removeSubjectRef` are read-modify-write with no CAS. The\n * design assumes a SINGLE WRITER (the noy-db single-process write model). Two\n * concurrent writers racing on the SAME subject can lose an entry (last-write\n * wins on the ref list). This is documented, not fixed in v1:\n * `rebuildSubjectIndex` performs a full scan to recover a correct index from\n * the canonical records, so a lost ref is recoverable. A CAS-backed index is\n * deferred to a later slice.\n *\n * @module\n */\nimport { encrypt, decrypt } from '../crypto.js'\nimport type { NoydbStore, EncryptedEnvelope } from '../types.js'\nimport { NOYDB_FORMAT_VERSION } from '../types.js'\n\n/** Reserved collection holding the encrypted subject → records index. */\nexport const SUBJECT_INDEX_COLLECTION = '_subject_index'\n\n/** A single record reference held in a subject's index entry. */\nexport interface SubjectRef {\n readonly collection: string\n readonly id: string\n}\n\ntype GetDEK = (collectionName: string) => Promise<CryptoKey>\n\n/** SHA-256 hex of a UTF-8 string. The subject-index record key derivation. */\nasync function sha256HexString(input: string): Promise<string> {\n const bytes = new TextEncoder().encode(input)\n const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes)\n return Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/** Stable subject-index record id for a subject id. */\nexport async function subjectKey(subjectId: string): Promise<string> {\n return sha256HexString(subjectId)\n}\n\n/** Read + decrypt the ref list for a subject. Returns `[]` when absent. */\nasync function readRefs(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n key: string,\n): Promise<SubjectRef[]> {\n const env = await adapter.get(vault, SUBJECT_INDEX_COLLECTION, key)\n if (!env || !env._data) return []\n if (!encrypted) return JSON.parse(env._data) as SubjectRef[]\n const dek = await getDEK(SUBJECT_INDEX_COLLECTION)\n const json = await decrypt(env._iv, env._data, dek)\n return JSON.parse(json) as SubjectRef[]\n}\n\n/** Encrypt + write a ref list for a subject under its derived key. */\nasync function writeRefs(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n key: string,\n refs: SubjectRef[],\n): Promise<void> {\n const json = JSON.stringify(refs)\n let env: EncryptedEnvelope\n if (!encrypted) {\n env = { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: new Date().toISOString(), _iv: '', _data: json }\n } else {\n const dek = await getDEK(SUBJECT_INDEX_COLLECTION)\n const { iv, data } = await encrypt(json, dek)\n env = { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: new Date().toISOString(), _iv: iv, _data: data }\n }\n await adapter.put(vault, SUBJECT_INDEX_COLLECTION, key, env)\n}\n\n/**\n * Add a `{ collection, id }` ref to a subject's index entry (idempotent —\n * a duplicate ref is not appended). Read-modify-write; see the concurrency\n * note in the module docstring.\n */\nexport async function addSubjectRef(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n subjectId: string,\n ref: SubjectRef,\n): Promise<void> {\n const key = await subjectKey(subjectId)\n const refs = await readRefs(adapter, vault, getDEK, encrypted, key)\n if (refs.some((r) => r.collection === ref.collection && r.id === ref.id)) return\n refs.push(ref)\n await writeRefs(adapter, vault, getDEK, encrypted, key, refs)\n}\n\n/**\n * Remove a `{ collection, id }` ref from a subject's index entry. When the\n * last ref is removed the (now empty) entry is deleted so the store holds no\n * residual key for an erased subject.\n */\nexport async function removeSubjectRef(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n subjectId: string,\n ref: SubjectRef,\n): Promise<void> {\n const key = await subjectKey(subjectId)\n const refs = await readRefs(adapter, vault, getDEK, encrypted, key)\n const next = refs.filter((r) => !(r.collection === ref.collection && r.id === ref.id))\n if (next.length === refs.length) return\n if (next.length === 0) {\n await adapter.delete(vault, SUBJECT_INDEX_COLLECTION, key)\n return\n }\n await writeRefs(adapter, vault, getDEK, encrypted, key, next)\n}\n\n/** Look up every record ref for a subject. Returns `[]` when none exist. */\nexport async function lookupSubject(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n subjectId: string,\n): Promise<SubjectRef[]> {\n const key = await subjectKey(subjectId)\n return readRefs(adapter, vault, getDEK, encrypted, key)\n}\n\n/**\n * Rebuild the entire subject index from the canonical records (the recovery\n * path for the documented read-modify-write race). Scans each declared\n * collection, reads `record[subjectField]` (dotted path), and rewrites the\n * index from scratch. Tombstoned (already-shredded) records contribute no\n * ref — their body is gone, so they cannot be re-indexed.\n *\n * `decodeRecord` decrypts an envelope to a plain object (or returns null for\n * a tombstone / unreadable record); supplied by the caller so this module\n * stays free of Collection internals.\n */\nexport async function rebuildSubjectIndex(\n adapter: NoydbStore,\n vault: string,\n getDEK: GetDEK,\n encrypted: boolean,\n subjects: Readonly<Record<string, string>>,\n decodeRecord: (collection: string, id: string, env: EncryptedEnvelope) => Promise<Record<string, unknown> | null>,\n): Promise<number> {\n // Drop every existing index entry first so removed refs don't linger.\n const existing = await adapter.list(vault, SUBJECT_INDEX_COLLECTION)\n for (const k of existing) {\n await adapter.delete(vault, SUBJECT_INDEX_COLLECTION, k)\n }\n\n // subjectId → refs, accumulated across all declared collections.\n const bySubject = new Map<string, SubjectRef[]>()\n for (const [collection, field] of Object.entries(subjects)) {\n const ids = await adapter.list(vault, collection)\n for (const id of ids) {\n if (id.startsWith('_')) continue\n const env = await adapter.get(vault, collection, id)\n if (!env || !env._data) continue // missing or tombstone\n const record = await decodeRecord(collection, id, env)\n if (record === null) continue\n const subjectValue = readDottedPath(record, field)\n if (subjectValue === undefined || subjectValue === null) continue\n const subjectId = coerceSubjectId(subjectValue)\n const list = bySubject.get(subjectId) ?? []\n list.push({ collection, id })\n bySubject.set(subjectId, list)\n }\n }\n\n let entries = 0\n for (const [subjectId, refs] of bySubject) {\n const key = await subjectKey(subjectId)\n await writeRefs(adapter, vault, getDEK, encrypted, key, refs)\n entries++\n }\n return entries\n}\n\n/**\n * Coerce a read subject-field value to a stable string id. Primitives use\n * their natural string form; objects/arrays are JSON-stringified so structural\n * subjects still get a deterministic key (avoids the `[object Object]` trap).\n */\nexport function coerceSubjectId(value: unknown): string {\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {\n return String(value)\n }\n return JSON.stringify(value)\n}\n\n/** Read a (possibly dotted) field path from a plain record. */\nexport function readDottedPath(record: Record<string, unknown>, field: string): unknown {\n if (!field.includes('.')) return record[field]\n let cursor: unknown = record\n for (const segment of field.split('.')) {\n if (cursor === null || cursor === undefined) return undefined\n cursor = (cursor as Record<string, unknown>)[segment]\n }\n return cursor\n}\n"],"mappings":";;;;;;;;;AAiDO,IAAM,YAA4B,EAAE,UAAU,CAAC,EAAE;AAuBjD,SAAS,kBAAkB,MAA0C;AAC1E,SAAO,EAAE,UAAU,EAAE,GAAG,KAAK,SAAS,EAAE;AAC1C;;;AC3CO,IAAM,2BAA2B;AAWxC,eAAe,gBAAgB,OAAgC;AAC7D,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK;AAC5C,QAAM,SAAS,MAAM,WAAW,OAAO,OAAO,OAAO,WAAW,KAAK;AACrE,SAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,EACrC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AACZ;AAGA,eAAsB,WAAW,WAAoC;AACnE,SAAO,gBAAgB,SAAS;AAClC;AAGA,eAAe,SACb,SACA,OACA,QACA,WACA,KACuB;AACvB,QAAM,MAAM,MAAM,QAAQ,IAAI,OAAO,0BAA0B,GAAG;AAClE,MAAI,CAAC,OAAO,CAAC,IAAI,MAAO,QAAO,CAAC;AAChC,MAAI,CAAC,UAAW,QAAO,KAAK,MAAM,IAAI,KAAK;AAC3C,QAAM,MAAM,MAAM,OAAO,wBAAwB;AACjD,QAAM,OAAO,MAAM,QAAQ,IAAI,KAAK,IAAI,OAAO,GAAG;AAClD,SAAO,KAAK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,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AACxF,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO,KAAK,UAAU,KAAK;AAC7B;AAGO,SAAS,eAAe,QAAiC,OAAwB;AACtF,MAAI,CAAC,MAAM,SAAS,GAAG,EAAG,QAAO,OAAO,KAAK;AAC7C,MAAI,SAAkB;AACtB,aAAW,WAAW,MAAM,MAAM,GAAG,GAAG;AACtC,QAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,aAAU,OAAmC,OAAO;AAAA,EACtD;AACA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NoydbError
3
- } from "./chunk-535SSHBS.js";
3
+ } from "./chunk-ZEGSDPB7.js";
4
4
 
5
5
  // src/money/iso4217.ts
6
6
  var MINOR_UNITS = {
@@ -521,4 +521,4 @@ export {
521
521
  evaluateClause,
522
522
  hasFnClause
523
523
  };
524
- //# sourceMappingURL=chunk-CJORTUJ2.js.map
524
+ //# sourceMappingURL=chunk-J7RWBXFY.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ScriptViolationError
3
- } from "./chunk-535SSHBS.js";
3
+ } from "./chunk-ZEGSDPB7.js";
4
4
 
5
5
  // src/i18n/script.ts
6
6
  var LATIN_BASE = /* @__PURE__ */ new Set([
@@ -136,4 +136,4 @@ export {
136
136
  inferScripts,
137
137
  enforceScript
138
138
  };
139
- //# sourceMappingURL=chunk-AAVWKNZW.js.map
139
+ //# sourceMappingURL=chunk-JDWE6JMX.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-F3BPIPLS.js";
3
+ } from "./chunk-SISBMAPO.js";
4
4
  import {
5
5
  encrypt
6
- } from "./chunk-YULZKK4F.js";
6
+ } from "./chunk-UNTGHX5A.js";
7
7
 
8
8
  // src/blobs/export-blobs.ts
9
9
  var ExportBlobsAbortedError = class extends Error {
@@ -258,4 +258,4 @@ export {
258
258
  BLOB_EVICTION_AUDIT_COLLECTION,
259
259
  runCompaction
260
260
  };
261
- //# sourceMappingURL=chunk-XL35NSEN.js.map
261
+ //# sourceMappingURL=chunk-KCEHMDZF.js.map
@@ -2,7 +2,7 @@ import {
2
2
  OverlayBaseIsVirtualError,
3
3
  OverlayCollectionUnavailableError,
4
4
  OverlayNameCollisionError
5
- } from "./chunk-535SSHBS.js";
5
+ } from "./chunk-ZEGSDPB7.js";
6
6
 
7
7
  // src/overlay-views/registry.ts
8
8
  var OverlayedViewRegistry = class {
@@ -68,4 +68,4 @@ var OverlayedViewRegistry = class {
68
68
  export {
69
69
  OverlayedViewRegistry
70
70
  };
71
- //# sourceMappingURL=chunk-TS26M2SB.js.map
71
+ //# sourceMappingURL=chunk-M476FOQ7.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dekKey
3
- } from "./chunk-4TBBMHVC.js";
3
+ } from "./chunk-5LIROIDM.js";
4
4
  import {
5
5
  generateULID
6
6
  } from "./chunk-FZU343FL.js";
@@ -9,10 +9,10 @@ import {
9
9
  encrypt,
10
10
  unwrapKey,
11
11
  wrapKey
12
- } from "./chunk-YULZKK4F.js";
12
+ } from "./chunk-UNTGHX5A.js";
13
13
  import {
14
14
  DelegationTargetMissingError
15
- } from "./chunk-535SSHBS.js";
15
+ } from "./chunk-ZEGSDPB7.js";
16
16
 
17
17
  // src/team/delegation.ts
18
18
  var DELEGATIONS_COLLECTION = "_delegations";
@@ -94,4 +94,4 @@ export {
94
94
  loadActiveDelegations,
95
95
  revokeDelegation
96
96
  };
97
- //# sourceMappingURL=chunk-F4OJZIWQ.js.map
97
+ //# sourceMappingURL=chunk-NBBMMJ2H.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  evaluateClause,
3
3
  readPath
4
- } from "./chunk-CJORTUJ2.js";
4
+ } from "./chunk-J7RWBXFY.js";
5
5
  import {
6
6
  IndexRequiredError
7
- } from "./chunk-535SSHBS.js";
7
+ } from "./chunk-ZEGSDPB7.js";
8
8
 
9
9
  // src/indexing/persisted-indexes.ts
10
10
  var IDX_PREFIX = "_idx/";
@@ -427,4 +427,4 @@ export {
427
427
  PersistedCollectionIndex,
428
428
  LazyQuery
429
429
  };
430
- //# sourceMappingURL=chunk-CZI2A4MQ.js.map
430
+ //# sourceMappingURL=chunk-NYSYPFXJ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-535SSHBS.js";
3
+ } from "./chunk-ZEGSDPB7.js";
4
4
 
5
5
  // src/derivations/with-derivation.ts
6
6
  function withDerivation(spec) {
@@ -60,4 +60,4 @@ function withDerivation(spec) {
60
60
  export {
61
61
  withDerivation
62
62
  };
63
- //# sourceMappingURL=chunk-OQSRJG6A.js.map
63
+ //# sourceMappingURL=chunk-PDULVIBY.js.map
@@ -69,4 +69,4 @@ export {
69
69
  parseIndex,
70
70
  envelopePayloadHash
71
71
  };
72
- //# sourceMappingURL=chunk-Z6FNBOTC.js.map
72
+ //# sourceMappingURL=chunk-PDVP3C2I.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/history/ledger/entry.ts","../src/history/ledger/hash.ts"],"sourcesContent":["/**\n * Ledger entry shape + canonical JSON + sha256 helpers.\n *\n * This file holds the PURE primitives used by the hash-chained ledger:\n * the entry type, the deterministic (sort-stable) JSON encoder, and\n * the sha256 hasher that produces `prevHash` and `ledger.head()`.\n *\n * Everything here is validator-free and side-effect free — the only\n * runtime dep is Web Crypto's `subtle.digest` for the sha256 call,\n * which we already use for every other hashing operation in the core.\n *\n * The hash chain property works like this:\n *\n * hash(entry[i]) = sha256(canonicalJSON(entry[i]))\n * entry[i+1].prevHash = hash(entry[i])\n *\n * Any modification to `entry[i]` (field values, field order, whitespace)\n * produces a different `hash(entry[i])`, which means `entry[i+1]`'s\n * stored `prevHash` no longer matches the recomputed hash, which means\n * `verify()` returns `{ ok: false, divergedAt: i + 1 }`. The chain is\n * append-only and tamper-evident without external anchoring.\n */\n\n/**\n * A single ledger entry in its plaintext form — what gets serialized,\n * hashed, and then encrypted with the ledger DEK before being written\n * to the `_ledger/` adapter collection.\n *\n * ## Why hash the ciphertext, not the plaintext?\n *\n * `payloadHash` is the sha256 of the record's ENCRYPTED envelope bytes,\n * not its plaintext. This matters:\n *\n * 1. **Zero-knowledge preserved.** A user (or a third party) can\n * verify the ledger against the stored envelopes without any\n * decryption keys. The adapter layer already holds only\n * ciphertext, so hashing the ciphertext keeps the ledger at the\n * same privacy level as the adapter.\n *\n * 2. **Determinism.** Plaintext → ciphertext is randomized by the\n * fresh per-write IV, so `hash(plaintext)` would need extra\n * normalization. `hash(ciphertext)` is already deterministic and\n * unique per write.\n *\n * 3. **Detection property.** If an attacker modifies even one byte of\n * the stored ciphertext (trying to flip a record), the hash\n * changes, the ledger's recorded `payloadHash` no longer matches,\n * and a data-integrity check fails. We don't do that check in\n * `verify()` today, but the\n * hook is there for a future `verifyIntegrity()` follow-up.\n *\n * Fields marked `op`, `collection`, `id`, `version`, `ts`, `actor` are\n * plaintext METADATA about the operation — NOT the record itself. The\n * entry is still encrypted at rest via the ledger DEK, but adapters\n * could theoretically infer operation patterns from the sizes and\n * timestamps. This is an accepted trade-off for the tamper-evidence\n * property; full ORAM-level privacy is out of scope for noy-db.\n */\nexport interface LedgerEntry {\n /**\n * Zero-based sequential position of this entry in the chain. The\n * canonical adapter key is this number zero-padded to 10 digits\n * (`\"0000000001\"`) so lexicographic ordering matches numeric order.\n */\n readonly index: number\n\n /**\n * Hex-encoded sha256 of the canonical JSON of the PREVIOUS entry.\n * The genesis entry (index 0) has `prevHash === ''` — the first\n * entry in a fresh vault has nothing to point back to.\n */\n readonly prevHash: string\n\n /**\n * Which kind of mutation this entry records. only supports\n * data operations (`put`, `delete`, `amendment`). Access-control\n * operations (`grant`, `revoke`, `rotate`) will be added in a\n * follow-up once the keyring write path is instrumented — that's\n * tracked in the epic issue.\n *\n * `'amendment'` is the multi-record audit entry written by the\n * guards subsystem when an admin/owner uses `withTransactions(...)`\n * to repair a constraint-violating state. See `amendment` field\n * below for the structured payload.\n *\n * `'lifecycle'` records a non-data audit event (e.g. partition\n * handover) — `collection`/`id` are empty and the event detail\n * lives in `reason` (e.g. `'partition-handed-over:<sealId>'`). Like\n * `amendment`, it carries no data envelope, so `verifyBackupIntegrity`\n * skips it in the data cross-check (it still participates in the\n * tamper-evident chain).\n */\n readonly op: 'put' | 'delete' | 'amendment' | 'lifecycle' | 'migration'\n\n /** The collection the mutation targeted. */\n readonly collection: string\n\n /** The record id the mutation targeted. */\n readonly id: string\n\n /**\n * The record version AFTER this mutation. For `put` this is the\n * newly assigned version; for `delete` this is the version that\n * was deleted (the last version visible to reads).\n */\n readonly version: number\n\n /** ISO timestamp of the mutation. */\n readonly ts: string\n\n /** User id of the actor who performed the mutation. */\n readonly actor: string\n\n /**\n * Hex-encoded sha256 of the encrypted envelope's `_data` field.\n * For `put`, this is the hash of the new ciphertext. For `delete`,\n * it's the hash of the last visible ciphertext at deletion time,\n * or the empty string if nothing was there to delete. Hashing the\n * ciphertext (not the plaintext) preserves zero-knowledge — see\n * the file docstring.\n */\n readonly payloadHash: string\n\n /**\n * Optional human-readable tag describing why this mutation happened.\n * Threaded through `collection.put(_, _, { reason })`. Common\n * values include `'import:csv'`, `'import:json'`, `'import:xlsx'` from\n * `as-*` ImportPlan.apply(), but consumers can use any string for\n * domain-specific audit filtering. Auto-strip via `canonicalJson` —\n * absent on the wire, never serialized as `null`.\n *\n * Audit consumers filter: `entries.filter(e => e.reason?.startsWith('import:'))`.\n */\n readonly reason?: string\n\n /**\n * Optional hex-encoded sha256 of the encrypted JSON Patch delta\n * blob stored alongside this entry in `_ledger_deltas/`. Present\n * only for `put` operations that had a previous version — the\n * genesis put of a new record, and every `delete`, leave this\n * field undefined.\n *\n * The delta payload itself lives in a sibling internal collection\n * (`_ledger_deltas/<paddedIndex>`) and is encrypted with the\n * ledger DEK. Callers use `ledger.loadDelta(index)` to decrypt and\n * deserialize it when reconstructing a historical version.\n *\n * Why optional instead of always-present: the first put of a\n * record has no previous version to diff against, so storing an\n * empty patch would be noise. For deletes there's no \"next\" state\n * to describe with a delta. Both cases set this field to undefined.\n *\n * Note: the canonical-JSON hasher treats `undefined` as invalid\n * (it's one of the guard rails), so on the wire this field is\n * either `{ deltaHash: '<hex>' }` or absent from the JSON\n * entirely — never `{ deltaHash: undefined }`.\n */\n readonly deltaHash?: string\n\n /**\n * Present only when `op === 'amendment'`. Records the human reason,\n * the role of the actor, the (collection, id, vBefore, vAfter) tuple\n * for every record touched, and which guard invariants passed.\n *\n * See docs/superpowers/specs/2026-05-18-guards-design.md.\n */\n readonly amendment?: {\n readonly reason: string\n readonly role: 'admin' | 'owner'\n readonly changes: ReadonlyArray<{\n readonly collection: string\n readonly id: string\n readonly vBefore: number\n readonly vAfter: number\n }>\n readonly invariantsPassed: ReadonlyArray<string>\n }\n}\n\n/**\n * Canonical (sort-stable) JSON encoder.\n *\n * This function is the load-bearing primitive of the hash chain:\n * `sha256(canonicalJSON(entry))` must produce the same hex string\n * every time, on every machine, for the same logical entry — otherwise\n * `verify()` would return `{ ok: false }` on cross-platform reads.\n *\n * JavaScript's `JSON.stringify` is almost canonical, but NOT quite:\n * it preserves the insertion order of object keys, which means\n * `{a:1,b:2}` and `{b:2,a:1}` serialize differently. We fix this by\n * recursively walking objects and sorting their keys before\n * concatenation.\n *\n * Arrays keep their original order (reordering them would change\n * semantics). Numbers, strings, booleans, and `null` use the default\n * JSON encoding. `undefined` and functions are rejected — ledger\n * entries are plain data, and silently dropping `undefined` would\n * break the \"same input → same hash\" property if a caller forgot to\n * omit a field.\n *\n * Performance: one pass per nesting level; O(n log n) for key sorting\n * at each object. Entries are small (< 1 KB) so this is negligible\n * compared to the sha256 call.\n */\nexport function canonicalJson(value: unknown): string {\n if (value === null) return 'null'\n if (typeof value === 'boolean') return value ? 'true' : 'false'\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error(\n `canonicalJson: refusing to encode non-finite number ${String(value)}`,\n )\n }\n return JSON.stringify(value)\n }\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') {\n throw new Error('canonicalJson: BigInt is not JSON-serializable')\n }\n if (typeof value === 'undefined' || typeof value === 'function') {\n throw new Error(\n `canonicalJson: refusing to encode ${typeof value} — include all fields explicitly`,\n )\n }\n if (Array.isArray(value)) {\n return '[' + value.map((v) => canonicalJson(v)).join(',') + ']'\n }\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>\n const keys = Object.keys(obj).sort()\n const parts: string[] = []\n for (const key of keys) {\n parts.push(JSON.stringify(key) + ':' + canonicalJson(obj[key]))\n }\n return '{' + parts.join(',') + '}'\n }\n throw new Error(`canonicalJson: unexpected value type: ${typeof value}`)\n}\n\n/**\n * Compute a hex-encoded sha256 of a string via Web Crypto's subtle API.\n *\n * We use hex (not base64) for hashes because hex is case-insensitive,\n * fixed-length (64 chars), and easier to compare visually in debug\n * output. Base64 would save a few bytes in storage but every encrypted\n * ledger entry is already much larger than the hash itself.\n */\nexport async function sha256Hex(input: string): Promise<string> {\n const bytes = new TextEncoder().encode(input)\n const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes)\n return bytesToHex(new Uint8Array(digest))\n}\n\n/**\n * Compute the canonical hash of a ledger entry. Short wrapper around\n * `canonicalJson` + `sha256Hex`; callers use this instead of composing\n * the two functions every time, so any future change to the hashing\n * pipeline (e.g., adding a domain-separation prefix) lives in one place.\n */\nexport async function hashEntry(entry: LedgerEntry): Promise<string> {\n return sha256Hex(canonicalJson(entry))\n}\n\n/** Convert a Uint8Array to a lowercase hex string. */\nfunction bytesToHex(bytes: Uint8Array): string {\n const hex = new Array<string>(bytes.length)\n for (let i = 0; i < bytes.length; i++) {\n // Non-null assertion: indexing a Uint8Array within bounds always\n // returns a number, but the compiler's noUncheckedIndexedAccess\n // flag widens it to `number | undefined`. Safe here by construction.\n hex[i] = (bytes[i] ?? 0).toString(16).padStart(2, '0')\n }\n return hex.join('')\n}\n\n/**\n * Pad an index to the canonical 10-digit form used as the adapter key.\n * Ten digits is enough for ~10 billion ledger entries per vault\n * — far beyond any realistic use case, but cheap enough that the extra\n * digits don't hurt storage.\n */\nexport function paddedIndex(index: number): string {\n return String(index).padStart(10, '0')\n}\n\n/** Parse a padded adapter key back into a number. Returns NaN on malformed input. */\nexport function parseIndex(key: string): number {\n return Number.parseInt(key, 10)\n}\n","/**\n * Envelope payload hash — pinned in its own leaf module so consumers\n * (DictionaryHandle, the active history strategy) can import it\n * without dragging in the `LedgerStore` class.\n *\n * see `constants.ts` for the broader rationale.\n *\n * @internal\n */\n\nimport type { EncryptedEnvelope } from '../../types.js'\nimport { sha256Hex } from './entry.js'\n\n/**\n * Compute the `payloadHash` value for an encrypted envelope. Used by\n * `LedgerStore.append` for both put (hash the new envelope) and\n * delete (hash the previous envelope) paths, and by\n * `DictionaryHandle` so its ledger entries match the same contract.\n *\n * Returns the empty string when there is no envelope (delete of a\n * never-existed record). The empty string tolerated by the ledger\n * entry's `payloadHash` field as the canonical \"nothing here\" value.\n */\nexport async function envelopePayloadHash(\n envelope: EncryptedEnvelope | null,\n): Promise<string> {\n if (!envelope) return ''\n // `_data` is a base64 string for encrypted envelopes and the raw\n // JSON for plaintext ones. Both are strings, so a single sha256Hex\n // call works for both modes — the hash value differs between\n // encrypted/plaintext compartments because the bytes on disk\n // differ.\n return sha256Hex(envelope._data)\n}\n"],"mappings":";AA4MO,SAAS,cAAc,OAAwB;AACpD,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,UAAW,QAAO,QAAQ,SAAS;AACxD,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,YAAM,IAAI;AAAA,QACR,uDAAuD,OAAO,KAAK,CAAC;AAAA,MACtE;AAAA,IACF;AACA,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B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ACpB;AAQO,SAAS,YAAY,OAAuB;AACjD,SAAO,OAAO,KAAK,EAAE,SAAS,IAAI,GAAG;AACvC;AAGO,SAAS,WAAW,KAAqB;AAC9C,SAAO,OAAO,SAAS,KAAK,EAAE;AAChC;;;ACzQA,eAAsB,oBACpB,UACiB;AACjB,MAAI,CAAC,SAAU,QAAO;AAMtB,SAAO,UAAU,SAAS,KAAK;AACjC;","names":[]}
1
+ {"version":3,"sources":["../src/history/ledger/entry.ts","../src/history/ledger/hash.ts"],"sourcesContent":["/**\n * Ledger entry shape + canonical JSON + sha256 helpers.\n *\n * This file holds the PURE primitives used by the hash-chained ledger:\n * the entry type, the deterministic (sort-stable) JSON encoder, and\n * the sha256 hasher that produces `prevHash` and `ledger.head()`.\n *\n * Everything here is validator-free and side-effect free — the only\n * runtime dep is Web Crypto's `subtle.digest` for the sha256 call,\n * which we already use for every other hashing operation in the core.\n *\n * The hash chain property works like this:\n *\n * hash(entry[i]) = sha256(canonicalJSON(entry[i]))\n * entry[i+1].prevHash = hash(entry[i])\n *\n * Any modification to `entry[i]` (field values, field order, whitespace)\n * produces a different `hash(entry[i])`, which means `entry[i+1]`'s\n * stored `prevHash` no longer matches the recomputed hash, which means\n * `verify()` returns `{ ok: false, divergedAt: i + 1 }`. The chain is\n * append-only and tamper-evident without external anchoring.\n */\n\n/**\n * A single ledger entry in its plaintext form — what gets serialized,\n * hashed, and then encrypted with the ledger DEK before being written\n * to the `_ledger/` adapter collection.\n *\n * ## Why hash the ciphertext, not the plaintext?\n *\n * `payloadHash` is the sha256 of the record's ENCRYPTED envelope bytes,\n * not its plaintext. This matters:\n *\n * 1. **Zero-knowledge preserved.** A user (or a third party) can\n * verify the ledger against the stored envelopes without any\n * decryption keys. The adapter layer already holds only\n * ciphertext, so hashing the ciphertext keeps the ledger at the\n * same privacy level as the adapter.\n *\n * 2. **Determinism.** Plaintext → ciphertext is randomized by the\n * fresh per-write IV, so `hash(plaintext)` would need extra\n * normalization. `hash(ciphertext)` is already deterministic and\n * unique per write.\n *\n * 3. **Detection property.** If an attacker modifies even one byte of\n * the stored ciphertext (trying to flip a record), the hash\n * changes, the ledger's recorded `payloadHash` no longer matches,\n * and a data-integrity check fails. We don't do that check in\n * `verify()` today, but the\n * hook is there for a future `verifyIntegrity()` follow-up.\n *\n * Fields marked `op`, `collection`, `id`, `version`, `ts`, `actor` are\n * plaintext METADATA about the operation — NOT the record itself. The\n * entry is still encrypted at rest via the ledger DEK, but adapters\n * could theoretically infer operation patterns from the sizes and\n * timestamps. This is an accepted trade-off for the tamper-evidence\n * property; full ORAM-level privacy is out of scope for noy-db.\n */\nexport interface LedgerEntry {\n /**\n * Zero-based sequential position of this entry in the chain. The\n * canonical adapter key is this number zero-padded to 10 digits\n * (`\"0000000001\"`) so lexicographic ordering matches numeric order.\n */\n readonly index: number\n\n /**\n * Hex-encoded sha256 of the canonical JSON of the PREVIOUS entry.\n * The genesis entry (index 0) has `prevHash === ''` — the first\n * entry in a fresh vault has nothing to point back to.\n */\n readonly prevHash: string\n\n /**\n * Which kind of mutation this entry records. only supports\n * data operations (`put`, `delete`, `amendment`). Access-control\n * operations (`grant`, `revoke`, `rotate`) will be added in a\n * follow-up once the keyring write path is instrumented — that's\n * tracked in the epic issue.\n *\n * `'amendment'` is the multi-record audit entry written by the\n * guards subsystem when an admin/owner uses `withTransactions(...)`\n * to repair a constraint-violating state. See `amendment` field\n * below for the structured payload.\n *\n * `'lifecycle'` records a non-data audit event (e.g. partition\n * handover) — `collection`/`id` are empty and the event detail\n * lives in `reason` (e.g. `'partition-handed-over:<sealId>'`). Like\n * `amendment`, it carries no data envelope, so `verifyBackupIntegrity`\n * skips it in the data cross-check (it still participates in the\n * tamper-evident chain).\n *\n * `'forget'` is the single summary entry written by `vault.forget()`\n * (#304 GDPR crypto-shred). `collection`/`id` are empty and `version`\n * is 0 — a forget is not scoped to one record. `payloadHash` carries\n * `sha256Hex(subjectId)` so the ledger PROVES \"subject X existed and\n * was erased on date D\" without retaining the subject id or any\n * plaintext; `reason` holds a JSON summary of the shred counts. Like\n * `amendment`/`lifecycle` it carries no data envelope and is skipped\n * by the reconstruct walker (it still participates in the chain, so\n * `verify()` passes after a shred).\n */\n readonly op: 'put' | 'delete' | 'amendment' | 'lifecycle' | 'migration' | 'forget'\n\n /** The collection the mutation targeted. */\n readonly collection: string\n\n /** The record id the mutation targeted. */\n readonly id: string\n\n /**\n * The record version AFTER this mutation. For `put` this is the\n * newly assigned version; for `delete` this is the version that\n * was deleted (the last version visible to reads).\n */\n readonly version: number\n\n /** ISO timestamp of the mutation. */\n readonly ts: string\n\n /** User id of the actor who performed the mutation. */\n readonly actor: string\n\n /**\n * Hex-encoded sha256 of the encrypted envelope's `_data` field.\n * For `put`, this is the hash of the new ciphertext. For `delete`,\n * it's the hash of the last visible ciphertext at deletion time,\n * or the empty string if nothing was there to delete. Hashing the\n * ciphertext (not the plaintext) preserves zero-knowledge — see\n * the file docstring.\n */\n readonly payloadHash: string\n\n /**\n * Optional human-readable tag describing why this mutation happened.\n * Threaded through `collection.put(_, _, { reason })`. Common\n * values include `'import:csv'`, `'import:json'`, `'import:xlsx'` from\n * `as-*` ImportPlan.apply(), but consumers can use any string for\n * domain-specific audit filtering. Auto-strip via `canonicalJson` —\n * absent on the wire, never serialized as `null`.\n *\n * Audit consumers filter: `entries.filter(e => e.reason?.startsWith('import:'))`.\n */\n readonly reason?: string\n\n /**\n * Optional hex-encoded sha256 of the encrypted JSON Patch delta\n * blob stored alongside this entry in `_ledger_deltas/`. Present\n * only for `put` operations that had a previous version — the\n * genesis put of a new record, and every `delete`, leave this\n * field undefined.\n *\n * The delta payload itself lives in a sibling internal collection\n * (`_ledger_deltas/<paddedIndex>`) and is encrypted with the\n * ledger DEK. Callers use `ledger.loadDelta(index)` to decrypt and\n * deserialize it when reconstructing a historical version.\n *\n * Why optional instead of always-present: the first put of a\n * record has no previous version to diff against, so storing an\n * empty patch would be noise. For deletes there's no \"next\" state\n * to describe with a delta. Both cases set this field to undefined.\n *\n * Note: the canonical-JSON hasher treats `undefined` as invalid\n * (it's one of the guard rails), so on the wire this field is\n * either `{ deltaHash: '<hex>' }` or absent from the JSON\n * entirely — never `{ deltaHash: undefined }`.\n */\n readonly deltaHash?: string\n\n /**\n * Present only when `op === 'amendment'`. Records the human reason,\n * the role of the actor, the (collection, id, vBefore, vAfter) tuple\n * for every record touched, and which guard invariants passed.\n *\n * See docs/superpowers/specs/2026-05-18-guards-design.md.\n */\n readonly amendment?: {\n readonly reason: string\n readonly role: 'admin' | 'owner'\n readonly changes: ReadonlyArray<{\n readonly collection: string\n readonly id: string\n readonly vBefore: number\n readonly vAfter: number\n }>\n readonly invariantsPassed: ReadonlyArray<string>\n }\n}\n\n/**\n * Canonical (sort-stable) JSON encoder.\n *\n * This function is the load-bearing primitive of the hash chain:\n * `sha256(canonicalJSON(entry))` must produce the same hex string\n * every time, on every machine, for the same logical entry — otherwise\n * `verify()` would return `{ ok: false }` on cross-platform reads.\n *\n * JavaScript's `JSON.stringify` is almost canonical, but NOT quite:\n * it preserves the insertion order of object keys, which means\n * `{a:1,b:2}` and `{b:2,a:1}` serialize differently. We fix this by\n * recursively walking objects and sorting their keys before\n * concatenation.\n *\n * Arrays keep their original order (reordering them would change\n * semantics). Numbers, strings, booleans, and `null` use the default\n * JSON encoding. `undefined` and functions are rejected — ledger\n * entries are plain data, and silently dropping `undefined` would\n * break the \"same input → same hash\" property if a caller forgot to\n * omit a field.\n *\n * Performance: one pass per nesting level; O(n log n) for key sorting\n * at each object. Entries are small (< 1 KB) so this is negligible\n * compared to the sha256 call.\n */\nexport function canonicalJson(value: unknown): string {\n if (value === null) return 'null'\n if (typeof value === 'boolean') return value ? 'true' : 'false'\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error(\n `canonicalJson: refusing to encode non-finite number ${String(value)}`,\n )\n }\n return JSON.stringify(value)\n }\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') {\n throw new Error('canonicalJson: BigInt is not JSON-serializable')\n }\n if (typeof value === 'undefined' || typeof value === 'function') {\n throw new Error(\n `canonicalJson: refusing to encode ${typeof value} — include all fields explicitly`,\n )\n }\n if (Array.isArray(value)) {\n return '[' + value.map((v) => canonicalJson(v)).join(',') + ']'\n }\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>\n const keys = Object.keys(obj).sort()\n const parts: string[] = []\n for (const key of keys) {\n parts.push(JSON.stringify(key) + ':' + canonicalJson(obj[key]))\n }\n return '{' + parts.join(',') + '}'\n }\n throw new Error(`canonicalJson: unexpected value type: ${typeof value}`)\n}\n\n/**\n * Compute a hex-encoded sha256 of a string via Web Crypto's subtle API.\n *\n * We use hex (not base64) for hashes because hex is case-insensitive,\n * fixed-length (64 chars), and easier to compare visually in debug\n * output. Base64 would save a few bytes in storage but every encrypted\n * ledger entry is already much larger than the hash itself.\n */\nexport async function sha256Hex(input: string): Promise<string> {\n const bytes = new TextEncoder().encode(input)\n const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes)\n return bytesToHex(new Uint8Array(digest))\n}\n\n/**\n * Compute the canonical hash of a ledger entry. Short wrapper around\n * `canonicalJson` + `sha256Hex`; callers use this instead of composing\n * the two functions every time, so any future change to the hashing\n * pipeline (e.g., adding a domain-separation prefix) lives in one place.\n */\nexport async function hashEntry(entry: LedgerEntry): Promise<string> {\n return sha256Hex(canonicalJson(entry))\n}\n\n/** Convert a Uint8Array to a lowercase hex string. */\nfunction bytesToHex(bytes: Uint8Array): string {\n const hex = new Array<string>(bytes.length)\n for (let i = 0; i < bytes.length; i++) {\n // Non-null assertion: indexing a Uint8Array within bounds always\n // returns a number, but the compiler's noUncheckedIndexedAccess\n // flag widens it to `number | undefined`. Safe here by construction.\n hex[i] = (bytes[i] ?? 0).toString(16).padStart(2, '0')\n }\n return hex.join('')\n}\n\n/**\n * Pad an index to the canonical 10-digit form used as the adapter key.\n * Ten digits is enough for ~10 billion ledger entries per vault\n * — far beyond any realistic use case, but cheap enough that the extra\n * digits don't hurt storage.\n */\nexport function paddedIndex(index: number): string {\n return String(index).padStart(10, '0')\n}\n\n/** Parse a padded adapter key back into a number. Returns NaN on malformed input. */\nexport function parseIndex(key: string): number {\n return Number.parseInt(key, 10)\n}\n","/**\n * Envelope payload hash — pinned in its own leaf module so consumers\n * (DictionaryHandle, the active history strategy) can import it\n * without dragging in the `LedgerStore` class.\n *\n * see `constants.ts` for the broader rationale.\n *\n * @internal\n */\n\nimport type { EncryptedEnvelope } from '../../types.js'\nimport { sha256Hex } from './entry.js'\n\n/**\n * Compute the `payloadHash` value for an encrypted envelope. Used by\n * `LedgerStore.append` for both put (hash the new envelope) and\n * delete (hash the previous envelope) paths, and by\n * `DictionaryHandle` so its ledger entries match the same contract.\n *\n * Returns the empty string when there is no envelope (delete of a\n * never-existed record). The empty string tolerated by the ledger\n * entry's `payloadHash` field as the canonical \"nothing here\" value.\n */\nexport async function envelopePayloadHash(\n envelope: EncryptedEnvelope | null,\n): Promise<string> {\n if (!envelope) return ''\n // `_data` is a base64 string for encrypted envelopes and the raw\n // JSON for plaintext ones. Both are strings, so a single sha256Hex\n // call works for both modes — the hash value differs between\n // encrypted/plaintext compartments because the bytes on disk\n // differ.\n return sha256Hex(envelope._data)\n}\n"],"mappings":";AAsNO,SAAS,cAAc,OAAwB;AACpD,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,UAAW,QAAO,QAAQ,SAAS;AACxD,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,YAAM,IAAI;AAAA,QACR,uDAAuD,OAAO,KAAK,CAAC;AAAA,MACtE;AAAA,IACF;AACA,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B;AACA,MAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,KAAK;AAC1D,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,MAAI,OAAO,UAAU,eAAe,O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,eAAsB,oBACpB,UACiB;AACjB,MAAI,CAAC,SAAU,QAAO;AAMtB,SAAO,UAAU,SAAS,KAAK;AACjC;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  dekKey
3
- } from "./chunk-4TBBMHVC.js";
3
+ } from "./chunk-5LIROIDM.js";
4
4
  import {
5
5
  assertStrongPassphrase,
6
6
  mintKeyringCanary,
7
7
  persistKeyring
8
- } from "./chunk-6H2ZUNR7.js";
8
+ } from "./chunk-BSZOCSDZ.js";
9
9
  import {
10
10
  NOYDB_FORMAT_VERSION,
11
11
  NOYDB_KEYRING_VERSION
12
- } from "./chunk-F3BPIPLS.js";
12
+ } from "./chunk-SISBMAPO.js";
13
13
  import {
14
14
  base64ToBuffer,
15
15
  bufferToBase64,
@@ -19,7 +19,7 @@ import {
19
19
  generateSalt,
20
20
  unwrapKey,
21
21
  wrapKey
22
- } from "./chunk-YULZKK4F.js";
22
+ } from "./chunk-UNTGHX5A.js";
23
23
  import {
24
24
  DelegationTargetMissingError,
25
25
  InvalidKeyError,
@@ -28,7 +28,7 @@ import {
28
28
  PermissionDeniedError,
29
29
  PrivilegeEscalationError,
30
30
  ValidationError
31
- } from "./chunk-535SSHBS.js";
31
+ } from "./chunk-ZEGSDPB7.js";
32
32
 
33
33
  // src/team/authenticators.ts
34
34
  async function enrollAuthenticator(store, vault, keyring, options) {
@@ -827,4 +827,4 @@ export {
827
827
  magicLinkGrantRecordId,
828
828
  isMagicLinkGrantExpired
829
829
  };
830
- //# sourceMappingURL=chunk-DLZ2ONOD.js.map
830
+ //# sourceMappingURL=chunk-QHM6XEAH.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  wrapDbWithPredicates
3
- } from "./chunk-G4SCICH5.js";
3
+ } from "./chunk-2FU2FTXD.js";
4
4
  import {
5
5
  canonicalGroupKey,
6
6
  groupAndReduce
7
- } from "./chunk-L2BNJ6HM.js";
7
+ } from "./chunk-7H2GEJ3O.js";
8
8
  import {
9
9
  MaterializedViewTooLargeError
10
- } from "./chunk-535SSHBS.js";
10
+ } from "./chunk-ZEGSDPB7.js";
11
11
 
12
12
  // src/materialized-views/executor.ts
13
13
  var DEFAULT_MAX_ROWS = 1e5;
@@ -150,4 +150,4 @@ async function listOutputIds(outputColl) {
150
150
  export {
151
151
  MaterializedViewExecutor
152
152
  };
153
- //# sourceMappingURL=chunk-HBXJ37ZY.js.map
153
+ //# sourceMappingURL=chunk-QO6RGLLD.js.map
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  ensureCollectionDEK
3
- } from "./chunk-6H2ZUNR7.js";
3
+ } from "./chunk-BSZOCSDZ.js";
4
4
  import {
5
5
  envelopePayloadHash
6
- } from "./chunk-Z6FNBOTC.js";
6
+ } from "./chunk-PDVP3C2I.js";
7
7
  import {
8
8
  NOYDB_FORMAT_VERSION
9
- } from "./chunk-F3BPIPLS.js";
9
+ } from "./chunk-SISBMAPO.js";
10
10
  import {
11
11
  decrypt,
12
12
  encrypt
13
- } from "./chunk-YULZKK4F.js";
13
+ } from "./chunk-UNTGHX5A.js";
14
14
  import {
15
15
  DictKeyMissingError,
16
16
  LocaleNotSpecifiedError,
17
17
  MissingTranslationError,
18
18
  PermissionDeniedError
19
- } from "./chunk-535SSHBS.js";
19
+ } from "./chunk-ZEGSDPB7.js";
20
20
 
21
21
  // src/i18n/policy.ts
22
22
  function resolvePolicy(onMissing, layer) {
@@ -233,6 +233,21 @@ function dictKey(name, keys, opts) {
233
233
  function isDictKeyDescriptor(x) {
234
234
  return typeof x === "object" && x !== null && x._noydbDictKey === true;
235
235
  }
236
+ function staticDict(name, table, opts) {
237
+ return {
238
+ _noydbStaticDict: true,
239
+ name,
240
+ table,
241
+ keys: Object.keys(table),
242
+ ...opts?.displayLocale !== void 0 ? { displayLocale: opts.displayLocale } : {},
243
+ ...opts?.onMissing !== void 0 ? { onMissing: opts.onMissing } : {},
244
+ ...opts?.substitute !== void 0 ? { substitute: opts.substitute } : {},
245
+ ...opts?.validateCodes !== void 0 ? { validateCodes: opts.validateCodes } : {}
246
+ };
247
+ }
248
+ function isStaticDictDescriptor(x) {
249
+ return typeof x === "object" && x !== null && x._noydbStaticDict === true;
250
+ }
236
251
  var DictionaryHandle = class {
237
252
  constructor(adapter, compartmentName, dictionaryName, keyring, getDEK, encrypted, ledger, options, findAndUpdateReferences, emitter) {
238
253
  this.adapter = adapter;
@@ -584,6 +599,8 @@ export {
584
599
  isDictCollectionName,
585
600
  dictKey,
586
601
  isDictKeyDescriptor,
602
+ staticDict,
603
+ isStaticDictDescriptor,
587
604
  DictionaryHandle
588
605
  };
589
- //# sourceMappingURL=chunk-7BQ4QWYX.js.map
606
+ //# sourceMappingURL=chunk-ROPJVUG3.js.map