@selvajs/selva 4.20.1-beta.1 → 4.20.1-beta.3

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.
Files changed (73) hide show
  1. package/build/adapter-node.js +1 -1
  2. package/build/client/_app/immutable/chunks/{D-SwRD80.js → D-uUm_OB.js} +43 -43
  3. package/build/client/_app/immutable/chunks/D-uUm_OB.js.br +0 -0
  4. package/build/client/_app/immutable/chunks/{D-SwRD80.js.gz → D-uUm_OB.js.gz} +0 -0
  5. package/build/client/_app/immutable/chunks/D84F7w9g.js +1 -0
  6. package/build/client/_app/immutable/chunks/D84F7w9g.js.br +1 -0
  7. package/build/client/_app/immutable/chunks/D84F7w9g.js.gz +0 -0
  8. package/build/client/_app/immutable/entry/{app.hg2qyLJU.js → app.BpT6WkO1.js} +2 -2
  9. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.br +0 -0
  10. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.gz +0 -0
  11. package/build/client/_app/immutable/nodes/21.BkNlRItr.js +1 -0
  12. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.br +0 -0
  13. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.gz +0 -0
  14. package/build/client/_app/version.json +1 -1
  15. package/build/client/_app/version.json.br +0 -0
  16. package/build/client/_app/version.json.gz +0 -0
  17. package/build/server/.vite/manifest.json +9 -2
  18. package/build/server/chunks/access.js +0 -3
  19. package/build/server/chunks/access.js.map +1 -1
  20. package/build/server/chunks/definitions.js +178 -1
  21. package/build/server/chunks/definitions.js.map +1 -1
  22. package/build/server/chunks/handlers.js +4 -5
  23. package/build/server/chunks/handlers.js.map +1 -1
  24. package/build/server/chunks/instance.js +3 -3
  25. package/build/server/chunks/internal.js +1 -1
  26. package/build/server/chunks/package.js +1 -1
  27. package/build/server/chunks/package.js.map +1 -1
  28. package/build/server/chunks/providers.server.js +112 -189
  29. package/build/server/chunks/providers.server.js.map +1 -1
  30. package/build/server/chunks/registry.js +3 -3
  31. package/build/server/chunks/registry.js.map +1 -1
  32. package/build/server/chunks/resolve.server.js +1 -1
  33. package/build/server/chunks/server-config-write.js +13 -1
  34. package/build/server/chunks/server-config-write.js.map +1 -1
  35. package/build/server/chunks/solve.server.js +8 -3
  36. package/build/server/chunks/solve.server.js.map +1 -1
  37. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +30 -48
  38. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js.map +1 -1
  39. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +3 -2
  40. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js.map +1 -1
  41. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +3 -2
  42. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js.map +1 -1
  43. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +3 -2
  44. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js.map +1 -1
  45. package/build/server/entries/endpoints/api/admin/users/_server.ts.js +6 -2
  46. package/build/server/entries/endpoints/api/admin/users/_server.ts.js.map +1 -1
  47. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +8 -8
  48. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js.map +1 -1
  49. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +1 -1
  50. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +1 -1
  51. package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
  52. package/build/server/entries/hooks.server.js +13 -1
  53. package/build/server/entries/hooks.server.js.map +1 -1
  54. package/build/server/entries/pages/accept-invite/_page.server.ts.js +19 -1
  55. package/build/server/entries/pages/accept-invite/_page.server.ts.js.map +1 -1
  56. package/build/server/entries/pages/library/_guid_/_page.server.ts.js +16 -3
  57. package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
  58. package/build/server/entries/pages/library/_guid_/_page.svelte.js +132 -89
  59. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  60. package/build/server/manifest-full.js +1 -1
  61. package/build/server/manifest.js +1 -1
  62. package/build/server/nodes/21.js +1 -1
  63. package/build/server/server.js +1 -1
  64. package/package.json +10 -10
  65. package/build/client/_app/immutable/chunks/D-SwRD80.js.br +0 -0
  66. package/build/client/_app/immutable/chunks/Dvq2vJj6.js +0 -1
  67. package/build/client/_app/immutable/chunks/Dvq2vJj6.js.br +0 -1
  68. package/build/client/_app/immutable/chunks/Dvq2vJj6.js.gz +0 -0
  69. package/build/client/_app/immutable/entry/app.hg2qyLJU.js.br +0 -0
  70. package/build/client/_app/immutable/entry/app.hg2qyLJU.js.gz +0 -0
  71. package/build/client/_app/immutable/nodes/21.gGT7QEb1.js +0 -1
  72. package/build/client/_app/immutable/nodes/21.gGT7QEb1.js.br +0 -1
  73. 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 = "__sveltekit_1wljyvz";
216
+ const global = "__sveltekit_8e03ud";
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 = "__sveltekit_1wljyvz";
1446
+ const global = "__sveltekit_8e03ud";
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("1794047538840")}`];
1470
+ const properties = [`base: ${base_expression}`, `version: ${s("1794066792698")}`];
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", "1794047538840");
2366
+ response.headers.set("x-sveltekit-version", "1794066792698");
2367
2367
  return response;
2368
2368
  }
2369
2369
  /**
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@selvajs/selva",
3
- version: "4.20.1-beta.1",
3
+ version: "4.20.1-beta.3",
4
4
  description: "Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.",
5
5
  license: "MIT",
6
6
  author: "VektorNode",
@@ -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\",\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":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.20.1-beta.3\",\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";
@@ -206,7 +206,10 @@ function prefix(id) {
206
206
  * `classifyAssetPath` / `ASSET_CLASSES` decide visibility from these prefixes.
207
207
  */
208
208
  var orgPaths = {
209
- asset: (id, kind) => `${prefix(id)}branding/${kind}.webp`,
209
+ asset: (id, kind) => {
210
+ assertSafeKey(kind, "assetKind");
211
+ return `${prefix(id)}branding/${kind}.webp`;
212
+ },
210
213
  prefix
211
214
  };
212
215
  // ../platform/src/permissions/guards.ts
@@ -682,178 +685,6 @@ function decryptWithKeys(envelope, keys, aad) {
682
685
  }
683
686
  throw lastError ?? /* @__PURE__ */ new Error("No key to decrypt with");
684
687
  }
685
- // ../server/src/logging/PinoLogger.ts
686
- /**
687
- * Field paths scrubbed before a record is written. A backstop for accidents,
688
- * NOT a licence to log objects: call sites are required not to log secrets in
689
- * the first place (see `LogFields`). This catches the case where a whole object
690
- * is spread into fields and happens to carry a credential.
691
- *
692
- * It matches by FIELD NAME, and only at the top level or one level deep (the
693
- * `*.` entries). It will not catch personal data — an email nested in a payload
694
- * sails straight through, and a log line reaches a collector that erasure can
695
- * never reach. The nested `*.` set doesn't cover every top-level name.
696
- */
697
- var REDACTED_PATHS = [
698
- "token",
699
- "sessionToken",
700
- "refreshToken",
701
- "apiKey",
702
- "api_key",
703
- "password",
704
- "authorization",
705
- "Authorization",
706
- "cookie",
707
- "secret",
708
- "*.secret",
709
- "*.authorization",
710
- "*.Authorization",
711
- "*.token",
712
- "*.sessionToken",
713
- "*.refreshToken",
714
- "*.apiKey",
715
- "*.password"
716
- ];
717
- /**
718
- * Minimal `ILogger` over `console.*`, used when pino isn't installed. Renders
719
- * as `LEVEL message {fields}` — greppable, and honest about not being
720
- * machine-parseable. `child` fields merge eagerly so correlation still works.
721
- */
722
- var ConsoleLogger = class ConsoleLogger {
723
- bound;
724
- minLevel;
725
- constructor(bound = {}, minLevel = "info") {
726
- this.bound = bound;
727
- this.minLevel = minLevel;
728
- }
729
- static ORDER = {
730
- debug: 10,
731
- info: 20,
732
- warn: 30,
733
- error: 40
734
- };
735
- write(level, message, fields) {
736
- if (ConsoleLogger.ORDER[level] < ConsoleLogger.ORDER[this.minLevel]) return;
737
- const merged = {
738
- ...this.bound,
739
- ...fields
740
- };
741
- const suffix = Object.keys(merged).length > 0 ? ` ${safeStringify(merged)}` : "";
742
- const line = `${level.toUpperCase()} ${message}${suffix}`;
743
- if (level === "error") console.error(line);
744
- else if (level === "warn") console.warn(line);
745
- else console.info(line);
746
- }
747
- debug(message, fields) {
748
- this.write("debug", message, fields);
749
- }
750
- info(message, fields) {
751
- this.write("info", message, fields);
752
- }
753
- warn(message, fields) {
754
- this.write("warn", message, fields);
755
- }
756
- error(message, fields) {
757
- this.write("error", message, fields);
758
- }
759
- child(fields) {
760
- return new ConsoleLogger({
761
- ...this.bound,
762
- ...fields
763
- }, this.minLevel);
764
- }
765
- };
766
- /** Fields can hold anything, including cycles. Never let rendering throw. */
767
- function safeStringify(value) {
768
- try {
769
- return JSON.stringify(value) ?? String(value);
770
- } catch {
771
- return "[unserializable]";
772
- }
773
- }
774
- var PinoLogger = class PinoLogger {
775
- pino;
776
- constructor(pino) {
777
- this.pino = pino;
778
- }
779
- debug(message, fields) {
780
- try {
781
- this.pino.debug(fields ?? {}, message);
782
- } catch {}
783
- }
784
- info(message, fields) {
785
- try {
786
- this.pino.info(fields ?? {}, message);
787
- } catch {}
788
- }
789
- warn(message, fields) {
790
- try {
791
- this.pino.warn(fields ?? {}, message);
792
- } catch {}
793
- }
794
- error(message, fields) {
795
- try {
796
- this.pino.error(fields ?? {}, message);
797
- } catch {}
798
- }
799
- child(fields) {
800
- try {
801
- return new PinoLogger(this.pino.child(fields));
802
- } catch {
803
- return this;
804
- }
805
- }
806
- };
807
- /** Build the app's root logger. Never throws, never returns `null`. */
808
- async function createLogger(opts = {}) {
809
- const level = opts.level ?? "info";
810
- try {
811
- const factory = await loadPinoFactory();
812
- if (!factory) return new ConsoleLogger(opts.base ?? {}, level);
813
- return new PinoLogger(factory({
814
- level,
815
- base: opts.base,
816
- redact: {
817
- paths: REDACTED_PATHS,
818
- censor: "[redacted]"
819
- },
820
- transport: opts.pretty ? {
821
- target: "pino-pretty",
822
- options: {
823
- colorize: true,
824
- ignore: "pid,hostname"
825
- }
826
- } : void 0
827
- }));
828
- } catch (err) {
829
- console.warn(`[Logger] pino was found but could not be initialized; falling back to console logging. ${String(err)}`);
830
- return new ConsoleLogger(opts.base ?? {}, level);
831
- }
832
- }
833
- /**
834
- * Load pino's factory, or `null` when it isn't installed.
835
- *
836
- * Don't inline the specifier. A literal `import('pino')` is statically
837
- * analyzable, so Vite applied browser-field mapping to this server build and
838
- * resolved it to pino's `server_false` browser shim — a stub whose factory
839
- * throws, turning "use pino" into a silent fall back to the console. Computing
840
- * the specifier defeats that and leaves the import to Node at runtime.
841
- * `@vite-ignore` alone was NOT enough: it silenced the warning and the rewrite
842
- * still happened.
843
- */
844
- async function loadPinoFactory() {
845
- const specifier = "pino";
846
- try {
847
- const mod = await import(
848
- /* @vite-ignore */
849
- specifier
850
- );
851
- const factory = mod.default ?? mod;
852
- return typeof factory === "function" ? factory : null;
853
- } catch {
854
- return null;
855
- }
856
- }
857
688
  // ../server/src/definitions/definition-service.ts
858
689
  /**
859
690
  * Orchestrates writes spanning IDataProvider + IStorageProvider. Application
@@ -1593,6 +1424,17 @@ var LocalInviteStore = class LocalInviteStore {
1593
1424
  });
1594
1425
  return true;
1595
1426
  }
1427
+ async reopen(_ctx, id, userId) {
1428
+ return this.locked(async () => {
1429
+ const file = await this.load();
1430
+ const target = file.invites.find((i) => i.id === id);
1431
+ if (!target?.acceptedAt || target.acceptedByUserId !== userId) return false;
1432
+ delete target.acceptedAt;
1433
+ delete target.acceptedByUserId;
1434
+ await this.save(file);
1435
+ return true;
1436
+ });
1437
+ }
1596
1438
  async revoke(ctx, id) {
1597
1439
  const target = await this.locked(async () => {
1598
1440
  const file = await this.load();
@@ -2867,9 +2709,9 @@ var LocalDefinitionStore = class LocalDefinitionStore {
2867
2709
  // ../providers/local/src/data/LocalShareLinkStore.ts
2868
2710
  var empty$2 = () => ({ links: {} });
2869
2711
  /**
2870
- * `tryIncrementSolveCount` is race-sensitive: this store does a plain
2871
- * read-modify-write, fine at single-node scale. Postgres adapters use a true
2872
- * atomic UPDATE instead.
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.
2873
2715
  */
2874
2716
  var LocalShareLinkStore = class LocalShareLinkStore {
2875
2717
  definitionProvider;
@@ -3338,11 +3180,6 @@ var LocalDataProvider = class LocalDataProvider {
3338
3180
  await this.userData.deleteUser(userId);
3339
3181
  } catch {}
3340
3182
  await this.apiTokens.eraseUser(ctx, userId);
3341
- for (let i = 0; i < 100; i++) {
3342
- const membership = await this.orgs.findUserMembership(ctx, userId);
3343
- if (!membership) break;
3344
- await this.orgs.removeOrgMember(ctx, membership.org.id, userId);
3345
- }
3346
3183
  await this.erasable.orgs.eraseUser(userId);
3347
3184
  await this.erasable.definitions.eraseUser(userId);
3348
3185
  await this.erasable.invites.eraseUser(userId, opts?.email);
@@ -3472,6 +3309,13 @@ var LocalStorageProvider = class LocalStorageProvider {
3472
3309
  };
3473
3310
  // ../providers/supabase/src/storage/SupabaseStorageProvider.ts
3474
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
+ }
3475
3319
  var SupabaseStorageProvider = class SupabaseStorageProvider {
3476
3320
  client;
3477
3321
  publicBucket;
@@ -3512,6 +3356,7 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
3512
3356
  return classifyAssetPath(storagePath)?.class.visibility === "public" ? this.publicBucket : this.privateBucket;
3513
3357
  }
3514
3358
  async get(storagePath) {
3359
+ assertNoClimb(storagePath);
3515
3360
  const bucket = this.bucketFor(storagePath);
3516
3361
  const { data, error } = await this.client.storage.from(bucket).download(storagePath);
3517
3362
  if (error) {
@@ -3523,6 +3368,7 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
3523
3368
  return new Uint8Array(buffer);
3524
3369
  }
3525
3370
  async put(storagePath, data, contentType) {
3371
+ assertNoClimb(storagePath);
3526
3372
  const transcoded = await transcodeImageIfNeeded(data, contentType, storagePath);
3527
3373
  const bucket = this.bucketFor(transcoded.path);
3528
3374
  const { error } = await this.client.storage.from(bucket).upload(transcoded.path, transcoded.data, {
@@ -3534,11 +3380,13 @@ var SupabaseStorageProvider = class SupabaseStorageProvider {
3534
3380
  return transcoded.path;
3535
3381
  }
3536
3382
  async delete(storagePath) {
3383
+ assertNoClimb(storagePath);
3537
3384
  const bucket = this.bucketFor(storagePath);
3538
3385
  const { error } = await this.client.storage.from(bucket).remove([storagePath]);
3539
3386
  if (error) throw error;
3540
3387
  }
3541
3388
  async deletePrefix(prefix) {
3389
+ assertNoClimb(prefix);
3542
3390
  if (trimTrailing(prefix, "/") === "") throw new ProviderError(`Refusing to delete the whole store: prefix ${JSON.stringify(prefix)}`, 400);
3543
3391
  await Promise.all([this.deletePrefixInBucket(this.publicBucket, prefix), this.deletePrefixInBucket(this.privateBucket, prefix)]);
3544
3392
  }
@@ -4533,6 +4381,14 @@ var SupabaseInviteStore = class {
4533
4381
  });
4534
4382
  return true;
4535
4383
  }
4384
+ async reopen(ctx, id, userId) {
4385
+ const { data, error } = await this.clients.forRequest(ctx).from("invites").update({
4386
+ accepted_at: null,
4387
+ accepted_by_user_id: null
4388
+ }).eq("id", id).eq("accepted_by_user_id", userId).select("id");
4389
+ if (error) throw mapPostgrestError(error);
4390
+ return (data?.length ?? 0) > 0;
4391
+ }
4536
4392
  async revoke(ctx, id) {
4537
4393
  const { data, error } = await this.clients.forRequest(ctx).from("invites").delete().eq("id", id).is("accepted_at", null).select("org_id");
4538
4394
  if (error) throw mapPostgrestError(error);
@@ -5828,7 +5684,7 @@ var SupabaseDataProvider = class SupabaseDataProvider {
5828
5684
  */
5829
5685
  async onUserDeleted(_ctx, userId, opts) {
5830
5686
  const client = this.clients.serviceClient;
5831
- const email = opts?.email;
5687
+ const email = opts?.email?.trim().toLowerCase();
5832
5688
  const deletedActions = await client.from("audit_events").delete().eq("actor_id", userId);
5833
5689
  if (deletedActions.error) throw new ProviderError(`Failed to erase audit_events for user: ${deletedActions.error.message}`, 500);
5834
5690
  const tombstoned = await client.from("solve_metrics").update({ actor_id: ERASED_ACTOR_ID }).eq("actor_id", userId);
@@ -6651,14 +6507,28 @@ function createAllowlistStore(filePath) {
6651
6507
  if (dirty) await writeFile$1(filePath, file);
6652
6508
  });
6653
6509
  },
6510
+ claim(id, upn, opts) {
6511
+ return locked(async () => {
6512
+ const file = await readFile(filePath);
6513
+ const user = file.users.find((u) => u.id === id);
6514
+ if (!user) return null;
6515
+ const key = norm(upn);
6516
+ if (!user.claimedByUpn || opts?.replace && user.claimedByUpn !== key) {
6517
+ user.claimedByUpn = key;
6518
+ await writeFile$1(filePath, file);
6519
+ }
6520
+ return user.claimedByUpn;
6521
+ });
6522
+ },
6654
6523
  rebindUpn(id, upn) {
6655
6524
  return locked(async () => {
6656
6525
  const file = await readFile(filePath);
6657
6526
  const key = norm(upn);
6658
6527
  const user = file.users.find((u) => u.id === id);
6659
- if (!user || user.upn === key) return;
6528
+ if (!user || user.upn === key && user.claimedByUpn === key) return;
6660
6529
  if (file.users.some((u) => u.id !== id && u.upn === key)) return;
6661
6530
  user.upn = key;
6531
+ user.claimedByUpn = key;
6662
6532
  await writeFile$1(filePath, file);
6663
6533
  });
6664
6534
  },
@@ -6722,6 +6592,8 @@ var HeaderProxyAuth = class {
6722
6592
  bootstrapPolicy;
6723
6593
  missingHeadersWarned = false;
6724
6594
  duplicateUpnWarned = false;
6595
+ duplicateEmailWarned = false;
6596
+ claimWriteWarned = false;
6725
6597
  constructor(users, headers, bootstrapPolicy, logger = new NoopLogger()) {
6726
6598
  this.users = users;
6727
6599
  this.headers = headers;
@@ -6747,6 +6619,43 @@ var HeaderProxyAuth = class {
6747
6619
  hasNoIdentityHeaders(headers) {
6748
6620
  return !headers.get(this.headers.upn) && !headers.get(this.headers.email) && !headers.get(this.headers.displayName);
6749
6621
  }
6622
+ /**
6623
+ * The email header, or undefined when it carries more than one value. Email
6624
+ * can select a row through the fallback, so a joined value (a proxy appending
6625
+ * its copy to the client's) is the same spoofing signal as on the UPN.
6626
+ */
6627
+ singleValuedEmail(headers) {
6628
+ const email = headers.get(this.headers.email)?.trim() || void 0;
6629
+ if (!email?.includes(",")) return email;
6630
+ if (!this.duplicateEmailWarned) {
6631
+ this.duplicateEmailWarned = true;
6632
+ 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.", {
6633
+ component: "HeaderAuth",
6634
+ header: this.headers.email
6635
+ });
6636
+ }
6637
+ }
6638
+ /**
6639
+ * Claims the row, or returns null when the allowlist can't be written. A failed
6640
+ * claim must not fail the sign-in: that would lock every unclaimed user out of
6641
+ * a deployment whose allowlist is read-only or has the wrong owner. The row
6642
+ * then stays unclaimed, and the email fallback still admits any UPN to it.
6643
+ */
6644
+ async tryClaim(id, upn, replace) {
6645
+ try {
6646
+ return await this.users.claim(id, upn, { replace });
6647
+ } catch (err) {
6648
+ if (!this.claimWriteWarned) {
6649
+ this.claimWriteWarned = true;
6650
+ 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.", {
6651
+ component: "HeaderAuth",
6652
+ userId: id,
6653
+ code: err.code
6654
+ });
6655
+ }
6656
+ return null;
6657
+ }
6658
+ }
6750
6659
  async identifyFromHeaders(headers) {
6751
6660
  const upn = headers.get(this.headers.upn);
6752
6661
  if (!upn || !upn.trim()) {
@@ -6773,9 +6682,10 @@ var HeaderProxyAuth = class {
6773
6682
  }
6774
6683
  return null;
6775
6684
  }
6776
- const email = headers.get(this.headers.email)?.trim() || void 0;
6685
+ const email = this.singleValuedEmail(headers);
6777
6686
  const displayName = headers.get(this.headers.displayName)?.trim() || void 0;
6778
6687
  let entry = await this.users.findByUpn(upn);
6688
+ let matchedByUpn = entry !== null;
6779
6689
  if (!entry && email) {
6780
6690
  const byEmail = await this.users.findByEmail(email);
6781
6691
  if (byEmail) entry = byEmail;
@@ -6784,13 +6694,26 @@ var HeaderProxyAuth = class {
6784
6694
  if (await this.bootstrapPolicy({
6785
6695
  upn,
6786
6696
  email
6787
- })) try {
6788
- entry = await this.users.createUser(upn);
6789
- } catch {
6790
- entry = await this.users.findByUpn(upn);
6697
+ })) {
6698
+ try {
6699
+ entry = await this.users.createUser(upn);
6700
+ } catch {
6701
+ entry = await this.users.findByUpn(upn);
6702
+ }
6703
+ matchedByUpn = entry !== null;
6791
6704
  }
6792
6705
  }
6793
6706
  if (!entry || entry.disabled) return null;
6707
+ const presented = upn.trim().toLowerCase();
6708
+ let claimant = entry.claimedByUpn;
6709
+ if (!claimant || matchedByUpn && claimant !== presented) claimant = await this.tryClaim(entry.id, upn, matchedByUpn) ?? void 0;
6710
+ if (claimant && claimant !== presented) {
6711
+ 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.", {
6712
+ component: "HeaderAuth",
6713
+ userId: entry.id
6714
+ });
6715
+ return null;
6716
+ }
6794
6717
  if (email && entry.email !== email || displayName && entry.displayName !== displayName) {
6795
6718
  await this.users.syncFromHeaders(entry.id, {
6796
6719
  email,