@noy-db/hub 0.2.0-pre.9 → 0.3.0-pre.10
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/README.md +129 -3
- package/dist/aggregate/index.d.ts +5 -2
- package/dist/aggregate/index.js +25 -16
- package/dist/aggregate/index.js.map +1 -1
- package/dist/api-TX2EX2FX.js +20 -0
- package/dist/as/index.d.ts +6 -0
- package/dist/as/index.js +30 -0
- package/dist/at/index.d.ts +4 -0
- package/dist/at/index.js +1 -0
- package/dist/attestation/index.d.ts +14 -47
- package/dist/attestation/index.js +60 -10
- package/dist/attestation/index.js.map +1 -1
- package/dist/backup-R7NTDFKY.js +225 -0
- package/dist/backup-R7NTDFKY.js.map +1 -0
- package/dist/blobs/index.d.ts +5 -8
- package/dist/blobs/index.js +25 -12
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.d.ts +15 -70
- package/dist/bundle/index.js +45 -476
- package/dist/bundle/index.js.map +1 -1
- package/dist/{ulid-CJ8RzRrm.d.ts → bundle-D6GxiUfq.d.ts} +31 -86
- package/dist/by/index.d.ts +1 -0
- package/dist/by/index.js +11 -0
- package/dist/cargo/index.d.ts +7 -0
- package/dist/cargo/index.js +95 -0
- package/dist/chunk-2OV5NVE7.js +95 -0
- package/dist/chunk-2OV5NVE7.js.map +1 -0
- package/dist/chunk-2OZXVKVP.js +367 -0
- package/dist/chunk-2OZXVKVP.js.map +1 -0
- package/dist/{chunk-HNRHLRDC.js → chunk-2REPHKET.js} +6 -5
- package/dist/chunk-2REPHKET.js.map +1 -0
- package/dist/{chunk-PE2FR4J3.js → chunk-3JXPAHOZ.js} +17 -17
- package/dist/chunk-3JXPAHOZ.js.map +1 -0
- package/dist/{chunk-H2X3ISXG.js → chunk-3MATJ6O4.js} +7 -7
- package/dist/chunk-3MATJ6O4.js.map +1 -0
- package/dist/{chunk-PP6W64Y3.js → chunk-3OPY6MK2.js} +132 -3
- package/dist/chunk-3OPY6MK2.js.map +1 -0
- package/dist/{chunk-T7JEBOGN.js → chunk-3QSIU3UT.js} +49 -71
- package/dist/chunk-3QSIU3UT.js.map +1 -0
- package/dist/{chunk-ZYWZWG6G.js → chunk-4OMCIY6F.js} +32 -12
- package/dist/chunk-4OMCIY6F.js.map +1 -0
- package/dist/chunk-4Q6HSHHL.js +90 -0
- package/dist/chunk-4Q6HSHHL.js.map +1 -0
- package/dist/chunk-5I35DOHK.js +94 -0
- package/dist/chunk-5I35DOHK.js.map +1 -0
- package/dist/chunk-5VG4IJR7.js +235 -0
- package/dist/chunk-5VG4IJR7.js.map +1 -0
- package/dist/chunk-5YESYH2C.js +155 -0
- package/dist/chunk-5YESYH2C.js.map +1 -0
- package/dist/chunk-6G5ORS5D.js +202 -0
- package/dist/chunk-6G5ORS5D.js.map +1 -0
- package/dist/{chunk-VTKGMEPP.js → chunk-6P5XCKSD.js} +13 -3
- package/dist/chunk-6P5XCKSD.js.map +1 -0
- package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
- package/dist/chunk-6S7T6WC4.js.map +1 -0
- package/dist/{chunk-U26HQ6KJ.js → chunk-7BWJHO2A.js} +4 -4
- package/dist/chunk-7BWJHO2A.js.map +1 -0
- package/dist/chunk-7P2SDJG3.js +279 -0
- package/dist/chunk-7P2SDJG3.js.map +1 -0
- package/dist/chunk-ANB77BVV.js +150 -0
- package/dist/chunk-ANB77BVV.js.map +1 -0
- package/dist/chunk-AURFOK3D.js +35 -0
- package/dist/chunk-AURFOK3D.js.map +1 -0
- package/dist/chunk-BKARNZJN.js +382 -0
- package/dist/chunk-BKARNZJN.js.map +1 -0
- package/dist/{chunk-3BFJOWSU.js → chunk-BQISD5ZV.js} +35 -7
- package/dist/chunk-BQISD5ZV.js.map +1 -0
- package/dist/{chunk-2GLDA55J.js → chunk-BUAQ7YI3.js} +260 -135
- package/dist/chunk-BUAQ7YI3.js.map +1 -0
- package/dist/{chunk-2WUSG3IT.js → chunk-CB7CWSKW.js} +5 -5
- package/dist/chunk-CB7CWSKW.js.map +1 -0
- package/dist/chunk-CHFZDSE4.js +1 -0
- package/dist/{aggregate/index.cjs → chunk-DFVUTGT2.js} +206 -222
- package/dist/chunk-DFVUTGT2.js.map +1 -0
- package/dist/chunk-DJ7KIPLV.js +23 -0
- package/dist/chunk-DJ7KIPLV.js.map +1 -0
- package/dist/chunk-DSKDQP3G.js +14066 -0
- package/dist/chunk-DSKDQP3G.js.map +1 -0
- package/dist/{chunk-5T22KDPN.js → chunk-DV4HUP5G.js} +10 -8
- package/dist/chunk-DV4HUP5G.js.map +1 -0
- package/dist/chunk-EOXAAJTY.js +621 -0
- package/dist/chunk-EOXAAJTY.js.map +1 -0
- package/dist/chunk-ET67AY6B.js +74 -0
- package/dist/chunk-ET67AY6B.js.map +1 -0
- package/dist/chunk-F4CEK5YM.js +123 -0
- package/dist/chunk-F4CEK5YM.js.map +1 -0
- package/dist/chunk-FORYWFN6.js +130 -0
- package/dist/chunk-FORYWFN6.js.map +1 -0
- package/dist/{chunk-JWRVQKRZ.js → chunk-FRP6D2DM.js} +21 -20
- package/dist/chunk-FRP6D2DM.js.map +1 -0
- package/dist/chunk-FUOE7UUV.js +341 -0
- package/dist/chunk-FUOE7UUV.js.map +1 -0
- package/dist/chunk-G4JYND6L.js +42 -0
- package/dist/chunk-G4JYND6L.js.map +1 -0
- package/dist/{chunk-53XBRIRT.js → chunk-G6XV4H65.js} +9 -9
- package/dist/chunk-G6XV4H65.js.map +1 -0
- package/dist/chunk-GHVIKOHT.js +1 -0
- package/dist/{chunk-PX35GA7L.js → chunk-GNMXXTMN.js} +11 -9
- package/dist/chunk-GNMXXTMN.js.map +1 -0
- package/dist/chunk-GYGLAVCX.js +19 -0
- package/dist/chunk-GYGLAVCX.js.map +1 -0
- package/dist/chunk-HPWKV3YB.js +21 -0
- package/dist/chunk-HPWKV3YB.js.map +1 -0
- package/dist/chunk-HY3AUMFI.js +41 -0
- package/dist/chunk-HY3AUMFI.js.map +1 -0
- package/dist/chunk-HYR4WZZ3.js +69 -0
- package/dist/chunk-HYR4WZZ3.js.map +1 -0
- package/dist/chunk-I7FD46FF.js +9 -0
- package/dist/chunk-I7FD46FF.js.map +1 -0
- package/dist/{chunk-TFBP23BX.js → chunk-ICXIFFYZ.js} +66 -7
- package/dist/chunk-ICXIFFYZ.js.map +1 -0
- package/dist/{chunk-TV3YZ35S.js → chunk-IGJCYUT5.js} +17 -8
- package/dist/chunk-IGJCYUT5.js.map +1 -0
- package/dist/{chunk-F3GDRNUT.js → chunk-IVLTXX4W.js} +36 -68
- package/dist/chunk-IVLTXX4W.js.map +1 -0
- package/dist/{chunk-DONMZAD2.js → chunk-J4LPNIGK.js} +62 -169
- package/dist/chunk-J4LPNIGK.js.map +1 -0
- package/dist/chunk-JJZ2LW6T.js +36 -0
- package/dist/chunk-JJZ2LW6T.js.map +1 -0
- package/dist/chunk-JK733I5V.js +23 -0
- package/dist/chunk-JK733I5V.js.map +1 -0
- package/dist/{chunk-3YPCK6JX.js → chunk-KJ2BCBTL.js} +181 -422
- package/dist/chunk-KJ2BCBTL.js.map +1 -0
- package/dist/chunk-KNZB6JMR.js +129 -0
- package/dist/chunk-KNZB6JMR.js.map +1 -0
- package/dist/{chunk-OIF6LZUR.js → chunk-KPZS5QAQ.js} +30 -11
- package/dist/chunk-KPZS5QAQ.js.map +1 -0
- package/dist/chunk-LB7FD65R.js +163 -0
- package/dist/chunk-LB7FD65R.js.map +1 -0
- package/dist/{chunk-DO7C2TOG.js → chunk-LEJIKBBB.js} +3 -3
- package/dist/{chunk-DO7C2TOG.js.map → chunk-LEJIKBBB.js.map} +1 -1
- package/dist/{chunk-O3VZPBZG.js → chunk-LL2NIVUR.js} +56 -13
- package/dist/chunk-LL2NIVUR.js.map +1 -0
- package/dist/chunk-LP7BEXCT.js +32 -0
- package/dist/chunk-LP7BEXCT.js.map +1 -0
- package/dist/chunk-MCHVVJIA.js +968 -0
- package/dist/chunk-MCHVVJIA.js.map +1 -0
- package/dist/chunk-NO272T7Q.js +194 -0
- package/dist/chunk-NO272T7Q.js.map +1 -0
- package/dist/{chunk-22DWZL57.js → chunk-NUEQU36L.js} +70 -267
- package/dist/chunk-NUEQU36L.js.map +1 -0
- package/dist/chunk-O45M6LDB.js +38 -0
- package/dist/chunk-O45M6LDB.js.map +1 -0
- package/dist/chunk-OBKWYKYC.js +117 -0
- package/dist/chunk-OBKWYKYC.js.map +1 -0
- package/dist/{chunk-DJHHA6XH.js → chunk-OHHKHSJP.js} +50 -20
- package/dist/chunk-OHHKHSJP.js.map +1 -0
- package/dist/chunk-OT76OZL6.js +45 -0
- package/dist/chunk-OT76OZL6.js.map +1 -0
- package/dist/chunk-OVYRLHPE.js +150 -0
- package/dist/chunk-OVYRLHPE.js.map +1 -0
- package/dist/{chunk-ML236QKC.js → chunk-OXCSVM3B.js} +5 -5
- package/dist/chunk-OXCSVM3B.js.map +1 -0
- package/dist/chunk-P33LUIML.js +205 -0
- package/dist/chunk-P33LUIML.js.map +1 -0
- package/dist/{chunk-DL3HWOQ5.js → chunk-PLS64NCS.js} +10 -8
- package/dist/chunk-PLS64NCS.js.map +1 -0
- package/dist/{chunk-SYMWGEET.js → chunk-PS2NEWEX.js} +3 -3
- package/dist/chunk-PS2NEWEX.js.map +1 -0
- package/dist/chunk-PY4KJPYU.js +9 -0
- package/dist/chunk-PY4KJPYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-QA2KUPCP.js +45 -0
- package/dist/chunk-QA2KUPCP.js.map +1 -0
- package/dist/chunk-QOC3VYL2.js +30 -0
- package/dist/chunk-QOC3VYL2.js.map +1 -0
- package/dist/{chunk-BVRYKATC.js → chunk-QSFOZUYL.js} +62 -34
- package/dist/chunk-QSFOZUYL.js.map +1 -0
- package/dist/chunk-RHK32N73.js +30 -0
- package/dist/chunk-RHK32N73.js.map +1 -0
- package/dist/{chunk-K3DK3NU5.js → chunk-RW3Y22MW.js} +20 -5
- package/dist/chunk-RW3Y22MW.js.map +1 -0
- package/dist/{chunk-B6PB7JLN.js → chunk-S7VFUQM2.js} +541 -6
- package/dist/chunk-S7VFUQM2.js.map +1 -0
- package/dist/chunk-SVLR4POP.js +64 -0
- package/dist/chunk-SVLR4POP.js.map +1 -0
- package/dist/chunk-T7WSLRAU.js +49 -0
- package/dist/chunk-T7WSLRAU.js.map +1 -0
- package/dist/{chunk-WPLVTJ5D.js → chunk-TAKWLZZX.js} +285 -63
- package/dist/chunk-TAKWLZZX.js.map +1 -0
- package/dist/chunk-THNJ3IKU.js +17 -0
- package/dist/chunk-THNJ3IKU.js.map +1 -0
- package/dist/{chunk-XJFLDA7A.js → chunk-TMBXVJKT.js} +9 -6
- package/dist/chunk-TMBXVJKT.js.map +1 -0
- package/dist/chunk-TWKKOM55.js +54 -0
- package/dist/chunk-TWKKOM55.js.map +1 -0
- package/dist/chunk-U3WZCU7E.js +14 -0
- package/dist/chunk-U3WZCU7E.js.map +1 -0
- package/dist/{chunk-Z6FNBOTC.js → chunk-UF362QVH.js} +15 -17
- package/dist/chunk-UF362QVH.js.map +1 -0
- package/dist/chunk-UN4FVIBH.js +135 -0
- package/dist/chunk-UN4FVIBH.js.map +1 -0
- package/dist/chunk-VEAVKDDB.js +29 -0
- package/dist/chunk-VEAVKDDB.js.map +1 -0
- package/dist/chunk-VEPTFUJY.js +29 -0
- package/dist/chunk-VEPTFUJY.js.map +1 -0
- package/dist/chunk-VJV7GKQK.js +662 -0
- package/dist/chunk-VJV7GKQK.js.map +1 -0
- package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
- package/dist/chunk-VQNJ7UZL.js.map +1 -0
- package/dist/chunk-VQRAIPYF.js +50 -0
- package/dist/chunk-VQRAIPYF.js.map +1 -0
- package/dist/{chunk-DFMLEQZB.js → chunk-VRIYFLBA.js} +5 -10
- package/dist/chunk-VRIYFLBA.js.map +1 -0
- package/dist/chunk-VWM3DAVB.js +265 -0
- package/dist/chunk-VWM3DAVB.js.map +1 -0
- package/dist/{chunk-NONAAENK.js → chunk-VWRRVE6D.js} +11 -4
- package/dist/chunk-VWRRVE6D.js.map +1 -0
- package/dist/chunk-VYYM3MEN.js +98 -0
- package/dist/chunk-VYYM3MEN.js.map +1 -0
- package/dist/chunk-WBJIQSLL.js +167 -0
- package/dist/chunk-WBJIQSLL.js.map +1 -0
- package/dist/chunk-WIGQB62E.js +164 -0
- package/dist/chunk-WIGQB62E.js.map +1 -0
- package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
- package/dist/chunk-WXSYDNBT.js.map +1 -0
- package/dist/chunk-WZSCE6RM.js +466 -0
- package/dist/chunk-WZSCE6RM.js.map +1 -0
- package/dist/chunk-XGDAPN6M.js +255 -0
- package/dist/chunk-XGDAPN6M.js.map +1 -0
- package/dist/{chunk-QODLLGQ7.js → chunk-XH7XP3OL.js} +372 -37
- package/dist/chunk-XH7XP3OL.js.map +1 -0
- package/dist/chunk-XREOISSI.js +40 -0
- package/dist/chunk-XREOISSI.js.map +1 -0
- package/dist/chunk-XUBPSPKD.js +164 -0
- package/dist/chunk-XUBPSPKD.js.map +1 -0
- package/dist/chunk-Y3A5CB5G.js +247 -0
- package/dist/chunk-Y3A5CB5G.js.map +1 -0
- package/dist/{chunk-I5FOWO4J.js → chunk-YCXCR7VG.js} +52 -73
- package/dist/chunk-YCXCR7VG.js.map +1 -0
- package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
- package/dist/chunk-YMUGBZN2.js.map +1 -0
- package/dist/chunk-YMVQD5Q5.js +453 -0
- package/dist/chunk-YMVQD5Q5.js.map +1 -0
- package/dist/chunk-YN5IAHN6.js +32 -0
- package/dist/chunk-YN5IAHN6.js.map +1 -0
- package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
- package/dist/chunk-ZJADGNYF.js.map +1 -0
- package/dist/chunk-ZYJ55N7N.js +86 -0
- package/dist/chunk-ZYJ55N7N.js.map +1 -0
- package/dist/classified/index.d.ts +16 -0
- package/dist/classified/index.js +40 -0
- package/dist/classified-marker-H6YSHYNK.js +24 -0
- package/dist/classified-marker-H6YSHYNK.js.map +1 -0
- package/dist/collection-facade-LVD22JLM.js +39 -0
- package/dist/computed-EXDMQODG.js +11 -0
- package/dist/consent/index.d.ts +4 -7
- package/dist/consent/index.js +13 -5
- package/dist/consent/index.js.map +1 -1
- package/dist/crdt/index.d.ts +5 -2
- package/dist/crdt/index.js +3 -2
- package/dist/crdt/index.js.map +1 -1
- package/dist/dead-filter-HQIE2YG7.js +28 -0
- package/dist/dead-filter-HQIE2YG7.js.map +1 -0
- package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
- package/dist/delegation-BJP73GAP.js +25 -0
- package/dist/derivations/index.d.ts +6 -9
- package/dist/derivations/index.js +18 -6
- package/dist/derive-BME7HDWO.js +21 -0
- package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-Bmm2pgJ0.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/enclave-NHORSWSF.js +125 -0
- package/dist/executor-FE6X4LFX.js +9 -0
- package/dist/executor-KSHKRJXP.js +25 -0
- package/dist/executor-ZHTJJICG.js +9 -0
- package/dist/export-accessible-DACHM5VT.js +23 -0
- package/dist/extract-partition-RNENZZ4T.js +36 -0
- package/dist/fanout-sidecar-OFWN3NM7.js +74 -0
- package/dist/fanout-sidecar-OFWN3NM7.js.map +1 -0
- package/dist/fence-watcher-DHQ775JB.js +69 -0
- package/dist/fence-watcher-DHQ775JB.js.map +1 -0
- package/dist/find-BNGBJNKP.js +11 -0
- package/dist/forget/index.d.ts +36 -0
- package/dist/forget/index.js +25 -0
- package/dist/forget/index.js.map +1 -0
- package/dist/guards/index.d.ts +12 -9
- package/dist/guards/index.js +12 -5
- package/dist/{hash-DdpVypUp.d.cts → hash-DAJjMsCE.d.ts} +10 -1
- package/dist/history/index.d.ts +5 -8
- package/dist/history/index.js +25 -12
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.d.ts +25 -8
- package/dist/i18n/index.js +137 -29
- package/dist/i18n/index.js.map +1 -1
- package/dist/in/index.d.ts +4 -0
- package/dist/in/index.js +1 -0
- package/dist/in/index.js.map +1 -0
- package/dist/index-B9QdHytu.d.ts +123 -0
- package/dist/index-DjWbxsjb.d.ts +23579 -0
- package/dist/index-qwuNvO2B.d.ts +144 -0
- package/dist/index.d.ts +1179 -449
- package/dist/index.js +2524 -312
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.d.ts +5 -3
- package/dist/indexing/index.js +6 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-NDI4CVZU.js +19 -0
- package/dist/issue-NDI4CVZU.js.map +1 -0
- package/dist/json-schema-I22JCYCG.js +44 -0
- package/dist/json-schema-I22JCYCG.js.map +1 -0
- package/dist/lazy/index.d.ts +20 -0
- package/dist/lazy/index.js +12 -0
- package/dist/lazy/index.js.map +1 -0
- package/dist/ledger-6NDS2EO4.js +42 -0
- package/dist/ledger-6NDS2EO4.js.map +1 -0
- package/dist/liberate-HN3RIGIP.js +24 -0
- package/dist/liberate-HN3RIGIP.js.map +1 -0
- package/dist/link-set-SJB2MVJV.js +31 -0
- package/dist/link-set-SJB2MVJV.js.map +1 -0
- package/dist/materialized-views/index.d.ts +23 -20
- package/dist/materialized-views/index.js +26 -12
- package/dist/mime-magic-bBj5OgUC.d.ts +103 -0
- package/dist/noydb-BWF6EPIR.js +66 -0
- package/dist/noydb-BWF6EPIR.js.map +1 -0
- package/dist/on/index.d.ts +4 -0
- package/dist/on/index.js +17 -0
- package/dist/on/index.js.map +1 -0
- package/dist/overlay-views/index.d.ts +26 -11
- package/dist/overlay-views/index.js +7 -6
- package/dist/periods/index.d.ts +4 -7
- package/dist/periods/index.js +27 -9
- package/dist/pod/index.d.ts +62 -0
- package/dist/pod/index.js +67 -0
- package/dist/pod/index.js.map +1 -0
- package/dist/policy-WGNAG5H6.js +41 -0
- package/dist/policy-WGNAG5H6.js.map +1 -0
- package/dist/portability/index.d.ts +19 -0
- package/dist/portability/index.js +43 -0
- package/dist/portability/index.js.map +1 -0
- package/dist/post-register-CWKBQRC7.js +55 -0
- package/dist/post-register-CWKBQRC7.js.map +1 -0
- package/dist/{public-envelope-BW6OXORV.js → public-envelope-EJLVIFX7.js} +6 -5
- package/dist/public-envelope-EJLVIFX7.js.map +1 -0
- package/dist/query/index.d.ts +4 -3
- package/dist/query/index.js +24 -13
- package/dist/read-only-facade-CHCKSEPD.js +8 -0
- package/dist/read-only-facade-CHCKSEPD.js.map +1 -0
- package/dist/register-SBIX7TVV.js +23 -0
- package/dist/register-SBIX7TVV.js.map +1 -0
- package/dist/registry-3EQG6OOE.js +18 -0
- package/dist/registry-3EQG6OOE.js.map +1 -0
- package/dist/registry-CA327ACV.js +9 -0
- package/dist/registry-CA327ACV.js.map +1 -0
- package/dist/registry-E7OXOTSV.js +19 -0
- package/dist/registry-E7OXOTSV.js.map +1 -0
- package/dist/registry-VW6P6A3J.js +8 -0
- package/dist/registry-VW6P6A3J.js.map +1 -0
- package/dist/request-withdrawal-KAH2AAXC.js +31 -0
- package/dist/request-withdrawal-KAH2AAXC.js.map +1 -0
- package/dist/reveal-R3JLHMUF.js +38 -0
- package/dist/reveal-R3JLHMUF.js.map +1 -0
- package/dist/revoke-IXLOJ3IH.js +24 -0
- package/dist/revoke-IXLOJ3IH.js.map +1 -0
- package/dist/satellites/index.d.ts +4 -0
- package/dist/satellites/index.js +8 -0
- package/dist/satellites/index.js.map +1 -0
- package/dist/sealed-record/index.d.ts +68 -0
- package/dist/sealed-record/index.js +71 -0
- package/dist/sealed-record/index.js.map +1 -0
- package/dist/session/index.d.ts +5 -8
- package/dist/session/index.js +13 -5
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.d.ts +4 -7
- package/dist/shadow/index.js +4 -3
- package/dist/shadow/index.js.map +1 -1
- package/dist/signer-Y46N2GJ3.js +25 -0
- package/dist/signer-Y46N2GJ3.js.map +1 -0
- package/dist/snapshots/index.d.ts +5 -8
- package/dist/snapshots/index.js +19 -11
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-6ZDBTQT7.js → stale-Z7IW6RIL.js} +3 -2
- package/dist/stale-Z7IW6RIL.js.map +1 -0
- package/dist/storage-ADNP2UWI.js +23 -0
- package/dist/storage-ADNP2UWI.js.map +1 -0
- package/dist/store-coordination-provider-DTDMI6VL.js +142 -0
- package/dist/store-coordination-provider-DTDMI6VL.js.map +1 -0
- package/dist/subject-index-CyOgGMJL.d.ts +380 -0
- package/dist/sync/index.d.ts +3 -6
- package/dist/sync/index.js +13 -6
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.d.ts +46 -10
- package/dist/team/index.js +35 -18
- package/dist/tiers/index.d.ts +4 -0
- package/dist/tiers/index.js +39 -0
- package/dist/tiers/index.js.map +1 -0
- package/dist/to/index.d.ts +4 -0
- package/dist/to/index.js +16 -0
- package/dist/to/index.js.map +1 -0
- package/dist/transition-guard-DI-krBsZ.d.ts +165 -0
- package/dist/tx/index.d.ts +22 -9
- package/dist/tx/index.js +13 -8
- package/dist/tx/index.js.map +1 -1
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ulid-DRH25k3y.d.ts +66 -0
- package/dist/ulid-PTAIMDG4.js +10 -0
- package/dist/ulid-PTAIMDG4.js.map +1 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +7 -2
- package/dist/util/index.js.map +1 -1
- package/dist/validators-BUcli5Nh.d.ts +101 -0
- package/dist/vault-diff-Z2DUayMe.d.ts +147 -0
- package/dist/verify-JPF2YR5E.js +139 -0
- package/dist/verify-JPF2YR5E.js.map +1 -0
- package/dist/walk-XYA2O3LW.js +241 -0
- package/dist/walk-XYA2O3LW.js.map +1 -0
- package/dist/with/index.d.ts +37 -0
- package/dist/with/index.js +31 -0
- package/dist/with/index.js.map +1 -0
- package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-BUmzlXue.d.ts} +1 -1
- package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-m4FaXXTO.d.ts} +2 -3
- package/dist/with-rollup-DEKGI9vb.d.ts +47 -0
- package/dist/withdraw-accessible-WLV4MTEN.js +28 -0
- package/dist/withdraw-accessible-WLV4MTEN.js.map +1 -0
- package/dist/zod-HAJM7LMS.js +14763 -0
- package/dist/zod-HAJM7LMS.js.map +1 -0
- package/package.json +122 -202
- package/dist/aggregate/index.cjs.map +0 -1
- package/dist/aggregate/index.d.cts +0 -38
- package/dist/attestation/index.cjs +0 -305
- package/dist/attestation/index.cjs.map +0 -1
- package/dist/attestation/index.d.cts +0 -52
- package/dist/blobs/index.cjs +0 -1480
- package/dist/blobs/index.cjs.map +0 -1
- package/dist/blobs/index.d.cts +0 -46
- package/dist/bundle/index.cjs +0 -19264
- package/dist/bundle/index.cjs.map +0 -1
- package/dist/bundle/index.d.cts +0 -176
- package/dist/chunk-22DWZL57.js.map +0 -1
- package/dist/chunk-2GLDA55J.js.map +0 -1
- package/dist/chunk-2QR2PQTT.js.map +0 -1
- package/dist/chunk-2WUSG3IT.js.map +0 -1
- package/dist/chunk-3BFJOWSU.js.map +0 -1
- package/dist/chunk-3YPCK6JX.js.map +0 -1
- package/dist/chunk-53XBRIRT.js.map +0 -1
- package/dist/chunk-5T22KDPN.js.map +0 -1
- package/dist/chunk-5XHKQ56N.js +0 -340
- package/dist/chunk-5XHKQ56N.js.map +0 -1
- package/dist/chunk-6CME4UEK.js +0 -10329
- package/dist/chunk-6CME4UEK.js.map +0 -1
- package/dist/chunk-6STK5TQP.js +0 -139
- package/dist/chunk-6STK5TQP.js.map +0 -1
- package/dist/chunk-A3JMGXPG.js.map +0 -1
- package/dist/chunk-B6PB7JLN.js.map +0 -1
- package/dist/chunk-BVRYKATC.js.map +0 -1
- package/dist/chunk-DE6GKS6G.js +0 -79
- package/dist/chunk-DE6GKS6G.js.map +0 -1
- package/dist/chunk-DFMLEQZB.js.map +0 -1
- package/dist/chunk-DJHHA6XH.js.map +0 -1
- package/dist/chunk-DL3HWOQ5.js.map +0 -1
- package/dist/chunk-DONMZAD2.js.map +0 -1
- package/dist/chunk-EMIGCR7X.js.map +0 -1
- package/dist/chunk-F3GDRNUT.js.map +0 -1
- package/dist/chunk-FZU343FL.js.map +0 -1
- package/dist/chunk-H2X3ISXG.js.map +0 -1
- package/dist/chunk-HNRHLRDC.js.map +0 -1
- package/dist/chunk-I5FOWO4J.js.map +0 -1
- package/dist/chunk-J66GRPNH.js.map +0 -1
- package/dist/chunk-JWRVQKRZ.js.map +0 -1
- package/dist/chunk-K3DK3NU5.js.map +0 -1
- package/dist/chunk-ML236QKC.js.map +0 -1
- package/dist/chunk-NONAAENK.js.map +0 -1
- package/dist/chunk-O3VZPBZG.js.map +0 -1
- package/dist/chunk-OIF6LZUR.js.map +0 -1
- package/dist/chunk-OQ6PIGHA.js +0 -19
- package/dist/chunk-OQ6PIGHA.js.map +0 -1
- package/dist/chunk-PE2FR4J3.js.map +0 -1
- package/dist/chunk-PP6W64Y3.js.map +0 -1
- package/dist/chunk-PX35GA7L.js.map +0 -1
- package/dist/chunk-QEILDE6R.js +0 -793
- package/dist/chunk-QEILDE6R.js.map +0 -1
- package/dist/chunk-QODLLGQ7.js.map +0 -1
- package/dist/chunk-RAZ4OVLL.js +0 -51
- package/dist/chunk-RAZ4OVLL.js.map +0 -1
- package/dist/chunk-SYMWGEET.js.map +0 -1
- package/dist/chunk-T7JEBOGN.js.map +0 -1
- package/dist/chunk-TFBP23BX.js.map +0 -1
- package/dist/chunk-TV3YZ35S.js.map +0 -1
- package/dist/chunk-U26HQ6KJ.js.map +0 -1
- package/dist/chunk-UF3BUNQZ.js +0 -1
- package/dist/chunk-UMLVJTYV.js +0 -20
- package/dist/chunk-UMLVJTYV.js.map +0 -1
- package/dist/chunk-VTKGMEPP.js.map +0 -1
- package/dist/chunk-W6EQLGMB.js +0 -100
- package/dist/chunk-W6EQLGMB.js.map +0 -1
- package/dist/chunk-WIRRPTFH.js +0 -17
- package/dist/chunk-WIRRPTFH.js.map +0 -1
- package/dist/chunk-WPLVTJ5D.js.map +0 -1
- package/dist/chunk-XJFLDA7A.js.map +0 -1
- package/dist/chunk-Z6FNBOTC.js.map +0 -1
- package/dist/chunk-ZYWZWG6G.js.map +0 -1
- package/dist/consent/index.cjs +0 -204
- package/dist/consent/index.cjs.map +0 -1
- package/dist/consent/index.d.cts +0 -25
- package/dist/crdt/index.cjs +0 -152
- package/dist/crdt/index.cjs.map +0 -1
- package/dist/crdt/index.d.cts +0 -30
- package/dist/crypto-HTZ4FJOP.js +0 -44
- package/dist/delegation-RI54P6I5.js +0 -17
- package/dist/derivations/index.cjs +0 -351
- package/dist/derivations/index.cjs.map +0 -1
- package/dist/derivations/index.d.cts +0 -72
- package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
- package/dist/executor-5PNY7LGW.js +0 -8
- package/dist/executor-B4QIYGZX.js +0 -8
- package/dist/executor-BWXXDQ7K.js +0 -11
- package/dist/fanout-sidecar-OKPMMPLG.js +0 -51
- package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
- package/dist/guards/index.cjs +0 -322
- package/dist/guards/index.cjs.map +0 -1
- package/dist/guards/index.d.cts +0 -31
- package/dist/hash-HJqD14vS.d.ts +0 -63
- package/dist/history/index.cjs +0 -1222
- package/dist/history/index.cjs.map +0 -1
- package/dist/history/index.d.cts +0 -63
- package/dist/i18n/index.cjs +0 -1100
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -39
- package/dist/index-4fBVt8j9.d.cts +0 -2387
- package/dist/index-D8I_pyJD.d.ts +0 -2387
- package/dist/index.cjs +0 -24487
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -776
- package/dist/indexing/index.cjs +0 -742
- package/dist/indexing/index.cjs.map +0 -1
- package/dist/indexing/index.d.cts +0 -36
- package/dist/issue-VGDPP4B5.js +0 -12
- package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
- package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
- package/dist/ledger-TMRZYNVJ.js +0 -33
- package/dist/materialized-views/index.cjs +0 -854
- package/dist/materialized-views/index.cjs.map +0 -1
- package/dist/materialized-views/index.d.cts +0 -186
- package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
- package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
- package/dist/noydb-G725ZSZG.js +0 -34
- package/dist/overlay-views/index.cjs +0 -359
- package/dist/overlay-views/index.cjs.map +0 -1
- package/dist/overlay-views/index.d.cts +0 -82
- package/dist/periods/index.cjs +0 -1041
- package/dist/periods/index.cjs.map +0 -1
- package/dist/periods/index.d.cts +0 -22
- package/dist/predicate-BSAGEyu5.d.cts +0 -209
- package/dist/predicate-BSAGEyu5.d.ts +0 -209
- package/dist/query/index.cjs +0 -2375
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -3
- package/dist/read-only-facade-ITU6L7BL.js +0 -7
- package/dist/registry-3QP3YKQS.js +0 -8
- package/dist/registry-DKEXOJVO.js +0 -7
- package/dist/registry-OJIOSBV6.js +0 -10
- package/dist/registry-USRVT6YF.js +0 -8
- package/dist/revoke-JCC7N56X.js +0 -17
- package/dist/session/index.cjs +0 -495
- package/dist/session/index.cjs.map +0 -1
- package/dist/session/index.d.cts +0 -46
- package/dist/shadow/index.cjs +0 -133
- package/dist/shadow/index.cjs.map +0 -1
- package/dist/shadow/index.d.cts +0 -17
- package/dist/signer-72QAUSVW.js +0 -18
- package/dist/snapshots/index.cjs +0 -937
- package/dist/snapshots/index.cjs.map +0 -1
- package/dist/snapshots/index.d.cts +0 -28
- package/dist/store/index.cjs +0 -1083
- package/dist/store/index.cjs.map +0 -1
- package/dist/store/index.d.cts +0 -492
- package/dist/store/index.d.ts +0 -492
- package/dist/store/index.js +0 -37
- package/dist/strategy-BSxFXGzb.d.cts +0 -110
- package/dist/strategy-BSxFXGzb.d.ts +0 -110
- package/dist/strategy-DSTrsZ8t.d.cts +0 -601
- package/dist/strategy-DSTrsZ8t.d.ts +0 -601
- package/dist/sync/index.cjs +0 -1062
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.d.cts +0 -43
- package/dist/team/index.cjs +0 -2798
- package/dist/team/index.cjs.map +0 -1
- package/dist/team/index.d.cts +0 -118
- package/dist/tx/index.cjs +0 -544
- package/dist/tx/index.cjs.map +0 -1
- package/dist/tx/index.d.cts +0 -21
- package/dist/types-Df28QFKb.d.ts +0 -12818
- package/dist/types-DyXYr8rE.d.cts +0 -12818
- package/dist/ulid-COREQ2RQ.js +0 -9
- package/dist/ulid-Drr7ykr6.d.cts +0 -603
- package/dist/util/index.cjs +0 -230
- package/dist/util/index.cjs.map +0 -1
- package/dist/util/index.d.cts +0 -77
- package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
- package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
- package/dist/with-guard-ByyxmEe7.d.cts +0 -18
- package/dist/with-guard-qube6BMI.d.ts +0 -18
- package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
- package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
- /package/dist/{chunk-UF3BUNQZ.js.map → api-TX2EX2FX.js.map} +0 -0
- /package/dist/{store → as}/index.js.map +0 -0
- /package/dist/{crypto-HTZ4FJOP.js.map → at/index.js.map} +0 -0
- /package/dist/{delegation-RI54P6I5.js.map → by/index.js.map} +0 -0
- /package/dist/{executor-5PNY7LGW.js.map → cargo/index.js.map} +0 -0
- /package/dist/{executor-B4QIYGZX.js.map → chunk-CHFZDSE4.js.map} +0 -0
- /package/dist/{executor-BWXXDQ7K.js.map → chunk-GHVIKOHT.js.map} +0 -0
- /package/dist/{issue-VGDPP4B5.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/dist/{ledger-TMRZYNVJ.js.map → classified/index.js.map} +0 -0
- /package/dist/{noydb-G725ZSZG.js.map → collection-facade-LVD22JLM.js.map} +0 -0
- /package/dist/{public-envelope-BW6OXORV.js.map → computed-EXDMQODG.js.map} +0 -0
- /package/dist/{read-only-facade-ITU6L7BL.js.map → delegation-BJP73GAP.js.map} +0 -0
- /package/dist/{registry-3QP3YKQS.js.map → derive-BME7HDWO.js.map} +0 -0
- /package/dist/{registry-DKEXOJVO.js.map → enclave-NHORSWSF.js.map} +0 -0
- /package/dist/{registry-OJIOSBV6.js.map → executor-FE6X4LFX.js.map} +0 -0
- /package/dist/{registry-USRVT6YF.js.map → executor-KSHKRJXP.js.map} +0 -0
- /package/dist/{revoke-JCC7N56X.js.map → executor-ZHTJJICG.js.map} +0 -0
- /package/dist/{signer-72QAUSVW.js.map → export-accessible-DACHM5VT.js.map} +0 -0
- /package/dist/{stale-6ZDBTQT7.js.map → extract-partition-RNENZZ4T.js.map} +0 -0
- /package/dist/{ulid-COREQ2RQ.js.map → find-BNGBJNKP.js.map} +0 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadVaultPolicy,
|
|
3
|
+
saveVaultPolicy
|
|
4
|
+
} from "./chunk-G4JYND6L.js";
|
|
5
|
+
import {
|
|
6
|
+
PolicyDeniedError,
|
|
7
|
+
ValidationError
|
|
8
|
+
} from "./chunk-S7VFUQM2.js";
|
|
9
|
+
|
|
10
|
+
// src/with-party/policy/presets.ts
|
|
11
|
+
var PERSONAL_POLICY = Object.freeze({
|
|
12
|
+
passphrase: {
|
|
13
|
+
minWords: 6,
|
|
14
|
+
minWordLength: 3,
|
|
15
|
+
rejectRepeatedAdjacent: true
|
|
16
|
+
},
|
|
17
|
+
gates: {
|
|
18
|
+
"rotate-passphrase": {
|
|
19
|
+
minTier: 1,
|
|
20
|
+
// Any second factor satisfies the gate — off-device kinds (TOTP,
|
|
21
|
+
// email-OTP, paper recovery, roaming WebAuthn) are the strongest;
|
|
22
|
+
// platform-bound kinds (platform WebAuthn, password, PIN) are
|
|
23
|
+
// accepted because requiring "something off-device" is overkill
|
|
24
|
+
// for personal/SMB threat models. Consumers needing the off-device
|
|
25
|
+
// guarantee should use STRICT_POLICY or override this gate.
|
|
26
|
+
factors: [{
|
|
27
|
+
anyOf: [
|
|
28
|
+
"totp",
|
|
29
|
+
"email-otp",
|
|
30
|
+
"recovery",
|
|
31
|
+
"webauthn-roaming",
|
|
32
|
+
"webauthn-platform",
|
|
33
|
+
"password",
|
|
34
|
+
"pin"
|
|
35
|
+
]
|
|
36
|
+
}]
|
|
37
|
+
},
|
|
38
|
+
"recover-passphrase": {
|
|
39
|
+
minTier: 1,
|
|
40
|
+
enabled: true
|
|
41
|
+
},
|
|
42
|
+
// rotate-recovery: deliberate paper-sheet regeneration
|
|
43
|
+
// when the user remembers their passphrase. PERSONAL allows tier-1 —
|
|
44
|
+
// knowing the passphrase is enough.
|
|
45
|
+
"rotate-recovery": { minTier: 1 },
|
|
46
|
+
"enroll-authenticator": { minTier: 1 },
|
|
47
|
+
"remove-authenticator": { minTier: 1 },
|
|
48
|
+
// update-authenticator: meta-only mutation (slot rename, label
|
|
49
|
+
// changes). Symmetric with enroll/remove under PERSONAL — tier-1
|
|
50
|
+
// unlock alone. The structural anti-slot-swap guard inside the
|
|
51
|
+
// implementation enforces wrap-material/id/method immutability
|
|
52
|
+
// regardless of this gate's settings.
|
|
53
|
+
"update-authenticator": { minTier: 1 },
|
|
54
|
+
"rotate-unlock": { minTier: 2 },
|
|
55
|
+
"enroll-user": { minTier: 1 },
|
|
56
|
+
"revoke-user": { minTier: 1 },
|
|
57
|
+
// Peer-recovery is a high-trust intentional op — co-owners
|
|
58
|
+
// recovering each other should not need an off-device factor in
|
|
59
|
+
// the personal/SMB threat model (the partner is already vetted by
|
|
60
|
+
// virtue of being a co-owner). Tier-1 unlock is the floor; the
|
|
61
|
+
// STRICT preset adds a recovery/email-OTP requirement.
|
|
62
|
+
"peer-recover-user": { minTier: 1 },
|
|
63
|
+
// update-user: post-grant identity mutation (role/displayName/
|
|
64
|
+
// permissions). PERSONAL_POLICY treats this on par with enroll-user
|
|
65
|
+
// / revoke-user — tier-1 unlock alone. The role-elevation guard
|
|
66
|
+
// inside the implementation is the structural backstop that this
|
|
67
|
+
// gate's settings cannot weaken.
|
|
68
|
+
"update-user": { minTier: 1 },
|
|
69
|
+
"export-bundle": { minTier: 1 },
|
|
70
|
+
"export-plaintext": {
|
|
71
|
+
minTier: 1,
|
|
72
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
73
|
+
},
|
|
74
|
+
"view-user-auth": {
|
|
75
|
+
minTier: 1,
|
|
76
|
+
enabled: false
|
|
77
|
+
},
|
|
78
|
+
// ─── User envelope gates ──────────────────────────────────────────
|
|
79
|
+
// edit-own-profile: tier 3 floor — any active session can edit their
|
|
80
|
+
// own profile/preferences. Tightening to require a TOTP for
|
|
81
|
+
// profile changes is a one-line override.
|
|
82
|
+
// view-team-profiles: tier 2 floor — an authenticated session can
|
|
83
|
+
// read teammates' profiles (display names, avatars, locales).
|
|
84
|
+
// Setting `enabled: false` makes vault.user.list() return only
|
|
85
|
+
// self (privacy-strict opt-out).
|
|
86
|
+
"edit-own-profile": { minTier: 3 },
|
|
87
|
+
"view-team-profiles": { minTier: 2 },
|
|
88
|
+
// client-unilateral-withdraw: a non-owner's self-service DESTRUCTIVE
|
|
89
|
+
// withdrawal (export-and-delete/freeze). Fail-closed by default —
|
|
90
|
+
// the firm opts in per jurisdiction/contract (e.g. GDPR Art. 17).
|
|
91
|
+
// Listed explicitly (not just relying on the built-in default) so it is
|
|
92
|
+
// discoverable in describeGate / policy dumps.
|
|
93
|
+
"client-unilateral-withdraw": { minTier: 1, enabled: false },
|
|
94
|
+
// Two-party withdrawal: filing a request is non-destructive
|
|
95
|
+
// (tier-1, enabled so a read-only client can ask); deciding it is the
|
|
96
|
+
// destructive step (tier-2 floor + owner/admin role, enforced in code).
|
|
97
|
+
"user-request-withdrawal": { minTier: 1 },
|
|
98
|
+
"approve-user-withdrawal": { minTier: 2 }
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
var STRICT_POLICY = Object.freeze({
|
|
102
|
+
passphrase: {
|
|
103
|
+
minWords: 8,
|
|
104
|
+
minWordLength: 3,
|
|
105
|
+
rejectRepeatedAdjacent: true
|
|
106
|
+
},
|
|
107
|
+
gates: {
|
|
108
|
+
"rotate-passphrase": {
|
|
109
|
+
minTier: 1,
|
|
110
|
+
factors: [{ anyOf: ["totp", "email-otp", "recovery"], count: 2 }]
|
|
111
|
+
},
|
|
112
|
+
"recover-passphrase": {
|
|
113
|
+
minTier: 1,
|
|
114
|
+
enabled: true
|
|
115
|
+
},
|
|
116
|
+
// rotate-recovery: STRICT requires an off-device factor —
|
|
117
|
+
// rotating recovery is an off-site-trust event; a stolen unlocked
|
|
118
|
+
// laptop must not be able to silently mint a new sheet for the
|
|
119
|
+
// attacker. Matches the `peer-recover-user` STRICT default.
|
|
120
|
+
"rotate-recovery": {
|
|
121
|
+
minTier: 1,
|
|
122
|
+
factors: [{ anyOf: ["totp", "email-otp", "webauthn-roaming"] }]
|
|
123
|
+
},
|
|
124
|
+
"enroll-authenticator": {
|
|
125
|
+
minTier: 1,
|
|
126
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
127
|
+
},
|
|
128
|
+
"remove-authenticator": {
|
|
129
|
+
minTier: 1,
|
|
130
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
131
|
+
},
|
|
132
|
+
// STRICT update-authenticator: same factor floor as enroll/remove.
|
|
133
|
+
// Even though meta changes don't touch wrap material, a malicious
|
|
134
|
+
// rename could mislead the user about which device a slot
|
|
135
|
+
// corresponds to ("MacBook Touch ID" → "iPhone Touch ID" on a
|
|
136
|
+
// shared workstation). STRICT requires a fresh factor proof.
|
|
137
|
+
"update-authenticator": {
|
|
138
|
+
minTier: 1,
|
|
139
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
140
|
+
},
|
|
141
|
+
"rotate-unlock": { minTier: 1 },
|
|
142
|
+
"enroll-user": {
|
|
143
|
+
minTier: 1,
|
|
144
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
145
|
+
},
|
|
146
|
+
"revoke-user": {
|
|
147
|
+
minTier: 1,
|
|
148
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
149
|
+
},
|
|
150
|
+
// STRICT peer-recovery: the issuer must present a recovery code
|
|
151
|
+
// OR a fresh off-device second factor at the moment of recovery.
|
|
152
|
+
// This binds the high-trust operation to a verifiable proof
|
|
153
|
+
// (recovery sheet photographed by an attacker won't suffice —
|
|
154
|
+
// they'd also need tier-1 unlock first; this gate is the freshness
|
|
155
|
+
// binding on top). Roaming WebAuthn (YubiKey-class hardware key)
|
|
156
|
+
// accepted; platform-bound kinds (Touch ID, password, PIN)
|
|
157
|
+
// intentionally excluded under STRICT because they don't survive
|
|
158
|
+
// device theft — the off-device requirement is the whole point.
|
|
159
|
+
"peer-recover-user": {
|
|
160
|
+
minTier: 1,
|
|
161
|
+
factors: [{ anyOf: ["recovery", "totp", "email-otp", "webauthn-roaming"] }]
|
|
162
|
+
},
|
|
163
|
+
// STRICT update-user: matches the enroll-user / revoke-user shape
|
|
164
|
+
// (off-device factor required). Update-user is admin-shaped — it
|
|
165
|
+
// mutates someone else's role/permissions; STRICT requires a fresh
|
|
166
|
+
// off-device factor proof so the operator affirmatively re-asserts
|
|
167
|
+
// identity at the moment of mutation. Platform-bound factors
|
|
168
|
+
// (Touch ID / password / PIN) intentionally excluded: same logic as
|
|
169
|
+
// peer-recover-user — the off-device requirement is the whole
|
|
170
|
+
// point under STRICT.
|
|
171
|
+
"update-user": {
|
|
172
|
+
minTier: 1,
|
|
173
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
174
|
+
},
|
|
175
|
+
"export-bundle": {
|
|
176
|
+
minTier: 1,
|
|
177
|
+
factors: [{ anyOf: ["totp", "email-otp"] }],
|
|
178
|
+
warn: { sharedDevice: "block" }
|
|
179
|
+
},
|
|
180
|
+
"export-plaintext": {
|
|
181
|
+
minTier: 1,
|
|
182
|
+
factors: [{ anyOf: ["totp", "email-otp"], count: 2 }],
|
|
183
|
+
warn: { sharedDevice: "block" }
|
|
184
|
+
},
|
|
185
|
+
"view-user-auth": {
|
|
186
|
+
minTier: 1,
|
|
187
|
+
enabled: false
|
|
188
|
+
},
|
|
189
|
+
// ─── User envelope gates ──────────────────────────────────────────
|
|
190
|
+
// STRICT: profile edits require a TOTP/email-OTP factor (typical
|
|
191
|
+
// shared-workstation hardening — your name/avatar shouldn't change
|
|
192
|
+
// without a fresh second-factor proof).
|
|
193
|
+
"edit-own-profile": {
|
|
194
|
+
minTier: 2,
|
|
195
|
+
factors: [{ anyOf: ["totp", "email-otp"] }]
|
|
196
|
+
},
|
|
197
|
+
"view-team-profiles": { minTier: 2 },
|
|
198
|
+
// STRICT: still fail-closed, but if a regulated firm flips enabled:true
|
|
199
|
+
// they inherit a two-factor proof + shared-device block for the
|
|
200
|
+
// destructive withdrawal (mirrors export-plaintext's hardening).
|
|
201
|
+
"client-unilateral-withdraw": {
|
|
202
|
+
minTier: 1,
|
|
203
|
+
enabled: false,
|
|
204
|
+
factors: [{ anyOf: ["totp", "email-otp"], count: 2 }],
|
|
205
|
+
warn: { sharedDevice: "block" }
|
|
206
|
+
},
|
|
207
|
+
// STRICT: filing stays tier-1; the destructive APPROVE demands an
|
|
208
|
+
// off-device factor + shared-device block (mirrors export-bundle).
|
|
209
|
+
"user-request-withdrawal": { minTier: 1 },
|
|
210
|
+
"approve-user-withdrawal": {
|
|
211
|
+
minTier: 2,
|
|
212
|
+
factors: [{ anyOf: ["totp", "email-otp"] }],
|
|
213
|
+
warn: { sharedDevice: "block" }
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
function mergePolicy(base, override) {
|
|
218
|
+
if (!override) return base;
|
|
219
|
+
const passphrase = override.passphrase ?? base.passphrase;
|
|
220
|
+
return {
|
|
221
|
+
...passphrase !== void 0 ? { passphrase } : {},
|
|
222
|
+
gates: {
|
|
223
|
+
...base.gates,
|
|
224
|
+
...override.gates ?? {}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/with-party/policy/engine.ts
|
|
230
|
+
var DEFAULT_FRESHNESS_MS = 5 * 60 * 1e3;
|
|
231
|
+
async function checkGate(policy, gate, context) {
|
|
232
|
+
const configured = policy.gates[gate];
|
|
233
|
+
if (!configured) {
|
|
234
|
+
if (gate.startsWith("app:")) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
throw deny(gate, "disabled", { minTier: 1, enabled: false });
|
|
238
|
+
}
|
|
239
|
+
if (configured.enabled === false) {
|
|
240
|
+
throw deny(gate, "disabled", configured);
|
|
241
|
+
}
|
|
242
|
+
if (context.activeTier > configured.minTier) {
|
|
243
|
+
throw deny(gate, "insufficient-tier", configured);
|
|
244
|
+
}
|
|
245
|
+
if (configured.factors && configured.factors.length > 0) {
|
|
246
|
+
const presented = context.factors ?? [];
|
|
247
|
+
const now = context.now ?? Date.now();
|
|
248
|
+
for (const requirement of configured.factors) {
|
|
249
|
+
const matches = countMatchingFactors(presented, requirement, now);
|
|
250
|
+
const need = requirement.count ?? 1;
|
|
251
|
+
if (matches.fresh < need) {
|
|
252
|
+
if (matches.totalKindMatches < need) {
|
|
253
|
+
throw deny(gate, "missing-factor", configured);
|
|
254
|
+
}
|
|
255
|
+
throw deny(gate, "stale-proof", configured);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (configured.warn?.sharedDevice === "block" && context.sharedDevice === true) {
|
|
260
|
+
throw deny(gate, "shared-device-blocked", configured);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async function describeGate(policy, gate, context) {
|
|
264
|
+
try {
|
|
265
|
+
await checkGate(policy, gate, context);
|
|
266
|
+
return { ok: true };
|
|
267
|
+
} catch (err) {
|
|
268
|
+
if (err instanceof PolicyDeniedError) {
|
|
269
|
+
return { ok: false, reason: err.reason, required: err.required };
|
|
270
|
+
}
|
|
271
|
+
throw err;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function countMatchingFactors(presented, requirement, now) {
|
|
275
|
+
const freshnessMs = requirement.freshnessMs ?? DEFAULT_FRESHNESS_MS;
|
|
276
|
+
let totalKindMatches = 0;
|
|
277
|
+
let fresh = 0;
|
|
278
|
+
for (const proof of presented) {
|
|
279
|
+
if (!requirement.anyOf.includes(proof.kind)) continue;
|
|
280
|
+
totalKindMatches += 1;
|
|
281
|
+
const minted = proof.mintedAt ? Date.parse(proof.mintedAt) : now;
|
|
282
|
+
if (Number.isFinite(minted) && now - minted <= freshnessMs) {
|
|
283
|
+
fresh += 1;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return { totalKindMatches, fresh };
|
|
287
|
+
}
|
|
288
|
+
function deny(gate, reason, required) {
|
|
289
|
+
return new PolicyDeniedError(gate, reason, required);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/with-party/policy/noydb-facade.ts
|
|
293
|
+
var NoydbPolicy = class {
|
|
294
|
+
constructor(deps) {
|
|
295
|
+
this.deps = deps;
|
|
296
|
+
}
|
|
297
|
+
deps;
|
|
298
|
+
/**
|
|
299
|
+
* Touch the policy enforcer for a vault (records activity, resets
|
|
300
|
+
* idle timer). Also touches the legacy session timer. No-op if no enforcer.
|
|
301
|
+
*/
|
|
302
|
+
touchPolicy(vault) {
|
|
303
|
+
this.deps.resetSessionTimer();
|
|
304
|
+
if (vault) {
|
|
305
|
+
this.deps.policyEnforcers.get(vault)?.touch();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Check that a policy-guarded operation is permitted.
|
|
310
|
+
* Throws `SessionPolicyError` if re-auth is required.
|
|
311
|
+
*/
|
|
312
|
+
checkPolicyOperation(vault, op) {
|
|
313
|
+
this.deps.policyEnforcers.get(vault)?.checkOperation(op);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Read the active policy for a vault. Loads from `_meta/policy` on
|
|
317
|
+
* first call; subsequent calls hit the in-memory cache. Throws
|
|
318
|
+
* `ValidationError` if the vault has not been opened.
|
|
319
|
+
*/
|
|
320
|
+
async getPolicy(vault) {
|
|
321
|
+
if (this.deps.isClosed()) throw new ValidationError("Instance is closed");
|
|
322
|
+
const cached = this.deps.policyCache.get(vault);
|
|
323
|
+
if (cached) return cached;
|
|
324
|
+
await this.bootstrapPolicy(vault);
|
|
325
|
+
return this.deps.policyCache.get(vault) ?? PERSONAL_POLICY;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Replace the policy document at `_meta/policy` and update the
|
|
329
|
+
* in-memory cache. Gated by the `enroll-user` policy (a policy
|
|
330
|
+
* change is fundamentally a privilege-management action).
|
|
331
|
+
*/
|
|
332
|
+
async updatePolicy(vault, override) {
|
|
333
|
+
if (this.deps.isClosed()) throw new ValidationError("Instance is closed");
|
|
334
|
+
const current = await this.getPolicy(vault);
|
|
335
|
+
const merged = mergePolicy(current, override);
|
|
336
|
+
if (this.deps.encrypted) {
|
|
337
|
+
await saveVaultPolicy(this.deps.store, vault, merged);
|
|
338
|
+
}
|
|
339
|
+
this.deps.policyCache.set(vault, merged);
|
|
340
|
+
return merged;
|
|
341
|
+
}
|
|
342
|
+
/** Read or persist the vault policy at `_meta/policy` on first open. */
|
|
343
|
+
async bootstrapPolicy(vault, opts) {
|
|
344
|
+
const onDisk = await loadVaultPolicy(this.deps.store, vault);
|
|
345
|
+
if (onDisk) {
|
|
346
|
+
this.deps.policyCache.set(vault, onDisk);
|
|
347
|
+
await this.deps.assertRecoveryEnrolled(vault, onDisk, opts);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const initial = this.deps.policyOption ? mergePolicy(PERSONAL_POLICY, this.deps.policyOption) : PERSONAL_POLICY;
|
|
351
|
+
await saveVaultPolicy(this.deps.store, vault, initial);
|
|
352
|
+
this.deps.policyCache.set(vault, initial);
|
|
353
|
+
await this.deps.assertRecoveryEnrolled(vault, initial, opts);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
var createNoydbPolicy = (deps) => new NoydbPolicy(deps);
|
|
357
|
+
|
|
358
|
+
export {
|
|
359
|
+
PERSONAL_POLICY,
|
|
360
|
+
STRICT_POLICY,
|
|
361
|
+
mergePolicy,
|
|
362
|
+
DEFAULT_FRESHNESS_MS,
|
|
363
|
+
checkGate,
|
|
364
|
+
describeGate,
|
|
365
|
+
createNoydbPolicy
|
|
366
|
+
};
|
|
367
|
+
//# sourceMappingURL=chunk-2OZXVKVP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-party/policy/presets.ts","../src/with-party/policy/engine.ts","../src/with-party/policy/noydb-facade.ts"],"sourcesContent":["import type { VaultPolicy } from '../../kernel/types.js'\n\n/**\n * Default policy for personal vaults and SMB deployments — the gates\n * that need an off-device factor get one (TOTP / email-OTP / paper\n * recovery), the rest take a tier-1 unlock alone. Tier-3 (PIN) is the\n * floor only for `rotate-unlock` because that's the\n * \"change my PIN\" flow.\n *\n * The unspecified gates (e.g. `view-user-auth`) inherit the engine\n * default of `{ enabled: false, minTier: 1 }` — they fail closed.\n *\n * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → Built-in gates\n */\nexport const PERSONAL_POLICY: VaultPolicy = Object.freeze({\n passphrase: {\n minWords: 6,\n minWordLength: 3,\n rejectRepeatedAdjacent: true,\n },\n gates: {\n 'rotate-passphrase': {\n minTier: 1,\n // Any second factor satisfies the gate — off-device kinds (TOTP,\n // email-OTP, paper recovery, roaming WebAuthn) are the strongest;\n // platform-bound kinds (platform WebAuthn, password, PIN) are\n // accepted because requiring \"something off-device\" is overkill\n // for personal/SMB threat models. Consumers needing the off-device\n // guarantee should use STRICT_POLICY or override this gate.\n factors: [{\n anyOf: [\n 'totp', 'email-otp', 'recovery',\n 'webauthn-roaming', 'webauthn-platform',\n 'password', 'pin',\n ],\n }],\n },\n 'recover-passphrase': {\n minTier: 1,\n enabled: true,\n },\n // rotate-recovery: deliberate paper-sheet regeneration\n // when the user remembers their passphrase. PERSONAL allows tier-1 —\n // knowing the passphrase is enough.\n 'rotate-recovery': { minTier: 1 },\n 'enroll-authenticator': { minTier: 1 },\n 'remove-authenticator': { minTier: 1 },\n // update-authenticator: meta-only mutation (slot rename, label\n // changes). Symmetric with enroll/remove under PERSONAL — tier-1\n // unlock alone. The structural anti-slot-swap guard inside the\n // implementation enforces wrap-material/id/method immutability\n // regardless of this gate's settings.\n 'update-authenticator': { minTier: 1 },\n 'rotate-unlock': { minTier: 2 },\n 'enroll-user': { minTier: 1 },\n 'revoke-user': { minTier: 1 },\n // Peer-recovery is a high-trust intentional op — co-owners\n // recovering each other should not need an off-device factor in\n // the personal/SMB threat model (the partner is already vetted by\n // virtue of being a co-owner). Tier-1 unlock is the floor; the\n // STRICT preset adds a recovery/email-OTP requirement.\n 'peer-recover-user': { minTier: 1 },\n // update-user: post-grant identity mutation (role/displayName/\n // permissions). PERSONAL_POLICY treats this on par with enroll-user\n // / revoke-user — tier-1 unlock alone. The role-elevation guard\n // inside the implementation is the structural backstop that this\n // gate's settings cannot weaken.\n 'update-user': { minTier: 1 },\n 'export-bundle': { minTier: 1 },\n 'export-plaintext': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'view-user-auth': {\n minTier: 1,\n enabled: false,\n },\n // ─── User envelope gates ──────────────────────────────────────────\n // edit-own-profile: tier 3 floor — any active session can edit their\n // own profile/preferences. Tightening to require a TOTP for\n // profile changes is a one-line override.\n // view-team-profiles: tier 2 floor — an authenticated session can\n // read teammates' profiles (display names, avatars, locales).\n // Setting `enabled: false` makes vault.user.list() return only\n // self (privacy-strict opt-out).\n 'edit-own-profile': { minTier: 3 },\n 'view-team-profiles': { minTier: 2 },\n // client-unilateral-withdraw: a non-owner's self-service DESTRUCTIVE\n // withdrawal (export-and-delete/freeze). Fail-closed by default —\n // the firm opts in per jurisdiction/contract (e.g. GDPR Art. 17).\n // Listed explicitly (not just relying on the built-in default) so it is\n // discoverable in describeGate / policy dumps.\n 'client-unilateral-withdraw': { minTier: 1, enabled: false },\n // Two-party withdrawal: filing a request is non-destructive\n // (tier-1, enabled so a read-only client can ask); deciding it is the\n // destructive step (tier-2 floor + owner/admin role, enforced in code).\n 'user-request-withdrawal': { minTier: 1 },\n 'approve-user-withdrawal': { minTier: 2 },\n },\n}) as VaultPolicy\n\n/**\n * Strict policy for regulated deployments and shared workstations —\n * raises the phrase floor to 8 words, demands two distinct factors for\n * exports, and blocks export-on-shared-device. Use as a base for\n * `policy: { ...STRICT_POLICY, gates: { ...STRICT_POLICY.gates, ... } }`\n * tweaks.\n */\nexport const STRICT_POLICY: VaultPolicy = Object.freeze({\n passphrase: {\n minWords: 8,\n minWordLength: 3,\n rejectRepeatedAdjacent: true,\n },\n gates: {\n 'rotate-passphrase': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp', 'recovery'], count: 2 }],\n },\n 'recover-passphrase': {\n minTier: 1,\n enabled: true,\n },\n // rotate-recovery: STRICT requires an off-device factor —\n // rotating recovery is an off-site-trust event; a stolen unlocked\n // laptop must not be able to silently mint a new sheet for the\n // attacker. Matches the `peer-recover-user` STRICT default.\n 'rotate-recovery': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp', 'webauthn-roaming'] }],\n },\n 'enroll-authenticator': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'remove-authenticator': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n // STRICT update-authenticator: same factor floor as enroll/remove.\n // Even though meta changes don't touch wrap material, a malicious\n // rename could mislead the user about which device a slot\n // corresponds to (\"MacBook Touch ID\" → \"iPhone Touch ID\" on a\n // shared workstation). STRICT requires a fresh factor proof.\n 'update-authenticator': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'rotate-unlock': { minTier: 1 },\n 'enroll-user': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'revoke-user': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n // STRICT peer-recovery: the issuer must present a recovery code\n // OR a fresh off-device second factor at the moment of recovery.\n // This binds the high-trust operation to a verifiable proof\n // (recovery sheet photographed by an attacker won't suffice —\n // they'd also need tier-1 unlock first; this gate is the freshness\n // binding on top). Roaming WebAuthn (YubiKey-class hardware key)\n // accepted; platform-bound kinds (Touch ID, password, PIN)\n // intentionally excluded under STRICT because they don't survive\n // device theft — the off-device requirement is the whole point.\n 'peer-recover-user': {\n minTier: 1,\n factors: [{ anyOf: ['recovery', 'totp', 'email-otp', 'webauthn-roaming'] }],\n },\n // STRICT update-user: matches the enroll-user / revoke-user shape\n // (off-device factor required). Update-user is admin-shaped — it\n // mutates someone else's role/permissions; STRICT requires a fresh\n // off-device factor proof so the operator affirmatively re-asserts\n // identity at the moment of mutation. Platform-bound factors\n // (Touch ID / password / PIN) intentionally excluded: same logic as\n // peer-recover-user — the off-device requirement is the whole\n // point under STRICT.\n 'update-user': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'export-bundle': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n warn: { sharedDevice: 'block' },\n },\n 'export-plaintext': {\n minTier: 1,\n factors: [{ anyOf: ['totp', 'email-otp'], count: 2 }],\n warn: { sharedDevice: 'block' },\n },\n 'view-user-auth': {\n minTier: 1,\n enabled: false,\n },\n // ─── User envelope gates ──────────────────────────────────────────\n // STRICT: profile edits require a TOTP/email-OTP factor (typical\n // shared-workstation hardening — your name/avatar shouldn't change\n // without a fresh second-factor proof).\n 'edit-own-profile': {\n minTier: 2,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n },\n 'view-team-profiles': { minTier: 2 },\n // STRICT: still fail-closed, but if a regulated firm flips enabled:true\n // they inherit a two-factor proof + shared-device block for the\n // destructive withdrawal (mirrors export-plaintext's hardening).\n 'client-unilateral-withdraw': {\n minTier: 1,\n enabled: false,\n factors: [{ anyOf: ['totp', 'email-otp'], count: 2 }],\n warn: { sharedDevice: 'block' },\n },\n // STRICT: filing stays tier-1; the destructive APPROVE demands an\n // off-device factor + shared-device block (mirrors export-bundle).\n 'user-request-withdrawal': { minTier: 1 },\n 'approve-user-withdrawal': {\n minTier: 2,\n factors: [{ anyOf: ['totp', 'email-otp'] }],\n warn: { sharedDevice: 'block' },\n },\n },\n}) as VaultPolicy\n\n/**\n * Merge a developer override onto a preset. Unspecified gates inherit;\n * specified gates fully replace the preset's entry for that gate.\n *\n * Example:\n *\n * ```ts\n * mergePolicy(PERSONAL_POLICY, {\n * gates: {\n * 'app:approve-large-payment': { minTier: 2, factors: [{ anyOf: ['totp'] }] },\n * },\n * })\n * // → PERSONAL_POLICY plus the new app gate; existing gates intact.\n * ```\n */\nexport function mergePolicy(\n base: VaultPolicy,\n override?: Partial<VaultPolicy>,\n): VaultPolicy {\n if (!override) return base\n const passphrase = override.passphrase ?? base.passphrase\n return {\n ...(passphrase !== undefined ? { passphrase } : {}),\n gates: {\n ...base.gates,\n ...(override.gates ?? {}),\n },\n }\n}\n","/**\n * Policy gate engine — the {@link checkGate} entry point.\n *\n * Given a configured {@link VaultPolicy}, an active session tier, and\n * the factor proofs an actor is presenting, decide whether the gate\n * permits the action. On denial, throws {@link PolicyDeniedError} with\n * a stable {@link PolicyDenyReason} so consumers can branch in error\n * UIs.\n *\n * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → checkGate() API\n *\n * @module\n */\nimport { PolicyDeniedError, type PolicyDenyReason } from '../../kernel/errors.js'\nimport type {\n ActiveTier,\n FactorProof,\n GateName,\n GatePolicy,\n VaultPolicy,\n FactorRequirement,\n} from '../../kernel/types.js'\n\n/** Default freshness window — 5 minutes. */\nexport const DEFAULT_FRESHNESS_MS = 5 * 60 * 1000\n\n/** Caller-supplied context for one `checkGate` invocation. */\nexport interface CheckGateContext {\n /** Tier the active session currently holds. */\n readonly activeTier: ActiveTier\n /** Proofs the actor is presenting for this gate. */\n readonly factors?: ReadonlyArray<FactorProof>\n /**\n * If the host knows the actor is on a shared device, set this to\n * `true` so the engine can apply `warn.sharedDevice` rules. Defaults\n * to `false`.\n */\n readonly sharedDevice?: boolean\n /**\n * Override `now()` for tests. Defaults to `Date.now()`.\n * @internal\n */\n readonly now?: number\n}\n\n/**\n * Decide whether `gate` permits the action under `context`. Throws\n * {@link PolicyDeniedError} on denial; resolves with `void` on success.\n *\n * Lookup rules:\n * - **Built-in gates** without a configured policy fail closed\n * (`enabled: false`).\n * - **App-defined gates** (`app:*`) without a configured policy are\n * treated as no-op (allow). The developer registered the policy if\n * they wanted enforcement; absence means the gate is informational.\n */\nexport async function checkGate(\n policy: VaultPolicy,\n gate: GateName,\n context: CheckGateContext,\n): Promise<void> {\n const configured = policy.gates[gate]\n if (!configured) {\n if (gate.startsWith('app:')) {\n // Custom app gate without a policy — the developer hasn't\n // registered one; engine treats it as an unenforced label.\n return\n }\n // Built-in gate without a policy — fail closed.\n throw deny(gate, 'disabled', { minTier: 1, enabled: false })\n }\n\n if (configured.enabled === false) {\n throw deny(gate, 'disabled', configured)\n }\n\n // Tier check first — cheap and a hard prerequisite.\n if (context.activeTier > configured.minTier) {\n // Higher number is a LOWER tier in this model (1 is most privileged).\n throw deny(gate, 'insufficient-tier', configured)\n }\n\n // Factor checks — every requirement entry must be satisfied.\n if (configured.factors && configured.factors.length > 0) {\n const presented = context.factors ?? []\n const now = context.now ?? Date.now()\n for (const requirement of configured.factors) {\n const matches = countMatchingFactors(presented, requirement, now)\n const need = requirement.count ?? 1\n if (matches.fresh < need) {\n if (matches.totalKindMatches < need) {\n throw deny(gate, 'missing-factor', configured)\n }\n // Some matched the kind list but not the freshness window.\n throw deny(gate, 'stale-proof', configured)\n }\n }\n }\n\n // Soft signals — only `'block'` raises here.\n if (configured.warn?.sharedDevice === 'block' && context.sharedDevice === true) {\n throw deny(gate, 'shared-device-blocked', configured)\n }\n}\n\n/**\n * Same as {@link checkGate} but returns a structured verdict instead\n * of throwing. Useful when an error UI wants to show the user\n * \"you'll need TOTP plus a recovery code to do that\" without first\n * triggering the action.\n */\nexport async function describeGate(\n policy: VaultPolicy,\n gate: GateName,\n context: CheckGateContext,\n): Promise<{ ok: true } | { ok: false; reason: PolicyDenyReason; required: GatePolicy }> {\n try {\n await checkGate(policy, gate, context)\n return { ok: true }\n } catch (err) {\n if (err instanceof PolicyDeniedError) {\n return { ok: false, reason: err.reason, required: err.required }\n }\n throw err\n }\n}\n\nfunction countMatchingFactors(\n presented: ReadonlyArray<FactorProof>,\n requirement: FactorRequirement,\n now: number,\n): { totalKindMatches: number; fresh: number } {\n const freshnessMs = requirement.freshnessMs ?? DEFAULT_FRESHNESS_MS\n let totalKindMatches = 0\n let fresh = 0\n for (const proof of presented) {\n if (!requirement.anyOf.includes(proof.kind)) continue\n totalKindMatches += 1\n const minted = proof.mintedAt ? Date.parse(proof.mintedAt) : now\n if (Number.isFinite(minted) && now - minted <= freshnessMs) {\n fresh += 1\n }\n }\n return { totalKindMatches, fresh }\n}\n\nfunction deny(gate: GateName, reason: PolicyDenyReason, required: GatePolicy): PolicyDeniedError {\n return new PolicyDeniedError(gate, reason, required)\n}\n","/**\n * Noydb-side policy / session-policy facade.\n *\n * Holds the vault-policy read/update/bootstrap logic (`getPolicy`,\n * `updatePolicy`, `bootstrapPolicy`) and the per-vault session-policy\n * enforcer wiring (`touchPolicy`, `checkPolicyOperation`). The session\n * *timer* and the managed-recovery enrolment check stay kernel-resident on\n * `Noydb` (interleaved with the instance lifecycle) and arrive here as the\n * `resetSessionTimer` / `assertRecoveryEnrolled` callbacks. The policy cache\n * and the enforcer map stay `Noydb`-resident too (touched by\n * `openVault`/`close`) and arrive by reference; behaviour is byte-identical\n * to the inline `Noydb` methods it replaced — every other dependency the\n * moving code touched on `this.*` arrives via {@link NoydbPolicyDeps}.\n *\n * Internal service — reached through `noydb.getPolicy(...)` etc. Public\n * contract ({@link NoydbPolicyApi} / {@link NoydbPolicyDeps} /\n * {@link NoydbPolicyFactory}) lives in the kernel spine; `createNoydb()`\n * wires this file's {@link createNoydbPolicy} in via a pre-resolved dynamic\n * import (the S4 gate recipe).\n */\nimport { ValidationError } from '../../kernel/errors.js'\nimport { PERSONAL_POLICY, mergePolicy } from './presets.js'\nimport { loadVaultPolicy, saveVaultPolicy } from './storage.js'\nimport type { VaultPolicy, ReAuthOperation, NoydbPolicyApi, NoydbPolicyDeps, NoydbPolicyFactory } from '../../kernel/types.js'\n\nexport class NoydbPolicy implements NoydbPolicyApi {\n constructor(private readonly deps: NoydbPolicyDeps) {}\n\n /**\n * Touch the policy enforcer for a vault (records activity, resets\n * idle timer). Also touches the legacy session timer. No-op if no enforcer.\n */\n touchPolicy(vault?: string): void {\n this.deps.resetSessionTimer()\n if (vault) {\n this.deps.policyEnforcers.get(vault)?.touch()\n }\n }\n\n /**\n * Check that a policy-guarded operation is permitted.\n * Throws `SessionPolicyError` if re-auth is required.\n */\n checkPolicyOperation(vault: string, op: ReAuthOperation): void {\n this.deps.policyEnforcers.get(vault)?.checkOperation(op)\n }\n\n /**\n * Read the active policy for a vault. Loads from `_meta/policy` on\n * first call; subsequent calls hit the in-memory cache. Throws\n * `ValidationError` if the vault has not been opened.\n */\n async getPolicy(vault: string): Promise<VaultPolicy> {\n if (this.deps.isClosed()) throw new ValidationError('Instance is closed')\n const cached = this.deps.policyCache.get(vault)\n if (cached) return cached\n await this.bootstrapPolicy(vault)\n return this.deps.policyCache.get(vault) ?? PERSONAL_POLICY\n }\n\n /**\n * Replace the policy document at `_meta/policy` and update the\n * in-memory cache. Gated by the `enroll-user` policy (a policy\n * change is fundamentally a privilege-management action).\n */\n async updatePolicy(vault: string, override: Partial<VaultPolicy>): Promise<VaultPolicy> {\n if (this.deps.isClosed()) throw new ValidationError('Instance is closed')\n const current = await this.getPolicy(vault)\n const merged = mergePolicy(current, override)\n if (this.deps.encrypted) {\n await saveVaultPolicy(this.deps.store, vault, merged)\n }\n this.deps.policyCache.set(vault, merged)\n return merged\n }\n\n /** Read or persist the vault policy at `_meta/policy` on first open. */\n async bootstrapPolicy(\n vault: string,\n opts?: { skipManagedCheck?: boolean },\n ): Promise<void> {\n const onDisk = await loadVaultPolicy(this.deps.store, vault)\n if (onDisk) {\n // Honour the on-disk document; developer overrides cannot\n // weaken what the vault committed to at creation time.\n this.deps.policyCache.set(vault, onDisk)\n await this.deps.assertRecoveryEnrolled(vault, onDisk, opts)\n return\n }\n // First time — persist the developer's policy (or default preset).\n const initial = this.deps.policyOption\n ? mergePolicy(PERSONAL_POLICY, this.deps.policyOption)\n : PERSONAL_POLICY\n await saveVaultPolicy(this.deps.store, vault, initial)\n this.deps.policyCache.set(vault, initial)\n await this.deps.assertRecoveryEnrolled(vault, initial, opts)\n }\n}\n\n/**\n * Factory that builds the `NoydbPolicy` service. `createNoydb()`\n * pre-resolves this via a dynamic import (mirrors\n * `with-party/directory/user-envelope/api.js#createUserApi`) and threads\n * it through `NoydbOptions.policyFactory` so `Noydb`'s constructor can\n * build `this.policyManager` synchronously.\n */\nexport const createNoydbPolicy: NoydbPolicyFactory = (deps) => new NoydbPolicy(deps)\n"],"mappings":";;;;;;;;;;AAcO,IAAM,kBAA+B,OAAO,OAAO;AAAA,EACxD,YAAY;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,IACf,wBAAwB;AAAA,EAC1B;AAAA,EACA,OAAO;AAAA,IACL,qBAAqB;AAAA,MACnB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOT,SAAS,CAAC;AAAA,QACR,OAAO;AAAA,UACL;AAAA,UAAQ;AAAA,UAAa;AAAA,UACrB;AAAA,UAAoB;AAAA,UACpB;AAAA,UAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,sBAAsB;AAAA,MACpB,SAAS;AAAA,MACT,SAAS;AA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A;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,OAAe,UAAsD;AACtF,QAAI,KAAK,KAAK,SAAS,EAAG,OAAM,IAAI,gBAAgB,oBAAoB;AACxE,UAAM,UAAU,MAAM,KAAK,UAAU,KAAK;AAC1C,UAAM,SAAS,YAAY,SAAS,QAAQ;AAC5C,QAAI,KAAK,KAAK,WAAW;AACvB,YAAM,gBAAgB,KAAK,KAAK,OAAO,OAAO,MAAM;AAAA,IACtD;AACA,SAAK,KAAK,YAAY,IAAI,OAAO,MAAM;AACvC,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,gBACJ,OACA,MACe;AACf,UAAM,SAAS,MAAM,gBAAgB,KAAK,KAAK,OAAO,KAAK;AAC3D,QAAI,QAAQ;AAGV,WAAK,KAAK,YAAY,IAAI,OAAO,MAAM;AACvC,YAAM,KAAK,KAAK,uBAAuB,OAAO,QAAQ,IAAI;AAC1D;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,KAAK,eACtB,YAAY,iBAAiB,KAAK,KAAK,YAAY,IACnD;AACJ,UAAM,gBAAgB,KAAK,KAAK,OAAO,OAAO,OAAO;AACrD,SAAK,KAAK,YAAY,IAAI,OAAO,OAAO;AACxC,UAAM,KAAK,KAAK,uBAAuB,OAAO,SAAS,IAAI;AAAA,EAC7D;AACF;AASO,IAAM,oBAAwC,CAAC,SAAS,IAAI,YAAY,IAAI;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/materialized-views/stale.ts
|
|
1
|
+
// src/with-formula/materialized-views/stale.ts
|
|
2
2
|
var _staleByRegistry = /* @__PURE__ */ new WeakMap();
|
|
3
3
|
function markMVStale(registry, mvName) {
|
|
4
4
|
let set = _staleByRegistry.get(registry);
|
|
@@ -11,7 +11,7 @@ function markMVStale(registry, mvName) {
|
|
|
11
11
|
function isMVStale(registry, mvName) {
|
|
12
12
|
return _staleByRegistry.get(registry)?.has(mvName) ?? false;
|
|
13
13
|
}
|
|
14
|
-
async function resolveStaleMVOnRead(accessor, outputCollection) {
|
|
14
|
+
async function resolveStaleMVOnRead(accessor, outputCollection, dispatchCtx) {
|
|
15
15
|
const registry = accessor.registry();
|
|
16
16
|
const pending = _staleByRegistry.get(registry);
|
|
17
17
|
if (!pending || pending.size === 0) return;
|
|
@@ -30,12 +30,13 @@ async function resolveStaleMVOnRead(accessor, outputCollection) {
|
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
if (executor === null) {
|
|
33
|
-
({ MaterializedViewExecutor: executor } = await import("./executor-
|
|
33
|
+
({ MaterializedViewExecutor: executor } = await import("./executor-KSHKRJXP.js"));
|
|
34
34
|
}
|
|
35
35
|
await executor.refresh(reg, {
|
|
36
36
|
getCollection: (n) => accessor.getCollection(n),
|
|
37
37
|
getActiveTxContext: () => accessor.getActiveTxContext(),
|
|
38
|
-
getQueryContext: () => accessor.getQueryContext()
|
|
38
|
+
getQueryContext: () => accessor.getQueryContext(),
|
|
39
|
+
...dispatchCtx !== void 0 ? { dispatchCtx } : {}
|
|
39
40
|
});
|
|
40
41
|
pending.delete(name);
|
|
41
42
|
}
|
|
@@ -50,4 +51,4 @@ export {
|
|
|
50
51
|
resolveStaleMVOnRead,
|
|
51
52
|
clearMVStale
|
|
52
53
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-2REPHKET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-formula/materialized-views/stale.ts"],"sourcesContent":["import type { Collection } from '../../kernel/collection.js'\nimport type { TxContext } from '../../with-commit/tx/transaction.js'\nimport type { PutDerivedOutputCtx } from '../../kernel/via/dispatch.js'\nimport type { MaterializedViewRegistry } from './registry.js'\n// Type-only — runtime class loaded via dynamic import in\n// `resolveStaleMVOnRead` only when a stale flag actually fires.\n// Keeps the executor chunk out of the floor bundle (mirrors v1 floor-bundle isolation).\nimport type { MaterializedViewExecutor as MVExecutorType } from './executor.js'\nimport type { MVQueryContext } from './types.js'\n\n/**\n * Accessor shape passed in from the owning Vault. Provides the\n * registry (used as a stable WeakMap key + to look up MVs by output\n * collection) and the runtime context the lazy refresh needs.\n * Mirrors v1's `DerivationStaleAccessor`.\n */\nexport interface MVStaleAccessor {\n registry(): MaterializedViewRegistry\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getCollection(name: string): Collection<any>\n getActiveTxContext(): TxContext | null\n getQueryContext(): MVQueryContext\n}\n\n/**\n * In-memory stale map keyed by `MaterializedViewRegistry` instance\n * (stable per vault). Each registry maps to a set of MV names that\n * have at least one pending source-change requiring a re-materialize.\n *\n * Persistence across vault close is NOT implemented in this iteration\n * (concern flagged in the v2 spec, mirrors v1 derivation behavior).\n * On vault re-open, the unset stale flag is interpreted as \"fresh\" —\n * `vault.refreshView(name)` is the explicit recompute escape hatch.\n *\n * @internal\n */\nconst _staleByRegistry = new WeakMap<MaterializedViewRegistry, Set<string>>()\n\n/**\n * Mark an MV as stale. Called from `Collection.dispatchMaterializedViews`\n * when a source-write fires for a `refresh: 'lazy'` MV.\n *\n * @internal\n */\nexport function markMVStale(registry: MaterializedViewRegistry, mvName: string): void {\n let set = _staleByRegistry.get(registry)\n if (!set) {\n set = new Set()\n _staleByRegistry.set(registry, set)\n }\n set.add(mvName)\n}\n\n/**\n * Test-only: check whether a given MV name is currently flagged stale\n * against a registry. Exported so the regression suite can pin the\n * stale-bit lifecycle without touching the internal `WeakMap`.\n *\n * @internal\n */\nexport function isMVStale(registry: MaterializedViewRegistry, mvName: string): boolean {\n return _staleByRegistry.get(registry)?.has(mvName) ?? false\n}\n\n/**\n * Called from `Collection.get` (and any reader that materializes the\n * MV's output collection). If any MV producing `outputCollection` is\n * flagged stale, runs the executor against the live source state\n * before returning. No-op when there is no pending work — keeps the\n * read fast path negligible.\n *\n * `dispatchCtx` (#641): threaded from the calling `Collection`'s\n * `#dispatchCtx({ collection: outputCollection, id: 'resolve-on-read' })` — a read has no\n * real \"reacting write\" record, so `'resolve-on-read'` is the sentinel id, mirroring\n * `Vault.refreshView()`'s `'refreshView'` sentinel for the same reason. Passed straight\n * through to the executor so a stale row whose output lands in a closed period follows the\n * frozen-output rule (skip + `derivation:skipped-frozen`, #637) instead of throwing\n * `PeriodClosedError` out of a read.\n *\n * Dynamic-imports the executor only when a stale flag actually fires\n * (the floor-bundle isolation pattern v1 derivations established in\n * floor-bundle isolation pattern).\n */\nexport async function resolveStaleMVOnRead(\n accessor: MVStaleAccessor,\n outputCollection: string,\n dispatchCtx?: PutDerivedOutputCtx,\n): Promise<void> {\n const registry = accessor.registry()\n const pending = _staleByRegistry.get(registry)\n if (!pending || pending.size === 0) return\n\n // Find every MV that writes to this output collection AND is\n // currently flagged stale. Multiple MVs CAN share an output\n // collection in theory; in practice the registration validation +\n // cycle detection make this unusual.\n const candidates: string[] = []\n for (const mv of registry.all()) {\n if (mv.outputCollection !== outputCollection) continue\n if (!pending.has(mv.spec.name)) continue\n candidates.push(mv.spec.name)\n }\n if (candidates.length === 0) return\n\n let executor: typeof MVExecutorType | null = null\n for (const name of candidates) {\n const reg = registry.byName(name)\n if (!reg) {\n pending.delete(name)\n continue\n }\n if (executor === null) {\n ({ MaterializedViewExecutor: executor } = (await import('./executor.js')) as {\n MaterializedViewExecutor: typeof MVExecutorType\n })\n }\n await executor.refresh(reg, {\n getCollection: (n) => accessor.getCollection(n),\n getActiveTxContext: () => accessor.getActiveTxContext(),\n getQueryContext: () => accessor.getQueryContext(),\n ...(dispatchCtx !== undefined ? { dispatchCtx } : {}),\n })\n pending.delete(name)\n }\n}\n\n/**\n * Drop every stale flag for a registry. Used after a manual\n * `vault.refreshView(name)` runs the executor explicitly — the\n * post-refresh state matches the registered strategies, so\n * lingering stale bits would force a redundant refresh on the next\n * read.\n *\n * @internal\n */\nexport function clearMVStale(registry: MaterializedViewRegistry, mvName: string): void {\n _staleByRegistry.get(registry)?.delete(mvName)\n}\n"],"mappings":";AAoCA,IAAM,mBAAmB,oBAAI,QAA+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rF,mBAAiB,IAAI,QAAQ,GAAG,OAAO,MAAM;AAC/C;","names":[]}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LEDGER_COLLECTION,
|
|
3
|
+
LEDGER_DELTAS_COLLECTION
|
|
4
|
+
} from "./chunk-I7FD46FF.js";
|
|
1
5
|
import {
|
|
2
6
|
canonicalJson,
|
|
3
7
|
hashEntry,
|
|
4
8
|
paddedIndex,
|
|
5
9
|
sha256Hex
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UF362QVH.js";
|
|
7
11
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
openEnvelopeJson
|
|
13
|
+
} from "./chunk-MCHVVJIA.js";
|
|
10
14
|
import {
|
|
11
|
-
decrypt,
|
|
12
15
|
encrypt
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3OPY6MK2.js";
|
|
17
|
+
import {
|
|
18
|
+
NOYDB_FORMAT_VERSION
|
|
19
|
+
} from "./chunk-YN5IAHN6.js";
|
|
14
20
|
import {
|
|
15
21
|
ConflictError,
|
|
16
22
|
LedgerContentionError
|
|
17
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-S7VFUQM2.js";
|
|
18
24
|
|
|
19
|
-
// src/history/ledger/patch.ts
|
|
25
|
+
// src/with-commit/history/ledger/patch.ts
|
|
20
26
|
function computePatch(prev, next) {
|
|
21
27
|
const ops = [];
|
|
22
28
|
diff(prev, next, "", ops);
|
|
@@ -221,11 +227,7 @@ function clone(value) {
|
|
|
221
227
|
return JSON.parse(JSON.stringify(value));
|
|
222
228
|
}
|
|
223
229
|
|
|
224
|
-
// src/history/ledger/
|
|
225
|
-
var LEDGER_COLLECTION = "_ledger";
|
|
226
|
-
var LEDGER_DELTAS_COLLECTION = "_ledger_deltas";
|
|
227
|
-
|
|
228
|
-
// src/history/ledger/store.ts
|
|
230
|
+
// src/with-commit/history/ledger/store.ts
|
|
229
231
|
var MAX_APPEND_ATTEMPTS = 8;
|
|
230
232
|
var LedgerStore = class {
|
|
231
233
|
adapter;
|
|
@@ -416,7 +418,7 @@ var LedgerStore = class {
|
|
|
416
418
|
return JSON.parse(envelope._data);
|
|
417
419
|
}
|
|
418
420
|
const dek = await this.getDEK(LEDGER_COLLECTION);
|
|
419
|
-
const json = await
|
|
421
|
+
const json = await openEnvelopeJson(envelope, dek);
|
|
420
422
|
return JSON.parse(json);
|
|
421
423
|
}
|
|
422
424
|
/** Encrypt a JSON Patch into an envelope for storage. Mirrors encryptEntry. */
|
|
@@ -666,7 +668,7 @@ var LedgerStore = class {
|
|
|
666
668
|
return JSON.parse(envelope._data);
|
|
667
669
|
}
|
|
668
670
|
const dek = await this.getDEK(LEDGER_COLLECTION);
|
|
669
|
-
const json = await
|
|
671
|
+
const json = await openEnvelopeJson(envelope, dek);
|
|
670
672
|
return JSON.parse(json);
|
|
671
673
|
}
|
|
672
674
|
};
|
|
@@ -679,8 +681,6 @@ function sleepBackoff(attempt) {
|
|
|
679
681
|
export {
|
|
680
682
|
computePatch,
|
|
681
683
|
applyPatch,
|
|
682
|
-
LEDGER_COLLECTION,
|
|
683
|
-
LEDGER_DELTAS_COLLECTION,
|
|
684
684
|
LedgerStore
|
|
685
685
|
};
|
|
686
|
-
//# sourceMappingURL=chunk-
|
|
686
|
+
//# sourceMappingURL=chunk-3JXPAHOZ.js.map
|