@noy-db/hub 0.4.0-pre.5 → 0.4.0-pre.6
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.
- package/dist/{api-22ES33N3.js → api-5QVQX4HG.js} +6 -6
- package/dist/attestation/index.js +14 -14
- package/dist/{backup-YCHAC575.js → backup-USYSNCYM.js} +6 -6
- package/dist/blobs/index.js +8 -5
- package/dist/blobs/index.js.map +1 -1
- package/dist/broker/index.js +6 -6
- package/dist/cargo/index.js +26 -28
- package/dist/{chunk-RWW3I3PO.js → chunk-2BVW754E.js} +2 -2
- package/dist/{chunk-VEGQYPCP.js → chunk-2ZSC454H.js} +3 -3
- package/dist/{chunk-S4YERMGJ.js → chunk-32467U5J.js} +3 -3
- package/dist/{chunk-UVBHM7AK.js → chunk-3GXDB3NQ.js} +4 -4
- package/dist/{chunk-L2CAWCQL.js → chunk-3S2YNMUS.js} +53 -5
- package/dist/chunk-3S2YNMUS.js.map +1 -0
- package/dist/{chunk-HAPY7WFP.js → chunk-3TZUC4WS.js} +9 -9
- package/dist/{chunk-M6QA2KK2.js → chunk-44Y3P5U6.js} +2 -2
- package/dist/{chunk-WQN5SM7P.js → chunk-4B3DL75F.js} +2 -2
- package/dist/{chunk-XUFAFHQM.js → chunk-5ABOFAHN.js} +7 -4
- package/dist/chunk-5ABOFAHN.js.map +1 -0
- package/dist/chunk-5D2ALSM5.js +19 -0
- package/dist/chunk-5D2ALSM5.js.map +1 -0
- package/dist/{chunk-OHV6T5JB.js → chunk-6SSWOUUS.js} +2 -2
- package/dist/{chunk-6RPWILRH.js → chunk-7IQWHYL2.js} +3 -3
- package/dist/chunk-AFHQATY4.js +47 -0
- package/dist/chunk-AFHQATY4.js.map +1 -0
- package/dist/{chunk-I2XEBEEF.js → chunk-AZXEOEQK.js} +3 -3
- package/dist/{chunk-K7BADAOS.js → chunk-C2V7AJO2.js} +3 -3
- package/dist/chunk-CADUYBQD.js +151 -0
- package/dist/chunk-CADUYBQD.js.map +1 -0
- package/dist/{chunk-YTW6ZIPD.js → chunk-DOZFU7OZ.js} +1 -1
- package/dist/chunk-DOZFU7OZ.js.map +1 -0
- package/dist/{chunk-YCAJDK4O.js → chunk-E7FSBI6I.js} +3 -3
- package/dist/chunk-EP5L47XV.js +22 -0
- package/dist/chunk-EP5L47XV.js.map +1 -0
- package/dist/{chunk-YWZEDG7F.js → chunk-EPME33Y4.js} +4 -4
- package/dist/{chunk-EEZCB74X.js → chunk-EWPS35AR.js} +465 -393
- package/dist/chunk-EWPS35AR.js.map +1 -0
- package/dist/{chunk-BY5YBSXA.js → chunk-GQT6J4FJ.js} +14 -1
- package/dist/chunk-GQT6J4FJ.js.map +1 -0
- package/dist/{chunk-YXZNGHID.js → chunk-H5GMROCB.js} +2 -2
- package/dist/{chunk-QMMOMBH6.js → chunk-HA7P3BTB.js} +24 -175
- package/dist/chunk-HA7P3BTB.js.map +1 -0
- package/dist/{chunk-FTCGEUOY.js → chunk-HDF5R2K6.js} +4 -4
- package/dist/{chunk-R2N37AA6.js → chunk-HVPW6PCX.js} +2 -2
- package/dist/{chunk-YXIVUWDU.js → chunk-HXVRRJBD.js} +3 -3
- package/dist/{chunk-5ATANZSW.js → chunk-ICYC5YNI.js} +4 -4
- package/dist/{chunk-7ICV4ASA.js → chunk-IUATR5UE.js} +25 -3
- package/dist/chunk-IUATR5UE.js.map +1 -0
- package/dist/{chunk-QZJEYZ4I.js → chunk-JGOKAZNB.js} +3 -3
- package/dist/{chunk-JN3SGXJE.js → chunk-JOCMXSR2.js} +1 -1
- package/dist/{chunk-JN3SGXJE.js.map → chunk-JOCMXSR2.js.map} +1 -1
- package/dist/{chunk-7BIJS6II.js → chunk-JTIPVW4J.js} +3 -3
- package/dist/{chunk-SC4JLMZI.js → chunk-KCZAFDP5.js} +2 -2
- package/dist/{chunk-GP54LU5N.js → chunk-LG2GUYRX.js} +7 -7
- package/dist/{chunk-J5TEU77Q.js → chunk-LN3MQFUE.js} +54 -2
- package/dist/chunk-LN3MQFUE.js.map +1 -0
- package/dist/{chunk-FIP7KI2P.js → chunk-M4GO4ZJK.js} +205 -15
- package/dist/chunk-M4GO4ZJK.js.map +1 -0
- package/dist/{chunk-QMZ5A6FQ.js → chunk-M7W2KYTL.js} +2 -2
- package/dist/{chunk-K4BWPNJO.js → chunk-MLCTPWSO.js} +3 -3
- package/dist/{chunk-GEEJPID6.js → chunk-MMVQ3SUO.js} +3 -3
- package/dist/{chunk-HQKRZIX6.js → chunk-MPPWL64H.js} +24 -41
- package/dist/chunk-MPPWL64H.js.map +1 -0
- package/dist/{chunk-YZN6NRTR.js → chunk-MQBFT2OT.js} +11 -9
- package/dist/chunk-MQBFT2OT.js.map +1 -0
- package/dist/{chunk-TNJVDG2B.js → chunk-NA374QG7.js} +2 -2
- package/dist/chunk-NIKO2BBZ.js +23 -0
- package/dist/chunk-NIKO2BBZ.js.map +1 -0
- package/dist/chunk-PEOZ34EM.js +13 -0
- package/dist/chunk-PEOZ34EM.js.map +1 -0
- package/dist/chunk-PVEWA2DU.js +23 -0
- package/dist/chunk-PVEWA2DU.js.map +1 -0
- package/dist/{chunk-V5JUAW4M.js → chunk-QVIZDLAR.js} +5 -5
- package/dist/{chunk-DYZ5CCVM.js → chunk-RM5EXCFF.js} +1 -1
- package/dist/{chunk-DYZ5CCVM.js.map → chunk-RM5EXCFF.js.map} +1 -1
- package/dist/chunk-SMY5X46Z.js +14 -0
- package/dist/chunk-SMY5X46Z.js.map +1 -0
- package/dist/{chunk-2CRZOVDI.js → chunk-UNREYBZO.js} +2 -2
- package/dist/{chunk-KJTIAECI.js → chunk-V2R2VWER.js} +168 -9
- package/dist/chunk-V2R2VWER.js.map +1 -0
- package/dist/{chunk-CKUYQO2P.js → chunk-VDTWFN2P.js} +7 -5
- package/dist/chunk-VDTWFN2P.js.map +1 -0
- package/dist/chunk-VKQCVU2Z.js +21 -0
- package/dist/chunk-VKQCVU2Z.js.map +1 -0
- package/dist/{chunk-UTEATWHO.js → chunk-VNJMLOQS.js} +4 -4
- package/dist/{chunk-JAMDDLIM.js → chunk-WCJJQV2D.js} +2 -2
- package/dist/{chunk-OMSKGLYA.js → chunk-WWBC4KLB.js} +2 -2
- package/dist/{chunk-JIHH26WQ.js → chunk-XG7OZDOS.js} +3 -3
- package/dist/{chunk-QBOQI6PG.js → chunk-XONZGK6J.js} +2 -2
- package/dist/{chunk-YQQPNXNO.js → chunk-XSOGLHGY.js} +2 -2
- package/dist/{chunk-3OWYOECI.js → chunk-XY6MNSAF.js} +4 -4
- package/dist/chunk-XZHEOSQ2.js +16 -0
- package/dist/chunk-XZHEOSQ2.js.map +1 -0
- package/dist/{chunk-X3MWEFPT.js → chunk-YGMREQAK.js} +3 -3
- package/dist/chunk-YMUFFJCO.js +23 -0
- package/dist/chunk-YMUFFJCO.js.map +1 -0
- package/dist/{chunk-3LJYHE7S.js → chunk-ZDFU34XY.js} +9 -6
- package/dist/{chunk-3LJYHE7S.js.map → chunk-ZDFU34XY.js.map} +1 -1
- package/dist/{chunk-ILM6X6CP.js → chunk-ZF572E2M.js} +2 -2
- package/dist/{chunk-TNATF3HB.js → chunk-ZGEFBDPR.js} +2 -2
- package/dist/chunk-ZGEFBDPR.js.map +1 -0
- package/dist/{chunk-OGVE4IJW.js → chunk-ZHMUFYZF.js} +4 -4
- package/dist/{chunk-YFFEF6HR.js → chunk-ZHZ4PET5.js} +2 -2
- package/dist/{chunk-YZNKFYDC.js → chunk-ZM72UO3Y.js} +2 -2
- package/dist/classified/index.js +3 -3
- package/dist/{classified-marker-52P3D72W.js → classified-marker-SVDRXLD3.js} +3 -3
- package/dist/{collection-facade-XKCFHSLR.js → collection-facade-S5PPKZD5.js} +9 -9
- package/dist/consent/index.js +8 -4
- package/dist/consent/index.js.map +1 -1
- package/dist/{cover-5BSNJREH.js → cover-ADBCTIKN.js} +3 -3
- package/dist/crdt/index.js +4 -0
- package/dist/crdt/index.js.map +1 -1
- package/dist/{dead-filter-JXVCKS6W.js → dead-filter-HKDMTMVY.js} +2 -2
- package/dist/{delegation-WWZPEDK2.js → delegation-EV7LKJPH.js} +5 -5
- package/dist/derivations/index.js +3 -3
- package/dist/{derive-CWWFEQ4N.js → derive-5LDJW76F.js} +4 -4
- package/dist/{dispatch-PKQQFDBT.js → dispatch-SPMYNXNW.js} +12 -11
- package/dist/{dispatch-PKQQFDBT.js.map → dispatch-SPMYNXNW.js.map} +1 -1
- package/dist/{dispatch-SMXUO7W5.js → dispatch-V5MSMQYX.js} +5 -5
- package/dist/{enclave-I5H3GINP.js → enclave-ZA7C3H2L.js} +4 -4
- package/dist/executor-SVHAJZ4A.js +28 -0
- package/dist/{export-accessible-FBL6TDSK.js → export-accessible-S35YKIBL.js} +7 -7
- package/dist/{extract-partition-ZYIRYMTI.js → extract-partition-UVHAM5WZ.js} +10 -10
- package/dist/{fanout-sidecar-WWXVHHUH.js → fanout-sidecar-HRMHC34B.js} +4 -4
- package/dist/forget/index.js +4 -4
- package/dist/history/index.js +10 -6
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +10 -8
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +4 -7
- package/dist/index.js +94 -151
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +3 -1
- package/dist/indexing/index.js.map +1 -1
- package/dist/{issue-F76PAGIR.js → issue-5X3SMCF4.js} +6 -6
- package/dist/kernel/lazy.d.ts +30 -0
- package/dist/kernel/noydb.d.ts +21 -10
- package/dist/kernel/query/builder.d.ts +10 -10
- package/dist/kernel/query/index.d.ts +0 -6
- package/dist/kernel/query/scan-builder.d.ts +4 -4
- package/dist/kernel/types.d.ts +5 -5
- package/dist/{ledger-M2BKCNVS.js → ledger-K6JBFL3Z.js} +6 -6
- package/dist/liberate-NHTCKBU4.js +24 -0
- package/dist/{link-set-ZU4E5J5S.js → link-set-XVZY2ODC.js} +5 -5
- package/dist/materialized-views/index.js +15 -12
- package/dist/noydb-TI3RFU6M.js +78 -0
- package/dist/periods/index.js +9 -7
- package/dist/pod/index.js +5 -6
- package/dist/{policy-IY2YEA3A.js → policy-QWGJB7P7.js} +4 -4
- package/dist/port/with/collection-registries.d.ts +62 -0
- package/dist/port/with/strategies.d.ts +2 -2
- package/dist/port/with/team-strategy.d.ts +2 -1
- package/dist/portability/index.js +6 -6
- package/dist/{post-register-XIAHB6KF.js → post-register-5VHHVFJY.js} +4 -4
- package/dist/query/index.js +4 -44
- package/dist/{aggregate → reduce}/index.js +22 -15
- package/dist/reduce/index.js.map +1 -0
- package/dist/{register-HB4TQZSV.js → register-CEX7R7NE.js} +6 -6
- package/dist/{registry-6BMBFEXT.js → registry-DIKMRXUC.js} +5 -5
- package/dist/{registry-JOFO7RAH.js → registry-EWIB5NTI.js} +4 -4
- package/dist/{request-withdrawal-UN3TRHWI.js → request-withdrawal-AAG57QO4.js} +9 -9
- package/dist/{reveal-VWXRV2XU.js → reveal-7OOT5XPD.js} +3 -3
- package/dist/{revoke-OLO2OVR7.js → revoke-U5LCIJMF.js} +6 -6
- package/dist/sealed-record/index.js +6 -6
- package/dist/{seed-CDBFOTIK.js → seed-GVOI6QP6.js} +6 -6
- package/dist/session/index.js +7 -3
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.js +4 -0
- package/dist/shadow/index.js.map +1 -1
- package/dist/{signer-MGGKPYAN.js → signer-NAA2OX7H.js} +5 -5
- package/dist/snapshots/index.js +9 -5
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-NBROTA66.js → stale-BJO2WIN7.js} +6 -5
- package/dist/{storage-3R37QZLA.js → storage-FL7XXZTN.js} +5 -5
- package/dist/{store-coordination-provider-P3IU5JHD.js → store-coordination-provider-DX5HECK3.js} +3 -3
- package/dist/sync/index.js +8 -4
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.js +15 -17
- package/dist/tiers/index.js +4 -4
- package/dist/tx/index.js +5 -1
- package/dist/tx/index.js.map +1 -1
- package/dist/via/blob/index.d.ts +2 -0
- package/dist/via/i18n/core.d.ts +1 -1
- package/dist/via/i18n/index.d.ts +2 -0
- package/dist/via/money/money-reducer.d.ts +2 -2
- package/dist/{walk-E3OVLBFR.js → walk-JXMWKKQW.js} +5 -5
- package/dist/with-audit/consent/index.d.ts +2 -0
- package/dist/with-audit/periods/index.d.ts +2 -0
- package/dist/with-cargo/floor.d.ts +3 -3
- package/dist/with-commit/crdt/index.d.ts +2 -0
- package/dist/with-commit/history/index.d.ts +2 -0
- package/dist/with-fork/shadow/index.d.ts +2 -0
- package/dist/with-fork/snapshots/index.d.ts +2 -0
- package/dist/with-formula/materialized-views/types.d.ts +7 -7
- package/dist/with-lookup/indexing/index.d.ts +2 -0
- package/dist/with-lookup/{aggregate → reduce}/active.d.ts +8 -8
- package/dist/with-lookup/{aggregate → reduce}/groupby.d.ts +21 -21
- package/dist/with-lookup/reduce/index.d.ts +34 -0
- package/dist/with-lookup/{aggregate → reduce}/reducers.d.ts +10 -10
- package/dist/with-lookup/{aggregate/aggregation.d.ts → reduce/reduction.d.ts} +21 -21
- package/dist/with-lookup/{aggregate → reduce}/strategy.d.ts +15 -15
- package/dist/with-party/session/index.d.ts +2 -0
- package/dist/with-party/sync/index.d.ts +2 -0
- package/dist/with-party/team/keyring.d.ts +20 -1
- package/dist/with-party/team/noydb-facade.d.ts +2 -1
- package/dist/{withdraw-accessible-Q2EMATCU.js → withdraw-accessible-GO6KQJVM.js} +8 -8
- package/package.json +6 -34
- package/dist/aggregate/index.js.map +0 -1
- package/dist/as/index.js +0 -30
- package/dist/at/index.js +0 -1
- package/dist/by/index.js +0 -11
- package/dist/chunk-2YELV6TV.js +0 -1
- package/dist/chunk-7ICV4ASA.js.map +0 -1
- package/dist/chunk-AFAPBZAA.js +0 -54
- package/dist/chunk-AFAPBZAA.js.map +0 -1
- package/dist/chunk-BY5YBSXA.js.map +0 -1
- package/dist/chunk-CJVEAVYH.js +0 -205
- package/dist/chunk-CJVEAVYH.js.map +0 -1
- package/dist/chunk-CKUYQO2P.js.map +0 -1
- package/dist/chunk-EEZCB74X.js.map +0 -1
- package/dist/chunk-FIP7KI2P.js.map +0 -1
- package/dist/chunk-HQKRZIX6.js.map +0 -1
- package/dist/chunk-IGLU4ME7.js +0 -255
- package/dist/chunk-IGLU4ME7.js.map +0 -1
- package/dist/chunk-J5TEU77Q.js.map +0 -1
- package/dist/chunk-KJTIAECI.js.map +0 -1
- package/dist/chunk-L2CAWCQL.js.map +0 -1
- package/dist/chunk-LB7FD65R.js +0 -163
- package/dist/chunk-LB7FD65R.js.map +0 -1
- package/dist/chunk-QMMOMBH6.js.map +0 -1
- package/dist/chunk-TNATF3HB.js.map +0 -1
- package/dist/chunk-XUFAFHQM.js.map +0 -1
- package/dist/chunk-YTW6ZIPD.js.map +0 -1
- package/dist/chunk-YZN6NRTR.js.map +0 -1
- package/dist/executor-SHYLIBOM.js +0 -26
- package/dist/in/index.js +0 -1
- package/dist/liberate-ZP7UB57K.js +0 -24
- package/dist/noydb-BNDGEK5X.js +0 -71
- package/dist/on/index.js +0 -17
- package/dist/port/as/index.d.ts +0 -26
- package/dist/port/at/index.d.ts +0 -18
- package/dist/port/in/index.d.ts +0 -21
- package/dist/port/on/index.d.ts +0 -27
- package/dist/port/ui/index.d.ts +0 -21
- package/dist/port/with/index.d.ts +0 -18
- package/dist/request-withdrawal-UN3TRHWI.js.map +0 -1
- package/dist/revoke-OLO2OVR7.js.map +0 -1
- package/dist/signer-MGGKPYAN.js.map +0 -1
- package/dist/stale-NBROTA66.js.map +0 -1
- package/dist/storage-3R37QZLA.js.map +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/with/index.js +0 -31
- package/dist/with/index.js.map +0 -1
- package/dist/with-lookup/aggregate/index.d.ts +0 -23
- package/dist/withdraw-accessible-Q2EMATCU.js.map +0 -1
- /package/dist/{api-22ES33N3.js.map → api-5QVQX4HG.js.map} +0 -0
- /package/dist/{backup-YCHAC575.js.map → backup-USYSNCYM.js.map} +0 -0
- /package/dist/{chunk-RWW3I3PO.js.map → chunk-2BVW754E.js.map} +0 -0
- /package/dist/{chunk-VEGQYPCP.js.map → chunk-2ZSC454H.js.map} +0 -0
- /package/dist/{chunk-S4YERMGJ.js.map → chunk-32467U5J.js.map} +0 -0
- /package/dist/{chunk-UVBHM7AK.js.map → chunk-3GXDB3NQ.js.map} +0 -0
- /package/dist/{chunk-HAPY7WFP.js.map → chunk-3TZUC4WS.js.map} +0 -0
- /package/dist/{chunk-M6QA2KK2.js.map → chunk-44Y3P5U6.js.map} +0 -0
- /package/dist/{chunk-WQN5SM7P.js.map → chunk-4B3DL75F.js.map} +0 -0
- /package/dist/{chunk-OHV6T5JB.js.map → chunk-6SSWOUUS.js.map} +0 -0
- /package/dist/{chunk-6RPWILRH.js.map → chunk-7IQWHYL2.js.map} +0 -0
- /package/dist/{chunk-I2XEBEEF.js.map → chunk-AZXEOEQK.js.map} +0 -0
- /package/dist/{chunk-K7BADAOS.js.map → chunk-C2V7AJO2.js.map} +0 -0
- /package/dist/{chunk-YCAJDK4O.js.map → chunk-E7FSBI6I.js.map} +0 -0
- /package/dist/{chunk-YWZEDG7F.js.map → chunk-EPME33Y4.js.map} +0 -0
- /package/dist/{chunk-YXZNGHID.js.map → chunk-H5GMROCB.js.map} +0 -0
- /package/dist/{chunk-FTCGEUOY.js.map → chunk-HDF5R2K6.js.map} +0 -0
- /package/dist/{chunk-R2N37AA6.js.map → chunk-HVPW6PCX.js.map} +0 -0
- /package/dist/{chunk-YXIVUWDU.js.map → chunk-HXVRRJBD.js.map} +0 -0
- /package/dist/{chunk-5ATANZSW.js.map → chunk-ICYC5YNI.js.map} +0 -0
- /package/dist/{chunk-QZJEYZ4I.js.map → chunk-JGOKAZNB.js.map} +0 -0
- /package/dist/{chunk-7BIJS6II.js.map → chunk-JTIPVW4J.js.map} +0 -0
- /package/dist/{chunk-SC4JLMZI.js.map → chunk-KCZAFDP5.js.map} +0 -0
- /package/dist/{chunk-GP54LU5N.js.map → chunk-LG2GUYRX.js.map} +0 -0
- /package/dist/{chunk-QMZ5A6FQ.js.map → chunk-M7W2KYTL.js.map} +0 -0
- /package/dist/{chunk-K4BWPNJO.js.map → chunk-MLCTPWSO.js.map} +0 -0
- /package/dist/{chunk-GEEJPID6.js.map → chunk-MMVQ3SUO.js.map} +0 -0
- /package/dist/{chunk-TNJVDG2B.js.map → chunk-NA374QG7.js.map} +0 -0
- /package/dist/{chunk-V5JUAW4M.js.map → chunk-QVIZDLAR.js.map} +0 -0
- /package/dist/{chunk-2CRZOVDI.js.map → chunk-UNREYBZO.js.map} +0 -0
- /package/dist/{chunk-UTEATWHO.js.map → chunk-VNJMLOQS.js.map} +0 -0
- /package/dist/{chunk-JAMDDLIM.js.map → chunk-WCJJQV2D.js.map} +0 -0
- /package/dist/{chunk-OMSKGLYA.js.map → chunk-WWBC4KLB.js.map} +0 -0
- /package/dist/{chunk-JIHH26WQ.js.map → chunk-XG7OZDOS.js.map} +0 -0
- /package/dist/{chunk-QBOQI6PG.js.map → chunk-XONZGK6J.js.map} +0 -0
- /package/dist/{chunk-YQQPNXNO.js.map → chunk-XSOGLHGY.js.map} +0 -0
- /package/dist/{chunk-3OWYOECI.js.map → chunk-XY6MNSAF.js.map} +0 -0
- /package/dist/{chunk-X3MWEFPT.js.map → chunk-YGMREQAK.js.map} +0 -0
- /package/dist/{chunk-ILM6X6CP.js.map → chunk-ZF572E2M.js.map} +0 -0
- /package/dist/{chunk-OGVE4IJW.js.map → chunk-ZHMUFYZF.js.map} +0 -0
- /package/dist/{chunk-YFFEF6HR.js.map → chunk-ZHZ4PET5.js.map} +0 -0
- /package/dist/{chunk-YZNKFYDC.js.map → chunk-ZM72UO3Y.js.map} +0 -0
- /package/dist/{classified-marker-52P3D72W.js.map → classified-marker-SVDRXLD3.js.map} +0 -0
- /package/dist/{as/index.js.map → collection-facade-S5PPKZD5.js.map} +0 -0
- /package/dist/{at/index.js.map → cover-ADBCTIKN.js.map} +0 -0
- /package/dist/{dead-filter-JXVCKS6W.js.map → dead-filter-HKDMTMVY.js.map} +0 -0
- /package/dist/{by/index.js.map → delegation-EV7LKJPH.js.map} +0 -0
- /package/dist/{chunk-2YELV6TV.js.map → derive-5LDJW76F.js.map} +0 -0
- /package/dist/{dispatch-SMXUO7W5.js.map → dispatch-V5MSMQYX.js.map} +0 -0
- /package/dist/{collection-facade-XKCFHSLR.js.map → enclave-ZA7C3H2L.js.map} +0 -0
- /package/dist/{cover-5BSNJREH.js.map → executor-SVHAJZ4A.js.map} +0 -0
- /package/dist/{delegation-WWZPEDK2.js.map → export-accessible-S35YKIBL.js.map} +0 -0
- /package/dist/{derive-CWWFEQ4N.js.map → extract-partition-UVHAM5WZ.js.map} +0 -0
- /package/dist/{fanout-sidecar-WWXVHHUH.js.map → fanout-sidecar-HRMHC34B.js.map} +0 -0
- /package/dist/{enclave-I5H3GINP.js.map → issue-5X3SMCF4.js.map} +0 -0
- /package/dist/{executor-SHYLIBOM.js.map → ledger-K6JBFL3Z.js.map} +0 -0
- /package/dist/{export-accessible-FBL6TDSK.js.map → liberate-NHTCKBU4.js.map} +0 -0
- /package/dist/{extract-partition-ZYIRYMTI.js.map → link-set-XVZY2ODC.js.map} +0 -0
- /package/dist/{in/index.js.map → noydb-TI3RFU6M.js.map} +0 -0
- /package/dist/{issue-F76PAGIR.js.map → policy-QWGJB7P7.js.map} +0 -0
- /package/dist/{post-register-XIAHB6KF.js.map → post-register-5VHHVFJY.js.map} +0 -0
- /package/dist/{ledger-M2BKCNVS.js.map → register-CEX7R7NE.js.map} +0 -0
- /package/dist/{liberate-ZP7UB57K.js.map → registry-DIKMRXUC.js.map} +0 -0
- /package/dist/{link-set-ZU4E5J5S.js.map → registry-EWIB5NTI.js.map} +0 -0
- /package/dist/{noydb-BNDGEK5X.js.map → request-withdrawal-AAG57QO4.js.map} +0 -0
- /package/dist/{reveal-VWXRV2XU.js.map → reveal-7OOT5XPD.js.map} +0 -0
- /package/dist/{on/index.js.map → revoke-U5LCIJMF.js.map} +0 -0
- /package/dist/{seed-CDBFOTIK.js.map → seed-GVOI6QP6.js.map} +0 -0
- /package/dist/{policy-IY2YEA3A.js.map → signer-NAA2OX7H.js.map} +0 -0
- /package/dist/{register-HB4TQZSV.js.map → stale-BJO2WIN7.js.map} +0 -0
- /package/dist/{registry-6BMBFEXT.js.map → storage-FL7XXZTN.js.map} +0 -0
- /package/dist/{store-coordination-provider-P3IU5JHD.js.map → store-coordination-provider-DX5HECK3.js.map} +0 -0
- /package/dist/{walk-E3OVLBFR.js.map → walk-JXMWKKQW.js.map} +0 -0
- /package/dist/with-lookup/{aggregate → reduce}/canonical-key.d.ts +0 -0
- /package/dist/{registry-JOFO7RAH.js.map → withdraw-accessible-GO6KQJVM.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SCHEMAS_COLLECTION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-32467U5J.js";
|
|
4
4
|
import {
|
|
5
5
|
BLOB_CHUNKS_COLLECTION,
|
|
6
6
|
BLOB_COLLECTION,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
BLOB_INTENT_COLLECTION,
|
|
9
9
|
BLOB_SLOTS_PREFIX,
|
|
10
10
|
BLOB_VERSIONS_PREFIX
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2ZSC454H.js";
|
|
12
12
|
import {
|
|
13
13
|
assembleBundleContainer,
|
|
14
14
|
buildExtractedPartitionWrapper
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-E7FSBI6I.js";
|
|
16
16
|
import {
|
|
17
17
|
generateULID
|
|
18
18
|
} from "./chunk-ZJADGNYF.js";
|
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
canonicalJson,
|
|
24
24
|
envelopePayloadHash,
|
|
25
25
|
hashEntry
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2BVW754E.js";
|
|
27
27
|
import {
|
|
28
28
|
openEnvelopeJson,
|
|
29
29
|
writeEnvelopeBody
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-MMVQ3SUO.js";
|
|
31
31
|
import {
|
|
32
32
|
bufferToBase64,
|
|
33
33
|
decrypt,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
import {
|
|
42
42
|
NOYDB_BACKUP_VERSION,
|
|
43
43
|
NOYDB_FORMAT_VERSION
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
45
45
|
import {
|
|
46
46
|
PartitionExtractionError
|
|
47
47
|
} from "./chunk-6SYOHUHM.js";
|
|
@@ -492,4 +492,4 @@ export {
|
|
|
492
492
|
extractPartition,
|
|
493
493
|
extractPartitionCore
|
|
494
494
|
};
|
|
495
|
-
//# sourceMappingURL=chunk-
|
|
495
|
+
//# sourceMappingURL=chunk-LG2GUYRX.js.map
|
|
@@ -1,13 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installViaBinder
|
|
3
|
+
} from "./chunk-ZUDAK436.js";
|
|
1
4
|
import {
|
|
2
5
|
encrypt
|
|
3
6
|
} from "./chunk-7U6AB7DZ.js";
|
|
4
7
|
import {
|
|
5
8
|
NOYDB_FORMAT_VERSION
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
7
10
|
import {
|
|
8
11
|
ValidationError
|
|
9
12
|
} from "./chunk-6SYOHUHM.js";
|
|
10
13
|
|
|
14
|
+
// src/via/blob/binding.ts
|
|
15
|
+
async function eraseBlobs(ctx, cfg) {
|
|
16
|
+
if (cfg.purgeBlobsForRecord) return cfg.purgeBlobsForRecord(ctx.id);
|
|
17
|
+
return { shredded: 0, residue: [] };
|
|
18
|
+
}
|
|
19
|
+
function buildBlobDescribeFragment(fields) {
|
|
20
|
+
return {
|
|
21
|
+
blobFields: Object.fromEntries(
|
|
22
|
+
Object.entries(fields).map(([field, p]) => [field, {
|
|
23
|
+
...p.retainDays !== void 0 ? { retainDays: p.retainDays } : {},
|
|
24
|
+
...p.evictWhen !== void 0 ? { evictWhen: true } : {},
|
|
25
|
+
...p.legalHold !== void 0 ? { legalHold: true } : {},
|
|
26
|
+
...p.retainUntil !== void 0 ? { retainUntil: true } : {},
|
|
27
|
+
...p.external === true ? { external: true } : {},
|
|
28
|
+
...p.public === true ? { public: true } : {},
|
|
29
|
+
...p.backlink !== void 0 ? { backlink: p.backlink } : {}
|
|
30
|
+
}])
|
|
31
|
+
)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function blobBinding(cfg) {
|
|
35
|
+
return {
|
|
36
|
+
brand: "blob",
|
|
37
|
+
// encryptedAtRest: 'envelope' — blob chunks are AEAD-encrypted envelopes
|
|
38
|
+
// in `_blob_chunks` (service-side), not sealed record fields; queryable:
|
|
39
|
+
// 'none' — nothing indexes blob content; exportable — vault.exportBlobs()
|
|
40
|
+
// is a first-class door; forgettable — shredAllForRecord participates in
|
|
41
|
+
// vault.forget().
|
|
42
|
+
posture: { encryptedAtRest: "envelope", queryable: "none", exportable: true, forgettable: true },
|
|
43
|
+
covers: (field) => field in cfg.fields,
|
|
44
|
+
erase: (ctx) => eraseBlobs(ctx, cfg),
|
|
45
|
+
describeFragment: () => buildBlobDescribeFragment(cfg.fields)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function linkBlobVia() {
|
|
49
|
+
installViaBinder("blob", (c) => blobBinding(c));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/port/with/blob-strategy.ts
|
|
53
|
+
linkBlobVia();
|
|
54
|
+
var NO_BLOBS = {
|
|
55
|
+
openSlot() {
|
|
56
|
+
throw new Error(
|
|
57
|
+
'Blob storage is not enabled on this Noydb instance. Import `{ withBlobs }` from "@noy-db/hub/blobs" and pass `withBlobs()` to `createNoydb({ blobStrategy: withBlobs() })`.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
11
62
|
// src/with-shape/blobs/export-blobs.ts
|
|
12
63
|
var ExportBlobsAbortedError = class extends Error {
|
|
13
64
|
constructor(reason) {
|
|
@@ -339,10 +390,11 @@ async function writeAuditEntry(ctx, entry) {
|
|
|
339
390
|
}
|
|
340
391
|
|
|
341
392
|
export {
|
|
393
|
+
NO_BLOBS,
|
|
342
394
|
ExportBlobsAbortedError,
|
|
343
395
|
EXPORT_AUDIT_COLLECTION,
|
|
344
396
|
createExportBlobsHandle,
|
|
345
397
|
BLOB_EVICTION_AUDIT_COLLECTION,
|
|
346
398
|
runCompaction
|
|
347
399
|
};
|
|
348
|
-
//# sourceMappingURL=chunk-
|
|
400
|
+
//# sourceMappingURL=chunk-LN3MQFUE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/via/blob/binding.ts","../src/port/with/blob-strategy.ts","../src/with-shape/blobs/export-blobs.ts","../src/with-shape/blobs/blob-compaction.ts"],"sourcesContent":["/**\n * The blob `ViaBinding` (#629 Task 7) — wires the `blobFields` declaration\n * into the kernel's generic Via port as a deliberately THIN binding:\n * declaration + posture + `describeFragment` + `erase` glue, and nothing\n * else. Blob content is fully out-of-band (`collection.blob(id)` →\n * `BlobSet` writing `_blob_*` side-collections; it never touches\n * `_putInternal` or the record codec), so this binding declares **no\n * write/read pipeline hooks** — in particular no `encodeAtRest`/\n * `decodeAtRest`: a blobFields collection must not flip the pipeline's\n * `hasAtRestHooks`, or the codec would abandon its inline seal path for a\n * feature that never seals record fields. The routing/compaction/TTL/\n * legal-hold/exportBlobs machinery stays service-side in\n * `with-shape/blobs/` (the i18n-dictionary precedent — that machinery\n * does real chunk AEAD + key-lifecycle work `via-enclave-isolation`\n * forbids under `via/*`).\n *\n * Like classified (see `port/with/classified-strategy.ts`), the link is\n * EAGER — `port/with/blob-strategy.ts` calls {@link linkBlobVia} at module\n * load. `blobFields` policies are plain object literals (there is no\n * `blob.*()` declaration factory to hang a lazy link on), so the binder\n * must be installed before `compileViaBindings` ever sees one.\n *\n * There is no `declare`-time validation: `blobFields` has never had a\n * construction-time refusal matrix (policies are consulted lazily by\n * `vault.compact()` and `BlobSet.put`), and inventing one here would\n * break the behavior lock.\n *\n * `covers` (#629 Task 8) is a passive coverage predicate, not a pipeline\n * hook — it lets `ViaPipeline.postureFor` recognize a `blobFields` slot so\n * `.where()`/`.orderBy()`/`.aggregate()` can refuse it (posture\n * `queryable: 'none'`); it does not participate in clause building or\n * evaluation.\n */\nimport type { ViaBinding, ViaEraseCtx, ViaEraseReport } from '../../kernel/via/index.js'\nimport { installViaBinder } from '../../kernel/via/index.js'\nimport type { BlobFieldsConfig } from '../../with-shape/blobs/blob-compaction.js'\n\n/**\n * Config a blob collection's `blobFields` declaration resolves to — the\n * binding's construction input. `purgeBlobsForRecord` is an OPTIONAL\n * vault/service-provided closure for the `erase` hook, mapping\n * `collection.blob(id).shredAllForRecord()`'s `{shredded, retainedShared,\n * residue}: string[]` accounting onto `ViaEraseReport` — `shredded`/\n * `retainedShared` become counts, each residue eTag becomes a tagged\n * `{kind: 'blob-residue', eTag}` entry.\n *\n * DELIBERATELY left unwired by `compileViaBindings` (#629 Task 10, resolved\n * within parity-first — see task-10-report.md \"blob purge\" section):\n * `per-blob-cek.test.ts`/`forget.test.ts` prove blob-shred-on-forget is\n * gated SOLELY on the vault's `blobStrategy` being configured, never on a\n * given collection's OWN `blobFields` declaration (`.blob(id)` is callable,\n * and IS exercised by those tests, on collections with no `blobFields` at\n * all). Routing it exclusively through this binding would silently stop\n * blob crypto-shredding for every such collection; `vault.forget()` keeps\n * calling `collection.blob(id).shredAllForRecord()` directly for that\n * reason. The hook stays real/tested (see `blob-binding.test.ts`) for a\n * future caller that wants it.\n */\nexport interface BlobViaConfig {\n readonly fields: BlobFieldsConfig\n readonly collectionName: string\n /** Purge one record's blob slots (crypto-shred participation). Returns the erase report for `forget()`'s summary. */\n readonly purgeBlobsForRecord?: (id: string) => Promise<ViaEraseReport>\n}\n\n/**\n * `forget()`'s per-ref blob-purge participation: delegate to the wired\n * closure, or report a clean zero-shredded, zero-residue no-op — the\n * default in production too (#629 Task 10 deliberately leaves this unwired;\n * see `BlobViaConfig`'s doc comment).\n */\nasync function eraseBlobs(ctx: ViaEraseCtx, cfg: BlobViaConfig): Promise<ViaEraseReport> {\n if (cfg.purgeBlobsForRecord) return cfg.purgeBlobsForRecord(ctx.id)\n return { shredded: 0, residue: [] }\n}\n\n/**\n * One field's blob knobs as they appear on `describeFragment()`'s payload\n * (#657 — the second real `ViaBinding.describeFragment` consumer after\n * `lookup`'s; see `with-shape/introspection/describe.ts`'s `buildDescription`).\n * Declarative scalars (`retainDays`/`external`/`public`/`backlink`) verbatim;\n * predicate knobs (`evictWhen`/`legalHold`/`retainUntil` — functions over the\n * decrypted record) as presence flags, since a predicate has no serializable\n * form — mirrors `buildBlobDescribeFragment`'s per-field shape below.\n */\nexport interface BlobDescribeFragmentEntry {\n readonly retainDays?: number\n readonly evictWhen?: true\n readonly legalHold?: true\n readonly retainUntil?: true\n readonly external?: true\n readonly public?: true\n readonly backlink?: string\n}\n\n/** The `'blob'` binding's `describeFragment()` payload shape. */\nexport interface BlobDescribeFragment {\n readonly blobFields: Record<string, BlobDescribeFragmentEntry>\n}\n\n/**\n * `{ blobFields: { <field>: <knobs> } }` — declarative scalars\n * (`retainDays`/`external`/`public`/`backlink`) verbatim; predicate knobs\n * (`evictWhen`/`legalHold`/`retainUntil` — functions over the decrypted\n * record) as presence flags, since a predicate has no serializable form.\n */\nfunction buildBlobDescribeFragment(fields: BlobFieldsConfig): Record<string, unknown> {\n return {\n blobFields: Object.fromEntries(\n Object.entries(fields).map(([field, p]) => [field, {\n ...(p.retainDays !== undefined ? { retainDays: p.retainDays } : {}),\n ...(p.evictWhen !== undefined ? { evictWhen: true } : {}),\n ...(p.legalHold !== undefined ? { legalHold: true } : {}),\n ...(p.retainUntil !== undefined ? { retainUntil: true } : {}),\n ...(p.external === true ? { external: true } : {}),\n ...(p.public === true ? { public: true } : {}),\n ...(p.backlink !== undefined ? { backlink: p.backlink } : {}),\n }]),\n ),\n }\n}\n\nexport function blobBinding(cfg: BlobViaConfig): ViaBinding {\n return {\n brand: 'blob',\n // encryptedAtRest: 'envelope' — blob chunks are AEAD-encrypted envelopes\n // in `_blob_chunks` (service-side), not sealed record fields; queryable:\n // 'none' — nothing indexes blob content; exportable — vault.exportBlobs()\n // is a first-class door; forgettable — shredAllForRecord participates in\n // vault.forget().\n posture: { encryptedAtRest: 'envelope', queryable: 'none', exportable: true, forgettable: true },\n covers: (field) => field in cfg.fields,\n erase: (ctx) => eraseBlobs(ctx, cfg),\n describeFragment: () => buildBlobDescribeFragment(cfg.fields),\n }\n}\n\nexport function linkBlobVia(): void {\n installViaBinder('blob', (c) => blobBinding(c as BlobViaConfig))\n}\n","/**\n * Strategy seam between core Collection and the optional blob service\n * (#629 Task 7 — moved out of `with-shape/blobs/strategy.ts`, precedent:\n * `port/with/classified-strategy.ts`/`i18n-strategy.ts`). Lives on the\n * `/with` port (the one seam the kernel spine may import statically) so\n * `Collection`/`Vault` can hold the `NO_BLOBS` default without a\n * spine→service static import.\n *\n * Core imports `BlobStrategy` as a TYPE-ONLY symbol and `NO_BLOBS` as a\n * minimal runtime stub. Neither pulls in the heavy `BlobSet` / chunk /\n * MIME machinery — those only arrive when the consumer explicitly\n * imports `@noy-db/hub/blobs` (see `via/blob/index.ts` →\n * `withBlobs()` factory).\n *\n * This file is intentionally tiny so the bundler keeps it in the graph\n * without dragging everything else in.\n *\n * @internal\n */\n\nimport type { BlobSet } from '../../with-shape/blobs/blob-set.js'\nimport type { NoydbStore } from '../../kernel/types.js'\nimport type { ObjectProjection } from '../../with-shape/blobs/object-projection.js'\nimport type { BlobFieldsConfig } from '../../with-shape/blobs/blob-compaction.js'\nimport type { EnclaveKey } from '../../kernel/enclave/index.js'\nimport type { UnlockedKeyring } from '../../with-party/team/keyring.js'\nimport { linkBlobVia } from '../../via/blob/binding.js'\n\n// Install the blob Via binder EAGERLY (#629 Task 7) — `blobFields` policies\n// are plain object literals (there is no `blob.*()` declaration factory to\n// hang a lazy money/i18n-style link on), so the binder must be installed\n// before `compileViaBindings` ever compiles one. This port module is\n// already unconditionally imported by the kernel spine (for the `NO_BLOBS`\n// strategy default below), so linking here guarantees it — same rationale\n// as `port/with/classified-strategy.ts`'s eager `linkClassifiedVia()`. The\n// binding module is hook-free glue (declare/describe/erase) and imports no\n// machinery, so the eager cost is a few hundred bytes, not `BlobSet`.\nlinkBlobVia()\n\n/**\n * Args forwarded by `Collection.blob(id)` to the active strategy's\n * `openSlot`. The strategy is responsible for returning a live\n * `BlobSet` bound to the given record.\n *\n * @internal\n */\nexport interface BlobStrategyOpenArgs {\n readonly store: NoydbStore\n readonly vault: string\n readonly collection: string\n readonly recordId: string\n readonly getDEK: (collectionName: string) => Promise<EnclaveKey>\n readonly encrypted: boolean\n readonly userId: string\n /**\n * Collection opts into per-record keys (`perRecordKeys`), so its blobs are\n * erasable: new uploads mint a per-blob content CEK (crypto-shreddable at\n * `refCount → 0`). Off → legacy shared-`_blob`-DEK chunks. See the per-blob\n * CEK design spec.\n */\n readonly erasableBlobs?: boolean\n /**\n * Collection has `tiers` active (#724 I1 completion). Combined with\n * `erasableBlobs` false, a content write is refused —\n * `UnsupportedTierCompositionError` — since a legacy blob has no\n * per-blob `_cek` and can never be tier-isolated on elevate/demote.\n */\n readonly tiersActive?: boolean\n /**\n * Vault is in debug-plaintext mode (`encrypt: false` + `debugPlaintext: true`).\n * Blobs are then written as a single un-gzipped object (one base64 chunk) so\n * the stored object is directly recoverable with native tools (`base64 -d`),\n * matching the directly-inspectable record layout. Dev-only — see the\n * plaintext/debug-store-mode design.\n */\n readonly debugPlaintext?: boolean\n /**\n * Object projection for `external` blob fields (`createNoydb({ objectStore })`).\n * When present, fields declared `external` in `blobFields` route their raw\n * bytes here instead of the encrypted-chunk path.\n */\n readonly objectStore?: ObjectProjection\n /** Per-collection blob field policies — used to resolve `external` / `public`. */\n readonly blobFields?: BlobFieldsConfig\n /**\n * The caller's unlocked keyring (#749). Threaded through so `BlobSet.atTier()`\n * can run `assertTierAccess` — the SAME clearance gate `putAtTier`/`elevate`/\n * `demote` run before any tier `getDEK` call — rather than relying on a bare\n * `getDEK`, which auto-mints a DEK for ANY role and never throws (verified: it\n * is not itself a gate). Omitted only by a construction path that never calls\n * `atTier()`.\n */\n readonly keyring?: UnlockedKeyring\n}\n\n/**\n * The seam interface. `@internal` — do not build public APIs on this\n * shape; it can evolve freely until blobs are extracted into their\n * own package, at which point it will be promoted to public.\n *\n * @internal\n */\nexport interface BlobStrategy {\n openSlot(args: BlobStrategyOpenArgs): BlobSet\n}\n\n/**\n * Default strategy for collections that did not opt into blob storage.\n * Every operation surfaces an actionable error that points the caller\n * at the opt-in path.\n *\n * @internal\n */\nexport const NO_BLOBS: BlobStrategy = {\n openSlot() {\n throw new Error(\n 'Blob storage is not enabled on this Noydb instance. ' +\n 'Import `{ withBlobs }` from \"@noy-db/hub/blobs\" and pass `withBlobs()` to `createNoydb({ blobStrategy: withBlobs() })`.',\n )\n },\n}\n","/**\n * `vault.exportBlobs()` — bulk blob extraction primitive.\n *\n * Async-iterable handle over every blob attached to records in a\n * vault, optionally filtered by collection allowlist and per-record\n * predicate. Emits tuples of `{ blobId, recordRef, bytes, meta }` so\n * the consumer can pipe into any sink (zip stream, S3 multipart, USB\n * copy, cold-storage tape) without pulling the whole export into\n * memory.\n *\n * ## Auth + audit\n *\n * - Capability check runs **once** at handle creation via\n * `Vault.assertCanExport('plaintext', 'blob')`. An operator whose\n * keyring lacks that bit fails before a single byte of ciphertext\n * is decrypted.\n * - Audit entry lands in `_export_audit` at handle creation: the\n * actor, start timestamp, target collections, predicate presence,\n * and batch mechanism. **No content hashes** — per the spec\n * non-correlation invariant.\n *\n * ## Abort + resume\n *\n * - `handle.abort()` flips the internal signal; the next iteration\n * boundary throws `AbortError`. Consumers already in `for await`\n * can catch and exit cleanly.\n * - Restart after a partial failure with `{ afterBlobId }` — the\n * iterator skips tuples up to (and including) that blob id before\n * yielding again. Combined with a blob-count ceiling it supports\n * idempotent batch re-runs.\n *\n * @module\n */\n\nimport type { Collection } from '../../kernel/collection.js'\nimport type { SlotInfo } from '../../kernel/types.js'\n\n// ─── Types ──────────────────────────────────────────────────────────────\n\nexport interface ExportBlobsOptions {\n /**\n * Collection allowlist. Omit to export blobs from every collection\n * the caller has read access to.\n */\n readonly collections?: readonly string[]\n /**\n * Per-record predicate. Called on the decrypted record BEFORE any\n * blob bytes are read for that record — returning false skips the\n * record and all its slots without touching their chunks.\n */\n readonly where?: (record: unknown, context: { collection: string; id: string }) => boolean\n /**\n * Resume after a specific blob id. The iterator skips tuples up to\n * and including this id, then yields. Format of the id is the same\n * as `ExportedBlob.blobId` (the HMAC-keyed eTag).\n */\n readonly afterBlobId?: string\n /**\n * External abort signal. When fired, the next iterator tick throws\n * `ExportBlobsAbortedError`. Honored alongside `handle.abort()`.\n */\n readonly signal?: AbortSignal\n}\n\nexport interface ExportedBlob {\n /** Opaque blob identifier — HMAC-keyed eTag, stable across vaults. */\n readonly blobId: string\n /** Where this blob came from in the vault. */\n readonly recordRef: {\n readonly collection: string\n readonly id: string\n readonly slot: string\n }\n /** Decrypted plaintext bytes. */\n readonly bytes: Uint8Array\n /** Best-effort metadata (from the blob slot record). */\n readonly meta: {\n readonly size: number\n /**\n * User-visible filename stored on the slot. Often equal to the\n * slot name; differs when the caller supplied an explicit\n * `filename` to `BlobSet.put()`.\n */\n readonly filename: string\n readonly mimeType?: string\n readonly createdAt?: string\n }\n}\n\nexport interface ExportBlobsHandle extends AsyncIterable<ExportedBlob> {\n /** Abort the export. Safe to call multiple times. */\n abort(): void\n /** True once `abort()` has fired or the external signal aborted. */\n readonly aborted: boolean\n}\n\nexport class ExportBlobsAbortedError extends Error {\n constructor(reason: string) {\n super(`exportBlobs aborted: ${reason}`)\n this.name = 'ExportBlobsAbortedError'\n }\n}\n\n// ─── Audit ──────────────────────────────────────────────────────────────\n\nexport const EXPORT_AUDIT_COLLECTION = '_export_audit'\n\nexport interface ExportBlobsAuditEntry {\n readonly id: string\n readonly mechanism: 'exportBlobs'\n readonly actor: string\n readonly startedAt: string\n readonly collections: readonly string[] | null\n readonly predicate: boolean\n readonly afterBlobId: string | null\n}\n\n// ─── Implementation ─────────────────────────────────────────────────────\n\n/**\n * Build the handle. Factored out of `Vault.exportBlobs` so the\n * implementation can be unit-tested without going through the\n * compartment lifecycle.\n */\nexport function createExportBlobsHandle(\n actor: string,\n listAccessibleCollections: () => Promise<string[]>,\n getCollection: <T>(name: string) => Collection<T>,\n writeAudit: (entry: ExportBlobsAuditEntry) => Promise<void>,\n options: ExportBlobsOptions,\n): ExportBlobsHandle {\n let aborted = false\n\n const abort = (): void => {\n aborted = true\n }\n\n if (options.signal) {\n if (options.signal.aborted) aborted = true\n options.signal.addEventListener('abort', () => { aborted = true })\n }\n\n function assertLive(): void {\n if (aborted) throw new ExportBlobsAbortedError('aborted by caller')\n }\n\n const allowlist = options.collections ? new Set(options.collections) : null\n\n // Write the audit entry BEFORE the first yield so a blocked\n // iteration still leaves an audit trail that the export started.\n let auditPromise: Promise<void> | null = null\n function writeAuditOnce(): Promise<void> {\n if (!auditPromise) {\n auditPromise = writeAudit({\n id: generateBatchId(),\n mechanism: 'exportBlobs',\n actor,\n startedAt: new Date().toISOString(),\n collections: options.collections ?? null,\n predicate: Boolean(options.where),\n afterBlobId: options.afterBlobId ?? null,\n })\n }\n return auditPromise\n }\n\n async function* generate(): AsyncGenerator<ExportedBlob> {\n await writeAuditOnce()\n assertLive()\n\n // Resolve target collections lazily — also keeps the call async.\n const allCollections = await listAccessibleCollections()\n const targets = allCollections.filter(name => {\n if (name.startsWith('_')) return false\n if (allowlist && !allowlist.has(name)) return false\n return true\n })\n\n let resumeCursorHit = options.afterBlobId === undefined\n\n for (const collectionName of targets) {\n if (aborted) return\n\n const coll = getCollection<Record<string, unknown>>(collectionName)\n const records = await coll.list().catch(() => [])\n for (const record of records) {\n if (aborted) return\n assertLive()\n\n const idField = (record as { id?: unknown }).id\n if (typeof idField !== 'string') continue\n\n if (options.where && !options.where(record, { collection: collectionName, id: idField })) continue\n\n const blobSet = coll.blob(idField)\n const slots = await blobSet.list().catch(() => [] as SlotInfo[])\n for (const slot of slots) {\n if (aborted) return\n\n if (!resumeCursorHit) {\n if (slot.eTag === options.afterBlobId) {\n resumeCursorHit = true\n }\n continue\n }\n\n const bytes = await blobSet.get(slot.name)\n if (!bytes) continue\n\n const item: ExportedBlob = {\n blobId: slot.eTag,\n recordRef: { collection: collectionName, id: idField, slot: slot.name },\n bytes,\n meta: {\n size: slot.size,\n filename: slot.filename,\n ...(slot.mimeType !== undefined && { mimeType: slot.mimeType }),\n ...(slot.uploadedAt !== undefined && { createdAt: slot.uploadedAt }),\n },\n }\n yield item\n }\n }\n }\n }\n\n const handle: ExportBlobsHandle = {\n abort,\n get aborted() { return aborted },\n [Symbol.asyncIterator]: () => generate(),\n }\n return handle\n}\n\n// ─── Helpers ────────────────────────────────────────────────────────────\n\nfunction generateBatchId(): string {\n // 16 bytes of crypto randomness, URL-safe base64, no padding.\n const raw = globalThis.crypto.getRandomValues(new Uint8Array(16))\n let s = ''\n for (const b of raw) s += b.toString(16).padStart(2, '0')\n return `batch-${Date.now().toString(36)}-${s.slice(0, 12)}`\n}\n","/**\n * Blob retention + compaction.\n *\n * Declarative per-collection / per-slot eviction policy. Two\n * triggers:\n *\n * - **`retainDays`** — age-based TTL. A slot uploaded more than N\n * days ago is evicted.\n * - **`evictWhen(record)`** — predicate over the **decrypted**\n * record. Lets consumers express \"the image is safe to drop once\n * the structured invoice has been reviewed and confirmed.\"\n *\n * Either trigger (or both) causes the slot to evict. Eviction removes\n * the slot entry from `_blob_slots_{collection}`, decrements the\n * blob's refCount (so unreferenced chunks can be GC'd by the next\n * sweep), and writes one entry to the `_blob_eviction_audit`\n * collection for tamper-evident record-keeping.\n *\n * The audit entry carries the eTag of the evicted blob (opaque HMAC\n * of plaintext under the vault's `_blob` DEK) — no plaintext leakage,\n * per the SPEC non-correlation invariant. Consumers reconstructing\n * \"what used to be attached\" can look up the audit entry by record\n * id.\n *\n * Compaction is **consumer-scheduled** — noy-db never runs a\n * background daemon. Call `vault.compact()` whenever your workflow\n * allows (cron, manual \"tidy\" button, cold-storage export prep, …).\n *\n * @module\n */\n\nimport type { NoydbStore, EncryptedEnvelope, SlotInfo } from '../../kernel/types.js'\nimport { NOYDB_FORMAT_VERSION } from '../../kernel/types.js'\nimport { ValidationError } from '../../kernel/errors.js'\nimport { encrypt, type EnclaveKey } from '../../kernel/enclave/index.js'\n\n// ─── Config types ───────────────────────────────────────────────────────\n\nexport interface BlobFieldPolicy<T = unknown> {\n /**\n * Via port brand marker — lets a `BlobFieldPolicy` satisfy the kernel's\n * opaque `ViaDescriptor` (#629 Task 7). Optional (the\n * `ClassifiedFieldSpec._viaBrand` precedent): `blobFields` policies are\n * plain object literals with no declaration factory to stamp it, so a\n * mandatory field would break every existing declaration.\n */\n readonly _viaBrand?: 'blob'\n /**\n * Age-based TTL in days. A slot whose `uploadedAt` is older than\n * `now - retainDays × 86400s` evicts on the next `vault.compact()`.\n * Omit to disable age-based eviction.\n */\n readonly retainDays?: number\n /**\n * Predicate evaluated against the decrypted record. When it returns\n * `true`, every matching slot on that record evicts. Omit to\n * disable predicate-based eviction.\n */\n readonly evictWhen?: (record: T) => boolean\n /**\n * **Legal hold.** When this predicate returns `true`, the slot is\n * never evicted — `retainDays`/`evictWhen` are overridden. Use for a\n * litigation / audit hold on a fiscal document: the blob stays until\n * the predicate returns `false` (the hold is released). Fail-closed:\n * if the predicate throws, the slot is treated as held.\n */\n readonly legalHold?: (record: T) => boolean\n /**\n * **Period-bound retention.** Returns the date (Date / ISO string /\n * epoch ms) until which the slot must be retained — typically derived\n * from the record's fiscal period (e.g. period end + 10 years). While\n * `now < retainUntil`, the slot is never evicted, regardless of\n * `retainDays`. Return `null`/`undefined` to impose no floor.\n * Fail-closed: a throwing function holds the slot.\n */\n readonly retainUntil?: (record: T) => Date | string | number | null | undefined\n /**\n * **External projection.** When `true`, this field's bytes are stored in the\n * vault's `ObjectProjection` (`createNoydb({ objectStore })`) as a single raw,\n * **unencrypted** object — servable directly from S3/CDN and processable by\n * native tooling — instead of the encrypted-chunk path. The encrypted slot\n * record remains the catalog (anchoring invariant). Requires an `objectStore`;\n * **outside the zero-knowledge guarantee** — use only for assets meant to\n * leave the vault. See the as-aws-s3 design spec.\n */\n readonly external?: boolean\n /**\n * For an `external` field: make the object world-readable (CDN origin) rather\n * than presigned-only. Default `false` (presigned). Ignored unless `external`.\n */\n readonly public?: boolean\n /**\n * For an `external` field: how to stamp a **backlink** (this record's\n * vault/collection/id/field) onto the object's metadata — the self-describing\n * \"secondary store\" that powers reconcile / DR / import re-pairing.\n * - `'opaque-token'` (default): a random id; preserves the opaque-bucket\n * property (no names leak); the token is also recorded on the slot.\n * - `'encrypted'`: the reference encrypted under the blob DEK (ZK-preserving;\n * falls back to `'opaque-token'` on a plaintext vault).\n * - `'plain'`: the reference in cleartext metadata — **leaks structure** to\n * bucket readers; only for non-sensitive deployments.\n * - `'none'`: no backlink.\n */\n readonly backlink?: 'opaque-token' | 'encrypted' | 'plain' | 'none'\n}\n\nexport type BlobFieldsConfig<T = unknown> = Record<string, BlobFieldPolicy<T>>\n\n// ─── Audit collection ──────────────────────────────────────────────────\n\nexport const BLOB_EVICTION_AUDIT_COLLECTION = '_blob_eviction_audit'\n\nexport interface BlobEvictionEntry {\n readonly id: string\n readonly collection: string\n readonly recordId: string\n readonly slotName: string\n readonly blobHash: string\n /** `'budget'` — evicted by the #808 cache-budget LRU pass, not a policy. */\n readonly reason: 'ttl' | 'predicate' | 'both' | 'budget'\n readonly evictedAt: string\n readonly actor: string\n}\n\n// ─── Compaction result ──────────────────────────────────────────────────\n\nexport interface CompactionResult {\n /** Number of blob slots evicted by the policy pass across all collections. */\n readonly evicted: number\n /** Number of records touched (iterated + policy checked). */\n readonly records: number\n /** Number of collections with `blobFields` configured. */\n readonly collections: number\n /**\n * Number of audit entries written — one per policy eviction plus one per\n * budget SLOT eviction (dropping a device-local cache copy writes none).\n */\n readonly auditEntries: number\n /**\n * Number of slots that would have evicted (TTL/predicate triggered)\n * but were retained by a `legalHold` or `retainUntil` floor.\n */\n readonly held: number\n /**\n * #808: number of slots whose due policy eviction was skipped because they\n * are pinned for offline on THIS device (pin state is device-local).\n */\n readonly pinned: number\n /**\n * #808: number of evictions performed by the `cacheBudget` LRU pass —\n * internal slots evicted through the standard eviction writer plus\n * device-local external cache copies dropped. 0 when no budget was given.\n */\n readonly budgetEvicted: number\n /** #808: plaintext bytes freed by the `cacheBudget` LRU pass. */\n readonly budgetBytesFreed: number\n /** Per-collection breakdown for diagnostics. */\n readonly byCollection: Record<string, { records: number; evicted: number }>\n}\n\n// ─── Core ──────────────────────────────────────────────────────────────\n\nexport interface CompactRunOptions {\n /** Override \"now\" for deterministic testing. */\n readonly now?: Date\n /**\n * Stop after this many evictions. Useful for capped batches / cron\n * jobs that need to fit in a time window. `undefined` = unbounded.\n */\n readonly maxEvictions?: number\n /**\n * Dry-run — evaluate policies and return the counts, but do NOT\n * delete slots or write audit entries. Lets a consumer preview\n * what would happen.\n */\n readonly dryRun?: boolean\n /**\n * #808 mobile cache budget: cap the locally-cached UNPINNED blob bytes.\n * After the policy pass, a dedicated LRU pass walks every collection's\n * slots (pinned slots and `legalHold`/`retainUntil`-held slots are exempt\n * and uncounted) and evicts oldest-access-first — internal slots through\n * the standard eviction writer (`deleteSlot` + a `'budget'` audit entry),\n * external slots by dropping their device-local encrypted cache copy only\n * (the object-store copy is authoritative and untouched) — until the\n * remaining unpinned bytes fit `maxBytes`. Internal slots count their\n * uncompressed `size`; external slots count `cachedBytes` (0 = nothing\n * local, nothing to evict). LRU order comes from the device-local\n * `lastAccessAt` stamp, falling back to `uploadedAt`.\n */\n readonly cacheBudget?: { readonly maxBytes: number }\n}\n\nexport interface CompactionContext {\n readonly adapter: NoydbStore\n readonly vault: string\n readonly actor: string\n readonly encrypted: boolean\n readonly getDEK: (collection: string) => Promise<EnclaveKey>\n /**\n * Resolve a collection's declared `blobFields` config. Returns an\n * empty map for collections without the config — the walk skips\n * those.\n */\n readonly getBlobFields: <T>(collection: string) => BlobFieldsConfig<T> | null\n /** List collection names in the vault. */\n readonly listCollections: () => Promise<string[]>\n /** List record ids in a collection. */\n readonly listRecords: (collection: string) => Promise<string[]>\n /** Decrypt and return the record. Null when absent. */\n readonly getRecord: <T>(collection: string, id: string) => Promise<T | null>\n /** Return the BlobSet-like handle for a record's slots. */\n readonly listSlots: (collection: string, id: string) => Promise<SlotInfo[]>\n /** Delete a slot and decrement its blob's refCount. */\n readonly deleteSlot: (collection: string, id: string, slotName: string) => Promise<void>\n /**\n * #808: drop a slot's DEVICE-LOCAL cached copy (the encrypted external\n * side-cache) without touching the slot or the object store. Returns the\n * plaintext bytes freed. Optional — absent (or a 0 return) means external\n * cache entries simply cannot be budget-evicted through this context.\n */\n readonly dropLocalCache?: (collection: string, id: string, slotName: string) => Promise<number>\n}\n\nexport async function runCompaction(\n ctx: CompactionContext,\n options: CompactRunOptions = {},\n): Promise<CompactionResult> {\n const now = options.now ?? new Date()\n const maxEvictions = options.maxEvictions ?? Infinity\n const dryRun = options.dryRun === true\n if (options.cacheBudget !== undefined\n && (!Number.isFinite(options.cacheBudget.maxBytes) || options.cacheBudget.maxBytes < 0)) {\n throw new ValidationError('compact(): cacheBudget.maxBytes must be a non-negative finite number (#808)')\n }\n\n const allCollections = await ctx.listCollections()\n const byCollection: Record<string, { records: number; evicted: number }> = {}\n let evicted = 0\n let records = 0\n let auditEntries = 0\n let held = 0\n let pinned = 0\n let collectionsWithPolicy = 0\n\n outer: for (const collectionName of allCollections) {\n if (collectionName.startsWith('_')) continue\n const config = ctx.getBlobFields(collectionName)\n if (!config) continue\n const configuredSlots = Object.keys(config)\n if (configuredSlots.length === 0) continue\n collectionsWithPolicy += 1\n byCollection[collectionName] = { records: 0, evicted: 0 }\n\n const ids = await ctx.listRecords(collectionName)\n for (const recordId of ids) {\n if (evicted >= maxEvictions) break outer\n\n const record = await ctx.getRecord(collectionName, recordId).catch(() => null)\n if (record === null) continue\n records += 1\n byCollection[collectionName].records += 1\n\n const slots = await ctx.listSlots(collectionName, recordId).catch(() => [])\n for (const slot of slots) {\n if (evicted >= maxEvictions) break outer\n const policy = config[slot.name]\n if (!policy) continue\n\n const reason = evaluatePolicy(policy, record, slot, now)\n if (!reason) continue\n\n // #808: device-local offline pin — an exemption inside this existing\n // pass, exactly like a hold: counted, never evicted. `slot.pinned` is\n // the device-local annotation `BlobSet.list()` stamps from the\n // withBlobs() pin registry (never synced state).\n if (slot.pinned === true) {\n pinned += 1\n continue\n }\n\n // Retention floor: a legal hold or period-bound retainUntil\n // blocks an otherwise-due eviction. Counted, never evicted.\n if (isHeld(policy, record, now)) {\n held += 1\n continue\n }\n\n if (!dryRun) {\n await ctx.deleteSlot(collectionName, recordId, slot.name)\n await writeAuditEntry(ctx, {\n id: generateEvictionId(collectionName, recordId, slot.name),\n collection: collectionName,\n recordId,\n slotName: slot.name,\n blobHash: slot.eTag,\n reason,\n evictedAt: now.toISOString(),\n actor: ctx.actor,\n })\n auditEntries += 1\n }\n evicted += 1\n byCollection[collectionName].evicted += 1\n }\n }\n }\n\n // #808: cache-budget LRU pass — runs AFTER the policy pass so a slot that\n // just evicted no longer counts toward the budget. Reuses this module's own\n // eviction writer (deleteSlot + audit), never a parallel one.\n let budgetEvicted = 0\n let budgetBytesFreed = 0\n if (options.cacheBudget !== undefined) {\n const pass = await runBudgetPass(ctx, options.cacheBudget.maxBytes, {\n now, dryRun, remainingEvictions: maxEvictions - evicted,\n })\n budgetEvicted = pass.evicted\n budgetBytesFreed = pass.bytesFreed\n auditEntries += pass.auditEntries\n }\n\n return {\n evicted,\n records,\n collections: collectionsWithPolicy,\n auditEntries,\n held,\n pinned,\n budgetEvicted,\n budgetBytesFreed,\n byCollection,\n }\n}\n\n// ─── #808: cache-budget LRU pass ───────────────────────────────────────\n\ninterface BudgetCandidate {\n readonly collection: string\n readonly recordId: string\n readonly slotName: string\n readonly eTag: string\n readonly bytes: number\n /** `'slot'` — internal blob, evicted via `deleteSlot`; `'cache'` — external device-local copy, dropped via `dropLocalCache`. */\n readonly kind: 'slot' | 'cache'\n readonly lastAccessMs: number\n}\n\n/**\n * Enforce `cacheBudget.maxBytes` over the locally-cached UNPINNED blob bytes\n * (see {@link CompactRunOptions.cacheBudget} for the full contract). Walks\n * EVERY collection — unlike the policy pass, the budget is not gated on a\n * declared `blobFields` config — but still honors a declared policy's\n * `legalHold`/`retainUntil` floor where one exists.\n */\nasync function runBudgetPass(\n ctx: CompactionContext,\n maxBytes: number,\n opts: { now: Date; dryRun: boolean; remainingEvictions: number },\n): Promise<{ evicted: number; bytesFreed: number; auditEntries: number }> {\n const candidates: BudgetCandidate[] = []\n let total = 0\n\n for (const collectionName of await ctx.listCollections()) {\n if (collectionName.startsWith('_')) continue\n const config = ctx.getBlobFields(collectionName)\n for (const recordId of await ctx.listRecords(collectionName)) {\n const slots = await ctx.listSlots(collectionName, recordId).catch(() => [])\n if (slots.length === 0) continue\n // The record is only needed to evaluate a declared policy's retention\n // floor — skip the decrypt entirely for policy-less collections.\n const record = config\n ? await ctx.getRecord<unknown>(collectionName, recordId).catch(() => null)\n : null\n for (const slot of slots) {\n if (slot.pinned === true) continue // pinned: exempt AND uncounted (#808)\n const policy = config?.[slot.name]\n if (policy && record !== null && isHeld(policy, record, opts.now)) continue // floor blocks budget too\n const lastAccessMs = Date.parse(slot.lastAccessAt ?? slot.uploadedAt) || 0\n const isExternal = slot.external !== undefined\n const bytes = isExternal ? slot.cachedBytes ?? 0 : slot.size\n if (bytes <= 0) continue // external with no local copy: nothing cached to evict\n total += bytes\n candidates.push({\n collection: collectionName, recordId, slotName: slot.name, eTag: slot.eTag,\n bytes, kind: isExternal ? 'cache' : 'slot', lastAccessMs,\n })\n }\n }\n }\n\n // Oldest access first; deterministic tiebreak so equal timestamps (common\n // within one ms) never make the eviction order flap between runs.\n candidates.sort((a, b) =>\n a.lastAccessMs - b.lastAccessMs\n || a.collection.localeCompare(b.collection)\n || a.recordId.localeCompare(b.recordId)\n || a.slotName.localeCompare(b.slotName))\n\n let evicted = 0\n let bytesFreed = 0\n let auditEntries = 0\n for (const c of candidates) {\n if (total <= maxBytes || evicted >= opts.remainingEvictions) break\n if (!opts.dryRun) {\n if (c.kind === 'slot') {\n await ctx.deleteSlot(c.collection, c.recordId, c.slotName)\n await writeAuditEntry(ctx, {\n id: generateEvictionId(c.collection, c.recordId, c.slotName),\n collection: c.collection,\n recordId: c.recordId,\n slotName: c.slotName,\n blobHash: c.eTag,\n reason: 'budget',\n evictedAt: opts.now.toISOString(),\n actor: ctx.actor,\n })\n auditEntries += 1\n } else {\n // Device-local cache drop only — the slot (catalog) and the\n // object-store copy are untouched, so no eviction audit entry.\n await ctx.dropLocalCache?.(c.collection, c.recordId, c.slotName)\n }\n }\n evicted += 1\n bytesFreed += c.bytes\n total -= c.bytes\n }\n\n return { evicted, bytesFreed, auditEntries }\n}\n\n/**\n * Whether a retention floor (legal hold or period-bound `retainUntil`)\n * currently blocks eviction of this record's slots. Fail-closed: a\n * throwing predicate holds the slot.\n */\nfunction isHeld<T>(policy: BlobFieldPolicy<T>, record: T, now: Date): boolean {\n if (policy.legalHold) {\n try {\n if (policy.legalHold(record)) return true\n } catch {\n return true\n }\n }\n if (policy.retainUntil) {\n try {\n const until = policy.retainUntil(record)\n if (until !== null && until !== undefined) {\n const t = until instanceof Date ? until.getTime() : typeof until === 'number' ? until : Date.parse(String(until))\n if (!Number.isFinite(t)) return true // fail-closed: unparseable retainUntil holds the slot\n if (t > now.getTime()) return true\n }\n } catch {\n return true\n }\n }\n return false\n}\n\nfunction evaluatePolicy<T>(\n policy: BlobFieldPolicy<T>,\n record: T,\n slot: SlotInfo,\n now: Date,\n): 'ttl' | 'predicate' | 'both' | null {\n let ttlTriggered = false\n let predicateTriggered = false\n\n if (policy.retainDays !== undefined && policy.retainDays > 0) {\n const uploadedAt = Date.parse(slot.uploadedAt)\n if (Number.isFinite(uploadedAt)) {\n const ageMs = now.getTime() - uploadedAt\n const limitMs = policy.retainDays * 86_400_000\n if (ageMs > limitMs) ttlTriggered = true\n }\n }\n\n if (policy.evictWhen) {\n try {\n if (policy.evictWhen(record)) predicateTriggered = true\n } catch {\n // Predicate error → do NOT evict. Fail closed.\n }\n }\n\n if (ttlTriggered && predicateTriggered) return 'both'\n if (ttlTriggered) return 'ttl'\n if (predicateTriggered) return 'predicate'\n return null\n}\n\nfunction generateEvictionId(collection: string, recordId: string, slotName: string): string {\n const rand = globalThis.crypto.getRandomValues(new Uint8Array(8))\n let suffix = ''\n for (const b of rand) suffix += b.toString(16).padStart(2, '0')\n return `${collection}__${recordId}__${slotName}__${suffix}`\n}\n\nasync function writeAuditEntry(ctx: CompactionContext, entry: BlobEvictionEntry): Promise<void> {\n const json = JSON.stringify(entry)\n let envelope: EncryptedEnvelope\n if (ctx.encrypted) {\n const dek = await ctx.getDEK(BLOB_EVICTION_AUDIT_COLLECTION)\n const { iv, data } = await encrypt(json, dek)\n envelope = {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: 1,\n _ts: entry.evictedAt,\n _iv: iv,\n _data: data,\n _by: entry.actor,\n }\n } else {\n envelope = {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: 1,\n _ts: entry.evictedAt,\n _iv: '',\n _data: json,\n _by: entry.actor,\n }\n }\n await ctx.adapter.put(ctx.vault, BLOB_EVICTION_AUDIT_COLLECTION, entry.id, envelope)\n}\n"],"mappings":";;;;;;;;;;;;;;AAuEA,eAAe,WAAW,KAAkB,KAA6C;AACvF,MAAI,IAAI,oBAAqB,QAAO,IAAI,oBAAoB,IAAI,EAAE;AAClE,SAAO,EAAE,UAAU,GAAG,SAAS,CAAC,EAAE;AACpC;AAgCA,SAAS,0BAA0B,QAAmD;AACpF,SAAO;AAAA,IACL,YAAY,OAAO;AAAA,MACjB,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC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AI,IAAI,OAAO,gCAAgC,MAAM,IAAI,QAAQ;AACrF;","names":[]}
|
|
@@ -2,32 +2,27 @@ import {
|
|
|
2
2
|
assertStrongSecret,
|
|
3
3
|
mintKeyringCanary,
|
|
4
4
|
persistKeyring
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
burnPaperRecoveryEntry,
|
|
8
|
-
loadPaperRecoveryEntries,
|
|
9
|
-
loadShamirRecoveryEntries,
|
|
10
|
-
unwrapDeksFromPaperEntry,
|
|
11
|
-
unwrapDeksFromShamirEntry
|
|
12
|
-
} from "./chunk-CJVEAVYH.js";
|
|
5
|
+
} from "./chunk-ZDFU34XY.js";
|
|
13
6
|
import {
|
|
14
7
|
dekKey
|
|
15
8
|
} from "./chunk-LC7DSMHR.js";
|
|
16
9
|
import {
|
|
17
10
|
openEnvelopeJson
|
|
18
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MMVQ3SUO.js";
|
|
19
12
|
import {
|
|
20
13
|
base64ToBuffer,
|
|
21
14
|
bufferToBase64,
|
|
22
15
|
deriveKey,
|
|
16
|
+
deriveSecretKey,
|
|
23
17
|
encrypt,
|
|
24
18
|
generateSalt,
|
|
25
19
|
unwrapKey,
|
|
26
20
|
wrapKey
|
|
27
21
|
} from "./chunk-7U6AB7DZ.js";
|
|
28
22
|
import {
|
|
23
|
+
NOYDB_FORMAT_VERSION,
|
|
29
24
|
NOYDB_KEYRING_VERSION
|
|
30
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
31
26
|
import {
|
|
32
27
|
DelegationTargetMissingError,
|
|
33
28
|
InvalidKeyError,
|
|
@@ -52,18 +47,200 @@ var NO_TEAM = {
|
|
|
52
47
|
}
|
|
53
48
|
};
|
|
54
49
|
|
|
50
|
+
// src/with-party/team/wrapped-deks.ts
|
|
51
|
+
var PBKDF2_ITERATIONS = 6e5;
|
|
52
|
+
var SALT_BYTES = 32;
|
|
53
|
+
var IV_BYTES = 12;
|
|
54
|
+
var subtle = globalThis.crypto.subtle;
|
|
55
|
+
async function mintWrappedDeksBlob(deks, credential) {
|
|
56
|
+
const salt = crypto.getRandomValues(new Uint8Array(SALT_BYTES));
|
|
57
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
|
|
58
|
+
const wrappingKey = await deriveWrappingKey(credential, salt);
|
|
59
|
+
const exported = {};
|
|
60
|
+
for (const [coll, dek] of deks) {
|
|
61
|
+
const raw = await subtle.exportKey("raw", dek);
|
|
62
|
+
exported[coll] = bytesToBase64(new Uint8Array(raw));
|
|
63
|
+
}
|
|
64
|
+
const plaintext = new TextEncoder().encode(JSON.stringify({ deks: exported }));
|
|
65
|
+
const ciphertext = await subtle.encrypt(
|
|
66
|
+
{ name: "AES-GCM", iv },
|
|
67
|
+
wrappingKey,
|
|
68
|
+
plaintext
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
salt: bytesToBase64(salt),
|
|
72
|
+
iv: bytesToBase64(iv),
|
|
73
|
+
wrappedDeks: bytesToBase64(new Uint8Array(ciphertext))
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function unwrapDeksFromBlob(blob, credential) {
|
|
77
|
+
const wrappingKey = await deriveWrappingKey(credential, base64ToBytes(blob.salt));
|
|
78
|
+
const plaintext = await subtle.decrypt(
|
|
79
|
+
{ name: "AES-GCM", iv: base64ToBytes(blob.iv) },
|
|
80
|
+
wrappingKey,
|
|
81
|
+
base64ToBytes(blob.wrappedDeks)
|
|
82
|
+
);
|
|
83
|
+
const parsed = JSON.parse(new TextDecoder().decode(plaintext));
|
|
84
|
+
const deks = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const [coll, b64] of Object.entries(parsed.deks)) {
|
|
86
|
+
const raw = base64ToBytes(b64);
|
|
87
|
+
const key = await subtle.importKey(
|
|
88
|
+
"raw",
|
|
89
|
+
raw,
|
|
90
|
+
{ name: "AES-GCM", length: 256 },
|
|
91
|
+
true,
|
|
92
|
+
["encrypt", "decrypt"]
|
|
93
|
+
);
|
|
94
|
+
deks.set(coll, key);
|
|
95
|
+
}
|
|
96
|
+
return deks;
|
|
97
|
+
}
|
|
98
|
+
async function deriveWrappingKey(credential, salt) {
|
|
99
|
+
return deriveSecretKey(credential, salt, { iterations: PBKDF2_ITERATIONS, keyUsage: "aes-gcm" });
|
|
100
|
+
}
|
|
101
|
+
function bytesToBase64(b) {
|
|
102
|
+
let s = "";
|
|
103
|
+
for (const x of b) s += String.fromCharCode(x);
|
|
104
|
+
return btoa(s);
|
|
105
|
+
}
|
|
106
|
+
function base64ToBytes(b64) {
|
|
107
|
+
const s = atob(b64);
|
|
108
|
+
const out = new Uint8Array(s.length);
|
|
109
|
+
for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/with-party/team/recovery.ts
|
|
114
|
+
var PAPER_DOC_ID = "recovery-paper";
|
|
115
|
+
async function loadPaperRecoveryEntries(store, vault) {
|
|
116
|
+
const env = await store.get(vault, "_meta", PAPER_DOC_ID);
|
|
117
|
+
if (!env) return [];
|
|
118
|
+
try {
|
|
119
|
+
const doc = JSON.parse(env._data);
|
|
120
|
+
if (doc.profile !== "paper" || !Array.isArray(doc.entries)) return [];
|
|
121
|
+
return doc.entries;
|
|
122
|
+
} catch {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function savePaperRecoveryEntries(store, vault, entries) {
|
|
127
|
+
const doc = {
|
|
128
|
+
_noydb_recovery: 1,
|
|
129
|
+
profile: "paper",
|
|
130
|
+
entries
|
|
131
|
+
};
|
|
132
|
+
const envelope = {
|
|
133
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
134
|
+
_v: 1,
|
|
135
|
+
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
136
|
+
_iv: "",
|
|
137
|
+
_data: JSON.stringify(doc)
|
|
138
|
+
};
|
|
139
|
+
await store.put(vault, "_meta", PAPER_DOC_ID, envelope);
|
|
140
|
+
}
|
|
141
|
+
async function burnPaperRecoveryEntry(store, vault, codeId) {
|
|
142
|
+
const entries = await loadPaperRecoveryEntries(store, vault);
|
|
143
|
+
const remaining = entries.filter((e) => e.codeId !== codeId);
|
|
144
|
+
await savePaperRecoveryEntries(store, vault, remaining);
|
|
145
|
+
}
|
|
146
|
+
async function hasRecoveryEnrolled(store, vault) {
|
|
147
|
+
const paper = await loadPaperRecoveryEntries(store, vault);
|
|
148
|
+
if (paper.length > 0) return true;
|
|
149
|
+
const shamir = await loadShamirRecoveryEntries(store, vault);
|
|
150
|
+
return shamir.length > 0;
|
|
151
|
+
}
|
|
152
|
+
async function hasStrongRecoveryEnrolled(store, vault) {
|
|
153
|
+
const shamir = await loadShamirRecoveryEntries(store, vault);
|
|
154
|
+
return shamir.length > 0;
|
|
155
|
+
}
|
|
156
|
+
var SHAMIR_DOC_ID = "recovery-shamir";
|
|
157
|
+
async function loadShamirRecoveryEntries(store, vault) {
|
|
158
|
+
const env = await store.get(vault, "_meta", SHAMIR_DOC_ID);
|
|
159
|
+
if (!env) return [];
|
|
160
|
+
try {
|
|
161
|
+
const doc = JSON.parse(env._data);
|
|
162
|
+
if (doc.profile !== "shamir" || !Array.isArray(doc.entries)) return [];
|
|
163
|
+
return doc.entries;
|
|
164
|
+
} catch {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function saveShamirRecoveryEntries(store, vault, entries) {
|
|
169
|
+
const doc = {
|
|
170
|
+
_noydb_recovery: 1,
|
|
171
|
+
profile: "shamir",
|
|
172
|
+
entries
|
|
173
|
+
};
|
|
174
|
+
const envelope = {
|
|
175
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
176
|
+
_v: 1,
|
|
177
|
+
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
178
|
+
_iv: "",
|
|
179
|
+
_data: JSON.stringify(doc)
|
|
180
|
+
};
|
|
181
|
+
await store.put(vault, "_meta", SHAMIR_DOC_ID, envelope);
|
|
182
|
+
}
|
|
183
|
+
async function mintShamirRecoveryEntry(provider, deks, entryId, k, n, label) {
|
|
184
|
+
const recoverySecret = crypto.getRandomValues(new Uint8Array(32));
|
|
185
|
+
try {
|
|
186
|
+
const credential = bytesToBase642(recoverySecret);
|
|
187
|
+
const blob = await mintWrappedDeksBlob(deks, credential);
|
|
188
|
+
const shareStrings = provider.splitToShares(recoverySecret, k, n);
|
|
189
|
+
const entry = {
|
|
190
|
+
...blob,
|
|
191
|
+
entryId,
|
|
192
|
+
k,
|
|
193
|
+
n,
|
|
194
|
+
enrolledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
195
|
+
...label !== void 0 && { label }
|
|
196
|
+
};
|
|
197
|
+
return { entry, shareStrings };
|
|
198
|
+
} finally {
|
|
199
|
+
recoverySecret.fill(0);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function unwrapDeksFromShamirEntry(provider, entry, shareStrings) {
|
|
203
|
+
if (shareStrings.length < entry.k) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Insufficient shares: this Shamir entry needs ${entry.k} of ${entry.n}, but ${shareStrings.length} were provided.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const secret = provider.combineShares(shareStrings);
|
|
209
|
+
try {
|
|
210
|
+
return await unwrapDeksFromBlob(entry, bytesToBase642(secret));
|
|
211
|
+
} finally {
|
|
212
|
+
secret.fill(0);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function bytesToBase642(b) {
|
|
216
|
+
let s = "";
|
|
217
|
+
for (const x of b) s += String.fromCharCode(x);
|
|
218
|
+
return btoa(s);
|
|
219
|
+
}
|
|
220
|
+
async function mintPaperRecoveryEntry(deks, code, codeId) {
|
|
221
|
+
const blob = await mintWrappedDeksBlob(deks, code);
|
|
222
|
+
return {
|
|
223
|
+
...blob,
|
|
224
|
+
codeId,
|
|
225
|
+
enrolledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
async function unwrapDeksFromPaperEntry(entry, code) {
|
|
229
|
+
return unwrapDeksFromBlob(entry, code);
|
|
230
|
+
}
|
|
231
|
+
|
|
55
232
|
// src/with-party/team/magic-link-grant.ts
|
|
56
233
|
var MAGIC_LINK_GRANTS_COLLECTION = "_magic_link_grants";
|
|
57
234
|
var MAGIC_LINK_CONTENT_INFO_PREFIX = "noydb-magic-link-content-v1:";
|
|
58
235
|
var MAGIC_LINK_KEK_INFO_PREFIX = "noydb-magic-link-v1:";
|
|
59
236
|
async function deriveMagicLinkContentKey(serverSecret, token, vault) {
|
|
60
|
-
const
|
|
237
|
+
const subtle2 = globalThis.crypto.subtle;
|
|
61
238
|
const ikmBytes = serverSecret instanceof Uint8Array ? serverSecret : new TextEncoder().encode(serverSecret);
|
|
62
239
|
const tokenBytes = new TextEncoder().encode(token);
|
|
63
|
-
const saltBuffer = await
|
|
240
|
+
const saltBuffer = await subtle2.digest("SHA-256", tokenBytes);
|
|
64
241
|
const info = new TextEncoder().encode(MAGIC_LINK_CONTENT_INFO_PREFIX + vault);
|
|
65
|
-
const ikm = await
|
|
66
|
-
return
|
|
242
|
+
const ikm = await subtle2.importKey("raw", ikmBytes, "HKDF", false, ["deriveKey"]);
|
|
243
|
+
return subtle2.deriveKey(
|
|
67
244
|
{ name: "HKDF", hash: "SHA-256", salt: saltBuffer, info },
|
|
68
245
|
ikm,
|
|
69
246
|
{ name: "AES-GCM", length: 256 },
|
|
@@ -567,6 +744,19 @@ function appendSlot(keyring, slot) {
|
|
|
567
744
|
|
|
568
745
|
export {
|
|
569
746
|
NO_TEAM,
|
|
747
|
+
mintWrappedDeksBlob,
|
|
748
|
+
unwrapDeksFromBlob,
|
|
749
|
+
loadPaperRecoveryEntries,
|
|
750
|
+
savePaperRecoveryEntries,
|
|
751
|
+
burnPaperRecoveryEntry,
|
|
752
|
+
hasRecoveryEnrolled,
|
|
753
|
+
hasStrongRecoveryEnrolled,
|
|
754
|
+
loadShamirRecoveryEntries,
|
|
755
|
+
saveShamirRecoveryEntries,
|
|
756
|
+
mintShamirRecoveryEntry,
|
|
757
|
+
unwrapDeksFromShamirEntry,
|
|
758
|
+
mintPaperRecoveryEntry,
|
|
759
|
+
unwrapDeksFromPaperEntry,
|
|
570
760
|
MAGIC_LINK_GRANTS_COLLECTION,
|
|
571
761
|
MAGIC_LINK_CONTENT_INFO_PREFIX,
|
|
572
762
|
MAGIC_LINK_KEK_INFO_PREFIX,
|
|
@@ -586,4 +776,4 @@ export {
|
|
|
586
776
|
removeAuthenticator,
|
|
587
777
|
findAuthenticator
|
|
588
778
|
};
|
|
589
|
-
//# sourceMappingURL=chunk-
|
|
779
|
+
//# sourceMappingURL=chunk-M4GO4ZJK.js.map
|