@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.
- package/.krusbl-release-attestation.json +3 -3
- package/package.json +2 -2
- package/packages/backend/dist/auth/LuthOAuthUserInfo.d.ts +10 -0
- package/packages/backend/dist/auth/OidcBff.d.ts +3 -2
- package/packages/backend/dist/auth/OidcBffEnv.d.ts +6 -7
- package/packages/backend/dist/auth/index.d.ts +0 -2
- package/packages/backend/dist/auth/index.js +2 -24
- package/packages/backend/dist/{chunk-NR7OXPB3.js → chunk-2SNWR4FI.js} +88 -57
- package/packages/backend/dist/{chunk-R4B3KPHY.js → chunk-B6BQPDJE.js} +31 -10
- package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +6 -3
- package/packages/backend/dist/index.d.ts +0 -1
- package/packages/backend/dist/index.js +0 -16
- package/packages/backend/dist/krnl-services.js +1 -2
- package/packages/backend/dist/node.d.ts +0 -1
- package/packages/backend/dist/node.js +2 -84
- package/packages/backend/package.json +1 -1
- package/packages/client/dist/auth.d.ts +9 -20
- package/packages/client/dist/auth.js +1 -23
- package/packages/client/dist/chunk-QGZHKLOK.js +75 -0
- package/packages/client/dist/index.d.ts +2 -2
- package/packages/client/dist/index.js +1 -23
- package/packages/client/package.json +1 -1
- package/packages/state-graph/dist/browser.js +8 -8
- package/packages/state-graph/dist/index.js +8 -8
- package/packages/state-graph/dist/spatial/index.js +1 -1
- package/packages/backend/dist/auth/BaseAccountProvider.d.ts +0 -7
- package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +0 -6
- package/packages/backend/dist/auth/UnifiedAuthCore.d.ts +0 -23
- package/packages/backend/dist/auth/UnifiedAuthCore.test.d.ts +0 -1
- package/packages/backend/dist/chunk-2COYZMUJ.js +0 -78
- package/packages/backend/dist/chunk-Y7ZE6D5H.js +0 -20
- package/packages/backend/dist/luth/LuthDiscoveryService.d.ts +0 -15
- package/packages/backend/dist/luth/index.d.ts +0 -1
- package/packages/client/dist/chunk-WYC7RG32.js +0 -147
- package/packages/state-graph/dist/{chunk-7N2LLBUW.js → chunk-UKTICGGV.js} +4 -4
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
export { ApplicationAuthClient, ApplicationAuthClientConfig, LuthAuthClient as CanonicalAuthClient, DEFAULT_LUTH_URL, DeploymentEnvironment, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, LuthAuthClient, LuthAuthClientConfig, LuthAuthError, LuthAuthTokenStore, LuthSession, LuthSessionResult, LuthUser, RegisterApplicationResult, createApplicationAuthClient, createLuthAuthClient as createCanonicalAuthClient, createLuthAuthClient, hydrateLuthTokenFromUrl, resolveClientEnvironment, resolveClientOrigin } from '@dinilmusick/gutts/auth';
|
|
1
|
+
export { DEFAULT_LUTH_URL } from '@dinilmusick/gutts/auth';
|
|
3
2
|
|
|
4
3
|
interface LuthPrincipal {
|
|
5
4
|
id: string;
|
|
6
5
|
email: string;
|
|
7
6
|
name: string;
|
|
8
|
-
role:
|
|
7
|
+
role: 'user';
|
|
9
8
|
}
|
|
10
9
|
declare const CANONICAL_PUBLIC_ROUTES: (string | RegExp)[];
|
|
10
|
+
/** Never interpret a cookie, API key, user ID or Origin as a Luth token. */
|
|
11
11
|
declare function extractLuthToken(request: Request): string;
|
|
12
|
-
declare function isPublicRoute(
|
|
12
|
+
declare function isPublicRoute(path: string, extraPublicRoutes?: (string | RegExp)[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Verify the official OAuth Provider token on every protected request.
|
|
15
|
+
* Never forward an application cookie; never cache identity across revocation.
|
|
16
|
+
*/
|
|
13
17
|
declare function verifyLuthRequest(request: Request, options?: {
|
|
14
18
|
luthUrl?: string;
|
|
15
19
|
extraPublicRoutes?: (string | RegExp)[];
|
|
16
20
|
}): Promise<LuthPrincipal | Response | null>;
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
id: string;
|
|
20
|
-
url: string;
|
|
21
|
-
label?: string;
|
|
22
|
-
environment?: DeploymentEnvironment;
|
|
23
|
-
isActive: boolean;
|
|
24
|
-
isPrimary?: boolean;
|
|
25
|
-
priority?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Creates an authenticated fetch function that automatically injects Luth bearer headers and credentials: 'include'. */
|
|
29
|
-
declare function createUniversalAuthFetch(authClient: {
|
|
30
|
-
getAuthHeaders: () => HeadersInit;
|
|
31
|
-
}): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
32
|
-
|
|
33
|
-
export { CANONICAL_PUBLIC_ROUTES, type LuthDeploymentRecord, type LuthPrincipal, createUniversalAuthFetch, extractLuthToken, isPublicRoute, verifyLuthRequest };
|
|
22
|
+
export { CANONICAL_PUBLIC_ROUTES, type LuthPrincipal, extractLuthToken, isPublicRoute, verifyLuthRequest };
|
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ApplicationAuthClient,
|
|
3
2
|
CANONICAL_PUBLIC_ROUTES,
|
|
4
3
|
DEFAULT_LUTH_URL,
|
|
5
|
-
LuthAuthClient,
|
|
6
|
-
LuthAuthClient2,
|
|
7
|
-
LuthAuthError,
|
|
8
|
-
createApplicationAuthClient,
|
|
9
|
-
createLuthAuthClient,
|
|
10
|
-
createLuthAuthClient2,
|
|
11
|
-
createUniversalAuthFetch,
|
|
12
4
|
extractLuthToken,
|
|
13
|
-
hydrateLuthTokenFromUrl,
|
|
14
5
|
isPublicRoute,
|
|
15
|
-
resolveClientEnvironment,
|
|
16
|
-
resolveClientOrigin,
|
|
17
6
|
verifyLuthRequest
|
|
18
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QGZHKLOK.js";
|
|
19
8
|
export {
|
|
20
|
-
ApplicationAuthClient,
|
|
21
9
|
CANONICAL_PUBLIC_ROUTES,
|
|
22
|
-
LuthAuthClient2 as CanonicalAuthClient,
|
|
23
10
|
DEFAULT_LUTH_URL,
|
|
24
|
-
LuthAuthClient,
|
|
25
|
-
LuthAuthError,
|
|
26
|
-
createApplicationAuthClient,
|
|
27
|
-
createLuthAuthClient2 as createCanonicalAuthClient,
|
|
28
|
-
createLuthAuthClient,
|
|
29
|
-
createUniversalAuthFetch,
|
|
30
11
|
extractLuthToken,
|
|
31
|
-
hydrateLuthTokenFromUrl,
|
|
32
12
|
isPublicRoute,
|
|
33
|
-
resolveClientEnvironment,
|
|
34
|
-
resolveClientOrigin,
|
|
35
13
|
verifyLuthRequest
|
|
36
14
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/auth.ts
|
|
2
|
+
import { DEFAULT_LUTH_URL as DEFAULT_LUTH_URL2 } from "@dinilmusick/gutts/auth";
|
|
3
|
+
|
|
4
|
+
// src/UniversalLuthGuard.ts
|
|
5
|
+
import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
|
|
6
|
+
var CANONICAL_PUBLIC_ROUTES = [
|
|
7
|
+
"/health",
|
|
8
|
+
"/api/health",
|
|
9
|
+
"/api/status",
|
|
10
|
+
"/api/auth/oidc/start",
|
|
11
|
+
"/api/auth/oidc/callback",
|
|
12
|
+
"/api/auth/oidc/session",
|
|
13
|
+
"/api/auth/oidc/logout",
|
|
14
|
+
/^\/api(\/v1)?\/database\/status$/,
|
|
15
|
+
/^\/api(\/v1)?\/guest(\/.*)?$/,
|
|
16
|
+
/^\/api(\/v1)?\/spec(\/.*)?$/
|
|
17
|
+
];
|
|
18
|
+
function extractLuthToken(request) {
|
|
19
|
+
const authorization = request.headers.get("authorization") || "";
|
|
20
|
+
const match = /^Bearer ([A-Za-z0-9._~-]{16,2048})$/i.exec(authorization.trim());
|
|
21
|
+
return match?.[1] || "";
|
|
22
|
+
}
|
|
23
|
+
function isPublicRoute(path, extraPublicRoutes = []) {
|
|
24
|
+
return [...CANONICAL_PUBLIC_ROUTES, ...extraPublicRoutes].some((route) => typeof route === "string" ? route === path : route.test(path));
|
|
25
|
+
}
|
|
26
|
+
function deny(request, unavailable = false) {
|
|
27
|
+
const mcp = new URL(request.url).pathname.includes("/mcp");
|
|
28
|
+
const status = unavailable ? 503 : 401;
|
|
29
|
+
const message = unavailable ? "Luth OAuth provider unavailable." : "Valid OAuth 2.1 Bearer token required.";
|
|
30
|
+
return Response.json(mcp ? {
|
|
31
|
+
jsonrpc: "2.0",
|
|
32
|
+
id: null,
|
|
33
|
+
error: { code: unavailable ? -32603 : -32001, message }
|
|
34
|
+
} : { success: false, error: message }, {
|
|
35
|
+
status,
|
|
36
|
+
headers: { "cache-control": "no-store" }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function verifyLuthRequest(request, options) {
|
|
40
|
+
const path = new URL(request.url).pathname;
|
|
41
|
+
if (request.method === "OPTIONS" || isPublicRoute(path, options?.extraPublicRoutes)) return null;
|
|
42
|
+
const token = extractLuthToken(request);
|
|
43
|
+
if (!token) return deny(request);
|
|
44
|
+
try {
|
|
45
|
+
const issuer = new URL(options?.luthUrl || DEFAULT_LUTH_URL);
|
|
46
|
+
if (issuer.protocol !== "https:") return deny(request, true);
|
|
47
|
+
const response = await fetch(new URL("/api/auth/oauth2/userinfo", issuer.origin), {
|
|
48
|
+
method: "GET",
|
|
49
|
+
credentials: "omit",
|
|
50
|
+
cache: "no-store",
|
|
51
|
+
redirect: "error",
|
|
52
|
+
headers: { authorization: "Bearer " + token, accept: "application/json" }
|
|
53
|
+
});
|
|
54
|
+
if (response.status === 401 || response.status === 403) return deny(request);
|
|
55
|
+
if (!response.ok) return deny(request, true);
|
|
56
|
+
const body = await response.json();
|
|
57
|
+
if (typeof body.sub !== "string" || !body.sub || typeof body.email !== "string" || !body.email) return deny(request);
|
|
58
|
+
return {
|
|
59
|
+
id: body.sub,
|
|
60
|
+
email: body.email,
|
|
61
|
+
name: typeof body.name === "string" && body.name ? body.name : body.email,
|
|
62
|
+
role: "user"
|
|
63
|
+
};
|
|
64
|
+
} catch {
|
|
65
|
+
return deny(request, true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
CANONICAL_PUBLIC_ROUTES,
|
|
71
|
+
extractLuthToken,
|
|
72
|
+
isPublicRoute,
|
|
73
|
+
verifyLuthRequest,
|
|
74
|
+
DEFAULT_LUTH_URL2 as DEFAULT_LUTH_URL
|
|
75
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { DEFAULT_LUTH_URL } from '@dinilmusick/gutts/auth';
|
|
2
|
+
export { CANONICAL_PUBLIC_ROUTES, LuthPrincipal, extractLuthToken, isPublicRoute, verifyLuthRequest } from './auth.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @file queueContracts.ts
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ApplicationAuthClient,
|
|
3
2
|
CANONICAL_PUBLIC_ROUTES,
|
|
4
3
|
DEFAULT_LUTH_URL,
|
|
5
|
-
LuthAuthClient,
|
|
6
|
-
LuthAuthClient2,
|
|
7
|
-
LuthAuthError,
|
|
8
|
-
createApplicationAuthClient,
|
|
9
|
-
createLuthAuthClient,
|
|
10
|
-
createLuthAuthClient2,
|
|
11
|
-
createUniversalAuthFetch,
|
|
12
4
|
extractLuthToken,
|
|
13
|
-
hydrateLuthTokenFromUrl,
|
|
14
5
|
isPublicRoute,
|
|
15
|
-
resolveClientEnvironment,
|
|
16
|
-
resolveClientOrigin,
|
|
17
6
|
verifyLuthRequest
|
|
18
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QGZHKLOK.js";
|
|
19
8
|
|
|
20
9
|
// src/browserExecutionClient.ts
|
|
21
10
|
var BrowserExecutionClient = class {
|
|
@@ -190,24 +179,13 @@ var OPFSWorkspaceStorage = class {
|
|
|
190
179
|
}
|
|
191
180
|
};
|
|
192
181
|
export {
|
|
193
|
-
ApplicationAuthClient,
|
|
194
182
|
BrowserExecutionClient,
|
|
195
183
|
CANONICAL_PUBLIC_ROUTES,
|
|
196
|
-
LuthAuthClient2 as CanonicalAuthClient,
|
|
197
184
|
DEFAULT_LUTH_URL,
|
|
198
|
-
LuthAuthClient,
|
|
199
|
-
LuthAuthError,
|
|
200
185
|
OPFSWorkspaceStorage,
|
|
201
186
|
WorkspaceAutosaveController,
|
|
202
|
-
createApplicationAuthClient,
|
|
203
187
|
createBrowserExecutionClient,
|
|
204
|
-
createLuthAuthClient2 as createCanonicalAuthClient,
|
|
205
|
-
createLuthAuthClient,
|
|
206
|
-
createUniversalAuthFetch,
|
|
207
188
|
extractLuthToken,
|
|
208
|
-
hydrateLuthTokenFromUrl,
|
|
209
189
|
isPublicRoute,
|
|
210
|
-
resolveClientEnvironment,
|
|
211
|
-
resolveClientOrigin,
|
|
212
190
|
verifyLuthRequest
|
|
213
191
|
};
|
|
@@ -252,7 +252,7 @@ import {
|
|
|
252
252
|
validateProjectGraph,
|
|
253
253
|
validateUniversalConnection,
|
|
254
254
|
zoomAtPoint
|
|
255
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-UKTICGGV.js";
|
|
256
256
|
import {
|
|
257
257
|
BaseHandle,
|
|
258
258
|
DataHandle,
|
|
@@ -261,6 +261,7 @@ import {
|
|
|
261
261
|
ViewHandle,
|
|
262
262
|
instantiateSubgraph
|
|
263
263
|
} from "./chunk-OXUDG6HE.js";
|
|
264
|
+
import "./chunk-RHRXPY2U.js";
|
|
264
265
|
import {
|
|
265
266
|
LifecycleCycleError,
|
|
266
267
|
LifecycleGraph,
|
|
@@ -284,7 +285,6 @@ import {
|
|
|
284
285
|
CustomViewWindow,
|
|
285
286
|
DEFAULT_GRAPH_SETTINGS
|
|
286
287
|
} from "./chunk-5KP74NMF.js";
|
|
287
|
-
import "./chunk-RHRXPY2U.js";
|
|
288
288
|
import {
|
|
289
289
|
AttractionEngine,
|
|
290
290
|
GhostInferenceEngine,
|
|
@@ -294,6 +294,12 @@ import {
|
|
|
294
294
|
getBeamPoints,
|
|
295
295
|
useMagneticTraces
|
|
296
296
|
} from "./chunk-JXDJZSFW.js";
|
|
297
|
+
import {
|
|
298
|
+
ConnectionRuleStore,
|
|
299
|
+
HandleTypeRegistry,
|
|
300
|
+
WireTypeRegistry,
|
|
301
|
+
initializeDefaultGraphRules
|
|
302
|
+
} from "./chunk-TZOL3RN7.js";
|
|
297
303
|
import {
|
|
298
304
|
AutoSolidify,
|
|
299
305
|
SpatialEngine,
|
|
@@ -304,12 +310,6 @@ import {
|
|
|
304
310
|
SolidConnection,
|
|
305
311
|
ViewLink
|
|
306
312
|
} from "./chunk-OYN4ZEZC.js";
|
|
307
|
-
import {
|
|
308
|
-
ConnectionRuleStore,
|
|
309
|
-
HandleTypeRegistry,
|
|
310
|
-
WireTypeRegistry,
|
|
311
|
-
initializeDefaultGraphRules
|
|
312
|
-
} from "./chunk-TZOL3RN7.js";
|
|
313
313
|
import {
|
|
314
314
|
CompatibilityMatrix
|
|
315
315
|
} from "./chunk-ISFNY7EZ.js";
|
|
@@ -252,7 +252,7 @@ import {
|
|
|
252
252
|
validateProjectGraph,
|
|
253
253
|
validateUniversalConnection,
|
|
254
254
|
zoomAtPoint
|
|
255
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-UKTICGGV.js";
|
|
256
256
|
import {
|
|
257
257
|
BaseHandle,
|
|
258
258
|
DataHandle,
|
|
@@ -261,6 +261,7 @@ import {
|
|
|
261
261
|
ViewHandle,
|
|
262
262
|
instantiateSubgraph
|
|
263
263
|
} from "./chunk-OXUDG6HE.js";
|
|
264
|
+
import "./chunk-RHRXPY2U.js";
|
|
264
265
|
import {
|
|
265
266
|
LifecycleCycleError,
|
|
266
267
|
LifecycleGraph,
|
|
@@ -284,7 +285,6 @@ import {
|
|
|
284
285
|
CustomViewWindow,
|
|
285
286
|
DEFAULT_GRAPH_SETTINGS
|
|
286
287
|
} from "./chunk-5KP74NMF.js";
|
|
287
|
-
import "./chunk-RHRXPY2U.js";
|
|
288
288
|
import {
|
|
289
289
|
AttractionEngine,
|
|
290
290
|
GhostInferenceEngine,
|
|
@@ -294,6 +294,12 @@ import {
|
|
|
294
294
|
getBeamPoints,
|
|
295
295
|
useMagneticTraces
|
|
296
296
|
} from "./chunk-JXDJZSFW.js";
|
|
297
|
+
import {
|
|
298
|
+
ConnectionRuleStore,
|
|
299
|
+
HandleTypeRegistry,
|
|
300
|
+
WireTypeRegistry,
|
|
301
|
+
initializeDefaultGraphRules
|
|
302
|
+
} from "./chunk-TZOL3RN7.js";
|
|
297
303
|
import {
|
|
298
304
|
AutoSolidify,
|
|
299
305
|
SpatialEngine,
|
|
@@ -304,12 +310,6 @@ import {
|
|
|
304
310
|
SolidConnection,
|
|
305
311
|
ViewLink
|
|
306
312
|
} from "./chunk-OYN4ZEZC.js";
|
|
307
|
-
import {
|
|
308
|
-
ConnectionRuleStore,
|
|
309
|
-
HandleTypeRegistry,
|
|
310
|
-
WireTypeRegistry,
|
|
311
|
-
initializeDefaultGraphRules
|
|
312
|
-
} from "./chunk-TZOL3RN7.js";
|
|
313
313
|
import {
|
|
314
314
|
CompatibilityMatrix
|
|
315
315
|
} from "./chunk-ISFNY7EZ.js";
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
getBeamPoints,
|
|
8
8
|
useMagneticTraces
|
|
9
9
|
} from "../chunk-JXDJZSFW.js";
|
|
10
|
+
import "../chunk-TZOL3RN7.js";
|
|
10
11
|
import {
|
|
11
12
|
AutoSolidify,
|
|
12
13
|
SpatialEngine,
|
|
13
14
|
TraceEngine
|
|
14
15
|
} from "../chunk-OV4JVTNY.js";
|
|
15
16
|
import "../chunk-OYN4ZEZC.js";
|
|
16
|
-
import "../chunk-TZOL3RN7.js";
|
|
17
17
|
import "../chunk-ISFNY7EZ.js";
|
|
18
18
|
export {
|
|
19
19
|
AttractionEngine,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical account-provider compatibility type.
|
|
3
|
-
*
|
|
4
|
-
* Auth is owned by Luth; this alias exists only for control-plane APIs that
|
|
5
|
-
* historically accepted a BaseAccountProvider.
|
|
6
|
-
*/
|
|
7
|
-
export { LuthAuthClient as BaseAccountProvider, createLuthAuthClient as createBaseAccountProvider, } from '@dinilmusick/gutts';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { LuthAuthClient, createLuthAuthClient, resolveClientOrigin, resolveClientEnvironment, } from '@dinilmusick/gutts/auth';
|
|
2
|
-
export type { DeploymentEnvironment, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, LuthAuthClientConfig, LuthAuthTokenStore, LuthSessionResult, RegisterApplicationResult, LuthUser, LuthSession, } from '@dinilmusick/gutts/auth';
|
|
3
|
-
export { LuthAuthError } from '@dinilmusick/gutts/auth';
|
|
4
|
-
export { LuthAuthClient as CanonicalAuthClient } from '@dinilmusick/gutts/auth';
|
|
5
|
-
export { createLuthAuthClient as createCanonicalAuthClient } from '@dinilmusick/gutts/auth';
|
|
6
|
-
export type { LuthUser as CanonicalAuthUser, LuthSession as CanonicalAuthSession } from '@dinilmusick/gutts/auth';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface SystemUser {
|
|
2
|
-
id: string;
|
|
3
|
-
email: string;
|
|
4
|
-
name: string;
|
|
5
|
-
username: string;
|
|
6
|
-
role: string;
|
|
7
|
-
status: string;
|
|
8
|
-
appProfiles?: Record<string, unknown>;
|
|
9
|
-
emailVerified?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export type AuthEnvironment = Record<string, unknown>;
|
|
12
|
-
export declare function loginSystemUser(email: string, rawPass: string, isAdmin: boolean, _queryDb: (sql: string, params?: unknown[]) => Promise<{
|
|
13
|
-
rows: any[];
|
|
14
|
-
}>, env?: AuthEnvironment): Promise<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
status: number;
|
|
17
|
-
token?: string;
|
|
18
|
-
user?: SystemUser;
|
|
19
|
-
error?: string;
|
|
20
|
-
}>;
|
|
21
|
-
export declare function resolveUserFromToken(tokenOrUserId: string, _queryDb: (sql: string, params?: unknown[]) => Promise<{
|
|
22
|
-
rows: any[];
|
|
23
|
-
}>, env?: AuthEnvironment): Promise<SystemUser | null>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// src/auth/UnifiedAuthCore.ts
|
|
2
|
-
import {
|
|
3
|
-
LuthAuthClient,
|
|
4
|
-
DEFAULT_LUTH_URL
|
|
5
|
-
} from "@dinilmusick/gutts/auth";
|
|
6
|
-
function tokenStore(initial = "") {
|
|
7
|
-
let token = initial;
|
|
8
|
-
return {
|
|
9
|
-
get: () => token,
|
|
10
|
-
set: (value) => {
|
|
11
|
-
token = value;
|
|
12
|
-
},
|
|
13
|
-
clear: () => {
|
|
14
|
-
token = "";
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function createClient(_env, token = "") {
|
|
19
|
-
return new LuthAuthClient({
|
|
20
|
-
ecosystemId: "ultrst-armada",
|
|
21
|
-
applicationId: "kloks-backend",
|
|
22
|
-
luthUrl: DEFAULT_LUTH_URL,
|
|
23
|
-
origin: process.env.APP_URL || DEFAULT_LUTH_URL,
|
|
24
|
-
autoRegister: false,
|
|
25
|
-
tokenStore: tokenStore(token)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function toSystemUser(user) {
|
|
29
|
-
return {
|
|
30
|
-
...user,
|
|
31
|
-
username: user.email.split("@")[0],
|
|
32
|
-
role: "user",
|
|
33
|
-
status: "ACTIVE"
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async function loginSystemUser(email, rawPass, isAdmin, _queryDb, env) {
|
|
37
|
-
if (!email?.trim() || !rawPass) return { success: false, status: 400, error: "Email and password are required" };
|
|
38
|
-
if (isAdmin) return { success: false, status: 403, error: "Administrative authentication is not provided by canonical Luth user login." };
|
|
39
|
-
try {
|
|
40
|
-
const client = createClient(env);
|
|
41
|
-
await client.signInWithEmail({ email: email.trim(), password: rawPass });
|
|
42
|
-
const session = await client.getSession();
|
|
43
|
-
if (!session.authenticated || !session.user || !session.session) {
|
|
44
|
-
return { success: false, status: 401, error: "Canonical authentication service did not establish a session." };
|
|
45
|
-
}
|
|
46
|
-
const user = toSystemUser(session.user);
|
|
47
|
-
const authorization = client.getAuthHeaders().Authorization || "";
|
|
48
|
-
const token = authorization.replace(/^Bearer\s+/i, "").trim();
|
|
49
|
-
if (!token) return { success: false, status: 502, error: "Luth did not return a usable bearer session token." };
|
|
50
|
-
return {
|
|
51
|
-
success: true,
|
|
52
|
-
status: 200,
|
|
53
|
-
user,
|
|
54
|
-
token
|
|
55
|
-
};
|
|
56
|
-
} catch (error) {
|
|
57
|
-
const status = error && typeof error === "object" && "status" in error && typeof error.status === "number" ? error.status : 503;
|
|
58
|
-
return { success: false, status, error: error instanceof Error ? error.message : "Canonical authentication service unavailable" };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function resolveUserFromToken(tokenOrUserId, _queryDb, env) {
|
|
62
|
-
if (!tokenOrUserId) return null;
|
|
63
|
-
try {
|
|
64
|
-
const credential = tokenOrUserId.trim().replace(/^Bearer[ \t]+/i, "").trim();
|
|
65
|
-
if (!credential) return null;
|
|
66
|
-
const client = createClient(env, credential);
|
|
67
|
-
const session = await client.getSession();
|
|
68
|
-
if (!session.authenticated || !session.user) return null;
|
|
69
|
-
return toSystemUser(session.user);
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
loginSystemUser,
|
|
77
|
-
resolveUserFromToken
|
|
78
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// src/auth/CanonicalAuthClient.ts
|
|
2
|
-
import {
|
|
3
|
-
LuthAuthClient,
|
|
4
|
-
createLuthAuthClient,
|
|
5
|
-
resolveClientOrigin,
|
|
6
|
-
resolveClientEnvironment
|
|
7
|
-
} from "@dinilmusick/gutts/auth";
|
|
8
|
-
import { LuthAuthError } from "@dinilmusick/gutts/auth";
|
|
9
|
-
import { LuthAuthClient as LuthAuthClient2 } from "@dinilmusick/gutts/auth";
|
|
10
|
-
import { createLuthAuthClient as createLuthAuthClient2 } from "@dinilmusick/gutts/auth";
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
LuthAuthClient,
|
|
14
|
-
createLuthAuthClient,
|
|
15
|
-
resolveClientOrigin,
|
|
16
|
-
resolveClientEnvironment,
|
|
17
|
-
LuthAuthError,
|
|
18
|
-
LuthAuthClient2,
|
|
19
|
-
createLuthAuthClient2
|
|
20
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file LuthDiscoveryService.ts
|
|
3
|
-
* @description Universal Luth Auth Service Discovery with multi-deployment fallback and round-robin.
|
|
4
|
-
* Runs identically in Node.js, Vercel Serverless, and Cloudflare Workers (< 200 lines).
|
|
5
|
-
*/
|
|
6
|
-
export declare function getRegisteredLuthDeploymentUrls(queryDb?: (sql: string, params?: unknown[]) => Promise<{
|
|
7
|
-
rows: any[];
|
|
8
|
-
}>): Promise<string[]>;
|
|
9
|
-
export declare function getPrimaryLuthDeploymentUrl(queryDb?: (sql: string, params?: unknown[]) => Promise<{
|
|
10
|
-
rows: any[];
|
|
11
|
-
}>): Promise<string>;
|
|
12
|
-
export declare function getNextLuthDeploymentUrl(queryDb?: (sql: string, params?: unknown[]) => Promise<{
|
|
13
|
-
rows: any[];
|
|
14
|
-
}>): Promise<string>;
|
|
15
|
-
export declare function clearLuthDiscoveryCache(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './LuthDiscoveryService.js';
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// src/auth.ts
|
|
2
|
-
import {
|
|
3
|
-
LuthAuthClient,
|
|
4
|
-
createLuthAuthClient,
|
|
5
|
-
hydrateLuthTokenFromUrl,
|
|
6
|
-
resolveClientOrigin,
|
|
7
|
-
resolveClientEnvironment,
|
|
8
|
-
LuthAuthError,
|
|
9
|
-
DEFAULT_LUTH_URL as DEFAULT_LUTH_URL2,
|
|
10
|
-
ApplicationAuthClient,
|
|
11
|
-
createApplicationAuthClient
|
|
12
|
-
} from "@dinilmusick/gutts/auth";
|
|
13
|
-
import {
|
|
14
|
-
LuthAuthClient as LuthAuthClient2,
|
|
15
|
-
createLuthAuthClient as createLuthAuthClient2
|
|
16
|
-
} from "@dinilmusick/gutts/auth";
|
|
17
|
-
|
|
18
|
-
// src/UniversalLuthGuard.ts
|
|
19
|
-
import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
|
|
20
|
-
var CANONICAL_PUBLIC_ROUTES = [
|
|
21
|
-
"/health",
|
|
22
|
-
"/api/health",
|
|
23
|
-
"/api/status",
|
|
24
|
-
"/api/auth",
|
|
25
|
-
/^\/api(\/v1)?\/auth(\/.*)?$/,
|
|
26
|
-
/^\/api(\/v1)?\/database\/status$/,
|
|
27
|
-
/^\/api(\/v1)?\/guest(\/.*)?$/,
|
|
28
|
-
/^\/api(\/v1)?\/discovery(\/.*)?$/,
|
|
29
|
-
/^\/api(\/v1)?\/spec(\/.*)?$/
|
|
30
|
-
];
|
|
31
|
-
var SESSION_CACHE_TTL_MS = 6e4;
|
|
32
|
-
var sessionCache = /* @__PURE__ */ new Map();
|
|
33
|
-
function extractLuthToken(request) {
|
|
34
|
-
const authorization = request.headers.get("authorization") || "";
|
|
35
|
-
const bearer = /^Bearer\s+([^\s]+)$/i.exec(authorization.trim());
|
|
36
|
-
if (bearer) return bearer[1];
|
|
37
|
-
const apiKey = request.headers.get("x-api-key")?.trim();
|
|
38
|
-
if (apiKey) return apiKey;
|
|
39
|
-
const cookieHeader = request.headers.get("cookie") || "";
|
|
40
|
-
const cookies = cookieHeader.split(";").map((c) => c.trim());
|
|
41
|
-
for (const prefix of ["better-auth.session_token=", "__Secure-better-auth.session_token=", "luth_session="]) {
|
|
42
|
-
const found = cookies.find((c) => c.startsWith(prefix));
|
|
43
|
-
if (found) {
|
|
44
|
-
try {
|
|
45
|
-
return decodeURIComponent(found.slice(prefix.length));
|
|
46
|
-
} catch {
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
function isPublicRoute(pathname, extraPublicRoutes) {
|
|
54
|
-
const routes = extraPublicRoutes ? [...CANONICAL_PUBLIC_ROUTES, ...extraPublicRoutes] : CANONICAL_PUBLIC_ROUTES;
|
|
55
|
-
return routes.some((route) => typeof route === "string" ? pathname === route : route.test(pathname));
|
|
56
|
-
}
|
|
57
|
-
async function verifyLuthRequest(request, options) {
|
|
58
|
-
const url = new URL(request.url);
|
|
59
|
-
if (request.method === "OPTIONS") return null;
|
|
60
|
-
if (isPublicRoute(url.pathname, options?.extraPublicRoutes)) return null;
|
|
61
|
-
const isMcp = url.pathname.includes("/mcp");
|
|
62
|
-
const token = extractLuthToken(request);
|
|
63
|
-
if (!token) {
|
|
64
|
-
const payload = isMcp ? { jsonrpc: "2.0", id: null, error: { code: -32001, message: "A verified Luth session is required." } } : { success: false, error: "A verified Luth session is required." };
|
|
65
|
-
return new Response(JSON.stringify(payload), { status: 401, headers: { "Content-Type": "application/json" } });
|
|
66
|
-
}
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
const cached = sessionCache.get(token);
|
|
69
|
-
if (cached && cached.expiresAt > now) {
|
|
70
|
-
return cached.principal;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
const luthUrl = options?.luthUrl || DEFAULT_LUTH_URL;
|
|
74
|
-
const res = await fetch(`${luthUrl}/api/session`, {
|
|
75
|
-
headers: {
|
|
76
|
-
authorization: `Bearer ${token}`,
|
|
77
|
-
cookie: request.headers.get("cookie") || "",
|
|
78
|
-
origin: url.origin
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
if (!res.ok) {
|
|
82
|
-
const payload = isMcp ? { jsonrpc: "2.0", id: null, error: { code: -32001, message: "The Luth session is invalid or expired." } } : { success: false, error: "The Luth session is invalid or expired." };
|
|
83
|
-
return new Response(JSON.stringify(payload), { status: 401, headers: { "Content-Type": "application/json" } });
|
|
84
|
-
}
|
|
85
|
-
const data = await res.json();
|
|
86
|
-
const user = data?.user || (data?.authenticated ? data?.session?.user : null);
|
|
87
|
-
if (!user || !user.id) {
|
|
88
|
-
const payload = isMcp ? { jsonrpc: "2.0", id: null, error: { code: -32001, message: "The Luth session is invalid or expired." } } : { success: false, error: "The Luth session is invalid or expired." };
|
|
89
|
-
return new Response(JSON.stringify(payload), { status: 401, headers: { "Content-Type": "application/json" } });
|
|
90
|
-
}
|
|
91
|
-
const principal = {
|
|
92
|
-
id: String(user.id),
|
|
93
|
-
email: String(user.email || ""),
|
|
94
|
-
name: String(user.name || user.email?.split("@")[0] || ""),
|
|
95
|
-
role: String(user.role || "user")
|
|
96
|
-
};
|
|
97
|
-
sessionCache.set(token, { principal, expiresAt: now + SESSION_CACHE_TTL_MS });
|
|
98
|
-
return principal;
|
|
99
|
-
} catch {
|
|
100
|
-
const payload = isMcp ? { jsonrpc: "2.0", id: null, error: { code: -32603, message: "Canonical Luth authentication service unavailable." } } : { success: false, error: "Canonical Luth authentication service unavailable." };
|
|
101
|
-
return new Response(JSON.stringify(payload), { status: 503, headers: { "Content-Type": "application/json" } });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src/auth.ts
|
|
106
|
-
function createUniversalAuthFetch(authClient) {
|
|
107
|
-
return async function universalAuthFetch(input, init = {}) {
|
|
108
|
-
const headers = new Headers();
|
|
109
|
-
if (typeof input === "object" && input !== null && "headers" in input && input.headers) {
|
|
110
|
-
new Headers(input.headers).forEach((value, key) => {
|
|
111
|
-
headers.set(key, value);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (init.headers) {
|
|
115
|
-
new Headers(init.headers).forEach((value, key) => {
|
|
116
|
-
headers.set(key, value);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
new Headers(authClient.getAuthHeaders()).forEach((value, key) => {
|
|
120
|
-
if (!headers.has(key)) headers.set(key, value);
|
|
121
|
-
});
|
|
122
|
-
return fetch(input, {
|
|
123
|
-
...init,
|
|
124
|
-
headers,
|
|
125
|
-
credentials: init.credentials ?? "include"
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export {
|
|
131
|
-
CANONICAL_PUBLIC_ROUTES,
|
|
132
|
-
extractLuthToken,
|
|
133
|
-
isPublicRoute,
|
|
134
|
-
verifyLuthRequest,
|
|
135
|
-
createUniversalAuthFetch,
|
|
136
|
-
LuthAuthClient,
|
|
137
|
-
createLuthAuthClient,
|
|
138
|
-
hydrateLuthTokenFromUrl,
|
|
139
|
-
resolveClientOrigin,
|
|
140
|
-
resolveClientEnvironment,
|
|
141
|
-
LuthAuthError,
|
|
142
|
-
DEFAULT_LUTH_URL2 as DEFAULT_LUTH_URL,
|
|
143
|
-
ApplicationAuthClient,
|
|
144
|
-
createApplicationAuthClient,
|
|
145
|
-
LuthAuthClient2,
|
|
146
|
-
createLuthAuthClient2
|
|
147
|
-
};
|
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
AttractionEngine
|
|
9
9
|
} from "./chunk-JXDJZSFW.js";
|
|
10
|
+
import {
|
|
11
|
+
HandleTypeRegistry,
|
|
12
|
+
WireTypeRegistry
|
|
13
|
+
} from "./chunk-TZOL3RN7.js";
|
|
10
14
|
import {
|
|
11
15
|
AutoSolidify,
|
|
12
16
|
TraceEngine
|
|
@@ -14,10 +18,6 @@ import {
|
|
|
14
18
|
import {
|
|
15
19
|
SolidConnection
|
|
16
20
|
} from "./chunk-OYN4ZEZC.js";
|
|
17
|
-
import {
|
|
18
|
-
HandleTypeRegistry,
|
|
19
|
-
WireTypeRegistry
|
|
20
|
-
} from "./chunk-TZOL3RN7.js";
|
|
21
21
|
import {
|
|
22
22
|
CompatibilityMatrix
|
|
23
23
|
} from "./chunk-ISFNY7EZ.js";
|