@selvajs/selva 4.20.0 → 4.20.1-beta.0
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.CqMxMIbm.css +2 -0
- package/build/client/_app/immutable/assets/0.CqMxMIbm.css.br +0 -0
- package/build/client/_app/immutable/assets/0.CqMxMIbm.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/{DyqtDkQe.js → B9o4N7Mf.js} +1 -1
- package/build/client/_app/immutable/chunks/B9o4N7Mf.js.br +0 -0
- package/build/client/_app/immutable/chunks/B9o4N7Mf.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DbTdXFSI.js → CDkfHL-P.js} +1 -1
- package/build/client/_app/immutable/chunks/CDkfHL-P.js.br +0 -0
- package/build/client/_app/immutable/chunks/CDkfHL-P.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DVcao28H.js → CEJB5MhK.js} +1 -1
- package/build/client/_app/immutable/chunks/CEJB5MhK.js.br +0 -0
- package/build/client/_app/immutable/chunks/CEJB5MhK.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CmSGJYdN.js +1 -0
- package/build/client/_app/immutable/chunks/CmSGJYdN.js.br +1 -0
- package/build/client/_app/immutable/chunks/CmSGJYdN.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{6oDkMEbX.js → DkB5TkAO.js} +62 -39
- package/build/client/_app/immutable/chunks/DkB5TkAO.js.br +0 -0
- package/build/client/_app/immutable/chunks/DkB5TkAO.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.CN37JsEV.js → app.BOj9G5jx.js} +2 -2
- package/build/client/_app/immutable/entry/app.BOj9G5jx.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BOj9G5jx.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.c6X0ddnS.js → 2.CERUnqD5.js} +1 -1
- package/build/client/_app/immutable/nodes/{2.c6X0ddnS.js.br → 2.CERUnqD5.js.br} +0 -0
- package/build/client/_app/immutable/nodes/2.CERUnqD5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.CyrNl6i7.js → 20.BqTJQD3B.js} +1 -1
- package/build/client/_app/immutable/nodes/20.BqTJQD3B.js.br +0 -0
- package/build/client/_app/immutable/nodes/{20.CyrNl6i7.js.gz → 20.BqTJQD3B.js.gz} +0 -0
- package/build/client/_app/immutable/nodes/21.DeRwDjP4.js +1 -0
- package/build/client/_app/immutable/nodes/21.DeRwDjP4.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.DeRwDjP4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{5.Ck6I7GRI.js → 5.Cw-wybBi.js} +1 -1
- package/build/client/_app/immutable/nodes/5.Cw-wybBi.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.Cw-wybBi.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.BiSiWLjz.js → 6.BiVPgDTL.js} +1 -1
- package/build/client/_app/immutable/nodes/6.BiVPgDTL.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BiVPgDTL.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{7.OTA16TkX.js → 7.BUhgSp_A.js} +1 -1
- package/build/client/_app/immutable/nodes/7.BUhgSp_A.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.BUhgSp_A.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/server/.vite/manifest.json +2 -2
- package/build/server/_app/immutable/assets/_layout.CqMxMIbm.css +2 -0
- package/build/server/_app/immutable/assets/{_page.BLIssNhc.css → _page.l97MEw0G.css} +1 -1
- package/build/server/chunks/SettingsMenu.js +1 -1
- package/build/server/chunks/SettingsMenu.js.map +1 -1
- package/build/server/chunks/boot.server.js +2 -1
- package/build/server/chunks/boot.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/instance.js +3 -3
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/providers.server.js +52 -19
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +104 -35
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/manifest-full.js +1 -1
- package/build/server/manifest.js +1 -1
- package/build/server/nodes/0.js +2 -2
- package/build/server/nodes/2.js +1 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/21.js +2 -2
- 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 +6 -6
- 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/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.gz +0 -0
- package/build/client/_app/immutable/nodes/20.CyrNl6i7.js.br +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/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.146jEGn4.js} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.br → 0.146jEGn4.js.br} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.gz → 0.146jEGn4.js.gz} +0 -0
|
@@ -638,7 +638,8 @@ var RETIRED_KEYS = {
|
|
|
638
638
|
SUPABASE_PRIVATE_URL_PREFIX: "fixed at /api/files",
|
|
639
639
|
COMPUTE_SOLVE_DEADLINE_MS: "set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server",
|
|
640
640
|
MAX_SOLVE_DURATION_MS: "set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server",
|
|
641
|
-
COMPUTE_REUSE_DEFINITION_CACHE: "on whenever the compute server reports /limits"
|
|
641
|
+
COMPUTE_REUSE_DEFINITION_CACHE: "on whenever the compute server reports /limits",
|
|
642
|
+
COMPUTE_CACHE_ERRORED_SOLVES: "removed"
|
|
642
643
|
};
|
|
643
644
|
/**
|
|
644
645
|
* The manifest for this deployment: engine and app keys, plus the slices of
|
|
@@ -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,IAAI,EAAE,SAAU,IAAI,KAAK;EAC5D,OAAO;GACN,KAAK,KAAK;GACV,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;GAC1C,MAAM,KAAK;GACX,UAAU,KAAK,aAAa;GAC5B,GAAI,KAAK,SAAS,SAAS,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;GAC9D,GAAI,KAAK,SAAS,SAAS,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;GAC9D,OAAO,KAAK;GACZ,SAAS,KAAK,YAAY;GAC1B,aAAa,KAAK;GAClB,GAAI,KAAK,SAAS,EAAE,QAAQ,KAAK,OAAO,IAA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KAAK,IAAI;CAAE,CAAC;CAEzF,OAAO;AACR;;AC5DA,IAAM,QAAQ,KAAa,OAAe,aAAqB,WAC9D,cAAc;CACb,KAAK,cAAc;CACnB;CACA,MAAM;CACN,SAAS;CACT,WAAW;CACX,OAAO;CACP;CACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAC5B,CAAC;AAEF,IAAM,cACL,KACA,UACA,OACA,aACA,QAAmF,CAAC,MAEpF,cAAc;CACb;CACA;CACA,MAAM;CACN,KAAK;CACL,SAAS;CACT,WAAW;CACX,OAAO;CACP;CACA,GAAG;AACJ,CAAC;AAEF,IAAM,KAAK;AAEX,IAAa,kBAAkB,gBAAgB;CAE9C,GACC;EACC;GACC;GACA;GACA;EACD;EACA;GACC;GACA;GACA;EACD;EACA;GACC;GACA;GACA;EACD;CACD,CAAC,CACA,KAAK,CAAC,MAAM,OAAO,iBACpB,cAAc;EACb,KAAK,SAAS,KAAK;EACnB;EACA,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,SAAS;EACT;EACA,QACC;CACF,CAAC,CACF;CACA,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,QAAQ,CAAC,UAAU,OAAO;EAC1B,SAAS;EACT,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;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,eACA,oDACA,gEACD;CACA,KACC,4BACA,qBACA,iEACD;CAGA,GACC;EACC;GAAC;GAAQ;GAAgB;EAAwC;EACjE;GAAC;GAAkB;GAAoB;EAAqD;EAC5F;GAAC;GAAW;GAAW;EAA+B;EACtD;GAAC;GAAe;GAAoB;EAAgD;CACrF,CAAC,CACA,KAAK,CAAC,KAAK,OAAO,iBACnB,cAAc;EACb,KAAK,eAAe;EACpB;EACA,MAAM;EACN,WAAW;EACX,OAAO;EACP;CACD,CAAC,CACF;CAGA,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;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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,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,aACC;EACD,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,aACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,aACC;CACF,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,aAAa;CACd,CAAC;AACF,CAAC;;AAGD,IAAa,mBAAmB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;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":["../../../../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\tCOMPUTE_CACHE_ERRORED_SOLVES: 'removed'\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,IAAI,EAAE,SAAU,IAAI,KAAK;EAC5D,OAAO;GACN,KAAK,KAAK;GACV,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;GAC1C,MAAM,KAAK;GACX,UAAU,KAAK,aAAa;GAC5B,GAAI,KAAK,SAAS,SAAS,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAA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;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,eACA,oDACA,gEACD;CACA,KACC,4BACA,qBACA,iEACD;CAGA,GACC;EACC;GAAC;GAAQ;GAAgB;EAAwC;EACjE;GAAC;GAAkB;GAAoB;EAAqD;EAC5F;GAAC;GAAW;GAAW;EAA+B;EACtD;GAAC;GAAe;GAAoB;EAAgD;CACrF,CAAC,CACA,KAAK,CAAC,KAAK,OAAO,iBACnB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AC;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,aAAa;CACd,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,OAAO;EACP,aACC;EACD,QAAQ;CACT,CAAC;CACD,cAAc;EACb,KAAK;EACL,OAAO;EACP,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,aACC;CACF,CAAC;CACD,cAAc;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,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"}
|
|
@@ -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
|
/**
|