@ultrst-armada/kloks 1.24.5 → 1.24.9
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/README.md +11 -0
- package/package.json +15 -12
- package/packages/audio-midi/dist/index.js +16 -16
- package/packages/backend/dist/ai-inference/index.js +0 -1
- package/packages/backend/dist/ai-keys/index.js +0 -1
- package/packages/backend/dist/ai-models/index.js +0 -1
- package/packages/backend/dist/ai-provider/index.js +0 -1
- package/packages/backend/dist/ai-routing/index.js +0 -1
- package/packages/backend/dist/ai-tools/index.js +0 -1
- package/packages/backend/dist/api/index.js +0 -1
- package/packages/backend/dist/auth/index.d.ts +5 -74
- package/packages/backend/dist/auth/index.js +16 -19
- package/packages/backend/dist/{chunk-2OPIDIIB.js → chunk-3VWBZEMG.js} +26 -2
- package/packages/backend/dist/chunk-ED32WV3T.js +75 -0
- package/packages/backend/dist/chunk-EO5VUYYU.js +20 -0
- package/packages/backend/dist/{chunk-B3VJ4HDV.js → chunk-JOTDEFRG.js} +1 -1
- package/packages/backend/dist/{chunk-OB65KZ2M.js → chunk-M45KQRPR.js} +1 -1
- package/packages/backend/dist/{chunk-AHJ2EWQW.js → chunk-Q7ZJSEII.js} +2 -21
- package/packages/backend/dist/chunk-SXDYW3QA.js +579 -0
- package/packages/backend/dist/client/index.js +0 -1
- package/packages/backend/dist/connectivity/index.js +0 -1
- package/packages/backend/dist/control-plane/index.d.ts +3 -3
- package/packages/backend/dist/control-plane/index.js +0 -1
- package/packages/backend/dist/development/client.d.ts +20 -6
- package/packages/backend/dist/development/client.js +42 -28
- package/packages/backend/dist/development/index.d.ts +20 -6
- package/packages/backend/dist/development/index.js +43 -32
- package/packages/backend/dist/development/playwrightInspectionService.js +2 -3
- package/packages/backend/dist/development/playwrightInspectionTypes.d.ts +1 -0
- package/packages/backend/dist/index.d.ts +3 -54
- package/packages/backend/dist/index.js +20 -103
- package/packages/backend/dist/krnl-ai-services.js +2 -3
- package/packages/backend/dist/krnl-services.js +3 -4
- package/packages/backend/dist/services/index.js +2 -3
- package/packages/backend/dist/srkl/index.js +0 -1
- package/packages/backend/dist/storage/index.js +0 -1
- package/packages/backend/dist/workspace/index.js +0 -1
- package/packages/backend/package.json +3 -10
- package/packages/client/dist/auth.d.ts +1 -0
- package/packages/client/dist/auth.js +22 -0
- package/packages/client/dist/chunk-B4WOPCRZ.js +26 -0
- package/packages/client/dist/index.d.ts +2 -0
- package/packages/client/dist/index.js +19 -1
- package/packages/client/package.json +8 -2
- package/packages/fod/dist/index.d.ts +11 -1
- package/packages/fod/dist/index.js +2 -0
- package/packages/fod/package.json +2 -3
- package/packages/functions/dist/index.js +16 -16
- package/packages/functions/package.json +2 -1
- package/packages/services/dist/index.d.ts +46 -1
- package/packages/services/dist/index.js +96 -18
- package/packages/services/kloks.manifest.json +19 -0
- package/packages/state-graph/dist/index.js +39 -39
- package/packages/backend/dist/BaseAccountProvider-DduKf5HG.d.ts +0 -66
- package/packages/backend/dist/chunk-2HCQ2SIR.js +0 -213
- package/packages/backend/dist/chunk-A3BE6ROS.js +0 -180
- package/packages/backend/dist/chunk-MWSYNRNZ.js +0 -871
- package/packages/backend/dist/chunk-QGM4M3NI.js +0 -37
- package/packages/backend/dist/dist-XMSSRYDR.js +0 -899
- package/packages/backend/dist/transformers.node-HWHOAE4H.js +0 -43879
|
@@ -7,29 +7,6 @@ import {
|
|
|
7
7
|
instantiateSubgraph
|
|
8
8
|
} from "./chunk-S22PMERU.js";
|
|
9
9
|
import "./chunk-RHRXPY2U.js";
|
|
10
|
-
import {
|
|
11
|
-
LifecycleCycleError,
|
|
12
|
-
LifecycleGraph,
|
|
13
|
-
SKIPO_STATE,
|
|
14
|
-
SkipoStateEngine,
|
|
15
|
-
useLifecycleScope,
|
|
16
|
-
useSkipoBind,
|
|
17
|
-
useSkipoState
|
|
18
|
-
} from "./chunk-EW4ACSZB.js";
|
|
19
|
-
import {
|
|
20
|
-
CommandApi,
|
|
21
|
-
GhostStore,
|
|
22
|
-
GraphStore
|
|
23
|
-
} from "./chunk-4UVGXFEM.js";
|
|
24
|
-
import {
|
|
25
|
-
BaseGraph,
|
|
26
|
-
BaseNode,
|
|
27
|
-
BaseViewWindow,
|
|
28
|
-
CustomGraph,
|
|
29
|
-
CustomNode,
|
|
30
|
-
CustomViewWindow,
|
|
31
|
-
DEFAULT_GRAPH_SETTINGS
|
|
32
|
-
} from "./chunk-KG6QYS26.js";
|
|
33
10
|
import {
|
|
34
11
|
AttractionEngine,
|
|
35
12
|
GhostInferenceEngine,
|
|
@@ -45,6 +22,20 @@ import {
|
|
|
45
22
|
WireTypeRegistry,
|
|
46
23
|
initializeDefaultGraphRules
|
|
47
24
|
} from "./chunk-TZOL3RN7.js";
|
|
25
|
+
import {
|
|
26
|
+
CommandApi,
|
|
27
|
+
GhostStore,
|
|
28
|
+
GraphStore
|
|
29
|
+
} from "./chunk-4UVGXFEM.js";
|
|
30
|
+
import {
|
|
31
|
+
BaseGraph,
|
|
32
|
+
BaseNode,
|
|
33
|
+
BaseViewWindow,
|
|
34
|
+
CustomGraph,
|
|
35
|
+
CustomNode,
|
|
36
|
+
CustomViewWindow,
|
|
37
|
+
DEFAULT_GRAPH_SETTINGS
|
|
38
|
+
} from "./chunk-KG6QYS26.js";
|
|
48
39
|
import {
|
|
49
40
|
AutoSolidify,
|
|
50
41
|
SpatialEngine,
|
|
@@ -58,12 +49,21 @@ import {
|
|
|
58
49
|
import {
|
|
59
50
|
CompatibilityMatrix
|
|
60
51
|
} from "./chunk-ISFNY7EZ.js";
|
|
52
|
+
import {
|
|
53
|
+
LifecycleCycleError,
|
|
54
|
+
LifecycleGraph,
|
|
55
|
+
SKIPO_STATE,
|
|
56
|
+
SkipoStateEngine,
|
|
57
|
+
useLifecycleScope,
|
|
58
|
+
useSkipoBind,
|
|
59
|
+
useSkipoState
|
|
60
|
+
} from "./chunk-EW4ACSZB.js";
|
|
61
61
|
import "./chunk-QGM4M3NI.js";
|
|
62
62
|
|
|
63
63
|
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
64
64
|
import { randomUUID } from "crypto";
|
|
65
65
|
|
|
66
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
66
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/define-api.js
|
|
67
67
|
function defineApi(definition) {
|
|
68
68
|
const properties = Object.fromEntries(definition.parameters.map((parameter) => [
|
|
69
69
|
parameter.name,
|
|
@@ -84,7 +84,7 @@ function defineApi(definition) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
87
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/array-apis.js
|
|
88
88
|
var array = { type: "array" };
|
|
89
89
|
var integer = { type: "integer" };
|
|
90
90
|
var arrayApis = [
|
|
@@ -95,7 +95,7 @@ var arrayApis = [
|
|
|
95
95
|
defineApi({ id: "gutts.arrays.last", name: "last", category: "arrays", description: "Returns the final element of an array, or undefined when the array is empty.", parameters: [{ name: "values", description: "The array whose final element should be returned.", required: true, schema: array }], output: { description: "The final array element, or undefined for an empty array." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
96
96
|
];
|
|
97
97
|
|
|
98
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
98
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/json-apis.js
|
|
99
99
|
var json = { type: "object", description: "A JSON-compatible value." };
|
|
100
100
|
var jsonApis = [
|
|
101
101
|
defineApi({ id: "gutts.json.isJsonValue", name: "isJsonValue", category: "json", description: "Checks whether an unknown value can be represented as a finite JSON value.", parameters: [{ name: "value", description: "The value to validate as JSON-compatible data.", required: true, schema: {} }], output: { type: "boolean", description: "True when the value is a valid JSON value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -104,7 +104,7 @@ var jsonApis = [
|
|
|
104
104
|
defineApi({ id: "gutts.json.stringifyJson", name: "stringifyJson", category: "json", description: "Serializes a JSON-compatible value into JSON text, optionally using indentation.", parameters: [{ name: "value", description: "The JSON-compatible value to serialize.", required: true, schema: {} }, { name: "space", description: "Optional number of indentation spaces to use in the serialized output.", required: false, schema: { type: "number" } }], output: { type: "string", description: "The serialized JSON text." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws TypeError when the value cannot be serialized as JSON."] })
|
|
105
105
|
];
|
|
106
106
|
|
|
107
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
107
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/number-apis.js
|
|
108
108
|
var numberApis = [
|
|
109
109
|
defineApi({ id: "gutts.numbers.clamp", name: "clamp", category: "numbers", description: "Restricts a numeric value to an inclusive minimum and maximum range.", parameters: [{ name: "value", description: "The numeric value to constrain.", required: true, schema: { type: "number" } }, { name: "min", description: "The inclusive lower bound.", required: true, schema: { type: "number" } }, { name: "max", description: "The inclusive upper bound.", required: true, schema: { type: "number" } }], output: { type: "number", description: "The value constrained to the inclusive range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
110
110
|
defineApi({ id: "gutts.numbers.inRange", name: "inRange", category: "numbers", description: "Checks whether a numeric value falls within the configured range.", parameters: [{ name: "value", description: "The numeric value to test.", required: true, schema: { type: "number" } }, { name: "min", description: "The lower range boundary.", required: true, schema: { type: "number" } }, { name: "max", description: "The upper range boundary.", required: true, schema: { type: "number" } }], output: { type: "boolean", description: "Whether the value is inside the range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
@@ -113,7 +113,7 @@ var numberApis = [
|
|
|
113
113
|
defineApi({ id: "gutts.numbers.sum", name: "sum", category: "numbers", description: "Adds all numbers in an array and returns their total.", parameters: [{ name: "values", description: "The numeric values to add.", required: true, schema: { type: "array", items: { type: "number" } } }], output: { type: "number", description: "The sum of all input numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
114
114
|
];
|
|
115
115
|
|
|
116
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
116
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
|
|
117
117
|
var objectApis = [
|
|
118
118
|
defineApi({ id: "gutts.objects.hasOwn", name: "hasOwn", category: "objects", description: "Checks whether an object contains a requested property.", parameters: [{ name: "value", description: "The object to inspect.", required: true, schema: { type: "object" } }, { name: "key", description: "The property key to look for.", required: true, schema: { type: "string" } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
119
119
|
defineApi({ id: "gutts.objects.pick", name: "pick", category: "objects", description: "Creates an object containing only requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to retain.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -121,7 +121,7 @@ var objectApis = [
|
|
|
121
121
|
defineApi({ id: "gutts.objects.isPlainObject", name: "isPlainObject", category: "objects", description: "Checks whether a value is a plain JavaScript object.", parameters: [{ name: "value", description: "The value to classify.", required: true, schema: {} }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
122
122
|
];
|
|
123
123
|
|
|
124
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
124
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
|
|
125
125
|
var string = { type: "string" };
|
|
126
126
|
var stringApis = [
|
|
127
127
|
defineApi({ id: "gutts.strings.isBlank", name: "isBlank", category: "strings", description: "Checks whether a string contains no non-whitespace characters.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -137,7 +137,7 @@ var stringApis = [
|
|
|
137
137
|
defineApi({ id: "gutts.strings.truncateWords", name: "truncateWords", category: "strings", description: "Shortens a string to a maximum number of words and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxWords", description: "The non-negative maximum number of words.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxWords is negative."] })
|
|
138
138
|
];
|
|
139
139
|
|
|
140
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
140
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
|
|
141
141
|
var string2 = { type: "string" };
|
|
142
142
|
var urlApis = [
|
|
143
143
|
defineApi({ id: "gutts.urls.isUrl", name: "isUrl", category: "urls", description: "Checks whether a string can be parsed as a URL by the standard URL constructor.", parameters: [{ name: "value", description: "The string to validate.", required: true, schema: string2 }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -146,7 +146,7 @@ var urlApis = [
|
|
|
146
146
|
defineApi({ id: "gutts.urls.setQueryParam", name: "setQueryParam", category: "urls", description: "Returns a URL with one query-string parameter set to the supplied value.", parameters: [{ name: "url", description: "The URL to modify.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }, { name: "value", description: "The query parameter value.", required: true, schema: string2 }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws when url cannot be parsed as a URL."] })
|
|
147
147
|
];
|
|
148
148
|
|
|
149
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
149
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
|
|
150
150
|
var needle3Metadata = {
|
|
151
151
|
id: "model.cactus-needle3",
|
|
152
152
|
name: "Needle 3",
|
|
@@ -177,12 +177,12 @@ var needle3CompleteApi = defineApi({
|
|
|
177
177
|
semantics: { deterministic: false, pure: false, sideEffects: false }
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
180
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
|
|
181
181
|
import fs from "fs";
|
|
182
182
|
import path from "path";
|
|
183
183
|
import os from "os";
|
|
184
184
|
|
|
185
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
185
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
|
|
186
186
|
var smolLM2Metadata = {
|
|
187
187
|
id: "model.smollm2-135m-instruct",
|
|
188
188
|
name: "SmolLM2-135M-Instruct",
|
|
@@ -214,7 +214,7 @@ var smolLM2GenerateApi = defineApi({
|
|
|
214
214
|
errors: ["Model load failure", "Inference failure"]
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
217
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
|
|
218
218
|
var whistleMetadata = {
|
|
219
219
|
id: "model.cactus-whistle",
|
|
220
220
|
name: "Whistle",
|
|
@@ -244,7 +244,7 @@ var whistleTranscribeApi = defineApi({
|
|
|
244
244
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
247
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
|
|
248
248
|
var defineEttin = (id2, name, parameters, description) => ({
|
|
249
249
|
id: id2,
|
|
250
250
|
name,
|
|
@@ -279,7 +279,7 @@ var ettinRerankApi = defineApi({
|
|
|
279
279
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
282
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
|
|
283
283
|
var miniLML6Metadata = {
|
|
284
284
|
id: "model.minilm-l6-v2",
|
|
285
285
|
name: "MiniLM-L6-v2",
|
|
@@ -310,7 +310,7 @@ var miniLMSimilarityApi = defineApi({
|
|
|
310
310
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
313
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
|
|
314
314
|
var guttsApiDefinitions = Object.freeze([
|
|
315
315
|
...arrayApis,
|
|
316
316
|
...jsonApis,
|
|
@@ -326,7 +326,7 @@ var guttsApiDefinitions = Object.freeze([
|
|
|
326
326
|
]);
|
|
327
327
|
var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
|
|
328
328
|
|
|
329
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
329
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
|
|
330
330
|
var schemaType = (schema) => String(schema?.type ?? "any");
|
|
331
331
|
function guttsApiToFodNode(api) {
|
|
332
332
|
return {
|
|
@@ -342,7 +342,7 @@ function guttsApiToFodNode(api) {
|
|
|
342
342
|
}
|
|
343
343
|
var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
|
|
344
344
|
|
|
345
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.
|
|
345
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.3_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
|
|
346
346
|
var guttsModelDefinitions = Object.freeze([
|
|
347
347
|
smolLM2Metadata,
|
|
348
348
|
needle3Metadata,
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { SkipoBase } from '@ultrst-armada/kloks/functions';
|
|
2
|
-
|
|
3
|
-
type UserRole = 'user' | 'admin';
|
|
4
|
-
interface User {
|
|
5
|
-
id: string;
|
|
6
|
-
email: string;
|
|
7
|
-
passwordHash: string;
|
|
8
|
-
role: UserRole;
|
|
9
|
-
displayName?: string;
|
|
10
|
-
createdAt: number;
|
|
11
|
-
updatedAt: number;
|
|
12
|
-
}
|
|
13
|
-
interface AuthCredentials {
|
|
14
|
-
email: string;
|
|
15
|
-
password: string;
|
|
16
|
-
}
|
|
17
|
-
interface AuthSession {
|
|
18
|
-
token: string;
|
|
19
|
-
userId: string;
|
|
20
|
-
role: UserRole;
|
|
21
|
-
expiresAt: number;
|
|
22
|
-
}
|
|
23
|
-
interface SignupInput {
|
|
24
|
-
email: string;
|
|
25
|
-
password: string;
|
|
26
|
-
displayName?: string;
|
|
27
|
-
}
|
|
28
|
-
interface CreateUserData {
|
|
29
|
-
email: string;
|
|
30
|
-
passwordHash: string;
|
|
31
|
-
role: UserRole;
|
|
32
|
-
displayName?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare class SessionManager {
|
|
36
|
-
private ttl;
|
|
37
|
-
constructor(ttlMs?: number);
|
|
38
|
-
generateToken(userId: string): string;
|
|
39
|
-
createSession(userId: string, role: UserRole): AuthSession;
|
|
40
|
-
isValid(session: AuthSession): boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
declare class RateLimiter {
|
|
44
|
-
private attempts;
|
|
45
|
-
private windowMs;
|
|
46
|
-
private maxUser;
|
|
47
|
-
private maxAdmin;
|
|
48
|
-
constructor(windowMs?: number, maxUser?: number, maxAdmin?: number);
|
|
49
|
-
check(identifier: string, isAdminAttempt?: boolean): void;
|
|
50
|
-
reset(identifier: string): void;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
declare abstract class BaseAccountProvider extends SkipoBase {
|
|
54
|
-
protected rateLimiter: RateLimiter;
|
|
55
|
-
protected sessionManager: SessionManager;
|
|
56
|
-
abstract findUserByEmail(email: string): Promise<User | null>;
|
|
57
|
-
abstract findUserById(id: string): Promise<User | null>;
|
|
58
|
-
abstract createUser(data: CreateUserData): Promise<User>;
|
|
59
|
-
abstract updateUser(id: string, data: Partial<User>): Promise<User>;
|
|
60
|
-
abstract listUsers(): Promise<User[]>;
|
|
61
|
-
authenticate(credentials: AuthCredentials): Promise<AuthSession>;
|
|
62
|
-
signup(input: SignupInput): Promise<User>;
|
|
63
|
-
verifySession(token: string | null): Promise<AuthSession | null>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { type AuthCredentials as A, BaseAccountProvider as B, type CreateUserData as C, RateLimiter as R, SessionManager as S, type User as U, type AuthSession as a, type SignupInput as b, type UserRole as c };
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// src/auth/SessionManager.ts
|
|
2
|
-
var SessionManager = class {
|
|
3
|
-
ttl;
|
|
4
|
-
constructor(ttlMs = 864e5) {
|
|
5
|
-
this.ttl = ttlMs;
|
|
6
|
-
}
|
|
7
|
-
generateToken(userId) {
|
|
8
|
-
return `sess::${userId}::${Date.now()}::${Math.random().toString(36).substring(2, 9)}`;
|
|
9
|
-
}
|
|
10
|
-
createSession(userId, role) {
|
|
11
|
-
return {
|
|
12
|
-
token: this.generateToken(userId),
|
|
13
|
-
userId,
|
|
14
|
-
role,
|
|
15
|
-
expiresAt: Date.now() + this.ttl
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
isValid(session) {
|
|
19
|
-
return Date.now() < session.expiresAt;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// src/auth/RateLimiter.ts
|
|
24
|
-
var RateLimiter = class {
|
|
25
|
-
attempts = /* @__PURE__ */ new Map();
|
|
26
|
-
windowMs;
|
|
27
|
-
maxUser;
|
|
28
|
-
maxAdmin;
|
|
29
|
-
constructor(windowMs = 9e5, maxUser = 5, maxAdmin = 3) {
|
|
30
|
-
this.windowMs = windowMs;
|
|
31
|
-
this.maxUser = maxUser;
|
|
32
|
-
this.maxAdmin = maxAdmin;
|
|
33
|
-
}
|
|
34
|
-
check(identifier, isAdminAttempt = false) {
|
|
35
|
-
const now = Date.now();
|
|
36
|
-
let record = this.attempts.get(identifier);
|
|
37
|
-
if (!record || now - record.windowStart > this.windowMs) {
|
|
38
|
-
record = { count: 0, windowStart: now };
|
|
39
|
-
this.attempts.set(identifier, record);
|
|
40
|
-
}
|
|
41
|
-
record.count++;
|
|
42
|
-
const limit = isAdminAttempt ? this.maxAdmin : this.maxUser;
|
|
43
|
-
if (record.count > limit) {
|
|
44
|
-
throw new Error("Too many requests. Please try again later.");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
reset(identifier) {
|
|
48
|
-
this.attempts.delete(identifier);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/auth/CanonicalAuthClient.ts
|
|
53
|
-
var cleanBaseUrl = (value) => value.trim().replace(/\/+$/, "");
|
|
54
|
-
var CanonicalAuthClient = class {
|
|
55
|
-
baseUrl;
|
|
56
|
-
fetcher;
|
|
57
|
-
credentials;
|
|
58
|
-
constructor(options) {
|
|
59
|
-
if (!options.baseUrl?.trim()) throw new Error("Canonical auth base URL is required.");
|
|
60
|
-
this.baseUrl = cleanBaseUrl(options.baseUrl);
|
|
61
|
-
this.fetcher = options.fetcher ?? fetch;
|
|
62
|
-
this.credentials = options.credentials ?? "include";
|
|
63
|
-
}
|
|
64
|
-
async request(path, init = {}) {
|
|
65
|
-
const response = await this.fetcher(`${this.baseUrl}/api/auth${path}`, {
|
|
66
|
-
...init,
|
|
67
|
-
credentials: this.credentials,
|
|
68
|
-
headers: { "Content-Type": "application/json", ...init.headers ?? {} }
|
|
69
|
-
});
|
|
70
|
-
const text = await response.text();
|
|
71
|
-
let data = {};
|
|
72
|
-
try {
|
|
73
|
-
data = text ? JSON.parse(text) : {};
|
|
74
|
-
} catch {
|
|
75
|
-
data = { message: text };
|
|
76
|
-
}
|
|
77
|
-
return { status: response.status, data, token: response.headers.get("set-auth-token") ?? void 0 };
|
|
78
|
-
}
|
|
79
|
-
async signInEmail(email, password) {
|
|
80
|
-
const result = await this.request("/sign-in/email", {
|
|
81
|
-
method: "POST",
|
|
82
|
-
body: JSON.stringify({ email: email.trim().toLowerCase(), password })
|
|
83
|
-
});
|
|
84
|
-
if (result.status >= 400 || result.data?.error) {
|
|
85
|
-
return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Authentication failed." };
|
|
86
|
-
}
|
|
87
|
-
return { success: true, status: result.status, user: result.data?.user, session: result.data?.session, token: result.token };
|
|
88
|
-
}
|
|
89
|
-
async signUpEmail(email, password, name) {
|
|
90
|
-
const result = await this.request("/sign-up/email", {
|
|
91
|
-
method: "POST",
|
|
92
|
-
body: JSON.stringify({ email: email.trim().toLowerCase(), password, name: name.trim() })
|
|
93
|
-
});
|
|
94
|
-
if (result.status >= 400 || result.data?.error) {
|
|
95
|
-
return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Registration failed." };
|
|
96
|
-
}
|
|
97
|
-
return { success: true, status: result.status, user: result.data?.user, session: result.data?.session, token: result.data?.token ?? result.data?.session?.token };
|
|
98
|
-
}
|
|
99
|
-
async signInGoogle(callbackURL) {
|
|
100
|
-
const result = await this.request("/sign-in/social", {
|
|
101
|
-
method: "POST",
|
|
102
|
-
body: JSON.stringify({ provider: "google", callbackURL })
|
|
103
|
-
});
|
|
104
|
-
if (result.status >= 400 || result.data?.error) {
|
|
105
|
-
return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Google sign-in failed." };
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
success: true,
|
|
109
|
-
status: result.status,
|
|
110
|
-
user: result.data?.user,
|
|
111
|
-
session: result.data?.session,
|
|
112
|
-
redirectUrl: result.data?.url ?? result.data?.redirect
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
async requestGoogleDriveAccess(callbackURL) {
|
|
116
|
-
const result = await this.request("/link-social", {
|
|
117
|
-
method: "POST",
|
|
118
|
-
body: JSON.stringify({
|
|
119
|
-
provider: "google",
|
|
120
|
-
scopes: ["https://www.googleapis.com/auth/drive.file"],
|
|
121
|
-
...callbackURL ? { callbackURL } : {}
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
if (result.status >= 400 || result.data?.error) {
|
|
125
|
-
return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Google Drive authorization failed." };
|
|
126
|
-
}
|
|
127
|
-
return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
|
|
128
|
-
}
|
|
129
|
-
async getSession(cookie) {
|
|
130
|
-
const headers = {};
|
|
131
|
-
if (cookie) headers.Cookie = cookie;
|
|
132
|
-
const result = await this.request("/get-session", { headers });
|
|
133
|
-
if (result.status >= 400 || !result.data?.user) return null;
|
|
134
|
-
return result.data;
|
|
135
|
-
}
|
|
136
|
-
async getSessionWithToken(token) {
|
|
137
|
-
if (!token?.trim()) return null;
|
|
138
|
-
const result = await this.request("/get-session", { headers: { Authorization: `Bearer ${token}` } });
|
|
139
|
-
if (result.status >= 400 || !result.data?.user) return null;
|
|
140
|
-
return result.data;
|
|
141
|
-
}
|
|
142
|
-
async signOut() {
|
|
143
|
-
const result = await this.request("/sign-out", { method: "POST", body: "{}" });
|
|
144
|
-
return result.status < 400 && !result.data?.error;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
function createCanonicalAuthClient(baseUrl, fetcher) {
|
|
148
|
-
return new CanonicalAuthClient({ baseUrl, fetcher });
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/auth/UnifiedAuthCore.ts
|
|
152
|
-
function requireAuthBaseUrl(env) {
|
|
153
|
-
const baseUrl = String(env?.SRKL_AUTH_BASE_URL ?? (typeof process !== "undefined" ? process.env.SRKL_AUTH_BASE_URL : "") ?? "").trim();
|
|
154
|
-
if (!baseUrl) {
|
|
155
|
-
throw new Error("SRKL_AUTH_BASE_URL is required. Local application auth is not supported.");
|
|
156
|
-
}
|
|
157
|
-
return baseUrl;
|
|
158
|
-
}
|
|
159
|
-
async function loginSystemUser(email, rawPass, isAdmin, _queryDb, env) {
|
|
160
|
-
if (!email?.trim() || !rawPass) return { success: false, status: 400, error: "Email and password are required" };
|
|
161
|
-
try {
|
|
162
|
-
const client = createCanonicalAuthClient(requireAuthBaseUrl(env));
|
|
163
|
-
const result = await client.signInEmail(email, rawPass);
|
|
164
|
-
if (!result.success || !result.user) {
|
|
165
|
-
return { success: false, status: result.status, error: result.error ?? "Invalid email or password" };
|
|
166
|
-
}
|
|
167
|
-
if (isAdmin && result.user.role !== "admin") {
|
|
168
|
-
return { success: false, status: 403, error: "Insufficient administrative privileges" };
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
success: true,
|
|
172
|
-
status: result.status,
|
|
173
|
-
user: {
|
|
174
|
-
...result.user,
|
|
175
|
-
username: result.user.username ?? result.user.email.split("@")[0],
|
|
176
|
-
role: result.user.role ?? "user",
|
|
177
|
-
status: result.user.status ?? "ACTIVE"
|
|
178
|
-
},
|
|
179
|
-
token: typeof result.session?.token === "string" ? result.session.token : void 0
|
|
180
|
-
};
|
|
181
|
-
} catch (error) {
|
|
182
|
-
return { success: false, status: 503, error: error instanceof Error ? error.message : "Canonical authentication service unavailable" };
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async function resolveUserFromToken(tokenOrUserId, _queryDb, env) {
|
|
186
|
-
if (!tokenOrUserId) return null;
|
|
187
|
-
try {
|
|
188
|
-
const client = createCanonicalAuthClient(requireAuthBaseUrl(env));
|
|
189
|
-
const credential = tokenOrUserId.trim();
|
|
190
|
-
if (!credential) return null;
|
|
191
|
-
const token = credential.replace(/^Bearer[ \t]+/i, "").trim();
|
|
192
|
-
if (!token) return null;
|
|
193
|
-
const session = await client.getSession(`better-auth.session_token=${token}`);
|
|
194
|
-
if (!session?.user) return null;
|
|
195
|
-
return {
|
|
196
|
-
...session.user,
|
|
197
|
-
username: session.user.username ?? session.user.email.split("@")[0],
|
|
198
|
-
role: session.user.role ?? "user",
|
|
199
|
-
status: session.user.status ?? "ACTIVE"
|
|
200
|
-
};
|
|
201
|
-
} catch {
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export {
|
|
207
|
-
SessionManager,
|
|
208
|
-
RateLimiter,
|
|
209
|
-
CanonicalAuthClient,
|
|
210
|
-
createCanonicalAuthClient,
|
|
211
|
-
loginSystemUser,
|
|
212
|
-
resolveUserFromToken
|
|
213
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RateLimiter,
|
|
3
|
-
SessionManager
|
|
4
|
-
} from "./chunk-2HCQ2SIR.js";
|
|
5
|
-
|
|
6
|
-
// src/auth/PasswordHasher.ts
|
|
7
|
-
var bcrypt = null;
|
|
8
|
-
try {
|
|
9
|
-
bcrypt = (await import("bcryptjs")).default;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
console.warn("[Skipo] bcryptjs not installed. Using fallback hashing (DEV ONLY).");
|
|
12
|
-
}
|
|
13
|
-
var PasswordHasher = class {
|
|
14
|
-
static async hash(password, saltRounds = 10) {
|
|
15
|
-
if (bcrypt) {
|
|
16
|
-
return bcrypt.hash(password, saltRounds);
|
|
17
|
-
}
|
|
18
|
-
return `fallback_hash_${Buffer.from(password).toString("base64")}`;
|
|
19
|
-
}
|
|
20
|
-
static async verify(password, hash) {
|
|
21
|
-
if (bcrypt) {
|
|
22
|
-
return bcrypt.compare(password, hash);
|
|
23
|
-
}
|
|
24
|
-
return hash === `fallback_hash_${Buffer.from(password).toString("base64")}`;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// src/auth/BaseAccountProvider.ts
|
|
29
|
-
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
30
|
-
var BaseAccountProvider = class extends SkipoBase {
|
|
31
|
-
rateLimiter = new RateLimiter();
|
|
32
|
-
sessionManager = new SessionManager();
|
|
33
|
-
async authenticate(credentials) {
|
|
34
|
-
this.rateLimiter.check(credentials.email);
|
|
35
|
-
const user = await this.findUserByEmail(credentials.email);
|
|
36
|
-
if (!user) {
|
|
37
|
-
throw new Error("Invalid credentials.");
|
|
38
|
-
}
|
|
39
|
-
const isValid = await PasswordHasher.verify(credentials.password, user.passwordHash);
|
|
40
|
-
if (!isValid) {
|
|
41
|
-
throw new Error("Invalid credentials.");
|
|
42
|
-
}
|
|
43
|
-
this.rateLimiter.reset(credentials.email);
|
|
44
|
-
return this.sessionManager.createSession(user.id, user.role);
|
|
45
|
-
}
|
|
46
|
-
async signup(input) {
|
|
47
|
-
const existing = await this.findUserByEmail(input.email);
|
|
48
|
-
if (existing) {
|
|
49
|
-
throw new Error("Email already in use.");
|
|
50
|
-
}
|
|
51
|
-
const passwordHash = await PasswordHasher.hash(input.password);
|
|
52
|
-
return this.createUser({
|
|
53
|
-
email: input.email,
|
|
54
|
-
passwordHash,
|
|
55
|
-
role: "user",
|
|
56
|
-
// Enforce user role
|
|
57
|
-
displayName: input.displayName
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
async verifySession(token) {
|
|
61
|
-
if (!token) return null;
|
|
62
|
-
const parts = token.split("::");
|
|
63
|
-
if (parts.length >= 4 && parts[0] === "sess") {
|
|
64
|
-
const userId = parts[1];
|
|
65
|
-
const user = await this.findUserById(userId);
|
|
66
|
-
if (user) {
|
|
67
|
-
const issueTime = parseInt(parts[2], 10);
|
|
68
|
-
if (Date.now() - issueTime < 864e5) {
|
|
69
|
-
return {
|
|
70
|
-
token,
|
|
71
|
-
userId: user.id,
|
|
72
|
-
role: user.role,
|
|
73
|
-
expiresAt: issueTime + 864e5
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/auth/LocalAccountProvider.ts
|
|
83
|
-
import { promises as fs } from "fs";
|
|
84
|
-
import path from "path";
|
|
85
|
-
var LocalAccountProvider = class extends BaseAccountProvider {
|
|
86
|
-
filePath;
|
|
87
|
-
users = /* @__PURE__ */ new Map();
|
|
88
|
-
isLoaded = false;
|
|
89
|
-
constructor(filePath = ".skipo/accounts.json") {
|
|
90
|
-
super();
|
|
91
|
-
this.filePath = path.resolve(filePath);
|
|
92
|
-
}
|
|
93
|
-
async load() {
|
|
94
|
-
if (this.isLoaded) return;
|
|
95
|
-
try {
|
|
96
|
-
await fs.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
97
|
-
const data = await fs.readFile(this.filePath, "utf-8");
|
|
98
|
-
const parsed = JSON.parse(data);
|
|
99
|
-
for (const [id, user] of Object.entries(parsed)) {
|
|
100
|
-
this.users.set(id, user);
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {
|
|
103
|
-
if (e.code !== "ENOENT") {
|
|
104
|
-
throw e;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
this.isLoaded = true;
|
|
108
|
-
}
|
|
109
|
-
async persist() {
|
|
110
|
-
const data = Object.fromEntries(this.users);
|
|
111
|
-
await fs.writeFile(this.filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
112
|
-
}
|
|
113
|
-
async findUserByEmail(email) {
|
|
114
|
-
await this.load();
|
|
115
|
-
for (const user of this.users.values()) {
|
|
116
|
-
if (user.email === email) return user;
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
async findUserById(id) {
|
|
121
|
-
await this.load();
|
|
122
|
-
return this.users.get(id) || null;
|
|
123
|
-
}
|
|
124
|
-
async createUser(data) {
|
|
125
|
-
await this.load();
|
|
126
|
-
const isFirst = this.users.size === 0;
|
|
127
|
-
const user = {
|
|
128
|
-
id: `usr_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
|
|
129
|
-
email: data.email,
|
|
130
|
-
passwordHash: data.passwordHash,
|
|
131
|
-
role: isFirst ? "admin" : data.role,
|
|
132
|
-
displayName: data.displayName,
|
|
133
|
-
createdAt: Date.now(),
|
|
134
|
-
updatedAt: Date.now()
|
|
135
|
-
};
|
|
136
|
-
this.users.set(user.id, user);
|
|
137
|
-
await this.persist();
|
|
138
|
-
return user;
|
|
139
|
-
}
|
|
140
|
-
async updateUser(id, data) {
|
|
141
|
-
await this.load();
|
|
142
|
-
const user = this.users.get(id);
|
|
143
|
-
if (!user) throw new Error("User not found");
|
|
144
|
-
const updated = { ...user, ...data, updatedAt: Date.now() };
|
|
145
|
-
this.users.set(id, updated);
|
|
146
|
-
await this.persist();
|
|
147
|
-
return updated;
|
|
148
|
-
}
|
|
149
|
-
async listUsers() {
|
|
150
|
-
await this.load();
|
|
151
|
-
return Array.from(this.users.values());
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// src/auth/AdminGuard.ts
|
|
156
|
-
import { SkipoBase as SkipoBase2 } from "@ultrst-armada/kloks/functions";
|
|
157
|
-
var AdminGuard = class _AdminGuard extends SkipoBase2 {
|
|
158
|
-
static async verify(authHeaderOrToken, provider) {
|
|
159
|
-
const session = await _AdminGuard.verifyUser(authHeaderOrToken, provider);
|
|
160
|
-
if (session.role !== "admin") {
|
|
161
|
-
throw new Error("Forbidden: Admin access required.");
|
|
162
|
-
}
|
|
163
|
-
return session;
|
|
164
|
-
}
|
|
165
|
-
static async verifyUser(authHeaderOrToken, provider) {
|
|
166
|
-
const token = authHeaderOrToken?.startsWith("Bearer ") ? authHeaderOrToken.substring(7).trim() : authHeaderOrToken?.trim() || null;
|
|
167
|
-
const session = await provider.verifySession(token);
|
|
168
|
-
if (!session) {
|
|
169
|
-
throw new Error("Unauthorized: Invalid or missing session token.");
|
|
170
|
-
}
|
|
171
|
-
return session;
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export {
|
|
176
|
-
PasswordHasher,
|
|
177
|
-
BaseAccountProvider,
|
|
178
|
-
LocalAccountProvider,
|
|
179
|
-
AdminGuard
|
|
180
|
-
};
|