@ultrst-armada/kloks 2.2.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/package.json +1 -1
  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 -3
  7. package/packages/backend/dist/auth/index.js +2 -26
  8. package/packages/backend/dist/{chunk-AKVBFHHD.js → chunk-2SNWR4FI.js} +88 -57
  9. package/packages/backend/dist/{chunk-UI7AYFAU.js → chunk-363J52AF.js} +0 -48
  10. package/packages/backend/dist/{chunk-GCVR257U.js → chunk-3SDRLTD6.js} +1 -1
  11. package/packages/backend/dist/chunk-7HD7OEUY.js +177 -0
  12. package/packages/backend/dist/chunk-B5DCG4UC.js +602 -0
  13. package/packages/backend/dist/{chunk-7XTURV44.js → chunk-F7BO3GLA.js} +2 -2
  14. package/packages/backend/dist/{chunk-RHW75K46.js → chunk-IAW6N73D.js} +49 -1
  15. package/packages/backend/dist/{chunk-IRKJ6HKP.js → chunk-IXEKOWY4.js} +1 -1
  16. package/packages/backend/dist/{chunk-4X4QGVAO.js → chunk-NRW4TECO.js} +1 -1
  17. package/packages/backend/dist/{chunk-3ZL2DX73.js → chunk-PAU25K7F.js} +5 -172
  18. package/packages/backend/dist/{chunk-NUBA6A5T.js → chunk-VN2NR3KT.js} +1 -1
  19. package/packages/backend/dist/{chunk-R4B3KPHY.js → chunk-YFISFDBW.js} +36 -15
  20. package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +6 -3
  21. package/packages/backend/dist/index.d.ts +0 -2
  22. package/packages/backend/dist/index.js +7 -25
  23. package/packages/backend/dist/krnl-services.js +6 -6
  24. package/packages/backend/dist/node.d.ts +0 -1
  25. package/packages/backend/dist/node.js +20 -95
  26. package/packages/backend/dist/provider-services/index.js +7 -7
  27. package/packages/backend/dist/provider-services/node.d.ts +2 -0
  28. package/packages/backend/dist/provider-services/node.js +15 -4
  29. package/packages/backend/dist/provider-services/saved-account-crypto.d.ts +19 -0
  30. package/packages/backend/dist/provider-services/saved-account-probe.d.ts +26 -0
  31. package/packages/backend/dist/provider-services/saved-account-store.d.ts +29 -0
  32. package/packages/backend/dist/services/node.js +5 -4
  33. package/packages/backend/dist/srkl/index.js +3 -2
  34. package/packages/backend/dist/workspace/node.js +5 -4
  35. package/packages/backend/dist/{workspaceFileCore-XPT6WTFY.js → workspaceFileCore-2KCVSECY.js} +3 -2
  36. package/packages/client/dist/auth.d.ts +9 -21
  37. package/packages/client/dist/auth.js +1 -23
  38. package/packages/client/dist/chunk-QGZHKLOK.js +75 -0
  39. package/packages/client/dist/index.d.ts +2 -3
  40. package/packages/client/dist/index.js +1 -23
  41. package/packages/backend/dist/auth/BaseAccountProvider.d.ts +0 -7
  42. package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +0 -6
  43. package/packages/backend/dist/auth/UnifiedAuthCore.d.ts +0 -23
  44. package/packages/backend/dist/auth/UniversalLuthInitialization.d.ts +0 -55
  45. package/packages/backend/dist/chunk-2COYZMUJ.js +0 -78
  46. package/packages/backend/dist/chunk-MDTLU7H4.js +0 -58
  47. package/packages/backend/dist/chunk-U5VPYALB.js +0 -261
  48. package/packages/backend/dist/luth/LuthDiscoveryService.d.ts +0 -15
  49. package/packages/backend/dist/luth/index.d.ts +0 -1
  50. package/packages/client/dist/chunk-4HR374IB.js +0 -148
  51. /package/packages/backend/dist/{auth/UnifiedAuthCore.test.d.ts → provider-services/saved-account-store.test.d.ts} +0 -0
@@ -1,148 +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
- export * from "@dinilmusick/gutts/auth";
107
- function createUniversalAuthFetch(authClient) {
108
- return async function universalAuthFetch(input, init = {}) {
109
- const headers = new Headers();
110
- if (typeof input === "object" && input !== null && "headers" in input && input.headers) {
111
- new Headers(input.headers).forEach((value, key) => {
112
- headers.set(key, value);
113
- });
114
- }
115
- if (init.headers) {
116
- new Headers(init.headers).forEach((value, key) => {
117
- headers.set(key, value);
118
- });
119
- }
120
- new Headers(authClient.getAuthHeaders()).forEach((value, key) => {
121
- if (!headers.has(key)) headers.set(key, value);
122
- });
123
- return fetch(input, {
124
- ...init,
125
- headers,
126
- credentials: init.credentials ?? "include"
127
- });
128
- };
129
- }
130
-
131
- export {
132
- CANONICAL_PUBLIC_ROUTES,
133
- extractLuthToken,
134
- isPublicRoute,
135
- verifyLuthRequest,
136
- createUniversalAuthFetch,
137
- LuthAuthClient,
138
- createLuthAuthClient,
139
- hydrateLuthTokenFromUrl,
140
- resolveClientOrigin,
141
- resolveClientEnvironment,
142
- LuthAuthError,
143
- DEFAULT_LUTH_URL2 as DEFAULT_LUTH_URL,
144
- ApplicationAuthClient,
145
- createApplicationAuthClient,
146
- LuthAuthClient2,
147
- createLuthAuthClient2
148
- };