@noy-db/hub 0.6.0-pre.17 → 0.6.0-pre.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-Z5VHH24A.js +20 -0
- package/dist/attestation/index.js +18 -18
- package/dist/{backup-7X3PFTSI.js → backup-K62BFMYK.js} +16 -16
- package/dist/{backup-7X3PFTSI.js.map → backup-K62BFMYK.js.map} +1 -1
- package/dist/blobs/index.js +13 -13
- package/dist/broker/index.js +12 -12
- package/dist/cargo/index.js +32 -32
- package/dist/{chunk-5SK5AFYH.js → chunk-2E2MKBMI.js} +2 -2
- package/dist/{chunk-SDEHNGWW.js → chunk-2IK6AC6A.js} +7 -6
- package/dist/{chunk-SDEHNGWW.js.map → chunk-2IK6AC6A.js.map} +1 -1
- package/dist/{chunk-7TZTQS4H.js → chunk-32O2N2CH.js} +48 -21
- package/dist/chunk-32O2N2CH.js.map +1 -0
- package/dist/{chunk-QKRJUPAC.js → chunk-37P5VB4N.js} +13 -16
- package/dist/chunk-37P5VB4N.js.map +1 -0
- package/dist/{chunk-5UGEGEIJ.js → chunk-3Y4OFWQJ.js} +1 -1
- package/dist/chunk-3Y4OFWQJ.js.map +1 -0
- package/dist/{chunk-7LLKPODL.js → chunk-437FDIHO.js} +3 -3
- package/dist/{chunk-AMKCY454.js → chunk-47ZFULEZ.js} +8 -3
- package/dist/{chunk-AMKCY454.js.map → chunk-47ZFULEZ.js.map} +1 -1
- package/dist/{chunk-4GR422R5.js → chunk-4HVTRHSA.js} +16 -9
- package/dist/chunk-4HVTRHSA.js.map +1 -0
- package/dist/{chunk-VEA35MQP.js → chunk-5BS6IQZZ.js} +11 -14
- package/dist/chunk-5BS6IQZZ.js.map +1 -0
- package/dist/{chunk-QWNYUTI2.js → chunk-5EJQNA26.js} +2 -2
- package/dist/{chunk-C66T4W5P.js → chunk-5J5TTSGW.js} +3 -3
- package/dist/{chunk-JHYISAID.js → chunk-5JT4Y5UE.js} +10 -10
- package/dist/{chunk-VUQZYVYX.js → chunk-6S466CMQ.js} +92 -35
- package/dist/chunk-6S466CMQ.js.map +1 -0
- package/dist/{chunk-IRHOQFA7.js → chunk-7RCZ436O.js} +2 -2
- package/dist/{chunk-42IDLU5V.js → chunk-A3NTKHDB.js} +2 -2
- package/dist/{chunk-3JQVA527.js → chunk-A4K5GLE6.js} +4 -4
- package/dist/{chunk-K2MR7ROB.js → chunk-APV42WPR.js} +2 -2
- package/dist/{chunk-MVG67SMN.js → chunk-AQF7JSQR.js} +2 -2
- package/dist/{chunk-VTTRWLOR.js → chunk-BP4I7IBK.js} +2 -2
- package/dist/{chunk-T7AEAFEE.js → chunk-BTNKPDZM.js} +3 -3
- package/dist/{chunk-PCXAUC65.js → chunk-C7WJNVJG.js} +2 -2
- package/dist/{chunk-UNR6G3EJ.js → chunk-CV7WXCZD.js} +37 -33
- package/dist/chunk-CV7WXCZD.js.map +1 -0
- package/dist/{chunk-67XA44HH.js → chunk-CVYXIN5B.js} +3 -3
- package/dist/{chunk-BKYQNNO3.js → chunk-D5UDZANO.js} +203 -137
- package/dist/chunk-D5UDZANO.js.map +1 -0
- package/dist/{chunk-HVR74IBG.js → chunk-DJ23QZIN.js} +2 -2
- package/dist/{chunk-BMDF4TLU.js → chunk-DKYEVHZH.js} +7 -10
- package/dist/chunk-DKYEVHZH.js.map +1 -0
- package/dist/{chunk-N7HOHWKF.js → chunk-DYASJSKI.js} +8 -11
- package/dist/{chunk-N7HOHWKF.js.map → chunk-DYASJSKI.js.map} +1 -1
- package/dist/{chunk-OAWVM5L6.js → chunk-E6VDPBE3.js} +13 -15
- package/dist/chunk-E6VDPBE3.js.map +1 -0
- package/dist/{chunk-WBHQX6ME.js → chunk-E6WANBD6.js} +14 -15
- package/dist/chunk-E6WANBD6.js.map +1 -0
- package/dist/{chunk-VQQUOEON.js → chunk-EG6AQBYW.js} +10 -10
- package/dist/{chunk-GWI65NDQ.js → chunk-EJIVFOOQ.js} +6 -6
- package/dist/{chunk-YGJZLOSR.js → chunk-GDGTIWB4.js} +2 -2
- package/dist/{chunk-TQ7IRULX.js → chunk-GILI76SU.js} +2 -2
- package/dist/{chunk-4444HN72.js → chunk-GT72D4FO.js} +3 -3
- package/dist/{chunk-OXRPH6AR.js → chunk-GYUCRDAU.js} +15 -12
- package/dist/chunk-GYUCRDAU.js.map +1 -0
- package/dist/{chunk-JV2CNEX2.js → chunk-HGAR7H5M.js} +239 -188
- package/dist/chunk-HGAR7H5M.js.map +1 -0
- package/dist/{chunk-SGEI3IJK.js → chunk-HGJC7I5F.js} +2 -2
- package/dist/{chunk-C52CJDFO.js → chunk-HJRTFXAA.js} +7 -10
- package/dist/chunk-HJRTFXAA.js.map +1 -0
- package/dist/chunk-HK67PX4J.js +27 -0
- package/dist/chunk-HK67PX4J.js.map +1 -0
- package/dist/{chunk-V4M4BZNW.js → chunk-HTHRCGWP.js} +2 -2
- package/dist/{chunk-YVOW35HH.js → chunk-HTMQBBF3.js} +5 -7
- package/dist/chunk-HTMQBBF3.js.map +1 -0
- package/dist/{chunk-QC2HGYFX.js → chunk-HUYNPLTT.js} +4 -4
- package/dist/{chunk-APUP2J5M.js → chunk-I26TE27S.js} +7 -7
- package/dist/{chunk-DEP24EE3.js → chunk-ICCRAPWD.js} +4 -4
- package/dist/{chunk-ES36R3U2.js → chunk-IOURTXTM.js} +52 -65
- package/dist/chunk-IOURTXTM.js.map +1 -0
- package/dist/{chunk-JU3JKOY5.js → chunk-IPDS2TYW.js} +3 -3
- package/dist/{chunk-QJBXB4WU.js → chunk-JHO6FGZX.js} +25 -31
- package/dist/chunk-JHO6FGZX.js.map +1 -0
- package/dist/{chunk-YDJXGYYA.js → chunk-JIF3IBRK.js} +2 -2
- package/dist/{chunk-S6CP5FWF.js → chunk-KBOPY6W2.js} +2 -2
- package/dist/{chunk-RVTOCAHQ.js → chunk-KDX6VEYV.js} +2 -2
- package/dist/chunk-KDX6VEYV.js.map +1 -0
- package/dist/{chunk-H545OIWE.js → chunk-KM6YR5XF.js} +2 -2
- package/dist/{chunk-AFSMT3WI.js → chunk-KUXTWVAR.js} +3 -3
- package/dist/{chunk-466KGOQB.js → chunk-L2XQ776M.js} +2 -2
- package/dist/{chunk-QI2KXQOM.js → chunk-L6FSZFG7.js} +2 -2
- package/dist/{chunk-EEBMKMA7.js → chunk-LAFP5H5U.js} +35 -47
- package/dist/chunk-LAFP5H5U.js.map +1 -0
- package/dist/{chunk-I7JF5TNL.js → chunk-LBDTQM3R.js} +3 -3
- package/dist/{chunk-V3OLO4TK.js → chunk-M4IKEOJS.js} +20 -17
- package/dist/chunk-M4IKEOJS.js.map +1 -0
- package/dist/{chunk-5NKSNW25.js → chunk-MNMYHZVU.js} +2 -2
- package/dist/{chunk-IEA3TZJE.js → chunk-MNUTPZRQ.js} +31 -49
- package/dist/chunk-MNUTPZRQ.js.map +1 -0
- package/dist/{chunk-Z2OFE6IX.js → chunk-MQXYR65M.js} +15 -24
- package/dist/chunk-MQXYR65M.js.map +1 -0
- package/dist/{chunk-5VVBZ6E4.js → chunk-N2HKBESK.js} +4 -4
- package/dist/{chunk-HNOBRU24.js → chunk-N7YAQKAO.js} +2 -2
- package/dist/{chunk-6U7M7AX6.js → chunk-NH2MST6J.js} +2 -2
- package/dist/{chunk-JAHIL6WO.js → chunk-NRNTXBHT.js} +7 -10
- package/dist/chunk-NRNTXBHT.js.map +1 -0
- package/dist/{chunk-URVL4EKU.js → chunk-NYSD43OE.js} +15 -24
- package/dist/chunk-NYSD43OE.js.map +1 -0
- package/dist/{chunk-LUFZPROB.js → chunk-ODVIFBAQ.js} +16 -17
- package/dist/chunk-ODVIFBAQ.js.map +1 -0
- package/dist/{chunk-SJOK23XT.js → chunk-OIIAXFKM.js} +4 -4
- package/dist/chunk-OIIAXFKM.js.map +1 -0
- package/dist/{chunk-FSZPQCDR.js → chunk-OQLYMBJI.js} +3 -3
- package/dist/{chunk-EMFFWSAD.js → chunk-OWGEHDT2.js} +10 -10
- package/dist/chunk-OWGEHDT2.js.map +1 -0
- package/dist/{chunk-I64WQSN3.js → chunk-P7L3OQLL.js} +19 -2
- package/dist/chunk-P7L3OQLL.js.map +1 -0
- package/dist/{chunk-FZ2SSI5R.js → chunk-PG6PFMDC.js} +2 -2
- package/dist/{chunk-2RGQNFJB.js → chunk-PZSS7MUM.js} +11 -9
- package/dist/chunk-PZSS7MUM.js.map +1 -0
- package/dist/{chunk-UKKBKEUI.js → chunk-QPIUFRUC.js} +3 -3
- package/dist/{chunk-RJTGXZT6.js → chunk-REL4OLWW.js} +2 -2
- package/dist/{chunk-N4GAJSRQ.js → chunk-RNSC2ARR.js} +3 -3
- package/dist/{chunk-RWPNRCK2.js → chunk-RORE2GX2.js} +2 -2
- package/dist/{chunk-YH65A6WM.js → chunk-RSFG7XHM.js} +2 -2
- package/dist/{chunk-QLMUW7OC.js → chunk-S55DBWRC.js} +2 -2
- package/dist/{chunk-AKFNLRA2.js → chunk-SA77BQ7F.js} +27 -143
- package/dist/chunk-SA77BQ7F.js.map +1 -0
- package/dist/{chunk-RBTZLXZJ.js → chunk-SFD2LL7G.js} +2 -2
- package/dist/{chunk-XTC5EKST.js → chunk-SG3OQCRG.js} +3 -3
- package/dist/{chunk-JN64WH3U.js → chunk-T7IR4N2S.js} +1 -1
- package/dist/{chunk-JN64WH3U.js.map → chunk-T7IR4N2S.js.map} +1 -1
- package/dist/{chunk-P5ARVLNW.js → chunk-TC6MBEGH.js} +11 -8
- package/dist/chunk-TC6MBEGH.js.map +1 -0
- package/dist/{chunk-D6E5N2O3.js → chunk-TENLCGYD.js} +12 -10
- package/dist/{chunk-D6E5N2O3.js.map → chunk-TENLCGYD.js.map} +1 -1
- package/dist/{chunk-X2FXEEQT.js → chunk-VH2W6BOG.js} +7 -7
- package/dist/{chunk-FHFMWYGM.js → chunk-VHVMJWM6.js} +7 -7
- package/dist/{chunk-FHFMWYGM.js.map → chunk-VHVMJWM6.js.map} +1 -1
- package/dist/{chunk-QTDAPDDV.js → chunk-VJ4B3ZXY.js} +15 -3
- package/dist/chunk-VJ4B3ZXY.js.map +1 -0
- package/dist/{chunk-RDPZMUCX.js → chunk-W6NFONOV.js} +2 -2
- package/dist/{chunk-Z3U2YVNM.js → chunk-WBNXZU42.js} +4 -4
- package/dist/{chunk-7EIPPOEL.js → chunk-WKD5ESK4.js} +2 -2
- package/dist/{chunk-6VAM5THN.js → chunk-YEZW6UJA.js} +15 -15
- package/dist/{chunk-6VAM5THN.js.map → chunk-YEZW6UJA.js.map} +1 -1
- package/dist/chunk-YOT7D63X.js +190 -0
- package/dist/chunk-YOT7D63X.js.map +1 -0
- package/dist/{chunk-6JRIYG2C.js → chunk-YVTADFTC.js} +14 -15
- package/dist/chunk-YVTADFTC.js.map +1 -0
- package/dist/{chunk-C3YP5KKS.js → chunk-ZBDWKPBW.js} +15 -16
- package/dist/chunk-ZBDWKPBW.js.map +1 -0
- package/dist/{chunk-NWPR2V5W.js → chunk-ZPMXYPBR.js} +2 -2
- package/dist/{chunk-RGPB25DB.js → chunk-ZVAFJQZB.js} +25 -19
- package/dist/chunk-ZVAFJQZB.js.map +1 -0
- package/dist/{chunk-TQLYMYOK.js → chunk-ZWKF3CD3.js} +2 -2
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-W2PUYC3K.js → classified-marker-PMDG3O36.js} +3 -3
- package/dist/collection-facade-ZJK5EB33.js +45 -0
- package/dist/{computed-5E2OM6EN.js → computed-UHCBRILW.js} +3 -3
- package/dist/consent/index.js +9 -9
- package/dist/cover/index.js +10 -3
- package/dist/custody/index.js +11 -11
- package/dist/{dead-filter-MVFQCLXY.js → dead-filter-777VWDER.js} +2 -2
- package/dist/debug/index.js +1 -1
- package/dist/{delegation-I7XXO5LL.js → delegation-4R5DU23X.js} +23 -24
- package/dist/delegation-4R5DU23X.js.map +1 -0
- package/dist/derivations/index.js +12 -12
- package/dist/derive-3WAS2G5T.js +22 -0
- package/dist/directory/index.js +10 -10
- package/dist/{dispatch-PY5RUHJF.js → dispatch-3EN6YCCS.js} +18 -18
- package/dist/{dispatch-K3MDLCXG.js → dispatch-ASL257KG.js} +5 -5
- package/dist/{enclave-77K7UDLS.js → enclave-ZJS5R5RH.js} +17 -9
- package/dist/executor-GPM6DNWV.js +9 -0
- package/dist/executor-LJSMZ4IB.js +9 -0
- package/dist/executor-SHUVRZUJ.js +29 -0
- package/dist/export-accessible-GNY6DC6U.js +23 -0
- package/dist/extract-partition-BG3AF4NZ.js +38 -0
- package/dist/{fanout-sidecar-JI3MUPQV.js → fanout-sidecar-TFPWDOME.js} +18 -27
- package/dist/fanout-sidecar-TFPWDOME.js.map +1 -0
- package/dist/find-KX6OKHDP.js +11 -0
- package/dist/forget/index.js +9 -9
- package/dist/guards/index.js +4 -4
- package/dist/history/index.js +23 -20
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +14 -14
- package/dist/index.d.ts +16 -0
- package/dist/index.js +156 -154
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +2 -2
- package/dist/introspection/index.js +11 -11
- package/dist/issue-PAUM7NCX.js +19 -0
- package/dist/kernel/enclave/index.d.ts +6 -5
- package/dist/kernel/enclave/record-aad.d.ts +79 -7
- package/dist/kernel/enclave/record-envelope.d.ts +54 -7
- package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
- package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
- package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
- package/dist/kernel/enclave/record-keys/rekey.d.ts +8 -2
- package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -3
- package/dist/kernel/errors.d.ts +17 -1
- package/dist/kernel/merge-authority.d.ts +25 -0
- package/dist/kernel/tier-visibility.d.ts +15 -0
- package/dist/kernel/types.d.ts +8 -0
- package/dist/kernel/vault.d.ts +1 -1
- package/dist/kernel/via/index.d.ts +11 -2
- package/dist/{ledger-3RDSSMGD.js → ledger-62CEPRPX.js} +11 -11
- package/dist/liberate-7QY7TULB.js +24 -0
- package/dist/{link-set-VJIWWUZO.js → link-set-ZRYNUHN3.js} +11 -11
- package/dist/{managed-secret-XGGJ3BC3.js → managed-secret-T2WB4O47.js} +11 -3
- package/dist/materialized-views/index.js +22 -22
- package/dist/money/index.js +4 -4
- package/dist/noydb-VZIVPDXG.js +84 -0
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +12 -12
- package/dist/pod/index.js +58 -57
- package/dist/{pod-handle-7BVSWP5B.js → pod-handle-UPLXOGIK.js} +11 -11
- package/dist/{pod-handle-7BVSWP5B.js.map → pod-handle-UPLXOGIK.js.map} +1 -1
- package/dist/policy/index.js +11 -4
- package/dist/port/with/merge-authority.d.ts +52 -0
- package/dist/port/with/strategies.d.ts +2 -0
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-W3T4U57K.js → post-register-J4DEVNXK.js} +6 -6
- package/dist/query/index.js +3 -3
- package/dist/reduce/index.js +4 -4
- package/dist/register-UPD4GKBC.js +32 -0
- package/dist/registry-7KX2HWFS.js +18 -0
- package/dist/registry-PKYYEHEW.js +9 -0
- package/dist/registry-XHCYMD34.js +19 -0
- package/dist/registry-XIRTZHPC.js +9 -0
- package/dist/request-withdrawal-XZSESWZV.js +31 -0
- package/dist/{reveal-G7W7N3AZ.js → reveal-525XWQU2.js} +6 -6
- package/dist/revoke-QI7YHQ2B.js +24 -0
- package/dist/satellites/index.js +1 -1
- package/dist/schema-update/index.js +2 -2
- package/dist/sealed-record/index.js +20 -13
- package/dist/sealed-record/index.js.map +1 -1
- package/dist/search/index.js +4 -4
- package/dist/{seed-2FUULTQV.js → seed-2KZDTFS4.js} +19 -22
- package/dist/seed-2KZDTFS4.js.map +1 -0
- package/dist/sequence/index.js +9 -9
- package/dist/session/index.js +9 -9
- package/dist/shadow/index.js +2 -2
- package/dist/signer-BZWDPGGN.js +25 -0
- package/dist/snapshots/index.js +10 -10
- package/dist/{stale-42FPALK2.js → stale-PQYPVCER.js} +10 -10
- package/dist/storage-MJHKNQRO.js +23 -0
- package/dist/{store-coordination-provider-Y3VXBHPL.js → store-coordination-provider-TFHZLKHG.js} +18 -12
- package/dist/store-coordination-provider-TFHZLKHG.js.map +1 -0
- package/dist/sync/index.js +11 -11
- package/dist/team/index.js +15 -14
- package/dist/tiers/index.js +11 -10
- package/dist/to/index.js +1 -1
- package/dist/transactions/index.js +3 -3
- package/dist/util/index.js +1 -1
- package/dist/vault-head/index.js +111 -0
- package/dist/vault-head/index.js.map +1 -0
- package/dist/{verify-SHJXGZGM.js → verify-J6DEOXP3.js} +5 -5
- package/dist/walk-BX4NSB5L.js +21 -0
- package/dist/with-audit/periods/periods.d.ts +1 -1
- package/dist/with-audit/periods/strategy.d.ts +1 -1
- package/dist/with-audit/sealed-record/index.d.ts +13 -0
- package/dist/with-audit/tiers/index.d.ts +17 -2
- package/dist/with-commit/history/history.d.ts +26 -0
- package/dist/with-commit/history/index.d.ts +2 -1
- package/dist/with-commit/history/ledger/store.d.ts +7 -1
- package/dist/with-commit/history/strategy.d.ts +11 -1
- package/dist/with-commit/vault-head/active.d.ts +2 -0
- package/dist/with-commit/vault-head/head.d.ts +28 -0
- package/dist/with-commit/vault-head/index.d.ts +10 -0
- package/dist/with-commit/vault-head/strategy.d.ts +127 -0
- package/dist/with-commit/vault-head/verify.d.ts +50 -0
- package/dist/with-party/directory/cover/storage.d.ts +0 -8
- package/dist/with-party/directory/storage.d.ts +0 -11
- package/dist/with-party/directory/visibility.d.ts +0 -21
- package/dist/with-party/policy/storage.d.ts +0 -10
- package/dist/with-party/team/tiers.d.ts +2 -1
- package/dist/with-sync/engine.d.ts +33 -5
- package/dist/with-sync/strategy.d.ts +3 -0
- package/dist/withdraw-accessible-K4CPMH4C.js +28 -0
- package/package.json +7 -3
- package/dist/api-AEIN3KAQ.js +0 -20
- package/dist/chunk-2RGQNFJB.js.map +0 -1
- package/dist/chunk-4GR422R5.js.map +0 -1
- package/dist/chunk-5UGEGEIJ.js.map +0 -1
- package/dist/chunk-6JRIYG2C.js.map +0 -1
- package/dist/chunk-7TZTQS4H.js.map +0 -1
- package/dist/chunk-AFHQATY4.js +0 -47
- package/dist/chunk-AFHQATY4.js.map +0 -1
- package/dist/chunk-AKFNLRA2.js.map +0 -1
- package/dist/chunk-BKYQNNO3.js.map +0 -1
- package/dist/chunk-BMDF4TLU.js.map +0 -1
- package/dist/chunk-C3YP5KKS.js.map +0 -1
- package/dist/chunk-C52CJDFO.js.map +0 -1
- package/dist/chunk-EEBMKMA7.js.map +0 -1
- package/dist/chunk-EMFFWSAD.js.map +0 -1
- package/dist/chunk-ES36R3U2.js.map +0 -1
- package/dist/chunk-I64WQSN3.js.map +0 -1
- package/dist/chunk-IEA3TZJE.js.map +0 -1
- package/dist/chunk-JAHIL6WO.js.map +0 -1
- package/dist/chunk-JV2CNEX2.js.map +0 -1
- package/dist/chunk-LUFZPROB.js.map +0 -1
- package/dist/chunk-OAWVM5L6.js.map +0 -1
- package/dist/chunk-OXRPH6AR.js.map +0 -1
- package/dist/chunk-P5ARVLNW.js.map +0 -1
- package/dist/chunk-QJBXB4WU.js.map +0 -1
- package/dist/chunk-QKRJUPAC.js.map +0 -1
- package/dist/chunk-QTDAPDDV.js.map +0 -1
- package/dist/chunk-RGPB25DB.js.map +0 -1
- package/dist/chunk-RVTOCAHQ.js.map +0 -1
- package/dist/chunk-SJOK23XT.js.map +0 -1
- package/dist/chunk-UNR6G3EJ.js.map +0 -1
- package/dist/chunk-URVL4EKU.js.map +0 -1
- package/dist/chunk-V3OLO4TK.js.map +0 -1
- package/dist/chunk-VEA35MQP.js.map +0 -1
- package/dist/chunk-VUQZYVYX.js.map +0 -1
- package/dist/chunk-WBHQX6ME.js.map +0 -1
- package/dist/chunk-YVOW35HH.js.map +0 -1
- package/dist/chunk-Z2OFE6IX.js.map +0 -1
- package/dist/collection-facade-CRXN72DU.js +0 -45
- package/dist/delegation-I7XXO5LL.js.map +0 -1
- package/dist/derive-NL7X2EFT.js +0 -22
- package/dist/executor-FNGVGDW3.js +0 -29
- package/dist/executor-PCZN2LTY.js +0 -9
- package/dist/executor-WFTHIDT7.js +0 -9
- package/dist/export-accessible-QWUYY2OY.js +0 -23
- package/dist/extract-partition-CGCURVS4.js +0 -38
- package/dist/fanout-sidecar-JI3MUPQV.js.map +0 -1
- package/dist/find-VBNMB42N.js +0 -11
- package/dist/issue-7IPUNAFA.js +0 -19
- package/dist/liberate-2DNJ7AJ7.js +0 -24
- package/dist/noydb-CLQP36JR.js +0 -83
- package/dist/register-YUVC4G27.js +0 -32
- package/dist/registry-BPKJX562.js +0 -19
- package/dist/registry-E4FM32KD.js +0 -9
- package/dist/registry-HACMULJJ.js +0 -9
- package/dist/registry-HRFRBFDV.js +0 -18
- package/dist/request-withdrawal-CXTQLMJK.js +0 -31
- package/dist/revoke-ZX3TZUI6.js +0 -24
- package/dist/seed-2FUULTQV.js.map +0 -1
- package/dist/signer-FPUIX63Z.js +0 -25
- package/dist/storage-6QODT6K5.js +0 -23
- package/dist/store-coordination-provider-Y3VXBHPL.js.map +0 -1
- package/dist/walk-5PGJI3ND.js +0 -21
- package/dist/withdraw-accessible-PFCQQGNP.js +0 -28
- /package/dist/{api-AEIN3KAQ.js.map → api-Z5VHH24A.js.map} +0 -0
- /package/dist/{chunk-5SK5AFYH.js.map → chunk-2E2MKBMI.js.map} +0 -0
- /package/dist/{chunk-7LLKPODL.js.map → chunk-437FDIHO.js.map} +0 -0
- /package/dist/{chunk-QWNYUTI2.js.map → chunk-5EJQNA26.js.map} +0 -0
- /package/dist/{chunk-C66T4W5P.js.map → chunk-5J5TTSGW.js.map} +0 -0
- /package/dist/{chunk-JHYISAID.js.map → chunk-5JT4Y5UE.js.map} +0 -0
- /package/dist/{chunk-IRHOQFA7.js.map → chunk-7RCZ436O.js.map} +0 -0
- /package/dist/{chunk-42IDLU5V.js.map → chunk-A3NTKHDB.js.map} +0 -0
- /package/dist/{chunk-3JQVA527.js.map → chunk-A4K5GLE6.js.map} +0 -0
- /package/dist/{chunk-K2MR7ROB.js.map → chunk-APV42WPR.js.map} +0 -0
- /package/dist/{chunk-MVG67SMN.js.map → chunk-AQF7JSQR.js.map} +0 -0
- /package/dist/{chunk-VTTRWLOR.js.map → chunk-BP4I7IBK.js.map} +0 -0
- /package/dist/{chunk-T7AEAFEE.js.map → chunk-BTNKPDZM.js.map} +0 -0
- /package/dist/{chunk-PCXAUC65.js.map → chunk-C7WJNVJG.js.map} +0 -0
- /package/dist/{chunk-67XA44HH.js.map → chunk-CVYXIN5B.js.map} +0 -0
- /package/dist/{chunk-HVR74IBG.js.map → chunk-DJ23QZIN.js.map} +0 -0
- /package/dist/{chunk-VQQUOEON.js.map → chunk-EG6AQBYW.js.map} +0 -0
- /package/dist/{chunk-GWI65NDQ.js.map → chunk-EJIVFOOQ.js.map} +0 -0
- /package/dist/{chunk-YGJZLOSR.js.map → chunk-GDGTIWB4.js.map} +0 -0
- /package/dist/{chunk-TQ7IRULX.js.map → chunk-GILI76SU.js.map} +0 -0
- /package/dist/{chunk-4444HN72.js.map → chunk-GT72D4FO.js.map} +0 -0
- /package/dist/{chunk-SGEI3IJK.js.map → chunk-HGJC7I5F.js.map} +0 -0
- /package/dist/{chunk-V4M4BZNW.js.map → chunk-HTHRCGWP.js.map} +0 -0
- /package/dist/{chunk-QC2HGYFX.js.map → chunk-HUYNPLTT.js.map} +0 -0
- /package/dist/{chunk-APUP2J5M.js.map → chunk-I26TE27S.js.map} +0 -0
- /package/dist/{chunk-DEP24EE3.js.map → chunk-ICCRAPWD.js.map} +0 -0
- /package/dist/{chunk-JU3JKOY5.js.map → chunk-IPDS2TYW.js.map} +0 -0
- /package/dist/{chunk-YDJXGYYA.js.map → chunk-JIF3IBRK.js.map} +0 -0
- /package/dist/{chunk-S6CP5FWF.js.map → chunk-KBOPY6W2.js.map} +0 -0
- /package/dist/{chunk-H545OIWE.js.map → chunk-KM6YR5XF.js.map} +0 -0
- /package/dist/{chunk-AFSMT3WI.js.map → chunk-KUXTWVAR.js.map} +0 -0
- /package/dist/{chunk-466KGOQB.js.map → chunk-L2XQ776M.js.map} +0 -0
- /package/dist/{chunk-QI2KXQOM.js.map → chunk-L6FSZFG7.js.map} +0 -0
- /package/dist/{chunk-I7JF5TNL.js.map → chunk-LBDTQM3R.js.map} +0 -0
- /package/dist/{chunk-5NKSNW25.js.map → chunk-MNMYHZVU.js.map} +0 -0
- /package/dist/{chunk-5VVBZ6E4.js.map → chunk-N2HKBESK.js.map} +0 -0
- /package/dist/{chunk-HNOBRU24.js.map → chunk-N7YAQKAO.js.map} +0 -0
- /package/dist/{chunk-6U7M7AX6.js.map → chunk-NH2MST6J.js.map} +0 -0
- /package/dist/{chunk-FSZPQCDR.js.map → chunk-OQLYMBJI.js.map} +0 -0
- /package/dist/{chunk-FZ2SSI5R.js.map → chunk-PG6PFMDC.js.map} +0 -0
- /package/dist/{chunk-UKKBKEUI.js.map → chunk-QPIUFRUC.js.map} +0 -0
- /package/dist/{chunk-RJTGXZT6.js.map → chunk-REL4OLWW.js.map} +0 -0
- /package/dist/{chunk-N4GAJSRQ.js.map → chunk-RNSC2ARR.js.map} +0 -0
- /package/dist/{chunk-RWPNRCK2.js.map → chunk-RORE2GX2.js.map} +0 -0
- /package/dist/{chunk-YH65A6WM.js.map → chunk-RSFG7XHM.js.map} +0 -0
- /package/dist/{chunk-QLMUW7OC.js.map → chunk-S55DBWRC.js.map} +0 -0
- /package/dist/{chunk-RBTZLXZJ.js.map → chunk-SFD2LL7G.js.map} +0 -0
- /package/dist/{chunk-XTC5EKST.js.map → chunk-SG3OQCRG.js.map} +0 -0
- /package/dist/{chunk-X2FXEEQT.js.map → chunk-VH2W6BOG.js.map} +0 -0
- /package/dist/{chunk-RDPZMUCX.js.map → chunk-W6NFONOV.js.map} +0 -0
- /package/dist/{chunk-Z3U2YVNM.js.map → chunk-WBNXZU42.js.map} +0 -0
- /package/dist/{chunk-7EIPPOEL.js.map → chunk-WKD5ESK4.js.map} +0 -0
- /package/dist/{chunk-NWPR2V5W.js.map → chunk-ZPMXYPBR.js.map} +0 -0
- /package/dist/{chunk-TQLYMYOK.js.map → chunk-ZWKF3CD3.js.map} +0 -0
- /package/dist/{classified-marker-W2PUYC3K.js.map → classified-marker-PMDG3O36.js.map} +0 -0
- /package/dist/{collection-facade-CRXN72DU.js.map → collection-facade-ZJK5EB33.js.map} +0 -0
- /package/dist/{computed-5E2OM6EN.js.map → computed-UHCBRILW.js.map} +0 -0
- /package/dist/{dead-filter-MVFQCLXY.js.map → dead-filter-777VWDER.js.map} +0 -0
- /package/dist/{derive-NL7X2EFT.js.map → derive-3WAS2G5T.js.map} +0 -0
- /package/dist/{dispatch-PY5RUHJF.js.map → dispatch-3EN6YCCS.js.map} +0 -0
- /package/dist/{dispatch-K3MDLCXG.js.map → dispatch-ASL257KG.js.map} +0 -0
- /package/dist/{enclave-77K7UDLS.js.map → enclave-ZJS5R5RH.js.map} +0 -0
- /package/dist/{executor-FNGVGDW3.js.map → executor-GPM6DNWV.js.map} +0 -0
- /package/dist/{executor-PCZN2LTY.js.map → executor-LJSMZ4IB.js.map} +0 -0
- /package/dist/{executor-WFTHIDT7.js.map → executor-SHUVRZUJ.js.map} +0 -0
- /package/dist/{export-accessible-QWUYY2OY.js.map → export-accessible-GNY6DC6U.js.map} +0 -0
- /package/dist/{extract-partition-CGCURVS4.js.map → extract-partition-BG3AF4NZ.js.map} +0 -0
- /package/dist/{find-VBNMB42N.js.map → find-KX6OKHDP.js.map} +0 -0
- /package/dist/{issue-7IPUNAFA.js.map → issue-PAUM7NCX.js.map} +0 -0
- /package/dist/{ledger-3RDSSMGD.js.map → ledger-62CEPRPX.js.map} +0 -0
- /package/dist/{liberate-2DNJ7AJ7.js.map → liberate-7QY7TULB.js.map} +0 -0
- /package/dist/{link-set-VJIWWUZO.js.map → link-set-ZRYNUHN3.js.map} +0 -0
- /package/dist/{managed-secret-XGGJ3BC3.js.map → managed-secret-T2WB4O47.js.map} +0 -0
- /package/dist/{noydb-CLQP36JR.js.map → noydb-VZIVPDXG.js.map} +0 -0
- /package/dist/{post-register-W3T4U57K.js.map → post-register-J4DEVNXK.js.map} +0 -0
- /package/dist/{register-YUVC4G27.js.map → register-UPD4GKBC.js.map} +0 -0
- /package/dist/{registry-BPKJX562.js.map → registry-7KX2HWFS.js.map} +0 -0
- /package/dist/{registry-E4FM32KD.js.map → registry-PKYYEHEW.js.map} +0 -0
- /package/dist/{registry-HACMULJJ.js.map → registry-XHCYMD34.js.map} +0 -0
- /package/dist/{registry-HRFRBFDV.js.map → registry-XIRTZHPC.js.map} +0 -0
- /package/dist/{request-withdrawal-CXTQLMJK.js.map → request-withdrawal-XZSESWZV.js.map} +0 -0
- /package/dist/{reveal-G7W7N3AZ.js.map → reveal-525XWQU2.js.map} +0 -0
- /package/dist/{revoke-ZX3TZUI6.js.map → revoke-QI7YHQ2B.js.map} +0 -0
- /package/dist/{signer-FPUIX63Z.js.map → signer-BZWDPGGN.js.map} +0 -0
- /package/dist/{stale-42FPALK2.js.map → stale-PQYPVCER.js.map} +0 -0
- /package/dist/{storage-6QODT6K5.js.map → storage-MJHKNQRO.js.map} +0 -0
- /package/dist/{verify-SHJXGZGM.js.map → verify-J6DEOXP3.js.map} +0 -0
- /package/dist/{walk-5PGJI3ND.js.map → walk-BX4NSB5L.js.map} +0 -0
- /package/dist/{withdraw-accessible-PFCQQGNP.js.map → withdraw-accessible-K4CPMH4C.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-commit/history/history.ts","../src/with-commit/history/strategy.ts"],"sourcesContent":["import { buildRecordEnvelope } from '../../kernel/enclave/index.js'\nimport type { RecordIdentity } from '../../kernel/enclave/index.js'\nimport type { NoydbStore, EncryptedEnvelope, HistoryOptions, PruneOptions } from '../../kernel/types.js'\nimport { isTombstone, isTombstoneShape, rewrapEnvelope, isRewrappedUnder, type EnclaveKey } from '../../kernel/enclave/index.js'\n\n/**\n * History storage convention:\n * Collection: `_history`\n * ID format: `{collection}:{recordId}:{paddedVersion}`\n * Version is zero-padded to 10 digits for lexicographic sorting.\n */\n\nconst HISTORY_COLLECTION = '_history'\nconst VERSION_PAD = 10\n\nfunction historyId(collection: string, recordId: string, version: number): string {\n return `${collection}:${recordId}:${String(version).padStart(VERSION_PAD, '0')}`\n}\n\n/**\n * The identity a history snapshot is **sealed against** — its STORAGE location,\n * not the live record it is a copy of (#1041).\n *\n * ## Why storage, and why this is a decision rather than a detail\n *\n * A snapshot is a copy, so two identities are available: the live record\n * (`collection`/`recordId`) or where the bytes actually land\n * (`_history`/`historyId(...)`). They are not equivalent under attack.\n *\n * Binding the LIVE identity makes a snapshot's AAD **indistinguishable from the\n * live record's at the same version** — so an untrusted store could serve a\n * history entry *as the current record* and the client would accept it. It also\n * leaves entries relocatable within `_history`.\n *\n * Binding STORAGE identity closes both. The cost is that the id must be known\n * *before* the envelope is sealed, where `saveHistory` previously derived it\n * *after* (from `envelope._v`) — which is precisely the restructure this\n * function exists to make possible.\n *\n * `saveHistory` uses this too, so the sealed identity and the put location have\n * **one definition** and cannot drift apart. Changing the layout here changes\n * both at once, by construction.\n */\nexport function historyIdentity(collection: string, recordId: string, version: number): RecordIdentity {\n // The snapshot's own `_v` IS the version it preserves — the same number that\n // appears in its id. One argument feeds both, so they cannot disagree (#1093).\n return { collection: HISTORY_COLLECTION, id: historyId(collection, recordId, version), version }\n}\n\n// Unused today, kept for future history-id parsing utilities.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction parseHistoryId(id: string): { collection: string; recordId: string; version: number } | null {\n const lastColon = id.lastIndexOf(':')\n if (lastColon < 0) return null\n const versionStr = id.slice(lastColon + 1)\n const rest = id.slice(0, lastColon)\n const firstColon = rest.indexOf(':')\n if (firstColon < 0) return null\n return {\n collection: rest.slice(0, firstColon),\n recordId: rest.slice(firstColon + 1),\n version: parseInt(versionStr, 10),\n }\n}\n\nfunction matchesPrefix(id: string, collection: string, recordId?: string): boolean {\n if (recordId) {\n return id.startsWith(`${collection}:${recordId}:`)\n }\n return id.startsWith(`${collection}:`)\n}\n\n/** Save a history entry (a complete encrypted envelope snapshot). */\nexport async function saveHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n envelope: EncryptedEnvelope,\n): Promise<void> {\n // Same derivation the caller sealed against — one definition, so the sealed\n // identity and the put location cannot drift (#1041).\n const { id } = historyIdentity(collection, recordId, envelope._v)\n await adapter.put(vault, HISTORY_COLLECTION, id, envelope)\n}\n\n/** Get history entries for a record, sorted newest-first. */\nexport async function getHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n options?: HistoryOptions,\n): Promise<EncryptedEnvelope[]> {\n const allIds = await adapter.list(vault, HISTORY_COLLECTION)\n const matchingIds = allIds\n .filter(id => matchesPrefix(id, collection, recordId))\n .sort()\n .reverse() // newest first\n\n const entries: EncryptedEnvelope[] = []\n\n for (const id of matchingIds) {\n const envelope = await adapter.get(vault, HISTORY_COLLECTION, id)\n if (!envelope) continue\n\n // Apply time filters\n if (options?.from && envelope._ts < options.from) continue\n if (options?.to && envelope._ts > options.to) continue\n\n entries.push(envelope)\n\n if (options?.limit && entries.length >= options.limit) break\n }\n\n return entries\n}\n\n/** Get a specific version's envelope from history. */\nexport async function getVersionEnvelope(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n version: number,\n): Promise<EncryptedEnvelope | null> {\n const id = historyId(collection, recordId, version)\n return adapter.get(vault, HISTORY_COLLECTION, id)\n}\n\n/** Prune history entries. Returns the number of entries deleted. */\nexport async function pruneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string | undefined,\n options: PruneOptions,\n): Promise<number> {\n const allIds = await adapter.list(vault, HISTORY_COLLECTION)\n const matchingIds = allIds\n .filter(id => recordId ? matchesPrefix(id, collection, recordId) : matchesPrefix(id, collection))\n .sort()\n\n let toDelete: string[] = []\n\n if (options.keepVersions !== undefined) {\n // Keep only the N most recent, delete the rest\n const keep = options.keepVersions\n if (matchingIds.length > keep) {\n toDelete = matchingIds.slice(0, matchingIds.length - keep)\n }\n }\n\n if (options.beforeDate) {\n // Delete entries older than the specified date\n for (const id of matchingIds) {\n if (toDelete.includes(id)) continue\n const envelope = await adapter.get(vault, HISTORY_COLLECTION, id)\n if (envelope && envelope._ts < options.beforeDate) {\n toDelete.push(id)\n }\n }\n }\n\n // Deduplicate\n const uniqueDeletes = [...new Set(toDelete)]\n\n for (const id of uniqueDeletes) {\n await adapter.delete(vault, HISTORY_COLLECTION, id)\n }\n\n return uniqueDeletes.length\n}\n\n/** Clear all history for a vault, optionally scoped to a collection or record. */\nexport async function clearHistory(\n adapter: NoydbStore,\n vault: string,\n collection?: string,\n recordId?: string,\n): Promise<number> {\n const allIds = await adapter.list(vault, HISTORY_COLLECTION)\n let toDelete: string[]\n\n if (collection && recordId) {\n toDelete = allIds.filter(id => matchesPrefix(id, collection, recordId))\n } else if (collection) {\n toDelete = allIds.filter(id => matchesPrefix(id, collection))\n } else {\n toDelete = allIds\n }\n\n for (const id of toDelete) {\n await adapter.delete(vault, HISTORY_COLLECTION, id)\n }\n\n return toDelete.length\n}\n\n/**\n * Crypto-shred every `_history` version of a record. Each non-tombstone\n * history envelope is OVERWRITTEN in place with a tombstone\n * `{ _noydb, _v, _ts: now, _by: actor, _iv: '', _data: '' }` — dropping\n * `_iv`/`_data`/`_cek`/`_det`, so the prior ciphertext (and the wrapped CEK\n * that could decrypt it) is gone everywhere this store reaches. The version\n * counter (`_v`) is preserved so the audit trail still shows \"N versions\n * existed and were erased.\"\n *\n * Overwrite — NOT delete — so the history key itself survives as proof the\n * version existed. Already-tombstoned versions (re-run / idempotent forget)\n * are left untouched and not counted.\n *\n * Returns the number of history versions newly tombstoned.\n */\nexport async function tombstoneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n actor: string,\n encrypted: boolean,\n): Promise<number> {\n const allIds = await adapter.list(vault, HISTORY_COLLECTION)\n const matchingIds = allIds.filter(id => matchesPrefix(id, collection, recordId))\n\n const now = new Date().toISOString()\n let count = 0\n for (const id of matchingIds) {\n const env = await adapter.get(vault, HISTORY_COLLECTION, id)\n if (!env) continue\n // Already a tombstone (no body and no wrapped CEK)? Skip — idempotent.\n if (isTombstone(env, encrypted)) continue\n // `by` rides on the IDENTITY — passing it in the body went through a\n // conditional spread, which TypeScript does not excess-property-check, so\n // it was silently dropped once `_by` moved to the identity (#1041).\n const tombstone: EncryptedEnvelope = buildRecordEnvelope(\n { collection: HISTORY_COLLECTION, id, ...(actor ? { by: actor } : {}), version: env._v },\n { ts: now, iv: '', data: '' },\n )\n await adapter.put(vault, HISTORY_COLLECTION, id, tombstone)\n count++\n }\n return count\n}\n\n/**\n * Re-key every `_history` snapshot of a record from `fromDek` to `toDek`.\n * Mirrors what `rewrapBodyToDek` already does for a record's LIVE body on a\n * tier move (elevate/demote/putAtTier) — each `_history` envelope also\n * carries its own `_cek`, wrapped under the collection's tier-0 DEK at write\n * time (`record-codec.ts`), so a tier move that rewraps only the live\n * envelope leaves prior versions decryptable at rest under the tier the\n * record left. This is defense-in-depth *beneath* the read-gate\n * (`history()`/`getVersion()` already return empty for an elevated record;\n * this protects the ciphertext even if that gate is bypassed).\n *\n * Rewraps content in place — unlike `tombstoneHistory`, it does NOT blank\n * `_iv`/`_data`/`_cek` — so a subsequent `demote()` restores tier-0\n * readability. Tombstone-shaped entries (a forgotten/shredded version —\n * blanked `_data`, no `_cek`) are skipped: there is no key material left to\n * rewrap.\n *\n * **Legacy fallback.** A snapshot written before this fix stays wrapped\n * under the tier-0 DEK even after its live record has since moved tiers, so\n * a rewrap attempted with a tier-N `fromDek` fails to unwrap/decrypt. When\n * the caller supplies `tier0Dek`, a failed rewrap is retried once with\n * `tier0Dek` as `fromDek` (the only other key a pre-fix snapshot can be\n * wrapped under — history is written only by tier-0 `put()`). The output is\n * always wrapped under `toDek` regardless of which `fromDek` succeeded. A\n * rewrap that fails under BOTH keys re-throws — that is real corruption, not\n * a tier mismatch, and must not be swallowed.\n *\n * **Crash-atomicity / idempotency (#712 whole-branch-fix-3).** This loop has\n * no transaction around it: a crash after some entries have been rewritten\n * under `toDek` but before the loop finishes leaves the record's history\n * split across two keys. A retry of the SAME call must not re-fail on the\n * entries that already made it — so each entry is probed with\n * `isRewrappedUnder(env, toDek)` FIRST; a match means it's already at the\n * target key and is skipped (put nothing). This makes same-target retries\n * and demote-after-crash fully self-healing. It does NOT close every crash\n * window: a crash that lands SOME entries under `toDek` while the record's\n * NEXT move target differs from this call's `toDek` (an intermediate-tier\n * crash — e.g. elevate 0→1 crashes mid-loop, then the record is moved 1→2)\n * still finds those entries unreadable under either `fromDek` or the\n * tier-0 fallback, since `toDek` is a third key the next call never probes\n * for. That residual window is an accepted, fail-closed limitation (see\n * `.changeset/history-at-rest.md` and the design doc) — availability is\n * lost, never confidentiality.\n */\nexport async function rewrapHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n fromDek: EnclaveKey,\n toDek: EnclaveKey,\n tier0Dek?: EnclaveKey,\n): Promise<void> {\n const allIds = await adapter.list(vault, HISTORY_COLLECTION)\n const matchingIds = allIds.filter(id => matchesPrefix(id, collection, recordId))\n\n for (const id of matchingIds) {\n const env = await adapter.get(vault, HISTORY_COLLECTION, id)\n if (!env) continue\n // Already a tombstone (forgotten/shredded version)? Nothing to rewrap.\n if (isTombstoneShape(env)) continue\n // #712/whole-branch-fix-3: toDek-first idempotency skip — already at the\n // target key (a same-target retry, or demote-after-crash landing back on\n // a key it already reached)? Nothing to do; put nothing.\n // In-place re-key of a `_history` entry: the address does not move, so the\n // same identity opens and re-seals it (#1041). Built from the entry itself,\n // exactly as a reader would via `recordAadFor`.\n const identity = {\n collection: HISTORY_COLLECTION, id, version: env._v,\n ...(env._tier !== undefined ? { tier: env._tier } : {}),\n ...(env._by !== undefined ? { by: env._by } : {}),\n }\n if (await isRewrappedUnder(identity, env, toDek)) continue\n\n let next: EncryptedEnvelope\n try {\n next = await rewrapEnvelope(identity, env, fromDek, toDek)\n } catch (err) {\n if (!tier0Dek) throw err\n // Legacy fallback: retry once under the tier-0 DEK. A failure here is\n // real corruption, not a tier mismatch — let it propagate.\n next = await rewrapEnvelope(identity, env, tier0Dek, toDek)\n }\n\n await adapter.put(vault, HISTORY_COLLECTION, id, next)\n }\n}\n","/**\n * Strategy seam for the optional history + ledger + time-machine\n * service. Core imports `HistoryStrategy` type-only + `NO_HISTORY`\n * stub; real implementations of `saveHistory`, `LedgerStore`,\n * `VaultInstant`, `computePatch`, `diff` etc. are only reachable via\n * `withHistory()` in `./active.ts`.\n *\n * Applications that don't track per-record versioning, don't need the\n * hash-chained audit ledger, and don't restore to past instants ship\n * none of the ~1,880 LOC behind this seam.\n *\n * Strategy contract:\n *\n * - **saveHistory / pruneHistory / clearHistory** — no-ops under\n * NO_HISTORY. Writes still succeed; no snapshot is captured.\n * - **getHistoryEntries / getVersionEnvelope / diff** — throw under\n * NO_HISTORY. These are read APIs the consumer would only call\n * after explicitly asking for history; the throw guides them to\n * `@noy-db/hub/history`.\n * - **envelopePayloadHash / computePatch** — return empty / `[]`\n * under NO_HISTORY. These are only used inside the\n * `if (this.ledger)` branch, which is itself gated by\n * `buildLedger()` returning null.\n * - **buildLedger** — returns `null` under NO_HISTORY. The Vault's\n * public `vault.ledger()` accessor throws when null.\n * - **buildVaultInstant** — throws under NO_HISTORY. `vault.at()`\n * propagates the throw.\n *\n * @internal\n */\n\nimport type {\n EncryptedEnvelope,\n NoydbStore,\n HistoryOptions,\n PruneOptions,\n} from '../../kernel/types.js'\nimport type { LedgerStore } from './ledger/store.js'\nimport type { JsonPatch } from './ledger/patch.js'\nimport type { DiffEntry } from './diff.js'\nimport type { VaultInstant, VaultEngine } from './time-machine.js'\nimport type { EnclaveKey, RecordIdentity } from '../../kernel/enclave/index.js'\nimport { historyIdentity } from './history.js'\n\n/**\n * Options accepted by `HistoryStrategy.buildLedger`. Mirrors the\n * `LedgerStore` constructor verbatim — kept in this file so `core`\n * code never imports the LedgerStore module at runtime.\n *\n * @internal\n */\nexport interface BuildLedgerOptions {\n adapter: NoydbStore\n vault: string\n encrypted: boolean\n getDEK: (collectionName: string) => Promise<EnclaveKey>\n actor: string\n}\n\n/**\n * @internal\n */\nexport interface HistoryStrategy {\n /**\n * Persist a full encrypted envelope snapshot of the prior version\n * under `_history/{collection}:{id}:{paddedVersion}`. No-op under\n * `NO_HISTORY`.\n */\n saveHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n envelope: EncryptedEnvelope,\n ): Promise<void>\n\n /**\n * The identity a snapshot of `collection/recordId@version` must be **sealed\n * against** — its `_history` storage location (#1041).\n *\n * On the port because the kernel writes history snapshots but must not import\n * `with-commit` to learn its layout. Exposing it here keeps the derivation in\n * the module that owns the layout, and `saveHistory` uses the same function,\n * so the sealed identity and the put location cannot drift.\n */\n historyIdentity(collection: string, recordId: string, version: number): RecordIdentity\n\n /**\n * List history envelopes for a record, newest first. Throws under\n * `NO_HISTORY` — callers reach this via `collection.history()` /\n * `collection.getVersion()` / `collection.diff()`, which only work\n * with the strategy enabled.\n */\n getHistoryEntries(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n options?: HistoryOptions,\n ): Promise<EncryptedEnvelope[]>\n\n /**\n * Fetch a specific version's envelope. Throws under `NO_HISTORY`.\n */\n getVersionEnvelope(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n version: number,\n ): Promise<EncryptedEnvelope | null>\n\n /**\n * Prune history entries by retention rule. Returns `0` under\n * `NO_HISTORY`.\n */\n pruneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string | undefined,\n options: PruneOptions,\n ): Promise<number>\n\n /**\n * Clear all history for vault/collection/record. Returns `0` under\n * `NO_HISTORY`.\n */\n clearHistory(\n adapter: NoydbStore,\n vault: string,\n collection?: string,\n recordId?: string,\n ): Promise<number>\n\n /**\n * Crypto-shred (overwrite-to-tombstone) every `_history` version of a\n * record for GDPR erasure. Returns the number of versions newly\n * tombstoned, or `0` under `NO_HISTORY` (no history = nothing to shred).\n */\n tombstoneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n actor: string,\n encrypted: boolean,\n ): Promise<number>\n\n /**\n * Re-key every `_history` snapshot of a record from `fromDek` to `toDek`\n * on a tier move (elevate/demote/putAtTier), mirroring the live-body\n * rewrap so prior versions are not left decryptable at rest under a tier\n * the record has moved away from. Optional `tier0Dek` enables the legacy\n * fallback for snapshots written before this rewrap existed (see\n * `history.ts` for the full contract). No-op under `NO_HISTORY` (no\n * history = nothing to rewrap).\n */\n rewrapHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n fromDek: EnclaveKey,\n toDek: EnclaveKey,\n tier0Dek?: EnclaveKey,\n ): Promise<void>\n\n /**\n * Compute the SHA-256 hash of an envelope's encrypted payload, used\n * by `LedgerStore.append` to track tamper-evidence. Returns the\n * empty string under `NO_HISTORY` (the call site is gated by\n * `if (this.ledger)`, so the value is never observed).\n */\n envelopePayloadHash(envelope: EncryptedEnvelope | null): Promise<string>\n\n /**\n * Compute the JSON patch from `from` → `to`. Returns `[]` under\n * `NO_HISTORY`.\n */\n computePatch(from: unknown, to: unknown): JsonPatch\n\n /**\n * Compute the typed diff between two records. Throws under\n * `NO_HISTORY` — `collection.diff()` is a history-read API.\n */\n diff(recordA: unknown, recordB: unknown): DiffEntry[]\n\n /**\n * Construct (or return null) a `LedgerStore` for the vault. Returns\n * `null` under `NO_HISTORY`; the Vault treats null as \"no ledger\n * attached\" — collection write paths skip the append branch and the\n * public `vault.ledger()` accessor throws.\n */\n buildLedger(opts: BuildLedgerOptions): LedgerStore | null\n\n /**\n * Construct a `VaultInstant` for time-machine reads. Throws under\n * `NO_HISTORY`.\n */\n buildVaultInstant(engine: VaultEngine, timestamp: string): VaultInstant\n}\n\n/**\n * Error thrown when the consumer reaches a history-gated surface\n * without opting into the strategy. The message names the offending\n * operation and points to the subpath import.\n *\n * @internal\n */\nfunction notEnabled(op: string): Error {\n return new Error(\n `${op} requires the history strategy. Import ` +\n '`{ withHistory }` from \"@noy-db/hub/history\" and pass it to ' +\n '`createNoydb({ historyStrategy: withHistory() })`.',\n )\n}\n\n/**\n * No-history stub. Snapshots and prune/clear are no-ops; reads and\n * time-machine throw with an actionable message; ledger construction\n * returns null so the write-path's `if (this.ledger)` branch is dead\n * code in the bundle.\n *\n * @internal\n */\nexport const NO_HISTORY: HistoryStrategy = {\n async saveHistory() {},\n // Unreachable in practice — `saveHistory` above is a no-op, so nothing is\n // ever sealed. Returns the real layout rather than a sentinel so a future\n // caller that reads it without writing cannot be misled.\n historyIdentity: (collection, recordId, version) => historyIdentity(collection, recordId, version),\n async getHistoryEntries() { throw notEnabled('collection.history()') },\n async getVersionEnvelope() { throw notEnabled('collection.getVersion()') },\n async pruneHistory() { return 0 },\n async clearHistory() { return 0 },\n async tombstoneHistory() { return 0 },\n async rewrapHistory() {},\n async envelopePayloadHash() { return '' },\n computePatch() { return [] },\n diff() { throw notEnabled('collection.diff()') },\n buildLedger() { return null },\n buildVaultInstant() { throw notEnabled('vault.at() / vault.timeMachine()') },\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildRecordAad,
|
|
2
3
|
openEnvelopeJson
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-D5UDZANO.js";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
buildRecordEnvelope
|
|
7
|
+
} from "./chunk-ZVAFJQZB.js";
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
encrypt
|
|
10
|
+
} from "./chunk-VJ4B3ZXY.js";
|
|
10
11
|
|
|
11
12
|
// src/with-shape/persisted-schemas/storage.ts
|
|
12
13
|
var SCHEMAS_COLLECTION = "_schemas";
|
|
@@ -15,7 +16,7 @@ async function loadPersistedSchemaEntry(store, vault, collection, dek) {
|
|
|
15
16
|
if (!envelope) return { version: 0, payload: void 0 };
|
|
16
17
|
const version = envelope._v;
|
|
17
18
|
try {
|
|
18
|
-
const plaintext = await openEnvelopeJson(envelope, dek);
|
|
19
|
+
const plaintext = await openEnvelopeJson({ collection: SCHEMAS_COLLECTION, id: collection }, envelope, dek);
|
|
19
20
|
const parsed = JSON.parse(plaintext);
|
|
20
21
|
if (parsed._noydb_schema !== 1) return { version, payload: void 0 };
|
|
21
22
|
return { version, payload: parsed };
|
|
@@ -28,15 +29,13 @@ async function loadPersistedSchema(store, vault, collection, dek) {
|
|
|
28
29
|
}
|
|
29
30
|
async function savePersistedSchema(store, vault, collection, dek, payload, expectedVersion) {
|
|
30
31
|
const json = JSON.stringify(payload);
|
|
31
|
-
const { iv, data } = await encrypt(json, dek);
|
|
32
32
|
const baseVersion = expectedVersion ?? (await store.get(vault, SCHEMAS_COLLECTION, collection))?._v ?? 0;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
33
|
+
const identity = { collection: SCHEMAS_COLLECTION, id: collection, version: baseVersion + 1 };
|
|
34
|
+
const { iv, data } = await encrypt(json, dek, buildRecordAad(identity));
|
|
35
|
+
const env = buildRecordEnvelope(
|
|
36
|
+
identity,
|
|
37
|
+
{ iv, data }
|
|
38
|
+
);
|
|
40
39
|
await store.put(vault, SCHEMAS_COLLECTION, collection, env, expectedVersion);
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -46,4 +45,4 @@ export {
|
|
|
46
45
|
loadPersistedSchema,
|
|
47
46
|
savePersistedSchema
|
|
48
47
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-YVTADFTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-shape/persisted-schemas/storage.ts"],"sourcesContent":["/**\n * Read / write the per-collection persisted-schema envelope. Mirrors the\n * standard noy-db record envelope shape and is **AES-GCM encrypted with\n * the collection's DEK** — the schema body (field names, enum values,\n * constraints) is sensitive metadata, so it gets the same encryption\n * envelope as the records it describes.\n *\n * Storage layout:\n *\n * <vault>/_schemas/<collection> → EncryptedEnvelope\n *\n * The DEK passed to {@link savePersistedSchema} / {@link loadPersistedSchema}\n * is the same key the collection uses for its records.\n *\n * @module\n */\n\nimport { buildRecordAad, buildRecordEnvelope, encrypt, openEnvelopeJson, type EnclaveKey } from '../../kernel/enclave/index.js'\nimport type { NoydbStore } from '../../kernel/types.js'\nimport type { PersistedSchemaEnvelope } from './types.js'\n\n/** Reserved collection name where persisted schemas live. */\nexport const SCHEMAS_COLLECTION = '_schemas' as const\n\n/**\n * A decrypted persisted-schema read paired with the wrapping envelope's\n * `_v`. The version is the optimistic-concurrency token: pass it back to\n * {@link savePersistedSchema} as `expectedVersion` to make the write a CAS\n * that rejects a stale put (see #583 — the `_schemas` record is shared by\n * the JSON-Schema writer and the classified-marker writer).\n */\nexport interface PersistedSchemaEntry {\n /** Wrapping envelope `_v` (0 when no record exists yet). */\n readonly version: number\n /** Decrypted payload, or `undefined` when absent/corrupt/wrong-DEK. */\n readonly payload: PersistedSchemaEnvelope | undefined\n}\n\n/**\n * Read the persisted-schema envelope for one collection together with its\n * wrapping `_v`. The version reflects the raw stored envelope even when the\n * payload cannot be decrypted/parsed (so a CAS still guards a corrupt record\n * rather than silently clobbering it).\n */\nexport async function loadPersistedSchemaEntry(\n store: NoydbStore,\n vault: string,\n collection: string,\n dek: EnclaveKey,\n): Promise<PersistedSchemaEntry> {\n const envelope = await store.get(vault, SCHEMAS_COLLECTION, collection)\n if (!envelope) return { version: 0, payload: undefined }\n const version = envelope._v\n try {\n const plaintext = await openEnvelopeJson({ collection: SCHEMAS_COLLECTION, id: collection }, envelope, dek)\n const parsed = JSON.parse(plaintext) as PersistedSchemaEnvelope\n if (parsed._noydb_schema !== 1) return { version, payload: undefined }\n return { version, payload: parsed }\n } catch {\n return { version, payload: undefined }\n }\n}\n\n/**\n * Read and decrypt the persisted-schema envelope for one collection.\n * Returns `undefined` when no envelope has been written or when decryption\n * fails (e.g. wrong DEK passed). Tolerates corrupted records — JSON parse\n * failures surface as `undefined`, mirroring `_meta/handle`'s contract.\n */\nexport async function loadPersistedSchema(\n store: NoydbStore,\n vault: string,\n collection: string,\n dek: EnclaveKey,\n): Promise<PersistedSchemaEnvelope | undefined> {\n return (await loadPersistedSchemaEntry(store, vault, collection, dek)).payload\n}\n\n/**\n * Encrypt and persist a schema envelope for one collection. Always\n * overwrites any prior write (callers gate on hash equality before calling\n * to avoid no-op writes).\n *\n * Pass `expectedVersion` — the `version` from {@link loadPersistedSchemaEntry}\n * captured at load time — to make the write an optimistic CAS: on a store with\n * `casAtomic`, `store.put` throws {@link ConflictError} when the record was\n * bumped concurrently, so a lost update on the shared `_schemas` record is\n * rejected instead of silently clobbering the other writer's field (#583).\n * When omitted, keeps the legacy unconditional last-writer-wins behaviour.\n */\nexport async function savePersistedSchema(\n store: NoydbStore,\n vault: string,\n collection: string,\n dek: EnclaveKey,\n payload: PersistedSchemaEnvelope,\n expectedVersion?: number,\n): Promise<void> {\n const json = JSON.stringify(payload)\n const baseVersion = expectedVersion ?? (await store.get(vault, SCHEMAS_COLLECTION, collection))?._v ?? 0\n const identity = { collection: SCHEMAS_COLLECTION, id: collection, version: baseVersion + 1 }\n const { iv, data } = await encrypt(json, dek, buildRecordAad(identity))\n const env = buildRecordEnvelope(\n identity,\n { iv, data },\n )\n await store.put(vault, SCHEMAS_COLLECTION, collection, env, expectedVersion)\n}\n"],"mappings":";;;;;;;;;;;;AAsBO,IAAM,qBAAqB;AAsBlC,eAAsB,yBACpB,OACA,OACA,YACA,KAC+B;AAC/B,QAAM,WAAW,MAAM,MAAM,IAAI,OAAO,oBAAoB,UAAU;AACtE,MAAI,CAAC,SAAU,QAAO,EAAE,SAAS,GAAG,SAAS,OAAU;AACvD,QAAM,UAAU,SAAS;AACzB,MAAI;AACF,UAAM,YAAY,MAAM,iBAAiB,EAAE,YAAY,oBAAoB,IAAI,WAAW,GAAG,UAAU,GAAG;AAC1G,UAAM,SAAS,KAAK,MAAM,SAAS;AACnC,QAAI,OAAO,kBAAkB,EAAG,QAAO,EAAE,SAAS,SAAS,OAAU;AACrE,WAAO,EAAE,SAAS,SAAS,OAAO;AAAA,EACpC,QAAQ;AACN,WAAO,EAAE,SAAS,SAAS,OAAU;AAAA,EACvC;AACF;AAQA,eAAsB,oBACpB,OACA,OACA,YACA,KAC8C;AAC9C,UAAQ,MAAM,yBAAyB,OAAO,OAAO,YAAY,GAAG,GAAG;AACzE;AAcA,eAAsB,oBACpB,OACA,OACA,YACA,KACA,SACA,iBACe;AACf,QAAM,OAAO,KAAK,UAAU,OAAO;AACnC,QAAM,cAAc,oBAAoB,MAAM,MAAM,IAAI,OAAO,oBAAoB,UAAU,IAAI,MAAM;AACvG,QAAM,WAAW,EAAE,YAAY,oBAAoB,IAAI,YAAY,SAAS,cAAc,EAAE;AAC5F,QAAM,EAAE,IAAI,KAAK,IAAI,MAAM,QAAQ,MAAM,KAAK,eAAe,QAAQ,CAAC;AACtE,QAAM,MAAM;AAAA,IACV;AAAA,IACA,EAAE,IAAI,KAAK;AAAA,EACb;AACA,QAAM,MAAM,IAAI,OAAO,oBAAoB,YAAY,KAAK,eAAe;AAC7E;","names":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildRecordAad,
|
|
2
3
|
openEnvelopeJson
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-D5UDZANO.js";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
buildRecordEnvelope
|
|
7
|
+
} from "./chunk-ZVAFJQZB.js";
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
encrypt
|
|
10
|
+
} from "./chunk-VJ4B3ZXY.js";
|
|
10
11
|
import {
|
|
11
12
|
ConflictError
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P7L3OQLL.js";
|
|
13
14
|
|
|
14
15
|
// src/with-audit/attestation/signer.ts
|
|
15
16
|
import { generateDocSigningKeyPair } from "@noy-db/attestation";
|
|
@@ -20,7 +21,7 @@ async function loadSigner(store, vault, getDEK) {
|
|
|
20
21
|
const existing = await store.get(vault, ATTESTATIONS_COLLECTION, SIGNER_RECORD_ID);
|
|
21
22
|
if (!existing) return null;
|
|
22
23
|
const dek = await getDEK(ATTESTATIONS_COLLECTION);
|
|
23
|
-
const json = await openEnvelopeJson(existing, dek);
|
|
24
|
+
const json = await openEnvelopeJson({ collection: ATTESTATIONS_COLLECTION, id: SIGNER_RECORD_ID }, existing, dek);
|
|
24
25
|
return JSON.parse(json);
|
|
25
26
|
}
|
|
26
27
|
async function loadOrCreateSigner(store, vault, getDEK) {
|
|
@@ -28,14 +29,12 @@ async function loadOrCreateSigner(store, vault, getDEK) {
|
|
|
28
29
|
if (existing) return existing;
|
|
29
30
|
const dek = await getDEK(ATTESTATIONS_COLLECTION);
|
|
30
31
|
const signer = await generateDocSigningKeyPair();
|
|
31
|
-
const {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_data: data
|
|
38
|
-
};
|
|
32
|
+
const identity = { collection: ATTESTATIONS_COLLECTION, id: SIGNER_RECORD_ID, version: 1 };
|
|
33
|
+
const { iv, data } = await encrypt(JSON.stringify(signer), dek, buildRecordAad(identity));
|
|
34
|
+
const env = buildRecordEnvelope(
|
|
35
|
+
identity,
|
|
36
|
+
{ iv, data }
|
|
37
|
+
);
|
|
39
38
|
try {
|
|
40
39
|
await store.put(vault, ATTESTATIONS_COLLECTION, SIGNER_RECORD_ID, env, 0);
|
|
41
40
|
return signer;
|
|
@@ -56,4 +55,4 @@ export {
|
|
|
56
55
|
loadSigner,
|
|
57
56
|
loadOrCreateSigner
|
|
58
57
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-ZBDWKPBW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-audit/attestation/signer.ts"],"sourcesContent":["import type { NoydbStore } from '../../kernel/types.js'\nimport { buildRecordAad, buildRecordEnvelope, encrypt, openEnvelopeJson, type EnclaveKey } from '../../kernel/enclave/index.js'\nimport { ConflictError } from '../../kernel/errors.js'\nimport { generateDocSigningKeyPair } from '@noy-db/attestation'\n\nexport const ATTESTATIONS_COLLECTION = '_attestations'\nexport const SIGNER_RECORD_ID = '_signer'\nexport const REVOKED_RECORD_ID = '_revoked'\n\nexport interface DocSigner {\n readonly keyId: string\n readonly publicKeyB64: string\n readonly privateKeyPkcs8B64: string\n}\n\n/**\n * Pure read: return the firm's persisted document-signing keypair, or `null`\n * if none has been minted yet. Never writes — callers that must NOT mint\n * (e.g. an ungated public-key getter) use this instead of `loadOrCreateSigner`.\n *\n * Stored as an encrypted record `_attestations/_signer` under the\n * `_attestations` collection DEK (resolved via `getDEK`, which is\n * AES-KW-wrapped under the owner KEK + persisted by the keyring). The KEK\n * itself is AES-KW-only and cannot AES-GCM-encrypt these bytes — hence\n * storage under a normal collection DEK.\n */\nexport async function loadSigner(\n store: NoydbStore,\n vault: string,\n getDEK: (collection: string) => Promise<EnclaveKey>,\n): Promise<DocSigner | null> {\n const existing = await store.get(vault, ATTESTATIONS_COLLECTION, SIGNER_RECORD_ID)\n if (!existing) return null\n const dek = await getDEK(ATTESTATIONS_COLLECTION)\n const json = await openEnvelopeJson({ collection: ATTESTATIONS_COLLECTION, id: SIGNER_RECORD_ID }, existing, dek)\n return JSON.parse(json) as DocSigner\n}\n\n/**\n * Lazily mint (or load) the firm's Ed25519 document-signing keypair.\n *\n * On a concurrent first-mint, two callers can both read `null` and both mint\n * distinct keypairs. The `put(…, expectedVersion: 0)` (\"must not already\n * exist\") lets exactly one win; the loser catches `ConflictError`, re-reads,\n * and returns the winner's signer — converging on a single keypair rather than\n * clobbering it or surfacing a raw conflict. (All real stores treat a missing\n * record + `ev: 0` as a no-conflict write, so the catch fires on lost-race only.)\n */\nexport async function loadOrCreateSigner(\n store: NoydbStore,\n vault: string,\n getDEK: (collection: string) => Promise<EnclaveKey>,\n): Promise<DocSigner> {\n const existing = await loadSigner(store, vault, getDEK)\n if (existing) return existing\n\n const dek = await getDEK(ATTESTATIONS_COLLECTION)\n const signer = await generateDocSigningKeyPair()\n const identity = { collection: ATTESTATIONS_COLLECTION, id: SIGNER_RECORD_ID, version: 1 }\n const { iv, data } = await encrypt(JSON.stringify(signer), dek, buildRecordAad(identity))\n const env = buildRecordEnvelope(\n identity,\n { iv, data },\n )\n try {\n await store.put(vault, ATTESTATIONS_COLLECTION, SIGNER_RECORD_ID, env, 0)\n return signer\n } catch (e) {\n if (!(e instanceof ConflictError)) throw e\n // Lost the race — another writer minted first. Adopt the winner.\n const winner = await loadSigner(store, vault, getDEK)\n if (!winner) {\n throw new ConflictError(0, 'loadOrCreateSigner: signer mint lost a concurrent race but the winning record could not be re-read.')\n }\n return winner\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,SAAS,iCAAiC;AAEnC,IAAM,0BAA0B;AAChC,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAmBjC,eAAsB,WACpB,OACA,OACA,QAC2B;AAC3B,QAAM,WAAW,MAAM,MAAM,IAAI,OAAO,yBAAyB,gBAAgB;AACjF,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,MAAM,MAAM,OAAO,uBAAuB;AAChD,QAAM,OAAO,MAAM,iBAAiB,EAAE,YAAY,yBAAyB,IAAI,iBAAiB,GAAG,UAAU,GAAG;AAChH,SAAO,KAAK,MAAM,IAAI;AACxB;AAYA,eAAsB,mBACpB,OACA,OACA,QACoB;AACpB,QAAM,WAAW,MAAM,WAAW,OAAO,OAAO,MAAM;AACtD,MAAI,SAAU,QAAO;AAErB,QAAM,MAAM,MAAM,OAAO,uBAAuB;AAChD,QAAM,SAAS,MAAM,0BAA0B;AAC/C,QAAM,WAAW,EAAE,YAAY,yBAAyB,IAAI,kBAAkB,SAAS,EAAE;AACzF,QAAM,EAAE,IAAI,KAAK,IAAI,MAAM,QAAQ,KAAK,UAAU,MAAM,GAAG,KAAK,eAAe,QAAQ,CAAC;AACxF,QAAM,MAAM;AAAA,IACV;AAAA,IACA,EAAE,IAAI,KAAK;AAAA,EACb;AACA,MAAI;AACF,UAAM,MAAM,IAAI,OAAO,yBAAyB,kBAAkB,KAAK,CAAC;AACxE,WAAO;AAAA,EACT,SAAS,GAAG;AACV,QAAI,EAAE,aAAa,eAAgB,OAAM;AAEzC,UAAM,SAAS,MAAM,WAAW,OAAO,OAAO,MAAM;AACpD,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,cAAc,GAAG,qGAAqG;AAAA,IAClI;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
writePod
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2IK6AC6A.js";
|
|
4
4
|
|
|
5
5
|
// src/with-audit/portability/export-accessible.ts
|
|
6
6
|
function resolveAccessibleCollections(keyring, scope, writableOnly = false) {
|
|
@@ -42,4 +42,4 @@ export {
|
|
|
42
42
|
buildAccessibleBundle,
|
|
43
43
|
exportAccessibleData
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-ZPMXYPBR.js.map
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NOYDB_FORMAT_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3Y4OFWQJ.js";
|
|
4
4
|
|
|
5
5
|
// src/kernel/enclave/record-envelope.ts
|
|
6
6
|
function buildRecordEnvelope(identity, body) {
|
|
7
|
-
void identity;
|
|
8
7
|
return {
|
|
9
8
|
_noydb: NOYDB_FORMAT_VERSION,
|
|
10
|
-
_v:
|
|
9
|
+
_v: identity.version,
|
|
11
10
|
_ts: body.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
12
11
|
_iv: body.iv,
|
|
13
12
|
_data: body.data,
|
|
14
|
-
...
|
|
13
|
+
...identity.by !== void 0 ? { _by: identity.by } : {},
|
|
14
|
+
...identity.tier !== void 0 && identity.tier > 0 ? { _tier: identity.tier } : {},
|
|
15
15
|
...body.cek !== void 0 ? { _cek: body.cek } : {},
|
|
16
16
|
...body.provenance !== void 0 ? { _source: body.provenance.source, _sourceTs: body.provenance.sourceTs } : {},
|
|
17
17
|
...body.extra ?? {}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
async function buildSealedRecordEnvelope(identity, seal, body) {
|
|
21
|
+
const sealed = await seal(identity);
|
|
22
|
+
return buildRecordEnvelope(identity, {
|
|
23
|
+
...body,
|
|
24
|
+
iv: sealed._iv,
|
|
25
|
+
data: sealed._data,
|
|
26
|
+
cek: sealed._cek
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
|
|
21
30
|
// src/kernel/enclave/record-keys/tombstone.ts
|
|
22
31
|
function isTombstoneShape(envelope) {
|
|
@@ -26,35 +35,32 @@ function isTombstone(envelope, encrypted) {
|
|
|
26
35
|
if (!encrypted) return false;
|
|
27
36
|
return isTombstoneShape(envelope);
|
|
28
37
|
}
|
|
29
|
-
function buildTombstone(
|
|
30
|
-
return buildRecordEnvelope(
|
|
31
|
-
version,
|
|
32
|
-
iv: "",
|
|
33
|
-
|
|
34
|
-
...actor ? { by: actor } : {}
|
|
35
|
-
});
|
|
38
|
+
function buildTombstone(ref, version, actor) {
|
|
39
|
+
return buildRecordEnvelope(
|
|
40
|
+
{ ...ref, version, ...actor ? { by: actor } : {} },
|
|
41
|
+
{ iv: "", data: "" }
|
|
42
|
+
);
|
|
36
43
|
}
|
|
37
44
|
function isDeleteMarker(envelope) {
|
|
38
45
|
return envelope._del === true;
|
|
39
46
|
}
|
|
40
|
-
function buildDeleteMarker(
|
|
47
|
+
function buildDeleteMarker(ref, version, actor) {
|
|
41
48
|
return {
|
|
42
|
-
...buildRecordEnvelope(
|
|
43
|
-
version,
|
|
44
|
-
iv: "",
|
|
45
|
-
|
|
46
|
-
...actor ? { by: actor } : {}
|
|
47
|
-
}),
|
|
49
|
+
...buildRecordEnvelope(
|
|
50
|
+
{ ...ref, version, ...actor ? { by: actor } : {} },
|
|
51
|
+
{ iv: "", data: "" }
|
|
52
|
+
),
|
|
48
53
|
_del: true
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
export {
|
|
53
58
|
buildRecordEnvelope,
|
|
59
|
+
buildSealedRecordEnvelope,
|
|
54
60
|
isTombstoneShape,
|
|
55
61
|
isTombstone,
|
|
56
62
|
buildTombstone,
|
|
57
63
|
isDeleteMarker,
|
|
58
64
|
buildDeleteMarker
|
|
59
65
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-ZVAFJQZB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/kernel/enclave/record-envelope.ts","../src/kernel/enclave/record-keys/tombstone.ts"],"sourcesContent":["/**\n * The one place an `EncryptedEnvelope` is constructed (#1051).\n *\n * ## Why this exists\n *\n * 49 files built envelopes with an object literal, bypassing\n * `RecordCodec.buildEnvelope` (which had 4 callers). That is **writer\n * fan-out**: N independent places each had to know the envelope contract, and\n * nothing checked that they agreed.\n *\n * It only became load-bearing with #1041. Binding a record's identity into the\n * AEAD requires every writer to supply that identity — and a writer that\n * doesn't produces data the reader rejects. Reader fan-out you fix by threading\n * an argument through call sites; **writer fan-out cannot be migrated\n * incrementally**, because the first migrated writer emits envelopes the\n * unmigrated readers refuse.\n *\n * ## Why adopting it is safe\n *\n * `identity` is **required but not yet used**. Output is byte-identical to the\n * literals it replaces, so every producer can migrate independently and the\n * existing suite verifies each step. The behaviour change happens **once**,\n * when AAD is switched on here — by which point every writer already supplies\n * identity, and the compiler proved it.\n *\n * That ordering is deliberate: a required-but-unused parameter converts \"did\n * we find every writer?\" from a question into a compile error, the same trick\n * that made the `NOYDB_FORMAT_VERSION` single-sourcing safe in #1048.\n *\n * @packageDocumentation\n */\nimport { NOYDB_FORMAT_VERSION } from '../types.js'\nimport type { EncryptedEnvelope } from '../types.js'\nimport type { RecordIdentity } from './record-aad.js'\n\n/** The body an envelope carries, independent of who is writing it. */\nexport interface RecordEnvelopeBody {\n /** AES-GCM IV, base64. Empty string for a plaintext or tombstone envelope. */\n readonly iv: string\n /** Ciphertext (or plaintext JSON when the collection stores plaintext). */\n readonly data: string\n /** ISO timestamp. Defaults to now — pass it when the caller has a real one. */\n readonly ts?: string | undefined\n /** Wrapped per-record CEK, when the record has one. */\n readonly cek?: string | undefined\n readonly provenance?: { readonly source: string; readonly sourceTs: string } | undefined\n /**\n * Slots the envelope may additionally carry.\n *\n * `_tier`, `_by` and `_v` are deliberately NOT here — they come from\n * `identity`, which is the single source for all three. See\n * {@link buildRecordEnvelope}.\n */\n readonly extra?: Partial<Pick<EncryptedEnvelope, '_det' | '_sealed' | '_vdig' | '_bidx'>> | undefined\n}\n\n/**\n * Build an envelope for `identity`.\n *\n * ## `identity` is the SINGLE SOURCE for `_by`, `_tier` and `_v`\n *\n * All three are stamped from it, and `RecordEnvelopeBody` deliberately cannot\n * carry them. That is not tidiness — it is what makes the AAD binding safe.\n *\n * The caller encrypts the body under AAD derived from `{collection, id, tier,\n * by, version}`. A reader recomputes that AAD from the address it fetched from\n * plus `_tier`/`_by`/`_v` read back **off the envelope** (`recordAadFor`). So if the\n * identity a writer *declares* could differ from the fields it *stamps*, the\n * AAD would not reproduce and the record would be undecryptable — silently, at\n * write time, discoverable only on the next read, and invisible to every gate\n * because the envelope is perfectly well-formed.\n *\n * An earlier draft took both and asserted they agreed. The assertion fired 230\n * times on the existing tree, which is the argument against it: a rule that can\n * be violated is a rule someone must remember. Taking one source removes the\n * violation instead of reporting it.\n */\nexport function buildRecordEnvelope(\n identity: RecordIdentity,\n body: RecordEnvelopeBody,\n): EncryptedEnvelope {\n return {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: identity.version,\n _ts: body.ts ?? new Date().toISOString(),\n _iv: body.iv,\n _data: body.data,\n ...(identity.by !== undefined ? { _by: identity.by } : {}),\n ...(identity.tier !== undefined && identity.tier > 0 ? { _tier: identity.tier } : {}),\n ...(body.cek !== undefined ? { _cek: body.cek } : {}),\n ...(body.provenance !== undefined\n ? { _source: body.provenance.source, _sourceTs: body.provenance.sourceTs }\n : {}),\n ...(body.extra ?? {}),\n }\n}\n\n/**\n * Build an envelope from an already-sealed body — the output of\n * `writeEnvelopeBody` — **without the caller ever naming `_iv`/`_data`/`_cek`**.\n *\n * This exists because of a guard, and the guard was right. Migrating\n * `writeEnvelopeBody` callers to {@link buildRecordEnvelope} meant rewriting\n * `...body` (a spread, which names nothing) into `iv: body._iv, data:\n * body._data, cek: body._cek` — and `enclave-body-only` failed it: three new\n * protected-body accesses in files that previously had zero.\n *\n * That is the correct outcome rather than an obstacle. #1051 exists to move\n * knowledge of the envelope's shape *inward*; a migration that spreads the\n * protected field names outward to every caller would have defeated its own\n * purpose while looking like progress. The pairing belongs here.\n *\n * ## It takes a SEALER, not a sealed body — and that is load-bearing (#1041)\n *\n * The obvious shape is `(identity, alreadySealedBody, rest)`. That requires the\n * caller to name the identity TWICE — once for `writeEnvelopeBody` and once\n * here — and the two must agree byte for byte or the record is sealed under\n * AAD no reader can reproduce.\n *\n * They did not agree. `with-party/broker/seed.ts` sealed against\n * `{collection, id}` and stamped `{collection, id, by}`, so every broker seed\n * became unreadable the moment AAD switched on. Taking the sealer means the\n * identity is written once and handed to both — divergence stops being\n * possible rather than being something to remember.\n */\nexport async function buildSealedRecordEnvelope(\n identity: RecordIdentity,\n seal: (identity: RecordIdentity) => Promise<Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>>,\n body: Omit<RecordEnvelopeBody, 'iv' | 'data' | 'cek'>,\n): Promise<EncryptedEnvelope> {\n const sealed = await seal(identity)\n return buildRecordEnvelope(identity, {\n ...body,\n iv: sealed._iv,\n data: sealed._data,\n cek: sealed._cek,\n })\n}\n","/**\n * Tombstone shape + predicate for the per-record-key (CEK) layer.\n *\n * A *tombstone* is the residue a GDPR crypto-shred (`vault.forget()`)\n * leaves on disk: the live envelope rewritten to `{ _noydb, _v, _ts, _by,\n * _iv:'', _data:'' }`, dropping `_iv`/`_data`/`_cek`/`_det`. With the wrapped\n * per-record CEK gone, the body — and every history version under the same\n * CEK — is permanently undecryptable, while the record KEY survives so the\n * version counter and \"record existed and was erased\" persist for the audit\n * ledger.\n *\n * These two helpers are the pure, collection-independent core of that\n * contract: {@link buildTombstone} mints the shape, {@link isTombstone}\n * recognises it on the read path. The orchestration that *writes* a tombstone\n * (`_writeTombstone`) and drives `vault.forget()` lives with the collection /\n * vault; it calls into these.\n */\nimport { type EncryptedEnvelope } from '../../types.js'\nimport { buildRecordEnvelope } from '../record-envelope.js'\nimport type { RecordRef } from '../record-aad.js'\n\n/**\n * Shape-only tombstone recognition for layers that have no per-collection\n * context (the sync engine, #590): a tombstone carries an empty `_data` and\n * no wrapped CEK. No live envelope can match — record bodies never serialize\n * to the empty string (the `_sync` meta envelope carries non-empty `_data`,\n * and legacy migration envelopes carry non-empty `_iv`/`_data`).\n */\nexport function isTombstoneShape(envelope: EncryptedEnvelope): boolean {\n return envelope._data === '' && envelope._cek === undefined && envelope._del !== true\n}\n\n/**\n * Is this envelope a crypto-shred tombstone?\n *\n * A tombstone carries no body (`_data` empty) and no wrapped CEK (`_cek`\n * absent) — decrypting it would call `decrypt('', '', dek)` → an AES-GCM\n * throw, so every read choke point must short-circuit to `null` instead.\n *\n * `encrypted` is the collection's encryption flag: on an unencrypted\n * collection there are no envelopes to shred, so nothing is ever a tombstone.\n * (Legacy migration envelopes carry non-empty `_iv`/`_data`, so they are not\n * tombstones and stay readable.)\n */\nexport function isTombstone(envelope: EncryptedEnvelope, encrypted: boolean): boolean {\n if (!encrypted) return false\n return isTombstoneShape(envelope)\n}\n\n/**\n * Mint a tombstone envelope from a record's live version + actor.\n *\n * Keeps `_v` (the displaced version) so the counter is monotonic across the\n * shred, stamps a fresh `_ts`, and records `_by` when an actor is supplied.\n * Deliberately omits `_iv`/`_data`/`_cek`/`_det` — that omission *is* the\n * erasure.\n */\nexport function buildTombstone(\n ref: RecordRef,\n version: number,\n actor: string,\n): EncryptedEnvelope {\n // `actor` rides on the IDENTITY, not the body — it is stamped as `_by` and\n // bound into the AAD from that one source (#1041).\n return buildRecordEnvelope(\n { ...ref, version, ...(actor ? { by: actor } : {}) },\n { iv: '', data: '' },\n )\n}\n\n/** #589: is this envelope an ordinary-delete marker (version-ordered, reads as absent)? */\nexport function isDeleteMarker(envelope: EncryptedEnvelope): boolean {\n return envelope._del === true\n}\n\n/**\n * Mint a delete marker from the deleted record's next version + actor (#589).\n * Minted at the NEXT version (`existing._v + 1`) — unlike `buildTombstone`, which\n * keeps the displaced `_v` — so it wins convergence over the pre-delete copy and a\n * re-create can still win over it at a higher version.\n */\nexport function buildDeleteMarker(\n ref: RecordRef,\n version: number,\n actor: string,\n): EncryptedEnvelope {\n // `_del` is not one of buildRecordEnvelope's declared slots — a delete marker\n // is a distinct envelope class, not a record body — so it is stamped here.\n return {\n ...buildRecordEnvelope(\n { ...ref, version, ...(actor ? { by: actor } : {}) },\n { iv: '', data: '' },\n ),\n _del: true,\n }\n}\n"],"mappings":";;;;;AA6EO,SAAS,oBACd,UACA,MACmB;AACnB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,IAAI,SAAS;AAAA,IACb,KAAK,KAAK,OAAM,oBAAI,KAAK,GAAE,YAAY;AAAA,IACvC,KAAK,KAAK;AAAA,IACV,OAAO,KAAK;AAAA,IACZ,GAAI,SAAS,OAAO,SAAY,EAAE,KAAK,SAAS,GAAG,IAAI,CAAC;AAAA,IACxD,GAAI,SAAS,SAAS,UAAa,SAAS,OAAO,IAAI,EAAE,OAAO,SAAS,KAAK,IAAI,CAAC;AAAA,IACnF,GAAI,KAAK,QAAQ,SAAY,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC;AAAA,IACnD,GAAI,KAAK,eAAe,SACpB,EAAE,SAAS,KAAK,WAAW,QAAQ,WAAW,KAAK,WAAW,SAAS,IACvE,CAAC;AAAA,IACL,GAAI,KAAK,SAAS,CAAC;AAAA,EACrB;AACF;AA8BA,eAAsB,0BACpB,UACA,MACA,MAC4B;AAC5B,QAAM,SAAS,MAAM,KAAK,QAAQ;AAClC,SAAO,oBAAoB,UAAU;AAAA,IACnC,GAAG;AAAA,IACH,IAAI,OAAO;AAAA,IACX,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,EACd,CAAC;AACH;;;AC7GO,SAAS,iBAAiB,UAAsC;AACrE,SAAO,SAAS,UAAU,MAAM,SAAS,SAAS,UAAa,SAAS,SAAS;AACnF;AAcO,SAAS,YAAY,UAA6B,WAA6B;AACpF,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,iBAAiB,QAAQ;AAClC;AAUO,SAAS,eACd,KACA,SACA,OACmB;AAGnB,SAAO;AAAA,IACL,EAAE,GAAG,KAAK,SAAS,GAAI,QAAQ,EAAE,IAAI,MAAM,IAAI,CAAC,EAAG;AAAA,IACnD,EAAE,IAAI,IAAI,MAAM,GAAG;AAAA,EACrB;AACF;AAGO,SAAS,eAAe,UAAsC;AACnE,SAAO,SAAS,SAAS;AAC3B;AAQO,SAAS,kBACd,KACA,SACA,OACmB;AAGnB,SAAO;AAAA,IACL,GAAG;AAAA,MACD,EAAE,GAAG,KAAK,SAAS,GAAI,QAAQ,EAAE,IAAI,MAAM,IAAI,CAAC,EAAG;AAAA,MACnD,EAAE,IAAI,IAAI,MAAM,GAAG;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AttestationNotEnabledError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P7L3OQLL.js";
|
|
4
4
|
|
|
5
5
|
// src/with-audit/attestation/strategy.ts
|
|
6
6
|
var NO_ATTESTATION = {
|
|
@@ -27,4 +27,4 @@ var NO_ATTESTATION = {
|
|
|
27
27
|
export {
|
|
28
28
|
NO_ATTESTATION
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-ZWKF3CD3.js.map
|
package/dist/classified/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
classified,
|
|
3
3
|
luhnCheck,
|
|
4
4
|
withClassified
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-EJIVFOOQ.js";
|
|
6
6
|
import {
|
|
7
7
|
ClassifiedNeverStoredError,
|
|
8
8
|
ClassifiedValidationError,
|
|
@@ -11,15 +11,15 @@ import {
|
|
|
11
11
|
isClassifiedFieldSpec,
|
|
12
12
|
isClassifiedGroup,
|
|
13
13
|
resolveClassifiedFields
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
14
|
+
} from "../chunk-N2HKBESK.js";
|
|
15
|
+
import "../chunk-KDX6VEYV.js";
|
|
16
|
+
import "../chunk-3Y4OFWQJ.js";
|
|
17
17
|
import {
|
|
18
18
|
ClassifiedConfigError,
|
|
19
19
|
ClassifiedRevealError,
|
|
20
20
|
ClassifiedRotationError,
|
|
21
21
|
ClassifiedVerifyError
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-P7L3OQLL.js";
|
|
23
23
|
import "../chunk-PZ5AY32C.js";
|
|
24
24
|
export {
|
|
25
25
|
ClassifiedConfigError,
|
|
@@ -13,11 +13,11 @@ function markerForFields(vdigFields) {
|
|
|
13
13
|
async function persistClassifiedMarkerForFields(store, vault, collectionName, vdigFields, dek) {
|
|
14
14
|
const marker = markerForFields(vdigFields);
|
|
15
15
|
if (marker === null) return;
|
|
16
|
-
const { persistClassifiedMarker } = await import("./register-
|
|
16
|
+
const { persistClassifiedMarker } = await import("./register-UPD4GKBC.js");
|
|
17
17
|
await persistClassifiedMarker({ store, vault, collectionName, dek, marker });
|
|
18
18
|
}
|
|
19
19
|
async function readClassifiedMarkerDigestOnly(store, vault, collectionName, dek) {
|
|
20
|
-
const { loadPersistedSchema } = await import("./storage-
|
|
20
|
+
const { loadPersistedSchema } = await import("./storage-MJHKNQRO.js");
|
|
21
21
|
const persisted = await loadPersistedSchema(store, vault, collectionName, dek);
|
|
22
22
|
return persisted?.classified?.digestOnly ?? [];
|
|
23
23
|
}
|
|
@@ -25,4 +25,4 @@ export {
|
|
|
25
25
|
persistClassifiedMarkerForFields,
|
|
26
26
|
readClassifiedMarkerDigestOnly
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=classified-marker-
|
|
28
|
+
//# sourceMappingURL=classified-marker-PMDG3O36.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildPersistedIndexCallbacks,
|
|
3
|
+
buildRetrievalDocs,
|
|
4
|
+
embedOnWrite,
|
|
5
|
+
flushIndex,
|
|
6
|
+
hasIndexedBlobFields,
|
|
7
|
+
rebuildEmbeddings,
|
|
8
|
+
retrieve,
|
|
9
|
+
search,
|
|
10
|
+
similarTo,
|
|
11
|
+
syncTierSearch,
|
|
12
|
+
warmIndex
|
|
13
|
+
} from "./chunk-OWGEHDT2.js";
|
|
14
|
+
import "./chunk-5JT4Y5UE.js";
|
|
15
|
+
import "./chunk-AURFOK3D.js";
|
|
16
|
+
import "./chunk-PG6PFMDC.js";
|
|
17
|
+
import "./chunk-GYUCRDAU.js";
|
|
18
|
+
import "./chunk-437FDIHO.js";
|
|
19
|
+
import "./chunk-KDX6VEYV.js";
|
|
20
|
+
import "./chunk-RNSC2ARR.js";
|
|
21
|
+
import "./chunk-47ZFULEZ.js";
|
|
22
|
+
import "./chunk-D5UDZANO.js";
|
|
23
|
+
import "./chunk-ZVAFJQZB.js";
|
|
24
|
+
import "./chunk-OQLYMBJI.js";
|
|
25
|
+
import "./chunk-DJ23QZIN.js";
|
|
26
|
+
import "./chunk-SFD2LL7G.js";
|
|
27
|
+
import "./chunk-LP7BEXCT.js";
|
|
28
|
+
import "./chunk-VJ4B3ZXY.js";
|
|
29
|
+
import "./chunk-3Y4OFWQJ.js";
|
|
30
|
+
import "./chunk-P7L3OQLL.js";
|
|
31
|
+
import "./chunk-PZ5AY32C.js";
|
|
32
|
+
export {
|
|
33
|
+
buildPersistedIndexCallbacks,
|
|
34
|
+
buildRetrievalDocs,
|
|
35
|
+
embedOnWrite,
|
|
36
|
+
flushIndex,
|
|
37
|
+
hasIndexedBlobFields,
|
|
38
|
+
rebuildEmbeddings,
|
|
39
|
+
retrieve,
|
|
40
|
+
search,
|
|
41
|
+
similarTo,
|
|
42
|
+
syncTierSearch,
|
|
43
|
+
warmIndex
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=collection-facade-ZJK5EB33.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComputedFieldError,
|
|
3
3
|
evalComputedFields
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-GDGTIWB4.js";
|
|
5
|
+
import "./chunk-P7L3OQLL.js";
|
|
6
6
|
import "./chunk-PZ5AY32C.js";
|
|
7
7
|
export {
|
|
8
8
|
ComputedFieldError,
|
|
9
9
|
evalComputedFields
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=computed-
|
|
11
|
+
//# sourceMappingURL=computed-UHCBRILW.js.map
|
package/dist/consent/index.js
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
CONSENT_AUDIT_COLLECTION,
|
|
3
3
|
loadConsentEntries,
|
|
4
4
|
writeConsentEntry
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-NYSD43OE.js";
|
|
6
6
|
import {
|
|
7
7
|
NO_CONSENT
|
|
8
8
|
} from "../chunk-PEOZ34EM.js";
|
|
9
9
|
import "../chunk-4AOERLTV.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-D5UDZANO.js";
|
|
11
|
+
import "../chunk-ZVAFJQZB.js";
|
|
12
|
+
import "../chunk-OQLYMBJI.js";
|
|
13
|
+
import "../chunk-DJ23QZIN.js";
|
|
14
|
+
import "../chunk-SFD2LL7G.js";
|
|
15
15
|
import "../chunk-LP7BEXCT.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-VJ4B3ZXY.js";
|
|
17
|
+
import "../chunk-3Y4OFWQJ.js";
|
|
18
|
+
import "../chunk-P7L3OQLL.js";
|
|
19
19
|
import "../chunk-PZ5AY32C.js";
|
|
20
20
|
|
|
21
21
|
// src/with-audit/consent/active.ts
|
package/dist/cover/index.js
CHANGED
|
@@ -14,9 +14,16 @@ import {
|
|
|
14
14
|
saveCover,
|
|
15
15
|
validateCoverInput,
|
|
16
16
|
validateCoverSize
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
17
|
+
} from "../chunk-DYASJSKI.js";
|
|
18
|
+
import "../chunk-D5UDZANO.js";
|
|
19
|
+
import "../chunk-ZVAFJQZB.js";
|
|
20
|
+
import "../chunk-OQLYMBJI.js";
|
|
21
|
+
import "../chunk-DJ23QZIN.js";
|
|
22
|
+
import "../chunk-SFD2LL7G.js";
|
|
23
|
+
import "../chunk-LP7BEXCT.js";
|
|
24
|
+
import "../chunk-VJ4B3ZXY.js";
|
|
25
|
+
import "../chunk-3Y4OFWQJ.js";
|
|
26
|
+
import "../chunk-P7L3OQLL.js";
|
|
20
27
|
import "../chunk-PZ5AY32C.js";
|
|
21
28
|
export {
|
|
22
29
|
COVER_FIELDS,
|
package/dist/custody/index.js
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
CustodyApi,
|
|
3
3
|
NO_CUSTODY,
|
|
4
4
|
withCustody
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-HUYNPLTT.js";
|
|
6
|
+
import "../chunk-E6WANBD6.js";
|
|
7
|
+
import "../chunk-JHO6FGZX.js";
|
|
8
|
+
import "../chunk-D5UDZANO.js";
|
|
9
|
+
import "../chunk-ZVAFJQZB.js";
|
|
10
|
+
import "../chunk-OQLYMBJI.js";
|
|
11
|
+
import "../chunk-DJ23QZIN.js";
|
|
12
|
+
import "../chunk-SFD2LL7G.js";
|
|
13
13
|
import "../chunk-LP7BEXCT.js";
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-VJ4B3ZXY.js";
|
|
15
|
+
import "../chunk-3Y4OFWQJ.js";
|
|
16
16
|
import {
|
|
17
17
|
CustodyNotEnabledError
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-P7L3OQLL.js";
|
|
19
19
|
import "../chunk-PZ5AY32C.js";
|
|
20
20
|
export {
|
|
21
21
|
CustodyApi,
|
|
@@ -5,7 +5,7 @@ import "./chunk-PZ5AY32C.js";
|
|
|
5
5
|
|
|
6
6
|
// src/with-shape/satellites/dead-filter.ts
|
|
7
7
|
async function liveBaseIdSetsForBundle(store, vaultName, collectionNames, getDEK) {
|
|
8
|
-
const { loadPersistedSchema } = await import("./storage-
|
|
8
|
+
const { loadPersistedSchema } = await import("./storage-MJHKNQRO.js");
|
|
9
9
|
const out = /* @__PURE__ */ new Map();
|
|
10
10
|
for (const name of collectionNames) {
|
|
11
11
|
if (name.startsWith("_")) continue;
|
|
@@ -25,4 +25,4 @@ async function liveBaseIdSetsForBundle(store, vaultName, collectionNames, getDEK
|
|
|
25
25
|
export {
|
|
26
26
|
liveBaseIdSetsForBundle
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=dead-filter-
|
|
28
|
+
//# sourceMappingURL=dead-filter-777VWDER.js.map
|