@selvajs/selva 4.21.0-beta.11 → 4.21.0-beta.13
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/build/adapter-node.js +2 -2
- package/build/client/_app/immutable/assets/0.DOeHn583.css +2 -0
- package/build/client/_app/immutable/assets/0.DOeHn583.css.br +0 -0
- package/build/client/_app/immutable/assets/0.DOeHn583.css.gz +0 -0
- package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm +0 -0
- package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm.br +0 -0
- package/build/client/_app/immutable/assets/rhino3dm.CWOyICcB.wasm.gz +0 -0
- package/build/client/_app/immutable/chunks/2rFska3d.js +1 -0
- package/build/client/_app/immutable/chunks/2rFska3d.js.br +1 -0
- package/build/client/_app/immutable/chunks/2rFska3d.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{B3BHv1lE.js → 5M5n6ftO.js} +59 -58
- package/build/client/_app/immutable/chunks/5M5n6ftO.js.br +0 -0
- package/build/client/_app/immutable/chunks/5M5n6ftO.js.gz +0 -0
- package/build/client/_app/immutable/chunks/71J-lVIC.js +7 -0
- package/build/client/_app/immutable/chunks/71J-lVIC.js.br +0 -0
- package/build/client/_app/immutable/chunks/71J-lVIC.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{Dqy8nTaG.js → BCbumNc2.js} +1 -1
- package/build/client/_app/immutable/chunks/BCbumNc2.js.br +0 -0
- package/build/client/_app/immutable/chunks/BCbumNc2.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BEzPIk5e.js +1 -0
- package/build/client/_app/immutable/chunks/BEzPIk5e.js.br +0 -0
- package/build/client/_app/immutable/chunks/BEzPIk5e.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B_4x1b7P.js +1 -0
- package/build/client/_app/immutable/chunks/B_4x1b7P.js.br +0 -0
- package/build/client/_app/immutable/chunks/B_4x1b7P.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{BAhtiTKe.js → Bs2bQTgl.js} +1 -1
- package/build/client/_app/immutable/chunks/Bs2bQTgl.js.br +0 -0
- package/build/client/_app/immutable/chunks/Bs2bQTgl.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{cUJB_11K.js → CzHxHvr2.js} +1 -1
- package/build/client/_app/immutable/chunks/CzHxHvr2.js.br +0 -0
- package/build/client/_app/immutable/chunks/CzHxHvr2.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Db9exncB.js +1 -0
- package/build/client/_app/immutable/chunks/Db9exncB.js.br +0 -0
- package/build/client/_app/immutable/chunks/Db9exncB.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{BEPlNI5E.js → FIoX_cjM.js} +1 -1
- package/build/client/_app/immutable/chunks/FIoX_cjM.js.br +0 -0
- package/build/client/_app/immutable/chunks/FIoX_cjM.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{CmlXAF26.js → aBYenH6-.js} +1 -1
- package/build/client/_app/immutable/chunks/aBYenH6-.js.br +0 -0
- package/build/client/_app/immutable/chunks/aBYenH6-.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.B3im90t6.js → app.BP5swwM7.js} +2 -2
- package/build/client/_app/immutable/entry/app.BP5swwM7.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BP5swwM7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.DWd6YbcT.js → 1.DmBjtFLw.js} +1 -1
- package/build/client/_app/immutable/nodes/1.DmBjtFLw.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.DmBjtFLw.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.bCPP2ncY.js → 2.CWOFnTAV.js} +1 -1
- package/build/client/_app/immutable/nodes/2.CWOFnTAV.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CWOFnTAV.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.DI5Eri_M.js → 20.4vwwwrQ_.js} +1 -1
- package/build/client/_app/immutable/nodes/20.4vwwwrQ_.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.4vwwwrQ_.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.C1xtue6U.js +1 -0
- package/build/client/_app/immutable/nodes/21.C1xtue6U.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.C1xtue6U.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{25.BRm8FzmQ.js → 25.DR2ojPn5.js} +22 -22
- package/build/client/_app/immutable/nodes/25.DR2ojPn5.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.DR2ojPn5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{3.Ctd9OGCk.js → 3.GtVSkcEP.js} +1 -1
- package/build/client/_app/immutable/nodes/{3.Ctd9OGCk.js.br → 3.GtVSkcEP.js.br} +0 -0
- package/build/client/_app/immutable/nodes/3.GtVSkcEP.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{30.B6pd-F-z.js → 30.Cd56Qv6o.js} +5 -6
- package/build/client/_app/immutable/nodes/30.Cd56Qv6o.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.Cd56Qv6o.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{5.BUX4zZQj.js → 5.wbpOzblK.js} +1 -1
- package/build/client/_app/immutable/nodes/5.wbpOzblK.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.wbpOzblK.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.BpjtFwPi.js → 6.B2HdJrZB.js} +1 -1
- package/build/client/_app/immutable/nodes/6.B2HdJrZB.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.B2HdJrZB.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{7.hBM6C-wN.js → 7.BuWU0YDv.js} +1 -1
- package/build/client/_app/immutable/nodes/7.BuWU0YDv.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.BuWU0YDv.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/runtime-meta.json +1 -1
- package/build/server/.vite/manifest.json +145 -137
- package/build/server/_app/immutable/assets/_layout.DOeHn583.css +2 -0
- package/build/server/_app/immutable/assets/rhino3dm.CWOyICcB.wasm +0 -0
- package/build/server/chunks/access.js +63 -48
- package/build/server/chunks/access.js.map +1 -1
- package/build/server/chunks/access2.server.js +1 -1
- package/build/server/chunks/api-errors.js +3 -3
- package/build/server/chunks/api.js +1 -1
- package/build/server/chunks/boot.server.js +1 -1
- package/build/server/chunks/bootHealth.server.js +1 -1
- package/build/server/chunks/create-project.js +1 -1
- package/build/server/chunks/delete-with-blobs.js +1 -1
- package/build/server/chunks/{schema-extraction.js → errors.js} +31 -24
- package/build/server/chunks/errors.js.map +1 -0
- package/build/server/chunks/grasshopper.js +17 -10
- package/build/server/chunks/grasshopper.js.map +1 -1
- package/build/server/chunks/handlers.js +82 -75
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/http.js +1 -1
- package/build/server/chunks/http2.js +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/instanceAdmins.server.js +2 -2
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/{keepalive-vtcjhAV3.js → keepalive-DbmLH4v1.js} +5 -4
- package/build/server/chunks/keepalive-DbmLH4v1.js.map +1 -0
- package/build/server/chunks/limits.js +1 -1
- package/build/server/chunks/liveSolve.server.js +1 -1
- package/build/server/chunks/localeContext.svelte.js +74 -0
- package/build/server/chunks/localeContext.svelte.js.map +1 -1
- package/build/server/chunks/{visibility.js → logging.js} +262 -3
- package/build/server/chunks/logging.js.map +1 -0
- package/build/server/chunks/openapi.js +1 -1
- package/build/server/chunks/ops.js +64 -1
- package/build/server/chunks/ops.js.map +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/presets.server.js +1 -1
- package/build/server/chunks/providers.server.js +448 -317
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/remote-definition.js +1 -1
- package/build/server/chunks/resolve-server.js +1 -1
- package/build/server/chunks/rhino3dm.js +5 -0
- package/build/server/chunks/rhino3dm.js.map +1 -0
- package/build/server/chunks/safe-url.js +2 -2
- package/build/server/chunks/schema.js +1 -1
- package/build/server/chunks/schema.js.map +1 -1
- package/build/server/chunks/selfUpdate.server.js +1 -1
- package/build/server/chunks/server-config-write.js +1 -1
- package/build/server/chunks/server2.js +5 -1
- package/build/server/chunks/server2.js.map +1 -1
- package/build/server/chunks/solve.server.js +5 -4
- package/build/server/chunks/solve.server.js.map +1 -1
- package/build/server/chunks/sveltekit.js +2 -2
- package/build/server/chunks/tokens.js +2 -2
- package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/system/throughput/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/diag/throughput/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +2 -3
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +3 -3
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/changes/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/inventory/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/scripts/_scriptId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/check/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/compute/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/resend/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/solve/_solveId_/cancel/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/solve-events/_solveId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +1 -1
- package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +1 -1
- package/build/server/entries/endpoints/auth/supabase/start/_server.ts.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +14 -8
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/hooks.server.js +37 -3
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/accept-invite/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/organizations/_page.server.ts.js +4 -9
- package/build/server/entries/pages/admin/organizations/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/docs/api/_page.server.ts.js +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +8 -7
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +9874 -3725
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/library/_page.server.ts.js +1 -2
- package/build/server/entries/pages/library/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +2 -2
- package/build/server/entries/pages/projects/_page.server.ts.js +2 -2
- package/build/server/entries/pages/projects/_page.svelte.js +10 -4
- package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/setup/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/team/members/_page.server.ts.js +4 -2
- package/build/server/entries/pages/team/members/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/team/members/_page.svelte.js +6 -5
- package/build/server/entries/pages/team/members/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/projects/_page.server.ts.js +5 -12
- package/build/server/entries/pages/team/projects/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/team/reclaim/_page.server.ts.js +6 -13
- package/build/server/entries/pages/team/reclaim/_page.server.ts.js.map +1 -1
- package/build/server/manifest-full.js +1 -1
- package/build/server/manifest.js +1 -1
- package/build/server/nodes/0.js +2 -2
- package/build/server/nodes/1.js +1 -1
- package/build/server/nodes/2.js +1 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/21.js +1 -1
- package/build/server/nodes/25.js +1 -1
- package/build/server/nodes/3.js +1 -1
- package/build/server/nodes/30.js +1 -1
- package/build/server/nodes/5.js +1 -1
- package/build/server/nodes/6.js +1 -1
- package/build/server/nodes/7.js +1 -1
- package/build/server/server.js +1 -1
- package/package.json +13 -13
- package/templates/.env.example +18 -1
- package/build/client/_app/immutable/assets/0.DJ150bSr.css +0 -2
- package/build/client/_app/immutable/assets/0.DJ150bSr.css.br +0 -0
- package/build/client/_app/immutable/assets/0.DJ150bSr.css.gz +0 -0
- package/build/client/_app/immutable/chunks/B3BHv1lE.js.br +0 -0
- package/build/client/_app/immutable/chunks/B3BHv1lE.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BAhtiTKe.js.br +0 -0
- package/build/client/_app/immutable/chunks/BAhtiTKe.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BEPlNI5E.js.br +0 -0
- package/build/client/_app/immutable/chunks/BEPlNI5E.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CmlXAF26.js.br +0 -0
- package/build/client/_app/immutable/chunks/CmlXAF26.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DQbsDiDJ.js +0 -1
- package/build/client/_app/immutable/chunks/DQbsDiDJ.js.br +0 -1
- package/build/client/_app/immutable/chunks/DQbsDiDJ.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DW5EJMC7.js +0 -1
- package/build/client/_app/immutable/chunks/DW5EJMC7.js.br +0 -0
- package/build/client/_app/immutable/chunks/DW5EJMC7.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dqy8nTaG.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dqy8nTaG.js.gz +0 -0
- package/build/client/_app/immutable/chunks/cUJB_11K.js.br +0 -0
- package/build/client/_app/immutable/chunks/cUJB_11K.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.B3im90t6.js.br +0 -0
- package/build/client/_app/immutable/entry/app.B3im90t6.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.bCPP2ncY.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.bCPP2ncY.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.DI5Eri_M.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.DI5Eri_M.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.BI8SjY_r.js +0 -1
- package/build/client/_app/immutable/nodes/21.BI8SjY_r.js.br +0 -1
- package/build/client/_app/immutable/nodes/21.BI8SjY_r.js.gz +0 -0
- package/build/client/_app/immutable/nodes/25.BRm8FzmQ.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.BRm8FzmQ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.gz +0 -0
- package/build/client/_app/immutable/nodes/30.B6pd-F-z.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.B6pd-F-z.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.BUX4zZQj.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.BUX4zZQj.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BpjtFwPi.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BpjtFwPi.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.hBM6C-wN.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.hBM6C-wN.js.gz +0 -0
- package/build/server/_app/immutable/assets/_layout.DJ150bSr.css +0 -2
- package/build/server/chunks/definitions.js +0 -263
- package/build/server/chunks/definitions.js.map +0 -1
- package/build/server/chunks/keepalive-vtcjhAV3.js.map +0 -1
- package/build/server/chunks/schema-extraction.js.map +0 -1
- package/build/server/chunks/visibility.js.map +0 -1
- /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js → 0.CXQcjMDK.js} +0 -0
- /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js.br → 0.CXQcjMDK.js.br} +0 -0
- /package/build/client/_app/immutable/nodes/{0.Bu9WQ0W_.js.gz → 0.CXQcjMDK.js.gz} +0 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { n as env, t as previousKey } from "./previous-key.js";
|
|
2
|
-
import { B as
|
|
2
|
+
import { B as isFlagEnabled, I as ENGINE_SETTINGS, V as NoopLogger, at as trimTrailing, it as parseKey32, nt as resolveConfig, ot as composeManifest, rt as rawValue, st as defineSetting, tt as readSetting } from "./access.js";
|
|
3
3
|
import { i as ProviderError, n as assertNotShareContext, r as hasPermission, t as SYSTEM_CONTEXT } from "./context.js";
|
|
4
4
|
import { f as scopeConfigToOrg, h as isPlatformServer, m as isOrgServer, o as summarizeInventory } from "./inventory.js";
|
|
5
5
|
import { a as toSourceDocumentId, i as UUID_REGEX } from "./schemas.js";
|
|
6
6
|
import { i as DEFAULT_ORG_PERMISSIONS, t as ALL_ORG_ASSET_KINDS } from "./schemas2.js";
|
|
7
7
|
import { t as ALL_PLATFORM_PERMISSIONS } from "./types3.js";
|
|
8
|
-
import {
|
|
8
|
+
import { a as createLogger, g as encodeOffsetCursor, h as decodeOffsetCursor, i as ConsoleLogger, m as clampPageLimit, n as renderThrown } from "./logging.js";
|
|
9
9
|
import { n as readBool } from "./limits.js";
|
|
10
|
-
import { a as createLogger, i as ConsoleLogger, n as renderThrown } from "./definitions.js";
|
|
11
|
-
import { c as stableStringify, d as ErrorCodes, g as isDefinitionRef, h as enableDebugLogging, i as TreeBuilder, l as withSolveMode, n as GrasshopperClient, u as ComputeError } from "./grasshopper.js";
|
|
12
10
|
import { n as getInputItems } from "./traversal.js";
|
|
13
|
-
import { i as
|
|
11
|
+
import { c as stableStringify, d as ErrorCodes, g as isDefinitionRef, h as enableDebugLogging, i as TreeBuilder, l as withSolveMode, n as GrasshopperClient, u as ComputeError } from "./grasshopper.js";
|
|
12
|
+
import { i as serverSourcedInputIds, n as KEEPALIVE_PREFERENCE, r as raceAbort, t as KEEPALIVE_INTERVAL_MS } from "./keepalive-DbmLH4v1.js";
|
|
14
13
|
import { createRequire } from "node:module";
|
|
15
14
|
import * as crypto from "node:crypto";
|
|
16
15
|
import { createCipheriv, createDecipheriv, createHash, createHmac, createPrivateKey, randomBytes, randomUUID, sign, timingSafeEqual } from "node:crypto";
|
|
17
|
-
import { gzip } from "node:zlib";
|
|
18
16
|
import { pathToFileURL } from "node:url";
|
|
19
17
|
import * as path$1 from "node:path";
|
|
20
18
|
import { resolve } from "node:path";
|
|
@@ -22,6 +20,7 @@ import { existsSync } from "node:fs";
|
|
|
22
20
|
import * as fs$1 from "node:fs/promises";
|
|
23
21
|
import { createClient } from "@supabase/supabase-js";
|
|
24
22
|
import { promisify } from "node:util";
|
|
23
|
+
import { gzip } from "node:zlib";
|
|
25
24
|
// \0rolldown/runtime.js
|
|
26
25
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
27
26
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
@@ -562,281 +561,6 @@ function auditSoftDelete(ctx, fallbackActor) {
|
|
|
562
561
|
var NoopSolveMetricSink = class {
|
|
563
562
|
async record(_ctx, _metric) {}
|
|
564
563
|
};
|
|
565
|
-
// ../platform/src/computeServer/secrets.ts
|
|
566
|
-
var ALGO = "aes-256-gcm";
|
|
567
|
-
var IV_BYTES = 12;
|
|
568
|
-
var TAG_BYTES = 16;
|
|
569
|
-
var PREFIX_V1 = "enc:v1:";
|
|
570
|
-
var PREFIX_V2 = "enc:v2:";
|
|
571
|
-
var PREFIX_V3 = "enc:v3:";
|
|
572
|
-
var PREFIX_LENGTH = 7;
|
|
573
|
-
function isEncryptedSecret(value) {
|
|
574
|
-
return isLegacyEnvelope(value) || value.startsWith(PREFIX_V3);
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* An `enc:v1:` or `enc:v2:` envelope: sealed without a {@link SecretBinding}, so it
|
|
578
|
-
* still opens after its record's URL changes. Stores re-seal these.
|
|
579
|
-
*/
|
|
580
|
-
function isLegacyEnvelope(value) {
|
|
581
|
-
return value.startsWith(PREFIX_V1) || value.startsWith(PREFIX_V2);
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* An `enc:v<n>:` envelope this build cannot open: a newer Selva sealed it, and this
|
|
585
|
-
* one runs after a downgrade. It is ciphertext, so it must never be reported or
|
|
586
|
-
* used as a plaintext key.
|
|
587
|
-
*/
|
|
588
|
-
function isUnknownEnvelope(value) {
|
|
589
|
-
return /^enc:v\d+:/.test(value) && !isEncryptedSecret(value);
|
|
590
|
-
}
|
|
591
|
-
function bindingAad({ id, url }) {
|
|
592
|
-
return Buffer.from(JSON.stringify([id, url]), "utf8");
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* AES-256-GCM envelope for at-rest secrets (e.g. compute API keys):
|
|
596
|
-
* `enc:v<n>:<base64(iv|tag|ciphertext)>`. What `aad` is picks the version, and
|
|
597
|
-
* the version says what GCM authenticates besides the ciphertext:
|
|
598
|
-
* - a {@link SecretBinding} gives `v3`: the record's id and URL. Ciphertext copied
|
|
599
|
-
* onto another record, or a record pointed at another host, fails to decrypt
|
|
600
|
-
* instead of handing the plaintext to that host.
|
|
601
|
-
* - a string gives `v2`: that string, which stores set to the record's id.
|
|
602
|
-
* - nothing gives `v1`: nothing.
|
|
603
|
-
*
|
|
604
|
-
* Defends against backup leaks, accidental file/DB sharing, and read-only
|
|
605
|
-
* storage access — not against an attacker who also has the master key
|
|
606
|
-
* (`SELVA_AT_REST_KEY` env var, process memory). This is encryption at rest,
|
|
607
|
-
* not a secret manager.
|
|
608
|
-
*
|
|
609
|
-
* Pure `node:crypto`, no fs or DB coupling, so the local and Supabase
|
|
610
|
-
* compute-server stores share this one implementation.
|
|
611
|
-
*/
|
|
612
|
-
function encryptSecret(plaintext, key, aad) {
|
|
613
|
-
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
614
|
-
if (isEncryptedSecret(plaintext)) throw new Error("Refusing to encrypt a value that is already encrypted");
|
|
615
|
-
const [prefix, aadBytes] = aad === void 0 ? [PREFIX_V1, void 0] : typeof aad === "string" ? [PREFIX_V2, Buffer.from(aad, "utf8")] : [PREFIX_V3, bindingAad(aad)];
|
|
616
|
-
const iv = randomBytes(IV_BYTES);
|
|
617
|
-
const cipher = createCipheriv(ALGO, key, iv);
|
|
618
|
-
if (aadBytes) cipher.setAAD(aadBytes);
|
|
619
|
-
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
620
|
-
const tag = cipher.getAuthTag();
|
|
621
|
-
return prefix + Buffer.concat([
|
|
622
|
-
iv,
|
|
623
|
-
tag,
|
|
624
|
-
ciphertext
|
|
625
|
-
]).toString("base64");
|
|
626
|
-
}
|
|
627
|
-
function aadToOpen(envelope, aad) {
|
|
628
|
-
if (envelope.startsWith(PREFIX_V1)) return void 0;
|
|
629
|
-
if (envelope.startsWith(PREFIX_V2)) {
|
|
630
|
-
if (aad === void 0) throw new Error("This secret is bound to a record: pass its id");
|
|
631
|
-
return Buffer.from(typeof aad === "string" ? aad : aad.id, "utf8");
|
|
632
|
-
}
|
|
633
|
-
if (aad === void 0 || typeof aad === "string") throw new Error("This secret is bound to a record and its URL: pass both");
|
|
634
|
-
return bindingAad(aad);
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* `aad` is ignored for `v1`. `v2` takes the string it was sealed with, or a
|
|
638
|
-
* binding's `id`; `v3` needs the binding.
|
|
639
|
-
*/
|
|
640
|
-
function decryptSecret(envelope, key, aad) {
|
|
641
|
-
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
642
|
-
if (!isEncryptedSecret(envelope)) throw new Error("Value is not an encrypted secret envelope");
|
|
643
|
-
const aadBytes = aadToOpen(envelope, aad);
|
|
644
|
-
const buf = Buffer.from(envelope.slice(PREFIX_LENGTH), "base64");
|
|
645
|
-
if (buf.length < 28) throw new Error("Encrypted secret is shorter than its IV and tag");
|
|
646
|
-
const iv = buf.subarray(0, IV_BYTES);
|
|
647
|
-
const tag = buf.subarray(IV_BYTES, 28);
|
|
648
|
-
const ciphertext = buf.subarray(28);
|
|
649
|
-
const decipher = createDecipheriv(ALGO, key, iv, { authTagLength: TAG_BYTES });
|
|
650
|
-
decipher.setAuthTag(tag);
|
|
651
|
-
if (aadBytes) decipher.setAAD(aadBytes);
|
|
652
|
-
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
653
|
-
}
|
|
654
|
-
var GENERATE_HINT = "Generate one with: node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"";
|
|
655
|
-
/**
|
|
656
|
-
* Decodes a `SELVA_AT_REST_KEY` env var into a 32-byte buffer (64-char hex or
|
|
657
|
-
* base64, with or without padding). Throws on anything else so a
|
|
658
|
-
* misconfigured key fails loudly at boot instead of silently producing
|
|
659
|
-
* ciphertext nothing can decrypt.
|
|
660
|
-
*/
|
|
661
|
-
function decodeSecretKey(raw) {
|
|
662
|
-
const key = parseKey32(raw);
|
|
663
|
-
if (key) return key;
|
|
664
|
-
throw new Error(`SELVA_AT_REST_KEY must be 32 bytes encoded as 64-char hex or base64. ${GENERATE_HINT}`);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* `SELVA_AT_REST_KEY`, plus `SELVA_AT_REST_KEY_PREVIOUS` while it is within its
|
|
668
|
-
* deadline. Throws when the current key is missing or malformed.
|
|
669
|
-
*/
|
|
670
|
-
function readAtRestKeys(env) {
|
|
671
|
-
if (!env.SELVA_AT_REST_KEY) throw new Error(`Missing required env var: SELVA_AT_REST_KEY (32-byte hex or base64). ${GENERATE_HINT}`);
|
|
672
|
-
const current = decodeSecretKey(env.SELVA_AT_REST_KEY);
|
|
673
|
-
const previous = previousKey(env, "SELVA_AT_REST_KEY").key;
|
|
674
|
-
return previous ? {
|
|
675
|
-
current,
|
|
676
|
-
previous: decodeSecretKey(previous)
|
|
677
|
-
} : { current };
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* {@link decryptSecret} under each key in turn, current first. AES-GCM
|
|
681
|
-
* authenticates, so a wrong key fails rather than returning garbage, and trying
|
|
682
|
-
* the next one is safe. `keyIndex` above 0 means the caller should re-encrypt
|
|
683
|
-
* under `keys[0]`.
|
|
684
|
-
*/
|
|
685
|
-
function decryptWithKeys(envelope, keys, aad) {
|
|
686
|
-
let lastError;
|
|
687
|
-
for (const [keyIndex, key] of keys.entries()) try {
|
|
688
|
-
return {
|
|
689
|
-
plaintext: decryptSecret(envelope, key, aad),
|
|
690
|
-
keyIndex
|
|
691
|
-
};
|
|
692
|
-
} catch (err) {
|
|
693
|
-
lastError = err;
|
|
694
|
-
}
|
|
695
|
-
throw lastError ?? /* @__PURE__ */ new Error("No key to decrypt with");
|
|
696
|
-
}
|
|
697
|
-
// ../server/src/definitions/definition-service.ts
|
|
698
|
-
var inventoryFields = (inventory) => inventory ? {
|
|
699
|
-
inventory,
|
|
700
|
-
inventorySummary: summarizeInventory(inventory)
|
|
701
|
-
} : {};
|
|
702
|
-
/**
|
|
703
|
-
* Orchestrates writes spanning IDataProvider + IStorageProvider. Application
|
|
704
|
-
* orchestration, not platform contract — hence not in @selvajs/platform.
|
|
705
|
-
*
|
|
706
|
-
* Methods that write both metadata and blobs order the two so a mid-flight
|
|
707
|
-
* failure leaves a state the API can still serve; those reasons sit inline at
|
|
708
|
-
* each write. `publish` and `updateMeta` flip pointers/metadata only and touch
|
|
709
|
-
* storage not at all.
|
|
710
|
-
*/
|
|
711
|
-
var DefinitionService = class {
|
|
712
|
-
data;
|
|
713
|
-
storage;
|
|
714
|
-
constructor(data, storage) {
|
|
715
|
-
this.data = data;
|
|
716
|
-
this.storage = storage;
|
|
717
|
-
}
|
|
718
|
-
async create(ctx, input, file, schema, inventory) {
|
|
719
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
720
|
-
const actor = ctx.userId || input.ownerId;
|
|
721
|
-
const record = {
|
|
722
|
-
guid: input.guid,
|
|
723
|
-
projectId: input.projectId,
|
|
724
|
-
ownerId: input.ownerId,
|
|
725
|
-
createdBy: actor,
|
|
726
|
-
updatedBy: actor,
|
|
727
|
-
displayName: input.displayName,
|
|
728
|
-
description: input.description,
|
|
729
|
-
category: input.category,
|
|
730
|
-
tags: input.tags,
|
|
731
|
-
coverImage: input.coverImage,
|
|
732
|
-
computeServerId: input.computeServerId,
|
|
733
|
-
status: "pending",
|
|
734
|
-
solveCount: 0,
|
|
735
|
-
nextVersionNumber: 2,
|
|
736
|
-
liveVersionId: null,
|
|
737
|
-
draftVersionId: null,
|
|
738
|
-
sourceDocumentId: toSourceDocumentId(schema.documentId) ?? void 0,
|
|
739
|
-
createdAt: now,
|
|
740
|
-
updatedAt: now,
|
|
741
|
-
deletedAt: null
|
|
742
|
-
};
|
|
743
|
-
await this.data.definitions.create(ctx, record);
|
|
744
|
-
const versionId = randomUUID();
|
|
745
|
-
const fileKey = definitionPaths.version(input.guid, 1, input.fileExt);
|
|
746
|
-
await this.storage.put(fileKey, file, "application/octet-stream");
|
|
747
|
-
const version = {
|
|
748
|
-
id: versionId,
|
|
749
|
-
definitionId: input.guid,
|
|
750
|
-
versionNumber: 1,
|
|
751
|
-
fileExt: input.fileExt,
|
|
752
|
-
fileKey,
|
|
753
|
-
originalFilename: input.originalFilename,
|
|
754
|
-
uploadedBy: actor,
|
|
755
|
-
uploadedAt: now,
|
|
756
|
-
schema,
|
|
757
|
-
schemaExtractedAt: now,
|
|
758
|
-
...inventoryFields(inventory)
|
|
759
|
-
};
|
|
760
|
-
await this.data.definitions.createVersion(ctx, version);
|
|
761
|
-
await this.data.definitions.attachInitialVersion(ctx, input.guid, versionId);
|
|
762
|
-
return {
|
|
763
|
-
record: {
|
|
764
|
-
...record,
|
|
765
|
-
status: "draft",
|
|
766
|
-
liveVersionId: versionId,
|
|
767
|
-
draftVersionId: versionId
|
|
768
|
-
},
|
|
769
|
-
version
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Advances the draft pointer only — `live` is unchanged. Use `publish` to
|
|
774
|
-
* promote.
|
|
775
|
-
*/
|
|
776
|
-
async uploadVersion(ctx, guid, file, ext, originalName, schema, changeNote, inventory) {
|
|
777
|
-
const existing = await this.data.definitions.get(ctx, guid);
|
|
778
|
-
if (!existing) throw new ProviderError(`Definition not found: ${guid}`, 404);
|
|
779
|
-
const next = await this.data.definitions.reserveNextVersionNumber(ctx, guid);
|
|
780
|
-
const versionId = randomUUID();
|
|
781
|
-
const fileKey = definitionPaths.version(guid, next, ext);
|
|
782
|
-
await this.storage.put(fileKey, file, "application/octet-stream");
|
|
783
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
784
|
-
const version = {
|
|
785
|
-
id: versionId,
|
|
786
|
-
definitionId: guid,
|
|
787
|
-
versionNumber: next,
|
|
788
|
-
fileExt: ext,
|
|
789
|
-
fileKey,
|
|
790
|
-
originalFilename: originalName,
|
|
791
|
-
uploadedBy: ctx.userId || existing.ownerId,
|
|
792
|
-
uploadedAt: now,
|
|
793
|
-
changeNote: changeNote?.trim() || void 0,
|
|
794
|
-
schema,
|
|
795
|
-
schemaExtractedAt: now,
|
|
796
|
-
...inventoryFields(inventory)
|
|
797
|
-
};
|
|
798
|
-
await this.data.definitions.createVersion(ctx, version);
|
|
799
|
-
await this.data.definitions.setDraftVersion(ctx, guid, versionId);
|
|
800
|
-
const sourceDocumentId = toSourceDocumentId(schema.documentId);
|
|
801
|
-
if (sourceDocumentId && sourceDocumentId !== existing.sourceDocumentId) await this.data.definitions.update(ctx, guid, { sourceDocumentId });
|
|
802
|
-
return version;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Moves the live channel to `versionId`, or to the current draft if omitted.
|
|
806
|
-
* Any version id is accepted, so this rolls backward as well as forward.
|
|
807
|
-
*/
|
|
808
|
-
async publish(ctx, guid, versionId) {
|
|
809
|
-
const existing = await this.data.definitions.get(ctx, guid);
|
|
810
|
-
if (!existing) throw new ProviderError(`Definition not found: ${guid}`, 404);
|
|
811
|
-
const target = versionId ?? existing.draftVersionId;
|
|
812
|
-
if (!target) throw new ProviderError("No version to publish", 400);
|
|
813
|
-
const version = await this.data.definitions.getVersion(ctx, target);
|
|
814
|
-
if (!version || version.definitionId !== guid) throw new ProviderError(`Version '${target}' not found for this definition`, 404);
|
|
815
|
-
await this.data.definitions.setLiveVersion(ctx, guid, target);
|
|
816
|
-
if (existing.status === "draft" || existing.status === "pending") await this.data.definitions.update(ctx, guid, { status: "published" });
|
|
817
|
-
return version;
|
|
818
|
-
}
|
|
819
|
-
async deleteVersion(ctx, guid, versionId) {
|
|
820
|
-
const version = await this.data.definitions.getVersion(ctx, versionId);
|
|
821
|
-
if (!version || version.definitionId !== guid) throw new ProviderError(`Version '${versionId}' not found for this definition`, 404);
|
|
822
|
-
await this.data.definitions.deleteVersion(ctx, versionId);
|
|
823
|
-
await this.storage.delete(version.fileKey);
|
|
824
|
-
}
|
|
825
|
-
async updateMeta(ctx, guid, patch) {
|
|
826
|
-
await this.data.definitions.update(ctx, guid, patch);
|
|
827
|
-
}
|
|
828
|
-
async saveCoverImage(ctx, guid, imageData) {
|
|
829
|
-
const path = definitionPaths.image(guid);
|
|
830
|
-
await this.storage.put(path, imageData, "image/webp");
|
|
831
|
-
const url = withCacheBust(this.storage.getPublicUrl(path), Date.now());
|
|
832
|
-
await this.data.definitions.update(ctx, guid, { coverImage: url });
|
|
833
|
-
return url;
|
|
834
|
-
}
|
|
835
|
-
async delete(ctx, guid) {
|
|
836
|
-
await this.data.definitions.delete(ctx, guid);
|
|
837
|
-
await this.storage.deletePrefix(definitionPaths.prefix(guid));
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
564
|
// ../server/src/providers/create-selva-providers.ts
|
|
841
565
|
var FLAG_KEYS = [
|
|
842
566
|
"ALLOW_CROSS_ORG_PUBLIC",
|
|
@@ -1627,6 +1351,138 @@ var LocalApiTokenStore = class LocalApiTokenStore {
|
|
|
1627
1351
|
});
|
|
1628
1352
|
}
|
|
1629
1353
|
};
|
|
1354
|
+
// ../platform/src/computeServer/secrets.ts
|
|
1355
|
+
var ALGO = "aes-256-gcm";
|
|
1356
|
+
var IV_BYTES = 12;
|
|
1357
|
+
var TAG_BYTES = 16;
|
|
1358
|
+
var PREFIX_V1 = "enc:v1:";
|
|
1359
|
+
var PREFIX_V2 = "enc:v2:";
|
|
1360
|
+
var PREFIX_V3 = "enc:v3:";
|
|
1361
|
+
var PREFIX_LENGTH = 7;
|
|
1362
|
+
function isEncryptedSecret(value) {
|
|
1363
|
+
return isLegacyEnvelope(value) || value.startsWith(PREFIX_V3);
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* An `enc:v1:` or `enc:v2:` envelope: sealed without a {@link SecretBinding}, so it
|
|
1367
|
+
* still opens after its record's URL changes. Stores re-seal these.
|
|
1368
|
+
*/
|
|
1369
|
+
function isLegacyEnvelope(value) {
|
|
1370
|
+
return value.startsWith(PREFIX_V1) || value.startsWith(PREFIX_V2);
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* An `enc:v<n>:` envelope this build cannot open: a newer Selva sealed it, and this
|
|
1374
|
+
* one runs after a downgrade. It is ciphertext, so it must never be reported or
|
|
1375
|
+
* used as a plaintext key.
|
|
1376
|
+
*/
|
|
1377
|
+
function isUnknownEnvelope(value) {
|
|
1378
|
+
return /^enc:v\d+:/.test(value) && !isEncryptedSecret(value);
|
|
1379
|
+
}
|
|
1380
|
+
function bindingAad({ id, url }) {
|
|
1381
|
+
return Buffer.from(JSON.stringify([id, url]), "utf8");
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* AES-256-GCM envelope for at-rest secrets (e.g. compute API keys):
|
|
1385
|
+
* `enc:v<n>:<base64(iv|tag|ciphertext)>`. What `aad` is picks the version, and
|
|
1386
|
+
* the version says what GCM authenticates besides the ciphertext:
|
|
1387
|
+
* - a {@link SecretBinding} gives `v3`: the record's id and URL. Ciphertext copied
|
|
1388
|
+
* onto another record, or a record pointed at another host, fails to decrypt
|
|
1389
|
+
* instead of handing the plaintext to that host.
|
|
1390
|
+
* - a string gives `v2`: that string, which stores set to the record's id.
|
|
1391
|
+
* - nothing gives `v1`: nothing.
|
|
1392
|
+
*
|
|
1393
|
+
* Defends against backup leaks, accidental file/DB sharing, and read-only
|
|
1394
|
+
* storage access — not against an attacker who also has the master key
|
|
1395
|
+
* (`SELVA_AT_REST_KEY` env var, process memory). This is encryption at rest,
|
|
1396
|
+
* not a secret manager.
|
|
1397
|
+
*
|
|
1398
|
+
* Pure `node:crypto`, no fs or DB coupling, so the local and Supabase
|
|
1399
|
+
* compute-server stores share this one implementation.
|
|
1400
|
+
*/
|
|
1401
|
+
function encryptSecret(plaintext, key, aad) {
|
|
1402
|
+
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
1403
|
+
if (isEncryptedSecret(plaintext)) throw new Error("Refusing to encrypt a value that is already encrypted");
|
|
1404
|
+
const [prefix, aadBytes] = aad === void 0 ? [PREFIX_V1, void 0] : typeof aad === "string" ? [PREFIX_V2, Buffer.from(aad, "utf8")] : [PREFIX_V3, bindingAad(aad)];
|
|
1405
|
+
const iv = randomBytes(IV_BYTES);
|
|
1406
|
+
const cipher = createCipheriv(ALGO, key, iv);
|
|
1407
|
+
if (aadBytes) cipher.setAAD(aadBytes);
|
|
1408
|
+
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
1409
|
+
const tag = cipher.getAuthTag();
|
|
1410
|
+
return prefix + Buffer.concat([
|
|
1411
|
+
iv,
|
|
1412
|
+
tag,
|
|
1413
|
+
ciphertext
|
|
1414
|
+
]).toString("base64");
|
|
1415
|
+
}
|
|
1416
|
+
function aadToOpen(envelope, aad) {
|
|
1417
|
+
if (envelope.startsWith(PREFIX_V1)) return void 0;
|
|
1418
|
+
if (envelope.startsWith(PREFIX_V2)) {
|
|
1419
|
+
if (aad === void 0) throw new Error("This secret is bound to a record: pass its id");
|
|
1420
|
+
return Buffer.from(typeof aad === "string" ? aad : aad.id, "utf8");
|
|
1421
|
+
}
|
|
1422
|
+
if (aad === void 0 || typeof aad === "string") throw new Error("This secret is bound to a record and its URL: pass both");
|
|
1423
|
+
return bindingAad(aad);
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* `aad` is ignored for `v1`. `v2` takes the string it was sealed with, or a
|
|
1427
|
+
* binding's `id`; `v3` needs the binding.
|
|
1428
|
+
*/
|
|
1429
|
+
function decryptSecret(envelope, key, aad) {
|
|
1430
|
+
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
1431
|
+
if (!isEncryptedSecret(envelope)) throw new Error("Value is not an encrypted secret envelope");
|
|
1432
|
+
const aadBytes = aadToOpen(envelope, aad);
|
|
1433
|
+
const buf = Buffer.from(envelope.slice(PREFIX_LENGTH), "base64");
|
|
1434
|
+
if (buf.length < 28) throw new Error("Encrypted secret is shorter than its IV and tag");
|
|
1435
|
+
const iv = buf.subarray(0, IV_BYTES);
|
|
1436
|
+
const tag = buf.subarray(IV_BYTES, 28);
|
|
1437
|
+
const ciphertext = buf.subarray(28);
|
|
1438
|
+
const decipher = createDecipheriv(ALGO, key, iv, { authTagLength: TAG_BYTES });
|
|
1439
|
+
decipher.setAuthTag(tag);
|
|
1440
|
+
if (aadBytes) decipher.setAAD(aadBytes);
|
|
1441
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
1442
|
+
}
|
|
1443
|
+
var GENERATE_HINT = "Generate one with: node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"";
|
|
1444
|
+
/**
|
|
1445
|
+
* Decodes a `SELVA_AT_REST_KEY` env var into a 32-byte buffer (64-char hex or
|
|
1446
|
+
* base64, with or without padding). Throws on anything else so a
|
|
1447
|
+
* misconfigured key fails loudly at boot instead of silently producing
|
|
1448
|
+
* ciphertext nothing can decrypt.
|
|
1449
|
+
*/
|
|
1450
|
+
function decodeSecretKey(raw) {
|
|
1451
|
+
const key = parseKey32(raw);
|
|
1452
|
+
if (key) return key;
|
|
1453
|
+
throw new Error(`SELVA_AT_REST_KEY must be 32 bytes encoded as 64-char hex or base64. ${GENERATE_HINT}`);
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* `SELVA_AT_REST_KEY`, plus `SELVA_AT_REST_KEY_PREVIOUS` while it is within its
|
|
1457
|
+
* deadline. Throws when the current key is missing or malformed.
|
|
1458
|
+
*/
|
|
1459
|
+
function readAtRestKeys(env) {
|
|
1460
|
+
if (!env.SELVA_AT_REST_KEY) throw new Error(`Missing required env var: SELVA_AT_REST_KEY (32-byte hex or base64). ${GENERATE_HINT}`);
|
|
1461
|
+
const current = decodeSecretKey(env.SELVA_AT_REST_KEY);
|
|
1462
|
+
const previous = previousKey(env, "SELVA_AT_REST_KEY").key;
|
|
1463
|
+
return previous ? {
|
|
1464
|
+
current,
|
|
1465
|
+
previous: decodeSecretKey(previous)
|
|
1466
|
+
} : { current };
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* {@link decryptSecret} under each key in turn, current first. AES-GCM
|
|
1470
|
+
* authenticates, so a wrong key fails rather than returning garbage, and trying
|
|
1471
|
+
* the next one is safe. `keyIndex` above 0 means the caller should re-encrypt
|
|
1472
|
+
* under `keys[0]`.
|
|
1473
|
+
*/
|
|
1474
|
+
function decryptWithKeys(envelope, keys, aad) {
|
|
1475
|
+
let lastError;
|
|
1476
|
+
for (const [keyIndex, key] of keys.entries()) try {
|
|
1477
|
+
return {
|
|
1478
|
+
plaintext: decryptSecret(envelope, key, aad),
|
|
1479
|
+
keyIndex
|
|
1480
|
+
};
|
|
1481
|
+
} catch (err) {
|
|
1482
|
+
lastError = err;
|
|
1483
|
+
}
|
|
1484
|
+
throw lastError ?? /* @__PURE__ */ new Error("No key to decrypt with");
|
|
1485
|
+
}
|
|
1630
1486
|
// ../providers/local/src/data/LocalComputeServerStore.ts
|
|
1631
1487
|
var empty$5 = () => ({
|
|
1632
1488
|
servers: [],
|
|
@@ -2167,6 +2023,15 @@ var LocalOrgStore = class LocalOrgStore {
|
|
|
2167
2023
|
const m = orgMembers.find((m) => m.orgId === orgId && m.userId === userId);
|
|
2168
2024
|
return m && isLive$1(m) ? m : null;
|
|
2169
2025
|
}
|
|
2026
|
+
async countOrgMembers(_ctx, orgIds) {
|
|
2027
|
+
const { orgMembers } = await this.loader.get();
|
|
2028
|
+
const counts = new Map(orgIds.map((id) => [id, 0]));
|
|
2029
|
+
for (const m of orgMembers) {
|
|
2030
|
+
const n = counts.get(m.orgId);
|
|
2031
|
+
if (n !== void 0 && isLive$1(m)) counts.set(m.orgId, n + 1);
|
|
2032
|
+
}
|
|
2033
|
+
return counts;
|
|
2034
|
+
}
|
|
2170
2035
|
async getOrgMembersFor(_ctx, orgIds, userId) {
|
|
2171
2036
|
const { orgMembers } = await this.loader.get();
|
|
2172
2037
|
const byOrgId = new Map(orgMembers.filter((m) => m.userId === userId && isLive$1(m)).map((m) => [m.orgId, m]));
|
|
@@ -2402,6 +2267,15 @@ var LocalProjectStore = class {
|
|
|
2402
2267
|
const byProjectId = new Map(projectMembers.filter((m) => m.userId === userId && isLive(m)).map((m) => [m.projectId, m]));
|
|
2403
2268
|
return new Map(projectIds.map((id) => [id, byProjectId.get(id) ?? null]));
|
|
2404
2269
|
}
|
|
2270
|
+
async countProjectMembers(_ctx, projectIds) {
|
|
2271
|
+
const { projectMembers } = await this.loader.get();
|
|
2272
|
+
const counts = new Map(projectIds.map((id) => [id, 0]));
|
|
2273
|
+
for (const m of projectMembers) {
|
|
2274
|
+
const n = counts.get(m.projectId);
|
|
2275
|
+
if (n !== void 0 && isLive(m)) counts.set(m.projectId, n + 1);
|
|
2276
|
+
}
|
|
2277
|
+
return counts;
|
|
2278
|
+
}
|
|
2405
2279
|
async addProjectMember(ctx, member) {
|
|
2406
2280
|
const store = await this.loader.get();
|
|
2407
2281
|
const existing = store.projectMembers.find((m) => m.projectId === member.projectId && m.userId === member.userId);
|
|
@@ -3503,6 +3377,90 @@ function mapPostgrestError(e) {
|
|
|
3503
3377
|
}
|
|
3504
3378
|
return new Error(String(e));
|
|
3505
3379
|
}
|
|
3380
|
+
// ../providers/supabase/src/data/SupabasePlatformProjectGrantStore.ts
|
|
3381
|
+
var GRANT_COLUMNS = "id, project_id, grantee_type, grantee_id, can_solve, created_by, created_at";
|
|
3382
|
+
/** Reads go through the caller's client, so RLS shows a grantee only its own grants. */
|
|
3383
|
+
var SupabasePlatformProjectGrantStore = class {
|
|
3384
|
+
clients;
|
|
3385
|
+
constructor(clients) {
|
|
3386
|
+
this.clients = clients;
|
|
3387
|
+
}
|
|
3388
|
+
async listByProject(ctx, projectId) {
|
|
3389
|
+
const { data, error } = await this.clients.forRequest(ctx).from("platform_project_grants").select(GRANT_COLUMNS).eq("project_id", projectId).order("created_at", { ascending: true });
|
|
3390
|
+
if (error) throw mapPostgrestError(error);
|
|
3391
|
+
return (data ?? []).map(rowToGrant);
|
|
3392
|
+
}
|
|
3393
|
+
async listByProjects(ctx, projectIds) {
|
|
3394
|
+
const result = new Map(projectIds.map((id) => [id, []]));
|
|
3395
|
+
if (projectIds.length === 0) return result;
|
|
3396
|
+
const { data, error } = await this.clients.forRequest(ctx).from("platform_project_grants").select(GRANT_COLUMNS).in("project_id", [...projectIds]).order("created_at", { ascending: true });
|
|
3397
|
+
if (error) throw mapPostgrestError(error);
|
|
3398
|
+
for (const row of data ?? []) {
|
|
3399
|
+
const grant = rowToGrant(row);
|
|
3400
|
+
result.get(grant.projectId)?.push(grant);
|
|
3401
|
+
}
|
|
3402
|
+
return result;
|
|
3403
|
+
}
|
|
3404
|
+
async create(_ctx, grant) {
|
|
3405
|
+
const { error } = await this.clients.serviceClient.from("platform_project_grants").insert(grantToRow(grant));
|
|
3406
|
+
if (error?.code === "23505" && error.message.includes("platform_project_grants_grantee_key")) throw new ProviderError(`A grant for this ${grant.granteeType} already exists on this project`, 409);
|
|
3407
|
+
if (error) throw mapPostgrestError(error);
|
|
3408
|
+
}
|
|
3409
|
+
async delete(_ctx, id) {
|
|
3410
|
+
const { data, error } = await this.clients.serviceClient.from("platform_project_grants").delete().eq("id", id).select("id");
|
|
3411
|
+
if (error) throw mapPostgrestError(error);
|
|
3412
|
+
if (!data || data.length === 0) throw new ProviderError(`Grant '${id}' not found`, 404);
|
|
3413
|
+
}
|
|
3414
|
+
async deleteByProject(_ctx, projectId) {
|
|
3415
|
+
const { error } = await this.clients.serviceClient.from("platform_project_grants").delete().eq("project_id", projectId);
|
|
3416
|
+
if (error && !isMissingTable(error)) throw mapPostgrestError(error);
|
|
3417
|
+
}
|
|
3418
|
+
async deleteByGranteeOrg(_ctx, orgId) {
|
|
3419
|
+
const { error } = await this.clients.serviceClient.from("platform_project_grants").delete().eq("grantee_type", "org").eq("grantee_id", orgId);
|
|
3420
|
+
if (error && !isMissingTable(error)) throw mapPostgrestError(error);
|
|
3421
|
+
}
|
|
3422
|
+
/** A user grant is the user's own, so it goes with them; one they created stays. */
|
|
3423
|
+
async eraseUser(userId) {
|
|
3424
|
+
const client = this.clients.serviceClient;
|
|
3425
|
+
const deleted = await client.from("platform_project_grants").delete().eq("grantee_type", "user").eq("grantee_id", userId);
|
|
3426
|
+
if (deleted.error) {
|
|
3427
|
+
if (isMissingTable(deleted.error)) return;
|
|
3428
|
+
throw mapPostgrestError(deleted.error);
|
|
3429
|
+
}
|
|
3430
|
+
const anonymized = await client.from("platform_project_grants").update({ created_by: null }).eq("created_by", userId);
|
|
3431
|
+
if (anonymized.error) throw mapPostgrestError(anonymized.error);
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
/**
|
|
3435
|
+
* Deleting an org, a project or a user runs these cleanups on every deployment, also one whose
|
|
3436
|
+
* database is still behind `20261117200000`, which the migration handshake lets boot. Without the
|
|
3437
|
+
* table there is nothing to clean up.
|
|
3438
|
+
*/
|
|
3439
|
+
function isMissingTable(error) {
|
|
3440
|
+
return error.code === "PGRST205" || error.code === "42P01";
|
|
3441
|
+
}
|
|
3442
|
+
function rowToGrant(row) {
|
|
3443
|
+
return {
|
|
3444
|
+
id: row.id,
|
|
3445
|
+
projectId: row.project_id,
|
|
3446
|
+
granteeType: row.grantee_type,
|
|
3447
|
+
granteeId: row.grantee_id,
|
|
3448
|
+
canSolve: row.can_solve,
|
|
3449
|
+
createdBy: row.created_by ?? "deleted",
|
|
3450
|
+
createdAt: row.created_at
|
|
3451
|
+
};
|
|
3452
|
+
}
|
|
3453
|
+
function grantToRow(g) {
|
|
3454
|
+
return {
|
|
3455
|
+
id: g.id,
|
|
3456
|
+
project_id: g.projectId,
|
|
3457
|
+
grantee_type: g.granteeType,
|
|
3458
|
+
grantee_id: g.granteeId,
|
|
3459
|
+
can_solve: g.canSolve,
|
|
3460
|
+
created_by: g.createdBy === "deleted" ? null : g.createdBy,
|
|
3461
|
+
created_at: g.createdAt
|
|
3462
|
+
};
|
|
3463
|
+
}
|
|
3506
3464
|
// ../providers/supabase/src/data/pagination.ts
|
|
3507
3465
|
/**
|
|
3508
3466
|
* `ListOptions.cursor` is meant to be opaque; here it's just an offset
|
|
@@ -3569,9 +3527,12 @@ var ORG_MEMBER_COLUMNS = "org_id, user_id, role, permissions, joined_at, updated
|
|
|
3569
3527
|
var SupabaseOrgStore = class {
|
|
3570
3528
|
clients;
|
|
3571
3529
|
events;
|
|
3530
|
+
/** Grants have no soft-delete: deleting an org removes the grants it holds and those on its projects. */
|
|
3531
|
+
grants;
|
|
3572
3532
|
constructor(clients, events = new NoopEventSink()) {
|
|
3573
3533
|
this.clients = clients;
|
|
3574
3534
|
this.events = events;
|
|
3535
|
+
this.grants = new SupabasePlatformProjectGrantStore(clients);
|
|
3575
3536
|
}
|
|
3576
3537
|
async listOrgs(ctx, opts) {
|
|
3577
3538
|
const range = toRange(opts);
|
|
@@ -3645,6 +3606,8 @@ var SupabaseOrgStore = class {
|
|
|
3645
3606
|
}
|
|
3646
3607
|
const { error: invErr } = await client.from("invites").delete().eq("org_id", id);
|
|
3647
3608
|
if (invErr) throw mapPostgrestError(invErr);
|
|
3609
|
+
await this.grants.deleteByGranteeOrg(ctx, id);
|
|
3610
|
+
for (const projectId of projectIds) await this.grants.deleteByProject(ctx, projectId);
|
|
3648
3611
|
const { error: tokErr } = await client.from("api_tokens").delete().eq("org_id", id);
|
|
3649
3612
|
if (tokErr) throw mapPostgrestError(tokErr);
|
|
3650
3613
|
const { error: cdErr } = await client.from("compute_server_org_defaults").delete().eq("org_id", id);
|
|
@@ -3674,6 +3637,18 @@ var SupabaseOrgStore = class {
|
|
|
3674
3637
|
if (error) throw mapPostgrestError(error);
|
|
3675
3638
|
return data ? rowToOrgMember(data) : null;
|
|
3676
3639
|
}
|
|
3640
|
+
async countOrgMembers(ctx, orgIds) {
|
|
3641
|
+
const client = this.clients.forRequest(ctx);
|
|
3642
|
+
const counts = await Promise.all(orgIds.map(async (orgId) => {
|
|
3643
|
+
const { count, error } = await client.from("org_members").select("user_id", {
|
|
3644
|
+
count: "exact",
|
|
3645
|
+
head: true
|
|
3646
|
+
}).eq("org_id", orgId).is("deleted_at", null);
|
|
3647
|
+
if (error) throw mapPostgrestError(error);
|
|
3648
|
+
return [orgId, count ?? 0];
|
|
3649
|
+
}));
|
|
3650
|
+
return new Map(counts);
|
|
3651
|
+
}
|
|
3677
3652
|
async getOrgMembersFor(ctx, orgIds, userId) {
|
|
3678
3653
|
const result = new Map(orgIds.map((id) => [id, null]));
|
|
3679
3654
|
if (orgIds.length === 0) return result;
|
|
@@ -3827,9 +3802,12 @@ var PROJECT_MEMBER_COLUMNS = "project_id, user_id, role, joined_at, updated_at,
|
|
|
3827
3802
|
var SupabaseProjectStore = class {
|
|
3828
3803
|
clients;
|
|
3829
3804
|
events;
|
|
3805
|
+
/** Grants have no soft-delete: deleting a project removes its grants, as in the local provider. */
|
|
3806
|
+
grants;
|
|
3830
3807
|
constructor(clients, events = new NoopEventSink()) {
|
|
3831
3808
|
this.clients = clients;
|
|
3832
3809
|
this.events = events;
|
|
3810
|
+
this.grants = new SupabasePlatformProjectGrantStore(clients);
|
|
3833
3811
|
}
|
|
3834
3812
|
async listProjects(ctx, orgId, opts) {
|
|
3835
3813
|
const range = toRange(opts);
|
|
@@ -3899,6 +3877,7 @@ var SupabaseProjectStore = class {
|
|
|
3899
3877
|
definitionId: row.guid,
|
|
3900
3878
|
...actorOf(ctx)
|
|
3901
3879
|
});
|
|
3880
|
+
await this.grants.deleteByProject(ctx, id);
|
|
3902
3881
|
await this.events.emit({
|
|
3903
3882
|
type: "project.deleted",
|
|
3904
3883
|
projectId: id,
|
|
@@ -3946,6 +3925,18 @@ var SupabaseProjectStore = class {
|
|
|
3946
3925
|
for (const row of data ?? []) result.set(row.project_id, rowToProjectMember(row));
|
|
3947
3926
|
return result;
|
|
3948
3927
|
}
|
|
3928
|
+
async countProjectMembers(ctx, projectIds) {
|
|
3929
|
+
const client = this.clients.forRequest(ctx);
|
|
3930
|
+
const counts = await Promise.all(projectIds.map(async (projectId) => {
|
|
3931
|
+
const { count, error } = await client.from("project_members").select("user_id", {
|
|
3932
|
+
count: "exact",
|
|
3933
|
+
head: true
|
|
3934
|
+
}).eq("project_id", projectId).is("deleted_at", null);
|
|
3935
|
+
if (error) throw mapPostgrestError(error);
|
|
3936
|
+
return [projectId, count ?? 0];
|
|
3937
|
+
}));
|
|
3938
|
+
return new Map(counts);
|
|
3939
|
+
}
|
|
3949
3940
|
async addProjectMember(ctx, member) {
|
|
3950
3941
|
const row = {
|
|
3951
3942
|
...projectMemberToRow(member),
|
|
@@ -5131,7 +5122,7 @@ function tokenToRow(t) {
|
|
|
5131
5122
|
* whenever a migration is added — `migration-head.test.ts` asserts it
|
|
5132
5123
|
* matches the migrations directory, so CI catches drift.
|
|
5133
5124
|
*/
|
|
5134
|
-
var EXPECTED_MIGRATION_HEAD = "
|
|
5125
|
+
var EXPECTED_MIGRATION_HEAD = "20261117200000";
|
|
5135
5126
|
/**
|
|
5136
5127
|
* The oldest head this build runs on; the handshake fails below it. Behind
|
|
5137
5128
|
* {@link EXPECTED_MIGRATION_HEAD} only while a migration has to land after the
|
|
@@ -5633,29 +5624,6 @@ function mapError(e) {
|
|
|
5633
5624
|
}
|
|
5634
5625
|
// ../providers/supabase/src/data/SupabaseDataProvider.ts
|
|
5635
5626
|
/**
|
|
5636
|
-
* Stub until the Supabase implementation lands. Reads and mutations throw a
|
|
5637
|
-
* 501; cascade hooks are silent no-ops so deleting an org or project doesn't
|
|
5638
|
-
* blow up on a deployment without the feature wired.
|
|
5639
|
-
*/
|
|
5640
|
-
var NOT_IMPLEMENTED_MSG = "Platform projects are not supported on this deployment yet.";
|
|
5641
|
-
var notImplementedGrantStore = {
|
|
5642
|
-
unsupported: true,
|
|
5643
|
-
listByProject: async () => {
|
|
5644
|
-
throw new ProviderError(NOT_IMPLEMENTED_MSG, 501);
|
|
5645
|
-
},
|
|
5646
|
-
listByProjects: async () => {
|
|
5647
|
-
throw new ProviderError(NOT_IMPLEMENTED_MSG, 501);
|
|
5648
|
-
},
|
|
5649
|
-
create: async () => {
|
|
5650
|
-
throw new ProviderError(NOT_IMPLEMENTED_MSG, 501);
|
|
5651
|
-
},
|
|
5652
|
-
delete: async () => {
|
|
5653
|
-
throw new ProviderError(NOT_IMPLEMENTED_MSG, 501);
|
|
5654
|
-
},
|
|
5655
|
-
deleteByProject: async () => {},
|
|
5656
|
-
deleteByGranteeOrg: async () => {}
|
|
5657
|
-
};
|
|
5658
|
-
/**
|
|
5659
5627
|
* Composition of every data store for the Supabase backend. Builds one
|
|
5660
5628
|
* `ClientBundle` and wires every store to it, so all stores in a process
|
|
5661
5629
|
* share the same pooled clients.
|
|
@@ -5689,7 +5657,7 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5689
5657
|
this.apiTokens = new SupabaseApiTokenStore(clients, events);
|
|
5690
5658
|
this.userProfile = new SupabaseUserProfileProvider(clients);
|
|
5691
5659
|
this.permissions = new SupabasePlatformPermissionStore(clients);
|
|
5692
|
-
this.platformProjectGrants =
|
|
5660
|
+
this.platformProjectGrants = new SupabasePlatformProjectGrantStore(clients);
|
|
5693
5661
|
this.auditQuery = new SupabaseAuditQuery(clients);
|
|
5694
5662
|
}
|
|
5695
5663
|
static fromEnv(env, events, logger = new NoopLogger()) {
|
|
@@ -5767,7 +5735,7 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5767
5735
|
async ensureUser() {}
|
|
5768
5736
|
/**
|
|
5769
5737
|
* FK cascade against `auth.users` already removes the profile, memberships,
|
|
5770
|
-
* and owned rows.
|
|
5738
|
+
* and owned rows. Four classes of personal data aren't reachable by those
|
|
5771
5739
|
* FKs and get scrubbed here explicitly, with the RLS-bypassing service client:
|
|
5772
5740
|
*
|
|
5773
5741
|
* 1. `audit_events` keyed by a plain-text `actor_id` (no FK) — deleted.
|
|
@@ -5778,6 +5746,8 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5778
5746
|
* 3. `solve_metrics.actor_id`, deliberately not FK-cascaded (retention
|
|
5779
5747
|
* telemetry) — tombstoned to {@link ERASED_ACTOR_ID} so the row's
|
|
5780
5748
|
* aggregate value survives without identifying the person.
|
|
5749
|
+
* 4. `platform_project_grants`, whose grantee has no FK: grants to the user
|
|
5750
|
+
* are deleted, and those they created lose `created_by`.
|
|
5781
5751
|
*
|
|
5782
5752
|
* Each step tolerates missing rows, so retrying is safe. Email scrubs are
|
|
5783
5753
|
* skipped when `opts.email` is absent — the caller must capture it before
|
|
@@ -5790,12 +5760,26 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5790
5760
|
if (deletedActions.error) throw new ProviderError(`Failed to erase audit_events for user: ${deletedActions.error.message}`, 500);
|
|
5791
5761
|
const tombstoned = await client.from("solve_metrics").update({ actor_id: ERASED_ACTOR_ID }).eq("actor_id", userId);
|
|
5792
5762
|
if (tombstoned.error) throw new ProviderError(`Failed to anonymize solve_metrics for user: ${tombstoned.error.message}`, 500);
|
|
5763
|
+
await this.platformProjectGrants.eraseUser(userId);
|
|
5793
5764
|
if (!email) return;
|
|
5794
5765
|
const deletedInvites = await client.from("invites").delete().eq("email", email);
|
|
5795
5766
|
if (deletedInvites.error) throw new ProviderError(`Failed to erase invites for user email: ${deletedInvites.error.message}`, 500);
|
|
5796
5767
|
const redacted = await client.rpc("redact_audit_event_email", { p_email: email });
|
|
5797
5768
|
if (redacted.error) throw new ProviderError(`Failed to redact audit_events email payloads: ${redacted.error.message}`, 500);
|
|
5798
5769
|
}
|
|
5770
|
+
async purgeExpired(_ctx, cutoffs) {
|
|
5771
|
+
const client = this.clients.serviceClient;
|
|
5772
|
+
const purge = async (table, before) => {
|
|
5773
|
+
if (!before) return 0;
|
|
5774
|
+
const { error, count } = await client.from(table).delete({ count: "exact" }).lt("occurred_at", before.toISOString());
|
|
5775
|
+
if (error) throw new ProviderError(`Failed to purge ${table}: ${error.message}`, 500);
|
|
5776
|
+
return count ?? 0;
|
|
5777
|
+
};
|
|
5778
|
+
return {
|
|
5779
|
+
auditEvents: await purge("audit_events", cutoffs.auditEventsBefore),
|
|
5780
|
+
solveMetrics: await purge("solve_metrics", cutoffs.solveMetricsBefore)
|
|
5781
|
+
};
|
|
5782
|
+
}
|
|
5799
5783
|
};
|
|
5800
5784
|
// ../providers/supabase/src/auth/SupabaseDelegatedSession.ts
|
|
5801
5785
|
var DEFAULT_TTL_SECONDS = 60;
|
|
@@ -6957,6 +6941,149 @@ var HeaderAuthProvider = class HeaderAuthProvider {
|
|
|
6957
6941
|
await this.users.touchLastLogin(id);
|
|
6958
6942
|
}
|
|
6959
6943
|
};
|
|
6944
|
+
// ../server/src/definitions/definition-service.ts
|
|
6945
|
+
var inventoryFields = (inventory) => inventory ? {
|
|
6946
|
+
inventory,
|
|
6947
|
+
inventorySummary: summarizeInventory(inventory)
|
|
6948
|
+
} : {};
|
|
6949
|
+
/**
|
|
6950
|
+
* Orchestrates writes spanning IDataProvider + IStorageProvider. Application
|
|
6951
|
+
* orchestration, not platform contract — hence not in @selvajs/platform.
|
|
6952
|
+
*
|
|
6953
|
+
* Methods that write both metadata and blobs order the two so a mid-flight
|
|
6954
|
+
* failure leaves a state the API can still serve; those reasons sit inline at
|
|
6955
|
+
* each write. `publish` and `updateMeta` flip pointers/metadata only and touch
|
|
6956
|
+
* storage not at all.
|
|
6957
|
+
*/
|
|
6958
|
+
var DefinitionService = class {
|
|
6959
|
+
data;
|
|
6960
|
+
storage;
|
|
6961
|
+
constructor(data, storage) {
|
|
6962
|
+
this.data = data;
|
|
6963
|
+
this.storage = storage;
|
|
6964
|
+
}
|
|
6965
|
+
async create(ctx, input, file, schema, inventory) {
|
|
6966
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
6967
|
+
const actor = ctx.userId || input.ownerId;
|
|
6968
|
+
const record = {
|
|
6969
|
+
guid: input.guid,
|
|
6970
|
+
projectId: input.projectId,
|
|
6971
|
+
ownerId: input.ownerId,
|
|
6972
|
+
createdBy: actor,
|
|
6973
|
+
updatedBy: actor,
|
|
6974
|
+
displayName: input.displayName,
|
|
6975
|
+
description: input.description,
|
|
6976
|
+
category: input.category,
|
|
6977
|
+
tags: input.tags,
|
|
6978
|
+
coverImage: input.coverImage,
|
|
6979
|
+
computeServerId: input.computeServerId,
|
|
6980
|
+
status: "pending",
|
|
6981
|
+
solveCount: 0,
|
|
6982
|
+
nextVersionNumber: 2,
|
|
6983
|
+
liveVersionId: null,
|
|
6984
|
+
draftVersionId: null,
|
|
6985
|
+
sourceDocumentId: toSourceDocumentId(schema.documentId) ?? void 0,
|
|
6986
|
+
createdAt: now,
|
|
6987
|
+
updatedAt: now,
|
|
6988
|
+
deletedAt: null
|
|
6989
|
+
};
|
|
6990
|
+
await this.data.definitions.create(ctx, record);
|
|
6991
|
+
const versionId = randomUUID();
|
|
6992
|
+
const fileKey = definitionPaths.version(input.guid, 1, input.fileExt);
|
|
6993
|
+
await this.storage.put(fileKey, file, "application/octet-stream");
|
|
6994
|
+
const version = {
|
|
6995
|
+
id: versionId,
|
|
6996
|
+
definitionId: input.guid,
|
|
6997
|
+
versionNumber: 1,
|
|
6998
|
+
fileExt: input.fileExt,
|
|
6999
|
+
fileKey,
|
|
7000
|
+
originalFilename: input.originalFilename,
|
|
7001
|
+
uploadedBy: actor,
|
|
7002
|
+
uploadedAt: now,
|
|
7003
|
+
schema,
|
|
7004
|
+
schemaExtractedAt: now,
|
|
7005
|
+
...inventoryFields(inventory)
|
|
7006
|
+
};
|
|
7007
|
+
await this.data.definitions.createVersion(ctx, version);
|
|
7008
|
+
await this.data.definitions.attachInitialVersion(ctx, input.guid, versionId);
|
|
7009
|
+
return {
|
|
7010
|
+
record: {
|
|
7011
|
+
...record,
|
|
7012
|
+
status: "draft",
|
|
7013
|
+
liveVersionId: versionId,
|
|
7014
|
+
draftVersionId: versionId
|
|
7015
|
+
},
|
|
7016
|
+
version
|
|
7017
|
+
};
|
|
7018
|
+
}
|
|
7019
|
+
/**
|
|
7020
|
+
* Advances the draft pointer only — `live` is unchanged. Use `publish` to
|
|
7021
|
+
* promote.
|
|
7022
|
+
*/
|
|
7023
|
+
async uploadVersion(ctx, guid, file, ext, originalName, schema, changeNote, inventory) {
|
|
7024
|
+
const existing = await this.data.definitions.get(ctx, guid);
|
|
7025
|
+
if (!existing) throw new ProviderError(`Definition not found: ${guid}`, 404);
|
|
7026
|
+
const next = await this.data.definitions.reserveNextVersionNumber(ctx, guid);
|
|
7027
|
+
const versionId = randomUUID();
|
|
7028
|
+
const fileKey = definitionPaths.version(guid, next, ext);
|
|
7029
|
+
await this.storage.put(fileKey, file, "application/octet-stream");
|
|
7030
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7031
|
+
const version = {
|
|
7032
|
+
id: versionId,
|
|
7033
|
+
definitionId: guid,
|
|
7034
|
+
versionNumber: next,
|
|
7035
|
+
fileExt: ext,
|
|
7036
|
+
fileKey,
|
|
7037
|
+
originalFilename: originalName,
|
|
7038
|
+
uploadedBy: ctx.userId || existing.ownerId,
|
|
7039
|
+
uploadedAt: now,
|
|
7040
|
+
changeNote: changeNote?.trim() || void 0,
|
|
7041
|
+
schema,
|
|
7042
|
+
schemaExtractedAt: now,
|
|
7043
|
+
...inventoryFields(inventory)
|
|
7044
|
+
};
|
|
7045
|
+
await this.data.definitions.createVersion(ctx, version);
|
|
7046
|
+
await this.data.definitions.setDraftVersion(ctx, guid, versionId);
|
|
7047
|
+
const sourceDocumentId = toSourceDocumentId(schema.documentId);
|
|
7048
|
+
if (sourceDocumentId && sourceDocumentId !== existing.sourceDocumentId) await this.data.definitions.update(ctx, guid, { sourceDocumentId });
|
|
7049
|
+
return version;
|
|
7050
|
+
}
|
|
7051
|
+
/**
|
|
7052
|
+
* Moves the live channel to `versionId`, or to the current draft if omitted.
|
|
7053
|
+
* Any version id is accepted, so this rolls backward as well as forward.
|
|
7054
|
+
*/
|
|
7055
|
+
async publish(ctx, guid, versionId) {
|
|
7056
|
+
const existing = await this.data.definitions.get(ctx, guid);
|
|
7057
|
+
if (!existing) throw new ProviderError(`Definition not found: ${guid}`, 404);
|
|
7058
|
+
const target = versionId ?? existing.draftVersionId;
|
|
7059
|
+
if (!target) throw new ProviderError("No version to publish", 400);
|
|
7060
|
+
const version = await this.data.definitions.getVersion(ctx, target);
|
|
7061
|
+
if (!version || version.definitionId !== guid) throw new ProviderError(`Version '${target}' not found for this definition`, 404);
|
|
7062
|
+
await this.data.definitions.setLiveVersion(ctx, guid, target);
|
|
7063
|
+
if (existing.status === "draft" || existing.status === "pending") await this.data.definitions.update(ctx, guid, { status: "published" });
|
|
7064
|
+
return version;
|
|
7065
|
+
}
|
|
7066
|
+
async deleteVersion(ctx, guid, versionId) {
|
|
7067
|
+
const version = await this.data.definitions.getVersion(ctx, versionId);
|
|
7068
|
+
if (!version || version.definitionId !== guid) throw new ProviderError(`Version '${versionId}' not found for this definition`, 404);
|
|
7069
|
+
await this.data.definitions.deleteVersion(ctx, versionId);
|
|
7070
|
+
await this.storage.delete(version.fileKey);
|
|
7071
|
+
}
|
|
7072
|
+
async updateMeta(ctx, guid, patch) {
|
|
7073
|
+
await this.data.definitions.update(ctx, guid, patch);
|
|
7074
|
+
}
|
|
7075
|
+
async saveCoverImage(ctx, guid, imageData) {
|
|
7076
|
+
const path = definitionPaths.image(guid);
|
|
7077
|
+
await this.storage.put(path, imageData, "image/webp");
|
|
7078
|
+
const url = withCacheBust(this.storage.getPublicUrl(path), Date.now());
|
|
7079
|
+
await this.data.definitions.update(ctx, guid, { coverImage: url });
|
|
7080
|
+
return url;
|
|
7081
|
+
}
|
|
7082
|
+
async delete(ctx, guid) {
|
|
7083
|
+
await this.data.definitions.delete(ctx, guid);
|
|
7084
|
+
await this.storage.deletePrefix(definitionPaths.prefix(guid));
|
|
7085
|
+
}
|
|
7086
|
+
};
|
|
6960
7087
|
// ../../node_modules/.pnpm/undici@8.12.3/node_modules/undici/lib/core/symbols.js
|
|
6961
7088
|
var require_symbols = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6962
7089
|
module.exports = {
|
|
@@ -34683,16 +34810,20 @@ function postedServerSourcedIds(inputs, values) {
|
|
|
34683
34810
|
}
|
|
34684
34811
|
/**
|
|
34685
34812
|
* The input tree a solve sends: each input's value, or its schema default when it has none. A
|
|
34686
|
-
* server-sourced input
|
|
34813
|
+
* server-sourced input takes its value from `boundValues` (what the host resolved), never from
|
|
34814
|
+
* `values`.
|
|
34687
34815
|
*/
|
|
34688
|
-
function buildSolveInputTree(inputs, values) {
|
|
34689
|
-
return TreeBuilder.fromValues(inputs.filter((input) => input.paramType).map((input) =>
|
|
34690
|
-
|
|
34691
|
-
|
|
34692
|
-
|
|
34693
|
-
|
|
34694
|
-
|
|
34695
|
-
|
|
34816
|
+
function buildSolveInputTree(inputs, values, boundValues = {}) {
|
|
34817
|
+
return TreeBuilder.fromValues(inputs.filter((input) => input.paramType).map((input) => {
|
|
34818
|
+
const from = input.serverSourced ? boundValues : values;
|
|
34819
|
+
return {
|
|
34820
|
+
paramName: input.nickname,
|
|
34821
|
+
paramType: input.paramType,
|
|
34822
|
+
value: (Object.hasOwn(from, input.id) ? from[input.id] : void 0) ?? input.default,
|
|
34823
|
+
minimum: input.minimum,
|
|
34824
|
+
maximum: input.maximum
|
|
34825
|
+
};
|
|
34826
|
+
}));
|
|
34696
34827
|
}
|
|
34697
34828
|
/**
|
|
34698
34829
|
* Runs one solve against a warm scheduler and classifies how it ended: a solved response, or an
|
|
@@ -34898,7 +35029,7 @@ var SolveEngine = class {
|
|
|
34898
35029
|
const treeBuildStart = performance.now();
|
|
34899
35030
|
let inputTree;
|
|
34900
35031
|
try {
|
|
34901
|
-
inputTree = buildSolveInputTree(args.inputs, args.values);
|
|
35032
|
+
inputTree = buildSolveInputTree(args.inputs, args.values, args.boundValues);
|
|
34902
35033
|
} catch (error) {
|
|
34903
35034
|
return {
|
|
34904
35035
|
kind: "compute_error",
|