@selvajs/selva 4.20.0 → 4.20.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter-node.js +1 -1
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css +2 -0
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css.br +0 -0
- package/build/client/_app/immutable/assets/0.2jDm0bqh.css.gz +0 -0
- package/build/client/_app/immutable/assets/{21.CZQvs3vE.css → 21.DDgTnace.css} +1 -1
- package/build/client/_app/immutable/assets/21.DDgTnace.css.br +0 -0
- package/build/client/_app/immutable/assets/21.DDgTnace.css.gz +0 -0
- package/build/client/_app/immutable/chunks/{DbTdXFSI.js → BDYCH-_Q.js} +1 -1
- package/build/client/_app/immutable/chunks/BDYCH-_Q.js.br +0 -0
- package/build/client/_app/immutable/chunks/BDYCH-_Q.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{6oDkMEbX.js → D-SwRD80.js} +62 -39
- package/build/client/_app/immutable/chunks/D-SwRD80.js.br +0 -0
- package/build/client/_app/immutable/chunks/D-SwRD80.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js +1 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.br +1 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DVcao28H.js → DzxE3j6C.js} +1 -1
- package/build/client/_app/immutable/chunks/DzxE3j6C.js.br +0 -0
- package/build/client/_app/immutable/chunks/DzxE3j6C.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DyqtDkQe.js → qi43d-TM.js} +1 -1
- package/build/client/_app/immutable/chunks/qi43d-TM.js.br +0 -0
- package/build/client/_app/immutable/chunks/qi43d-TM.js.gz +0 -0
- package/build/client/_app/immutable/chunks/zJ-SFdYZ.js +1 -0
- package/build/client/_app/immutable/chunks/zJ-SFdYZ.js.br +0 -0
- package/build/client/_app/immutable/chunks/zJ-SFdYZ.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.CN37JsEV.js → app.hg2qyLJU.js} +2 -2
- package/build/client/_app/immutable/entry/app.hg2qyLJU.js.br +0 -0
- package/build/client/_app/immutable/entry/app.hg2qyLJU.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.c6X0ddnS.js → 2.CUNbzjI_.js} +1 -1
- package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.CyrNl6i7.js → 20.9OIre0ah.js} +1 -1
- package/build/client/_app/immutable/nodes/20.9OIre0ah.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.9OIre0ah.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js +1 -0
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.br +1 -0
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{30.Bz0cB9UL.js → 30.BBuL_XNB.js} +2 -2
- package/build/client/_app/immutable/nodes/30.BBuL_XNB.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.BBuL_XNB.js.gz +0 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js +5 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js.br +0 -0
- package/build/client/_app/immutable/nodes/35.De6sleaH.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{5.Ck6I7GRI.js → 5.DmA9lTA-.js} +1 -1
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.br +1 -0
- package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.BiSiWLjz.js → 6.D6WLqCgl.js} +1 -1
- package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{7.OTA16TkX.js → 7.CNuRjkv2.js} +1 -1
- package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/runtime-meta.json +1 -1
- package/build/server/.vite/manifest.json +108 -89
- package/build/server/_app/immutable/assets/_layout.2jDm0bqh.css +2 -0
- package/build/server/_app/immutable/assets/{_page.BLIssNhc.css → _page.l97MEw0G.css} +1 -1
- package/build/server/chunks/SettingsMenu.js +2 -2
- package/build/server/chunks/SettingsMenu.js.map +1 -1
- package/build/server/chunks/{abort-CNJ8Sn4g.js → abort-Bfrdupaj.js} +10 -3
- package/build/server/chunks/{abort-CNJ8Sn4g.js.map → abort-Bfrdupaj.js.map} +1 -1
- package/build/server/chunks/access.js +608 -150
- package/build/server/chunks/access.js.map +1 -1
- package/build/server/chunks/access2.server.js +2 -2
- package/build/server/chunks/api-errors.js +1 -1
- package/build/server/chunks/api.js +66 -18
- package/build/server/chunks/api.js.map +1 -1
- package/build/server/chunks/auth-bootstrap.server.js +1 -1
- package/build/server/chunks/boot.server.js +12 -701
- package/build/server/chunks/boot.server.js.map +1 -1
- package/build/server/chunks/bootHealth.server.js.map +1 -1
- package/build/server/chunks/compute.js +1 -1
- package/build/server/chunks/computeLimits.js +1 -1
- package/build/server/chunks/computeRateLimit.server.js +1 -1
- package/build/server/chunks/context.js +9 -43
- package/build/server/chunks/context.js.map +1 -1
- package/build/server/chunks/create-project.js +2 -2
- package/build/server/chunks/delete-with-blobs.js +1 -1
- package/build/server/chunks/engine.server.js +2 -16
- package/build/server/chunks/engine.server.js.map +1 -1
- package/build/server/chunks/grasshopper.js +2 -1
- package/build/server/chunks/grasshopper.js.map +1 -1
- package/build/server/chunks/handlers.js +13 -29
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/http.js +93 -6
- package/build/server/chunks/http.js.map +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/instanceAdmins.server.js +1 -1
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/limits.js +71 -0
- package/build/server/chunks/limits.js.map +1 -0
- package/build/server/chunks/ops.js +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/permissions.server.js +1 -1
- package/build/server/chunks/presets.server.js +1 -1
- package/build/server/chunks/previous-key.js +18 -2
- package/build/server/chunks/previous-key.js.map +1 -1
- package/build/server/chunks/providers.server.js +808 -444
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +4 -1
- package/build/server/chunks/registry.js.map +1 -1
- package/build/server/chunks/remote-definition.js +1 -1
- package/build/server/chunks/safe-url.js +1 -1
- package/build/server/chunks/schema.js.map +1 -1
- package/build/server/chunks/schemas.js +12 -61
- package/build/server/chunks/schemas.js.map +1 -1
- package/build/server/chunks/schemas2.js +80 -0
- package/build/server/chunks/schemas2.js.map +1 -0
- package/build/server/chunks/server-config-write.js +3 -8
- package/build/server/chunks/server-config-write.js.map +1 -1
- package/build/server/chunks/signInMaxAge.server.js +1 -1
- package/build/server/chunks/solve.server.js +4 -2
- package/build/server/chunks/solve.server.js.map +1 -1
- package/build/server/chunks/sveltekit.js +4 -4
- package/build/server/chunks/token2.server.js +1 -1
- package/build/server/chunks/tokens.js +2 -2
- package/build/server/chunks/types.js +9 -4
- package/build/server/chunks/types.js.map +1 -1
- package/build/server/chunks/types2.js +1 -2
- package/build/server/chunks/types2.js.map +1 -1
- package/build/server/chunks/visibility.js +1 -1
- package/build/server/chunks/visibility.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +3 -3
- package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +6 -5
- package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +2 -1
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/compute/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_id_/resend/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/invites/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +2 -2
- package/build/server/entries/endpoints/api/v1/projects/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/solve/_solveId_/cancel/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +1 -1
- package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +5 -4
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/hooks.server.js +3 -92
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/accept-invite/_page.server.ts.js +9 -6
- package/build/server/entries/pages/accept-invite/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/admin/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/organizations/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/projects/_id_/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/projects/_page.server.ts.js +1 -1
- package/build/server/entries/pages/admin/system/_page.server.ts.js +2 -2
- package/build/server/entries/pages/admin/users/_page.server.ts.js +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +114 -43
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +1 -1
- package/build/server/entries/pages/projects/_layout.server.ts.js +1 -1
- package/build/server/entries/pages/projects/_page.server.ts.js +2 -2
- package/build/server/entries/pages/setup/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/compute/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/members/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/members/_page.svelte.js +2 -2
- package/build/server/entries/pages/team/members/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/projects/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/settings/_page.server.ts.js +1 -1
- package/build/server/entries/pages/team/shares/_page.server.ts.js +1 -1
- package/build/server/manifest-full.js +1 -1
- package/build/server/manifest.js +1 -1
- package/build/server/nodes/0.js +2 -2
- package/build/server/nodes/2.js +1 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/21.js +2 -2
- package/build/server/nodes/30.js +1 -1
- package/build/server/nodes/35.js +1 -1
- package/build/server/nodes/5.js +1 -1
- package/build/server/nodes/6.js +1 -1
- package/build/server/nodes/7.js +1 -1
- package/build/server/server.js +1 -1
- package/package.json +12 -12
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css +0 -2
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css.br +0 -0
- package/build/client/_app/immutable/assets/0.DwB0QWdx.css.gz +0 -0
- package/build/client/_app/immutable/assets/21.CZQvs3vE.css.br +0 -0
- package/build/client/_app/immutable/assets/21.CZQvs3vE.css.gz +0 -0
- package/build/client/_app/immutable/chunks/6oDkMEbX.js.br +0 -0
- package/build/client/_app/immutable/chunks/6oDkMEbX.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B9IvNrzX.js +0 -1
- package/build/client/_app/immutable/chunks/B9IvNrzX.js.br +0 -1
- package/build/client/_app/immutable/chunks/B9IvNrzX.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DVcao28H.js.br +0 -0
- package/build/client/_app/immutable/chunks/DVcao28H.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DbTdXFSI.js.br +0 -0
- package/build/client/_app/immutable/chunks/DbTdXFSI.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DyqtDkQe.js.br +0 -0
- package/build/client/_app/immutable/chunks/DyqtDkQe.js.gz +0 -0
- package/build/client/_app/immutable/chunks/I4bYfY0F.js +0 -1
- package/build/client/_app/immutable/chunks/I4bYfY0F.js.br +0 -0
- package/build/client/_app/immutable/chunks/I4bYfY0F.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CN37JsEV.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CN37JsEV.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.c6X0ddnS.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.c6X0ddnS.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.CyrNl6i7.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.CyrNl6i7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js +0 -1
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js.br +0 -0
- package/build/client/_app/immutable/nodes/21._AcAMXtP.js.gz +0 -0
- package/build/client/_app/immutable/nodes/30.Bz0cB9UL.js.br +0 -0
- package/build/client/_app/immutable/nodes/30.Bz0cB9UL.js.gz +0 -0
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js +0 -5
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js.br +0 -0
- package/build/client/_app/immutable/nodes/35.DFkalFgm.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.Ck6I7GRI.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.Ck6I7GRI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BiSiWLjz.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BiSiWLjz.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.OTA16TkX.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.OTA16TkX.js.gz +0 -0
- package/build/server/_app/immutable/assets/_layout.DwB0QWdx.css +0 -2
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js → 0.CYdyv5To.js} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.br → 0.CYdyv5To.js.br} +0 -0
- /package/build/client/_app/immutable/nodes/{0.CC0wt5QB.js.gz → 0.CYdyv5To.js.gz} +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { n as env, t as previousKey } from "./previous-key.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { B as NoopLogger, I as ENGINE_SETTINGS, at as composeManifest, et as readSetting, it as trimTrailing, nt as rawValue, ot as defineSetting, rt as parseKey32, tt as resolveConfig, z as isFlagEnabled } from "./access.js";
|
|
3
|
+
import { i as ProviderError, n as assertNotShareContext, r as hasPermission, t as SYSTEM_CONTEXT } from "./context.js";
|
|
4
4
|
import { c as isOrgServer, l as isPlatformServer, o as scopeConfigToOrg } from "./utils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as toSourceDocumentId, i as UUID_REGEX } from "./schemas.js";
|
|
6
|
+
import { i as DEFAULT_ORG_PERMISSIONS, t as ALL_ORG_ASSET_KINDS } from "./schemas2.js";
|
|
6
7
|
import { t as ALL_PLATFORM_PERMISSIONS } from "./types3.js";
|
|
7
8
|
import { d as encodeOffsetCursor, l as clampPageLimit, u as decodeOffsetCursor } from "./visibility.js";
|
|
9
|
+
import { n as readBool } from "./limits.js";
|
|
8
10
|
import { n as renderThrown } from "./definitions.js";
|
|
9
11
|
import { c as ComputeError, i as TreeBuilder, l as ErrorCodes, m as isDefinitionRef, n as GrasshopperClient, p as enableDebugLogging, s as stableStringify } from "./grasshopper.js";
|
|
10
|
-
import {
|
|
12
|
+
import { i as getInputItems, n as serverSourcedInputIds, t as raceAbort } from "./abort-Bfrdupaj.js";
|
|
11
13
|
import { createRequire } from "node:module";
|
|
12
14
|
import * as crypto from "node:crypto";
|
|
13
15
|
import { createCipheriv, createDecipheriv, createHash, createHmac, createPrivateKey, randomBytes, randomUUID, sign, timingSafeEqual } from "node:crypto";
|
|
14
|
-
import { z } from "zod";
|
|
15
16
|
import { gzip } from "node:zlib";
|
|
16
17
|
import { pathToFileURL } from "node:url";
|
|
17
18
|
import * as path$1 from "node:path";
|
|
@@ -23,234 +24,121 @@ import { promisify } from "node:util";
|
|
|
23
24
|
// \0rolldown/runtime.js
|
|
24
25
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
25
26
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
26
|
-
// ../platform/src/config/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
for (const name of [spec.key, ...spec.aliases ?? []]) {
|
|
36
|
-
if (seen.has(name)) throw new Error(`Config key ${name} is declared twice`);
|
|
37
|
-
seen.add(name);
|
|
38
|
-
}
|
|
39
|
-
out.push(spec);
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
}
|
|
43
|
-
// ../platform/src/utils/trim.ts
|
|
44
|
-
function trimTrailing$1(s, ch) {
|
|
45
|
-
let end = s.length;
|
|
46
|
-
while (end > 0 && s[end - 1] === ch) end--;
|
|
47
|
-
return s.slice(0, end);
|
|
48
|
-
}
|
|
49
|
-
// ../platform/src/config/resolve.ts
|
|
50
|
-
var TRUE = /* @__PURE__ */ new Set([
|
|
51
|
-
"true",
|
|
52
|
-
"1",
|
|
53
|
-
"yes",
|
|
54
|
-
"on"
|
|
55
|
-
]);
|
|
56
|
-
var FALSE = /* @__PURE__ */ new Set([
|
|
57
|
-
"false",
|
|
58
|
-
"0",
|
|
59
|
-
"no",
|
|
60
|
-
"off"
|
|
61
|
-
]);
|
|
62
|
-
function parse(spec, raw) {
|
|
63
|
-
const v = raw.trim();
|
|
64
|
-
switch (spec.type) {
|
|
65
|
-
case "string":
|
|
66
|
-
if (spec.minLength !== void 0 && v.length < spec.minLength) return {
|
|
67
|
-
ok: false,
|
|
68
|
-
problem: `must be at least ${spec.minLength} characters`
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
ok: true,
|
|
72
|
-
value: v
|
|
73
|
-
};
|
|
74
|
-
case "key": return isKey32(v) ? {
|
|
75
|
-
ok: true,
|
|
76
|
-
value: v
|
|
77
|
-
} : {
|
|
78
|
-
ok: false,
|
|
79
|
-
problem: "must be 32 bytes as 64 hex characters or base64"
|
|
80
|
-
};
|
|
81
|
-
case "url": try {
|
|
82
|
-
new URL(v);
|
|
83
|
-
return {
|
|
84
|
-
ok: true,
|
|
85
|
-
value: trimTrailing$1(v, "/")
|
|
86
|
-
};
|
|
87
|
-
} catch {
|
|
88
|
-
return {
|
|
89
|
-
ok: false,
|
|
90
|
-
problem: "must be an absolute URL"
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
case "int": {
|
|
94
|
-
const n = Number(v);
|
|
95
|
-
if (!Number.isInteger(n)) return {
|
|
96
|
-
ok: false,
|
|
97
|
-
problem: "must be a whole number"
|
|
98
|
-
};
|
|
99
|
-
if (spec.min !== void 0 && n < spec.min) return {
|
|
100
|
-
ok: false,
|
|
101
|
-
problem: `must be ≥ ${spec.min}`
|
|
102
|
-
};
|
|
103
|
-
if (spec.max !== void 0 && n > spec.max) return {
|
|
104
|
-
ok: false,
|
|
105
|
-
problem: `must be ≤ ${spec.max}`
|
|
106
|
-
};
|
|
107
|
-
return {
|
|
108
|
-
ok: true,
|
|
109
|
-
value: n
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
case "bool": {
|
|
113
|
-
const lower = v.toLowerCase();
|
|
114
|
-
if (TRUE.has(lower)) return {
|
|
115
|
-
ok: true,
|
|
116
|
-
value: true
|
|
117
|
-
};
|
|
118
|
-
if (FALSE.has(lower)) return {
|
|
119
|
-
ok: true,
|
|
120
|
-
value: false
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
ok: false,
|
|
124
|
-
problem: "must be true or false"
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
case "enum": {
|
|
128
|
-
const lower = v.toLowerCase();
|
|
129
|
-
const match = spec.values.find((m) => m.toLowerCase() === lower);
|
|
130
|
-
return match !== void 0 ? {
|
|
131
|
-
ok: true,
|
|
132
|
-
value: match
|
|
133
|
-
} : {
|
|
134
|
-
ok: false,
|
|
135
|
-
problem: `must be one of ${spec.values.join(" | ")}`
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
case "list": return {
|
|
139
|
-
ok: true,
|
|
140
|
-
value: v.split(",").map((s) => s.trim()).filter(Boolean)
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function isKey32(v) {
|
|
145
|
-
if (/^[0-9a-fA-F]{64}$/.test(v)) return true;
|
|
146
|
-
const buf = Buffer.from(v, "base64");
|
|
147
|
-
return buf.length === 32 && trimTrailing$1(buf.toString("base64"), "=") === trimTrailing$1(v, "=");
|
|
148
|
-
}
|
|
149
|
-
function resolveKey(spec, env) {
|
|
150
|
-
let raw = env[spec.key];
|
|
151
|
-
let source = "env";
|
|
152
|
-
let alias;
|
|
153
|
-
if (raw === void 0 || raw === "") {
|
|
154
|
-
alias = spec.aliases?.find((a) => env[a] !== void 0 && env[a] !== "");
|
|
155
|
-
raw = alias ? env[alias] : void 0;
|
|
156
|
-
source = alias ? "alias" : spec.default !== void 0 ? "default" : "unset";
|
|
157
|
-
}
|
|
158
|
-
const base = {
|
|
159
|
-
key: spec.key,
|
|
160
|
-
spec,
|
|
161
|
-
...alias ? { alias } : {}
|
|
162
|
-
};
|
|
163
|
-
if (raw === void 0) {
|
|
164
|
-
if (spec.required) return {
|
|
165
|
-
...base,
|
|
166
|
-
source,
|
|
167
|
-
status: "error",
|
|
168
|
-
value: void 0,
|
|
169
|
-
problem: "is required"
|
|
170
|
-
};
|
|
27
|
+
// ../platform/src/config/report.ts
|
|
28
|
+
/**
|
|
29
|
+
* What `selva config show` and the admin page render. Pure, and free of
|
|
30
|
+
* secret values, so the result can go to a browser or a terminal as is.
|
|
31
|
+
*/
|
|
32
|
+
function buildConfigReport(manifest, env, options = {}) {
|
|
33
|
+
const resolved = resolveConfig(manifest, env, options);
|
|
34
|
+
const rows = manifest.map((spec) => {
|
|
35
|
+
const k = resolved.keys[spec.key];
|
|
171
36
|
return {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
37
|
+
key: spec.key,
|
|
38
|
+
...spec.label ? { label: spec.label } : {},
|
|
39
|
+
type: spec.type,
|
|
40
|
+
required: spec.required === true,
|
|
41
|
+
...spec.type === "int" && spec.zero ? { zero: spec.zero } : {},
|
|
42
|
+
...spec.type === "int" && spec.unit ? { unit: spec.unit } : {},
|
|
43
|
+
class: spec.class,
|
|
44
|
+
summary: spec.summary === true,
|
|
45
|
+
description: spec.description,
|
|
46
|
+
...spec.impact ? { impact: spec.impact } : {},
|
|
47
|
+
source: k.source,
|
|
48
|
+
status: k.status,
|
|
49
|
+
display: display(spec, k, rawValue(spec, env)?.raw),
|
|
50
|
+
...k.problem ? { problem: k.problem } : {},
|
|
51
|
+
...k.alias ? { alias: k.alias } : {}
|
|
176
52
|
};
|
|
177
|
-
}
|
|
178
|
-
const parsed = parse(spec, raw);
|
|
179
|
-
if (parsed.ok) return {
|
|
180
|
-
...base,
|
|
181
|
-
source,
|
|
182
|
-
status: "ok",
|
|
183
|
-
value: parsed.value
|
|
184
|
-
};
|
|
185
|
-
if (spec.onInvalid === "fail") return {
|
|
186
|
-
...base,
|
|
187
|
-
source,
|
|
188
|
-
status: "error",
|
|
189
|
-
value: void 0,
|
|
190
|
-
problem: parsed.problem
|
|
191
|
-
};
|
|
53
|
+
});
|
|
192
54
|
return {
|
|
193
|
-
...
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
value: spec.default,
|
|
197
|
-
problem: parsed.problem
|
|
55
|
+
rows: [...rows.filter((r) => r.summary), ...rows.filter((r) => !r.summary)],
|
|
56
|
+
problems: rows.filter((r) => r.status !== "ok"),
|
|
57
|
+
unknown: resolved.unknown
|
|
198
58
|
};
|
|
199
59
|
}
|
|
200
|
-
/**
|
|
201
|
-
function
|
|
60
|
+
/** `raw` is the env text the value came from, undefined when it is the default. */
|
|
61
|
+
function display(spec, k, raw) {
|
|
62
|
+
if (k.source === "unset") return "";
|
|
63
|
+
if (spec.sensitive) return raw !== void 0 && spec.generated ? fingerprint(raw) : "set";
|
|
64
|
+
return raw === void 0 ? formatValue(k.value) : raw.trim();
|
|
65
|
+
}
|
|
66
|
+
function formatValue(value) {
|
|
67
|
+
if (Array.isArray(value)) return value.join(",");
|
|
68
|
+
return value === void 0 ? "" : String(value);
|
|
69
|
+
}
|
|
70
|
+
/** Short, stable id for a generated key, so two machines can be compared. */
|
|
71
|
+
function fingerprint(value) {
|
|
72
|
+
return `sha256:${createHash("sha256").update(value.trim()).digest("hex").slice(0, 8)}`;
|
|
73
|
+
}
|
|
74
|
+
// ../platform/src/config/snapshot.ts
|
|
75
|
+
var SENSITIVE_MARKER = "set";
|
|
76
|
+
function takeSnapshot(manifest, env, salt) {
|
|
77
|
+
const key = typeof salt === "string" && salt !== "" ? salt : randomBytes(16).toString("hex");
|
|
202
78
|
const values = {};
|
|
203
|
-
const
|
|
204
|
-
const errors = [];
|
|
205
|
-
const known = new Set(options.external ?? []);
|
|
79
|
+
const sensitive = [];
|
|
206
80
|
for (const spec of manifest) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const declared = manifest.map((s) => s.key);
|
|
215
|
-
const prefixes = options.prefixes ?? [];
|
|
216
|
-
const unknown = [];
|
|
217
|
-
for (const key of Object.keys(env)) {
|
|
218
|
-
if (known.has(key) || !prefixes.some((p) => key.startsWith(p))) continue;
|
|
219
|
-
const suggestion = nearest(key, declared);
|
|
220
|
-
unknown.push(suggestion ? {
|
|
221
|
-
key,
|
|
222
|
-
suggestion
|
|
223
|
-
} : { key });
|
|
81
|
+
const found = rawValue(spec, env);
|
|
82
|
+
if (!found) continue;
|
|
83
|
+
const raw = found.raw.trim();
|
|
84
|
+
if (spec.sensitive) {
|
|
85
|
+
values[spec.key] = spec.generated ? createHmac("sha256", key).update(raw).digest("hex").slice(0, 16) : SENSITIVE_MARKER;
|
|
86
|
+
sensitive.push(spec.key);
|
|
87
|
+
} else values[spec.key] = raw;
|
|
224
88
|
}
|
|
225
89
|
return {
|
|
90
|
+
version: 1,
|
|
91
|
+
salt: key,
|
|
226
92
|
values,
|
|
227
|
-
|
|
228
|
-
errors,
|
|
229
|
-
unknown
|
|
93
|
+
sensitive
|
|
230
94
|
};
|
|
231
95
|
}
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
96
|
+
/**
|
|
97
|
+
* What changed since `before`, the previous snapshot as read from disk; anything
|
|
98
|
+
* that is not a snapshot counts as none. Take `after` with `before.salt`, or every
|
|
99
|
+
* generated key reads as changed.
|
|
100
|
+
*/
|
|
101
|
+
function diffSnapshots(before, after) {
|
|
102
|
+
if (!isSnapshot(before)) return [];
|
|
103
|
+
const secret = /* @__PURE__ */ new Set([...before.sensitive, ...after.sensitive]);
|
|
104
|
+
const changes = [];
|
|
105
|
+
const plain = (key, from, to) => secret.has(key) ? {} : {
|
|
106
|
+
...from !== void 0 ? { from } : {},
|
|
107
|
+
...to !== void 0 ? { to } : {}
|
|
108
|
+
};
|
|
109
|
+
for (const [key, to] of Object.entries(after.values)) {
|
|
110
|
+
const from = before.values[key];
|
|
111
|
+
if (from === void 0) changes.push({
|
|
112
|
+
key,
|
|
113
|
+
change: "added",
|
|
114
|
+
...plain(key, void 0, to)
|
|
115
|
+
});
|
|
116
|
+
else if (from !== to) changes.push({
|
|
117
|
+
key,
|
|
118
|
+
change: "changed",
|
|
119
|
+
...plain(key, from, to)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
for (const [key, from] of Object.entries(before.values)) if (!(key in after.values)) changes.push({
|
|
123
|
+
key,
|
|
124
|
+
change: "removed",
|
|
125
|
+
...plain(key, from)
|
|
126
|
+
});
|
|
127
|
+
return changes;
|
|
244
128
|
}
|
|
245
|
-
function
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
for (let j = 1; j <= b.length; j++) row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
250
|
-
prev = row;
|
|
251
|
-
}
|
|
252
|
-
return prev[b.length];
|
|
129
|
+
function isSnapshot(value) {
|
|
130
|
+
if (typeof value !== "object" || value === null) return false;
|
|
131
|
+
const { version, salt, values, sensitive } = value;
|
|
132
|
+
return version === 1 && typeof salt === "string" && salt !== "" && typeof values === "object" && values !== null && !Array.isArray(values) && Object.values(values).every((v) => typeof v === "string") && Array.isArray(sensitive) && sensitive.every((k) => typeof k === "string");
|
|
253
133
|
}
|
|
134
|
+
// ../platform/src/errors/interface.ts
|
|
135
|
+
/**
|
|
136
|
+
* Default `IErrorReporter` — discards every report, so call sites can report
|
|
137
|
+
* unconditionally when no error-tracking backend is configured.
|
|
138
|
+
*/
|
|
139
|
+
var NoopErrorReporter = class {
|
|
140
|
+
capture(_error, _context) {}
|
|
141
|
+
};
|
|
254
142
|
// ../platform/src/data/interface.ts
|
|
255
143
|
/**
|
|
256
144
|
* Written to `solve_metrics.actor_id` when a user is erased, so capacity/billing
|
|
@@ -270,63 +158,19 @@ function assertSafeKey(value, label) {
|
|
|
270
158
|
if (!value || !SAFE_SEGMENT_ONLY.test(value) || value === "." || value === "..") throw new Error(`Unsafe ${label}: ${JSON.stringify(value)}`);
|
|
271
159
|
}
|
|
272
160
|
// ../platform/src/definitions/paths.ts
|
|
161
|
+
function prefix$1(guid) {
|
|
162
|
+
assertSafeKey(guid, "guid");
|
|
163
|
+
return `definitions/${guid}/`;
|
|
164
|
+
}
|
|
273
165
|
var definitionPaths = {
|
|
274
166
|
version: (guid, versionNumber, ext) => {
|
|
275
|
-
|
|
167
|
+
const dir = prefix$1(guid);
|
|
276
168
|
if (!Number.isInteger(versionNumber) || versionNumber < 1) throw new Error(`Unsafe versionNumber: ${versionNumber}`);
|
|
277
|
-
return
|
|
278
|
-
},
|
|
279
|
-
image: (guid) => {
|
|
280
|
-
assertSafeKey(guid, "guid");
|
|
281
|
-
return `definitions/${guid}/cover.webp`;
|
|
169
|
+
return `${dir}versions/v${versionNumber}.${ext}`;
|
|
282
170
|
},
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return `definitions/${guid}/`;
|
|
286
|
-
}
|
|
171
|
+
image: (guid) => `${prefix$1(guid)}cover.webp`,
|
|
172
|
+
prefix: prefix$1
|
|
287
173
|
};
|
|
288
|
-
// ../platform/src/definitions/schemas.ts
|
|
289
|
-
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
290
|
-
var GuidSchema = z.string().toLowerCase().regex(UUID_REGEX, "Invalid GUID format");
|
|
291
|
-
/** A Grasshopper document GUID as stores keep and compare it (lowercase), or null for anything else. */
|
|
292
|
-
function toSourceDocumentId(value) {
|
|
293
|
-
return typeof value === "string" && UUID_REGEX.test(value) ? value.toLowerCase() : null;
|
|
294
|
-
}
|
|
295
|
-
var DefinitionStatusSchema = z.enum([
|
|
296
|
-
"draft",
|
|
297
|
-
"published",
|
|
298
|
-
"archived"
|
|
299
|
-
]);
|
|
300
|
-
var DefinitionChannelSchema = z.enum(["live", "draft"]);
|
|
301
|
-
/** HTTP-body validator for new-definition input. */
|
|
302
|
-
var CreateDefinitionInputSchema = z.object({
|
|
303
|
-
displayName: z.string().trim().min(1, "Display name is required").max(256),
|
|
304
|
-
description: z.string().max(2e3).optional(),
|
|
305
|
-
coverImage: z.string().max(2048).optional(),
|
|
306
|
-
category: z.string().max(128).optional(),
|
|
307
|
-
tags: z.array(z.string().max(64)).max(20).optional(),
|
|
308
|
-
projectId: GuidSchema,
|
|
309
|
-
computeServerId: GuidSchema.optional()
|
|
310
|
-
});
|
|
311
|
-
/**
|
|
312
|
-
* PATCH validator. Field semantics match `DefinitionRecordPatch`:
|
|
313
|
-
* - missing / `undefined` — leave unchanged
|
|
314
|
-
* - `null` — clear (only on nullable fields)
|
|
315
|
-
* - value — set
|
|
316
|
-
*/
|
|
317
|
-
var UpdateMetadataInputSchema = z.object({
|
|
318
|
-
displayName: z.string().trim().min(1, "Display name is required").max(256).optional(),
|
|
319
|
-
description: z.string().max(2e3).nullable().optional(),
|
|
320
|
-
coverImage: z.string().max(2048).nullable().optional(),
|
|
321
|
-
category: z.string().max(128).nullable().optional(),
|
|
322
|
-
tags: z.array(z.string().max(64)).max(20).nullable().optional(),
|
|
323
|
-
projectId: GuidSchema.optional(),
|
|
324
|
-
computeServerId: GuidSchema.nullable().optional(),
|
|
325
|
-
solveCacheLimit: z.number().int().min(0).max(1e5).nullable().optional(),
|
|
326
|
-
status: DefinitionStatusSchema.optional()
|
|
327
|
-
});
|
|
328
|
-
/** Body for `POST /api/definitions/[guid]/publish`. */
|
|
329
|
-
var PublishVersionInputSchema = z.object({ versionId: GuidSchema.optional() }).default({});
|
|
330
174
|
// ../platform/src/events/interface.ts
|
|
331
175
|
/**
|
|
332
176
|
* `ctx.userId === ''` is the `SYSTEM_CONTEXT` convention for a server-internal
|
|
@@ -348,6 +192,10 @@ var NoopEventSink = class {
|
|
|
348
192
|
async emit(_event) {}
|
|
349
193
|
};
|
|
350
194
|
// ../platform/src/organizations/paths.ts
|
|
195
|
+
function prefix(id) {
|
|
196
|
+
assertSafeKey(id, "orgId");
|
|
197
|
+
return `orgs/${id}/`;
|
|
198
|
+
}
|
|
351
199
|
/**
|
|
352
200
|
* Every branding asset is stored as `.webp` (uploads go through the shared
|
|
353
201
|
* transcoder), so the path per kind is fixed and a re-upload overwrites in
|
|
@@ -358,16 +206,28 @@ var NoopEventSink = class {
|
|
|
358
206
|
* `classifyAssetPath` / `ASSET_CLASSES` decide visibility from these prefixes.
|
|
359
207
|
*/
|
|
360
208
|
var orgPaths = {
|
|
361
|
-
asset: (id, kind) => {
|
|
362
|
-
|
|
363
|
-
assertSafeKey(kind, "assetKind");
|
|
364
|
-
return `orgs/${id}/branding/${kind}.webp`;
|
|
365
|
-
},
|
|
366
|
-
prefix: (id) => {
|
|
367
|
-
assertSafeKey(id, "orgId");
|
|
368
|
-
return `orgs/${id}/`;
|
|
369
|
-
}
|
|
209
|
+
asset: (id, kind) => `${prefix(id)}branding/${kind}.webp`,
|
|
210
|
+
prefix
|
|
370
211
|
};
|
|
212
|
+
// ../platform/src/permissions/guards.ts
|
|
213
|
+
/** May `ctx` read `userId`'s platform permissions? Throws `ProviderError(403)` if not. */
|
|
214
|
+
function assertCanReadPermissions(ctx, userId) {
|
|
215
|
+
assertNotShareContext(ctx, "read permissions");
|
|
216
|
+
if (ctx.userId === userId || hasPermission(ctx, "manage_instance_users")) return;
|
|
217
|
+
throw new ProviderError("Forbidden: cannot read another user’s permissions", 403);
|
|
218
|
+
}
|
|
219
|
+
/** May `ctx` read several users' platform permissions? Throws `ProviderError(403)` if not. */
|
|
220
|
+
function assertCanReadPermissionsBatch(ctx) {
|
|
221
|
+
assertNotShareContext(ctx, "read permissions");
|
|
222
|
+
if (hasPermission(ctx, "manage_instance_users")) return;
|
|
223
|
+
throw new ProviderError("Forbidden: instance admin or manage_instance_users required", 403);
|
|
224
|
+
}
|
|
225
|
+
/** May `ctx` change platform permissions? Throws `ProviderError(403)` if not. */
|
|
226
|
+
function assertCanManagePermissions(ctx) {
|
|
227
|
+
assertNotShareContext(ctx, "manage permissions");
|
|
228
|
+
if (hasPermission(ctx, "instance_admin")) return;
|
|
229
|
+
throw new ProviderError("Forbidden: instance admin required", 403);
|
|
230
|
+
}
|
|
371
231
|
// ../platform/src/storage/image.ts
|
|
372
232
|
/**
|
|
373
233
|
* Shared image-transcoding helper for `IStorageProvider` implementations.
|
|
@@ -379,19 +239,21 @@ var orgPaths = {
|
|
|
379
239
|
*/
|
|
380
240
|
var IMAGE_MAX_WIDTH = 1200;
|
|
381
241
|
var MAX_INPUT_PIXELS = 6e7;
|
|
242
|
+
var MAX_INPUT_SIDE = 16384;
|
|
382
243
|
var TRANSCODE_TIMEOUT_SECONDS = 10;
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
"
|
|
388
|
-
"
|
|
389
|
-
"
|
|
244
|
+
var TRANSCODE_WAIT_MS = 2e4;
|
|
245
|
+
var SVG_MAX_BYTES = 1048576;
|
|
246
|
+
var SVG_MAX_ELEMENTS = 1e4;
|
|
247
|
+
var SVG_ENCODINGS = /* @__PURE__ */ new Set([
|
|
248
|
+
"utf-8",
|
|
249
|
+
"us-ascii",
|
|
250
|
+
"iso-8859-1"
|
|
390
251
|
]);
|
|
391
252
|
/** True if the input is an image to process. The content type decides, unless it says nothing. */
|
|
392
253
|
function isImageUpload(contentType, storagePath) {
|
|
393
|
-
|
|
394
|
-
|
|
254
|
+
const type = mediaType(contentType);
|
|
255
|
+
if (type && type !== "application/octet-stream") return type.startsWith("image/");
|
|
256
|
+
return /\.(webp|png|jpe?g|gif|tif?f|svg)$/i.test(storagePath);
|
|
395
257
|
}
|
|
396
258
|
/**
|
|
397
259
|
* Rewrites a path's extension to `.webp`; unchanged for non-image extensions.
|
|
@@ -399,14 +261,15 @@ function isImageUpload(contentType, storagePath) {
|
|
|
399
261
|
* persisted — served bytes stay XSS-free without a sanitizer.
|
|
400
262
|
*/
|
|
401
263
|
function toWebpPath(storagePath) {
|
|
402
|
-
return storagePath.replace(/\.(png|jpe?g|gif|
|
|
264
|
+
return storagePath.replace(/\.(png|jpe?g|gif|tif?f|svg)$/i, ".webp");
|
|
403
265
|
}
|
|
404
266
|
/**
|
|
405
267
|
* Transcodes images to WebP; passes non-images through unchanged, so
|
|
406
268
|
* providers can call this unconditionally before `put`.
|
|
407
269
|
*
|
|
408
|
-
* Throws `ProviderError(422)` for bytes it won't process,
|
|
409
|
-
*
|
|
270
|
+
* Throws `ProviderError(422)` for bytes it won't process, `ProviderError(503)`
|
|
271
|
+
* when too many transcodes are queued, and a plain error if `sharp` isn't
|
|
272
|
+
* installed, which is a config problem rather than a bad upload.
|
|
410
273
|
*/
|
|
411
274
|
async function transcodeImageIfNeeded(data, contentType, storagePath) {
|
|
412
275
|
if (!isImageUpload(contentType, storagePath)) return {
|
|
@@ -414,19 +277,97 @@ async function transcodeImageIfNeeded(data, contentType, storagePath) {
|
|
|
414
277
|
contentType: contentType ?? "application/octet-stream",
|
|
415
278
|
path: storagePath
|
|
416
279
|
};
|
|
280
|
+
const input = Buffer.from(data);
|
|
281
|
+
const format = checkFormat(input, contentType, storagePath);
|
|
417
282
|
const sharp = await loadSharp();
|
|
418
|
-
const compressed = await withTranscodeSlot(() => rasterize(sharp,
|
|
283
|
+
const compressed = await withTranscodeSlot(() => rasterize(sharp, input, format));
|
|
419
284
|
return {
|
|
420
285
|
data: new Uint8Array(compressed),
|
|
421
286
|
contentType: "image/webp",
|
|
422
287
|
path: toWebpPath(storagePath)
|
|
423
288
|
};
|
|
424
289
|
}
|
|
425
|
-
|
|
290
|
+
function mediaType(contentType) {
|
|
291
|
+
return (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
292
|
+
}
|
|
293
|
+
/** Refuses what sharp should never parse, from the bytes alone. */
|
|
294
|
+
function checkFormat(input, contentType, storagePath) {
|
|
295
|
+
const format = sniffFormat(input);
|
|
296
|
+
if (!format) throw new ProviderError("Unsupported image format", 422);
|
|
297
|
+
if (format === "svg") {
|
|
298
|
+
if (!(mediaType(contentType) === "image/svg+xml" || /\.svg$/i.test(storagePath))) throw new ProviderError("SVG content needs the image/svg+xml type", 422);
|
|
299
|
+
checkSvg(input);
|
|
300
|
+
}
|
|
301
|
+
return format;
|
|
302
|
+
}
|
|
303
|
+
function sniffFormat(input) {
|
|
304
|
+
const head = input.subarray(0, 12).toString("latin1");
|
|
305
|
+
if (head.startsWith("ÿØÿ")) return "jpeg";
|
|
306
|
+
if (head.startsWith("PNG\r\n\n")) return "png";
|
|
307
|
+
if (head.startsWith("GIF87a") || head.startsWith("GIF89a")) return "gif";
|
|
308
|
+
if (head.startsWith("RIFF") && head.slice(8, 12) === "WEBP") return "webp";
|
|
309
|
+
if (head.startsWith("II*\0") || head.startsWith("MM\0*")) return "tiff";
|
|
310
|
+
if (/^(?:\xEF\xBB\xBF)?[\t\n\r ]*</.test(input.subarray(0, 1024).toString("latin1"))) return "svg";
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Refuses an SVG that could draw slowly, or pull in one that does: a `data:` URL
|
|
315
|
+
* (librsvg follows it to another SVG or stylesheet) or an entity (which can spell
|
|
316
|
+
* anything). librsvg decodes character references and CSS escapes, and joins
|
|
317
|
+
* `<style>` text across comments and child elements, so the checks read the text
|
|
318
|
+
* the same way.
|
|
319
|
+
*/
|
|
320
|
+
function checkSvg(input) {
|
|
321
|
+
const refuse = (why) => new ProviderError(`SVG ${why}`, 422);
|
|
322
|
+
if (input.length > SVG_MAX_BYTES) throw refuse(`is larger than ${SVG_MAX_BYTES / 1024} KB`);
|
|
323
|
+
const text = input.toString("latin1");
|
|
324
|
+
if (input.includes(0) || !SVG_ENCODINGS.has(declaredEncoding(text))) throw refuse("must be UTF-8");
|
|
325
|
+
if (/<!ENTITY/i.test(text)) throw refuse("may not declare entities");
|
|
326
|
+
let elements = 0;
|
|
327
|
+
for (const _ of text.matchAll(/<[A-Za-z_:]/g)) if (++elements > SVG_MAX_ELEMENTS) throw refuse(`has more than ${SVG_MAX_ELEMENTS} elements`);
|
|
328
|
+
for (const seen of [unescapeSvg(text), unescapeSvg(textContent(text))]) {
|
|
329
|
+
if (/filter/i.test(seen) || /<(?:[\w.-]+:)?fe[A-Z]/.test(seen)) throw refuse("filters are not accepted");
|
|
330
|
+
if (/<(?:[\w.-]+:)?use\b/.test(seen) || /mask|marker|dasharray/i.test(seen)) throw refuse("<use>, masks, markers and dash patterns are not accepted");
|
|
331
|
+
if (/d[\t\n\r]*a[\t\n\r]*t[\t\n\r]*a[\t\n\r]*:/i.test(seen)) throw refuse("may not embed data: URLs");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function declaredEncoding(text) {
|
|
335
|
+
const decl = /^(?:\xEF\xBB\xBF)?<\?xml[^>]*\bencoding\s*=\s*["']([^"']*)["']/.exec(text);
|
|
336
|
+
return decl ? decl[1].toLowerCase() : "utf-8";
|
|
337
|
+
}
|
|
338
|
+
function unescapeSvg(text) {
|
|
339
|
+
return text.replace(/&#(?:x([0-9a-f]+)|(\d+));/gi, (_, hex, dec) => codePoint(hex ? parseInt(hex, 16) : Number(dec))).replace(/\\(?:([0-9a-f]{1,6})[\t\n\r ]?|([^\n]))/gi, (_, hex, ch) => hex ? codePoint(parseInt(hex, 16)) : ch);
|
|
340
|
+
}
|
|
341
|
+
function codePoint(n) {
|
|
342
|
+
return n > 0 && n <= 1114111 ? String.fromCodePoint(n) : "";
|
|
343
|
+
}
|
|
344
|
+
/** Character data only: comments, tags and processing instructions dropped, CDATA kept. */
|
|
345
|
+
function textContent(text) {
|
|
346
|
+
let out = "";
|
|
347
|
+
let i = 0;
|
|
348
|
+
while (i < text.length) if (text.startsWith("<!--", i)) {
|
|
349
|
+
const end = text.indexOf("-->", i + 4);
|
|
350
|
+
i = end < 0 ? text.length : end + 3;
|
|
351
|
+
} else if (text.startsWith("<![CDATA[", i)) {
|
|
352
|
+
const end = text.indexOf("]]>", i + 9);
|
|
353
|
+
out += text.slice(i + 9, end < 0 ? text.length : end);
|
|
354
|
+
i = end < 0 ? text.length : end + 3;
|
|
355
|
+
} else if (text[i] === "<") {
|
|
356
|
+
const end = text.indexOf(">", i + 1);
|
|
357
|
+
i = end < 0 ? text.length : end + 1;
|
|
358
|
+
} else {
|
|
359
|
+
const end = text.indexOf("<", i);
|
|
360
|
+
out += text.slice(i, end < 0 ? text.length : end);
|
|
361
|
+
i = end < 0 ? text.length : end;
|
|
362
|
+
}
|
|
363
|
+
return out;
|
|
364
|
+
}
|
|
365
|
+
async function rasterize(sharp, input, format) {
|
|
426
366
|
try {
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
367
|
+
const meta = await sharp(input, { limitInputPixels: false }).metadata();
|
|
368
|
+
if (meta.format !== format) throw new ProviderError(`Unsupported image format: ${meta.format}`, 422);
|
|
369
|
+
const { width = 0, height = 0 } = meta;
|
|
370
|
+
if (width > MAX_INPUT_SIDE || height > MAX_INPUT_SIDE) throw new ProviderError(`Image is more than ${MAX_INPUT_SIDE} pixels on a side`, 422);
|
|
430
371
|
if (width * height > MAX_INPUT_PIXELS) throw new ProviderError("Image has too many pixels", 422);
|
|
431
372
|
return await sharp(input, { limitInputPixels: MAX_INPUT_PIXELS }).autoOrient().resize({
|
|
432
373
|
width: IMAGE_MAX_WIDTH,
|
|
@@ -436,15 +377,19 @@ async function rasterize(sharp, input, contentType, storagePath) {
|
|
|
436
377
|
}).webp({ quality: 85 }).timeout({ seconds: TRANSCODE_TIMEOUT_SECONDS }).toBuffer();
|
|
437
378
|
} catch (err) {
|
|
438
379
|
if (err instanceof ProviderError) throw err;
|
|
380
|
+
if (err instanceof Error && /^timeout:/m.test(err.message)) throw new ProviderError(`The image took more than ${TRANSCODE_TIMEOUT_SECONDS} seconds to process`, 422);
|
|
439
381
|
throw new ProviderError("The image could not be read", 422);
|
|
440
382
|
}
|
|
441
383
|
}
|
|
442
384
|
var activeTranscodes = 0;
|
|
443
385
|
var waitingTranscodes = [];
|
|
444
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Runs `fn` when a slot is free. A finishing transcode hands its slot straight to
|
|
388
|
+
* the next. Throws `ProviderError(503)` when the queue is full or the wait runs out.
|
|
389
|
+
*/
|
|
445
390
|
async function withTranscodeSlot(fn) {
|
|
446
391
|
if (activeTranscodes < 2) activeTranscodes += 1;
|
|
447
|
-
else await
|
|
392
|
+
else await waitForSlot();
|
|
448
393
|
try {
|
|
449
394
|
return await fn();
|
|
450
395
|
} finally {
|
|
@@ -453,6 +398,21 @@ async function withTranscodeSlot(fn) {
|
|
|
453
398
|
else activeTranscodes -= 1;
|
|
454
399
|
}
|
|
455
400
|
}
|
|
401
|
+
function waitForSlot() {
|
|
402
|
+
const busy = () => new ProviderError("Too many images are being processed. Try again shortly.", 503);
|
|
403
|
+
if (waitingTranscodes.length >= 8) return Promise.reject(busy());
|
|
404
|
+
return new Promise((resolve, reject) => {
|
|
405
|
+
const timer = setTimeout(() => {
|
|
406
|
+
waitingTranscodes.splice(waitingTranscodes.indexOf(start), 1);
|
|
407
|
+
reject(busy());
|
|
408
|
+
}, TRANSCODE_WAIT_MS);
|
|
409
|
+
const start = () => {
|
|
410
|
+
clearTimeout(timer);
|
|
411
|
+
resolve();
|
|
412
|
+
};
|
|
413
|
+
waitingTranscodes.push(start);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
456
416
|
var SHARP_MODULE = "sharp";
|
|
457
417
|
var cachedSharp = null;
|
|
458
418
|
async function loadSharp() {
|
|
@@ -556,6 +516,16 @@ function emptyProfile(userId) {
|
|
|
556
516
|
recentRuns: []
|
|
557
517
|
};
|
|
558
518
|
}
|
|
519
|
+
// ../platform/src/userProfile/guards.ts
|
|
520
|
+
/**
|
|
521
|
+
* For provider authors: may `ctx` read or change `userId`'s profile? Throws
|
|
522
|
+
* `ProviderError(403)` if not.
|
|
523
|
+
*/
|
|
524
|
+
function assertCanAccessProfile(ctx, userId) {
|
|
525
|
+
assertNotShareContext(ctx, "access user profiles");
|
|
526
|
+
if (ctx.userId === userId || hasPermission(ctx, "instance_admin")) return;
|
|
527
|
+
throw new ProviderError("Forbidden: cannot access another user’s profile", 403);
|
|
528
|
+
}
|
|
559
529
|
// ../platform/src/utils/audit.ts
|
|
560
530
|
/**
|
|
561
531
|
* Audit-field stamping helpers. Every mutable entity carries `createdAt` /
|
|
@@ -588,31 +558,36 @@ function auditSoftDelete(ctx, fallbackActor) {
|
|
|
588
558
|
var NoopSolveMetricSink = class {
|
|
589
559
|
async record(_ctx, _metric) {}
|
|
590
560
|
};
|
|
591
|
-
// ../platform/src/errors/interface.ts
|
|
592
|
-
/**
|
|
593
|
-
* Default `IErrorReporter` — discards every report. Used when no error-tracking
|
|
594
|
-
* backend is configured (e.g. `SENTRY_DSN` unset), so call sites can report
|
|
595
|
-
* unconditionally. Swap in a real reporter to ship errors off-box.
|
|
596
|
-
*/
|
|
597
|
-
var NoopErrorReporter = class {
|
|
598
|
-
capture(_error, _context) {}
|
|
599
|
-
};
|
|
600
561
|
// ../platform/src/computeServer/secrets.ts
|
|
601
562
|
var ALGO = "aes-256-gcm";
|
|
602
563
|
var IV_BYTES = 12;
|
|
564
|
+
var TAG_BYTES = 16;
|
|
603
565
|
var PREFIX_V1 = "enc:v1:";
|
|
604
566
|
var PREFIX_V2 = "enc:v2:";
|
|
567
|
+
var PREFIX_V3 = "enc:v3:";
|
|
568
|
+
var PREFIX_LENGTH = 7;
|
|
605
569
|
function isEncryptedSecret(value) {
|
|
570
|
+
return isLegacyEnvelope(value) || value.startsWith(PREFIX_V3);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* An `enc:v1:` or `enc:v2:` envelope: sealed without a {@link SecretBinding}, so it
|
|
574
|
+
* still opens after its record's URL changes. Stores re-seal these.
|
|
575
|
+
*/
|
|
576
|
+
function isLegacyEnvelope(value) {
|
|
606
577
|
return value.startsWith(PREFIX_V1) || value.startsWith(PREFIX_V2);
|
|
607
578
|
}
|
|
579
|
+
function bindingAad({ id, url }) {
|
|
580
|
+
return Buffer.from(JSON.stringify([id, url]), "utf8");
|
|
581
|
+
}
|
|
608
582
|
/**
|
|
609
|
-
* AES-256-GCM envelope for at-rest secrets (e.g. compute API keys)
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
583
|
+
* AES-256-GCM envelope for at-rest secrets (e.g. compute API keys):
|
|
584
|
+
* `enc:v<n>:<base64(iv|tag|ciphertext)>`. What `aad` is picks the version, and
|
|
585
|
+
* the version says what GCM authenticates besides the ciphertext:
|
|
586
|
+
* - a {@link SecretBinding} gives `v3`: the record's id and URL. Ciphertext copied
|
|
587
|
+
* onto another record, or a record pointed at another host, fails to decrypt
|
|
588
|
+
* instead of handing the plaintext to that host.
|
|
589
|
+
* - a string gives `v2`: that string, which stores set to the record's id.
|
|
590
|
+
* - nothing gives `v1`: nothing.
|
|
616
591
|
*
|
|
617
592
|
* Defends against backup leaks, accidental file/DB sharing, and read-only
|
|
618
593
|
* storage access — not against an attacker who also has the master key
|
|
@@ -621,39 +596,50 @@ function isEncryptedSecret(value) {
|
|
|
621
596
|
*
|
|
622
597
|
* Pure `node:crypto`, no fs or DB coupling, so the local and Supabase
|
|
623
598
|
* compute-server stores share this one implementation.
|
|
624
|
-
*
|
|
625
|
-
* Pass `aad` to bind the secret to its record. {@link decryptSecret} then needs the
|
|
626
|
-
* same value.
|
|
627
599
|
*/
|
|
628
600
|
function encryptSecret(plaintext, key, aad) {
|
|
629
601
|
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
630
602
|
if (isEncryptedSecret(plaintext)) throw new Error("Refusing to encrypt a value that is already encrypted");
|
|
603
|
+
const [prefix, aadBytes] = aad === void 0 ? [PREFIX_V1, void 0] : typeof aad === "string" ? [PREFIX_V2, Buffer.from(aad, "utf8")] : [PREFIX_V3, bindingAad(aad)];
|
|
631
604
|
const iv = randomBytes(IV_BYTES);
|
|
632
605
|
const cipher = createCipheriv(ALGO, key, iv);
|
|
633
|
-
if (
|
|
606
|
+
if (aadBytes) cipher.setAAD(aadBytes);
|
|
634
607
|
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
635
608
|
const tag = cipher.getAuthTag();
|
|
636
|
-
return
|
|
609
|
+
return prefix + Buffer.concat([
|
|
637
610
|
iv,
|
|
638
611
|
tag,
|
|
639
612
|
ciphertext
|
|
640
613
|
]).toString("base64");
|
|
641
614
|
}
|
|
642
|
-
|
|
615
|
+
function aadToOpen(envelope, aad) {
|
|
616
|
+
if (envelope.startsWith(PREFIX_V1)) return void 0;
|
|
617
|
+
if (envelope.startsWith(PREFIX_V2)) {
|
|
618
|
+
if (aad === void 0) throw new Error("This secret is bound to a record: pass its id");
|
|
619
|
+
return Buffer.from(typeof aad === "string" ? aad : aad.id, "utf8");
|
|
620
|
+
}
|
|
621
|
+
if (aad === void 0 || typeof aad === "string") throw new Error("This secret is bound to a record and its URL: pass both");
|
|
622
|
+
return bindingAad(aad);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* `aad` is ignored for `v1`. `v2` takes the string it was sealed with, or a
|
|
626
|
+
* binding's `id`; `v3` needs the binding.
|
|
627
|
+
*/
|
|
643
628
|
function decryptSecret(envelope, key, aad) {
|
|
644
629
|
if (key.length !== 32) throw new Error(`Secret key must be 32 bytes; got ${key.length}`);
|
|
645
630
|
if (!isEncryptedSecret(envelope)) throw new Error("Value is not an encrypted secret envelope");
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
|
|
631
|
+
const aadBytes = aadToOpen(envelope, aad);
|
|
632
|
+
const buf = Buffer.from(envelope.slice(PREFIX_LENGTH), "base64");
|
|
633
|
+
if (buf.length < 28) throw new Error("Encrypted secret is shorter than its IV and tag");
|
|
649
634
|
const iv = buf.subarray(0, IV_BYTES);
|
|
650
635
|
const tag = buf.subarray(IV_BYTES, 28);
|
|
651
636
|
const ciphertext = buf.subarray(28);
|
|
652
|
-
const decipher = createDecipheriv(ALGO, key, iv);
|
|
637
|
+
const decipher = createDecipheriv(ALGO, key, iv, { authTagLength: TAG_BYTES });
|
|
653
638
|
decipher.setAuthTag(tag);
|
|
654
|
-
if (
|
|
639
|
+
if (aadBytes) decipher.setAAD(aadBytes);
|
|
655
640
|
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
656
641
|
}
|
|
642
|
+
var GENERATE_HINT = "Generate one with: node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"";
|
|
657
643
|
/**
|
|
658
644
|
* Decodes a `SELVA_AT_REST_KEY` env var into a 32-byte buffer (64-char hex or
|
|
659
645
|
* base64, with or without padding). Throws on anything else so a
|
|
@@ -661,11 +647,22 @@ function decryptSecret(envelope, key, aad) {
|
|
|
661
647
|
* ciphertext nothing can decrypt.
|
|
662
648
|
*/
|
|
663
649
|
function decodeSecretKey(raw) {
|
|
664
|
-
const key = raw
|
|
665
|
-
if (
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
650
|
+
const key = parseKey32(raw);
|
|
651
|
+
if (key) return key;
|
|
652
|
+
throw new Error(`SELVA_AT_REST_KEY must be 32 bytes encoded as 64-char hex or base64. ${GENERATE_HINT}`);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* `SELVA_AT_REST_KEY`, plus `SELVA_AT_REST_KEY_PREVIOUS` while it is within its
|
|
656
|
+
* deadline. Throws when the current key is missing or malformed.
|
|
657
|
+
*/
|
|
658
|
+
function readAtRestKeys(env) {
|
|
659
|
+
if (!env.SELVA_AT_REST_KEY) throw new Error(`Missing required env var: SELVA_AT_REST_KEY (32-byte hex or base64). ${GENERATE_HINT}`);
|
|
660
|
+
const current = decodeSecretKey(env.SELVA_AT_REST_KEY);
|
|
661
|
+
const previous = previousKey(env, "SELVA_AT_REST_KEY").key;
|
|
662
|
+
return previous ? {
|
|
663
|
+
current,
|
|
664
|
+
previous: decodeSecretKey(previous)
|
|
665
|
+
} : { current };
|
|
669
666
|
}
|
|
670
667
|
/**
|
|
671
668
|
* {@link decryptSecret} under each key in turn, current first. AES-GCM
|
|
@@ -1066,7 +1063,9 @@ async function createSelvaProviders(env, options) {
|
|
|
1066
1063
|
let solveMetricSink;
|
|
1067
1064
|
function resolve() {
|
|
1068
1065
|
if (config) return config;
|
|
1069
|
-
|
|
1066
|
+
const candidate = typeof raw === "function" ? raw(env) : raw;
|
|
1067
|
+
if (isFlagEnabled(candidate, "ENABLE_PLATFORM_PROJECTS") && candidate.data.platformProjectGrants.unsupported) throw new Error(`ENABLE_PLATFORM_PROJECTS is on, but ${candidate.data.constructor.name} cannot store platform-project grants. Turn SELVA_FLAG_ENABLE_PLATFORM_PROJECTS off.`);
|
|
1068
|
+
config = candidate;
|
|
1070
1069
|
const wiring = {
|
|
1071
1070
|
component: "selva",
|
|
1072
1071
|
auth: config.auth.name,
|
|
@@ -1578,6 +1577,7 @@ var LocalInviteStore = class LocalInviteStore {
|
|
|
1578
1577
|
const file = await this.load();
|
|
1579
1578
|
const target = file.invites.find((i) => i.id === id);
|
|
1580
1579
|
if (!target || target.acceptedAt) return null;
|
|
1580
|
+
if (Date.parse(target.expiresAt) <= Date.now()) return null;
|
|
1581
1581
|
target.acceptedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1582
1582
|
target.acceptedByUserId = userId;
|
|
1583
1583
|
await this.save(file);
|
|
@@ -1779,11 +1779,10 @@ function assertIdsFree(incoming, otherScopes) {
|
|
|
1779
1779
|
const taken = new Set(otherScopes.map((s) => s.id));
|
|
1780
1780
|
if (incoming.some((s) => taken.has(s.id))) throw new ProviderError("A compute server id is already in use", 409);
|
|
1781
1781
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1782
|
+
var bindingOf$1 = (s) => ({
|
|
1783
|
+
id: s.id,
|
|
1784
|
+
url: s.serverUrl
|
|
1785
|
+
});
|
|
1787
1786
|
/**
|
|
1788
1787
|
* Reads/writes compute.config.json, re-read on every call so edits take
|
|
1789
1788
|
* effect without a restart. Mutation methods are scope-targeted
|
|
@@ -1795,8 +1794,8 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1795
1794
|
secretKey;
|
|
1796
1795
|
static fromEnv(env, logger) {
|
|
1797
1796
|
if (!env.DATA_PATH) throw new Error("Missing required env var: DATA_PATH");
|
|
1798
|
-
|
|
1799
|
-
return new LocalComputeServerStore(path$1.join(env.DATA_PATH, "compute.config.json"),
|
|
1797
|
+
const keys = readAtRestKeys(env);
|
|
1798
|
+
return new LocalComputeServerStore(path$1.join(env.DATA_PATH, "compute.config.json"), keys.current, logger, keys.previous);
|
|
1800
1799
|
}
|
|
1801
1800
|
logger;
|
|
1802
1801
|
/** Current key first; the previous one still opens rows sealed before a rotation. */
|
|
@@ -1834,7 +1833,7 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1834
1833
|
try {
|
|
1835
1834
|
return {
|
|
1836
1835
|
...s,
|
|
1837
|
-
apiKey: decryptWithKeys(s.apiKey, this.keys, s
|
|
1836
|
+
apiKey: decryptWithKeys(s.apiKey, this.keys, bindingOf$1(s)).plaintext
|
|
1838
1837
|
};
|
|
1839
1838
|
} catch (cause) {
|
|
1840
1839
|
this.logger.warn("Could not decrypt apiKey: the stored ciphertext does not match the current SELVA_AT_REST_KEY. This server is returned without an apiKey and solves against it will fail. Re-enter the key via /admin/compute, or restore the original SELVA_AT_REST_KEY.", {
|
|
@@ -1862,6 +1861,7 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1862
1861
|
const failures = [];
|
|
1863
1862
|
let plaintextFound = false;
|
|
1864
1863
|
let onPreviousKey = 0;
|
|
1864
|
+
let legacyEnvelopes = 0;
|
|
1865
1865
|
for (const s of all.servers) {
|
|
1866
1866
|
if (!s.apiKey) continue;
|
|
1867
1867
|
if (!isEncryptedSecret(s.apiKey)) {
|
|
@@ -1873,8 +1873,9 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1873
1873
|
});
|
|
1874
1874
|
continue;
|
|
1875
1875
|
}
|
|
1876
|
+
if (isLegacyEnvelope(s.apiKey)) legacyEnvelopes += 1;
|
|
1876
1877
|
try {
|
|
1877
|
-
if (decryptWithKeys(s.apiKey, this.keys, s
|
|
1878
|
+
if (decryptWithKeys(s.apiKey, this.keys, bindingOf$1(s)).keyIndex > 0) onPreviousKey += 1;
|
|
1878
1879
|
} catch (cause) {
|
|
1879
1880
|
failures.push({
|
|
1880
1881
|
serverId: s.id,
|
|
@@ -1888,28 +1889,28 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1888
1889
|
ok: failures.length === 0,
|
|
1889
1890
|
failures,
|
|
1890
1891
|
plaintextFound,
|
|
1891
|
-
...this.keys.length > 1 ? { onPreviousKey } : {}
|
|
1892
|
+
...this.keys.length > 1 ? { onPreviousKey } : {},
|
|
1893
|
+
...legacyEnvelopes > 0 ? { legacyEnvelopes } : {}
|
|
1892
1894
|
};
|
|
1893
1895
|
}
|
|
1894
1896
|
/**
|
|
1895
|
-
* Re-seal every row that only the previous key opens,
|
|
1896
|
-
*
|
|
1897
|
-
* interleave with an admin save. Returns how many rows it re-sealed.
|
|
1897
|
+
* Re-seal every row that only the previous key opens, or that sits in a legacy
|
|
1898
|
+
* envelope, under the current key and the row's binding. Under the file lock,
|
|
1899
|
+
* so it can't interleave with an admin save. Returns how many rows it re-sealed.
|
|
1898
1900
|
*/
|
|
1899
1901
|
async reencryptSecrets() {
|
|
1900
|
-
if (this.keys.length < 2) return 0;
|
|
1901
1902
|
return withFileLock(this.configFilePath, async () => {
|
|
1902
1903
|
const all = await this.readAll();
|
|
1903
1904
|
let changed = 0;
|
|
1904
1905
|
const servers = all.servers.map((s) => {
|
|
1905
1906
|
if (!s.apiKey || !isEncryptedSecret(s.apiKey)) return s;
|
|
1906
1907
|
try {
|
|
1907
|
-
const { plaintext, keyIndex } = decryptWithKeys(s.apiKey, this.keys, s
|
|
1908
|
-
if (keyIndex === 0) return s;
|
|
1908
|
+
const { plaintext, keyIndex } = decryptWithKeys(s.apiKey, this.keys, bindingOf$1(s));
|
|
1909
|
+
if (keyIndex === 0 && !isLegacyEnvelope(s.apiKey)) return s;
|
|
1909
1910
|
changed += 1;
|
|
1910
1911
|
return {
|
|
1911
1912
|
...s,
|
|
1912
|
-
apiKey: encryptSecret(plaintext, this.secretKey, s
|
|
1913
|
+
apiKey: encryptSecret(plaintext, this.secretKey, bindingOf$1(s))
|
|
1913
1914
|
};
|
|
1914
1915
|
} catch {
|
|
1915
1916
|
return s;
|
|
@@ -1927,7 +1928,7 @@ var LocalComputeServerStore = class LocalComputeServerStore {
|
|
|
1927
1928
|
if (!s.apiKey) return s;
|
|
1928
1929
|
return {
|
|
1929
1930
|
...s,
|
|
1930
|
-
apiKey: encryptSecret(s.apiKey, this.secretKey, s
|
|
1931
|
+
apiKey: encryptSecret(s.apiKey, this.secretKey, bindingOf$1(s))
|
|
1931
1932
|
};
|
|
1932
1933
|
});
|
|
1933
1934
|
}
|
|
@@ -2884,8 +2885,8 @@ var LocalShareLinkStore = class LocalShareLinkStore {
|
|
|
2884
2885
|
this.events = opts.events ?? new NoopEventSink();
|
|
2885
2886
|
}
|
|
2886
2887
|
/**
|
|
2887
|
-
* Wires the definition store so token resolution can check
|
|
2888
|
-
* definition's `deletedAt`,
|
|
2888
|
+
* Wires the definition store so token resolution and solve counting can check
|
|
2889
|
+
* the parent definition's `deletedAt`, as Supabase does in SQL. Optional: if
|
|
2889
2890
|
* unset, this falls back to the local-only revoke check, and the selva
|
|
2890
2891
|
* app's route layer does the parent lookup as a safety net either way.
|
|
2891
2892
|
*/
|
|
@@ -2967,16 +2968,18 @@ var LocalShareLinkStore = class LocalShareLinkStore {
|
|
|
2967
2968
|
const all = await this.readAll();
|
|
2968
2969
|
const found = Object.values(all.links).find((l) => l.tokenHash === tokenHash);
|
|
2969
2970
|
if (!this.isLive(found)) return null;
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
return
|
|
2971
|
+
return await this.parentIsLive(found) ? found : null;
|
|
2972
|
+
}
|
|
2973
|
+
async parentIsLive(link) {
|
|
2974
|
+
if (!this.definitionProvider) return true;
|
|
2975
|
+
return await this.definitionProvider.get(SYSTEM_CONTEXT, link.definitionId) !== null;
|
|
2974
2976
|
}
|
|
2975
2977
|
async revoke(ctx, id) {
|
|
2976
2978
|
if (!await this.locked(async () => {
|
|
2977
2979
|
const all = await this.readAll();
|
|
2978
2980
|
const l = all.links[id];
|
|
2979
|
-
if (!l
|
|
2981
|
+
if (!l) throw new ProviderError(`Share link '${id}' not found`, 404);
|
|
2982
|
+
if (!this.isLive(l)) return false;
|
|
2980
2983
|
l.revokedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2981
2984
|
await this.writeAll(all);
|
|
2982
2985
|
return true;
|
|
@@ -2993,6 +2996,7 @@ var LocalShareLinkStore = class LocalShareLinkStore {
|
|
|
2993
2996
|
const l = all.links[id];
|
|
2994
2997
|
if (!l || !this.isLive(l)) return null;
|
|
2995
2998
|
if (l.maxSolves != null && l.solveCount >= l.maxSolves) return null;
|
|
2999
|
+
if (!await this.parentIsLive(l)) return null;
|
|
2996
3000
|
l.solveCount += 1;
|
|
2997
3001
|
await this.writeAll(all);
|
|
2998
3002
|
return l.solveCount;
|
|
@@ -3420,8 +3424,8 @@ var LocalStorageProvider = class LocalStorageProvider {
|
|
|
3420
3424
|
resolvePath(storagePath) {
|
|
3421
3425
|
const base = path$1.resolve(this.basePath);
|
|
3422
3426
|
const full = path$1.resolve(base, storagePath);
|
|
3423
|
-
if (full !== base && !full.startsWith(base + path$1.sep)) throw new
|
|
3424
|
-
if (path$1.dirname(full) === base && full.endsWith(".json")) throw new
|
|
3427
|
+
if (full !== base && !full.startsWith(base + path$1.sep)) throw new ProviderError(`Path escapes base: ${storagePath}`, 400);
|
|
3428
|
+
if (path$1.dirname(full) === base && full.endsWith(".json")) throw new ProviderError(`Path is a data file, not an asset: ${storagePath}`, 400);
|
|
3425
3429
|
return full;
|
|
3426
3430
|
}
|
|
3427
3431
|
async get(storagePath) {
|
|
@@ -3456,7 +3460,7 @@ var LocalStorageProvider = class LocalStorageProvider {
|
|
|
3456
3460
|
}
|
|
3457
3461
|
async deletePrefix(prefix) {
|
|
3458
3462
|
const fullPath = this.resolvePath(prefix);
|
|
3459
|
-
if (fullPath === path$1.resolve(this.basePath)) throw new
|
|
3463
|
+
if (fullPath === path$1.resolve(this.basePath)) throw new ProviderError(`Refusing to delete the whole store: ${JSON.stringify(prefix)}`, 400);
|
|
3460
3464
|
await fs$1.rm(fullPath, {
|
|
3461
3465
|
recursive: true,
|
|
3462
3466
|
force: true
|
|
@@ -3466,12 +3470,6 @@ var LocalStorageProvider = class LocalStorageProvider {
|
|
|
3466
3470
|
return `${this.publicUrlBase}/${storagePath}`;
|
|
3467
3471
|
}
|
|
3468
3472
|
};
|
|
3469
|
-
// ../providers/supabase/src/trim.ts
|
|
3470
|
-
function trimTrailing(s, ch) {
|
|
3471
|
-
let end = s.length;
|
|
3472
|
-
while (end > 0 && s[end - 1] === ch) end--;
|
|
3473
|
-
return s.slice(0, end);
|
|
3474
|
-
}
|
|
3475
3473
|
// ../providers/supabase/src/storage/SupabaseStorageProvider.ts
|
|
3476
3474
|
var LIST_PAGE_SIZE = 1e3;
|
|
3477
3475
|
var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
@@ -3541,7 +3539,7 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
|
3541
3539
|
if (error) throw error;
|
|
3542
3540
|
}
|
|
3543
3541
|
async deletePrefix(prefix) {
|
|
3544
|
-
if (trimTrailing(prefix, "/") === "") throw new
|
|
3542
|
+
if (trimTrailing(prefix, "/") === "") throw new ProviderError(`Refusing to delete the whole store: prefix ${JSON.stringify(prefix)}`, 400);
|
|
3545
3543
|
await Promise.all([this.deletePrefixInBucket(this.publicBucket, prefix), this.deletePrefixInBucket(this.privateBucket, prefix)]);
|
|
3546
3544
|
}
|
|
3547
3545
|
async deletePrefixInBucket(bucket, prefix) {
|
|
@@ -4245,8 +4243,9 @@ var SupabaseDefinitionStore = class {
|
|
|
4245
4243
|
if (!data || data.length === 0) throw new ProviderError(`Definition '${guid}' not found`, 404);
|
|
4246
4244
|
}
|
|
4247
4245
|
async delete(ctx, guid) {
|
|
4248
|
-
const { error } = await this.clients.forRequest(ctx).from("definitions").update(stampSoftDelete(ctx)).eq("guid", guid).is("deleted_at", null);
|
|
4246
|
+
const { data, error } = await this.clients.forRequest(ctx).from("definitions").update(stampSoftDelete(ctx)).eq("guid", guid).is("deleted_at", null).select("guid");
|
|
4249
4247
|
if (error) throw mapPostgrestError(error);
|
|
4248
|
+
if (!data || data.length === 0) return;
|
|
4250
4249
|
await this.events.emit({
|
|
4251
4250
|
type: "definition.deleted",
|
|
4252
4251
|
definitionId: guid,
|
|
@@ -4517,10 +4516,11 @@ var SupabaseInviteStore = class {
|
|
|
4517
4516
|
};
|
|
4518
4517
|
}
|
|
4519
4518
|
async markAccepted(ctx, id, userId) {
|
|
4519
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4520
4520
|
const { data, error } = await this.clients.forRequest(ctx).from("invites").update({
|
|
4521
|
-
accepted_at:
|
|
4521
|
+
accepted_at: now,
|
|
4522
4522
|
accepted_by_user_id: userId
|
|
4523
|
-
}).eq("id", id).is("accepted_at", null).select("org_id");
|
|
4523
|
+
}).eq("id", id).is("accepted_at", null).gt("expires_at", now).select("org_id");
|
|
4524
4524
|
if (error) throw mapPostgrestError(error);
|
|
4525
4525
|
const row = data?.[0];
|
|
4526
4526
|
if (!row) return false;
|
|
@@ -4598,6 +4598,10 @@ function inviteToRow(i) {
|
|
|
4598
4598
|
var SERVER_COLUMNS = "id, scope, owner_org_id, shared_with_all, label, server_url, has_api_key";
|
|
4599
4599
|
var SHARE_COLUMNS = "server_id, org_id";
|
|
4600
4600
|
var ORG_DEFAULT_COLUMNS = "org_id, default_server_id";
|
|
4601
|
+
var bindingOf = (row) => ({
|
|
4602
|
+
id: row.id,
|
|
4603
|
+
url: row.server_url
|
|
4604
|
+
});
|
|
4601
4605
|
/**
|
|
4602
4606
|
* Compute-server config backed by three tables:
|
|
4603
4607
|
* - `compute_servers`: one row per server. `scope = 'platform' | 'org'`.
|
|
@@ -4669,7 +4673,7 @@ var SupabaseComputeServerStore = class {
|
|
|
4669
4673
|
const { data: visible, error: visibleError } = await this.clients.forRequest(ctx).from("compute_servers").select("id").eq("id", serverId).maybeSingle();
|
|
4670
4674
|
if (visibleError) throw mapPostgrestError(visibleError);
|
|
4671
4675
|
if (!visible) return void 0;
|
|
4672
|
-
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, label, api_key").eq("id", serverId).maybeSingle();
|
|
4676
|
+
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, label, server_url, api_key").eq("id", serverId).maybeSingle();
|
|
4673
4677
|
if (error) throw mapPostgrestError(error);
|
|
4674
4678
|
if (!data) return void 0;
|
|
4675
4679
|
return this.decryptRowApiKey(data).api_key ?? void 0;
|
|
@@ -4734,16 +4738,19 @@ var SupabaseComputeServerStore = class {
|
|
|
4734
4738
|
if (shErr) throw mapPostgrestError(shErr);
|
|
4735
4739
|
}
|
|
4736
4740
|
/**
|
|
4737
|
-
* Encrypt a server's `apiKey` before it is written to the DB, bound to its id
|
|
4738
|
-
* Throws on a value that is already an envelope, and if the store was
|
|
4739
|
-
* without a key, so we never silently persist plaintext.
|
|
4741
|
+
* Encrypt a server's `apiKey` before it is written to the DB, bound to its id
|
|
4742
|
+
* and URL. Throws on a value that is already an envelope, and if the store was
|
|
4743
|
+
* built without a key, so we never silently persist plaintext.
|
|
4740
4744
|
*/
|
|
4741
4745
|
encryptServerApiKey(s) {
|
|
4742
4746
|
if (!s.apiKey) return s;
|
|
4743
4747
|
if (!this.secretKey) throw new Error("Cannot store a compute-server apiKey: SELVA_AT_REST_KEY is not configured. Set it so secrets are encrypted at rest.");
|
|
4744
4748
|
return {
|
|
4745
4749
|
...s,
|
|
4746
|
-
apiKey: encryptSecret(s.apiKey, this.secretKey,
|
|
4750
|
+
apiKey: encryptSecret(s.apiKey, this.secretKey, {
|
|
4751
|
+
id: s.id,
|
|
4752
|
+
url: s.serverUrl
|
|
4753
|
+
})
|
|
4747
4754
|
};
|
|
4748
4755
|
}
|
|
4749
4756
|
/**
|
|
@@ -4778,7 +4785,7 @@ var SupabaseComputeServerStore = class {
|
|
|
4778
4785
|
try {
|
|
4779
4786
|
return {
|
|
4780
4787
|
...row,
|
|
4781
|
-
api_key: decryptWithKeys(row.api_key, this.keys, row
|
|
4788
|
+
api_key: decryptWithKeys(row.api_key, this.keys, bindingOf(row)).plaintext
|
|
4782
4789
|
};
|
|
4783
4790
|
} catch (cause) {
|
|
4784
4791
|
this.logger.warn("Could not decrypt api_key: the stored ciphertext does not match the current SELVA_AT_REST_KEY. This server is returned without an apiKey and solves against it will fail. Re-enter the key via /admin/compute, or restore the original SELVA_AT_REST_KEY", {
|
|
@@ -4800,15 +4807,14 @@ var SupabaseComputeServerStore = class {
|
|
|
4800
4807
|
* report for boot health to drive `/api/health`.
|
|
4801
4808
|
*/
|
|
4802
4809
|
async verifySecrets() {
|
|
4803
|
-
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, label, api_key");
|
|
4810
|
+
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, label, server_url, api_key");
|
|
4804
4811
|
if (error) throw mapPostgrestError(error);
|
|
4805
4812
|
const failures = [];
|
|
4806
4813
|
let plaintextFound = false;
|
|
4807
4814
|
let onPreviousKey = 0;
|
|
4815
|
+
let legacyEnvelopes = 0;
|
|
4808
4816
|
for (const row of data ?? []) {
|
|
4809
|
-
const apiKey = row
|
|
4810
|
-
const id = row.id;
|
|
4811
|
-
const label = row.label;
|
|
4817
|
+
const { api_key: apiKey, id, label } = row;
|
|
4812
4818
|
if (!apiKey) continue;
|
|
4813
4819
|
if (!isEncryptedSecret(apiKey)) {
|
|
4814
4820
|
plaintextFound = true;
|
|
@@ -4828,8 +4834,9 @@ var SupabaseComputeServerStore = class {
|
|
|
4828
4834
|
});
|
|
4829
4835
|
continue;
|
|
4830
4836
|
}
|
|
4837
|
+
if (isLegacyEnvelope(apiKey)) legacyEnvelopes += 1;
|
|
4831
4838
|
try {
|
|
4832
|
-
if (decryptWithKeys(apiKey, this.keys,
|
|
4839
|
+
if (decryptWithKeys(apiKey, this.keys, bindingOf(row)).keyIndex > 0) onPreviousKey += 1;
|
|
4833
4840
|
} catch (cause) {
|
|
4834
4841
|
failures.push({
|
|
4835
4842
|
serverId: id,
|
|
@@ -4843,29 +4850,31 @@ var SupabaseComputeServerStore = class {
|
|
|
4843
4850
|
ok: failures.length === 0,
|
|
4844
4851
|
failures,
|
|
4845
4852
|
plaintextFound,
|
|
4846
|
-
...this.keys.length > 1 ? { onPreviousKey } : {}
|
|
4853
|
+
...this.keys.length > 1 ? { onPreviousKey } : {},
|
|
4854
|
+
...legacyEnvelopes > 0 ? { legacyEnvelopes } : {}
|
|
4847
4855
|
};
|
|
4848
4856
|
}
|
|
4849
4857
|
/**
|
|
4850
|
-
* Re-seal under the current key every row only the
|
|
4851
|
-
*
|
|
4852
|
-
*
|
|
4858
|
+
* Re-seal, under the current key and the row's binding, every row only the
|
|
4859
|
+
* previous key opens or that sits in a legacy envelope. The update matches on
|
|
4860
|
+
* the old ciphertext and URL too, so a row an admin re-saved in between is
|
|
4861
|
+
* left alone rather than overwritten.
|
|
4853
4862
|
*/
|
|
4854
4863
|
async reencryptSecrets() {
|
|
4855
|
-
if (
|
|
4856
|
-
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, api_key");
|
|
4864
|
+
if (!this.secretKey) return 0;
|
|
4865
|
+
const { data, error } = await this.clients.serviceClient.from("compute_servers").select("id, label, server_url, api_key");
|
|
4857
4866
|
if (error) throw mapPostgrestError(error);
|
|
4858
4867
|
let changed = 0;
|
|
4859
4868
|
for (const row of data ?? []) {
|
|
4860
4869
|
if (!row.api_key || !isEncryptedSecret(row.api_key)) continue;
|
|
4861
4870
|
let opened;
|
|
4862
4871
|
try {
|
|
4863
|
-
opened = decryptWithKeys(row.api_key, this.keys, row
|
|
4872
|
+
opened = decryptWithKeys(row.api_key, this.keys, bindingOf(row));
|
|
4864
4873
|
} catch {
|
|
4865
4874
|
continue;
|
|
4866
4875
|
}
|
|
4867
|
-
if (opened.keyIndex === 0) continue;
|
|
4868
|
-
const { error: updateError, count } = await this.clients.serviceClient.from("compute_servers").update({ api_key: encryptSecret(opened.plaintext, this.secretKey, row
|
|
4876
|
+
if (opened.keyIndex === 0 && !isLegacyEnvelope(row.api_key)) continue;
|
|
4877
|
+
const { error: updateError, count } = await this.clients.serviceClient.from("compute_servers").update({ api_key: encryptSecret(opened.plaintext, this.secretKey, bindingOf(row)) }, { count: "exact" }).eq("id", row.id).eq("server_url", row.server_url).eq("api_key", row.api_key);
|
|
4869
4878
|
if (updateError) throw mapPostgrestError(updateError);
|
|
4870
4879
|
changed += count ?? 0;
|
|
4871
4880
|
}
|
|
@@ -5180,7 +5189,7 @@ function tokenToRow(t) {
|
|
|
5180
5189
|
* whenever a migration is added — `migration-head.test.ts` asserts it
|
|
5181
5190
|
* matches the migrations directory, so CI catches drift.
|
|
5182
5191
|
*/
|
|
5183
|
-
var EXPECTED_MIGRATION_HEAD = "
|
|
5192
|
+
var EXPECTED_MIGRATION_HEAD = "20261107120100";
|
|
5184
5193
|
// ../providers/supabase/src/data/client.ts
|
|
5185
5194
|
/** Default schema every engine store targets. */
|
|
5186
5195
|
var DEFAULT_SCHEMA = "selva";
|
|
@@ -5447,8 +5456,6 @@ var SupabaseSolveMetricSink = class {
|
|
|
5447
5456
|
}
|
|
5448
5457
|
};
|
|
5449
5458
|
// ../providers/supabase/src/data/SupabaseAuditQuery.ts
|
|
5450
|
-
var MAX_LIMIT = 200;
|
|
5451
|
-
var DEFAULT_LIMIT = 100;
|
|
5452
5459
|
var ISO_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})$/;
|
|
5453
5460
|
var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
5454
5461
|
/**
|
|
@@ -5465,7 +5472,7 @@ var SupabaseAuditQuery = class {
|
|
|
5465
5472
|
this.clients = clients;
|
|
5466
5473
|
}
|
|
5467
5474
|
async list(_ctx, filters) {
|
|
5468
|
-
const limit =
|
|
5475
|
+
const limit = clampPageLimit(filters.limit);
|
|
5469
5476
|
let q = this.clients.serviceClient.from("audit_events").select("id, type, actor_id, occurred_at, data").order("occurred_at", { ascending: false }).order("id", { ascending: false }).limit(limit + 1);
|
|
5470
5477
|
if (filters.types && filters.types.length > 0) q = q.in("type", [...filters.types]);
|
|
5471
5478
|
if (filters.actorId) q = q.eq("actor_id", filters.actorId);
|
|
@@ -5498,11 +5505,6 @@ var SupabaseAuditQuery = class {
|
|
|
5498
5505
|
};
|
|
5499
5506
|
}
|
|
5500
5507
|
};
|
|
5501
|
-
function clampLimit(requested) {
|
|
5502
|
-
if (!requested || requested <= 0) return DEFAULT_LIMIT;
|
|
5503
|
-
if (requested > MAX_LIMIT) return MAX_LIMIT;
|
|
5504
|
-
return Math.max(1, Math.floor(requested));
|
|
5505
|
-
}
|
|
5506
5508
|
// ../providers/supabase/src/userProfile/SupabaseUserProfileProvider.ts
|
|
5507
5509
|
/**
|
|
5508
5510
|
* Backed by `public.user_profiles` (one row per `auth.users.id`), auto-seeded
|
|
@@ -5687,6 +5689,7 @@ function mapError(e) {
|
|
|
5687
5689
|
*/
|
|
5688
5690
|
var NOT_IMPLEMENTED_MSG = "Platform projects are not supported on this deployment yet.";
|
|
5689
5691
|
var notImplementedGrantStore = {
|
|
5692
|
+
unsupported: true,
|
|
5690
5693
|
listByProject: async () => {
|
|
5691
5694
|
throw new ProviderError(NOT_IMPLEMENTED_MSG, 501);
|
|
5692
5695
|
},
|
|
@@ -5741,10 +5744,8 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5741
5744
|
}
|
|
5742
5745
|
static fromEnv(env, events, logger = new NoopLogger()) {
|
|
5743
5746
|
const bundle = clientBundleFromEnv(env);
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
const previous = previousKey(env, "SELVA_AT_REST_KEY").key;
|
|
5747
|
-
return new SupabaseDataProvider(bundle, events ?? new SupabaseEventSink(bundle, { logger }), secretKey, logger, previous ? decodeSecretKey(previous) : void 0);
|
|
5747
|
+
const keys = readAtRestKeys(env);
|
|
5748
|
+
return new SupabaseDataProvider(bundle, events ?? new SupabaseEventSink(bundle, { logger }), keys.current, logger, keys.previous);
|
|
5748
5749
|
}
|
|
5749
5750
|
static create(opts, events, secretKey, logger = new NoopLogger()) {
|
|
5750
5751
|
const bundle = buildClientBundle(opts);
|
|
@@ -6268,10 +6269,11 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6268
6269
|
return this.hydrate(data.user);
|
|
6269
6270
|
}
|
|
6270
6271
|
async listUsers(opts) {
|
|
6271
|
-
const perPage = opts?.limit
|
|
6272
|
-
const
|
|
6272
|
+
const perPage = clampPageLimit(opts?.limit);
|
|
6273
|
+
const requested = opts?.cursor ? parseInt(opts.cursor, 10) : 1;
|
|
6274
|
+
const page = Number.isFinite(requested) && requested >= 1 ? requested : 1;
|
|
6273
6275
|
const { data, error } = await this.admin.auth.admin.listUsers({
|
|
6274
|
-
page
|
|
6276
|
+
page,
|
|
6275
6277
|
perPage
|
|
6276
6278
|
});
|
|
6277
6279
|
if (error) throw error;
|
|
@@ -6850,13 +6852,13 @@ var HeaderAuthProvider = class HeaderAuthProvider {
|
|
|
6850
6852
|
}
|
|
6851
6853
|
async listUsers(opts) {
|
|
6852
6854
|
const all = await this.users.listUsers();
|
|
6853
|
-
const limit =
|
|
6854
|
-
const offset = opts?.cursor
|
|
6855
|
+
const limit = clampPageLimit(opts?.limit);
|
|
6856
|
+
const offset = decodeOffsetCursor(opts?.cursor);
|
|
6855
6857
|
const slice = all.slice(offset, offset + limit).map(toAuthUser);
|
|
6856
6858
|
const nextOffset = offset + slice.length;
|
|
6857
6859
|
return {
|
|
6858
6860
|
items: slice,
|
|
6859
|
-
nextCursor: nextOffset < all.length ?
|
|
6861
|
+
nextCursor: nextOffset < all.length ? encodeOffsetCursor(nextOffset) : void 0
|
|
6860
6862
|
};
|
|
6861
6863
|
}
|
|
6862
6864
|
/**
|
|
@@ -33989,16 +33991,18 @@ function solveLimitsFor(reported) {
|
|
|
33989
33991
|
if (!reported) return {
|
|
33990
33992
|
solveDeadlineMs: DEFAULT_SOLVE_DEADLINE_MS,
|
|
33991
33993
|
maxRequestBytes: null,
|
|
33992
|
-
reuseDefinitionCache: false
|
|
33994
|
+
reuseDefinitionCache: false,
|
|
33995
|
+
deploymentId: null
|
|
33993
33996
|
};
|
|
33994
33997
|
return {
|
|
33995
33998
|
solveDeadlineMs: Math.min(reported.timeoutSeconds * 1e3 + DEADLINE_SLACK_MS, MAX_SOLVE_DEADLINE_MS),
|
|
33996
33999
|
maxRequestBytes: reported.maxRequestBytes,
|
|
33997
|
-
reuseDefinitionCache: reported.signalsStaleDefinition
|
|
34000
|
+
reuseDefinitionCache: reported.signalsStaleDefinition,
|
|
34001
|
+
deploymentId: reported.deploymentId ?? null
|
|
33998
34002
|
};
|
|
33999
34003
|
}
|
|
34000
34004
|
function sameSolveLimits(a, b) {
|
|
34001
|
-
return a.solveDeadlineMs === b.solveDeadlineMs && a.maxRequestBytes === b.maxRequestBytes && a.reuseDefinitionCache === b.reuseDefinitionCache;
|
|
34005
|
+
return a.solveDeadlineMs === b.solveDeadlineMs && a.maxRequestBytes === b.maxRequestBytes && a.reuseDefinitionCache === b.reuseDefinitionCache && a.deploymentId === b.deploymentId;
|
|
34002
34006
|
}
|
|
34003
34007
|
var DEFAULT_MAX_WARM_COMPUTE_SERVERS = 16;
|
|
34004
34008
|
/**
|
|
@@ -34007,6 +34011,18 @@ var DEFAULT_MAX_WARM_COMPUTE_SERVERS = 16;
|
|
|
34007
34011
|
*/
|
|
34008
34012
|
var LIMITS_RECHECK_MS = 3e5;
|
|
34009
34013
|
/**
|
|
34014
|
+
* How stale the server's `deploymentId` may be before a warm client whose solve cache could
|
|
34015
|
+
* answer is handed out again. A cache hit never reaches the server, so riding on solve completion
|
|
34016
|
+
* would let a redeployed plugin's old results be served until the next miss.
|
|
34017
|
+
*/
|
|
34018
|
+
var DEPLOYMENT_RECHECK_MS = 3e4;
|
|
34019
|
+
/**
|
|
34020
|
+
* Longest a request waits on that check. The proxy answers `/limits` itself, in milliseconds; an
|
|
34021
|
+
* unreachable server must not hold a request that the cache could answer. The check finishes
|
|
34022
|
+
* behind it and retires the client if the deployment changed.
|
|
34023
|
+
*/
|
|
34024
|
+
var DEPLOYMENT_CHECK_WAIT_MS = 1e3;
|
|
34025
|
+
/**
|
|
34010
34026
|
* How long a failed build is remembered before the next `getClient` retries the
|
|
34011
34027
|
* handshake. Without this, every solve against a down server pays the full probe
|
|
34012
34028
|
* ladder again, so a user clicking Solve twice waits twice.
|
|
@@ -34026,10 +34042,12 @@ function describeSettledSolve(result) {
|
|
|
34026
34042
|
}
|
|
34027
34043
|
function createClientCache(config) {
|
|
34028
34044
|
const maxWarmComputeServers = config.maxWarmComputeServers ?? DEFAULT_MAX_WARM_COMPUTE_SERVERS;
|
|
34045
|
+
const cacheEnabled = config.responseCacheMaxBytes > 0;
|
|
34029
34046
|
const cache = /* @__PURE__ */ new Map();
|
|
34030
34047
|
const pending = /* @__PURE__ */ new Map();
|
|
34031
34048
|
const failed = /* @__PURE__ */ new Map();
|
|
34032
34049
|
const draining = /* @__PURE__ */ new Set();
|
|
34050
|
+
const deploymentChecks = /* @__PURE__ */ new WeakMap();
|
|
34033
34051
|
if (config.debug === "verbose") enableDebugLogging();
|
|
34034
34052
|
const debugLog = (message) => {
|
|
34035
34053
|
if (config.debug) config.onDebugLog?.(message);
|
|
@@ -34074,22 +34092,25 @@ function createClientCache(config) {
|
|
|
34074
34092
|
if (definitionGuid) clientConfig.headers = { "X-Selva-Definition": definitionGuid };
|
|
34075
34093
|
const client = await GrasshopperClient.create(clientConfig);
|
|
34076
34094
|
const probe = createConcurrencyProbe(client, debugLog);
|
|
34077
|
-
const
|
|
34078
|
-
const [
|
|
34095
|
+
const readReported = async () => await Promise.resolve(client.serverStats?.getLimits?.()).catch(() => null) ?? null;
|
|
34096
|
+
const [reported] = await Promise.all([readReported(), probe.refresh()]);
|
|
34097
|
+
const limits = solveLimitsFor(reported);
|
|
34079
34098
|
debugLog(`[Compute/client-cache] server ${server.id}: deadline ${limits.solveDeadlineMs}ms, request cap ${limits.maxRequestBytes ?? "not reported"}, pointer reuse ${limits.reuseDefinitionCache}`);
|
|
34080
34099
|
let limitsCheckedAt = Date.now();
|
|
34081
|
-
let
|
|
34100
|
+
let recheck = null;
|
|
34101
|
+
/** Re-reads the limits; true when they changed, which retires this client. */
|
|
34102
|
+
const recheckLimits = () => recheck ??= readReported().then((next) => {
|
|
34103
|
+
limitsCheckedAt = Date.now();
|
|
34104
|
+
if (next === null && reported !== null) return false;
|
|
34105
|
+
if (sameSolveLimits(solveLimitsFor(next), limits)) return false;
|
|
34106
|
+
debugLog(`[Compute/client-cache] server ${server.id} limits changed — rebuilding`);
|
|
34107
|
+
if (cache.get(server.id) === entry) evictEntry(server.id);
|
|
34108
|
+
return true;
|
|
34109
|
+
}).finally(() => {
|
|
34110
|
+
recheck = null;
|
|
34111
|
+
});
|
|
34082
34112
|
const recheckLimitsIfDue = () => {
|
|
34083
|
-
if (
|
|
34084
|
-
checkingLimits = true;
|
|
34085
|
-
readLimits().then((next) => {
|
|
34086
|
-
limitsCheckedAt = Date.now();
|
|
34087
|
-
if (sameSolveLimits(next, limits)) return;
|
|
34088
|
-
debugLog(`[Compute/client-cache] server ${server.id} limits changed — rebuilding`);
|
|
34089
|
-
if (cache.get(server.id) === entry) evictEntry(server.id);
|
|
34090
|
-
}).finally(() => {
|
|
34091
|
-
checkingLimits = false;
|
|
34092
|
-
});
|
|
34113
|
+
if (Date.now() - limitsCheckedAt >= LIMITS_RECHECK_MS) recheckLimits();
|
|
34093
34114
|
};
|
|
34094
34115
|
const scheduler = client.createScheduler({
|
|
34095
34116
|
mode: "queue",
|
|
@@ -34097,7 +34118,7 @@ function createClientCache(config) {
|
|
|
34097
34118
|
maxQueueDepth: config.maxQueueDepth || void 0,
|
|
34098
34119
|
queueWaitMs: config.queueWaitMs || void 0,
|
|
34099
34120
|
timeoutMs: limits.solveDeadlineMs,
|
|
34100
|
-
cache:
|
|
34121
|
+
cache: cacheEnabled ? { maxBytes: config.responseCacheMaxBytes } : false,
|
|
34101
34122
|
reuseServerDefinitionCache: limits.reuseDefinitionCache,
|
|
34102
34123
|
onSettle: (_ctx, result) => {
|
|
34103
34124
|
queueMicrotask(() => finishDraining(entry));
|
|
@@ -34114,6 +34135,18 @@ function createClientCache(config) {
|
|
|
34114
34135
|
scheduler,
|
|
34115
34136
|
limits
|
|
34116
34137
|
};
|
|
34138
|
+
deploymentChecks.set(entry, async () => {
|
|
34139
|
+
if (Date.now() - limitsCheckedAt < DEPLOYMENT_RECHECK_MS) return true;
|
|
34140
|
+
let timer;
|
|
34141
|
+
const waited = new Promise((resolve) => {
|
|
34142
|
+
timer = setTimeout(() => resolve(false), DEPLOYMENT_CHECK_WAIT_MS);
|
|
34143
|
+
});
|
|
34144
|
+
try {
|
|
34145
|
+
return !await Promise.race([recheckLimits(), waited]);
|
|
34146
|
+
} finally {
|
|
34147
|
+
clearTimeout(timer);
|
|
34148
|
+
}
|
|
34149
|
+
});
|
|
34117
34150
|
return entry;
|
|
34118
34151
|
}
|
|
34119
34152
|
function evictEntry(id) {
|
|
@@ -34122,14 +34155,15 @@ function createClientCache(config) {
|
|
|
34122
34155
|
cache.delete(id);
|
|
34123
34156
|
retire(entry);
|
|
34124
34157
|
}
|
|
34125
|
-
|
|
34158
|
+
const self = {
|
|
34126
34159
|
async getClient(server, opts) {
|
|
34127
34160
|
const key = server.id;
|
|
34128
34161
|
const existing = cache.get(key);
|
|
34129
34162
|
if (existing) {
|
|
34130
34163
|
cache.delete(key);
|
|
34131
34164
|
cache.set(key, existing);
|
|
34132
|
-
return existing;
|
|
34165
|
+
if (!cacheEnabled || await deploymentChecks.get(existing)?.() !== false) return existing;
|
|
34166
|
+
return self.getClient(server, opts);
|
|
34133
34167
|
}
|
|
34134
34168
|
const inFlight = pending.get(key);
|
|
34135
34169
|
if (inFlight) return inFlight.promise;
|
|
@@ -34223,6 +34257,7 @@ function createClientCache(config) {
|
|
|
34223
34257
|
failed.clear();
|
|
34224
34258
|
}
|
|
34225
34259
|
};
|
|
34260
|
+
return self;
|
|
34226
34261
|
}
|
|
34227
34262
|
/**
|
|
34228
34263
|
* In-process cache of `.gh` definition bytes, keyed by immutable **version id**.
|
|
@@ -34534,27 +34569,43 @@ function createSolveCacheSingleFlight(options = {}) {
|
|
|
34534
34569
|
};
|
|
34535
34570
|
}
|
|
34536
34571
|
/**
|
|
34537
|
-
* What `SolveEngine.solve` takes as `inputs`, from a schema the host stored. The
|
|
34538
|
-
* the number widgets
|
|
34572
|
+
* What `SolveEngine.solve` takes as `inputs`, from a schema the host stored. The layout, not
|
|
34573
|
+
* `schema.inputs`, carries the number widgets' bounds and each input's source: without this,
|
|
34574
|
+
* nothing clamps and a `server` input takes the caller's value.
|
|
34539
34575
|
*/
|
|
34540
34576
|
function solveInputsFromSchema(schema) {
|
|
34541
34577
|
const bounds = /* @__PURE__ */ new Map();
|
|
34542
34578
|
for (const item of getInputItems(schema)) if (item.widgetType === "number" && item.config) bounds.set(item.paramId, item.config);
|
|
34579
|
+
const serverSourced = serverSourcedInputIds(schema);
|
|
34543
34580
|
return schema.inputs.map((input) => {
|
|
34544
34581
|
const widget = bounds.get(input.id);
|
|
34545
|
-
|
|
34582
|
+
if (!widget && !serverSourced.has(input.id)) return input;
|
|
34583
|
+
return {
|
|
34546
34584
|
...input,
|
|
34547
|
-
|
|
34548
|
-
|
|
34549
|
-
|
|
34585
|
+
...widget ? {
|
|
34586
|
+
minimum: widget.minimum,
|
|
34587
|
+
maximum: widget.maximum
|
|
34588
|
+
} : {},
|
|
34589
|
+
...serverSourced.has(input.id) ? { serverSourced: true } : {}
|
|
34590
|
+
};
|
|
34550
34591
|
});
|
|
34551
34592
|
}
|
|
34552
|
-
/**
|
|
34593
|
+
/**
|
|
34594
|
+
* Ids in `values` that set a server-sourced input. A host refuses a request carrying any: the
|
|
34595
|
+
* input tree would ignore them, and the caller should hear so rather than solve on the default.
|
|
34596
|
+
*/
|
|
34597
|
+
function postedServerSourcedIds(inputs, values) {
|
|
34598
|
+
return inputs.filter((input) => input.serverSourced && Object.hasOwn(values, input.id)).map((input) => input.id);
|
|
34599
|
+
}
|
|
34600
|
+
/**
|
|
34601
|
+
* The input tree a solve sends: each input's value, or its schema default when it has none. A
|
|
34602
|
+
* server-sourced input always takes its default.
|
|
34603
|
+
*/
|
|
34553
34604
|
function buildSolveInputTree(inputs, values) {
|
|
34554
34605
|
return TreeBuilder.fromValues(inputs.filter((input) => input.paramType).map((input) => ({
|
|
34555
34606
|
paramName: input.nickname,
|
|
34556
34607
|
paramType: input.paramType,
|
|
34557
|
-
value: (Object.hasOwn(values, input.id) ? values[input.id] : void 0) ?? input.default,
|
|
34608
|
+
value: (!input.serverSourced && Object.hasOwn(values, input.id) ? values[input.id] : void 0) ?? input.default,
|
|
34558
34609
|
minimum: input.minimum,
|
|
34559
34610
|
maximum: input.maximum
|
|
34560
34611
|
})));
|
|
@@ -35149,6 +35200,325 @@ var SmtpNotificationProvider = class {
|
|
|
35149
35200
|
}
|
|
35150
35201
|
}
|
|
35151
35202
|
};
|
|
35203
|
+
// ../providers/header-auth/src/config.ts
|
|
35204
|
+
var header = (key, fallback, slot) => defineSetting({
|
|
35205
|
+
key,
|
|
35206
|
+
label: `${slot[0].toUpperCase()}${slot.slice(1)} header`,
|
|
35207
|
+
type: "string",
|
|
35208
|
+
default: fallback,
|
|
35209
|
+
onInvalid: "fail",
|
|
35210
|
+
class: "bootstrap",
|
|
35211
|
+
description: `Header the proxy puts the user's ${slot} in.`,
|
|
35212
|
+
impact: "A name the proxy never sends signs nobody in. Override all three or none."
|
|
35213
|
+
});
|
|
35214
|
+
var HEADER_AUTH_SETTINGS = composeManifest([
|
|
35215
|
+
defineSetting({
|
|
35216
|
+
key: "HEADER_AUTH_DATA_DIR",
|
|
35217
|
+
label: "Allowlist folder",
|
|
35218
|
+
type: "string",
|
|
35219
|
+
onInvalid: "fail",
|
|
35220
|
+
class: "bootstrap",
|
|
35221
|
+
description: "Directory holding header-allowlist.json. Falls back to DATA_PATH."
|
|
35222
|
+
}),
|
|
35223
|
+
header("HEADER_AUTH_UPN_HEADER", "SELVA-UserPrincipalName", "UPN"),
|
|
35224
|
+
header("HEADER_AUTH_EMAIL_HEADER", "SELVA-Email", "email"),
|
|
35225
|
+
header("HEADER_AUTH_DISPLAY_NAME_HEADER", "SELVA-DisplayName", "display name")
|
|
35226
|
+
]);
|
|
35227
|
+
// ../providers/local/src/config.ts
|
|
35228
|
+
var LOCAL_SETTINGS = composeManifest([defineSetting({
|
|
35229
|
+
key: "DATA_PATH",
|
|
35230
|
+
label: "Data folder",
|
|
35231
|
+
type: "string",
|
|
35232
|
+
required: true,
|
|
35233
|
+
onInvalid: "fail",
|
|
35234
|
+
class: "bootstrap",
|
|
35235
|
+
summary: true,
|
|
35236
|
+
description: "Folder on this server holding users, orgs, projects and uploads. Back it up.",
|
|
35237
|
+
impact: "Pointing it elsewhere starts an empty instance; the old data stays where it was."
|
|
35238
|
+
})]);
|
|
35239
|
+
// src/lib/server/config/settings.ts
|
|
35240
|
+
var COMPUTE_DEBUG = defineSetting({
|
|
35241
|
+
key: "SELVA_FLAG_COMPUTE_DEBUG",
|
|
35242
|
+
label: "Compute debug logging",
|
|
35243
|
+
type: "string",
|
|
35244
|
+
default: "off",
|
|
35245
|
+
onInvalid: "default",
|
|
35246
|
+
class: "setting",
|
|
35247
|
+
description: "off, on (cache and timing lines per solve) or verbose (adds Compute’s raw error bodies).",
|
|
35248
|
+
impact: "verbose can write what was solved to the log, which erasure cannot reach."
|
|
35249
|
+
});
|
|
35250
|
+
/** `SELVA_FLAG_COMPUTE_DEBUG`: `verbose`, or on and off in the manifest's boolean words. */
|
|
35251
|
+
function computeDebugMode(env) {
|
|
35252
|
+
if (readSetting(COMPUTE_DEBUG, env).toLowerCase() === "verbose") return "verbose";
|
|
35253
|
+
return readSetting({
|
|
35254
|
+
...COMPUTE_DEBUG,
|
|
35255
|
+
type: "bool",
|
|
35256
|
+
default: false
|
|
35257
|
+
}, env) ? "on" : "off";
|
|
35258
|
+
}
|
|
35259
|
+
/** Keys only this app reads. adapter-node's own keys are here too: they decide whether it works. */
|
|
35260
|
+
var APP_SETTINGS = composeManifest([
|
|
35261
|
+
defineSetting({
|
|
35262
|
+
key: "ORIGIN",
|
|
35263
|
+
label: "Public address",
|
|
35264
|
+
type: "url",
|
|
35265
|
+
origin: true,
|
|
35266
|
+
onInvalid: "fail",
|
|
35267
|
+
class: "bootstrap",
|
|
35268
|
+
summary: true,
|
|
35269
|
+
description: "The URL people use to reach Selva, such as https://selva.example.com.",
|
|
35270
|
+
impact: "Wrong or unset behind a proxy: form posts fail the CSRF check and invite links carry an internal host."
|
|
35271
|
+
}),
|
|
35272
|
+
defineSetting({
|
|
35273
|
+
key: "PORT",
|
|
35274
|
+
label: "Port",
|
|
35275
|
+
type: "int",
|
|
35276
|
+
min: 1,
|
|
35277
|
+
max: 65535,
|
|
35278
|
+
default: 3e3,
|
|
35279
|
+
onInvalid: "fail",
|
|
35280
|
+
class: "bootstrap",
|
|
35281
|
+
description: "Port the app listens on."
|
|
35282
|
+
}),
|
|
35283
|
+
defineSetting({
|
|
35284
|
+
key: "HOST",
|
|
35285
|
+
label: "Listen address",
|
|
35286
|
+
type: "string",
|
|
35287
|
+
default: "0.0.0.0",
|
|
35288
|
+
onInvalid: "fail",
|
|
35289
|
+
class: "bootstrap",
|
|
35290
|
+
summary: true,
|
|
35291
|
+
description: "Which network address the app accepts connections on. 127.0.0.1 when a proxy sits in front.",
|
|
35292
|
+
impact: "Under header auth, anything that reaches the port directly can claim to be any user."
|
|
35293
|
+
}),
|
|
35294
|
+
defineSetting({
|
|
35295
|
+
key: "BODY_SIZE_LIMIT",
|
|
35296
|
+
label: "Max request size",
|
|
35297
|
+
type: "string",
|
|
35298
|
+
default: "512K",
|
|
35299
|
+
onInvalid: "fail",
|
|
35300
|
+
class: "bootstrap",
|
|
35301
|
+
summary: true,
|
|
35302
|
+
description: "Largest request the server accepts at all, uploads included (K, M or G suffix).",
|
|
35303
|
+
impact: "Below COMPUTE_REQUEST_MAX_BYTES, uploads and file inputs fail with 413."
|
|
35304
|
+
}),
|
|
35305
|
+
defineSetting({
|
|
35306
|
+
key: "ADDRESS_HEADER",
|
|
35307
|
+
label: "Visitor IP header",
|
|
35308
|
+
type: "string",
|
|
35309
|
+
onInvalid: "fail",
|
|
35310
|
+
class: "bootstrap",
|
|
35311
|
+
summary: true,
|
|
35312
|
+
description: "Header your proxy uses to pass on the visitor’s IP address. Usually X-Forwarded-For.",
|
|
35313
|
+
impact: "Unset behind a proxy: every client shares one rate-limit bucket."
|
|
35314
|
+
}),
|
|
35315
|
+
defineSetting({
|
|
35316
|
+
key: "XFF_DEPTH",
|
|
35317
|
+
label: "Proxies in front",
|
|
35318
|
+
type: "int",
|
|
35319
|
+
min: 1,
|
|
35320
|
+
onInvalid: "fail",
|
|
35321
|
+
class: "bootstrap",
|
|
35322
|
+
summary: true,
|
|
35323
|
+
description: "How many proxies sit between visitors and the app. Usually 1."
|
|
35324
|
+
}),
|
|
35325
|
+
defineSetting({
|
|
35326
|
+
key: "PROTOCOL_HEADER",
|
|
35327
|
+
label: "Protocol header",
|
|
35328
|
+
type: "string",
|
|
35329
|
+
onInvalid: "fail",
|
|
35330
|
+
class: "bootstrap",
|
|
35331
|
+
description: "Header carrying the original protocol, when ORIGIN is unset."
|
|
35332
|
+
}),
|
|
35333
|
+
defineSetting({
|
|
35334
|
+
key: "HOST_HEADER",
|
|
35335
|
+
label: "Host header",
|
|
35336
|
+
type: "string",
|
|
35337
|
+
onInvalid: "fail",
|
|
35338
|
+
class: "bootstrap",
|
|
35339
|
+
description: "Header carrying the original host, when ORIGIN is unset."
|
|
35340
|
+
}),
|
|
35341
|
+
defineSetting({
|
|
35342
|
+
key: "NODE_ENV",
|
|
35343
|
+
label: "Run mode",
|
|
35344
|
+
type: "string",
|
|
35345
|
+
onInvalid: "fail",
|
|
35346
|
+
class: "bootstrap",
|
|
35347
|
+
description: "production in deployments: hides stack traces and makes cookies Secure."
|
|
35348
|
+
}),
|
|
35349
|
+
defineSetting({
|
|
35350
|
+
key: "ALLOW_INSECURE_COOKIES",
|
|
35351
|
+
label: "Allow sign-in over http",
|
|
35352
|
+
type: "bool",
|
|
35353
|
+
default: false,
|
|
35354
|
+
onInvalid: "fail",
|
|
35355
|
+
class: "bootstrap",
|
|
35356
|
+
description: "Drop the Secure cookie flag so sign-in works over plain http.",
|
|
35357
|
+
legacy: { bool: "exact-true" }
|
|
35358
|
+
}),
|
|
35359
|
+
defineSetting({
|
|
35360
|
+
key: "INSTALL_DIR",
|
|
35361
|
+
label: "Install folder",
|
|
35362
|
+
type: "string",
|
|
35363
|
+
onInvalid: "fail",
|
|
35364
|
+
class: "bootstrap",
|
|
35365
|
+
description: "Deployment directory the admin updater runs in. Defaults to the working directory."
|
|
35366
|
+
}),
|
|
35367
|
+
defineSetting({
|
|
35368
|
+
key: "SELVA_EVENT_CALLBACK_ORIGIN",
|
|
35369
|
+
label: "Solve event callback address",
|
|
35370
|
+
type: "url",
|
|
35371
|
+
origin: true,
|
|
35372
|
+
onInvalid: "fail",
|
|
35373
|
+
class: "bootstrap",
|
|
35374
|
+
description: "Origin Rhino.Compute posts live solve events to, when it differs from the browser’s."
|
|
35375
|
+
}),
|
|
35376
|
+
defineSetting({
|
|
35377
|
+
key: "MCP_ALLOWED_ORIGINS",
|
|
35378
|
+
label: "Extra MCP origins",
|
|
35379
|
+
type: "list",
|
|
35380
|
+
default: [],
|
|
35381
|
+
onInvalid: "fail",
|
|
35382
|
+
class: "setting",
|
|
35383
|
+
description: "Browser origins /mcp accepts besides its own."
|
|
35384
|
+
}),
|
|
35385
|
+
defineSetting({
|
|
35386
|
+
key: "LOG_LEVEL",
|
|
35387
|
+
label: "Log level",
|
|
35388
|
+
type: "enum",
|
|
35389
|
+
values: [
|
|
35390
|
+
"debug",
|
|
35391
|
+
"info",
|
|
35392
|
+
"warn",
|
|
35393
|
+
"error"
|
|
35394
|
+
],
|
|
35395
|
+
onInvalid: "default",
|
|
35396
|
+
class: "setting",
|
|
35397
|
+
description: "Lowest severity written to the log. Default info (debug in development)."
|
|
35398
|
+
}),
|
|
35399
|
+
COMPUTE_DEBUG,
|
|
35400
|
+
defineSetting({
|
|
35401
|
+
key: "SENTRY_DSN",
|
|
35402
|
+
label: "Sentry error reporting",
|
|
35403
|
+
type: "url",
|
|
35404
|
+
onInvalid: "fail",
|
|
35405
|
+
class: "secret",
|
|
35406
|
+
sensitive: true,
|
|
35407
|
+
description: "Ship unexpected server errors to Sentry, scrubbed of cookies, auth headers, bodies and query strings."
|
|
35408
|
+
}),
|
|
35409
|
+
defineSetting({
|
|
35410
|
+
key: "SENTRY_TRACES_SAMPLE_RATE",
|
|
35411
|
+
label: "Sentry trace sampling",
|
|
35412
|
+
type: "string",
|
|
35413
|
+
default: "0",
|
|
35414
|
+
onInvalid: "default",
|
|
35415
|
+
class: "tunable",
|
|
35416
|
+
description: "Share of requests traced to Sentry, 0–1 (out of range is clamped). 0 sends errors only."
|
|
35417
|
+
}),
|
|
35418
|
+
defineSetting({
|
|
35419
|
+
key: "SELVA_RELEASE",
|
|
35420
|
+
label: "Release tag",
|
|
35421
|
+
type: "string",
|
|
35422
|
+
onInvalid: "fail",
|
|
35423
|
+
class: "tunable",
|
|
35424
|
+
description: "Release tag on Sentry events and log records."
|
|
35425
|
+
})
|
|
35426
|
+
]);
|
|
35427
|
+
/** Prefixes whose undeclared keys are reported as unknown (likely typos). */
|
|
35428
|
+
var WATCHED_PREFIXES = [
|
|
35429
|
+
"SELVA_",
|
|
35430
|
+
"SUPABASE_",
|
|
35431
|
+
"COMPUTE_",
|
|
35432
|
+
"SMTP_",
|
|
35433
|
+
"HEADER_AUTH_",
|
|
35434
|
+
"API_TOKEN_",
|
|
35435
|
+
"MAX_",
|
|
35436
|
+
"REMOTE_DEFINITION_",
|
|
35437
|
+
"SIGN_IN_",
|
|
35438
|
+
"BOOTSTRAP_"
|
|
35439
|
+
];
|
|
35440
|
+
/** Read by tooling, not by the app: not unknown, not reported. */
|
|
35441
|
+
var EXTERNAL_KEYS = ["SELVA_REQUIRE_SUPABASE"];
|
|
35442
|
+
/**
|
|
35443
|
+
* Keys no release reads any more, with what took their place. Boot and doctor
|
|
35444
|
+
* name them instead of calling them typos; `selva migrate` removes them.
|
|
35445
|
+
*/
|
|
35446
|
+
var RETIRED_KEYS = {
|
|
35447
|
+
SELVA_FLAG_COMPUTE_DEBUG_VERBOSE: "use SELVA_FLAG_COMPUTE_DEBUG=verbose",
|
|
35448
|
+
COMPUTE_RATE_LIMIT_WINDOW_MS: "fixed at 100 s",
|
|
35449
|
+
API_TOKEN_RATE_LIMIT_WINDOW_MS: "fixed at 60 s",
|
|
35450
|
+
MAX_IMAGE_FILE_SIZE_BYTES: "fixed at 10 MB",
|
|
35451
|
+
COMPUTE_REQUEST_MAX_BYTES: "fixed at 256 MB",
|
|
35452
|
+
COMPUTE_RESPONSE_MAX_BYTES: "fixed at 300 MB",
|
|
35453
|
+
REMOTE_DEFINITION_FETCH_TIMEOUT_MS: "fixed at 30 s",
|
|
35454
|
+
REMOTE_DEFINITION_CACHE_TTL_MS: "fixed at 5 min",
|
|
35455
|
+
DEFINITION_CACHE_TTL_MS: "fixed at 5 min",
|
|
35456
|
+
SUPABASE_TOKEN_VERIFICATION: "always hybrid",
|
|
35457
|
+
SUPABASE_REVALIDATE_MS: "fixed at 60 s",
|
|
35458
|
+
SUPABASE_PRIVATE_URL_PREFIX: "fixed at /api/files",
|
|
35459
|
+
COMPUTE_SOLVE_DEADLINE_MS: "set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server",
|
|
35460
|
+
MAX_SOLVE_DURATION_MS: "set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server",
|
|
35461
|
+
COMPUTE_REUSE_DEFINITION_CACHE: "on whenever the compute server reports /limits",
|
|
35462
|
+
COMPUTE_CACHE_ERRORED_SOLVES: "removed"
|
|
35463
|
+
};
|
|
35464
|
+
/**
|
|
35465
|
+
* The manifest for this deployment: engine and app keys, plus the slices of
|
|
35466
|
+
* the providers it selects. A provider's required keys only apply when it is
|
|
35467
|
+
* in use, so slices are chosen here rather than all composed at once.
|
|
35468
|
+
*/
|
|
35469
|
+
function deploymentManifest(env) {
|
|
35470
|
+
const chosen = new Set([
|
|
35471
|
+
"SELVA_AUTH_PROVIDER",
|
|
35472
|
+
"SELVA_DATA_PROVIDER",
|
|
35473
|
+
"SELVA_STORAGE_PROVIDER"
|
|
35474
|
+
].map((k) => (env[k] ?? "local").toLowerCase()));
|
|
35475
|
+
return composeManifest([
|
|
35476
|
+
ENGINE_SETTINGS,
|
|
35477
|
+
APP_SETTINGS,
|
|
35478
|
+
...chosen.has("local") ? [LOCAL_SETTINGS] : [],
|
|
35479
|
+
...chosen.has("supabase") ? [SUPABASE_SETTINGS] : [],
|
|
35480
|
+
...chosen.has("header") ? [HEADER_AUTH_SETTINGS] : []
|
|
35481
|
+
]);
|
|
35482
|
+
}
|
|
35483
|
+
/** Every key any slice declares, whichever providers are chosen. */
|
|
35484
|
+
var ALL_SETTINGS = composeManifest([
|
|
35485
|
+
ENGINE_SETTINGS,
|
|
35486
|
+
APP_SETTINGS,
|
|
35487
|
+
LOCAL_SETTINGS,
|
|
35488
|
+
SUPABASE_SETTINGS,
|
|
35489
|
+
HEADER_AUTH_SETTINGS
|
|
35490
|
+
]);
|
|
35491
|
+
/** The report for this deployment. Keys of providers it doesn't use are known, not typos. */
|
|
35492
|
+
function deploymentReport(env) {
|
|
35493
|
+
const manifest = deploymentManifest(env);
|
|
35494
|
+
const active = new Set(manifest.flatMap((s) => [s.key, ...s.aliases ?? []]));
|
|
35495
|
+
const inactive = ALL_SETTINGS.flatMap((s) => [s.key, ...s.aliases ?? []]).filter((k) => !active.has(k));
|
|
35496
|
+
return buildConfigReport(manifest, env, {
|
|
35497
|
+
prefixes: WATCHED_PREFIXES,
|
|
35498
|
+
external: [
|
|
35499
|
+
...EXTERNAL_KEYS,
|
|
35500
|
+
...Object.keys(RETIRED_KEYS),
|
|
35501
|
+
...inactive
|
|
35502
|
+
]
|
|
35503
|
+
});
|
|
35504
|
+
}
|
|
35505
|
+
var NOT_FROM_ENV_FILE = /* @__PURE__ */ new Set(["NODE_ENV"]);
|
|
35506
|
+
/** What the boot snapshot and the CLI's drift check compare. */
|
|
35507
|
+
function deploymentSnapshot(env, salt) {
|
|
35508
|
+
return takeSnapshot(deploymentManifest(env).filter((s) => !NOT_FROM_ENV_FILE.has(s.key)), env, salt);
|
|
35509
|
+
}
|
|
35510
|
+
/** The rotation overlap of each root key: what the admin page and doctor count down. */
|
|
35511
|
+
function keyRotationStatus(env, now = Date.now()) {
|
|
35512
|
+
return ["SELVA_HMAC_KEY", "SELVA_AT_REST_KEY"].map((key) => {
|
|
35513
|
+
const p = previousKey(env, key, now);
|
|
35514
|
+
return {
|
|
35515
|
+
key,
|
|
35516
|
+
state: p.state,
|
|
35517
|
+
..."expires" in p ? { expires: p.expires } : {},
|
|
35518
|
+
..."daysLeft" in p ? { daysLeft: p.daysLeft } : {}
|
|
35519
|
+
};
|
|
35520
|
+
});
|
|
35521
|
+
}
|
|
35152
35522
|
// src/lib/server/providers.server.ts
|
|
35153
35523
|
var lazyLogger = {
|
|
35154
35524
|
debug: (m, f) => getLogger().debug(m, f),
|
|
@@ -35272,13 +35642,7 @@ function getNotificationProvider() {
|
|
|
35272
35642
|
function parseLogLevel(raw) {
|
|
35273
35643
|
const value = raw?.trim().toLowerCase();
|
|
35274
35644
|
if (value === "debug" || value === "info" || value === "warn" || value === "error") return value;
|
|
35275
|
-
if (
|
|
35276
|
-
"true",
|
|
35277
|
-
"1",
|
|
35278
|
-
"yes",
|
|
35279
|
-
"on",
|
|
35280
|
-
"verbose"
|
|
35281
|
-
].includes((env.SELVA_FLAG_COMPUTE_DEBUG ?? "").toLowerCase())) return "debug";
|
|
35645
|
+
if (computeDebugMode(env) !== "off") return "debug";
|
|
35282
35646
|
return env.NODE_ENV === "development" ? "debug" : "info";
|
|
35283
35647
|
}
|
|
35284
35648
|
createLogger({
|
|
@@ -35327,6 +35691,6 @@ if (!globalThis[ERROR_HOOKS_FLAG]) {
|
|
|
35327
35691
|
getErrorReporter().capture(error, { tags: { origin: "uncaughtException" } });
|
|
35328
35692
|
});
|
|
35329
35693
|
}
|
|
35330
|
-
export {
|
|
35694
|
+
export { deploymentSnapshot as A, classifyAssetPath as B, getUserProfileStore as C, computeDebugMode as D, RETIRED_KEYS as E, postedServerSourcedIds as F, definitionPaths as G, NoopEventSink as H, solveInputsFromSchema as I, diffSnapshots as K, LocalComputeServerStore as L, MAX_SOLVE_DEADLINE_MS as M, SolveEngine as N, deploymentManifest as O, acceptsGzip as P, isEncryptedSecret as R, getTenancy as S, providers as T, actorFrom as U, orgPaths as V, actorOf as W, getPlatformProjectGrantStore as _, getComputeServerConfigStore as a, getSolveMetricSink as b, getDefinitionService as c, getInviteStore as d, getLogger as f, getPermissionStore as g, getOrganizationProvider as h, getBranding as i, keyRotationStatus as j, deploymentReport as k, getErrorReporter as l, getOrgAssetService as m, getAuditQuery as n, getDataProvider as o, getNotificationProvider as p, getAuthProvider as r, getDefinitionMeta as s, flag as t, getEventSink as u, getProjectProvider as v, lazyLogger as w, getStorageProvider as x, getShareLinkStore as y, emptyProfile as z };
|
|
35331
35695
|
|
|
35332
35696
|
//# sourceMappingURL=providers.server.js.map
|