@selvajs/selva 4.20.0 → 4.20.1-beta.1
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.2jDm0bqh.css +2 -0
- 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/assets/{21.CZQvs3vE.css → 21.DDgTnace.css} +1 -1
- package/build/client/_app/immutable/assets/21.DDgTnace.css.br +0 -0
- package/build/client/_app/immutable/assets/21.DDgTnace.css.gz +0 -0
- package/build/client/_app/immutable/chunks/{DbTdXFSI.js → BDYCH-_Q.js} +1 -1
- 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/{6oDkMEbX.js → D-SwRD80.js} +62 -39
- package/build/client/_app/immutable/chunks/D-SwRD80.js.br +0 -0
- package/build/client/_app/immutable/chunks/D-SwRD80.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js +1 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.br +1 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DVcao28H.js → DzxE3j6C.js} +1 -1
- 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/{DyqtDkQe.js → qi43d-TM.js} +1 -1
- 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/chunks/zJ-SFdYZ.js +1 -0
- package/build/client/_app/immutable/chunks/zJ-SFdYZ.js.br +0 -0
- package/build/client/_app/immutable/chunks/zJ-SFdYZ.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.CN37JsEV.js → app.hg2qyLJU.js} +2 -2
- package/build/client/_app/immutable/entry/app.hg2qyLJU.js.br +0 -0
- package/build/client/_app/immutable/entry/app.hg2qyLJU.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.c6X0ddnS.js → 2.CUNbzjI_.js} +1 -1
- 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.CyrNl6i7.js → 20.9OIre0ah.js} +1 -1
- 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.gGT7QEb1.js +1 -0
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.br +1 -0
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{30.Bz0cB9UL.js → 30.BBuL_XNB.js} +2 -2
- package/build/client/_app/immutable/nodes/30.BBuL_XNB.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.BBuL_XNB.js.gz +0 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js +5 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js.br +0 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{5.Ck6I7GRI.js → 5.DmA9lTA-.js} +1 -1
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.br +1 -0
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.BiSiWLjz.js → 6.D6WLqCgl.js} +1 -1
- 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.OTA16TkX.js → 7.CNuRjkv2.js} +1 -1
- 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/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 +108 -89
- package/build/server/_app/immutable/assets/_layout.2jDm0bqh.css +2 -0
- package/build/server/_app/immutable/assets/{_page.BLIssNhc.css → _page.l97MEw0G.css} +1 -1
- package/build/server/chunks/SettingsMenu.js +2 -2
- package/build/server/chunks/SettingsMenu.js.map +1 -1
- package/build/server/chunks/{abort-CNJ8Sn4g.js → abort-Bfrdupaj.js} +10 -3
- package/build/server/chunks/{abort-CNJ8Sn4g.js.map → abort-Bfrdupaj.js.map} +1 -1
- package/build/server/chunks/access.js +608 -150
- package/build/server/chunks/access.js.map +1 -1
- package/build/server/chunks/access2.server.js +2 -2
- package/build/server/chunks/api-errors.js +1 -1
- package/build/server/chunks/api.js +66 -18
- package/build/server/chunks/api.js.map +1 -1
- package/build/server/chunks/auth-bootstrap.server.js +1 -1
- package/build/server/chunks/boot.server.js +12 -701
- package/build/server/chunks/boot.server.js.map +1 -1
- package/build/server/chunks/bootHealth.server.js.map +1 -1
- package/build/server/chunks/compute.js +1 -1
- package/build/server/chunks/computeLimits.js +1 -1
- package/build/server/chunks/computeRateLimit.server.js +1 -1
- package/build/server/chunks/context.js +9 -43
- package/build/server/chunks/context.js.map +1 -1
- package/build/server/chunks/create-project.js +2 -2
- package/build/server/chunks/delete-with-blobs.js +1 -1
- package/build/server/chunks/engine.server.js +2 -16
- package/build/server/chunks/engine.server.js.map +1 -1
- package/build/server/chunks/grasshopper.js +2 -1
- package/build/server/chunks/grasshopper.js.map +1 -1
- package/build/server/chunks/handlers.js +13 -29
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/http.js +93 -6
- package/build/server/chunks/http.js.map +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/instanceAdmins.server.js +1 -1
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/limits.js +71 -0
- package/build/server/chunks/limits.js.map +1 -0
- package/build/server/chunks/ops.js +1 -1
- package/build/server/chunks/package.js +1 -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/previous-key.js +18 -2
- package/build/server/chunks/previous-key.js.map +1 -1
- package/build/server/chunks/providers.server.js +808 -444
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +4 -1
- package/build/server/chunks/registry.js.map +1 -1
- package/build/server/chunks/remote-definition.js +1 -1
- package/build/server/chunks/safe-url.js +1 -1
- package/build/server/chunks/schema.js.map +1 -1
- package/build/server/chunks/schemas.js +12 -61
- package/build/server/chunks/schemas.js.map +1 -1
- package/build/server/chunks/schemas2.js +80 -0
- package/build/server/chunks/schemas2.js.map +1 -0
- package/build/server/chunks/server-config-write.js +3 -8
- package/build/server/chunks/server-config-write.js.map +1 -1
- package/build/server/chunks/signInMaxAge.server.js +1 -1
- package/build/server/chunks/solve.server.js +4 -2
- package/build/server/chunks/solve.server.js.map +1 -1
- package/build/server/chunks/sveltekit.js +4 -4
- package/build/server/chunks/token2.server.js +1 -1
- package/build/server/chunks/tokens.js +2 -2
- package/build/server/chunks/types.js +9 -4
- package/build/server/chunks/types.js.map +1 -1
- package/build/server/chunks/types2.js +1 -2
- package/build/server/chunks/types2.js.map +1 -1
- package/build/server/chunks/visibility.js +1 -1
- package/build/server/chunks/visibility.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +3 -3
- package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +6 -5
- package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +2 -2
- 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/update/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +2 -1
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +2 -2
- 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 +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +2 -2
- 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 +1 -1
- package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +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 +5 -4
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/hooks.server.js +3 -92
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/accept-invite/_page.server.ts.js +9 -6
- package/build/server/entries/pages/accept-invite/_page.server.ts.js.map +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 +1 -1
- package/build/server/entries/pages/admin/projects/_id_/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/projects/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/system/_page.server.ts.js +2 -2
- package/build/server/entries/pages/admin/users/_page.server.ts.js +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +114 -43
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +1 -1
- package/build/server/entries/pages/projects/_layout.server.ts.js +1 -1
- package/build/server/entries/pages/projects/_page.server.ts.js +2 -2
- package/build/server/entries/pages/setup/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/compute/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/members/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/members/_page.svelte.js +2 -2
- package/build/server/entries/pages/team/members/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/projects/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/settings/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/shares/_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/2.js +1 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/21.js +2 -2
- package/build/server/nodes/30.js +1 -1
- package/build/server/nodes/35.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 +12 -12
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css +0 -2
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css.br +0 -0
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css.gz +0 -0
- package/build/client/_app/immutable/assets/21.CZQvs3vE.css.br +0 -0
- package/build/client/_app/immutable/assets/21.CZQvs3vE.css.gz +0 -0
- package/build/client/_app/immutable/chunks/6oDkMEbX.js.br +0 -0
- package/build/client/_app/immutable/chunks/6oDkMEbX.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B9IvNrzX.js +0 -1
- package/build/client/_app/immutable/chunks/B9IvNrzX.js.br +0 -1
- package/build/client/_app/immutable/chunks/B9IvNrzX.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DVcao28H.js.br +0 -0
- package/build/client/_app/immutable/chunks/DVcao28H.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DbTdXFSI.js.br +0 -0
- package/build/client/_app/immutable/chunks/DbTdXFSI.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DyqtDkQe.js.br +0 -0
- package/build/client/_app/immutable/chunks/DyqtDkQe.js.gz +0 -0
- package/build/client/_app/immutable/chunks/I4bYfY0F.js +0 -1
- package/build/client/_app/immutable/chunks/I4bYfY0F.js.br +0 -0
- package/build/client/_app/immutable/chunks/I4bYfY0F.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CN37JsEV.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CN37JsEV.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.c6X0ddnS.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.c6X0ddnS.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.CyrNl6i7.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.CyrNl6i7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js +0 -1
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js.br +0 -0
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js.gz +0 -0
- package/build/client/_app/immutable/nodes/30.Bz0cB9UL.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.Bz0cB9UL.js.gz +0 -0
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js +0 -5
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js.br +0 -0
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.Ck6I7GRI.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.Ck6I7GRI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BiSiWLjz.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BiSiWLjz.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.OTA16TkX.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.OTA16TkX.js.gz +0 -0
- package/build/server/_app/immutable/assets/_layout.DwB0QWdx.css +0 -2
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js → 0.CYdyv5To.js} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.br → 0.CYdyv5To.js.br} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.gz → 0.CYdyv5To.js.gz} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.server.js","names":[],"sources":["../../../../platform/src/config/report.ts","../../../../platform/src/config/snapshot.ts","../../../../server/src/config/settings.ts","../../../../providers/header-auth/src/config.ts","../../../../providers/local/src/config.ts","../../../src/lib/server/config/settings.ts","../../../src/lib/server/config/checks.ts","../../../src/lib/server/config/boot.server.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport type { IntUnit, Manifest, SettingClass, SettingSpec } from './manifest.js';\nimport {\n\tresolveConfig,\n\ttype EnvRecord,\n\ttype KeyStatus,\n\ttype ResolveOptions,\n\ttype UnknownKey,\n\ttype ValueSource\n} from './resolve.js';\n\nexport interface ReportRow {\n\tkey: string;\n\tlabel?: string;\n\ttype: SettingSpec['type'];\n\trequired: boolean;\n\t/** What 0 means for an int whose 0 is a sentinel. */\n\tzero?: string;\n\tunit?: IntUnit;\n\tclass: SettingClass;\n\tsummary: boolean;\n\tdescription: string;\n\timpact?: string;\n\tsource: ValueSource;\n\tstatus: KeyStatus;\n\t/** Safe to print: secrets are a fingerprint or \"set\", never the value. */\n\tdisplay: string;\n\tproblem?: string;\n\talias?: string;\n}\n\nexport interface ConfigReport {\n\t/** Summary rows first, then the rest, each in manifest order. */\n\trows: ReportRow[];\n\t/** Rows whose value failed its rule. */\n\tproblems: ReportRow[];\n\tunknown: UnknownKey[];\n}\n\n/**\n * What `selva config show` and the admin page render. Pure, and free of\n * secret values, so the result can go to a browser or a terminal as is.\n */\nexport function buildConfigReport(\n\tmanifest: Manifest,\n\tenv: EnvRecord,\n\toptions: ResolveOptions = {}\n): ConfigReport {\n\tconst resolved = resolveConfig(manifest, env, options);\n\tconst rows: ReportRow[] = manifest.map((spec) => {\n\t\tconst k = resolved.keys[spec.key];\n\t\tconst raw = k.source === 'alias' ? env[k.alias!] : env[spec.key];\n\t\treturn {\n\t\t\tkey: spec.key,\n\t\t\t...(spec.label ? { label: spec.label } : {}),\n\t\t\ttype: spec.type,\n\t\t\trequired: spec.required === true,\n\t\t\t...(spec.type === 'int' && spec.zero ? { zero: spec.zero } : {}),\n\t\t\t...(spec.type === 'int' && spec.unit ? { unit: spec.unit } : {}),\n\t\t\tclass: spec.class,\n\t\t\tsummary: spec.summary === true,\n\t\t\tdescription: spec.description,\n\t\t\t...(spec.impact ? { impact: spec.impact } : {}),\n\t\t\tsource: k.source,\n\t\t\tstatus: k.status,\n\t\t\tdisplay: display(spec.sensitive === true, spec.generated === true, k.source, raw, k.value),\n\t\t\t...(k.problem ? { problem: k.problem } : {}),\n\t\t\t...(k.alias ? { alias: k.alias } : {})\n\t\t};\n\t});\n\treturn {\n\t\trows: [...rows.filter((r) => r.summary), ...rows.filter((r) => !r.summary)],\n\t\tproblems: rows.filter((r) => r.status !== 'ok'),\n\t\tunknown: resolved.unknown\n\t};\n}\n\nfunction display(\n\tsensitive: boolean,\n\tgenerated: boolean,\n\tsource: ValueSource,\n\traw: string | undefined,\n\tvalue: unknown\n): string {\n\tif (source === 'unset') return '';\n\tif (sensitive && raw !== undefined) {\n\t\t// A fingerprint of a 256-bit random key reveals nothing; of a password it\n\t\t// would be an offline guessing oracle.\n\t\treturn generated ? fingerprint(raw) : 'set';\n\t}\n\tif (sensitive) return 'set';\n\tif (source === 'default' || raw === undefined) return formatValue(value);\n\treturn raw.trim();\n}\n\nfunction formatValue(value: unknown): string {\n\tif (Array.isArray(value)) return value.join(',');\n\treturn value === undefined ? '' : String(value);\n}\n\n/** Short, stable id for a generated key, so two machines can be compared. */\nexport function fingerprint(value: string): string {\n\treturn `sha256:${createHash('sha256').update(value.trim()).digest('hex').slice(0, 8)}`;\n}\n","import { createHmac, randomBytes } from 'node:crypto';\nimport type { Manifest } from './manifest.js';\nimport type { EnvRecord } from './resolve.js';\n\n/**\n * The set keys of one boot, written beside `.env` so the next boot, and the\n * CLI, can say what changed. Sensitive values are salted HMACs: the file lives\n * next to `.env`, but it must not become a second copy of the secrets.\n */\nexport interface ConfigSnapshot {\n\tversion: 1;\n\tsalt: string;\n\tvalues: Record<string, string>;\n\t/** Keys whose `values` entry is a digest, not the value. */\n\tsensitive: string[];\n}\n\nexport interface ConfigChange {\n\tkey: string;\n\tchange: 'added' | 'removed' | 'changed';\n\t/** Absent for sensitive keys. */\n\tfrom?: string;\n\tto?: string;\n}\n\nexport function takeSnapshot(\n\tmanifest: Manifest,\n\tenv: EnvRecord,\n\tsalt: string = randomBytes(16).toString('hex')\n): ConfigSnapshot {\n\tconst values: Record<string, string> = {};\n\tconst sensitive: string[] = [];\n\tfor (const spec of manifest) {\n\t\tconst name = [spec.key, ...(spec.aliases ?? [])].find(\n\t\t\t(k) => env[k] !== undefined && env[k] !== ''\n\t\t);\n\t\tif (name === undefined) continue;\n\t\tconst raw = (env[name] as string).trim();\n\t\tif (spec.sensitive) {\n\t\t\tvalues[spec.key] = createHmac('sha256', salt).update(raw).digest('hex').slice(0, 16);\n\t\t\tsensitive.push(spec.key);\n\t\t} else {\n\t\t\tvalues[spec.key] = raw;\n\t\t}\n\t}\n\treturn { version: 1, salt, values, sensitive };\n}\n\n/** Only meaningful when both snapshots share a salt; pass `before.salt` when taking `after`. */\nexport function diffSnapshots(before: ConfigSnapshot, after: ConfigSnapshot): ConfigChange[] {\n\tconst secret = new Set([...before.sensitive, ...after.sensitive]);\n\tconst changes: ConfigChange[] = [];\n\tconst plain = (key: string, from?: string, to?: string) =>\n\t\tsecret.has(key)\n\t\t\t? {}\n\t\t\t: { ...(from !== undefined ? { from } : {}), ...(to !== undefined ? { to } : {}) };\n\n\tfor (const [key, to] of Object.entries(after.values)) {\n\t\tconst from = before.values[key];\n\t\tif (from === undefined) changes.push({ key, change: 'added', ...plain(key, undefined, to) });\n\t\telse if (from !== to) changes.push({ key, change: 'changed', ...plain(key, from, to) });\n\t}\n\tfor (const [key, from] of Object.entries(before.values)) {\n\t\tif (!(key in after.values)) changes.push({ key, change: 'removed', ...plain(key, from) });\n\t}\n\treturn changes;\n}\n","import { composeManifest, defineSetting, type IntSetting } from '@selvajs/platform/config';\nimport { DEFAULT_API_RATE_LIMIT } from '../api/rate-limit.js';\n\n// Keys the engine reads, wherever the host app runs it. Providers declare their\n// own (`@selvajs/*-provider/config`); the host app declares what only it reads.\n\nconst flag = (key: string, label: string, description: string, impact?: string) =>\n\tdefineSetting({\n\t\tkey: `SELVA_FLAG_${key}`,\n\t\tlabel,\n\t\ttype: 'bool',\n\t\tdefault: false,\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tdescription,\n\t\t...(impact ? { impact } : {})\n\t});\n\nconst tunableInt = (\n\tkey: string,\n\tfallback: number,\n\tlabel: string,\n\tdescription: string,\n\textra: Partial<Pick<IntSetting, 'min' | 'aliases' | 'impact' | 'zero' | 'unit'>> = {}\n) =>\n\tdefineSetting({\n\t\tkey,\n\t\tlabel,\n\t\ttype: 'int',\n\t\tmin: 1,\n\t\tdefault: fallback,\n\t\tonInvalid: 'default',\n\t\tclass: 'tunable',\n\t\tdescription,\n\t\t...extra\n\t});\n\nconst MB = 1024 * 1024;\n\nexport const ENGINE_SETTINGS = composeManifest([\n\t// ── Wiring ───────────────────────────────────────────────────────────────\n\t...(\n\t\t[\n\t\t\t[\n\t\t\t\t'AUTH',\n\t\t\t\t'Sign-in',\n\t\t\t\t'Who checks passwords: local (this server), supabase, or header (your SSO proxy).'\n\t\t\t],\n\t\t\t[\n\t\t\t\t'DATA',\n\t\t\t\t'Database',\n\t\t\t\t'Where users, orgs and projects live: local (files on this server) or supabase.'\n\t\t\t],\n\t\t\t[\n\t\t\t\t'STORAGE',\n\t\t\t\t'File storage',\n\t\t\t\t'Where uploaded .gh files and images live: local (this server) or supabase.'\n\t\t\t]\n\t\t] as const\n\t).map(([slot, label, description]) =>\n\t\tdefineSetting({\n\t\t\tkey: `SELVA_${slot}_PROVIDER`,\n\t\t\tlabel,\n\t\t\ttype: 'string',\n\t\t\tdefault: 'local',\n\t\t\tonInvalid: 'fail',\n\t\t\tclass: 'bootstrap',\n\t\t\tsummary: true,\n\t\t\tdescription,\n\t\t\timpact:\n\t\t\t\t'Switching it does not move any data: the instance starts on what the new provider holds.'\n\t\t})\n\t),\n\tdefineSetting({\n\t\tkey: 'SELVA_TENANCY',\n\t\tlabel: 'Organizations',\n\t\ttype: 'enum',\n\t\tvalues: ['single', 'multi'],\n\t\tdefault: 'single',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription: 'single: everyone shares one organization. multi: users can create their own.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_CONFIG_PATH',\n\t\tlabel: 'Custom config file',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'A selva.config.js that replaces env-driven provider wiring.'\n\t}),\n\n\t// ── Keys ─────────────────────────────────────────────────────────────────\n\tdefineSetting({\n\t\tkey: 'SELVA_HMAC_KEY',\n\t\tlabel: 'Signing key',\n\t\ttype: 'string',\n\t\tminLength: 32,\n\t\trequired: true,\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tgenerated: true,\n\t\tsummary: true,\n\t\tdescription:\n\t\t\t'Stops sign-ins, links and tokens from being forged. Generated at install; never share it.',\n\t\timpact:\n\t\t\t'Changing it without SELVA_HMAC_KEY_PREVIOUS breaks what it signed: run `selva keys rotate hmac`.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_AT_REST_KEY',\n\t\tlabel: 'Encryption key',\n\t\ttype: 'key',\n\t\trequired: true,\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tgenerated: true,\n\t\tsummary: true,\n\t\tdescription: 'Encrypts the Rhino.Compute API keys stored here. Generated at install.',\n\t\timpact:\n\t\t\t'Changing it without SELVA_AT_REST_KEY_PREVIOUS makes stored API keys unreadable: run `selva keys rotate at-rest`.'\n\t}),\n\n\tdefineSetting({\n\t\tkey: 'SELVA_HMAC_KEY_PREVIOUS',\n\t\tlabel: 'Previous signing key',\n\t\ttype: 'string',\n\t\tminLength: 32,\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tgenerated: true,\n\t\tsummary: true,\n\t\tdescription: 'Kept after a rotation so what the old signing key signed works until it expires.',\n\t\timpact: 'Removing it ends sessions, MCP clients and links signed before the rotation.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_AT_REST_KEY_PREVIOUS',\n\t\tlabel: 'Previous encryption key',\n\t\ttype: 'key',\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tgenerated: true,\n\t\tsummary: true,\n\t\tdescription:\n\t\t\t'Kept after a rotation until stored API keys are re-encrypted, which happens at the next start.',\n\t\timpact: 'Remove it only once /admin/system shows no API key on the previous key.'\n\t}),\n\n\tdefineSetting({\n\t\tkey: 'SELVA_HMAC_KEY_PREVIOUS_EXPIRES',\n\t\tlabel: 'Previous signing key expiry',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tdescription:\n\t\t\t'When SELVA_HMAC_KEY_PREVIOUS stops being accepted (ISO date). Set by `selva keys rotate`.',\n\t\timpact:\n\t\t\t'After it, anything only the previous key opens is refused. An unreadable date counts as passed.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_AT_REST_KEY_PREVIOUS_EXPIRES',\n\t\tlabel: 'Previous encryption key expiry',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tdescription:\n\t\t\t'When SELVA_AT_REST_KEY_PREVIOUS stops being accepted (ISO date). Set by `selva keys rotate`.',\n\t\timpact:\n\t\t\t'After it, anything only the previous key opens is refused. An unreadable date counts as passed.'\n\t}),\n\n\t// ── Access ───────────────────────────────────────────────────────────────\n\tdefineSetting({\n\t\tkey: 'BOOTSTRAP_INSTANCE_ADMIN_EMAIL',\n\t\tlabel: 'Recovery admin email',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsensitive: true,\n\t\tsummary: true,\n\t\tdescription:\n\t\t\t'While no instance admin exists, only this address may become one. For first setup and lockouts.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SIGN_IN_MAX_AGE_DAYS',\n\t\tlabel: 'Force sign-in again after',\n\t\ttype: 'int',\n\t\tmin: 0,\n\t\tdefault: 0,\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tsummary: true,\n\t\tzero: 'Never',\n\t\tunit: 'days',\n\t\tdescription: 'Days before users must sign in at the identity provider again. 0 is never.',\n\t\timpact: 'API tokens of anyone who has not signed in within this many days are revoked.'\n\t}),\n\tflag('ALLOW_ORG_CREATION', 'Users create orgs', 'Self-service org creation (read by host apps).'),\n\tflag(\n\t\t'ALLOW_CROSS_ORG_PUBLIC',\n\t\t'Public across orgs',\n\t\t'Public projects are visible to every signed-in user, not just the publishing org.',\n\t\t'Turning it on widens who sees existing public projects.'\n\t),\n\tflag(\n\t\t'ALLOW_ORG_COMPUTE_OVERRIDE',\n\t\t'Orgs bring their own compute',\n\t\t'Orgs may configure their own Rhino.Compute server.'\n\t),\n\tflag(\n\t\t'ENABLE_SHARING',\n\t\t'Share links',\n\t\t'Per-definition share links for anonymous access.',\n\t\t'Turning it off stops every existing share link from resolving.'\n\t),\n\tflag(\n\t\t'ENABLE_PLATFORM_PROJECTS',\n\t\t'Platform projects',\n\t\t'Projects owned by instance admins and granted to orgs or users.'\n\t),\n\n\t// ── Branding ─────────────────────────────────────────────────────────────\n\t...(\n\t\t[\n\t\t\t['NAME', 'Product name', 'Product name in the header and titles.'],\n\t\t\t['COPYRIGHT_NAME', 'Copyright holder', 'Footer copyright owner. Defaults to the brand name.'],\n\t\t\t['TAGLINE', 'Tagline', 'Subtitle on the landing page.'],\n\t\t\t['DESCRIPTION', 'Site description', 'Meta description for search and link previews.']\n\t\t] as const\n\t).map(([key, label, description]) =>\n\t\tdefineSetting({\n\t\t\tkey: `SELVA_BRAND_${key}`,\n\t\t\tlabel,\n\t\t\ttype: 'string',\n\t\t\tonInvalid: 'fail',\n\t\t\tclass: 'setting',\n\t\t\tdescription\n\t\t})\n\t),\n\n\t// ── Mail ─────────────────────────────────────────────────────────────────\n\tdefineSetting({\n\t\tkey: 'SMTP_HOST',\n\t\tlabel: 'Mail server',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tdescription: 'SMTP server. Unset: invites return a link to send by hand.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SMTP_PORT',\n\t\tlabel: 'Mail server port',\n\t\ttype: 'int',\n\t\tmin: 1,\n\t\tmax: 65535,\n\t\tdefault: 587,\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tdescription: '587 for STARTTLS, 465 for implicit TLS.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SMTP_USER',\n\t\tlabel: 'Mail username',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tsensitive: true,\n\t\tdescription: 'SMTP login.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SMTP_PASS',\n\t\tlabel: 'Mail password',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tdescription: 'SMTP password.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SMTP_FROM',\n\t\tlabel: 'Sender address',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tsensitive: true,\n\t\tdescription: 'Sender address. Required once SMTP_HOST is set.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SMTP_SECURE',\n\t\tlabel: 'Mail TLS mode',\n\t\ttype: 'bool',\n\t\tonInvalid: 'fail',\n\t\tclass: 'tunable',\n\t\tdescription: 'Override the TLS mode inferred from the port.',\n\t\tlegacy: { bool: 'exact-true' }\n\t}),\n\n\t// ── Compute limits ───────────────────────────────────────────────────────\n\ttunableInt(\n\t\t'COMPUTE_RATE_LIMIT_MAX',\n\t\t120,\n\t\t'Solves per window',\n\t\t'Solves per user or share link per 100-second window.'\n\t),\n\ttunableInt('MAX_DEFINITION_FILE_SIZE_BYTES', 50 * MB, 'Max .gh upload', 'Largest .gh upload.', {\n\t\tunit: 'bytes'\n\t}),\n\ttunableInt(\n\t\t'COMPUTE_MAX_QUEUE_DEPTH',\n\t\t0,\n\t\t'Solve queue length',\n\t\t'Solves allowed to wait per compute server. 0 is unbounded.',\n\t\t{ min: 0, zero: 'No limit' }\n\t),\n\ttunableInt(\n\t\t'COMPUTE_QUEUE_WAIT_MS',\n\t\t0,\n\t\t'Max queue wait',\n\t\t'Longest a solve may wait queued. 0 is no deadline.',\n\t\t{ min: 0, unit: 'ms', zero: 'No limit' }\n\t),\n\ttunableInt(\n\t\t'COMPUTE_DEFINITION_CACHE_MB',\n\t\t256,\n\t\t'Definition cache size',\n\t\t'Definition cache budget. 0 turns it off.',\n\t\t{ min: 0, unit: 'mb', zero: 'Off', aliases: ['COMPUTE_DEFINITION_BYTE_CACHE_MB'] }\n\t),\n\ttunableInt(\n\t\t'COMPUTE_SOLVE_CACHE_MB',\n\t\t256,\n\t\t'Solve cache size',\n\t\t'Solve cache budget per warm compute server. 0 turns it off.',\n\t\t{ min: 0, unit: 'mb', zero: 'Off', aliases: ['COMPUTE_RESPONSE_CACHE_MB'] }\n\t),\n\tdefineSetting({\n\t\tkey: 'COMPUTE_SERVER_CACHESOLVE',\n\t\tlabel: 'Compute server solve cache',\n\t\ttype: 'bool',\n\t\tdefault: true,\n\t\tonInvalid: 'default',\n\t\tclass: 'tunable',\n\t\tdescription: 'Ask Rhino.Compute to cache solve results server-side.'\n\t}),\n\ttunableInt(\n\t\t'API_TOKEN_RATE_LIMIT_MAX',\n\t\tDEFAULT_API_RATE_LIMIT.maxPerWindow,\n\t\t'API requests per minute',\n\t\t'Requests per API token per minute. 0 is off.',\n\t\t{ min: 0, zero: 'Off' }\n\t)\n]);\n","import { composeManifest, defineSetting } from '@selvajs/platform/config';\n\nconst header = (key: string, fallback: string, slot: string) =>\n\tdefineSetting({\n\t\tkey,\n\t\tlabel: `${slot[0].toUpperCase()}${slot.slice(1)} header`,\n\t\ttype: 'string',\n\t\tdefault: fallback,\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: `Header the proxy puts the user's ${slot} in.`,\n\t\timpact: 'A name the proxy never sends signs nobody in. Override all three or none.'\n\t});\n\nexport const HEADER_AUTH_SETTINGS = composeManifest([\n\tdefineSetting({\n\t\tkey: 'HEADER_AUTH_DATA_DIR',\n\t\tlabel: 'Allowlist folder',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'Directory holding header-allowlist.json. Falls back to DATA_PATH.'\n\t}),\n\theader('HEADER_AUTH_UPN_HEADER', 'SELVA-UserPrincipalName', 'UPN'),\n\theader('HEADER_AUTH_EMAIL_HEADER', 'SELVA-Email', 'email'),\n\theader('HEADER_AUTH_DISPLAY_NAME_HEADER', 'SELVA-DisplayName', 'display name')\n]);\n","import { composeManifest, defineSetting } from '@selvajs/platform/config';\n\nexport const LOCAL_SETTINGS = composeManifest([\n\tdefineSetting({\n\t\tkey: 'DATA_PATH',\n\t\tlabel: 'Data folder',\n\t\ttype: 'string',\n\t\trequired: true,\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription: 'Folder on this server holding users, orgs, projects and uploads. Back it up.',\n\t\timpact: 'Pointing it elsewhere starts an empty instance; the old data stays where it was.'\n\t})\n]);\n","import {\n\tbuildConfigReport,\n\tcomposeManifest,\n\tpreviousKey,\n\ttype KeyRotation,\n\tdefineSetting,\n\ttakeSnapshot,\n\ttype ConfigReport,\n\ttype ConfigSnapshot,\n\ttype EnvRecord,\n\ttype Manifest\n} from '@selvajs/platform/config';\nimport { ENGINE_SETTINGS } from '@selvajs/server/config';\nimport { HEADER_AUTH_SETTINGS } from '@selvajs/header-auth-provider/config';\nimport { LOCAL_SETTINGS } from '@selvajs/local-provider/config';\nimport { SUPABASE_SETTINGS } from '@selvajs/supabase-provider/config';\n\n/** Keys only this app reads. adapter-node's own keys are here too: they decide whether it works. */\nexport const APP_SETTINGS = composeManifest([\n\tdefineSetting({\n\t\tkey: 'ORIGIN',\n\t\tlabel: 'Public address',\n\t\ttype: 'url',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription: 'The URL people use to reach Selva, such as https://selva.example.com.',\n\t\timpact:\n\t\t\t'Wrong or unset behind a proxy: form posts fail the CSRF check and invite links carry an internal host.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'PORT',\n\t\tlabel: 'Port',\n\t\ttype: 'int',\n\t\tmin: 1,\n\t\tmax: 65535,\n\t\tdefault: 3000,\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'Port the app listens on.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'HOST',\n\t\tlabel: 'Listen address',\n\t\ttype: 'string',\n\t\tdefault: '0.0.0.0',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription:\n\t\t\t'Which network address the app accepts connections on. 127.0.0.1 when a proxy sits in front.',\n\t\timpact: 'Under header auth, anything that reaches the port directly can claim to be any user.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'BODY_SIZE_LIMIT',\n\t\tlabel: 'Max request size',\n\t\ttype: 'string',\n\t\tdefault: '512K',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription: 'Largest request the server accepts at all, uploads included (K, M or G suffix).',\n\t\timpact: 'Below COMPUTE_REQUEST_MAX_BYTES, uploads and file inputs fail with 413.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'ADDRESS_HEADER',\n\t\tlabel: 'Visitor IP header',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription:\n\t\t\t'Header your proxy uses to pass on the visitor’s IP address. Usually X-Forwarded-For.',\n\t\timpact: 'Unset behind a proxy: every client shares one rate-limit bucket.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'XFF_DEPTH',\n\t\tlabel: 'Proxies in front',\n\t\ttype: 'int',\n\t\tmin: 1,\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tsummary: true,\n\t\tdescription: 'How many proxies sit between visitors and the app. Usually 1.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'PROTOCOL_HEADER',\n\t\tlabel: 'Protocol header',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'Header carrying the original protocol, when ORIGIN is unset.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'HOST_HEADER',\n\t\tlabel: 'Host header',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'Header carrying the original host, when ORIGIN is unset.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'NODE_ENV',\n\t\tlabel: 'Run mode',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'production in deployments: hides stack traces and makes cookies Secure.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'ALLOW_INSECURE_COOKIES',\n\t\tlabel: 'Allow sign-in over http',\n\t\ttype: 'bool',\n\t\tdefault: false,\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription: 'Drop the Secure cookie flag so sign-in works over plain http.',\n\t\tlegacy: { bool: 'exact-true' }\n\t}),\n\tdefineSetting({\n\t\tkey: 'INSTALL_DIR',\n\t\tlabel: 'Install folder',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription:\n\t\t\t'Deployment directory the admin updater runs in. Defaults to the working directory.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_EVENT_CALLBACK_ORIGIN',\n\t\tlabel: 'Solve event callback address',\n\t\ttype: 'url',\n\t\tonInvalid: 'fail',\n\t\tclass: 'bootstrap',\n\t\tdescription:\n\t\t\t'Origin Rhino.Compute posts live solve events to, when it differs from the browser’s.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'MCP_ALLOWED_ORIGINS',\n\t\tlabel: 'Extra MCP origins',\n\t\ttype: 'list',\n\t\tdefault: [],\n\t\tonInvalid: 'fail',\n\t\tclass: 'setting',\n\t\tdescription: 'Browser origins /mcp accepts besides its own.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'LOG_LEVEL',\n\t\tlabel: 'Log level',\n\t\ttype: 'enum',\n\t\tvalues: ['debug', 'info', 'warn', 'error'],\n\t\tonInvalid: 'default',\n\t\tclass: 'setting',\n\t\tdescription: 'Lowest severity written to the log. Default info (debug in development).'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_FLAG_COMPUTE_DEBUG',\n\t\tlabel: 'Compute debug logging',\n\t\ttype: 'string',\n\t\tdefault: 'off',\n\t\tonInvalid: 'default',\n\t\tclass: 'setting',\n\t\tdescription:\n\t\t\t'off, on (cache and timing lines per solve) or verbose (adds Compute’s raw error bodies).',\n\t\timpact: 'verbose can write what was solved to the log, which erasure cannot reach.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SENTRY_DSN',\n\t\tlabel: 'Sentry error reporting',\n\t\ttype: 'url',\n\t\tonInvalid: 'fail',\n\t\tclass: 'secret',\n\t\tsensitive: true,\n\t\tdescription:\n\t\t\t'Ship unexpected server errors to Sentry, scrubbed of cookies, auth headers, bodies and query strings.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SENTRY_TRACES_SAMPLE_RATE',\n\t\tlabel: 'Sentry trace sampling',\n\t\ttype: 'string',\n\t\tdefault: '0',\n\t\tonInvalid: 'default',\n\t\tclass: 'tunable',\n\t\tdescription:\n\t\t\t'Share of requests traced to Sentry, 0–1 (out of range is clamped). 0 sends errors only.'\n\t}),\n\tdefineSetting({\n\t\tkey: 'SELVA_RELEASE',\n\t\tlabel: 'Release tag',\n\t\ttype: 'string',\n\t\tonInvalid: 'fail',\n\t\tclass: 'tunable',\n\t\tdescription: 'Release tag on Sentry events and log records.'\n\t})\n]);\n\n/** Prefixes whose undeclared keys are reported as unknown (likely typos). */\nexport const WATCHED_PREFIXES = [\n\t'SELVA_',\n\t'SUPABASE_',\n\t'COMPUTE_',\n\t'SMTP_',\n\t'HEADER_AUTH_',\n\t'API_TOKEN_',\n\t'MAX_',\n\t'REMOTE_DEFINITION_',\n\t'SIGN_IN_',\n\t'BOOTSTRAP_'\n] as const;\n\n/** Read by tooling, not by the app: not unknown, not reported. */\nexport const EXTERNAL_KEYS = ['SELVA_REQUIRE_SUPABASE'] as const;\n\n/**\n * Keys no release reads any more, with what took their place. Boot and doctor\n * name them instead of calling them typos; `selva migrate` removes them.\n */\nexport const RETIRED_KEYS: Readonly<Record<string, string>> = {\n\tSELVA_FLAG_COMPUTE_DEBUG_VERBOSE: 'use SELVA_FLAG_COMPUTE_DEBUG=verbose',\n\tCOMPUTE_RATE_LIMIT_WINDOW_MS: 'fixed at 100 s',\n\tAPI_TOKEN_RATE_LIMIT_WINDOW_MS: 'fixed at 60 s',\n\tMAX_IMAGE_FILE_SIZE_BYTES: 'fixed at 10 MB',\n\tCOMPUTE_REQUEST_MAX_BYTES: 'fixed at 256 MB',\n\tCOMPUTE_RESPONSE_MAX_BYTES: 'fixed at 300 MB',\n\tREMOTE_DEFINITION_FETCH_TIMEOUT_MS: 'fixed at 30 s',\n\tREMOTE_DEFINITION_CACHE_TTL_MS: 'fixed at 5 min',\n\tDEFINITION_CACHE_TTL_MS: 'fixed at 5 min',\n\tSUPABASE_TOKEN_VERIFICATION: 'always hybrid',\n\tSUPABASE_REVALIDATE_MS: 'fixed at 60 s',\n\tSUPABASE_PRIVATE_URL_PREFIX: 'fixed at /api/files',\n\tCOMPUTE_SOLVE_DEADLINE_MS: 'set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server',\n\tMAX_SOLVE_DURATION_MS: 'set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server',\n\tCOMPUTE_REUSE_DEFINITION_CACHE: 'on whenever the compute server reports /limits'\n};\n\n/**\n * The manifest for this deployment: engine and app keys, plus the slices of\n * the providers it selects. A provider's required keys only apply when it is\n * in use, so slices are chosen here rather than all composed at once.\n */\nexport function deploymentManifest(env: EnvRecord): Manifest {\n\tconst chosen = new Set(\n\t\t(['SELVA_AUTH_PROVIDER', 'SELVA_DATA_PROVIDER', 'SELVA_STORAGE_PROVIDER'] as const).map((k) =>\n\t\t\t(env[k] ?? 'local').toLowerCase()\n\t\t)\n\t);\n\treturn composeManifest([\n\t\tENGINE_SETTINGS,\n\t\tAPP_SETTINGS,\n\t\t...(chosen.has('local') ? [LOCAL_SETTINGS] : []),\n\t\t...(chosen.has('supabase') ? [SUPABASE_SETTINGS] : []),\n\t\t...(chosen.has('header') ? [HEADER_AUTH_SETTINGS] : [])\n\t]);\n}\n\n/** Every key any slice declares, whichever providers are chosen. */\nexport const ALL_SETTINGS: Manifest = composeManifest([\n\tENGINE_SETTINGS,\n\tAPP_SETTINGS,\n\tLOCAL_SETTINGS,\n\tSUPABASE_SETTINGS,\n\tHEADER_AUTH_SETTINGS\n]);\n\n/** The report for this deployment. Keys of providers it doesn't use are known, not typos. */\nexport function deploymentReport(env: EnvRecord): ConfigReport {\n\tconst manifest = deploymentManifest(env);\n\tconst active = new Set(manifest.flatMap((s) => [s.key, ...(s.aliases ?? [])]));\n\tconst inactive = ALL_SETTINGS.flatMap((s) => [s.key, ...(s.aliases ?? [])]).filter(\n\t\t(k) => !active.has(k)\n\t);\n\treturn buildConfigReport(manifest, env, {\n\t\tprefixes: WATCHED_PREFIXES,\n\t\texternal: [...EXTERNAL_KEYS, ...Object.keys(RETIRED_KEYS), ...inactive]\n\t});\n}\n\n// Set by the process manager (pm2's ecosystem file), never by .env, so the CLI\n// comparing .env with the last boot would report it as drift forever.\nconst NOT_FROM_ENV_FILE = new Set(['NODE_ENV']);\n\n/** What the boot snapshot and the CLI's drift check compare. */\nexport function deploymentSnapshot(env: EnvRecord, salt?: string): ConfigSnapshot {\n\tconst manifest = deploymentManifest(env).filter((s) => !NOT_FROM_ENV_FILE.has(s.key));\n\treturn takeSnapshot(manifest, env, salt);\n}\n\n/** The rotation overlap of each root key: what the admin page and doctor count down. */\nexport function keyRotationStatus(env: EnvRecord, now: number = Date.now()): KeyRotation[] {\n\treturn (['SELVA_HMAC_KEY', 'SELVA_AT_REST_KEY'] as const).map((key) => {\n\t\tconst p = previousKey(env, key, now);\n\t\t// The previous key itself never leaves the server.\n\t\treturn {\n\t\t\tkey,\n\t\t\tstate: p.state,\n\t\t\t...('expires' in p ? { expires: p.expires } : {}),\n\t\t\t...('daysLeft' in p ? { daysLeft: p.daysLeft } : {})\n\t\t};\n\t});\n}\n","import {\n\tresolveConfig,\n\ttype ConfigReport,\n\ttype EnvRecord,\n\ttype KeyRotation\n} from '@selvajs/platform/config';\nimport { deploymentManifest } from './settings.js';\n\n/**\n * Plain-language findings for the admin Configuration page: what is wrong with\n * this deployment, what it breaks, and the command that fixes it. Each finding\n * is derived from the env and the request the admin made, so a proxy that was\n * never mentioned in `.env` still shows up.\n */\n\nexport type CheckLevel = 'error' | 'warning' | 'info';\n\nexport interface ConfigCheck {\n\tid: string;\n\tlevel: CheckLevel;\n\ttitle: string;\n\tdetail: string;\n\t/** Shell commands, run in order on the server. */\n\tfix?: string[];\n\tkeys: string[];\n}\n\nexport interface RequestFacts {\n\t/** A proxy forwarded this request: one of the X-Forwarded-* or Forwarded headers arrived. */\n\tproxied: boolean;\n\t/** What the visitor typed, as far as the proxy says: `https://selva.example.com`. */\n\tseenOrigin: string;\n}\n\nexport function requestFacts(headers: Headers, url: URL): RequestFacts {\n\tconst forwardedHost = firstValue(headers.get('x-forwarded-host'));\n\tconst forwardedProto = firstValue(headers.get('x-forwarded-proto'));\n\tconst proxied =\n\t\theaders.has('x-forwarded-for') ||\n\t\theaders.has('forwarded') ||\n\t\tforwardedHost !== undefined ||\n\t\tforwardedProto !== undefined;\n\tconst proto = forwardedProto ?? url.protocol.replace(/:$/, '');\n\tconst host = forwardedHost ?? url.host;\n\treturn { proxied, seenOrigin: `${proto}://${host}` };\n}\n\nfunction firstValue(header: string | null): string | undefined {\n\tconst v = header?.split(',')[0]?.trim();\n\treturn v ? v : undefined;\n}\n\nexport interface CheckInput {\n\tenv: EnvRecord;\n\treport: ConfigReport;\n\trotation: KeyRotation[];\n\t/** Stored compute API keys still sealed under the previous at-rest key; null outside a rotation. */\n\tatRestOnPreviousKey: number | null;\n\trequest: RequestFacts;\n\tcomputeRequestMaxBytes: number;\n\t/** `vite dev`: development mode is expected, not a finding. */\n\tdev: boolean;\n}\n\nconst restart = 'npx selva restart';\nconst set = (key: string, value: string) => `npx selva config set ${key}=${value}`;\n\nexport function configChecks(input: CheckInput): ConfigCheck[] {\n\tconst { env, report, request } = input;\n\tconst values = resolveConfig(deploymentManifest(env), env).values;\n\tconst label = (key: string) => report.rows.find((r) => r.key === key)?.label ?? key;\n\tconst out: ConfigCheck[] = [];\n\n\tfor (const p of report.problems) {\n\t\tout.push({\n\t\t\tid: `invalid:${p.key}`,\n\t\t\tlevel: p.status === 'error' ? 'error' : 'warning',\n\t\t\ttitle: `${label(p.key)} has a bad value`,\n\t\t\tdetail:\n\t\t\t\tp.status === 'error'\n\t\t\t\t\t? `The value ${p.problem}. The app refuses to start with it.`\n\t\t\t\t\t: `The value ${p.problem}, so the app ignores it and uses the default.`,\n\t\t\tkeys: [p.key]\n\t\t});\n\t}\n\n\tfor (const u of report.unknown) {\n\t\tout.push({\n\t\t\tid: `unknown:${u.key}`,\n\t\t\tlevel: 'warning',\n\t\t\ttitle: `${u.key} does nothing`,\n\t\t\tdetail: u.suggestion\n\t\t\t\t? `Selva doesn't read ${u.key}. It looks like a typo of ${u.suggestion}, which is the one that counts.`\n\t\t\t\t: `Selva doesn't read ${u.key}. Remove it, or check the name against the settings below.`,\n\t\t\t...(u.suggestion ? { fix: [`npx selva config unset ${u.key}`] } : {}),\n\t\t\tkeys: [u.key]\n\t\t});\n\t}\n\n\tconst renamed = report.rows.filter((r) => r.source === 'alias');\n\tif (renamed.length > 0) {\n\t\tout.push({\n\t\t\tid: 'renamed',\n\t\t\tlevel: 'info',\n\t\t\ttitle: 'Some settings use an old name',\n\t\t\tdetail: `${renamed.map((r) => `${r.alias} is now ${r.key}`).join('; ')}. They still work; renaming keeps it that way.`,\n\t\t\tfix: ['selva migrate'],\n\t\t\tkeys: renamed.map((r) => r.key)\n\t\t});\n\t}\n\n\tconst origin = values.ORIGIN as string | undefined;\n\tif (request.proxied && !origin) {\n\t\tout.push({\n\t\t\tid: 'origin-missing',\n\t\t\tlevel: 'error',\n\t\t\ttitle: 'Public address is not set',\n\t\t\tdetail:\n\t\t\t\t'Requests reach Selva through a proxy, but it doesn’t know its own public address. Form posts fail their security check and invite links point at an internal address.',\n\t\t\tfix: [set('ORIGIN', request.seenOrigin), restart],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t} else if (request.proxied && origin && sameOrigin(origin, request.seenOrigin) === false) {\n\t\tout.push({\n\t\t\tid: 'origin-mismatch',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Public address doesn’t match how you reached this page',\n\t\t\tdetail: `You opened Selva at ${request.seenOrigin}, but its public address is ${origin}. Sign-in from ${request.seenOrigin} fails, and invite links point at ${origin}.`,\n\t\t\tfix: [set('ORIGIN', request.seenOrigin), restart],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t}\n\n\tif (origin && /^http:\\/\\//i.test(origin) && !isLoopbackUrl(origin)) {\n\t\tout.push({\n\t\t\tid: 'origin-http',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Sign-ins travel unencrypted',\n\t\t\tdetail: `The public address ${origin} uses http, so passwords and session cookies cross the network in plain text. Put a proxy with a certificate in front: selva setup-proxy does it.`,\n\t\t\tfix: ['selva setup-proxy'],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t}\n\n\tif (request.proxied && !values.ADDRESS_HEADER) {\n\t\tout.push({\n\t\t\tid: 'address-header',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Every visitor looks like the same person',\n\t\t\tdetail:\n\t\t\t\t'Behind a proxy, Selva sees the proxy’s address instead of each visitor’s. Rate limits are shared by everyone, so five failed logins from anyone lock out the whole instance.',\n\t\t\tfix: [set('ADDRESS_HEADER', 'X-Forwarded-For'), set('XFF_DEPTH', '1'), restart],\n\t\t\tkeys: ['ADDRESS_HEADER', 'XFF_DEPTH']\n\t\t});\n\t}\n\n\tconst host = values.HOST as string;\n\tif (request.proxied && (host === '0.0.0.0' || host === '::')) {\n\t\tconst headerAuth = (env.SELVA_AUTH_PROVIDER ?? '').toLowerCase() === 'header';\n\t\tout.push({\n\t\t\tid: 'host-open',\n\t\t\tlevel: headerAuth ? 'error' : 'warning',\n\t\t\ttitle: 'The app can be reached without going through the proxy',\n\t\t\tdetail: headerAuth\n\t\t\t\t? 'Sign-in comes from headers the proxy sets. Anyone who reaches the app’s port directly can send those headers and sign in as any user.'\n\t\t\t\t: 'The app accepts connections from any network, not just from the proxy. Skip this if the proxy runs in another container.',\n\t\t\tfix: [set('HOST', '127.0.0.1'), restart],\n\t\t\tkeys: ['HOST']\n\t\t});\n\t}\n\n\tconst bodyLimit = parseBodySize(values.BODY_SIZE_LIMIT as string);\n\tif (bodyLimit !== null && bodyLimit < input.computeRequestMaxBytes) {\n\t\tout.push({\n\t\t\tid: 'body-size',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Large solves and uploads will be rejected',\n\t\t\tdetail: `The server accepts requests up to ${values.BODY_SIZE_LIMIT}, smaller than the ${formatBytes(input.computeRequestMaxBytes)} a solve may send. Bigger ones fail with \"413 Payload Too Large\" before Selva sees them.`,\n\t\t\tfix: [\n\t\t\t\tset('BODY_SIZE_LIMIT', `${Math.ceil(input.computeRequestMaxBytes / 1024 / 1024)}M`),\n\t\t\t\trestart\n\t\t\t],\n\t\t\tkeys: ['BODY_SIZE_LIMIT']\n\t\t});\n\t}\n\n\tif (values.ALLOW_INSECURE_COOKIES === true) {\n\t\tout.push({\n\t\t\tid: 'insecure-cookies',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Sign-in cookies may be sent over http',\n\t\t\tdetail:\n\t\t\t\t'Meant for testing on a local network. Anyone on the same network can copy a session and act as that user.',\n\t\t\tfix: ['npx selva config unset ALLOW_INSECURE_COOKIES', restart],\n\t\t\tkeys: ['ALLOW_INSECURE_COOKIES']\n\t\t});\n\t}\n\n\tif (!input.dev && env.NODE_ENV !== 'production') {\n\t\tout.push({\n\t\t\tid: 'not-production',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Running in development mode',\n\t\t\tdetail:\n\t\t\t\t'Error pages show stack traces and cookies aren’t marked Secure. npx selva restart starts it through pm2, which sets NODE_ENV=production.',\n\t\t\tfix: [restart],\n\t\t\tkeys: ['NODE_ENV']\n\t\t});\n\t}\n\n\tif (values.SELVA_FLAG_COMPUTE_DEBUG === 'verbose') {\n\t\tout.push({\n\t\t\tid: 'verbose-debug',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Logs may contain what users solved',\n\t\t\tdetail:\n\t\t\t\t'Verbose compute debugging writes Rhino.Compute’s raw error bodies to the log, and deleting a user doesn’t remove them from there. Turn it off once you’re done debugging.',\n\t\t\tfix: ['npx selva config unset SELVA_FLAG_COMPUTE_DEBUG', restart],\n\t\t\tkeys: ['SELVA_FLAG_COMPUTE_DEBUG']\n\t\t});\n\t}\n\n\tif (values.SMTP_HOST && !values.SMTP_FROM) {\n\t\tout.push({\n\t\t\tid: 'smtp-from',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Mail has no sender address',\n\t\t\tdetail: 'A mail server is set but no sender address, so invite emails can’t be sent.',\n\t\t\tfix: [set('SMTP_FROM', 'selva@your-domain'), restart],\n\t\t\tkeys: ['SMTP_FROM']\n\t\t});\n\t}\n\n\tfor (const r of input.rotation) {\n\t\tconst name = r.key === 'SELVA_HMAC_KEY' ? 'signing key' : 'encryption key';\n\t\tconst finish = `npx selva keys rotate ${r.key === 'SELVA_HMAC_KEY' ? 'hmac' : 'at-rest'} --finish`;\n\t\tconst atRestBusy = r.key === 'SELVA_AT_REST_KEY' && (input.atRestOnPreviousKey ?? 0) > 0;\n\t\tif (r.state === 'active') {\n\t\t\tout.push({\n\t\t\t\tid: `rotation:${r.key}`,\n\t\t\t\tlevel: 'info',\n\t\t\t\ttitle: `Changing the ${name}`,\n\t\t\t\tdetail: `The old ${name} keeps working for ${r.daysLeft} more ${r.daysLeft === 1 ? 'day' : 'days'}, until ${r.expires?.slice(0, 10)}. Nothing to do: it stops on its own.`,\n\t\t\t\tkeys: [`${r.key}_PREVIOUS`]\n\t\t\t});\n\t\t} else if (r.state === 'expired' || r.state === 'no-deadline') {\n\t\t\tout.push({\n\t\t\t\tid: `rotation:${r.key}`,\n\t\t\t\tlevel: 'warning',\n\t\t\t\ttitle:\n\t\t\t\t\tr.state === 'expired'\n\t\t\t\t\t\t? `The old ${name} has expired but is still in .env`\n\t\t\t\t\t\t: `The old ${name} never expires`,\n\t\t\t\tdetail:\n\t\t\t\t\tr.state === 'expired'\n\t\t\t\t\t\t? `It stopped working on ${r.expires?.slice(0, 10)}. Remove it to finish the change.`\n\t\t\t\t\t\t: `It was added without an end date, so a leaked old key stays useful forever. Finish the change to remove it.`,\n\t\t\t\t...(atRestBusy ? {} : { fix: [finish, restart] }),\n\t\t\t\tkeys: [`${r.key}_PREVIOUS`]\n\t\t\t});\n\t\t}\n\t}\n\n\tif (input.atRestOnPreviousKey !== null) {\n\t\tconst n = input.atRestOnPreviousKey;\n\t\tout.push(\n\t\t\tn > 0\n\t\t\t\t? {\n\t\t\t\t\t\tid: 'at-rest-pending',\n\t\t\t\t\t\tlevel: 'warning',\n\t\t\t\t\t\ttitle: `${n} stored compute API ${n === 1 ? 'key is' : 'keys are'} still on the old encryption key`,\n\t\t\t\t\t\tdetail:\n\t\t\t\t\t\t\t'Restart the app to re-encrypt them. Don’t finish the key change before this reaches zero, or they become unreadable.',\n\t\t\t\t\t\tfix: [restart],\n\t\t\t\t\t\tkeys: ['SELVA_AT_REST_KEY_PREVIOUS']\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tid: 'at-rest-pending',\n\t\t\t\t\t\tlevel: 'info',\n\t\t\t\t\t\ttitle: 'Every stored compute API key is on the new encryption key',\n\t\t\t\t\t\tdetail: 'The old encryption key is no longer needed. Finishing removes it.',\n\t\t\t\t\t\tfix: ['npx selva keys rotate at-rest --finish', restart],\n\t\t\t\t\t\tkeys: ['SELVA_AT_REST_KEY_PREVIOUS']\n\t\t\t\t\t}\n\t\t);\n\t}\n\n\tconst order: Record<CheckLevel, number> = { error: 0, warning: 1, info: 2 };\n\treturn out.sort((a, b) => order[a.level] - order[b.level]);\n}\n\nfunction sameOrigin(a: string, b: string): boolean | null {\n\ttry {\n\t\treturn new URL(a).origin === new URL(b).origin;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isLoopbackUrl(url: string): boolean {\n\ttry {\n\t\tconst h = new URL(url).hostname;\n\t\treturn h === 'localhost' || h === '127.0.0.1' || h === '[::1]';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** adapter-node's BODY_SIZE_LIMIT: bytes, or a K/M/G suffix, or Infinity. Null when unreadable. */\nexport function parseBodySize(raw: string | undefined): number | null {\n\tif (!raw) return null;\n\tconst v = raw.trim();\n\tif (v.toLowerCase() === 'infinity') return Infinity;\n\tconst m = /^(\\d+(?:\\.\\d+)?)\\s*([kmg])?b?$/i.exec(v);\n\tif (!m) return null;\n\tconst mult = { k: 1024, m: 1024 ** 2, g: 1024 ** 3 }[(m[2] ?? '').toLowerCase()] ?? 1;\n\treturn Number(m[1]) * mult;\n}\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes >= 1024 ** 3) return `${+(bytes / 1024 ** 3).toFixed(1)} GB`;\n\tif (bytes >= 1024 ** 2) return `${Math.round(bytes / 1024 ** 2)} MB`;\n\treturn `${Math.round(bytes / 1024)} KB`;\n}\n","import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { env } from '#lib/server/env.js';\nimport {\n\tdiffSnapshots,\n\ttype ConfigChange,\n\ttype ConfigReport,\n\ttype ConfigSnapshot,\n\ttype KeyRotation\n} from '@selvajs/platform/config';\nimport { getLogger } from '#lib/server/providers.server.js';\nimport { findDeploymentDir } from '#lib/server/selfUpdate.server.js';\nimport {\n\tdeploymentReport,\n\tdeploymentSnapshot,\n\tkeyRotationStatus,\n\tRETIRED_KEYS\n} from './settings.js';\nimport { configChecks, type CheckInput, type ConfigCheck } from './checks.js';\n\n/** Beside `.env` in the deployment directory. The CLI reads it too. */\nexport const SNAPSHOT_FILE = '.selva-config-snapshot.json';\n\nlet report: ConfigReport | null = null;\nlet changes: ConfigChange[] = [];\n\n/** The configuration this process runs on, safe to send to an admin's browser. */\nexport function getConfigReport(): ConfigReport {\n\treport ??= deploymentReport(env);\n\treturn report;\n}\n\n/** Each root key's rotation overlap, read now so a deadline that passes shows without a restart. */\nexport function getKeyRotation(): KeyRotation[] {\n\treturn keyRotationStatus(env);\n}\n\n/** Findings for the admin page, read per request: proxy detection depends on the request. */\nexport function getConfigChecks(\n\tinput: Omit<CheckInput, 'env' | 'report' | 'rotation'>\n): ConfigCheck[] {\n\treturn configChecks({ ...input, env, report: getConfigReport(), rotation: getKeyRotation() });\n}\n\n/** What differs from the previous boot's snapshot. Empty outside a deployment. */\nexport function getChangesSinceLastBoot(): ConfigChange[] {\n\treturn changes;\n}\n\n/**\n * Run once at server start. Throws on a fail-closed key with a bad value, so a\n * typo in a security control stops boot instead of switching the control off.\n */\nexport function checkConfigAtBoot(): void {\n\tconst current = getConfigReport();\n\tconst log = getLogger();\n\n\tconst errors = current.problems.filter((p) => p.status === 'error');\n\tfor (const p of current.problems.filter((r) => r.status === 'invalid')) {\n\t\tlog.warn('Invalid env value, using the default', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: p.key,\n\t\t\tproblem: p.problem\n\t\t});\n\t}\n\tfor (const u of current.unknown) {\n\t\tlog.warn('Unknown env var', { component: 'config', envVar: u.key, suggestion: u.suggestion });\n\t}\n\tfor (const [key, now] of Object.entries(RETIRED_KEYS)) {\n\t\tif (env[key] === undefined) continue;\n\t\tlog.warn('Retired env var, ignored: run `selva migrate`', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: key,\n\t\t\tnow\n\t\t});\n\t}\n\tfor (const row of current.rows.filter((r) => r.source === 'alias')) {\n\t\tlog.warn('Deprecated env var: run `selva migrate`', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: row.alias,\n\t\t\trenamedTo: row.key\n\t\t});\n\t}\n\tfor (const r of getKeyRotation()) {\n\t\tif (r.state === 'expired' || r.state === 'no-deadline') {\n\t\t\tlog.warn(\n\t\t\t\tr.state === 'expired'\n\t\t\t\t\t? 'Previous key passed its deadline and is no longer accepted: remove it'\n\t\t\t\t\t: 'Previous key has no deadline and is accepted for good',\n\t\t\t\t{ component: 'config', envVar: `${r.key}_PREVIOUS`, expires: r.expires }\n\t\t\t);\n\t\t}\n\t}\n\tif (errors.length > 0) {\n\t\tthrow new Error(\n\t\t\t'Invalid configuration:\\n' + errors.map((e) => ` ${e.key} ${e.problem}`).join('\\n')\n\t\t);\n\t}\n\n\tchanges = recordSnapshot();\n\tif (changes.length > 0) {\n\t\tlog.info('Configuration changed since the last boot', {\n\t\t\tcomponent: 'config',\n\t\t\tkeys: changes.map((c) => c.key)\n\t\t});\n\t}\n}\n\nfunction recordSnapshot(): ConfigChange[] {\n\tconst dir = findDeploymentDir(env);\n\tif (!dir) return [];\n\tconst path = join(dir, SNAPSHOT_FILE);\n\tlet previous: ConfigSnapshot | null = null;\n\ttry {\n\t\tif (existsSync(path)) previous = JSON.parse(readFileSync(path, 'utf8')) as ConfigSnapshot;\n\t} catch {\n\t\tprevious = null;\n\t}\n\tconst next = deploymentSnapshot(env, previous?.salt);\n\ttry {\n\t\twriteFileSync(path, JSON.stringify(next, null, '\\t') + '\\n', { mode: 0o600 });\n\t\tif (process.platform !== 'win32') chmodSync(path, 0o600);\n\t} catch (err) {\n\t\tgetLogger().warn('Could not write the config snapshot', {\n\t\t\tcomponent: 'config',\n\t\t\terr: err instanceof Error ? err.message : String(err)\n\t\t});\n\t}\n\treturn previous ? diffSnapshots(previous, next) : [];\n}\n"],"mappings":";;;;;;;;;;;;AA2CA,SAAgB,kBACf,UACA,KACA,UAA0B,CAAC,GACZ;CACf,MAAM,WAAW,cAAc,UAAU,KAAK,OAAO;CACrD,MAAM,OAAoB,SAAS,KAAK,SAAS;EAChD,MAAM,IAAI,SAAS,KAAK,KAAK;EAC7B,MAAM,MAAM,EAAE,WAAW,UAAU,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,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CAGD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,UAAU;EACV,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;EACX,SAAS;EACT,aACC;EACD,QACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,UAAU;EACV,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;EACX,SAAS;EACT,aAAa;EACb,QACC;CACF,CAAC;CAED,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;EACX,SAAS;EACT,aAAa;EACb,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;EACX,SAAS;EACT,aACC;EACD,QAAQ;CACT,CAAC;CAED,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aACC;EACD,QACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aACC;EACD,QACC;CACF,CAAC;CAGD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,SAAS;EACT,aACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,KAAK;EACL,SAAS;EACT,WAAW;EACX,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;EACN,aAAa;EACb,QAAQ;CACT,CAAC;CACD,KAAK,sBAAsB,qBAAqB,gDAAgD;CAChG,KACC,0BACA,sBACA,qFACA,yDACD;CACA,KACC,8BACA,gCACA,oDACD;CACA,KACC,kBACA,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D,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,SAAS;EACT,aACC;EACD,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,SAAS;EACT,aAAa;EACb,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,SAAS;EACT,aACC;EACD,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,KAAK;EACL,WAAW;EACX,OAAO;EACP,SAAS;EACT,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,aAAa;EACb,QAAQ,EAAE,MAAM,aAAa;CAC9B,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS,CAAC;EACV,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,QAAQ;GAAC;GAAS;GAAQ;GAAQ;EAAO;EACzC,WAAW;EACX,OAAO;EACP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,SAAS,CAAC,CAAC,KAAK,IAAI,CACpF;CAGD,UAAU,eAAe;CACzB,IAAI,QAAQ,SAAS,GACpB,IAAI,KAAK,6CAA6C;EACrD,WAAW;EACX,MAAM,QAAQ,KAAK,MAAM,EAAE,GAAG;CAC/B,CAAC;AAEH;AAEA,SAAS,iBAAiC;CACzC,MAAM,MAAM,kBAAkB,GAAG;CACjC,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,MAAM,OAAO,KAAK,KAAK,aAAa;CACpC,IAAI,WAAkC;CACtC,IAAI;EACH,IAAI,WAAW,IAAI,GAAG,WAAW,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;CACvE,QAAQ;EACP,WAAW;CACZ;CACA,MAAM,OAAO,mBAAmB,KAAK,UAAU,IAAI;CACnD,IAAI;EACH,cAAc,MAAM,KAAK,UAAU,MAAM,MAAM,GAAI,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;EAC5E,IAAI,QAAQ,aAAa,SAAS,UAAU,MAAM,GAAK;CACxD,SAAS,KAAK;EACb,UAAU,CAAC,CAAC,KAAK,uCAAuC;GACvD,WAAW;GACX,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACrD,CAAC;CACF;CACA,OAAO,WAAW,cAAc,UAAU,IAAI,IAAI,CAAC;AACpD"}
|
|
1
|
+
{"version":3,"file":"boot.server.js","names":[],"sources":["../../../src/lib/server/config/checks.ts","../../../src/lib/server/config/boot.server.ts"],"sourcesContent":["import {\n\tresolveConfig,\n\ttype ConfigReport,\n\ttype EnvRecord,\n\ttype KeyRotation\n} from '@selvajs/platform/config';\nimport { computeDebugMode, deploymentManifest } from './settings.js';\n\n/**\n * Plain-language findings for the admin Configuration page: what is wrong with\n * this deployment, what it breaks, and the command that fixes it. Each finding\n * is derived from the env and the request the admin made, so a proxy that was\n * never mentioned in `.env` still shows up.\n */\n\nexport type CheckLevel = 'error' | 'warning' | 'info';\n\nexport interface ConfigCheck {\n\tid: string;\n\tlevel: CheckLevel;\n\ttitle: string;\n\tdetail: string;\n\t/** Shell commands, run in order on the server. */\n\tfix?: string[];\n\tkeys: string[];\n}\n\nexport interface RequestFacts {\n\t/** A proxy forwarded this request: one of the X-Forwarded-* or Forwarded headers arrived. */\n\tproxied: boolean;\n\t/** What the visitor typed, as far as the proxy says: `https://selva.example.com`. */\n\tseenOrigin: string;\n}\n\nexport function requestFacts(headers: Headers, url: URL): RequestFacts {\n\tconst forwardedHost = firstValue(headers.get('x-forwarded-host'));\n\tconst forwardedProto = firstValue(headers.get('x-forwarded-proto'));\n\tconst proxied =\n\t\theaders.has('x-forwarded-for') ||\n\t\theaders.has('forwarded') ||\n\t\tforwardedHost !== undefined ||\n\t\tforwardedProto !== undefined;\n\tconst proto = forwardedProto ?? url.protocol.replace(/:$/, '');\n\tconst host = forwardedHost ?? url.host;\n\treturn { proxied, seenOrigin: `${proto}://${host}` };\n}\n\nfunction firstValue(header: string | null): string | undefined {\n\tconst v = header?.split(',')[0]?.trim();\n\treturn v ? v : undefined;\n}\n\nexport interface CheckInput {\n\tenv: EnvRecord;\n\treport: ConfigReport;\n\trotation: KeyRotation[];\n\t/** Stored compute API keys still sealed under the previous at-rest key; null outside a rotation. */\n\tatRestOnPreviousKey: number | null;\n\trequest: RequestFacts;\n\tcomputeRequestMaxBytes: number;\n\t/** `vite dev`: development mode is expected, not a finding. */\n\tdev: boolean;\n}\n\nconst restart = 'npx selva restart';\nconst set = (key: string, value: string) => `npx selva config set ${key}=${value}`;\n\nexport function configChecks(input: CheckInput): ConfigCheck[] {\n\tconst { env, report, request } = input;\n\tconst values = resolveConfig(deploymentManifest(env), env).values;\n\tconst label = (key: string) => report.rows.find((r) => r.key === key)?.label ?? key;\n\tconst out: ConfigCheck[] = [];\n\n\tfor (const p of report.problems) {\n\t\tout.push({\n\t\t\tid: `invalid:${p.key}`,\n\t\t\tlevel: p.status === 'error' ? 'error' : 'warning',\n\t\t\ttitle: `${label(p.key)} has a bad value`,\n\t\t\tdetail:\n\t\t\t\tp.status === 'error'\n\t\t\t\t\t? `The value ${p.problem}. The app refuses to start with it.`\n\t\t\t\t\t: `The value ${p.problem}, so the app ignores it and uses the default.`,\n\t\t\tkeys: [p.key]\n\t\t});\n\t}\n\n\tfor (const u of report.unknown) {\n\t\tout.push({\n\t\t\tid: `unknown:${u.key}`,\n\t\t\tlevel: 'warning',\n\t\t\ttitle: `${u.key} does nothing`,\n\t\t\tdetail: u.suggestion\n\t\t\t\t? `Selva doesn't read ${u.key}. It looks like a typo of ${u.suggestion}, which is the one that counts.`\n\t\t\t\t: `Selva doesn't read ${u.key}. Remove it, or check the name against the settings below.`,\n\t\t\t...(u.suggestion ? { fix: [`npx selva config unset ${u.key}`] } : {}),\n\t\t\tkeys: [u.key]\n\t\t});\n\t}\n\n\tconst renamed = report.rows.filter((r) => r.source === 'alias');\n\tif (renamed.length > 0) {\n\t\tout.push({\n\t\t\tid: 'renamed',\n\t\t\tlevel: 'info',\n\t\t\ttitle: 'Some settings use an old name',\n\t\t\tdetail: `${renamed.map((r) => `${r.alias} is now ${r.key}`).join('; ')}. They still work; renaming keeps it that way.`,\n\t\t\tfix: ['selva migrate'],\n\t\t\tkeys: renamed.map((r) => r.key)\n\t\t});\n\t}\n\n\tconst origin = values.ORIGIN as string | undefined;\n\tif (request.proxied && !origin) {\n\t\tout.push({\n\t\t\tid: 'origin-missing',\n\t\t\tlevel: 'error',\n\t\t\ttitle: 'Public address is not set',\n\t\t\tdetail:\n\t\t\t\t'Requests reach Selva through a proxy, but it doesn’t know its own public address. Form posts fail their security check and invite links point at an internal address.',\n\t\t\tfix: [set('ORIGIN', request.seenOrigin), restart],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t} else if (request.proxied && origin && sameOrigin(origin, request.seenOrigin) === false) {\n\t\tout.push({\n\t\t\tid: 'origin-mismatch',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Public address doesn’t match how you reached this page',\n\t\t\tdetail: `You opened Selva at ${request.seenOrigin}, but its public address is ${origin}. Sign-in from ${request.seenOrigin} fails, and invite links point at ${origin}.`,\n\t\t\tfix: [set('ORIGIN', request.seenOrigin), restart],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t}\n\n\tif (origin && /^http:\\/\\//i.test(origin) && !isLoopbackUrl(origin)) {\n\t\tout.push({\n\t\t\tid: 'origin-http',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Sign-ins travel unencrypted',\n\t\t\tdetail: `The public address ${origin} uses http, so passwords and session cookies cross the network in plain text. Put a proxy with a certificate in front: selva setup-proxy does it.`,\n\t\t\tfix: ['selva setup-proxy'],\n\t\t\tkeys: ['ORIGIN']\n\t\t});\n\t}\n\n\tif (request.proxied && !values.ADDRESS_HEADER) {\n\t\tout.push({\n\t\t\tid: 'address-header',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Every visitor looks like the same person',\n\t\t\tdetail:\n\t\t\t\t'Behind a proxy, Selva sees the proxy’s address instead of each visitor’s. Rate limits are shared by everyone, so five failed logins from anyone lock out the whole instance.',\n\t\t\tfix: [set('ADDRESS_HEADER', 'X-Forwarded-For'), set('XFF_DEPTH', '1'), restart],\n\t\t\tkeys: ['ADDRESS_HEADER', 'XFF_DEPTH']\n\t\t});\n\t}\n\n\tconst host = values.HOST as string;\n\tif (request.proxied && (host === '0.0.0.0' || host === '::')) {\n\t\tconst headerAuth = (env.SELVA_AUTH_PROVIDER ?? '').toLowerCase() === 'header';\n\t\tout.push({\n\t\t\tid: 'host-open',\n\t\t\tlevel: headerAuth ? 'error' : 'warning',\n\t\t\ttitle: 'The app can be reached without going through the proxy',\n\t\t\tdetail: headerAuth\n\t\t\t\t? 'Sign-in comes from headers the proxy sets. Anyone who reaches the app’s port directly can send those headers and sign in as any user.'\n\t\t\t\t: 'The app accepts connections from any network, not just from the proxy. Skip this if the proxy runs in another container.',\n\t\t\tfix: [set('HOST', '127.0.0.1'), restart],\n\t\t\tkeys: ['HOST']\n\t\t});\n\t}\n\n\tconst bodyLimit = parseBodySize(values.BODY_SIZE_LIMIT as string);\n\tif (bodyLimit !== null && bodyLimit < input.computeRequestMaxBytes) {\n\t\tout.push({\n\t\t\tid: 'body-size',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Large solves and uploads will be rejected',\n\t\t\tdetail: `The server accepts requests up to ${values.BODY_SIZE_LIMIT}, smaller than the ${formatBytes(input.computeRequestMaxBytes)} a solve may send. Bigger ones fail with \"413 Payload Too Large\" before Selva sees them.`,\n\t\t\tfix: [\n\t\t\t\tset('BODY_SIZE_LIMIT', `${Math.ceil(input.computeRequestMaxBytes / 1024 / 1024)}M`),\n\t\t\t\trestart\n\t\t\t],\n\t\t\tkeys: ['BODY_SIZE_LIMIT']\n\t\t});\n\t}\n\n\tif (values.ALLOW_INSECURE_COOKIES === true) {\n\t\tout.push({\n\t\t\tid: 'insecure-cookies',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Sign-in cookies may be sent over http',\n\t\t\tdetail:\n\t\t\t\t'Meant for testing on a local network. Anyone on the same network can copy a session and act as that user.',\n\t\t\tfix: ['npx selva config unset ALLOW_INSECURE_COOKIES', restart],\n\t\t\tkeys: ['ALLOW_INSECURE_COOKIES']\n\t\t});\n\t}\n\n\tif (!input.dev && env.NODE_ENV !== 'production') {\n\t\tout.push({\n\t\t\tid: 'not-production',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Running in development mode',\n\t\t\tdetail:\n\t\t\t\t'Error pages show stack traces and cookies aren’t marked Secure. npx selva restart starts it through pm2, which sets NODE_ENV=production.',\n\t\t\tfix: [restart],\n\t\t\tkeys: ['NODE_ENV']\n\t\t});\n\t}\n\n\tif (computeDebugMode(env) === 'verbose') {\n\t\tout.push({\n\t\t\tid: 'verbose-debug',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Logs may contain what users solved',\n\t\t\tdetail:\n\t\t\t\t'Verbose compute debugging writes Rhino.Compute’s raw error bodies to the log, and deleting a user doesn’t remove them from there. Turn it off once you’re done debugging.',\n\t\t\tfix: ['npx selva config unset SELVA_FLAG_COMPUTE_DEBUG', restart],\n\t\t\tkeys: ['SELVA_FLAG_COMPUTE_DEBUG']\n\t\t});\n\t}\n\n\tif (values.SMTP_HOST && !values.SMTP_FROM) {\n\t\tout.push({\n\t\t\tid: 'smtp-from',\n\t\t\tlevel: 'warning',\n\t\t\ttitle: 'Mail has no sender address',\n\t\t\tdetail: 'A mail server is set but no sender address, so invite emails can’t be sent.',\n\t\t\tfix: [set('SMTP_FROM', 'selva@your-domain'), restart],\n\t\t\tkeys: ['SMTP_FROM']\n\t\t});\n\t}\n\n\tfor (const r of input.rotation) {\n\t\tconst name = r.key === 'SELVA_HMAC_KEY' ? 'signing key' : 'encryption key';\n\t\tconst finish = `npx selva keys rotate ${r.key === 'SELVA_HMAC_KEY' ? 'hmac' : 'at-rest'} --finish`;\n\t\tconst atRestBusy = r.key === 'SELVA_AT_REST_KEY' && (input.atRestOnPreviousKey ?? 0) > 0;\n\t\tif (r.state === 'active') {\n\t\t\tout.push({\n\t\t\t\tid: `rotation:${r.key}`,\n\t\t\t\tlevel: 'info',\n\t\t\t\ttitle: `Changing the ${name}`,\n\t\t\t\tdetail: `The old ${name} keeps working for ${r.daysLeft} more ${r.daysLeft === 1 ? 'day' : 'days'}, until ${r.expires?.slice(0, 10)}. Nothing to do: it stops on its own.`,\n\t\t\t\tkeys: [`${r.key}_PREVIOUS`]\n\t\t\t});\n\t\t} else if (r.state === 'expired' || r.state === 'no-deadline') {\n\t\t\tout.push({\n\t\t\t\tid: `rotation:${r.key}`,\n\t\t\t\tlevel: 'warning',\n\t\t\t\ttitle:\n\t\t\t\t\tr.state === 'expired'\n\t\t\t\t\t\t? `The old ${name} has expired but is still in .env`\n\t\t\t\t\t\t: `The old ${name} never expires`,\n\t\t\t\tdetail:\n\t\t\t\t\tr.state === 'expired'\n\t\t\t\t\t\t? `It stopped working on ${r.expires?.slice(0, 10)}. Remove it to finish the change.`\n\t\t\t\t\t\t: `It was added without an end date, so a leaked old key stays useful forever. Finish the change to remove it.`,\n\t\t\t\t...(atRestBusy ? {} : { fix: [finish, restart] }),\n\t\t\t\tkeys: [`${r.key}_PREVIOUS`]\n\t\t\t});\n\t\t}\n\t}\n\n\tif (input.atRestOnPreviousKey !== null) {\n\t\tconst n = input.atRestOnPreviousKey;\n\t\tout.push(\n\t\t\tn > 0\n\t\t\t\t? {\n\t\t\t\t\t\tid: 'at-rest-pending',\n\t\t\t\t\t\tlevel: 'warning',\n\t\t\t\t\t\ttitle: `${n} stored compute API ${n === 1 ? 'key is' : 'keys are'} still on the old encryption key`,\n\t\t\t\t\t\tdetail:\n\t\t\t\t\t\t\t'Restart the app to re-encrypt them. Don’t finish the key change before this reaches zero, or they become unreadable.',\n\t\t\t\t\t\tfix: [restart],\n\t\t\t\t\t\tkeys: ['SELVA_AT_REST_KEY_PREVIOUS']\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tid: 'at-rest-pending',\n\t\t\t\t\t\tlevel: 'info',\n\t\t\t\t\t\ttitle: 'Every stored compute API key is on the new encryption key',\n\t\t\t\t\t\tdetail: 'The old encryption key is no longer needed. Finishing removes it.',\n\t\t\t\t\t\tfix: ['npx selva keys rotate at-rest --finish', restart],\n\t\t\t\t\t\tkeys: ['SELVA_AT_REST_KEY_PREVIOUS']\n\t\t\t\t\t}\n\t\t);\n\t}\n\n\tconst order: Record<CheckLevel, number> = { error: 0, warning: 1, info: 2 };\n\treturn out.sort((a, b) => order[a.level] - order[b.level]);\n}\n\nfunction sameOrigin(a: string, b: string): boolean | null {\n\ttry {\n\t\treturn new URL(a).origin === new URL(b).origin;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isLoopbackUrl(url: string): boolean {\n\ttry {\n\t\tconst h = new URL(url).hostname;\n\t\treturn h === 'localhost' || h === '127.0.0.1' || h === '[::1]';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** adapter-node's BODY_SIZE_LIMIT: bytes, or a K/M/G suffix, or Infinity. Null when unreadable. */\nexport function parseBodySize(raw: string | undefined): number | null {\n\tif (!raw) return null;\n\tconst v = raw.trim();\n\tif (v.toLowerCase() === 'infinity') return Infinity;\n\tconst m = /^(\\d+(?:\\.\\d+)?)\\s*([kmg])?b?$/i.exec(v);\n\tif (!m) return null;\n\tconst mult = { k: 1024, m: 1024 ** 2, g: 1024 ** 3 }[(m[2] ?? '').toLowerCase()] ?? 1;\n\treturn Number(m[1]) * mult;\n}\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes >= 1024 ** 3) return `${+(bytes / 1024 ** 3).toFixed(1)} GB`;\n\tif (bytes >= 1024 ** 2) return `${Math.round(bytes / 1024 ** 2)} MB`;\n\treturn `${Math.round(bytes / 1024)} KB`;\n}\n","import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { env } from '#lib/server/env.js';\nimport {\n\tdiffSnapshots,\n\ttype ConfigChange,\n\ttype ConfigReport,\n\ttype ConfigSnapshot,\n\ttype KeyRotation\n} from '@selvajs/platform/config';\nimport { getLogger } from '#lib/server/providers.server.js';\nimport { findDeploymentDir } from '#lib/server/selfUpdate.server.js';\nimport {\n\tdeploymentReport,\n\tdeploymentSnapshot,\n\tkeyRotationStatus,\n\tRETIRED_KEYS\n} from './settings.js';\nimport { configChecks, type CheckInput, type ConfigCheck } from './checks.js';\n\n/** Beside `.env` in the deployment directory. The CLI reads it too. */\nexport const SNAPSHOT_FILE = '.selva-config-snapshot.json';\n\nlet report: ConfigReport | null = null;\nlet changes: ConfigChange[] = [];\n\n/** The configuration this process runs on, safe to send to an admin's browser. */\nexport function getConfigReport(): ConfigReport {\n\treport ??= deploymentReport(env);\n\treturn report;\n}\n\n/** Each root key's rotation overlap, read now so a deadline that passes shows without a restart. */\nexport function getKeyRotation(): KeyRotation[] {\n\treturn keyRotationStatus(env);\n}\n\n/** Findings for the admin page, read per request: proxy detection depends on the request. */\nexport function getConfigChecks(\n\tinput: Omit<CheckInput, 'env' | 'report' | 'rotation'>\n): ConfigCheck[] {\n\treturn configChecks({ ...input, env, report: getConfigReport(), rotation: getKeyRotation() });\n}\n\n/** What differs from the previous boot's snapshot. Empty outside a deployment. */\nexport function getChangesSinceLastBoot(): ConfigChange[] {\n\treturn changes;\n}\n\n/**\n * Run once at server start. Throws on a fail-closed key with a bad value, so a\n * typo in a security control stops boot instead of switching the control off.\n */\nexport function checkConfigAtBoot(): void {\n\tconst current = getConfigReport();\n\tconst log = getLogger();\n\n\tconst errors = current.problems.filter((p) => p.status === 'error');\n\tfor (const p of current.problems.filter((r) => r.status === 'invalid')) {\n\t\tlog.warn('Invalid env value, using the default', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: p.key,\n\t\t\tproblem: p.problem\n\t\t});\n\t}\n\tfor (const u of current.unknown) {\n\t\tlog.warn('Unknown env var', { component: 'config', envVar: u.key, suggestion: u.suggestion });\n\t}\n\tfor (const [key, now] of Object.entries(RETIRED_KEYS)) {\n\t\tif (env[key] === undefined) continue;\n\t\tlog.warn('Retired env var, ignored: run `selva migrate`', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: key,\n\t\t\tnow\n\t\t});\n\t}\n\tfor (const row of current.rows.filter((r) => r.source === 'alias')) {\n\t\tlog.warn('Deprecated env var: run `selva migrate`', {\n\t\t\tcomponent: 'config',\n\t\t\tenvVar: row.alias,\n\t\t\trenamedTo: row.key\n\t\t});\n\t}\n\tfor (const r of getKeyRotation()) {\n\t\tif (r.state === 'expired' || r.state === 'no-deadline') {\n\t\t\tlog.warn(\n\t\t\t\tr.state === 'expired'\n\t\t\t\t\t? 'Previous key is no longer accepted (deadline passed, unreadable or too far out): remove it'\n\t\t\t\t\t: 'Previous key has no deadline and is accepted for good',\n\t\t\t\t{ component: 'config', envVar: `${r.key}_PREVIOUS`, expires: r.expires }\n\t\t\t);\n\t\t}\n\t}\n\tif (errors.length > 0) {\n\t\tthrow new Error(\n\t\t\t'Invalid configuration:\\n' + errors.map((e) => ` ${e.key} ${e.problem}`).join('\\n')\n\t\t);\n\t}\n\n\tchanges = recordSnapshot();\n\tif (changes.length > 0) {\n\t\tlog.info('Configuration changed since the last boot', {\n\t\t\tcomponent: 'config',\n\t\t\tkeys: changes.map((c) => c.key)\n\t\t});\n\t}\n}\n\nfunction recordSnapshot(): ConfigChange[] {\n\tconst dir = findDeploymentDir(env);\n\tif (!dir) return [];\n\tconst path = join(dir, SNAPSHOT_FILE);\n\tlet previous: ConfigSnapshot | null = null;\n\ttry {\n\t\tif (existsSync(path)) previous = JSON.parse(readFileSync(path, 'utf8')) as ConfigSnapshot;\n\t} catch {\n\t\tprevious = null;\n\t}\n\tconst next = deploymentSnapshot(\n\t\tenv,\n\t\ttypeof previous?.salt === 'string' ? previous.salt : undefined\n\t);\n\ttry {\n\t\twriteFileSync(path, JSON.stringify(next, null, '\\t') + '\\n', { mode: 0o600 });\n\t\tif (process.platform !== 'win32') chmodSync(path, 0o600);\n\t} catch (err) {\n\t\tgetLogger().warn('Could not write the config snapshot', {\n\t\t\tcomponent: 'config',\n\t\t\terr: err instanceof Error ? err.message : String(err)\n\t\t});\n\t}\n\tif (!previous) return [];\n\t// A hand-edited or truncated file counts as no previous snapshot: it must not stop boot.\n\ttry {\n\t\treturn diffSnapshots(previous, next);\n\t} catch {\n\t\treturn [];\n\t}\n}\n"],"mappings":";;;;;;;AAkCA,SAAgB,aAAa,SAAkB,KAAwB;CACtE,MAAM,gBAAgB,WAAW,QAAQ,IAAI,kBAAkB,CAAC;CAChE,MAAM,iBAAiB,WAAW,QAAQ,IAAI,mBAAmB,CAAC;CAQlE,OAAO;EAAE,SANR,QAAQ,IAAI,iBAAiB,KAC7B,QAAQ,IAAI,WAAW,KACvB,kBAAkB,KAAA,KAClB,mBAAmB,KAAA;EAGF,YAAY,GAFhB,kBAAkB,IAAI,SAAS,QAAQ,MAAM,EAAE,EAEtB,KAD1B,iBAAiB,IAAI;CACiB;AACpD;AAEA,SAAS,WAAW,QAA2C;CAC9D,M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C/B,CAAC;AAEH;AAEA,SAAS,iBAAiC;CACzC,MAAM,MAAM,kBAAkB,GAAG;CACjC,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,MAAM,OAAO,KAAK,KAAK,aAAa;CACpC,IAAI,WAAkC;CACtC,IAAI;EACH,IAAI,WAAW,IAAI,GAAG,WAAW,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;CACvE,QAAQ;EACP,WAAW;CACZ;CACA,MAAM,OAAO,mBACZ,KACA,OAAO,UAAU,SAAS,WAAW,SAAS,OAAO,KAAA,CACtD;CACA,IAAI;EACH,cAAc,MAAM,KAAK,UAAU,MAAM,MAAM,GAAI,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;EAC5E,IAAI,QAAQ,aAAa,SAAS,UAAU,MAAM,GAAK;CACxD,SAAS,KAAK;EACb,UAAU,CAAC,CAAC,KAAK,uCAAuC;GACvD,WAAW;GACX,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACrD,CAAC;CACF;CACA,IAAI,CAAC,UAAU,OAAO,CAAC;CAEvB,IAAI;EACH,OAAO,cAAc,UAAU,IAAI;CACpC,QAAQ;EACP,OAAO,CAAC;CACT;AACD"}
|
|
@@ -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
|
|
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\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\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,gBAAiD;CAErD,MAAM,QAAQ,UAAU,KAAK;CAK7B,IAAI,OAAO,MAAM,qBAAqB,YACrC,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,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+
import "./limits.js";
|
|
2
2
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { 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
4
|
import "./compute.js";
|
|
5
5
|
// src/lib/server/computeLimits.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { w as lazyLogger } from "./providers.server.js";
|
|
2
2
|
import { n as env } from "./previous-key.js";
|
|
3
|
-
import {
|
|
3
|
+
import { A as resolveApiRateLimitConfig, D as createApiRateLimiter } from "./api.js";
|
|
4
4
|
import { t as createComputeRateLimiter } from "./rate-limit.js";
|
|
5
5
|
import "./compute.js";
|
|
6
6
|
import { c as RATE_LIMIT_WINDOW_MS, s as RATE_LIMIT_MAX_REQUESTS } from "./computeLimits.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as ALL_ORG_PERMISSIONS } from "./
|
|
1
|
+
import { n as ALL_ORG_PERMISSIONS } from "./schemas2.js";
|
|
2
2
|
import { t as ALL_PLATFORM_PERMISSIONS } from "./types3.js";
|
|
3
|
-
// ../platform/src/errors.ts
|
|
3
|
+
// ../platform/src/errors/provider-error.ts
|
|
4
|
+
var BRAND = Symbol.for("@selvajs/platform/ProviderError");
|
|
4
5
|
/**
|
|
5
6
|
* Thrown by providers to signal an expected failure the API layer forwards with
|
|
6
7
|
* a specific status. Unknown errors should propagate as plain `Error` and become 500s.
|
|
7
8
|
*/
|
|
8
|
-
var BRAND = Symbol.for("@selvajs/platform/ProviderError");
|
|
9
9
|
var ProviderError = class ProviderError extends Error {
|
|
10
10
|
statusCode;
|
|
11
11
|
[BRAND] = true;
|
|
@@ -32,12 +32,13 @@ var SYSTEM_CONTEXT = {
|
|
|
32
32
|
system: true
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `actingOrgId
|
|
35
|
+
* A share-link context holds nothing, whatever it carries; `system` and `instance_admin`
|
|
36
|
+
* hold everything. An org permission is read from `ctx.orgPermissions` without looking at
|
|
37
|
+
* `actingOrgId`, so build the context for the org you act on.
|
|
38
38
|
*/
|
|
39
39
|
function hasPermission(ctx, permission) {
|
|
40
|
-
if (
|
|
40
|
+
if (isShareContext(ctx)) return false;
|
|
41
|
+
if (ctx.system) return true;
|
|
41
42
|
if (ctx.platformPermissions.includes("instance_admin")) return true;
|
|
42
43
|
if (isPlatformPermission(permission)) return ctx.platformPermissions.includes(permission);
|
|
43
44
|
return ctx.orgPermissions.includes(permission);
|
|
@@ -58,45 +59,10 @@ function isShareContext(ctx) {
|
|
|
58
59
|
function assertNotShareContext(ctx, what) {
|
|
59
60
|
if (isShareContext(ctx)) throw new ProviderError(`Forbidden: a share link cannot ${what}`, 403);
|
|
60
61
|
}
|
|
61
|
-
/** May `ctx` read `userId`'s platform permissions? Throws `ProviderError(403)` if not. */
|
|
62
|
-
function assertCanReadPermissions(ctx, userId) {
|
|
63
|
-
assertNotShareContext(ctx, "read permissions");
|
|
64
|
-
if (ctx.system) return;
|
|
65
|
-
if (ctx.userId === userId) return;
|
|
66
|
-
if (hasPermission(ctx, "instance_admin")) return;
|
|
67
|
-
if (hasPermission(ctx, "manage_instance_users")) return;
|
|
68
|
-
throw new ProviderError("Forbidden: cannot read another user’s permissions", 403);
|
|
69
|
-
}
|
|
70
|
-
/** May `ctx` read several users' platform permissions? Throws `ProviderError(403)` if not. */
|
|
71
|
-
function assertCanReadPermissionsBatch(ctx) {
|
|
72
|
-
assertNotShareContext(ctx, "read permissions");
|
|
73
|
-
if (ctx.system) return;
|
|
74
|
-
if (hasPermission(ctx, "instance_admin")) return;
|
|
75
|
-
if (hasPermission(ctx, "manage_instance_users")) return;
|
|
76
|
-
throw new ProviderError("Forbidden: instance admin or manage_instance_users required", 403);
|
|
77
|
-
}
|
|
78
|
-
/** May `ctx` change platform permissions? Throws `ProviderError(403)` if not. */
|
|
79
|
-
function assertCanManagePermissions(ctx) {
|
|
80
|
-
assertNotShareContext(ctx, "manage permissions");
|
|
81
|
-
if (ctx.system) return;
|
|
82
|
-
if (hasPermission(ctx, "instance_admin")) return;
|
|
83
|
-
throw new ProviderError("Forbidden: instance admin required", 403);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* For provider authors: may `ctx` read or change `userId`'s profile? Throws
|
|
87
|
-
* `ProviderError(403)` if not.
|
|
88
|
-
*/
|
|
89
|
-
function assertCanAccessProfile(ctx, userId) {
|
|
90
|
-
assertNotShareContext(ctx, "access user profiles");
|
|
91
|
-
if (ctx.system) return;
|
|
92
|
-
if (ctx.userId === userId) return;
|
|
93
|
-
if (hasPermission(ctx, "instance_admin")) return;
|
|
94
|
-
throw new ProviderError("Forbidden: cannot access another user’s profile", 403);
|
|
95
|
-
}
|
|
96
62
|
var PLATFORM_PERMISSION_VALUES = new Set(ALL_PLATFORM_PERMISSIONS);
|
|
97
63
|
function isPlatformPermission(p) {
|
|
98
64
|
return PLATFORM_PERMISSION_VALUES.has(p);
|
|
99
65
|
}
|
|
100
|
-
export {
|
|
66
|
+
export { ProviderError as i, assertNotShareContext as n, hasPermission as r, SYSTEM_CONTEXT as t };
|
|
101
67
|
|
|
102
68
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../../platform/src/errors.ts","../../../../platform/src/context.ts"],"sourcesContent":["/**\n * Thrown by providers to signal an expected failure the API layer forwards with\n * a specific status. Unknown errors should propagate as plain `Error` and become 500s.\n */\
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../../platform/src/errors/provider-error.ts","../../../../platform/src/context.ts"],"sourcesContent":["const BRAND = Symbol.for('@selvajs/platform/ProviderError');\n\n/**\n * Thrown by providers to signal an expected failure the API layer forwards with\n * a specific status. Unknown errors should propagate as plain `Error` and become 500s.\n */\nexport class ProviderError extends Error {\n\treadonly statusCode: number;\n\treadonly [BRAND] = true;\n\n\t/**\n\t * Providers depend on this package, so a version mismatch installs two copies\n\t * and plain `instanceof` would turn a 403 from one into a 500 in the other.\n\t */\n\tstatic [Symbol.hasInstance](value: unknown): boolean {\n\t\tif (this !== ProviderError) return Function.prototype[Symbol.hasInstance].call(this, value);\n\t\treturn typeof value === 'object' && value !== null && BRAND in value;\n\t}\n\n\tconstructor(message: string, statusCode: number = 400) {\n\t\tsuper(message);\n\t\tthis.name = 'ProviderError';\n\t\tthis.statusCode = statusCode;\n\t}\n}\n","import type { PlatformPermission } from './permissions/types.js';\nimport { ALL_PLATFORM_PERMISSIONS } from './permissions/types.js';\nimport type { OrgPermission } from './organizations/schemas.js';\nimport { ALL_ORG_PERMISSIONS } from './organizations/schemas.js';\nimport { ProviderError } from './errors/index.js';\nimport type { ApiScope } from './apiTokens/types.js';\n\n/**\n * Per-request identity + scope passed to every data provider call, built once\n * per HTTP request from the authenticated session.\n *\n * `actingOrgId` is the org the user is currently acting as — NOT \"an org the\n * user is a member of.\" Tenancy checks compare it to the resource's `orgId`.\n *\n * `instance_admin` implies every other permission everywhere, via `hasPermission`.\n * `system: true` marks a trusted server-internal call; adapters with RLS treat it\n * as fully authorized.\n */\nexport interface RequestContext {\n\t/** Empty string for system contexts. */\n\tuserId: string;\n\t/** Undefined for instance-admin global reads and pre-org routes. */\n\tactingOrgId?: string;\n\tplatformPermissions: PlatformPermission[];\n\t/** Empty when `actingOrgId` is undefined. */\n\torgPermissions: OrgPermission[];\n\t/** Never derive from a user session. */\n\tsystem?: true;\n\t/**\n\t * Set when `system` was granted by a share-link token rather than by a\n\t * trusted server flow. The token holder is anonymous, so `system` here means\n\t * only \"use the service-role client\" (no user JWT exists to scope RLS) — it\n\t * must never read as \"authorized\". `assertNotShareContext` is how a store\n\t * guard refuses.\n\t */\n\tshareLinkId?: string;\n\t/**\n\t * Set when the request authenticated with an API token. `scopeAllows` reads\n\t * it; a request without it is a browser or proxy session.\n\t */\n\tapiScope?: { tokenId: string; scopes: readonly ApiScope[]; expiresAt: string };\n\t/** Opaque adapter payload — the Supabase adapter passes the user JWT through for RLS; local ignores it. */\n\tadapterContext?: unknown;\n}\n\n/** For server-internal operations outside any HTTP request (bootstrap, janitors, migrations). */\nexport const SYSTEM_CONTEXT: RequestContext = {\n\tuserId: '',\n\tplatformPermissions: [...ALL_PLATFORM_PERMISSIONS],\n\torgPermissions: [...ALL_ORG_PERMISSIONS],\n\tsystem: true\n};\n\n/**\n * A share-link context holds nothing, whatever it carries; `system` and `instance_admin`\n * hold everything. An org permission is read from `ctx.orgPermissions` without looking at\n * `actingOrgId`, so build the context for the org you act on.\n */\nexport function hasPermission(\n\tctx: RequestContext,\n\tpermission: PlatformPermission | OrgPermission\n): boolean {\n\tif (isShareContext(ctx)) return false;\n\tif (ctx.system) return true;\n\tif (ctx.platformPermissions.includes('instance_admin')) return true;\n\tif (isPlatformPermission(permission)) {\n\t\treturn ctx.platformPermissions.includes(permission);\n\t}\n\treturn ctx.orgPermissions.includes(permission);\n}\n\n/**\n * An anonymous share-link holder. `system` is true on these contexts for adapter\n * dispatch only — a guard that treats `system` as \"fully authorized\" must\n * exclude them first.\n */\nexport function isShareContext(ctx: RequestContext): boolean {\n\treturn ctx.shareLinkId !== undefined;\n}\n\n/**\n * Refuse a privileged operation to a share-link context. Call at the top of any\n * guard whose first line is `if (ctx.system) return` — the token grants one\n * definition on one channel, never instance authority.\n */\nexport function assertNotShareContext(ctx: RequestContext, what: string): void {\n\tif (isShareContext(ctx)) {\n\t\tthrow new ProviderError(`Forbidden: a share link cannot ${what}`, 403);\n\t}\n}\n\nconst PLATFORM_PERMISSION_VALUES = new Set<string>(ALL_PLATFORM_PERMISSIONS);\n\nfunction isPlatformPermission(p: string): p is PlatformPermission {\n\treturn PLATFORM_PERMISSION_VALUES.has(p);\n}\n\n/**\n * Returns the org the caller is acting as, or throws `ProviderError(403)`.\n * Centralizes this guard so every store that scopes rows to an acting org fails\n * the same consistent way, instead of leaking `org_id = undefined` into a query.\n */\nexport function requireActingOrg(ctx: RequestContext): string {\n\tif (!ctx.actingOrgId) {\n\t\tthrow new ProviderError('No acting organization in context', 403);\n\t}\n\treturn ctx.actingOrgId;\n}\n"],"mappings":";;;AAAA,IAAM,QAAQ,OAAO,IAAI,iCAAiC;;;;;AAM1D,IAAa,gBAAb,MAAa,sBAAsB,MAAM;CACxC;CACA,CAAU,SAAS;;;;;CAMnB,QAAQ,OAAO,aAAa,OAAyB;EACpD,IAAI,SAAS,eAAe,OAAO,SAAS,UAAU,OAAO,YAAY,CAAC,KAAK,MAAM,KAAK;EAC1F,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;CAChE;CAEA,YAAY,SAAiB,aAAqB,KAAK;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,aAAa;CACnB;AACD;;;ACsBA,IAAa,iBAAiC;CAC7C,QAAQ;CACR,qBAAqB,CAAC,GAAG,wBAAwB;CACjD,gBAAgB,CAAC,GAAG,mBAAmB;CACvC,QAAQ;AACT;;;;;;AAOA,SAAgB,cACf,KACA,YACU;CACV,IAAI,eAAe,GAAG,GAAG,OAAO;CAChC,IAAI,IAAI,QAAQ,OAAO;CACvB,IAAI,IAAI,oBAAoB,SAAS,gBAAgB,GAAG,OAAO;CAC/D,IAAI,qBAAqB,UAAU,GAClC,OAAO,IAAI,oBAAoB,SAAS,UAAU;CAEnD,OAAO,IAAI,eAAe,SAAS,UAAU;AAC9C;;;;;;AAOA,SAAgB,eAAe,KAA8B;CAC5D,OAAO,IAAI,gBAAgB,KAAA;AAC5B;;;;;;AAOA,SAAgB,sBAAsB,KAAqB,MAAoB;CAC9E,IAAI,eAAe,GAAG,GACrB,MAAM,IAAI,cAAc,kCAAkC,QAAQ,GAAG;AAEvE;AAEA,IAAM,6BAA6B,IAAI,IAAY,wBAAwB;AAE3E,SAAS,qBAAqB,GAAoC;CACjE,OAAO,2BAA2B,IAAI,CAAC;AACxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as apiError, k as ApiErrorCode } from "./access.js";
|
|
2
|
-
import {
|
|
3
|
-
import { f as slugify } from "./
|
|
2
|
+
import { i as ProviderError } from "./context.js";
|
|
3
|
+
import { f as slugify } from "./schemas2.js";
|
|
4
4
|
// ../server/src/projects/create-project.ts
|
|
5
5
|
var MAX_SLUG_ATTEMPTS = 25;
|
|
6
6
|
function isSlugConflict(err) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as definitionPaths, V 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,4 +1,4 @@
|
|
|
1
|
-
import { D as SolveEngine, f as getLogger } from "./providers.server.js";
|
|
1
|
+
import { D as computeDebugMode, N as SolveEngine, f as getLogger } from "./providers.server.js";
|
|
2
2
|
import { n as env } from "./previous-key.js";
|
|
3
3
|
import { f as computeLimits } from "./computeLimits.js";
|
|
4
4
|
// src/lib/server/compute/engine.server.ts
|
|
@@ -6,21 +6,7 @@ import { f as computeLimits } from "./computeLimits.js";
|
|
|
6
6
|
* App-wide `SolveEngine` instance (`@selvajs/solve/server`) — backs the warm
|
|
7
7
|
* client cache, the definition-byte cache, and solve coalescing for the whole app.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
* `SELVA_FLAG_COMPUTE_DEBUG` is a three-way knob, not a boolean: `off` (default),
|
|
11
|
-
* `on` (concise cache/timing logs), or `verbose` (adds lib-level request logs and
|
|
12
|
-
* Compute's raw error bodies). `verbose` implies `on`.
|
|
13
|
-
*/
|
|
14
|
-
var COMPUTE_DEBUG_MODE = (() => {
|
|
15
|
-
const raw = (env.SELVA_FLAG_COMPUTE_DEBUG ?? "").toLowerCase();
|
|
16
|
-
if (raw === "verbose") return "verbose";
|
|
17
|
-
return [
|
|
18
|
-
"true",
|
|
19
|
-
"1",
|
|
20
|
-
"yes",
|
|
21
|
-
"on"
|
|
22
|
-
].includes(raw) ? "on" : "off";
|
|
23
|
-
})();
|
|
9
|
+
var COMPUTE_DEBUG_MODE = computeDebugMode(env);
|
|
24
10
|
var COMPUTE_DEBUG = COMPUTE_DEBUG_MODE !== "off";
|
|
25
11
|
var COMPUTE_DEBUG_VERBOSE = COMPUTE_DEBUG_MODE === "verbose";
|
|
26
12
|
var engine = new SolveEngine({
|
|
@@ -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 type { ComputeServerConfig } from '@selvajs/platform';\n\n
|
|
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(\n\tserverConfig: ComputeServerConfig,\n\topts?: { definitionGuid?: string }\n): Promise<CachedClient> {\n\treturn engine.getClient(\n\t\t{ id: serverConfig.id, serverUrl: serverConfig.serverUrl, apiKey: serverConfig.apiKey },\n\t\topts\n\t);\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":";;;;;;;;AAaA,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,UACf,cACA,MACwB;CACxB,OAAO,OAAO,UACb;EAAE,IAAI,aAAa;EAAI,WAAW,aAAa;EAAW,QAAQ,aAAa;CAAO,GACtF,IACD;AACD;;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"}
|
|
@@ -1536,7 +1536,8 @@ var ComputeServerStats = class ComputeServerStats {
|
|
|
1536
1536
|
return {
|
|
1537
1537
|
timeoutSeconds: json.timeoutSeconds,
|
|
1538
1538
|
maxRequestBytes: json.maxRequestBytes,
|
|
1539
|
-
signalsStaleDefinition: json.signalsStaleDefinition === true
|
|
1539
|
+
signalsStaleDefinition: json.signalsStaleDefinition === true,
|
|
1540
|
+
deploymentId: typeof json.deploymentId === "string" && json.deploymentId !== "" ? json.deploymentId : null
|
|
1540
1541
|
};
|
|
1541
1542
|
}
|
|
1542
1543
|
/**
|