@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
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildRecordEnvelope,
|
|
2
3
|
isDeleteMarker,
|
|
3
4
|
isTombstone
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FX3UIDCS.js";
|
|
5
6
|
import {
|
|
6
7
|
blindedEqual,
|
|
7
8
|
openVdigPayload,
|
|
8
9
|
sealVdigPayload
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CKKN25P2.js";
|
|
10
11
|
import {
|
|
11
12
|
dualReadSealedSlot,
|
|
12
13
|
parseSealedSlot
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7Q3RHOA5.js";
|
|
14
15
|
import {
|
|
15
16
|
mintBidxTag
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4K6BIMLF.js";
|
|
17
18
|
import {
|
|
18
19
|
VDIG_ITERATIONS,
|
|
19
20
|
normalizeForVerify,
|
|
@@ -23,20 +24,22 @@ import {
|
|
|
23
24
|
base64ToBuffer,
|
|
24
25
|
bufferToBase64,
|
|
25
26
|
decrypt,
|
|
27
|
+
decryptBytesWithAAD,
|
|
26
28
|
deriveDeterministicKey,
|
|
27
29
|
deriveSealedFieldKey,
|
|
28
30
|
deriveSealedFieldKeyFromCek,
|
|
29
31
|
encrypt,
|
|
32
|
+
encryptBytesWithAAD,
|
|
30
33
|
encryptDeterministic,
|
|
31
34
|
generateDEK,
|
|
32
35
|
generateSalt,
|
|
33
36
|
unwrapCek,
|
|
34
37
|
wrapCek
|
|
35
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ONPVHX2Y.js";
|
|
36
39
|
import {
|
|
37
40
|
NOYDB_FORMAT_VERSION,
|
|
38
41
|
SealedHandle
|
|
39
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-UJ4Z67UQ.js";
|
|
40
43
|
import {
|
|
41
44
|
ClassifiedConfigError,
|
|
42
45
|
ClassifiedRotationError,
|
|
@@ -45,7 +48,48 @@ import {
|
|
|
45
48
|
SchemaValidationError,
|
|
46
49
|
TamperedError,
|
|
47
50
|
ValidationError
|
|
48
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-Z3BZXPRO.js";
|
|
52
|
+
|
|
53
|
+
// src/kernel/enclave/record-aad.ts
|
|
54
|
+
var SCHEME = "noydb-aad/2";
|
|
55
|
+
var encoder = new TextEncoder();
|
|
56
|
+
function buildRecordAad(identity) {
|
|
57
|
+
if (!Number.isFinite(identity.version)) {
|
|
58
|
+
throw new TypeError(
|
|
59
|
+
`record AAD: version must be a finite number for "${identity.collection}/${identity.id}", received ${String(identity.version)}. Sealing without one produces a record no reader can open.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const parts = [encoder.encode(SCHEME)];
|
|
63
|
+
const pushField = (value) => {
|
|
64
|
+
const bytes = encoder.encode(value);
|
|
65
|
+
const len = new Uint8Array(4);
|
|
66
|
+
new DataView(len.buffer).setUint32(0, bytes.length, false);
|
|
67
|
+
parts.push(len, bytes);
|
|
68
|
+
};
|
|
69
|
+
pushField(identity.collection);
|
|
70
|
+
pushField(identity.id);
|
|
71
|
+
pushField(String(identity.tier ?? 0));
|
|
72
|
+
parts.push(new Uint8Array([identity.by === void 0 ? 0 : 1]));
|
|
73
|
+
if (identity.by !== void 0) pushField(identity.by);
|
|
74
|
+
pushField(String(identity.version));
|
|
75
|
+
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
76
|
+
const out = new Uint8Array(total);
|
|
77
|
+
let offset = 0;
|
|
78
|
+
for (const p of parts) {
|
|
79
|
+
out.set(p, offset);
|
|
80
|
+
offset += p.length;
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function recordAadFor(ref, envelope) {
|
|
85
|
+
return buildRecordAad({
|
|
86
|
+
collection: ref.collection,
|
|
87
|
+
id: ref.id,
|
|
88
|
+
version: envelope._v,
|
|
89
|
+
tier: envelope._tier,
|
|
90
|
+
by: envelope._by
|
|
91
|
+
});
|
|
92
|
+
}
|
|
49
93
|
|
|
50
94
|
// src/kernel/enclave/record-keys/lifecycle.ts
|
|
51
95
|
async function resolveStableCek(deps, id) {
|
|
@@ -61,15 +105,17 @@ async function resolveStableCek(deps, id) {
|
|
|
61
105
|
deps.cache?.set(id, fresh, 1);
|
|
62
106
|
return fresh;
|
|
63
107
|
}
|
|
64
|
-
async function rewrapBodyToDek(envelope, fromDek, toDek) {
|
|
108
|
+
async function rewrapBodyToDek(from, to, envelope, fromDek, toDek) {
|
|
109
|
+
const openAad = buildRecordAad(from);
|
|
110
|
+
const sealAad = buildRecordAad(to);
|
|
65
111
|
if (envelope._cek !== void 0) {
|
|
66
112
|
const cek = await unwrapCek(envelope._cek, fromDek);
|
|
67
|
-
const plaintext2 = await decrypt(envelope._iv, envelope._data, cek);
|
|
68
|
-
const { iv: iv2, data: data2 } = await encrypt(plaintext2, cek);
|
|
113
|
+
const plaintext2 = await decrypt(envelope._iv, envelope._data, cek, openAad);
|
|
114
|
+
const { iv: iv2, data: data2 } = await encrypt(plaintext2, cek, sealAad);
|
|
69
115
|
return { _iv: iv2, _data: data2, _cek: await wrapCek(cek, toDek), cek };
|
|
70
116
|
}
|
|
71
|
-
const plaintext = await decrypt(envelope._iv, envelope._data, fromDek);
|
|
72
|
-
const { iv, data } = await encrypt(plaintext, toDek);
|
|
117
|
+
const plaintext = await decrypt(envelope._iv, envelope._data, fromDek, openAad);
|
|
118
|
+
const { iv, data } = await encrypt(plaintext, toDek, sealAad);
|
|
73
119
|
return { _iv: iv, _data: data, cek: null };
|
|
74
120
|
}
|
|
75
121
|
function applyRewrappedBody(envelope, body) {
|
|
@@ -84,15 +130,15 @@ function applyRewrappedBody(envelope, body) {
|
|
|
84
130
|
}
|
|
85
131
|
return next;
|
|
86
132
|
}
|
|
87
|
-
async function rewrapEnvelope(envelope, fromDek, toDek) {
|
|
88
|
-
return applyRewrappedBody(envelope, await rewrapBodyToDek(envelope, fromDek, toDek));
|
|
133
|
+
async function rewrapEnvelope(identity, envelope, fromDek, toDek) {
|
|
134
|
+
return applyRewrappedBody(envelope, await rewrapBodyToDek(identity, identity, envelope, fromDek, toDek));
|
|
89
135
|
}
|
|
90
|
-
async function isRewrappedUnder(envelope, dek) {
|
|
136
|
+
async function isRewrappedUnder(identity, envelope, dek) {
|
|
91
137
|
try {
|
|
92
138
|
if (envelope._cek !== void 0) {
|
|
93
139
|
await unwrapCek(envelope._cek, dek);
|
|
94
140
|
} else {
|
|
95
|
-
await decrypt(envelope._iv, envelope._data, dek);
|
|
141
|
+
await decrypt(envelope._iv, envelope._data, dek, buildRecordAad(identity));
|
|
96
142
|
}
|
|
97
143
|
return true;
|
|
98
144
|
} catch {
|
|
@@ -100,6 +146,129 @@ async function isRewrappedUnder(envelope, dek) {
|
|
|
100
146
|
}
|
|
101
147
|
}
|
|
102
148
|
|
|
149
|
+
// src/kernel/enclave/record-keys/rekey.ts
|
|
150
|
+
async function rekeyEnvelopeToDek(ref, envelope, oldDek, newDek) {
|
|
151
|
+
const aad = recordAadFor(ref, envelope);
|
|
152
|
+
const { _bidx, ...carried } = envelope;
|
|
153
|
+
void _bidx;
|
|
154
|
+
if (envelope._cek !== void 0) {
|
|
155
|
+
const cek = await unwrapCek(envelope._cek, oldDek);
|
|
156
|
+
return { ...carried, _cek: await wrapCek(cek, newDek) };
|
|
157
|
+
}
|
|
158
|
+
const plaintext = await decrypt(envelope._iv, envelope._data, oldDek, aad);
|
|
159
|
+
const { iv, data } = await encrypt(plaintext, newDek, aad);
|
|
160
|
+
return { ...carried, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data };
|
|
161
|
+
}
|
|
162
|
+
async function rekeyEnvelopeIfNeeded(ref, envelope, oldDek, newDek) {
|
|
163
|
+
try {
|
|
164
|
+
return await rekeyEnvelopeToDek(ref, envelope, oldDek, newDek);
|
|
165
|
+
} catch (errUnderOld) {
|
|
166
|
+
try {
|
|
167
|
+
if (envelope._cek !== void 0) await unwrapCek(envelope._cek, newDek);
|
|
168
|
+
else await decrypt(envelope._iv, envelope._data, newDek, recordAadFor(ref, envelope));
|
|
169
|
+
return null;
|
|
170
|
+
} catch {
|
|
171
|
+
throw errUnderOld;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function envelopeOpensUnderAny(ref, envelope, keys) {
|
|
176
|
+
for (const key of keys) {
|
|
177
|
+
try {
|
|
178
|
+
if (envelope._cek !== void 0) await unwrapCek(envelope._cek, key);
|
|
179
|
+
else await decrypt(envelope._iv, envelope._data, key, recordAadFor(ref, envelope));
|
|
180
|
+
return true;
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/kernel/enclave/record-keys/rekey-blob.ts
|
|
188
|
+
var BLOB_INDEX_COLLECTION = "_blob_index";
|
|
189
|
+
var BLOB_CHUNKS_COLLECTION = "_blob_chunks";
|
|
190
|
+
function chunkAad(eTag, index, chunkCount) {
|
|
191
|
+
return new TextEncoder().encode(`${eTag}:${index}:${chunkCount}`);
|
|
192
|
+
}
|
|
193
|
+
async function opensJson(ref, env, key) {
|
|
194
|
+
try {
|
|
195
|
+
return await decrypt(env._iv, env._data, key, recordAadFor(ref, env));
|
|
196
|
+
} catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function rekeyBlobSet(adapter, vault, oldDek, newDek, otherDeks = []) {
|
|
201
|
+
let blobs = 0;
|
|
202
|
+
let chunks = 0;
|
|
203
|
+
let foreign = 0;
|
|
204
|
+
let alreadyMoved = 0;
|
|
205
|
+
let eTags;
|
|
206
|
+
try {
|
|
207
|
+
eTags = await adapter.list(vault, BLOB_INDEX_COLLECTION);
|
|
208
|
+
} catch {
|
|
209
|
+
return { blobs, chunks, foreign, alreadyMoved };
|
|
210
|
+
}
|
|
211
|
+
for (const eTag of eTags) {
|
|
212
|
+
const idxEnv = await adapter.get(vault, BLOB_INDEX_COLLECTION, eTag);
|
|
213
|
+
if (!idxEnv || !idxEnv._iv) continue;
|
|
214
|
+
const ref = { collection: BLOB_INDEX_COLLECTION, id: eTag };
|
|
215
|
+
const json = await opensJson(ref, idxEnv, oldDek);
|
|
216
|
+
if (json === null) {
|
|
217
|
+
if (await opensJson(ref, idxEnv, newDek) !== null) {
|
|
218
|
+
alreadyMoved++;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let claimed = false;
|
|
222
|
+
for (const key of otherDeks) {
|
|
223
|
+
if (await opensJson(ref, idxEnv, key) !== null) {
|
|
224
|
+
claimed = true;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (claimed) {
|
|
229
|
+
foreign++;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
throw new Error(
|
|
233
|
+
`[noy-db] rotateKeys: blob index entry "${eTag}" opens under neither the retiring nor the new \`_blob\` DEK, nor any other key this keyring holds. Rotation stopped rather than leaving it unreadable and unreported.`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
const blob = JSON.parse(json);
|
|
237
|
+
for (let i = 0; i < blob.chunkCount; i++) {
|
|
238
|
+
const id = `${eTag}_${i}`;
|
|
239
|
+
const chunkEnv = await adapter.get(vault, BLOB_CHUNKS_COLLECTION, id);
|
|
240
|
+
if (!chunkEnv || !chunkEnv._iv) continue;
|
|
241
|
+
const aad = chunkAad(eTag, i, blob.chunkCount);
|
|
242
|
+
let plain;
|
|
243
|
+
try {
|
|
244
|
+
plain = await decryptBytesWithAAD(chunkEnv._iv, chunkEnv._data, oldDek, aad);
|
|
245
|
+
} catch {
|
|
246
|
+
if (blob._cek !== void 0 || blob._cekPending !== void 0) continue;
|
|
247
|
+
try {
|
|
248
|
+
await decryptBytesWithAAD(chunkEnv._iv, chunkEnv._data, newDek, aad);
|
|
249
|
+
continue;
|
|
250
|
+
} catch {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`[noy-db] rotateKeys: blob chunk "${id}" (${i + 1}/${blob.chunkCount} of eTag "${eTag}") opens under neither the retiring nor the new \`_blob\` DEK, and its blob holds no content CEK that could explain it. Rotation stopped rather than leaving it unreadable and unreported.`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const { iv: iv2, data: data2 } = await encryptBytesWithAAD(plain, newDek, aad);
|
|
257
|
+
await adapter.put(vault, BLOB_CHUNKS_COLLECTION, id, { ...chunkEnv, _iv: iv2, _data: data2 });
|
|
258
|
+
chunks++;
|
|
259
|
+
}
|
|
260
|
+
const rewrapped = {
|
|
261
|
+
...blob,
|
|
262
|
+
...blob._cek !== void 0 ? { _cek: await wrapCek(await unwrapCek(blob._cek, oldDek), newDek) } : {},
|
|
263
|
+
...blob._cekPending !== void 0 ? { _cekPending: await wrapCek(await unwrapCek(blob._cekPending, oldDek), newDek) } : {}
|
|
264
|
+
};
|
|
265
|
+
const { iv, data } = await encrypt(JSON.stringify(rewrapped), newDek, recordAadFor(ref, idxEnv));
|
|
266
|
+
await adapter.put(vault, BLOB_INDEX_COLLECTION, eTag, { ...idxEnv, _iv: iv, _data: data });
|
|
267
|
+
blobs++;
|
|
268
|
+
}
|
|
269
|
+
return { blobs, chunks, foreign, alreadyMoved };
|
|
270
|
+
}
|
|
271
|
+
|
|
103
272
|
// src/kernel/enclave/record-keys/sealed-slots.ts
|
|
104
273
|
async function sealOneFieldWithDek(field, value, dek, keyMaterial) {
|
|
105
274
|
const fieldKey = keyMaterial.cek !== void 0 ? await deriveSealedFieldKeyFromCek(keyMaterial.cek, keyMaterial.collection, field) : await deriveSealedFieldKey(dek, keyMaterial.collection, field);
|
|
@@ -175,22 +344,17 @@ function makeReservedEnvelopes(dekResolver, declaredPrefixes) {
|
|
|
175
344
|
);
|
|
176
345
|
}
|
|
177
346
|
};
|
|
178
|
-
const encryptForPrefix = async (
|
|
179
|
-
assertPrefixed(collection, "encrypt");
|
|
180
|
-
const dek = await dekResolver(collection);
|
|
181
|
-
const {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
_v: v,
|
|
185
|
-
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
186
|
-
_iv: iv,
|
|
187
|
-
_data: data
|
|
188
|
-
};
|
|
347
|
+
const encryptForPrefix = async (ref, json, v) => {
|
|
348
|
+
assertPrefixed(ref.collection, "encrypt");
|
|
349
|
+
const dek = await dekResolver(ref.collection);
|
|
350
|
+
const identity = { ...ref, version: v };
|
|
351
|
+
const { iv, data } = await encrypt(json, dek, buildRecordAad(identity));
|
|
352
|
+
return buildRecordEnvelope(identity, { iv, data });
|
|
189
353
|
};
|
|
190
|
-
const decryptForPrefix = async (collection, env) => {
|
|
354
|
+
const decryptForPrefix = async (collection, id, env) => {
|
|
191
355
|
assertPrefixed(collection, "decrypt");
|
|
192
356
|
const dek = await dekResolver(collection);
|
|
193
|
-
return decrypt(env._iv, env._data, dek);
|
|
357
|
+
return decrypt(env._iv, env._data, dek, recordAadFor({ collection, id }, env));
|
|
194
358
|
};
|
|
195
359
|
return { encrypt: encryptForPrefix, decrypt: decryptForPrefix };
|
|
196
360
|
};
|
|
@@ -320,30 +484,12 @@ var RecordCodec = class _RecordCodec {
|
|
|
320
484
|
* parts. Pure, no crypto. Each call stamps its own `_ts` — provenance carries
|
|
321
485
|
* a SEPARATE timestamp (computed by the caller), so the two never share one.
|
|
322
486
|
*/
|
|
323
|
-
static buildEnvelope(p) {
|
|
324
|
-
return
|
|
325
|
-
_noydb: NOYDB_FORMAT_VERSION,
|
|
326
|
-
_v: p.version,
|
|
327
|
-
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
328
|
-
_iv: p.iv,
|
|
329
|
-
_data: p.data,
|
|
330
|
-
...p.by !== void 0 ? { _by: p.by } : {},
|
|
331
|
-
...p.cek !== void 0 ? { _cek: p.cek } : {},
|
|
332
|
-
...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {},
|
|
333
|
-
...p.extra ?? {}
|
|
334
|
-
};
|
|
487
|
+
static buildEnvelope(identity, p) {
|
|
488
|
+
return buildRecordEnvelope(identity, p);
|
|
335
489
|
}
|
|
336
490
|
/** Plaintext (`_iv:''`) body envelope — the `!storeCiphertext` shape. */
|
|
337
|
-
static buildPlaintextEnvelope(p) {
|
|
338
|
-
return {
|
|
339
|
-
_noydb: NOYDB_FORMAT_VERSION,
|
|
340
|
-
_v: p.version,
|
|
341
|
-
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
342
|
-
_iv: "",
|
|
343
|
-
_data: p.data,
|
|
344
|
-
...p.by !== void 0 ? { _by: p.by } : {},
|
|
345
|
-
...p.provenance !== void 0 ? { _source: p.provenance.source, _sourceTs: p.provenance.sourceTs } : {}
|
|
346
|
-
};
|
|
491
|
+
static buildPlaintextEnvelope(identity, p) {
|
|
492
|
+
return buildRecordEnvelope(identity, { ...p, iv: "" });
|
|
347
493
|
}
|
|
348
494
|
// ──────────────────────────────────────────────────────────────────────
|
|
349
495
|
// Write path
|
|
@@ -356,22 +502,20 @@ var RecordCodec = class _RecordCodec {
|
|
|
356
502
|
* (see {@link encryptRecord}). Rejects `_`-prefixed record fields, which
|
|
357
503
|
* would collide with the reserved metadata namespace.
|
|
358
504
|
*/
|
|
359
|
-
buildDebugEnvelope(record, version, source, sourceTs) {
|
|
505
|
+
buildDebugEnvelope(id, record, version, source, sourceTs) {
|
|
360
506
|
const rec = record;
|
|
361
507
|
for (const key of Object.keys(rec)) {
|
|
362
508
|
if (key.startsWith("_")) throw new DebugReservedFieldError(this.ctx.name, key);
|
|
363
509
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
...rec
|
|
374
|
-
};
|
|
510
|
+
const base = buildRecordEnvelope(
|
|
511
|
+
{ collection: this.ctx.name, id, by: this.ctx.actor, version },
|
|
512
|
+
{
|
|
513
|
+
iv: "",
|
|
514
|
+
data: "",
|
|
515
|
+
...this.ctx.provenance && source !== void 0 ? { provenance: { source, sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } } : {}
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
return { ...base, _debug: NOYDB_FORMAT_VERSION, ...rec };
|
|
375
519
|
}
|
|
376
520
|
/**
|
|
377
521
|
* Encrypt a JSON body into an envelope.
|
|
@@ -382,24 +526,56 @@ var RecordCodec = class _RecordCodec {
|
|
|
382
526
|
* path encrypts the body directly under the collection DEK — byte-identical
|
|
383
527
|
* to pre-CEK behaviour, so non-adopting collections pay nothing.
|
|
384
528
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
529
|
+
/**
|
|
530
|
+
* `ref` is the identity the envelope is sealed against, and it is **the
|
|
531
|
+
* location the bytes are stored at** — not necessarily this codec's own
|
|
532
|
+
* collection (#1051).
|
|
533
|
+
*
|
|
534
|
+
* That distinction was discovered here rather than assumed. Several callers
|
|
535
|
+
* put the result somewhere else entirely: search's vector sidecar lands in
|
|
536
|
+
* `_vec` under `encodeVecId(name, id)`, the lexical index under `_ft/<name>`,
|
|
537
|
+
* indexing's entries under a synthetic `idxId`. A codec that supplied
|
|
538
|
+
* `this.ctx.name` for those would seal them against a collection they are not
|
|
539
|
+
* in, and once AAD binds identity every one of them would fail to verify.
|
|
540
|
+
*
|
|
541
|
+
* ⚠️ **`_history` is the open case, and it is #1041's to settle.** Snapshots
|
|
542
|
+
* are produced with the LIVE record's identity here and then re-homed by
|
|
543
|
+
* `saveHistory` into `_history/<historyId(collection,id,_v)>`. Both readings
|
|
544
|
+
* are defensible — bind where it lives, or bind what it is a copy of — and
|
|
545
|
+
* the choice must be made before AAD is switched on, not inferred from this
|
|
546
|
+
* migration.
|
|
547
|
+
*/
|
|
548
|
+
async encryptJsonString(ref, json, version, cek, source, sourceTs) {
|
|
549
|
+
const identity = { ...ref, version, by: this.ctx.actor };
|
|
387
550
|
const provenance = this.ctx.provenance && source !== void 0 ? { source, sourceTs: sourceTs ?? (/* @__PURE__ */ new Date()).toISOString() } : void 0;
|
|
388
551
|
if (!this.ctx.storeCiphertext) {
|
|
389
|
-
return _RecordCodec.buildPlaintextEnvelope({
|
|
552
|
+
return _RecordCodec.buildPlaintextEnvelope(identity, { data: json, provenance });
|
|
390
553
|
}
|
|
391
554
|
const dek = await this.ctx.getDEK();
|
|
555
|
+
const aad = buildRecordAad(identity);
|
|
392
556
|
if (cek !== void 0) {
|
|
393
|
-
const { iv: iv2, data: data2 } = await encrypt(json, cek);
|
|
557
|
+
const { iv: iv2, data: data2 } = await encrypt(json, cek, aad);
|
|
394
558
|
const wrapped = await wrapCek(cek, dek);
|
|
395
|
-
return _RecordCodec.buildEnvelope({
|
|
559
|
+
return _RecordCodec.buildEnvelope(identity, { iv: iv2, data: data2, cek: wrapped, provenance });
|
|
396
560
|
}
|
|
397
|
-
const { iv, data } = await encrypt(json, dek);
|
|
398
|
-
return _RecordCodec.buildEnvelope({
|
|
561
|
+
const { iv, data } = await encrypt(json, dek, aad);
|
|
562
|
+
return _RecordCodec.buildEnvelope(identity, { iv, data, provenance });
|
|
399
563
|
}
|
|
400
|
-
|
|
564
|
+
/**
|
|
565
|
+
* `ref` is FIRST and required (#1051). It was previously a trailing optional
|
|
566
|
+
* `id?: string`, which TypeScript cannot promote to required because it sits
|
|
567
|
+
* after other optionals — so the migration would have needed an `id ?? ''`
|
|
568
|
+
* fallback. That is exactly the silent default this issue exists to remove:
|
|
569
|
+
* once identity is bound into the AEAD, every record written with an empty id
|
|
570
|
+
* binds to the SAME identity and becomes interchangeable with the others.
|
|
571
|
+
* An object, not a bare string, so a swap with `version`/`source` cannot
|
|
572
|
+
* compile on the hottest write path. Carries the collection too — see
|
|
573
|
+
* {@link encryptJsonString} for why the codec must not assume its own.
|
|
574
|
+
*/
|
|
575
|
+
async encryptRecord(ref, record, version, cek, source, sourceTs, vdig) {
|
|
576
|
+
const id = ref.id;
|
|
401
577
|
if (!this.ctx.storeCiphertext && this.ctx.debugPlaintext && !this.ctx.name.startsWith("_")) {
|
|
402
|
-
return this.buildDebugEnvelope(record, version, source, sourceTs);
|
|
578
|
+
return this.buildDebugEnvelope(id, record, version, source, sourceTs);
|
|
403
579
|
}
|
|
404
580
|
if (this.ctx.storeCiphertext) {
|
|
405
581
|
const declared = this.ctx.vdigFields;
|
|
@@ -426,9 +602,9 @@ var RecordCodec = class _RecordCodec {
|
|
|
426
602
|
let openRecord = record;
|
|
427
603
|
let sealed;
|
|
428
604
|
if (this.ctx.storeCiphertext && this.ctx.via?.hasAtRestHooks) {
|
|
429
|
-
if (id ===
|
|
605
|
+
if (id === "") {
|
|
430
606
|
throw new Error(
|
|
431
|
-
`RecordCodec.encryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this write path supplied
|
|
607
|
+
`RecordCodec.encryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this write path supplied an empty record id (needed to scope the sealed-slot capability) \u2014 caller bug.`
|
|
432
608
|
);
|
|
433
609
|
}
|
|
434
610
|
const src = record;
|
|
@@ -436,7 +612,7 @@ var RecordCodec = class _RecordCodec {
|
|
|
436
612
|
openRecord = result.record;
|
|
437
613
|
if (result.sealed !== void 0) {
|
|
438
614
|
sealed = {};
|
|
439
|
-
for (const [field,
|
|
615
|
+
for (const [field, ref2] of Object.entries(result.sealed)) sealed[field] = `${ref2.iv}:${ref2.data}`;
|
|
440
616
|
}
|
|
441
617
|
} else if (this.ctx.storeCiphertext && this.ctx.sensitiveFields.size > 0) {
|
|
442
618
|
const src = record;
|
|
@@ -501,7 +677,7 @@ var RecordCodec = class _RecordCodec {
|
|
|
501
677
|
if (Object.keys(out).length > 0) vdigOut = out;
|
|
502
678
|
if (Object.keys(bidxOut).length > 0) bidxOutMap = bidxOut;
|
|
503
679
|
}
|
|
504
|
-
const base = await this.encryptJsonString(JSON.stringify(openRecord), version, cek, source, sourceTs);
|
|
680
|
+
const base = await this.encryptJsonString(ref, JSON.stringify(openRecord), version, cek, source, sourceTs);
|
|
505
681
|
const withSealed = sealed ? { ...base, _sealed: sealed } : base;
|
|
506
682
|
const withVdig = vdigOut ? { ...withSealed, _vdig: vdigOut } : withSealed;
|
|
507
683
|
const withBidx = bidxOutMap ? { ...withVdig, _bidx: bidxOutMap } : withVdig;
|
|
@@ -556,7 +732,15 @@ var RecordCodec = class _RecordCodec {
|
|
|
556
732
|
* The optional `id` lets reads populate the CEK cache; it is omitted by
|
|
557
733
|
* callers (history, conflict merge) that have only the envelope.
|
|
558
734
|
*/
|
|
559
|
-
|
|
735
|
+
/**
|
|
736
|
+
* `ref` must be the SAME identity the writer sealed against — which is the
|
|
737
|
+
* storage address, not necessarily this codec's own collection. Search's
|
|
738
|
+
* vector sidecar lives in `_vec`, its lexical index in `_ft`; passing
|
|
739
|
+
* `this.ctx.name` for those would recompute the wrong AAD and fail to open a
|
|
740
|
+
* perfectly good record (#1041).
|
|
741
|
+
*/
|
|
742
|
+
async decryptJsonString(ref, envelope) {
|
|
743
|
+
const id = ref.id;
|
|
560
744
|
if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
|
|
561
745
|
if (!this.ctx.storeCiphertext) {
|
|
562
746
|
if (envelope._debug !== void 0) {
|
|
@@ -568,10 +752,11 @@ var RecordCodec = class _RecordCodec {
|
|
|
568
752
|
}
|
|
569
753
|
return envelope._data === "" ? null : envelope._data;
|
|
570
754
|
}
|
|
755
|
+
const aad = recordAadFor(ref, envelope);
|
|
571
756
|
const cek = await this.resolveEnvelopeCek(envelope, id);
|
|
572
|
-
if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek);
|
|
757
|
+
if (cek !== void 0) return decrypt(envelope._iv, envelope._data, cek, aad);
|
|
573
758
|
const dek = await this.ctx.getDEK();
|
|
574
|
-
return decrypt(envelope._iv, envelope._data, dek);
|
|
759
|
+
return decrypt(envelope._iv, envelope._data, dek, aad);
|
|
575
760
|
}
|
|
576
761
|
/**
|
|
577
762
|
* Unseal a single `_sealed[field]` slot to its plaintext value: derive the
|
|
@@ -695,7 +880,7 @@ var RecordCodec = class _RecordCodec {
|
|
|
695
880
|
*/
|
|
696
881
|
async applySealedSlots(record, sealed, cek, opts = {}) {
|
|
697
882
|
if (this.ctx.via?.hasAtRestHooks) {
|
|
698
|
-
if (opts.id === void 0) {
|
|
883
|
+
if (opts.id === void 0 || opts.id === "") {
|
|
699
884
|
throw new Error(
|
|
700
885
|
`RecordCodec.decryptRecord: collection "${this.ctx.name}" has via at-rest hooks but this read path supplied no record id (needed to scope the sealed-slot capability) \u2014 caller bug.`
|
|
701
886
|
);
|
|
@@ -745,15 +930,17 @@ var RecordCodec = class _RecordCodec {
|
|
|
745
930
|
* output-recompute path, not the public per-record read surface schema
|
|
746
931
|
* validation guards.
|
|
747
932
|
*/
|
|
748
|
-
async decryptRecordAtDek(envelope, dek
|
|
933
|
+
async decryptRecordAtDek(ref, envelope, dek) {
|
|
934
|
+
const id = ref.id;
|
|
749
935
|
if (isTombstone(envelope, this.ctx.storeCiphertext) || isDeleteMarker(envelope)) return null;
|
|
750
936
|
let plaintext;
|
|
751
937
|
let cek;
|
|
938
|
+
const aad = recordAadFor(ref, envelope);
|
|
752
939
|
if (envelope._cek !== void 0) {
|
|
753
940
|
cek = await unwrapCek(envelope._cek, dek);
|
|
754
|
-
plaintext = await decrypt(envelope._iv, envelope._data, cek);
|
|
941
|
+
plaintext = await decrypt(envelope._iv, envelope._data, cek, aad);
|
|
755
942
|
} else {
|
|
756
|
-
plaintext = await decrypt(envelope._iv, envelope._data, dek);
|
|
943
|
+
plaintext = await decrypt(envelope._iv, envelope._data, dek, aad);
|
|
757
944
|
}
|
|
758
945
|
let record = JSON.parse(plaintext);
|
|
759
946
|
if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
|
|
@@ -776,8 +963,8 @@ var RecordCodec = class _RecordCodec {
|
|
|
776
963
|
* that may predate a schema change, so validating it would be a
|
|
777
964
|
* false positive. Every non-history read leaves this flag `false`.
|
|
778
965
|
*/
|
|
779
|
-
async decryptRecord(envelope, opts = {}) {
|
|
780
|
-
const json = await this.decryptJsonString(
|
|
966
|
+
async decryptRecord(ref, envelope, opts = {}) {
|
|
967
|
+
const json = await this.decryptJsonString(ref, envelope);
|
|
781
968
|
if (json === null) return null;
|
|
782
969
|
let parsed = JSON.parse(json);
|
|
783
970
|
if (this.ctx.crdtMode && parsed !== null && typeof parsed === "object" && "_crdt" in parsed) {
|
|
@@ -785,9 +972,9 @@ var RecordCodec = class _RecordCodec {
|
|
|
785
972
|
}
|
|
786
973
|
let record = parsed;
|
|
787
974
|
if (envelope._sealed !== void 0 && this.ctx.storeCiphertext) {
|
|
788
|
-
const sealedCek = await this.resolveEnvelopeCek(envelope,
|
|
975
|
+
const sealedCek = await this.resolveEnvelopeCek(envelope, ref.id);
|
|
789
976
|
record = await this.applySealedSlots(record, envelope._sealed, sealedCek, {
|
|
790
|
-
|
|
977
|
+
id: ref.id,
|
|
791
978
|
...opts.sealedAsHandles !== void 0 ? { sealedAsHandles: opts.sealedAsHandles } : {}
|
|
792
979
|
});
|
|
793
980
|
}
|
|
@@ -841,16 +1028,16 @@ async function sealRecordToHost(ctx, collection, id, hostSealer, opts) {
|
|
|
841
1028
|
};
|
|
842
1029
|
const envelopeKey = `${collection}/${id}/${hint.pid}`;
|
|
843
1030
|
const prior = await ctx.adapter.get(ctx.vault, SEALED_CEK_NS, envelopeKey);
|
|
844
|
-
const env =
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1031
|
+
const env = buildRecordEnvelope(
|
|
1032
|
+
{ collection: SEALED_CEK_NS, id: envelopeKey, version: (prior?._v ?? 0) + 1 },
|
|
1033
|
+
{
|
|
1034
|
+
// AES-GCM bypassed — the sealing layer is the security boundary, exactly
|
|
1035
|
+
// like the managed-secret `_meta/sealed-secret` envelope.
|
|
1036
|
+
iv: "",
|
|
1037
|
+
data: JSON.stringify(delivery),
|
|
1038
|
+
...ctx.actor ? { by: ctx.actor } : {}
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
854
1041
|
await ctx.adapter.put(ctx.vault, SEALED_CEK_NS, envelopeKey, env);
|
|
855
1042
|
return { pid: hint.pid, envelopeKey };
|
|
856
1043
|
}
|
|
@@ -868,9 +1055,26 @@ async function rotateRecordCek(ctx, collection, id) {
|
|
|
868
1055
|
}
|
|
869
1056
|
const dek = await ctx.getDEK(collection);
|
|
870
1057
|
const oldCek = await unwrapCek(live._cek, dek);
|
|
871
|
-
const
|
|
1058
|
+
const openAad = recordAadFor({ collection, id }, live);
|
|
1059
|
+
const json = await decrypt(live._iv, live._data, oldCek, openAad);
|
|
1060
|
+
const rotatedIdentity = {
|
|
1061
|
+
// A CEK rotation DOES bump `_v` (asserted in `record-scoped-cek-sealing`:
|
|
1062
|
+
// "the live envelope was re-keyed — new `_cek`, bumped `_v`"), so it seals
|
|
1063
|
+
// at the new version, not the one it just opened.
|
|
1064
|
+
//
|
|
1065
|
+
// ⚠️ Do not confuse this with `rekeyEnvelopeToDek`, the DEK-rotation helper,
|
|
1066
|
+
// which PRESERVES `_v` (#1074) because it re-keys a record without writing
|
|
1067
|
+
// one. Two rotations, opposite answers — and with `_v` bound (#1093) getting
|
|
1068
|
+
// it backwards no longer produces a wrong number, it produces an
|
|
1069
|
+
// unreadable record.
|
|
1070
|
+
collection,
|
|
1071
|
+
id,
|
|
1072
|
+
version: live._v + 1,
|
|
1073
|
+
...live._tier !== void 0 ? { tier: live._tier } : {},
|
|
1074
|
+
...ctx.actor ? { by: ctx.actor } : live._by !== void 0 ? { by: live._by } : {}
|
|
1075
|
+
};
|
|
872
1076
|
const newCek = await generateDEK();
|
|
873
|
-
const { iv, data } = await encrypt(json, newCek);
|
|
1077
|
+
const { iv, data } = await encrypt(json, newCek, buildRecordAad(rotatedIdentity));
|
|
874
1078
|
let sealedOut;
|
|
875
1079
|
if (live._sealed !== void 0) {
|
|
876
1080
|
const out = {};
|
|
@@ -890,30 +1094,27 @@ async function rotateRecordCek(ctx, collection, id) {
|
|
|
890
1094
|
}
|
|
891
1095
|
vdigOut = out;
|
|
892
1096
|
}
|
|
893
|
-
const env = {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
...sealedOut !== void 0 ? { _sealed: sealedOut } : {},
|
|
915
|
-
...vdigOut !== void 0 ? { _vdig: vdigOut } : {}
|
|
916
|
-
};
|
|
1097
|
+
const env = buildRecordEnvelope(rotatedIdentity, {
|
|
1098
|
+
iv,
|
|
1099
|
+
data,
|
|
1100
|
+
cek: await wrapCek(newCek, dek),
|
|
1101
|
+
extra: {
|
|
1102
|
+
...live._det !== void 0 ? { _det: live._det } : {},
|
|
1103
|
+
// `_bidx` (equality-index tag) is DEK-rooted and CEK-independent, so it is
|
|
1104
|
+
// carried forward VERBATIM — not recomputed — unlike `_vdig`/`_sealed`
|
|
1105
|
+
// below, which are CEK-bound and must be re-sealed under the new CEK.
|
|
1106
|
+
// Dropping this line would silently orphan the equality index on rotation
|
|
1107
|
+
// (the #306 Slice-A data-loss bug, replayed on the index).
|
|
1108
|
+
...live._bidx !== void 0 ? { _bidx: live._bidx } : {},
|
|
1109
|
+
// Re-encrypt sealed (`sensitive`) fields under the new CEK. Sealed
|
|
1110
|
+
// keys derive off the per-record CEK, so the rotated record's old CEK is
|
|
1111
|
+
// destroyed here — carrying the old `_sealed` slots forward verbatim would
|
|
1112
|
+
// orphan them (unreadable under the new CEK). `sealedOut` holds the slots
|
|
1113
|
+
// dual-read from the old CEK (or the legacy DEK) and re-sealed under newCek.
|
|
1114
|
+
...sealedOut !== void 0 ? { _sealed: sealedOut } : {},
|
|
1115
|
+
...vdigOut !== void 0 ? { _vdig: vdigOut } : {}
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
917
1118
|
await ctx.adapter.put(ctx.vault, collection, id, env);
|
|
918
1119
|
await ctx.invalidateRecordCaches(collection, id);
|
|
919
1120
|
const prefix = `${collection}/${id}/`;
|
|
@@ -957,7 +1158,7 @@ async function findByDet(ctx, field, value) {
|
|
|
957
1158
|
const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
|
|
958
1159
|
if (!env || !env._det || (env._tier ?? 0) > 0) continue;
|
|
959
1160
|
if (env._det[field] === target || env._det[field] === legacyTarget) {
|
|
960
|
-
return ctx.codec.decryptRecord(
|
|
1161
|
+
return ctx.codec.decryptRecord({ collection: ctx.name, id }, env);
|
|
961
1162
|
}
|
|
962
1163
|
}
|
|
963
1164
|
return null;
|
|
@@ -971,7 +1172,7 @@ async function queryByDet(ctx, field, value) {
|
|
|
971
1172
|
const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
|
|
972
1173
|
if (!env || !env._det || (env._tier ?? 0) > 0) continue;
|
|
973
1174
|
if (env._det[field] === target || env._det[field] === legacyTarget) {
|
|
974
|
-
const rec = await ctx.codec.decryptRecord(
|
|
1175
|
+
const rec = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env);
|
|
975
1176
|
if (rec !== null) matches.push(rec);
|
|
976
1177
|
}
|
|
977
1178
|
}
|
|
@@ -979,23 +1180,25 @@ async function queryByDet(ctx, field, value) {
|
|
|
979
1180
|
}
|
|
980
1181
|
|
|
981
1182
|
// src/kernel/enclave/record-keys/envelope-body.ts
|
|
982
|
-
async function openEnvelopeJson(env, key, opts) {
|
|
1183
|
+
async function openEnvelopeJson(ref, env, key, opts) {
|
|
983
1184
|
if (opts?.encrypted === false) return env._data;
|
|
1185
|
+
const aad = recordAadFor(ref, env);
|
|
984
1186
|
if (env._cek !== void 0) {
|
|
985
1187
|
const cek = await unwrapCek(env._cek, key);
|
|
986
|
-
return decrypt(env._iv, env._data, cek);
|
|
1188
|
+
return decrypt(env._iv, env._data, cek, aad);
|
|
987
1189
|
}
|
|
988
|
-
return decrypt(env._iv, env._data, key);
|
|
1190
|
+
return decrypt(env._iv, env._data, key, aad);
|
|
989
1191
|
}
|
|
990
|
-
async function writeEnvelopeBody(json, key, opts) {
|
|
1192
|
+
async function writeEnvelopeBody(identity, json, key, opts) {
|
|
991
1193
|
if (opts?.encrypted === false) return { _iv: "", _data: json };
|
|
1194
|
+
const aad = buildRecordAad(identity);
|
|
992
1195
|
if (opts?.perRecordKey === true) {
|
|
993
1196
|
const cek = await generateDEK();
|
|
994
|
-
const { iv: iv2, data: data2 } = await encrypt(json, cek);
|
|
1197
|
+
const { iv: iv2, data: data2 } = await encrypt(json, cek, aad);
|
|
995
1198
|
const wrapped = await wrapCek(cek, key);
|
|
996
1199
|
return { _iv: iv2, _data: data2, _cek: wrapped };
|
|
997
1200
|
}
|
|
998
|
-
const { iv, data } = await encrypt(json, key);
|
|
1201
|
+
const { iv, data } = await encrypt(json, key, aad);
|
|
999
1202
|
return { _iv: iv, _data: data };
|
|
1000
1203
|
}
|
|
1001
1204
|
function envelopeBodySize(env) {
|
|
@@ -1018,6 +1221,18 @@ function envelopeBodyForHash(env) {
|
|
|
1018
1221
|
if (env._bidx !== void 0) segments.push(mapPart("_bidx", env._bidx));
|
|
1019
1222
|
return `{${segments.join(",")}}`;
|
|
1020
1223
|
}
|
|
1224
|
+
function hasSealedBody(env) {
|
|
1225
|
+
return env._iv !== "";
|
|
1226
|
+
}
|
|
1227
|
+
async function verifyRecordIdentity(ref, env, key) {
|
|
1228
|
+
if (!hasSealedBody(env)) return true;
|
|
1229
|
+
try {
|
|
1230
|
+
await openEnvelopeJson(ref, env, key);
|
|
1231
|
+
return true;
|
|
1232
|
+
} catch {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1021
1236
|
|
|
1022
1237
|
// src/kernel/enclave/broker/proof.ts
|
|
1023
1238
|
var subtle2 = globalThis.crypto.subtle;
|
|
@@ -1103,11 +1318,17 @@ async function verifyBrokerProof(args) {
|
|
|
1103
1318
|
}
|
|
1104
1319
|
|
|
1105
1320
|
export {
|
|
1321
|
+
buildRecordAad,
|
|
1322
|
+
recordAadFor,
|
|
1106
1323
|
resolveStableCek,
|
|
1107
1324
|
rewrapBodyToDek,
|
|
1108
1325
|
applyRewrappedBody,
|
|
1109
1326
|
rewrapEnvelope,
|
|
1110
1327
|
isRewrappedUnder,
|
|
1328
|
+
rekeyEnvelopeToDek,
|
|
1329
|
+
rekeyEnvelopeIfNeeded,
|
|
1330
|
+
envelopeOpensUnderAny,
|
|
1331
|
+
rekeyBlobSet,
|
|
1111
1332
|
makeReservedEnvelopes,
|
|
1112
1333
|
validateSchemaInput,
|
|
1113
1334
|
validateSchemaOutput,
|
|
@@ -1123,10 +1344,12 @@ export {
|
|
|
1123
1344
|
envelopeBodySize,
|
|
1124
1345
|
hasPerRecordKey,
|
|
1125
1346
|
envelopeBodyForHash,
|
|
1347
|
+
hasSealedBody,
|
|
1348
|
+
verifyRecordIdentity,
|
|
1126
1349
|
deriveBrokerProofBits,
|
|
1127
1350
|
deriveBrokerProofKey,
|
|
1128
1351
|
computeBrokerProof,
|
|
1129
1352
|
issueChallenge,
|
|
1130
1353
|
verifyBrokerProof
|
|
1131
1354
|
};
|
|
1132
|
-
//# sourceMappingURL=chunk-
|
|
1355
|
+
//# sourceMappingURL=chunk-CXPOG3ZY.js.map
|