@selvajs/selva 4.20.1-beta.4 → 4.21.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter-node.js +1 -1
- package/build/client/_app/immutable/assets/0.CqqJCiiV.css +2 -0
- package/build/client/_app/immutable/assets/0.CqqJCiiV.css.br +0 -0
- package/build/client/_app/immutable/assets/0.CqqJCiiV.css.gz +0 -0
- package/build/client/_app/immutable/chunks/{CzfnuBzq.js → BAhtiTKe.js} +1 -1
- 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/{qi43d-TM.js → CKbHmAlc.js} +1 -1
- package/build/client/_app/immutable/chunks/CKbHmAlc.js.br +0 -0
- package/build/client/_app/immutable/chunks/CKbHmAlc.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{C6Y_BUwr.js → CmlXAF26.js} +1 -1
- 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/Cv7GBWJh.js +2 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{BDYCH-_Q.js → D5j4-ZO1.js} +1 -1
- package/build/client/_app/immutable/chunks/D5j4-ZO1.js.br +0 -0
- package/build/client/_app/immutable/chunks/D5j4-ZO1.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DW5EJMC7.js +1 -0
- 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/{D-uUm_OB.js → DptnDNFA.js} +61 -56
- package/build/client/_app/immutable/chunks/DptnDNFA.js.br +0 -0
- package/build/client/_app/immutable/chunks/{D-uUm_OB.js.gz → DptnDNFA.js.gz} +0 -0
- package/build/client/_app/immutable/chunks/DvJo0Zn0.js +1 -0
- package/build/client/_app/immutable/chunks/DvJo0Zn0.js.br +1 -0
- package/build/client/_app/immutable/chunks/DvJo0Zn0.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DzxE3j6C.js → qXnHMKD9.js} +1 -1
- package/build/client/_app/immutable/chunks/qXnHMKD9.js.br +0 -0
- package/build/client/_app/immutable/chunks/qXnHMKD9.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.BpT6WkO1.js → app.DPbjEDd3.js} +2 -2
- package/build/client/_app/immutable/entry/app.DPbjEDd3.js.br +0 -0
- package/build/client/_app/immutable/entry/app.DPbjEDd3.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.D3kiiIk_.js → 1.DWd6YbcT.js} +1 -1
- 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/15._hpTnSzc.js +36 -0
- package/build/client/_app/immutable/nodes/15._hpTnSzc.js.br +0 -0
- package/build/client/_app/immutable/nodes/15._hpTnSzc.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.CUNbzjI_.js → 2.CS32Eh9m.js} +1 -1
- package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.9OIre0ah.js → 20.CVaxGEhZ.js} +1 -1
- package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.DpKe0-GH.js +1 -0
- package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.gz +0 -0
- package/build/client/_app/immutable/nodes/24.DkL5kHzA.js +3 -0
- package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.br +0 -0
- package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{25.DW1_vMxq.js → 25.DiYmTwXC.js} +2 -2
- package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/26.7nAJpm5P.js +5 -0
- package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.br +0 -0
- package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{3.3Z4QUsQQ.js → 3.Ctd9OGCk.js} +1 -1
- package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{5.DmA9lTA-.js → 5.Wh_w3RkZ.js} +1 -1
- package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.br +2 -0
- package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.D6WLqCgl.js → 6.C-DiUI5R.js} +1 -1
- package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{7.CNuRjkv2.js → 7.B8yubYrv.js} +1 -1
- package/build/client/_app/immutable/nodes/7.B8yubYrv.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.B8yubYrv.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 +35 -45
- package/build/server/_app/immutable/assets/_layout.CqqJCiiV.css +2 -0
- package/build/server/chunks/DefinitionCard.js +3 -0
- package/build/server/chunks/DefinitionCard.js.map +1 -1
- package/build/server/chunks/access.js +15 -3
- package/build/server/chunks/access.js.map +1 -1
- package/build/server/chunks/api-errors.js +18 -3
- package/build/server/chunks/api-errors.js.map +1 -1
- package/build/server/chunks/api.js +9 -2
- package/build/server/chunks/api.js.map +1 -1
- package/build/server/chunks/auth-bootstrap.server.js +63 -39
- package/build/server/chunks/auth-bootstrap.server.js.map +1 -1
- package/build/server/chunks/boot.server.js +1 -1
- package/build/server/chunks/bootHealth.server.js +23 -23
- package/build/server/chunks/bootHealth.server.js.map +1 -1
- package/build/server/chunks/computeRateLimit.server.js +2 -2
- package/build/server/chunks/delete-with-blobs.js +1 -1
- package/build/server/chunks/engine.server.js +52 -5
- package/build/server/chunks/engine.server.js.map +1 -1
- package/build/server/chunks/grasshopper.js +217 -162
- package/build/server/chunks/grasshopper.js.map +1 -1
- package/build/server/chunks/handlers.js +70 -60
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/http.js +24 -24
- package/build/server/chunks/http.js.map +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 +31 -16
- package/build/server/chunks/instanceAdmins.server.js.map +1 -1
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/{abort-Bfrdupaj.js → keepalive-vtcjhAV3.js} +6 -3
- package/build/server/chunks/keepalive-vtcjhAV3.js.map +1 -0
- package/build/server/chunks/liveSolve.server.js +1 -1
- package/build/server/chunks/localeContext.svelte.js +14 -0
- package/build/server/chunks/localeContext.svelte.js.map +1 -1
- package/build/server/chunks/oauth.js +70 -24
- package/build/server/chunks/oauth.js.map +1 -1
- package/build/server/chunks/{outcome-DNrffAXp.js → outcome-D28FgvFK.js} +9 -6
- package/build/server/chunks/outcome-D28FgvFK.js.map +1 -0
- package/build/server/chunks/package.js +2 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/permissions.server.js +1 -1
- package/build/server/chunks/presets.server.js +1 -1
- package/build/server/chunks/providers.server.js +324 -121
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +1 -1
- package/build/server/chunks/resolve-server.js +1 -1
- package/build/server/chunks/schema-extraction.js +75 -8
- package/build/server/chunks/schema-extraction.js.map +1 -1
- package/build/server/chunks/schema.js +1 -1
- package/build/server/chunks/schema.js.map +1 -1
- package/build/server/chunks/server-config-write.js +6 -6
- package/build/server/chunks/server-config-write.js.map +1 -1
- package/build/server/chunks/server2.js +2 -2
- package/build/server/chunks/server2.js.map +1 -1
- package/build/server/chunks/serverStats.server.js +1 -1
- package/build/server/chunks/signInMaxAge.server.js +1 -1
- package/build/server/chunks/solve.server.js +34 -8
- package/build/server/chunks/solve.server.js.map +1 -1
- package/build/server/chunks/sveltekit.js +4 -5
- package/build/server/chunks/sveltekit.js.map +1 -1
- package/build/server/chunks/update-outcome.js +11 -0
- package/build/server/chunks/update-outcome.js.map +1 -1
- package/build/server/chunks/updateCheck.server.js +24 -12
- package/build/server/chunks/updateCheck.server.js.map +1 -1
- package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js +6 -3
- package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js +6 -3
- package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js +6 -3
- package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js.map +1 -1
- 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 +1 -1
- 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 +9 -2
- package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +59 -15
- package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +42 -16
- package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +24 -13
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +15 -6
- package/build/server/entries/endpoints/api/v1/compute/_server.ts.js.map +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 +5 -4
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js.map +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_/schema/_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_/members/_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/solve/_solveId_/cancel/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +1 -1
- package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +2 -2
- package/build/server/entries/endpoints/auth/email/callback/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +2 -2
- package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +43 -13
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/oauth/register/_server.ts.js +1 -1
- package/build/server/entries/endpoints/oauth/token/_server.ts.js +1 -1
- package/build/server/entries/hooks.server.js +25 -6
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/admin/compute/_page.server.ts.js +1 -2
- package/build/server/entries/pages/admin/compute/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/admin/system/_page.server.ts.js +8 -3
- package/build/server/entries/pages/admin/system/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/admin/system/_page.svelte.js +18 -2
- package/build/server/entries/pages/admin/system/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +198 -99
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +693 -40
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +3 -2
- package/build/server/entries/pages/oauth/authorize/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/oauth/authorize/_page.svelte.js +8 -1
- package/build/server/entries/pages/oauth/authorize/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/projects/_page.svelte.js +2 -0
- package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/setup/_page.server.ts.js +62 -8
- package/build/server/entries/pages/setup/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/setup/_page.svelte.js +52 -33
- package/build/server/entries/pages/setup/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/tokens/_page.server.ts.js +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/15.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/24.js +1 -1
- package/build/server/nodes/25.js +1 -1
- package/build/server/nodes/26.js +1 -1
- package/build/server/nodes/3.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 +16 -13
- package/templates/.env.example +15 -7
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css +0 -2
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css.br +0 -0
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css.gz +0 -0
- package/build/client/_app/immutable/chunks/BDYCH-_Q.js.br +0 -0
- package/build/client/_app/immutable/chunks/BDYCH-_Q.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C6Y_BUwr.js.br +0 -0
- package/build/client/_app/immutable/chunks/C6Y_BUwr.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CzfnuBzq.js.br +0 -0
- package/build/client/_app/immutable/chunks/CzfnuBzq.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D-uUm_OB.js.br +0 -0
- package/build/client/_app/immutable/chunks/D84F7w9g.js +0 -1
- package/build/client/_app/immutable/chunks/D84F7w9g.js.br +0 -1
- package/build/client/_app/immutable/chunks/D84F7w9g.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DQsP4nZb.js +0 -1
- package/build/client/_app/immutable/chunks/DQsP4nZb.js.br +0 -0
- package/build/client/_app/immutable/chunks/DQsP4nZb.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DzeQucGI.js +0 -2
- package/build/client/_app/immutable/chunks/DzeQucGI.js.br +0 -0
- package/build/client/_app/immutable/chunks/DzeQucGI.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DzxE3j6C.js.br +0 -0
- package/build/client/_app/immutable/chunks/DzxE3j6C.js.gz +0 -0
- package/build/client/_app/immutable/chunks/qi43d-TM.js.br +0 -0
- package/build/client/_app/immutable/chunks/qi43d-TM.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.BpT6WkO1.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BpT6WkO1.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.gz +0 -0
- package/build/client/_app/immutable/nodes/15.BXIV1QfS.js +0 -32
- package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.br +0 -0
- package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.9OIre0ah.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.9OIre0ah.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js +0 -1
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js.gz +0 -0
- package/build/client/_app/immutable/nodes/24.CPSunfJJ.js +0 -3
- package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.br +0 -0
- package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.gz +0 -0
- package/build/client/_app/immutable/nodes/26.CqaMEm_t.js +0 -6
- package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.br +0 -0
- package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.br +0 -1
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.gz +0 -0
- package/build/server/_app/immutable/assets/_layout.2jDm0bqh.css +0 -2
- package/build/server/chunks/abort-Bfrdupaj.js.map +0 -1
- package/build/server/chunks/computeLimits.js +0 -33
- package/build/server/chunks/computeLimits.js.map +0 -1
- package/build/server/chunks/outcome-DNrffAXp.js.map +0 -1
- /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js → 0.Ds0zeDAg.js} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.br → 0.Ds0zeDAg.js.br} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.gz → 0.Ds0zeDAg.js.gz} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-bootstrap.server.js","names":[],"sources":["../../../src/lib/server/auth-bootstrap.server.ts"],"sourcesContent":["import { env } from '#lib/server/env.js';\nimport { randomUUID } from 'node:crypto';\nimport {\n\tALL_PLATFORM_PERMISSIONS,\n\tSYSTEM_CONTEXT,\n\ttype AuthUser,\n\ttype Organization,\n\ttype Project,\n\ttype TenancyMode\n} from '@selvajs/platform';\nimport {\n\tgetAuthProvider,\n\tgetDataProvider,\n\tgetLogger,\n\tgetOrganizationProvider,\n\tgetPermissionStore,\n\tgetProjectProvider,\n\tgetTenancy\n} from './providers.server.js';\nimport { orgSlugFromName } from '@selvajs/platform';\n\n/**\n * Shared post-verification flow used by every IdP-callback route (OAuth,\n * email link, future SAML, …). Order matters:\n *\n * 1. `data.ensureUser` — guarantee a user-data row exists for whatever ID\n * the auth provider issued. Local-provider creates a JSON row;\n * Supabase no-ops (its DB trigger has already fired).\n * 2. Bootstrap-admin grant — if no instance_admin exists yet AND the\n * tenancy/env policy allows it, grant the signing-in user every\n * platform permission so `/admin` becomes reachable.\n * 3. Single-tenant org seed — create the default Organization + Project\n * owned by the new admin, mirroring what `/setup` does for password\n * auth. Without this, org-scoped permissions (manage_projects,\n * manage_definitions) silently drop because `actingOrgId` resolves to\n * undefined.\n *\n * Cookie/redirect are the caller's job since they vary by capability (OAuth\n * has refresh tokens, magic-link does sometimes, SAML doesn't).\n */\nexport async function bootstrapUserSession(user: AuthUser): Promise<void> {\n\tawait getDataProvider().ensureUser(SYSTEM_CONTEXT, user.id);\n\n\tconst tenancy = getTenancy();\n\tconst perms = getPermissionStore();\n\tconst hasAdmin = await perms.hasInstanceAdmin(SYSTEM_CONTEXT);\n\tlet grantedAdminHere = false;\n\tif (!hasAdmin) {\n\t\tif (!shouldBootstrapAdmin(user, env.BOOTSTRAP_INSTANCE_ADMIN_EMAIL, tenancy)) return;\n\t\t// `claimFirstInstanceAdmin`, not `set`: the probe above and the write are\n\t\t// two round-trips, and with no BOOTSTRAP_INSTANCE_ADMIN_EMAIL configured\n\t\t// every signer is eligible — so two people signing in at the same moment\n\t\t// both saw \"no admin\" and both became permanent platform admins. The\n\t\t// store re-checks under a lock and only one caller wins.\n\t\tgrantedAdminHere = await perms.claimFirstInstanceAdmin(SYSTEM_CONTEXT, user.id, [\n\t\t\t...ALL_PLATFORM_PERMISSIONS\n\t\t]);\n\t\t// Lost the race: an admin now exists and it is not this user. Everything\n\t\t// below is org self-heal, which the winner performs.\n\t\tif (!grantedAdminHere) return;\n\t}\n\n\t// Self-heal: deployments that skipped /setup (header-auth, OAuth callback)\n\t// can be left without a default org, dropping org-scoped permissions\n\t// silently. Seed it if missing; once it exists this is a single cheap\n\t// listOrgs read per request and an early-return.\n\tif (tenancy !== 'single') return;\n\tconst orgs = getOrganizationProvider();\n\tconst existing = await orgs.listOrgs(SYSTEM_CONTEXT, { limit: 1 });\n\tif (existing.items.length > 0) return;\n\n\t// Only the instance admin owns the freshly-created org. Skip the read if\n\t// we just granted it above; otherwise re-check for the self-heal path.\n\tif (!grantedAdminHere) {\n\t\tconst userPerms = await perms.getFor(SYSTEM_CONTEXT, user.id);\n\t\tif (!userPerms.includes('instance_admin')) return;\n\t}\n\tawait ensureSingleTenantDefaultOrg(user);\n}\n\n/**\n * Seeds the single default Organization + Project that `actingOrgId` needs\n * to resolve, for flows that skip `/setup` (header-auth, OAuth callback,\n * future SAML). No-op outside single-tenant mode and once any org exists.\n * Slug derives from the admin's email/displayName so the URL looks like the\n * deployment rather than a UUID; falls back to `default` for anonymous\n * UPN-only sign-ins.\n */\nasync function ensureSingleTenantDefaultOrg(user: AuthUser): Promise<void> {\n\tif (getTenancy() !== 'single') return;\n\tconst orgs = getOrganizationProvider();\n\tconst existing = await orgs.listOrgs(SYSTEM_CONTEXT, { limit: 1 });\n\tif (existing.items.length > 0) return;\n\n\tconst displayName =\n\t\ttypeof user.metadata?.displayName === 'string' ? user.metadata.displayName : undefined;\n\tconst orgName = displayName?.trim() || user.email?.split('@')[0]?.trim() || 'Default';\n\tconst slug = orgSlugFromName(orgName);\n\n\tconst now = new Date().toISOString();\n\tconst org: Organization = {\n\t\tid: randomUUID(),\n\t\tname: orgName,\n\t\tslug,\n\t\townerId: user.id,\n\t\tcreatedBy: user.id,\n\t\tupdatedBy: user.id,\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t\tdeletedAt: null\n\t};\n\tawait orgs.createOrg(SYSTEM_CONTEXT, org);\n\n\tconst projects = getProjectProvider();\n\tconst project: Project = {\n\t\tid: randomUUID(),\n\t\torgId: org.id,\n\t\tname: 'Default',\n\t\tslug: 'default',\n\t\tvisibility: 'public',\n\t\townerId: user.id,\n\t\tcreatedBy: user.id,\n\t\tupdatedBy: user.id,\n\t\tautoJoinOnUpload: false,\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t\tdeletedAt: null\n\t};\n\tawait projects.createProject(SYSTEM_CONTEXT, project);\n}\n\n/**\n * Whether the signing-in user qualifies for the first-admin grant. Pure — no\n * I/O — so the policy is unit-testable.\n *\n * - `tenancy='single'` + no env var → first signer wins (fine for\n * self-hosted fresh installs).\n * - `tenancy='single'` + env var set → only the named user qualifies.\n * - `tenancy='multi'` → env var REQUIRED; the named user must match the\n * signer. Without it, the first random signup would become Selva staff.\n *\n * The env var also doubles as the break-glass recovery path when admin is\n * lost to backup restores or migration drift.\n */\nexport function shouldBootstrapAdmin(\n\tuser: AuthUser,\n\tconfiguredEmail: string | undefined,\n\tmode: TenancyMode\n): boolean {\n\tconst expected = configuredEmail?.trim().toLowerCase();\n\tif (mode === 'multi' && !expected) return false;\n\tif (!expected) return true;\n\tconst actual = user.email?.trim().toLowerCase();\n\treturn !!actual && actual === expected;\n}\n\n/**\n * Header-auth variant of `shouldBootstrapAdmin`, used by\n * `wireHeaderAuthBootstrap` to decide whether an unrecognized UPN arriving\n * through the proxy should be auto-allowlisted as the first admin. Operates\n * on the raw UPN/email before any allowlist row exists. For Entra\n * deployments UPN ≈ email; if they differ, the proxy forwards both and we\n * prefer email when present.\n */\nfunction shouldBootstrapUpn(\n\tupn: string,\n\temail: string | undefined,\n\tconfiguredEmail: string | undefined,\n\tmode: TenancyMode\n): boolean {\n\tconst expected = configuredEmail?.trim().toLowerCase();\n\tif (mode === 'multi' && !expected) return false;\n\tif (!expected) return true;\n\tconst candidate = (email ?? upn).trim().toLowerCase();\n\treturn !!candidate && candidate === expected;\n}\n\n/**\n * Wires a bootstrap-allowlist policy onto the auth provider if it supports\n * header-auth-style first-admin bootstrapping. Idempotent — safe to call on\n * every startup; the provider holds the policy until process exit.\n *\n * Header-auth deployments can't reach `/setup` (no password form, no OAuth\n * callback), so without this the first proxy-authenticated visitor is\n * silently rejected (UPN not in allowlist) and the operator has to\n * hand-write JSON files. With it, the first visit whose UPN/email matches\n * `BOOTSTRAP_INSTANCE_ADMIN_EMAIL` is auto-allowlisted, and the immediately\n * following `bootstrapUserSession` call grants instance_admin.\n *\n * Gated by `hasInstanceAdmin` — once any admin exists, the policy returns\n * false and strict allowlist-only behavior resumes.\n */\nexport function wireHeaderAuthBootstrap(): void {\n\tconst auth = getAuthProvider() as unknown as {\n\t\tproxyAuth?: unknown;\n\t\tsetBootstrapAllowlistPolicy?: (\n\t\t\tpolicy: ((p: { upn: string; email: string | undefined }) => boolean | Promise<boolean>) | null\n\t\t) => void;\n\t};\n\t// Non-proxy providers (Local, Supabase) bootstrap admin through /setup or\n\t// the OAuth callback — this is a no-op for them. Without this guard the\n\t// warning below misfires for every LocalAuthProvider deployment that sets\n\t// BOOTSTRAP_INSTANCE_ADMIN_EMAIL.\n\tif (!auth.proxyAuth) return;\n\n\tif (typeof auth.setBootstrapAllowlistPolicy !== 'function') {\n\t\t// A stale @selvajs/header-auth-provider build doesn't expose this hook.\n\t\t// Without a warning the operator sees `user:null` indefinitely with no\n\t\t// signal to upgrade or hand-seed the allowlist.\n\t\tif (env.BOOTSTRAP_INSTANCE_ADMIN_EMAIL?.trim()) {\n\t\t\tgetLogger().warn(\n\t\t\t\t'BOOTSTRAP_INSTANCE_ADMIN_EMAIL is set but the installed @selvajs/header-auth-provider ' +\n\t\t\t\t\t'does not expose setBootstrapAllowlistPolicy. Upgrade the provider, or hand-seed ' +\n\t\t\t\t\t'header-allowlist.json.',\n\t\t\t\t{ component: 'auth-bootstrap' }\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tauth.setBootstrapAllowlistPolicy(async ({ upn, email }) => {\n\t\tconst hasAdmin = await getPermissionStore().hasInstanceAdmin(SYSTEM_CONTEXT);\n\t\tif (hasAdmin) return false;\n\t\treturn shouldBootstrapUpn(upn, email, env.BOOTSTRAP_INSTANCE_ADMIN_EMAIL, getTenancy());\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,eAAsB,qBAAqB,MAA+B;CACzE,MAAM,gBAAgB,CAAC,CAAC,WAAW,gBAAgB,KAAK,EAAE;CAE1D,MAAM,UAAU,WAAW;CAC3B,MAAM,QAAQ,mBAAmB;CACjC,MAAM,WAAW,MAAM,MAAM,iBAAiB,cAAc;CAC5D,IAAI,mBAAmB;CACvB,IAAI,CAAC,UAAU;EACd,IAAI,CAAC,qBAAqB,MAAM,IAAI,gCAAgC,OAAO,GAAG;EAM9E,mBAAmB,MAAM,MAAM,wBAAwB,gBAAgB,KAAK,IAAI,CAC/E,GAAG,wBACJ,CAAC;EAGD,IAAI,CAAC,kBAAkB;CACxB;CAMA,IAAI,YAAY,UAAU;CAG1B,KAAI,MAFS,wBACU,CAAA,CAAK,SAAS,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAA,CACpD,MAAM,SAAS,GAAG;CAI/B,IAAI,CAAC,kBAEA;MAAA,EAAC,MADmB,MAAM,OAAO,gBAAgB,KAAK,EAAE,EAAA,CAC7C,SAAS,gBAAgB,GAAG;CAAA;CAE5C,MAAM,6BAA6B,IAAI;AACxC;;;;;;;;;AAUA,eAAe,6BAA6B,MAA+B;CAC1E,IAAI,WAAW,MAAM,UAAU;CAC/B,MAAM,OAAO,wBAAwB;CAErC,KAAI,MADmB,KAAK,SAAS,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAA,CACpD,MAAM,SAAS,GAAG;CAI/B,MAAM,WADL,OAAO,KAAK,UAAU,gBAAgB,WAAW,KAAK,SAAS,cAAc,KAAA,EAAA,EACjD,KAAK,KAAK,KAAK,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK;CAC5E,MAAM,OAAO,gBAAgB,OAAO;CAEpC,MAAM,uBAAM,IAAI,KAAK,EAAA,CAAE,YAAY;CACnC,MAAM,MAAoB;EACzB,IAAI,WAAW;EACf,MAAM;EACN;EACA,SAAS,KAAK;EACd,WAAW,KAAK;EAChB,WAAW,KAAK;EAChB,WAAW;EACX,WAAW;EACX,WAAW;CACZ;CACA,MAAM,KAAK,UAAU,gBAAgB,GAAG;CAExC,MAAM,WAAW,mBAAmB;CACpC,MAAM,UAAmB;EACxB,IAAI,WAAW;EACf,OAAO,IAAI;EACX,MAAM;EACN,MAAM;EACN,YAAY;EACZ,SAAS,KAAK;EACd,WAAW,KAAK;EAChB,WAAW,KAAK;EAChB,kBAAkB;EAClB,WAAW;EACX,WAAW;EACX,WAAW;CACZ;CACA,MAAM,SAAS,cAAc,gBAAgB,OAAO;AACrD;;;;;;;;;;;;;;AAeA,SAAgB,qBACf,MACA,iBACA,MACU;CACV,MAAM,WAAW,iBAAiB,KAAK,CAAC,CAAC,YAAY;CACrD,IAAI,SAAS,WAAW,CAAC,UAAU,OAAO;CAC1C,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,SAAS,KAAK,OAAO,KAAK,CAAC,CAAC,YAAY;CAC9C,OAAO,CAAC,CAAC,UAAU,WAAW;AAC/B;;;;;;;;;AAUA,SAAS,mBACR,KACA,OACA,iBACA,MACU;CACV,MAAM,WAAW,iBAAiB,KAAK,CAAC,CAAC,YAAY;CACrD,IAAI,SAAS,WAAW,CAAC,UAAU,OAAO;CAC1C,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,aAAa,SAAS,IAAA,CAAK,KAAK,CAAC,CAAC,YAAY;CACpD,OAAO,CAAC,CAAC,aAAa,cAAc;AACrC;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BAAgC;CAC/C,MAAM,OAAO,gBAAgB;CAU7B,IAAI,CAAC,KAAK,WAAW;CAErB,IAAI,OAAO,KAAK,gCAAgC,YAAY;EAI3D,IAAI,IAAI,gCAAgC,KAAK,GAC5C,UAAU,CAAC,CAAC,KACX,gMAGA,EAAE,WAAW,iBAAiB,CAC/B;EAED;CACD;CAEA,KAAK,4BAA4B,OAAO,EAAE,KAAK,YAAY;EAE1D,IAAI,MADmB,mBAAmB,CAAC,CAAC,iBAAiB,cAAc,GAC7D,OAAO;EACrB,OAAO,mBAAmB,KAAK,OAAO,IAAI,gCAAgC,WAAW,CAAC;CACvF,CAAC;AACF"}
|
|
1
|
+
{"version":3,"file":"auth-bootstrap.server.js","names":[],"sources":["../../../../platform/src/config/setup-token.ts","../../../src/lib/server/auth-bootstrap.server.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto';\n\n/**\n * The secret in the first-run setup link. Derived from `SELVA_HMAC_KEY`, so\n * claiming an instance that has no admin takes read access to its `.env`.\n * Stateless: every instance and the CLI compute the same value.\n */\nexport function setupToken(hmacKey: string): string {\n\treturn createHmac('sha256', hmacKey.trim()).update('selva:setup:v1').digest('base64url');\n}\n\nexport function isSetupToken(candidate: string | null | undefined, hmacKey: string): boolean {\n\tif (!candidate) return false;\n\tconst expected = Buffer.from(setupToken(hmacKey));\n\tconst given = Buffer.from(candidate);\n\treturn given.length === expected.length && timingSafeEqual(given, expected);\n}\n\n/** Where the operator claims the instance. `origin` has no trailing slash. */\nexport function setupUrl(origin: string, hmacKey: string): string {\n\treturn `${origin.replace(/\\/+$/, '')}/setup?token=${setupToken(hmacKey)}`;\n}\n","import { env } from '#lib/server/env.js';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { randomUUID } from 'node:crypto';\nimport type { Cookies } from '@sveltejs/kit';\nimport {\n\tALL_PLATFORM_PERMISSIONS,\n\tSYSTEM_CONTEXT,\n\ttype AuthUser,\n\ttype Organization,\n\ttype Project\n} from '@selvajs/platform';\nimport { isSetupToken } from '@selvajs/platform/config';\nimport {\n\tgetAuthProvider,\n\tgetDataProvider,\n\tgetLogger,\n\tgetOrganizationProvider,\n\tgetPermissionStore,\n\tgetProjectProvider,\n\tgetTenancy\n} from './providers.server.js';\nimport { cookiesAreSecure } from './admin-auth.server.js';\nimport { orgSlugFromName } from '@selvajs/platform';\n\n// ============================================================================\n// Setup-link proof\n// ============================================================================\n\nconst SETUP_PROOF_COOKIE = 'selva_setup';\n\n/**\n * Keeps a valid setup link across the sign-in round-trip, so an IdP callback\n * can tell the operator from whoever else reached the host first. Lax, not\n * Strict: the OAuth callback arrives as a cross-site redirect.\n */\nexport function rememberSetupProof(cookies: Cookies, token: string): void {\n\tcookies.set(SETUP_PROOF_COOKIE, token, {\n\t\tpath: '/',\n\t\thttpOnly: true,\n\t\tsameSite: 'lax',\n\t\tsecure: cookiesAreSecure(),\n\t\tmaxAge: 60 * 60\n\t});\n}\n\nexport function hasSetupProof(cookies: Cookies): boolean {\n\tconst hmacKey = env.SELVA_HMAC_KEY;\n\treturn !!hmacKey && isSetupToken(cookies.get(SETUP_PROOF_COOKIE), hmacKey);\n}\n\n// The header-auth allowlist policy is called without the request, so the proxy\n// path hands it the proof through here.\nconst proxySetupProof = new AsyncLocalStorage<boolean>();\n\nexport function identifyWithSetupProof<T>(\n\tsetupProven: boolean,\n\tidentify: () => Promise<T>\n): Promise<T> {\n\treturn proxySetupProof.run(setupProven, identify);\n}\n\n// ============================================================================\n// First-admin bootstrap\n// ============================================================================\n\n/**\n * Shared post-verification flow used by every IdP-callback route (OAuth,\n * email link, future SAML, …). Order matters:\n *\n * 1. `data.ensureUser` — guarantee a user-data row exists for whatever ID\n * the auth provider issued. Local-provider creates a JSON row;\n * Supabase no-ops (its DB trigger has already fired).\n * 2. Bootstrap-admin grant — if no instance_admin exists yet AND\n * `shouldBootstrapAdmin` allows it, grant the signing-in user every\n * platform permission so `/admin` becomes reachable.\n * 3. Single-tenant org seed — create the default Organization + Project\n * owned by the new admin, mirroring what `/setup` does for password\n * auth. Without this, org-scoped permissions (manage_projects,\n * manage_definitions) silently drop because `actingOrgId` resolves to\n * undefined.\n *\n * Cookie/redirect are the caller's job since they vary by capability (OAuth\n * has refresh tokens, magic-link does sometimes, SAML doesn't).\n */\nexport async function bootstrapUserSession(user: AuthUser, setupProven: boolean): Promise<void> {\n\tawait getDataProvider().ensureUser(SYSTEM_CONTEXT, user.id);\n\n\tconst tenancy = getTenancy();\n\tconst perms = getPermissionStore();\n\tconst hasAdmin = await perms.hasInstanceAdmin(SYSTEM_CONTEXT);\n\tlet grantedAdminHere = false;\n\tif (!hasAdmin) {\n\t\tif (!shouldBootstrapAdmin(user.email, env.BOOTSTRAP_INSTANCE_ADMIN_EMAIL, setupProven)) return;\n\t\t// `claimFirstInstanceAdmin`, not `set`: the probe above and the write are\n\t\t// two round-trips, and two eligible sign-ins at the same moment would both\n\t\t// see \"no admin\". The store re-checks under a lock and only one wins.\n\t\tgrantedAdminHere = await perms.claimFirstInstanceAdmin(SYSTEM_CONTEXT, user.id, [\n\t\t\t...ALL_PLATFORM_PERMISSIONS\n\t\t]);\n\t\t// Lost the race: an admin now exists and it is not this user. Everything\n\t\t// below is org self-heal, which the winner performs.\n\t\tif (!grantedAdminHere) return;\n\t}\n\n\t// Self-heal: deployments that skipped /setup (header-auth, OAuth callback)\n\t// can be left without a default org, dropping org-scoped permissions\n\t// silently. Seed it if missing; once it exists this is a single cheap\n\t// listOrgs read per request and an early-return.\n\tif (tenancy !== 'single') return;\n\tconst orgs = getOrganizationProvider();\n\tconst existing = await orgs.listOrgs(SYSTEM_CONTEXT, { limit: 1 });\n\tif (existing.items.length > 0) return;\n\n\t// Only the instance admin owns the freshly-created org. Skip the read if\n\t// we just granted it above; otherwise re-check for the self-heal path.\n\tif (!grantedAdminHere) {\n\t\tconst userPerms = await perms.getFor(SYSTEM_CONTEXT, user.id);\n\t\tif (!userPerms.includes('instance_admin')) return;\n\t}\n\tawait ensureSingleTenantDefaultOrg(user);\n}\n\n/**\n * Seeds the single default Organization + Project that `actingOrgId` needs\n * to resolve, for flows that skip `/setup` (header-auth, OAuth callback,\n * future SAML). No-op outside single-tenant mode and once any org exists.\n * Slug derives from the admin's email/displayName so the URL looks like the\n * deployment rather than a UUID; falls back to `default` for anonymous\n * UPN-only sign-ins.\n */\nasync function ensureSingleTenantDefaultOrg(user: AuthUser): Promise<void> {\n\tif (getTenancy() !== 'single') return;\n\tconst orgs = getOrganizationProvider();\n\tconst existing = await orgs.listOrgs(SYSTEM_CONTEXT, { limit: 1 });\n\tif (existing.items.length > 0) return;\n\n\tconst displayName =\n\t\ttypeof user.metadata?.displayName === 'string' ? user.metadata.displayName : undefined;\n\tconst orgName = displayName?.trim() || user.email?.split('@')[0]?.trim() || 'Default';\n\tconst slug = orgSlugFromName(orgName);\n\n\tconst now = new Date().toISOString();\n\tconst org: Organization = {\n\t\tid: randomUUID(),\n\t\tname: orgName,\n\t\tslug,\n\t\townerId: user.id,\n\t\tcreatedBy: user.id,\n\t\tupdatedBy: user.id,\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t\tdeletedAt: null\n\t};\n\tawait orgs.createOrg(SYSTEM_CONTEXT, org);\n\n\tconst projects = getProjectProvider();\n\tconst project: Project = {\n\t\tid: randomUUID(),\n\t\torgId: org.id,\n\t\tname: 'Default',\n\t\tslug: 'default',\n\t\tvisibility: 'public',\n\t\townerId: user.id,\n\t\tcreatedBy: user.id,\n\t\tupdatedBy: user.id,\n\t\tautoJoinOnUpload: false,\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t\tdeletedAt: null\n\t};\n\tawait projects.createProject(SYSTEM_CONTEXT, project);\n}\n\n/**\n * Whether a sign-in may claim the empty instance. Pure, so the policy is\n * unit-testable. The claim has to be proven:\n *\n * - `BOOTSTRAP_INSTANCE_ADMIN_EMAIL` set: only that address. The IdP has\n * proven it by the time this runs.\n * - Unset: only a browser that opened the setup link, which takes read access\n * to the deployment's `.env`. Otherwise whoever reached the host first\n * would become admin.\n *\n * The env var also doubles as the break-glass recovery path when admin is\n * lost to backup restores or migration drift.\n */\nexport function shouldBootstrapAdmin(\n\temail: string | undefined,\n\tconfiguredEmail: string | undefined,\n\tsetupProven: boolean\n): boolean {\n\tconst expected = configuredEmail?.trim().toLowerCase();\n\tif (!expected) return setupProven;\n\tconst actual = email?.trim().toLowerCase();\n\treturn !!actual && actual === expected;\n}\n\n/**\n * Wires a bootstrap-allowlist policy onto the auth provider if it supports\n * header-auth-style first-admin bootstrapping. Idempotent — safe to call on\n * every startup; the provider holds the policy until process exit.\n *\n * Header-auth deployments have no sign-in form or callback, so without this\n * the first proxy-authenticated visitor is silently rejected (UPN not in\n * allowlist) and the operator has to hand-write JSON files. With it, the first\n * visit `shouldBootstrapAdmin` accepts is auto-allowlisted, and the immediately\n * following `bootstrapUserSession` call grants instance_admin. For Entra\n * deployments UPN ≈ email; when the proxy forwards both, the email is matched.\n *\n * Gated by `hasInstanceAdmin` — once any admin exists, the policy returns\n * false and strict allowlist-only behavior resumes.\n */\nexport function wireHeaderAuthBootstrap(): void {\n\tconst auth = getAuthProvider() as unknown as {\n\t\tproxyAuth?: unknown;\n\t\tsetBootstrapAllowlistPolicy?: (\n\t\t\tpolicy: ((p: { upn: string; email: string | undefined }) => boolean | Promise<boolean>) | null\n\t\t) => void;\n\t};\n\t// Non-proxy providers (Local, Supabase) bootstrap admin through /setup or\n\t// the OAuth callback — this is a no-op for them. Without this guard the\n\t// warning below misfires for every LocalAuthProvider deployment that sets\n\t// BOOTSTRAP_INSTANCE_ADMIN_EMAIL.\n\tif (!auth.proxyAuth) return;\n\n\tif (typeof auth.setBootstrapAllowlistPolicy !== 'function') {\n\t\t// A stale @selvajs/header-auth-provider build doesn't expose this hook.\n\t\t// Without a warning the operator sees `user:null` indefinitely with no\n\t\t// signal to upgrade or hand-seed the allowlist.\n\t\tif (env.BOOTSTRAP_INSTANCE_ADMIN_EMAIL?.trim()) {\n\t\t\tgetLogger().warn(\n\t\t\t\t'BOOTSTRAP_INSTANCE_ADMIN_EMAIL is set but the installed @selvajs/header-auth-provider ' +\n\t\t\t\t\t'does not expose setBootstrapAllowlistPolicy. Upgrade the provider, or hand-seed ' +\n\t\t\t\t\t'header-allowlist.json.',\n\t\t\t\t{ component: 'auth-bootstrap' }\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tauth.setBootstrapAllowlistPolicy(async ({ upn, email }) => {\n\t\tconst hasAdmin = await getPermissionStore().hasInstanceAdmin(SYSTEM_CONTEXT);\n\t\tif (hasAdmin) return false;\n\t\treturn shouldBootstrapAdmin(\n\t\t\temail ?? upn,\n\t\t\tenv.BOOTSTRAP_INSTANCE_ADMIN_EMAIL,\n\t\t\tproxySetupProof.getStore() === true\n\t\t);\n\t});\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as deploymentSnapshot, D as computeDebugMode, E as RETIRED_KEYS,
|
|
1
|
+
import { A as deploymentSnapshot, D as computeDebugMode, E as RETIRED_KEYS, O as deploymentManifest, Y as diffSnapshots, f as getLogger, j as keyRotationStatus, k as deploymentReport } from "./providers.server.js";
|
|
2
2
|
import { n as env } from "./previous-key.js";
|
|
3
3
|
import { tt as resolveConfig } from "./access.js";
|
|
4
4
|
import { t as findDeploymentDir } from "./selfUpdate.server.js";
|
|
@@ -4,9 +4,31 @@ import { n as renderThrown } from "./definitions.js";
|
|
|
4
4
|
var cached = null;
|
|
5
5
|
var inflight = null;
|
|
6
6
|
async function run() {
|
|
7
|
+
let schemaVersion = null;
|
|
8
|
+
const data = providers.data;
|
|
9
|
+
if (typeof data.verifySchemaVersion === "function") try {
|
|
10
|
+
schemaVersion = await data.verifySchemaVersion();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
getLogger().error("verifySchemaVersion threw — treating as failure", {
|
|
13
|
+
component: "boot",
|
|
14
|
+
err: renderThrown(err)
|
|
15
|
+
});
|
|
16
|
+
schemaVersion = {
|
|
17
|
+
ok: false,
|
|
18
|
+
expected: "(unknown)",
|
|
19
|
+
actual: null,
|
|
20
|
+
message: err instanceof Error ? err.message : String(err)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (schemaVersion && !schemaVersion.ok) getLogger().error("Database schema handshake failed. /api/health will return 503.", {
|
|
24
|
+
component: "boot",
|
|
25
|
+
expected: schemaVersion.expected,
|
|
26
|
+
actual: schemaVersion.actual ?? "unavailable",
|
|
27
|
+
detail: schemaVersion.message
|
|
28
|
+
});
|
|
7
29
|
let atRestSecrets = null;
|
|
8
30
|
const store = providers.data.computeServer;
|
|
9
|
-
if (typeof store.reencryptSecrets === "function") try {
|
|
31
|
+
if (schemaVersion?.ok !== false && typeof store.reencryptSecrets === "function") try {
|
|
10
32
|
const resealed = await store.reencryptSecrets();
|
|
11
33
|
if (resealed > 0) getLogger().info("Re-sealed compute API keys under the current SELVA_AT_REST_KEY", {
|
|
12
34
|
component: "boot",
|
|
@@ -46,28 +68,6 @@ async function run() {
|
|
|
46
68
|
});
|
|
47
69
|
getLogger().error("At-rest secret verification failed. /api/health will return 503. Recover by re-entering the affected apiKeys via /admin/compute, or by restoring the original SELVA_AT_REST_KEY. See docs/Troubleshooting.md.", { component: "boot" });
|
|
48
70
|
}
|
|
49
|
-
let schemaVersion = null;
|
|
50
|
-
const data = providers.data;
|
|
51
|
-
if (typeof data.verifySchemaVersion === "function") try {
|
|
52
|
-
schemaVersion = await data.verifySchemaVersion();
|
|
53
|
-
} catch (err) {
|
|
54
|
-
getLogger().error("verifySchemaVersion threw — treating as failure", {
|
|
55
|
-
component: "boot",
|
|
56
|
-
err: renderThrown(err)
|
|
57
|
-
});
|
|
58
|
-
schemaVersion = {
|
|
59
|
-
ok: false,
|
|
60
|
-
expected: "(unknown)",
|
|
61
|
-
actual: null,
|
|
62
|
-
message: err instanceof Error ? err.message : String(err)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (schemaVersion && !schemaVersion.ok) getLogger().error("Database schema handshake failed. /api/health will return 503.", {
|
|
66
|
-
component: "boot",
|
|
67
|
-
expected: schemaVersion.expected,
|
|
68
|
-
actual: schemaVersion.actual ?? "unavailable",
|
|
69
|
-
detail: schemaVersion.message
|
|
70
|
-
});
|
|
71
71
|
return {
|
|
72
72
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
73
73
|
atRestSecrets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootHealth.server.js","names":[],"sources":["../../../src/lib/server/bootHealth.server.ts"],"sourcesContent":["import type { SchemaVersionReport, SecretVerificationReport } from '@selvajs/platform';\nimport { renderThrown } from '@selvajs/server/logging';\nimport { getLogger, providers } from './providers.server.js';\n\n/**\n * Boot-time integrity report. Checks at-rest secret decryption (compute\n * server apiKeys) for any provider that exposes `verifySecrets` — both the\n * local (on-disk) and Supabase (in-DB) compute-server stores encrypt apiKeys\n * and implement it.\n *\n * Goals:\n * - Fail loudly at deploy time when `SELVA_AT_REST_KEY` doesn't match what\n * `.selva-data/compute.config.json` was encrypted with, so a rotated key\n * or a misplaced backup doesn't surface as a blank `/projects` page later.\n * - Drive `/api/health` to non-200 when degraded, so load balancers and\n * monitoring catch the state without a human reading server logs.\n *\n * Does NOT block request serving — paired with per-row tolerance in\n * `LocalComputeServerStore.decryptApiKeys`, the app keeps rendering and an\n * operator can recover via `/admin/compute`.\n */\nexport interface BootHealth {\n\tcheckedAt: string;\n\tatRestSecrets: SecretVerificationReport | null;\n\t/**\n\t * App↔DB schema handshake — null when the data provider doesn't implement\n\t * it (local provider: schema and app ship together). A not-ok report\n\t * degrades `/api/health` to 503, which also makes the self-update\n\t * runner's health probe roll back an update whose migrations weren't\n\t * applied, instead of leaving a skewed app serving PGRST errors.\n\t */\n\tschemaVersion: SchemaVersionReport | null;\n}\n\nlet cached: BootHealth | null = null;\nlet inflight: Promise<BootHealth> | null = null;\n\nasync function run(): Promise<BootHealth> {\n\tlet atRestSecrets: SecretVerificationReport | null = null;\n\n\tconst store = providers.data.computeServer;\n\t// Before verifying: rows sealed under SELVA_AT_REST_KEY_PREVIOUS or in an\n\t// older envelope move to the current key and envelope, so the previous key\n\t// can be dropped. Once per process, here,\n\t// because verifySecrets also serves an admin GET and must not write.\n\tif (typeof store.reencryptSecrets === 'function') {\n\t\ttry {\n\t\t\tconst resealed = await store.reencryptSecrets();\n\t\t\tif (resealed > 0) {\n\t\t\t\tgetLogger().info('Re-sealed compute API keys under the current SELVA_AT_REST_KEY', {\n\t\t\t\t\tcomponent: 'boot',\n\t\t\t\t\tcount: resealed\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tgetLogger().error('Re-sealing compute API keys failed', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\terr: renderThrown(err)\n\t\t\t});\n\t\t}\n\t}\n\tif (typeof store.verifySecrets === 'function') {\n\t\ttry {\n\t\t\tatRestSecrets = await store.verifySecrets();\n\t\t} catch (err) {\n\t\t\tgetLogger().error('verifySecrets threw — treating as failure', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\terr: renderThrown(err)\n\t\t\t});\n\t\t\tatRestSecrets = {\n\t\t\t\tok: false,\n\t\t\t\tplaintextFound: false,\n\t\t\t\tfailures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tserverId: '(unknown)',\n\t\t\t\t\t\tserverLabel: '(unknown)',\n\t\t\t\t\t\treason: 'key_mismatch',\n\t\t\t\t\t\tcause: err instanceof Error ? err.message : String(err)\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\t\t}\n\t}\n\n\tif (atRestSecrets && !atRestSecrets.ok) {\n\t\tfor (const f of atRestSecrets.failures) {\n\t\t\tgetLogger().error('At-rest secret verification failed for compute server', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\tserverLabel: f.serverLabel,\n\t\t\t\tserverId: f.serverId,\n\t\t\t\treason: f.reason,\n\t\t\t\tcause: f.cause\n\t\t\t});\n\t\t}\n\t\tgetLogger().error(\n\t\t\t'At-rest secret verification failed. /api/health will return 503. ' +\n\t\t\t\t'Recover by re-entering the affected apiKeys via /admin/compute, or by ' +\n\t\t\t\t'restoring the original SELVA_AT_REST_KEY. See docs/Troubleshooting.md.',\n\t\t\t{ component: 'boot' }\n\t\t);\n\t}\n\n\
|
|
1
|
+
{"version":3,"file":"bootHealth.server.js","names":[],"sources":["../../../src/lib/server/bootHealth.server.ts"],"sourcesContent":["import type { SchemaVersionReport, SecretVerificationReport } from '@selvajs/platform';\nimport { renderThrown } from '@selvajs/server/logging';\nimport { getLogger, providers } from './providers.server.js';\n\n/**\n * Boot-time integrity report. Checks at-rest secret decryption (compute\n * server apiKeys) for any provider that exposes `verifySecrets` — both the\n * local (on-disk) and Supabase (in-DB) compute-server stores encrypt apiKeys\n * and implement it.\n *\n * Goals:\n * - Fail loudly at deploy time when `SELVA_AT_REST_KEY` doesn't match what\n * `.selva-data/compute.config.json` was encrypted with, so a rotated key\n * or a misplaced backup doesn't surface as a blank `/projects` page later.\n * - Drive `/api/health` to non-200 when degraded, so load balancers and\n * monitoring catch the state without a human reading server logs.\n *\n * Does NOT block request serving — paired with per-row tolerance in\n * `LocalComputeServerStore.decryptApiKeys`, the app keeps rendering and an\n * operator can recover via `/admin/compute`.\n */\nexport interface BootHealth {\n\tcheckedAt: string;\n\tatRestSecrets: SecretVerificationReport | null;\n\t/**\n\t * App↔DB schema handshake — null when the data provider doesn't implement\n\t * it (local provider: schema and app ship together). A not-ok report\n\t * degrades `/api/health` to 503, which also makes the self-update\n\t * runner's health probe roll back an update whose migrations weren't\n\t * applied, instead of leaving a skewed app serving PGRST errors.\n\t */\n\tschemaVersion: SchemaVersionReport | null;\n}\n\nlet cached: BootHealth | null = null;\nlet inflight: Promise<BootHealth> | null = null;\n\nasync function run(): Promise<BootHealth> {\n\tlet schemaVersion: SchemaVersionReport | null = null;\n\tconst data = providers.data;\n\tif (typeof data.verifySchemaVersion === 'function') {\n\t\ttry {\n\t\t\tschemaVersion = await data.verifySchemaVersion();\n\t\t} catch (err) {\n\t\t\t// verifySchemaVersion must not throw by contract; treat a throw as failure.\n\t\t\tgetLogger().error('verifySchemaVersion threw — treating as failure', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\terr: renderThrown(err)\n\t\t\t});\n\t\t\tschemaVersion = {\n\t\t\t\tok: false,\n\t\t\t\texpected: '(unknown)',\n\t\t\t\tactual: null,\n\t\t\t\tmessage: err instanceof Error ? err.message : String(err)\n\t\t\t};\n\t\t}\n\t}\n\n\tif (schemaVersion && !schemaVersion.ok) {\n\t\tgetLogger().error('Database schema handshake failed. /api/health will return 503.', {\n\t\t\tcomponent: 'boot',\n\t\t\texpected: schemaVersion.expected,\n\t\t\tactual: schemaVersion.actual ?? 'unavailable',\n\t\t\tdetail: schemaVersion.message\n\t\t});\n\t}\n\n\tlet atRestSecrets: SecretVerificationReport | null = null;\n\n\tconst store = providers.data.computeServer;\n\t// Before verifying: rows sealed under SELVA_AT_REST_KEY_PREVIOUS or in an\n\t// older envelope move to the current key and envelope, so the previous key\n\t// can be dropped. Once per process, here,\n\t// because verifySecrets also serves an admin GET and must not write.\n\t// Skipped when the schema handshake failed: the update runner answers that 503 by\n\t// reinstalling the previous version, which could not read keys already re-sealed\n\t// in this version's envelope.\n\tif (schemaVersion?.ok !== false && typeof store.reencryptSecrets === 'function') {\n\t\ttry {\n\t\t\tconst resealed = await store.reencryptSecrets();\n\t\t\tif (resealed > 0) {\n\t\t\t\tgetLogger().info('Re-sealed compute API keys under the current SELVA_AT_REST_KEY', {\n\t\t\t\t\tcomponent: 'boot',\n\t\t\t\t\tcount: resealed\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tgetLogger().error('Re-sealing compute API keys failed', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\terr: renderThrown(err)\n\t\t\t});\n\t\t}\n\t}\n\tif (typeof store.verifySecrets === 'function') {\n\t\ttry {\n\t\t\tatRestSecrets = await store.verifySecrets();\n\t\t} catch (err) {\n\t\t\tgetLogger().error('verifySecrets threw — treating as failure', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\terr: renderThrown(err)\n\t\t\t});\n\t\t\tatRestSecrets = {\n\t\t\t\tok: false,\n\t\t\t\tplaintextFound: false,\n\t\t\t\tfailures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tserverId: '(unknown)',\n\t\t\t\t\t\tserverLabel: '(unknown)',\n\t\t\t\t\t\treason: 'key_mismatch',\n\t\t\t\t\t\tcause: err instanceof Error ? err.message : String(err)\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\t\t}\n\t}\n\n\tif (atRestSecrets && !atRestSecrets.ok) {\n\t\tfor (const f of atRestSecrets.failures) {\n\t\t\tgetLogger().error('At-rest secret verification failed for compute server', {\n\t\t\t\tcomponent: 'boot',\n\t\t\t\tserverLabel: f.serverLabel,\n\t\t\t\tserverId: f.serverId,\n\t\t\t\treason: f.reason,\n\t\t\t\tcause: f.cause\n\t\t\t});\n\t\t}\n\t\tgetLogger().error(\n\t\t\t'At-rest secret verification failed. /api/health will return 503. ' +\n\t\t\t\t'Recover by re-entering the affected apiKeys via /admin/compute, or by ' +\n\t\t\t\t'restoring the original SELVA_AT_REST_KEY. See docs/Troubleshooting.md.',\n\t\t\t{ component: 'boot' }\n\t\t);\n\t}\n\n\treturn {\n\t\tcheckedAt: new Date().toISOString(),\n\t\tatRestSecrets,\n\t\tschemaVersion\n\t};\n}\n\n/**\n * Runs the underlying checks at most once — subsequent callers receive the\n * same result; in-flight callers share a single promise. Does NOT auto-refresh\n * after an operator fixes the underlying issue — restart the process to\n * re-run the boot check. That's deliberate: boot health represents the state\n * at boot, by definition.\n */\nexport function getBootHealth(): Promise<BootHealth> {\n\tif (cached) return Promise.resolve(cached);\n\tif (inflight) return inflight;\n\tinflight = run().then((result) => {\n\t\tcached = result;\n\t\tinflight = null;\n\t\treturn result;\n\t});\n\treturn inflight;\n}\n\n/** Synchronous accessor — null until the first `getBootHealth()` call resolves. */\nexport function getBootHealthSync(): BootHealth | null {\n\treturn cached;\n}\n\nexport function isDegraded(report: BootHealth): boolean {\n\tif (report.atRestSecrets !== null && !report.atRestSecrets.ok) return true;\n\tif (report.schemaVersion !== null && !report.schemaVersion.ok) return true;\n\treturn false;\n}\n"],"mappings":";;;AAkCA,IAAI,SAA4B;AAChC,IAAI,WAAuC;AAE3C,eAAe,MAA2B;CACzC,IAAI,gBAA4C;CAChD,MAAM,OAAO,UAAU;CACvB,IAAI,OAAO,KAAK,wBAAwB,YACvC,IAAI;EACH,gBAAgB,MAAM,KAAK,oBAAoB;CAChD,SAAS,KAAK;EAEb,UAAU,CAAC,CAAC,MAAM,mDAAmD;GACpE,WAAW;GACX,KAAK,aAAa,GAAG;EACtB,CAAC;EACD,gBAAgB;GACf,IAAI;GACJ,UAAU;GACV,QAAQ;GACR,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACzD;CACD;CAGD,IAAI,iBAAiB,CAAC,cAAc,IACnC,UAAU,CAAC,CAAC,MAAM,kEAAkE;EACnF,WAAW;EACX,UAAU,cAAc;EACxB,QAAQ,cAAc,UAAU;EAChC,QAAQ,cAAc;CACvB,CAAC;CAGF,IAAI,gBAAiD;CAErD,MAAM,QAAQ,UAAU,KAAK;CAQ7B,IAAI,eAAe,OAAO,SAAS,OAAO,MAAM,qBAAqB,YACpE,IAAI;EACH,MAAM,WAAW,MAAM,MAAM,iBAAiB;EAC9C,IAAI,WAAW,GACd,UAAU,CAAC,CAAC,KAAK,kEAAkE;GAClF,WAAW;GACX,OAAO;EACR,CAAC;CAEH,SAAS,KAAK;EACb,UAAU,CAAC,CAAC,MAAM,sCAAsC;GACvD,WAAW;GACX,KAAK,aAAa,GAAG;EACtB,CAAC;CACF;CAED,IAAI,OAAO,MAAM,kBAAkB,YAClC,IAAI;EACH,gBAAgB,MAAM,MAAM,cAAc;CAC3C,SAAS,KAAK;EACb,UAAU,CAAC,CAAC,MAAM,6CAA6C;GAC9D,WAAW;GACX,KAAK,aAAa,GAAG;EACtB,CAAC;EACD,gBAAgB;GACf,IAAI;GACJ,gBAAgB;GAChB,UAAU,CACT;IACC,UAAU;IACV,aAAa;IACb,QAAQ;IACR,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GACvD,CACD;EACD;CACD;CAGD,IAAI,iBAAiB,CAAC,cAAc,IAAI;EACvC,KAAK,MAAM,KAAK,cAAc,UAC7B,UAAU,CAAC,CAAC,MAAM,yDAAyD;GAC1E,WAAW;GACX,aAAa,EAAE;GACf,UAAU,EAAE;GACZ,QAAQ,EAAE;GACV,OAAO,EAAE;EACV,CAAC;EAEF,UAAU,CAAC,CAAC,MACX,iNAGA,EAAE,WAAW,OAAO,CACrB;CACD;CAEA,OAAO;EACN,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;EAClC;EACA;CACD;AACD;;;;;;;;AASA,SAAgB,gBAAqC;CACpD,IAAI,QAAQ,OAAO,QAAQ,QAAQ,MAAM;CACzC,IAAI,UAAU,OAAO;CACrB,WAAW,IAAI,CAAC,CAAC,MAAM,WAAW;EACjC,SAAS;EACT,WAAW;EACX,OAAO;CACR,CAAC;CACD,OAAO;AACR;AAOA,SAAgB,WAAW,QAA6B;CACvD,IAAI,OAAO,kBAAkB,QAAQ,CAAC,OAAO,cAAc,IAAI,OAAO;CACtE,IAAI,OAAO,kBAAkB,QAAQ,CAAC,OAAO,cAAc,IAAI,OAAO;CACtE,OAAO;AACR"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { w as lazyLogger } from "./providers.server.js";
|
|
2
2
|
import { n as env } from "./previous-key.js";
|
|
3
|
-
import {
|
|
3
|
+
import { O as createApiRateLimiter, j as resolveApiRateLimitConfig } from "./api.js";
|
|
4
4
|
import { t as createComputeRateLimiter } from "./rate-limit.js";
|
|
5
5
|
import "./compute.js";
|
|
6
|
-
import {
|
|
6
|
+
import { v as RATE_LIMIT_MAX_REQUESTS, y as RATE_LIMIT_WINDOW_MS } from "./engine.server.js";
|
|
7
7
|
// src/lib/server/computeRateLimit.server.ts
|
|
8
8
|
/**
|
|
9
9
|
* App-wide instance of the compute-solve rate limiter (fixed-window, per-key,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as definitionPaths, W as orgPaths } from "./providers.server.js";
|
|
2
2
|
import { t as SYSTEM_CONTEXT } from "./context.js";
|
|
3
3
|
import { f as listAll, p as walkPages } from "./visibility.js";
|
|
4
4
|
// ../server/src/projects/delete-with-blobs.ts
|
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
import { D as computeDebugMode,
|
|
1
|
+
import { D as computeDebugMode, M as DEFAULT_SOLVE_DEADLINE_MS, P as SolveEngine, f as getLogger, w as lazyLogger } from "./providers.server.js";
|
|
2
2
|
import { n as env } from "./previous-key.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as resolveComputeLimits } from "./limits.js";
|
|
4
|
+
import "./compute.js";
|
|
5
|
+
// src/lib/server/computeLimits.ts
|
|
6
|
+
/**
|
|
7
|
+
* Thin adapter over `@selvajs/server`'s `resolveComputeLimits`: reads the server
|
|
8
|
+
* env once and re-exports the resolved values as named constants.
|
|
9
|
+
*
|
|
10
|
+
* Client-side counterparts (in-flight compute throttle, slider debounce) are
|
|
11
|
+
* bundled into the client and can't read env — see `async-throttle.ts` in
|
|
12
|
+
* `@selvajs/solve/client` and the input components.
|
|
13
|
+
*/
|
|
14
|
+
var limits = resolveComputeLimits(env, lazyLogger);
|
|
15
|
+
/** The whole resolved object — passed wholesale to `SolveEngine` (`compute/engine.server.ts`). */
|
|
16
|
+
var computeLimits = limits;
|
|
17
|
+
var RATE_LIMIT_WINDOW_MS = limits.rateLimitWindowMs;
|
|
18
|
+
var RATE_LIMIT_MAX_REQUESTS = limits.rateLimitMaxRequests;
|
|
19
|
+
var MAX_DEFINITION_FILE_SIZE = limits.maxDefinitionFileSize;
|
|
20
|
+
var MAX_IMAGE_FILE_SIZE = limits.maxImageFileSize;
|
|
21
|
+
var COMPUTE_REQUEST_MAX_BYTES = limits.computeRequestMaxBytes;
|
|
22
|
+
var COMPUTE_RESPONSE_MAX_BYTES = limits.computeResponseMaxBytes;
|
|
23
|
+
var REMOTE_DEFINITION_MAX_BYTES = limits.remoteDefinitionMaxBytes;
|
|
24
|
+
var REMOTE_DEFINITION_FETCH_TIMEOUT_MS = limits.remoteDefinitionFetchTimeoutMs;
|
|
25
|
+
var REMOTE_DEFINITION_CACHE_TTL_MS = limits.remoteDefinitionCacheTtlMs;
|
|
26
|
+
limits.computeServerCachesolve;
|
|
27
|
+
limits.computeMaxQueueDepth;
|
|
28
|
+
limits.computeQueueWaitMs;
|
|
29
|
+
var COMPUTE_DEFINITION_CACHE_BYTES = limits.computeDefinitionCacheBytes;
|
|
30
|
+
var COMPUTE_SOLVE_CACHE_BYTES = limits.computeSolveCacheBytes;
|
|
4
31
|
// src/lib/server/compute/engine.server.ts
|
|
5
32
|
/**
|
|
6
33
|
* App-wide `SolveEngine` instance (`@selvajs/solve/server`) — backs the warm
|
|
@@ -21,12 +48,32 @@ var engine = new SolveEngine({
|
|
|
21
48
|
}
|
|
22
49
|
});
|
|
23
50
|
/** Get (or create) the warm client + scheduler for a resolved compute server. */
|
|
24
|
-
function getClient(serverConfig
|
|
51
|
+
function getClient(serverConfig) {
|
|
25
52
|
return engine.getClient({
|
|
26
53
|
id: serverConfig.id,
|
|
27
54
|
serverUrl: serverConfig.serverUrl,
|
|
28
55
|
apiKey: serverConfig.apiKey
|
|
29
|
-
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The solve deadline `server` reports, for the browser's AbortController. A cold client connects
|
|
60
|
+
* first, and a page must not wait on a slow Compute for it: past `waitMs` it gets the default.
|
|
61
|
+
* The connect carries on and warms the client for the first solve.
|
|
62
|
+
*/
|
|
63
|
+
async function solveDeadlineFor(serverConfig, waitMs = 2e3) {
|
|
64
|
+
const fallback = new Promise((resolve) => {
|
|
65
|
+
setTimeout(() => resolve(DEFAULT_SOLVE_DEADLINE_MS), waitMs).unref?.();
|
|
66
|
+
});
|
|
67
|
+
const reported = getClient(serverConfig).then(({ limits }) => limits.solveDeadlineMs, () => DEFAULT_SOLVE_DEADLINE_MS);
|
|
68
|
+
return Promise.race([reported, fallback]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The largest solve request Selva takes: the largest a warm compute server reports
|
|
72
|
+
* (`RHINO_COMPUTE_MAX_REQUEST_SIZE`), so that one setting drives both. Until a server has been
|
|
73
|
+
* reached, `COMPUTE_REQUEST_MAX_BYTES`. Each server still refuses what exceeds its own cap.
|
|
74
|
+
*/
|
|
75
|
+
function computeRequestCap() {
|
|
76
|
+
return engine.largestReportedRequestBytes() ?? COMPUTE_REQUEST_MAX_BYTES;
|
|
30
77
|
}
|
|
31
78
|
/** Drop the warm client for a server whose config just changed (URL/key rotation or deletion). */
|
|
32
79
|
function evictComputeClient(id) {
|
|
@@ -52,6 +99,6 @@ function solveCacheStats() {
|
|
|
52
99
|
function definitionByteCacheStats() {
|
|
53
100
|
return engine.stats().definitionBytes;
|
|
54
101
|
}
|
|
55
|
-
export {
|
|
102
|
+
export { REMOTE_DEFINITION_MAX_BYTES as S, MAX_IMAGE_FILE_SIZE as _, computeRequestCap as a, REMOTE_DEFINITION_CACHE_TTL_MS as b, evictComputeClient as c, solveDeadlineFor as d, COMPUTE_DEFINITION_CACHE_BYTES as f, MAX_DEFINITION_FILE_SIZE as g, COMPUTE_SOLVE_CACHE_BYTES as h, clearSolveResultCache as i, getClient as l, COMPUTE_RESPONSE_MAX_BYTES as m, COMPUTE_DEBUG_VERBOSE as n, definitionByteCacheStats as o, COMPUTE_REQUEST_MAX_BYTES as p, clearDefinitionCache as r, engine as s, COMPUTE_DEBUG as t, solveCacheStats as u, RATE_LIMIT_MAX_REQUESTS as v, REMOTE_DEFINITION_FETCH_TIMEOUT_MS as x, RATE_LIMIT_WINDOW_MS as y };
|
|
56
103
|
|
|
57
104
|
//# sourceMappingURL=engine.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.server.js","names":[],"sources":["../../../src/lib/server/compute/engine.server.ts"],"sourcesContent":["/**\n * App-wide `SolveEngine` instance (`@selvajs/solve/server`) — backs the warm\n * client cache, the definition-byte cache, and solve coalescing for the whole app.\n */\n\nimport { SolveEngine, type CachedClient } from '@selvajs/solve/server';\nimport { env } from '#lib/server/env.js';\nimport { getLogger } from '#lib/server/providers.server.js';\nimport { computeLimits } from '#lib/server/computeLimits.js';\nimport { computeDebugMode } from '#lib/server/config/settings.js';\nimport type { ComputeServerConfig } from '@selvajs/platform';\n\n// `verbose` adds lib-level request logs and Compute's raw error bodies, and implies `on`.\nconst COMPUTE_DEBUG_MODE = computeDebugMode(env);\n\nexport const COMPUTE_DEBUG = COMPUTE_DEBUG_MODE !== 'off';\nexport const COMPUTE_DEBUG_VERBOSE = COMPUTE_DEBUG_MODE === 'verbose';\n\nexport const engine = new SolveEngine({\n\tlimits: computeLimits,\n\tdebug: COMPUTE_DEBUG ? (COMPUTE_DEBUG_VERBOSE ? 'verbose' : true) : false,\n\tonDebugLog: (message) => getLogger().debug(message, { component: 'Compute/client-cache' }),\n\tonSolveCoalesced: (key) => {\n\t\tif (COMPUTE_DEBUG) {\n\t\t\t// key = version:server:tree-json — truncate the tree tail for the log.\n\t\t\tgetLogger().debug('Coalesced onto in-flight solve', {\n\t\t\t\tcomponent: 'Compute/single-flight',\n\t\t\t\tkey: `${key.slice(0, 96)}…`\n\t\t\t});\n\t\t}\n\t}\n});\n\n/** Get (or create) the warm client + scheduler for a resolved compute server. */\nexport function getClient(
|
|
1
|
+
{"version":3,"file":"engine.server.js","names":[],"sources":["../../../src/lib/server/computeLimits.ts","../../../src/lib/server/compute/engine.server.ts"],"sourcesContent":["/**\n * Thin adapter over `@selvajs/server`'s `resolveComputeLimits`: reads the server\n * env once and re-exports the resolved values as named constants.\n *\n * Client-side counterparts (in-flight compute throttle, slider debounce) are\n * bundled into the client and can't read env — see `async-throttle.ts` in\n * `@selvajs/solve/client` and the input components.\n */\n\nimport { env } from '#lib/server/env.js';\nimport { resolveComputeLimits } from '@selvajs/server/compute';\n// Limits resolve at module scope, before the pino swap — a captured logger\n// would pin the boot placeholder, so this needs the forwarding one.\nimport { lazyLogger } from '#lib/server/providers.server.js';\n\n// The logger surfaces malformed env values (a non-numeric COMPUTE_RATE_LIMIT_MAX\n// falls back to its default).\nconst limits = resolveComputeLimits(env, lazyLogger);\n\n/** The whole resolved object — passed wholesale to `SolveEngine` (`compute/engine.server.ts`). */\nexport const computeLimits = limits;\n\n// Per-key compute rate limit (see computeRateLimit.server.ts).\nexport const RATE_LIMIT_WINDOW_MS = limits.rateLimitWindowMs;\nexport const RATE_LIMIT_MAX_REQUESTS = limits.rateLimitMaxRequests;\n\n// Upload caps. Only the .gh cap is an env var. The Rhino.Compute server caps at\n// RHINO_COMPUTE_MAX_REQUEST_SIZE (default 50 MB), so raising\n// MAX_DEFINITION_FILE_SIZE_BYTES past that only defers the 413 to compute:\n// raise it there too.\nexport const MAX_DEFINITION_FILE_SIZE = limits.maxDefinitionFileSize;\nexport const MAX_IMAGE_FILE_SIZE = limits.maxImageFileSize;\n\n// /api/compute JSON request/response body caps. In a production (adapter-node)\n// build these must stay <= the global BODY_SIZE_LIMIT or the global backstop\n// rejects first; under vite dev it isn't enforced.\nexport const COMPUTE_REQUEST_MAX_BYTES = limits.computeRequestMaxBytes;\nexport const COMPUTE_RESPONSE_MAX_BYTES = limits.computeResponseMaxBytes;\n\n// Remote-definition fetch caps (SSRF + slow-loris protection sits in safe-url).\nexport const REMOTE_DEFINITION_MAX_BYTES = limits.remoteDefinitionMaxBytes;\nexport const REMOTE_DEFINITION_FETCH_TIMEOUT_MS = limits.remoteDefinitionFetchTimeoutMs;\n\n// TTL for the in-process cache of REMOTE-fetched .gh bytes. Only the remote path\n// is TTL'd — the definition cache below is keyed on an immutable version id.\nexport const REMOTE_DEFINITION_CACHE_TTL_MS = limits.remoteDefinitionCacheTtlMs;\n\n// Server-side solve-result cache (`cachesolve`).\nexport const COMPUTE_SERVER_CACHESOLVE = limits.computeServerCachesolve;\n\n// Backpressure: queue-depth cap and queue-wait deadline. Both 0 = unbounded/off.\nexport const COMPUTE_MAX_QUEUE_DEPTH = limits.computeMaxQueueDepth;\nexport const COMPUTE_QUEUE_WAIT_MS = limits.computeQueueWaitMs;\n\n// Definition cache — .gh bytes keyed on immutable version id. 0 disables.\nexport const COMPUTE_DEFINITION_CACHE_BYTES = limits.computeDefinitionCacheBytes;\n\n// Solve cache — results, PER warm client (so the worst case is ×16). 0 disables.\nexport const COMPUTE_SOLVE_CACHE_BYTES = limits.computeSolveCacheBytes;\n","/**\n * App-wide `SolveEngine` instance (`@selvajs/solve/server`) — backs the warm\n * client cache, the definition-byte cache, and solve coalescing for the whole app.\n */\n\nimport { DEFAULT_SOLVE_DEADLINE_MS, SolveEngine, type CachedClient } from '@selvajs/solve/server';\nimport { env } from '#lib/server/env.js';\nimport { getLogger } from '#lib/server/providers.server.js';\nimport { computeLimits, COMPUTE_REQUEST_MAX_BYTES } from '#lib/server/computeLimits.js';\nimport { computeDebugMode } from '#lib/server/config/settings.js';\nimport type { ComputeServerConfig } from '@selvajs/platform';\n\n// `verbose` adds lib-level request logs and Compute's raw error bodies, and implies `on`.\nconst COMPUTE_DEBUG_MODE = computeDebugMode(env);\n\nexport const COMPUTE_DEBUG = COMPUTE_DEBUG_MODE !== 'off';\nexport const COMPUTE_DEBUG_VERBOSE = COMPUTE_DEBUG_MODE === 'verbose';\n\nexport const engine = new SolveEngine({\n\tlimits: computeLimits,\n\tdebug: COMPUTE_DEBUG ? (COMPUTE_DEBUG_VERBOSE ? 'verbose' : true) : false,\n\tonDebugLog: (message) => getLogger().debug(message, { component: 'Compute/client-cache' }),\n\tonSolveCoalesced: (key) => {\n\t\tif (COMPUTE_DEBUG) {\n\t\t\t// key = version:server:tree-json — truncate the tree tail for the log.\n\t\t\tgetLogger().debug('Coalesced onto in-flight solve', {\n\t\t\t\tcomponent: 'Compute/single-flight',\n\t\t\t\tkey: `${key.slice(0, 96)}…`\n\t\t\t});\n\t\t}\n\t}\n});\n\n/** Get (or create) the warm client + scheduler for a resolved compute server. */\nexport function getClient(serverConfig: ComputeServerConfig): Promise<CachedClient> {\n\treturn engine.getClient({\n\t\tid: serverConfig.id,\n\t\tserverUrl: serverConfig.serverUrl,\n\t\tapiKey: serverConfig.apiKey\n\t});\n}\n\n/**\n * The solve deadline `server` reports, for the browser's AbortController. A cold client connects\n * first, and a page must not wait on a slow Compute for it: past `waitMs` it gets the default.\n * The connect carries on and warms the client for the first solve.\n */\nexport async function solveDeadlineFor(\n\tserverConfig: ComputeServerConfig,\n\twaitMs = 2_000\n): Promise<number> {\n\tconst fallback = new Promise<number>((resolve) => {\n\t\tsetTimeout(() => resolve(DEFAULT_SOLVE_DEADLINE_MS), waitMs).unref?.();\n\t});\n\tconst reported = getClient(serverConfig).then(\n\t\t({ limits }) => limits.solveDeadlineMs,\n\t\t() => DEFAULT_SOLVE_DEADLINE_MS\n\t);\n\treturn Promise.race([reported, fallback]);\n}\n\n/**\n * The largest solve request Selva takes: the largest a warm compute server reports\n * (`RHINO_COMPUTE_MAX_REQUEST_SIZE`), so that one setting drives both. Until a server has been\n * reached, `COMPUTE_REQUEST_MAX_BYTES`. Each server still refuses what exceeds its own cap.\n */\nexport function computeRequestCap(): number {\n\treturn engine.largestReportedRequestBytes() ?? COMPUTE_REQUEST_MAX_BYTES;\n}\n\n/** Drop the warm client for a server whose config just changed (URL/key rotation or deletion). */\nexport function evictComputeClient(id: string): void {\n\tengine.evictServer(id);\n}\n\n/**\n * Drop cached solve results held by this Selva process (every warm client's\n * scheduler). Separate from the compute server's own `cache/purge`: that one\n * clears Rhino's `cachesolve`, this one clears the layer in front of it.\n */\nexport function clearSolveResultCache(): void {\n\tengine.clearSolveCaches();\n}\n\n/** Drop the `.gh` bytes this Selva process is holding. Costs a storage re-read, nothing more. */\nexport function clearDefinitionCache(): void {\n\tengine.clearDefinitionCache();\n}\n\n/** Solve-cache counters for the admin panel's hit rate. */\nexport function solveCacheStats() {\n\treturn engine.stats().client;\n}\n\n/** Definition-byte-cache counters (hits/misses/evictions/entries/bytes) for admin/debug surfaces. */\nexport function definitionByteCacheStats() {\n\treturn engine.stats().definitionBytes;\n}\n\n/** Materialize a version's bytes through the shared byte cache (render/IO path). */\nexport function loadDefinitionBytes(\n\tversionId: string,\n\tload: () => Promise<Uint8Array>\n): Promise<Uint8Array> {\n\treturn engine.definitionRef(versionId, load).load();\n}\n\nexport type { CachedClient };\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAM,SAAS,qBAAqB,KAAK,UAAU;;AAGnD,IAAa,gBAAgB;AAG7B,IAAa,uBAAuB,OAAO;AAC3C,IAAa,0BAA0B,OAAO;AAM9C,IAAa,2BAA2B,OAAO;AAC/C,IAAa,sBAAsB,OAAO;AAK1C,IAAa,4BAA4B,OAAO;AAChD,IAAa,6BAA6B,OAAO;AAGjD,IAAa,8BAA8B,OAAO;AAClD,IAAa,qCAAqC,OAAO;AAIzD,IAAa,iCAAiC,OAAO;AAGZ,OAAO;AAGT,OAAO;AACT,OAAO;AAG5C,IAAa,iCAAiC,OAAO;AAGrD,IAAa,4BAA4B,OAAO;;;;;;AC7ChD,IAAM,qBAAqB,iBAAiB,GAAG;AAE/C,IAAa,gBAAgB,uBAAuB;AACpD,IAAa,wBAAwB,uBAAuB;AAE5D,IAAa,SAAS,IAAI,YAAY;CACrC,QAAQ;CACR,OAAO,gBAAiB,wBAAwB,YAAY,OAAQ;CACpE,aAAa,YAAY,UAAU,CAAC,CAAC,MAAM,SAAS,EAAE,WAAW,uBAAuB,CAAC;CACzF,mBAAmB,QAAQ;EAC1B,IAAI,eAEH,UAAU,CAAC,CAAC,MAAM,kCAAkC;GACnD,WAAW;GACX,KAAK,GAAG,IAAI,MAAM,GAAG,EAAE,EAAE;EAC1B,CAAC;CAEH;AACD,CAAC;;AAGD,SAAgB,UAAU,cAA0D;CACnF,OAAO,OAAO,UAAU;EACvB,IAAI,aAAa;EACjB,WAAW,aAAa;EACxB,QAAQ,aAAa;CACtB,CAAC;AACF;;;;;;AAOA,eAAsB,iBACrB,cACA,SAAS,KACS;CAClB,MAAM,WAAW,IAAI,SAAiB,YAAY;EACjD,iBAAiB,QAAQ,yBAAyB,GAAG,MAAM,CAAC,CAAC,QAAQ;CACtE,CAAC;CACD,MAAM,WAAW,UAAU,YAAY,CAAC,CAAC,MACvC,EAAE,aAAa,OAAO,uBACjB,yBACP;CACA,OAAO,QAAQ,KAAK,CAAC,UAAU,QAAQ,CAAC;AACzC;;;;;;AAOA,SAAgB,oBAA4B;CAC3C,OAAO,OAAO,4BAA4B,KAAK;AAChD;;AAGA,SAAgB,mBAAmB,IAAkB;CACpD,OAAO,YAAY,EAAE;AACtB;;;;;;AAOA,SAAgB,wBAA8B;CAC7C,OAAO,iBAAiB;AACzB;;AAGA,SAAgB,uBAA6B;CAC5C,OAAO,qBAAqB;AAC7B;;AAGA,SAAgB,kBAAkB;CACjC,OAAO,OAAO,MAAM,CAAC,CAAC;AACvB;;AAGA,SAAgB,2BAA2B;CAC1C,OAAO,OAAO,MAAM,CAAC,CAAC;AACvB"}
|