@sixb/core 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/delegated-admission.d.ts +24 -0
- package/dist/actions/delegated-admission.d.ts.map +1 -0
- package/dist/actions/descriptor.d.ts +29 -0
- package/dist/actions/descriptor.d.ts.map +1 -0
- package/dist/actions/execution.d.ts +5 -5
- package/dist/actions/execution.d.ts.map +1 -1
- package/dist/actions/index.js +78 -84
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run-authorization.d.ts +20 -0
- package/dist/actions/run-authorization.d.ts.map +1 -0
- package/dist/actions/run-dispatch.d.ts +3 -1
- package/dist/actions/run-dispatch.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +2 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/validation.d.ts +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/actions/worker.js +33 -37
- package/dist/actions/worker.js.map +2 -2
- package/dist/agents/adapters.d.ts +8 -125
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +1 -1
- package/dist/agents/authority.d.ts.map +1 -1
- package/dist/agents/{context.d.ts → context/entries.d.ts} +3 -3
- package/dist/agents/context/entries.d.ts.map +1 -0
- package/dist/agents/context/index.d.ts +4 -0
- package/dist/agents/context/index.d.ts.map +1 -0
- package/dist/agents/context/index.js +19 -0
- package/dist/agents/{streams.js.map → context/index.js.map} +1 -1
- package/dist/agents/context-model.d.ts +1 -1
- package/dist/agents/context-model.d.ts.map +1 -1
- package/dist/agents/context-resolution.d.ts +1 -1
- package/dist/agents/context-resolution.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +0 -9
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/identity.d.ts +3 -0
- package/dist/agents/identity.d.ts.map +1 -0
- package/dist/agents/index.d.ts +7 -7
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +193 -205
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +5 -6
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +4 -0
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/request.d.ts +1 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +4 -0
- package/dist/agents/streams/index.d.ts.map +1 -0
- package/dist/agents/streams/index.js +20 -0
- package/dist/{chunk-y64skrwp.js.map → agents/streams/index.js.map} +1 -1
- package/dist/agents/streams/internal.d.ts +3 -0
- package/dist/agents/streams/internal.d.ts.map +1 -0
- package/dist/agents/streams/internal.js +40 -0
- package/dist/agents/{context.js.map → streams/internal.js.map} +1 -1
- package/dist/agents/{streams.d.ts → streams/protocol.d.ts} +5 -5
- package/dist/agents/streams/protocol.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts +0 -1
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/types.d.ts +1 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +0 -4
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/ai-usage/execution.d.ts.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +96 -105
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/strategy.js +8 -9
- package/dist/auth/strategy.js.map +1 -1
- package/dist/authorization/decision.d.ts +10 -2
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +2 -1
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +51 -53
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/browser.js +15 -17
- package/dist/blob-storage/browser.js.map +1 -1
- package/dist/blob-storage/index.js +36 -38
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/bootstrap/discovery.d.ts +20 -1
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.d.ts +2 -2
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +79 -81
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
- package/dist/broker/index.js +8 -10
- package/dist/broker/index.js.map +1 -1
- package/dist/{chunk-k34z5rvh.js → chunk-0rdrecsb.js} +18 -18
- package/dist/{chunk-k34z5rvh.js.map → chunk-0rdrecsb.js.map} +2 -2
- package/dist/{chunk-3fqt22c4.js → chunk-0w35wavj.js} +360 -168
- package/dist/chunk-0w35wavj.js.map +14 -0
- package/dist/chunk-0y39rgsb.js +43 -0
- package/dist/{chunk-c15dr03f.js.map → chunk-0y39rgsb.js.map} +2 -2
- package/dist/{chunk-hdz94br2.js → chunk-17kfctj6.js} +23 -13
- package/dist/chunk-17kfctj6.js.map +10 -0
- package/dist/{chunk-e4rvtvpw.js → chunk-1enhpacz.js} +418 -233
- package/dist/chunk-1enhpacz.js.map +34 -0
- package/dist/{chunk-5gd7tpv6.js → chunk-2c4j899j.js} +4 -4
- package/dist/{chunk-5gd7tpv6.js.map → chunk-2c4j899j.js.map} +2 -2
- package/dist/{chunk-7ds9620f.js → chunk-38zv5rkr.js} +24 -8
- package/dist/chunk-38zv5rkr.js.map +10 -0
- package/dist/{chunk-w3e09qqk.js → chunk-39tqv9hz.js} +24 -24
- package/dist/{chunk-w3e09qqk.js.map → chunk-39tqv9hz.js.map} +2 -2
- package/dist/{chunk-04b07a9q.js → chunk-3bh94gbw.js} +13 -13
- package/dist/{chunk-04b07a9q.js.map → chunk-3bh94gbw.js.map} +2 -2
- package/dist/{chunk-8m5ejdpn.js → chunk-3f7veca0.js} +4 -4
- package/dist/{chunk-8m5ejdpn.js.map → chunk-3f7veca0.js.map} +2 -2
- package/dist/chunk-3frsnm7x.js +32 -0
- package/dist/chunk-3frsnm7x.js.map +11 -0
- package/dist/{chunk-n2w475r0.js → chunk-3tgwrcyh.js} +81 -81
- package/dist/{chunk-n2w475r0.js.map → chunk-3tgwrcyh.js.map} +2 -2
- package/dist/{chunk-qv38twt8.js → chunk-52hbv0ak.js} +192 -171
- package/dist/{chunk-qv38twt8.js.map → chunk-52hbv0ak.js.map} +6 -6
- package/dist/{chunk-nf4r78r4.js → chunk-5a4a52tq.js} +4 -4
- package/dist/{chunk-nf4r78r4.js.map → chunk-5a4a52tq.js.map} +2 -2
- package/dist/{chunk-rte5sm3z.js → chunk-5hz0fnca.js} +23 -23
- package/dist/{chunk-rte5sm3z.js.map → chunk-5hz0fnca.js.map} +2 -2
- package/dist/chunk-653vwrzr.js +39 -0
- package/dist/chunk-653vwrzr.js.map +10 -0
- package/dist/{chunk-qw9gvjv5.js → chunk-72w2pxk7.js} +13 -13
- package/dist/{chunk-qw9gvjv5.js.map → chunk-72w2pxk7.js.map} +2 -2
- package/dist/chunk-7apz6hg4.js +50 -0
- package/dist/{chunk-jq43kdvk.js.map → chunk-7apz6hg4.js.map} +2 -2
- package/dist/chunk-7bs40fe1.js +218 -0
- package/dist/{chunk-08twe8m6.js.map → chunk-7bs40fe1.js.map} +3 -3
- package/dist/chunk-7zgecwy1.js +113 -0
- package/dist/chunk-7zgecwy1.js.map +10 -0
- package/dist/{chunk-tn7xcs2n.js → chunk-860dwwy0.js} +93 -30
- package/dist/chunk-860dwwy0.js.map +14 -0
- package/dist/chunk-8vj0rjgs.js +165 -0
- package/dist/chunk-8vj0rjgs.js.map +15 -0
- package/dist/{chunk-7y0f6rf1.js → chunk-92vk7gta.js} +58 -58
- package/dist/chunk-92vk7gta.js.map +10 -0
- package/dist/{chunk-gbrpsx4m.js → chunk-93csa55g.js} +72 -16
- package/dist/chunk-93csa55g.js.map +11 -0
- package/dist/{chunk-d8qkxt2v.js → chunk-98cw09sw.js} +7 -7
- package/dist/chunk-98cw09sw.js.map +10 -0
- package/dist/chunk-9qsh3p5y.js +111 -0
- package/dist/chunk-9qsh3p5y.js.map +11 -0
- package/dist/{chunk-4a849fr1.js → chunk-9tc8dxmn.js} +1 -1
- package/dist/{chunk-z2sery1b.js → chunk-9vx5e9g1.js} +68 -28
- package/dist/chunk-9vx5e9g1.js.map +11 -0
- package/dist/{chunk-9aehf39w.js → chunk-an5tt9y0.js} +353 -353
- package/dist/{chunk-9aehf39w.js.map → chunk-an5tt9y0.js.map} +2 -2
- package/dist/{chunk-x0qhkqje.js → chunk-ap0g1g74.js} +37 -37
- package/dist/{chunk-x0qhkqje.js.map → chunk-ap0g1g74.js.map} +2 -2
- package/dist/chunk-awbhdqyc.js +252 -0
- package/dist/chunk-awbhdqyc.js.map +10 -0
- package/dist/{chunk-ka3a2ft3.js → chunk-b19g04jk.js} +12 -12
- package/dist/{chunk-ka3a2ft3.js.map → chunk-b19g04jk.js.map} +2 -2
- package/dist/chunk-br3k6qbf.js +436 -0
- package/dist/chunk-br3k6qbf.js.map +12 -0
- package/dist/{chunk-dbc80ad7.js → chunk-c5rkjrgp.js} +28 -28
- package/dist/{chunk-dbc80ad7.js.map → chunk-c5rkjrgp.js.map} +2 -2
- package/dist/{chunk-dktq02ne.js → chunk-cqr3acm1.js} +4 -4
- package/dist/{chunk-dktq02ne.js.map → chunk-cqr3acm1.js.map} +2 -2
- package/dist/chunk-d62kjtbg.js +7 -0
- package/dist/{chunk-zcnhxkvd.js.map → chunk-d62kjtbg.js.map} +2 -2
- package/dist/{chunk-74drx9gd.js → chunk-dfm066qg.js} +10 -10
- package/dist/{chunk-74drx9gd.js.map → chunk-dfm066qg.js.map} +2 -2
- package/dist/{chunk-atmkaf60.js → chunk-dmn70ztd.js} +30 -34
- package/dist/chunk-dmn70ztd.js.map +11 -0
- package/dist/chunk-dz5h08xv.js +1887 -0
- package/dist/chunk-dz5h08xv.js.map +25 -0
- package/dist/{chunk-p2vqaxkc.js → chunk-e0d1rzef.js} +27 -22
- package/dist/{chunk-p2vqaxkc.js.map → chunk-e0d1rzef.js.map} +3 -3
- package/dist/{chunk-5sz8ta9r.js → chunk-e1c18xjx.js} +52 -52
- package/dist/{chunk-5sz8ta9r.js.map → chunk-e1c18xjx.js.map} +2 -2
- package/dist/{chunk-ha58tjtt.js → chunk-emyyk7dx.js} +59 -55
- package/dist/{chunk-ha58tjtt.js.map → chunk-emyyk7dx.js.map} +3 -3
- package/dist/{chunk-3kv70xwp.js → chunk-ey1nk510.js} +18 -2
- package/dist/chunk-ey1nk510.js.map +10 -0
- package/dist/chunk-f0rwz2vh.js +152 -0
- package/dist/chunk-f0rwz2vh.js.map +11 -0
- package/dist/{chunk-2xns679x.js → chunk-f4w3yp4f.js} +171 -36
- package/dist/chunk-f4w3yp4f.js.map +12 -0
- package/dist/{chunk-979ww6b3.js → chunk-fb3feg1e.js} +29 -29
- package/dist/{chunk-979ww6b3.js.map → chunk-fb3feg1e.js.map} +2 -2
- package/dist/{chunk-rre42skh.js → chunk-g00bfdq6.js} +729 -296
- package/dist/{chunk-rre42skh.js.map → chunk-g00bfdq6.js.map} +11 -7
- package/dist/{chunk-p03r0h5s.js → chunk-g53f0e4j.js} +76 -202
- package/dist/chunk-g53f0e4j.js.map +15 -0
- package/dist/chunk-g6cke204.js +124 -0
- package/dist/chunk-g6cke204.js.map +10 -0
- package/dist/{chunk-51fjndv0.js → chunk-gfdh9kqa.js} +4 -4
- package/dist/{chunk-51fjndv0.js.map → chunk-gfdh9kqa.js.map} +2 -2
- package/dist/chunk-h1gfhhbh.js +602 -0
- package/dist/chunk-h1gfhhbh.js.map +18 -0
- package/dist/chunk-h3v76ams.js +32 -0
- package/dist/{chunk-08m3b6w8.js.map → chunk-h3v76ams.js.map} +2 -2
- package/dist/chunk-hpr1r6av.js +4006 -0
- package/dist/chunk-hpr1r6av.js.map +44 -0
- package/dist/{chunk-jecn6t54.js → chunk-jgwb25gc.js} +74 -74
- package/dist/{chunk-jecn6t54.js.map → chunk-jgwb25gc.js.map} +2 -2
- package/dist/{chunk-rp1mvzb4.js → chunk-jjy0fhrn.js} +40 -35
- package/dist/{chunk-rp1mvzb4.js.map → chunk-jjy0fhrn.js.map} +3 -3
- package/dist/{chunk-4nxeacx7.js → chunk-jmfet9r4.js} +6 -6
- package/dist/{chunk-4nxeacx7.js.map → chunk-jmfet9r4.js.map} +2 -2
- package/dist/{chunk-64sr682n.js → chunk-k3cqkkn2.js} +61 -55
- package/dist/chunk-k3cqkkn2.js.map +12 -0
- package/dist/{chunk-s5y30bc9.js → chunk-kxwa347f.js} +51 -49
- package/dist/{chunk-s5y30bc9.js.map → chunk-kxwa347f.js.map} +4 -4
- package/dist/{chunk-2ab72m2h.js → chunk-m2ca93my.js} +3 -3
- package/dist/{chunk-2ab72m2h.js.map → chunk-m2ca93my.js.map} +2 -2
- package/dist/{chunk-qjycjdj6.js → chunk-m3z3x9v0.js} +106 -65
- package/dist/{chunk-qjycjdj6.js.map → chunk-m3z3x9v0.js.map} +3 -3
- package/dist/{chunk-6ed5bwnd.js → chunk-mjbk2djy.js} +2092 -1714
- package/dist/chunk-mjbk2djy.js.map +57 -0
- package/dist/{chunk-5jcdmjam.js → chunk-mmagke4x.js} +6 -6
- package/dist/{chunk-5jcdmjam.js.map → chunk-mmagke4x.js.map} +2 -2
- package/dist/chunk-mrp7k0pw.js +147 -0
- package/dist/chunk-mrp7k0pw.js.map +10 -0
- package/dist/{chunk-d63tybny.js → chunk-ms2tmn1k.js} +139 -139
- package/dist/{chunk-d63tybny.js.map → chunk-ms2tmn1k.js.map} +2 -2
- package/dist/{chunk-xdpwpkha.js → chunk-ppytyr6w.js} +156 -179
- package/dist/{chunk-xdpwpkha.js.map → chunk-ppytyr6w.js.map} +3 -5
- package/dist/{chunk-trxxmgnf.js → chunk-pqajwytd.js} +10 -10
- package/dist/{chunk-trxxmgnf.js.map → chunk-pqajwytd.js.map} +3 -3
- package/dist/{chunk-qjzp9xyb.js → chunk-pr2h4bv4.js} +33 -35
- package/dist/chunk-pr2h4bv4.js.map +12 -0
- package/dist/{chunk-xwnf87e1.js → chunk-q5gz3g2j.js} +64 -64
- package/dist/{chunk-xwnf87e1.js.map → chunk-q5gz3g2j.js.map} +2 -2
- package/dist/{chunk-agsvg9ar.js → chunk-qf954wje.js} +6 -6
- package/dist/{chunk-agsvg9ar.js.map → chunk-qf954wje.js.map} +2 -2
- package/dist/{chunk-wjgm6jjt.js → chunk-qhcpj9wc.js} +166 -132
- package/dist/chunk-qhcpj9wc.js.map +14 -0
- package/dist/{chunk-tpnd31c1.js → chunk-r29fxdhn.js} +12 -12
- package/dist/{chunk-tpnd31c1.js.map → chunk-r29fxdhn.js.map} +2 -2
- package/dist/{chunk-b49dgvsj.js → chunk-r2y23egw.js} +3 -3
- package/dist/{chunk-b49dgvsj.js.map → chunk-r2y23egw.js.map} +2 -2
- package/dist/{chunk-2b5qtban.js → chunk-r4tfx1sf.js} +142 -89
- package/dist/chunk-r4tfx1sf.js.map +15 -0
- package/dist/{chunk-4rh2m6zg.js → chunk-rb1xx120.js} +13 -13
- package/dist/{chunk-4rh2m6zg.js.map → chunk-rb1xx120.js.map} +2 -2
- package/dist/chunk-s3csryxe.js +152 -0
- package/dist/chunk-s3csryxe.js.map +11 -0
- package/dist/chunk-s670k14v.js +60 -0
- package/dist/{chunk-407j3msh.js.map → chunk-s670k14v.js.map} +2 -2
- package/dist/chunk-skz0hst3.js +788 -0
- package/dist/chunk-skz0hst3.js.map +19 -0
- package/dist/chunk-v4jbb3rs.js +403 -0
- package/dist/chunk-v4jbb3rs.js.map +10 -0
- package/dist/{chunk-d2ndstdf.js → chunk-vf691g1r.js} +61 -59
- package/dist/{chunk-d2ndstdf.js.map → chunk-vf691g1r.js.map} +2 -2
- package/dist/{chunk-1kamz6j0.js → chunk-vsj3mdfj.js} +8 -8
- package/dist/{chunk-1kamz6j0.js.map → chunk-vsj3mdfj.js.map} +2 -2
- package/dist/{chunk-9dzba0f2.js → chunk-wjasrj67.js} +8 -8
- package/dist/{chunk-9dzba0f2.js.map → chunk-wjasrj67.js.map} +2 -2
- package/dist/{chunk-1evzqhks.js → chunk-wr8qp979.js} +6 -6
- package/dist/{chunk-1evzqhks.js.map → chunk-wr8qp979.js.map} +2 -2
- package/dist/{chunk-n6jxh8sw.js → chunk-wy0qdqfm.js} +18 -18
- package/dist/{chunk-n6jxh8sw.js.map → chunk-wy0qdqfm.js.map} +2 -2
- package/dist/{chunk-8tsf6dmc.js → chunk-x57ycxq0.js} +204 -204
- package/dist/{chunk-8tsf6dmc.js.map → chunk-x57ycxq0.js.map} +2 -2
- package/dist/chunk-x9v4cx1d.js +139 -0
- package/dist/chunk-x9v4cx1d.js.map +10 -0
- package/dist/{chunk-kt81c11h.js → chunk-xfbydgzy.js} +27 -27
- package/dist/{chunk-kt81c11h.js.map → chunk-xfbydgzy.js.map} +2 -2
- package/dist/{chunk-vjjv9mrb.js → chunk-xyr8kppc.js} +22 -22
- package/dist/{chunk-vjjv9mrb.js.map → chunk-xyr8kppc.js.map} +3 -3
- package/dist/chunk-ypbtykv6.js +1537 -0
- package/dist/chunk-ypbtykv6.js.map +19 -0
- package/dist/{chunk-ry24jbr1.js → chunk-yv79ncbv.js} +10 -10
- package/dist/{chunk-ry24jbr1.js.map → chunk-yv79ncbv.js.map} +2 -2
- package/dist/{chunk-xc7hq65b.js → chunk-z30bv4ga.js} +80 -33
- package/dist/chunk-z30bv4ga.js.map +11 -0
- package/dist/{chunk-8ydjhh27.js → chunk-z3y411fq.js} +11 -7
- package/dist/{chunk-8ydjhh27.js.map → chunk-z3y411fq.js.map} +3 -3
- package/dist/{chunk-9t8f5xfx.js → chunk-z5rnrmz1.js} +10 -10
- package/dist/{chunk-9t8f5xfx.js.map → chunk-z5rnrmz1.js.map} +2 -2
- package/dist/{chunk-96swp2wd.js → chunk-z667z3sg.js} +3 -3
- package/dist/{chunk-96swp2wd.js.map → chunk-z667z3sg.js.map} +2 -2
- package/dist/chunk-z8fx5cgb.js +159 -0
- package/dist/chunk-z8fx5cgb.js.map +11 -0
- package/dist/{chunk-xhy826cz.js → chunk-zcnq6105.js} +7 -7
- package/dist/{chunk-xhy826cz.js.map → chunk-zcnq6105.js.map} +2 -2
- package/dist/{chunk-yt8wphsx.js → chunk-zvx7h87b.js} +3 -3
- package/dist/{chunk-yt8wphsx.js.map → chunk-zvx7h87b.js.map} +2 -2
- package/dist/connectors/connections/internal.js +9 -10
- package/dist/connectors/connections/internal.js.map +1 -1
- package/dist/datasets/builders.d.ts +11 -2
- package/dist/datasets/builders.d.ts.map +1 -1
- package/dist/datasets/changes.d.ts +14 -4
- package/dist/datasets/changes.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +15 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/index.d.ts +1 -0
- package/dist/datasets/index.d.ts.map +1 -1
- package/dist/datasets/sequence.d.ts +7 -0
- package/dist/datasets/sequence.d.ts.map +1 -0
- package/dist/datasets/types.d.ts +1 -0
- package/dist/datasets/types.d.ts.map +1 -1
- package/dist/datasets/validation.d.ts.map +1 -1
- package/dist/datasets/write.d.ts +37 -0
- package/dist/datasets/write.d.ts.map +1 -0
- package/dist/datasets/write.js +13 -0
- package/dist/datasets/write.js.map +9 -0
- package/dist/edits/index.js +7 -8
- package/dist/edits/index.js.map +1 -1
- package/dist/error-reporting/internal.js +22 -24
- package/dist/error-reporting/internal.js.map +1 -1
- package/dist/errors/internal.d.ts +1 -1
- package/dist/errors/internal.d.ts.map +1 -1
- package/dist/errors/internal.js +22 -24
- package/dist/errors/internal.js.map +1 -1
- package/dist/errors/redaction.d.ts +8 -0
- package/dist/errors/redaction.d.ts.map +1 -0
- package/dist/errors/types.d.ts +4 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +60 -63
- package/dist/events/index.js.map +1 -1
- package/dist/events/scope.js +4 -5
- package/dist/events/scope.js.map +1 -1
- package/dist/events/selectors/index.js +9 -10
- package/dist/events/selectors/index.js.map +1 -1
- package/dist/events/types/datasets.d.ts +2 -6
- package/dist/events/types/datasets.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +3 -3
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +70 -75
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts +58 -20
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +69 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -0
- package/dist/execution/durable.d.ts +1 -0
- package/dist/execution/durable.d.ts.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/primitive.d.ts +2 -0
- package/dist/execution/primitive.d.ts.map +1 -1
- package/dist/execution/primitive.js +63 -64
- package/dist/execution/primitive.js.map +3 -3
- package/dist/execution/request.d.ts +12 -0
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +97 -71
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/scopes.d.ts +16 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/types.d.ts +9 -0
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts +2 -0
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +10 -11
- package/dist/http/index.js.map +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +455 -463
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/definition-updates.d.ts.map +1 -1
- package/dist/lake-storage/errors.d.ts +5 -1
- package/dist/lake-storage/errors.d.ts.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +1 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +6 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +40 -27
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/merge-validation.d.ts.map +1 -1
- package/dist/lake-storage/merge.d.ts +13 -2
- package/dist/lake-storage/merge.d.ts.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +19 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -0
- package/dist/lake-storage/sql-transforms.d.ts +2 -1
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +10 -5
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +4 -0
- package/dist/lake-storage/version-inputs.d.ts.map +1 -0
- package/dist/logging/index.d.ts +3 -4
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +18 -40
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/internal.d.ts +5 -0
- package/dist/logging/internal.d.ts.map +1 -0
- package/dist/logging/internal.js +43 -0
- package/dist/logging/internal.js.map +9 -0
- package/dist/materialization/index.js +46 -49
- package/dist/materialization/index.js.map +1 -1
- package/dist/materializer/index.js +137 -142
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/errors.d.ts +4 -0
- package/dist/models/errors.d.ts.map +1 -1
- package/dist/models/execution/binding.d.ts +9 -0
- package/dist/models/execution/binding.d.ts.map +1 -0
- package/dist/models/execution/errors.d.ts +9 -0
- package/dist/models/execution/errors.d.ts.map +1 -0
- package/dist/models/execution/index.d.ts +11 -0
- package/dist/models/execution/index.d.ts.map +1 -0
- package/dist/models/execution/index.js +55 -0
- package/dist/models/execution/index.js.map +9 -0
- package/dist/models/execution/model-call-accounting.d.ts +17 -0
- package/dist/models/execution/model-call-accounting.d.ts.map +1 -0
- package/dist/models/execution/model-call-admission.d.ts +47 -0
- package/dist/models/execution/model-call-admission.d.ts.map +1 -0
- package/dist/models/execution/model-call-limits.d.ts +15 -0
- package/dist/models/execution/model-call-limits.d.ts.map +1 -0
- package/dist/models/execution/model-call-recorder.d.ts +40 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -0
- package/dist/models/execution/model-call-recovery.d.ts +12 -0
- package/dist/models/execution/model-call-recovery.d.ts.map +1 -0
- package/dist/models/execution/recovery-queue.d.ts +5 -0
- package/dist/models/execution/recovery-queue.d.ts.map +1 -0
- package/dist/models/execution/types.d.ts +44 -0
- package/dist/models/execution/types.d.ts.map +1 -0
- package/dist/models/execution/usage.d.ts +5 -0
- package/dist/models/execution/usage.d.ts.map +1 -0
- package/dist/models/execution.d.ts +6 -0
- package/dist/models/execution.d.ts.map +1 -0
- package/dist/models/generation-types.d.ts +40 -0
- package/dist/models/generation-types.d.ts.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +42 -43
- package/dist/models/index.js.map +1 -1
- package/dist/models/language-model.d.ts +3 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/output.d.ts +5 -0
- package/dist/models/output.d.ts.map +1 -0
- package/dist/models/resolve.d.ts +4 -0
- package/dist/models/resolve.d.ts.map +1 -0
- package/dist/objects/authorized-ontology-view.d.ts +25 -0
- package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +1 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +75 -84
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/authorization.d.ts +2 -7
- package/dist/objects/link/authorization.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +4 -2
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.js +67 -73
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/links.d.ts +22 -1
- package/dist/objects/query/links.d.ts.map +1 -1
- package/dist/objects/query/selected-read-admission.d.ts +27 -0
- package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +60 -2
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
- package/dist/objects/service/list-service.d.ts +2 -3
- package/dist/objects/service/list-service.d.ts.map +1 -1
- package/dist/objects/telemetry/history.d.ts +8 -6
- package/dist/objects/telemetry/history.d.ts.map +1 -1
- package/dist/objects/telemetry/index.d.ts +2 -2
- package/dist/objects/telemetry/index.d.ts.map +1 -1
- package/dist/objects/telemetry/workload.d.ts +11 -0
- package/dist/objects/telemetry/workload.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +2 -2
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +61 -111
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/inference/index.d.ts +2 -1
- package/dist/ontology/inference/index.d.ts.map +1 -1
- package/dist/ontology/internal.d.ts +7 -1
- package/dist/ontology/internal.d.ts.map +1 -1
- package/dist/ontology/internal.js +65 -121
- package/dist/ontology/internal.js.map +3 -4
- package/dist/ontology/json-schema.d.ts +10 -6
- package/dist/ontology/json-schema.d.ts.map +1 -1
- package/dist/ontology/link-path-selection.d.ts +35 -0
- package/dist/ontology/link-path-selection.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +2 -0
- package/dist/ontology/refs.d.ts.map +1 -1
- package/dist/ontology/tokens.d.ts +2 -1
- package/dist/ontology/tokens.d.ts.map +1 -1
- package/dist/pipelines/execution.d.ts.map +1 -1
- package/dist/pipelines/index.js +57 -63
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/request.d.ts.map +1 -1
- package/dist/projections/execution.d.ts.map +1 -1
- package/dist/projections/internal.js +58 -64
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +11 -15
- package/dist/query.js.map +1 -1
- package/dist/queues/index.d.ts +2 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +6 -7
- package/dist/queues/index.js.map +1 -1
- package/dist/queues/types.d.ts +3 -20
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/rules/execution.d.ts.map +1 -1
- package/dist/rules/internal.js +4 -5
- package/dist/rules/internal.js.map +1 -1
- package/dist/runtime/create.d.ts +6 -2
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +2 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +4 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +13 -14
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +6 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +3 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/errors.d.ts +4 -0
- package/dist/sandboxes/errors.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +2 -2
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +14 -13
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +35 -7
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/scheduler/index.js +9 -10
- package/dist/scheduler/index.js.map +1 -1
- package/dist/schedules/execution.d.ts +2 -1
- package/dist/schedules/execution.d.ts.map +1 -1
- package/dist/schedules/index.js +31 -33
- package/dist/schedules/index.js.map +1 -1
- package/dist/security/every.d.ts +4 -1
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +7 -2
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +1 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +7 -1
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +2 -0
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/access-plan.d.ts +22 -0
- package/dist/shares/access-plan.d.ts.map +1 -0
- package/dist/shares/builders.d.ts +14 -0
- package/dist/shares/builders.d.ts.map +1 -0
- package/dist/shares/compiler.d.ts +14 -0
- package/dist/shares/compiler.d.ts.map +1 -0
- package/dist/shares/errors.d.ts +4 -0
- package/dist/shares/errors.d.ts.map +1 -0
- package/dist/shares/execution.d.ts +57 -0
- package/dist/shares/execution.d.ts.map +1 -0
- package/dist/shares/index.d.ts +10 -0
- package/dist/shares/index.d.ts.map +1 -0
- package/dist/shares/internal.d.ts +3 -0
- package/dist/shares/internal.d.ts.map +1 -0
- package/dist/shares/internal.js +231 -0
- package/dist/shares/internal.js.map +10 -0
- package/dist/shares/intersection.d.ts +9 -0
- package/dist/shares/intersection.d.ts.map +1 -0
- package/dist/shares/session-protocol.d.ts +41 -0
- package/dist/shares/session-protocol.d.ts.map +1 -0
- package/dist/shares/types.d.ts +51 -0
- package/dist/shares/types.d.ts.map +1 -0
- package/dist/shares/validation.d.ts +11 -0
- package/dist/shares/validation.d.ts.map +1 -0
- package/dist/storage/action-runs/failure.js +7 -9
- package/dist/storage/action-runs/failure.js.map +1 -1
- package/dist/storage/action-runs/provider.js +4 -8
- package/dist/storage/action-runs/provider.js.map +1 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +26 -30
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +0 -3
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/attribution.d.ts +4 -0
- package/dist/storage/ai-cost/attribution.d.ts.map +1 -0
- package/dist/storage/ai-cost/groups.d.ts +3 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +1 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +30 -143
- package/dist/storage/ai-cost/provider.js.map +3 -4
- package/dist/storage/ai-cost/types.d.ts +15 -0
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +14 -16
- package/dist/storage/ai-limits/enforcement.js.map +1 -1
- package/dist/storage/ai-limits/provider.js +56 -57
- package/dist/storage/ai-limits/provider.js.map +1 -1
- package/dist/storage/auth/in-memory.d.ts +1 -1
- package/dist/storage/auth/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +34 -36
- package/dist/storage/connector-connections/provider.js.map +2 -2
- package/dist/storage/executions/in-memory.d.ts +3 -0
- package/dist/storage/executions/in-memory.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +6 -2
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +35 -12
- package/dist/storage/executions/provider.js.map +3 -3
- package/dist/storage/executions/run-link.d.ts +7 -0
- package/dist/storage/executions/run-link.d.ts.map +1 -1
- package/dist/storage/executions/types.d.ts +6 -2
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts +8 -0
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +8 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +14 -9
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +221 -227
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +10 -0
- package/dist/storage/internal.d.ts.map +1 -0
- package/dist/storage/internal.js +47 -0
- package/dist/storage/internal.js.map +9 -0
- package/dist/storage/objects/execution-limits.d.ts +25 -0
- package/dist/storage/objects/execution-limits.d.ts.map +1 -0
- package/dist/storage/objects/guard.d.ts +16 -0
- package/dist/storage/objects/guard.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/index.d.ts +3 -0
- package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/keys.d.ts +10 -0
- package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/query.d.ts +31 -0
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
- package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
- package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
- package/dist/storage/objects/index.d.ts +4 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +1 -1
- package/dist/storage/objects/keys.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts +25 -0
- package/dist/storage/objects/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +114 -22
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +105 -109
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/operation-scope.d.ts +3 -0
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +18 -17
- package/dist/storage/operation-scope.js.map +1 -1
- package/dist/storage/pipeline-runs/provider.js +4 -6
- package/dist/storage/pipeline-runs/provider.js.map +1 -1
- package/dist/storage/projection-runs/provider.js +66 -70
- package/dist/storage/projection-runs/provider.js.map +1 -1
- package/dist/storage/share-grants/errors.d.ts +8 -0
- package/dist/storage/share-grants/errors.d.ts.map +1 -0
- package/dist/storage/share-grants/in-memory.d.ts +11 -0
- package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
- package/dist/storage/share-grants/index.d.ts +5 -0
- package/dist/storage/share-grants/index.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.d.ts +4 -0
- package/dist/storage/share-grants/provider.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +22 -0
- package/dist/storage/share-grants/provider.js.map +9 -0
- package/dist/storage/share-grants/record.d.ts +11 -0
- package/dist/storage/share-grants/record.d.ts.map +1 -0
- package/dist/storage/share-grants/types.d.ts +97 -0
- package/dist/storage/share-grants/types.d.ts.map +1 -0
- package/dist/storage/share-sessions/errors.d.ts +8 -0
- package/dist/storage/share-sessions/errors.d.ts.map +1 -0
- package/dist/storage/share-sessions/in-memory.d.ts +14 -0
- package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
- package/dist/storage/share-sessions/index.d.ts +5 -0
- package/dist/storage/share-sessions/index.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.d.ts +3 -0
- package/dist/storage/share-sessions/provider.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.js +19 -0
- package/dist/storage/share-sessions/provider.js.map +9 -0
- package/dist/storage/share-sessions/record.d.ts +8 -0
- package/dist/storage/share-sessions/record.d.ts.map +1 -0
- package/dist/storage/share-sessions/types.d.ts +50 -0
- package/dist/storage/share-sessions/types.d.ts.map +1 -0
- package/dist/storage/sync-runs/provider.js +4 -6
- package/dist/storage/sync-runs/provider.js.map +1 -1
- package/dist/storage/transaction.d.ts +2 -1
- package/dist/storage/transaction.d.ts.map +1 -1
- package/dist/storage/types.d.ts +8 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/webhook-runs/provider.js +4 -6
- package/dist/storage/webhook-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +13 -18
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +0 -3
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/execution.d.ts.map +1 -1
- package/dist/syncs/index.js +55 -62
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/testing/action-execution.d.ts +4 -1
- package/dist/testing/action-execution.d.ts.map +1 -1
- package/dist/testing/agent-execution.d.ts +1 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts +4 -0
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts +4 -0
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution.d.ts +1 -0
- package/dist/testing/execution.d.ts.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3087 -1328
- package/dist/testing/index.js.map +17 -13
- package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
- package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-read-scope-contract.d.ts +22 -0
- package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
- package/dist/testing/share-grant-storage-contract.d.ts +10 -0
- package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
- package/dist/testing/share-session-storage-contract.d.ts +9 -0
- package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
- package/dist/testing/workflow-execution.d.ts +1 -0
- package/dist/testing/workflow-execution.d.ts.map +1 -1
- package/dist/webhooks/internal.js +51 -56
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +11 -13
- package/dist/workers/index.js.map +2 -2
- package/dist/workflows/execution.d.ts.map +1 -1
- package/dist/workflows/failure.d.ts +2 -0
- package/dist/workflows/failure.d.ts.map +1 -1
- package/dist/workflows/index.js +135 -140
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +0 -1
- package/dist/workflows/run-dispatch.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +2 -0
- package/dist/workflows/types.d.ts.map +1 -1
- package/package.json +72 -30
- package/src/actions/delegated-admission.ts +72 -0
- package/src/actions/descriptor.ts +58 -0
- package/src/actions/execution.ts +99 -24
- package/src/actions/request.ts +136 -19
- package/src/actions/run-authorization.ts +53 -0
- package/src/actions/run-dispatch.ts +10 -7
- package/src/actions/types/context.ts +2 -0
- package/src/actions/validation.ts +2 -1
- package/src/agents/adapters.ts +34 -429
- package/src/agents/authority.ts +3 -4
- package/src/agents/{context.ts → context/entries.ts} +4 -4
- package/src/agents/context/index.ts +15 -0
- package/src/agents/context-model.ts +1 -1
- package/src/agents/context-resolution.ts +2 -5
- package/src/agents/errors.ts +0 -10
- package/src/agents/execution.ts +13 -5
- package/src/agents/identity.ts +4 -0
- package/src/agents/index.ts +5 -24
- package/src/agents/message.ts +5 -6
- package/src/agents/model-loop.ts +62 -6
- package/src/agents/request.ts +27 -29
- package/src/agents/streams/index.ts +18 -0
- package/src/agents/streams/internal.ts +19 -0
- package/src/agents/{streams.ts → streams/protocol.ts} +5 -5
- package/src/agents/tool-definition.ts +0 -19
- package/src/agents/types.ts +1 -1
- package/src/agents/validation.ts +9 -72
- package/src/ai-usage/execution.ts +4 -11
- package/src/auth/index.ts +0 -1
- package/src/authorization/decision.ts +29 -14
- package/src/authorization/grant-kinds.ts +10 -0
- package/src/authorization/index.ts +1 -0
- package/src/bootstrap/discovery.ts +84 -24
- package/src/bootstrap/index.ts +8 -1
- package/src/bootstrap/ontology-type-manifest.ts +12 -6
- package/src/datasets/builders.ts +23 -2
- package/src/datasets/changes.ts +16 -4
- package/src/datasets/execution.ts +76 -5
- package/src/datasets/index.ts +1 -0
- package/src/datasets/sequence.ts +77 -0
- package/src/datasets/types.ts +1 -0
- package/src/datasets/validation.ts +26 -0
- package/src/datasets/write.ts +240 -0
- package/src/errors/internal.ts +90 -10
- package/src/errors/redaction.ts +98 -0
- package/src/errors/types.ts +4 -0
- package/src/events/execution.ts +57 -7
- package/src/events/types/datasets.ts +2 -6
- package/src/execution/agent.ts +6 -7
- package/src/execution/authorization.ts +470 -90
- package/src/execution/authorized-object-reader.ts +695 -0
- package/src/execution/durable.ts +21 -3
- package/src/execution/index.ts +1 -0
- package/src/execution/primitive.ts +5 -1
- package/src/execution/request.ts +66 -13
- package/src/execution/scopes.ts +36 -6
- package/src/execution/types.ts +8 -0
- package/src/http/api-routes.ts +45 -0
- package/src/index.ts +56 -33
- package/src/lake-storage/definition-updates.ts +9 -0
- package/src/lake-storage/errors.ts +6 -1
- package/src/lake-storage/in-memory.ts +53 -17
- package/src/lake-storage/index.ts +10 -1
- package/src/lake-storage/merge-validation.ts +12 -2
- package/src/lake-storage/merge.ts +40 -2
- package/src/lake-storage/source-ordering.ts +95 -0
- package/src/lake-storage/sql-transforms.ts +2 -1
- package/src/lake-storage/types.ts +10 -5
- package/src/lake-storage/version-inputs.ts +14 -0
- package/src/logging/index.ts +2 -33
- package/src/logging/internal.ts +43 -0
- package/src/models/errors.ts +12 -0
- package/src/models/execution/binding.ts +29 -0
- package/src/models/execution/errors.ts +18 -0
- package/src/models/execution/index.ts +26 -0
- package/src/models/execution/model-call-accounting.ts +211 -0
- package/src/models/execution/model-call-admission.ts +127 -0
- package/src/models/execution/model-call-limits.ts +135 -0
- package/src/models/execution/model-call-recorder.ts +235 -0
- package/src/models/execution/model-call-recovery.ts +125 -0
- package/src/models/execution/recovery-queue.ts +31 -0
- package/src/models/execution/types.ts +58 -0
- package/src/models/execution/usage.ts +23 -0
- package/src/models/execution.ts +207 -0
- package/src/models/generation-types.ts +50 -0
- package/src/models/index.ts +8 -0
- package/src/models/language-model.ts +3 -0
- package/src/models/output.ts +45 -0
- package/src/models/resolve.ts +27 -0
- package/src/objects/authorized-ontology-view.ts +512 -0
- package/src/objects/execution.ts +99 -144
- package/src/objects/link/authorization.ts +3 -2
- package/src/objects/query/executor.ts +45 -34
- package/src/objects/query/links.ts +84 -25
- package/src/objects/query/selected-read-admission.ts +310 -0
- package/src/objects/query/validate.ts +353 -36
- package/src/objects/sdk/object-handle.ts +2 -8
- package/src/objects/sdk/object-set.ts +10 -11
- package/src/objects/sdk/runtime-query-executor.ts +8 -28
- package/src/objects/sdk/telemetry-channel.ts +11 -7
- package/src/objects/service/list-service.ts +15 -29
- package/src/objects/telemetry/history.ts +297 -17
- package/src/objects/telemetry/index.ts +2 -2
- package/src/objects/telemetry/workload.ts +79 -0
- package/src/ontology/index.ts +7 -2
- package/src/ontology/inference/index.ts +4 -1
- package/src/ontology/internal.ts +35 -1
- package/src/ontology/json-schema.ts +13 -12
- package/src/ontology/link-path-selection.ts +193 -0
- package/src/ontology/refs.ts +19 -0
- package/src/ontology/tokens.ts +15 -8
- package/src/pipelines/execution.ts +30 -7
- package/src/pipelines/request.ts +5 -0
- package/src/projections/execution.ts +72 -11
- package/src/projections/run-dispatch.ts +7 -12
- package/src/query.ts +0 -1
- package/src/queues/index.ts +4 -2
- package/src/queues/types.ts +6 -25
- package/src/rules/execution.ts +20 -8
- package/src/runtime/create.ts +7 -2
- package/src/runtime/definitions.ts +2 -0
- package/src/runtime/host.ts +27 -7
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +9 -0
- package/src/runtime/sixb.ts +27 -2
- package/src/runtime/types.ts +3 -0
- package/src/sandboxes/errors.ts +5 -0
- package/src/sandboxes/index.ts +3 -0
- package/src/sandboxes/sandbox.ts +35 -7
- package/src/schedules/execution.ts +24 -2
- package/src/security/every.ts +4 -0
- package/src/security/grants.ts +45 -3
- package/src/security/index.ts +1 -0
- package/src/security/registry.ts +3 -0
- package/src/security/types.ts +8 -0
- package/src/security/validation.ts +3 -0
- package/src/shares/access-plan.ts +225 -0
- package/src/shares/builders.ts +381 -0
- package/src/shares/compiler.ts +359 -0
- package/src/shares/errors.ts +3 -0
- package/src/shares/execution.ts +394 -0
- package/src/shares/index.ts +28 -0
- package/src/shares/internal.ts +9 -0
- package/src/shares/intersection.ts +178 -0
- package/src/shares/session-protocol.ts +258 -0
- package/src/shares/types.ts +76 -0
- package/src/shares/validation.ts +40 -0
- package/src/storage/agents/in-memory.ts +0 -3
- package/src/storage/agents/types.ts +0 -3
- package/src/storage/ai-cost/analytics.ts +1 -1
- package/src/storage/ai-cost/attribution.ts +15 -0
- package/src/storage/ai-cost/groups.ts +5 -1
- package/src/storage/ai-cost/provider.ts +1 -0
- package/src/storage/ai-cost/types.ts +7 -0
- package/src/storage/auth/in-memory.ts +1 -1
- package/src/storage/executions/in-memory.ts +13 -10
- package/src/storage/executions/provider.ts +34 -1
- package/src/storage/executions/run-link.ts +29 -0
- package/src/storage/executions/types.ts +6 -2
- package/src/storage/executions/validation.ts +78 -1
- package/src/storage/in-memory/index.ts +37 -3
- package/src/storage/index.ts +54 -29
- package/src/storage/internal.ts +20 -0
- package/src/storage/objects/execution-limits.ts +283 -0
- package/src/storage/objects/guard.ts +55 -0
- package/src/storage/objects/in-memory/index.ts +2 -0
- package/src/storage/objects/in-memory/keys.ts +46 -0
- package/src/storage/objects/in-memory/query.ts +754 -0
- package/src/storage/objects/in-memory/read-scope.ts +211 -0
- package/src/storage/objects/in-memory/read-source.ts +10 -0
- package/src/storage/objects/in-memory/selected-reader.ts +252 -0
- package/src/storage/objects/in-memory/storage.ts +589 -0
- package/src/storage/objects/index.ts +21 -0
- package/src/storage/objects/keys.ts +1 -1
- package/src/storage/objects/read-scope.ts +672 -0
- package/src/storage/objects/types.ts +123 -19
- package/src/storage/operation-scope.ts +16 -0
- package/src/storage/share-grants/errors.ts +14 -0
- package/src/storage/share-grants/in-memory.ts +107 -0
- package/src/storage/share-grants/index.ts +14 -0
- package/src/storage/share-grants/provider.ts +11 -0
- package/src/storage/share-grants/record.ts +347 -0
- package/src/storage/share-grants/types.ts +112 -0
- package/src/storage/share-sessions/errors.ts +14 -0
- package/src/storage/share-sessions/in-memory.ts +105 -0
- package/src/storage/share-sessions/index.ts +11 -0
- package/src/storage/share-sessions/provider.ts +9 -0
- package/src/storage/share-sessions/record.ts +176 -0
- package/src/storage/share-sessions/types.ts +57 -0
- package/src/storage/transaction.ts +14 -2
- package/src/storage/types.ts +27 -0
- package/src/storage/workflow-runs/in-memory.ts +0 -2
- package/src/storage/workflow-runs/types.ts +0 -3
- package/src/syncs/execution.ts +25 -5
- package/src/syncs/request.ts +5 -0
- package/src/testing/action-execution.ts +9 -2
- package/src/testing/agent-execution.ts +3 -0
- package/src/testing/agent-storage-contract.ts +0 -5
- package/src/testing/ai-model-call-groups-contract.ts +74 -2
- package/src/testing/dataset-sequence-contract.ts +373 -0
- package/src/testing/effective-storage-contract.ts +34 -0
- package/src/testing/execution-storage-contract.ts +138 -1
- package/src/testing/execution.ts +6 -0
- package/src/testing/index.ts +16 -0
- package/src/testing/lake-merge-storage-contract.ts +3 -0
- package/src/testing/lake-storage-contract.ts +58 -0
- package/src/testing/object-read-scope-contract.ts +939 -0
- package/src/testing/share-grant-storage-contract.ts +325 -0
- package/src/testing/share-session-storage-contract.ts +235 -0
- package/src/testing/workflow-execution.ts +4 -0
- package/src/workflows/execution.ts +53 -14
- package/src/workflows/failure.ts +62 -1
- package/src/workflows/request.ts +5 -9
- package/src/workflows/run-dispatch.ts +0 -3
- package/src/workflows/types.ts +2 -0
- package/src/workflows/validation.ts +1 -1
- package/dist/agents/context.d.ts.map +0 -1
- package/dist/agents/context.js +0 -23
- package/dist/agents/streams.d.ts.map +0 -1
- package/dist/agents/streams.js +0 -55
- package/dist/chunk-08m3b6w8.js +0 -32
- package/dist/chunk-08twe8m6.js +0 -218
- package/dist/chunk-2b5qtban.js.map +0 -14
- package/dist/chunk-2xns679x.js.map +0 -11
- package/dist/chunk-37wk412q.js +0 -1370
- package/dist/chunk-37wk412q.js.map +0 -23
- package/dist/chunk-3fqt22c4.js.map +0 -14
- package/dist/chunk-3kv70xwp.js.map +0 -10
- package/dist/chunk-407j3msh.js +0 -60
- package/dist/chunk-64sr682n.js.map +0 -12
- package/dist/chunk-6ed5bwnd.js.map +0 -57
- package/dist/chunk-7ds9620f.js.map +0 -10
- package/dist/chunk-7y0f6rf1.js.map +0 -10
- package/dist/chunk-atmkaf60.js.map +0 -11
- package/dist/chunk-c15dr03f.js +0 -43
- package/dist/chunk-d8qkxt2v.js.map +0 -10
- package/dist/chunk-dqn23610.js +0 -72
- package/dist/chunk-dqn23610.js.map +0 -11
- package/dist/chunk-e4rvtvpw.js.map +0 -34
- package/dist/chunk-gbrpsx4m.js.map +0 -11
- package/dist/chunk-h0knpbz5.js +0 -2486
- package/dist/chunk-h0knpbz5.js.map +0 -38
- package/dist/chunk-hdz94br2.js.map +0 -10
- package/dist/chunk-jq43kdvk.js +0 -50
- package/dist/chunk-n2arzn6e.js +0 -1745
- package/dist/chunk-n2arzn6e.js.map +0 -20
- package/dist/chunk-p03r0h5s.js.map +0 -16
- package/dist/chunk-qjzp9xyb.js.map +0 -12
- package/dist/chunk-tn7xcs2n.js.map +0 -13
- package/dist/chunk-wjgm6jjt.js.map +0 -13
- package/dist/chunk-xc7hq65b.js.map +0 -10
- package/dist/chunk-y35ma3mj.js +0 -551
- package/dist/chunk-y35ma3mj.js.map +0 -15
- package/dist/chunk-y64skrwp.js +0 -19
- package/dist/chunk-z2sery1b.js.map +0 -11
- package/dist/chunk-zcnhxkvd.js +0 -7
- package/dist/logging/types.js +0 -27
- package/dist/logging/types.js.map +0 -9
- package/dist/storage/objects/in-memory.d.ts.map +0 -1
- package/src/storage/objects/in-memory.ts +0 -1241
- /package/dist/{chunk-zqqz8052.js → chunk-7n30ybym.js} +0 -0
- /package/dist/{chunk-zqqz8052.js.map → chunk-7n30ybym.js.map} +0 -0
- /package/dist/{chunk-4a849fr1.js.map → chunk-9tc8dxmn.js.map} +0 -0
|
@@ -1,37 +1,48 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
GRANT_KINDS,
|
|
4
|
+
grantKindOf,
|
|
5
|
+
canAccessApplication2,
|
|
6
|
+
resolveRoleGrants2,
|
|
7
|
+
resolveAuthorizationContext2
|
|
8
|
+
} from "./chunk-dz5h08xv.js";
|
|
9
|
+
import {
|
|
10
|
+
normalizeSchemaValue2,
|
|
11
|
+
coerceSchemaValueToTyped2
|
|
12
|
+
} from "./chunk-ms2tmn1k.js";
|
|
13
|
+
import {
|
|
14
|
+
AuthRuntimeError2,
|
|
15
|
+
resolveAuthSessionAudience2,
|
|
9
16
|
resolveAuthCookieOptionsForAudience,
|
|
10
|
-
|
|
17
|
+
getCookie2,
|
|
18
|
+
resolveAuthConfig2,
|
|
11
19
|
resolveInvitationExpiresAt,
|
|
12
|
-
sanitizeReturnTo
|
|
13
|
-
|
|
20
|
+
sanitizeReturnTo,
|
|
21
|
+
assertNonEmpty3,
|
|
22
|
+
normalizePagination,
|
|
23
|
+
isInvitationDeliveryAuthStrategy2
|
|
24
|
+
} from "./chunk-q5gz3g2j.js";
|
|
14
25
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "./chunk-
|
|
26
|
+
validateSchemaOrRefValue2,
|
|
27
|
+
snapshotLinkPathSelection
|
|
28
|
+
} from "./chunk-f0rwz2vh.js";
|
|
29
|
+
import {
|
|
30
|
+
OntologyValidationError2
|
|
31
|
+
} from "./chunk-cqr3acm1.js";
|
|
21
32
|
|
|
22
33
|
// src/auth/access-tokens.ts
|
|
23
34
|
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
24
|
-
var
|
|
25
|
-
var
|
|
35
|
+
var PERSONAL_ACCESS_TOKEN_PREFIX2 = "sixb_pat";
|
|
36
|
+
var SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX2 = "sixb_sat";
|
|
26
37
|
var ACCESS_TOKEN_ID_PATTERN = /^tok_[A-Za-z0-9_-]+$/;
|
|
27
38
|
var ACCESS_TOKEN_SECRET_PATTERN = /^[A-Za-z0-9_-]{32,}$/;
|
|
28
|
-
function
|
|
39
|
+
function generateAccessTokenSecret2() {
|
|
29
40
|
return randomBytes(32).toString("base64url");
|
|
30
41
|
}
|
|
31
|
-
function
|
|
42
|
+
function hashAccessTokenSecret2(secret) {
|
|
32
43
|
return createHash("sha256").update(secret).digest("hex");
|
|
33
44
|
}
|
|
34
|
-
function
|
|
45
|
+
function formatAccessTokenValue2(kind, tokenId, tokenSecret) {
|
|
35
46
|
const prefix = accessTokenPrefixForKind(kind);
|
|
36
47
|
if (!ACCESS_TOKEN_ID_PATTERN.test(tokenId)) {
|
|
37
48
|
throw new Error("[Sixb] Access token ids must start with 'tok_' and be URL-safe.");
|
|
@@ -41,7 +52,7 @@ function formatAccessTokenValue(kind, tokenId, tokenSecret) {
|
|
|
41
52
|
}
|
|
42
53
|
return `${prefix}_${tokenId}.${tokenSecret}`;
|
|
43
54
|
}
|
|
44
|
-
function
|
|
55
|
+
function parseAccessTokenValue2(value) {
|
|
45
56
|
if (!value) {
|
|
46
57
|
return null;
|
|
47
58
|
}
|
|
@@ -61,7 +72,7 @@ function parseAccessTokenValue(value) {
|
|
|
61
72
|
}
|
|
62
73
|
return { kind, tokenId, tokenSecret };
|
|
63
74
|
}
|
|
64
|
-
function
|
|
75
|
+
function getBearerAccessTokenValue2(request) {
|
|
65
76
|
const header = request.headers.get("authorization");
|
|
66
77
|
if (!header) {
|
|
67
78
|
return null;
|
|
@@ -72,49 +83,49 @@ function getBearerAccessTokenValue(request) {
|
|
|
72
83
|
}
|
|
73
84
|
return token;
|
|
74
85
|
}
|
|
75
|
-
function
|
|
76
|
-
const tokenSecret =
|
|
86
|
+
function createAccessTokenCredential2(kind, tokenId = `tok_${randomUUID()}`) {
|
|
87
|
+
const tokenSecret = generateAccessTokenSecret2();
|
|
77
88
|
return {
|
|
78
89
|
kind,
|
|
79
90
|
tokenId,
|
|
80
91
|
tokenSecret,
|
|
81
|
-
tokenHash:
|
|
82
|
-
tokenValue:
|
|
92
|
+
tokenHash: hashAccessTokenSecret2(tokenSecret),
|
|
93
|
+
tokenValue: formatAccessTokenValue2(kind, tokenId, tokenSecret)
|
|
83
94
|
};
|
|
84
95
|
}
|
|
85
96
|
function accessTokenPrefixForKind(kind) {
|
|
86
97
|
switch (kind) {
|
|
87
98
|
case "personal":
|
|
88
|
-
return
|
|
99
|
+
return PERSONAL_ACCESS_TOKEN_PREFIX2;
|
|
89
100
|
case "serviceAccount":
|
|
90
|
-
return
|
|
101
|
+
return SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX2;
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
104
|
function accessTokenKindFromLabel(label) {
|
|
94
|
-
if (label.startsWith(`${
|
|
105
|
+
if (label.startsWith(`${PERSONAL_ACCESS_TOKEN_PREFIX2}_`)) {
|
|
95
106
|
return "personal";
|
|
96
107
|
}
|
|
97
|
-
if (label.startsWith(`${
|
|
108
|
+
if (label.startsWith(`${SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX2}_`)) {
|
|
98
109
|
return "serviceAccount";
|
|
99
110
|
}
|
|
100
111
|
return null;
|
|
101
112
|
}
|
|
102
113
|
// src/auth/csrf.ts
|
|
103
114
|
import { randomBytes as randomBytes2, timingSafeEqual } from "crypto";
|
|
104
|
-
var
|
|
105
|
-
function
|
|
115
|
+
var CSRF_HEADER_NAME2 = "x-sixb-csrf";
|
|
116
|
+
function generateCsrfToken2() {
|
|
106
117
|
return randomBytes2(32).toString("base64url");
|
|
107
118
|
}
|
|
108
|
-
function
|
|
119
|
+
function isCsrfExemptMethod2(method) {
|
|
109
120
|
const normalized = method.toUpperCase();
|
|
110
121
|
return normalized === "GET" || normalized === "HEAD" || normalized === "OPTIONS";
|
|
111
122
|
}
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
123
|
+
function verifyDoubleSubmitCsrf2(request, options) {
|
|
124
|
+
if (isCsrfExemptMethod2(request.method)) {
|
|
114
125
|
return true;
|
|
115
126
|
}
|
|
116
|
-
const cookieValue =
|
|
117
|
-
const headerValue = request.headers.get(options.headerName ??
|
|
127
|
+
const cookieValue = getCookie2(request, options.cookieName);
|
|
128
|
+
const headerValue = request.headers.get(options.headerName ?? CSRF_HEADER_NAME2);
|
|
118
129
|
if (!cookieValue || !headerValue) {
|
|
119
130
|
return false;
|
|
120
131
|
}
|
|
@@ -132,13 +143,13 @@ function safeEqual(left, right) {
|
|
|
132
143
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
133
144
|
|
|
134
145
|
// src/security/applications.ts
|
|
135
|
-
var
|
|
146
|
+
var applications2 = {
|
|
136
147
|
atlas: { kind: "application", id: "atlas", label: "Atlas" },
|
|
137
148
|
app: { kind: "application", id: "app", label: "Custom app" }
|
|
138
149
|
};
|
|
139
|
-
var APPLICATION_IDS = new Set(Object.values(
|
|
150
|
+
var APPLICATION_IDS = new Set(Object.values(applications2).map((application) => application.id));
|
|
140
151
|
// src/security/errors.ts
|
|
141
|
-
class
|
|
152
|
+
class SecurityValidationError2 extends Error {
|
|
142
153
|
name = "SecurityValidationError";
|
|
143
154
|
}
|
|
144
155
|
|
|
@@ -210,6 +221,7 @@ var GRANT_CAPABILITIES = Object.keys({
|
|
|
210
221
|
edit: true,
|
|
211
222
|
append: true,
|
|
212
223
|
apply: true,
|
|
224
|
+
share: true,
|
|
213
225
|
run: true,
|
|
214
226
|
observe: true,
|
|
215
227
|
manage: true
|
|
@@ -222,12 +234,12 @@ function formatAlternatives(values) {
|
|
|
222
234
|
function isRecord(value) {
|
|
223
235
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
224
236
|
}
|
|
225
|
-
function assertNonEmptyString(value, field, createError = (message) => new
|
|
237
|
+
function assertNonEmptyString(value, field, createError = (message) => new SecurityValidationError2(message)) {
|
|
226
238
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
227
239
|
throw createError(`[Sixb] ${field} must not be empty.`);
|
|
228
240
|
}
|
|
229
241
|
}
|
|
230
|
-
function assertOptionalString(value, field, createError = (message) => new
|
|
242
|
+
function assertOptionalString(value, field, createError = (message) => new SecurityValidationError2(message)) {
|
|
231
243
|
if (value === undefined) {
|
|
232
244
|
return;
|
|
233
245
|
}
|
|
@@ -257,7 +269,7 @@ function assertNoDuplicateIds(ids, field) {
|
|
|
257
269
|
const seen = new Set;
|
|
258
270
|
for (const id of ids) {
|
|
259
271
|
if (seen.has(id)) {
|
|
260
|
-
throw new
|
|
272
|
+
throw new SecurityValidationError2(`[Sixb] ${field} contains duplicate group id '${id}'.`);
|
|
261
273
|
}
|
|
262
274
|
seen.add(id);
|
|
263
275
|
}
|
|
@@ -266,12 +278,12 @@ function assertNoDuplicateOperations(operations, field) {
|
|
|
266
278
|
const seen = new Set;
|
|
267
279
|
for (const operation of operations) {
|
|
268
280
|
if (seen.has(operation)) {
|
|
269
|
-
throw new
|
|
281
|
+
throw new SecurityValidationError2(`[Sixb] ${field} contains duplicate operation '${operation}'.`);
|
|
270
282
|
}
|
|
271
283
|
seen.add(operation);
|
|
272
284
|
}
|
|
273
285
|
}
|
|
274
|
-
function assertGroupDefinition(value, createError = (message) => new
|
|
286
|
+
function assertGroupDefinition(value, createError = (message) => new SecurityValidationError2(message)) {
|
|
275
287
|
if (!isRecord(value)) {
|
|
276
288
|
throw createError("[Sixb] Group definition must be an object.");
|
|
277
289
|
}
|
|
@@ -290,7 +302,7 @@ function isGroupDefinition(value) {
|
|
|
290
302
|
return false;
|
|
291
303
|
}
|
|
292
304
|
}
|
|
293
|
-
function assertMembershipPolicyDefinition(value, createError = (message) => new
|
|
305
|
+
function assertMembershipPolicyDefinition(value, createError = (message) => new SecurityValidationError2(message)) {
|
|
294
306
|
if (!isRecord(value)) {
|
|
295
307
|
throw createError("[Sixb] Membership policy definition must be an object.");
|
|
296
308
|
}
|
|
@@ -310,7 +322,7 @@ function isMembershipPolicyDefinition(value) {
|
|
|
310
322
|
return false;
|
|
311
323
|
}
|
|
312
324
|
}
|
|
313
|
-
function assertGrantDefinition(value, field, createError = (message) => new
|
|
325
|
+
function assertGrantDefinition(value, field, createError = (message) => new SecurityValidationError2(message)) {
|
|
314
326
|
if (!isRecord(value) || value.kind !== "grant") {
|
|
315
327
|
throw createError(`[Sixb] ${field} must contain only grant definitions from 'can'.`);
|
|
316
328
|
}
|
|
@@ -352,7 +364,7 @@ function assertSelection(value, field, createError) {
|
|
|
352
364
|
assertNonEmptyString(id, `${field} grant selection id`, createError);
|
|
353
365
|
}
|
|
354
366
|
}
|
|
355
|
-
function assertRoleDefinition(value, createError = (message) => new
|
|
367
|
+
function assertRoleDefinition(value, createError = (message) => new SecurityValidationError2(message)) {
|
|
356
368
|
if (!isRecord(value)) {
|
|
357
369
|
throw createError("[Sixb] Role definition must be an object.");
|
|
358
370
|
}
|
|
@@ -385,25 +397,25 @@ function validateSecurityDefinitionsAtStartup(input) {
|
|
|
385
397
|
for (const group of input.groups) {
|
|
386
398
|
assertGroupDefinition(group);
|
|
387
399
|
if (groupsById.has(group.id)) {
|
|
388
|
-
throw new
|
|
400
|
+
throw new SecurityValidationError2(`[Sixb] Duplicate group id: ${group.id}`);
|
|
389
401
|
}
|
|
390
402
|
groupsById.set(group.id, group);
|
|
391
403
|
}
|
|
392
404
|
for (const role of input.roles ?? []) {
|
|
393
405
|
assertRoleDefinition(role);
|
|
394
406
|
if (rolesById.has(role.id)) {
|
|
395
|
-
throw new
|
|
407
|
+
throw new SecurityValidationError2(`[Sixb] Duplicate role id: ${role.id}`);
|
|
396
408
|
}
|
|
397
409
|
if (role.grantedToGroupIds.length === 0) {
|
|
398
|
-
throw new
|
|
410
|
+
throw new SecurityValidationError2(`[Sixb] Role '${role.id}' must be granted to at least one group.`);
|
|
399
411
|
}
|
|
400
412
|
if (role.grants.length === 0) {
|
|
401
|
-
throw new
|
|
413
|
+
throw new SecurityValidationError2(`[Sixb] Role '${role.id}' must declare at least one grant.`);
|
|
402
414
|
}
|
|
403
415
|
assertNoDuplicateIds(role.grantedToGroupIds, `Role '${role.id}' grantedTo`);
|
|
404
416
|
for (const groupId of role.grantedToGroupIds) {
|
|
405
417
|
if (!groupsById.has(groupId)) {
|
|
406
|
-
throw new
|
|
418
|
+
throw new SecurityValidationError2(`[Sixb] Role '${role.id}' grantedTo references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
407
419
|
}
|
|
408
420
|
}
|
|
409
421
|
for (const grant of role.grants) {
|
|
@@ -414,25 +426,25 @@ function validateSecurityDefinitionsAtStartup(input) {
|
|
|
414
426
|
for (const policy of input.membershipPolicies) {
|
|
415
427
|
assertMembershipPolicyDefinition(policy);
|
|
416
428
|
if (membershipPoliciesById.has(policy.id)) {
|
|
417
|
-
throw new
|
|
429
|
+
throw new SecurityValidationError2(`[Sixb] Duplicate membership policy id: ${policy.id}`);
|
|
418
430
|
}
|
|
419
431
|
if (policy.grantedToGroupIds.length === 0) {
|
|
420
|
-
throw new
|
|
432
|
+
throw new SecurityValidationError2(`[Sixb] Membership policy '${policy.id}' must grant membership authority to at least one group.`);
|
|
421
433
|
}
|
|
422
434
|
if (policy.can.length === 0) {
|
|
423
|
-
throw new
|
|
435
|
+
throw new SecurityValidationError2(`[Sixb] Membership policy '${policy.id}' must declare at least one operation.`);
|
|
424
436
|
}
|
|
425
437
|
assertNoDuplicateIds(policy.grantedToGroupIds, `Membership policy '${policy.id}' grantedTo`);
|
|
426
438
|
assertNoDuplicateIds(policy.scopeGroupIds, `Membership policy '${policy.id}' scope`);
|
|
427
439
|
assertNoDuplicateOperations(policy.can, `Membership policy '${policy.id}' can`);
|
|
428
440
|
for (const groupId of policy.grantedToGroupIds) {
|
|
429
441
|
if (!groupsById.has(groupId)) {
|
|
430
|
-
throw new
|
|
442
|
+
throw new SecurityValidationError2(`[Sixb] Membership policy '${policy.id}' grantedTo references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
431
443
|
}
|
|
432
444
|
}
|
|
433
445
|
for (const groupId of policy.scopeGroupIds) {
|
|
434
446
|
if (!groupsById.has(groupId)) {
|
|
435
|
-
throw new
|
|
447
|
+
throw new SecurityValidationError2(`[Sixb] Membership policy '${policy.id}' scope references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
436
448
|
}
|
|
437
449
|
}
|
|
438
450
|
membershipPoliciesById.set(policy.id, policy);
|
|
@@ -448,9 +460,9 @@ function validateSecurityDefinitionsAtStartup(input) {
|
|
|
448
460
|
}
|
|
449
461
|
function assertGrantReferences(roleId, grant, registered) {
|
|
450
462
|
if (grant.capability === "run" && grant.target === "agent") {
|
|
451
|
-
const
|
|
463
|
+
const spec = GRANT_KINDS[grantKindOf(grant)];
|
|
452
464
|
if (!registered.agentAvailable) {
|
|
453
|
-
throw new
|
|
465
|
+
throw new SecurityValidationError2(`[Sixb] Role '${roleId}' grants ${grant.capability} on the project Agent, but it is unavailable. ${spec.fix}`);
|
|
454
466
|
}
|
|
455
467
|
return;
|
|
456
468
|
}
|
|
@@ -462,7 +474,7 @@ function assertGrantReferences(roleId, grant, registered) {
|
|
|
462
474
|
const ids = grant.selection.all ? grant.selection.except : grant.selection.ids;
|
|
463
475
|
for (const id of ids) {
|
|
464
476
|
if (!universe.has(id)) {
|
|
465
|
-
throw new
|
|
477
|
+
throw new SecurityValidationError2(`[Sixb] Role '${roleId}' grants ${grant.capability} on unknown ${spec.subject} '${id}'. ${spec.fix}`);
|
|
466
478
|
}
|
|
467
479
|
}
|
|
468
480
|
}
|
|
@@ -471,13 +483,13 @@ function assertGrantReferences(roleId, grant, registered) {
|
|
|
471
483
|
var MEMBERSHIP_OPERATIONS2 = new Set(["invite", "assignGroups", "suspend"]);
|
|
472
484
|
function assertNonEmptyArray(value, field) {
|
|
473
485
|
if (value.length === 0) {
|
|
474
|
-
throw new
|
|
486
|
+
throw new SecurityValidationError2(`[Sixb] ${field} must not be empty.`);
|
|
475
487
|
}
|
|
476
488
|
}
|
|
477
489
|
function groupIdsFrom(groups, field) {
|
|
478
490
|
return groups.map((group) => {
|
|
479
491
|
if (!isRecord(group) || group.kind !== "group") {
|
|
480
|
-
throw new
|
|
492
|
+
throw new SecurityValidationError2(`[Sixb] ${field} must contain only group definitions.`);
|
|
481
493
|
}
|
|
482
494
|
assertNonEmptyString(group.id, `${field} group id`);
|
|
483
495
|
return group.id;
|
|
@@ -486,12 +498,12 @@ function groupIdsFrom(groups, field) {
|
|
|
486
498
|
function membershipOperationsFrom(operations, field) {
|
|
487
499
|
return operations.map((operation) => {
|
|
488
500
|
if (!MEMBERSHIP_OPERATIONS2.has(operation)) {
|
|
489
|
-
throw new
|
|
501
|
+
throw new SecurityValidationError2(`[Sixb] ${field} must contain only membership operations: invite, assignGroups, suspend.`);
|
|
490
502
|
}
|
|
491
503
|
return operation;
|
|
492
504
|
});
|
|
493
505
|
}
|
|
494
|
-
function
|
|
506
|
+
function defineGroup2(id, options = {}) {
|
|
495
507
|
assertNonEmptyString(id, "Group id");
|
|
496
508
|
assertOptionalString(options.label, `Group '${id}' label`);
|
|
497
509
|
assertOptionalString(options.description, `Group '${id}' description`);
|
|
@@ -502,7 +514,7 @@ function defineGroup(id, options = {}) {
|
|
|
502
514
|
...options.description !== undefined ? { description: options.description } : {}
|
|
503
515
|
};
|
|
504
516
|
}
|
|
505
|
-
function
|
|
517
|
+
function defineRole2(id, options) {
|
|
506
518
|
assertNonEmptyString(id, "Role id");
|
|
507
519
|
assertOptionalString(options.label, `Role '${id}' label`);
|
|
508
520
|
assertOptionalString(options.description, `Role '${id}' description`);
|
|
@@ -512,7 +524,7 @@ function defineRole(id, options) {
|
|
|
512
524
|
assertGrantDefinition(grant, `Role '${id}' grants`);
|
|
513
525
|
}
|
|
514
526
|
if (options.grants.length === 0) {
|
|
515
|
-
throw new
|
|
527
|
+
throw new SecurityValidationError2(`[Sixb] Role '${id}' grants must not be empty.`);
|
|
516
528
|
}
|
|
517
529
|
return {
|
|
518
530
|
kind: "role",
|
|
@@ -523,7 +535,7 @@ function defineRole(id, options) {
|
|
|
523
535
|
grants: options.grants
|
|
524
536
|
};
|
|
525
537
|
}
|
|
526
|
-
function
|
|
538
|
+
function defineMembershipPolicy2(id, options) {
|
|
527
539
|
assertNonEmptyString(id, "Membership policy id");
|
|
528
540
|
assertNonEmptyArray(options.grantedTo, `Membership policy '${id}' grantedTo`);
|
|
529
541
|
assertNonEmptyArray(options.can, `Membership policy '${id}' can`);
|
|
@@ -544,7 +556,8 @@ var BREADTH_TARGETS = [
|
|
|
544
556
|
"sync",
|
|
545
557
|
"pipeline",
|
|
546
558
|
"application",
|
|
547
|
-
"connector"
|
|
559
|
+
"connector",
|
|
560
|
+
"share"
|
|
548
561
|
];
|
|
549
562
|
function isBreadthSelector(value) {
|
|
550
563
|
if (typeof value !== "object" || value === null)
|
|
@@ -554,7 +567,7 @@ function isBreadthSelector(value) {
|
|
|
554
567
|
}
|
|
555
568
|
function definitionIdOf(item, label) {
|
|
556
569
|
if (typeof item?.id !== "string" || !item.id.trim()) {
|
|
557
|
-
throw new
|
|
570
|
+
throw new SecurityValidationError2(`[Sixb] ${label} requires definitions with a non-empty id.`);
|
|
558
571
|
}
|
|
559
572
|
return item.id;
|
|
560
573
|
}
|
|
@@ -570,7 +583,7 @@ function all(target, except = []) {
|
|
|
570
583
|
}
|
|
571
584
|
};
|
|
572
585
|
}
|
|
573
|
-
var
|
|
586
|
+
var every2 = {
|
|
574
587
|
object: () => all("object"),
|
|
575
588
|
dataset: () => all("dataset"),
|
|
576
589
|
action: () => all("action"),
|
|
@@ -578,8 +591,405 @@ var every = {
|
|
|
578
591
|
sync: () => all("sync"),
|
|
579
592
|
pipeline: () => all("pipeline"),
|
|
580
593
|
application: () => all("application"),
|
|
581
|
-
connector: () => all("connector")
|
|
594
|
+
connector: () => all("connector"),
|
|
595
|
+
share: () => all("share")
|
|
582
596
|
};
|
|
597
|
+
// src/actions/errors.ts
|
|
598
|
+
class ActionDefinitionError2 extends Error {
|
|
599
|
+
name = "ActionDefinitionError";
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
class ActionEditCommitError2 extends Error {
|
|
603
|
+
name = "ActionEditCommitError";
|
|
604
|
+
}
|
|
605
|
+
function missingActionMutationMessage(actionId) {
|
|
606
|
+
return `Action "${actionId}" must declare .writeback(...) or .edits(...).`;
|
|
607
|
+
}
|
|
608
|
+
function effectsWithoutEditsMessage(actionId) {
|
|
609
|
+
return `Action "${actionId}" cannot declare .effects(...) without .edits(...).`;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// src/actions/validation.ts
|
|
613
|
+
function assertNonEmpty2(value, field) {
|
|
614
|
+
if (!value.trim()) {
|
|
615
|
+
throw new ActionDefinitionError2(`Action ${field} must not be empty.`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function isActionDefinition2(value) {
|
|
619
|
+
const binding = value?.binding;
|
|
620
|
+
return typeof value === "object" && value !== null && value.kind === "action" && (binding?.kind === "global" || binding?.kind === "object");
|
|
621
|
+
}
|
|
622
|
+
function isGlobalActionDefinition2(value) {
|
|
623
|
+
return value.binding.kind === "global";
|
|
624
|
+
}
|
|
625
|
+
function isObjectActionDefinition2(value) {
|
|
626
|
+
return value.binding.kind === "object";
|
|
627
|
+
}
|
|
628
|
+
function normalizeActionParams(runtime, paramsConfig, params, pathPrefix) {
|
|
629
|
+
const knownParamIds = new Set(Object.keys(paramsConfig));
|
|
630
|
+
const normalized = {};
|
|
631
|
+
for (const paramId of Object.keys(params)) {
|
|
632
|
+
if (!knownParamIds.has(paramId)) {
|
|
633
|
+
throw new OntologyValidationError2(`Unknown param '${paramId}' for action '${pathPrefix}'`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
for (const [paramId, paramDef] of Object.entries(paramsConfig)) {
|
|
637
|
+
const value = params[paramId];
|
|
638
|
+
if (value === undefined) {
|
|
639
|
+
if (paramDef.required) {
|
|
640
|
+
throw new OntologyValidationError2(`Missing required param '${paramId}' for action '${pathPrefix}'`);
|
|
641
|
+
}
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (value === null) {
|
|
645
|
+
if (!paramDef.nullable) {
|
|
646
|
+
throw new OntologyValidationError2(`[Sixb] Action param ${pathPrefix}.${paramId} cannot be null`);
|
|
647
|
+
}
|
|
648
|
+
normalized[paramId] = null;
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
validateSchemaOrRefValue2(paramDef.schema, value, `${pathPrefix}.${paramId}`, runtime.ontology.getValueTypesById());
|
|
652
|
+
normalized[paramId] = normalizeSchemaOrRefValue(paramDef.schema, value, `${pathPrefix}.${paramId}`, runtime.ontology.getValueTypesById());
|
|
653
|
+
}
|
|
654
|
+
return normalized;
|
|
655
|
+
}
|
|
656
|
+
function coerceActionParamsToTyped2(paramsConfig, params, valueTypesById) {
|
|
657
|
+
const coerced = { ...params };
|
|
658
|
+
for (const [paramId, paramDef] of Object.entries(paramsConfig)) {
|
|
659
|
+
const value = params[paramId];
|
|
660
|
+
if (value === undefined)
|
|
661
|
+
continue;
|
|
662
|
+
const schema = paramDef.schema;
|
|
663
|
+
if (typeof schema === "object" && schema !== null && schema.type === "objectRef") {
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
coerced[paramId] = coerceSchemaValueToTyped2(schema, value, valueTypesById);
|
|
667
|
+
}
|
|
668
|
+
return coerced;
|
|
669
|
+
}
|
|
670
|
+
function validateActionSubject(action, subject) {
|
|
671
|
+
if (isGlobalActionDefinition2(action) && subject.kind !== "none") {
|
|
672
|
+
throw new OntologyValidationError2(`Action '${action.id}' does not accept an object subject.`);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function resolveObjectActionSubject(params) {
|
|
676
|
+
const { runtime, action, subject } = params;
|
|
677
|
+
if (subject.kind !== "object") {
|
|
678
|
+
throw new OntologyValidationError2(`Action '${action.id}' requires an object subject.`);
|
|
679
|
+
}
|
|
680
|
+
const objectType = runtime.ontology.resolveObjectType(subject.objectTypeId);
|
|
681
|
+
if (!actionAppliesToObjectType(runtime, action, objectType)) {
|
|
682
|
+
throw new OntologyValidationError2(`Action '${action.id}' is not valid for object type '${objectType.id}'.`);
|
|
683
|
+
}
|
|
684
|
+
return objectType;
|
|
685
|
+
}
|
|
686
|
+
function actionAppliesToObjectType(runtime, action, objectType) {
|
|
687
|
+
return runtime.actionRegistry.listForType(objectType).some((candidate) => candidate.id === action.id);
|
|
688
|
+
}
|
|
689
|
+
function normalizeSchemaOrRefValue(schema, value, path, valueTypesById) {
|
|
690
|
+
if (typeof schema === "object" && schema !== null && schema.type === "objectRef") {
|
|
691
|
+
const refValue = value;
|
|
692
|
+
return {
|
|
693
|
+
objectTypeId: refValue.objectTypeId,
|
|
694
|
+
primaryId: refValue.primaryId
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
return normalizeSchemaValue2(schema, value, path, valueTypesById);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/shares/errors.ts
|
|
701
|
+
class ShareDefinitionError2 extends Error {
|
|
702
|
+
name = "ShareDefinitionError";
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// src/shares/builders.ts
|
|
706
|
+
var shareTargets = new WeakSet;
|
|
707
|
+
function defineShare2(id, options) {
|
|
708
|
+
assertNonEmpty(id, "Share id");
|
|
709
|
+
if (!isObjectType(options.target)) {
|
|
710
|
+
throw invalid(`Share '${id}' target must be an object type.`);
|
|
711
|
+
}
|
|
712
|
+
if (typeof options.grants !== "function") {
|
|
713
|
+
throw invalid(`Share '${id}' grants must be a function.`);
|
|
714
|
+
}
|
|
715
|
+
if (options.description !== undefined && typeof options.description !== "string") {
|
|
716
|
+
throw invalid(`Share '${id}' description must be a string.`);
|
|
717
|
+
}
|
|
718
|
+
const target = createShareTarget(options.target.id);
|
|
719
|
+
let authoredGrants;
|
|
720
|
+
try {
|
|
721
|
+
authoredGrants = options.grants({ target });
|
|
722
|
+
} catch (error) {
|
|
723
|
+
if (error instanceof ShareDefinitionError2)
|
|
724
|
+
throw error;
|
|
725
|
+
const reason = error instanceof Error ? error.message.replace(/^\[Sixb\] /, "") : String(error);
|
|
726
|
+
throw invalid(`Share '${id}' grants are invalid: ${reason}`);
|
|
727
|
+
}
|
|
728
|
+
if (!Array.isArray(authoredGrants) || authoredGrants.length === 0) {
|
|
729
|
+
throw invalid(`Share '${id}' must declare at least one grant.`);
|
|
730
|
+
}
|
|
731
|
+
const grants = snapshotShareGrants(id, options.target.id, authoredGrants);
|
|
732
|
+
return Object.freeze({
|
|
733
|
+
kind: "share",
|
|
734
|
+
id,
|
|
735
|
+
target: Object.freeze({ kind: "object", objectTypeId: options.target.id }),
|
|
736
|
+
grants,
|
|
737
|
+
...options.description === undefined ? {} : { description: options.description }
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
function isShareDefinition(value) {
|
|
741
|
+
if (!isRecord2(value) || value.kind !== "share" || !isNonEmpty(value.id))
|
|
742
|
+
return false;
|
|
743
|
+
if (!isRecord2(value.target) || value.target.kind !== "object" || !isNonEmpty(value.target.objectTypeId)) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
return Array.isArray(value.grants);
|
|
747
|
+
}
|
|
748
|
+
function snapshotShareDefinition(value) {
|
|
749
|
+
try {
|
|
750
|
+
if (!isRecord2(value)) {
|
|
751
|
+
throw invalid("Share definition kind must be 'share'.");
|
|
752
|
+
}
|
|
753
|
+
const kind = value.kind;
|
|
754
|
+
const authoredId = value.id;
|
|
755
|
+
const target = value.target;
|
|
756
|
+
const authoredGrants = value.grants;
|
|
757
|
+
const description = value.description;
|
|
758
|
+
if (kind !== "share") {
|
|
759
|
+
throw invalid("Share definition kind must be 'share'.");
|
|
760
|
+
}
|
|
761
|
+
const id = nonEmpty(authoredId, "Share id");
|
|
762
|
+
if (!isRecord2(target)) {
|
|
763
|
+
throw invalid(`Share '${id}' target must be an object type.`);
|
|
764
|
+
}
|
|
765
|
+
const targetKind = target.kind;
|
|
766
|
+
const authoredObjectTypeId = target.objectTypeId;
|
|
767
|
+
if (targetKind !== "object" || !isNonEmpty(authoredObjectTypeId)) {
|
|
768
|
+
throw invalid(`Share '${id}' target must be an object type.`);
|
|
769
|
+
}
|
|
770
|
+
if (!Array.isArray(authoredGrants) || authoredGrants.length === 0) {
|
|
771
|
+
throw invalid(`Share '${id}' must declare grants.`);
|
|
772
|
+
}
|
|
773
|
+
if (description !== undefined && typeof description !== "string") {
|
|
774
|
+
throw invalid(`Share '${id}' description must be a string.`);
|
|
775
|
+
}
|
|
776
|
+
const objectTypeId = authoredObjectTypeId;
|
|
777
|
+
return Object.freeze({
|
|
778
|
+
kind: "share",
|
|
779
|
+
id,
|
|
780
|
+
target: Object.freeze({ kind: "object", objectTypeId }),
|
|
781
|
+
grants: snapshotShareGrants(id, objectTypeId, authoredGrants),
|
|
782
|
+
...description === undefined ? {} : { description }
|
|
783
|
+
});
|
|
784
|
+
} catch (error) {
|
|
785
|
+
if (error instanceof ShareDefinitionError2)
|
|
786
|
+
throw error;
|
|
787
|
+
const reason = error instanceof Error ? error.message.replace(/^\[Sixb\] /, "") : String(error);
|
|
788
|
+
throw invalid(`Share definition is invalid: ${reason}`);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function isShareTarget(value) {
|
|
792
|
+
return typeof value === "object" && value !== null && shareTargets.has(value);
|
|
793
|
+
}
|
|
794
|
+
function createShareViewGrant(target) {
|
|
795
|
+
assertShareTarget(target);
|
|
796
|
+
return createShareViewGrantWithLinks(target.objectTypeId, Object.freeze({ kind: "none" }));
|
|
797
|
+
}
|
|
798
|
+
function createShareActionGrant(action, target) {
|
|
799
|
+
assertShareTarget(target);
|
|
800
|
+
const objectTypeId = action.binding.objectType.id;
|
|
801
|
+
if (target.objectTypeId !== objectTypeId) {
|
|
802
|
+
throw invalid(`Action '${action.id}' is defined on '${objectTypeId}', not Share target '${target.objectTypeId}'. Shared Actions are exact-type only in V1.`);
|
|
803
|
+
}
|
|
804
|
+
return Object.freeze({
|
|
805
|
+
kind: "action.apply",
|
|
806
|
+
actionId: action.id,
|
|
807
|
+
subjectObjectTypeId: target.objectTypeId
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
function createShareTarget(objectTypeId) {
|
|
811
|
+
const target = { objectTypeId };
|
|
812
|
+
shareTargets.add(target);
|
|
813
|
+
return Object.freeze(target);
|
|
814
|
+
}
|
|
815
|
+
function createShareViewGrantWithLinks(targetObjectTypeId, links) {
|
|
816
|
+
const grant = {
|
|
817
|
+
kind: "object.view",
|
|
818
|
+
targetObjectTypeId,
|
|
819
|
+
links
|
|
820
|
+
};
|
|
821
|
+
Object.defineProperty(grant, "withLinks", {
|
|
822
|
+
configurable: false,
|
|
823
|
+
enumerable: false,
|
|
824
|
+
writable: false,
|
|
825
|
+
value: (...args) => {
|
|
826
|
+
if (args.length === 0) {
|
|
827
|
+
return freezeViewGrant(targetObjectTypeId, Object.freeze({ kind: "all" }));
|
|
828
|
+
}
|
|
829
|
+
const selected = args[0];
|
|
830
|
+
if (!Array.isArray(selected)) {
|
|
831
|
+
throw invalid("withLinks(...) expects an array, or no argument for every direct link.");
|
|
832
|
+
}
|
|
833
|
+
return freezeViewGrant(targetObjectTypeId, Object.freeze({
|
|
834
|
+
kind: "selected",
|
|
835
|
+
links: Object.freeze(selected.map(snapshotLinkPathSelection))
|
|
836
|
+
}));
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
return Object.freeze(grant);
|
|
840
|
+
}
|
|
841
|
+
function freezeViewGrant(targetObjectTypeId, links) {
|
|
842
|
+
return Object.freeze({ kind: "object.view", targetObjectTypeId, links });
|
|
843
|
+
}
|
|
844
|
+
function snapshotShareGrants(shareId, targetObjectTypeId, authored) {
|
|
845
|
+
const grants = [];
|
|
846
|
+
const actionIds = new Set;
|
|
847
|
+
let viewCount = 0;
|
|
848
|
+
for (let index = 0;index < authored.length; index += 1) {
|
|
849
|
+
const grant = authored[index];
|
|
850
|
+
if (!isRecord2(grant)) {
|
|
851
|
+
throw invalid(`Share '${shareId}' grant ${index} must come from 'can'.`);
|
|
852
|
+
}
|
|
853
|
+
const kind = grant.kind;
|
|
854
|
+
if (kind === "object.view") {
|
|
855
|
+
const authoredTargetObjectTypeId = grant.targetObjectTypeId;
|
|
856
|
+
const links = grant.links;
|
|
857
|
+
if (authoredTargetObjectTypeId !== targetObjectTypeId) {
|
|
858
|
+
throw invalid(`Share '${shareId}' view grant must use its contextual target.`);
|
|
859
|
+
}
|
|
860
|
+
viewCount += 1;
|
|
861
|
+
if (viewCount > 1) {
|
|
862
|
+
throw invalid(`Share '${shareId}' must declare exactly one view grant.`);
|
|
863
|
+
}
|
|
864
|
+
grants.push(Object.freeze({
|
|
865
|
+
kind: "object.view",
|
|
866
|
+
targetObjectTypeId,
|
|
867
|
+
links: snapshotLinkMode(links)
|
|
868
|
+
}));
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (kind === "action.apply") {
|
|
872
|
+
const actionId = grant.actionId;
|
|
873
|
+
const subjectObjectTypeId = grant.subjectObjectTypeId;
|
|
874
|
+
if (!isNonEmpty(actionId) || subjectObjectTypeId !== targetObjectTypeId) {
|
|
875
|
+
throw invalid(`Share '${shareId}' action grant must apply to its contextual target.`);
|
|
876
|
+
}
|
|
877
|
+
if (actionIds.has(actionId)) {
|
|
878
|
+
throw invalid(`Share '${shareId}' contains duplicate action '${actionId}'.`);
|
|
879
|
+
}
|
|
880
|
+
actionIds.add(actionId);
|
|
881
|
+
grants.push(Object.freeze({
|
|
882
|
+
kind: "action.apply",
|
|
883
|
+
actionId,
|
|
884
|
+
subjectObjectTypeId: targetObjectTypeId
|
|
885
|
+
}));
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
throw invalid(`Share '${shareId}' grant ${index} must come from 'can'.`);
|
|
889
|
+
}
|
|
890
|
+
if (viewCount !== 1) {
|
|
891
|
+
throw invalid(`Share '${shareId}' must declare exactly one can.view(target) grant.`);
|
|
892
|
+
}
|
|
893
|
+
return Object.freeze(grants);
|
|
894
|
+
}
|
|
895
|
+
function snapshotLinkMode(value) {
|
|
896
|
+
if (!isRecord2(value))
|
|
897
|
+
throw invalid("Share link selection must be an object.");
|
|
898
|
+
const kind = value.kind;
|
|
899
|
+
const links = value.links;
|
|
900
|
+
if (kind === "none" || kind === "all") {
|
|
901
|
+
return Object.freeze({ kind });
|
|
902
|
+
}
|
|
903
|
+
if (kind !== "selected" || !Array.isArray(links)) {
|
|
904
|
+
throw invalid("Share link selection must be none, all, or selected links.");
|
|
905
|
+
}
|
|
906
|
+
if (links.length === 0) {
|
|
907
|
+
throw invalid("withLinks([]) is empty; omit withLinks() when no links should be shared.");
|
|
908
|
+
}
|
|
909
|
+
try {
|
|
910
|
+
return Object.freeze({
|
|
911
|
+
kind: "selected",
|
|
912
|
+
links: snapshotLinkPaths(links)
|
|
913
|
+
});
|
|
914
|
+
} catch (error) {
|
|
915
|
+
if (error instanceof ShareDefinitionError2)
|
|
916
|
+
throw error;
|
|
917
|
+
const reason = error instanceof Error ? error.message.replace(/^\[Sixb\] /, "") : String(error);
|
|
918
|
+
throw invalid(`Share link selection is invalid: ${reason}`);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
function snapshotLinkPaths(values) {
|
|
922
|
+
const byKey = new Map;
|
|
923
|
+
for (const value of values) {
|
|
924
|
+
const captured = canonicalizeLinkPath(snapshotLinkPathSelection(value));
|
|
925
|
+
const key = JSON.stringify([captured.sourceObjectTypeId, captured.linkId]);
|
|
926
|
+
const current = byKey.get(key);
|
|
927
|
+
if (!current) {
|
|
928
|
+
byKey.set(key, captured);
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (!sameLinkTargets(current.targetObjectTypeId, captured.targetObjectTypeId)) {
|
|
932
|
+
throw invalid(`Link '${captured.sourceObjectTypeId}.${captured.linkId}' declares inconsistent targets.`);
|
|
933
|
+
}
|
|
934
|
+
byKey.set(key, Object.freeze({
|
|
935
|
+
...current,
|
|
936
|
+
selection: mergeLinkModes(current.selection, captured.selection)
|
|
937
|
+
}));
|
|
938
|
+
}
|
|
939
|
+
return Object.freeze([...byKey.values()]);
|
|
940
|
+
}
|
|
941
|
+
function canonicalizeLinkPath(value) {
|
|
942
|
+
return Object.freeze({
|
|
943
|
+
...value,
|
|
944
|
+
selection: value.selection.kind === "selected" ? Object.freeze({
|
|
945
|
+
kind: "selected",
|
|
946
|
+
links: snapshotLinkPaths(value.selection.links)
|
|
947
|
+
}) : value.selection
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
function mergeLinkModes(left, right) {
|
|
951
|
+
if (left.kind === "all" || right.kind === "all")
|
|
952
|
+
return Object.freeze({ kind: "all" });
|
|
953
|
+
if (left.kind === "none")
|
|
954
|
+
return right;
|
|
955
|
+
if (right.kind === "none")
|
|
956
|
+
return left;
|
|
957
|
+
return Object.freeze({
|
|
958
|
+
kind: "selected",
|
|
959
|
+
links: snapshotLinkPaths([...left.links, ...right.links])
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
function sameLinkTargets(left, right) {
|
|
963
|
+
if (typeof left === "string" || typeof right === "string")
|
|
964
|
+
return left === right;
|
|
965
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
966
|
+
}
|
|
967
|
+
function assertShareTarget(value) {
|
|
968
|
+
if (!isShareTarget(value)) {
|
|
969
|
+
throw invalid("Shared grants must use the target provided by defineShare(...).");
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
function isObjectType(value) {
|
|
973
|
+
return isRecord2(value) && isNonEmpty(value.id) && Array.isArray(value.properties) && Array.isArray(value.links);
|
|
974
|
+
}
|
|
975
|
+
function isRecord2(value) {
|
|
976
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
977
|
+
}
|
|
978
|
+
function isNonEmpty(value) {
|
|
979
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
980
|
+
}
|
|
981
|
+
function assertNonEmpty(value, field) {
|
|
982
|
+
if (!isNonEmpty(value))
|
|
983
|
+
throw invalid(`${field} must not be empty.`);
|
|
984
|
+
}
|
|
985
|
+
function nonEmpty(value, field) {
|
|
986
|
+
assertNonEmpty(value, field);
|
|
987
|
+
return value;
|
|
988
|
+
}
|
|
989
|
+
function invalid(message) {
|
|
990
|
+
return new ShareDefinitionError2(`[Sixb] ${message}`);
|
|
991
|
+
}
|
|
992
|
+
|
|
583
993
|
// src/security/grants.ts
|
|
584
994
|
var VIEW_TARGETS = ["object", "dataset"];
|
|
585
995
|
var RUN_TARGETS = ["workflow", "sync", "pipeline"];
|
|
@@ -589,7 +999,8 @@ var TARGET_BY_DEFINITION_KIND = {
|
|
|
589
999
|
pipeline: "pipeline",
|
|
590
1000
|
workflow: "workflow",
|
|
591
1001
|
application: "application",
|
|
592
|
-
connector: "connector"
|
|
1002
|
+
connector: "connector",
|
|
1003
|
+
share: "share"
|
|
593
1004
|
};
|
|
594
1005
|
var UNDISCRIMINATED_TARGETS = ["object", "action"];
|
|
595
1006
|
function targetOfDefinition(item, label, allowedTargets) {
|
|
@@ -597,7 +1008,7 @@ function targetOfDefinition(item, label, allowedTargets) {
|
|
|
597
1008
|
const discriminated = typeof kind === "string" ? TARGET_BY_DEFINITION_KIND[kind] : undefined;
|
|
598
1009
|
if (discriminated) {
|
|
599
1010
|
if (!isAllowedTarget(discriminated, allowedTargets)) {
|
|
600
|
-
throw new
|
|
1011
|
+
throw new SecurityValidationError2(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} definitions, but received one targeting ${discriminated}.`);
|
|
601
1012
|
}
|
|
602
1013
|
return discriminated;
|
|
603
1014
|
}
|
|
@@ -605,7 +1016,7 @@ function targetOfDefinition(item, label, allowedTargets) {
|
|
|
605
1016
|
const only = candidates.length === 1 ? candidates[0] : undefined;
|
|
606
1017
|
if (only)
|
|
607
1018
|
return only;
|
|
608
|
-
throw new
|
|
1019
|
+
throw new SecurityValidationError2(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} definitions, but received one Sixb could not classify.`);
|
|
609
1020
|
}
|
|
610
1021
|
function isAllowedTarget(target, allowedTargets) {
|
|
611
1022
|
return allowedTargets.includes(target);
|
|
@@ -613,7 +1024,7 @@ function isAllowedTarget(target, allowedTargets) {
|
|
|
613
1024
|
function resolveGrant(input, label, allowedTargets) {
|
|
614
1025
|
if (isBreadthSelector(input)) {
|
|
615
1026
|
if (!isAllowedTarget(input.target, allowedTargets)) {
|
|
616
|
-
throw new
|
|
1027
|
+
throw new SecurityValidationError2(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} selectors, but received every.${input.target}().`);
|
|
617
1028
|
}
|
|
618
1029
|
return { target: input.target, selection: input.selection };
|
|
619
1030
|
}
|
|
@@ -626,11 +1037,11 @@ function resolveGrant(input, label, allowedTargets) {
|
|
|
626
1037
|
continue;
|
|
627
1038
|
}
|
|
628
1039
|
if (itemTarget !== target) {
|
|
629
|
-
throw new
|
|
1040
|
+
throw new SecurityValidationError2(`[Sixb] ${label} requires one target per grant, but received both ${target} and ${itemTarget} definitions. Use one grant each.`);
|
|
630
1041
|
}
|
|
631
1042
|
}
|
|
632
1043
|
if (target === undefined) {
|
|
633
|
-
throw new
|
|
1044
|
+
throw new SecurityValidationError2(`[Sixb] ${label} requires at least one definition.`);
|
|
634
1045
|
}
|
|
635
1046
|
const ids = [...new Set(items.map((item) => definitionIdOf(item, label)))];
|
|
636
1047
|
return { target, selection: { all: false, ids } };
|
|
@@ -640,6 +1051,8 @@ function access(input) {
|
|
|
640
1051
|
return { kind: "grant", capability: "access", target: "application", selection };
|
|
641
1052
|
}
|
|
642
1053
|
function view(input) {
|
|
1054
|
+
if (isShareTarget(input))
|
|
1055
|
+
return createShareViewGrant(input);
|
|
643
1056
|
const { target, selection } = resolveGrant(input, "can.view", VIEW_TARGETS);
|
|
644
1057
|
return { kind: "grant", capability: "view", target, selection };
|
|
645
1058
|
}
|
|
@@ -658,11 +1071,28 @@ function append(input) {
|
|
|
658
1071
|
};
|
|
659
1072
|
}
|
|
660
1073
|
function apply(input) {
|
|
661
|
-
|
|
1074
|
+
const grant = {
|
|
662
1075
|
kind: "grant",
|
|
663
1076
|
capability: "apply",
|
|
664
1077
|
selection: resolveGrant(input, "can.apply", ["action"]).selection
|
|
665
1078
|
};
|
|
1079
|
+
const one = Array.isArray(input) || isBreadthSelector(input) ? undefined : input;
|
|
1080
|
+
if (one && isObjectActionDefinition2(one)) {
|
|
1081
|
+
Object.defineProperty(grant, "on", {
|
|
1082
|
+
configurable: false,
|
|
1083
|
+
enumerable: false,
|
|
1084
|
+
writable: false,
|
|
1085
|
+
value: (target) => createShareActionGrant(one, target)
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
return grant;
|
|
1089
|
+
}
|
|
1090
|
+
function share(input) {
|
|
1091
|
+
return {
|
|
1092
|
+
kind: "grant",
|
|
1093
|
+
capability: "share",
|
|
1094
|
+
selection: resolveGrant(input, "can.share", ["share"]).selection
|
|
1095
|
+
};
|
|
666
1096
|
}
|
|
667
1097
|
function run(input) {
|
|
668
1098
|
if (isAgentReference(input)) {
|
|
@@ -679,7 +1109,7 @@ function isAgentUsageReference(input) {
|
|
|
679
1109
|
}
|
|
680
1110
|
function observe(input) {
|
|
681
1111
|
if (input !== "logs" && !isAgentUsageReference(input)) {
|
|
682
|
-
throw new
|
|
1112
|
+
throw new SecurityValidationError2('[Sixb] can.observe accepts "logs" or agent.usage.');
|
|
683
1113
|
}
|
|
684
1114
|
const target = input === "logs" ? "logs" : "aiUsage";
|
|
685
1115
|
return {
|
|
@@ -705,12 +1135,13 @@ function manage(input) {
|
|
|
705
1135
|
selection: resolveGrant(input, "can.manage", ["connector"]).selection
|
|
706
1136
|
};
|
|
707
1137
|
}
|
|
708
|
-
var
|
|
1138
|
+
var can2 = {
|
|
709
1139
|
access,
|
|
710
1140
|
view,
|
|
711
1141
|
edit,
|
|
712
1142
|
append,
|
|
713
1143
|
apply,
|
|
1144
|
+
share,
|
|
714
1145
|
run,
|
|
715
1146
|
observe,
|
|
716
1147
|
manage
|
|
@@ -736,7 +1167,8 @@ class SecurityRegistry {
|
|
|
736
1167
|
agentAvailable: input.agentAvailable,
|
|
737
1168
|
connectorIds: input.connectorIds,
|
|
738
1169
|
observableIds: new Set(["logs", "aiUsage"]),
|
|
739
|
-
manageableIds: new Set(["aiUsage"])
|
|
1170
|
+
manageableIds: new Set(["aiUsage"]),
|
|
1171
|
+
shareIds: input.shareIds
|
|
740
1172
|
});
|
|
741
1173
|
const universe = {
|
|
742
1174
|
applicationIds: input.applicationIds ?? APPLICATION_IDS,
|
|
@@ -749,6 +1181,7 @@ class SecurityRegistry {
|
|
|
749
1181
|
connectorIds: input.connectorIds ?? new Set,
|
|
750
1182
|
observableIds: new Set(["logs", "aiUsage"]),
|
|
751
1183
|
manageableIds: new Set(["aiUsage"]),
|
|
1184
|
+
shareIds: input.shareIds ?? new Set,
|
|
752
1185
|
getSubTypes: input.getSubTypes ?? (() => [])
|
|
753
1186
|
};
|
|
754
1187
|
this.groupsById = definitions.groupsById;
|
|
@@ -757,7 +1190,7 @@ class SecurityRegistry {
|
|
|
757
1190
|
this.resolvedRoles = definitions.roles.map((role) => ({
|
|
758
1191
|
id: role.id,
|
|
759
1192
|
grantedToGroupIds: role.grantedToGroupIds,
|
|
760
|
-
grants:
|
|
1193
|
+
grants: resolveRoleGrants2(role, universe)
|
|
761
1194
|
}));
|
|
762
1195
|
}
|
|
763
1196
|
listGroups() {
|
|
@@ -783,7 +1216,7 @@ class SecurityRegistry {
|
|
|
783
1216
|
}
|
|
784
1217
|
}
|
|
785
1218
|
// src/storage/auth/errors.ts
|
|
786
|
-
class
|
|
1219
|
+
class AuthStorageError2 extends Error {
|
|
787
1220
|
code;
|
|
788
1221
|
name = "AuthStorageError";
|
|
789
1222
|
constructor(code, message) {
|
|
@@ -855,18 +1288,18 @@ function cloneDate(value) {
|
|
|
855
1288
|
function dateOrNow(value) {
|
|
856
1289
|
return value ? cloneDate(value) : new Date;
|
|
857
1290
|
}
|
|
858
|
-
function
|
|
1291
|
+
function assertNonEmpty4(value, label) {
|
|
859
1292
|
const normalized = value.trim();
|
|
860
1293
|
if (!normalized) {
|
|
861
|
-
throw new
|
|
1294
|
+
throw new AuthStorageError2("invalid_input", `[Sixb] ${label} must be a non-empty string.`);
|
|
862
1295
|
}
|
|
863
1296
|
return normalized;
|
|
864
1297
|
}
|
|
865
1298
|
function normalizeEmail(email) {
|
|
866
|
-
return
|
|
1299
|
+
return assertNonEmpty4(email, "Email").toLowerCase();
|
|
867
1300
|
}
|
|
868
1301
|
function normalizeGroupIds(groupIds) {
|
|
869
|
-
return [...new Set((groupIds ?? []).map((groupId) =>
|
|
1302
|
+
return [...new Set((groupIds ?? []).map((groupId) => assertNonEmpty4(groupId, "Group id")))];
|
|
870
1303
|
}
|
|
871
1304
|
function normalizeOptionalGroupIds(groupIds) {
|
|
872
1305
|
return groupIds === undefined ? undefined : normalizeGroupIds(groupIds);
|
|
@@ -949,22 +1382,22 @@ function revokeActiveMagicLinksForEmail(state, projectId, email, revokedAt) {
|
|
|
949
1382
|
}
|
|
950
1383
|
function assertSessionIdAvailable(state, projectId, sessionId) {
|
|
951
1384
|
if (state.sessions.has(sessionKey(projectId, sessionId))) {
|
|
952
|
-
throw new
|
|
1385
|
+
throw new AuthStorageError2("duplicate_session", `[Sixb] Session '${sessionId}' already exists for project '${projectId}'.`);
|
|
953
1386
|
}
|
|
954
1387
|
}
|
|
955
1388
|
function validateCompleteSessionInput(state, projectId, session) {
|
|
956
|
-
const sessionId =
|
|
957
|
-
|
|
958
|
-
|
|
1389
|
+
const sessionId = assertNonEmpty4(session.id, "Session id");
|
|
1390
|
+
assertNonEmpty4(session.audience, "Session audience");
|
|
1391
|
+
assertNonEmpty4(session.tokenHash, "Session token hash");
|
|
959
1392
|
assertSessionIdAvailable(state, projectId, sessionId);
|
|
960
1393
|
}
|
|
961
1394
|
function createSessionRecord(state, input) {
|
|
962
|
-
const id =
|
|
963
|
-
const projectId =
|
|
964
|
-
const userId =
|
|
965
|
-
const strategyId =
|
|
966
|
-
const audience =
|
|
967
|
-
const tokenHash =
|
|
1395
|
+
const id = assertNonEmpty4(input.id, "Session id");
|
|
1396
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1397
|
+
const userId = assertNonEmpty4(input.userId, "User id");
|
|
1398
|
+
const strategyId = assertNonEmpty4(input.strategyId, "Strategy id");
|
|
1399
|
+
const audience = resolveAuthSessionAudience2(input.audience);
|
|
1400
|
+
const tokenHash = assertNonEmpty4(input.tokenHash, "Session token hash");
|
|
968
1401
|
assertSessionIdAvailable(state, projectId, id);
|
|
969
1402
|
const session = {
|
|
970
1403
|
id,
|
|
@@ -983,12 +1416,12 @@ function createSessionRecord(state, input) {
|
|
|
983
1416
|
return session;
|
|
984
1417
|
}
|
|
985
1418
|
function createServiceAccountRecord(state, input) {
|
|
986
|
-
const id =
|
|
987
|
-
const projectId =
|
|
988
|
-
const name =
|
|
1419
|
+
const id = assertNonEmpty4(input.id, "Service account id");
|
|
1420
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1421
|
+
const name = assertNonEmpty4(input.name, "Service account name");
|
|
989
1422
|
const key = serviceAccountKey(projectId, id);
|
|
990
1423
|
if (state.serviceAccounts.has(key)) {
|
|
991
|
-
throw new
|
|
1424
|
+
throw new AuthStorageError2("duplicate_service_account", `[Sixb] Service account '${id}' already exists for project '${projectId}'.`);
|
|
992
1425
|
}
|
|
993
1426
|
const createdAt = dateOrNow(input.createdAt);
|
|
994
1427
|
const serviceAccount = {
|
|
@@ -1006,11 +1439,11 @@ function createServiceAccountRecord(state, input) {
|
|
|
1006
1439
|
return serviceAccount;
|
|
1007
1440
|
}
|
|
1008
1441
|
function upsertServiceAccountGroupMembershipRecord(state, input) {
|
|
1009
|
-
const projectId =
|
|
1010
|
-
const serviceAccountId =
|
|
1011
|
-
const groupId =
|
|
1442
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1443
|
+
const serviceAccountId = assertNonEmpty4(input.serviceAccountId, "Service account id");
|
|
1444
|
+
const groupId = assertNonEmpty4(input.groupId, "Group id");
|
|
1012
1445
|
if (!state.serviceAccounts.has(serviceAccountKey(projectId, serviceAccountId))) {
|
|
1013
|
-
throw new
|
|
1446
|
+
throw new AuthStorageError2("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${projectId}'.`);
|
|
1014
1447
|
}
|
|
1015
1448
|
const key = serviceAccountGroupMembershipKey(projectId, serviceAccountId, groupId);
|
|
1016
1449
|
const existing = state.serviceAccountGroupMemberships.get(key);
|
|
@@ -1028,16 +1461,16 @@ function upsertServiceAccountGroupMembershipRecord(state, input) {
|
|
|
1028
1461
|
return membership;
|
|
1029
1462
|
}
|
|
1030
1463
|
function createAccessTokenRecord(state, input) {
|
|
1031
|
-
const id =
|
|
1032
|
-
const projectId =
|
|
1033
|
-
const name =
|
|
1034
|
-
const subjectId =
|
|
1035
|
-
const tokenHash =
|
|
1464
|
+
const id = assertNonEmpty4(input.id, "Access token id");
|
|
1465
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1466
|
+
const name = assertNonEmpty4(input.name, "Access token name");
|
|
1467
|
+
const subjectId = assertNonEmpty4(input.subjectId, "Access token subject id");
|
|
1468
|
+
const tokenHash = assertNonEmpty4(input.tokenHash, "Access token hash");
|
|
1036
1469
|
assertAccessTokenSubject(input.kind, input.subjectType);
|
|
1037
1470
|
assertAccessTokenSubjectExists(state, projectId, input.subjectType, subjectId);
|
|
1038
1471
|
const key = accessTokenKey(projectId, id);
|
|
1039
1472
|
if (state.accessTokens.has(key)) {
|
|
1040
|
-
throw new
|
|
1473
|
+
throw new AuthStorageError2("duplicate_access_token", `[Sixb] Access token '${id}' already exists for project '${projectId}'.`);
|
|
1041
1474
|
}
|
|
1042
1475
|
const token = {
|
|
1043
1476
|
id,
|
|
@@ -1057,11 +1490,11 @@ function createAccessTokenRecord(state, input) {
|
|
|
1057
1490
|
return token;
|
|
1058
1491
|
}
|
|
1059
1492
|
function upsertGroupMembershipRecord(state, input) {
|
|
1060
|
-
const projectId =
|
|
1061
|
-
const userId =
|
|
1062
|
-
const groupId =
|
|
1493
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1494
|
+
const userId = assertNonEmpty4(input.userId, "User id");
|
|
1495
|
+
const groupId = assertNonEmpty4(input.groupId, "Group id");
|
|
1063
1496
|
if (!state.users.has(userKey(projectId, userId))) {
|
|
1064
|
-
throw new
|
|
1497
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${userId}' not found for project '${projectId}'.`);
|
|
1065
1498
|
}
|
|
1066
1499
|
const key = groupMembershipKey(projectId, userId, groupId);
|
|
1067
1500
|
const existing = state.groupMemberships.get(key);
|
|
@@ -1079,9 +1512,9 @@ function upsertGroupMembershipRecord(state, input) {
|
|
|
1079
1512
|
return membership;
|
|
1080
1513
|
}
|
|
1081
1514
|
function removeGroupMembershipRecord(state, params) {
|
|
1082
|
-
const projectId =
|
|
1083
|
-
const userId =
|
|
1084
|
-
const groupId =
|
|
1515
|
+
const projectId = assertNonEmpty4(params.projectId, "Project id");
|
|
1516
|
+
const userId = assertNonEmpty4(params.userId, "User id");
|
|
1517
|
+
const groupId = assertNonEmpty4(params.groupId, "Group id");
|
|
1085
1518
|
const key = groupMembershipKey(projectId, userId, groupId);
|
|
1086
1519
|
const existing = state.groupMemberships.get(key);
|
|
1087
1520
|
if (!existing) {
|
|
@@ -1094,32 +1527,32 @@ function assertAccessTokenSubject(kind, subjectType) {
|
|
|
1094
1527
|
if (kind === "personal" && subjectType === "user" || kind === "serviceAccount" && subjectType === "serviceAccount") {
|
|
1095
1528
|
return;
|
|
1096
1529
|
}
|
|
1097
|
-
throw new
|
|
1530
|
+
throw new AuthStorageError2("invalid_input", `[Sixb] Access token kind '${kind}' cannot target subject type '${subjectType}'.`);
|
|
1098
1531
|
}
|
|
1099
1532
|
function assertAccessTokenSubjectExists(state, projectId, subjectType, subjectId) {
|
|
1100
1533
|
if (subjectType === "user") {
|
|
1101
1534
|
if (state.users.has(userKey(projectId, subjectId)))
|
|
1102
1535
|
return;
|
|
1103
|
-
throw new
|
|
1536
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${subjectId}' not found for project '${projectId}'.`);
|
|
1104
1537
|
}
|
|
1105
1538
|
if (state.serviceAccounts.has(serviceAccountKey(projectId, subjectId)))
|
|
1106
1539
|
return;
|
|
1107
|
-
throw new
|
|
1540
|
+
throw new AuthStorageError2("missing_service_account", `[Sixb] Service account '${subjectId}' not found for project '${projectId}'.`);
|
|
1108
1541
|
}
|
|
1109
1542
|
function consumeMagicLinkRecord(state, params) {
|
|
1110
|
-
const projectId =
|
|
1111
|
-
const id =
|
|
1112
|
-
const tokenHash =
|
|
1543
|
+
const projectId = assertNonEmpty4(params.projectId, "Project id");
|
|
1544
|
+
const id = assertNonEmpty4(params.id, "Magic link id");
|
|
1545
|
+
const tokenHash = assertNonEmpty4(params.tokenHash, "Magic link token hash");
|
|
1113
1546
|
const key = magicLinkKey(projectId, id);
|
|
1114
1547
|
const existing = state.magicLinks.get(key);
|
|
1115
1548
|
if (!existing) {
|
|
1116
|
-
throw new
|
|
1549
|
+
throw new AuthStorageError2("missing_magic_link", `[Sixb] Magic link '${id}' not found for project '${projectId}'.`);
|
|
1117
1550
|
}
|
|
1118
1551
|
if (existing.tokenHash !== tokenHash || existing.consumedAt || existing.revokedAt) {
|
|
1119
|
-
throw new
|
|
1552
|
+
throw new AuthStorageError2("invalid_magic_link", `[Sixb] Magic link '${id}' is not valid for project '${projectId}'.`);
|
|
1120
1553
|
}
|
|
1121
1554
|
if (existing.expiresAt <= params.consumedAt) {
|
|
1122
|
-
throw new
|
|
1555
|
+
throw new AuthStorageError2("expired_magic_link", `[Sixb] Magic link '${id}' is expired for project '${projectId}'.`);
|
|
1123
1556
|
}
|
|
1124
1557
|
const consumed = {
|
|
1125
1558
|
...existing,
|
|
@@ -1129,19 +1562,19 @@ function consumeMagicLinkRecord(state, params) {
|
|
|
1129
1562
|
return consumed;
|
|
1130
1563
|
}
|
|
1131
1564
|
function consumeOidcAttemptRecord(state, params) {
|
|
1132
|
-
const projectId =
|
|
1133
|
-
const id =
|
|
1134
|
-
const stateHash =
|
|
1565
|
+
const projectId = assertNonEmpty4(params.projectId, "Project id");
|
|
1566
|
+
const id = assertNonEmpty4(params.id, "OIDC authorization attempt id");
|
|
1567
|
+
const stateHash = assertNonEmpty4(params.stateHash, "OIDC state hash");
|
|
1135
1568
|
const key = oidcAttemptKey(projectId, id);
|
|
1136
1569
|
const existing = state.oidcAuthorizationAttempts.get(key);
|
|
1137
1570
|
if (!existing) {
|
|
1138
|
-
throw new
|
|
1571
|
+
throw new AuthStorageError2("missing_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' not found for project '${projectId}'.`);
|
|
1139
1572
|
}
|
|
1140
1573
|
if (existing.stateHash !== stateHash || existing.consumedAt) {
|
|
1141
|
-
throw new
|
|
1574
|
+
throw new AuthStorageError2("invalid_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' is not valid for project '${projectId}'.`);
|
|
1142
1575
|
}
|
|
1143
1576
|
if (existing.expiresAt <= params.consumedAt) {
|
|
1144
|
-
throw new
|
|
1577
|
+
throw new AuthStorageError2("expired_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' is expired for project '${projectId}'.`);
|
|
1145
1578
|
}
|
|
1146
1579
|
const consumed = {
|
|
1147
1580
|
...existing,
|
|
@@ -1186,7 +1619,7 @@ class InMemoryAuthAccessTokenStore {
|
|
|
1186
1619
|
const key = accessTokenKey(params.projectId, params.id);
|
|
1187
1620
|
const existing = this.state.accessTokens.get(key);
|
|
1188
1621
|
if (!existing) {
|
|
1189
|
-
throw new
|
|
1622
|
+
throw new AuthStorageError2("missing_access_token", `[Sixb] Access token '${params.id}' not found for project '${params.projectId}'.`);
|
|
1190
1623
|
}
|
|
1191
1624
|
const next = {
|
|
1192
1625
|
...existing,
|
|
@@ -1199,7 +1632,7 @@ class InMemoryAuthAccessTokenStore {
|
|
|
1199
1632
|
const key = accessTokenKey(params.projectId, params.id);
|
|
1200
1633
|
const existing = this.state.accessTokens.get(key);
|
|
1201
1634
|
if (!existing) {
|
|
1202
|
-
throw new
|
|
1635
|
+
throw new AuthStorageError2("missing_access_token", `[Sixb] Access token '${params.id}' not found for project '${params.projectId}'.`);
|
|
1203
1636
|
}
|
|
1204
1637
|
const next = {
|
|
1205
1638
|
...existing,
|
|
@@ -1213,7 +1646,7 @@ class InMemoryAuthAccessTokenStore {
|
|
|
1213
1646
|
}
|
|
1214
1647
|
|
|
1215
1648
|
// src/storage/auth/types.ts
|
|
1216
|
-
var
|
|
1649
|
+
var MAX_PENDING_DEVICE_AUTHORIZATIONS2 = 100;
|
|
1217
1650
|
|
|
1218
1651
|
// src/storage/auth/in-memory/device-authorizations.ts
|
|
1219
1652
|
class InMemoryAuthDeviceAuthorizationStore {
|
|
@@ -1222,16 +1655,16 @@ class InMemoryAuthDeviceAuthorizationStore {
|
|
|
1222
1655
|
this.state = state;
|
|
1223
1656
|
}
|
|
1224
1657
|
async create(input) {
|
|
1225
|
-
const id =
|
|
1226
|
-
const projectId =
|
|
1227
|
-
for (const [
|
|
1658
|
+
const id = assertNonEmpty4(input.id, "Device authorization id");
|
|
1659
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1660
|
+
for (const [key, authorization] of this.state.deviceAuthorizations) {
|
|
1228
1661
|
if (authorization.projectId === projectId && authorization.expiresAt <= input.createdAt) {
|
|
1229
|
-
this.state.deviceAuthorizations.delete(
|
|
1662
|
+
this.state.deviceAuthorizations.delete(key);
|
|
1230
1663
|
}
|
|
1231
1664
|
}
|
|
1232
1665
|
const pending = [...this.state.deviceAuthorizations.values()].filter((authorization) => authorization.projectId === projectId && authorization.status === "pending").length;
|
|
1233
|
-
if (pending >=
|
|
1234
|
-
throw new
|
|
1666
|
+
if (pending >= MAX_PENDING_DEVICE_AUTHORIZATIONS2) {
|
|
1667
|
+
throw new AuthStorageError2("device_authorization_limit_exceeded", `[Sixb] Project '${projectId}' has too many pending device authorizations.`);
|
|
1235
1668
|
}
|
|
1236
1669
|
const key = deviceAuthorizationKey(projectId, id);
|
|
1237
1670
|
if (this.state.deviceAuthorizations.has(key)) {
|
|
@@ -1240,10 +1673,10 @@ class InMemoryAuthDeviceAuthorizationStore {
|
|
|
1240
1673
|
const record = {
|
|
1241
1674
|
id,
|
|
1242
1675
|
projectId,
|
|
1243
|
-
deviceCodeHash:
|
|
1244
|
-
userCode:
|
|
1245
|
-
clientName:
|
|
1246
|
-
tokenName:
|
|
1676
|
+
deviceCodeHash: assertNonEmpty4(input.deviceCodeHash, "Device code hash"),
|
|
1677
|
+
userCode: assertNonEmpty4(input.userCode, "User code"),
|
|
1678
|
+
clientName: assertNonEmpty4(input.clientName, "Client name"),
|
|
1679
|
+
tokenName: assertNonEmpty4(input.tokenName, "Token name"),
|
|
1247
1680
|
tokenExpiresAt: new Date(input.tokenExpiresAt),
|
|
1248
1681
|
status: "pending",
|
|
1249
1682
|
createdAt: new Date(input.createdAt),
|
|
@@ -1269,13 +1702,13 @@ class InMemoryAuthDeviceAuthorizationStore {
|
|
|
1269
1702
|
const user = this.state.users.get(userKey(params.projectId, params.userId));
|
|
1270
1703
|
const session = this.state.sessions.get(sessionKey(params.projectId, params.sessionId));
|
|
1271
1704
|
if (!user || user.status !== "active" || !session || session.userId !== user.id || !isActiveSession(session, params.approvedAt)) {
|
|
1272
|
-
throw new
|
|
1705
|
+
throw new AuthStorageError2("invalid_device_authorization", "[Sixb] Device authorization requires an active user session.");
|
|
1273
1706
|
}
|
|
1274
1707
|
const next = {
|
|
1275
1708
|
...record,
|
|
1276
1709
|
status: "approved",
|
|
1277
|
-
approvedUserId:
|
|
1278
|
-
approvedSessionId:
|
|
1710
|
+
approvedUserId: assertNonEmpty4(params.userId, "Approved user id"),
|
|
1711
|
+
approvedSessionId: assertNonEmpty4(params.sessionId, "Approved session id"),
|
|
1279
1712
|
approvedAt: new Date(params.approvedAt)
|
|
1280
1713
|
};
|
|
1281
1714
|
this.state.deviceAuthorizations.set(deviceAuthorizationKey(params.projectId, params.id), next);
|
|
@@ -1294,16 +1727,16 @@ class InMemoryAuthDeviceAuthorizationStore {
|
|
|
1294
1727
|
requirePending(projectId, id, now) {
|
|
1295
1728
|
const record = this.state.deviceAuthorizations.get(deviceAuthorizationKey(projectId, id));
|
|
1296
1729
|
if (!record) {
|
|
1297
|
-
throw new
|
|
1730
|
+
throw new AuthStorageError2("missing_device_authorization", `[Sixb] Device authorization '${id}' not found for project '${projectId}'.`);
|
|
1298
1731
|
}
|
|
1299
1732
|
if (record.status !== "pending" || record.expiresAt <= now) {
|
|
1300
|
-
throw new
|
|
1733
|
+
throw new AuthStorageError2("invalid_device_authorization", `[Sixb] Device authorization '${id}' is no longer pending for project '${projectId}'.`);
|
|
1301
1734
|
}
|
|
1302
1735
|
return record;
|
|
1303
1736
|
}
|
|
1304
1737
|
}
|
|
1305
1738
|
function duplicateAuthorization(id, projectId) {
|
|
1306
|
-
return new
|
|
1739
|
+
return new AuthStorageError2("duplicate_device_authorization", `[Sixb] Device authorization '${id}' already exists for project '${projectId}'.`);
|
|
1307
1740
|
}
|
|
1308
1741
|
|
|
1309
1742
|
// src/storage/auth/in-memory/group-memberships.ts
|
|
@@ -1334,10 +1767,10 @@ class InMemoryAuthUserIdentityStore {
|
|
|
1334
1767
|
this.state = state;
|
|
1335
1768
|
}
|
|
1336
1769
|
async upsert(input) {
|
|
1337
|
-
const projectId =
|
|
1338
|
-
const strategyId =
|
|
1339
|
-
const subject =
|
|
1340
|
-
const userId =
|
|
1770
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1771
|
+
const strategyId = assertNonEmpty4(input.strategyId, "Strategy id");
|
|
1772
|
+
const subject = assertNonEmpty4(input.subject, "Subject");
|
|
1773
|
+
const userId = assertNonEmpty4(input.userId, "User id");
|
|
1341
1774
|
const key = identityKey(projectId, strategyId, subject);
|
|
1342
1775
|
const existing = this.state.identities.get(key);
|
|
1343
1776
|
const createdAt = existing?.createdAt ?? dateOrNow(input.createdAt);
|
|
@@ -1387,8 +1820,8 @@ class InMemoryAuthInvitationStore {
|
|
|
1387
1820
|
this.state = state;
|
|
1388
1821
|
}
|
|
1389
1822
|
async createOrUpdateActive(input) {
|
|
1390
|
-
const id =
|
|
1391
|
-
const projectId =
|
|
1823
|
+
const id = assertNonEmpty4(input.id, "Invitation id");
|
|
1824
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1392
1825
|
const email = normalizeEmail(input.email);
|
|
1393
1826
|
const groupIds = normalizeGroupIds(input.groupIds);
|
|
1394
1827
|
const now = dateOrNow(input.updatedAt ?? input.createdAt);
|
|
@@ -1407,7 +1840,7 @@ class InMemoryAuthInvitationStore {
|
|
|
1407
1840
|
}
|
|
1408
1841
|
const key = invitationKey(projectId, id);
|
|
1409
1842
|
if (this.state.invitations.has(key)) {
|
|
1410
|
-
throw new
|
|
1843
|
+
throw new AuthStorageError2("duplicate_invitation", `[Sixb] Invitation '${id}' already exists but is not active for project '${projectId}'.`);
|
|
1411
1844
|
}
|
|
1412
1845
|
const invitation = {
|
|
1413
1846
|
id,
|
|
@@ -1451,7 +1884,7 @@ class InMemoryAuthInvitationStore {
|
|
|
1451
1884
|
const key = invitationKey(params.projectId, params.id);
|
|
1452
1885
|
const existing = this.state.invitations.get(key);
|
|
1453
1886
|
if (!existing) {
|
|
1454
|
-
throw new
|
|
1887
|
+
throw new AuthStorageError2("missing_invitation", `[Sixb] Invitation '${params.id}' not found for project '${params.projectId}'.`);
|
|
1455
1888
|
}
|
|
1456
1889
|
const next = {
|
|
1457
1890
|
...existing,
|
|
@@ -1466,7 +1899,7 @@ class InMemoryAuthInvitationStore {
|
|
|
1466
1899
|
const key = invitationKey(params.projectId, params.id);
|
|
1467
1900
|
const existing = this.state.invitations.get(key);
|
|
1468
1901
|
if (!existing) {
|
|
1469
|
-
throw new
|
|
1902
|
+
throw new AuthStorageError2("missing_invitation", `[Sixb] Invitation '${params.id}' not found for project '${params.projectId}'.`);
|
|
1470
1903
|
}
|
|
1471
1904
|
const next = {
|
|
1472
1905
|
...existing,
|
|
@@ -1486,15 +1919,15 @@ class InMemoryAuthMagicLinkStore {
|
|
|
1486
1919
|
this.state = state;
|
|
1487
1920
|
}
|
|
1488
1921
|
async create(input) {
|
|
1489
|
-
const id =
|
|
1490
|
-
const projectId =
|
|
1491
|
-
const strategyId =
|
|
1492
|
-
const audience =
|
|
1922
|
+
const id = assertNonEmpty4(input.id, "Magic link id");
|
|
1923
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1924
|
+
const strategyId = assertNonEmpty4(input.strategyId, "Strategy id");
|
|
1925
|
+
const audience = resolveAuthSessionAudience2(input.audience);
|
|
1493
1926
|
const email = normalizeEmail(input.email);
|
|
1494
|
-
const tokenHash =
|
|
1927
|
+
const tokenHash = assertNonEmpty4(input.tokenHash, "Magic link token hash");
|
|
1495
1928
|
const key = magicLinkKey(projectId, id);
|
|
1496
1929
|
if (this.state.magicLinks.has(key)) {
|
|
1497
|
-
throw new
|
|
1930
|
+
throw new AuthStorageError2("duplicate_magic_link", `[Sixb] Magic link '${id}' already exists for project '${projectId}'.`);
|
|
1498
1931
|
}
|
|
1499
1932
|
revokeActiveMagicLinksForEmail(this.state, projectId, email, input.createdAt);
|
|
1500
1933
|
const link = {
|
|
@@ -1535,16 +1968,16 @@ class InMemoryAuthOidcAuthorizationAttemptStore {
|
|
|
1535
1968
|
this.state = state;
|
|
1536
1969
|
}
|
|
1537
1970
|
async create(input) {
|
|
1538
|
-
const id =
|
|
1539
|
-
const projectId =
|
|
1540
|
-
const strategyId =
|
|
1541
|
-
const audience =
|
|
1542
|
-
const stateHash =
|
|
1543
|
-
const nonceHash =
|
|
1544
|
-
const codeVerifier =
|
|
1971
|
+
const id = assertNonEmpty4(input.id, "OIDC authorization attempt id");
|
|
1972
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1973
|
+
const strategyId = assertNonEmpty4(input.strategyId, "Strategy id");
|
|
1974
|
+
const audience = resolveAuthSessionAudience2(input.audience);
|
|
1975
|
+
const stateHash = assertNonEmpty4(input.stateHash, "OIDC state hash");
|
|
1976
|
+
const nonceHash = assertNonEmpty4(input.nonceHash, "OIDC nonce hash");
|
|
1977
|
+
const codeVerifier = assertNonEmpty4(input.codeVerifier, "OIDC code verifier");
|
|
1545
1978
|
const key = oidcAttemptKey(projectId, id);
|
|
1546
1979
|
if (this.state.oidcAuthorizationAttempts.has(key)) {
|
|
1547
|
-
throw new
|
|
1980
|
+
throw new AuthStorageError2("duplicate_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' already exists for project '${projectId}'.`);
|
|
1548
1981
|
}
|
|
1549
1982
|
const attempt = {
|
|
1550
1983
|
id,
|
|
@@ -1580,10 +2013,10 @@ class InMemoryAuthServiceAccountGroupMembershipStore {
|
|
|
1580
2013
|
return cloneRecord(upsertServiceAccountGroupMembershipRecord(this.state, input));
|
|
1581
2014
|
}
|
|
1582
2015
|
async reconcileForServiceAccount(input) {
|
|
1583
|
-
const projectId =
|
|
1584
|
-
const serviceAccountId =
|
|
2016
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
2017
|
+
const serviceAccountId = assertNonEmpty4(input.serviceAccountId, "Service account id");
|
|
1585
2018
|
if (!this.state.serviceAccounts.has(serviceAccountKey(projectId, serviceAccountId))) {
|
|
1586
|
-
throw new
|
|
2019
|
+
throw new AuthStorageError2("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${projectId}'.`);
|
|
1587
2020
|
}
|
|
1588
2021
|
const groupIds = normalizeGroupIds(input.groupIds);
|
|
1589
2022
|
const desired = new Set(groupIds);
|
|
@@ -1632,16 +2065,16 @@ class InMemoryAuthServiceAccountStore {
|
|
|
1632
2065
|
return cloneOptionalRecord(record);
|
|
1633
2066
|
}
|
|
1634
2067
|
async update(input) {
|
|
1635
|
-
const projectId =
|
|
1636
|
-
const id =
|
|
2068
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
2069
|
+
const id = assertNonEmpty4(input.id, "Service account id");
|
|
1637
2070
|
const key = serviceAccountKey(projectId, id);
|
|
1638
2071
|
const existing = this.state.serviceAccounts.get(key);
|
|
1639
2072
|
if (!existing) {
|
|
1640
|
-
throw new
|
|
2073
|
+
throw new AuthStorageError2("missing_service_account", `[Sixb] Service account '${id}' not found for project '${projectId}'.`);
|
|
1641
2074
|
}
|
|
1642
2075
|
const next = {
|
|
1643
2076
|
...existing,
|
|
1644
|
-
name: input.name === undefined ? existing.name :
|
|
2077
|
+
name: input.name === undefined ? existing.name : assertNonEmpty4(input.name, "Service account name"),
|
|
1645
2078
|
description: input.description === undefined ? existing.description : input.description,
|
|
1646
2079
|
status: input.status ?? existing.status,
|
|
1647
2080
|
updatedAt: input.updatedAt ? cloneDate(input.updatedAt) : new Date
|
|
@@ -1715,7 +2148,7 @@ class InMemoryAuthSessionStore {
|
|
|
1715
2148
|
const key = sessionKey(params.projectId, params.id);
|
|
1716
2149
|
const existing = this.state.sessions.get(key);
|
|
1717
2150
|
if (!existing) {
|
|
1718
|
-
throw new
|
|
2151
|
+
throw new AuthStorageError2("missing_session", `[Sixb] Session '${params.id}' not found for project '${params.projectId}'.`);
|
|
1719
2152
|
}
|
|
1720
2153
|
const next = {
|
|
1721
2154
|
...existing,
|
|
@@ -1731,7 +2164,7 @@ class InMemoryAuthSessionStore {
|
|
|
1731
2164
|
const key = sessionKey(params.projectId, params.id);
|
|
1732
2165
|
const existing = this.state.sessions.get(key);
|
|
1733
2166
|
if (!existing) {
|
|
1734
|
-
throw new
|
|
2167
|
+
throw new AuthStorageError2("missing_session", `[Sixb] Session '${params.id}' not found for project '${params.projectId}'.`);
|
|
1735
2168
|
}
|
|
1736
2169
|
const next = {
|
|
1737
2170
|
...existing,
|
|
@@ -1749,15 +2182,15 @@ class InMemoryAuthUserStore {
|
|
|
1749
2182
|
this.state = state;
|
|
1750
2183
|
}
|
|
1751
2184
|
async create(input) {
|
|
1752
|
-
const id =
|
|
1753
|
-
const projectId =
|
|
2185
|
+
const id = assertNonEmpty4(input.id, "User id");
|
|
2186
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1754
2187
|
const email = normalizeEmail(input.email);
|
|
1755
2188
|
const key = userKey(projectId, id);
|
|
1756
2189
|
if (this.state.users.has(key)) {
|
|
1757
|
-
throw new
|
|
2190
|
+
throw new AuthStorageError2("duplicate_user", `[Sixb] User '${id}' already exists for project '${projectId}'.`);
|
|
1758
2191
|
}
|
|
1759
2192
|
if (getUserByEmail(this.state, projectId, email)) {
|
|
1760
|
-
throw new
|
|
2193
|
+
throw new AuthStorageError2("duplicate_user", `[Sixb] User email '${email}' already exists for project '${projectId}'.`);
|
|
1761
2194
|
}
|
|
1762
2195
|
const createdAt = dateOrNow(input.createdAt);
|
|
1763
2196
|
const user = {
|
|
@@ -1784,7 +2217,7 @@ class InMemoryAuthUserStore {
|
|
|
1784
2217
|
const key = userKey(input.projectId, input.id);
|
|
1785
2218
|
const existing = this.state.users.get(key);
|
|
1786
2219
|
if (!existing) {
|
|
1787
|
-
throw new
|
|
2220
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${input.id}' not found for project '${input.projectId}'.`);
|
|
1788
2221
|
}
|
|
1789
2222
|
const next = {
|
|
1790
2223
|
...existing,
|
|
@@ -1799,7 +2232,7 @@ class InMemoryAuthUserStore {
|
|
|
1799
2232
|
const key = userKey(input.projectId, input.id);
|
|
1800
2233
|
const existing = this.state.users.get(key);
|
|
1801
2234
|
if (!existing) {
|
|
1802
|
-
throw new
|
|
2235
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${input.id}' not found for project '${input.projectId}'.`);
|
|
1803
2236
|
}
|
|
1804
2237
|
const next = {
|
|
1805
2238
|
...existing,
|
|
@@ -1826,7 +2259,7 @@ class InMemoryAuthUserStore {
|
|
|
1826
2259
|
}
|
|
1827
2260
|
|
|
1828
2261
|
// src/storage/auth/in-memory/auth-storage.ts
|
|
1829
|
-
class
|
|
2262
|
+
class InMemoryAuthStorage2 {
|
|
1830
2263
|
state = createAuthStorageState();
|
|
1831
2264
|
users = new InMemoryAuthUserStore(this.state);
|
|
1832
2265
|
identities = new InMemoryAuthUserIdentityStore(this.state);
|
|
@@ -1871,22 +2304,22 @@ class InMemoryAuthStorage {
|
|
|
1871
2304
|
const key = deviceAuthorizationKey(input.projectId, input.id);
|
|
1872
2305
|
const authorization = this.state.deviceAuthorizations.get(key);
|
|
1873
2306
|
if (!authorization) {
|
|
1874
|
-
throw new
|
|
2307
|
+
throw new AuthStorageError2("missing_device_authorization", `[Sixb] Device authorization '${input.id}' not found for project '${input.projectId}'.`);
|
|
1875
2308
|
}
|
|
1876
2309
|
if (authorization.deviceCodeHash !== input.deviceCodeHash) {
|
|
1877
|
-
throw new
|
|
2310
|
+
throw new AuthStorageError2("invalid_device_authorization", "[Sixb] Invalid device authorization.");
|
|
1878
2311
|
}
|
|
1879
2312
|
if (authorization.status === "pending") {
|
|
1880
|
-
throw new
|
|
2313
|
+
throw new AuthStorageError2("pending_device_authorization", "[Sixb] Device authorization is pending.");
|
|
1881
2314
|
}
|
|
1882
2315
|
if (authorization.status === "denied") {
|
|
1883
|
-
throw new
|
|
2316
|
+
throw new AuthStorageError2("device_authorization_denied", "[Sixb] Device authorization was denied.");
|
|
1884
2317
|
}
|
|
1885
2318
|
if (authorization.status !== "approved" || !authorization.approvedUserId || !authorization.approvedSessionId || authorization.expiresAt <= input.completedAt) {
|
|
1886
|
-
throw new
|
|
2319
|
+
throw new AuthStorageError2("invalid_device_authorization", "[Sixb] Device authorization is invalid.");
|
|
1887
2320
|
}
|
|
1888
2321
|
if (input.accessToken.projectId !== input.projectId || input.accessToken.subjectType !== "user" || input.accessToken.subjectId !== authorization.approvedUserId || input.accessToken.createdBySessionId !== authorization.approvedSessionId) {
|
|
1889
|
-
throw new
|
|
2322
|
+
throw new AuthStorageError2("invalid_device_authorization", "[Sixb] Device access token is invalid.");
|
|
1890
2323
|
}
|
|
1891
2324
|
const accessToken = createAccessTokenRecord(this.state, input.accessToken);
|
|
1892
2325
|
const consumed = {
|
|
@@ -1898,17 +2331,17 @@ class InMemoryAuthStorage {
|
|
|
1898
2331
|
return { authorization: cloneRecord(consumed), accessToken: cloneRecord(accessToken) };
|
|
1899
2332
|
}
|
|
1900
2333
|
async completeMagicLinkSignIn(input) {
|
|
1901
|
-
const projectId =
|
|
2334
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
1902
2335
|
const completedAt = cloneDate(input.completedAt);
|
|
1903
2336
|
const magicLink = this.state.magicLinks.get(magicLinkKey(projectId, input.magicLinkId));
|
|
1904
2337
|
if (!magicLink) {
|
|
1905
|
-
throw new
|
|
2338
|
+
throw new AuthStorageError2("missing_magic_link", `[Sixb] Magic link '${input.magicLinkId}' not found for project '${projectId}'.`);
|
|
1906
2339
|
}
|
|
1907
2340
|
if (magicLink.tokenHash !== input.tokenHash || magicLink.consumedAt || magicLink.revokedAt) {
|
|
1908
|
-
throw new
|
|
2341
|
+
throw new AuthStorageError2("invalid_magic_link", `[Sixb] Magic link '${input.magicLinkId}' is not valid for project '${projectId}'.`);
|
|
1909
2342
|
}
|
|
1910
2343
|
if (magicLink.expiresAt <= completedAt) {
|
|
1911
|
-
throw new
|
|
2344
|
+
throw new AuthStorageError2("expired_magic_link", `[Sixb] Magic link '${input.magicLinkId}' is expired for project '${projectId}'.`);
|
|
1912
2345
|
}
|
|
1913
2346
|
const existingUser = getUserByEmail(this.state, projectId, magicLink.email);
|
|
1914
2347
|
const activeInvitation = getActiveInvitationByEmail(this.state, projectId, magicLink.email, completedAt);
|
|
@@ -1921,7 +2354,7 @@ class InMemoryAuthStorage {
|
|
|
1921
2354
|
tokenHash: input.tokenHash,
|
|
1922
2355
|
consumedAt: completedAt
|
|
1923
2356
|
});
|
|
1924
|
-
throw new
|
|
2357
|
+
throw new AuthStorageError2("suspended_user", `[Sixb] User '${existingUser.id}' is suspended for project '${projectId}'.`);
|
|
1925
2358
|
}
|
|
1926
2359
|
if (shouldCreateUser && !activeInvitation && !input.allowUserCreationWithoutInvitation) {
|
|
1927
2360
|
consumeMagicLinkRecord(this.state, {
|
|
@@ -1930,7 +2363,7 @@ class InMemoryAuthStorage {
|
|
|
1930
2363
|
tokenHash: input.tokenHash,
|
|
1931
2364
|
consumedAt: completedAt
|
|
1932
2365
|
});
|
|
1933
|
-
throw new
|
|
2366
|
+
throw new AuthStorageError2("user_creation_not_allowed", `[Sixb] Magic link '${input.magicLinkId}' cannot create a user for project '${projectId}'.`);
|
|
1934
2367
|
}
|
|
1935
2368
|
if (shouldCreateUser && !activeInvitation && input.allowUserCreationWithoutInvitation && input.requireNoActiveUsersForUserCreation && hasActiveUsers(this.state, projectId)) {
|
|
1936
2369
|
consumeMagicLinkRecord(this.state, {
|
|
@@ -1939,15 +2372,15 @@ class InMemoryAuthStorage {
|
|
|
1939
2372
|
tokenHash: input.tokenHash,
|
|
1940
2373
|
consumedAt: completedAt
|
|
1941
2374
|
});
|
|
1942
|
-
throw new
|
|
2375
|
+
throw new AuthStorageError2("user_creation_not_allowed", `[Sixb] Magic link '${input.magicLinkId}' cannot create a user for project '${projectId}'.`);
|
|
1943
2376
|
}
|
|
1944
2377
|
validateCompleteSessionInput(this.state, projectId, input.session);
|
|
1945
2378
|
assertSignInSessionAudience(projectId, input.session.audience, magicLink.audience);
|
|
1946
2379
|
let newUserId;
|
|
1947
2380
|
if (shouldCreateUser) {
|
|
1948
|
-
newUserId =
|
|
2381
|
+
newUserId = assertNonEmpty4(input.newUserId, "User id");
|
|
1949
2382
|
if (this.state.users.has(userKey(projectId, newUserId))) {
|
|
1950
|
-
throw new
|
|
2383
|
+
throw new AuthStorageError2("duplicate_user", `[Sixb] User '${newUserId}' already exists for project '${projectId}'.`);
|
|
1951
2384
|
}
|
|
1952
2385
|
}
|
|
1953
2386
|
consumeMagicLinkRecord(this.state, {
|
|
@@ -1959,7 +2392,7 @@ class InMemoryAuthStorage {
|
|
|
1959
2392
|
let user = existingUser;
|
|
1960
2393
|
if (!user) {
|
|
1961
2394
|
user = {
|
|
1962
|
-
id: newUserId ??
|
|
2395
|
+
id: newUserId ?? assertNonEmpty4(input.newUserId, "User id"),
|
|
1963
2396
|
projectId,
|
|
1964
2397
|
email: magicLink.email,
|
|
1965
2398
|
displayName: input.newUserDisplayName,
|
|
@@ -1997,19 +2430,19 @@ class InMemoryAuthStorage {
|
|
|
1997
2430
|
};
|
|
1998
2431
|
}
|
|
1999
2432
|
async completeOidcSignIn(input) {
|
|
2000
|
-
const projectId =
|
|
2433
|
+
const projectId = assertNonEmpty4(input.projectId, "Project id");
|
|
2001
2434
|
const completedAt = cloneDate(input.completedAt);
|
|
2002
2435
|
const attempt = this.state.oidcAuthorizationAttempts.get(oidcAttemptKey(projectId, input.oidcAuthorizationAttemptId));
|
|
2003
2436
|
if (!attempt) {
|
|
2004
|
-
throw new
|
|
2437
|
+
throw new AuthStorageError2("missing_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' not found for project '${projectId}'.`);
|
|
2005
2438
|
}
|
|
2006
2439
|
if (attempt.stateHash !== input.stateHash || attempt.consumedAt) {
|
|
2007
|
-
throw new
|
|
2440
|
+
throw new AuthStorageError2("invalid_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' is not valid for project '${projectId}'.`);
|
|
2008
2441
|
}
|
|
2009
2442
|
if (attempt.expiresAt <= completedAt) {
|
|
2010
|
-
throw new
|
|
2443
|
+
throw new AuthStorageError2("expired_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' is expired for project '${projectId}'.`);
|
|
2011
2444
|
}
|
|
2012
|
-
const subject =
|
|
2445
|
+
const subject = assertNonEmpty4(input.subject, "Subject");
|
|
2013
2446
|
const email = normalizeEmail(input.email);
|
|
2014
2447
|
const claims = normalizeClaims(input.claims);
|
|
2015
2448
|
const identity = this.state.identities.get(identityKey(projectId, attempt.strategyId, subject));
|
|
@@ -2019,41 +2452,41 @@ class InMemoryAuthStorage {
|
|
|
2019
2452
|
const manualGroupIds = normalizeGroupIds(input.manualGroupIds);
|
|
2020
2453
|
if (identity && !user) {
|
|
2021
2454
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2022
|
-
throw new
|
|
2455
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${identity.userId}' not found for linked OIDC identity.`);
|
|
2023
2456
|
}
|
|
2024
2457
|
if (!identity && user && (!input.autoLinkByVerifiedEmail || !input.emailVerified)) {
|
|
2025
2458
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2026
|
-
throw new
|
|
2459
|
+
throw new AuthStorageError2("email_link_not_allowed", `[Sixb] OIDC identity cannot auto-link to user '${user.id}' for project '${projectId}'.`);
|
|
2027
2460
|
}
|
|
2028
2461
|
if (user?.status === "suspended") {
|
|
2029
2462
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2030
|
-
throw new
|
|
2463
|
+
throw new AuthStorageError2("suspended_user", `[Sixb] User '${user.id}' is suspended for project '${projectId}'.`);
|
|
2031
2464
|
}
|
|
2032
2465
|
if (shouldCreateUser && !input.emailVerified) {
|
|
2033
2466
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2034
|
-
throw new
|
|
2467
|
+
throw new AuthStorageError2("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
|
|
2035
2468
|
}
|
|
2036
2469
|
if (shouldCreateUser && !activeInvitation && !input.allowUserCreationWithoutInvitation) {
|
|
2037
2470
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2038
|
-
throw new
|
|
2471
|
+
throw new AuthStorageError2("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
|
|
2039
2472
|
}
|
|
2040
2473
|
if (shouldCreateUser && !activeInvitation && input.allowUserCreationWithoutInvitation && input.requireNoActiveUsersForUserCreation && hasActiveUsers(this.state, projectId)) {
|
|
2041
2474
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2042
|
-
throw new
|
|
2475
|
+
throw new AuthStorageError2("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
|
|
2043
2476
|
}
|
|
2044
2477
|
validateCompleteSessionInput(this.state, projectId, input.session);
|
|
2045
2478
|
assertSignInSessionAudience(projectId, input.session.audience, attempt.audience);
|
|
2046
2479
|
let newUserId;
|
|
2047
2480
|
if (shouldCreateUser) {
|
|
2048
|
-
newUserId =
|
|
2481
|
+
newUserId = assertNonEmpty4(input.newUserId, "User id");
|
|
2049
2482
|
if (this.state.users.has(userKey(projectId, newUserId))) {
|
|
2050
|
-
throw new
|
|
2483
|
+
throw new AuthStorageError2("duplicate_user", `[Sixb] User '${newUserId}' already exists for project '${projectId}'.`);
|
|
2051
2484
|
}
|
|
2052
2485
|
}
|
|
2053
2486
|
this.consumeOidcAttempt(input, completedAt, projectId);
|
|
2054
2487
|
if (!user) {
|
|
2055
2488
|
user = {
|
|
2056
|
-
id: newUserId ??
|
|
2489
|
+
id: newUserId ?? assertNonEmpty4(input.newUserId, "User id"),
|
|
2057
2490
|
projectId,
|
|
2058
2491
|
email,
|
|
2059
2492
|
displayName: input.displayName,
|
|
@@ -2105,7 +2538,7 @@ class InMemoryAuthStorage {
|
|
|
2105
2538
|
const key = userKey(input.projectId, input.userId);
|
|
2106
2539
|
const existing = this.state.users.get(key);
|
|
2107
2540
|
if (!existing) {
|
|
2108
|
-
throw new
|
|
2541
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${input.userId}' not found for project '${input.projectId}'.`);
|
|
2109
2542
|
}
|
|
2110
2543
|
const next = {
|
|
2111
2544
|
...existing,
|
|
@@ -2191,7 +2624,7 @@ function assertSignInSessionAudience(projectId, sessionAudience, storedAudience)
|
|
|
2191
2624
|
if (sessionAudience === storedAudience) {
|
|
2192
2625
|
return;
|
|
2193
2626
|
}
|
|
2194
|
-
throw new
|
|
2627
|
+
throw new AuthStorageError2("invalid_input", `[Sixb] Sign-in session audience '${sessionAudience}' does not match stored auth audience '${storedAudience}' for project '${projectId}'.`);
|
|
2195
2628
|
}
|
|
2196
2629
|
// src/auth/session-cache.ts
|
|
2197
2630
|
class SessionCache {
|
|
@@ -2249,19 +2682,19 @@ class SessionCache {
|
|
|
2249
2682
|
|
|
2250
2683
|
// src/auth/sessions.ts
|
|
2251
2684
|
import { createHash as createHash2, randomBytes as randomBytes3, randomUUID as randomUUID2 } from "crypto";
|
|
2252
|
-
function
|
|
2685
|
+
function generateSessionSecret2() {
|
|
2253
2686
|
return randomBytes3(32).toString("base64url");
|
|
2254
2687
|
}
|
|
2255
|
-
function
|
|
2688
|
+
function hashSessionSecret2(secret) {
|
|
2256
2689
|
return createHash2("sha256").update(secret).digest("hex");
|
|
2257
2690
|
}
|
|
2258
|
-
function
|
|
2691
|
+
function formatSessionCookieValue2(sessionId, sessionSecret) {
|
|
2259
2692
|
if (!sessionId || !sessionSecret || sessionId.includes(".") || sessionSecret.includes(".")) {
|
|
2260
2693
|
throw new Error("[Sixb] Session cookie values must be non-empty and must not contain '.'.");
|
|
2261
2694
|
}
|
|
2262
2695
|
return `${sessionId}.${sessionSecret}`;
|
|
2263
2696
|
}
|
|
2264
|
-
function
|
|
2697
|
+
function parseSessionCookieValue2(value) {
|
|
2265
2698
|
if (!value) {
|
|
2266
2699
|
return null;
|
|
2267
2700
|
}
|
|
@@ -2274,13 +2707,13 @@ function parseSessionCookieValue(value) {
|
|
|
2274
2707
|
sessionSecret: value.slice(firstDot + 1)
|
|
2275
2708
|
};
|
|
2276
2709
|
}
|
|
2277
|
-
function
|
|
2278
|
-
const sessionSecret =
|
|
2710
|
+
function createSessionCredential2(sessionId = `ses_${randomUUID2()}`) {
|
|
2711
|
+
const sessionSecret = generateSessionSecret2();
|
|
2279
2712
|
return {
|
|
2280
2713
|
sessionId,
|
|
2281
2714
|
sessionSecret,
|
|
2282
|
-
tokenHash:
|
|
2283
|
-
cookieValue:
|
|
2715
|
+
tokenHash: hashSessionSecret2(sessionSecret),
|
|
2716
|
+
cookieValue: formatSessionCookieValue2(sessionId, sessionSecret)
|
|
2284
2717
|
};
|
|
2285
2718
|
}
|
|
2286
2719
|
|
|
@@ -2288,7 +2721,7 @@ function createSessionCredential(sessionId = `ses_${randomUUID2()}`) {
|
|
|
2288
2721
|
var SESSION_TOUCH_INTERVAL_MS = 60000;
|
|
2289
2722
|
var ACCESS_TOKEN_TOUCH_INTERVAL_MS = 60000;
|
|
2290
2723
|
|
|
2291
|
-
class
|
|
2724
|
+
class AuthRuntime2 {
|
|
2292
2725
|
projectId;
|
|
2293
2726
|
storage;
|
|
2294
2727
|
security;
|
|
@@ -2298,10 +2731,10 @@ class AuthRuntime {
|
|
|
2298
2731
|
this.projectId = options.projectId;
|
|
2299
2732
|
this.storage = options.storage;
|
|
2300
2733
|
this.security = options.security;
|
|
2301
|
-
this.config =
|
|
2734
|
+
this.config = resolveAuthConfig2(options.config);
|
|
2302
2735
|
this.sessionCache = this.config.session.cacheTtlMs > 0 ? new SessionCache(this.config.session.cacheTtlMs) : null;
|
|
2303
2736
|
if (this.isEnabled() && !this.storage.auth) {
|
|
2304
|
-
throw new
|
|
2737
|
+
throw new AuthRuntimeError2("auth_storage_missing", "[Sixb] Auth is enabled but storage.auth is not configured.");
|
|
2305
2738
|
}
|
|
2306
2739
|
}
|
|
2307
2740
|
isEnabled() {
|
|
@@ -2325,26 +2758,26 @@ class AuthRuntime {
|
|
|
2325
2758
|
const strategy = this.config.strategy;
|
|
2326
2759
|
if (!strategy) {
|
|
2327
2760
|
if (params.production) {
|
|
2328
|
-
throw new
|
|
2761
|
+
throw new AuthRuntimeError2("production_auth_required", "[SixbServer] Auth is required in production. Configure auth or use an explicit disabled auth strategy.");
|
|
2329
2762
|
}
|
|
2330
2763
|
return;
|
|
2331
2764
|
}
|
|
2332
2765
|
if (params.production && strategy.developmentOnly) {
|
|
2333
|
-
throw new
|
|
2766
|
+
throw new AuthRuntimeError2("production_auth_required", `[SixbServer] Auth strategy '${strategy.id}' is development-only and cannot be used in production.`);
|
|
2334
2767
|
}
|
|
2335
2768
|
if (params.production && (strategy.kind === "disabled" || strategy.disabled === true) && strategy.allowDisabledInProduction !== true) {
|
|
2336
|
-
throw new
|
|
2769
|
+
throw new AuthRuntimeError2("production_auth_required", "[SixbServer] Disabled auth in production requires allowDisabledInProduction: true.");
|
|
2337
2770
|
}
|
|
2338
2771
|
}
|
|
2339
2772
|
async getSession(request, options = {}) {
|
|
2340
2773
|
if (!this.isEnabled()) {
|
|
2341
2774
|
return { authenticated: false, reason: "auth_disabled" };
|
|
2342
2775
|
}
|
|
2343
|
-
const audience =
|
|
2776
|
+
const audience = resolveAuthSessionAudience2(options.audience);
|
|
2344
2777
|
const credentialSource = options.credentialSource ?? "session";
|
|
2345
2778
|
if (credentialSource !== "session") {
|
|
2346
2779
|
const authorizationHeader = request.headers.get("authorization");
|
|
2347
|
-
const tokenValue =
|
|
2780
|
+
const tokenValue = getBearerAccessTokenValue2(request);
|
|
2348
2781
|
if (tokenValue) {
|
|
2349
2782
|
return this.resolveAccessTokenSession(request, tokenValue);
|
|
2350
2783
|
}
|
|
@@ -2359,15 +2792,15 @@ class AuthRuntime {
|
|
|
2359
2792
|
}
|
|
2360
2793
|
async resolveCookieSession(request, audience, activity) {
|
|
2361
2794
|
const cookieOptions = this.getCookieOptions({ audience });
|
|
2362
|
-
const cookieValue =
|
|
2795
|
+
const cookieValue = getCookie2(request, cookieOptions.sessionCookieName);
|
|
2363
2796
|
if (!cookieValue) {
|
|
2364
2797
|
return { authenticated: false, reason: "missing_cookie" };
|
|
2365
2798
|
}
|
|
2366
|
-
const parts =
|
|
2799
|
+
const parts = parseSessionCookieValue2(cookieValue);
|
|
2367
2800
|
if (!parts) {
|
|
2368
2801
|
return { authenticated: false, reason: "invalid_cookie" };
|
|
2369
2802
|
}
|
|
2370
|
-
const tokenHash =
|
|
2803
|
+
const tokenHash = hashSessionSecret2(parts.sessionSecret);
|
|
2371
2804
|
const nowMs = Date.now();
|
|
2372
2805
|
const cached = this.sessionCache?.get({
|
|
2373
2806
|
sessionId: parts.sessionId,
|
|
@@ -2457,7 +2890,7 @@ class AuthRuntime {
|
|
|
2457
2890
|
return new Date(session.absoluteExpiresAt ? Math.min(idleExpiresAtMs, session.absoluteExpiresAt.getTime()) : idleExpiresAtMs);
|
|
2458
2891
|
}
|
|
2459
2892
|
async resolveAccessTokenSession(request, tokenValue) {
|
|
2460
|
-
const parts =
|
|
2893
|
+
const parts = parseAccessTokenValue2(tokenValue);
|
|
2461
2894
|
if (!parts) {
|
|
2462
2895
|
return { authenticated: false, reason: "invalid_access_token" };
|
|
2463
2896
|
}
|
|
@@ -2467,7 +2900,7 @@ class AuthRuntime {
|
|
|
2467
2900
|
projectId: this.projectId,
|
|
2468
2901
|
id: parts.tokenId,
|
|
2469
2902
|
kind: parts.kind,
|
|
2470
|
-
tokenHash:
|
|
2903
|
+
tokenHash: hashAccessTokenSecret2(parts.tokenSecret),
|
|
2471
2904
|
now
|
|
2472
2905
|
});
|
|
2473
2906
|
if (!accessToken) {
|
|
@@ -2485,7 +2918,7 @@ class AuthRuntime {
|
|
|
2485
2918
|
if (user.status === "suspended") {
|
|
2486
2919
|
return { authenticated: false, reason: "suspended_user" };
|
|
2487
2920
|
}
|
|
2488
|
-
const
|
|
2921
|
+
const memberships = await storage.groupMemberships.listForUser({
|
|
2489
2922
|
projectId: this.projectId,
|
|
2490
2923
|
userId: user.id
|
|
2491
2924
|
});
|
|
@@ -2495,7 +2928,7 @@ class AuthRuntime {
|
|
|
2495
2928
|
principal: { type: "user", id: user.id },
|
|
2496
2929
|
user,
|
|
2497
2930
|
accessToken,
|
|
2498
|
-
groupIds: constrainTokenGroupIds(
|
|
2931
|
+
groupIds: constrainTokenGroupIds(memberships.map((membership) => membership.groupId), accessToken)
|
|
2499
2932
|
};
|
|
2500
2933
|
}
|
|
2501
2934
|
const serviceAccount = await storage.serviceAccounts.getById({
|
|
@@ -2551,24 +2984,24 @@ class AuthRuntime {
|
|
|
2551
2984
|
async requirePrincipal(request, options = {}) {
|
|
2552
2985
|
const session = await this.getSession(request, options);
|
|
2553
2986
|
if (!session.authenticated) {
|
|
2554
|
-
throw new
|
|
2987
|
+
throw new AuthRuntimeError2("authentication_required", "[Sixb] Authentication is required.");
|
|
2555
2988
|
}
|
|
2556
2989
|
return session.principal;
|
|
2557
2990
|
}
|
|
2558
2991
|
async requireUser(request, options = {}) {
|
|
2559
2992
|
const session = await this.getSession(request, { ...options, credentialSource: "session" });
|
|
2560
2993
|
if (!session.authenticated) {
|
|
2561
|
-
throw new
|
|
2994
|
+
throw new AuthRuntimeError2("authentication_required", "[Sixb] Authentication is required.");
|
|
2562
2995
|
}
|
|
2563
2996
|
return session;
|
|
2564
2997
|
}
|
|
2565
2998
|
async requireUserRequest(request, options = {}) {
|
|
2566
2999
|
const session = await this.getSession(request, { ...options, credentialSource: "any" });
|
|
2567
3000
|
if (!session.authenticated) {
|
|
2568
|
-
throw new
|
|
3001
|
+
throw new AuthRuntimeError2("authentication_required", "[Sixb] Authentication is required.");
|
|
2569
3002
|
}
|
|
2570
3003
|
if (!isAuthenticatedUserRequestSession(session)) {
|
|
2571
|
-
throw new
|
|
3004
|
+
throw new AuthRuntimeError2("authorization_denied", "[Sixb] User authentication is required.");
|
|
2572
3005
|
}
|
|
2573
3006
|
return session;
|
|
2574
3007
|
}
|
|
@@ -2584,12 +3017,12 @@ class AuthRuntime {
|
|
|
2584
3017
|
async createAuthorizationContext(request, options = {}) {
|
|
2585
3018
|
const session = await this.getSession(request, options);
|
|
2586
3019
|
if (!session.authenticated) {
|
|
2587
|
-
throw new
|
|
3020
|
+
throw new AuthRuntimeError2("authentication_required", "[Sixb] Authentication is required.");
|
|
2588
3021
|
}
|
|
2589
3022
|
return this.contextFromSession(session);
|
|
2590
3023
|
}
|
|
2591
3024
|
contextFromSession(session) {
|
|
2592
|
-
return
|
|
3025
|
+
return resolveAuthorizationContext2({
|
|
2593
3026
|
principal: session.principal,
|
|
2594
3027
|
sessionId: session.credentialSource === "session" ? session.session.id : undefined,
|
|
2595
3028
|
groupIds: session.groupIds,
|
|
@@ -2616,7 +3049,7 @@ class AuthRuntime {
|
|
|
2616
3049
|
const groupIds = constrainRequestedGroupIds(input.groupIds, session.groupIds, {
|
|
2617
3050
|
subject: "personal access token"
|
|
2618
3051
|
});
|
|
2619
|
-
const credential =
|
|
3052
|
+
const credential = createAccessTokenCredential2("personal");
|
|
2620
3053
|
const accessToken = await storage.accessTokens.create({
|
|
2621
3054
|
id: credential.tokenId,
|
|
2622
3055
|
projectId: this.projectId,
|
|
@@ -2727,12 +3160,12 @@ class AuthRuntime {
|
|
|
2727
3160
|
const storage = this.requireAuthStorage();
|
|
2728
3161
|
const { serviceAccount, groupIds: serviceAccountGroupIds } = await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId);
|
|
2729
3162
|
if (serviceAccount.status === "suspended") {
|
|
2730
|
-
throw new
|
|
3163
|
+
throw new AuthStorageError2("suspended_service_account", `[Sixb] Service account '${input.serviceAccountId}' is suspended for project '${this.projectId}'.`);
|
|
2731
3164
|
}
|
|
2732
3165
|
const groupIds = constrainRequestedGroupIds(input.groupIds, serviceAccountGroupIds, {
|
|
2733
3166
|
subject: "service account token"
|
|
2734
3167
|
});
|
|
2735
|
-
const credential =
|
|
3168
|
+
const credential = createAccessTokenCredential2("serviceAccount");
|
|
2736
3169
|
const accessToken = await storage.accessTokens.create({
|
|
2737
3170
|
id: credential.tokenId,
|
|
2738
3171
|
projectId: this.projectId,
|
|
@@ -2774,7 +3207,7 @@ class AuthRuntime {
|
|
|
2774
3207
|
});
|
|
2775
3208
|
const groupIds = serviceAccount ? await this.listServiceAccountGroupIds(storage, serviceAccountId) : [];
|
|
2776
3209
|
if (!serviceAccount || !callerCanManageServiceAccount(callerGroupIds, groupIds)) {
|
|
2777
|
-
throw new
|
|
3210
|
+
throw new AuthStorageError2("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${this.projectId}'.`);
|
|
2778
3211
|
}
|
|
2779
3212
|
return { serviceAccount, groupIds };
|
|
2780
3213
|
}
|
|
@@ -2844,19 +3277,19 @@ class AuthRuntime {
|
|
|
2844
3277
|
const session = await this.requireUser(request, options);
|
|
2845
3278
|
const storage = this.requireAuthStorage();
|
|
2846
3279
|
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
|
|
2847
|
-
const userId =
|
|
3280
|
+
const userId = assertNonEmpty3(input.userId, "User id");
|
|
2848
3281
|
const { user, groupIds: currentGroupIds } = await this.requireManageableMember(storage, scope, "assignGroups", userId);
|
|
2849
3282
|
const requestedGroupIds = this.resolveMemberGroupIds(input.groupIds);
|
|
2850
3283
|
const missing = missingMembershipGroupIds(scope, "assignGroups", requestedGroupIds);
|
|
2851
3284
|
if (missing.length > 0) {
|
|
2852
|
-
throw new
|
|
3285
|
+
throw new AuthRuntimeError2("authorization_denied", `[Sixb] The current user is not allowed to assign group(s): ${missing.join(", ")}.`);
|
|
2853
3286
|
}
|
|
2854
3287
|
const current = new Set(currentGroupIds);
|
|
2855
3288
|
const requested = new Set(requestedGroupIds);
|
|
2856
3289
|
const additions = requestedGroupIds.filter((groupId) => !current.has(groupId));
|
|
2857
3290
|
const removals = currentGroupIds.filter((groupId) => !requested.has(groupId));
|
|
2858
3291
|
if (user.id === session.user.id && removals.length > 0) {
|
|
2859
|
-
throw new
|
|
3292
|
+
throw new AuthRuntimeError2("authorization_denied", "[Sixb] The current user cannot remove their own groups.");
|
|
2860
3293
|
}
|
|
2861
3294
|
const now = new Date;
|
|
2862
3295
|
for (const groupId of additions) {
|
|
@@ -2883,10 +3316,10 @@ class AuthRuntime {
|
|
|
2883
3316
|
const session = await this.requireUser(request, options);
|
|
2884
3317
|
const storage = this.requireAuthStorage();
|
|
2885
3318
|
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
|
|
2886
|
-
const userId =
|
|
3319
|
+
const userId = assertNonEmpty3(input.userId, "User id");
|
|
2887
3320
|
const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId);
|
|
2888
3321
|
if (user.id === session.user.id) {
|
|
2889
|
-
throw new
|
|
3322
|
+
throw new AuthRuntimeError2("authorization_denied", "[Sixb] The current user cannot suspend themselves.");
|
|
2890
3323
|
}
|
|
2891
3324
|
const suspended = await storage.suspendUserAndRevokeSessions({
|
|
2892
3325
|
projectId: this.projectId,
|
|
@@ -2900,7 +3333,7 @@ class AuthRuntime {
|
|
|
2900
3333
|
const session = await this.requireUser(request, options);
|
|
2901
3334
|
const storage = this.requireAuthStorage();
|
|
2902
3335
|
const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
|
|
2903
|
-
const userId =
|
|
3336
|
+
const userId = assertNonEmpty3(input.userId, "User id");
|
|
2904
3337
|
const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId);
|
|
2905
3338
|
const reactivated = await storage.users.updateStatus({
|
|
2906
3339
|
projectId: this.projectId,
|
|
@@ -2924,15 +3357,15 @@ class AuthRuntime {
|
|
|
2924
3357
|
const user = await storage.users.getById({ projectId: this.projectId, id: userId });
|
|
2925
3358
|
const groupIds = user ? (await storage.groupMemberships.listForUser({ projectId: this.projectId, userId })).map((membership) => membership.groupId) : [];
|
|
2926
3359
|
if (!user || !canPerformMembershipOperation(scope, operation, groupIds)) {
|
|
2927
|
-
throw new
|
|
3360
|
+
throw new AuthStorageError2("missing_user", `[Sixb] User '${userId}' not found for project '${this.projectId}'.`);
|
|
2928
3361
|
}
|
|
2929
3362
|
return { user, groupIds };
|
|
2930
3363
|
}
|
|
2931
3364
|
resolveMemberGroupIds(input) {
|
|
2932
|
-
const groupIds = [...new Set(input.map((groupId) =>
|
|
3365
|
+
const groupIds = [...new Set(input.map((groupId) => assertNonEmpty3(groupId, "Group id")))];
|
|
2933
3366
|
for (const groupId of groupIds) {
|
|
2934
3367
|
if (!this.security.getGroupById(groupId)) {
|
|
2935
|
-
throw new
|
|
3368
|
+
throw new AuthRuntimeError2("invalid_auth_input", `[Sixb] Unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
2936
3369
|
}
|
|
2937
3370
|
}
|
|
2938
3371
|
return groupIds;
|
|
@@ -2944,11 +3377,11 @@ class AuthRuntime {
|
|
|
2944
3377
|
const groupIds = this.resolveInviteGroupIds(input);
|
|
2945
3378
|
this.assertCanManageInvitationGroups(session.groupIds, groupIds);
|
|
2946
3379
|
const strategy = this.getStrategy();
|
|
2947
|
-
if (!
|
|
2948
|
-
throw new
|
|
3380
|
+
if (!isInvitationDeliveryAuthStrategy2(strategy)) {
|
|
3381
|
+
throw new AuthRuntimeError2("invalid_auth_config", "[Sixb] The active auth strategy does not support invitations.");
|
|
2949
3382
|
}
|
|
2950
3383
|
await this.assertCanInviteRecipient(strategy, authStorage, input.email, now);
|
|
2951
|
-
const deliveryAudience =
|
|
3384
|
+
const deliveryAudience = resolveAuthSessionAudience2(options.delivery?.audience ?? options.audience);
|
|
2952
3385
|
this.assertInvitationApplicationAccess(groupIds, deliveryAudience);
|
|
2953
3386
|
const invitation = await authStorage.invitations.createOrUpdateActive({
|
|
2954
3387
|
id: `inv_${randomUUID3()}`,
|
|
@@ -3012,17 +3445,17 @@ class AuthRuntime {
|
|
|
3012
3445
|
async revokeInvitation(request, input, options = {}) {
|
|
3013
3446
|
const session = await this.requireUser(request, options);
|
|
3014
3447
|
const authStorage = this.requireAuthStorage();
|
|
3015
|
-
const invitationId =
|
|
3448
|
+
const invitationId = assertNonEmpty3(input.invitationId, "Invitation id");
|
|
3016
3449
|
const invitation = await authStorage.invitations.getById({
|
|
3017
3450
|
projectId: this.projectId,
|
|
3018
3451
|
id: invitationId
|
|
3019
3452
|
});
|
|
3020
3453
|
if (!invitation) {
|
|
3021
|
-
throw new
|
|
3454
|
+
throw new AuthStorageError2("missing_invitation", `[Sixb] Invitation '${invitationId}' not found for project '${this.projectId}'.`);
|
|
3022
3455
|
}
|
|
3023
3456
|
this.assertCanManageInvitationGroups(session.groupIds, invitation.groupIds);
|
|
3024
3457
|
if (invitation.status !== "pending") {
|
|
3025
|
-
throw new
|
|
3458
|
+
throw new AuthRuntimeError2("invalid_auth_input", `[Sixb] Invitation '${invitationId}' is already ${invitation.status} and cannot be revoked.`);
|
|
3026
3459
|
}
|
|
3027
3460
|
return {
|
|
3028
3461
|
invitation: await authStorage.invitations.revoke({
|
|
@@ -3034,19 +3467,19 @@ class AuthRuntime {
|
|
|
3034
3467
|
}
|
|
3035
3468
|
requireAuthStorage() {
|
|
3036
3469
|
if (!this.storage.auth) {
|
|
3037
|
-
throw new
|
|
3470
|
+
throw new AuthRuntimeError2("auth_storage_missing", "[Sixb] Auth is enabled but storage.auth is not configured.");
|
|
3038
3471
|
}
|
|
3039
3472
|
return this.storage.auth;
|
|
3040
3473
|
}
|
|
3041
3474
|
resolveInviteGroupIds(input) {
|
|
3042
3475
|
if (input.groups && input.groupIds) {
|
|
3043
|
-
throw new
|
|
3476
|
+
throw new AuthRuntimeError2("invalid_auth_input", "[Sixb] Invitation input cannot provide both groups and groupIds.");
|
|
3044
3477
|
}
|
|
3045
|
-
const rawGroupIds = input.groupIds ?? input.groups?.map((group) =>
|
|
3046
|
-
const groupIds = [...new Set(rawGroupIds.map((groupId) =>
|
|
3478
|
+
const rawGroupIds = input.groupIds ?? input.groups?.map((group) => assertNonEmpty3(group.id, "Group id")) ?? [];
|
|
3479
|
+
const groupIds = [...new Set(rawGroupIds.map((groupId) => assertNonEmpty3(groupId, "Group id")))];
|
|
3047
3480
|
for (const groupId of groupIds) {
|
|
3048
3481
|
if (!this.security.getGroupById(groupId)) {
|
|
3049
|
-
throw new
|
|
3482
|
+
throw new AuthRuntimeError2("invalid_auth_input", `[Sixb] Unknown invitation group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
3050
3483
|
}
|
|
3051
3484
|
}
|
|
3052
3485
|
return groupIds;
|
|
@@ -3058,7 +3491,7 @@ class AuthRuntime {
|
|
|
3058
3491
|
});
|
|
3059
3492
|
}
|
|
3060
3493
|
resolveCreateInvitationCapability(input) {
|
|
3061
|
-
if (!
|
|
3494
|
+
if (!isInvitationDeliveryAuthStrategy2(this.getStrategy())) {
|
|
3062
3495
|
return { state: "disabled", reason: "invitation_delivery_not_supported" };
|
|
3063
3496
|
}
|
|
3064
3497
|
if (!input.canInvite) {
|
|
@@ -3068,14 +3501,14 @@ class AuthRuntime {
|
|
|
3068
3501
|
}
|
|
3069
3502
|
assertInvitationApplicationAccess(groupIds, audience) {
|
|
3070
3503
|
const roles = this.security.listResolvedRoles();
|
|
3071
|
-
const authorization =
|
|
3504
|
+
const authorization = resolveAuthorizationContext2({
|
|
3072
3505
|
principal: { type: "user", id: "invited-user" },
|
|
3073
3506
|
groupIds,
|
|
3074
3507
|
roles
|
|
3075
3508
|
});
|
|
3076
|
-
if (
|
|
3509
|
+
if (canAccessApplication2(authorization, roles, audience))
|
|
3077
3510
|
return;
|
|
3078
|
-
throw new
|
|
3511
|
+
throw new AuthRuntimeError2("authorization_denied", `[Sixb] Invitation groups do not grant access to application '${audience}'.`);
|
|
3079
3512
|
}
|
|
3080
3513
|
async assertCanInviteRecipient(strategy, authStorage, email, now) {
|
|
3081
3514
|
if (!strategy.validateInvitationRecipient) {
|
|
@@ -3101,9 +3534,9 @@ class AuthRuntime {
|
|
|
3101
3534
|
}
|
|
3102
3535
|
createInvitationDeliveryError(status) {
|
|
3103
3536
|
if (status === "rate_limited") {
|
|
3104
|
-
return new
|
|
3537
|
+
return new AuthRuntimeError2("rate_limited", "[Sixb] Invitation delivery is rate limited. Try again later.");
|
|
3105
3538
|
}
|
|
3106
|
-
return new
|
|
3539
|
+
return new AuthRuntimeError2("invalid_auth_input", "[Sixb] Invitation delivery was skipped by the active auth strategy.");
|
|
3107
3540
|
}
|
|
3108
3541
|
assertCanManageInvitationGroups(callerGroupIds, groupIds) {
|
|
3109
3542
|
const scope = this.resolveMembershipPolicyScopeForUser(callerGroupIds);
|
|
@@ -3111,10 +3544,10 @@ class AuthRuntime {
|
|
|
3111
3544
|
return;
|
|
3112
3545
|
}
|
|
3113
3546
|
if (groupIds.length === 0) {
|
|
3114
|
-
throw new
|
|
3547
|
+
throw new AuthRuntimeError2("authorization_denied", "[Sixb] The current user is not allowed to create or manage invitations without groups.");
|
|
3115
3548
|
}
|
|
3116
3549
|
const missing = missingMembershipGroupIds(scope, "invite", groupIds);
|
|
3117
|
-
throw new
|
|
3550
|
+
throw new AuthRuntimeError2("authorization_denied", `[Sixb] The current user is not allowed to create or manage invitations for group(s): ${missing.join(", ")}.`);
|
|
3118
3551
|
}
|
|
3119
3552
|
}
|
|
3120
3553
|
function resolveCorrelationId(request) {
|
|
@@ -3138,7 +3571,7 @@ function callerCanManageServiceAccount(callerGroupIds, serviceAccountGroupIds) {
|
|
|
3138
3571
|
return serviceAccountGroupIds.every((groupId) => callerGroups.has(groupId));
|
|
3139
3572
|
}
|
|
3140
3573
|
function missingAccessTokenError(tokenId, projectId) {
|
|
3141
|
-
return new
|
|
3574
|
+
return new AuthStorageError2("missing_access_token", `[Sixb] Access token '${tokenId}' not found for project '${projectId}'.`);
|
|
3142
3575
|
}
|
|
3143
3576
|
function constrainRequestedGroupIds(input, allowedGroupIds, options) {
|
|
3144
3577
|
const groupIds = normalizeRequestedGroupIds(input);
|
|
@@ -3148,7 +3581,7 @@ function constrainRequestedGroupIds(input, allowedGroupIds, options) {
|
|
|
3148
3581
|
const allowed = new Set(allowedGroupIds);
|
|
3149
3582
|
for (const groupId of groupIds) {
|
|
3150
3583
|
if (!allowed.has(groupId)) {
|
|
3151
|
-
throw new
|
|
3584
|
+
throw new AuthRuntimeError2("authorization_denied", `[Sixb] Group '${groupId}' cannot be assigned to this ${options.subject}.`);
|
|
3152
3585
|
}
|
|
3153
3586
|
}
|
|
3154
3587
|
return groupIds;
|
|
@@ -3161,7 +3594,7 @@ function normalizeRequestedGroupIds(input) {
|
|
|
3161
3594
|
for (const raw of input) {
|
|
3162
3595
|
const groupId = raw.trim();
|
|
3163
3596
|
if (!groupId) {
|
|
3164
|
-
throw new
|
|
3597
|
+
throw new AuthRuntimeError2("invalid_auth_input", "[Sixb] Group ids cannot be empty when creating auth credentials.");
|
|
3165
3598
|
}
|
|
3166
3599
|
if (!groupIds.includes(groupId)) {
|
|
3167
3600
|
groupIds.push(groupId);
|
|
@@ -3171,15 +3604,15 @@ function normalizeRequestedGroupIds(input) {
|
|
|
3171
3604
|
}
|
|
3172
3605
|
function createInvitationRecipientError(status, email) {
|
|
3173
3606
|
if (status === "rate_limited") {
|
|
3174
|
-
return new
|
|
3607
|
+
return new AuthRuntimeError2("rate_limited", "[Sixb] Invitation delivery is rate limited. Try again later.");
|
|
3175
3608
|
}
|
|
3176
3609
|
if (status === "invalid_email") {
|
|
3177
|
-
return new
|
|
3610
|
+
return new AuthRuntimeError2("invalid_auth_input", "[Sixb] Invitation email is invalid.");
|
|
3178
3611
|
}
|
|
3179
3612
|
if (status === "disallowed_domain") {
|
|
3180
|
-
return new
|
|
3613
|
+
return new AuthRuntimeError2("invalid_auth_input", `[Sixb] Invitation email '${email}' is not allowed by the active auth strategy.`);
|
|
3181
3614
|
}
|
|
3182
|
-
return new
|
|
3615
|
+
return new AuthRuntimeError2("invalid_auth_input", `[Sixb] Invitation email '${email}' belongs to a suspended user.`);
|
|
3183
3616
|
}
|
|
3184
3617
|
function membershipCapabilities(scope) {
|
|
3185
3618
|
return {
|
|
@@ -3196,10 +3629,10 @@ function groupIdsOf(groups) {
|
|
|
3196
3629
|
return groups.map((group) => typeof group === "string" ? group : group.id);
|
|
3197
3630
|
}
|
|
3198
3631
|
// src/auth/types.ts
|
|
3199
|
-
var
|
|
3200
|
-
function
|
|
3632
|
+
var SYSTEM_PRINCIPAL2 = { type: "system", id: "system" };
|
|
3633
|
+
function principalsEqual2(left, right) {
|
|
3201
3634
|
return left.type === right.type && left.id === right.id;
|
|
3202
3635
|
}
|
|
3203
|
-
export {
|
|
3636
|
+
export { ActionDefinitionError2, ActionEditCommitError2, missingActionMutationMessage, effectsWithoutEditsMessage, assertNonEmpty2, isActionDefinition2, isGlobalActionDefinition2, isObjectActionDefinition2, normalizeActionParams, coerceActionParamsToTyped2, validateActionSubject, resolveObjectActionSubject, PERSONAL_ACCESS_TOKEN_PREFIX2, SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX2, generateAccessTokenSecret2, hashAccessTokenSecret2, formatAccessTokenValue2, parseAccessTokenValue2, getBearerAccessTokenValue2, createAccessTokenCredential2, CSRF_HEADER_NAME2, generateCsrfToken2, isCsrfExemptMethod2, verifyDoubleSubmitCsrf2, applications2, SecurityValidationError2, isGroupDefinition, isMembershipPolicyDefinition, isRoleDefinition, defineGroup2, defineRole2, defineMembershipPolicy2, every2, ShareDefinitionError2, defineShare2, isShareDefinition, snapshotShareDefinition, can2, SecurityRegistry, AuthStorageError2, MAX_PENDING_DEVICE_AUTHORIZATIONS2, paginate, InMemoryAuthStorage2, generateSessionSecret2, hashSessionSecret2, formatSessionCookieValue2, parseSessionCookieValue2, createSessionCredential2, AuthRuntime2, SYSTEM_PRINCIPAL2, principalsEqual2 };
|
|
3204
3637
|
|
|
3205
|
-
//# debugId=
|
|
3638
|
+
//# debugId=4470AA67E3AEAE5264756E2164756E21
|