@selvajs/selva 4.20.1-beta.2 → 4.20.1-beta.4
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/chunks/{D-SwRD80.js → D-uUm_OB.js} +43 -43
- package/build/client/_app/immutable/chunks/D-uUm_OB.js.br +0 -0
- package/build/client/_app/immutable/chunks/{D-SwRD80.js.gz → D-uUm_OB.js.gz} +0 -0
- package/build/client/_app/immutable/chunks/D84F7w9g.js +1 -0
- package/build/client/_app/immutable/chunks/D84F7w9g.js.br +1 -0
- package/build/client/_app/immutable/chunks/D84F7w9g.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.hg2qyLJU.js → app.BpT6WkO1.js} +2 -2
- package/build/client/_app/immutable/entry/app.BpT6WkO1.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BpT6WkO1.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js +1 -0
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.BkNlRItr.js.gz +0 -0
- package/build/client/_app/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 +9 -2
- package/build/server/chunks/access.js +0 -3
- package/build/server/chunks/access.js.map +1 -1
- package/build/server/chunks/definitions.js +178 -1
- package/build/server/chunks/definitions.js.map +1 -1
- package/build/server/chunks/handlers.js +4 -5
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/providers.server.js +111 -202
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +3 -3
- package/build/server/chunks/registry.js.map +1 -1
- package/build/server/chunks/resolve.server.js +1 -1
- package/build/server/chunks/server-config-write.js +13 -1
- package/build/server/chunks/server-config-write.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +30 -48
- package/build/server/entries/endpoints/api/admin/compute/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +3 -2
- package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +3 -2
- package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +3 -2
- package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js +6 -2
- package/build/server/entries/endpoints/api/admin/users/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +8 -8
- package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +1 -1
- package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
- package/build/server/entries/hooks.server.js +34 -10
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +16 -3
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +132 -89
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/manifest-full.js +1 -1
- package/build/server/manifest.js +1 -1
- package/build/server/nodes/21.js +1 -1
- package/build/server/server.js +1 -1
- package/package.json +11 -11
- package/build/client/_app/immutable/chunks/D-SwRD80.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js +0 -1
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.br +0 -1
- package/build/client/_app/immutable/chunks/Dvq2vJj6.js.gz +0 -0
- 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/21.gGT7QEb1.js +0 -1
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.br +0 -1
- package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.gz +0 -0
|
@@ -213,7 +213,7 @@ function server_data_serializer(event, state) {
|
|
|
213
213
|
let promise_id = 1;
|
|
214
214
|
let max_nodes = -1;
|
|
215
215
|
const iterator = create_async_iterator();
|
|
216
|
-
const global = "
|
|
216
|
+
const global = "__sveltekit_rxhehf";
|
|
217
217
|
/** @param {number} index */
|
|
218
218
|
function get_replacer(index) {
|
|
219
219
|
/** @param {any} thing */
|
|
@@ -1443,7 +1443,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
|
|
|
1443
1443
|
"crossorigin"
|
|
1444
1444
|
]);
|
|
1445
1445
|
}
|
|
1446
|
-
const global = "
|
|
1446
|
+
const global = "__sveltekit_rxhehf";
|
|
1447
1447
|
const { data, chunks } = data_serializer.get_data(csp);
|
|
1448
1448
|
if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!(state.prerendering || state.prerender_default === true))).join("\n ")}`;
|
|
1449
1449
|
if (page_config.csr && client) {
|
|
@@ -1467,7 +1467,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
|
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
1469
|
const blocks = [];
|
|
1470
|
-
const properties = [`base: ${base_expression}`, `version: ${s("
|
|
1470
|
+
const properties = [`base: ${base_expression}`, `version: ${s("1794154569124")}`];
|
|
1471
1471
|
if (assets) properties.push(`assets: ${s(assets)}`);
|
|
1472
1472
|
if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : uneval$1(rendered_env)}`);
|
|
1473
1473
|
if (chunks) {
|
|
@@ -2363,7 +2363,7 @@ function redirect_response(status, location) {
|
|
|
2363
2363
|
* @param {Response} response
|
|
2364
2364
|
*/
|
|
2365
2365
|
function with_version_header(response) {
|
|
2366
|
-
response.headers.set("x-sveltekit-version", "
|
|
2366
|
+
response.headers.set("x-sveltekit-version", "1794154569124");
|
|
2367
2367
|
return response;
|
|
2368
2368
|
}
|
|
2369
2369
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.20.1-beta.
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.20.1-beta.4\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
|
|
@@ -7,7 +7,7 @@ import { i as DEFAULT_ORG_PERMISSIONS, t as ALL_ORG_ASSET_KINDS } from "./schema
|
|
|
7
7
|
import { t as ALL_PLATFORM_PERMISSIONS } from "./types3.js";
|
|
8
8
|
import { d as encodeOffsetCursor, l as clampPageLimit, u as decodeOffsetCursor } from "./visibility.js";
|
|
9
9
|
import { n as readBool } from "./limits.js";
|
|
10
|
-
import { n as renderThrown } from "./definitions.js";
|
|
10
|
+
import { a as createLogger, i as ConsoleLogger, n as renderThrown } from "./definitions.js";
|
|
11
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";
|
|
12
12
|
import { i as getInputItems, n as serverSourcedInputIds, t as raceAbort } from "./abort-Bfrdupaj.js";
|
|
13
13
|
import { createRequire } from "node:module";
|
|
@@ -685,178 +685,6 @@ function decryptWithKeys(envelope, keys, aad) {
|
|
|
685
685
|
}
|
|
686
686
|
throw lastError ?? /* @__PURE__ */ new Error("No key to decrypt with");
|
|
687
687
|
}
|
|
688
|
-
// ../server/src/logging/PinoLogger.ts
|
|
689
|
-
/**
|
|
690
|
-
* Field paths scrubbed before a record is written. A backstop for accidents,
|
|
691
|
-
* NOT a licence to log objects: call sites are required not to log secrets in
|
|
692
|
-
* the first place (see `LogFields`). This catches the case where a whole object
|
|
693
|
-
* is spread into fields and happens to carry a credential.
|
|
694
|
-
*
|
|
695
|
-
* It matches by FIELD NAME, and only at the top level or one level deep (the
|
|
696
|
-
* `*.` entries). It will not catch personal data — an email nested in a payload
|
|
697
|
-
* sails straight through, and a log line reaches a collector that erasure can
|
|
698
|
-
* never reach. The nested `*.` set doesn't cover every top-level name.
|
|
699
|
-
*/
|
|
700
|
-
var REDACTED_PATHS = [
|
|
701
|
-
"token",
|
|
702
|
-
"sessionToken",
|
|
703
|
-
"refreshToken",
|
|
704
|
-
"apiKey",
|
|
705
|
-
"api_key",
|
|
706
|
-
"password",
|
|
707
|
-
"authorization",
|
|
708
|
-
"Authorization",
|
|
709
|
-
"cookie",
|
|
710
|
-
"secret",
|
|
711
|
-
"*.secret",
|
|
712
|
-
"*.authorization",
|
|
713
|
-
"*.Authorization",
|
|
714
|
-
"*.token",
|
|
715
|
-
"*.sessionToken",
|
|
716
|
-
"*.refreshToken",
|
|
717
|
-
"*.apiKey",
|
|
718
|
-
"*.password"
|
|
719
|
-
];
|
|
720
|
-
/**
|
|
721
|
-
* Minimal `ILogger` over `console.*`, used when pino isn't installed. Renders
|
|
722
|
-
* as `LEVEL message {fields}` — greppable, and honest about not being
|
|
723
|
-
* machine-parseable. `child` fields merge eagerly so correlation still works.
|
|
724
|
-
*/
|
|
725
|
-
var ConsoleLogger = class ConsoleLogger {
|
|
726
|
-
bound;
|
|
727
|
-
minLevel;
|
|
728
|
-
constructor(bound = {}, minLevel = "info") {
|
|
729
|
-
this.bound = bound;
|
|
730
|
-
this.minLevel = minLevel;
|
|
731
|
-
}
|
|
732
|
-
static ORDER = {
|
|
733
|
-
debug: 10,
|
|
734
|
-
info: 20,
|
|
735
|
-
warn: 30,
|
|
736
|
-
error: 40
|
|
737
|
-
};
|
|
738
|
-
write(level, message, fields) {
|
|
739
|
-
if (ConsoleLogger.ORDER[level] < ConsoleLogger.ORDER[this.minLevel]) return;
|
|
740
|
-
const merged = {
|
|
741
|
-
...this.bound,
|
|
742
|
-
...fields
|
|
743
|
-
};
|
|
744
|
-
const suffix = Object.keys(merged).length > 0 ? ` ${safeStringify(merged)}` : "";
|
|
745
|
-
const line = `${level.toUpperCase()} ${message}${suffix}`;
|
|
746
|
-
if (level === "error") console.error(line);
|
|
747
|
-
else if (level === "warn") console.warn(line);
|
|
748
|
-
else console.info(line);
|
|
749
|
-
}
|
|
750
|
-
debug(message, fields) {
|
|
751
|
-
this.write("debug", message, fields);
|
|
752
|
-
}
|
|
753
|
-
info(message, fields) {
|
|
754
|
-
this.write("info", message, fields);
|
|
755
|
-
}
|
|
756
|
-
warn(message, fields) {
|
|
757
|
-
this.write("warn", message, fields);
|
|
758
|
-
}
|
|
759
|
-
error(message, fields) {
|
|
760
|
-
this.write("error", message, fields);
|
|
761
|
-
}
|
|
762
|
-
child(fields) {
|
|
763
|
-
return new ConsoleLogger({
|
|
764
|
-
...this.bound,
|
|
765
|
-
...fields
|
|
766
|
-
}, this.minLevel);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
/** Fields can hold anything, including cycles. Never let rendering throw. */
|
|
770
|
-
function safeStringify(value) {
|
|
771
|
-
try {
|
|
772
|
-
return JSON.stringify(value) ?? String(value);
|
|
773
|
-
} catch {
|
|
774
|
-
return "[unserializable]";
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
var PinoLogger = class PinoLogger {
|
|
778
|
-
pino;
|
|
779
|
-
constructor(pino) {
|
|
780
|
-
this.pino = pino;
|
|
781
|
-
}
|
|
782
|
-
debug(message, fields) {
|
|
783
|
-
try {
|
|
784
|
-
this.pino.debug(fields ?? {}, message);
|
|
785
|
-
} catch {}
|
|
786
|
-
}
|
|
787
|
-
info(message, fields) {
|
|
788
|
-
try {
|
|
789
|
-
this.pino.info(fields ?? {}, message);
|
|
790
|
-
} catch {}
|
|
791
|
-
}
|
|
792
|
-
warn(message, fields) {
|
|
793
|
-
try {
|
|
794
|
-
this.pino.warn(fields ?? {}, message);
|
|
795
|
-
} catch {}
|
|
796
|
-
}
|
|
797
|
-
error(message, fields) {
|
|
798
|
-
try {
|
|
799
|
-
this.pino.error(fields ?? {}, message);
|
|
800
|
-
} catch {}
|
|
801
|
-
}
|
|
802
|
-
child(fields) {
|
|
803
|
-
try {
|
|
804
|
-
return new PinoLogger(this.pino.child(fields));
|
|
805
|
-
} catch {
|
|
806
|
-
return this;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
/** Build the app's root logger. Never throws, never returns `null`. */
|
|
811
|
-
async function createLogger(opts = {}) {
|
|
812
|
-
const level = opts.level ?? "info";
|
|
813
|
-
try {
|
|
814
|
-
const factory = await loadPinoFactory();
|
|
815
|
-
if (!factory) return new ConsoleLogger(opts.base ?? {}, level);
|
|
816
|
-
return new PinoLogger(factory({
|
|
817
|
-
level,
|
|
818
|
-
base: opts.base,
|
|
819
|
-
redact: {
|
|
820
|
-
paths: REDACTED_PATHS,
|
|
821
|
-
censor: "[redacted]"
|
|
822
|
-
},
|
|
823
|
-
transport: opts.pretty ? {
|
|
824
|
-
target: "pino-pretty",
|
|
825
|
-
options: {
|
|
826
|
-
colorize: true,
|
|
827
|
-
ignore: "pid,hostname"
|
|
828
|
-
}
|
|
829
|
-
} : void 0
|
|
830
|
-
}));
|
|
831
|
-
} catch (err) {
|
|
832
|
-
console.warn(`[Logger] pino was found but could not be initialized; falling back to console logging. ${String(err)}`);
|
|
833
|
-
return new ConsoleLogger(opts.base ?? {}, level);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
/**
|
|
837
|
-
* Load pino's factory, or `null` when it isn't installed.
|
|
838
|
-
*
|
|
839
|
-
* Don't inline the specifier. A literal `import('pino')` is statically
|
|
840
|
-
* analyzable, so Vite applied browser-field mapping to this server build and
|
|
841
|
-
* resolved it to pino's `server_false` browser shim — a stub whose factory
|
|
842
|
-
* throws, turning "use pino" into a silent fall back to the console. Computing
|
|
843
|
-
* the specifier defeats that and leaves the import to Node at runtime.
|
|
844
|
-
* `@vite-ignore` alone was NOT enough: it silenced the warning and the rewrite
|
|
845
|
-
* still happened.
|
|
846
|
-
*/
|
|
847
|
-
async function loadPinoFactory() {
|
|
848
|
-
const specifier = "pino";
|
|
849
|
-
try {
|
|
850
|
-
const mod = await import(
|
|
851
|
-
/* @vite-ignore */
|
|
852
|
-
specifier
|
|
853
|
-
);
|
|
854
|
-
const factory = mod.default ?? mod;
|
|
855
|
-
return typeof factory === "function" ? factory : null;
|
|
856
|
-
} catch {
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
688
|
// ../server/src/definitions/definition-service.ts
|
|
861
689
|
/**
|
|
862
690
|
* Orchestrates writes spanning IDataProvider + IStorageProvider. Application
|
|
@@ -2881,9 +2709,9 @@ var LocalDefinitionStore = class LocalDefinitionStore {
|
|
|
2881
2709
|
// ../providers/local/src/data/LocalShareLinkStore.ts
|
|
2882
2710
|
var empty$2 = () => ({ links: {} });
|
|
2883
2711
|
/**
|
|
2884
|
-
* `tryIncrementSolveCount`
|
|
2885
|
-
*
|
|
2886
|
-
*
|
|
2712
|
+
* Writes queue on `withFileLock`, so `tryIncrementSolveCount` checks the cap and
|
|
2713
|
+
* counts as one step, but only within this process: two processes sharing
|
|
2714
|
+
* `share-links.json` can both admit the last solve under the cap.
|
|
2887
2715
|
*/
|
|
2888
2716
|
var LocalShareLinkStore = class LocalShareLinkStore {
|
|
2889
2717
|
definitionProvider;
|
|
@@ -3352,11 +3180,6 @@ var LocalDataProvider = class LocalDataProvider {
|
|
|
3352
3180
|
await this.userData.deleteUser(userId);
|
|
3353
3181
|
} catch {}
|
|
3354
3182
|
await this.apiTokens.eraseUser(ctx, userId);
|
|
3355
|
-
for (let i = 0; i < 100; i++) {
|
|
3356
|
-
const membership = await this.orgs.findUserMembership(ctx, userId);
|
|
3357
|
-
if (!membership) break;
|
|
3358
|
-
await this.orgs.removeOrgMember(ctx, membership.org.id, userId);
|
|
3359
|
-
}
|
|
3360
3183
|
await this.erasable.orgs.eraseUser(userId);
|
|
3361
3184
|
await this.erasable.definitions.eraseUser(userId);
|
|
3362
3185
|
await this.erasable.invites.eraseUser(userId, opts?.email);
|
|
@@ -3486,6 +3309,13 @@ var LocalStorageProvider = class LocalStorageProvider {
|
|
|
3486
3309
|
};
|
|
3487
3310
|
// ../providers/supabase/src/storage/SupabaseStorageProvider.ts
|
|
3488
3311
|
var LIST_PAGE_SIZE = 1e3;
|
|
3312
|
+
/**
|
|
3313
|
+
* Supabase Storage refuses to upload a `..` key but answers a read of one with
|
|
3314
|
+
* not-found. Refusing here gives every method the local store's 400.
|
|
3315
|
+
*/
|
|
3316
|
+
function assertNoClimb(storagePath) {
|
|
3317
|
+
if (storagePath.split("/").includes("..")) throw new ProviderError(`Path escapes the store: ${JSON.stringify(storagePath)}`, 400);
|
|
3318
|
+
}
|
|
3489
3319
|
var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
3490
3320
|
client;
|
|
3491
3321
|
publicBucket;
|
|
@@ -3526,6 +3356,7 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
|
3526
3356
|
return classifyAssetPath(storagePath)?.class.visibility === "public" ? this.publicBucket : this.privateBucket;
|
|
3527
3357
|
}
|
|
3528
3358
|
async get(storagePath) {
|
|
3359
|
+
assertNoClimb(storagePath);
|
|
3529
3360
|
const bucket = this.bucketFor(storagePath);
|
|
3530
3361
|
const { data, error } = await this.client.storage.from(bucket).download(storagePath);
|
|
3531
3362
|
if (error) {
|
|
@@ -3537,6 +3368,7 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
|
3537
3368
|
return new Uint8Array(buffer);
|
|
3538
3369
|
}
|
|
3539
3370
|
async put(storagePath, data, contentType) {
|
|
3371
|
+
assertNoClimb(storagePath);
|
|
3540
3372
|
const transcoded = await transcodeImageIfNeeded(data, contentType, storagePath);
|
|
3541
3373
|
const bucket = this.bucketFor(transcoded.path);
|
|
3542
3374
|
const { error } = await this.client.storage.from(bucket).upload(transcoded.path, transcoded.data, {
|
|
@@ -3548,11 +3380,13 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
|
|
|
3548
3380
|
return transcoded.path;
|
|
3549
3381
|
}
|
|
3550
3382
|
async delete(storagePath) {
|
|
3383
|
+
assertNoClimb(storagePath);
|
|
3551
3384
|
const bucket = this.bucketFor(storagePath);
|
|
3552
3385
|
const { error } = await this.client.storage.from(bucket).remove([storagePath]);
|
|
3553
3386
|
if (error) throw error;
|
|
3554
3387
|
}
|
|
3555
3388
|
async deletePrefix(prefix) {
|
|
3389
|
+
assertNoClimb(prefix);
|
|
3556
3390
|
if (trimTrailing(prefix, "/") === "") throw new ProviderError(`Refusing to delete the whole store: prefix ${JSON.stringify(prefix)}`, 400);
|
|
3557
3391
|
await Promise.all([this.deletePrefixInBucket(this.publicBucket, prefix), this.deletePrefixInBucket(this.privateBucket, prefix)]);
|
|
3558
3392
|
}
|
|
@@ -5211,7 +5045,7 @@ function tokenToRow(t) {
|
|
|
5211
5045
|
* whenever a migration is added — `migration-head.test.ts` asserts it
|
|
5212
5046
|
* matches the migrations directory, so CI catches drift.
|
|
5213
5047
|
*/
|
|
5214
|
-
var EXPECTED_MIGRATION_HEAD = "
|
|
5048
|
+
var EXPECTED_MIGRATION_HEAD = "20261108140000";
|
|
5215
5049
|
// ../providers/supabase/src/data/client.ts
|
|
5216
5050
|
/** Default schema every engine store targets. */
|
|
5217
5051
|
var DEFAULT_SCHEMA = "selva";
|
|
@@ -5620,7 +5454,7 @@ function mapError$1(e) {
|
|
|
5620
5454
|
* `user_profiles` is too coarse for cross-user reads, so `assertCanManagePermissions` /
|
|
5621
5455
|
* `assertCanReadPermissions` enforce the auth boundary here instead.
|
|
5622
5456
|
*
|
|
5623
|
-
* `user_profiles.disabled` mirrors `
|
|
5457
|
+
* `user_profiles.disabled` mirrors the user's ban and `app_metadata.disabled` via
|
|
5624
5458
|
* the `sync_auth_user_disabled` trigger, so admin-count queries can exclude
|
|
5625
5459
|
* disabled admins with a single indexed query instead of cross-referencing
|
|
5626
5460
|
* the auth admin API per candidate.
|
|
@@ -5850,7 +5684,7 @@ var SupabaseDataProvider = class SupabaseDataProvider {
|
|
|
5850
5684
|
*/
|
|
5851
5685
|
async onUserDeleted(_ctx, userId, opts) {
|
|
5852
5686
|
const client = this.clients.serviceClient;
|
|
5853
|
-
const email = opts?.email;
|
|
5687
|
+
const email = opts?.email?.trim().toLowerCase();
|
|
5854
5688
|
const deletedActions = await client.from("audit_events").delete().eq("actor_id", userId);
|
|
5855
5689
|
if (deletedActions.error) throw new ProviderError(`Failed to erase audit_events for user: ${deletedActions.error.message}`, 500);
|
|
5856
5690
|
const tombstoned = await client.from("solve_metrics").update({ actor_id: ERASED_ACTOR_ID }).eq("actor_id", userId);
|
|
@@ -6238,7 +6072,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6238
6072
|
if (this.tokenVerification === "strict" || isSymmetricJwt(token)) return this.verifyViaGetUser(token);
|
|
6239
6073
|
const claims = await this.getClaimsOrNull(token);
|
|
6240
6074
|
if (!claims) return null;
|
|
6241
|
-
if (claims.
|
|
6075
|
+
if (claims.app_metadata?.disabled === true) return null;
|
|
6242
6076
|
const sessionId = typeof claims.session_id === "string" ? claims.session_id : claims.sub;
|
|
6243
6077
|
if (this.shouldRevalidate(sessionId)) {
|
|
6244
6078
|
const fresh = await this.verifyViaGetUser(token);
|
|
@@ -6260,7 +6094,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6260
6094
|
async verifyViaGetUser(token) {
|
|
6261
6095
|
const { data, error } = await this.anon.auth.getUser(token);
|
|
6262
6096
|
if (error || !data.user) return null;
|
|
6263
|
-
if (data.user
|
|
6097
|
+
if (isDisabled(data.user)) return null;
|
|
6264
6098
|
return this.hydrate(data.user);
|
|
6265
6099
|
}
|
|
6266
6100
|
/** Local JWT verification. Returns the claims, or null if invalid/expired. */
|
|
@@ -6326,11 +6160,13 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6326
6160
|
async disableUser(id) {
|
|
6327
6161
|
const { data: existing, error: fetchError } = await this.admin.auth.admin.getUserById(id);
|
|
6328
6162
|
if (fetchError || !existing.user) return "not_found";
|
|
6329
|
-
const
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6163
|
+
const { error } = await this.admin.auth.admin.updateUserById(id, {
|
|
6164
|
+
ban_duration: BAN_FOREVER,
|
|
6165
|
+
app_metadata: {
|
|
6166
|
+
...existing.user.app_metadata ?? {},
|
|
6167
|
+
disabled: true
|
|
6168
|
+
}
|
|
6169
|
+
});
|
|
6334
6170
|
if (error) {
|
|
6335
6171
|
const e = error;
|
|
6336
6172
|
if (e.status === 404 || /not.?found/i.test(e.message ?? "")) return "not_found";
|
|
@@ -6354,7 +6190,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6354
6190
|
password
|
|
6355
6191
|
});
|
|
6356
6192
|
if (error || !data.user || !data.session) return null;
|
|
6357
|
-
if (data.user
|
|
6193
|
+
if (isDisabled(data.user)) return null;
|
|
6358
6194
|
return {
|
|
6359
6195
|
user: this.hydrate(data.user),
|
|
6360
6196
|
sessionToken: data.session.access_token
|
|
@@ -6367,7 +6203,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6367
6203
|
email: user.email ?? void 0,
|
|
6368
6204
|
createdAt: user.created_at ?? void 0,
|
|
6369
6205
|
lastLoginAt: user.last_sign_in_at ?? void 0,
|
|
6370
|
-
disabled: user
|
|
6206
|
+
disabled: isDisabled(user),
|
|
6371
6207
|
metadata: user.user_metadata
|
|
6372
6208
|
};
|
|
6373
6209
|
}
|
|
@@ -6463,7 +6299,7 @@ var SupabaseOAuthAuth = class {
|
|
|
6463
6299
|
async exchangeOAuthCode(code) {
|
|
6464
6300
|
const { data, error } = await this.anon.auth.exchangeCodeForSession(code);
|
|
6465
6301
|
if (error || !data.user || !data.session) return null;
|
|
6466
|
-
if (data.user
|
|
6302
|
+
if (isDisabled(data.user)) return null;
|
|
6467
6303
|
return {
|
|
6468
6304
|
user: this.hydrate(data.user),
|
|
6469
6305
|
sessionToken: data.session.access_token,
|
|
@@ -6471,6 +6307,12 @@ var SupabaseOAuthAuth = class {
|
|
|
6471
6307
|
};
|
|
6472
6308
|
}
|
|
6473
6309
|
};
|
|
6310
|
+
var BAN_FOREVER = "876000h";
|
|
6311
|
+
/** Disabled by an admin: flagged in app_metadata or banned. Never `user_metadata`, which the user writes. */
|
|
6312
|
+
function isDisabled(user) {
|
|
6313
|
+
if (user.app_metadata?.disabled === true) return true;
|
|
6314
|
+
return user.banned_until ? Date.parse(user.banned_until) > Date.now() : false;
|
|
6315
|
+
}
|
|
6474
6316
|
/**
|
|
6475
6317
|
* Supabase-backed `ISessionRefresh`. `refreshSession` uses the anon client —
|
|
6476
6318
|
* a refresh token authenticates itself. `revokeSession` uses the service-role
|
|
@@ -6488,7 +6330,7 @@ var SupabaseSessionRefresh = class {
|
|
|
6488
6330
|
async refreshSession(refreshToken) {
|
|
6489
6331
|
const { data, error } = await this.anon.auth.refreshSession({ refresh_token: refreshToken });
|
|
6490
6332
|
if (error || !data.session) return null;
|
|
6491
|
-
if (data.user
|
|
6333
|
+
if (data.user !== null && isDisabled(data.user)) return null;
|
|
6492
6334
|
return {
|
|
6493
6335
|
sessionToken: data.session.access_token,
|
|
6494
6336
|
refreshToken: data.session.refresh_token
|
|
@@ -6558,7 +6400,7 @@ var SupabaseEmailLinkAuth = class {
|
|
|
6558
6400
|
type
|
|
6559
6401
|
});
|
|
6560
6402
|
if (error || !data.user || !data.session) return null;
|
|
6561
|
-
if (data.user
|
|
6403
|
+
if (isDisabled(data.user)) return null;
|
|
6562
6404
|
return {
|
|
6563
6405
|
user: this.hydrate(data.user),
|
|
6564
6406
|
sessionToken: data.session.access_token,
|
|
@@ -6673,14 +6515,28 @@ function createAllowlistStore(filePath) {
|
|
|
6673
6515
|
if (dirty) await writeFile$1(filePath, file);
|
|
6674
6516
|
});
|
|
6675
6517
|
},
|
|
6518
|
+
claim(id, upn, opts) {
|
|
6519
|
+
return locked(async () => {
|
|
6520
|
+
const file = await readFile(filePath);
|
|
6521
|
+
const user = file.users.find((u) => u.id === id);
|
|
6522
|
+
if (!user) return null;
|
|
6523
|
+
const key = norm(upn);
|
|
6524
|
+
if (!user.claimedByUpn || opts?.replace && user.claimedByUpn !== key) {
|
|
6525
|
+
user.claimedByUpn = key;
|
|
6526
|
+
await writeFile$1(filePath, file);
|
|
6527
|
+
}
|
|
6528
|
+
return user.claimedByUpn;
|
|
6529
|
+
});
|
|
6530
|
+
},
|
|
6676
6531
|
rebindUpn(id, upn) {
|
|
6677
6532
|
return locked(async () => {
|
|
6678
6533
|
const file = await readFile(filePath);
|
|
6679
6534
|
const key = norm(upn);
|
|
6680
6535
|
const user = file.users.find((u) => u.id === id);
|
|
6681
|
-
if (!user || user.upn === key) return;
|
|
6536
|
+
if (!user || user.upn === key && user.claimedByUpn === key) return;
|
|
6682
6537
|
if (file.users.some((u) => u.id !== id && u.upn === key)) return;
|
|
6683
6538
|
user.upn = key;
|
|
6539
|
+
user.claimedByUpn = key;
|
|
6684
6540
|
await writeFile$1(filePath, file);
|
|
6685
6541
|
});
|
|
6686
6542
|
},
|
|
@@ -6744,6 +6600,8 @@ var HeaderProxyAuth = class {
|
|
|
6744
6600
|
bootstrapPolicy;
|
|
6745
6601
|
missingHeadersWarned = false;
|
|
6746
6602
|
duplicateUpnWarned = false;
|
|
6603
|
+
duplicateEmailWarned = false;
|
|
6604
|
+
claimWriteWarned = false;
|
|
6747
6605
|
constructor(users, headers, bootstrapPolicy, logger = new NoopLogger()) {
|
|
6748
6606
|
this.users = users;
|
|
6749
6607
|
this.headers = headers;
|
|
@@ -6769,6 +6627,43 @@ var HeaderProxyAuth = class {
|
|
|
6769
6627
|
hasNoIdentityHeaders(headers) {
|
|
6770
6628
|
return !headers.get(this.headers.upn) && !headers.get(this.headers.email) && !headers.get(this.headers.displayName);
|
|
6771
6629
|
}
|
|
6630
|
+
/**
|
|
6631
|
+
* The email header, or undefined when it carries more than one value. Email
|
|
6632
|
+
* can select a row through the fallback, so a joined value (a proxy appending
|
|
6633
|
+
* its copy to the client's) is the same spoofing signal as on the UPN.
|
|
6634
|
+
*/
|
|
6635
|
+
singleValuedEmail(headers) {
|
|
6636
|
+
const email = headers.get(this.headers.email)?.trim() || void 0;
|
|
6637
|
+
if (!email?.includes(",")) return email;
|
|
6638
|
+
if (!this.duplicateEmailWarned) {
|
|
6639
|
+
this.duplicateEmailWarned = true;
|
|
6640
|
+
this.logger.warn("Multiple values arrived in the email identity header on one request. The forward-auth proxy is not stripping client-supplied copies of the trusted headers. Ignoring the email header. Strip the configured headers at site scope, above forward_auth — see the @selvajs/header-auth-provider README.", {
|
|
6641
|
+
component: "HeaderAuth",
|
|
6642
|
+
header: this.headers.email
|
|
6643
|
+
});
|
|
6644
|
+
}
|
|
6645
|
+
}
|
|
6646
|
+
/**
|
|
6647
|
+
* Claims the row, or returns null when the allowlist can't be written. A failed
|
|
6648
|
+
* claim must not fail the sign-in: that would lock every unclaimed user out of
|
|
6649
|
+
* a deployment whose allowlist is read-only or has the wrong owner. The row
|
|
6650
|
+
* then stays unclaimed, and the email fallback still admits any UPN to it.
|
|
6651
|
+
*/
|
|
6652
|
+
async tryClaim(id, upn, replace) {
|
|
6653
|
+
try {
|
|
6654
|
+
return await this.users.claim(id, upn, { replace });
|
|
6655
|
+
} catch (err) {
|
|
6656
|
+
if (!this.claimWriteWarned) {
|
|
6657
|
+
this.claimWriteWarned = true;
|
|
6658
|
+
this.logger.warn("Could not record which UPN signed in to an allowlisted user: the allowlist file is not writable. Sign-in continues, but until it is writable the email header can still select any user whose UPN is an address.", {
|
|
6659
|
+
component: "HeaderAuth",
|
|
6660
|
+
userId: id,
|
|
6661
|
+
code: err.code
|
|
6662
|
+
});
|
|
6663
|
+
}
|
|
6664
|
+
return null;
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6772
6667
|
async identifyFromHeaders(headers) {
|
|
6773
6668
|
const upn = headers.get(this.headers.upn);
|
|
6774
6669
|
if (!upn || !upn.trim()) {
|
|
@@ -6795,9 +6690,10 @@ var HeaderProxyAuth = class {
|
|
|
6795
6690
|
}
|
|
6796
6691
|
return null;
|
|
6797
6692
|
}
|
|
6798
|
-
const email =
|
|
6693
|
+
const email = this.singleValuedEmail(headers);
|
|
6799
6694
|
const displayName = headers.get(this.headers.displayName)?.trim() || void 0;
|
|
6800
6695
|
let entry = await this.users.findByUpn(upn);
|
|
6696
|
+
let matchedByUpn = entry !== null;
|
|
6801
6697
|
if (!entry && email) {
|
|
6802
6698
|
const byEmail = await this.users.findByEmail(email);
|
|
6803
6699
|
if (byEmail) entry = byEmail;
|
|
@@ -6806,13 +6702,26 @@ var HeaderProxyAuth = class {
|
|
|
6806
6702
|
if (await this.bootstrapPolicy({
|
|
6807
6703
|
upn,
|
|
6808
6704
|
email
|
|
6809
|
-
}))
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6705
|
+
})) {
|
|
6706
|
+
try {
|
|
6707
|
+
entry = await this.users.createUser(upn);
|
|
6708
|
+
} catch {
|
|
6709
|
+
entry = await this.users.findByUpn(upn);
|
|
6710
|
+
}
|
|
6711
|
+
matchedByUpn = entry !== null;
|
|
6813
6712
|
}
|
|
6814
6713
|
}
|
|
6815
6714
|
if (!entry || entry.disabled) return null;
|
|
6715
|
+
const presented = upn.trim().toLowerCase();
|
|
6716
|
+
let claimant = entry.claimedByUpn;
|
|
6717
|
+
if (!claimant || matchedByUpn && claimant !== presented) claimant = await this.tryClaim(entry.id, upn, matchedByUpn) ?? void 0;
|
|
6718
|
+
if (claimant && claimant !== presented) {
|
|
6719
|
+
this.logger.warn("Refused a sign-in to an allowlisted user already claimed by a different UPN. If that user's UPN changed in the directory, set upn on their row in the allowlist file to the new one; their next sign-in claims it.", {
|
|
6720
|
+
component: "HeaderAuth",
|
|
6721
|
+
userId: entry.id
|
|
6722
|
+
});
|
|
6723
|
+
return null;
|
|
6724
|
+
}
|
|
6816
6725
|
if (email && entry.email !== email || displayName && entry.displayName !== displayName) {
|
|
6817
6726
|
await this.users.syncFromHeaders(entry.id, {
|
|
6818
6727
|
email,
|