@noy-db/hub 0.6.0-pre.17 → 0.6.0-pre.19

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 (426) hide show
  1. package/dist/api-Z5VHH24A.js +20 -0
  2. package/dist/attestation/index.js +18 -18
  3. package/dist/{backup-7X3PFTSI.js → backup-K62BFMYK.js} +16 -16
  4. package/dist/{backup-7X3PFTSI.js.map → backup-K62BFMYK.js.map} +1 -1
  5. package/dist/blobs/index.js +13 -13
  6. package/dist/broker/index.js +12 -12
  7. package/dist/cargo/index.js +32 -32
  8. package/dist/{chunk-5SK5AFYH.js → chunk-2E2MKBMI.js} +2 -2
  9. package/dist/{chunk-SDEHNGWW.js → chunk-2IK6AC6A.js} +7 -6
  10. package/dist/{chunk-SDEHNGWW.js.map → chunk-2IK6AC6A.js.map} +1 -1
  11. package/dist/{chunk-7TZTQS4H.js → chunk-32O2N2CH.js} +48 -21
  12. package/dist/chunk-32O2N2CH.js.map +1 -0
  13. package/dist/{chunk-QKRJUPAC.js → chunk-37P5VB4N.js} +13 -16
  14. package/dist/chunk-37P5VB4N.js.map +1 -0
  15. package/dist/{chunk-5UGEGEIJ.js → chunk-3Y4OFWQJ.js} +1 -1
  16. package/dist/chunk-3Y4OFWQJ.js.map +1 -0
  17. package/dist/{chunk-7LLKPODL.js → chunk-437FDIHO.js} +3 -3
  18. package/dist/{chunk-AMKCY454.js → chunk-47ZFULEZ.js} +8 -3
  19. package/dist/{chunk-AMKCY454.js.map → chunk-47ZFULEZ.js.map} +1 -1
  20. package/dist/{chunk-4GR422R5.js → chunk-4HVTRHSA.js} +16 -9
  21. package/dist/chunk-4HVTRHSA.js.map +1 -0
  22. package/dist/{chunk-VEA35MQP.js → chunk-5BS6IQZZ.js} +11 -14
  23. package/dist/chunk-5BS6IQZZ.js.map +1 -0
  24. package/dist/{chunk-QWNYUTI2.js → chunk-5EJQNA26.js} +2 -2
  25. package/dist/{chunk-C66T4W5P.js → chunk-5J5TTSGW.js} +3 -3
  26. package/dist/{chunk-JHYISAID.js → chunk-5JT4Y5UE.js} +10 -10
  27. package/dist/{chunk-VUQZYVYX.js → chunk-6S466CMQ.js} +92 -35
  28. package/dist/chunk-6S466CMQ.js.map +1 -0
  29. package/dist/{chunk-IRHOQFA7.js → chunk-7RCZ436O.js} +2 -2
  30. package/dist/{chunk-42IDLU5V.js → chunk-A3NTKHDB.js} +2 -2
  31. package/dist/{chunk-3JQVA527.js → chunk-A4K5GLE6.js} +4 -4
  32. package/dist/{chunk-K2MR7ROB.js → chunk-APV42WPR.js} +2 -2
  33. package/dist/{chunk-MVG67SMN.js → chunk-AQF7JSQR.js} +2 -2
  34. package/dist/{chunk-VTTRWLOR.js → chunk-BP4I7IBK.js} +2 -2
  35. package/dist/{chunk-T7AEAFEE.js → chunk-BTNKPDZM.js} +3 -3
  36. package/dist/{chunk-PCXAUC65.js → chunk-C7WJNVJG.js} +2 -2
  37. package/dist/{chunk-UNR6G3EJ.js → chunk-CV7WXCZD.js} +37 -33
  38. package/dist/chunk-CV7WXCZD.js.map +1 -0
  39. package/dist/{chunk-67XA44HH.js → chunk-CVYXIN5B.js} +3 -3
  40. package/dist/{chunk-BKYQNNO3.js → chunk-D5UDZANO.js} +203 -137
  41. package/dist/chunk-D5UDZANO.js.map +1 -0
  42. package/dist/{chunk-HVR74IBG.js → chunk-DJ23QZIN.js} +2 -2
  43. package/dist/{chunk-BMDF4TLU.js → chunk-DKYEVHZH.js} +7 -10
  44. package/dist/chunk-DKYEVHZH.js.map +1 -0
  45. package/dist/{chunk-N7HOHWKF.js → chunk-DYASJSKI.js} +8 -11
  46. package/dist/{chunk-N7HOHWKF.js.map → chunk-DYASJSKI.js.map} +1 -1
  47. package/dist/{chunk-OAWVM5L6.js → chunk-E6VDPBE3.js} +13 -15
  48. package/dist/chunk-E6VDPBE3.js.map +1 -0
  49. package/dist/{chunk-WBHQX6ME.js → chunk-E6WANBD6.js} +14 -15
  50. package/dist/chunk-E6WANBD6.js.map +1 -0
  51. package/dist/{chunk-VQQUOEON.js → chunk-EG6AQBYW.js} +10 -10
  52. package/dist/{chunk-GWI65NDQ.js → chunk-EJIVFOOQ.js} +6 -6
  53. package/dist/{chunk-YGJZLOSR.js → chunk-GDGTIWB4.js} +2 -2
  54. package/dist/{chunk-TQ7IRULX.js → chunk-GILI76SU.js} +2 -2
  55. package/dist/{chunk-4444HN72.js → chunk-GT72D4FO.js} +3 -3
  56. package/dist/{chunk-OXRPH6AR.js → chunk-GYUCRDAU.js} +15 -12
  57. package/dist/chunk-GYUCRDAU.js.map +1 -0
  58. package/dist/{chunk-JV2CNEX2.js → chunk-HGAR7H5M.js} +239 -188
  59. package/dist/chunk-HGAR7H5M.js.map +1 -0
  60. package/dist/{chunk-SGEI3IJK.js → chunk-HGJC7I5F.js} +2 -2
  61. package/dist/{chunk-C52CJDFO.js → chunk-HJRTFXAA.js} +7 -10
  62. package/dist/chunk-HJRTFXAA.js.map +1 -0
  63. package/dist/chunk-HK67PX4J.js +27 -0
  64. package/dist/chunk-HK67PX4J.js.map +1 -0
  65. package/dist/{chunk-V4M4BZNW.js → chunk-HTHRCGWP.js} +2 -2
  66. package/dist/{chunk-YVOW35HH.js → chunk-HTMQBBF3.js} +5 -7
  67. package/dist/chunk-HTMQBBF3.js.map +1 -0
  68. package/dist/{chunk-QC2HGYFX.js → chunk-HUYNPLTT.js} +4 -4
  69. package/dist/{chunk-APUP2J5M.js → chunk-I26TE27S.js} +7 -7
  70. package/dist/{chunk-DEP24EE3.js → chunk-ICCRAPWD.js} +4 -4
  71. package/dist/{chunk-ES36R3U2.js → chunk-IOURTXTM.js} +52 -65
  72. package/dist/chunk-IOURTXTM.js.map +1 -0
  73. package/dist/{chunk-JU3JKOY5.js → chunk-IPDS2TYW.js} +3 -3
  74. package/dist/{chunk-QJBXB4WU.js → chunk-JHO6FGZX.js} +25 -31
  75. package/dist/chunk-JHO6FGZX.js.map +1 -0
  76. package/dist/{chunk-YDJXGYYA.js → chunk-JIF3IBRK.js} +2 -2
  77. package/dist/{chunk-S6CP5FWF.js → chunk-KBOPY6W2.js} +2 -2
  78. package/dist/{chunk-RVTOCAHQ.js → chunk-KDX6VEYV.js} +2 -2
  79. package/dist/chunk-KDX6VEYV.js.map +1 -0
  80. package/dist/{chunk-H545OIWE.js → chunk-KM6YR5XF.js} +2 -2
  81. package/dist/{chunk-AFSMT3WI.js → chunk-KUXTWVAR.js} +3 -3
  82. package/dist/{chunk-466KGOQB.js → chunk-L2XQ776M.js} +2 -2
  83. package/dist/{chunk-QI2KXQOM.js → chunk-L6FSZFG7.js} +2 -2
  84. package/dist/{chunk-EEBMKMA7.js → chunk-LAFP5H5U.js} +35 -47
  85. package/dist/chunk-LAFP5H5U.js.map +1 -0
  86. package/dist/{chunk-I7JF5TNL.js → chunk-LBDTQM3R.js} +3 -3
  87. package/dist/{chunk-V3OLO4TK.js → chunk-M4IKEOJS.js} +20 -17
  88. package/dist/chunk-M4IKEOJS.js.map +1 -0
  89. package/dist/{chunk-5NKSNW25.js → chunk-MNMYHZVU.js} +2 -2
  90. package/dist/{chunk-IEA3TZJE.js → chunk-MNUTPZRQ.js} +31 -49
  91. package/dist/chunk-MNUTPZRQ.js.map +1 -0
  92. package/dist/{chunk-Z2OFE6IX.js → chunk-MQXYR65M.js} +15 -24
  93. package/dist/chunk-MQXYR65M.js.map +1 -0
  94. package/dist/{chunk-5VVBZ6E4.js → chunk-N2HKBESK.js} +4 -4
  95. package/dist/{chunk-HNOBRU24.js → chunk-N7YAQKAO.js} +2 -2
  96. package/dist/{chunk-6U7M7AX6.js → chunk-NH2MST6J.js} +2 -2
  97. package/dist/{chunk-JAHIL6WO.js → chunk-NRNTXBHT.js} +7 -10
  98. package/dist/chunk-NRNTXBHT.js.map +1 -0
  99. package/dist/{chunk-URVL4EKU.js → chunk-NYSD43OE.js} +15 -24
  100. package/dist/chunk-NYSD43OE.js.map +1 -0
  101. package/dist/{chunk-LUFZPROB.js → chunk-ODVIFBAQ.js} +16 -17
  102. package/dist/chunk-ODVIFBAQ.js.map +1 -0
  103. package/dist/{chunk-SJOK23XT.js → chunk-OIIAXFKM.js} +4 -4
  104. package/dist/chunk-OIIAXFKM.js.map +1 -0
  105. package/dist/{chunk-FSZPQCDR.js → chunk-OQLYMBJI.js} +3 -3
  106. package/dist/{chunk-EMFFWSAD.js → chunk-OWGEHDT2.js} +10 -10
  107. package/dist/chunk-OWGEHDT2.js.map +1 -0
  108. package/dist/{chunk-I64WQSN3.js → chunk-P7L3OQLL.js} +19 -2
  109. package/dist/chunk-P7L3OQLL.js.map +1 -0
  110. package/dist/{chunk-FZ2SSI5R.js → chunk-PG6PFMDC.js} +2 -2
  111. package/dist/{chunk-2RGQNFJB.js → chunk-PZSS7MUM.js} +11 -9
  112. package/dist/chunk-PZSS7MUM.js.map +1 -0
  113. package/dist/{chunk-UKKBKEUI.js → chunk-QPIUFRUC.js} +3 -3
  114. package/dist/{chunk-RJTGXZT6.js → chunk-REL4OLWW.js} +2 -2
  115. package/dist/{chunk-N4GAJSRQ.js → chunk-RNSC2ARR.js} +3 -3
  116. package/dist/{chunk-RWPNRCK2.js → chunk-RORE2GX2.js} +2 -2
  117. package/dist/{chunk-YH65A6WM.js → chunk-RSFG7XHM.js} +2 -2
  118. package/dist/{chunk-QLMUW7OC.js → chunk-S55DBWRC.js} +2 -2
  119. package/dist/{chunk-AKFNLRA2.js → chunk-SA77BQ7F.js} +27 -143
  120. package/dist/chunk-SA77BQ7F.js.map +1 -0
  121. package/dist/{chunk-RBTZLXZJ.js → chunk-SFD2LL7G.js} +2 -2
  122. package/dist/{chunk-XTC5EKST.js → chunk-SG3OQCRG.js} +3 -3
  123. package/dist/{chunk-JN64WH3U.js → chunk-T7IR4N2S.js} +1 -1
  124. package/dist/{chunk-JN64WH3U.js.map → chunk-T7IR4N2S.js.map} +1 -1
  125. package/dist/{chunk-P5ARVLNW.js → chunk-TC6MBEGH.js} +11 -8
  126. package/dist/chunk-TC6MBEGH.js.map +1 -0
  127. package/dist/{chunk-D6E5N2O3.js → chunk-TENLCGYD.js} +12 -10
  128. package/dist/{chunk-D6E5N2O3.js.map → chunk-TENLCGYD.js.map} +1 -1
  129. package/dist/{chunk-X2FXEEQT.js → chunk-VH2W6BOG.js} +7 -7
  130. package/dist/{chunk-FHFMWYGM.js → chunk-VHVMJWM6.js} +7 -7
  131. package/dist/{chunk-FHFMWYGM.js.map → chunk-VHVMJWM6.js.map} +1 -1
  132. package/dist/{chunk-QTDAPDDV.js → chunk-VJ4B3ZXY.js} +15 -3
  133. package/dist/chunk-VJ4B3ZXY.js.map +1 -0
  134. package/dist/{chunk-RDPZMUCX.js → chunk-W6NFONOV.js} +2 -2
  135. package/dist/{chunk-Z3U2YVNM.js → chunk-WBNXZU42.js} +4 -4
  136. package/dist/{chunk-7EIPPOEL.js → chunk-WKD5ESK4.js} +2 -2
  137. package/dist/{chunk-6VAM5THN.js → chunk-YEZW6UJA.js} +15 -15
  138. package/dist/{chunk-6VAM5THN.js.map → chunk-YEZW6UJA.js.map} +1 -1
  139. package/dist/chunk-YOT7D63X.js +190 -0
  140. package/dist/chunk-YOT7D63X.js.map +1 -0
  141. package/dist/{chunk-6JRIYG2C.js → chunk-YVTADFTC.js} +14 -15
  142. package/dist/chunk-YVTADFTC.js.map +1 -0
  143. package/dist/{chunk-C3YP5KKS.js → chunk-ZBDWKPBW.js} +15 -16
  144. package/dist/chunk-ZBDWKPBW.js.map +1 -0
  145. package/dist/{chunk-NWPR2V5W.js → chunk-ZPMXYPBR.js} +2 -2
  146. package/dist/{chunk-RGPB25DB.js → chunk-ZVAFJQZB.js} +25 -19
  147. package/dist/chunk-ZVAFJQZB.js.map +1 -0
  148. package/dist/{chunk-TQLYMYOK.js → chunk-ZWKF3CD3.js} +2 -2
  149. package/dist/classified/index.js +5 -5
  150. package/dist/{classified-marker-W2PUYC3K.js → classified-marker-PMDG3O36.js} +3 -3
  151. package/dist/collection-facade-ZJK5EB33.js +45 -0
  152. package/dist/{computed-5E2OM6EN.js → computed-UHCBRILW.js} +3 -3
  153. package/dist/consent/index.js +9 -9
  154. package/dist/cover/index.js +10 -3
  155. package/dist/custody/index.js +11 -11
  156. package/dist/{dead-filter-MVFQCLXY.js → dead-filter-777VWDER.js} +2 -2
  157. package/dist/debug/index.js +1 -1
  158. package/dist/{delegation-I7XXO5LL.js → delegation-4R5DU23X.js} +23 -24
  159. package/dist/delegation-4R5DU23X.js.map +1 -0
  160. package/dist/derivations/index.js +12 -12
  161. package/dist/derive-3WAS2G5T.js +22 -0
  162. package/dist/directory/index.js +10 -10
  163. package/dist/{dispatch-PY5RUHJF.js → dispatch-3EN6YCCS.js} +18 -18
  164. package/dist/{dispatch-K3MDLCXG.js → dispatch-ASL257KG.js} +5 -5
  165. package/dist/{enclave-77K7UDLS.js → enclave-ZJS5R5RH.js} +17 -9
  166. package/dist/executor-GPM6DNWV.js +9 -0
  167. package/dist/executor-LJSMZ4IB.js +9 -0
  168. package/dist/executor-SHUVRZUJ.js +29 -0
  169. package/dist/export-accessible-GNY6DC6U.js +23 -0
  170. package/dist/extract-partition-BG3AF4NZ.js +38 -0
  171. package/dist/{fanout-sidecar-JI3MUPQV.js → fanout-sidecar-TFPWDOME.js} +18 -27
  172. package/dist/fanout-sidecar-TFPWDOME.js.map +1 -0
  173. package/dist/find-KX6OKHDP.js +11 -0
  174. package/dist/forget/index.js +9 -9
  175. package/dist/guards/index.js +4 -4
  176. package/dist/history/index.js +23 -20
  177. package/dist/history/index.js.map +1 -1
  178. package/dist/i18n/index.js +14 -14
  179. package/dist/index.d.ts +16 -0
  180. package/dist/index.js +156 -154
  181. package/dist/index.js.map +1 -1
  182. package/dist/indexing/index.js +2 -2
  183. package/dist/introspection/index.js +11 -11
  184. package/dist/issue-PAUM7NCX.js +19 -0
  185. package/dist/kernel/enclave/index.d.ts +6 -5
  186. package/dist/kernel/enclave/record-aad.d.ts +79 -7
  187. package/dist/kernel/enclave/record-envelope.d.ts +54 -7
  188. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  189. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  190. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  191. package/dist/kernel/enclave/record-keys/rekey.d.ts +8 -2
  192. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -3
  193. package/dist/kernel/errors.d.ts +17 -1
  194. package/dist/kernel/merge-authority.d.ts +25 -0
  195. package/dist/kernel/tier-visibility.d.ts +15 -0
  196. package/dist/kernel/types.d.ts +8 -0
  197. package/dist/kernel/vault.d.ts +1 -1
  198. package/dist/kernel/via/index.d.ts +11 -2
  199. package/dist/{ledger-3RDSSMGD.js → ledger-62CEPRPX.js} +11 -11
  200. package/dist/liberate-7QY7TULB.js +24 -0
  201. package/dist/{link-set-VJIWWUZO.js → link-set-ZRYNUHN3.js} +11 -11
  202. package/dist/{managed-secret-XGGJ3BC3.js → managed-secret-T2WB4O47.js} +11 -3
  203. package/dist/materialized-views/index.js +22 -22
  204. package/dist/money/index.js +4 -4
  205. package/dist/noydb-VZIVPDXG.js +84 -0
  206. package/dist/overlay-views/index.js +4 -4
  207. package/dist/periods/index.js +12 -12
  208. package/dist/pod/index.js +58 -57
  209. package/dist/{pod-handle-7BVSWP5B.js → pod-handle-UPLXOGIK.js} +11 -11
  210. package/dist/{pod-handle-7BVSWP5B.js.map → pod-handle-UPLXOGIK.js.map} +1 -1
  211. package/dist/policy/index.js +11 -4
  212. package/dist/port/with/merge-authority.d.ts +52 -0
  213. package/dist/port/with/strategies.d.ts +2 -0
  214. package/dist/portability/index.js +8 -8
  215. package/dist/{post-register-W3T4U57K.js → post-register-J4DEVNXK.js} +6 -6
  216. package/dist/query/index.js +3 -3
  217. package/dist/reduce/index.js +4 -4
  218. package/dist/register-UPD4GKBC.js +32 -0
  219. package/dist/registry-7KX2HWFS.js +18 -0
  220. package/dist/registry-PKYYEHEW.js +9 -0
  221. package/dist/registry-XHCYMD34.js +19 -0
  222. package/dist/registry-XIRTZHPC.js +9 -0
  223. package/dist/request-withdrawal-XZSESWZV.js +31 -0
  224. package/dist/{reveal-G7W7N3AZ.js → reveal-525XWQU2.js} +6 -6
  225. package/dist/revoke-QI7YHQ2B.js +24 -0
  226. package/dist/satellites/index.js +1 -1
  227. package/dist/schema-update/index.js +2 -2
  228. package/dist/sealed-record/index.js +20 -13
  229. package/dist/sealed-record/index.js.map +1 -1
  230. package/dist/search/index.js +4 -4
  231. package/dist/{seed-2FUULTQV.js → seed-2KZDTFS4.js} +19 -22
  232. package/dist/seed-2KZDTFS4.js.map +1 -0
  233. package/dist/sequence/index.js +9 -9
  234. package/dist/session/index.js +9 -9
  235. package/dist/shadow/index.js +2 -2
  236. package/dist/signer-BZWDPGGN.js +25 -0
  237. package/dist/snapshots/index.js +10 -10
  238. package/dist/{stale-42FPALK2.js → stale-PQYPVCER.js} +10 -10
  239. package/dist/storage-MJHKNQRO.js +23 -0
  240. package/dist/{store-coordination-provider-Y3VXBHPL.js → store-coordination-provider-TFHZLKHG.js} +18 -12
  241. package/dist/store-coordination-provider-TFHZLKHG.js.map +1 -0
  242. package/dist/sync/index.js +11 -11
  243. package/dist/team/index.js +15 -14
  244. package/dist/tiers/index.js +11 -10
  245. package/dist/to/index.js +1 -1
  246. package/dist/transactions/index.js +3 -3
  247. package/dist/util/index.js +1 -1
  248. package/dist/vault-head/index.js +111 -0
  249. package/dist/vault-head/index.js.map +1 -0
  250. package/dist/{verify-SHJXGZGM.js → verify-J6DEOXP3.js} +5 -5
  251. package/dist/walk-BX4NSB5L.js +21 -0
  252. package/dist/with-audit/periods/periods.d.ts +1 -1
  253. package/dist/with-audit/periods/strategy.d.ts +1 -1
  254. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  255. package/dist/with-audit/tiers/index.d.ts +17 -2
  256. package/dist/with-commit/history/history.d.ts +26 -0
  257. package/dist/with-commit/history/index.d.ts +2 -1
  258. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  259. package/dist/with-commit/history/strategy.d.ts +11 -1
  260. package/dist/with-commit/vault-head/active.d.ts +2 -0
  261. package/dist/with-commit/vault-head/head.d.ts +28 -0
  262. package/dist/with-commit/vault-head/index.d.ts +10 -0
  263. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  264. package/dist/with-commit/vault-head/verify.d.ts +50 -0
  265. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  266. package/dist/with-party/directory/storage.d.ts +0 -11
  267. package/dist/with-party/directory/visibility.d.ts +0 -21
  268. package/dist/with-party/policy/storage.d.ts +0 -10
  269. package/dist/with-party/team/tiers.d.ts +2 -1
  270. package/dist/with-sync/engine.d.ts +33 -5
  271. package/dist/with-sync/strategy.d.ts +3 -0
  272. package/dist/withdraw-accessible-K4CPMH4C.js +28 -0
  273. package/package.json +7 -3
  274. package/dist/api-AEIN3KAQ.js +0 -20
  275. package/dist/chunk-2RGQNFJB.js.map +0 -1
  276. package/dist/chunk-4GR422R5.js.map +0 -1
  277. package/dist/chunk-5UGEGEIJ.js.map +0 -1
  278. package/dist/chunk-6JRIYG2C.js.map +0 -1
  279. package/dist/chunk-7TZTQS4H.js.map +0 -1
  280. package/dist/chunk-AFHQATY4.js +0 -47
  281. package/dist/chunk-AFHQATY4.js.map +0 -1
  282. package/dist/chunk-AKFNLRA2.js.map +0 -1
  283. package/dist/chunk-BKYQNNO3.js.map +0 -1
  284. package/dist/chunk-BMDF4TLU.js.map +0 -1
  285. package/dist/chunk-C3YP5KKS.js.map +0 -1
  286. package/dist/chunk-C52CJDFO.js.map +0 -1
  287. package/dist/chunk-EEBMKMA7.js.map +0 -1
  288. package/dist/chunk-EMFFWSAD.js.map +0 -1
  289. package/dist/chunk-ES36R3U2.js.map +0 -1
  290. package/dist/chunk-I64WQSN3.js.map +0 -1
  291. package/dist/chunk-IEA3TZJE.js.map +0 -1
  292. package/dist/chunk-JAHIL6WO.js.map +0 -1
  293. package/dist/chunk-JV2CNEX2.js.map +0 -1
  294. package/dist/chunk-LUFZPROB.js.map +0 -1
  295. package/dist/chunk-OAWVM5L6.js.map +0 -1
  296. package/dist/chunk-OXRPH6AR.js.map +0 -1
  297. package/dist/chunk-P5ARVLNW.js.map +0 -1
  298. package/dist/chunk-QJBXB4WU.js.map +0 -1
  299. package/dist/chunk-QKRJUPAC.js.map +0 -1
  300. package/dist/chunk-QTDAPDDV.js.map +0 -1
  301. package/dist/chunk-RGPB25DB.js.map +0 -1
  302. package/dist/chunk-RVTOCAHQ.js.map +0 -1
  303. package/dist/chunk-SJOK23XT.js.map +0 -1
  304. package/dist/chunk-UNR6G3EJ.js.map +0 -1
  305. package/dist/chunk-URVL4EKU.js.map +0 -1
  306. package/dist/chunk-V3OLO4TK.js.map +0 -1
  307. package/dist/chunk-VEA35MQP.js.map +0 -1
  308. package/dist/chunk-VUQZYVYX.js.map +0 -1
  309. package/dist/chunk-WBHQX6ME.js.map +0 -1
  310. package/dist/chunk-YVOW35HH.js.map +0 -1
  311. package/dist/chunk-Z2OFE6IX.js.map +0 -1
  312. package/dist/collection-facade-CRXN72DU.js +0 -45
  313. package/dist/delegation-I7XXO5LL.js.map +0 -1
  314. package/dist/derive-NL7X2EFT.js +0 -22
  315. package/dist/executor-FNGVGDW3.js +0 -29
  316. package/dist/executor-PCZN2LTY.js +0 -9
  317. package/dist/executor-WFTHIDT7.js +0 -9
  318. package/dist/export-accessible-QWUYY2OY.js +0 -23
  319. package/dist/extract-partition-CGCURVS4.js +0 -38
  320. package/dist/fanout-sidecar-JI3MUPQV.js.map +0 -1
  321. package/dist/find-VBNMB42N.js +0 -11
  322. package/dist/issue-7IPUNAFA.js +0 -19
  323. package/dist/liberate-2DNJ7AJ7.js +0 -24
  324. package/dist/noydb-CLQP36JR.js +0 -83
  325. package/dist/register-YUVC4G27.js +0 -32
  326. package/dist/registry-BPKJX562.js +0 -19
  327. package/dist/registry-E4FM32KD.js +0 -9
  328. package/dist/registry-HACMULJJ.js +0 -9
  329. package/dist/registry-HRFRBFDV.js +0 -18
  330. package/dist/request-withdrawal-CXTQLMJK.js +0 -31
  331. package/dist/revoke-ZX3TZUI6.js +0 -24
  332. package/dist/seed-2FUULTQV.js.map +0 -1
  333. package/dist/signer-FPUIX63Z.js +0 -25
  334. package/dist/storage-6QODT6K5.js +0 -23
  335. package/dist/store-coordination-provider-Y3VXBHPL.js.map +0 -1
  336. package/dist/walk-5PGJI3ND.js +0 -21
  337. package/dist/withdraw-accessible-PFCQQGNP.js +0 -28
  338. /package/dist/{api-AEIN3KAQ.js.map → api-Z5VHH24A.js.map} +0 -0
  339. /package/dist/{chunk-5SK5AFYH.js.map → chunk-2E2MKBMI.js.map} +0 -0
  340. /package/dist/{chunk-7LLKPODL.js.map → chunk-437FDIHO.js.map} +0 -0
  341. /package/dist/{chunk-QWNYUTI2.js.map → chunk-5EJQNA26.js.map} +0 -0
  342. /package/dist/{chunk-C66T4W5P.js.map → chunk-5J5TTSGW.js.map} +0 -0
  343. /package/dist/{chunk-JHYISAID.js.map → chunk-5JT4Y5UE.js.map} +0 -0
  344. /package/dist/{chunk-IRHOQFA7.js.map → chunk-7RCZ436O.js.map} +0 -0
  345. /package/dist/{chunk-42IDLU5V.js.map → chunk-A3NTKHDB.js.map} +0 -0
  346. /package/dist/{chunk-3JQVA527.js.map → chunk-A4K5GLE6.js.map} +0 -0
  347. /package/dist/{chunk-K2MR7ROB.js.map → chunk-APV42WPR.js.map} +0 -0
  348. /package/dist/{chunk-MVG67SMN.js.map → chunk-AQF7JSQR.js.map} +0 -0
  349. /package/dist/{chunk-VTTRWLOR.js.map → chunk-BP4I7IBK.js.map} +0 -0
  350. /package/dist/{chunk-T7AEAFEE.js.map → chunk-BTNKPDZM.js.map} +0 -0
  351. /package/dist/{chunk-PCXAUC65.js.map → chunk-C7WJNVJG.js.map} +0 -0
  352. /package/dist/{chunk-67XA44HH.js.map → chunk-CVYXIN5B.js.map} +0 -0
  353. /package/dist/{chunk-HVR74IBG.js.map → chunk-DJ23QZIN.js.map} +0 -0
  354. /package/dist/{chunk-VQQUOEON.js.map → chunk-EG6AQBYW.js.map} +0 -0
  355. /package/dist/{chunk-GWI65NDQ.js.map → chunk-EJIVFOOQ.js.map} +0 -0
  356. /package/dist/{chunk-YGJZLOSR.js.map → chunk-GDGTIWB4.js.map} +0 -0
  357. /package/dist/{chunk-TQ7IRULX.js.map → chunk-GILI76SU.js.map} +0 -0
  358. /package/dist/{chunk-4444HN72.js.map → chunk-GT72D4FO.js.map} +0 -0
  359. /package/dist/{chunk-SGEI3IJK.js.map → chunk-HGJC7I5F.js.map} +0 -0
  360. /package/dist/{chunk-V4M4BZNW.js.map → chunk-HTHRCGWP.js.map} +0 -0
  361. /package/dist/{chunk-QC2HGYFX.js.map → chunk-HUYNPLTT.js.map} +0 -0
  362. /package/dist/{chunk-APUP2J5M.js.map → chunk-I26TE27S.js.map} +0 -0
  363. /package/dist/{chunk-DEP24EE3.js.map → chunk-ICCRAPWD.js.map} +0 -0
  364. /package/dist/{chunk-JU3JKOY5.js.map → chunk-IPDS2TYW.js.map} +0 -0
  365. /package/dist/{chunk-YDJXGYYA.js.map → chunk-JIF3IBRK.js.map} +0 -0
  366. /package/dist/{chunk-S6CP5FWF.js.map → chunk-KBOPY6W2.js.map} +0 -0
  367. /package/dist/{chunk-H545OIWE.js.map → chunk-KM6YR5XF.js.map} +0 -0
  368. /package/dist/{chunk-AFSMT3WI.js.map → chunk-KUXTWVAR.js.map} +0 -0
  369. /package/dist/{chunk-466KGOQB.js.map → chunk-L2XQ776M.js.map} +0 -0
  370. /package/dist/{chunk-QI2KXQOM.js.map → chunk-L6FSZFG7.js.map} +0 -0
  371. /package/dist/{chunk-I7JF5TNL.js.map → chunk-LBDTQM3R.js.map} +0 -0
  372. /package/dist/{chunk-5NKSNW25.js.map → chunk-MNMYHZVU.js.map} +0 -0
  373. /package/dist/{chunk-5VVBZ6E4.js.map → chunk-N2HKBESK.js.map} +0 -0
  374. /package/dist/{chunk-HNOBRU24.js.map → chunk-N7YAQKAO.js.map} +0 -0
  375. /package/dist/{chunk-6U7M7AX6.js.map → chunk-NH2MST6J.js.map} +0 -0
  376. /package/dist/{chunk-FSZPQCDR.js.map → chunk-OQLYMBJI.js.map} +0 -0
  377. /package/dist/{chunk-FZ2SSI5R.js.map → chunk-PG6PFMDC.js.map} +0 -0
  378. /package/dist/{chunk-UKKBKEUI.js.map → chunk-QPIUFRUC.js.map} +0 -0
  379. /package/dist/{chunk-RJTGXZT6.js.map → chunk-REL4OLWW.js.map} +0 -0
  380. /package/dist/{chunk-N4GAJSRQ.js.map → chunk-RNSC2ARR.js.map} +0 -0
  381. /package/dist/{chunk-RWPNRCK2.js.map → chunk-RORE2GX2.js.map} +0 -0
  382. /package/dist/{chunk-YH65A6WM.js.map → chunk-RSFG7XHM.js.map} +0 -0
  383. /package/dist/{chunk-QLMUW7OC.js.map → chunk-S55DBWRC.js.map} +0 -0
  384. /package/dist/{chunk-RBTZLXZJ.js.map → chunk-SFD2LL7G.js.map} +0 -0
  385. /package/dist/{chunk-XTC5EKST.js.map → chunk-SG3OQCRG.js.map} +0 -0
  386. /package/dist/{chunk-X2FXEEQT.js.map → chunk-VH2W6BOG.js.map} +0 -0
  387. /package/dist/{chunk-RDPZMUCX.js.map → chunk-W6NFONOV.js.map} +0 -0
  388. /package/dist/{chunk-Z3U2YVNM.js.map → chunk-WBNXZU42.js.map} +0 -0
  389. /package/dist/{chunk-7EIPPOEL.js.map → chunk-WKD5ESK4.js.map} +0 -0
  390. /package/dist/{chunk-NWPR2V5W.js.map → chunk-ZPMXYPBR.js.map} +0 -0
  391. /package/dist/{chunk-TQLYMYOK.js.map → chunk-ZWKF3CD3.js.map} +0 -0
  392. /package/dist/{classified-marker-W2PUYC3K.js.map → classified-marker-PMDG3O36.js.map} +0 -0
  393. /package/dist/{collection-facade-CRXN72DU.js.map → collection-facade-ZJK5EB33.js.map} +0 -0
  394. /package/dist/{computed-5E2OM6EN.js.map → computed-UHCBRILW.js.map} +0 -0
  395. /package/dist/{dead-filter-MVFQCLXY.js.map → dead-filter-777VWDER.js.map} +0 -0
  396. /package/dist/{derive-NL7X2EFT.js.map → derive-3WAS2G5T.js.map} +0 -0
  397. /package/dist/{dispatch-PY5RUHJF.js.map → dispatch-3EN6YCCS.js.map} +0 -0
  398. /package/dist/{dispatch-K3MDLCXG.js.map → dispatch-ASL257KG.js.map} +0 -0
  399. /package/dist/{enclave-77K7UDLS.js.map → enclave-ZJS5R5RH.js.map} +0 -0
  400. /package/dist/{executor-FNGVGDW3.js.map → executor-GPM6DNWV.js.map} +0 -0
  401. /package/dist/{executor-PCZN2LTY.js.map → executor-LJSMZ4IB.js.map} +0 -0
  402. /package/dist/{executor-WFTHIDT7.js.map → executor-SHUVRZUJ.js.map} +0 -0
  403. /package/dist/{export-accessible-QWUYY2OY.js.map → export-accessible-GNY6DC6U.js.map} +0 -0
  404. /package/dist/{extract-partition-CGCURVS4.js.map → extract-partition-BG3AF4NZ.js.map} +0 -0
  405. /package/dist/{find-VBNMB42N.js.map → find-KX6OKHDP.js.map} +0 -0
  406. /package/dist/{issue-7IPUNAFA.js.map → issue-PAUM7NCX.js.map} +0 -0
  407. /package/dist/{ledger-3RDSSMGD.js.map → ledger-62CEPRPX.js.map} +0 -0
  408. /package/dist/{liberate-2DNJ7AJ7.js.map → liberate-7QY7TULB.js.map} +0 -0
  409. /package/dist/{link-set-VJIWWUZO.js.map → link-set-ZRYNUHN3.js.map} +0 -0
  410. /package/dist/{managed-secret-XGGJ3BC3.js.map → managed-secret-T2WB4O47.js.map} +0 -0
  411. /package/dist/{noydb-CLQP36JR.js.map → noydb-VZIVPDXG.js.map} +0 -0
  412. /package/dist/{post-register-W3T4U57K.js.map → post-register-J4DEVNXK.js.map} +0 -0
  413. /package/dist/{register-YUVC4G27.js.map → register-UPD4GKBC.js.map} +0 -0
  414. /package/dist/{registry-BPKJX562.js.map → registry-7KX2HWFS.js.map} +0 -0
  415. /package/dist/{registry-E4FM32KD.js.map → registry-PKYYEHEW.js.map} +0 -0
  416. /package/dist/{registry-HACMULJJ.js.map → registry-XHCYMD34.js.map} +0 -0
  417. /package/dist/{registry-HRFRBFDV.js.map → registry-XIRTZHPC.js.map} +0 -0
  418. /package/dist/{request-withdrawal-CXTQLMJK.js.map → request-withdrawal-XZSESWZV.js.map} +0 -0
  419. /package/dist/{reveal-G7W7N3AZ.js.map → reveal-525XWQU2.js.map} +0 -0
  420. /package/dist/{revoke-ZX3TZUI6.js.map → revoke-QI7YHQ2B.js.map} +0 -0
  421. /package/dist/{signer-FPUIX63Z.js.map → signer-BZWDPGGN.js.map} +0 -0
  422. /package/dist/{stale-42FPALK2.js.map → stale-PQYPVCER.js.map} +0 -0
  423. /package/dist/{storage-6QODT6K5.js.map → storage-MJHKNQRO.js.map} +0 -0
  424. /package/dist/{verify-SHJXGZGM.js.map → verify-J6DEOXP3.js.map} +0 -0
  425. /package/dist/{walk-5PGJI3ND.js.map → walk-BX4NSB5L.js.map} +0 -0
  426. /package/dist/{withdraw-accessible-PFCQQGNP.js.map → withdraw-accessible-K4CPMH4C.js.map} +0 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `@noy-db/hub/vault-head` — detect a store that WITHHOLDS (#1044).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { withVaultHead } from './active.js';
7
+ export { verifyVaultHead, type HeadDiscrepancy, type HeadVerifyResult } from './verify.js';
8
+ export { NO_VAULT_HEAD, VAULT_HEAD_COLLECTION, DEFAULT_HEAD_BUCKETS, type VaultHeadStrategy, type WithVaultHeadOptions, type HeadEntry, } from './strategy.js';
9
+ export type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js';
10
+ export type { EnclaveKey } from '../../kernel/enclave/index.js';
@@ -0,0 +1,127 @@
1
+ /**
2
+ * `withVaultHead()` — the opt-in detector for **omission** (#1044).
3
+ *
4
+ * ## What it is for, and what it deliberately is not
5
+ *
6
+ * #1041 made every envelope self-authenticating at its identity, and #1042
7
+ * made the merge reject one that is not. What neither can catch is **absence**:
8
+ * a store that serves a genuine, unmodified `v1` when `v7` exists, or serves
9
+ * nothing at all. An authentic old envelope is indistinguishable from an
10
+ * authentic current one without external knowledge of what *should* be there.
11
+ *
12
+ * The head is that external knowledge: an authenticated `{id → version}`
13
+ * manifest the client writes and the store cannot forge. It is **not** a Merkle
14
+ * chain over content — content integrity is already handled, so the head needs
15
+ * only versions.
16
+ *
17
+ * ## Why it is opt-in when AAD is not
18
+ *
19
+ * AAD costs nothing to coordinate and closes *alteration*, so it is kernel. The
20
+ * head costs a write per commit and needs anti-entropy; on a single-device
21
+ * offline vault it defends against nothing. Making it kernel would tax every
22
+ * user for a multi-writer property. ADR 0003, Decision 3.
23
+ *
24
+ * `SECURITY.md` states the split exactly: a store cannot alter, relocate,
25
+ * re-tier, re-author or rewind a record; **without `withVaultHead()` it can
26
+ * still withhold or omit.**
27
+ *
28
+ * ## Bucketed, and why that is not a compromise
29
+ *
30
+ * ADR 0003 left head granularity open and asked for it to be sized early.
31
+ * Measured, at the documented 50K-record vault ceiling:
32
+ *
33
+ * | shape | write cost per commit | detection |
34
+ * |---|---|---|
35
+ * | one per-vault manifest | **1.1 MiB** | per-record |
36
+ * | one per collection | the same problem, renamed | per-record |
37
+ * | **bucketed, 256 buckets** | **~4.4 KiB** | per-record |
38
+ *
39
+ * Bucketing changes *only* write amplification. Each bucket still lists every
40
+ * one of its records' versions, so detection stays per-record — which is why
41
+ * this is not a trade-off between cost and strength. Verifying one pulled
42
+ * record reads one bucket rather than a megabyte.
43
+ *
44
+ * ## Wired as a bus OBSERVER, not a call in `collection.ts`
45
+ *
46
+ * That is what `kernel-surface` means by "register on the ServiceBus instead of
47
+ * growing this file", and it keeps the hot write path untouched for anyone who
48
+ * has not opted in: nothing is registered at all, so `hasHandlers` stays false
49
+ * and the dispatch never happens.
50
+ *
51
+ * Both `afterPut` AND `afterDelete`, because a delete is a version bump like
52
+ * any other. A head that stopped tracking deleted records would let a store
53
+ * resurrect one by withholding the tombstone — precisely the omission this
54
+ * exists to catch.
55
+ *
56
+ * ⚠️ The registration must be UNCONDITIONAL on anything but `enabled`. Its first
57
+ * draft sat inside `#registerForgetHooks()`, which returns early when no forget
58
+ * subjects are declared, so the head silently recorded nothing unless the vault
59
+ * happened to use an unrelated feature. The tests caught it only because they
60
+ * asserted a COUNT rather than "no error" — a head that records nothing raises
61
+ * no errors and sweeps perfectly clean.
62
+ *
63
+ * @packageDocumentation
64
+ */
65
+ import type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js';
66
+ import type { EnclaveKey } from '../../kernel/enclave/index.js';
67
+ /** Reserved collection the head's buckets live in. */
68
+ export declare const VAULT_HEAD_COLLECTION: "_head";
69
+ /** Default bucket count — see the sizing table above. */
70
+ export declare const DEFAULT_HEAD_BUCKETS = 256;
71
+ export interface WithVaultHeadOptions {
72
+ /**
73
+ * How many buckets the manifest is split across. Higher means smaller writes
74
+ * and more reads to sweep the whole vault; lower means the opposite.
75
+ * Changing it on an existing vault re-homes every entry, so treat it as a
76
+ * layout decision rather than a tuning knob.
77
+ */
78
+ readonly buckets?: number;
79
+ }
80
+ /** One record's expected state, as the client last committed it. */
81
+ export interface HeadEntry {
82
+ readonly collection: string;
83
+ readonly id: string;
84
+ readonly version: number;
85
+ }
86
+ export interface VaultHeadStrategy {
87
+ /**
88
+ * Is the head actually keeping a manifest?
89
+ *
90
+ * An explicit flag rather than an identity check against the stub: the kernel
91
+ * decides whether to register the write-path observer at all, and
92
+ * `port-layering` forbids it importing `NO_VAULT_HEAD` to compare. Without
93
+ * this, every write in a vault that never opted in would still pay a cache
94
+ * lookup and a no-op call.
95
+ */
96
+ readonly enabled: boolean;
97
+ /** Bucket a record id lands in — pure, so callers can pre-group a batch. */
98
+ bucketFor(collection: string, id: string): string;
99
+ /**
100
+ * Record `entry` as the client's expectation for that record.
101
+ *
102
+ * Called on every committed write, INSIDE the same logical operation, so
103
+ * there is no window where the record exists and the head does not know it.
104
+ */
105
+ note(store: NoydbStore, vault: string, getDEK: (collection: string) => Promise<EnclaveKey>, entry: HeadEntry): Promise<void>;
106
+ /**
107
+ * What the client expects for `collection/id`, or `null` if the head has
108
+ * never seen it.
109
+ */
110
+ expected(store: NoydbStore, vault: string, getDEK: (collection: string) => Promise<EnclaveKey>, collection: string, id: string): Promise<number | null>;
111
+ /**
112
+ * Every record the head knows about in `collection` — the set a sweep
113
+ * compares against what the store actually serves, which is how DELETION
114
+ * SUPPRESSION is caught. A withheld record is absent from the store but
115
+ * present here.
116
+ */
117
+ knownIn(store: NoydbStore, vault: string, getDEK: (collection: string) => Promise<EnclaveKey>, collection: string): Promise<ReadonlyMap<string, number>>;
118
+ }
119
+ /**
120
+ * The un-opted-in stub. `note` is a NO-OP rather than a throw: the write path
121
+ * calls it unconditionally, and a vault without the head must simply not keep
122
+ * one. The READ side throws, because asking what the head expects when there is
123
+ * no head is a caller error, not a silent "nothing to report" — the latter
124
+ * would look exactly like a clean sweep.
125
+ */
126
+ export declare const NO_VAULT_HEAD: VaultHeadStrategy;
127
+ export type { EncryptedEnvelope };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The sweep — comparing what the head expects against what the store serves (#1044).
3
+ *
4
+ * This is the only place absence becomes visible. #1041 and #1042 can reject a
5
+ * record that lies about itself; neither can notice one that never arrived, or
6
+ * one served at an older version than the client wrote. Both are indistinguishable
7
+ * from the truth without an independent record of what should be there.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { NoydbStore } from '../../kernel/types.js';
12
+ import type { EnclaveKey } from '../../kernel/enclave/index.js';
13
+ import type { VaultHeadStrategy } from './strategy.js';
14
+ /** One record the store is not serving faithfully. */
15
+ export interface HeadDiscrepancy {
16
+ readonly collection: string;
17
+ readonly id: string;
18
+ /** What the client last committed. */
19
+ readonly expected: number;
20
+ /**
21
+ * What the store serves now — or `null` when it serves nothing.
22
+ *
23
+ * The two are different attacks wearing the same result. `null` is
24
+ * **suppression**: the record is gone. A lower number is **rollback**: an
25
+ * authentic older version served in place of the current one, which is the
26
+ * case no amount of per-envelope authentication can see.
27
+ */
28
+ readonly actual: number | null;
29
+ readonly kind: 'withheld' | 'rolled-back';
30
+ }
31
+ export interface HeadVerifyResult {
32
+ readonly checked: number;
33
+ readonly discrepancies: readonly HeadDiscrepancy[];
34
+ /** `true` when every record the head knows about is served at or above its expected version. */
35
+ readonly clean: boolean;
36
+ }
37
+ /**
38
+ * Sweep one collection.
39
+ *
40
+ * **A record the store serves that the head does NOT know is not reported.**
41
+ * That is not an oversight: the head can be enabled on an existing vault, and
42
+ * every pre-existing record would otherwise read as an anomaly. The head's
43
+ * claim is one-directional — *what I wrote must still be there* — and an
44
+ * unknown record simply falls outside it.
45
+ *
46
+ * **A HIGHER version than expected is also not reported**, for the same reason:
47
+ * another device legitimately advanced it. The head detects going backwards, not
48
+ * moving forwards.
49
+ */
50
+ export declare function verifyVaultHead(head: VaultHeadStrategy, store: NoydbStore, vault: string, getDEK: (collection: string) => Promise<EnclaveKey>, collection: string): Promise<HeadVerifyResult>;
@@ -1,11 +1,3 @@
1
- /**
2
- * Persistence helpers for `_meta/public-envelope` — the cover's
3
- * frozen wire location. Mirrors the bypass-AES pattern used by
4
- * `_meta/handle` and `_meta/policy` — the document is plaintext
5
- * JSON, the envelope's `_iv` field is left empty.
6
- *
7
- * @module
8
- */
9
1
  import type { NoydbStore } from '../../../kernel/types.js';
10
2
  import type { Cover } from './types.js';
11
3
  /**
@@ -1,14 +1,3 @@
1
- /**
2
- * Persistence helpers for the vault-level user-directory toggle
3
- * (`_meta/directory`). Mirrors the bypass-AES pattern used by
4
- * `_meta/policy` — the directory document is plain JSON, the
5
- * envelope's `_iv` field is left empty.
6
- *
7
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/user-envelope.md → Directory visibility
8
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/plaintext-bypass.md — every `_iv: ''` write site
9
- *
10
- * @module
11
- */
12
1
  import type { NoydbStore } from '../../kernel/types.js';
13
2
  import type { DirectoryConfig } from './types.js';
14
3
  /** Reserved collection name for vault-level metadata documents. */
@@ -1,24 +1,3 @@
1
- /**
2
- * Persistence helpers for the per-user visibility flag
3
- * (`_meta/visibility/<keyringId>`). Mirrors the bypass-AES pattern used
4
- * by `_meta/policy` — the visibility document is plain JSON, the
5
- * envelope's `_iv` field is left empty.
6
- *
7
- * Stored alongside the keyring file rather than inside the encrypted
8
- * user envelope (`_users/<keyringId>`) because:
9
- *
10
- * - `UserEnvelope<T>.data` is opaque-to-hub by contract — hub does not
11
- * introspect or reserve any keys inside it. Adding `hidden` there
12
- * would violate that contract.
13
- * - `listUsersWithEnvelopes` filters by the flag, and the filter must
14
- * work even when decryption fails (legacy keyrings predating the
15
- * envelope feature, or a corrupted envelope).
16
- *
17
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/user-envelope.md → Directory visibility
18
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/plaintext-bypass.md — every `_iv: ''` write site
19
- *
20
- * @module
21
- */
22
1
  import type { NoydbStore } from '../../kernel/types.js';
23
2
  import type { UserVisibility } from './types.js';
24
3
  /** Prefix for per-user visibility records inside `_meta`. */
@@ -1,13 +1,3 @@
1
- /**
2
- * Persistence helpers for the vault-level policy document
3
- * (`_meta/policy`). Mirrors the bypass-AES pattern used by
4
- * `_meta/handle` — the policy document is plain JSON, the envelope's
5
- * `_iv` field is left empty.
6
- *
7
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → Storage location
8
- *
9
- * @module
10
- */
11
1
  import type { NoydbStore, VaultPolicy } from '../../kernel/types.js';
12
2
  /** Reserved collection name for vault-level metadata documents. */
13
3
  export declare const META_COLLECTION = "_meta";
@@ -18,7 +18,8 @@
18
18
  */
19
19
  import type { UnlockedKeyring } from './keyring.js';
20
20
  /** Canonical DEK key for a given collection + tier. Tier 0 → bare name. */
21
- export declare function dekKey(collection: string, tier: number): string;
21
+ import { dekKey } from '../../kernel/tier-visibility.js';
22
+ export { dekKey };
22
23
  /**
23
24
  * Returns the user's effective clearance for a given collection: the
24
25
  * maximum tier for which their keyring holds a DEK. Falls back to 0
@@ -1,4 +1,5 @@
1
1
  import type { NoydbStore, DirtyEntry, ConflictStrategy, CollectionConflictResolver, PushOptions, PullOptions, PushResult, PullResult, SyncStatus, SyncTargetRole } from '../kernel/types.js';
2
+ import type { MergeAuthority } from '../port/with/merge-authority.js';
2
3
  import { type PeriodPullSource } from './period-scope.js';
3
4
  import type { NoydbEventEmitter } from '../kernel/events.js';
4
5
  import type { SyncPolicy } from '../kernel/sync-policy.js';
@@ -12,6 +13,7 @@ export interface ReservedLookupSource {
12
13
  }
13
14
  /** Sync engine: dirty tracking, push, pull, conflict resolution, scheduling. */
14
15
  export declare class SyncEngine {
16
+ private readonly mergeAuthority;
15
17
  private readonly local;
16
18
  private readonly remote;
17
19
  private readonly strategy;
@@ -101,6 +103,15 @@ export declare class SyncEngine {
101
103
  syncPolicy?: SyncPolicy;
102
104
  role?: SyncTargetRole;
103
105
  label?: string;
106
+ /**
107
+ * #1042 — the merge's verify/re-stamp capability. Optional so an engine
108
+ * built without one behaves exactly as before; the Vault supplies it.
109
+ *
110
+ * A closure, not an import: `with-sync` is DEK-free and
111
+ * `check:architecture` enforces that, so the capability arrives already
112
+ * bound to the keys rather than the engine reaching for them.
113
+ */
114
+ mergeAuthority?: MergeAuthority;
104
115
  });
105
116
  /** Start the sync scheduler. Called after vault is fully opened. */
106
117
  startScheduler(): void;
@@ -189,11 +200,28 @@ export declare class SyncEngine {
189
200
  * the remote's (the same-`_v` push tie), re-stamp it at `remote._v + 1`.
190
201
  * Without this the loser's next pull sees no delta (`_v`-based
191
202
  * detection) and the peers stay silently diverged at the same version.
192
- * `_v` is envelope metadata — AEAD-unbound, and `_vdig` is deliberately
193
- * `_v`-independent — so the engine may restamp ciphertext. Callers must
194
- * mirror the advanced envelope locally (`applyRemote`) so both sides
195
- * agree. The 'merged' branch needs none of this: resolver output is
196
- * already stamped `max(local, remote) + 1`.
203
+ * ## Why this is async, and why it goes through `MergeAuthority` (#1093)
204
+ *
205
+ * It used to be `{ ...winner, _v: remote._v + 1 }` — a metadata restamp on
206
+ * ciphertext the engine cannot decrypt. That spread was the SOLE reason `_v`
207
+ * could not be bound into the AAD: a version rewritten onto a body sealed at
208
+ * a different one produces a record no reader can open.
209
+ *
210
+ * `with-sync` is DEK-free by design and `check:architecture` enforces it, so
211
+ * the re-seal cannot happen here. It happens in the injected authority, which
212
+ * holds the keys. The engine still decides WHICH version to advance to; it
213
+ * simply no longer pretends it can rewrite a sealed body.
214
+ *
215
+ * The authority is ALWAYS present in the product — `kernel/noydb.ts` builds
216
+ * one from the keyring and passes it at both engine-construction sites, and
217
+ * `with-sync/active.ts` is the only place an engine is constructed. The
218
+ * fallback below is reachable only by constructing `SyncEngine` directly,
219
+ * which tests do. It restamps, as before — and would produce an unreadable
220
+ * record if such a test ever held AEAD-sealed envelopes. None do; the
221
+ * fixtures that reach it build their own plaintext ones.
222
+ *
223
+ * The 'merged' branch needs none of this: resolver output is already stamped
224
+ * `max(local, remote) + 1` by whoever built it.
197
225
  */
198
226
  private advancePastRemote;
199
227
  private applyRemote;
@@ -25,6 +25,7 @@
25
25
  * @internal
26
26
  */
27
27
  import type { NoydbStore, ConflictStrategy, SyncTargetRole } from '../kernel/types.js';
28
+ import type { MergeAuthority } from '../port/with/merge-authority.js';
28
29
  import type { NoydbEventEmitter } from '../kernel/events.js';
29
30
  import type { SyncPolicy } from '../kernel/sync-policy.js';
30
31
  import type { SyncEngine } from './engine.js';
@@ -47,6 +48,8 @@ export interface BuildSyncEngineOptions {
47
48
  syncPolicy?: SyncPolicy;
48
49
  role?: SyncTargetRole;
49
50
  label?: string;
51
+ /** #1042 — the merge's verify/re-stamp capability, bound to the keys by the caller. */
52
+ mergeAuthority?: MergeAuthority;
50
53
  }
51
54
  /**
52
55
  * @internal
@@ -0,0 +1,28 @@
1
+ import {
2
+ FROZEN_SNAPSHOTS_COLLECTION,
3
+ freezeAndDeleteClosure,
4
+ freezeSnapshotOnly,
5
+ randomId,
6
+ withdrawAccessibleData
7
+ } from "./chunk-TC6MBEGH.js";
8
+ import "./chunk-ZPMXYPBR.js";
9
+ import "./chunk-2IK6AC6A.js";
10
+ import "./chunk-DYASJSKI.js";
11
+ import "./chunk-D5UDZANO.js";
12
+ import "./chunk-ZVAFJQZB.js";
13
+ import "./chunk-OQLYMBJI.js";
14
+ import "./chunk-DJ23QZIN.js";
15
+ import "./chunk-SFD2LL7G.js";
16
+ import "./chunk-LP7BEXCT.js";
17
+ import "./chunk-VJ4B3ZXY.js";
18
+ import "./chunk-3Y4OFWQJ.js";
19
+ import "./chunk-P7L3OQLL.js";
20
+ import "./chunk-PZ5AY32C.js";
21
+ export {
22
+ FROZEN_SNAPSHOTS_COLLECTION,
23
+ freezeAndDeleteClosure,
24
+ freezeSnapshotOnly,
25
+ randomId,
26
+ withdrawAccessibleData
27
+ };
28
+ //# sourceMappingURL=withdraw-accessible-K4CPMH4C.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noy-db/hub",
3
- "version": "0.6.0-pre.17",
3
+ "version": "0.6.0-pre.19",
4
4
  "description": "Zero-knowledge, offline-first, encrypted document store — core library with AES-256-GCM, PBKDF2, multi-user keyring, and sync engine",
5
5
  "license": "MIT",
6
6
  "author": "vLannaAi <vicio@lanna.ai>",
@@ -37,6 +37,10 @@
37
37
  "types": "./dist/with-party/session/index.d.ts",
38
38
  "default": "./dist/session/index.js"
39
39
  },
40
+ "./vault-head": {
41
+ "types": "./dist/with-commit/vault-head/index.d.ts",
42
+ "default": "./dist/vault-head/index.js"
43
+ },
40
44
  "./history": {
41
45
  "types": "./dist/with-commit/history/index.d.ts",
42
46
  "default": "./dist/history/index.js"
@@ -211,14 +215,14 @@
211
215
  "node": ">=22.0.0"
212
216
  },
213
217
  "dependencies": {
214
- "@noy-db/attestation": "0.6.0-pre.17"
218
+ "@noy-db/attestation": "0.6.0-pre.19"
215
219
  },
216
220
  "devDependencies": {
217
221
  "@types/node": "^22.0.0",
218
222
  "esbuild": "^0.25.0",
219
223
  "zod": "^4.0.0",
220
224
  "zod-to-json-schema": "^3.25.2",
221
- "@noy-db/on-shamir": "0.6.0-pre.17"
225
+ "@noy-db/on-shamir": "0.6.0-pre.19"
222
226
  },
223
227
  "peerDependencies": {
224
228
  "zod-to-json-schema": "^3.25.0"
@@ -1,20 +0,0 @@
1
- import {
2
- UserApi,
3
- createUserApi
4
- } from "./chunk-67XA44HH.js";
5
- import "./chunk-QJBXB4WU.js";
6
- import "./chunk-BKYQNNO3.js";
7
- import "./chunk-RGPB25DB.js";
8
- import "./chunk-FSZPQCDR.js";
9
- import "./chunk-HVR74IBG.js";
10
- import "./chunk-RBTZLXZJ.js";
11
- import "./chunk-LP7BEXCT.js";
12
- import "./chunk-QTDAPDDV.js";
13
- import "./chunk-5UGEGEIJ.js";
14
- import "./chunk-I64WQSN3.js";
15
- import "./chunk-PZ5AY32C.js";
16
- export {
17
- UserApi,
18
- createUserApi
19
- };
20
- //# sourceMappingURL=api-AEIN3KAQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/with-commit/sequence/active.ts","../src/with-commit/sequence/strategy.ts","../src/with-commit/sequence/index.ts"],"sourcesContent":["/**\n * Enable the atomic-sequence capability.\n * Pass to `createNoydb({ sequenceStrategy: withSequence() })` to make\n * `vault.sequence('name').next()` / `.peek()` / `.seedTo()` live. The\n * {@link SequenceStore} CAS engine is statically imported here, so it is pulled\n * into the bundle only when `withSequence()` is referenced (the floor never\n * imports it).\n */\nimport type { SequenceStrategy } from './strategy.js'\nimport { SequenceStore } from './index.js'\n\nexport function withSequence(): SequenceStrategy {\n return {\n createStore(opts) {\n return new SequenceStore(opts)\n },\n }\n}\n","/**\n * Sequence capability strategy — the single on-demand factory the vault routes\n * `vault.sequence()` through to build its atomic-CAS {@link SequenceStore}. The\n * active engine ({@link withSequence}) constructs the real store (kept out of\n * the floor bundle — the store class is reached only via the opt-in\n * `active.ts` chunk); {@link NO_SEQUENCE} throws. The vault always assembles the\n * per-call {@link SequenceStoreOptions} and delegates here, so an un-opted-in\n * caller hits `NO_SEQUENCE`'s throw at `vault.sequence()`.\n *\n * Note: `vault.sequence()` is synchronous, so the factory is a plain (sync)\n * constructor — the engine is tree-shaken by reachability (only `withSequence()`\n * pulls `active.ts`, which statically imports the store), not by a dynamic\n * import. Deferred-numbering series (`withDeferredNumbering`) are a distinct\n * capability and are NOT routed through this strategy.\n * @internal\n */\nimport type { SequenceStore, SequenceStoreOptions } from './index.js'\nimport { SequenceNotEnabledError } from '../../kernel/errors.js'\n\nexport interface SequenceStrategy {\n createStore(opts: SequenceStoreOptions): SequenceStore\n}\n\n/**\n * No-op stub — the floor default. The capability factory throws\n * {@link SequenceNotEnabledError}; opt in with `sequenceStrategy: withSequence()`\n * in createNoydb. @internal\n */\nexport const NO_SEQUENCE: SequenceStrategy = {\n createStore(): SequenceStore {\n throw new SequenceNotEnabledError()\n },\n}\n","/**\n * Atomic sequence primitive — online-coordinated gap-free numbering.\n *\n * `vault.sequence('invoice-2026').next()` returns 1, 2, 3, … with no\n * gaps and no duplicates, even under concurrent callers. Each named\n * sequence is an independent counter record at `_sequences/<name>`,\n * incremented with an optimistic compare-and-swap retry loop — the same\n * proven pattern as the ledger head (`history/ledger/store.ts`).\n *\n * **Explicitly online-only.** Gap-free numbering requires single-authority\n * serialization, which an offline / non-CAS store cannot provide. `next()`\n * throws {@link SequenceOfflineError} unless the backing store advertises\n * `capabilities.casAtomic`. This is a deliberate, honest wall — an offline\n * writer cannot safely allocate a global sequence number.\n *\n * Note on \"gap-free\": the *sequence* is gap-free (each `next()` yields a\n * unique, +1 value). If a caller discards a value without using it, that\n * is a gap in *usage*, not in the sequence — assign each `next()` result\n * to its record in the same operation.\n */\n\nimport { buildRecordEnvelope } from '../../kernel/enclave/index.js'\nimport type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js'\nimport { encrypt, openEnvelopeJson, type EnclaveKey } from '../../kernel/enclave/index.js'\nimport type { ConflictError} from '../../kernel/errors.js';\nimport { isConflictError, SequenceContentionError, SequenceOfflineError, ValidationError } from '../../kernel/errors.js'\n\n// Capability opt-in seam (S4): `vault.sequence()` builds its CAS store through\n// the sequenceStrategy, so it throws SequenceNotEnabledError unless opted in.\nexport { withSequence } from './active.js'\nexport { NO_SEQUENCE, type SequenceStrategy } from './strategy.js'\nexport { SequenceNotEnabledError } from '../../kernel/errors.js'\n\nexport const SEQUENCE_COLLECTION = '_sequences'\n// A sequence is a single hot CAS row — higher contention than a ledger\n// append. A larger budget + jittered backoff absorbs moderate concurrency;\n// a genuine burst beyond this surfaces SequenceContentionError so the\n// caller can retry / queue (the honest online-only contract).\nconst MAX_NEXT_ATTEMPTS = 16\n\ninterface SequenceState {\n value: number\n}\n\n/** Options for `SequenceHandle.next`. Deferred-numbering series use `for`; the CAS counter ignores all of these. */\nexport interface NextOptions {\n /** Deferred mode: the record id to number. Ignored by the CAS counter. */\n readonly for?: string\n /** Deferred mode: reject after this many ms if still unsealed (reserved; not yet enforced in this slice). */\n readonly timeoutMs?: number\n}\n\n/**\n * Partitioning for a CAS sequence. A partitioned sequence is an\n * independent counter scoped to one tuple of values — e.g.\n * `sequence('invoice', { partition: [2026, 'EU'] })` numbers EU-2026 invoices\n * separately from `[2026, 'US']` and from the bare `invoice` series.\n *\n * Partition components are URI-encoded (so `/`, null bytes and other\n * separators in a value can never collide with the structural separators) and\n * `'/'`-joined, then appended to the series with a null-byte (`\\x00`)\n * separator. The null byte is illegal in a plain series name, which guarantees\n * a partitioned key is always disjoint from any unpartitioned series.\n */\nexport interface SequenceOptions {\n /** Partition tuple. Each component is URI-encoded and `'/'`-joined. */\n readonly partition?: readonly (string | number)[]\n /**\n * Render template for the serial string. When set, `vault.sequence`\n * returns a {@link FormattedSequenceHandle} whose `next()` resolves to\n * `{ serial, formatted }`. Tokens:\n * - `{seq}` — the allocated integer\n * - `{seq:0N}` — zero-padded to width N (e.g. `{seq:04}` → `0001`)\n * - `{partition.i}` — the i-th `partition` component (original value)\n *\n * Any other token, or a `{partition.i}` index beyond the supplied\n * `partition`, throws `ValidationError` at `vault.sequence()` construction.\n * Per-partition reset is inherent: a new partition tuple starts at 1.\n */\n readonly format?: string\n}\n\n/**\n * A formatted sequence handle. Identical to {@link SequenceHandle}\n * except `next()` also returns the rendered `formatted` string. `peek()` /\n * `seedTo()` operate on the underlying integer counter, unchanged.\n */\nexport interface FormattedSequenceHandle {\n /** Allocate the next value and return it with its rendered serial string. */\n next(opts?: NextOptions): Promise<{ serial: number; formatted: string }>\n /** Read the current integer value without allocating. Returns 0 if never used. */\n peek(): Promise<number>\n /** Set-if-greater on the underlying integer counter. See {@link SequenceHandle.seedTo}. */\n seedTo(n: number): Promise<void>\n}\n\n// Matches a single `{...}` token with no nested braces.\nconst SEQ_FORMAT_TOKEN = /\\{([^{}]*)\\}/g\nconst SEQ_PAD_TOKEN = /^seq:0(\\d+)$/\nconst SEQ_PARTITION_TOKEN = /^partition\\.(\\d+)$/\n\n/**\n * Validate a sequence `format` against the supplied partition and return a\n * pure `(serial) => string` renderer. Eager validation: every token is\n * checked now, so a bad pattern throws `ValidationError` at construction —\n * never at `next()` time.\n */\nexport function compileSequenceFormat(\n format: string,\n series: string,\n partition: readonly (string | number)[] | undefined,\n): (serial: number) => string {\n const parts = partition ?? []\n for (const m of format.matchAll(SEQ_FORMAT_TOKEN)) {\n const token = m[1] ?? ''\n if (token === 'seq') continue\n if (SEQ_PAD_TOKEN.test(token)) continue\n const partMatch = SEQ_PARTITION_TOKEN.exec(token)\n if (partMatch) {\n const idx = Number(partMatch[1])\n if (idx >= parts.length) {\n throw new ValidationError(\n `sequence(\"${series}\"): format token \"{${token}}\" references partition index ${idx}, ` +\n `but only ${parts.length} partition component(s) were supplied.`,\n )\n }\n continue\n }\n throw new ValidationError(\n `sequence(\"${series}\"): format contains unknown token \"{${token}}\". ` +\n `Accepted tokens: {seq}, {seq:0N}, {partition.i}.`,\n )\n }\n return (serial: number): string =>\n format.replace(SEQ_FORMAT_TOKEN, (full, token: string) => {\n if (token === 'seq') return String(serial)\n const padMatch = SEQ_PAD_TOKEN.exec(token)\n if (padMatch) return String(serial).padStart(Number(padMatch[1]), '0')\n const partMatch = SEQ_PARTITION_TOKEN.exec(token)\n if (partMatch) return String(parts[Number(partMatch[1])])\n return full // unreachable — validated above\n })\n}\n\n/**\n * Resolve the CAS storage key for a (series, partition) pair.\n *\n * With no partition the key is `series` verbatim. With a partition the key is\n * `${series}\\x00${parts}` where `parts` is each component passed through\n * `encodeURIComponent(String(part))` and `'/'`-joined. The null-byte separator\n * is illegal in a plain series name, so partitioned keys never collide with\n * unpartitioned ones; URI-encoding keeps any component containing `/` distinct\n * from a multi-component partition.\n *\n * @throws {ValidationError} if any partition component is empty after `String()`\n * or is a non-finite number (`NaN`, `±Infinity`).\n */\nexport function resolveSequenceKey(series: string, opts?: SequenceOptions): string {\n const partition = opts?.partition\n if (!partition || partition.length === 0) return series\n const parts = partition.map((p) => {\n if (typeof p === 'number' && !Number.isFinite(p)) {\n throw new ValidationError(`sequence partition component must be a finite number, got ${p}`)\n }\n const s = String(p)\n if (s === '') {\n throw new ValidationError('sequence partition component must not be empty')\n }\n return encodeURIComponent(s)\n })\n return `${series}\\x00${parts.join('/')}`\n}\n\nexport interface SequenceHandle {\n /** Atomically allocate and return the next value (1, 2, 3, …). Deferred series resolve at the next pass. */\n next(opts?: NextOptions): Promise<number>\n /** Read the current value without allocating. Returns 0 if never used. */\n peek(): Promise<number>\n /**\n * Set-if-greater: advance the counter to at least `n`. A no-op if the\n * current value is already `>= n` (so it never rewinds), and `seedTo(0)` is\n * a no-op. Idempotent and CAS-safe under concurrent `next()` / `seedTo()`.\n *\n * Use after a bundle / CSV import to fast-forward the counter past the\n * highest imported serial, so subsequent `next()` calls cannot re-use a\n * number that is already on a record.\n *\n * Online-only: throws {@link SequenceOfflineError} on a non-CAS store.\n */\n seedTo(n: number): Promise<void>\n}\n\nasync function sleepBackoff(attempt: number): Promise<void> {\n // Exponential backoff with full jitter to break the thundering herd\n // when many writers contend on the same counter row.\n const ceil = Math.min(2 ** attempt, 32)\n const ms = Math.floor(Math.random() * ceil)\n await new Promise((r) => setTimeout(r, ms))\n}\n\n/** Per-call context the vault assembles to build a {@link SequenceStore}. */\nexport interface SequenceStoreOptions {\n adapter: NoydbStore\n vault: string\n encrypted: boolean\n getDEK: (collectionName: string) => Promise<EnclaveKey>\n actor: string\n}\n\nexport class SequenceStore {\n private readonly adapter: NoydbStore\n private readonly vault: string\n private readonly encrypted: boolean\n private readonly getDEK: (collectionName: string) => Promise<EnclaveKey>\n private readonly actor: string\n /**\n * Memoized DEK promise. The `_sequences` collection DEK is created on\n * first access; without sharing one promise, a burst of concurrent\n * `next()` calls would each trigger DEK creation and diverge (one\n * writer's ciphertext unreadable by another). One shared promise → one\n * DEK.\n */\n private dekPromise: Promise<EnclaveKey> | null = null\n\n constructor(opts: SequenceStoreOptions) {\n this.adapter = opts.adapter\n this.vault = opts.vault\n this.encrypted = opts.encrypted\n this.getDEK = opts.getDEK\n this.actor = opts.actor\n }\n\n /** A handle bound to one sequence name. */\n handle(name: string): SequenceHandle {\n return {\n next: () => this.next(name),\n peek: () => this.peek(name),\n seedTo: (n) => this.seedTo(name, n),\n }\n }\n\n private assertOnline(): void {\n if (this.adapter.capabilities?.casAtomic !== true) {\n throw new SequenceOfflineError()\n }\n }\n\n private dek(): Promise<EnclaveKey> {\n if (!this.dekPromise) this.dekPromise = this.getDEK(SEQUENCE_COLLECTION)\n return this.dekPromise\n }\n\n private async read(name: string): Promise<{ env: EncryptedEnvelope | null; value: number }> {\n const env = await this.adapter.get(this.vault, SEQUENCE_COLLECTION, name)\n if (!env) return { env: null, value: 0 }\n const json = this.encrypted ? await openEnvelopeJson(env, await this.dek()) : env._data\n const state = JSON.parse(json) as SequenceState\n return { env, value: state.value }\n }\n\n private async encryptState(name: string, state: SequenceState, version: number): Promise<EncryptedEnvelope> {\n const json = JSON.stringify(state)\n if (!this.encrypted) {\n return buildRecordEnvelope({ collection: SEQUENCE_COLLECTION, id: name }, { version, iv: '', data: json, by: this.actor })\n }\n const { iv, data } = await encrypt(json, await this.dek())\n return buildRecordEnvelope({ collection: SEQUENCE_COLLECTION, id: name }, { version, iv, data, by: this.actor })\n }\n\n async peek(name: string): Promise<number> {\n return (await this.read(name)).value\n }\n\n async next(name: string): Promise<number> {\n this.assertOnline()\n let lastConflict: ConflictError | undefined\n for (let attempt = 0; attempt < MAX_NEXT_ATTEMPTS; attempt++) {\n const { env, value } = await this.read(name)\n const nextValue = value + 1\n const expectedVersion = env?._v ?? 0 // 0 ≡ \"must not yet exist\" (create)\n const envelope = await this.encryptState(name, { value: nextValue }, expectedVersion + 1)\n try {\n await this.adapter.put(this.vault, SEQUENCE_COLLECTION, name, envelope, expectedVersion)\n return nextValue\n } catch (err) {\n if (isConflictError(err)) {\n lastConflict = err\n if (attempt < MAX_NEXT_ATTEMPTS - 1) await sleepBackoff(attempt)\n continue\n }\n throw err\n }\n }\n void lastConflict\n throw new SequenceContentionError(name, MAX_NEXT_ATTEMPTS)\n }\n\n async seedTo(name: string, n: number): Promise<void> {\n this.assertOnline()\n if (n <= 0) return // set-if-greater: 0 (and any non-positive seed) is a no-op\n let lastConflict: ConflictError | undefined\n for (let attempt = 0; attempt < MAX_NEXT_ATTEMPTS; attempt++) {\n const { env, value } = await this.read(name)\n if (value >= n) return // already at or past the floor — no write, idempotent\n const expectedVersion = env?._v ?? 0 // 0 ≡ \"must not yet exist\" (create)\n const envelope = await this.encryptState(name, { value: n }, expectedVersion + 1)\n try {\n await this.adapter.put(this.vault, SEQUENCE_COLLECTION, name, envelope, expectedVersion)\n return\n } catch (err) {\n if (isConflictError(err)) {\n lastConflict = err\n if (attempt < MAX_NEXT_ATTEMPTS - 1) await sleepBackoff(attempt)\n continue\n }\n throw err\n }\n }\n void lastConflict\n throw new SequenceContentionError(name, MAX_NEXT_ATTEMPTS)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAWO,SAAS,eAAiC;AAC/C,SAAO;AAAA,IACL,YAAY,MAAM;AAChB,aAAO,IAAI,cAAc,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;;;ACWO,IAAM,cAAgC;AAAA,EAC3C,cAA6B;AAC3B,UAAM,IAAI,wBAAwB;AAAA,EACpC;AACF;;;ACCO,IAAM,sBAAsB;AAKnC,IAAM,oBAAoB;AA2D1B,IAAM,mBAAmB;AACzB,IAAM,gBAAgB;AACtB,IAAM,sBAAsB;AAQrB,SAAS,sBACd,QACA,QACA,WAC4B;AAC5B,QAAM,QAAQ,aAAa,CAAC;AAC5B,aAAW,KAAK,OAAO,SAAS,gBAAgB,GAAG;AACjD,UAAM,QAAQ,EAAE,CAAC,KAAK;AACtB,QAAI,UAAU,MAAO;AACrB,QAAI,cAAc,KAAK,KAAK,EAAG;AAC/B,UAAM,YAAY,oBAAoB,KAAK,KAAK;AAChD,QAAI,WAAW;AACb,YAAM,MAAM,OAAO,UAAU,CAAC,CAAC;AAC/B,UAAI,OAAO,MAAM,QAAQ;AACvB,cAAM,IAAI;AAAA,UACR,aAAa,MAAM,sBAAsB,KAAK,iCAAiC,GAAG,cACpE,MAAM,MAAM;AAAA,QAC5B;AAAA,MACF;AACA;AAAA,IACF;AACA,UAAM,IAAI;AAAA,MACR,aAAa,MAAM,uCAAuC,KAAK;AAAA,IAEjE;AAAA,EACF;AACA,SAAO,CAAC,WACN,OAAO,QAAQ,kBAAkB,CAAC,MAAM,UAAkB;AACxD,QAAI,UAAU,MAAO,QAAO,OAAO,MAAM;AACzC,UAAM,WAAW,cAAc,KAAK,KAAK;AACzC,QAAI,SAAU,QAAO,OAAO,MAAM,EAAE,SAAS,OAAO,SAAS,CAAC,CAAC,GAAG,GAAG;AACrE,UAAM,YAAY,oBAAoB,KAAK,KAAK;AAChD,QAAI,UAAW,QAAO,OAAO,MAAM,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACxD,WAAO;AAAA,EACT,CAAC;AACL;AAeO,SAAS,mBAAmB,QAAgB,MAAgC;AACjF,QAAM,YAAY,MAAM;AACxB,MAAI,CAAC,aAAa,UAAU,WAAW,EAAG,QAAO;AACjD,QAAM,QAAQ,UAAU,IAAI,CAAC,MAAM;AACjC,QAAI,OAAO,MAAM,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG;AAChD,YAAM,IAAI,gBAAgB,6DAA6D,CAAC,EAAE;AAAA,IAC5F;AACA,UAAM,IAAI,OAAO,CAAC;AAClB,QAAI,MAAM,IAAI;AACZ,YAAM,IAAI,gBAAgB,gDAAgD;AAAA,IAC5E;AACA,WAAO,mBAAmB,CAAC;AAAA,EAC7B,CAAC;AACD,SAAO,GAAG,MAAM,KAAO,MAAM,KAAK,GAAG,CAAC;AACxC;AAqBA,eAAe,aAAa,SAAgC;AAG1D,QAAM,OAAO,KAAK,IAAI,KAAK,SAAS,EAAE;AACtC,QAAM,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI;AAC1C,QAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC5C;AAWO,IAAM,gBAAN,MAAoB;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQT,aAAyC;AAAA,EAEjD,YAAY,MAA4B;AACtC,SAAK,UAAU,KAAK;AACpB,SAAK,QAAQ,KAAK;AAClB,SAAK,YAAY,KAAK;AACtB,SAAK,SAAS,KAAK;AACnB,SAAK,QAAQ,KAAK;AAAA,EACpB;AAAA;AAAA,EAGA,OAAO,MAA8B;AACnC,WAAO;AAAA,MACL,MAAM,MAAM,KAAK,KAAK,IAAI;AAAA,MAC1B,MAAM,MAAM,KAAK,KAAK,IAAI;AAAA,MAC1B,QAAQ,CAAC,MAAM,KAAK,OAAO,MAAM,CAAC;AAAA,IACpC;AAAA,EACF;AAAA,EAEQ,eAAqB;AAC3B,QAAI,KAAK,QAAQ,cAAc,cAAc,MAAM;AACjD,YAAM,IAAI,qBAAqB;AAAA,IACjC;AAAA,EACF;AAAA,EAEQ,MAA2B;AACjC,QAAI,CAAC,KAAK,WAAY,MAAK,aAAa,KAAK,OAAO,mBAAmB;AACvE,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAc,KAAK,MAAyE;AAC1F,UAAM,MAAM,MAAM,KAAK,QAAQ,IAAI,KAAK,OAAO,qBAAqB,IAAI;AACxE,QAAI,CAAC,IAAK,QAAO,EAAE,KAAK,MAAM,OAAO,EAAE;AACvC,UAAM,OAAO,KAAK,YAAY,MAAM,iBAAiB,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,IAAI;AAClF,UAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,WAAO,EAAE,KAAK,OAAO,MAAM,MAAM;AAAA,EACnC;AAAA,EAEA,MAAc,aAAa,MAAc,OAAsB,SAA6C;AAC1G,UAAM,OAAO,KAAK,UAAU,KAAK;AACjC,QAAI,CAAC,KAAK,WAAW;AACnB,aAAO,oBAAoB,EAAE,YAAY,qBAAqB,IAAI,KAAK,GAAG,EAAE,SAAS,IAAI,IAAI,MAAM,MAAM,IAAI,KAAK,MAAM,CAAC;AAAA,IAC3H;AACA,UAAM,EAAE,IAAI,KAAK,IAAI,MAAM,QAAQ,MAAM,MAAM,KAAK,IAAI,CAAC;AACzD,WAAO,oBAAoB,EAAE,YAAY,qBAAqB,IAAI,KAAK,GAAG,EAAE,SAAS,IAAI,MAAM,IAAI,KAAK,MAAM,CAAC;AAAA,EACjH;AAAA,EAEA,MAAM,KAAK,MAA+B;AACxC,YAAQ,MAAM,KAAK,KAAK,IAAI,GAAG;AAAA,EACjC;AAAA,EAEA,MAAM,KAAK,MAA+B;AACxC,SAAK,aAAa;AAClB,QAAI;AACJ,aAAS,UAAU,GAAG,UAAU,mBAAmB,WAAW;AAC5D,YAAM,EAAE,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI;AAC3C,YAAM,YAAY,QAAQ;AAC1B,YAAM,kBAAkB,KAAK,MAAM;AACnC,YAAM,WAAW,MAAM,KAAK,aAAa,MAAM,EAAE,OAAO,UAAU,GAAG,kBAAkB,CAAC;AACxF,UAAI;AACF,cAAM,KAAK,QAAQ,IAAI,KAAK,OAAO,qBAAqB,MAAM,UAAU,eAAe;AACvF,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,YAAI,gBAAgB,GAAG,GAAG;AACxB,yBAAe;AACf,cAAI,UAAU,oBAAoB,EAAG,OAAM,aAAa,OAAO;AAC/D;AAAA,QACF;AACA,cAAM;AAAA,MACR;AAAA,IACF;AACA,SAAK;AACL,UAAM,IAAI,wBAAwB,MAAM,iBAAiB;AAAA,EAC3D;AAAA,EAEA,MAAM,OAAO,MAAc,GAA0B;AACnD,SAAK,aAAa;AAClB,QAAI,KAAK,EAAG;AACZ,QAAI;AACJ,aAAS,UAAU,GAAG,UAAU,mBAAmB,WAAW;AAC5D,YAAM,EAAE,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI;AAC3C,UAAI,SAAS,EAAG;AAChB,YAAM,kBAAkB,KAAK,MAAM;AACnC,YAAM,WAAW,MAAM,KAAK,aAAa,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC;AAChF,UAAI;AACF,cAAM,KAAK,QAAQ,IAAI,KAAK,OAAO,qBAAqB,MAAM,UAAU,eAAe;AACvF;AAAA,MACF,SAAS,KAAK;AACZ,YAAI,gBAAgB,GAAG,GAAG;AACxB,yBAAe;AACf,cAAI,UAAU,oBAAoB,EAAG,OAAM,aAAa,OAAO;AAC/D;AAAA,QACF;AACA,cAAM;AAAA,MACR;AAAA,IACF;AACA,SAAK;AACL,UAAM,IAAI,wBAAwB,MAAM,iBAAiB;AAAA,EAC3D;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/with-audit/attestation/issue.ts"],"sourcesContent":["import type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js'\nimport { NOYDB_FORMAT_VERSION } from '../../kernel/types.js'\nimport { encrypt, type EnclaveKey } from '../../kernel/enclave/index.js'\nimport { AttestationError } from '../../kernel/errors.js'\nimport { generateULID } from '../../with-pod/ulid.js'\nimport { loadOrCreateSigner, ATTESTATIONS_COLLECTION } from './signer.js'\nimport {\n computeFieldHashes, signPayloadCore, encodeQr, bytesToB64url,\n type AttestationFieldSchema, type QrPayload,\n} from '@noy-db/attestation'\n\n/** Everything issueAttestationCore needs from the Vault, injected for testability. */\nexport interface IssueContext {\n readonly store: NoydbStore\n readonly vault: string\n readonly role: string\n /** The _attestations collection DEK (AES-KW-wrapped under KEK by the keyring). */\n getDEK(): Promise<EnclaveKey>\n /** Decrypted source record + its envelope version, or null if absent. */\n readRecord(collection: string, id: string): Promise<{ record: Record<string, unknown>; version: number } | null>\n}\n\nexport interface IssueArgs {\n readonly collection: string\n readonly id: string\n readonly fieldSchema: AttestationFieldSchema\n}\nexport interface IssueResult {\n readonly docId: string\n readonly qr: string\n readonly payload: QrPayload\n readonly keyId: string\n readonly publicKeyB64: string\n}\n\nexport async function issueAttestationCore(ctx: IssueContext, args: IssueArgs): Promise<IssueResult> {\n if (ctx.role !== 'owner') {\n throw new AttestationError(`issueAttestation requires the 'owner' role; caller is '${ctx.role}'. Issuing a signed attestation is the firm's identity operation.`)\n }\n const src = await ctx.readRecord(args.collection, args.id)\n if (!src) throw new AttestationError(`issueAttestation: source record '${args.collection}/${args.id}' not found.`)\n\n const dek = await ctx.getDEK()\n // ONE signer implementation, from signer.ts. Lazily minted + persisted.\n const signer = await loadOrCreateSigner(ctx.store, ctx.vault, () => Promise.resolve(dek))\n\n const saltB64 = bytesToB64url(crypto.getRandomValues(new Uint8Array(16)))\n let fieldHashes: string[]\n try {\n fieldHashes = await computeFieldHashes(saltB64, args.fieldSchema, src.record)\n } catch (e) {\n throw new AttestationError(`issueAttestation: ${(e as Error).message}`)\n }\n const docId = generateULID()\n\n const sig = await signPayloadCore({ v: 1, docId, salt: saltB64, keyId: signer.keyId, fieldHashes }, signer.privateKeyPkcs8B64)\n const payload: QrPayload = { v: 1, docId, salt: saltB64, alg: 'ed25519', keyId: signer.keyId, fieldHashes, sig }\n\n const index = {\n docId, issuedAt: new Date().toISOString(), keyId: signer.keyId,\n fieldPaths: args.fieldSchema.fields.map((f) => f.path),\n sourceRefs: [{ collection: args.collection, id: args.id, version: src.version }],\n }\n const { iv, data } = await encrypt(JSON.stringify(index), dek)\n const env: EncryptedEnvelope = { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: index.issuedAt, _iv: iv, _data: data }\n await ctx.store.put(ctx.vault, ATTESTATIONS_COLLECTION, docId, env)\n\n return { docId, qr: encodeQr(payload), payload, keyId: signer.keyId, publicKeyB64: signer.publicKeyB64 }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA;AAAA,EACE;AAAA,EAAoB;AAAA,EAAiB;AAAA,EAAU;AAAA,OAE1C;AA0BP,eAAsB,qBAAqB,KAAmB,MAAuC;AACnG,MAAI,IAAI,SAAS,SAAS;AACxB,UAAM,IAAI,iBAAiB,0DAA0D,IAAI,IAAI,mEAAmE;AAAA,EAClK;AACA,QAAM,MAAM,MAAM,IAAI,WAAW,KAAK,YAAY,KAAK,EAAE;AACzD,MAAI,CAAC,IAAK,OAAM,IAAI,iBAAiB,oCAAoC,KAAK,UAAU,IAAI,KAAK,EAAE,cAAc;AAEjH,QAAM,MAAM,MAAM,IAAI,OAAO;AAE7B,QAAM,SAAS,MAAM,mBAAmB,IAAI,OAAO,IAAI,OAAO,MAAM,QAAQ,QAAQ,GAAG,CAAC;AAExF,QAAM,UAAU,cAAc,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAAC;AACxE,MAAI;AACJ,MAAI;AACF,kBAAc,MAAM,mBAAmB,SAAS,KAAK,aAAa,IAAI,MAAM;AAAA,EAC9E,SAAS,GAAG;AACV,UAAM,IAAI,iBAAiB,qBAAsB,EAAY,OAAO,EAAE;AAAA,EACxE;AACA,QAAM,QAAQ,aAAa;AAE3B,QAAM,MAAM,MAAM,gBAAgB,EAAE,GAAG,GAAG,OAAO,MAAM,SAAS,OAAO,OAAO,OAAO,YAAY,GAAG,OAAO,kBAAkB;AAC7H,QAAM,UAAqB,EAAE,GAAG,GAAG,OAAO,MAAM,SAAS,KAAK,WAAW,OAAO,OAAO,OAAO,aAAa,IAAI;AAE/G,QAAM,QAAQ;AAAA,IACZ;AAAA,IAAO,WAAU,oBAAI,KAAK,GAAE,YAAY;AAAA,IAAG,OAAO,OAAO;AAAA,IACzD,YAAY,KAAK,YAAY,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACrD,YAAY,CAAC,EAAE,YAAY,KAAK,YAAY,IAAI,KAAK,IAAI,SAAS,IAAI,QAAQ,CAAC;AAAA,EACjF;AACA,QAAM,EAAE,IAAI,KAAK,IAAI,MAAM,QAAQ,KAAK,UAAU,KAAK,GAAG,GAAG;AAC7D,QAAM,MAAyB,EAAE,QAAQ,sBAAsB,IAAI,GAAG,KAAK,MAAM,UAAU,KAAK,IAAI,OAAO,KAAK;AAChH,QAAM,IAAI,MAAM,IAAI,IAAI,OAAO,yBAAyB,OAAO,GAAG;AAElE,SAAO,EAAE,OAAO,IAAI,SAAS,OAAO,GAAG,SAAS,OAAO,OAAO,OAAO,cAAc,OAAO,aAAa;AACzG;","names":[]}