@atlasauth/cli 0.25.1 → 0.26.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/CHANGELOG.md +31 -0
- package/README.md +26 -5
- package/dist/args.d.ts +30 -0
- package/dist/args.js +15 -0
- package/dist/args.js.map +1 -1
- package/dist/commands/config.d.ts +26 -2
- package/dist/commands/config.js +334 -44
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor-scan.d.ts +27 -0
- package/dist/commands/doctor-scan.js +221 -0
- package/dist/commands/doctor-scan.js.map +1 -0
- package/dist/commands/golive.js +16 -4
- package/dist/commands/golive.js.map +1 -1
- package/dist/commands/import-jsonl.d.ts +50 -0
- package/dist/commands/import-jsonl.js +252 -0
- package/dist/commands/import-jsonl.js.map +1 -0
- package/dist/commands/import.js +22 -12
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/init-next.d.ts +4 -0
- package/dist/commands/init-next.js +86 -0
- package/dist/commands/init-next.js.map +1 -0
- package/dist/commands/init.js +112 -25
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/project-commands.js +74 -4
- package/dist/commands/project-commands.js.map +1 -1
- package/dist/commands/setup-guide.d.ts +3 -0
- package/dist/commands/setup-guide.js +38 -0
- package/dist/commands/setup-guide.js.map +1 -0
- package/dist/commands/users.js +12 -1
- package/dist/commands/users.js.map +1 -1
- package/dist/config-http.d.ts +9 -0
- package/dist/config-http.js +7 -1
- package/dist/config-http.js.map +1 -1
- package/dist/context.d.ts +18 -1
- package/dist/context.js +6 -1
- package/dist/context.js.map +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.js +70 -12
- package/dist/help.js.map +1 -1
- package/dist/redact.d.ts +41 -0
- package/dist/redact.js +115 -0
- package/dist/redact.js.map +1 -0
- package/dist/run.d.ts +2 -2
- package/dist/run.js +16 -4
- package/dist/run.js.map +1 -1
- package/package.json +5 -5
package/dist/redact.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's one output-side secret filter. Every change a plan prints, every
|
|
3
|
+
* `--json` report of plan / preflight / golive and every API error passes through
|
|
4
|
+
* here, so a resource added later cannot leak by forgetting to mask a field.
|
|
5
|
+
*
|
|
6
|
+
* - {@link isSecretKey}: a field name that holds a secret. Names that only mention
|
|
7
|
+
* the word (`token_endpoint`, `password_policy`, `secret_key_prefix`) are not.
|
|
8
|
+
* - {@link redactDeep}: masks secret-named strings at any depth, and scrubs the rest.
|
|
9
|
+
* - {@link scrubText}: removes known values, Atlas-key-shaped values and
|
|
10
|
+
* `name=value` pairs from free text.
|
|
11
|
+
* - {@link rememberResolved}: records what a `${VAR}` placeholder resolved to, so a
|
|
12
|
+
* secret under an unexpected key still cannot print. {@link scrubbingIO} applies
|
|
13
|
+
* those values to everything the command writes.
|
|
14
|
+
*
|
|
15
|
+
* The state is per `run()`; {@link resetRedaction} clears it.
|
|
16
|
+
*/
|
|
17
|
+
import type { IO } from './io';
|
|
18
|
+
export declare const REDACTED = "<redacted>";
|
|
19
|
+
/** True for a field name whose string value is a secret. */
|
|
20
|
+
export declare function isSecretKey(key: string): boolean;
|
|
21
|
+
/** An unresolved `${VAR}` is a name, not a value: it stays visible (apply refuses it). */
|
|
22
|
+
export declare const isPlaceholder: (v: unknown) => boolean;
|
|
23
|
+
/** The secret formats Atlas mints: `atlas_<env>_<kind>_…`, and the legacy `sk_<env>_`, `psk_`, `dsk_`, `whsec_`. */
|
|
24
|
+
export declare const SECRET_VALUE_SOURCE = "\\b(?:atlas_(?:live|test)_(?:sk|psk|dsk|whsec|pl|at)_[A-Za-z0-9]+|(?:sk_(?:live|test)|psk|dsk|whsec)_[A-Za-z0-9_\\-+/=]+)";
|
|
25
|
+
/** Forget the remembered values and leave `--show-secrets` off. */
|
|
26
|
+
export declare function resetRedaction(): void;
|
|
27
|
+
/** `--show-secrets`: the caller has checked it is allowed here. */
|
|
28
|
+
export declare function setRevealSecrets(on: boolean): void;
|
|
29
|
+
export declare const revealingSecrets: () => boolean;
|
|
30
|
+
/** Remember what a `${VAR}` under `key` resolved to. Public values (a client id, a plain URL) stay printable. */
|
|
31
|
+
export declare function rememberResolved(key: string | undefined, value: string): void;
|
|
32
|
+
/** Remove known values, key-shaped values and secret `name=value` pairs from free text. */
|
|
33
|
+
export declare function scrubText(text: string): string;
|
|
34
|
+
/** A copy with every secret-named string masked and every other string scrubbed. */
|
|
35
|
+
export declare function redactDeep<T>(value: T, key?: string): T;
|
|
36
|
+
/**
|
|
37
|
+
* The sinks every command writes through, without any value `${VAR}` resolved to.
|
|
38
|
+
* Only remembered values: a secret a command prints on purpose (`--print-secret`)
|
|
39
|
+
* was never remembered, so it still prints.
|
|
40
|
+
*/
|
|
41
|
+
export declare function scrubbingIO(io: IO): IO;
|
package/dist/redact.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revealingSecrets = exports.SECRET_VALUE_SOURCE = exports.isPlaceholder = exports.REDACTED = void 0;
|
|
4
|
+
exports.isSecretKey = isSecretKey;
|
|
5
|
+
exports.resetRedaction = resetRedaction;
|
|
6
|
+
exports.setRevealSecrets = setRevealSecrets;
|
|
7
|
+
exports.rememberResolved = rememberResolved;
|
|
8
|
+
exports.scrubText = scrubText;
|
|
9
|
+
exports.redactDeep = redactDeep;
|
|
10
|
+
exports.scrubbingIO = scrubbingIO;
|
|
11
|
+
exports.REDACTED = '<redacted>';
|
|
12
|
+
const SECRET_WORD = /secret|token|password|passwd|api_?key|private_?key|signing_?key|encryption_?key|access_?key|credential|authorization/;
|
|
13
|
+
/** The name describes the secret rather than holding it. */
|
|
14
|
+
const DESCRIBES_IT = /_(endpoint|url|uri|method|policy|prefix|format|ttl|seconds|lifetimes?|params|set|file|files|at|type|name|id|ref|hint|hasher|alg|algorithm|enabled|required|source|length|mode|count|version)$/;
|
|
15
|
+
/** True for a field name whose string value is a secret. */
|
|
16
|
+
function isSecretKey(key) {
|
|
17
|
+
const snake = key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
|
|
18
|
+
// `has_secret`, `is_token`: a flag about the secret, never the secret.
|
|
19
|
+
return SECRET_WORD.test(snake) && !DESCRIBES_IT.test(snake) && !/^(has|is)_/.test(snake);
|
|
20
|
+
}
|
|
21
|
+
const PLACEHOLDER = /^\$\{[A-Z0-9_]+\}$/;
|
|
22
|
+
/** An unresolved `${VAR}` is a name, not a value: it stays visible (apply refuses it). */
|
|
23
|
+
const isPlaceholder = (v) => typeof v === 'string' && PLACEHOLDER.test(v);
|
|
24
|
+
exports.isPlaceholder = isPlaceholder;
|
|
25
|
+
/** The secret formats Atlas mints: `atlas_<env>_<kind>_…`, and the legacy `sk_<env>_`, `psk_`, `dsk_`, `whsec_`. */
|
|
26
|
+
exports.SECRET_VALUE_SOURCE = '\\b(?:atlas_(?:live|test)_(?:sk|psk|dsk|whsec|pl|at)_[A-Za-z0-9]+|(?:sk_(?:live|test)|psk|dsk|whsec)_[A-Za-z0-9_\\-+/=]+)';
|
|
27
|
+
const SECRET_VALUE = new RegExp(exports.SECRET_VALUE_SOURCE, 'g');
|
|
28
|
+
const KEY_VALUE = /(["']?)([A-Za-z][\w-]*)\1(\s*[:=]\s*)("(?:[^"\\]|\\.)*"|'[^']*'|[^\s,&;}"']+)/g;
|
|
29
|
+
const BEARER = /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/g;
|
|
30
|
+
const known = new Set();
|
|
31
|
+
let reveal = false;
|
|
32
|
+
/** Forget the remembered values and leave `--show-secrets` off. */
|
|
33
|
+
function resetRedaction() {
|
|
34
|
+
known.clear();
|
|
35
|
+
reveal = false;
|
|
36
|
+
}
|
|
37
|
+
/** `--show-secrets`: the caller has checked it is allowed here. */
|
|
38
|
+
function setRevealSecrets(on) {
|
|
39
|
+
reveal = on;
|
|
40
|
+
}
|
|
41
|
+
const revealingSecrets = () => reveal;
|
|
42
|
+
exports.revealingSecrets = revealingSecrets;
|
|
43
|
+
/** Below this a value is too short to scrub without mangling ordinary words; a secret-named key is masked anyway. */
|
|
44
|
+
const MIN_SCRUB_LENGTH = 6;
|
|
45
|
+
const PUBLIC_KEY = /(^|_)client_id$|^provider$|^from_address$/i;
|
|
46
|
+
function isPlainUrl(v) {
|
|
47
|
+
try {
|
|
48
|
+
const u = new URL(v);
|
|
49
|
+
return (u.protocol === 'https:' || u.protocol === 'http:') && !u.username && !u.password && !u.search;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Remember what a `${VAR}` under `key` resolved to. Public values (a client id, a plain URL) stay printable. */
|
|
56
|
+
function rememberResolved(key, value) {
|
|
57
|
+
if (value.length < MIN_SCRUB_LENGTH)
|
|
58
|
+
return;
|
|
59
|
+
if (!(key && isSecretKey(key)) && ((key && PUBLIC_KEY.test(key)) || isPlainUrl(value)))
|
|
60
|
+
return;
|
|
61
|
+
known.add(value);
|
|
62
|
+
known.add(JSON.stringify(value).slice(1, -1));
|
|
63
|
+
}
|
|
64
|
+
function scrubKnown(text) {
|
|
65
|
+
if (reveal || known.size === 0)
|
|
66
|
+
return text;
|
|
67
|
+
let out = text;
|
|
68
|
+
for (const v of [...known].sort((a, b) => b.length - a.length))
|
|
69
|
+
out = out.split(v).join(exports.REDACTED);
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** Remove known values, key-shaped values and secret `name=value` pairs from free text. */
|
|
73
|
+
function scrubText(text) {
|
|
74
|
+
if (reveal)
|
|
75
|
+
return text;
|
|
76
|
+
return scrubKnown(text)
|
|
77
|
+
.replace(SECRET_VALUE, exports.REDACTED)
|
|
78
|
+
.replace(BEARER, `Bearer ${exports.REDACTED}`)
|
|
79
|
+
.replace(KEY_VALUE, (match, _q, name, sep, value) => {
|
|
80
|
+
// `<value>` in a help line is a placeholder too.
|
|
81
|
+
if (!isSecretKey(name) || (0, exports.isPlaceholder)(value) || /^<[\w-]+>$/.test(value))
|
|
82
|
+
return match;
|
|
83
|
+
const quoted = value.startsWith('"') || value.startsWith("'");
|
|
84
|
+
// `client_secret: missing` is prose; `client_secret: 8f3a91c2…` and `token=abc` are not.
|
|
85
|
+
if (!quoted && sep.includes(':') && value.length < 8)
|
|
86
|
+
return match;
|
|
87
|
+
const q = quoted ? value[0] : '';
|
|
88
|
+
return `${match.slice(0, match.length - value.length)}${q}${exports.REDACTED}${q}`;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** A copy with every secret-named string masked and every other string scrubbed. */
|
|
92
|
+
function redactDeep(value, key) {
|
|
93
|
+
if (reveal)
|
|
94
|
+
return value;
|
|
95
|
+
if (typeof value === 'string') {
|
|
96
|
+
if (key && isSecretKey(key) && value !== '' && !(0, exports.isPlaceholder)(value))
|
|
97
|
+
return exports.REDACTED;
|
|
98
|
+
return scrubText(value);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(value))
|
|
101
|
+
return value.map((v) => redactDeep(v, key));
|
|
102
|
+
if (value !== null && typeof value === 'object') {
|
|
103
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redactDeep(v, k)]));
|
|
104
|
+
}
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The sinks every command writes through, without any value `${VAR}` resolved to.
|
|
109
|
+
* Only remembered values: a secret a command prints on purpose (`--print-secret`)
|
|
110
|
+
* was never remembered, so it still prints.
|
|
111
|
+
*/
|
|
112
|
+
function scrubbingIO(io) {
|
|
113
|
+
return { out: (t) => io.out(scrubKnown(t)), err: (t) => io.err(scrubKnown(t)) };
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":";;;AAyBA,kCAIC;AAiBD,wCAGC;AAGD,4CAEC;AAiB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type ParsedArgs } from './args';
|
|
2
|
-
import type
|
|
2
|
+
import { type RunContext } from './context';
|
|
3
3
|
/** A command handler: given the context and parsed args, do the work; return an exit code. */
|
|
4
4
|
export type Handler = (ctx: RunContext, args: ParsedArgs) => Promise<number>;
|
|
5
5
|
/**
|
|
@@ -9,4 +9,4 @@ export type Handler = (ctx: RunContext, args: ParsedArgs) => Promise<number>;
|
|
|
9
9
|
* captured IO. All error reporting funnels through the one try/catch so a user
|
|
10
10
|
* sees a clean message and a non-zero code — never a stack trace.
|
|
11
11
|
*/
|
|
12
|
-
export declare function run(argv: string[],
|
|
12
|
+
export declare function run(argv: string[], rawCtx: RunContext): Promise<number>;
|
package/dist/run.js
CHANGED
|
@@ -32,8 +32,11 @@ const id_accounts_1 = require("./commands/id-accounts");
|
|
|
32
32
|
const admin_1 = require("./commands/admin");
|
|
33
33
|
const partner_platforms_1 = require("./commands/partner-platforms");
|
|
34
34
|
const resources_1 = require("./commands/resources");
|
|
35
|
+
const context_1 = require("./context");
|
|
35
36
|
const errors_1 = require("./errors");
|
|
36
37
|
const help_1 = require("./help");
|
|
38
|
+
const redact_1 = require("./redact");
|
|
39
|
+
const setup_guide_1 = require("./commands/setup-guide");
|
|
37
40
|
const version_1 = require("./version");
|
|
38
41
|
/** The command table — the single place every top-level command is registered. */
|
|
39
42
|
const COMMANDS = {
|
|
@@ -57,6 +60,7 @@ const COMMANDS = {
|
|
|
57
60
|
actions: actions_1.actions,
|
|
58
61
|
pages: pages_1.pages,
|
|
59
62
|
init: init_1.init,
|
|
63
|
+
'setup-guide': setup_guide_1.setupGuide,
|
|
60
64
|
preflight: project_commands_1.preflight,
|
|
61
65
|
doctor: project_commands_1.doctor,
|
|
62
66
|
golive: golive_1.golive,
|
|
@@ -97,7 +101,9 @@ const COMMANDS = {
|
|
|
97
101
|
* captured IO. All error reporting funnels through the one try/catch so a user
|
|
98
102
|
* sees a clean message and a non-zero code — never a stack trace.
|
|
99
103
|
*/
|
|
100
|
-
async function run(argv,
|
|
104
|
+
async function run(argv, rawCtx) {
|
|
105
|
+
(0, redact_1.resetRedaction)();
|
|
106
|
+
const ctx = { ...rawCtx, io: (0, redact_1.scrubbingIO)(rawCtx.io) };
|
|
101
107
|
let args;
|
|
102
108
|
try {
|
|
103
109
|
args = (0, args_1.parse)(argv);
|
|
@@ -110,6 +116,12 @@ async function run(argv, ctx) {
|
|
|
110
116
|
ctx.io.out((0, version_1.getVersion)());
|
|
111
117
|
return 0;
|
|
112
118
|
}
|
|
119
|
+
if (args.values['show-secrets']) {
|
|
120
|
+
if (!(0, context_1.ttyOf)(ctx).stdout || ctx.env.CI) {
|
|
121
|
+
return report(ctx, new errors_1.CliError('--show-secrets needs a terminal: it is refused when stdout is not a TTY or CI is set.'));
|
|
122
|
+
}
|
|
123
|
+
(0, redact_1.setRevealSecrets)(true);
|
|
124
|
+
}
|
|
113
125
|
const command = args.positionals[0];
|
|
114
126
|
// Bare `atlas` or `atlas --help`: top-level help on stdout, success.
|
|
115
127
|
if (!command) {
|
|
@@ -143,15 +155,15 @@ async function run(argv, ctx) {
|
|
|
143
155
|
function report(ctx, err) {
|
|
144
156
|
if (err instanceof backend_1.AtlasApiError) {
|
|
145
157
|
const code = err.code ? ` [${err.code}]` : '';
|
|
146
|
-
ctx.io.err(`atlas: API error (HTTP ${err.status})${code}: ${err.message}`);
|
|
158
|
+
ctx.io.err(`atlas: API error (HTTP ${err.status})${code}: ${(0, redact_1.scrubText)(err.message)}`);
|
|
147
159
|
return 1;
|
|
148
160
|
}
|
|
149
161
|
if (err instanceof errors_1.CliError) {
|
|
150
|
-
ctx.io.err(`atlas: ${err.message}`);
|
|
162
|
+
ctx.io.err(`atlas: ${(0, redact_1.scrubText)(err.message)}`);
|
|
151
163
|
return err.exitCode;
|
|
152
164
|
}
|
|
153
165
|
const message = err instanceof Error ? err.message : String(err);
|
|
154
|
-
ctx.io.err(`atlas: ${message}`);
|
|
166
|
+
ctx.io.err(`atlas: ${(0, redact_1.scrubText)(message)}`);
|
|
155
167
|
return 1;
|
|
156
168
|
}
|
|
157
169
|
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;AA4GA,kBAiDC;AA7JD,gDAAmD;AACnD,iCAAgD;AAChD,gDAA6C;AAC7C,4CAAyC;AACzC,kDAA8C;AAC9C,0CAAwD;AACxD,kDAAkD;AAClD,8CAAsE;AACtE,0CAAuC;AACvC,8CAA2C;AAC3C,8CAAgD;AAChD,0CAAuC;AACvC,wCAAqC;AACrC,wCAAqC;AACrC,wCAAqC;AACrC,8CAA2C;AAC3C,gDAA6C;AAC7C,wDAAoD;AACpD,wCAAqC;AACrC,kEAAoF;AACpF,0CAAuC;AACvC,oDAAiD;AACjD,kDAA+C;AAC/C,8CAA2C;AAC3C,4CAAyC;AACzC,kDAA+C;AAC/C,0DAAuD;AACvD,wDAAoD;AACpD,4CAAyC;AACzC,oEAAgE;AAChE,oDAG8B;AAC9B,uCAAmD;AACnD,qCAAoC;AACpC,iCAAgD;AAChD,qCAAoF;AACpF,wDAAoD;AACpD,uCAAuC;AAKvC,kFAAkF;AAClF,MAAM,QAAQ,GAA4B;IACxC,KAAK,EAAL,YAAK;IACL,MAAM,EAAN,aAAM;IACN,MAAM,EAAN,aAAM;IACN,KAAK,EAAL,gBAAK;IACL,IAAI,EAAJ,eAAI;IACJ,KAAK,EAAL,aAAK;IACL,IAAI,EAAJ,WAAI;IACJ,UAAU,EAAE,kBAAO;IACnB,QAAQ,EAAR,mBAAQ;IACR,YAAY,EAAZ,2BAAY;IACZ,mBAAmB,EAAE,oCAAgB;IACrC,aAAa,EAAE,wBAAU;IACzB,KAAK,EAAL,aAAK;IACL,QAAQ,EAAR,mBAAQ;IACR,MAAM,EAAN,eAAM;IACN,I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AC;QACtF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,GAAG,YAAY,iBAAQ,EAAE,CAAC;QAC5B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,IAAA,kBAAS,EAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC,QAAQ,CAAC;IACtB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,IAAA,kBAAS,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "atlas — manage an Atlas instance from the terminal via the Backend API.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"atlas": "dist/cli.js"
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"yaml": "^2.6.0",
|
|
19
19
|
"@atlasauth/actions": "0.5.0",
|
|
20
|
-
"@atlasauth/
|
|
21
|
-
"@atlasauth/
|
|
22
|
-
"@atlasauth/upgrade": "0.7.0",
|
|
20
|
+
"@atlasauth/emulator": "0.1.0",
|
|
21
|
+
"@atlasauth/backend": "0.37.0",
|
|
23
22
|
"@atlasauth/referral-conformance": "0.2.1",
|
|
24
|
-
"@atlasauth/
|
|
23
|
+
"@atlasauth/upgrade": "0.7.0",
|
|
24
|
+
"@atlasauth/migrate": "0.2.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.9.0",
|