@ultrst-armada/kloks 2.2.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/package.json +2 -2
  3. package/packages/backend/dist/auth/LuthOAuthUserInfo.d.ts +10 -0
  4. package/packages/backend/dist/auth/OidcBff.d.ts +3 -2
  5. package/packages/backend/dist/auth/OidcBffEnv.d.ts +6 -7
  6. package/packages/backend/dist/auth/index.d.ts +0 -2
  7. package/packages/backend/dist/auth/index.js +2 -24
  8. package/packages/backend/dist/{chunk-NR7OXPB3.js → chunk-2SNWR4FI.js} +88 -57
  9. package/packages/backend/dist/{chunk-R4B3KPHY.js → chunk-B6BQPDJE.js} +31 -10
  10. package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +6 -3
  11. package/packages/backend/dist/index.d.ts +0 -1
  12. package/packages/backend/dist/index.js +0 -16
  13. package/packages/backend/dist/krnl-services.js +1 -2
  14. package/packages/backend/dist/node.d.ts +0 -1
  15. package/packages/backend/dist/node.js +2 -84
  16. package/packages/backend/package.json +1 -1
  17. package/packages/client/dist/auth.d.ts +9 -20
  18. package/packages/client/dist/auth.js +1 -23
  19. package/packages/client/dist/chunk-QGZHKLOK.js +75 -0
  20. package/packages/client/dist/index.d.ts +2 -2
  21. package/packages/client/dist/index.js +1 -23
  22. package/packages/client/package.json +1 -1
  23. package/packages/state-graph/dist/browser.js +8 -8
  24. package/packages/state-graph/dist/index.js +8 -8
  25. package/packages/state-graph/dist/spatial/index.js +1 -1
  26. package/packages/backend/dist/auth/BaseAccountProvider.d.ts +0 -7
  27. package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +0 -6
  28. package/packages/backend/dist/auth/UnifiedAuthCore.d.ts +0 -23
  29. package/packages/backend/dist/auth/UnifiedAuthCore.test.d.ts +0 -1
  30. package/packages/backend/dist/chunk-2COYZMUJ.js +0 -78
  31. package/packages/backend/dist/chunk-Y7ZE6D5H.js +0 -20
  32. package/packages/backend/dist/luth/LuthDiscoveryService.d.ts +0 -15
  33. package/packages/backend/dist/luth/index.d.ts +0 -1
  34. package/packages/client/dist/chunk-WYC7RG32.js +0 -147
  35. package/packages/state-graph/dist/{chunk-7N2LLBUW.js → chunk-UKTICGGV.js} +4 -4
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/kloks",
4
- "version": "2.2.8",
5
- "sourceCommit": "5c29834311d8c525ec703ef51b34de2c50f54987",
4
+ "version": "3.0.0",
5
+ "sourceCommit": "0e7389812754238becbf3adf370190fd50b5cb6d",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "44742095336"
7
+ "workflowRunId": "44884992381"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "2.2.8",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -361,7 +361,7 @@
361
361
  "verify:package-exports": "node scripts/verify-package-exports.mjs"
362
362
  },
363
363
  "dependencies": {
364
- "@dinilmusick/gutts": "2.2.3",
364
+ "@dinilmusick/gutts": "2.2.4",
365
365
  "@jitl/quickjs-wasmfile-release-sync": "0.32.0",
366
366
  "@webcontainer/api": "^1.6.4",
367
367
  "quickjs-emscripten-core": "0.32.0",
@@ -0,0 +1,10 @@
1
+ export interface OfficialLuthUser {
2
+ id: string;
3
+ email: string;
4
+ name: string;
5
+ }
6
+ /**
7
+ * Resource-server OAuth authentication: official live UserInfo only.
8
+ * No password grant, synthetic local session, x-api-key or Origin authority.
9
+ */
10
+ export declare function verifyLuthOAuthAccessToken(token: string, transport?: typeof fetch): Promise<OfficialLuthUser | null>;
@@ -14,9 +14,10 @@ export interface OAuthBffDatabase {
14
14
  export interface OAuthBffConfig {
15
15
  /** Luth's exact Better Auth issuer, including /api/auth. */
16
16
  issuer: string;
17
- /** Exact, administratively verified Luth OAuth client and callback binding. */
17
+ /** Luth-issued OAuth client registered dynamically, never preapproved by origin. */
18
18
  clientId: string;
19
- clientSecret: string;
19
+ /** Optional: public PKCE clients do not have a secret. */
20
+ clientSecret?: string;
20
21
  appId: string;
21
22
  redirectUri: string;
22
23
  /** Stable server-side secret, never serialized to a browser or log. */
@@ -1,19 +1,18 @@
1
1
  /**
2
- * All runtime configuration for ULTRST deployments is reached using these
3
- * four canonical bindings. Application credentials are kept in the protected
4
- * system database, never passed as Worker/Vercel/local environment variables.
2
+ * App-local OAuth client registration cache. This is NOT a trusted origins
3
+ * table: any app independently creates its OAuth client through Luth's
4
+ * anonymous RFC 7591 Dynamic Client Registration endpoint.
5
5
  */
6
6
  export interface CanonicalApplicationAuthEnvironment {
7
7
  APP_URL?: unknown;
8
- SYSTEM_DATABASE_URL?: unknown;
8
+ SYSTEM_DATABASE_URL_1?: unknown;
9
9
  SYSTEM_DATABASE_URL_2?: unknown;
10
10
  SYSTEM_DATABASE_URL_3?: unknown;
11
11
  [key: string]: unknown;
12
12
  }
13
13
  /**
14
- * Resolve a *fresh* application credential on every request. A revoked Luth
15
- * client or removed origin stops new operations immediately, rather than
16
- * remaining authorized by a stale in-memory credential cache.
14
+ * The app owns its opaque HttpOnly session and registered redirect URI.
15
+ * Luth alone owns OAuth client issuance, login, consent and token validity.
17
16
  */
18
17
  export declare function createCanonicalApplicationOAuthBff(request: Request, env: CanonicalApplicationAuthEnvironment, applicationId: string): {
19
18
  handle: (current: Request) => Promise<Response>;
@@ -1,4 +1,2 @@
1
- export * from './CanonicalAuthClient.js';
2
- export * from './UnifiedAuthCore.js';
3
1
  export * from './OidcBff.js';
4
2
  export * from './OidcBffEnv.js';
@@ -1,30 +1,8 @@
1
1
  import {
2
2
  createCanonicalApplicationOAuthBff,
3
3
  createOAuthBff
4
- } from "../chunk-NR7OXPB3.js";
5
- import {
6
- LuthAuthClient,
7
- LuthAuthClient2,
8
- LuthAuthError,
9
- createLuthAuthClient,
10
- createLuthAuthClient2,
11
- resolveClientEnvironment,
12
- resolveClientOrigin
13
- } from "../chunk-Y7ZE6D5H.js";
14
- import {
15
- loginSystemUser,
16
- resolveUserFromToken
17
- } from "../chunk-2COYZMUJ.js";
4
+ } from "../chunk-2SNWR4FI.js";
18
5
  export {
19
- LuthAuthClient2 as CanonicalAuthClient,
20
- LuthAuthClient,
21
- LuthAuthError,
22
6
  createCanonicalApplicationOAuthBff,
23
- createLuthAuthClient2 as createCanonicalAuthClient,
24
- createLuthAuthClient,
25
- createOAuthBff,
26
- loginSystemUser,
27
- resolveClientEnvironment,
28
- resolveClientOrigin,
29
- resolveUserFromToken
7
+ createOAuthBff
30
8
  };
@@ -54,7 +54,7 @@ function sameValue(left, right) {
54
54
  function configOrigin(config) {
55
55
  const url = new URL(config.redirectUri);
56
56
  const issuer = new URL(config.issuer);
57
- if (issuer.protocol !== "https:" || issuer.pathname !== "/api/auth" || issuer.search || issuer.hash || !config.clientId || !config.clientSecret || !config.appId || url.username || url.password || url.search || url.hash || url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {
57
+ if (issuer.protocol !== "https:" || issuer.pathname !== "/api/auth" || issuer.search || issuer.hash || !config.clientId || !config.appId || url.username || url.password || url.search || url.hash || url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {
58
58
  throw new Error("INVALID_VERIFIED_OAUTH_BFF_CONFIGURATION");
59
59
  }
60
60
  return url;
@@ -84,7 +84,9 @@ function reply(body, status) {
84
84
  return Response.json(body, { status, headers: { "cache-control": "no-store" } });
85
85
  }
86
86
  function clientCredentials(config) {
87
- return new URLSearchParams({ client_id: config.clientId, client_secret: config.clientSecret });
87
+ const fields = new URLSearchParams({ client_id: config.clientId });
88
+ if (config.clientSecret) fields.set("client_secret", config.clientSecret);
89
+ return fields;
88
90
  }
89
91
  async function exchange(config, body) {
90
92
  const response = await (config.fetcher || fetch)(config.issuer + "/oauth2/token", {
@@ -313,74 +315,103 @@ function createOAuthBff(config) {
313
315
  // src/auth/OidcBffEnv.ts
314
316
  import { neon } from "@neondatabase/serverless";
315
317
  import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
316
- function createCanonicalApplicationOAuthBff(request, env, applicationId) {
317
- if (!/^[a-z0-9][a-z0-9_-]{0,119}$/.test(applicationId)) {
318
- throw new Error("INVALID_APP_ID");
318
+ function secret() {
319
+ const bytes = crypto.getRandomValues(new Uint8Array(32));
320
+ return Array.from(bytes, (x) => x.toString(16).padStart(2, "0")).join("");
321
+ }
322
+ function redirectOf(request, env) {
323
+ const raw = String(env.APP_URL || "").trim();
324
+ if (!raw) throw new Error("APP_URL_UNAVAILABLE");
325
+ const app = new URL(raw);
326
+ if (app.protocol !== "https:" && !(app.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(app.hostname)) || app.origin !== raw.replace(/\/$/, "") || new URL(request.url).origin !== app.origin) {
327
+ throw new Error("APPLICATION_ORIGIN_MISMATCH");
319
328
  }
320
- const origin = String(env.APP_URL || "").trim();
321
- const candidates = [
322
- env.SYSTEM_DATABASE_URL,
329
+ return app.origin + "/api/auth/oidc/callback";
330
+ }
331
+ function connections(env) {
332
+ const values = [
333
+ env.SYSTEM_DATABASE_URL_1,
323
334
  env.SYSTEM_DATABASE_URL_2,
324
335
  env.SYSTEM_DATABASE_URL_3
325
- ].filter((value) => typeof value === "string" && !!value.trim()).map((value) => value.trim());
326
- if (!origin || !candidates.length) throw new Error("CANONICAL_APP_AUTH_NOT_PROVISIONED");
327
- const verifiedOrigin = new URL(origin);
328
- if (verifiedOrigin.origin !== origin.replace(/\/$/, "") || !["http:", "https:"].includes(verifiedOrigin.protocol) || new URL(request.url).origin !== verifiedOrigin.origin) {
329
- throw new Error("APPLICATION_ORIGIN_MISMATCH");
336
+ ];
337
+ return values.filter((value) => typeof value === "string" && !!value.trim()).map((value) => value.trim());
338
+ }
339
+ async function selfRegister(appId, redirectUri) {
340
+ const issuer = DEFAULT_LUTH_URL.replace(/\/$/, "");
341
+ const response = await fetch(issuer + "/api/auth/oauth2/register", {
342
+ method: "POST",
343
+ credentials: "omit",
344
+ redirect: "error",
345
+ cache: "no-store",
346
+ headers: { "content-type": "application/json", accept: "application/json" },
347
+ body: JSON.stringify({
348
+ client_name: appId,
349
+ redirect_uris: [redirectUri],
350
+ application_type: "web",
351
+ token_endpoint_auth_method: "none",
352
+ response_types: ["code"],
353
+ grant_types: ["authorization_code", "refresh_token"],
354
+ scope: "openid profile email offline_access"
355
+ })
356
+ });
357
+ if (!response.ok) throw new Error("LUTH_PUBLIC_OAUTH_REGISTRATION_DENIED");
358
+ const value = await response.json();
359
+ if (typeof value.client_id !== "string" || !value.client_id || !Array.isArray(value.redirect_uris) || value.redirect_uris.length !== 1 || value.redirect_uris[0] !== redirectUri || value.token_endpoint_auth_method !== "none" || value.client_secret != null) {
360
+ throw new Error("LUTH_PUBLIC_OAUTH_REGISTRATION_INVALID");
330
361
  }
362
+ return value.client_id;
363
+ }
364
+ function createCanonicalApplicationOAuthBff(request, env, applicationId) {
365
+ if (!/^[a-z0-9][a-z0-9_-]{0,119}$/.test(applicationId)) {
366
+ throw new Error("INVALID_APP_ID");
367
+ }
368
+ const redirectUri = redirectOf(request, env);
369
+ const databaseUrls = connections(env);
370
+ if (!databaseUrls.length) throw new Error("SYSTEM_DATABASE_UNAVAILABLE");
331
371
  async function resolve(current) {
332
- if (new URL(current.url).origin !== verifiedOrigin.origin) {
372
+ if (redirectOf(current, env) !== redirectUri) {
333
373
  throw new Error("APPLICATION_ORIGIN_MISMATCH");
334
374
  }
335
- const settingsKey = applicationId + "|" + verifiedOrigin.origin;
336
- const statement = `
337
- SELECT c."clientId" AS client_id,
338
- cred.credentials #> ARRAY['applicationOAuth', $3::text] AS settings
339
- FROM public."ultrst-apps" a
340
- JOIN public.luth_ecosystems e ON e.id = a.ecosystem_id
341
- JOIN public.luth_auth_origins o
342
- ON o.app_id = a.app_id AND o.ecosystem_id = a.ecosystem_id
343
- JOIN public."oauthClient" c
344
- ON c.metadata->>'appId' = a.app_id
345
- AND c.metadata->>'origin' = o.origin
346
- JOIN public."ultrst-credentials" cred ON cred.id = 'system'
347
- WHERE a.app_id = $1 AND a.status = 'active' AND e.status = 'active'
348
- AND o.origin = $2 AND o.enabled = true
349
- AND COALESCE(c.disabled, false) = false
350
- LIMIT 2
351
- `;
352
375
  let lastError;
353
- for (const dbUrl of candidates) {
354
- const sql = neon(dbUrl);
355
- let rows;
376
+ for (const url of databaseUrls) {
377
+ const sql = neon(url);
356
378
  try {
357
- rows = [...await sql(statement, [applicationId, verifiedOrigin.origin, settingsKey])];
379
+ let rows = [...await sql(
380
+ "SELECT client_id,encryption_secret FROM public.kloks_oidc_registrations WHERE app_id=$1 AND redirect_uri=$2 LIMIT 2",
381
+ [applicationId, redirectUri]
382
+ )];
383
+ if (!rows.length) {
384
+ const clientId = await selfRegister(applicationId, redirectUri);
385
+ await sql(
386
+ "INSERT INTO public.kloks_oidc_registrations (app_id,redirect_uri,client_id,encryption_secret) VALUES ($1,$2,$3,$4) ON CONFLICT (app_id,redirect_uri) DO NOTHING",
387
+ [applicationId, redirectUri, clientId, secret()]
388
+ );
389
+ rows = [...await sql(
390
+ "SELECT client_id,encryption_secret FROM public.kloks_oidc_registrations WHERE app_id=$1 AND redirect_uri=$2 LIMIT 2",
391
+ [applicationId, redirectUri]
392
+ )];
393
+ }
394
+ if (rows.length !== 1 || typeof rows[0]?.client_id !== "string" || typeof rows[0]?.encryption_secret !== "string" || rows[0].encryption_secret.length < 32) {
395
+ throw new Error("OAUTH_CLIENT_REGISTRATION_INVALID");
396
+ }
397
+ return createOAuthBff({
398
+ appId: applicationId,
399
+ issuer: DEFAULT_LUTH_URL.replace(/\/$/, "") + "/api/auth",
400
+ clientId: rows[0].client_id,
401
+ redirectUri,
402
+ encryptionSecret: rows[0].encryption_secret,
403
+ database: {
404
+ async query(statement, values) {
405
+ const result = await sql(statement, [...values]);
406
+ return { rows: [...result] };
407
+ }
408
+ }
409
+ });
358
410
  } catch (error) {
359
411
  lastError = error;
360
- continue;
361
- }
362
- if (rows.length !== 1) throw new Error("CANONICAL_APP_AUTH_NOT_PROVISIONED");
363
- const raw = rows[0].settings;
364
- const credential = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
365
- if (typeof credential.clientId !== "string" || typeof credential.clientSecret !== "string" || typeof credential.bffSecret !== "string" || credential.bffSecret.length < 32 || credential.clientId !== rows[0].client_id || !credential.clientSecret) {
366
- throw new Error("CANONICAL_APP_AUTH_NOT_PROVISIONED");
367
412
  }
368
- return createOAuthBff({
369
- appId: applicationId,
370
- issuer: DEFAULT_LUTH_URL.replace(/\/$/, "") + "/api/auth",
371
- clientId: credential.clientId,
372
- clientSecret: credential.clientSecret,
373
- redirectUri: verifiedOrigin.origin + "/api/auth/oidc/callback",
374
- encryptionSecret: credential.bffSecret,
375
- database: {
376
- async query(query, values) {
377
- const result = await sql(query, [...values]);
378
- return { rows: [...result] };
379
- }
380
- }
381
- });
382
413
  }
383
- throw new Error(lastError ? "SYSTEM_DATABASE_UNAVAILABLE" : "CANONICAL_APP_AUTH_NOT_PROVISIONED");
414
+ throw new Error(lastError ? "OAUTH_CLIENT_REGISTRATION_UNAVAILABLE" : "SYSTEM_DATABASE_UNAVAILABLE");
384
415
  }
385
416
  return {
386
417
  handle: async (current) => (await resolve(current)).handle(current),
@@ -46,10 +46,6 @@ import {
46
46
  import {
47
47
  queryUnifiedDb
48
48
  } from "./chunk-3RTRATDJ.js";
49
- import {
50
- loginSystemUser,
51
- resolveUserFromToken
52
- } from "./chunk-2COYZMUJ.js";
53
49
  import {
54
50
  authorizeB2,
55
51
  b2DownloadFile,
@@ -67,6 +63,36 @@ import {
67
63
  createServiceDefinition
68
64
  } from "@ultrst-armada/krnl";
69
65
 
66
+ // src/auth/LuthOAuthUserInfo.ts
67
+ import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
68
+ async function verifyLuthOAuthAccessToken(token, transport = fetch) {
69
+ const clean = token.trim().replace(/^Bearer\s+/i, "");
70
+ if (!/^[A-Za-z0-9._~-]{16,2048}$/.test(clean)) return null;
71
+ try {
72
+ const issuer = new URL(DEFAULT_LUTH_URL);
73
+ const result = await transport(
74
+ new URL("/api/auth/oauth2/userinfo", issuer.origin),
75
+ {
76
+ method: "GET",
77
+ credentials: "omit",
78
+ cache: "no-store",
79
+ redirect: "error",
80
+ headers: { authorization: "Bearer " + clean, accept: "application/json" }
81
+ }
82
+ );
83
+ if (!result.ok) return null;
84
+ const body = await result.json();
85
+ if (typeof body.sub !== "string" || !body.sub || typeof body.email !== "string" || !body.email) return null;
86
+ return {
87
+ id: body.sub,
88
+ email: body.email,
89
+ name: typeof body.name === "string" ? body.name : body.email
90
+ };
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+
70
96
  // src/core/b2ExplorerContext.ts
71
97
  function safeB2ExplorerPath(value) {
72
98
  if (typeof value !== "string" || !value || value.startsWith("/") || value.includes("\\") || /[\x00-\x1f\x7f]/.test(value)) {
@@ -546,15 +572,10 @@ var AuthServiceDefinition = createServiceDefinition({
546
572
  initial: { activeSessions: 0 }
547
573
  },
548
574
  operations: {
549
- login: {
550
- id: "AuthService.login",
551
- name: "login",
552
- handler: async (input) => loginSystemUser(input.email, input.password, Boolean(input.isAdmin), (sql, params) => queryUnifiedDb(sql, params, input.env), input.env)
553
- },
554
575
  resolveUser: {
555
576
  id: "AuthService.resolveUser",
556
577
  name: "resolveUser",
557
- handler: async (input) => resolveUserFromToken(input.tokenOrUserId, (sql, params) => queryUnifiedDb(sql, params, input.env), input.env)
578
+ handler: async (input) => verifyLuthOAuthAccessToken(input.accessToken)
558
579
  }
559
580
  }
560
581
  });
@@ -1,10 +1,13 @@
1
1
  import { SkipoBase } from '@ultrst-armada/kloks/functions/base';
2
- import { BaseAccountProvider } from '../auth/BaseAccountProvider.js';
2
+ import type { OfficialLuthUser } from '../auth/LuthOAuthUserInfo.js';
3
+ export interface OAuthResourceVerifier {
4
+ verifyAccessToken(token: string): Promise<OfficialLuthUser | null>;
5
+ }
3
6
  import { AuditLogger } from './AuditLogger.js';
4
7
  import { DatabaseClusterManager } from './DatabaseClusterManager.js';
5
8
  export declare class ControlPlaneManager extends SkipoBase {
6
- auth: BaseAccountProvider;
9
+ auth: OAuthResourceVerifier;
7
10
  audit: AuditLogger;
8
11
  cluster: DatabaseClusterManager;
9
- constructor(auth: BaseAccountProvider, audit: AuditLogger, cluster: DatabaseClusterManager);
12
+ constructor(auth: OAuthResourceVerifier, audit: AuditLogger, cluster: DatabaseClusterManager);
10
13
  }
@@ -1,6 +1,5 @@
1
1
  /** Portable backend surface. Node filesystem, database, server and service engines are exposed from the explicit /node adapter. */
2
2
  export * from './api/index.js';
3
- export * from './auth/CanonicalAuthClient.js';
4
3
  export * from './storage/index.js';
5
4
  export * from './workspace/index.js';
6
5
  export * from './connectivity/index.js';
@@ -99,15 +99,6 @@ import {
99
99
  withCors
100
100
  } from "./chunk-KCPQWJBO.js";
101
101
  import "./chunk-LMY6MGFD.js";
102
- import {
103
- LuthAuthClient,
104
- LuthAuthClient2,
105
- LuthAuthError,
106
- createLuthAuthClient,
107
- createLuthAuthClient2,
108
- resolveClientEnvironment,
109
- resolveClientOrigin
110
- } from "./chunk-Y7ZE6D5H.js";
111
102
  import {
112
103
  BackendRegistry,
113
104
  ConcurrencyConflictError,
@@ -159,7 +150,6 @@ export {
159
150
  BaseStorageAdapter,
160
151
  COMPUTE_PROFILE_PRESETS,
161
152
  CallbackRegistry,
162
- LuthAuthClient2 as CanonicalAuthClient,
163
153
  ConcurrencyConflictError,
164
154
  ConcurrencyManager,
165
155
  EventBus,
@@ -174,8 +164,6 @@ export {
174
164
  JobScheduler,
175
165
  LoadBalancer,
176
166
  LockManager,
177
- LuthAuthClient,
178
- LuthAuthError,
179
167
  RemoteExecutor,
180
168
  SequenceTracker,
181
169
  UnsupportedStorageOperation,
@@ -192,7 +180,6 @@ export {
192
180
  continueDropboxFolder,
193
181
  createBackblazeB2StorageService,
194
182
  createBackendClient,
195
- createLuthAuthClient2 as createCanonicalAuthClient,
196
183
  createCanonicalStorageService,
197
184
  createDropboxStorageService,
198
185
  createEmptyContract,
@@ -200,7 +187,6 @@ export {
200
187
  createFlyMachine,
201
188
  createGitHubStorageService,
202
189
  createGoogleDriveStorageService,
203
- createLuthAuthClient,
204
190
  createProviderClient,
205
191
  createSSEResponse,
206
192
  b2DownloadFile as downloadBackblazeB2File,
@@ -246,8 +232,6 @@ export {
246
232
  rankComputeRoutes,
247
233
  readOnlyService,
248
234
  resolveBackblazeEndpoint,
249
- resolveClientEnvironment,
250
- resolveClientOrigin,
251
235
  resolveComputeSpec,
252
236
  resolveProviderServiceId,
253
237
  resolveSystemDatabaseUrl,
@@ -27,14 +27,13 @@ import {
27
27
  krnlStorageServiceFacade,
28
28
  krnlWorkspaceServiceDefinition,
29
29
  krnlWorkspaceServiceFacade
30
- } from "./chunk-R4B3KPHY.js";
30
+ } from "./chunk-B6BQPDJE.js";
31
31
  import "./chunk-FZKBTF34.js";
32
32
  import "./chunk-7XTURV44.js";
33
33
  import "./chunk-GCVR257U.js";
34
34
  import "./chunk-IRKJ6HKP.js";
35
35
  import "./chunk-3ZL2DX73.js";
36
36
  import "./chunk-3RTRATDJ.js";
37
- import "./chunk-2COYZMUJ.js";
38
37
  import "./chunk-I6T64MLT.js";
39
38
  import "./chunk-IP6XWQU2.js";
40
39
  import "./chunk-EMSSTOOK.js";
@@ -7,7 +7,6 @@ export * from './data/index.js';
7
7
  export * from './connectivity/index.js';
8
8
  export * from './client/index.js';
9
9
  export * from './srkl/index.js';
10
- export * from './luth/index.js';
11
10
  export type { Runtime, Deployment, FunctionSet, ServiceFacade, OrchestrationFn, BackendFacade, ServiceRegistryRecord, } from './architecture/types.js';
12
11
  export { validateServiceDefinition } from './architecture/types.js';
13
12
  export * from './services/node.js';
@@ -93,7 +93,7 @@ import {
93
93
  import {
94
94
  createCanonicalApplicationOAuthBff,
95
95
  createOAuthBff
96
- } from "./chunk-NR7OXPB3.js";
96
+ } from "./chunk-2SNWR4FI.js";
97
97
  import {
98
98
  BackendProvider,
99
99
  useBackend,
@@ -132,15 +132,6 @@ import {
132
132
  import {
133
133
  SkipoBase
134
134
  } from "./chunk-LMY6MGFD.js";
135
- import {
136
- LuthAuthClient,
137
- LuthAuthClient2,
138
- LuthAuthError,
139
- createLuthAuthClient,
140
- createLuthAuthClient2,
141
- resolveClientEnvironment,
142
- resolveClientOrigin
143
- } from "./chunk-Y7ZE6D5H.js";
144
135
  import {
145
136
  BackendRegistry,
146
137
  ConcurrencyConflictError,
@@ -236,7 +227,7 @@ import {
236
227
  readUserWorkspaceStorageFile,
237
228
  verifyGoogleDriveAuthorizationState,
238
229
  writeUserWorkspaceStorageFile
239
- } from "./chunk-R4B3KPHY.js";
230
+ } from "./chunk-B6BQPDJE.js";
240
231
  import {
241
232
  formatCanonicalWorkspaceFolderName,
242
233
  sanitizeWorkspaceName
@@ -304,10 +295,6 @@ import {
304
295
  getUnifiedDbUrl,
305
296
  queryUnifiedDb
306
297
  } from "./chunk-3RTRATDJ.js";
307
- import {
308
- loginSystemUser,
309
- resolveUserFromToken
310
- } from "./chunk-2COYZMUJ.js";
311
298
  import {
312
299
  authorizeB2,
313
300
  b2DeleteFileVersion,
@@ -414,62 +401,6 @@ var FunctionalityTable = class extends BaseDataProvider {
414
401
  }
415
402
  };
416
403
 
417
- // src/luth/LuthDiscoveryService.ts
418
- import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
419
- var cachedLuthUrls = null;
420
- var roundRobinIndex = 0;
421
- async function getRegisteredLuthDeploymentUrls(queryDb) {
422
- if (cachedLuthUrls && Date.now() < cachedLuthUrls.expiresAt && cachedLuthUrls.urls.length > 0) {
423
- return cachedLuthUrls.urls;
424
- }
425
- if (queryDb) {
426
- try {
427
- const res = await queryDb(
428
- `SELECT url FROM "ultrst-luth-deployments" WHERE is_active = true ORDER BY is_primary DESC, priority DESC, created_at ASC`,
429
- []
430
- );
431
- if (res.rows.length > 0) {
432
- const urls = res.rows.map((r) => String(r.url || "").trim().replace(/\/+$/, "")).filter(Boolean);
433
- if (urls.length > 0) {
434
- cachedLuthUrls = { urls, expiresAt: Date.now() + 5 * 60 * 1e3 };
435
- return urls;
436
- }
437
- }
438
- } catch {
439
- try {
440
- const res2 = await queryDb(
441
- `SELECT origin FROM "ultrst-apps" WHERE app_id = 'luth' AND status = 'active' AND origin IS NOT NULL LIMIT 1`,
442
- []
443
- );
444
- if (res2.rows.length > 0 && res2.rows[0].origin) {
445
- const u = String(res2.rows[0].origin).trim().replace(/\/+$/, "");
446
- cachedLuthUrls = { urls: [u], expiresAt: Date.now() + 5 * 60 * 1e3 };
447
- return [u];
448
- }
449
- } catch {
450
- }
451
- }
452
- }
453
- const fallback = [DEFAULT_LUTH_URL];
454
- cachedLuthUrls = { urls: fallback, expiresAt: Date.now() + 5 * 60 * 1e3 };
455
- return fallback;
456
- }
457
- async function getPrimaryLuthDeploymentUrl(queryDb) {
458
- const urls = await getRegisteredLuthDeploymentUrls(queryDb);
459
- return urls[0] || DEFAULT_LUTH_URL;
460
- }
461
- async function getNextLuthDeploymentUrl(queryDb) {
462
- const urls = await getRegisteredLuthDeploymentUrls(queryDb);
463
- if (urls.length === 0) return DEFAULT_LUTH_URL;
464
- const next = urls[roundRobinIndex % urls.length];
465
- roundRobinIndex = (roundRobinIndex + 1) % urls.length;
466
- return next;
467
- }
468
- function clearLuthDiscoveryCache() {
469
- cachedLuthUrls = null;
470
- roundRobinIndex = 0;
471
- }
472
-
473
404
  // src/architecture/types.ts
474
405
  function validateServiceDefinition(def) {
475
406
  if (def.deployment === "remote" && def.runtime !== "server") {
@@ -4619,7 +4550,6 @@ export {
4619
4550
  BucketStorageService,
4620
4551
  CANONICAL_SRKL_URL,
4621
4552
  CallbackRegistry,
4622
- LuthAuthClient2 as CanonicalAuthClient,
4623
4553
  CanonicalStorageProviderService,
4624
4554
  CloudflareProviderService,
4625
4555
  CloudflareResourceFetcher,
@@ -4664,8 +4594,6 @@ export {
4664
4594
  LoadBalancer,
4665
4595
  LocalFSAdapter,
4666
4596
  LockManager,
4667
- LuthAuthClient,
4668
- LuthAuthError,
4669
4597
  MCPEngine,
4670
4598
  MetricsLogger,
4671
4599
  ModelCatalogService,
@@ -4721,7 +4649,6 @@ export {
4721
4649
  buildProjectsList,
4722
4650
  classifyAndFormatError,
4723
4651
  cleanDbUrl,
4724
- clearLuthDiscoveryCache,
4725
4652
  completeGoogleDriveAuthorization,
4726
4653
  completeGoogleDriveAuthorizationCallback,
4727
4654
  computeDeploymentFinalWeight,
@@ -4734,7 +4661,6 @@ export {
4734
4661
  createBackend,
4735
4662
  createBackendClient,
4736
4663
  createCanonicalApplicationOAuthBff,
4737
- createLuthAuthClient2 as createCanonicalAuthClient,
4738
4664
  createCompositeService,
4739
4665
  createCredential,
4740
4666
  createEmptyContract,
@@ -4745,7 +4671,6 @@ export {
4745
4671
  createGraphAssetFolder as createGraphAssetSubfolder,
4746
4672
  createGraphPackage,
4747
4673
  createLocalService,
4748
- createLuthAuthClient,
4749
4674
  createOAuthBff,
4750
4675
  createRemoteService,
4751
4676
  createSSEResponse,
@@ -4803,15 +4728,12 @@ export {
4803
4728
  getGatewayConfig,
4804
4729
  getGoogleDriveAccountIdentityForUser,
4805
4730
  getGraphPackageById,
4806
- getNextLuthDeploymentUrl,
4807
- getPrimaryLuthDeploymentUrl,
4808
4731
  getPrimarySrklDeploymentUrl2 as getPrimarySrklCoreDeploymentUrl,
4809
4732
  getPrimarySrklDeploymentUrl,
4810
4733
  getProjectById,
4811
4734
  getProviderMeta,
4812
4735
  getPublicRouteByPath,
4813
4736
  getPublicRoutes,
4814
- getRegisteredLuthDeploymentUrls,
4815
4737
  getSrklAccounts,
4816
4738
  getSrklAccounts2 as getSrklCoreAccounts,
4817
4739
  getSrklStatus,
@@ -4872,7 +4794,6 @@ export {
4872
4794
  listWorkspaceGraphs,
4873
4795
  loadCredentialManifest,
4874
4796
  loadWorkspaceData,
4875
- loginSystemUser,
4876
4797
  matchGatewayIngress,
4877
4798
  matchGatewayIngressAsync,
4878
4799
  mcpEngine,
@@ -4901,13 +4822,10 @@ export {
4901
4822
  renameAppInWorkspaceData,
4902
4823
  renameS3Folder,
4903
4824
  resolveBackblazeEndpoint,
4904
- resolveClientEnvironment,
4905
- resolveClientOrigin,
4906
4825
  resolveDynamicRouteFromDb,
4907
4826
  resolveSystemDatabaseClusterNodes,
4908
4827
  resolveSystemDatabaseUrl,
4909
4828
  resolveSystemDatabaseUrlCandidates,
4910
- resolveUserFromToken,
4911
4829
  resolveUserStorageConnectionSecret,
4912
4830
  resolveUserWorkspaceStorageAssociation,
4913
4831
  resolveWorkspaceConnection,
@@ -225,7 +225,7 @@
225
225
  "clean": "rm -rf dist"
226
226
  },
227
227
  "dependencies": {
228
- "@dinilmusick/gutts": "2.2.3",
228
+ "@dinilmusick/gutts": "2.2.4",
229
229
  "@kloks/functions": "workspace:*",
230
230
  "@kloks/state-graph": "workspace:*",
231
231
  "@webcontainer/api": "^1.6.4",