@noy-db/hub 0.4.0-pre.3 → 0.4.0-pre.5

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 (381) hide show
  1. package/README.md +2 -2
  2. package/dist/aggregate/index.js +4 -4
  3. package/dist/api-22ES33N3.js +20 -0
  4. package/dist/as/index.js +11 -11
  5. package/dist/attestation/index.js +20 -20
  6. package/dist/{backup-JL2GOTYQ.js → backup-YCHAC575.js} +11 -11
  7. package/dist/blobs/index.js +12 -12
  8. package/dist/broker/index.js +12 -12
  9. package/dist/by/index.js +2 -2
  10. package/dist/cargo/index.js +29 -29
  11. package/dist/{chunk-2RMDVWGB.js → chunk-2CRZOVDI.js} +2 -2
  12. package/dist/{chunk-T7S4V52L.js → chunk-2PDBYF2O.js} +4 -4
  13. package/dist/{chunk-WJDYZP3U.js → chunk-3LJYHE7S.js} +36 -36
  14. package/dist/chunk-3LJYHE7S.js.map +1 -0
  15. package/dist/{chunk-CCT4WZI6.js → chunk-3OWYOECI.js} +5 -5
  16. package/dist/chunk-3OWYOECI.js.map +1 -0
  17. package/dist/{chunk-L4OA7G5T.js → chunk-522MBPE5.js} +2 -2
  18. package/dist/{chunk-ZJGZDOQO.js → chunk-5ATANZSW.js} +6 -6
  19. package/dist/{chunk-M25ZIEB2.js → chunk-5HSSTOOG.js} +2 -2
  20. package/dist/{chunk-LLVW4V7R.js → chunk-5WLDZZ6S.js} +3 -3
  21. package/dist/{chunk-7B4GPCX7.js → chunk-6RPWILRH.js} +5 -5
  22. package/dist/{chunk-IGM563N5.js → chunk-6SYOHUHM.js} +6 -6
  23. package/dist/chunk-6SYOHUHM.js.map +1 -0
  24. package/dist/{chunk-HGVFJL63.js → chunk-7BIJS6II.js} +15 -5
  25. package/dist/{chunk-HGVFJL63.js.map → chunk-7BIJS6II.js.map} +1 -1
  26. package/dist/{chunk-KR5EGWI4.js → chunk-7ICV4ASA.js} +5 -5
  27. package/dist/{chunk-J3VW4J4E.js → chunk-7LP7FFJ2.js} +2 -2
  28. package/dist/chunk-7LP7FFJ2.js.map +1 -0
  29. package/dist/{chunk-5P5AAXYA.js → chunk-7U6AB7DZ.js} +7 -7
  30. package/dist/chunk-7U6AB7DZ.js.map +1 -0
  31. package/dist/{chunk-KMONEHDJ.js → chunk-AFAPBZAA.js} +2 -2
  32. package/dist/{chunk-GBEXTC6Z.js → chunk-BAAUFCJK.js} +3 -3
  33. package/dist/chunk-BAAUFCJK.js.map +1 -0
  34. package/dist/{chunk-CGPO3ZYB.js → chunk-BY5YBSXA.js} +2 -2
  35. package/dist/{chunk-3O62PVDW.js → chunk-CJVEAVYH.js} +5 -5
  36. package/dist/chunk-CJVEAVYH.js.map +1 -0
  37. package/dist/{chunk-3XVOLB75.js → chunk-CKUYQO2P.js} +3 -3
  38. package/dist/{chunk-2JZ763FV.js → chunk-D4LAJ737.js} +2 -2
  39. package/dist/{chunk-OOTTXUNV.js → chunk-DYZ5CCVM.js} +2 -2
  40. package/dist/{chunk-LUH2MPEF.js → chunk-EEZCB74X.js} +808 -1175
  41. package/dist/chunk-EEZCB74X.js.map +1 -0
  42. package/dist/{chunk-N4FZ6ITM.js → chunk-EGU4PWQW.js} +2 -2
  43. package/dist/{chunk-JKWNG3TM.js → chunk-FHHYCBBP.js} +2 -2
  44. package/dist/{chunk-UBF7HTOR.js → chunk-FIP7KI2P.js} +40 -40
  45. package/dist/chunk-FIP7KI2P.js.map +1 -0
  46. package/dist/{chunk-N4A3DCBT.js → chunk-FTCGEUOY.js} +8 -8
  47. package/dist/{chunk-5BB3N4KU.js → chunk-G4MFQXYX.js} +2 -2
  48. package/dist/{chunk-PEY6ZTCF.js → chunk-GEEJPID6.js} +9 -9
  49. package/dist/{chunk-PEY6ZTCF.js.map → chunk-GEEJPID6.js.map} +1 -1
  50. package/dist/{chunk-KVHWEPT2.js → chunk-GHEMAVTN.js} +2 -2
  51. package/dist/{chunk-OVFCAS7U.js → chunk-GP54LU5N.js} +9 -9
  52. package/dist/{chunk-XW7NWO4A.js → chunk-GTNRMJYH.js} +2 -2
  53. package/dist/{chunk-J6U4BOKP.js → chunk-HAPY7WFP.js} +12 -12
  54. package/dist/{chunk-GU5AYA2Q.js → chunk-HQKRZIX6.js} +5 -5
  55. package/dist/{chunk-OWE4BNTM.js → chunk-I2XEBEEF.js} +4 -4
  56. package/dist/{chunk-WEC3JGBA.js → chunk-IGLU4ME7.js} +3 -3
  57. package/dist/{chunk-BZK6JEX4.js → chunk-ILM6X6CP.js} +5 -5
  58. package/dist/{chunk-2KL6NDD4.js → chunk-J5TEU77Q.js} +4 -4
  59. package/dist/{chunk-UEO5CHOP.js → chunk-JAMDDLIM.js} +13 -13
  60. package/dist/chunk-JAMDDLIM.js.map +1 -0
  61. package/dist/{chunk-V7RGFJ3Z.js → chunk-JIHH26WQ.js} +6 -6
  62. package/dist/{chunk-XGVDLQJE.js → chunk-JN3SGXJE.js} +3 -3
  63. package/dist/{chunk-XULHFSHO.js → chunk-K4BWPNJO.js} +5 -5
  64. package/dist/chunk-K4BWPNJO.js.map +1 -0
  65. package/dist/{chunk-BZEPJJOK.js → chunk-K7BADAOS.js} +4 -4
  66. package/dist/{chunk-OWLPX2GI.js → chunk-KJTIAECI.js} +17 -17
  67. package/dist/chunk-KJTIAECI.js.map +1 -0
  68. package/dist/{chunk-SN75YVM5.js → chunk-L2CAWCQL.js} +18 -18
  69. package/dist/{chunk-SN75YVM5.js.map → chunk-L2CAWCQL.js.map} +1 -1
  70. package/dist/{chunk-MSO2C3KG.js → chunk-LC7DSMHR.js} +2 -2
  71. package/dist/{chunk-JA5B3SLH.js → chunk-M6QA2KK2.js} +2 -2
  72. package/dist/{chunk-IUIVDVXM.js → chunk-MUPZ6IZX.js} +2 -2
  73. package/dist/{chunk-QAFWRGVD.js → chunk-OGVE4IJW.js} +7 -7
  74. package/dist/{chunk-BCOKZC4B.js → chunk-OHV6T5JB.js} +19 -19
  75. package/dist/chunk-OHV6T5JB.js.map +1 -0
  76. package/dist/{chunk-25ZDB25Z.js → chunk-OMSKGLYA.js} +3 -3
  77. package/dist/chunk-OMSKGLYA.js.map +1 -0
  78. package/dist/{chunk-2U7Y7BNJ.js → chunk-ONB627HU.js} +2 -2
  79. package/dist/{chunk-GYB2QK5H.js → chunk-OWLZONGX.js} +2 -2
  80. package/dist/{chunk-YHPUDB7Q.js → chunk-OWOT7CFC.js} +2 -2
  81. package/dist/{chunk-VEX6G3YL.js → chunk-P4NUJVWL.js} +2 -2
  82. package/dist/{chunk-NM4LVUXH.js → chunk-PTT2NB46.js} +2 -2
  83. package/dist/{chunk-2ITLQZV5.js → chunk-PWWWMRT7.js} +2 -2
  84. package/dist/{chunk-GS3Q2KOZ.js → chunk-QBOQI6PG.js} +2 -2
  85. package/dist/{chunk-JIMEB4C6.js → chunk-QMMOMBH6.js} +4 -4
  86. package/dist/{chunk-QDNVHA2F.js → chunk-QMZ5A6FQ.js} +2 -2
  87. package/dist/{chunk-FLHOTGOO.js → chunk-QVGEVZ5F.js} +3 -3
  88. package/dist/{chunk-AFBJHD55.js → chunk-QZJEYZ4I.js} +5 -5
  89. package/dist/{chunk-V3YB7RGR.js → chunk-R2N37AA6.js} +3 -3
  90. package/dist/{chunk-JLHKBAFY.js → chunk-RWW3I3PO.js} +3 -3
  91. package/dist/{chunk-IGAIOGCN.js → chunk-S4YERMGJ.js} +4 -4
  92. package/dist/{chunk-OGFPMCSP.js → chunk-SBOHNJUD.js} +2 -2
  93. package/dist/{chunk-QXPOEAKR.js → chunk-SC4JLMZI.js} +2 -2
  94. package/dist/{chunk-EDC6MLXV.js → chunk-SEU6QHH4.js} +2 -2
  95. package/dist/{chunk-F4COUZLL.js → chunk-TMR64XPL.js} +2 -2
  96. package/dist/{chunk-DEQ2JTBR.js → chunk-TNATF3HB.js} +3 -3
  97. package/dist/{chunk-GZ2GKOF6.js → chunk-TNJVDG2B.js} +3 -3
  98. package/dist/{chunk-5OZCCLNC.js → chunk-TSNRZSRC.js} +2 -2
  99. package/dist/{chunk-QCUH2G77.js → chunk-UTEATWHO.js} +6 -6
  100. package/dist/{chunk-JA5O7UEZ.js → chunk-UVBHM7AK.js} +6 -6
  101. package/dist/chunk-UVBHM7AK.js.map +1 -0
  102. package/dist/{chunk-HKR25MGX.js → chunk-V5JUAW4M.js} +10 -10
  103. package/dist/chunk-V5JUAW4M.js.map +1 -0
  104. package/dist/{chunk-YGBIBOCR.js → chunk-VEGQYPCP.js} +7 -7
  105. package/dist/{chunk-25G7U6RD.js → chunk-WQN5SM7P.js} +2 -2
  106. package/dist/{chunk-NOT7XA7Q.js → chunk-X3MWEFPT.js} +5 -5
  107. package/dist/chunk-XUFAFHQM.js +78 -0
  108. package/dist/chunk-XUFAFHQM.js.map +1 -0
  109. package/dist/{chunk-MEKAMERX.js → chunk-YCAJDK4O.js} +29 -29
  110. package/dist/chunk-YCAJDK4O.js.map +1 -0
  111. package/dist/{chunk-BVZGNMVM.js → chunk-YFFEF6HR.js} +3 -3
  112. package/dist/{chunk-H4SMS4O2.js → chunk-YJ3TREAC.js} +2 -2
  113. package/dist/{chunk-5SZ24DL5.js → chunk-YQQPNXNO.js} +6 -6
  114. package/dist/{chunk-5BHNQNBI.js → chunk-YTW6ZIPD.js} +1 -1
  115. package/dist/chunk-YTW6ZIPD.js.map +1 -0
  116. package/dist/{chunk-EW4HFWGJ.js → chunk-YWZEDG7F.js} +6 -6
  117. package/dist/{chunk-2VUISNGP.js → chunk-YXIVUWDU.js} +5 -5
  118. package/dist/{chunk-YG2EG6CB.js → chunk-YXZNGHID.js} +4 -4
  119. package/dist/{chunk-QYJIOWKN.js → chunk-YZN6NRTR.js} +9 -9
  120. package/dist/{chunk-IZX3WZBF.js → chunk-YZNKFYDC.js} +4 -4
  121. package/dist/{chunk-E2R5NRZD.js → chunk-Z4D3YGAB.js} +2 -2
  122. package/dist/{chunk-STR7WBOB.js → chunk-ZUDAK436.js} +2 -2
  123. package/dist/{chunk-ITI3SJRB.js → chunk-ZX5FNWH7.js} +2 -2
  124. package/dist/classified/index.js +5 -5
  125. package/dist/{classified-marker-7S5IEP6Q.js → classified-marker-52P3D72W.js} +3 -3
  126. package/dist/collection-facade-XKCFHSLR.js +44 -0
  127. package/dist/{computed-WZNKRLCY.js → computed-33DRJDOC.js} +3 -3
  128. package/dist/consent/index.js +9 -9
  129. package/dist/{cover-B5MY43CK.js → cover-5BSNJREH.js} +4 -4
  130. package/dist/{dead-filter-KRRD57MR.js → dead-filter-JXVCKS6W.js} +2 -2
  131. package/dist/delegation-WWZPEDK2.js +25 -0
  132. package/dist/derivations/index.js +12 -12
  133. package/dist/derive-CWWFEQ4N.js +21 -0
  134. package/dist/dispatch-PKQQFDBT.js +193 -0
  135. package/dist/dispatch-PKQQFDBT.js.map +1 -0
  136. package/dist/dispatch-SMXUO7W5.js +72 -0
  137. package/dist/dispatch-SMXUO7W5.js.map +1 -0
  138. package/dist/{enclave-YFKA3GJT.js → enclave-I5H3GINP.js} +11 -11
  139. package/dist/executor-FCJEH3FU.js +9 -0
  140. package/dist/executor-OHET7TF7.js +9 -0
  141. package/dist/executor-SHYLIBOM.js +26 -0
  142. package/dist/export-accessible-FBL6TDSK.js +23 -0
  143. package/dist/extract-partition-ZYIRYMTI.js +38 -0
  144. package/dist/{fanout-sidecar-HJV3A7PM.js → fanout-sidecar-WWXVHHUH.js} +9 -9
  145. package/dist/find-LEBUXVL7.js +11 -0
  146. package/dist/forget/index.js +9 -9
  147. package/dist/guards/index.js +3 -3
  148. package/dist/history/index.js +12 -12
  149. package/dist/i18n/index.js +14 -14
  150. package/dist/index.d.ts +13 -9
  151. package/dist/index.js +119 -118
  152. package/dist/index.js.map +1 -1
  153. package/dist/indexing/index.js +2 -2
  154. package/dist/issue-F76PAGIR.js +19 -0
  155. package/dist/kernel/collection-config.d.ts +11 -69
  156. package/dist/kernel/collection.d.ts +10 -22
  157. package/dist/kernel/enclave/crypto.d.ts +8 -8
  158. package/dist/kernel/enclave/index.d.ts +2 -2
  159. package/dist/kernel/errors.d.ts +20 -20
  160. package/dist/kernel/noydb.d.ts +43 -103
  161. package/dist/kernel/types.d.ts +82 -41
  162. package/dist/kernel/validation.d.ts +33 -33
  163. package/dist/kernel/vault.d.ts +31 -215
  164. package/dist/kernel/via/dispatch.d.ts +7 -0
  165. package/dist/{ledger-SW6QQOAV.js → ledger-M2BKCNVS.js} +11 -11
  166. package/dist/liberate-ZP7UB57K.js +24 -0
  167. package/dist/{link-set-GNGGCFI4.js → link-set-ZU4E5J5S.js} +11 -11
  168. package/dist/materialized-views/index.js +19 -19
  169. package/dist/noydb-BNDGEK5X.js +71 -0
  170. package/dist/on/index.js +9 -9
  171. package/dist/overlay-views/index.js +4 -4
  172. package/dist/periods/index.js +13 -13
  173. package/dist/pod/index.js +11 -11
  174. package/dist/{policy-EAXSJNOT.js → policy-IY2YEA3A.js} +5 -5
  175. package/dist/port/at/index.d.ts +4 -4
  176. package/dist/port/with/archive-strategy.d.ts +31 -0
  177. package/dist/port/with/collection-options.d.ts +171 -0
  178. package/dist/port/with/strategies.d.ts +134 -0
  179. package/dist/port/with/team-strategy.d.ts +1 -1
  180. package/dist/portability/index.js +8 -8
  181. package/dist/{post-register-A7HCFBP5.js → post-register-XIAHB6KF.js} +6 -6
  182. package/dist/query/index.js +6 -6
  183. package/dist/register-HB4TQZSV.js +23 -0
  184. package/dist/registry-6BMBFEXT.js +19 -0
  185. package/dist/registry-7CZWF3EQ.js +9 -0
  186. package/dist/registry-JOFO7RAH.js +18 -0
  187. package/dist/request-withdrawal-UN3TRHWI.js +31 -0
  188. package/dist/{reveal-PB3YG544.js → reveal-VWXRV2XU.js} +6 -6
  189. package/dist/revoke-OLO2OVR7.js +24 -0
  190. package/dist/satellites/index.js +1 -1
  191. package/dist/sealed-record/index.js +12 -12
  192. package/dist/{seed-EKF4DIBB.js → seed-CDBFOTIK.js} +12 -12
  193. package/dist/seed-CDBFOTIK.js.map +1 -0
  194. package/dist/session/index.js +9 -9
  195. package/dist/shadow/index.js +2 -2
  196. package/dist/signer-MGGKPYAN.js +25 -0
  197. package/dist/snapshots/index.js +10 -10
  198. package/dist/{stale-4UNPHWOU.js → stale-NBROTA66.js} +10 -10
  199. package/dist/storage-3R37QZLA.js +23 -0
  200. package/dist/{store-coordination-provider-3AELCZ4Y.js → store-coordination-provider-P3IU5JHD.js} +3 -3
  201. package/dist/sync/index.js +10 -10
  202. package/dist/team/index.js +20 -20
  203. package/dist/tiers/index.js +10 -10
  204. package/dist/to/index.js +1 -1
  205. package/dist/tx/index.js +3 -3
  206. package/dist/util/index.js +1 -1
  207. package/dist/{verify-MXN66IIH.js → verify-5X37OXRY.js} +5 -5
  208. package/dist/{walk-H4YE52S2.js → walk-E3OVLBFR.js} +11 -11
  209. package/dist/with/index.js +11 -11
  210. package/dist/with-audit/portability/export-accessible.d.ts +4 -4
  211. package/dist/with-audit/portability/request-withdrawal.d.ts +3 -3
  212. package/dist/with-audit/portability/withdraw-accessible.d.ts +2 -2
  213. package/dist/with-audit/sealed-record/strategy.d.ts +1 -1
  214. package/dist/with-cargo/adopt-partition.d.ts +7 -7
  215. package/dist/with-cargo/index.d.ts +1 -1
  216. package/dist/with-commit/history/time-machine.d.ts +2 -2
  217. package/dist/with-formula/derivations/dispatch.d.ts +98 -0
  218. package/dist/with-formula/materialized-views/dispatch.d.ts +75 -0
  219. package/dist/with-party/custody/liberate.d.ts +3 -3
  220. package/dist/with-party/session/dev-unlock.d.ts +2 -2
  221. package/dist/with-party/session/session.d.ts +2 -2
  222. package/dist/with-party/team/deed.d.ts +8 -8
  223. package/dist/with-party/team/index.d.ts +2 -2
  224. package/dist/with-party/team/keyring.d.ts +19 -19
  225. package/dist/with-party/team/{managed-passphrase.d.ts → managed-secret.d.ts} +27 -27
  226. package/dist/with-party/team/noydb-facade.d.ts +41 -41
  227. package/dist/with-party/team/peer-recover.d.ts +13 -13
  228. package/dist/with-party/team/recovery.d.ts +5 -5
  229. package/dist/with-party/team/rotate-recover.d.ts +30 -30
  230. package/dist/with-pod/bundle.d.ts +30 -30
  231. package/dist/with-pod/format.d.ts +2 -2
  232. package/dist/withdraw-accessible-Q2EMATCU.js +28 -0
  233. package/package.json +3 -3
  234. package/dist/api-UPAT2O3M.js +0 -20
  235. package/dist/chunk-25ZDB25Z.js.map +0 -1
  236. package/dist/chunk-3O62PVDW.js.map +0 -1
  237. package/dist/chunk-5BHNQNBI.js.map +0 -1
  238. package/dist/chunk-5P5AAXYA.js.map +0 -1
  239. package/dist/chunk-BCOKZC4B.js.map +0 -1
  240. package/dist/chunk-CCT4WZI6.js.map +0 -1
  241. package/dist/chunk-GBEXTC6Z.js.map +0 -1
  242. package/dist/chunk-HKR25MGX.js.map +0 -1
  243. package/dist/chunk-IGM563N5.js.map +0 -1
  244. package/dist/chunk-J3VW4J4E.js.map +0 -1
  245. package/dist/chunk-JA5O7UEZ.js.map +0 -1
  246. package/dist/chunk-LUH2MPEF.js.map +0 -1
  247. package/dist/chunk-MEKAMERX.js.map +0 -1
  248. package/dist/chunk-OWLPX2GI.js.map +0 -1
  249. package/dist/chunk-UBF7HTOR.js.map +0 -1
  250. package/dist/chunk-UEO5CHOP.js.map +0 -1
  251. package/dist/chunk-WJDYZP3U.js.map +0 -1
  252. package/dist/chunk-XULHFSHO.js.map +0 -1
  253. package/dist/collection-facade-ENLTJZBT.js +0 -44
  254. package/dist/delegation-UT76AQIG.js +0 -25
  255. package/dist/derive-SGRCCKVP.js +0 -21
  256. package/dist/executor-TEZYRDN3.js +0 -9
  257. package/dist/executor-WQQRU6DO.js +0 -9
  258. package/dist/executor-YORMIBWV.js +0 -26
  259. package/dist/export-accessible-HXMKW5LJ.js +0 -23
  260. package/dist/extract-partition-QGQ2R42J.js +0 -38
  261. package/dist/find-VV6PBIHK.js +0 -11
  262. package/dist/issue-7JJ4Z7E2.js +0 -19
  263. package/dist/liberate-FK7JI2QX.js +0 -24
  264. package/dist/noydb-KUX2TJMX.js +0 -70
  265. package/dist/register-YBMRLZLO.js +0 -23
  266. package/dist/registry-3LXKNXWI.js +0 -9
  267. package/dist/registry-4V4YQCXJ.js +0 -19
  268. package/dist/registry-ZULMLCJK.js +0 -18
  269. package/dist/request-withdrawal-SEVUEUDG.js +0 -31
  270. package/dist/revoke-5QULL5GT.js +0 -24
  271. package/dist/seed-EKF4DIBB.js.map +0 -1
  272. package/dist/signer-ZMH35FT4.js +0 -25
  273. package/dist/storage-QOZKQMID.js +0 -23
  274. package/dist/withdraw-accessible-HPOVNG2G.js +0 -28
  275. /package/dist/{api-UPAT2O3M.js.map → api-22ES33N3.js.map} +0 -0
  276. /package/dist/{backup-JL2GOTYQ.js.map → backup-YCHAC575.js.map} +0 -0
  277. /package/dist/{chunk-2RMDVWGB.js.map → chunk-2CRZOVDI.js.map} +0 -0
  278. /package/dist/{chunk-T7S4V52L.js.map → chunk-2PDBYF2O.js.map} +0 -0
  279. /package/dist/{chunk-L4OA7G5T.js.map → chunk-522MBPE5.js.map} +0 -0
  280. /package/dist/{chunk-ZJGZDOQO.js.map → chunk-5ATANZSW.js.map} +0 -0
  281. /package/dist/{chunk-M25ZIEB2.js.map → chunk-5HSSTOOG.js.map} +0 -0
  282. /package/dist/{chunk-LLVW4V7R.js.map → chunk-5WLDZZ6S.js.map} +0 -0
  283. /package/dist/{chunk-7B4GPCX7.js.map → chunk-6RPWILRH.js.map} +0 -0
  284. /package/dist/{chunk-KR5EGWI4.js.map → chunk-7ICV4ASA.js.map} +0 -0
  285. /package/dist/{chunk-KMONEHDJ.js.map → chunk-AFAPBZAA.js.map} +0 -0
  286. /package/dist/{chunk-CGPO3ZYB.js.map → chunk-BY5YBSXA.js.map} +0 -0
  287. /package/dist/{chunk-3XVOLB75.js.map → chunk-CKUYQO2P.js.map} +0 -0
  288. /package/dist/{chunk-2JZ763FV.js.map → chunk-D4LAJ737.js.map} +0 -0
  289. /package/dist/{chunk-OOTTXUNV.js.map → chunk-DYZ5CCVM.js.map} +0 -0
  290. /package/dist/{chunk-N4FZ6ITM.js.map → chunk-EGU4PWQW.js.map} +0 -0
  291. /package/dist/{chunk-JKWNG3TM.js.map → chunk-FHHYCBBP.js.map} +0 -0
  292. /package/dist/{chunk-N4A3DCBT.js.map → chunk-FTCGEUOY.js.map} +0 -0
  293. /package/dist/{chunk-5BB3N4KU.js.map → chunk-G4MFQXYX.js.map} +0 -0
  294. /package/dist/{chunk-KVHWEPT2.js.map → chunk-GHEMAVTN.js.map} +0 -0
  295. /package/dist/{chunk-OVFCAS7U.js.map → chunk-GP54LU5N.js.map} +0 -0
  296. /package/dist/{chunk-XW7NWO4A.js.map → chunk-GTNRMJYH.js.map} +0 -0
  297. /package/dist/{chunk-J6U4BOKP.js.map → chunk-HAPY7WFP.js.map} +0 -0
  298. /package/dist/{chunk-GU5AYA2Q.js.map → chunk-HQKRZIX6.js.map} +0 -0
  299. /package/dist/{chunk-OWE4BNTM.js.map → chunk-I2XEBEEF.js.map} +0 -0
  300. /package/dist/{chunk-WEC3JGBA.js.map → chunk-IGLU4ME7.js.map} +0 -0
  301. /package/dist/{chunk-BZK6JEX4.js.map → chunk-ILM6X6CP.js.map} +0 -0
  302. /package/dist/{chunk-2KL6NDD4.js.map → chunk-J5TEU77Q.js.map} +0 -0
  303. /package/dist/{chunk-V7RGFJ3Z.js.map → chunk-JIHH26WQ.js.map} +0 -0
  304. /package/dist/{chunk-XGVDLQJE.js.map → chunk-JN3SGXJE.js.map} +0 -0
  305. /package/dist/{chunk-BZEPJJOK.js.map → chunk-K7BADAOS.js.map} +0 -0
  306. /package/dist/{chunk-MSO2C3KG.js.map → chunk-LC7DSMHR.js.map} +0 -0
  307. /package/dist/{chunk-JA5B3SLH.js.map → chunk-M6QA2KK2.js.map} +0 -0
  308. /package/dist/{chunk-IUIVDVXM.js.map → chunk-MUPZ6IZX.js.map} +0 -0
  309. /package/dist/{chunk-QAFWRGVD.js.map → chunk-OGVE4IJW.js.map} +0 -0
  310. /package/dist/{chunk-2U7Y7BNJ.js.map → chunk-ONB627HU.js.map} +0 -0
  311. /package/dist/{chunk-GYB2QK5H.js.map → chunk-OWLZONGX.js.map} +0 -0
  312. /package/dist/{chunk-YHPUDB7Q.js.map → chunk-OWOT7CFC.js.map} +0 -0
  313. /package/dist/{chunk-VEX6G3YL.js.map → chunk-P4NUJVWL.js.map} +0 -0
  314. /package/dist/{chunk-NM4LVUXH.js.map → chunk-PTT2NB46.js.map} +0 -0
  315. /package/dist/{chunk-2ITLQZV5.js.map → chunk-PWWWMRT7.js.map} +0 -0
  316. /package/dist/{chunk-GS3Q2KOZ.js.map → chunk-QBOQI6PG.js.map} +0 -0
  317. /package/dist/{chunk-JIMEB4C6.js.map → chunk-QMMOMBH6.js.map} +0 -0
  318. /package/dist/{chunk-QDNVHA2F.js.map → chunk-QMZ5A6FQ.js.map} +0 -0
  319. /package/dist/{chunk-FLHOTGOO.js.map → chunk-QVGEVZ5F.js.map} +0 -0
  320. /package/dist/{chunk-AFBJHD55.js.map → chunk-QZJEYZ4I.js.map} +0 -0
  321. /package/dist/{chunk-V3YB7RGR.js.map → chunk-R2N37AA6.js.map} +0 -0
  322. /package/dist/{chunk-JLHKBAFY.js.map → chunk-RWW3I3PO.js.map} +0 -0
  323. /package/dist/{chunk-IGAIOGCN.js.map → chunk-S4YERMGJ.js.map} +0 -0
  324. /package/dist/{chunk-OGFPMCSP.js.map → chunk-SBOHNJUD.js.map} +0 -0
  325. /package/dist/{chunk-QXPOEAKR.js.map → chunk-SC4JLMZI.js.map} +0 -0
  326. /package/dist/{chunk-EDC6MLXV.js.map → chunk-SEU6QHH4.js.map} +0 -0
  327. /package/dist/{chunk-F4COUZLL.js.map → chunk-TMR64XPL.js.map} +0 -0
  328. /package/dist/{chunk-DEQ2JTBR.js.map → chunk-TNATF3HB.js.map} +0 -0
  329. /package/dist/{chunk-GZ2GKOF6.js.map → chunk-TNJVDG2B.js.map} +0 -0
  330. /package/dist/{chunk-5OZCCLNC.js.map → chunk-TSNRZSRC.js.map} +0 -0
  331. /package/dist/{chunk-QCUH2G77.js.map → chunk-UTEATWHO.js.map} +0 -0
  332. /package/dist/{chunk-YGBIBOCR.js.map → chunk-VEGQYPCP.js.map} +0 -0
  333. /package/dist/{chunk-25G7U6RD.js.map → chunk-WQN5SM7P.js.map} +0 -0
  334. /package/dist/{chunk-NOT7XA7Q.js.map → chunk-X3MWEFPT.js.map} +0 -0
  335. /package/dist/{chunk-BVZGNMVM.js.map → chunk-YFFEF6HR.js.map} +0 -0
  336. /package/dist/{chunk-H4SMS4O2.js.map → chunk-YJ3TREAC.js.map} +0 -0
  337. /package/dist/{chunk-5SZ24DL5.js.map → chunk-YQQPNXNO.js.map} +0 -0
  338. /package/dist/{chunk-EW4HFWGJ.js.map → chunk-YWZEDG7F.js.map} +0 -0
  339. /package/dist/{chunk-2VUISNGP.js.map → chunk-YXIVUWDU.js.map} +0 -0
  340. /package/dist/{chunk-YG2EG6CB.js.map → chunk-YXZNGHID.js.map} +0 -0
  341. /package/dist/{chunk-QYJIOWKN.js.map → chunk-YZN6NRTR.js.map} +0 -0
  342. /package/dist/{chunk-IZX3WZBF.js.map → chunk-YZNKFYDC.js.map} +0 -0
  343. /package/dist/{chunk-E2R5NRZD.js.map → chunk-Z4D3YGAB.js.map} +0 -0
  344. /package/dist/{chunk-STR7WBOB.js.map → chunk-ZUDAK436.js.map} +0 -0
  345. /package/dist/{chunk-ITI3SJRB.js.map → chunk-ZX5FNWH7.js.map} +0 -0
  346. /package/dist/{classified-marker-7S5IEP6Q.js.map → classified-marker-52P3D72W.js.map} +0 -0
  347. /package/dist/{collection-facade-ENLTJZBT.js.map → collection-facade-XKCFHSLR.js.map} +0 -0
  348. /package/dist/{computed-WZNKRLCY.js.map → computed-33DRJDOC.js.map} +0 -0
  349. /package/dist/{cover-B5MY43CK.js.map → cover-5BSNJREH.js.map} +0 -0
  350. /package/dist/{dead-filter-KRRD57MR.js.map → dead-filter-JXVCKS6W.js.map} +0 -0
  351. /package/dist/{delegation-UT76AQIG.js.map → delegation-WWZPEDK2.js.map} +0 -0
  352. /package/dist/{derive-SGRCCKVP.js.map → derive-CWWFEQ4N.js.map} +0 -0
  353. /package/dist/{enclave-YFKA3GJT.js.map → enclave-I5H3GINP.js.map} +0 -0
  354. /package/dist/{executor-TEZYRDN3.js.map → executor-FCJEH3FU.js.map} +0 -0
  355. /package/dist/{executor-WQQRU6DO.js.map → executor-OHET7TF7.js.map} +0 -0
  356. /package/dist/{executor-YORMIBWV.js.map → executor-SHYLIBOM.js.map} +0 -0
  357. /package/dist/{export-accessible-HXMKW5LJ.js.map → export-accessible-FBL6TDSK.js.map} +0 -0
  358. /package/dist/{extract-partition-QGQ2R42J.js.map → extract-partition-ZYIRYMTI.js.map} +0 -0
  359. /package/dist/{fanout-sidecar-HJV3A7PM.js.map → fanout-sidecar-WWXVHHUH.js.map} +0 -0
  360. /package/dist/{find-VV6PBIHK.js.map → find-LEBUXVL7.js.map} +0 -0
  361. /package/dist/{issue-7JJ4Z7E2.js.map → issue-F76PAGIR.js.map} +0 -0
  362. /package/dist/{ledger-SW6QQOAV.js.map → ledger-M2BKCNVS.js.map} +0 -0
  363. /package/dist/{liberate-FK7JI2QX.js.map → liberate-ZP7UB57K.js.map} +0 -0
  364. /package/dist/{link-set-GNGGCFI4.js.map → link-set-ZU4E5J5S.js.map} +0 -0
  365. /package/dist/{noydb-KUX2TJMX.js.map → noydb-BNDGEK5X.js.map} +0 -0
  366. /package/dist/{policy-EAXSJNOT.js.map → policy-IY2YEA3A.js.map} +0 -0
  367. /package/dist/{post-register-A7HCFBP5.js.map → post-register-XIAHB6KF.js.map} +0 -0
  368. /package/dist/{register-YBMRLZLO.js.map → register-HB4TQZSV.js.map} +0 -0
  369. /package/dist/{registry-3LXKNXWI.js.map → registry-6BMBFEXT.js.map} +0 -0
  370. /package/dist/{registry-4V4YQCXJ.js.map → registry-7CZWF3EQ.js.map} +0 -0
  371. /package/dist/{registry-ZULMLCJK.js.map → registry-JOFO7RAH.js.map} +0 -0
  372. /package/dist/{request-withdrawal-SEVUEUDG.js.map → request-withdrawal-UN3TRHWI.js.map} +0 -0
  373. /package/dist/{reveal-PB3YG544.js.map → reveal-VWXRV2XU.js.map} +0 -0
  374. /package/dist/{revoke-5QULL5GT.js.map → revoke-OLO2OVR7.js.map} +0 -0
  375. /package/dist/{signer-ZMH35FT4.js.map → signer-MGGKPYAN.js.map} +0 -0
  376. /package/dist/{stale-4UNPHWOU.js.map → stale-NBROTA66.js.map} +0 -0
  377. /package/dist/{storage-QOZKQMID.js.map → storage-3R37QZLA.js.map} +0 -0
  378. /package/dist/{store-coordination-provider-3AELCZ4Y.js.map → store-coordination-provider-P3IU5JHD.js.map} +0 -0
  379. /package/dist/{verify-MXN66IIH.js.map → verify-5X37OXRY.js.map} +0 -0
  380. /package/dist/{walk-H4YE52S2.js.map → walk-E3OVLBFR.js.map} +0 -0
  381. /package/dist/{withdraw-accessible-HPOVNG2G.js.map → withdraw-accessible-Q2EMATCU.js.map} +0 -0
@@ -1,41 +1,41 @@
1
1
  import {
2
2
  walkClosure
3
- } from "./chunk-OVFCAS7U.js";
3
+ } from "./chunk-GP54LU5N.js";
4
4
  import {
5
5
  resolveManagedSecret
6
- } from "./chunk-BCOKZC4B.js";
6
+ } from "./chunk-OHV6T5JB.js";
7
7
  import {
8
8
  parseExtractedPartitionBody,
9
9
  readPod,
10
10
  readPodHeader
11
- } from "./chunk-MEKAMERX.js";
11
+ } from "./chunk-YCAJDK4O.js";
12
12
  import {
13
13
  createOwnerKeyring
14
- } from "./chunk-WJDYZP3U.js";
14
+ } from "./chunk-3LJYHE7S.js";
15
15
  import {
16
16
  LedgerStore
17
- } from "./chunk-ZJGZDOQO.js";
17
+ } from "./chunk-5ATANZSW.js";
18
18
  import {
19
19
  LEDGER_COLLECTION
20
20
  } from "./chunk-I7FD46FF.js";
21
21
  import {
22
22
  openEnvelopeJson
23
- } from "./chunk-PEY6ZTCF.js";
23
+ } from "./chunk-GEEJPID6.js";
24
24
  import {
25
25
  base64ToBuffer,
26
26
  wrapKey
27
- } from "./chunk-5P5AAXYA.js";
27
+ } from "./chunk-7U6AB7DZ.js";
28
28
  import {
29
29
  AdoptionStateError,
30
30
  TransferSealError,
31
31
  ValidationError
32
- } from "./chunk-IGM563N5.js";
32
+ } from "./chunk-6SYOHUHM.js";
33
33
 
34
34
  // src/with-cargo/active.ts
35
35
  function withCargo() {
36
36
  return {
37
37
  async extractPartition(vault, opts) {
38
- const { extractPartitionCore } = await import("./extract-partition-QGQ2R42J.js");
38
+ const { extractPartitionCore } = await import("./extract-partition-ZYIRYMTI.js");
39
39
  return extractPartitionCore(vault, opts);
40
40
  }
41
41
  };
@@ -174,13 +174,13 @@ async function adoptPartition(bundleBytes, opts) {
174
174
  return { vaultName, needsOwner: true, sealId: seal.sealId };
175
175
  }
176
176
  function isManaged(o) {
177
- return "passphraseMode" in o && o.passphraseMode === "managed";
177
+ return "secretMode" in o && o.secretMode === "managed";
178
178
  }
179
179
  async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
180
180
  const { userId, transferKey } = opts;
181
181
  if (isManaged(opts) && !opts.recovery.some((r) => r.profile === "shamir")) {
182
182
  throw new AdoptionStateError(
183
- "managed-mode adoption requires at least one strong (shamir) recovery profile in `recovery` \u2014 paper alone is not strong when there is no user passphrase to fall back on."
183
+ "managed-mode adoption requires at least one strong (shamir) recovery profile in `recovery` \u2014 paper alone is not strong when there is no user secret to fall back on."
184
184
  );
185
185
  }
186
186
  const adoptionEnv = await store.get(vaultName, "_meta", "adoption");
@@ -207,8 +207,8 @@ async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
207
207
  const priorDeks = existingKeyring ? JSON.parse(existingKeyring._data).deks : {};
208
208
  const ownerMinted = existingKeyring !== null && partitionCollections.every((c) => c in priorDeks);
209
209
  if (!ownerMinted) {
210
- const passphrase = isManaged(opts) ? await resolveManagedSecret(store, vaultName, opts.sealingKey) : opts.passphrase;
211
- const unlocked = await createOwnerKeyring(store, vaultName, userId, passphrase);
210
+ const secret = isManaged(opts) ? await resolveManagedSecret(store, vaultName, opts.sealingKey) : opts.secret;
211
+ const unlocked = await createOwnerKeyring(store, vaultName, userId, secret);
212
212
  const env = await store.get(vaultName, "_keyring", userId);
213
213
  if (!env) throw new AdoptionStateError(`keyring write for "${userId}" did not persist`);
214
214
  const keyringFile = JSON.parse(env._data);
@@ -241,15 +241,15 @@ async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
241
241
  }
242
242
  }
243
243
  if (isManaged(opts)) {
244
- const { createNoydb } = await import("./noydb-KUX2TJMX.js");
244
+ const { createNoydb } = await import("./noydb-BNDGEK5X.js");
245
245
  const db = await createNoydb({
246
246
  store,
247
247
  user: userId,
248
- passphraseMode: "managed",
248
+ secretMode: "managed",
249
249
  sealingKey: opts.sealingKey,
250
250
  shamirRecovery: opts.shamirRecovery
251
251
  });
252
- await db.openVaultAndEnrollRecovery(vaultName, { recovery: opts.recovery });
252
+ await db.team.openVaultAndEnrollRecovery(vaultName, { recovery: opts.recovery });
253
253
  }
254
254
  const consumed = { sealId: adoption.sealId, adoptedAt: adoption.adoptedAt, consumedAt: (/* @__PURE__ */ new Date()).toISOString() };
255
255
  await store.put(vaultName, "_meta", "adoption", { ...adoptionEnv, _data: JSON.stringify(consumed) });
@@ -296,4 +296,4 @@ export {
296
296
  withCargo,
297
297
  describeExtraction
298
298
  };
299
- //# sourceMappingURL=chunk-OWLPX2GI.js.map
299
+ //# sourceMappingURL=chunk-KJTIAECI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-cargo/active.ts","../src/with-cargo/describe-extraction.ts","../src/with-cargo/adopt-partition.ts","../src/with-cargo/decrypt-partition.ts"],"sourcesContent":["/**\n * Enable the cargo (partition extraction) capability.\n * Pass to `createNoydb({ cargoStrategy: withCargo() })` to make the source-side\n * `extractPartition(vault, ...)` free function live. The extraction crypto\n * engine is dynamically imported here, so it stays out of the floor bundle\n * until opted in. The recipient-side `adoptPartition` /\n * `decryptExtractedPartition` free functions — and `diffVault` (shared\n * import/merge infra) — are ungated and unaffected.\n */\nimport type { CargoStrategy } from './strategy.js'\n\nexport function withCargo(): CargoStrategy {\n return {\n async extractPartition(vault, opts) {\n const { extractPartitionCore } = await import('./extract-partition.js')\n return extractPartitionCore(vault, opts)\n },\n }\n}\n","/**\n * Partition-extraction dry-run. Read-only preview of what an\n * `extractPartition` would move: record counts, byte totals, and the\n * timestamp span per collection — computed from raw encrypted\n * envelopes WITHOUT decrypting them. Writes nothing, mutates nothing.\n *\n * @module\n */\nimport type { Vault } from '../kernel/vault.js'\nimport { walkClosure, type WalkClosureOptions, type DanglingRefNotice } from './walk-closure.js'\n\nexport interface ExtractionPreview {\n readonly totalRecords: number\n /** Sum of serialized encrypted-envelope sizes (bytes). */\n readonly totalBytes: number\n readonly byCollection: ReadonlyArray<{\n readonly name: string\n readonly recordCount: number\n readonly bytes: number\n /** Earliest envelope `_ts` in this collection (lexicographic). */\n readonly oldestTs?: string\n readonly newestTs?: string\n }>\n readonly graph: { readonly depth: number; readonly cyclesDetected: boolean }\n /** Records the walk reached but whose envelope couldn't be read. */\n readonly inaccessible: ReadonlyArray<{ readonly collection: string; readonly id: string }>\n /**\n * #772: outbound FK edges whose referenced parent was excluded from the\n * closure (missing, or tier-elevated and therefore invisible) — mirrors\n * `ExtractPartitionResult.danglingRefs` (#759) so a preview/extract pair\n * gives the SAME signal. A parent excluded this way never appears in\n * `byCollection` at all; this is the only preview-time indicator.\n */\n readonly danglingRefs: ReadonlyArray<DanglingRefNotice>\n}\n\nexport async function describeExtraction(\n vault: Vault,\n opts: WalkClosureOptions,\n): Promise<ExtractionPreview> {\n const { closure, graph, danglingRefs } = await walkClosure(vault, opts)\n\n const { name: vaultName, adapter } = vault._introspectState()\n const encoder = new TextEncoder()\n\n const byCollection: Array<{\n name: string; recordCount: number; bytes: number; oldestTs?: string; newestTs?: string\n }> = []\n const inaccessible: Array<{ collection: string; id: string }> = []\n let totalBytes = 0\n let totalRecords = 0\n\n for (const [collectionName, ids] of closure) {\n let bytes = 0\n let oldestTs: string | undefined\n let newestTs: string | undefined\n let recordCount = 0\n\n for (const id of ids) {\n const env = await adapter.get(vaultName, collectionName, id)\n if (!env) {\n // Walk reached it (via decrypted list) but the raw store read\n // returned nothing — surface rather than miscount.\n inaccessible.push({ collection: collectionName, id })\n continue\n }\n recordCount++\n bytes += encoder.encode(JSON.stringify(env)).length\n const ts = env._ts\n if (oldestTs === undefined || ts < oldestTs) oldestTs = ts\n if (newestTs === undefined || ts > newestTs) newestTs = ts\n }\n\n byCollection.push({\n name: collectionName,\n recordCount,\n bytes,\n // Spread conditionally — exactOptionalPropertyTypes forbids an\n // explicit `undefined` on an optional property.\n ...(oldestTs !== undefined ? { oldestTs } : {}),\n ...(newestTs !== undefined ? { newestTs } : {}),\n })\n totalBytes += bytes\n totalRecords += recordCount\n }\n\n byCollection.sort((a, b) => a.name.localeCompare(b.name))\n\n return Object.freeze({\n totalRecords,\n totalBytes,\n byCollection,\n graph,\n inaccessible,\n danglingRefs,\n })\n}\n","/**\n * Partition adoption. Recipient side: verify an extracted bundle,\n * validate the transfer key, import the re-keyed collections into a\n * destination store, and record an `_meta/adoption` marker. The bundle\n * stays UNOWNED after adoption — `createOwnerOnAdoptedPartition`\n * mints the owner; the transfer seal is then destroyed.\n *\n * @module\n */\nimport { base64ToBuffer, wrapKey, type EnclaveKey } from '../kernel/enclave/index.js'\nimport { TransferSealError, AdoptionStateError, ValidationError } from '../kernel/errors.js'\nimport type { NoydbStore, VaultSnapshot, KeyringFile } from '../kernel/types.js'\nimport { createOwnerKeyring } from '../with-party/team/keyring.js'\nimport { resolveManagedSecret } from '../with-party/team/managed-secret.js'\nimport type { SealingKeyProvider } from '../with-party/team/managed-secret.js'\nimport type { ShamirRecoveryProvider } from '../with-party/team/shamir-recovery-provider.js'\nimport type { RecoveryEnrollmentInput } from '../with-party/team/rotate-recover.js'\nimport { LedgerStore } from '../with-commit/history/ledger/store.js'\nimport { LEDGER_COLLECTION } from '../with-commit/history/ledger/constants.js'\nimport type { TransferSealPayload } from '../with-pod/bundle.js'\nimport { readPodHeader, readPod, parseExtractedPartitionBody } from '../with-pod/bundle.js'\n\n/**\n * Reverse of `sealDeks`. Imports the transfer key, decrypts the\n * sealed `{ collection: base64(rawDEK) }` map (layout iv(12)‖ct‖tag), and\n * re-imports each DEK as an AES-GCM key. Throws `TransferSealError` on a\n * wrong key (AES-GCM auth-tag failure) or malformed payload.\n */\nexport async function unsealDeks(\n seal: TransferSealPayload,\n transferKey: Uint8Array,\n): Promise<Map<string, EnclaveKey>> {\n if (transferKey.byteLength !== 32) {\n throw new TransferSealError(\n `transfer key must be 32 bytes, got ${transferKey.byteLength}.`,\n )\n }\n const key = await crypto.subtle.importKey('raw', transferKey as BufferSource, 'AES-GCM', false, ['decrypt'])\n const raw = base64ToBuffer(seal.payload)\n let plaintext: ArrayBuffer\n try {\n plaintext = await crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: raw.slice(0, 12) as BufferSource },\n key,\n raw.slice(12) as BufferSource,\n )\n } catch {\n throw new TransferSealError(\n 'transfer seal could not be opened — wrong transfer key (AES-GCM authentication failed).',\n )\n }\n let dekMap: Record<string, string>\n try {\n dekMap = JSON.parse(new TextDecoder().decode(plaintext)) as Record<string, string>\n } catch {\n throw new TransferSealError('transfer seal payload is not valid JSON after decryption.')\n }\n const deks = new Map<string, EnclaveKey>()\n for (const [collection, b64] of Object.entries(dekMap)) {\n // Extractable: the recipient must be able to re-wrap these under their\n // own KEK (AES-KW) at owner-creation. Matches generateDEK.\n const dek = await crypto.subtle.importKey('raw', base64ToBuffer(b64) as BufferSource, 'AES-GCM', true, ['encrypt', 'decrypt'])\n deks.set(collection, dek)\n }\n return deks\n}\n\nexport interface AdoptPartitionOptions {\n readonly transferKey: Uint8Array\n readonly destinationStore: NoydbStore\n readonly vaultName: string\n}\n\nexport interface AdoptPartitionResult {\n readonly vaultName: string\n readonly needsOwner: true\n readonly sealId: string\n}\n\nexport async function adoptPartition(\n bundleBytes: Uint8Array,\n opts: AdoptPartitionOptions,\n): Promise<AdoptPartitionResult> {\n const { transferKey, destinationStore, vaultName } = opts\n\n const header = readPodHeader(bundleBytes)\n if (header.bundleKind !== 'extracted-partition' || header.transferSeal === undefined) {\n throw new ValidationError(\n 'adoptPartition requires an extracted-partition bundle with a transfer seal. '\n + 'For ordinary backups use readPod + vault.load.',\n )\n }\n\n const { dumpJson } = await readPod(bundleBytes)\n const { dump, seal } = parseExtractedPartitionBody(dumpJson)\n\n // Validate the transfer key by unsealing in memory; throws\n // TransferSealError on mismatch. DEKs are discarded here — they stay\n // sealed at rest (in _meta/adoption) until owner-creation wraps them under the\n // recipient's KEK.\n await unsealDeks(seal, transferKey)\n\n // Single-occupancy per vaultName: an `_meta/adoption` marker already present\n // means this slot holds a partition (adopted-and-unowned, or already owned).\n // saveAll below would overwrite its data and replace the marker, stranding the\n // prior adoption's transfer seal. Refuse regardless of sealId — re-adopting the\n // SAME bundle is a redundant call, and adopting a DIFFERENT bundle here would\n // clobber the existing partition. Either way, pick a fresh vaultName.\n const existing = await destinationStore.get(vaultName, '_meta', 'adoption')\n if (existing) {\n const prior = JSON.parse(existing._data) as { sealId?: string }\n if (prior.sealId === seal.sealId) {\n throw new AdoptionStateError(\n `partition (sealId ${seal.sealId}) is already adopted into vault \"${vaultName}\".`,\n )\n }\n throw new AdoptionStateError(\n `vault \"${vaultName}\" already holds an adopted partition (sealId ${prior.sealId}); `\n + `adopting a different partition (sealId ${seal.sealId}) here would overwrite it. `\n + `Adopt into a fresh vaultName instead.`,\n )\n }\n\n // The marker-only check above misses a worse case: a vaultName already in use\n // by an ORDINARY vault (createNoydb + openVault) carries no `_meta/adoption`,\n // yet `saveAll` below is destructive on SQL adapters (`DELETE FROM ... WHERE\n // vault = ?` followed by upsert) and would wipe the legitimate keyring +\n // data. Refuse adoption into ANY occupied slot — a fresh vaultName is the\n // documented precondition.\n const existingKeyring = await destinationStore.list(vaultName, '_keyring')\n if (existingKeyring.length > 0) {\n throw new AdoptionStateError(\n `vault \"${vaultName}\" already holds a keyring (an unrelated owner exists at this slot); `\n + `adoptPartition requires a fresh vaultName to avoid destructive saveAll on SQL adapters.`,\n )\n }\n\n const backup = JSON.parse(dump) as { collections: VaultSnapshot; _internal?: VaultSnapshot }\n await destinationStore.saveAll(vaultName, backup.collections)\n\n // Import carried internal collections (e.g. _schemas from carrySchemas).\n // saveAll only writes data collections; _internal is written per-record.\n if (backup._internal) {\n for (const [collection, records] of Object.entries(backup._internal)) {\n for (const [id, envelope] of Object.entries(records)) {\n await destinationStore.put(vaultName, collection, id, envelope)\n }\n }\n }\n\n const adoptedAt = new Date().toISOString()\n const adoption = { sealId: seal.sealId, adoptedAt, needsOwner: true as const, transferSeal: seal }\n await destinationStore.put(vaultName, '_meta', 'adoption', {\n _noydb: 1, _v: 1, _ts: adoptedAt, _iv: '', _data: JSON.stringify(adoption),\n })\n\n return { vaultName, needsOwner: true, sealId: seal.sealId }\n}\n\nexport interface CreateOwnerResult {\n readonly vaultName: string\n readonly userId: string\n}\n\n/** Standard-mode owner: recipient supplies the secret. */\nexport interface CreateOwnerStandardOptions {\n readonly userId: string\n readonly secret: string\n readonly transferKey: Uint8Array\n}\n\n/**\n * Managed-mode owner: the secret is minted + sealed under\n * a `SealingKeyProvider` (e.g. an `at-*` OS keychain) so the partition\n * auto-unlocks on the recipient's device. Managed mode mandates a strong\n * (Shamir) recovery profile at creation, which needs the\n * `shamirRecovery` provider injected.\n */\nexport interface CreateOwnerManagedOptions {\n readonly userId: string\n readonly secretMode: 'managed'\n readonly sealingKey: SealingKeyProvider\n readonly recovery: ReadonlyArray<RecoveryEnrollmentInput>\n readonly shamirRecovery: ShamirRecoveryProvider\n readonly transferKey: Uint8Array\n}\n\nexport type CreateOwnerOptions = CreateOwnerStandardOptions | CreateOwnerManagedOptions\n\nfunction isManaged(o: CreateOwnerOptions): o is CreateOwnerManagedOptions {\n return 'secretMode' in o && o.secretMode === 'managed'\n}\n\n/**\n * Mint the first owner keyring on an adopted-but-unowned partition,\n * then destroy the transfer seal.\n *\n * Standard mode: the recipient supplies a secret. Managed mode: the\n * secret is minted + sealed under a `SealingKeyProvider` and a strong\n * (Shamir) recovery profile is enrolled — orchestrated via the existing\n * `openVaultAndEnrollRecovery` ceremony.\n *\n * Either way, reuses `createOwnerKeyring` to derive the KEK + write the base\n * keyring, then wraps the partition's DEKs (recovered from the seal) under that\n * KEK and re-persists the merged keyring file.\n *\n * Idempotent under retry: the seal is destroyed LAST (Stage D), after the\n * keyring (Stage A), the ledger transition (Stage B), and — in managed mode —\n * strong-recovery enrollment (Stage C). A failure in the fallible enrollment\n * step leaves the seal intact, and re-running with the same `userId` +\n * `transferKey` resumes from the first incomplete stage. (Multi-profile recovery\n * arrays may re-enroll an already-enrolled profile on retry; managed mode's\n * mandated single Shamir profile does not.)\n */\nexport async function createOwnerOnAdoptedPartition(\n store: NoydbStore,\n vaultName: string,\n opts: CreateOwnerOptions,\n): Promise<CreateOwnerResult> {\n const { userId, transferKey } = opts\n\n // Managed mode requires a strong (Shamir) recovery profile, validated BEFORE\n // any disk write — same gate as createNoydb.\n if (isManaged(opts) && !opts.recovery.some((r) => r.profile === 'shamir')) {\n throw new AdoptionStateError(\n 'managed-mode adoption requires at least one strong (shamir) recovery profile in '\n + '`recovery` — paper alone is not strong when there is no user secret to fall back on.',\n )\n }\n\n // 1. Verify adopted-unowned state.\n const adoptionEnv = await store.get(vaultName, '_meta', 'adoption')\n if (!adoptionEnv) {\n throw new AdoptionStateError(\n `vault \"${vaultName}\" is not an adopted partition (no _meta/adoption). `\n + `createOwnerOnAdoptedPartition only applies to vaults created via adoptPartition.`,\n )\n }\n const adoption = JSON.parse(adoptionEnv._data) as {\n sealId: string; adoptedAt: string; needsOwner?: boolean\n consumedAt?: string; transferSeal?: TransferSealPayload\n }\n if (adoption.consumedAt !== undefined || adoption.transferSeal === undefined) {\n throw new AdoptionStateError(\n `vault \"${vaultName}\" already has an owner (transfer seal consumed at ${adoption.consumedAt}).`,\n )\n }\n\n // 2. Recover the partition DEKs from the seal (throws on wrong key) BEFORE\n // writing any keyring, so a bad transfer key leaves no trace. Always\n // validated, including when resuming a partial prior call.\n const partitionDeks = await unsealDeks(adoption.transferSeal, transferKey)\n\n // The ceremony below is split into stages so a failure in the fallible\n // managed-enrollment step (network/provider outage) leaves the call RETRYABLE\n // — the seal is destroyed only once everything durable is in place. Each stage\n // detects its own prior completion rather than relying on a single resume bit.\n\n // A keyring present for a DIFFERENT user (with the seal still unconsumed) is a\n // genuine second-owner attempt — refuse it. A same-user keyring is a resumed\n // partial call and is handled by the stage checks below.\n const existingKeyring = await store.get(vaultName, '_keyring', userId)\n const otherOwners = (await store.list(vaultName, '_keyring')).filter((u) => u !== userId)\n if (otherOwners.length > 0) {\n throw new AdoptionStateError(\n `vault \"${vaultName}\" already has a keyring for a different owner; cannot create owner \"${userId}\".`,\n )\n }\n\n // Stage A — mint the owner keyring + merge the partition DEKs. Considered done\n // only when the keyring already holds every partition DEK. createOwnerKeyring\n // overwrites (fresh KEK + fresh _users DEK), so re-running is safe ONLY while\n // no recovery has been enrolled yet — guaranteed here because enrollment\n // (Stage C) runs strictly after Stage A completes.\n const partitionCollections = [...partitionDeks.keys()]\n const priorDeks = existingKeyring ? (JSON.parse(existingKeyring._data) as KeyringFile).deks : {}\n const ownerMinted = existingKeyring !== null && partitionCollections.every((c) => c in priorDeks)\n if (!ownerMinted) {\n // Resolve the owner secret. Managed mode mints a random secret, seals\n // it under the provider, and persists _meta/sealed-secret (so the\n // partition auto-unlocks on the recipient's device); standard mode uses the\n // caller's secret. Idempotent under retry — resolveManagedSecret's reopen\n // arm reuses an already-sealed secret.\n const secret = isManaged(opts)\n ? await resolveManagedSecret(store, vaultName, opts.sealingKey)\n : opts.secret\n\n // Mint the owner keyring (KEK + _users DEK + canary, written to disk).\n const unlocked = await createOwnerKeyring(store, vaultName, userId, secret)\n\n // Merge the partition DEKs (wrapped under the new KEK) into the keyring.\n const env = await store.get(vaultName, '_keyring', userId)\n if (!env) throw new AdoptionStateError(`keyring write for \"${userId}\" did not persist`)\n const keyringFile = JSON.parse(env._data) as KeyringFile\n const kek = unlocked.kek\n if (!kek) throw new AdoptionStateError(`owner keyring for \"${userId}\" has no KEK to wrap partition DEKs under`)\n const mergedDeks: Record<string, string> = { ...keyringFile.deks }\n for (const [collection, dek] of partitionDeks) {\n mergedDeks[collection] = await wrapKey(dek, kek)\n }\n const mergedFile: KeyringFile = { ...keyringFile, deks: mergedDeks }\n await store.put(vaultName, '_keyring', userId, { ...env, _data: JSON.stringify(mergedFile) })\n }\n\n // Stage B — record the ownership transition on the carried\n // audit chain (carryLedger sealed the _ledger DEK). No-op without that DEK.\n // Idempotent: appended only if the closing `transfer-seal-consumed` entry is\n // absent, so a retry does not duplicate the pair.\n const ledgerDek = partitionDeks.get(LEDGER_COLLECTION)\n if (ledgerDek) {\n const ledger = new LedgerStore({\n adapter: store,\n vault: vaultName,\n encrypted: true,\n getDEK: async () => ledgerDek,\n actor: userId,\n })\n const creationReason = `creation-of-new-owner:${userId}`\n const consumedReason = `transfer-seal-consumed:${adoption.sealId}`\n // Gate each append on its own presence — a crash or store error strictly\n // between the two adjacent puts would otherwise re-append the first one\n // on retry. The pair is the audit record, not a single transaction.\n const recordedReasons = new Set((await ledger.loadAllEntries()).map((e) => e.reason))\n if (!recordedReasons.has(creationReason)) {\n await ledger.append({ op: 'lifecycle', collection: '', id: '', version: 0, actor: '', payloadHash: '', reason: creationReason })\n }\n if (!recordedReasons.has(consumedReason)) {\n await ledger.append({ op: 'lifecycle', collection: '', id: '', version: 0, actor: '', payloadHash: '', reason: consumedReason })\n }\n }\n\n // Stage C — Managed mode: enroll the mandatory strong recovery\n // by orchestrating the existing public ceremony. The partition is\n // now a managed-mode vault on disk (sealed secret + keyring), so we\n // open it as a normal client and let openVaultAndEnrollRecovery do the\n // gate-bypass + enroll + re-assert. Dynamic import keeps the Noydb class\n // out of the @noy-db/hub/cargo static graph. Runs BEFORE seal destruction\n // so a failure here leaves the seal intact and the call retryable.\n if (isManaged(opts)) {\n const { createNoydb } = await import('../kernel/noydb.js')\n const db = await createNoydb({\n store,\n user: userId,\n secretMode: 'managed',\n sealingKey: opts.sealingKey,\n shamirRecovery: opts.shamirRecovery,\n })\n await db.team.openVaultAndEnrollRecovery(vaultName, { recovery: opts.recovery })\n }\n\n // Stage D — Destroy the transfer seal LAST — the commit point. Everything\n // above is either idempotent or resumable, so the seal is only consumed\n // once the owner keyring (and, in managed mode, strong recovery) is\n // durably in place. Retain sealId + consumedAt for audit.\n const consumed = { sealId: adoption.sealId, adoptedAt: adoption.adoptedAt, consumedAt: new Date().toISOString() }\n await store.put(vaultName, '_meta', 'adoption', { ...adoptionEnv, _data: JSON.stringify(consumed) })\n\n return { vaultName, userId }\n}\n","/**\n * Read-side counterpart to `extractPartition`: decrypt an\n * extracted-partition bundle's records to plaintext using its transfer\n * key, WITHOUT adopting it into a vault. Used by an outward\n * orchestration layer's reconcile/merge and field-authority flows to\n * compare incoming records against a receiver. The transfer key validates the bundle\n * (wrong key throws).\n * @module\n */\nimport type { EncryptedEnvelope } from '../kernel/types.js'\nimport { openEnvelopeJson } from '../kernel/enclave/index.js'\nimport { readPodHeader, readPod, parseExtractedPartitionBody } from '../with-pod/bundle.js'\nimport { unsealDeks } from './adopt-partition.js'\n\n/** One decrypted record from an extracted-partition compartment. */\nexport interface DecryptedRecord {\n readonly id: string\n readonly record: Record<string, unknown>\n /** Source envelope write timestamp (ISO) — for last-write-wins merges. */\n readonly ts: string\n /** Source envelope version. */\n readonly version: number\n /** Provenance source id (FR-5). Present only when the source collection had provenance:true and a source was supplied on put. */\n readonly source?: string\n /** ISO-8601 timestamp the provenance source was recorded (FR-5). */\n readonly sourceTs?: string\n}\n\n/**\n * Decrypt every record of an extracted-partition bundle to plaintext,\n * grouped by collection. Throws if the bundle isn't an\n * extracted-partition or the transfer key is wrong.\n */\nexport async function decryptExtractedPartition(\n bundleBytes: Uint8Array,\n transferKey: Uint8Array,\n): Promise<Record<string, DecryptedRecord[]>> {\n const header = readPodHeader(bundleBytes)\n if (header.bundleKind !== 'extracted-partition' || header.transferSeal === undefined) {\n throw new Error('decryptExtractedPartition: bundle is not an extracted-partition.')\n }\n const { dumpJson } = await readPod(bundleBytes)\n const { dump, seal } = parseExtractedPartitionBody(dumpJson)\n const deks = await unsealDeks(seal, transferKey) // throws TransferSealError on wrong key\n const backup = JSON.parse(dump) as { collections: Record<string, Record<string, EncryptedEnvelope>> }\n const out: Record<string, DecryptedRecord[]> = {}\n for (const [collection, byId] of Object.entries(backup.collections)) {\n const dek = deks.get(collection)\n if (dek === undefined) continue // no DEK sealed for this collection — skip\n const recs: DecryptedRecord[] = []\n for (const [id, env] of Object.entries(byId)) {\n const plaintext = await openEnvelopeJson(env, dek)\n const body = JSON.parse(plaintext) as Record<string, unknown>\n recs.push({\n id,\n record: { ...body, id },\n ts: env._ts,\n version: env._v,\n ...(env._source !== undefined ? { source: env._source } : {}),\n ...(env._sourceTs !== undefined ? { sourceTs: env._sourceTs } : {}),\n })\n }\n out[collection] = recs\n }\n return out\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,SAAS,YAA2B;AACzC,SAAO;AAAA,IACL,MAAM,iBAAiB,OAAO,MAAM;AAClC,YAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,iCAAwB;AACtE,aAAO,qBAAqB,OAAO,IAAI;AAAA,IACzC;AAAA,EACF;AACF;;;ACkBA,eAAsB,mBACpB,OACA,MAC4B;AAC5B,QAAM,EAAE,SAAS,OAAO,aAAa,IAAI,MAAM,YAAY,OAAO,IAAI;AAEtE,QAAM,EAAE,MAAM,WAAW,QAAQ,IAAI,MAAM,iBAAiB;AAC5D,QAAM,UAAU,IAAI,YAAY;AAEhC,QAAM,eAED,CAAC;AACN,QAAM,eAA0D,CAAC;AACjE,MAAI,aAAa;AACjB,MAAI,eAAe;AAEnB,aAAW,CAAC,gBAAgB,GAAG,KAAK,SAAS;AAC3C,QAAI,QAAQ;AACZ,QAAI;AACJ,QAAI;AAC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{
2
2
  grant,
3
3
  revoke
4
- } from "./chunk-WJDYZP3U.js";
4
+ } from "./chunk-3LJYHE7S.js";
5
5
  import {
6
6
  CargoNotEnabledError,
7
7
  CustodyNotEnabledError
8
- } from "./chunk-IGM563N5.js";
8
+ } from "./chunk-6SYOHUHM.js";
9
9
 
10
10
  // src/with-cargo/strategy.ts
11
11
  var NO_CARGO = {
@@ -14,6 +14,19 @@ var NO_CARGO = {
14
14
  }
15
15
  };
16
16
 
17
+ // src/with-party/custody/strategy.ts
18
+ var NO_CUSTODY = {
19
+ async grantCustodian() {
20
+ throw new CustodyNotEnabledError();
21
+ },
22
+ async revokeCustodian() {
23
+ throw new CustodyNotEnabledError();
24
+ },
25
+ async liberate() {
26
+ throw new CustodyNotEnabledError();
27
+ }
28
+ };
29
+
17
30
  // src/with-party/custody/active.ts
18
31
  function withCustody() {
19
32
  return {
@@ -24,25 +37,12 @@ function withCustody() {
24
37
  return host._revokeCustodianImpl(revoke, vault, options, factors);
25
38
  },
26
39
  async liberate(vault, opts) {
27
- const { liberateVault } = await import("./liberate-FK7JI2QX.js");
40
+ const { liberateVault } = await import("./liberate-ZP7UB57K.js");
28
41
  return liberateVault(vault, opts);
29
42
  }
30
43
  };
31
44
  }
32
45
 
33
- // src/with-party/custody/strategy.ts
34
- var NO_CUSTODY = {
35
- async grantCustodian() {
36
- throw new CustodyNotEnabledError();
37
- },
38
- async revokeCustodian() {
39
- throw new CustodyNotEnabledError();
40
- },
41
- async liberate() {
42
- throw new CustodyNotEnabledError();
43
- }
44
- };
45
-
46
46
  // src/with-party/custody/index.ts
47
47
  var CustodyApi = class {
48
48
  constructor(_grantCustodian, _revokeCustodian, _liberate) {
@@ -79,8 +79,8 @@ var CustodyApi = class {
79
79
 
80
80
  export {
81
81
  NO_CARGO,
82
- withCustody,
83
82
  NO_CUSTODY,
83
+ withCustody,
84
84
  CustodyApi
85
85
  };
86
- //# sourceMappingURL=chunk-SN75YVM5.js.map
86
+ //# sourceMappingURL=chunk-L2CAWCQL.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/with-cargo/strategy.ts","../src/with-party/custody/active.ts","../src/with-party/custody/strategy.ts","../src/with-party/custody/index.ts"],"sourcesContent":["/**\n * Cargo capability strategy (FR-6/FR-7) — the source-side, owner-level\n * partition operation that requires a live {@link Vault}: extracting a re-keyed\n * transfer-sealed partition ({@link extractPartitionCore}). The active engine\n * ({@link withCargo}) dynamically imports that engine (keeping the extraction\n * crypto out of the floor bundle); {@link NO_CARGO} throws.\n *\n * The public free function `extractPartition` (which takes a `Vault`) delegates\n * here via `vault.cargoStrategy`, so an un-opted-in caller hits `NO_CARGO`'s\n * throw.\n *\n * Carve-out (mirrors `openSealedRecord` / `liberateVault`): the recipient-side\n * free functions `adoptPartition` and `decryptExtractedPartition` operate on\n * raw bundle bytes + a destination store — they carry NO source instance to\n * gate against, so they stay ungated host-side tooling. `diffVault` is likewise\n * ungated: it's shared import/merge infrastructure the `as-*` exporters call\n * internally, not a gated cargo capability.\n * @internal\n */\nimport type { Vault } from '../kernel/vault.js'\nimport type { ExtractPartitionResult, ExtractPartitionOptions } from './extract-partition.js'\nimport { CargoNotEnabledError } from '../kernel/errors.js'\n\nexport interface CargoStrategy {\n extractPartition(vault: Vault, opts: ExtractPartitionOptions): Promise<ExtractPartitionResult>\n}\n\n/**\n * No-op stub — the floor default. The source-side cargo op throws\n * {@link CargoNotEnabledError}; opt in with `cargoStrategy: withCargo()` in\n * createNoydb. @internal\n */\nexport const NO_CARGO: CargoStrategy = {\n async extractPartition() { throw new CargoNotEnabledError() },\n}\n","/**\n * Enable the sovereign-custody (FR-6) capability.\n * Pass to `createNoydb({ custodyStrategy: withCustody() })` to make\n * `db.grantCustodian` / `db.revokeCustodian` (and the `vault.custody.*` facade\n * that delegates to them) plus `vault.custody.liberate()` live. The heavy\n * `liberateVault` ceremony is dynamically imported here, so it is reached only\n * via opt-in; grant/revoke run the host's own gate + keyring engine.\n */\nimport type { CustodyStrategy } from './strategy.js'\nimport { grant as grantEngine, revoke as revokeEngine } from '../team/keyring.js'\n\nexport function withCustody(): CustodyStrategy {\n return {\n async grantCustodian(host, vault, options, factors) {\n return host._grantCustodianImpl(grantEngine, vault, options, factors)\n },\n async revokeCustodian(host, vault, options, factors) {\n return host._revokeCustodianImpl(revokeEngine, vault, options, factors)\n },\n async liberate(vault, opts) {\n const { liberateVault } = await import('./liberate.js')\n return liberateVault(vault, opts)\n },\n }\n}\n","/**\n * Sovereign-custody (FR-6) capability strategy — the three on-demand\n * operations the custody surface routes through: minting a custodian\n * (`grantCustodian`), removing one (`revokeCustodian`), and the audited\n * ownership-claim ceremony (`liberate`). The active engine ({@link withCustody})\n * runs the grant/revoke impls the host exposes and dynamically imports the\n * heavy `liberateVault` ceremony (keeping it out of the floor bundle);\n * {@link NO_CUSTODY} throws.\n *\n * `Noydb.grantCustodian` / `Noydb.revokeCustodian` delegate here (passing\n * themselves as the {@link CustodyHost}), and `vault.custody.liberate` delegates\n * here with its {@link Vault}. An un-opted-in caller hits `NO_CUSTODY`'s throw.\n *\n * Note: the lower-level `liberateVault` FREE FUNCTION (exported from\n * `custody/liberate.ts`) stays ungated — it has no `createNoydb` instance to\n * gate against (the same carve-out as the `openSealedRecord` host opener). Only\n * the instance surfaces (`db.grantCustodian` / `db.revokeCustodian` /\n * `vault.custody.*`) are the capability.\n * @internal\n */\nimport type { GrantOptions, RevokeOptions, FactorProofBundle, NoydbStore } from '../../kernel/types.js'\nimport type { Vault } from '../../kernel/vault.js'\nimport type { UnlockedKeyring } from '../team/keyring.js'\nimport type { GrantCustodianOptions } from './index.js'\nimport type { LiberateOptions, LiberateResult } from './liberate.js'\nimport { CustodyNotEnabledError } from '../../kernel/errors.js'\n\n/**\n * The grant/revoke engine the strategy runs when opted in — implemented by\n * `Noydb` (`_grantCustodianImpl` / `_revokeCustodianImpl` hold the gate +\n * keyring logic; the public `grantCustodian` / `revokeCustodian` route through\n * the strategy). Since the #267 team split the keyring grant/revoke engines\n * are passed IN by `withCustody()` (statically linked there, not in the\n * kernel) so the single-user floor never carries them.\n */\nexport interface CustodyHost {\n _grantCustodianImpl(\n engine: (adapter: NoydbStore, vault: string, callerKeyring: UnlockedKeyring, options: GrantOptions) => Promise<void>,\n vault: string,\n options: GrantCustodianOptions,\n factors?: FactorProofBundle,\n ): Promise<void>\n _revokeCustodianImpl(\n engine: (adapter: NoydbStore, vault: string, callerKeyring: UnlockedKeyring, options: RevokeOptions) => Promise<void>,\n vault: string,\n options: RevokeOptions,\n factors?: FactorProofBundle,\n ): Promise<void>\n}\n\nexport interface CustodyStrategy {\n grantCustodian(host: CustodyHost, vault: string, options: GrantCustodianOptions, factors?: FactorProofBundle): Promise<void>\n revokeCustodian(host: CustodyHost, vault: string, options: RevokeOptions, factors?: FactorProofBundle): Promise<void>\n liberate(vault: Vault, opts: LiberateOptions): Promise<LiberateResult>\n}\n\n/**\n * No-op stub — the floor default. Every custody operation throws\n * {@link CustodyNotEnabledError}; opt in with `custodyStrategy: withCustody()`\n * in createNoydb. @internal\n */\nexport const NO_CUSTODY: CustodyStrategy = {\n async grantCustodian() { throw new CustodyNotEnabledError() },\n async revokeCustodian() { throw new CustodyNotEnabledError() },\n async liberate() { throw new CustodyNotEnabledError() },\n}\n","/**\n * Public `vault.custody.*` API surface (FR-6).\n *\n * The custody namespace is the vault-instance face of the FR-6 sovereign-custody\n * model — it mirrors `vault.user.*` exactly: a thin delegation shell with NO\n * business logic. The Vault constructs one `CustodyApi` per session, injecting\n * closures that bind the vault name / keyring into the genuinely-core\n * implementations (`Noydb.grantCustodian` / `Noydb.revokeCustodian` and the\n * `liberateVault` ceremony). Each method just forwards to its injected callback.\n *\n * Three operations:\n * - `grantCustodian(opts)` — owner-only: mint a `custodian` who operates the\n * vault fully but can never grant / rotate / sever / extract.\n * - `revokeCustodian(opts)` — owner-only: remove a custodian.\n * - `liberate(opts)` — custodian-only: audited claim of ownership over a\n * sealed-owner (Deed) vault (mints a DISTINCT new owner; ledger-audited).\n *\n * Provisioning a Deed (`createDeedOwner`) is deliberately NOT on this class: it\n * is a store-level operation that mints the vault's first owner, so there is no\n * vault instance (and thus no custody namespace) yet — it stays the exported\n * `team/deed.ts` function.\n *\n * @see docs/superpowers/specs/2026-06-17-fr6-deed-custodian-liberate-design.md\n * @module\n */\nimport type { GrantOptions, RevokeOptions, FactorProofBundle } from '../../kernel/types.js'\nimport type { LiberateOptions, LiberateResult } from './liberate.js'\n\n/** Options for `vault.custody.grantCustodian` — a grant with the role fixed to `custodian`. */\nexport type GrantCustodianOptions = Omit<GrantOptions, 'role'>\n\n// Capability opt-in seam (S4): grant/revoke custodian + liberate throw\n// CustodyNotEnabledError unless `custodyStrategy: withCustody()` is opted in.\nexport { withCustody } from './active.js'\nexport { NO_CUSTODY, type CustodyStrategy, type CustodyHost } from './strategy.js'\nexport { CustodyNotEnabledError } from '../../kernel/errors.js'\n\n/**\n * Implementation behind `vault.custody`. Constructed once per Vault. Holds the\n * injected, vault-bound implementations in closure; every method delegates with\n * no added logic (the owner-only / custodian-only / gate checks all live in the\n * injected implementations — `Noydb.grantCustodian` etc. and `liberateVault`).\n */\nexport class CustodyApi {\n constructor(\n /** Bound `Noydb.grantCustodian(this.name, ...)` — owner-only, gated. */\n private readonly _grantCustodian: (options: GrantCustodianOptions, factors?: FactorProofBundle) => Promise<void>,\n /** Bound `Noydb.revokeCustodian(this.name, ...)` — owner-only, gated. */\n private readonly _revokeCustodian: (options: RevokeOptions, factors?: FactorProofBundle) => Promise<void>,\n /** Bound `liberateVault(this, ...)` — custodian-only audited ownership claim. */\n private readonly _liberate: (opts: LiberateOptions) => Promise<LiberateResult>,\n ) {}\n\n /**\n * Owner-only: grant the FR-6 `custodian` role. The custodian operates every\n * collection (rw + access) but is provably unable to grant / revoke / rotate /\n * extract-and-sever. Defended in depth (gate + owner-only role check) inside\n * the injected `Noydb.grantCustodian`.\n */\n async grantCustodian(options: GrantCustodianOptions, factors?: FactorProofBundle): Promise<void> {\n return this._grantCustodian(options, factors)\n }\n\n /** Owner-only: revoke a custodian. */\n async revokeCustodian(options: RevokeOptions, factors?: FactorProofBundle): Promise<void> {\n return this._revokeCustodian(options, factors)\n }\n\n /**\n * Custodian-only: the audited claim of ownership over a sealed-owner (Deed)\n * vault. Mints a DISTINCT new owner re-wrapping the incumbent DEKs under a\n * fresh KEK (the latent owner is never impersonated), ledger-audited. See\n * {@link liberateVault}.\n */\n async liberate(opts: LiberateOptions): Promise<LiberateResult> {\n return this._liberate(opts)\n }\n}\n"],"mappings":";;;;;;;;;;AAgCO,IAAM,WAA0B;AAAA,EACrC,MAAM,mBAAmB;AAAE,UAAM,IAAI,qBAAqB;AAAA,EAAE;AAC9D;;;ACvBO,SAAS,cAA+B;AAC7C,SAAO;AAAA,IACL,MAAM,eAAe,MAAM,OAAO,SAAS,SAAS;AAClD,aAAO,KAAK,oBAAoB,OAAa,OAAO,SAAS,OAAO;AAAA,IACtE;AAAA,IACA,MAAM,gBAAgB,MAAM,OAAO,SAAS,SAAS;AACnD,aAAO,KAAK,qBAAqB,QAAc,OAAO,SAAS,OAAO;AAAA,IACxE;AAAA,IACA,MAAM,SAAS,OAAO,MAAM;AAC1B,YAAM,EAAE,cAAc,IAAI,MAAM,OAAO,wBAAe;AACtD,aAAO,cAAc,OAAO,IAAI;AAAA,IAClC;AAAA,EACF;AACF;;;ACqCO,IAAM,aAA8B;AAAA,EACzC,MAAM,iBAAiB;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AAAA,EAC5D,MAAM,kBAAkB;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AAAA,EAC7D,MAAM,WAAW;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AACxD;;;ACtBO,IAAM,aAAN,MAAiB;AAAA,EACtB,YAEmB,iBAEA,kBAEA,WACjB;AALiB;AAEA;AAEA;AAAA,EAChB;AAAA,EALgB;AAAA,EAEA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,MAAM,eAAe,SAAgC,SAA4C;AAC/F,WAAO,KAAK,gBAAgB,SAAS,OAAO;AAAA,EAC9C;AAAA;AAAA,EAGA,MAAM,gBAAgB,SAAwB,SAA4C;AACxF,WAAO,KAAK,iBAAiB,SAAS,OAAO;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,MAAgD;AAC7D,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/with-cargo/strategy.ts","../src/with-party/custody/strategy.ts","../src/with-party/custody/active.ts","../src/with-party/custody/index.ts"],"sourcesContent":["/**\n * Cargo capability strategy (FR-6/FR-7) — the source-side, owner-level\n * partition operation that requires a live {@link Vault}: extracting a re-keyed\n * transfer-sealed partition ({@link extractPartitionCore}). The active engine\n * ({@link withCargo}) dynamically imports that engine (keeping the extraction\n * crypto out of the floor bundle); {@link NO_CARGO} throws.\n *\n * The public free function `extractPartition` (which takes a `Vault`) delegates\n * here via `vault.cargoStrategy`, so an un-opted-in caller hits `NO_CARGO`'s\n * throw.\n *\n * Carve-out (mirrors `openSealedRecord` / `liberateVault`): the recipient-side\n * free functions `adoptPartition` and `decryptExtractedPartition` operate on\n * raw bundle bytes + a destination store — they carry NO source instance to\n * gate against, so they stay ungated host-side tooling. `diffVault` is likewise\n * ungated: it's shared import/merge infrastructure the `as-*` exporters call\n * internally, not a gated cargo capability.\n * @internal\n */\nimport type { Vault } from '../kernel/vault.js'\nimport type { ExtractPartitionResult, ExtractPartitionOptions } from './extract-partition.js'\nimport { CargoNotEnabledError } from '../kernel/errors.js'\n\nexport interface CargoStrategy {\n extractPartition(vault: Vault, opts: ExtractPartitionOptions): Promise<ExtractPartitionResult>\n}\n\n/**\n * No-op stub — the floor default. The source-side cargo op throws\n * {@link CargoNotEnabledError}; opt in with `cargoStrategy: withCargo()` in\n * createNoydb. @internal\n */\nexport const NO_CARGO: CargoStrategy = {\n async extractPartition() { throw new CargoNotEnabledError() },\n}\n","/**\n * Sovereign-custody (FR-6) capability strategy — the three on-demand\n * operations the custody surface routes through: minting a custodian\n * (`grantCustodian`), removing one (`revokeCustodian`), and the audited\n * ownership-claim ceremony (`liberate`). The active engine ({@link withCustody})\n * runs the grant/revoke impls the host exposes and dynamically imports the\n * heavy `liberateVault` ceremony (keeping it out of the floor bundle);\n * {@link NO_CUSTODY} throws.\n *\n * `Noydb.grantCustodian` / `Noydb.revokeCustodian` delegate here (passing\n * themselves as the {@link CustodyHost}), and `vault.custody.liberate` delegates\n * here with its {@link Vault}. An un-opted-in caller hits `NO_CUSTODY`'s throw.\n *\n * Note: the lower-level `liberateVault` FREE FUNCTION (exported from\n * `custody/liberate.ts`) stays ungated — it has no `createNoydb` instance to\n * gate against (the same carve-out as the `openSealedRecord` host opener). Only\n * the instance surfaces (`db.grantCustodian` / `db.revokeCustodian` /\n * `vault.custody.*`) are the capability.\n * @internal\n */\nimport type { GrantOptions, RevokeOptions, FactorProofBundle, NoydbStore } from '../../kernel/types.js'\nimport type { Vault } from '../../kernel/vault.js'\nimport type { UnlockedKeyring } from '../team/keyring.js'\nimport type { GrantCustodianOptions } from './index.js'\nimport type { LiberateOptions, LiberateResult } from './liberate.js'\nimport { CustodyNotEnabledError } from '../../kernel/errors.js'\n\n/**\n * The grant/revoke engine the strategy runs when opted in — implemented by\n * `Noydb` (`_grantCustodianImpl` / `_revokeCustodianImpl` hold the gate +\n * keyring logic; the public `grantCustodian` / `revokeCustodian` route through\n * the strategy). Since the #267 team split the keyring grant/revoke engines\n * are passed IN by `withCustody()` (statically linked there, not in the\n * kernel) so the single-user floor never carries them.\n */\nexport interface CustodyHost {\n _grantCustodianImpl(\n engine: (adapter: NoydbStore, vault: string, callerKeyring: UnlockedKeyring, options: GrantOptions) => Promise<void>,\n vault: string,\n options: GrantCustodianOptions,\n factors?: FactorProofBundle,\n ): Promise<void>\n _revokeCustodianImpl(\n engine: (adapter: NoydbStore, vault: string, callerKeyring: UnlockedKeyring, options: RevokeOptions) => Promise<void>,\n vault: string,\n options: RevokeOptions,\n factors?: FactorProofBundle,\n ): Promise<void>\n}\n\nexport interface CustodyStrategy {\n grantCustodian(host: CustodyHost, vault: string, options: GrantCustodianOptions, factors?: FactorProofBundle): Promise<void>\n revokeCustodian(host: CustodyHost, vault: string, options: RevokeOptions, factors?: FactorProofBundle): Promise<void>\n liberate(vault: Vault, opts: LiberateOptions): Promise<LiberateResult>\n}\n\n/**\n * No-op stub — the floor default. Every custody operation throws\n * {@link CustodyNotEnabledError}; opt in with `custodyStrategy: withCustody()`\n * in createNoydb. @internal\n */\nexport const NO_CUSTODY: CustodyStrategy = {\n async grantCustodian() { throw new CustodyNotEnabledError() },\n async revokeCustodian() { throw new CustodyNotEnabledError() },\n async liberate() { throw new CustodyNotEnabledError() },\n}\n","/**\n * Enable the sovereign-custody (FR-6) capability.\n * Pass to `createNoydb({ custodyStrategy: withCustody() })` to make\n * `db.grantCustodian` / `db.revokeCustodian` (and the `vault.custody.*` facade\n * that delegates to them) plus `vault.custody.liberate()` live. The heavy\n * `liberateVault` ceremony is dynamically imported here, so it is reached only\n * via opt-in; grant/revoke run the host's own gate + keyring engine.\n */\nimport type { CustodyStrategy } from './strategy.js'\nimport { grant as grantEngine, revoke as revokeEngine } from '../team/keyring.js'\n\nexport function withCustody(): CustodyStrategy {\n return {\n async grantCustodian(host, vault, options, factors) {\n return host._grantCustodianImpl(grantEngine, vault, options, factors)\n },\n async revokeCustodian(host, vault, options, factors) {\n return host._revokeCustodianImpl(revokeEngine, vault, options, factors)\n },\n async liberate(vault, opts) {\n const { liberateVault } = await import('./liberate.js')\n return liberateVault(vault, opts)\n },\n }\n}\n","/**\n * Public `vault.custody.*` API surface (FR-6).\n *\n * The custody namespace is the vault-instance face of the FR-6 sovereign-custody\n * model — it mirrors `vault.user.*` exactly: a thin delegation shell with NO\n * business logic. The Vault constructs one `CustodyApi` per session, injecting\n * closures that bind the vault name / keyring into the genuinely-core\n * implementations (`Noydb.grantCustodian` / `Noydb.revokeCustodian` and the\n * `liberateVault` ceremony). Each method just forwards to its injected callback.\n *\n * Three operations:\n * - `grantCustodian(opts)` — owner-only: mint a `custodian` who operates the\n * vault fully but can never grant / rotate / sever / extract.\n * - `revokeCustodian(opts)` — owner-only: remove a custodian.\n * - `liberate(opts)` — custodian-only: audited claim of ownership over a\n * sealed-owner (Deed) vault (mints a DISTINCT new owner; ledger-audited).\n *\n * Provisioning a Deed (`createDeedOwner`) is deliberately NOT on this class: it\n * is a store-level operation that mints the vault's first owner, so there is no\n * vault instance (and thus no custody namespace) yet — it stays the exported\n * `team/deed.ts` function.\n *\n * @see docs/superpowers/specs/2026-06-17-fr6-deed-custodian-liberate-design.md\n * @module\n */\nimport type { GrantOptions, RevokeOptions, FactorProofBundle } from '../../kernel/types.js'\nimport type { LiberateOptions, LiberateResult } from './liberate.js'\n\n/** Options for `vault.custody.grantCustodian` — a grant with the role fixed to `custodian`. */\nexport type GrantCustodianOptions = Omit<GrantOptions, 'role'>\n\n// Capability opt-in seam (S4): grant/revoke custodian + liberate throw\n// CustodyNotEnabledError unless `custodyStrategy: withCustody()` is opted in.\nexport { withCustody } from './active.js'\nexport { NO_CUSTODY, type CustodyStrategy, type CustodyHost } from './strategy.js'\nexport { CustodyNotEnabledError } from '../../kernel/errors.js'\n\n/**\n * Implementation behind `vault.custody`. Constructed once per Vault. Holds the\n * injected, vault-bound implementations in closure; every method delegates with\n * no added logic (the owner-only / custodian-only / gate checks all live in the\n * injected implementations — `Noydb.grantCustodian` etc. and `liberateVault`).\n */\nexport class CustodyApi {\n constructor(\n /** Bound `Noydb.grantCustodian(this.name, ...)` — owner-only, gated. */\n private readonly _grantCustodian: (options: GrantCustodianOptions, factors?: FactorProofBundle) => Promise<void>,\n /** Bound `Noydb.revokeCustodian(this.name, ...)` — owner-only, gated. */\n private readonly _revokeCustodian: (options: RevokeOptions, factors?: FactorProofBundle) => Promise<void>,\n /** Bound `liberateVault(this, ...)` — custodian-only audited ownership claim. */\n private readonly _liberate: (opts: LiberateOptions) => Promise<LiberateResult>,\n ) {}\n\n /**\n * Owner-only: grant the FR-6 `custodian` role. The custodian operates every\n * collection (rw + access) but is provably unable to grant / revoke / rotate /\n * extract-and-sever. Defended in depth (gate + owner-only role check) inside\n * the injected `Noydb.grantCustodian`.\n */\n async grantCustodian(options: GrantCustodianOptions, factors?: FactorProofBundle): Promise<void> {\n return this._grantCustodian(options, factors)\n }\n\n /** Owner-only: revoke a custodian. */\n async revokeCustodian(options: RevokeOptions, factors?: FactorProofBundle): Promise<void> {\n return this._revokeCustodian(options, factors)\n }\n\n /**\n * Custodian-only: the audited claim of ownership over a sealed-owner (Deed)\n * vault. Mints a DISTINCT new owner re-wrapping the incumbent DEKs under a\n * fresh KEK (the latent owner is never impersonated), ledger-audited. See\n * {@link liberateVault}.\n */\n async liberate(opts: LiberateOptions): Promise<LiberateResult> {\n return this._liberate(opts)\n }\n}\n"],"mappings":";;;;;;;;;;AAgCO,IAAM,WAA0B;AAAA,EACrC,MAAM,mBAAmB;AAAE,UAAM,IAAI,qBAAqB;AAAA,EAAE;AAC9D;;;AC2BO,IAAM,aAA8B;AAAA,EACzC,MAAM,iBAAiB;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AAAA,EAC5D,MAAM,kBAAkB;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AAAA,EAC7D,MAAM,WAAW;AAAE,UAAM,IAAI,uBAAuB;AAAA,EAAE;AACxD;;;ACtDO,SAAS,cAA+B;AAC7C,SAAO;AAAA,IACL,MAAM,eAAe,MAAM,OAAO,SAAS,SAAS;AAClD,aAAO,KAAK,oBAAoB,OAAa,OAAO,SAAS,OAAO;AAAA,IACtE;AAAA,IACA,MAAM,gBAAgB,MAAM,OAAO,SAAS,SAAS;AACnD,aAAO,KAAK,qBAAqB,QAAc,OAAO,SAAS,OAAO;AAAA,IACxE;AAAA,IACA,MAAM,SAAS,OAAO,MAAM;AAC1B,YAAM,EAAE,cAAc,IAAI,MAAM,OAAO,wBAAe;AACtD,aAAO,cAAc,OAAO,IAAI;AAAA,IAClC;AAAA,EACF;AACF;;;ACmBO,IAAM,aAAN,MAAiB;AAAA,EACtB,YAEmB,iBAEA,kBAEA,WACjB;AALiB;AAEA;AAEA;AAAA,EAChB;AAAA,EALgB;AAAA,EAEA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,MAAM,eAAe,SAAgC,SAA4C;AAC/F,WAAO,KAAK,gBAAgB,SAAS,OAAO;AAAA,EAC9C;AAAA;AAAA,EAGA,MAAM,gBAAgB,SAAwB,SAA4C;AACxF,WAAO,KAAK,iBAAiB,SAAS,OAAO;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,MAAgD;AAC7D,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TierNotGrantedError
3
- } from "./chunk-IGM563N5.js";
3
+ } from "./chunk-6SYOHUHM.js";
4
4
 
5
5
  // src/with-party/team/tiers.ts
6
6
  function dekKey(collection, tier) {
@@ -31,4 +31,4 @@ export {
31
31
  effectiveClearance,
32
32
  assertTierAccess
33
33
  };
34
- //# sourceMappingURL=chunk-MSO2C3KG.js.map
34
+ //# sourceMappingURL=chunk-LC7DSMHR.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-5BHNQNBI.js";
3
+ } from "./chunk-YTW6ZIPD.js";
4
4
 
5
5
  // src/with-shape/schema-update/fence.ts
6
6
  var FENCE_RECORD_ID = "schema-fence";
@@ -37,4 +37,4 @@ export {
37
37
  loadFence,
38
38
  saveFence
39
39
  };
40
- //# sourceMappingURL=chunk-JA5B3SLH.js.map
40
+ //# sourceMappingURL=chunk-M6QA2KK2.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NoydbError
3
- } from "./chunk-IGM563N5.js";
3
+ } from "./chunk-6SYOHUHM.js";
4
4
 
5
5
  // src/with-shape/links/names.ts
6
6
  var LINK_COLLECTION_PREFIX = "_links_";
@@ -38,4 +38,4 @@ export {
38
38
  linkRowKey,
39
39
  LinkIntegrityError
40
40
  };
41
- //# sourceMappingURL=chunk-IUIVDVXM.js.map
41
+ //# sourceMappingURL=chunk-MUPZ6IZX.js.map
@@ -7,28 +7,28 @@ import {
7
7
  PERIOD_FREEZES_COLLECTION,
8
8
  PERIOD_TARGET_PURGES_COLLECTION,
9
9
  periodExclusiveUpperBound
10
- } from "./chunk-F4COUZLL.js";
10
+ } from "./chunk-TMR64XPL.js";
11
11
  import {
12
12
  envelopeBodySize
13
- } from "./chunk-PEY6ZTCF.js";
13
+ } from "./chunk-GEEJPID6.js";
14
14
  import {
15
15
  isDeleteMarker,
16
16
  isTombstoneShape
17
- } from "./chunk-QXPOEAKR.js";
17
+ } from "./chunk-SC4JLMZI.js";
18
18
  import {
19
19
  bufferToBase64,
20
20
  decrypt,
21
21
  derivePresenceKey,
22
22
  encrypt,
23
23
  generateIV
24
- } from "./chunk-5P5AAXYA.js";
24
+ } from "./chunk-7U6AB7DZ.js";
25
25
  import {
26
26
  NOYDB_SYNC_VERSION
27
- } from "./chunk-5BHNQNBI.js";
27
+ } from "./chunk-YTW6ZIPD.js";
28
28
  import {
29
29
  ConflictError,
30
30
  ValidationError
31
- } from "./chunk-IGM563N5.js";
31
+ } from "./chunk-6SYOHUHM.js";
32
32
 
33
33
  // src/with-party/team/presence.ts
34
34
  var PresenceHandle = class {
@@ -1073,4 +1073,4 @@ export {
1073
1073
  SyncEngine,
1074
1074
  SyncTransaction
1075
1075
  };
1076
- //# sourceMappingURL=chunk-QAFWRGVD.js.map
1076
+ //# sourceMappingURL=chunk-OGVE4IJW.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-5BHNQNBI.js";
3
+ } from "./chunk-YTW6ZIPD.js";
4
4
 
5
- // src/with-party/team/managed-passphrase.ts
5
+ // src/with-party/team/managed-secret.ts
6
6
  var MemorySealingKeyProvider = class {
7
7
  id;
8
8
  fingerprint;
@@ -25,11 +25,11 @@ var MemorySealingKeyProvider = class {
25
25
  this.keyBytes[i] = this.fingerprint[i % 4] ^ i * 17;
26
26
  }
27
27
  }
28
- async seal(passphrase) {
29
- const out = new Uint8Array(4 + passphrase.length);
28
+ async seal(secret) {
29
+ const out = new Uint8Array(4 + secret.length);
30
30
  out.set(this.fingerprint, 0);
31
- for (let i = 0; i < passphrase.length; i++) {
32
- out[4 + i] = passphrase[i] ^ this.keyBytes[i % 16];
31
+ for (let i = 0; i < secret.length; i++) {
32
+ out[4 + i] = secret[i] ^ this.keyBytes[i % 16];
33
33
  }
34
34
  return out;
35
35
  }
@@ -138,7 +138,7 @@ var MemoryRecipientSealer = class {
138
138
  return pt;
139
139
  }
140
140
  };
141
- var SEALED_PASSPHRASE_RECORD_ID = "sealed-passphrase";
141
+ var SEALED_SECRET_RECORD_ID = "sealed-secret";
142
142
  function bytesToBase64(bytes) {
143
143
  let binary = "";
144
144
  for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
@@ -170,14 +170,14 @@ function parseSealedEnvelope(raw) {
170
170
  }
171
171
  return void 0;
172
172
  }
173
- async function saveSealedPassphrase(store, vault, payload) {
173
+ async function saveSealedSecret(store, vault, payload) {
174
174
  const persisted = {
175
175
  v: 1,
176
176
  _noydb_sealed: 1,
177
177
  pid: payload.providerId,
178
178
  payload: bytesToBase64(payload.sealed)
179
179
  };
180
- const prior = await store.get(vault, "_meta", SEALED_PASSPHRASE_RECORD_ID);
180
+ const prior = await store.get(vault, "_meta", SEALED_SECRET_RECORD_ID);
181
181
  const env = {
182
182
  _noydb: NOYDB_FORMAT_VERSION,
183
183
  _v: (prior?._v ?? 0) + 1,
@@ -186,10 +186,10 @@ async function saveSealedPassphrase(store, vault, payload) {
186
186
  _iv: "",
187
187
  _data: JSON.stringify(persisted)
188
188
  };
189
- await store.put(vault, "_meta", SEALED_PASSPHRASE_RECORD_ID, env);
189
+ await store.put(vault, "_meta", SEALED_SECRET_RECORD_ID, env);
190
190
  }
191
- async function loadSealedPassphrase(store, vault) {
192
- const envelope = await store.get(vault, "_meta", SEALED_PASSPHRASE_RECORD_ID);
191
+ async function loadSealedSecret(store, vault) {
192
+ const envelope = await store.get(vault, "_meta", SEALED_SECRET_RECORD_ID);
193
193
  if (!envelope) return void 0;
194
194
  try {
195
195
  return parseSealedEnvelope(JSON.parse(envelope._data));
@@ -198,11 +198,11 @@ async function loadSealedPassphrase(store, vault) {
198
198
  }
199
199
  }
200
200
  async function resolveManagedSecret(store, vault, provider) {
201
- const existing = await loadSealedPassphrase(store, vault);
201
+ const existing = await loadSealedSecret(store, vault);
202
202
  if (existing) {
203
203
  if (existing.providerId !== provider.id) {
204
204
  throw new Error(
205
- `Managed-mode vault "${vault}" was sealed under provider id "${existing.providerId}" but the current SealingKeyProvider is "${provider.id}". Pass the same provider that originally enrolled the vault, or treat this as a fresh enrollment and clear \`_meta/sealed-passphrase\` first.`
205
+ `Managed-mode vault "${vault}" was sealed under provider id "${existing.providerId}" but the current SealingKeyProvider is "${provider.id}". Pass the same provider that originally enrolled the vault, or treat this as a fresh enrollment and clear \`_meta/sealed-secret\` first.`
206
206
  );
207
207
  }
208
208
  const plaintext = await provider.unseal(existing.sealed);
@@ -211,7 +211,7 @@ async function resolveManagedSecret(store, vault, provider) {
211
211
  const random = new Uint8Array(32);
212
212
  globalThis.crypto.getRandomValues(random);
213
213
  const sealed = await provider.seal(random);
214
- await saveSealedPassphrase(store, vault, { providerId: provider.id, sealed });
214
+ await saveSealedSecret(store, vault, { providerId: provider.id, sealed });
215
215
  return bytesToBase64(random);
216
216
  }
217
217
 
@@ -221,10 +221,10 @@ export {
221
221
  parseRsaOaepTlv,
222
222
  aesGcmOpen,
223
223
  MemoryRecipientSealer,
224
- SEALED_PASSPHRASE_RECORD_ID,
224
+ SEALED_SECRET_RECORD_ID,
225
225
  parseSealedEnvelope,
226
- saveSealedPassphrase,
227
- loadSealedPassphrase,
226
+ saveSealedSecret,
227
+ loadSealedSecret,
228
228
  resolveManagedSecret
229
229
  };
230
- //# sourceMappingURL=chunk-BCOKZC4B.js.map
230
+ //# sourceMappingURL=chunk-OHV6T5JB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-party/team/managed-secret.ts"],"sourcesContent":["/**\n * Managed-secret mode — rubber-hose-resistant vaults.\n *\n * A vault mode where the secret is machine-generated and never\n * exposed to the user, sealed under a developer-provided\n * {@link SealingKeyProvider} (macOS Keychain, Windows Credential\n * Manager, libsecret, AWS KMS, …). The user has no secret to give\n * up to coercion — they can't reveal what they don't know.\n *\n * ## Components in this file\n *\n * - {@link SealingKeyProvider} — the interface concrete providers\n * implement. Provider implementations live OUTSIDE hub (per-\n * platform packages).\n * - {@link MemorySealingKeyProvider} — in-memory test provider; uses\n * a deterministic per-instance \"key\" so two providers with\n * different ids cannot unseal each other's outputs.\n * - {@link RecipientHint} — public material a sender uses to seal\n * plaintext for a specific recipient; published by\n * {@link RecipientSealer.publishRecipientHint} and transported\n * out-of-band to the sender before bundle writes.\n * - {@link RecipientSealer} — interface for asymmetric/granted\n * providers that support recipient-target sealing (RSA-OAEP,\n * cloud-KMS asymmetric, etc.); distinct from self-only\n * {@link SealingKeyProvider} (macOS Keychain, WebAuthn-PRF).\n * - {@link MemoryRecipientSealer} — in-process reference\n * implementation of both `RecipientSealer` and\n * `SealingKeyProvider` using real WebCrypto RSA-OAEP + AES-GCM;\n * safe for tests and same-process sender/recipient scenarios.\n * - {@link loadSealedSecret} / {@link saveSealedSecret} —\n * plaintext envelope storage at `_meta/sealed-secret`.\n * Mirrors the `_meta/handle` and `_meta/public-envelope` AES-\n * GCM-bypassed patterns. The sealing layer (provider's job)\n * is the security boundary; hub doesn't have a key to encrypt\n * with at this layer — that's the whole point of the design.\n * - {@link resolveManagedSecret} — orchestrates the \"generate +\n * seal + persist on first open; unseal on reopen\" flow.\n * Returns the plaintext secret string that the rest of the\n * `createNoydb` keyring path consumes.\n *\n * Deferred to follow-ups:\n * - Block `rotate-secret` policy gate under managed mode.\n * - Mandatory strong-recovery enforcement.\n * - Recovery flow under managed mode (generates fresh sealed phrase).\n *\n * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → Managed-secret mode\n *\n * @module\n */\n\nimport type { NoydbStore, EncryptedEnvelope, RecipientSealer } from '../../kernel/types.js'\nimport { NOYDB_FORMAT_VERSION } from '../../kernel/types.js'\n\n/**\n * The contract concrete providers (per-platform key stores) implement\n * to seal and unseal a hub-generated random secret. The plaintext\n * secret NEVER leaves hub-controlled memory in unsealed form —\n * the provider receives the bytes, returns opaque sealed bytes, and\n * later reverses the operation. Hub treats the sealed bytes as\n * fully opaque.\n *\n * Implementations live OUTSIDE `@noy-db/hub` (separate packages\n * per the issue's \"Concrete providers (live outside hub)\" note):\n *\n * | Platform | Package (TBD) | Backing |\n * |---|---|---|\n * | macOS | `@noy-db/seal-macos-keychain` | Security.framework |\n * | Windows | `@noy-db/seal-wincred` | Credential Manager |\n * | Linux | `@noy-db/seal-libsecret` | libsecret / secret-service |\n * | Cloud / server | `@noy-db/seal-aws-kms` | AWS KMS Decrypt |\n */\nexport interface SealingKeyProvider {\n /**\n * Non-sensitive identifier disclosed in the persisted envelope.\n * Surfaced to consumers via `loadSealedSecret().providerId` so\n * a vault opened with the wrong provider class can detect the\n * mismatch and surface a clear error. NOT secret — fine to log.\n *\n * Suggested format: `<family>:<scope>` — e.g. `macos-keychain:com.acme.app`,\n * `aws-kms:arn:aws:kms:us-east-1:123:key/abc`. The hub never\n * parses this; it's purely audit metadata.\n */\n readonly id: string\n\n /** Seal raw secret bytes. Output bytes are opaque to hub. */\n seal(secret: Uint8Array): Promise<Uint8Array>\n\n /**\n * Reverse {@link seal}. MUST throw on tamper, wrong-provider, or\n * any other failure — hub treats a thrown error as \"this provider\n * cannot unlock this vault\" and surfaces it to the caller.\n */\n unseal(sealed: Uint8Array): Promise<Uint8Array>\n}\n\n/**\n * In-memory test provider. NOT secure — uses a deterministic\n * per-instance \"key\" (16-byte SHA-256 of `id`) XOR'd over the\n * secret plus a 4-byte provider-id fingerprint prefix. The XOR is\n * sufficient to make different `id` values produce mutually-unsealable\n * outputs (the contract tests for that), but offers ZERO real\n * confidentiality — never use outside tests.\n *\n * Replace with a real platform provider in production.\n */\nexport class MemorySealingKeyProvider implements SealingKeyProvider {\n readonly id: string\n private readonly fingerprint: Uint8Array\n private readonly keyBytes: Uint8Array\n\n constructor(opts: { id: string }) {\n this.id = opts.id\n // Deterministic 4-byte fingerprint of the provider id, prepended\n // to every sealed output so we can detect \"wrong provider\" at\n // unseal time without leaking anything sensitive about either\n // provider's actual key material.\n const encoded = new TextEncoder().encode(opts.id)\n let h = 0\n for (let i = 0; i < encoded.length; i++) {\n h = (h * 31 + encoded[i]!) >>> 0\n }\n this.fingerprint = new Uint8Array([\n (h >>> 24) & 0xff, (h >>> 16) & 0xff, (h >>> 8) & 0xff, h & 0xff,\n ])\n // Deterministic 16-byte \"key\" derived from the id by repeating\n // the fingerprint with offsets. Good enough for the XOR-stream\n // test cipher; never confuse this with real key derivation.\n this.keyBytes = new Uint8Array(16)\n for (let i = 0; i < 16; i++) {\n this.keyBytes[i] = this.fingerprint[i % 4]! ^ (i * 17)\n }\n }\n\n async seal(secret: Uint8Array): Promise<Uint8Array> {\n const out = new Uint8Array(4 + secret.length)\n out.set(this.fingerprint, 0)\n for (let i = 0; i < secret.length; i++) {\n out[4 + i] = secret[i]! ^ this.keyBytes[i % 16]!\n }\n return out\n }\n\n async unseal(sealed: Uint8Array): Promise<Uint8Array> {\n if (sealed.length < 4) {\n throw new Error('MemorySealingKeyProvider: sealed input too short')\n }\n for (let i = 0; i < 4; i++) {\n if (sealed[i] !== this.fingerprint[i]) {\n throw new Error(\n `MemorySealingKeyProvider(\"${this.id}\"): provider-id mismatch on unseal `\n + '(sealed bytes were produced by a different provider)',\n )\n }\n }\n const body = sealed.subarray(4)\n const out = new Uint8Array(body.length)\n for (let i = 0; i < body.length; i++) {\n out[i] = body[i]! ^ this.keyBytes[i % 16]!\n }\n return out\n }\n}\n\n/**\n * Public material a sender uses to seal-for-this-recipient. Published by\n * a recipient's RecipientSealer; transported to the sender out-of-band\n * (email, S3, in-app message). The sender obtains the hint, supplies it\n * to writePod's sealedCredentials.perUser[userId].hint, and the\n * hub seals each user's credential against it. Per foundation §11.4.\n */\nexport type RecipientHint = {\n readonly v: 1\n /** Recipient's provider id; matches the SealedAutoUnlockEntry.pid they'll unseal under. */\n readonly pid: string\n /** Algorithm the sender uses to produce the seal. Slice 1 ships RSA-OAEP-SHA256 only. */\n readonly alg: 'rsa-oaep-sha256'\n /** Public material — alg-specific. For 'rsa-oaep-sha256': { publicKeyPem: string }. */\n readonly material: Readonly<Record<string, unknown>>\n}\n\n// Hoisted to kernel/types.ts (C3 — enclave self-containment: sealing.ts\n// consumes this as a spine-owned contract type). Re-exported here so existing\n// importers of this module are unaffected.\nexport type { RecipientSealer } from '../../kernel/types.js'\n\n/**\n * Shared RSA-OAEP-SHA256 + AES-GCM seal in the canonical recipient-target\n * TLV wire format. Mints a fresh 32-byte CEK, AES-GCM-encrypts `plaintext`\n * under it, RSA-OAEP-SHA256-wraps the CEK to `publicKeyPem`, and packs:\n *\n * byte 0 : version (0x01)\n * bytes 1..256 : RSA-OAEP-wrapped CEK (fixed 256 bytes at RSA-2048)\n * bytes 257..268: AES-GCM IV (12 bytes)\n * bytes 269.. : AES-GCM ciphertext ‖ 16-byte tag\n *\n * This is the single source of truth for the wire format — both\n * {@link MemoryRecipientSealer} and external sealers (e.g. `@noy-db/at-aws-kms`'s\n * asymmetric-KMS recipient sealer) call it so a blob sealed by one unseals\n * by the other. WebCrypto RSA-OAEP/SHA-256 here is wire-compatible with\n * AWS KMS `RSAES_OAEP_SHA_256` (both RSAES-OAEP, SHA-256 hash, MGF1-SHA256,\n * empty label).\n *\n * @public — re-exported from the hub barrel for external sealer packages.\n */\nexport async function sealRsaOaepTlv(plaintext: Uint8Array, publicKeyPem: string): Promise<Uint8Array> {\n // Parse PEM → SPKI bytes.\n const b64 = publicKeyPem.replace(/-----BEGIN PUBLIC KEY-----/, '').replace(/-----END PUBLIC KEY-----/, '').replace(/\\s+/g, '')\n const spki = base64ToBytes(b64)\n const recipientPub = await crypto.subtle.importKey(\n 'spki', spki as BufferSource,\n { name: 'RSA-OAEP', hash: 'SHA-256' },\n false, ['encrypt'],\n )\n // Mint fresh CEK + IV, AES-GCM encrypt plaintext.\n const cekBytes = crypto.getRandomValues(new Uint8Array(32))\n const cek = await crypto.subtle.importKey('raw', cekBytes as BufferSource, 'AES-GCM', false, ['encrypt'])\n const iv = crypto.getRandomValues(new Uint8Array(12))\n const ct = new Uint8Array(await crypto.subtle.encrypt({ name: 'AES-GCM', iv: iv as BufferSource }, cek, plaintext as BufferSource))\n // RSA-OAEP-wrap the CEK bytes.\n const wrapped = new Uint8Array(await crypto.subtle.encrypt({ name: 'RSA-OAEP' }, recipientPub, cekBytes as BufferSource))\n cekBytes.fill(0)\n if (wrapped.length !== 256) {\n throw new Error(`sealRsaOaepTlv: expected 256-byte RSA-OAEP wrap, got ${wrapped.length}`)\n }\n // TLV layout.\n const out = new Uint8Array(1 + 256 + 12 + ct.length)\n out[0] = 0x01\n out.set(wrapped, 1)\n out.set(iv, 1 + 256)\n out.set(ct, 1 + 256 + 12)\n return out\n}\n\n/**\n * Parse a {@link sealRsaOaepTlv} blob into its three segments without\n * decrypting. The `wrapped` CEK is RSA-OAEP-SHA256 ciphertext over a\n * 32-byte CEK — the unwrap step is pluggable: {@link MemoryRecipientSealer}\n * decrypts it with a local RSA private key; `@noy-db/at-aws-kms` hands it to\n * KMS `Decrypt`. After unwrapping, pass the CEK + `iv` + `ct` to\n * {@link aesGcmOpen}.\n *\n * @public — re-exported from the hub barrel for external sealer packages.\n */\nexport function parseRsaOaepTlv(bytes: Uint8Array): { wrapped: Uint8Array; iv: Uint8Array; ct: Uint8Array } {\n if (bytes.length < 1 + 256 + 12 + 16) {\n throw new Error('parseRsaOaepTlv: sealed input too short')\n }\n if (bytes[0] !== 0x01) {\n throw new Error(`parseRsaOaepTlv: unknown TLV version ${bytes[0]}`)\n }\n return {\n wrapped: bytes.subarray(1, 1 + 256),\n iv: bytes.subarray(1 + 256, 1 + 256 + 12),\n ct: bytes.subarray(1 + 256 + 12),\n }\n}\n\n/**\n * AES-GCM-decrypt the `ct` segment of a {@link parseRsaOaepTlv} result under\n * the unwrapped 32-byte CEK and its `iv`. Throws on a bad tag (tamper) — the\n * same authenticated-decryption guarantee the TLV relies on.\n *\n * @public — re-exported from the hub barrel for external sealer packages.\n */\nexport async function aesGcmOpen(cekBytes: Uint8Array, iv: Uint8Array, ct: Uint8Array): Promise<Uint8Array> {\n const cek = await crypto.subtle.importKey('raw', cekBytes as BufferSource, 'AES-GCM', false, ['decrypt'])\n return new Uint8Array(await crypto.subtle.decrypt({ name: 'AES-GCM', iv: iv as BufferSource }, cek, ct as BufferSource))\n}\n\n/**\n * Reference implementation of `RecipientSealer` + `SealingKeyProvider`.\n * Uses WebCrypto RSA-OAEP-SHA256 (2048-bit) to wrap a fresh 32-byte\n * AES-GCM CEK, AES-GCM-encrypts plaintext under it, and packs the\n * result into a self-describing TLV:\n *\n * byte 0 : version (0x01)\n * bytes 1..256 : RSA-OAEP-wrapped CEK (fixed 256 bytes at RSA-2048)\n * bytes 257..268: AES-GCM IV (12 bytes)\n * bytes 269.. : AES-GCM ciphertext ‖ 16-byte tag\n *\n * Implements BOTH interfaces. `seal(plaintext)` (self-target) is just\n * `sealForRecipient(plaintext, this own hint)` — same TLV. Convenient\n * for tests where one provider plays both ends. Real cloud providers\n * (`at-aws-kms`, etc.) will pick their own internal layouts; the only\n * contract is round-trip identity.\n *\n * SAFE for production within its scope — the cryptography is real\n * (RSA-OAEP + AES-GCM via WebCrypto), but the keypair lives in-process\n * and is regenerated on every construction. Not suitable as a managed\n * keychain; use it for tests and for shipping bundles where the\n * recipient instance lives in the same process as the sender (rare).\n */\nexport class MemoryRecipientSealer implements SealingKeyProvider, RecipientSealer {\n readonly id: string\n private readonly keypair: Promise<CryptoKeyPair>\n\n constructor(opts: { id: string }) {\n this.id = opts.id\n this.keypair = crypto.subtle.generateKey(\n { name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' },\n true,\n ['encrypt', 'decrypt'],\n )\n }\n\n async publishRecipientHint(): Promise<RecipientHint> {\n const { publicKey } = await this.keypair\n const spki = await crypto.subtle.exportKey('spki', publicKey)\n const pem = '-----BEGIN PUBLIC KEY-----\\n'\n + bytesToBase64(new Uint8Array(spki)).match(/.{1,64}/g)!.join('\\n')\n + '\\n-----END PUBLIC KEY-----\\n'\n return { v: 1, pid: this.id, alg: 'rsa-oaep-sha256', material: { publicKeyPem: pem } }\n }\n\n async sealForRecipient(plaintext: Uint8Array, hint: RecipientHint): Promise<Uint8Array> {\n if (hint.v !== 1) {\n throw new Error(`MemoryRecipientSealer.sealForRecipient: unsupported hint.v ${String(hint.v)} (expected 1)`)\n }\n if (hint.alg !== 'rsa-oaep-sha256') {\n throw new Error(`MemoryRecipientSealer.sealForRecipient: unsupported hint.alg '${String(hint.alg)}' (expected 'rsa-oaep-sha256')`)\n }\n const pem = hint.material['publicKeyPem']\n if (typeof pem !== 'string') {\n throw new Error('MemoryRecipientSealer.sealForRecipient: hint.material.publicKeyPem missing or not a string')\n }\n return sealRsaOaepTlv(plaintext, pem)\n }\n\n async seal(plaintext: Uint8Array): Promise<Uint8Array> {\n const hint = await this.publishRecipientHint()\n return this.sealForRecipient(plaintext, hint)\n }\n\n async unseal(bytes: Uint8Array): Promise<Uint8Array> {\n const { wrapped, iv, ct } = parseRsaOaepTlv(bytes)\n const { privateKey } = await this.keypair\n // Local RSA-OAEP-SHA256 unwrap of the CEK — the pluggable step external\n // sealers replace with KMS Decrypt.\n const cekBytes = new Uint8Array(await crypto.subtle.decrypt({ name: 'RSA-OAEP' }, privateKey, wrapped as BufferSource))\n const pt = await aesGcmOpen(cekBytes, iv, ct)\n cekBytes.fill(0)\n return pt\n }\n}\n\n// ─── Persisted envelope ────────────────────────────────────────────────\n\n/** Reserved id for the managed-secret envelope under `_meta`. */\nexport const SEALED_SECRET_RECORD_ID = 'sealed-secret' as const\n\n/** Plaintext payload stored inside the `_meta/sealed-secret` envelope. */\nexport interface SealedSecret {\n readonly _noydb_sealed: 1\n readonly providerId: string\n /** Sealed bytes. Base64-encoded on the wire; decoded on load. */\n readonly sealed: Uint8Array\n}\n\n/**\n * Wire-format envelope persisted at `_meta/sealed-secret` for\n * managed-mode vaults. The provider produces raw sealed bytes via\n * {@link SealingKeyProvider.seal}; this wrapper carries the dispatch\n * metadata hub needs to pick the right provider on the unseal path.\n *\n * Stability boundary: once shipped, the wire format only grows by\n * adding optional fields. See the at-* sealing dimension foundation\n * doc, §11.9.1.\n *\n * v1 shape (this release): `{ v: 1, _noydb_sealed: 1, pid, payload }`.\n *\n * Legacy shape (earlier releases): `{ _noydb_sealed: 1, providerId, sealed }`\n * — accepted on read for backwards compatibility; never produced on\n * write going forward.\n */\nexport interface SealedEnvelope {\n /** Envelope schema version. v1 is the current shape. */\n readonly v: 1\n /** Magic marker for forensics + legacy-shape detection. */\n readonly _noydb_sealed: 1\n /** Matches the producing provider's `.id`. Dispatch key on unseal. */\n readonly pid: string\n /** Sealed bytes from the provider, base64-encoded on the wire. */\n readonly payload: string\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = ''\n for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]!)\n return btoa(binary)\n}\n\nfunction base64ToBytes(b64: string): Uint8Array {\n const binary = atob(b64)\n const out = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i)\n return out\n}\n\n/**\n * Parse a `_meta/sealed-secret` `_data` JSON string into the\n * in-memory {@link SealedSecret} representation. Accepts both:\n *\n * 1. v1 wire format `{ v: 1, _noydb_sealed: 1, pid, payload }` —\n * the current shape.\n * 2. Legacy wire format `{ _noydb_sealed: 1, providerId, sealed }` —\n * read-only; never written\n * going forward.\n *\n * Returns `undefined` for any input that doesn't match either shape,\n * so callers can fall back to \"no managed-mode envelope present.\"\n *\n * @internal — exported only for the migration safety-net test suite.\n */\nexport function parseSealedEnvelope(raw: unknown): SealedSecret | undefined {\n if (typeof raw !== 'object' || raw === null) return undefined\n const r = raw as Record<string, unknown>\n if (r._noydb_sealed !== 1) return undefined\n\n // v1 shape — preferred.\n if (\n r.v === 1\n && typeof r.pid === 'string'\n && typeof r.payload === 'string'\n ) {\n return {\n _noydb_sealed: 1,\n providerId: r.pid,\n sealed: base64ToBytes(r.payload),\n }\n }\n\n // Legacy shape — earlier releases. Accept on read for compat.\n if (\n typeof r.providerId === 'string'\n && typeof r.sealed === 'string'\n ) {\n return {\n _noydb_sealed: 1,\n providerId: r.providerId,\n sealed: base64ToBytes(r.sealed),\n }\n }\n\n return undefined\n}\n\nexport async function saveSealedSecret(\n store: NoydbStore,\n vault: string,\n payload: { readonly providerId: string; readonly sealed: Uint8Array },\n): Promise<void> {\n const persisted: SealedEnvelope = {\n v: 1,\n _noydb_sealed: 1,\n pid: payload.providerId,\n payload: bytesToBase64(payload.sealed),\n }\n const prior = await store.get(vault, '_meta', SEALED_SECRET_RECORD_ID)\n const env: EncryptedEnvelope = {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: (prior?._v ?? 0) + 1,\n _ts: new Date().toISOString(),\n // AES-GCM bypassed — the sealing layer is the security boundary.\n _iv: '',\n _data: JSON.stringify(persisted),\n }\n await store.put(vault, '_meta', SEALED_SECRET_RECORD_ID, env)\n}\n\nexport async function loadSealedSecret(\n store: NoydbStore,\n vault: string,\n): Promise<SealedSecret | undefined> {\n const envelope = await store.get(vault, '_meta', SEALED_SECRET_RECORD_ID)\n if (!envelope) return undefined\n try {\n return parseSealedEnvelope(JSON.parse(envelope._data))\n } catch {\n return undefined\n }\n}\n\n// ─── createNoydb orchestration ─────────────────────────────────────────\n\n/**\n * Resolve the effective plaintext secret string for a managed-mode\n * vault. Two paths:\n *\n * 1. **First open (no envelope persisted):** generate a 256-bit random\n * via `crypto.getRandomValues`, base64-encode for use as a\n * secret string, seal the underlying bytes under the\n * provider, persist `_meta/sealed-secret`, return the\n * base64 string.\n *\n * 2. **Reopen (envelope exists):** read + unseal + decode → return.\n * A different provider whose `seal` output disagrees on the\n * stored bytes throws here, surfaced as a clear error.\n *\n * The returned string is the same shape that `secret:` would take in\n * standard mode — the rest of the keyring path consumes it\n * unchanged.\n *\n * @internal — called from `createNoydb` / `getKeyringInternal`.\n */\nexport async function resolveManagedSecret(\n store: NoydbStore,\n vault: string,\n provider: SealingKeyProvider,\n): Promise<string> {\n const existing = await loadSealedSecret(store, vault)\n if (existing) {\n if (existing.providerId !== provider.id) {\n throw new Error(\n `Managed-mode vault \"${vault}\" was sealed under provider id `\n + `\"${existing.providerId}\" but the current SealingKeyProvider is `\n + `\"${provider.id}\". Pass the same provider that originally enrolled `\n + 'the vault, or treat this as a fresh enrollment and clear '\n + '`_meta/sealed-secret` first.',\n )\n }\n const plaintext = await provider.unseal(existing.sealed)\n return bytesToBase64(plaintext)\n }\n\n // First open: mint a 256-bit random, seal, persist.\n const random = new Uint8Array(32)\n globalThis.crypto.getRandomValues(random)\n const sealed = await provider.seal(random)\n await saveSealedSecret(store, vault, { providerId: provider.id, sealed })\n return bytesToBase64(random)\n}\n"],"mappings":";;;;;AAyGO,IAAM,2BAAN,MAA6D;AAAA,EACzD;AAAA,EACQ;AAAA,EACA;AAAA,EAEjB,YAAY,MAAsB;AAChC,SAAK,KAAK,KAAK;AAKf,UAAM,UAAU,IAAI,YAAY,EAAE,OAAO,KAAK,EAAE;AAChD,QAAI,IAAI;AACR,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAK,IAAI,KAAK,QA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,SAAS,OAAO,SAAS,MAAM;AACvD,WAAO,cAAc,SAAS;AAAA,EAChC;AAGA,QAAM,SAAS,IAAI,WAAW,EAAE;AAChC,aAAW,OAAO,gBAAgB,MAAM;AACxC,QAAM,SAAS,MAAM,SAAS,KAAK,MAAM;AACzC,QAAM,iBAAiB,OAAO,OAAO,EAAE,YAAY,SAAS,IAAI,OAAO,CAAC;AACxE,SAAO,cAAc,MAAM;AAC7B;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writePod
3
- } from "./chunk-MEKAMERX.js";
3
+ } from "./chunk-YCAJDK4O.js";
4
4
 
5
5
  // src/with-audit/portability/export-accessible.ts
6
6
  function resolveAccessibleCollections(keyring, scope, writableOnly = false) {
@@ -18,7 +18,7 @@ async function buildAccessibleBundle(vault, collections, reKey, compression = "a
18
18
  return writePod(vault, {
19
19
  compression,
20
20
  ...collections !== void 0 ? { collections } : {},
21
- ...reKey ? { exportPassphrase: reKey.passphrase } : {}
21
+ ...reKey ? { exportSecret: reKey.secret } : {}
22
22
  });
23
23
  }
24
24
  async function exportAccessibleData(vault, opts = {}) {
@@ -42,4 +42,4 @@ export {
42
42
  buildAccessibleBundle,
43
43
  exportAccessibleData
44
44
  };
45
- //# sourceMappingURL=chunk-25ZDB25Z.js.map
45
+ //# sourceMappingURL=chunk-OMSKGLYA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-audit/portability/export-accessible.ts"],"sourcesContent":["/**\n * `exportMyAccessibleData`: a non-owner user exports the scope they\n * can decrypt as a portable, re-keyed `.noydb` bundle. Non-destructive and\n * **always allowed** (the \"data sovereignty by construction\" property of\n * sealing-at-dimension — the firm cannot deny it) but **audited**.\n *\n * Reuses the existing bundle machinery: the access boundary is the caller's DEK\n * set (operator/client → `keyring.permissions`; owner/admin/viewer → all), so a\n * record outside the caller's keys can never enter the bundle. Re-keying to a\n * new owner reuses `writePod`'s `exportSecret` shorthand.\n */\nimport type { Vault } from '../../kernel/vault.js'\nimport type { UnlockedKeyring } from '../../with-party/team/keyring.js'\nimport { writePod } from '../../with-pod/bundle.js'\n\n/**\n * Resolve the collections a caller may export/withdraw: operator/client are\n * scoped to their granted collections; owner/admin/viewer see everything\n * (`undefined` = no allowlist). A `scope.collections` sub-scope intersects the\n * granted set. `writableOnly` keeps only `rw` grants (for destructive ops).\n */\nexport function resolveAccessibleCollections(\n keyring: UnlockedKeyring,\n scope: { collections?: readonly string[] } | undefined,\n writableOnly = false,\n): string[] | undefined {\n let collections: string[] | undefined\n if (keyring.role === 'operator' || keyring.role === 'client') {\n collections = Object.entries(keyring.permissions)\n .filter(([, mode]) => !writableOnly || mode === 'rw')\n .map(([c]) => c)\n }\n if (scope?.collections) {\n const allow = new Set(scope.collections)\n collections = (collections ?? [...scope.collections]).filter((c) => allow.has(c))\n }\n return collections\n}\n\n/** Produce a (optionally re-keyed, scoped) `.noydb` bundle — no audit. */\nexport async function buildAccessibleBundle(\n vault: Vault,\n collections: string[] | undefined,\n reKey: { secret: string } | undefined,\n compression: 'auto' | 'brotli' | 'gzip' | 'none' = 'auto',\n): Promise<Uint8Array> {\n return writePod(vault, {\n compression,\n ...(collections !== undefined ? { collections } : {}),\n ...(reKey ? { exportSecret: reKey.secret } : {}),\n })\n}\n\nexport interface ExportAccessibleOptions {\n /**\n * Re-key the bundle so it is independently openable by a new owner with this\n * secret (the receiving firm / the client themselves). Omit to inherit\n * the source keyring (personal backup).\n */\n readonly reKey?: { readonly secret: string }\n /** Narrow the export to a subset of the caller's accessible collections. */\n readonly scope?: { readonly collections?: readonly string[] }\n readonly compression?: 'auto' | 'brotli' | 'gzip' | 'none'\n}\n\n/**\n * Produce a re-keyed, access-scoped `.noydb` bundle of the caller's accessible\n * data. Appends a tamper-evident audit entry (`reason: 'user-export:<userId>'`).\n */\nexport async function exportAccessibleData(\n vault: Vault,\n opts: ExportAccessibleOptions = {},\n): Promise<Uint8Array> {\n const { keyring } = vault._introspectState()\n const collections = resolveAccessibleCollections(keyring, opts.scope)\n const bytes = await buildAccessibleBundle(vault, collections, opts.reKey, opts.compression ?? 'auto')\n\n // §11.11 audit — non-destructive, always-allowed export. No-op when the vault\n // has no history/ledger strategy (avoids minting a phantom _ledger DEK).\n await vault._getLedgerOrNull()?.append({\n op: 'lifecycle',\n collection: '',\n id: '',\n version: 0,\n actor: keyring.userId,\n payloadHash: '',\n reason: `user-export:${keyring.userId}`,\n })\n\n return bytes\n}\n"],"mappings":";;;;;AAqBO,SAAS,6BACd,SACA,OACA,eAAe,OACO;AACtB,MAAI;AACJ,MAAI,QAAQ,SAAS,cAAc,QAAQ,SAAS,UAAU;AAC5D,kBAAc,OAAO,QAAQ,QAAQ,WAAW,EAC7C,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,gBAAgB,SAAS,IAAI,EACnD,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAAA,EACnB;AACA,MAAI,OAAO,aAAa;AACtB,UAAM,QAAQ,IAAI,IAAI,MAAM,WAAW;AACvC,mBAAe,eAAe,CAAC,GAAG,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC;AAAA,EAClF;AACA,SAAO;AACT;AAGA,eAAsB,sBACpB,OACA,aACA,OACA,cAAmD,QAC9B;AACrB,SAAO,SAAS,OAAO;AAAA,IACrB;AAAA,IACA,GAAI,gBAAgB,SAAY,EAAE,YAAY,IAAI,CAAC;AAAA,IACnD,GAAI,QAAQ,EAAE,cAAc,MAAM,OAAO,IAAI,CAAC;AAAA,EAChD,CAAC;AACH;AAkBA,eAAsB,qBACpB,OACA,OAAgC,CAAC,GACZ;AACrB,QAAM,EAAE,QAAQ,IAAI,MAAM,iBAAiB;AAC3C,QAAM,cAAc,6BAA6B,SAAS,KAAK,KAAK;AACpE,QAAM,QAAQ,MAAM,sBAAsB,OAAO,aAAa,KAAK,OAAO,KAAK,eAAe,MAAM;AAIpG,QAAM,MAAM,iBAAiB,GAAG,OAAO;AAAA,IACrC,IAAI;AAAA,IACJ,YAAY;AAAA,IACZ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,IACf,aAAa;AAAA,IACb,QAAQ,eAAe,QAAQ,MAAM;AAAA,EACvC,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ReadOnlyFrameError
3
- } from "./chunk-IGM563N5.js";
3
+ } from "./chunk-6SYOHUHM.js";
4
4
 
5
5
  // src/with-fork/shadow/vault-frame.ts
6
6
  var VaultFrame = class {
@@ -71,4 +71,4 @@ export {
71
71
  VaultFrame,
72
72
  CollectionFrame
73
73
  };
74
- //# sourceMappingURL=chunk-2U7Y7BNJ.js.map
74
+ //# sourceMappingURL=chunk-ONB627HU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PortabilityNotEnabledError
3
- } from "./chunk-IGM563N5.js";
3
+ } from "./chunk-6SYOHUHM.js";
4
4
 
5
5
  // src/with-audit/portability/strategy.ts
6
6
  var NO_PORTABILITY = {
@@ -27,4 +27,4 @@ var NO_PORTABILITY = {
27
27
  export {
28
28
  NO_PORTABILITY
29
29
  };
30
- //# sourceMappingURL=chunk-GYB2QK5H.js.map
30
+ //# sourceMappingURL=chunk-OWLZONGX.js.map