@noy-db/hub 0.6.0-pre.8 → 0.6.0
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/CHANGELOG.md +7079 -0
- package/codemods/0.6.0-pre.json +211 -0
- package/dist/api-6X2VLZ7J.js +20 -0
- package/dist/attestation/index.js +19 -19
- package/dist/{backup-KULFZ2T4.js → backup-VL4GRIEW.js} +36 -18
- package/dist/backup-VL4GRIEW.js.map +1 -0
- package/dist/blobs/index.js +22 -20
- package/dist/blobs/index.js.map +1 -1
- package/dist/broker/index.js +12 -12
- package/dist/cargo/index.js +35 -35
- package/dist/{chunk-KUDZVJKQ.js → chunk-22GR3O4J.js} +2 -2
- package/dist/{chunk-CCZJJ4I2.js → chunk-2CBFYXJX.js} +6 -6
- package/dist/{chunk-JJNOLSG5.js → chunk-2J5IT37K.js} +15 -16
- package/dist/chunk-2J5IT37K.js.map +1 -0
- package/dist/{chunk-PNKHAKQ7.js → chunk-2ZCWHCLF.js} +17 -10
- package/dist/chunk-2ZCWHCLF.js.map +1 -0
- package/dist/{chunk-2BMRJ6LQ.js → chunk-2ZT4INZ4.js} +8 -11
- package/dist/{chunk-2BMRJ6LQ.js.map → chunk-2ZT4INZ4.js.map} +1 -1
- package/dist/{chunk-FAXZQ5UF.js → chunk-323MN67Z.js} +2 -2
- package/dist/{chunk-VMCCGUQB.js → chunk-36CEG6CM.js} +2 -2
- package/dist/{chunk-PDLLCOGD.js → chunk-3OE2QNSM.js} +20 -17
- package/dist/chunk-3OE2QNSM.js.map +1 -0
- package/dist/{chunk-AHLJSVRL.js → chunk-3YGUHUJA.js} +5 -7
- package/dist/chunk-3YGUHUJA.js.map +1 -0
- package/dist/{chunk-ZJADGNYF.js → chunk-4AOERLTV.js} +1 -1
- package/dist/chunk-4AOERLTV.js.map +1 -0
- package/dist/{chunk-J7FM3RAU.js → chunk-4ATF4BLF.js} +87 -34
- package/dist/chunk-4ATF4BLF.js.map +1 -0
- package/dist/{chunk-747LRSOO.js → chunk-4K6BIMLF.js} +2 -2
- package/dist/{chunk-PXCBVDFY.js → chunk-5ATC6UT4.js} +40 -7
- package/dist/chunk-5ATC6UT4.js.map +1 -0
- package/dist/{chunk-4GZ6XOVW.js → chunk-5F7BZAGV.js} +44 -42
- package/dist/chunk-5F7BZAGV.js.map +1 -0
- package/dist/{chunk-FNSMZQS4.js → chunk-5IHGJHWC.js} +2 -2
- package/dist/{chunk-4I72F5DF.js → chunk-5LZZQMIC.js} +11 -14
- package/dist/chunk-5LZZQMIC.js.map +1 -0
- package/dist/{chunk-JXIDGFKS.js → chunk-5O5ZSW7N.js} +4 -2
- package/dist/chunk-5O5ZSW7N.js.map +1 -0
- package/dist/{chunk-CEJWMBXO.js → chunk-5OT4G5N5.js} +6 -2
- package/dist/chunk-5OT4G5N5.js.map +1 -0
- package/dist/{chunk-GAG7QOVO.js → chunk-64WHKBMP.js} +53 -18
- package/dist/chunk-64WHKBMP.js.map +1 -0
- package/dist/{chunk-7TSYBD3E.js → chunk-65JXA63J.js} +2 -2
- package/dist/{chunk-Z45YRGFO.js → chunk-6NR36UNB.js} +2 -2
- package/dist/{chunk-W77KZHCW.js → chunk-6RH7PRTL.js} +16 -17
- package/dist/chunk-6RH7PRTL.js.map +1 -0
- package/dist/{chunk-3JVXVJ7L.js → chunk-7OBIBPCV.js} +10 -10
- package/dist/{chunk-AR2JDFAE.js → chunk-7Q3RHOA5.js} +2 -2
- package/dist/chunk-7ZGPQOFV.js +190 -0
- package/dist/chunk-7ZGPQOFV.js.map +1 -0
- package/dist/{chunk-QULVCV3M.js → chunk-AJGGBXWA.js} +4 -4
- package/dist/{chunk-CADUYBQD.js → chunk-ATL3ZVXT.js} +2 -2
- package/dist/{chunk-DMQCLZ4Z.js → chunk-ATY3ZASK.js} +2 -2
- package/dist/{chunk-4HDYQL3J.js → chunk-B4CRUZPR.js} +2 -2
- package/dist/{chunk-IMZLOJTK.js → chunk-BMU2DS3S.js} +30 -21
- package/dist/chunk-BMU2DS3S.js.map +1 -0
- package/dist/{chunk-6SAFL5YE.js → chunk-BZ3WMOYX.js} +3 -3
- package/dist/{chunk-UHXCLPGC.js → chunk-C3XWJCG7.js} +2 -2
- package/dist/chunk-C3XWJCG7.js.map +1 -0
- package/dist/{chunk-HXGUIPQB.js → chunk-CKKN25P2.js} +3 -3
- package/dist/{chunk-3URQC7EH.js → chunk-CXPOG3ZY.js} +355 -132
- package/dist/chunk-CXPOG3ZY.js.map +1 -0
- package/dist/{chunk-3FSX6LDG.js → chunk-D2YFQ7XG.js} +18 -3
- package/dist/{chunk-3FSX6LDG.js.map → chunk-D2YFQ7XG.js.map} +1 -1
- package/dist/{chunk-52JPHN5N.js → chunk-D6SXRMZZ.js} +27 -149
- package/dist/chunk-D6SXRMZZ.js.map +1 -0
- package/dist/{chunk-2DHSSLOD.js → chunk-DECNV4QK.js} +13 -15
- package/dist/chunk-DECNV4QK.js.map +1 -0
- package/dist/{chunk-6BU3L4UE.js → chunk-DNKVKO7K.js} +7 -10
- package/dist/chunk-DNKVKO7K.js.map +1 -0
- package/dist/{chunk-6HFM7EIT.js → chunk-EHRIDNZX.js} +2 -2
- package/dist/{chunk-3737A6EA.js → chunk-EHW7NLGD.js} +127 -31
- package/dist/chunk-EHW7NLGD.js.map +1 -0
- package/dist/{chunk-BEFVYAR5.js → chunk-EQOTJL76.js} +4 -4
- package/dist/chunk-EQOTJL76.js.map +1 -0
- package/dist/{chunk-E6427JU2.js → chunk-EV2TDHQZ.js} +19 -3
- package/dist/chunk-EV2TDHQZ.js.map +1 -0
- package/dist/{chunk-WFUIE565.js → chunk-FNYCT27B.js} +17 -14
- package/dist/chunk-FNYCT27B.js.map +1 -0
- package/dist/{chunk-RTAMLDWP.js → chunk-FU5VYEYK.js} +2 -2
- package/dist/chunk-FX3UIDCS.js +66 -0
- package/dist/chunk-FX3UIDCS.js.map +1 -0
- package/dist/{chunk-7F4DBNSP.js → chunk-GANFIM2M.js} +135 -18
- package/dist/chunk-GANFIM2M.js.map +1 -0
- package/dist/{chunk-4VUPLMZ6.js → chunk-GCU42IG7.js} +66 -71
- package/dist/chunk-GCU42IG7.js.map +1 -0
- package/dist/{chunk-RXYYFSBB.js → chunk-GKTW3KLV.js} +4 -4
- package/dist/chunk-HK67PX4J.js +27 -0
- package/dist/chunk-HK67PX4J.js.map +1 -0
- package/dist/{chunk-OF3L2SD6.js → chunk-HOPNIR5R.js} +2 -2
- package/dist/{chunk-WLZ47GSL.js → chunk-HSJBJIB2.js} +12 -10
- package/dist/{chunk-WLZ47GSL.js.map → chunk-HSJBJIB2.js.map} +1 -1
- package/dist/{chunk-ADW22QSB.js → chunk-HWI7GHJZ.js} +4 -4
- package/dist/{chunk-GQ3BX5EA.js → chunk-I3ISCYT7.js} +2 -2
- package/dist/{chunk-YJ6IONGA.js → chunk-IWKCJCLP.js} +11 -3
- package/dist/{chunk-YJ6IONGA.js.map → chunk-IWKCJCLP.js.map} +1 -1
- package/dist/{chunk-NJDQ4YSV.js → chunk-IWQPYT6S.js} +4 -4
- package/dist/{chunk-JRKZTEZZ.js → chunk-J6I5VR6P.js} +444 -73
- package/dist/chunk-J6I5VR6P.js.map +1 -0
- package/dist/{chunk-2Z3NCLNX.js → chunk-JHYKSMVX.js} +7 -7
- package/dist/{chunk-6FJWSWFT.js → chunk-JIHWBKMQ.js} +3 -3
- package/dist/{chunk-YAWK6AWF.js → chunk-JKATP6OE.js} +2 -2
- package/dist/{chunk-PL2GHSCM.js → chunk-JMJSCI7U.js} +157 -90
- package/dist/chunk-JMJSCI7U.js.map +1 -0
- package/dist/{chunk-Q6TEJXBX.js → chunk-JXHNUYQO.js} +31 -49
- package/dist/chunk-JXHNUYQO.js.map +1 -0
- package/dist/{chunk-WK5XUYYF.js → chunk-JYPRZWCZ.js} +473 -231
- package/dist/chunk-JYPRZWCZ.js.map +1 -0
- package/dist/{chunk-5ZKS6ZE2.js → chunk-K6CPIK3R.js} +4 -4
- package/dist/chunk-K6CPIK3R.js.map +1 -0
- package/dist/{chunk-CDB2HVQW.js → chunk-KM6ZXG7U.js} +14 -15
- package/dist/chunk-KM6ZXG7U.js.map +1 -0
- package/dist/{chunk-DG27IUVI.js → chunk-LC6NE4IQ.js} +2 -2
- package/dist/{chunk-WASHZV34.js → chunk-LIR2DJWP.js} +63 -25
- package/dist/chunk-LIR2DJWP.js.map +1 -0
- package/dist/{chunk-VZ3XFUQ7.js → chunk-LUYPYCHY.js} +16 -22
- package/dist/chunk-LUYPYCHY.js.map +1 -0
- package/dist/{chunk-G6S5VVHP.js → chunk-M7WBE3OR.js} +10 -10
- package/dist/chunk-M7WBE3OR.js.map +1 -0
- package/dist/{chunk-VJFMXYKP.js → chunk-MPKP6L5E.js} +2 -2
- package/dist/{chunk-IGJCYUT5.js → chunk-NSITFOCJ.js} +1 -1
- package/dist/chunk-NSITFOCJ.js.map +1 -0
- package/dist/{chunk-FUHKW252.js → chunk-OCJ3JA4O.js} +2 -2
- package/dist/{chunk-VCETL77O.js → chunk-ONPVHX2Y.js} +36 -7
- package/dist/chunk-ONPVHX2Y.js.map +1 -0
- package/dist/{chunk-WLYIROCJ.js → chunk-OQMCFHUX.js} +2 -2
- package/dist/{chunk-JRCYZEHU.js → chunk-OR2FYRYR.js} +2 -2
- package/dist/{chunk-HNHCQ556.js → chunk-PFWE7FJG.js} +2 -2
- package/dist/{chunk-NPP5R7FF.js → chunk-PJX72ICF.js} +22 -18
- package/dist/chunk-PJX72ICF.js.map +1 -0
- package/dist/{chunk-U5O6GIWZ.js → chunk-POFYIGQ2.js} +3 -3
- package/dist/{chunk-35EBKWQU.js → chunk-QH47SQLD.js} +4 -4
- package/dist/{chunk-FZ6NYJ7L.js → chunk-QQRRKO7W.js} +11 -8
- package/dist/chunk-QQRRKO7W.js.map +1 -0
- package/dist/{chunk-HVQGCKY4.js → chunk-QVXZFJBU.js} +2 -2
- package/dist/{chunk-FMQJZH4R.js → chunk-RDB66EKD.js} +6 -6
- package/dist/{chunk-X56RTUK3.js → chunk-RJZQ2PVD.js} +3 -3
- package/dist/{chunk-SUFG5E73.js → chunk-RPRASGEY.js} +2 -2
- package/dist/{chunk-XWX7GL56.js → chunk-S2I5MYSA.js} +7 -10
- package/dist/chunk-S2I5MYSA.js.map +1 -0
- package/dist/{chunk-FFDNKRCY.js → chunk-S6PJ6ZKE.js} +2 -2
- package/dist/chunk-S6PJ6ZKE.js.map +1 -0
- package/dist/{chunk-JIUVJ4M7.js → chunk-S7PM7Z4K.js} +3 -3
- package/dist/{chunk-55LKVALY.js → chunk-T7IR4N2S.js} +1 -3
- package/dist/chunk-T7IR4N2S.js.map +1 -0
- package/dist/{chunk-N35NC4JH.js → chunk-TKBB62DN.js} +2 -2
- package/dist/{chunk-YPYHVOXP.js → chunk-UJ4Z67UQ.js} +2 -2
- package/dist/chunk-UJ4Z67UQ.js.map +1 -0
- package/dist/{chunk-7MNBICB5.js → chunk-W3HAIN6U.js} +16 -14
- package/dist/chunk-W3HAIN6U.js.map +1 -0
- package/dist/{chunk-4UVDI4XE.js → chunk-WPZ5FVAS.js} +4 -4
- package/dist/{chunk-MSWYQLMQ.js → chunk-XINT4VJA.js} +2 -2
- package/dist/{chunk-7G6VDWXB.js → chunk-XPEPMK4Y.js} +3 -3
- package/dist/chunk-XPEPMK4Y.js.map +1 -0
- package/dist/{chunk-W3TVWF6N.js → chunk-YCGLAANM.js} +2 -2
- package/dist/{chunk-O2ERS4UJ.js → chunk-YTUFV7U7.js} +80 -51
- package/dist/chunk-YTUFV7U7.js.map +1 -0
- package/dist/{chunk-FDX7OWWI.js → chunk-YYV53EHO.js} +2 -2
- package/dist/{chunk-HNGSV2YC.js → chunk-Z3BZXPRO.js} +67 -10
- package/dist/chunk-Z3BZXPRO.js.map +1 -0
- package/dist/{chunk-6NVPFKN3.js → chunk-ZIMQDXTQ.js} +92 -35
- package/dist/chunk-ZIMQDXTQ.js.map +1 -0
- package/dist/{chunk-5JY5TSVY.js → chunk-ZJUZOJVW.js} +25 -31
- package/dist/chunk-ZJUZOJVW.js.map +1 -0
- package/dist/{chunk-3IXIU6FP.js → chunk-ZY6P7M52.js} +7 -10
- package/dist/chunk-ZY6P7M52.js.map +1 -0
- package/dist/{chunk-H73G4XF4.js → chunk-ZYZJLYNS.js} +7 -11
- package/dist/chunk-ZYZJLYNS.js.map +1 -0
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-2KJAXRRO.js → classified-marker-AZDSDG6V.js} +3 -3
- package/dist/collection-facade-WSUAYFJ4.js +45 -0
- package/dist/{computed-6G5M3UPH.js → computed-VG2PCM4L.js} +3 -3
- package/dist/consent/index.js +10 -10
- package/dist/cover/index.js +10 -3
- package/dist/custody/index.js +12 -11
- package/dist/{dead-filter-DCB62VWW.js → dead-filter-JNQNB3TA.js} +2 -2
- package/dist/debug/index.js +1 -1
- package/dist/{delegation-MO7YZYJS.js → delegation-5F36DRDH.js} +24 -23
- package/dist/delegation-5F36DRDH.js.map +1 -0
- package/dist/derivations/index.js +12 -12
- package/dist/derive-MPOGZ4NR.js +22 -0
- package/dist/directory/index.js +10 -10
- package/dist/{dispatch-MJ6SHB3Y.js → dispatch-3ZA733EY.js} +18 -18
- package/dist/{dispatch-FZEAWKVM.js → dispatch-TNM5CRLZ.js} +9 -6
- package/dist/dispatch-TNM5CRLZ.js.map +1 -0
- package/dist/{enclave-JU4YIEPB.js → enclave-Y2ALNDRD.js} +31 -9
- package/dist/executor-BBEEUFO3.js +9 -0
- package/dist/executor-G6G3YEWR.js +9 -0
- package/dist/executor-ZUTUMTPA.js +29 -0
- package/dist/export-accessible-S3KEB763.js +23 -0
- package/dist/extract-partition-KVCTSUVE.js +38 -0
- package/dist/{fanout-sidecar-NNAJQXMX.js → fanout-sidecar-3QZU7ZZX.js} +18 -27
- package/dist/fanout-sidecar-3QZU7ZZX.js.map +1 -0
- package/dist/find-V4FN5ITT.js +11 -0
- package/dist/forget/index.js +9 -9
- package/dist/guards/index.js +7 -7
- 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 +30 -13
- package/dist/index.js +180 -188
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +4 -4
- package/dist/introspection/index.js +11 -11
- package/dist/issue-5CFBWBRX.js +19 -0
- package/dist/kernel/collection.d.ts +8 -2
- package/dist/kernel/constants.d.ts +36 -0
- package/dist/kernel/enclave/crypto.d.ts +52 -4
- package/dist/kernel/enclave/index.d.ts +10 -3
- package/dist/kernel/enclave/record-aad.d.ts +131 -0
- package/dist/kernel/enclave/record-envelope.d.ts +76 -0
- 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-blob.d.ts +88 -0
- package/dist/kernel/enclave/record-keys/rekey.d.ts +91 -0
- package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -2
- package/dist/kernel/errors.d.ts +132 -12
- package/dist/kernel/merge-authority.d.ts +25 -0
- package/dist/kernel/noydb.d.ts +27 -4
- package/dist/kernel/query/builder.d.ts +51 -4
- package/dist/kernel/query/join.d.ts +27 -0
- package/dist/kernel/query/live.d.ts +31 -9
- package/dist/kernel/query/predicate.d.ts +9 -0
- package/dist/kernel/refs.d.ts +3 -1
- package/dist/kernel/sync-policy.d.ts +0 -2
- package/dist/kernel/tier-visibility.d.ts +34 -0
- package/dist/kernel/types.d.ts +111 -13
- package/dist/kernel/vault.d.ts +14 -8
- package/dist/kernel/via/index.d.ts +11 -2
- package/dist/kernel/via/reconcile.d.ts +12 -0
- package/dist/{ledger-AETNF4OM.js → ledger-MQIIOTZB.js} +11 -11
- package/dist/liberate-LW7OKVBH.js +25 -0
- package/dist/{link-set-E5HNY67I.js → link-set-5PJBBR63.js} +11 -11
- package/dist/{managed-secret-CWQ6PND5.js → managed-secret-ETDG6AAE.js} +11 -3
- package/dist/materialized-views/index.js +24 -24
- package/dist/migrate-cek-V3VDRV24.js +19 -0
- package/dist/migrate-cek-V3VDRV24.js.map +1 -0
- package/dist/money/index.js +5 -5
- package/dist/noydb-LFDRMYZ5.js +85 -0
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +18 -12
- package/dist/pod/index.js +79 -89
- package/dist/pod-handle-AZ3CXY5Y.js +41 -0
- package/dist/pod-handle-AZ3CXY5Y.js.map +1 -0
- package/dist/policy/index.js +11 -4
- package/dist/port/to/index.d.ts +4 -4
- package/dist/port/to/locator.d.ts +54 -8
- package/dist/port/with/i18n-strategy.d.ts +4 -1
- package/dist/port/with/lookup-strategy.d.ts +4 -1
- package/dist/port/with/merge-authority.d.ts +52 -0
- package/dist/port/with/service-bus.d.ts +0 -4
- package/dist/port/with/strategies.d.ts +2 -0
- package/dist/port/with/team-strategy.d.ts +5 -1
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-2XSSMGEQ.js → post-register-QCJYRMIK.js} +6 -6
- package/dist/query/index.js +6 -6
- package/dist/reduce/index.js +6 -6
- package/dist/register-JBOEHTVX.js +32 -0
- package/dist/registry-5DYHQFJS.js +9 -0
- package/dist/registry-EANV44W2.js +9 -0
- package/dist/registry-J25H6VB4.js +19 -0
- package/dist/registry-R23SQUQH.js +18 -0
- package/dist/request-withdrawal-KQ4W4UT5.js +31 -0
- package/dist/{reveal-BW36KCOQ.js → reveal-W7BKZSUP.js} +6 -6
- package/dist/revoke-H3VSTAIE.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-GDV5PT4R.js → seed-55FPOMYP.js} +20 -22
- package/dist/seed-55FPOMYP.js.map +1 -0
- package/dist/sequence/index.js +9 -9
- package/dist/session/index.js +10 -10
- package/dist/shadow/index.js +2 -2
- package/dist/share-link/index.js +1 -1
- package/dist/signer-53AQ3BU2.js +25 -0
- package/dist/snapshots/index.js +10 -10
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-ARHFVL5U.js → stale-TH7SSVRV.js} +10 -10
- package/dist/storage-WSF7ZKTL.js +23 -0
- package/dist/{store-coordination-provider-GFCUOBR6.js → store-coordination-provider-R27VRD6K.js} +18 -12
- package/dist/store-coordination-provider-R27VRD6K.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 +17 -9
- package/dist/to/index.js.map +1 -1
- package/dist/transactions/index.js +4 -4
- package/dist/{ulid-PTAIMDG4.js → ulid-VQW6ERQN.js} +2 -2
- package/dist/util/index.js +1 -1
- package/dist/vault-head/index.js +115 -0
- package/dist/vault-head/index.js.map +1 -0
- package/dist/{verify-RO5RTZOJ.js → verify-M5LQH43C.js} +5 -5
- package/dist/via/blob/index.d.ts +3 -0
- package/dist/via/lookup/handle.d.ts +4 -1
- package/dist/walk-NABCHDZN.js +21 -0
- package/dist/with-audit/periods/index.d.ts +3 -3
- package/dist/with-audit/periods/periods.d.ts +82 -2
- package/dist/with-audit/periods/strategy.d.ts +1 -1
- package/dist/with-audit/periods/vault-facade.d.ts +54 -1
- package/dist/with-audit/periods/window.d.ts +10 -0
- package/dist/with-audit/sealed-record/index.d.ts +13 -0
- package/dist/with-audit/tiers/index.d.ts +17 -2
- package/dist/with-cargo/adopt-partition.d.ts +1 -1
- package/dist/with-cargo/extract-partition.d.ts +1 -1
- package/dist/with-cargo/index.d.ts +1 -1
- 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/numbering/index.d.ts +0 -5
- 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 +90 -0
- package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -0
- package/dist/with-formula/materialized-views/projection-legs.d.ts +59 -0
- package/dist/with-formula/materialized-views/registry.d.ts +50 -0
- package/dist/with-formula/materialized-views/types.d.ts +68 -10
- 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/index.d.ts +1 -1
- package/dist/with-party/team/keyring.d.ts +139 -2
- package/dist/with-party/team/noydb-facade.d.ts +5 -1
- package/dist/with-party/team/roster-tag.d.ts +101 -0
- package/dist/with-party/team/tiers.d.ts +2 -1
- package/dist/with-pod/format.d.ts +10 -12
- package/dist/with-pod/index.d.ts +10 -10
- package/dist/with-pod/open.d.ts +2 -2
- package/dist/with-pod/pod-handle.d.ts +19 -0
- package/dist/with-pod/pod-store.d.ts +0 -8
- package/dist/with-pod/{bundle.d.ts → pod.d.ts} +11 -19
- package/dist/with-pod/ulid.d.ts +1 -1
- package/dist/with-shape/blobs/blob-compaction.d.ts +13 -0
- package/dist/with-shape/blobs/blob-set.d.ts +83 -11
- package/dist/with-shape/blobs/orphan-report.d.ts +62 -0
- package/dist/with-shape/introspection/index.d.ts +1 -0
- package/dist/with-sync/engine.d.ts +54 -5
- package/dist/with-sync/strategy.d.ts +3 -0
- package/dist/withdraw-accessible-VCINIG6V.js +28 -0
- package/package.json +10 -4
- package/dist/api-RXUMEKT3.js +0 -20
- package/dist/backup-KULFZ2T4.js.map +0 -1
- package/dist/bundle-handle-GFNHT52M.js +0 -36
- package/dist/bundle-handle-GFNHT52M.js.map +0 -1
- package/dist/chunk-2DHSSLOD.js.map +0 -1
- package/dist/chunk-3737A6EA.js.map +0 -1
- package/dist/chunk-3IXIU6FP.js.map +0 -1
- package/dist/chunk-3URQC7EH.js.map +0 -1
- package/dist/chunk-4GZ6XOVW.js.map +0 -1
- package/dist/chunk-4I72F5DF.js.map +0 -1
- package/dist/chunk-4VUPLMZ6.js.map +0 -1
- package/dist/chunk-52JPHN5N.js.map +0 -1
- package/dist/chunk-55LKVALY.js.map +0 -1
- package/dist/chunk-5JY5TSVY.js.map +0 -1
- package/dist/chunk-5ZKS6ZE2.js.map +0 -1
- package/dist/chunk-6BU3L4UE.js.map +0 -1
- package/dist/chunk-6NVPFKN3.js.map +0 -1
- package/dist/chunk-7F4DBNSP.js.map +0 -1
- package/dist/chunk-7G6VDWXB.js.map +0 -1
- package/dist/chunk-7H73RIE3.js +0 -45
- package/dist/chunk-7H73RIE3.js.map +0 -1
- package/dist/chunk-7MNBICB5.js.map +0 -1
- package/dist/chunk-AFHQATY4.js +0 -47
- package/dist/chunk-AFHQATY4.js.map +0 -1
- package/dist/chunk-AHLJSVRL.js.map +0 -1
- package/dist/chunk-BEFVYAR5.js.map +0 -1
- package/dist/chunk-CDB2HVQW.js.map +0 -1
- package/dist/chunk-CEJWMBXO.js.map +0 -1
- package/dist/chunk-E6427JU2.js.map +0 -1
- package/dist/chunk-FFDNKRCY.js.map +0 -1
- package/dist/chunk-FZ6NYJ7L.js.map +0 -1
- package/dist/chunk-G6S5VVHP.js.map +0 -1
- package/dist/chunk-GAG7QOVO.js.map +0 -1
- package/dist/chunk-H73G4XF4.js.map +0 -1
- package/dist/chunk-HNGSV2YC.js.map +0 -1
- package/dist/chunk-IGJCYUT5.js.map +0 -1
- package/dist/chunk-IMZLOJTK.js.map +0 -1
- package/dist/chunk-J7FM3RAU.js.map +0 -1
- package/dist/chunk-JJNOLSG5.js.map +0 -1
- package/dist/chunk-JRKZTEZZ.js.map +0 -1
- package/dist/chunk-JXIDGFKS.js.map +0 -1
- package/dist/chunk-NPP5R7FF.js.map +0 -1
- package/dist/chunk-O2ERS4UJ.js.map +0 -1
- package/dist/chunk-PDLLCOGD.js.map +0 -1
- package/dist/chunk-PL2GHSCM.js.map +0 -1
- package/dist/chunk-PNKHAKQ7.js.map +0 -1
- package/dist/chunk-PXCBVDFY.js.map +0 -1
- package/dist/chunk-Q6TEJXBX.js.map +0 -1
- package/dist/chunk-UHXCLPGC.js.map +0 -1
- package/dist/chunk-VCETL77O.js.map +0 -1
- package/dist/chunk-VZ3XFUQ7.js.map +0 -1
- package/dist/chunk-W77KZHCW.js.map +0 -1
- package/dist/chunk-WASHZV34.js.map +0 -1
- package/dist/chunk-WFUIE565.js.map +0 -1
- package/dist/chunk-WK5XUYYF.js.map +0 -1
- package/dist/chunk-XWX7GL56.js.map +0 -1
- package/dist/chunk-YPYHVOXP.js.map +0 -1
- package/dist/chunk-ZJADGNYF.js.map +0 -1
- package/dist/collection-facade-QEJIM6BC.js +0 -45
- package/dist/delegation-MO7YZYJS.js.map +0 -1
- package/dist/derive-IUA6JFLB.js +0 -22
- package/dist/dispatch-FZEAWKVM.js.map +0 -1
- package/dist/executor-CYJQLKKI.js +0 -9
- package/dist/executor-S4QIKEHW.js +0 -9
- package/dist/executor-YIQB2S6N.js +0 -29
- package/dist/export-accessible-4S36PQNR.js +0 -23
- package/dist/extract-partition-IO7FDZ2P.js +0 -38
- package/dist/fanout-sidecar-NNAJQXMX.js.map +0 -1
- package/dist/find-RBBYKXI7.js +0 -11
- package/dist/issue-RIVHSY2S.js +0 -19
- package/dist/liberate-GFN4C7RR.js +0 -24
- package/dist/noydb-3MT74MZS.js +0 -83
- package/dist/register-4EFJCVYD.js +0 -32
- package/dist/registry-4SDHHOJ7.js +0 -18
- package/dist/registry-CZVINVQH.js +0 -9
- package/dist/registry-IKUR2MXD.js +0 -9
- package/dist/registry-OYTFGWVK.js +0 -19
- package/dist/request-withdrawal-KGXGDPVQ.js +0 -31
- package/dist/revoke-JFN773KF.js +0 -24
- package/dist/seed-GDV5PT4R.js.map +0 -1
- package/dist/signer-TA55QB6R.js +0 -25
- package/dist/storage-V7MTFAQJ.js +0 -23
- package/dist/store-coordination-provider-GFCUOBR6.js.map +0 -1
- package/dist/walk-3ZECBFDA.js +0 -21
- package/dist/with-pod/bundle-handle.d.ts +0 -9
- package/dist/withdraw-accessible-7PG4DYQK.js +0 -28
- /package/dist/{api-RXUMEKT3.js.map → api-6X2VLZ7J.js.map} +0 -0
- /package/dist/{chunk-KUDZVJKQ.js.map → chunk-22GR3O4J.js.map} +0 -0
- /package/dist/{chunk-CCZJJ4I2.js.map → chunk-2CBFYXJX.js.map} +0 -0
- /package/dist/{chunk-FAXZQ5UF.js.map → chunk-323MN67Z.js.map} +0 -0
- /package/dist/{chunk-VMCCGUQB.js.map → chunk-36CEG6CM.js.map} +0 -0
- /package/dist/{chunk-747LRSOO.js.map → chunk-4K6BIMLF.js.map} +0 -0
- /package/dist/{chunk-FNSMZQS4.js.map → chunk-5IHGJHWC.js.map} +0 -0
- /package/dist/{chunk-7TSYBD3E.js.map → chunk-65JXA63J.js.map} +0 -0
- /package/dist/{chunk-Z45YRGFO.js.map → chunk-6NR36UNB.js.map} +0 -0
- /package/dist/{chunk-3JVXVJ7L.js.map → chunk-7OBIBPCV.js.map} +0 -0
- /package/dist/{chunk-AR2JDFAE.js.map → chunk-7Q3RHOA5.js.map} +0 -0
- /package/dist/{chunk-QULVCV3M.js.map → chunk-AJGGBXWA.js.map} +0 -0
- /package/dist/{chunk-CADUYBQD.js.map → chunk-ATL3ZVXT.js.map} +0 -0
- /package/dist/{chunk-DMQCLZ4Z.js.map → chunk-ATY3ZASK.js.map} +0 -0
- /package/dist/{chunk-4HDYQL3J.js.map → chunk-B4CRUZPR.js.map} +0 -0
- /package/dist/{chunk-6SAFL5YE.js.map → chunk-BZ3WMOYX.js.map} +0 -0
- /package/dist/{chunk-HXGUIPQB.js.map → chunk-CKKN25P2.js.map} +0 -0
- /package/dist/{chunk-6HFM7EIT.js.map → chunk-EHRIDNZX.js.map} +0 -0
- /package/dist/{chunk-RTAMLDWP.js.map → chunk-FU5VYEYK.js.map} +0 -0
- /package/dist/{chunk-RXYYFSBB.js.map → chunk-GKTW3KLV.js.map} +0 -0
- /package/dist/{chunk-OF3L2SD6.js.map → chunk-HOPNIR5R.js.map} +0 -0
- /package/dist/{chunk-ADW22QSB.js.map → chunk-HWI7GHJZ.js.map} +0 -0
- /package/dist/{chunk-GQ3BX5EA.js.map → chunk-I3ISCYT7.js.map} +0 -0
- /package/dist/{chunk-NJDQ4YSV.js.map → chunk-IWQPYT6S.js.map} +0 -0
- /package/dist/{chunk-2Z3NCLNX.js.map → chunk-JHYKSMVX.js.map} +0 -0
- /package/dist/{chunk-6FJWSWFT.js.map → chunk-JIHWBKMQ.js.map} +0 -0
- /package/dist/{chunk-YAWK6AWF.js.map → chunk-JKATP6OE.js.map} +0 -0
- /package/dist/{chunk-DG27IUVI.js.map → chunk-LC6NE4IQ.js.map} +0 -0
- /package/dist/{chunk-VJFMXYKP.js.map → chunk-MPKP6L5E.js.map} +0 -0
- /package/dist/{chunk-FUHKW252.js.map → chunk-OCJ3JA4O.js.map} +0 -0
- /package/dist/{chunk-WLYIROCJ.js.map → chunk-OQMCFHUX.js.map} +0 -0
- /package/dist/{chunk-JRCYZEHU.js.map → chunk-OR2FYRYR.js.map} +0 -0
- /package/dist/{chunk-HNHCQ556.js.map → chunk-PFWE7FJG.js.map} +0 -0
- /package/dist/{chunk-U5O6GIWZ.js.map → chunk-POFYIGQ2.js.map} +0 -0
- /package/dist/{chunk-35EBKWQU.js.map → chunk-QH47SQLD.js.map} +0 -0
- /package/dist/{chunk-HVQGCKY4.js.map → chunk-QVXZFJBU.js.map} +0 -0
- /package/dist/{chunk-FMQJZH4R.js.map → chunk-RDB66EKD.js.map} +0 -0
- /package/dist/{chunk-X56RTUK3.js.map → chunk-RJZQ2PVD.js.map} +0 -0
- /package/dist/{chunk-SUFG5E73.js.map → chunk-RPRASGEY.js.map} +0 -0
- /package/dist/{chunk-JIUVJ4M7.js.map → chunk-S7PM7Z4K.js.map} +0 -0
- /package/dist/{chunk-N35NC4JH.js.map → chunk-TKBB62DN.js.map} +0 -0
- /package/dist/{chunk-4UVDI4XE.js.map → chunk-WPZ5FVAS.js.map} +0 -0
- /package/dist/{chunk-MSWYQLMQ.js.map → chunk-XINT4VJA.js.map} +0 -0
- /package/dist/{chunk-W3TVWF6N.js.map → chunk-YCGLAANM.js.map} +0 -0
- /package/dist/{chunk-FDX7OWWI.js.map → chunk-YYV53EHO.js.map} +0 -0
- /package/dist/{classified-marker-2KJAXRRO.js.map → classified-marker-AZDSDG6V.js.map} +0 -0
- /package/dist/{collection-facade-QEJIM6BC.js.map → collection-facade-WSUAYFJ4.js.map} +0 -0
- /package/dist/{computed-6G5M3UPH.js.map → computed-VG2PCM4L.js.map} +0 -0
- /package/dist/{dead-filter-DCB62VWW.js.map → dead-filter-JNQNB3TA.js.map} +0 -0
- /package/dist/{derive-IUA6JFLB.js.map → derive-MPOGZ4NR.js.map} +0 -0
- /package/dist/{dispatch-MJ6SHB3Y.js.map → dispatch-3ZA733EY.js.map} +0 -0
- /package/dist/{enclave-JU4YIEPB.js.map → enclave-Y2ALNDRD.js.map} +0 -0
- /package/dist/{executor-CYJQLKKI.js.map → executor-BBEEUFO3.js.map} +0 -0
- /package/dist/{executor-S4QIKEHW.js.map → executor-G6G3YEWR.js.map} +0 -0
- /package/dist/{executor-YIQB2S6N.js.map → executor-ZUTUMTPA.js.map} +0 -0
- /package/dist/{export-accessible-4S36PQNR.js.map → export-accessible-S3KEB763.js.map} +0 -0
- /package/dist/{extract-partition-IO7FDZ2P.js.map → extract-partition-KVCTSUVE.js.map} +0 -0
- /package/dist/{find-RBBYKXI7.js.map → find-V4FN5ITT.js.map} +0 -0
- /package/dist/{issue-RIVHSY2S.js.map → issue-5CFBWBRX.js.map} +0 -0
- /package/dist/{ledger-AETNF4OM.js.map → ledger-MQIIOTZB.js.map} +0 -0
- /package/dist/{liberate-GFN4C7RR.js.map → liberate-LW7OKVBH.js.map} +0 -0
- /package/dist/{link-set-E5HNY67I.js.map → link-set-5PJBBR63.js.map} +0 -0
- /package/dist/{managed-secret-CWQ6PND5.js.map → managed-secret-ETDG6AAE.js.map} +0 -0
- /package/dist/{noydb-3MT74MZS.js.map → noydb-LFDRMYZ5.js.map} +0 -0
- /package/dist/{post-register-2XSSMGEQ.js.map → post-register-QCJYRMIK.js.map} +0 -0
- /package/dist/{register-4EFJCVYD.js.map → register-JBOEHTVX.js.map} +0 -0
- /package/dist/{registry-4SDHHOJ7.js.map → registry-5DYHQFJS.js.map} +0 -0
- /package/dist/{registry-CZVINVQH.js.map → registry-EANV44W2.js.map} +0 -0
- /package/dist/{registry-IKUR2MXD.js.map → registry-J25H6VB4.js.map} +0 -0
- /package/dist/{registry-OYTFGWVK.js.map → registry-R23SQUQH.js.map} +0 -0
- /package/dist/{request-withdrawal-KGXGDPVQ.js.map → request-withdrawal-KQ4W4UT5.js.map} +0 -0
- /package/dist/{reveal-BW36KCOQ.js.map → reveal-W7BKZSUP.js.map} +0 -0
- /package/dist/{revoke-JFN773KF.js.map → revoke-H3VSTAIE.js.map} +0 -0
- /package/dist/{signer-TA55QB6R.js.map → signer-53AQ3BU2.js.map} +0 -0
- /package/dist/{stale-ARHFVL5U.js.map → stale-TH7SSVRV.js.map} +0 -0
- /package/dist/{storage-V7MTFAQJ.js.map → storage-WSF7ZKTL.js.map} +0 -0
- /package/dist/{ulid-PTAIMDG4.js.map → ulid-VQW6ERQN.js.map} +0 -0
- /package/dist/{verify-RO5RTZOJ.js.map → verify-M5LQH43C.js.map} +0 -0
- /package/dist/{walk-3ZECBFDA.js.map → walk-NABCHDZN.js.map} +0 -0
- /package/dist/{withdraw-accessible-7PG4DYQK.js.map → withdraw-accessible-VCINIG6V.js.map} +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record-identity AAD (#1041).
|
|
3
|
+
*
|
|
4
|
+
* AES-GCM authenticates its *additional authenticated data* alongside the
|
|
5
|
+
* ciphertext without encrypting it. Binding a record's identity here is what
|
|
6
|
+
* stops an untrusted store from silently **relocating** an envelope — moving
|
|
7
|
+
* it to another collection or id, re-tiering it, or rewriting who
|
|
8
|
+
* wrote it — while keeping a body whose auth tag still verifies.
|
|
9
|
+
*
|
|
10
|
+
* Scope, stated plainly: this closes cross-COLLECTION relocation, the `_tier`
|
|
11
|
+
* silent-hide, provenance forgery — and, since #1093, **version rollback**.
|
|
12
|
+
*
|
|
13
|
+
* ## `_v` is bound, and what it took to get there
|
|
14
|
+
*
|
|
15
|
+
* `_v` was deliberately left out at first, for a reason that was real rather
|
|
16
|
+
* than cautious: the sync engine re-stamped `_v` on existing ciphertext without
|
|
17
|
+
* holding a DEK (`advancePastRemote`), so binding it would have made every
|
|
18
|
+
* conflict-superseded record undecryptable. #1042's `MergeAuthority` removed
|
|
19
|
+
* that obstacle by giving the merge a DEK-holding capability, so advancing a
|
|
20
|
+
* version became a **re-seal** instead of a metadata edit — and only then could
|
|
21
|
+
* `_v` join the tuple.
|
|
22
|
+
*
|
|
23
|
+
* ⚠️ **What that buys, stated exactly** — the harness measured this, and the
|
|
24
|
+
* loose version ("rollback is prevented") is wrong.
|
|
25
|
+
*
|
|
26
|
+
* A body can no longer be presented at a version it was not sealed at. So the
|
|
27
|
+
* *restamped* rollback — take v1's bytes, label them v9, win the convergence
|
|
28
|
+
* comparison, overwrite the newer copy — is refused, and refused **before**
|
|
29
|
+
* `local.put`, so nothing is lost.
|
|
30
|
+
*
|
|
31
|
+
* A store re-serving the genuine v1 **at its own `_v: 1`** is still served, and
|
|
32
|
+
* has to be: that envelope is internally consistent, and a reader arriving
|
|
33
|
+
* fresh has nothing to compare it against. AAD binds a body to the version it
|
|
34
|
+
* claims; it cannot know which version *should* have arrived.
|
|
35
|
+
*
|
|
36
|
+
* So rollback stops being forgery and becomes **withholding** — hiding the newer
|
|
37
|
+
* version rather than faking one — which is `withVaultHead()`'s job (#1044).
|
|
38
|
+
*
|
|
39
|
+
* ## Why `vault` is not bound
|
|
40
|
+
*
|
|
41
|
+
* It was, briefly, and it broke `adoptPartition`. That path re-homes a whole
|
|
42
|
+
* partition into a new vault name by moving envelopes **verbatim** —
|
|
43
|
+
* `with-cargo/adopt-partition.ts:140` is a bare
|
|
44
|
+
* `destinationStore.saveAll(vaultName, backup.collections)` with no
|
|
45
|
+
* re-encryption, because it does not hold the keys to re-encrypt at that
|
|
46
|
+
* point. Binding the vault name makes every adopted record undecryptable.
|
|
47
|
+
*
|
|
48
|
+
* The uncomfortable truth behind that: **relocation is not purely an attack.**
|
|
49
|
+
* Adoption is a legitimate, supported relocation, and AAD cannot tell the two
|
|
50
|
+
* apart. So the vault boundary has to be defended by something that can
|
|
51
|
+
* distinguish intent — an authenticated head or an explicit re-key — rather
|
|
52
|
+
* than by sealing a name the product deliberately changes.
|
|
53
|
+
*
|
|
54
|
+
* Cross-*collection* relocation has no such legitimate counterpart, so it stays
|
|
55
|
+
* bound.
|
|
56
|
+
*
|
|
57
|
+
* @packageDocumentation
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Where an envelope was fetched from — the **read** side's half of identity.
|
|
61
|
+
*
|
|
62
|
+
* A reader supplies only the address, because that is genuinely all it knows:
|
|
63
|
+
* `_tier`, `_by` and `_v` are read back off the envelope itself
|
|
64
|
+
* ({@link recordAadFor}). Splitting this out of {@link RecordIdentity} is what
|
|
65
|
+
* lets `version` be *required* on the write side without forcing dozens of read
|
|
66
|
+
* call sites to invent one.
|
|
67
|
+
*/
|
|
68
|
+
export interface RecordRef {
|
|
69
|
+
readonly collection: string;
|
|
70
|
+
readonly id: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The identity an envelope's body is sealed against — the **write** side.
|
|
74
|
+
*
|
|
75
|
+
* Every field here is stamped onto the envelope by `buildRecordEnvelope` from
|
|
76
|
+
* this one object, so what a writer *seals* and what it *stamps* cannot drift.
|
|
77
|
+
*/
|
|
78
|
+
export interface RecordIdentity extends RecordRef {
|
|
79
|
+
/**
|
|
80
|
+
* The `_v` this body is sealed at (#1093).
|
|
81
|
+
*
|
|
82
|
+
* Required, and required is the point: a version that could be omitted would
|
|
83
|
+
* be a version some writer forgets, and a record sealed at a version nobody
|
|
84
|
+
* chose is one a reader cannot open. The compiler asks the question at every
|
|
85
|
+
* write site instead of leaving it to review.
|
|
86
|
+
*/
|
|
87
|
+
readonly version: number;
|
|
88
|
+
/** Absent is identical to `0` — the read paths treat them as one record. */
|
|
89
|
+
readonly tier?: number | undefined;
|
|
90
|
+
/** Absent (no `_by` on the envelope) is distinct from an empty string. */
|
|
91
|
+
readonly by?: string | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Length-prefixed, order-fixed encoding.
|
|
95
|
+
*
|
|
96
|
+
* The obvious `${collection}:${id}` is unsafe: an attacker who
|
|
97
|
+
* controls a collection name can choose one that re-splits the same joined
|
|
98
|
+
* string a different way, so two different identities produce identical AAD
|
|
99
|
+
* and the relocation this exists to prevent goes through. Every field is
|
|
100
|
+
* therefore written as a 4-byte big-endian length followed by its UTF-8 bytes,
|
|
101
|
+
* which no field content can imitate.
|
|
102
|
+
*
|
|
103
|
+
* A one-byte presence flag precedes `by` so that "no author recorded" and
|
|
104
|
+
* "author recorded as the empty string" cannot be swapped for one another.
|
|
105
|
+
*/
|
|
106
|
+
export declare function buildRecordAad(identity: RecordIdentity): Uint8Array;
|
|
107
|
+
/**
|
|
108
|
+
* The AAD a **reader** must supply to open `envelope`, given where it fetched
|
|
109
|
+
* it from.
|
|
110
|
+
*
|
|
111
|
+
* This is the read-side counterpart of {@link buildRecordAad}, and the split
|
|
112
|
+
* exists because of one asymmetry: **a writer always knows what it is writing;
|
|
113
|
+
* a reader often does not.** Query execution, sync merge and backup restore
|
|
114
|
+
* hold an envelope that arrived from a map or a batch, having discarded the
|
|
115
|
+
* address it came from.
|
|
116
|
+
*
|
|
117
|
+
* What makes the read side tractable is that only `{collection, id}` has to be
|
|
118
|
+
* threaded — precisely what the caller passed to `store.get`. `_tier`, `_by`
|
|
119
|
+
* and `_v` are read back **off the envelope**, so no extra plumbing carries
|
|
120
|
+
* them.
|
|
121
|
+
*
|
|
122
|
+
* That is not a weakening. An attacker who edits `_tier` to hide a record,
|
|
123
|
+
* `_by` to forge provenance, or `_v` to pass an old body off as the current
|
|
124
|
+
* one, changes the AAD the reader computes — and AES-GCM then fails to
|
|
125
|
+
* authenticate. The tampered field defeats itself.
|
|
126
|
+
*/
|
|
127
|
+
export declare function recordAadFor(ref: RecordRef, envelope: {
|
|
128
|
+
readonly _v: number;
|
|
129
|
+
readonly _tier?: number | undefined;
|
|
130
|
+
readonly _by?: string | undefined;
|
|
131
|
+
}): Uint8Array;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { EncryptedEnvelope } from '../types.js';
|
|
2
|
+
import type { RecordIdentity } from './record-aad.js';
|
|
3
|
+
/** The body an envelope carries, independent of who is writing it. */
|
|
4
|
+
export interface RecordEnvelopeBody {
|
|
5
|
+
/** AES-GCM IV, base64. Empty string for a plaintext or tombstone envelope. */
|
|
6
|
+
readonly iv: string;
|
|
7
|
+
/** Ciphertext (or plaintext JSON when the collection stores plaintext). */
|
|
8
|
+
readonly data: string;
|
|
9
|
+
/** ISO timestamp. Defaults to now — pass it when the caller has a real one. */
|
|
10
|
+
readonly ts?: string | undefined;
|
|
11
|
+
/** Wrapped per-record CEK, when the record has one. */
|
|
12
|
+
readonly cek?: string | undefined;
|
|
13
|
+
readonly provenance?: {
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly sourceTs: string;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Slots the envelope may additionally carry.
|
|
19
|
+
*
|
|
20
|
+
* `_tier`, `_by` and `_v` are deliberately NOT here — they come from
|
|
21
|
+
* `identity`, which is the single source for all three. See
|
|
22
|
+
* {@link buildRecordEnvelope}.
|
|
23
|
+
*/
|
|
24
|
+
readonly extra?: Partial<Pick<EncryptedEnvelope, '_det' | '_sealed' | '_vdig' | '_bidx'>> | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build an envelope for `identity`.
|
|
28
|
+
*
|
|
29
|
+
* ## `identity` is the SINGLE SOURCE for `_by`, `_tier` and `_v`
|
|
30
|
+
*
|
|
31
|
+
* All three are stamped from it, and `RecordEnvelopeBody` deliberately cannot
|
|
32
|
+
* carry them. That is not tidiness — it is what makes the AAD binding safe.
|
|
33
|
+
*
|
|
34
|
+
* The caller encrypts the body under AAD derived from `{collection, id, tier,
|
|
35
|
+
* by, version}`. A reader recomputes that AAD from the address it fetched from
|
|
36
|
+
* plus `_tier`/`_by`/`_v` read back **off the envelope** (`recordAadFor`). So if the
|
|
37
|
+
* identity a writer *declares* could differ from the fields it *stamps*, the
|
|
38
|
+
* AAD would not reproduce and the record would be undecryptable — silently, at
|
|
39
|
+
* write time, discoverable only on the next read, and invisible to every gate
|
|
40
|
+
* because the envelope is perfectly well-formed.
|
|
41
|
+
*
|
|
42
|
+
* An earlier draft took both and asserted they agreed. The assertion fired 230
|
|
43
|
+
* times on the existing tree, which is the argument against it: a rule that can
|
|
44
|
+
* be violated is a rule someone must remember. Taking one source removes the
|
|
45
|
+
* violation instead of reporting it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildRecordEnvelope(identity: RecordIdentity, body: RecordEnvelopeBody): EncryptedEnvelope;
|
|
48
|
+
/**
|
|
49
|
+
* Build an envelope from an already-sealed body — the output of
|
|
50
|
+
* `writeEnvelopeBody` — **without the caller ever naming `_iv`/`_data`/`_cek`**.
|
|
51
|
+
*
|
|
52
|
+
* This exists because of a guard, and the guard was right. Migrating
|
|
53
|
+
* `writeEnvelopeBody` callers to {@link buildRecordEnvelope} meant rewriting
|
|
54
|
+
* `...body` (a spread, which names nothing) into `iv: body._iv, data:
|
|
55
|
+
* body._data, cek: body._cek` — and `enclave-body-only` failed it: three new
|
|
56
|
+
* protected-body accesses in files that previously had zero.
|
|
57
|
+
*
|
|
58
|
+
* That is the correct outcome rather than an obstacle. #1051 exists to move
|
|
59
|
+
* knowledge of the envelope's shape *inward*; a migration that spreads the
|
|
60
|
+
* protected field names outward to every caller would have defeated its own
|
|
61
|
+
* purpose while looking like progress. The pairing belongs here.
|
|
62
|
+
*
|
|
63
|
+
* ## It takes a SEALER, not a sealed body — and that is load-bearing (#1041)
|
|
64
|
+
*
|
|
65
|
+
* The obvious shape is `(identity, alreadySealedBody, rest)`. That requires the
|
|
66
|
+
* caller to name the identity TWICE — once for `writeEnvelopeBody` and once
|
|
67
|
+
* here — and the two must agree byte for byte or the record is sealed under
|
|
68
|
+
* AAD no reader can reproduce.
|
|
69
|
+
*
|
|
70
|
+
* They did not agree. `with-party/broker/seed.ts` sealed against
|
|
71
|
+
* `{collection, id}` and stamped `{collection, id, by}`, so every broker seed
|
|
72
|
+
* became unreadable the moment AAD switched on. Taking the sealer means the
|
|
73
|
+
* identity is written once and handed to both — divergence stops being
|
|
74
|
+
* possible rather than being something to remember.
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildSealedRecordEnvelope(identity: RecordIdentity, seal: (identity: RecordIdentity) => Promise<Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>>, body: Omit<RecordEnvelopeBody, 'iv' | 'data' | 'cek'>): Promise<EncryptedEnvelope>;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* per-function doc for its oracle call site) — this file introduces no new
|
|
14
14
|
* crypto or semantics, only a narrower door onto what already runs.
|
|
15
15
|
*/
|
|
16
|
+
import { type RecordIdentity, type RecordRef } from '../record-aad.js';
|
|
16
17
|
import { type EnclaveKey } from '../crypto.js';
|
|
17
18
|
import type { EncryptedEnvelope } from '../../types.js';
|
|
18
19
|
/**
|
|
@@ -27,7 +28,7 @@ import type { EncryptedEnvelope } from '../../types.js';
|
|
|
27
28
|
* (the collection DEK), decrypt the body under the unwrapped CEK.
|
|
28
29
|
* - `env._cek` absent → legacy path, decrypt the body directly under `key`.
|
|
29
30
|
*/
|
|
30
|
-
export declare function openEnvelopeJson(env: EncryptedEnvelope, key: EnclaveKey, opts?: {
|
|
31
|
+
export declare function openEnvelopeJson(ref: RecordRef, env: EncryptedEnvelope, key: EnclaveKey, opts?: {
|
|
31
32
|
encrypted?: boolean;
|
|
32
33
|
}): Promise<string>;
|
|
33
34
|
/**
|
|
@@ -43,7 +44,7 @@ export declare function openEnvelopeJson(env: EncryptedEnvelope, key: EnclaveKey
|
|
|
43
44
|
* generated here rather than supplied by the caller).
|
|
44
45
|
* - otherwise → legacy path, body encrypted directly under `key`.
|
|
45
46
|
*/
|
|
46
|
-
export declare function writeEnvelopeBody(json: string, key: EnclaveKey, opts?: {
|
|
47
|
+
export declare function writeEnvelopeBody(identity: RecordIdentity, json: string, key: EnclaveKey, opts?: {
|
|
47
48
|
encrypted?: boolean;
|
|
48
49
|
perRecordKey?: boolean;
|
|
49
50
|
}): Promise<Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>>;
|
|
@@ -85,3 +86,34 @@ export declare function hasPerRecordKey(env: EncryptedEnvelope): boolean;
|
|
|
85
86
|
* `envelope-body.test.ts`).
|
|
86
87
|
*/
|
|
87
88
|
export declare function envelopeBodyForHash(env: EncryptedEnvelope): string;
|
|
89
|
+
/**
|
|
90
|
+
* Does `env` carry an AEAD-sealed body at all?
|
|
91
|
+
*
|
|
92
|
+
* The one question callers outside the enclave legitimately need to ask about
|
|
93
|
+
* `_iv` — a tombstone and a plaintext-collection record have none, so there is
|
|
94
|
+
* nothing to authenticate and nothing to re-seal. Both {@link
|
|
95
|
+
* verifyRecordIdentity} (which treats them as vacuously authentic) and the
|
|
96
|
+
* merge authority's `advance` (which stamps them without re-sealing) turn on
|
|
97
|
+
* it, and asking it here keeps `_iv` from leaking back out to the callers —
|
|
98
|
+
* which `enclave-body-only` refused, correctly, when `advance` tested it inline.
|
|
99
|
+
*/
|
|
100
|
+
export declare function hasSealedBody(env: Pick<EncryptedEnvelope, '_iv'>): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Does `env` authenticate at the identity `ref` claims, under `key`? (#1042)
|
|
103
|
+
*
|
|
104
|
+
* The merge's fail-closed check, living here because it is envelope surgery:
|
|
105
|
+
* deciding "is there a sealed body at all" reads `_iv`, which
|
|
106
|
+
* `enclave-body-only` reserves to this folder. An earlier draft did that test
|
|
107
|
+
* in `kernel/noydb.ts` and the guard refused it — correctly, since a caller
|
|
108
|
+
* outside the enclave inspecting protected fields is how envelope knowledge
|
|
109
|
+
* leaks back out.
|
|
110
|
+
*
|
|
111
|
+
* Returns a boolean rather than throwing: `applyRemote` must be able to reject
|
|
112
|
+
* one poisoned record without halting an entire sync, and a hostile store
|
|
113
|
+
* would very much like the opposite.
|
|
114
|
+
*
|
|
115
|
+
* **A record with no sealed body is vacuously authentic** — a tombstone carries
|
|
116
|
+
* none, and a plaintext collection has no AEAD to verify. Those are pass-through
|
|
117
|
+
* by construction, not by omission.
|
|
118
|
+
*/
|
|
119
|
+
export declare function verifyRecordIdentity(ref: RecordRef, env: EncryptedEnvelope, key: EnclaveKey): Promise<boolean>;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { type EnclaveKey } from '../crypto.js';
|
|
23
23
|
import type { EncryptedEnvelope } from '../../types.js';
|
|
24
|
+
import { type RecordIdentity } from '../record-aad.js';
|
|
24
25
|
import type { Lru } from '../../cache/index.js';
|
|
25
26
|
/** Dependencies {@link resolveStableCek} needs from its collection. */
|
|
26
27
|
export interface StableCekDeps {
|
|
@@ -46,15 +47,31 @@ export interface RewrappedBody {
|
|
|
46
47
|
readonly cek: EnclaveKey | null;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
* Move a record body from `fromDek` to `toDek`.
|
|
50
|
+
* Move a record body from `fromDek`/`from` to `toDek`/`to`.
|
|
50
51
|
*
|
|
51
52
|
* - Per-record-key record (`_cek` present): unwrap the CEK under `fromDek`,
|
|
52
53
|
* re-encrypt the body under the SAME CEK, re-wrap the CEK under `toDek`. The
|
|
53
54
|
* body key is unchanged → history-chain identity preserved.
|
|
54
55
|
* - Legacy record (no `_cek`): decrypt under `fromDek`, re-encrypt under `toDek`
|
|
55
|
-
* directly
|
|
56
|
+
* directly.
|
|
57
|
+
*
|
|
58
|
+
* ## Why it takes TWO identities (#1041)
|
|
59
|
+
*
|
|
60
|
+
* A rewrap is the one operation where the identity genuinely **changes**. A
|
|
61
|
+
* tier move rewrites `_tier`; a history snapshot lands at a different
|
|
62
|
+
* `(collection, id)` entirely. Since AAD binds both, the body must be opened
|
|
63
|
+
* under the identity it currently has and re-sealed under the one it is moving
|
|
64
|
+
* to. A single identity would be wrong for one end or the other.
|
|
65
|
+
*
|
|
66
|
+
* ⚠️ **This retires an optimisation, deliberately.** Callers used to compute
|
|
67
|
+
* ONE rewrap and reuse the bytes for both a tier move's live write and its
|
|
68
|
+
* `_history` snapshot (#728). Those now have different destination identities,
|
|
69
|
+
* so they need different AAD and therefore different ciphertext — the same
|
|
70
|
+
* bytes cannot satisfy both. Reusing one rewrap for two destinations is now a
|
|
71
|
+
* silent corruption, not a saving: it produces a record that opens at one
|
|
72
|
+
* address and not the other.
|
|
56
73
|
*/
|
|
57
|
-
export declare function rewrapBodyToDek(envelope: Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>, fromDek: EnclaveKey, toDek: EnclaveKey): Promise<RewrappedBody>;
|
|
74
|
+
export declare function rewrapBodyToDek(from: RecordIdentity, to: RecordIdentity, envelope: Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek' | '_tier' | '_by'>, fromDek: EnclaveKey, toDek: EnclaveKey): Promise<RewrappedBody>;
|
|
58
75
|
/**
|
|
59
76
|
* Merge an ALREADY-rewrapped {@link RewrappedBody} into `envelope`, keeping
|
|
60
77
|
* every field but the re-keyed body (`_iv`/`_data`/`_cek`) unchanged.
|
|
@@ -76,7 +93,7 @@ export declare function applyRewrappedBody(envelope: EncryptedEnvelope, body: Re
|
|
|
76
93
|
* envelope, generalized to any envelope shape (history callers don't bump
|
|
77
94
|
* `_v`/`_ts`/`_tier` the way a tier move does).
|
|
78
95
|
*/
|
|
79
|
-
export declare function rewrapEnvelope(envelope: EncryptedEnvelope, fromDek: EnclaveKey, toDek: EnclaveKey): Promise<EncryptedEnvelope>;
|
|
96
|
+
export declare function rewrapEnvelope(identity: RecordIdentity, envelope: EncryptedEnvelope, fromDek: EnclaveKey, toDek: EnclaveKey): Promise<EncryptedEnvelope>;
|
|
80
97
|
/**
|
|
81
98
|
* Is `envelope` ALREADY wrapped under `dek` (a per-record CEK wrapped under
|
|
82
99
|
* `dek`, or — legacy, no `_cek` — the body itself decryptable under `dek`)?
|
|
@@ -104,4 +121,4 @@ export declare function rewrapEnvelope(envelope: EncryptedEnvelope, fromDek: Enc
|
|
|
104
121
|
* those fields themselves, preserving the check-architecture body-access
|
|
105
122
|
* ratchet.
|
|
106
123
|
*/
|
|
107
|
-
export declare function isRewrappedUnder(envelope: Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>, dek: EnclaveKey): Promise<boolean>;
|
|
124
|
+
export declare function isRewrappedUnder(identity: RecordIdentity, envelope: Pick<EncryptedEnvelope, '_iv' | '_data' | '_cek'>, dek: EnclaveKey): Promise<boolean>;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { type EnclaveKey } from '../crypto.js';
|
|
20
20
|
import { type EncryptedEnvelope, type CrdtMode, type CrdtStrategy, type VdigFieldPolicy, type SealedHandle } from '../../types.js';
|
|
21
|
+
import { type RecordIdentity, type RecordRef } from '../record-aad.js';
|
|
21
22
|
import { type StandardSchemaV1 } from '../../schema.js';
|
|
22
23
|
import type { Lru } from '../../cache/index.js';
|
|
23
24
|
import type { ViaCryptoCtx } from '../../via/index.js';
|
|
@@ -127,11 +128,9 @@ export declare class RecordCodec<T> {
|
|
|
127
128
|
* parts. Pure, no crypto. Each call stamps its own `_ts` — provenance carries
|
|
128
129
|
* a SEPARATE timestamp (computed by the caller), so the two never share one.
|
|
129
130
|
*/
|
|
130
|
-
static buildEnvelope(p: {
|
|
131
|
-
version: number;
|
|
131
|
+
static buildEnvelope(identity: RecordIdentity, p: {
|
|
132
132
|
iv: string;
|
|
133
133
|
data: string;
|
|
134
|
-
by?: string;
|
|
135
134
|
cek?: string;
|
|
136
135
|
provenance?: {
|
|
137
136
|
source: string;
|
|
@@ -140,10 +139,8 @@ export declare class RecordCodec<T> {
|
|
|
140
139
|
extra?: Partial<Pick<EncryptedEnvelope, '_tier' | '_det' | '_sealed'>>;
|
|
141
140
|
}): EncryptedEnvelope;
|
|
142
141
|
/** Plaintext (`_iv:''`) body envelope — the `!storeCiphertext` shape. */
|
|
143
|
-
static buildPlaintextEnvelope(p: {
|
|
144
|
-
version: number;
|
|
142
|
+
static buildPlaintextEnvelope(identity: RecordIdentity, p: {
|
|
145
143
|
data: string;
|
|
146
|
-
by?: string;
|
|
147
144
|
provenance?: {
|
|
148
145
|
source: string;
|
|
149
146
|
sourceTs: string;
|
|
@@ -157,7 +154,7 @@ export declare class RecordCodec<T> {
|
|
|
157
154
|
* (see {@link encryptRecord}). Rejects `_`-prefixed record fields, which
|
|
158
155
|
* would collide with the reserved metadata namespace.
|
|
159
156
|
*/
|
|
160
|
-
buildDebugEnvelope(record: T, version: number, source?: string, sourceTs?: string): EncryptedEnvelope;
|
|
157
|
+
buildDebugEnvelope(id: string, record: T, version: number, source?: string, sourceTs?: string): EncryptedEnvelope;
|
|
161
158
|
/**
|
|
162
159
|
* Encrypt a JSON body into an envelope.
|
|
163
160
|
*
|
|
@@ -167,11 +164,41 @@ export declare class RecordCodec<T> {
|
|
|
167
164
|
* path encrypts the body directly under the collection DEK — byte-identical
|
|
168
165
|
* to pre-CEK behaviour, so non-adopting collections pay nothing.
|
|
169
166
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
/**
|
|
168
|
+
* `ref` is the identity the envelope is sealed against, and it is **the
|
|
169
|
+
* location the bytes are stored at** — not necessarily this codec's own
|
|
170
|
+
* collection (#1051).
|
|
171
|
+
*
|
|
172
|
+
* That distinction was discovered here rather than assumed. Several callers
|
|
173
|
+
* put the result somewhere else entirely: search's vector sidecar lands in
|
|
174
|
+
* `_vec` under `encodeVecId(name, id)`, the lexical index under `_ft/<name>`,
|
|
175
|
+
* indexing's entries under a synthetic `idxId`. A codec that supplied
|
|
176
|
+
* `this.ctx.name` for those would seal them against a collection they are not
|
|
177
|
+
* in, and once AAD binds identity every one of them would fail to verify.
|
|
178
|
+
*
|
|
179
|
+
* ⚠️ **`_history` is the open case, and it is #1041's to settle.** Snapshots
|
|
180
|
+
* are produced with the LIVE record's identity here and then re-homed by
|
|
181
|
+
* `saveHistory` into `_history/<historyId(collection,id,_v)>`. Both readings
|
|
182
|
+
* are defensible — bind where it lives, or bind what it is a copy of — and
|
|
183
|
+
* the choice must be made before AAD is switched on, not inferred from this
|
|
184
|
+
* migration.
|
|
185
|
+
*/
|
|
186
|
+
encryptJsonString(ref: RecordRef, json: string, version: number, cek?: EnclaveKey, source?: string, sourceTs?: string): Promise<EncryptedEnvelope>;
|
|
187
|
+
/**
|
|
188
|
+
* `ref` is FIRST and required (#1051). It was previously a trailing optional
|
|
189
|
+
* `id?: string`, which TypeScript cannot promote to required because it sits
|
|
190
|
+
* after other optionals — so the migration would have needed an `id ?? ''`
|
|
191
|
+
* fallback. That is exactly the silent default this issue exists to remove:
|
|
192
|
+
* once identity is bound into the AEAD, every record written with an empty id
|
|
193
|
+
* binds to the SAME identity and becomes interchangeable with the others.
|
|
194
|
+
* An object, not a bare string, so a swap with `version`/`source` cannot
|
|
195
|
+
* compile on the hottest write path. Carries the collection too — see
|
|
196
|
+
* {@link encryptJsonString} for why the codec must not assume its own.
|
|
197
|
+
*/
|
|
198
|
+
encryptRecord(ref: RecordRef, record: T, version: number, cek?: EnclaveKey, source?: string, sourceTs?: string, vdig?: {
|
|
172
199
|
readonly id: string;
|
|
173
200
|
readonly prev: EncryptedEnvelope | null;
|
|
174
|
-
}
|
|
201
|
+
}): Promise<EncryptedEnvelope>;
|
|
175
202
|
/**
|
|
176
203
|
* Resolve the per-record CEK for a stored envelope, or `undefined` for a
|
|
177
204
|
* legacy (`_cek`-absent) envelope. Unwraps `_cek` under the collection DEK and
|
|
@@ -195,7 +222,14 @@ export declare class RecordCodec<T> {
|
|
|
195
222
|
* The optional `id` lets reads populate the CEK cache; it is omitted by
|
|
196
223
|
* callers (history, conflict merge) that have only the envelope.
|
|
197
224
|
*/
|
|
198
|
-
|
|
225
|
+
/**
|
|
226
|
+
* `ref` must be the SAME identity the writer sealed against — which is the
|
|
227
|
+
* storage address, not necessarily this codec's own collection. Search's
|
|
228
|
+
* vector sidecar lives in `_vec`, its lexical index in `_ft`; passing
|
|
229
|
+
* `this.ctx.name` for those would recompute the wrong AAD and fail to open a
|
|
230
|
+
* perfectly good record (#1041).
|
|
231
|
+
*/
|
|
232
|
+
decryptJsonString(ref: RecordRef, envelope: EncryptedEnvelope): Promise<string | null>;
|
|
199
233
|
/**
|
|
200
234
|
* Unseal a single `_sealed[field]` slot to its plaintext value: derive the
|
|
201
235
|
* per-field key off the collection DEK, AES-GCM-decrypt the `iv:data` blob,
|
|
@@ -304,7 +338,7 @@ export declare class RecordCodec<T> {
|
|
|
304
338
|
* output-recompute path, not the public per-record read surface schema
|
|
305
339
|
* validation guards.
|
|
306
340
|
*/
|
|
307
|
-
decryptRecordAtDek(envelope: EncryptedEnvelope, dek: EnclaveKey
|
|
341
|
+
decryptRecordAtDek(ref: RecordRef, envelope: EncryptedEnvelope, dek: EnclaveKey): Promise<T | null>;
|
|
308
342
|
/**
|
|
309
343
|
* Decrypt an envelope into a record of type `T`.
|
|
310
344
|
*
|
|
@@ -320,9 +354,8 @@ export declare class RecordCodec<T> {
|
|
|
320
354
|
* that may predate a schema change, so validating it would be a
|
|
321
355
|
* false positive. Every non-history read leaves this flag `false`.
|
|
322
356
|
*/
|
|
323
|
-
decryptRecord(envelope: EncryptedEnvelope, opts?: {
|
|
357
|
+
decryptRecord(ref: RecordRef, envelope: EncryptedEnvelope, opts?: {
|
|
324
358
|
skipValidation?: boolean;
|
|
325
|
-
id?: string;
|
|
326
359
|
sealedAsHandles?: boolean;
|
|
327
360
|
}): Promise<T | null>;
|
|
328
361
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-key a vault's blob set from an old `_blob` DEK to a new one (#1122).
|
|
3
|
+
*
|
|
4
|
+
* ## The defect this closes
|
|
5
|
+
*
|
|
6
|
+
* `rotateKeys` re-keys `store.list(vault, <slot>)` plus the derived refs
|
|
7
|
+
* `derivedRefsFor` declares. That assumes a DEK slot named `X` protects data
|
|
8
|
+
* filed under collection `X`. For `_blob` it is false: the slot is `_blob`, but
|
|
9
|
+
* every byte it protects lives in `_blob_index` and `_blob_chunks`. So rotating
|
|
10
|
+
* `_blob` minted a fresh DEK, re-encrypted **nothing**, and made every blob in
|
|
11
|
+
* the vault permanently unreadable — reported to the user as `TamperedError`,
|
|
12
|
+
* i.e. as an attack, when it was self-inflicted. An ordinary `revoke` of a
|
|
13
|
+
* whole-vault grantee reaches it, because such a grantee's DEK map contains
|
|
14
|
+
* `_blob`.
|
|
15
|
+
*
|
|
16
|
+
* ## Why this cannot be done by `rekeyEnvelopeIfNeeded` alone
|
|
17
|
+
*
|
|
18
|
+
* Two of the three surfaces do not have the shape that helper assumes:
|
|
19
|
+
*
|
|
20
|
+
* - a **chunk** envelope is sealed over raw bytes under a bespoke AAD
|
|
21
|
+
* (`{eTag}:{index}:{count}`), not under the record AAD, so the generic
|
|
22
|
+
* helper cannot open it;
|
|
23
|
+
* - an **index** envelope's body is JSON that may itself carry a wrapped
|
|
24
|
+
* per-blob content CEK (`_cek` / `_cekPending`). Re-encrypting the body under
|
|
25
|
+
* the new DEK without re-wrapping that CEK leaves a blob whose metadata opens
|
|
26
|
+
* and whose bytes never will.
|
|
27
|
+
*
|
|
28
|
+
* ## Why it lives in the enclave
|
|
29
|
+
*
|
|
30
|
+
* It reads and writes protected body slots and it unwraps/re-wraps keys — the
|
|
31
|
+
* two things `enclave-body-only` reserves to `kernel/enclave/**`, and the same
|
|
32
|
+
* reason `rekeyEnvelopeToDek` moved here in #1074. `with-party` orchestrates
|
|
33
|
+
* the rotation and must not touch a body to do it.
|
|
34
|
+
*
|
|
35
|
+
* The blob layout below is duplicated from its owner rather than imported:
|
|
36
|
+
* `with-shape/blobs/blob-set.ts` already imports `with-party/team/tiers.js`, so
|
|
37
|
+
* a `with-party → with-shape` import would close a cycle, and the kernel may
|
|
38
|
+
* not depend on a service. `BlobObject` itself is a kernel type, so only the
|
|
39
|
+
* three collection/id string layouts are copied, with their owner named.
|
|
40
|
+
*
|
|
41
|
+
* @packageDocumentation
|
|
42
|
+
*/
|
|
43
|
+
import { type EnclaveKey } from '../crypto.js';
|
|
44
|
+
import type { NoydbStore } from '../../types.js';
|
|
45
|
+
/**
|
|
46
|
+
* What a rotation did to the blob set.
|
|
47
|
+
*
|
|
48
|
+
* Deliberately NOT on the enclave barrel: no caller outside this module binds
|
|
49
|
+
* it, and that surface is the fork-swap trust boundary, so exporting a type
|
|
50
|
+
* nobody consumes is pure widening.
|
|
51
|
+
*
|
|
52
|
+
* It is a return value rather than a log line because `foreign` and `blobs`
|
|
53
|
+
* are the only way to tell "left alone, correctly" from "left alone, because
|
|
54
|
+
* the caller passed a wrong `otherDeks` set". Both re-key nothing and both
|
|
55
|
+
* return successfully. `rotate-preserves-blobs.test.ts` asserts these counts
|
|
56
|
+
* against a direct call for exactly that reason.
|
|
57
|
+
*/
|
|
58
|
+
export interface BlobRekeyReport {
|
|
59
|
+
/** Index envelopes moved onto the new DEK. */
|
|
60
|
+
readonly blobs: number;
|
|
61
|
+
/** Chunk envelopes re-encrypted under the new DEK. */
|
|
62
|
+
readonly chunks: number;
|
|
63
|
+
/**
|
|
64
|
+
* Index envelopes left alone because they open under a DEK the caller holds
|
|
65
|
+
* for a DIFFERENT slot — an elevated blob, sealed under `_blob#<tier>`. Those
|
|
66
|
+
* are that slot's rotation to do, not this one's.
|
|
67
|
+
*/
|
|
68
|
+
readonly foreign: number;
|
|
69
|
+
/** Index envelopes already under the new DEK — a resumed rotation. */
|
|
70
|
+
readonly alreadyMoved: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Move every blob sealed under `oldDek` onto `newDek`.
|
|
74
|
+
*
|
|
75
|
+
* Chunks are re-encrypted BEFORE their index entry is re-sealed, and that order
|
|
76
|
+
* is the resume property: an index entry still readable under `oldDek` means
|
|
77
|
+
* its chunks may be half-moved (each one is probed individually), and an index
|
|
78
|
+
* entry readable under `newDek` means its chunks are already done. An
|
|
79
|
+
* interrupted rotation is finished by re-running it with the same `newDek`.
|
|
80
|
+
*
|
|
81
|
+
* `otherDeks` is what keeps a tier-elevated blob from being mistaken for a
|
|
82
|
+
* damaged one. Membership in `_blob_index` is by DEK, not by collection name:
|
|
83
|
+
* a record elevated to tier N has its blob metadata sealed under `_blob#N`. An
|
|
84
|
+
* envelope that opens under NONE of the keys the caller holds is genuinely
|
|
85
|
+
* unreadable and throws, exactly as `rekeyEnvelopeIfNeeded` does — silently
|
|
86
|
+
* walking past it would turn a loud failure into permanent quiet loss.
|
|
87
|
+
*/
|
|
88
|
+
export declare function rekeyBlobSet(adapter: NoydbStore, vault: string, oldDek: EnclaveKey, newDek: EnclaveKey, otherDeks?: readonly EnclaveKey[]): Promise<BlobRekeyReport>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-key one envelope from an old collection DEK to a new one (#1074).
|
|
3
|
+
*
|
|
4
|
+
* Lives in the enclave because it is envelope surgery: it reads and writes the
|
|
5
|
+
* protected body slots (`_iv`/`_data`/`_cek`), which `enclave-body-only`
|
|
6
|
+
* reserves to `kernel/enclave/**`. `rotateKeys` previously did this inline in
|
|
7
|
+
* `with-party/team/keyring.ts` and got it wrong in two ways that the guard
|
|
8
|
+
* would have caught had the code lived here.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import { type EnclaveKey } from '../crypto.js';
|
|
13
|
+
import type { EncryptedEnvelope } from '../../types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Produce the envelope `envelope` becomes once its collection's DEK rotates
|
|
16
|
+
* from `oldDek` to `newDek`.
|
|
17
|
+
*
|
|
18
|
+
* **Every slot is carried forward except `_bidx`.** The previous inline version
|
|
19
|
+
* built a fresh literal holding only `_noydb/_v/_ts/_iv/_data`, silently
|
|
20
|
+
* discarding `_by`, `_tier`, `_cek`, `_sealed`, `_vdig` and `_source`. Losing
|
|
21
|
+
* `_tier` was the worst of those: tier-0 reads treat elevated as missing, so an
|
|
22
|
+
* elevated record did not error after a rotation — it simply disappeared.
|
|
23
|
+
*
|
|
24
|
+
* `_bidx` is dropped deliberately. It is a DEK-rooted equality tag, so a tag
|
|
25
|
+
* carried across a DEK rotation can never be re-derived to match a query again
|
|
26
|
+
* while still leaking the old equality partition. Index coverage regrows
|
|
27
|
+
* per-record on the next `put()` under the new DEK.
|
|
28
|
+
*
|
|
29
|
+
* Two shapes, and picking the wrong one is why this needed a helper:
|
|
30
|
+
*
|
|
31
|
+
* - **per-record CEK** (`_cek` present) — the body is sealed under the CEK and
|
|
32
|
+
* the CEK is wrapped under the collection DEK, so rotation re-wraps the CEK
|
|
33
|
+
* and leaves the body **untouched**. The old inline code instead ran
|
|
34
|
+
* `decrypt(body, oldDek)` on these, which throws: rotation could not complete
|
|
35
|
+
* on a collection containing any CEK record.
|
|
36
|
+
* - **bare** — body sealed directly under the DEK, so decrypt and re-encrypt.
|
|
37
|
+
*
|
|
38
|
+
* Idempotence is the caller's problem, not this function's: it assumes
|
|
39
|
+
* `envelope` is still under `oldDek`. A resumable rotation must know which side
|
|
40
|
+
* of the migration each record is on before calling.
|
|
41
|
+
*/
|
|
42
|
+
export declare function rekeyEnvelopeToDek(ref: {
|
|
43
|
+
readonly collection: string;
|
|
44
|
+
readonly id: string;
|
|
45
|
+
}, envelope: EncryptedEnvelope, oldDek: EnclaveKey, newDek: EnclaveKey): Promise<EncryptedEnvelope>;
|
|
46
|
+
/**
|
|
47
|
+
* Resumable variant: returns the re-keyed envelope, or `null` when `envelope`
|
|
48
|
+
* is **already** under `newDek` and needs no work (#1074 part 2).
|
|
49
|
+
*
|
|
50
|
+
* A rotation interrupted mid-collection leaves records on both sides of the
|
|
51
|
+
* migration. Resuming means re-running the rotation with the *same* new DEK,
|
|
52
|
+
* which requires distinguishing "not yet moved" from "already moved" without
|
|
53
|
+
* the caller touching protected slots.
|
|
54
|
+
*
|
|
55
|
+
* Detection is by trial decryption under `oldDek`. There is no metadata that
|
|
56
|
+
* says which DEK sealed a record — deliberately, since such a marker would be
|
|
57
|
+
* store-writable and therefore a downgrade lever (the same reasoning that
|
|
58
|
+
* keeps the reader from branching on `_noydb`).
|
|
59
|
+
*
|
|
60
|
+
* A record that opens under *neither* key is genuinely damaged and rethrows,
|
|
61
|
+
* rather than being silently skipped: a rotation that quietly walked past
|
|
62
|
+
* unreadable records would convert a loud failure into permanent silent loss,
|
|
63
|
+
* which is the defect this whole issue is about.
|
|
64
|
+
*/
|
|
65
|
+
export declare function rekeyEnvelopeIfNeeded(ref: {
|
|
66
|
+
readonly collection: string;
|
|
67
|
+
readonly id: string;
|
|
68
|
+
}, envelope: EncryptedEnvelope, oldDek: EnclaveKey, newDek: EnclaveKey): Promise<EncryptedEnvelope | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Does this envelope open under ANY of `keys`? A read-only probe — decrypts
|
|
71
|
+
* nothing into a caller-visible value and writes nothing.
|
|
72
|
+
*
|
|
73
|
+
* Exists so a rotation can tell *"this envelope belongs to a DIFFERENT DEK slot
|
|
74
|
+
* the caller also holds"* from *"this envelope is damaged"* (#1125). Those two
|
|
75
|
+
* look identical from a failed `rekeyEnvelopeIfNeeded`, and collapsing them
|
|
76
|
+
* either aborts a legitimate rotation or walks past unreadable data.
|
|
77
|
+
*
|
|
78
|
+
* **The question is deliberately asked of the KEY, not of the envelope's claimed
|
|
79
|
+
* `_tier`.** `_tier` is unencrypted — the store writes it — so routing a
|
|
80
|
+
* rotation on it would let a store mark a tier-0 record `_tier: 5` and have the
|
|
81
|
+
* rotation skip it, leaving a revoked member's DEK live on real data. That is
|
|
82
|
+
* #1115's defect wearing a different hat. A key either opens the body or it does
|
|
83
|
+
* not, and a store cannot forge that.
|
|
84
|
+
*
|
|
85
|
+
* Mirrors `rekeyBlobSet`'s `otherDeks` treatment, which asks the same question
|
|
86
|
+
* about the same kind of ambiguity.
|
|
87
|
+
*/
|
|
88
|
+
export declare function envelopeOpensUnderAny(ref: {
|
|
89
|
+
readonly collection: string;
|
|
90
|
+
readonly id: string;
|
|
91
|
+
}, envelope: EncryptedEnvelope, keys: readonly EnclaveKey[]): Promise<boolean>;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* vault; it calls into these.
|
|
17
17
|
*/
|
|
18
18
|
import { type EncryptedEnvelope } from '../../types.js';
|
|
19
|
+
import type { RecordRef } from '../record-aad.js';
|
|
19
20
|
/**
|
|
20
21
|
* Shape-only tombstone recognition for layers that have no per-collection
|
|
21
22
|
* context (the sync engine, #590): a tombstone carries an empty `_data` and
|
|
@@ -45,7 +46,7 @@ export declare function isTombstone(envelope: EncryptedEnvelope, encrypted: bool
|
|
|
45
46
|
* Deliberately omits `_iv`/`_data`/`_cek`/`_det` — that omission *is* the
|
|
46
47
|
* erasure.
|
|
47
48
|
*/
|
|
48
|
-
export declare function buildTombstone(version: number, actor: string): EncryptedEnvelope;
|
|
49
|
+
export declare function buildTombstone(ref: RecordRef, version: number, actor: string): EncryptedEnvelope;
|
|
49
50
|
/** #589: is this envelope an ordinary-delete marker (version-ordered, reads as absent)? */
|
|
50
51
|
export declare function isDeleteMarker(envelope: EncryptedEnvelope): boolean;
|
|
51
52
|
/**
|
|
@@ -54,4 +55,4 @@ export declare function isDeleteMarker(envelope: EncryptedEnvelope): boolean;
|
|
|
54
55
|
* keeps the displaced `_v` — so it wins convergence over the pre-delete copy and a
|
|
55
56
|
* re-create can still win over it at a higher version.
|
|
56
57
|
*/
|
|
57
|
-
export declare function buildDeleteMarker(version: number, actor: string): EncryptedEnvelope;
|
|
58
|
+
export declare function buildDeleteMarker(ref: RecordRef, version: number, actor: string): EncryptedEnvelope;
|