@drisp/cli 0.4.0 → 0.4.2
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/dist/{WorkflowInstallWizard-5JWVHIVJ.js → WorkflowInstallWizard-NDWLVIFI.js} +5 -3
- package/dist/athena-gateway.js +27 -113
- package/dist/chunk-2HR7FV3M.js +502 -0
- package/dist/{chunk-3FVULBV4.js → chunk-4CRZXLIP.js} +53 -117
- package/dist/chunk-6TJHAUNB.js +161 -0
- package/dist/{chunk-PSD3WBN4.js → chunk-BTKQ67RE.js} +1 -1
- package/dist/{chunk-LPG5WBPV.js → chunk-GE6PPB6Z.js} +11 -511
- package/dist/chunk-HXBCZAP7.js +1 -0
- package/dist/chunk-WHELLVBL.js +12361 -0
- package/dist/cli.js +3232 -13774
- package/dist/dashboard-daemon.js +255 -0
- package/dist/hook-forwarder.js +2 -1
- package/package.json +3 -2
|
@@ -78,7 +78,8 @@ function initTelemetry(options) {
|
|
|
78
78
|
host: POSTHOG_HOST,
|
|
79
79
|
disableGeoip: true,
|
|
80
80
|
flushAt: 20,
|
|
81
|
-
flushInterval: 3e4
|
|
81
|
+
flushInterval: 3e4,
|
|
82
|
+
enableExceptionAutocapture: true
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
function isTelemetryEnabled() {
|
|
@@ -191,97 +192,18 @@ function trackGatewayRuntimeRebind(props) {
|
|
|
191
192
|
function trackGatewayRuntimeExpired(props) {
|
|
192
193
|
capture("gateway.runtime.expired", props);
|
|
193
194
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
import fs from "fs";
|
|
197
|
-
function writeGatewayTrace(message) {
|
|
198
|
-
if (process.env["ATHENA_GATEWAY_TRACE"] !== "1") return;
|
|
199
|
-
const line = `athena-gateway: [trace] ${message}
|
|
200
|
-
`;
|
|
201
|
-
const traceFile = process.env["ATHENA_GATEWAY_TRACE_FILE"];
|
|
202
|
-
if (traceFile && traceFile.length > 0) {
|
|
203
|
-
try {
|
|
204
|
-
fs.appendFileSync(traceFile, line, "utf-8");
|
|
205
|
-
return;
|
|
206
|
-
} catch {
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
process.stderr.write(line);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// src/gateway/auth.ts
|
|
213
|
-
import crypto from "crypto";
|
|
214
|
-
import fs2 from "fs";
|
|
215
|
-
import path2 from "path";
|
|
216
|
-
var TOKEN_BYTES = 32;
|
|
217
|
-
function loadOrCreateToken(tokenPath) {
|
|
218
|
-
try {
|
|
219
|
-
const buf = fs2.readFileSync(tokenPath);
|
|
220
|
-
const text = buf.toString("utf-8").trim();
|
|
221
|
-
if (text.length >= 16) return text;
|
|
222
|
-
} catch (err) {
|
|
223
|
-
const code = err.code;
|
|
224
|
-
if (code !== "ENOENT") throw err;
|
|
225
|
-
}
|
|
226
|
-
return writeNewToken(tokenPath);
|
|
227
|
-
}
|
|
228
|
-
function rotateGatewayToken(tokenPath) {
|
|
229
|
-
return writeNewToken(tokenPath);
|
|
230
|
-
}
|
|
231
|
-
function writeNewToken(tokenPath) {
|
|
232
|
-
const dir = path2.dirname(tokenPath);
|
|
233
|
-
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
234
|
-
const token = crypto.randomBytes(TOKEN_BYTES).toString("base64url");
|
|
235
|
-
const tmpPath = `${tokenPath}.tmp-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
|
|
236
|
-
fs2.writeFileSync(tmpPath, token + "\n", { mode: 384 });
|
|
237
|
-
try {
|
|
238
|
-
fs2.renameSync(tmpPath, tokenPath);
|
|
239
|
-
} catch (err) {
|
|
240
|
-
try {
|
|
241
|
-
fs2.unlinkSync(tmpPath);
|
|
242
|
-
} catch {
|
|
243
|
-
}
|
|
244
|
-
throw err;
|
|
245
|
-
}
|
|
246
|
-
if (process.platform !== "win32") {
|
|
247
|
-
fs2.chmodSync(dir, 448);
|
|
248
|
-
fs2.chmodSync(tokenPath, 384);
|
|
249
|
-
}
|
|
250
|
-
return token;
|
|
251
|
-
}
|
|
252
|
-
function timingSafeTokenEqual(a, b) {
|
|
253
|
-
const ab = Buffer.from(a, "utf-8");
|
|
254
|
-
const bb = Buffer.from(b, "utf-8");
|
|
255
|
-
if (ab.length !== bb.length) {
|
|
256
|
-
const filler = Buffer.alloc(Math.max(ab.length, bb.length));
|
|
257
|
-
crypto.timingSafeEqual(filler, filler);
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
return crypto.timingSafeEqual(ab, bb);
|
|
261
|
-
}
|
|
262
|
-
function requireTokenForBind(spec, token) {
|
|
263
|
-
if (spec.kind === "uds" || isLoopbackHost(spec.host)) return;
|
|
264
|
-
if (!token || token.length < 16) {
|
|
265
|
-
throw new Error(
|
|
266
|
-
`gateway: refusing to bind ${spec.host}:${spec.port} without token configured`
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
if (spec.tls) return;
|
|
270
|
-
if (!spec.insecure) {
|
|
271
|
-
throw new Error(
|
|
272
|
-
`gateway: refusing to bind ${spec.host}:${spec.port} without TLS; pass --tls-cert/--tls-key, or --insecure only for trusted reverse-proxy/tunnel deployments`
|
|
273
|
-
);
|
|
274
|
-
}
|
|
195
|
+
function trackSetupCompleted(props) {
|
|
196
|
+
capture("setup.completed", props);
|
|
275
197
|
}
|
|
276
198
|
|
|
277
199
|
// src/infra/config/dashboardClient.ts
|
|
278
|
-
import
|
|
279
|
-
import
|
|
200
|
+
import crypto from "crypto";
|
|
201
|
+
import fs from "fs";
|
|
280
202
|
import os3 from "os";
|
|
281
|
-
import
|
|
203
|
+
import path2 from "path";
|
|
282
204
|
function dashboardClientConfigPath(env = process.env) {
|
|
283
205
|
const home = env["HOME"] ?? os3.homedir();
|
|
284
|
-
return
|
|
206
|
+
return path2.join(home, ".config", "athena", "dashboard.json");
|
|
285
207
|
}
|
|
286
208
|
function normalizeDashboardUrl(input) {
|
|
287
209
|
let parsed;
|
|
@@ -299,7 +221,7 @@ function readDashboardClientConfig(env = process.env) {
|
|
|
299
221
|
const configPath = dashboardClientConfigPath(env);
|
|
300
222
|
let raw;
|
|
301
223
|
try {
|
|
302
|
-
raw =
|
|
224
|
+
raw = fs.readFileSync(configPath, "utf-8");
|
|
303
225
|
} catch (err) {
|
|
304
226
|
if (err.code === "ENOENT") return null;
|
|
305
227
|
throw err;
|
|
@@ -323,29 +245,29 @@ function readDashboardClientConfig(env = process.env) {
|
|
|
323
245
|
function writeDashboardClientConfig(config, env = process.env) {
|
|
324
246
|
const validated = parseDashboardClientConfig(config);
|
|
325
247
|
const configPath = dashboardClientConfigPath(env);
|
|
326
|
-
const dir =
|
|
327
|
-
|
|
328
|
-
const tmpPath = `${configPath}.${process.pid}.${
|
|
329
|
-
const fd =
|
|
248
|
+
const dir = path2.dirname(configPath);
|
|
249
|
+
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
250
|
+
const tmpPath = `${configPath}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
|
|
251
|
+
const fd = fs.openSync(tmpPath, "w", 384);
|
|
330
252
|
try {
|
|
331
|
-
|
|
332
|
-
|
|
253
|
+
fs.writeSync(fd, JSON.stringify(validated, null, 2) + "\n");
|
|
254
|
+
fs.fsyncSync(fd);
|
|
333
255
|
} finally {
|
|
334
|
-
|
|
256
|
+
fs.closeSync(fd);
|
|
335
257
|
}
|
|
336
258
|
try {
|
|
337
|
-
|
|
259
|
+
fs.renameSync(tmpPath, configPath);
|
|
338
260
|
} catch (err) {
|
|
339
261
|
try {
|
|
340
|
-
|
|
262
|
+
fs.unlinkSync(tmpPath);
|
|
341
263
|
} catch {
|
|
342
264
|
}
|
|
343
265
|
throw err;
|
|
344
266
|
}
|
|
345
267
|
if (process.platform !== "win32") {
|
|
346
268
|
try {
|
|
347
|
-
|
|
348
|
-
|
|
269
|
+
fs.chmodSync(dir, 448);
|
|
270
|
+
fs.chmodSync(configPath, 384);
|
|
349
271
|
} catch {
|
|
350
272
|
}
|
|
351
273
|
}
|
|
@@ -353,7 +275,7 @@ function writeDashboardClientConfig(config, env = process.env) {
|
|
|
353
275
|
function removeDashboardClientConfig(env = process.env) {
|
|
354
276
|
const configPath = dashboardClientConfigPath(env);
|
|
355
277
|
try {
|
|
356
|
-
|
|
278
|
+
fs.unlinkSync(configPath);
|
|
357
279
|
} catch (err) {
|
|
358
280
|
if (err.code !== "ENOENT") throw err;
|
|
359
281
|
}
|
|
@@ -392,7 +314,7 @@ function parseDashboardClientConfig(raw) {
|
|
|
392
314
|
}
|
|
393
315
|
|
|
394
316
|
// src/infra/config/dashboardAuth.ts
|
|
395
|
-
import
|
|
317
|
+
import fs2 from "fs";
|
|
396
318
|
var DEFAULT_LOCK_TIMEOUT_MS = 3e4;
|
|
397
319
|
var DEFAULT_LOCK_POLL_MS = 50;
|
|
398
320
|
var DEFAULT_STALE_LOCK_MS = 6e4;
|
|
@@ -475,14 +397,14 @@ async function withLock(env, deps, fn) {
|
|
|
475
397
|
let fd = null;
|
|
476
398
|
for (; ; ) {
|
|
477
399
|
try {
|
|
478
|
-
fd =
|
|
400
|
+
fd = fs2.openSync(lockPath, "wx", 384);
|
|
479
401
|
break;
|
|
480
402
|
} catch (err) {
|
|
481
403
|
if (err.code !== "EEXIST") throw err;
|
|
482
404
|
try {
|
|
483
|
-
const stat =
|
|
405
|
+
const stat = fs2.statSync(lockPath);
|
|
484
406
|
if (Date.now() - stat.mtimeMs > staleMs) {
|
|
485
|
-
|
|
407
|
+
fs2.unlinkSync(lockPath);
|
|
486
408
|
continue;
|
|
487
409
|
}
|
|
488
410
|
} catch {
|
|
@@ -500,11 +422,11 @@ async function withLock(env, deps, fn) {
|
|
|
500
422
|
return await fn();
|
|
501
423
|
} finally {
|
|
502
424
|
try {
|
|
503
|
-
|
|
425
|
+
fs2.closeSync(fd);
|
|
504
426
|
} catch {
|
|
505
427
|
}
|
|
506
428
|
try {
|
|
507
|
-
|
|
429
|
+
fs2.unlinkSync(lockPath);
|
|
508
430
|
} catch {
|
|
509
431
|
}
|
|
510
432
|
}
|
|
@@ -536,6 +458,23 @@ function truncate(text, max) {
|
|
|
536
458
|
return text.length > max ? text.slice(0, max) + "\u2026" : text;
|
|
537
459
|
}
|
|
538
460
|
|
|
461
|
+
// src/infra/gatewayTrace.ts
|
|
462
|
+
import fs3 from "fs";
|
|
463
|
+
function writeGatewayTrace(message) {
|
|
464
|
+
if (process.env["ATHENA_GATEWAY_TRACE"] !== "1") return;
|
|
465
|
+
const line = `athena-gateway: [trace] ${message}
|
|
466
|
+
`;
|
|
467
|
+
const traceFile = process.env["ATHENA_GATEWAY_TRACE_FILE"];
|
|
468
|
+
if (traceFile && traceFile.length > 0) {
|
|
469
|
+
try {
|
|
470
|
+
fs3.appendFileSync(traceFile, line, "utf-8");
|
|
471
|
+
return;
|
|
472
|
+
} catch {
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
process.stderr.write(line);
|
|
476
|
+
}
|
|
477
|
+
|
|
539
478
|
// src/gateway/transport/types.ts
|
|
540
479
|
var TransportUnreachableError = class extends Error {
|
|
541
480
|
constructor(message) {
|
|
@@ -566,9 +505,9 @@ function redactFrame(value) {
|
|
|
566
505
|
}
|
|
567
506
|
|
|
568
507
|
// src/gateway/transport/uds.ts
|
|
569
|
-
import
|
|
508
|
+
import fs4 from "fs";
|
|
570
509
|
import net from "net";
|
|
571
|
-
import
|
|
510
|
+
import path3 from "path";
|
|
572
511
|
|
|
573
512
|
// src/gateway/transport/framing.ts
|
|
574
513
|
var DEFAULT_MAX_LINE_BYTES = 1024 * 1024;
|
|
@@ -628,7 +567,7 @@ function createUdsClientTransport(opts) {
|
|
|
628
567
|
async function listenUds(opts, onConnection) {
|
|
629
568
|
const logError = opts.logError ?? ((m) => process.stderr.write(m + "\n"));
|
|
630
569
|
await unlinkIfStale(opts.socketPath);
|
|
631
|
-
|
|
570
|
+
fs4.mkdirSync(path3.dirname(opts.socketPath), { recursive: true, mode: 448 });
|
|
632
571
|
const activeSockets = /* @__PURE__ */ new Set();
|
|
633
572
|
const server = net.createServer({ pauseOnConnect: false }, (socket) => {
|
|
634
573
|
activeSockets.add(socket);
|
|
@@ -642,7 +581,7 @@ async function listenUds(opts, onConnection) {
|
|
|
642
581
|
server.off("error", onError);
|
|
643
582
|
try {
|
|
644
583
|
if (process.platform !== "win32") {
|
|
645
|
-
|
|
584
|
+
fs4.chmodSync(opts.socketPath, 384);
|
|
646
585
|
}
|
|
647
586
|
} catch (err) {
|
|
648
587
|
logError(
|
|
@@ -660,7 +599,7 @@ async function listenUds(opts, onConnection) {
|
|
|
660
599
|
activeSockets.clear();
|
|
661
600
|
server.close(() => {
|
|
662
601
|
try {
|
|
663
|
-
|
|
602
|
+
fs4.unlinkSync(opts.socketPath);
|
|
664
603
|
} catch {
|
|
665
604
|
}
|
|
666
605
|
resolve();
|
|
@@ -699,7 +638,7 @@ async function connectUds(opts) {
|
|
|
699
638
|
return createSocketConnection(socket, "uds");
|
|
700
639
|
}
|
|
701
640
|
async function unlinkIfStale(socketPath) {
|
|
702
|
-
if (!
|
|
641
|
+
if (!fs4.existsSync(socketPath)) return;
|
|
703
642
|
const alive = await new Promise((resolve) => {
|
|
704
643
|
const probe = net.connect(socketPath);
|
|
705
644
|
const timer = setTimeout(() => {
|
|
@@ -718,7 +657,7 @@ async function unlinkIfStale(socketPath) {
|
|
|
718
657
|
});
|
|
719
658
|
if (!alive) {
|
|
720
659
|
try {
|
|
721
|
-
|
|
660
|
+
fs4.unlinkSync(socketPath);
|
|
722
661
|
} catch {
|
|
723
662
|
}
|
|
724
663
|
}
|
|
@@ -825,10 +764,7 @@ export {
|
|
|
825
764
|
trackGatewayTransportReconnect,
|
|
826
765
|
trackGatewayRuntimeRebind,
|
|
827
766
|
trackGatewayRuntimeExpired,
|
|
828
|
-
|
|
829
|
-
rotateGatewayToken,
|
|
830
|
-
timingSafeTokenEqual,
|
|
831
|
-
requireTokenForBind,
|
|
767
|
+
trackSetupCompleted,
|
|
832
768
|
dashboardClientConfigPath,
|
|
833
769
|
normalizeDashboardUrl,
|
|
834
770
|
readDashboardClientConfig,
|
|
@@ -836,4 +772,4 @@ export {
|
|
|
836
772
|
removeDashboardClientConfig,
|
|
837
773
|
refreshDashboardAccessToken
|
|
838
774
|
};
|
|
839
|
-
//# sourceMappingURL=chunk-
|
|
775
|
+
//# sourceMappingURL=chunk-4CRZXLIP.js.map
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isLoopbackHost
|
|
3
|
+
} from "./chunk-4CRZXLIP.js";
|
|
4
|
+
|
|
5
|
+
// src/gateway/auth.ts
|
|
6
|
+
import crypto from "crypto";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
var TOKEN_BYTES = 32;
|
|
10
|
+
function loadOrCreateToken(tokenPath) {
|
|
11
|
+
try {
|
|
12
|
+
const buf = fs.readFileSync(tokenPath);
|
|
13
|
+
const text = buf.toString("utf-8").trim();
|
|
14
|
+
if (text.length >= 16) return text;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
const code = err.code;
|
|
17
|
+
if (code !== "ENOENT") throw err;
|
|
18
|
+
}
|
|
19
|
+
return writeNewToken(tokenPath);
|
|
20
|
+
}
|
|
21
|
+
function rotateGatewayToken(tokenPath) {
|
|
22
|
+
return writeNewToken(tokenPath);
|
|
23
|
+
}
|
|
24
|
+
function writeNewToken(tokenPath) {
|
|
25
|
+
const dir = path.dirname(tokenPath);
|
|
26
|
+
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
27
|
+
const token = crypto.randomBytes(TOKEN_BYTES).toString("base64url");
|
|
28
|
+
const tmpPath = `${tokenPath}.tmp-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
|
|
29
|
+
fs.writeFileSync(tmpPath, token + "\n", { mode: 384 });
|
|
30
|
+
try {
|
|
31
|
+
fs.renameSync(tmpPath, tokenPath);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
try {
|
|
34
|
+
fs.unlinkSync(tmpPath);
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
if (process.platform !== "win32") {
|
|
40
|
+
fs.chmodSync(dir, 448);
|
|
41
|
+
fs.chmodSync(tokenPath, 384);
|
|
42
|
+
}
|
|
43
|
+
return token;
|
|
44
|
+
}
|
|
45
|
+
function timingSafeTokenEqual(a, b) {
|
|
46
|
+
const ab = Buffer.from(a, "utf-8");
|
|
47
|
+
const bb = Buffer.from(b, "utf-8");
|
|
48
|
+
if (ab.length !== bb.length) {
|
|
49
|
+
const filler = Buffer.alloc(Math.max(ab.length, bb.length));
|
|
50
|
+
crypto.timingSafeEqual(filler, filler);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return crypto.timingSafeEqual(ab, bb);
|
|
54
|
+
}
|
|
55
|
+
function requireTokenForBind(spec, token) {
|
|
56
|
+
if (spec.kind === "uds" || isLoopbackHost(spec.host)) return;
|
|
57
|
+
if (!token || token.length < 16) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`gateway: refusing to bind ${spec.host}:${spec.port} without token configured`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (spec.tls) return;
|
|
63
|
+
if (!spec.insecure) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`gateway: refusing to bind ${spec.host}:${spec.port} without TLS; pass --tls-cert/--tls-key, or --insecure only for trusted reverse-proxy/tunnel deployments`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/infra/config/channels.ts
|
|
71
|
+
import fs2 from "fs";
|
|
72
|
+
import os from "os";
|
|
73
|
+
import path2 from "path";
|
|
74
|
+
function channelSidecarDir(home = os.homedir()) {
|
|
75
|
+
return path2.join(home, ".config", "athena", "channels");
|
|
76
|
+
}
|
|
77
|
+
function loadChannelSidecars(home = os.homedir()) {
|
|
78
|
+
const dir = channelSidecarDir(home);
|
|
79
|
+
const sidecars = [];
|
|
80
|
+
const errors = [];
|
|
81
|
+
let entries;
|
|
82
|
+
try {
|
|
83
|
+
entries = fs2.readdirSync(dir);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
const code = err.code;
|
|
86
|
+
if (code === "ENOENT") return { sidecars, errors };
|
|
87
|
+
errors.push({
|
|
88
|
+
path: dir,
|
|
89
|
+
reason: `read dir failed: ${err instanceof Error ? err.message : String(err)}`
|
|
90
|
+
});
|
|
91
|
+
return { sidecars, errors };
|
|
92
|
+
}
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (!entry.endsWith(".json")) continue;
|
|
95
|
+
const full = path2.join(dir, entry);
|
|
96
|
+
const name = entry.slice(0, -".json".length);
|
|
97
|
+
const result = loadOne(name, full);
|
|
98
|
+
if (result.ok) sidecars.push(result.sidecar);
|
|
99
|
+
else errors.push({ path: full, reason: result.reason });
|
|
100
|
+
}
|
|
101
|
+
return { sidecars, errors };
|
|
102
|
+
}
|
|
103
|
+
function loadOne(name, filePath) {
|
|
104
|
+
let raw;
|
|
105
|
+
try {
|
|
106
|
+
if (process.platform !== "win32") {
|
|
107
|
+
const stat = fs2.statSync(filePath);
|
|
108
|
+
if ((stat.mode & 63) !== 0) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
reason: `file ${filePath} is too permissive (mode ${(stat.mode & 511).toString(8)}); chmod 600`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
raw = JSON.parse(fs2.readFileSync(filePath, "utf-8"));
|
|
116
|
+
} catch (err) {
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (typeof raw !== "object" || raw === null) {
|
|
123
|
+
return { ok: false, reason: "config root must be an object" };
|
|
124
|
+
}
|
|
125
|
+
const obj = raw;
|
|
126
|
+
const userIdsRaw = obj["allowed_user_ids"];
|
|
127
|
+
const allowedUserIds = [];
|
|
128
|
+
if (userIdsRaw !== void 0) {
|
|
129
|
+
if (!Array.isArray(userIdsRaw)) {
|
|
130
|
+
return { ok: false, reason: "allowed_user_ids must be an array" };
|
|
131
|
+
}
|
|
132
|
+
for (const id of userIdsRaw) {
|
|
133
|
+
if (typeof id === "string") allowedUserIds.push(id);
|
|
134
|
+
else if (typeof id === "number") allowedUserIds.push(String(id));
|
|
135
|
+
else
|
|
136
|
+
return {
|
|
137
|
+
ok: false,
|
|
138
|
+
reason: "allowed_user_ids entries must be string or number"
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const options = {};
|
|
143
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
144
|
+
if (key === "allowed_user_ids") continue;
|
|
145
|
+
options[key] = value;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
ok: true,
|
|
149
|
+
sidecar: { name, path: filePath, allowedUserIds, options }
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
loadOrCreateToken,
|
|
155
|
+
rotateGatewayToken,
|
|
156
|
+
timingSafeTokenEqual,
|
|
157
|
+
requireTokenForBind,
|
|
158
|
+
channelSidecarDir,
|
|
159
|
+
loadChannelSidecars
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=chunk-6TJHAUNB.js.map
|