@fgv/ks 5.1.0-32 → 5.1.0-33
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/.rush/temp/{a6880a75712d4e6394e80b0eaef433f28fc4d049.tar.log → 63130e3ee65fdf330e9864a3461cb90992c0196a.tar.log} +6 -2
- package/.rush/temp/chunked-rush-logs/ks.build.chunks.jsonl +2 -2
- package/.rush/temp/operation/build/all.log +2 -2
- package/.rush/temp/operation/build/log-chunks.jsonl +2 -2
- package/.rush/temp/operation/build/state.json +1 -1
- package/README.md +13 -0
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +27 -12
- package/lib/app.js.map +1 -1
- package/lib/encoding.d.ts +7 -0
- package/lib/encoding.d.ts.map +1 -0
- package/lib/encoding.js +30 -0
- package/lib/encoding.js.map +1 -0
- package/lib/help.d.ts.map +1 -1
- package/lib/help.js +1 -0
- package/lib/help.js.map +1 -1
- package/package.json +5 -5
- package/rush-logs/ks.build.cache.log +1 -1
- package/rush-logs/ks.build.log +2 -2
- package/src/app.ts +95 -64
- package/src/encoding.ts +30 -0
- package/src/help.ts +1 -0
- package/temp/build/lint/_eslint-5eVG3S6w.json +7 -3
- package/temp/build/typescript/ts_l9Fw4VUO.json +1 -1
- package/test/unit/app.test.ts +271 -5
- package/test/unit/encoding.test.ts +50 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Start time:
|
|
2
|
-
Invoking "/usr/bin/tar -c -f /home/runner/work/fgv/fgv/common/temp/build-cache/
|
|
1
|
+
Start time: Sat May 30 2026 06:27:12 GMT+0000 (Coordinated Universal Time)
|
|
2
|
+
Invoking "/usr/bin/tar -c -f /home/runner/work/fgv/fgv/common/temp/build-cache/63130e3ee65fdf330e9864a3461cb90992c0196a-86bf49f8ecd7d6b3.temp -z --files-from=-"
|
|
3
3
|
|
|
4
4
|
======= BEGIN PROCESS INPUT ======
|
|
5
5
|
.rush/temp/operation/build/all.log
|
|
@@ -13,6 +13,10 @@ lib/cli.d.ts
|
|
|
13
13
|
lib/cli.d.ts.map
|
|
14
14
|
lib/cli.js
|
|
15
15
|
lib/cli.js.map
|
|
16
|
+
lib/encoding.d.ts
|
|
17
|
+
lib/encoding.d.ts.map
|
|
18
|
+
lib/encoding.js
|
|
19
|
+
lib/encoding.js.map
|
|
16
20
|
lib/help.d.ts
|
|
17
21
|
lib/help.d.ts.map
|
|
18
22
|
lib/help.js
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
{"kind":"O","text":"[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.\n"}
|
|
4
4
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.9.3\n"}
|
|
5
5
|
{"kind":"O","text":"[build:lint] Using ESLint version 9.39.4\n"}
|
|
6
|
-
{"kind":"O","text":" ---- build finished (12.
|
|
7
|
-
{"kind":"O","text":"-------------------- Finished (12.
|
|
6
|
+
{"kind":"O","text":" ---- build finished (12.387s) ---- \n"}
|
|
7
|
+
{"kind":"O","text":"-------------------- Finished (12.391s) --------------------\n"}
|
|
@@ -3,5 +3,5 @@ Invoking: heft build --clean
|
|
|
3
3
|
[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.
|
|
4
4
|
[build:typescript] Using TypeScript version 5.9.3
|
|
5
5
|
[build:lint] Using ESLint version 9.39.4
|
|
6
|
-
---- build finished (12.
|
|
7
|
-
-------------------- Finished (12.
|
|
6
|
+
---- build finished (12.387s) ----
|
|
7
|
+
-------------------- Finished (12.391s) --------------------
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
{"kind":"O","text":"[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.\n"}
|
|
4
4
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.9.3\n"}
|
|
5
5
|
{"kind":"O","text":"[build:lint] Using ESLint version 9.39.4\n"}
|
|
6
|
-
{"kind":"O","text":" ---- build finished (12.
|
|
7
|
-
{"kind":"O","text":"-------------------- Finished (12.
|
|
6
|
+
{"kind":"O","text":" ---- build finished (12.387s) ---- \n"}
|
|
7
|
+
{"kind":"O","text":"-------------------- Finished (12.391s) --------------------\n"}
|
package/README.md
CHANGED
|
@@ -56,3 +56,16 @@ eval "$(ks session --var FGV_KS_PASSWORD)"
|
|
|
56
56
|
```bash
|
|
57
57
|
ks export --template-string 'export XAI_API_KEY={{xai}}' --clipboard
|
|
58
58
|
```
|
|
59
|
+
|
|
60
|
+
### Encode secrets for binary-safe display or piping
|
|
61
|
+
|
|
62
|
+
`ks get` and `ks export` accept `--encoding <text|base64|hex>`. The default
|
|
63
|
+
(`text`) preserves the existing behavior; `base64` (RFC 4648, padded) and
|
|
64
|
+
`hex` (lowercase) emit the UTF-8 bytes of the secret in the chosen
|
|
65
|
+
encoding, which is useful for piping secrets that may contain control
|
|
66
|
+
characters or for keeping keys opaque in shell history.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
ks get my-key --encoding base64
|
|
70
|
+
ks export --template-string 'export TOKEN={{my-key}}' --encoding hex
|
|
71
|
+
```
|
package/lib/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AA6RA,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;;IAOtB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,OAAO,CAAC,cAAc;CAwUvB"}
|
package/lib/app.js
CHANGED
|
@@ -10,10 +10,14 @@ const ts_utils_1 = require("@fgv/ts-utils");
|
|
|
10
10
|
const io_1 = require("./io");
|
|
11
11
|
const help_1 = require("./help");
|
|
12
12
|
const keystore_1 = require("./keystore");
|
|
13
|
+
const encoding_1 = require("./encoding");
|
|
13
14
|
const template_1 = require("./template");
|
|
14
15
|
function stripTrailingNewline(value) {
|
|
15
16
|
return value.replace(/\r?\n$/, '');
|
|
16
17
|
}
|
|
18
|
+
function addEncodingOption(command, description) {
|
|
19
|
+
return command.option(`--encoding <${encoding_1.ENCODINGS.join('|')}>`, description, encoding_1.DEFAULT_ENCODING);
|
|
20
|
+
}
|
|
17
21
|
function hasExplicitPasswordSource(options) {
|
|
18
22
|
return Boolean(options.passwordEnv || options.passwordFile || options.passwordStdin);
|
|
19
23
|
}
|
|
@@ -137,7 +141,7 @@ async function readTemplate(options) {
|
|
|
137
141
|
}
|
|
138
142
|
return (0, ts_utils_1.fail)('Specify either --template-file or --template-string');
|
|
139
143
|
}
|
|
140
|
-
async function collectTemplateContext(keystore, template) {
|
|
144
|
+
async function collectTemplateContext(keystore, template, encoding) {
|
|
141
145
|
const variablesResult = (0, template_1.extractTemplateVariables)(template);
|
|
142
146
|
if (variablesResult.isFailure()) {
|
|
143
147
|
return (0, ts_utils_1.fail)(variablesResult.message);
|
|
@@ -152,7 +156,7 @@ async function collectTemplateContext(keystore, template) {
|
|
|
152
156
|
for (const variable of variablesResult.value) {
|
|
153
157
|
const secretResult = keystore.getApiKey(variable);
|
|
154
158
|
if (secretResult.isSuccess()) {
|
|
155
|
-
context[variable] = secretResult.value;
|
|
159
|
+
context[variable] = (0, encoding_1.encodeSecret)(secretResult.value, encoding);
|
|
156
160
|
continue;
|
|
157
161
|
}
|
|
158
162
|
if (knownSecrets.has(variable)) {
|
|
@@ -162,7 +166,7 @@ async function collectTemplateContext(keystore, template) {
|
|
|
162
166
|
if (promptResult.isFailure()) {
|
|
163
167
|
return (0, ts_utils_1.fail)(promptResult.message);
|
|
164
168
|
}
|
|
165
|
-
context[variable] = promptResult.value;
|
|
169
|
+
context[variable] = (0, encoding_1.encodeSecret)(promptResult.value, encoding);
|
|
166
170
|
missing.push([variable, promptResult.value]);
|
|
167
171
|
}
|
|
168
172
|
return (0, ts_utils_1.succeed)({ context, missing });
|
|
@@ -278,15 +282,20 @@ class KsCli {
|
|
|
278
282
|
process.exit(1);
|
|
279
283
|
}
|
|
280
284
|
});
|
|
281
|
-
this._program
|
|
285
|
+
const getCommand = this._program
|
|
282
286
|
.command('get <name>')
|
|
283
287
|
.description('Read a secret from the keystore')
|
|
284
288
|
.option('--keystore <path>', 'Keystore file path', (0, io_1.defaultKeystorePath)())
|
|
285
289
|
.option('--password-env <name>', 'Environment variable to read the password from')
|
|
286
290
|
.option('--password-file <path>', 'Read the password from a file')
|
|
287
291
|
.option('--password-stdin', 'Read the password from stdin', false)
|
|
288
|
-
.option('--clipboard', 'Copy the secret to the clipboard', false)
|
|
289
|
-
|
|
292
|
+
.option('--clipboard', 'Copy the secret to the clipboard', false);
|
|
293
|
+
addEncodingOption(getCommand, 'Encode the secret value before output (default: text)').action(async (name, options) => {
|
|
294
|
+
const encoding = (0, encoding_1.parseEncoding)(options.encoding);
|
|
295
|
+
if (encoding.isFailure()) {
|
|
296
|
+
console.error(`Error: ${encoding.message}`);
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
290
299
|
const password = await resolvePassword(options, 'Keystore password');
|
|
291
300
|
if (password.isFailure()) {
|
|
292
301
|
console.error(`Error: ${password.message}`);
|
|
@@ -297,15 +306,16 @@ class KsCli {
|
|
|
297
306
|
console.error(`Error: ${secret.message}`);
|
|
298
307
|
process.exit(1);
|
|
299
308
|
}
|
|
309
|
+
const encoded = (0, encoding_1.encodeSecret)(secret.value, encoding.value);
|
|
300
310
|
if (options.clipboard) {
|
|
301
|
-
const copied = await (0, io_1.copyTextToClipboard)(
|
|
311
|
+
const copied = await (0, io_1.copyTextToClipboard)(encoded);
|
|
302
312
|
if (copied.isFailure()) {
|
|
303
313
|
console.error(`Error: ${copied.message}`);
|
|
304
314
|
process.exit(1);
|
|
305
315
|
}
|
|
306
316
|
return;
|
|
307
317
|
}
|
|
308
|
-
console.log(
|
|
318
|
+
console.log(encoded);
|
|
309
319
|
});
|
|
310
320
|
this._program
|
|
311
321
|
.command('list')
|
|
@@ -348,7 +358,7 @@ class KsCli {
|
|
|
348
358
|
process.exit(1);
|
|
349
359
|
}
|
|
350
360
|
});
|
|
351
|
-
this._program
|
|
361
|
+
const exportCommand = this._program
|
|
352
362
|
.command('export')
|
|
353
363
|
.description('Render a shell template using secrets from the keystore')
|
|
354
364
|
.option('--keystore <path>', 'Keystore file path', (0, io_1.defaultKeystorePath)())
|
|
@@ -358,8 +368,13 @@ class KsCli {
|
|
|
358
368
|
.option('--template-file <path>', 'Read the shell template from a file')
|
|
359
369
|
.option('--template-string <text>', 'Use the supplied shell template string')
|
|
360
370
|
.option('--clipboard', 'Copy the rendered output to the clipboard', false)
|
|
361
|
-
.option('--persist-missing', 'Persist prompted secrets back to the keystore', false)
|
|
362
|
-
|
|
371
|
+
.option('--persist-missing', 'Persist prompted secrets back to the keystore', false);
|
|
372
|
+
addEncodingOption(exportCommand, 'Encode each secret value before template substitution (default: text)').action(async (options) => {
|
|
373
|
+
const encoding = (0, encoding_1.parseEncoding)(options.encoding);
|
|
374
|
+
if (encoding.isFailure()) {
|
|
375
|
+
console.error(`Error: ${encoding.message}`);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
363
378
|
const password = await resolvePassword(options, 'Keystore password');
|
|
364
379
|
if (password.isFailure()) {
|
|
365
380
|
console.error(`Error: ${password.message}`);
|
|
@@ -375,7 +390,7 @@ class KsCli {
|
|
|
375
390
|
console.error(`Error: ${opened.message}`);
|
|
376
391
|
process.exit(1);
|
|
377
392
|
}
|
|
378
|
-
const contextResult = await collectTemplateContext(opened.value.keystore, template.value);
|
|
393
|
+
const contextResult = await collectTemplateContext(opened.value.keystore, template.value, encoding.value);
|
|
379
394
|
if (contextResult.isFailure()) {
|
|
380
395
|
console.error(`Error: ${contextResult.message}`);
|
|
381
396
|
process.exit(1);
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1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AAE,OAA8C,EAAE,EAAE;;YAC/D,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,GAAG,mCAAI,iBAAiB,CAAC;YACjD,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,yBAAyB,OAAO,mCAAmC,CAAC,CAAC;gBACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAA,iBAAY,EAAC,qBAAqB,CAAC,CAAC;YAC3D,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,UAAU,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,UAAU,OAAO,IAAI,IAAA,qBAAU,EAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACjE,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAmB,EAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;oBACvB,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;gBACD,OAAO;YACT,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AA7TD,sBA6TC","sourcesContent":["import { Command } from 'commander';\nimport pkg from '../package.json';\n\nimport { CryptoUtils } from '@fgv/ts-extras';\nimport { Result, fail, succeed } from '@fgv/ts-utils';\n\nimport {\n copyTextToClipboard,\n defaultKeystorePath,\n promptHidden,\n promptVisible,\n readAllFromStdin,\n readTextFile,\n resolvePath\n} from './io';\nimport { getHelpText } from './help';\nimport {\n changeKeystorePassword,\n createKeystore,\n listSecrets,\n readSecret,\n openKeystore,\n removeSecret,\n saveKeystoreFile,\n storeSecret\n} from './keystore';\nimport { extractTemplateVariables, renderShellTemplate, shellQuote } from './template';\n\ninterface IKeystoreCommandOptions {\n keystore?: string;\n passwordEnv?: string;\n passwordFile?: string;\n passwordStdin?: boolean;\n}\n\ninterface ISecretValueOptions {\n stdin?: boolean;\n file?: string;\n}\n\ninterface IPutCommandOptions extends IKeystoreCommandOptions, ISecretValueOptions {\n name?: string;\n description?: string;\n replace?: boolean;\n}\n\ninterface IGetCommandOptions extends IKeystoreCommandOptions {\n clipboard?: boolean;\n}\n\ninterface IExportCommandOptions extends IKeystoreCommandOptions {\n templateFile?: string;\n templateString?: string;\n clipboard?: boolean;\n persistMissing?: boolean;\n}\n\ninterface IPasswordChangeOptions extends IKeystoreCommandOptions {\n newPasswordEnv?: string;\n newPasswordFile?: string;\n newPasswordStdin?: boolean;\n}\n\nfunction stripTrailingNewline(value: string): string {\n return value.replace(/\\r?\\n$/, '');\n}\n\nfunction hasExplicitPasswordSource(options: IKeystoreCommandOptions | IPasswordChangeOptions): boolean {\n return Boolean(options.passwordEnv || options.passwordFile || options.passwordStdin);\n}\n\nasync function readPasswordFromSource(\n options: IKeystoreCommandOptions | IPasswordChangeOptions\n): Promise<Result<string>> {\n if (options.passwordFile) {\n const fileResult = await readTextFile(options.passwordFile);\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(stripTrailingNewline(fileResult.value));\n }\n\n if (options.passwordStdin) {\n const stdinResult = await readAllFromStdin();\n if (stdinResult.isFailure()) {\n return fail(stdinResult.message);\n }\n return succeed(stripTrailingNewline(stdinResult.value));\n }\n\n if (options.passwordEnv) {\n const envValue = process.env[options.passwordEnv];\n if (envValue === undefined || envValue.length === 0) {\n return fail(`Environment variable '${options.passwordEnv}' is not set`);\n }\n return succeed(envValue);\n }\n\n const defaultEnv = process.env.FGV_KS_PASSWORD ?? process.env.KS_PASSWORD;\n if (defaultEnv !== undefined && defaultEnv.length > 0) {\n return succeed(defaultEnv);\n }\n\n return fail('Password not provided');\n}\n\nasync function resolvePassword(\n options: IKeystoreCommandOptions | IPasswordChangeOptions,\n label: string\n): Promise<Result<string>> {\n const source = await readPasswordFromSource(options);\n if (source.isSuccess()) {\n return source;\n }\n\n // If an explicit source was configured and failed, surface the error rather than prompting\n if (hasExplicitPasswordSource(options)) {\n return source;\n }\n\n const prompted = await promptHidden(`${label}: `);\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n return succeed(prompted.value);\n}\n\nasync function resolveSecretName(\n positionalName: string | undefined,\n options: IPutCommandOptions\n): Promise<Result<string>> {\n if (options.name !== undefined && options.name.length > 0) {\n return succeed(options.name);\n }\n\n if (positionalName !== undefined && positionalName.length > 0) {\n return succeed(positionalName);\n }\n\n const prompted = await promptVisible('Secret name: ');\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n if (prompted.value.length === 0) {\n return fail('Secret name cannot be empty');\n }\n\n return succeed(prompted.value);\n}\n\nasync function resolvePasswordConfirmed(\n options: IKeystoreCommandOptions | IPasswordChangeOptions,\n label: string\n): Promise<Result<string>> {\n // Only skip confirmation when password comes from an explicit non-interactive source.\n // Ambient env vars (FGV_KS_PASSWORD/KS_PASSWORD) are for reading the current password\n // and must not silently bypass confirmation when setting a new one.\n if (hasExplicitPasswordSource(options)) {\n return resolvePassword(options, label);\n }\n\n const first = await promptHidden(`${label}: `);\n if (first.isFailure()) {\n return fail(first.message);\n }\n\n const second = await promptHidden(`${label} (confirm): `);\n if (second.isFailure()) {\n return fail(second.message);\n }\n\n if (first.value !== second.value) {\n return fail('Passwords do not match');\n }\n\n return succeed(first.value);\n}\n\nasync function resolveSecretValue(options: ISecretValueOptions): Promise<Result<string>> {\n if (options.file && options.stdin) {\n return fail('Use either --file or --stdin, not both');\n }\n\n if (options.file) {\n const fileResult = await readTextFile(options.file);\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(stripTrailingNewline(fileResult.value));\n }\n\n if (options.stdin) {\n const stdinResult = await readAllFromStdin();\n if (stdinResult.isFailure()) {\n return fail(stdinResult.message);\n }\n return succeed(stripTrailingNewline(stdinResult.value));\n }\n\n const prompted = await promptHidden('Secret value: ');\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n return succeed(prompted.value);\n}\n\nasync function readTemplate(\n options: Pick<IExportCommandOptions, 'templateFile' | 'templateString'>\n): Promise<Result<string>> {\n if (options.templateFile && options.templateString) {\n return fail('Use either --template-file or --template-string, not both');\n }\n\n if (options.templateFile) {\n const fileResult = await readTextFile(resolvePath(options.templateFile));\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(fileResult.value);\n }\n\n if (options.templateString !== undefined) {\n return succeed(options.templateString);\n }\n\n return fail('Specify either --template-file or --template-string');\n}\n\ninterface ITemplateContextResult {\n readonly context: Record<string, string>;\n readonly missing: readonly [string, string][];\n}\n\nasync function collectTemplateContext(\n keystore: CryptoUtils.KeyStore.KeyStore,\n template: string\n): Promise<Result<ITemplateContextResult>> {\n const variablesResult = extractTemplateVariables(template);\n if (variablesResult.isFailure()) {\n return fail(variablesResult.message);\n }\n\n const secretListResult = keystore.listSecrets();\n if (secretListResult.isFailure()) {\n return fail(`Failed to list secrets: ${secretListResult.message}`);\n }\n const knownSecrets = new Set(secretListResult.value);\n\n const context = Object.create(null) as Record<string, string>;\n const missing: Array<[string, string]> = [];\n\n for (const variable of variablesResult.value) {\n const secretResult = keystore.getApiKey(variable);\n if (secretResult.isSuccess()) {\n context[variable] = secretResult.value;\n continue;\n }\n\n if (knownSecrets.has(variable)) {\n return fail(`Secret '${variable}' exists but is not an API key: ${secretResult.message}`);\n }\n\n const promptResult = await promptHidden(`Secret '${variable}' is missing. Enter value: `);\n if (promptResult.isFailure()) {\n return fail(promptResult.message);\n }\n\n context[variable] = promptResult.value;\n missing.push([variable, promptResult.value]);\n }\n\n return succeed({ context, missing });\n}\n\nexport class KsCli {\n private readonly _program: Command;\n\n public constructor() {\n this._program = new Command();\n this._setupCommands();\n }\n\n public async run(argv: string[]): Promise<void> {\n await this._program.parseAsync(argv);\n }\n\n private _setupCommands(): void {\n this._program.name('ks').description('Manage ts-extras keystore files').version(pkg.version);\n this._program.addHelpCommand(false);\n\n this._program\n .command('help [topic]')\n .description('Show overview, commands, password, or template help')\n .action((topic: string | undefined) => {\n const help = getHelpText(topic, this._program);\n if (help.isFailure()) {\n console.error(`Error: ${help.message}`);\n process.exit(1);\n }\n\n console.log(help.value);\n });\n\n this._program\n .command('init')\n .description('Initialize a new keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (options: IKeystoreCommandOptions) => {\n const password = await resolvePasswordConfirmed(options, 'New keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const created = await createKeystore(options.keystore, password.value);\n if (created.isFailure()) {\n console.error(`Error: ${created.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('password')\n .description('Change the keystore password')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the current password from')\n .option('--password-file <path>', 'Read the current password from a file')\n .option('--password-stdin', 'Read the current password from stdin', false)\n .option('--new-password-env <name>', 'Environment variable to read the new password from')\n .option('--new-password-file <path>', 'Read the new password from a file')\n .option('--new-password-stdin', 'Read the new password from stdin', false)\n .action(async (options: IPasswordChangeOptions) => {\n const currentPassword = await resolvePassword(options, 'Current keystore password');\n if (currentPassword.isFailure()) {\n console.error(`Error: ${currentPassword.message}`);\n process.exit(1);\n }\n\n const newPasswordOptions: IPasswordChangeOptions = {\n keystore: options.keystore,\n passwordEnv: options.newPasswordEnv,\n passwordFile: options.newPasswordFile,\n passwordStdin: options.newPasswordStdin\n };\n const nextPassword = await resolvePasswordConfirmed(newPasswordOptions, 'New keystore password');\n if (nextPassword.isFailure()) {\n console.error(`Error: ${nextPassword.message}`);\n process.exit(1);\n }\n\n const changed = await changeKeystorePassword(\n options.keystore,\n currentPassword.value,\n nextPassword.value\n );\n if (changed.isFailure()) {\n console.error(`Error: ${changed.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('put [name]')\n .description('Store a secret in the keystore from stdin, a file, or interactive prompts')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--name <name>', 'Secret name')\n .option('--stdin', 'Read the secret from stdin', false)\n .option('--file <path>', 'Read the secret from a file')\n .option('--description <text>', 'Optional secret description')\n .option('--replace', 'Replace an existing secret', false)\n .action(async (positionalName: string | undefined, options: IPutCommandOptions) => {\n const name = await resolveSecretName(positionalName, options);\n if (name.isFailure()) {\n console.error(`Error: ${name.message}`);\n process.exit(1);\n }\n\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const secret = await resolveSecretValue(options);\n if (secret.isFailure()) {\n console.error(`Error: ${secret.message}`);\n process.exit(1);\n }\n\n const stored = await storeSecret(options.keystore, password.value, name.value, secret.value, {\n description: options.description,\n replace: options.replace\n });\n if (stored.isFailure()) {\n console.error(`Error: ${stored.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('get <name>')\n .description('Read a secret from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--clipboard', 'Copy the secret to the clipboard', false)\n .action(async (name: string, options: IGetCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const secret = await readSecret(options.keystore, password.value, name);\n if (secret.isFailure()) {\n console.error(`Error: ${secret.message}`);\n process.exit(1);\n }\n\n if (options.clipboard) {\n const copied = await copyTextToClipboard(secret.value);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(secret.value);\n });\n\n this._program\n .command('list')\n .description('List secrets in the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (options: IKeystoreCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const names = await listSecrets(options.keystore, password.value);\n if (names.isFailure()) {\n console.error(`Error: ${names.message}`);\n process.exit(1);\n }\n\n for (const name of names.value) {\n console.log(name);\n }\n });\n\n this._program\n .command('remove <name>')\n .description('Remove a secret from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (name: string, options: IKeystoreCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const removed = await removeSecret(options.keystore, password.value, name);\n if (removed.isFailure()) {\n console.error(`Error: ${removed.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('export')\n .description('Render a shell template using secrets from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--template-file <path>', 'Read the shell template from a file')\n .option('--template-string <text>', 'Use the supplied shell template string')\n .option('--clipboard', 'Copy the rendered output to the clipboard', false)\n .option('--persist-missing', 'Persist prompted secrets back to the keystore', false)\n .action(async (options: IExportCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const template = await readTemplate(options);\n if (template.isFailure()) {\n console.error(`Error: ${template.message}`);\n process.exit(1);\n }\n\n const opened = await openKeystore(options.keystore, password.value);\n if (opened.isFailure()) {\n console.error(`Error: ${opened.message}`);\n process.exit(1);\n }\n\n const contextResult = await collectTemplateContext(opened.value.keystore, template.value);\n if (contextResult.isFailure()) {\n console.error(`Error: ${contextResult.message}`);\n process.exit(1);\n }\n\n const rendered = renderShellTemplate(template.value, contextResult.value.context);\n if (rendered.isFailure()) {\n console.error(`Error: ${rendered.message}`);\n process.exit(1);\n }\n\n if (options.persistMissing && contextResult.value.missing.length > 0) {\n for (const [name, value] of contextResult.value.missing) {\n const stored = await opened.value.keystore.importApiKey(name, value, { replace: true });\n if (stored.isFailure()) {\n console.error(`Error: Failed to persist missing secret '${name}': ${stored.message}`);\n process.exit(1);\n }\n }\n\n const saved = await opened.value.keystore.save(password.value);\n if (saved.isFailure()) {\n console.error(`Error: ${saved.message}`);\n process.exit(1);\n }\n\n const persisted = await saveKeystoreFile(opened.value.path, saved.value);\n if (persisted.isFailure()) {\n console.error(`Error: ${persisted.message}`);\n process.exit(1);\n }\n }\n\n if (options.clipboard) {\n const copied = await copyTextToClipboard(rendered.value);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(rendered.value);\n });\n\n this._program\n .command('session')\n .description('Prompt for a password and emit a shell export statement')\n .option('--var <name>', 'Environment variable name to emit', 'FGV_KS_PASSWORD')\n .option('--clipboard', 'Copy the export statement to the clipboard', false)\n .action(async (options: { var?: string; clipboard?: boolean }) => {\n const varName = options.var ?? 'FGV_KS_PASSWORD';\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(varName)) {\n console.error(`Error: '--var' value '${varName}' is not a valid shell identifier`);\n process.exit(1);\n }\n\n const password = await promptHidden('Keystore password: ');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const output = `export ${varName}=${shellQuote(password.value)}`;\n if (options.clipboard) {\n const copied = await copyTextToClipboard(output);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(output);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,mEAAkC;AAGlC,4CAAsD;AAEtD,6BAQc;AACd,iCAAqC;AACrC,yCASoB;AACpB,yCAAgG;AAChG,yCAAuF;AAuCvF,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAgB,EAAE,WAAmB;IAC9D,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,2BAAgB,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,yBAAyB,CAAC,OAAyD;IAC1F,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;AACvF,CAAC;AAED,KAAK,UAAU,sBAAsB,CACnC,OAAyD;;IAEzD,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,MAAM,IAAA,iBAAY,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAA,eAAI,EAAC,UAAU,CA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":["import { Command } from 'commander';\nimport pkg from '../package.json';\n\nimport { CryptoUtils } from '@fgv/ts-extras';\nimport { Result, fail, succeed } from '@fgv/ts-utils';\n\nimport {\n copyTextToClipboard,\n defaultKeystorePath,\n promptHidden,\n promptVisible,\n readAllFromStdin,\n readTextFile,\n resolvePath\n} from './io';\nimport { getHelpText } from './help';\nimport {\n changeKeystorePassword,\n createKeystore,\n listSecrets,\n readSecret,\n openKeystore,\n removeSecret,\n saveKeystoreFile,\n storeSecret\n} from './keystore';\nimport { DEFAULT_ENCODING, encodeSecret, Encoding, ENCODINGS, parseEncoding } from './encoding';\nimport { extractTemplateVariables, renderShellTemplate, shellQuote } from './template';\n\ninterface IKeystoreCommandOptions {\n keystore?: string;\n passwordEnv?: string;\n passwordFile?: string;\n passwordStdin?: boolean;\n}\n\ninterface ISecretValueOptions {\n stdin?: boolean;\n file?: string;\n}\n\ninterface IPutCommandOptions extends IKeystoreCommandOptions, ISecretValueOptions {\n name?: string;\n description?: string;\n replace?: boolean;\n}\n\ninterface IGetCommandOptions extends IKeystoreCommandOptions {\n clipboard?: boolean;\n encoding?: string;\n}\n\ninterface IExportCommandOptions extends IKeystoreCommandOptions {\n templateFile?: string;\n templateString?: string;\n clipboard?: boolean;\n persistMissing?: boolean;\n encoding?: string;\n}\n\ninterface IPasswordChangeOptions extends IKeystoreCommandOptions {\n newPasswordEnv?: string;\n newPasswordFile?: string;\n newPasswordStdin?: boolean;\n}\n\nfunction stripTrailingNewline(value: string): string {\n return value.replace(/\\r?\\n$/, '');\n}\n\nfunction addEncodingOption(command: Command, description: string): Command {\n return command.option(`--encoding <${ENCODINGS.join('|')}>`, description, DEFAULT_ENCODING);\n}\n\nfunction hasExplicitPasswordSource(options: IKeystoreCommandOptions | IPasswordChangeOptions): boolean {\n return Boolean(options.passwordEnv || options.passwordFile || options.passwordStdin);\n}\n\nasync function readPasswordFromSource(\n options: IKeystoreCommandOptions | IPasswordChangeOptions\n): Promise<Result<string>> {\n if (options.passwordFile) {\n const fileResult = await readTextFile(options.passwordFile);\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(stripTrailingNewline(fileResult.value));\n }\n\n if (options.passwordStdin) {\n const stdinResult = await readAllFromStdin();\n if (stdinResult.isFailure()) {\n return fail(stdinResult.message);\n }\n return succeed(stripTrailingNewline(stdinResult.value));\n }\n\n if (options.passwordEnv) {\n const envValue = process.env[options.passwordEnv];\n if (envValue === undefined || envValue.length === 0) {\n return fail(`Environment variable '${options.passwordEnv}' is not set`);\n }\n return succeed(envValue);\n }\n\n const defaultEnv = process.env.FGV_KS_PASSWORD ?? process.env.KS_PASSWORD;\n if (defaultEnv !== undefined && defaultEnv.length > 0) {\n return succeed(defaultEnv);\n }\n\n return fail('Password not provided');\n}\n\nasync function resolvePassword(\n options: IKeystoreCommandOptions | IPasswordChangeOptions,\n label: string\n): Promise<Result<string>> {\n const source = await readPasswordFromSource(options);\n if (source.isSuccess()) {\n return source;\n }\n\n // If an explicit source was configured and failed, surface the error rather than prompting\n if (hasExplicitPasswordSource(options)) {\n return source;\n }\n\n const prompted = await promptHidden(`${label}: `);\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n return succeed(prompted.value);\n}\n\nasync function resolveSecretName(\n positionalName: string | undefined,\n options: IPutCommandOptions\n): Promise<Result<string>> {\n if (options.name !== undefined && options.name.length > 0) {\n return succeed(options.name);\n }\n\n if (positionalName !== undefined && positionalName.length > 0) {\n return succeed(positionalName);\n }\n\n const prompted = await promptVisible('Secret name: ');\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n if (prompted.value.length === 0) {\n return fail('Secret name cannot be empty');\n }\n\n return succeed(prompted.value);\n}\n\nasync function resolvePasswordConfirmed(\n options: IKeystoreCommandOptions | IPasswordChangeOptions,\n label: string\n): Promise<Result<string>> {\n // Only skip confirmation when password comes from an explicit non-interactive source.\n // Ambient env vars (FGV_KS_PASSWORD/KS_PASSWORD) are for reading the current password\n // and must not silently bypass confirmation when setting a new one.\n if (hasExplicitPasswordSource(options)) {\n return resolvePassword(options, label);\n }\n\n const first = await promptHidden(`${label}: `);\n if (first.isFailure()) {\n return fail(first.message);\n }\n\n const second = await promptHidden(`${label} (confirm): `);\n if (second.isFailure()) {\n return fail(second.message);\n }\n\n if (first.value !== second.value) {\n return fail('Passwords do not match');\n }\n\n return succeed(first.value);\n}\n\nasync function resolveSecretValue(options: ISecretValueOptions): Promise<Result<string>> {\n if (options.file && options.stdin) {\n return fail('Use either --file or --stdin, not both');\n }\n\n if (options.file) {\n const fileResult = await readTextFile(options.file);\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(stripTrailingNewline(fileResult.value));\n }\n\n if (options.stdin) {\n const stdinResult = await readAllFromStdin();\n if (stdinResult.isFailure()) {\n return fail(stdinResult.message);\n }\n return succeed(stripTrailingNewline(stdinResult.value));\n }\n\n const prompted = await promptHidden('Secret value: ');\n if (prompted.isFailure()) {\n return fail(prompted.message);\n }\n\n return succeed(prompted.value);\n}\n\nasync function readTemplate(\n options: Pick<IExportCommandOptions, 'templateFile' | 'templateString'>\n): Promise<Result<string>> {\n if (options.templateFile && options.templateString) {\n return fail('Use either --template-file or --template-string, not both');\n }\n\n if (options.templateFile) {\n const fileResult = await readTextFile(resolvePath(options.templateFile));\n if (fileResult.isFailure()) {\n return fail(fileResult.message);\n }\n return succeed(fileResult.value);\n }\n\n if (options.templateString !== undefined) {\n return succeed(options.templateString);\n }\n\n return fail('Specify either --template-file or --template-string');\n}\n\ninterface ITemplateContextResult {\n readonly context: Record<string, string>;\n readonly missing: readonly [string, string][];\n}\n\nasync function collectTemplateContext(\n keystore: CryptoUtils.KeyStore.KeyStore,\n template: string,\n encoding: Encoding\n): Promise<Result<ITemplateContextResult>> {\n const variablesResult = extractTemplateVariables(template);\n if (variablesResult.isFailure()) {\n return fail(variablesResult.message);\n }\n\n const secretListResult = keystore.listSecrets();\n if (secretListResult.isFailure()) {\n return fail(`Failed to list secrets: ${secretListResult.message}`);\n }\n const knownSecrets = new Set(secretListResult.value);\n\n const context = Object.create(null) as Record<string, string>;\n const missing: Array<[string, string]> = [];\n\n for (const variable of variablesResult.value) {\n const secretResult = keystore.getApiKey(variable);\n if (secretResult.isSuccess()) {\n context[variable] = encodeSecret(secretResult.value, encoding);\n continue;\n }\n\n if (knownSecrets.has(variable)) {\n return fail(`Secret '${variable}' exists but is not an API key: ${secretResult.message}`);\n }\n\n const promptResult = await promptHidden(`Secret '${variable}' is missing. Enter value: `);\n if (promptResult.isFailure()) {\n return fail(promptResult.message);\n }\n\n context[variable] = encodeSecret(promptResult.value, encoding);\n missing.push([variable, promptResult.value]);\n }\n\n return succeed({ context, missing });\n}\n\nexport class KsCli {\n private readonly _program: Command;\n\n public constructor() {\n this._program = new Command();\n this._setupCommands();\n }\n\n public async run(argv: string[]): Promise<void> {\n await this._program.parseAsync(argv);\n }\n\n private _setupCommands(): void {\n this._program.name('ks').description('Manage ts-extras keystore files').version(pkg.version);\n this._program.addHelpCommand(false);\n\n this._program\n .command('help [topic]')\n .description('Show overview, commands, password, or template help')\n .action((topic: string | undefined) => {\n const help = getHelpText(topic, this._program);\n if (help.isFailure()) {\n console.error(`Error: ${help.message}`);\n process.exit(1);\n }\n\n console.log(help.value);\n });\n\n this._program\n .command('init')\n .description('Initialize a new keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (options: IKeystoreCommandOptions) => {\n const password = await resolvePasswordConfirmed(options, 'New keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const created = await createKeystore(options.keystore, password.value);\n if (created.isFailure()) {\n console.error(`Error: ${created.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('password')\n .description('Change the keystore password')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the current password from')\n .option('--password-file <path>', 'Read the current password from a file')\n .option('--password-stdin', 'Read the current password from stdin', false)\n .option('--new-password-env <name>', 'Environment variable to read the new password from')\n .option('--new-password-file <path>', 'Read the new password from a file')\n .option('--new-password-stdin', 'Read the new password from stdin', false)\n .action(async (options: IPasswordChangeOptions) => {\n const currentPassword = await resolvePassword(options, 'Current keystore password');\n if (currentPassword.isFailure()) {\n console.error(`Error: ${currentPassword.message}`);\n process.exit(1);\n }\n\n const newPasswordOptions: IPasswordChangeOptions = {\n keystore: options.keystore,\n passwordEnv: options.newPasswordEnv,\n passwordFile: options.newPasswordFile,\n passwordStdin: options.newPasswordStdin\n };\n const nextPassword = await resolvePasswordConfirmed(newPasswordOptions, 'New keystore password');\n if (nextPassword.isFailure()) {\n console.error(`Error: ${nextPassword.message}`);\n process.exit(1);\n }\n\n const changed = await changeKeystorePassword(\n options.keystore,\n currentPassword.value,\n nextPassword.value\n );\n if (changed.isFailure()) {\n console.error(`Error: ${changed.message}`);\n process.exit(1);\n }\n });\n\n this._program\n .command('put [name]')\n .description('Store a secret in the keystore from stdin, a file, or interactive prompts')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--name <name>', 'Secret name')\n .option('--stdin', 'Read the secret from stdin', false)\n .option('--file <path>', 'Read the secret from a file')\n .option('--description <text>', 'Optional secret description')\n .option('--replace', 'Replace an existing secret', false)\n .action(async (positionalName: string | undefined, options: IPutCommandOptions) => {\n const name = await resolveSecretName(positionalName, options);\n if (name.isFailure()) {\n console.error(`Error: ${name.message}`);\n process.exit(1);\n }\n\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const secret = await resolveSecretValue(options);\n if (secret.isFailure()) {\n console.error(`Error: ${secret.message}`);\n process.exit(1);\n }\n\n const stored = await storeSecret(options.keystore, password.value, name.value, secret.value, {\n description: options.description,\n replace: options.replace\n });\n if (stored.isFailure()) {\n console.error(`Error: ${stored.message}`);\n process.exit(1);\n }\n });\n\n const getCommand = this._program\n .command('get <name>')\n .description('Read a secret from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--clipboard', 'Copy the secret to the clipboard', false);\n addEncodingOption(getCommand, 'Encode the secret value before output (default: text)').action(\n async (name: string, options: IGetCommandOptions) => {\n const encoding = parseEncoding(options.encoding);\n if (encoding.isFailure()) {\n console.error(`Error: ${encoding.message}`);\n process.exit(1);\n }\n\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const secret = await readSecret(options.keystore, password.value, name);\n if (secret.isFailure()) {\n console.error(`Error: ${secret.message}`);\n process.exit(1);\n }\n\n const encoded = encodeSecret(secret.value, encoding.value);\n\n if (options.clipboard) {\n const copied = await copyTextToClipboard(encoded);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(encoded);\n }\n );\n\n this._program\n .command('list')\n .description('List secrets in the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (options: IKeystoreCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const names = await listSecrets(options.keystore, password.value);\n if (names.isFailure()) {\n console.error(`Error: ${names.message}`);\n process.exit(1);\n }\n\n for (const name of names.value) {\n console.log(name);\n }\n });\n\n this._program\n .command('remove <name>')\n .description('Remove a secret from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .action(async (name: string, options: IKeystoreCommandOptions) => {\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const removed = await removeSecret(options.keystore, password.value, name);\n if (removed.isFailure()) {\n console.error(`Error: ${removed.message}`);\n process.exit(1);\n }\n });\n\n const exportCommand = this._program\n .command('export')\n .description('Render a shell template using secrets from the keystore')\n .option('--keystore <path>', 'Keystore file path', defaultKeystorePath())\n .option('--password-env <name>', 'Environment variable to read the password from')\n .option('--password-file <path>', 'Read the password from a file')\n .option('--password-stdin', 'Read the password from stdin', false)\n .option('--template-file <path>', 'Read the shell template from a file')\n .option('--template-string <text>', 'Use the supplied shell template string')\n .option('--clipboard', 'Copy the rendered output to the clipboard', false)\n .option('--persist-missing', 'Persist prompted secrets back to the keystore', false);\n addEncodingOption(\n exportCommand,\n 'Encode each secret value before template substitution (default: text)'\n ).action(async (options: IExportCommandOptions) => {\n const encoding = parseEncoding(options.encoding);\n if (encoding.isFailure()) {\n console.error(`Error: ${encoding.message}`);\n process.exit(1);\n }\n\n const password = await resolvePassword(options, 'Keystore password');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const template = await readTemplate(options);\n if (template.isFailure()) {\n console.error(`Error: ${template.message}`);\n process.exit(1);\n }\n\n const opened = await openKeystore(options.keystore, password.value);\n if (opened.isFailure()) {\n console.error(`Error: ${opened.message}`);\n process.exit(1);\n }\n\n const contextResult = await collectTemplateContext(\n opened.value.keystore,\n template.value,\n encoding.value\n );\n if (contextResult.isFailure()) {\n console.error(`Error: ${contextResult.message}`);\n process.exit(1);\n }\n\n const rendered = renderShellTemplate(template.value, contextResult.value.context);\n if (rendered.isFailure()) {\n console.error(`Error: ${rendered.message}`);\n process.exit(1);\n }\n\n if (options.persistMissing && contextResult.value.missing.length > 0) {\n for (const [name, value] of contextResult.value.missing) {\n const stored = await opened.value.keystore.importApiKey(name, value, { replace: true });\n if (stored.isFailure()) {\n console.error(`Error: Failed to persist missing secret '${name}': ${stored.message}`);\n process.exit(1);\n }\n }\n\n const saved = await opened.value.keystore.save(password.value);\n if (saved.isFailure()) {\n console.error(`Error: ${saved.message}`);\n process.exit(1);\n }\n\n const persisted = await saveKeystoreFile(opened.value.path, saved.value);\n if (persisted.isFailure()) {\n console.error(`Error: ${persisted.message}`);\n process.exit(1);\n }\n }\n\n if (options.clipboard) {\n const copied = await copyTextToClipboard(rendered.value);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(rendered.value);\n });\n\n this._program\n .command('session')\n .description('Prompt for a password and emit a shell export statement')\n .option('--var <name>', 'Environment variable name to emit', 'FGV_KS_PASSWORD')\n .option('--clipboard', 'Copy the export statement to the clipboard', false)\n .action(async (options: { var?: string; clipboard?: boolean }) => {\n const varName = options.var ?? 'FGV_KS_PASSWORD';\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(varName)) {\n console.error(`Error: '--var' value '${varName}' is not a valid shell identifier`);\n process.exit(1);\n }\n\n const password = await promptHidden('Keystore password: ');\n if (password.isFailure()) {\n console.error(`Error: ${password.message}`);\n process.exit(1);\n }\n\n const output = `export ${varName}=${shellQuote(password.value)}`;\n if (options.clipboard) {\n const copied = await copyTextToClipboard(output);\n if (copied.isFailure()) {\n console.error(`Error: ${copied.message}`);\n process.exit(1);\n }\n return;\n }\n\n console.log(output);\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
export type Encoding = 'text' | 'base64' | 'hex';
|
|
3
|
+
export declare const ENCODINGS: readonly Encoding[];
|
|
4
|
+
export declare const DEFAULT_ENCODING: Encoding;
|
|
5
|
+
export declare function parseEncoding(value: string | undefined): Result<Encoding>;
|
|
6
|
+
export declare function encodeSecret(value: string, encoding: Encoding): string;
|
|
7
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEjD,eAAO,MAAM,SAAS,EAAE,SAAS,QAAQ,EAA8B,CAAC;AAExE,eAAO,MAAM,gBAAgB,EAAE,QAAiB,CAAC;AAEjD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CASzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAStE"}
|
package/lib/encoding.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_ENCODING = exports.ENCODINGS = void 0;
|
|
4
|
+
exports.parseEncoding = parseEncoding;
|
|
5
|
+
exports.encodeSecret = encodeSecret;
|
|
6
|
+
const ts_extras_1 = require("@fgv/ts-extras");
|
|
7
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
8
|
+
exports.ENCODINGS = ['text', 'base64', 'hex'];
|
|
9
|
+
exports.DEFAULT_ENCODING = 'text';
|
|
10
|
+
function parseEncoding(value) {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return (0, ts_utils_1.succeed)(exports.DEFAULT_ENCODING);
|
|
13
|
+
}
|
|
14
|
+
const normalized = value.toLowerCase();
|
|
15
|
+
if (normalized === 'text' || normalized === 'base64' || normalized === 'hex') {
|
|
16
|
+
return (0, ts_utils_1.succeed)(normalized);
|
|
17
|
+
}
|
|
18
|
+
return (0, ts_utils_1.fail)(`Invalid encoding '${value}'. Expected one of: ${exports.ENCODINGS.join(', ')}`);
|
|
19
|
+
}
|
|
20
|
+
function encodeSecret(value, encoding) {
|
|
21
|
+
if (encoding === 'text') {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
const bytes = new TextEncoder().encode(value);
|
|
25
|
+
if (encoding === 'base64') {
|
|
26
|
+
return ts_extras_1.CryptoUtils.toBase64(bytes);
|
|
27
|
+
}
|
|
28
|
+
return Buffer.from(bytes).toString('hex');
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":";;;AASA,sCASC;AAED,oCASC;AA7BD,8CAA6C;AAC7C,4CAAsD;AAIzC,QAAA,SAAS,GAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAE3D,QAAA,gBAAgB,GAAa,MAAM,CAAC;AAEjD,SAAgB,aAAa,CAAC,KAAyB;IACrD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAA,kBAAO,EAAC,wBAAgB,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAC7E,OAAO,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,IAAA,eAAI,EAAC,qBAAqB,KAAK,uBAAuB,iBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvF,CAAC;AAED,SAAgB,YAAY,CAAC,KAAa,EAAE,QAAkB;IAC5D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,uBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { CryptoUtils } from '@fgv/ts-extras';\nimport { Result, fail, succeed } from '@fgv/ts-utils';\n\nexport type Encoding = 'text' | 'base64' | 'hex';\n\nexport const ENCODINGS: readonly Encoding[] = ['text', 'base64', 'hex'];\n\nexport const DEFAULT_ENCODING: Encoding = 'text';\n\nexport function parseEncoding(value: string | undefined): Result<Encoding> {\n if (value === undefined) {\n return succeed(DEFAULT_ENCODING);\n }\n const normalized = value.toLowerCase();\n if (normalized === 'text' || normalized === 'base64' || normalized === 'hex') {\n return succeed(normalized);\n }\n return fail(`Invalid encoding '${value}'. Expected one of: ${ENCODINGS.join(', ')}`);\n}\n\nexport function encodeSecret(value: string, encoding: Encoding): string {\n if (encoding === 'text') {\n return value;\n }\n const bytes = new TextEncoder().encode(value);\n if (encoding === 'base64') {\n return CryptoUtils.toBase64(bytes);\n }\n return Buffer.from(bytes).toString('hex');\n}\n"]}
|
package/lib/help.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAQ,MAAM,EAAW,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAQ,MAAM,EAAW,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAmF1E,wBAAgB,WAAW,CAAC,KAAK,GAAE,MAAM,GAAG,SAAqB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CA6BpG"}
|
package/lib/help.js
CHANGED
|
@@ -55,6 +55,7 @@ Options:
|
|
|
55
55
|
--template-string <text> Use an inline shell template string
|
|
56
56
|
--persist-missing Save prompted secrets back to the keystore
|
|
57
57
|
--clipboard Copy the rendered output to the clipboard
|
|
58
|
+
--encoding <text|base64|hex> Encode each secret before template substitution (default: text)
|
|
58
59
|
|
|
59
60
|
Missing secrets referenced by the template are prompted interactively.
|
|
60
61
|
Rendered values are shell-quoted before output.
|
package/lib/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";;AAuFA,kCA6BC;AAlHD,4CAAsD;AAItD,MAAM,qBAAqB,GAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAErG,MAAM,aAAa,GAAW;;;;;;;;;;;;;;;;;;aAkBjB,CAAC;AAEd,MAAM,aAAa,GAAW;;;;;;;;;;kEAUoC,CAAC;AAEnE,MAAM,aAAa,GAAW;;;;;;;;;;;mCAWK,CAAC;AAEpC,MAAM,aAAa,GAAW;;;;;;;;;;;;;;;;;2DAiB6B,CAAC;AAE5D,MAAM,UAAU,GAAwC;IACtD,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,aAAa;IACvB,QAAQ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KAAK,UAAU;YACb,OAAO,IAAA,kBAAO,EAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACtC;YACE,OAAO,IAAA,eAAI,EAAC,uBAAuB,KAAK,wBAAwB,qBAAqB,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC","sourcesContent":["import { Command } from 'commander';\n\nimport { fail, Result, succeed } from '@fgv/ts-utils';\n\nexport type HelpTopic = 'overview' | 'commands' | 'password' | 'template';\n\nconst AVAILABLE_HELP_TOPICS: readonly HelpTopic[] = ['overview', 'commands', 'password', 'template'];\n\nconst HELP_OVERVIEW: string = `ks manages ts-extras keystore files.\n\nStart here:\n ks help overview\n ks help commands\n ks help password\n ks help template\n\nDefault keystore:\n ~/.fgv-ks\n\nCommon commands:\n ks init\n ks put <name>\n ks get <name>\n ks list\n ks remove <name>\n ks export\n ks session`;\n\nconst HELP_COMMANDS: string = `ks commands\n\n ks init Create a new keystore\n ks password Change the keystore password\n ks put <name> Store a secret in the keystore\n ks get <name> Read a secret from the keystore\n ks list List stored secrets\n ks remove <name> Remove a stored secret\n ks export Render a shell template from keystore secrets\n ks session Emit a shell export statement for the password\n ks help [topic] Show self-contained help on a specific topic`;\n\nconst HELP_PASSWORD: string = `ks password sources\n\nPasswords may be supplied with:\n --password-file <path>\n --password-stdin\n --password-env <name>\n FGV_KS_PASSWORD\n KS_PASSWORD\n\nIf no password source is provided, ks prompts interactively.\nThe session command can emit a shell export statement:\n ks session --var FGV_KS_PASSWORD`;\n\nconst HELP_TEMPLATE: string = `ks export template format\n\nTemplates use simple Mustache-style variables such as {{xai}}.\nOnly simple variables are supported; sections and other advanced Mustache features are rejected.\n\nOptions:\n --template-file <path> Read the shell template from a file\n --template-string <text> Use an inline shell template string\n --persist-missing Save prompted secrets back to the keystore\n --clipboard Copy the rendered output to the clipboard\n --encoding <text|base64|hex> Encode each secret before template substitution (default: text)\n\nMissing secrets referenced by the template are prompted interactively.\nRendered values are shell-quoted before output.\n\nExample:\n ks export --template-file ./keystore.template.sh\n ks export --template-string 'export XAI_API_KEY={{xai}}'`;\n\nconst HELP_TEXTS: Readonly<Record<HelpTopic, string>> = {\n commands: HELP_COMMANDS,\n overview: HELP_OVERVIEW,\n password: HELP_PASSWORD,\n template: HELP_TEMPLATE\n};\n\nfunction normalizeHelpTopic(topic: string): string {\n return topic.trim().toLowerCase();\n}\n\nfunction formatAvailableTopics(): string {\n return AVAILABLE_HELP_TOPICS.join(', ');\n}\n\nexport function getHelpText(topic: string | undefined = undefined, program?: Command): Result<string> {\n if (topic === undefined || topic.trim().length === 0) {\n return succeed(HELP_TEXTS.overview);\n }\n\n const normalized = normalizeHelpTopic(topic);\n\n if (program !== undefined) {\n const command = program.commands.find((candidate: Command) => candidate.name() === normalized);\n if (command !== undefined && command.name() !== 'help') {\n return succeed(command.helpInformation());\n }\n }\n\n switch (normalized) {\n case 'help':\n case 'overview':\n return succeed(HELP_TEXTS.overview);\n case 'commands':\n case 'command':\n return succeed(HELP_TEXTS.commands);\n case 'password':\n case 'passwords':\n return succeed(HELP_TEXTS.password);\n case 'template':\n return succeed(HELP_TEXTS.template);\n default:\n return fail(`Unknown help topic '${topic}'. Available topics: ${formatAvailableTopics()}`);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ks",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-33",
|
|
4
4
|
"description": "Command-line utility for managing ts-extras keystore files",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"clipboardy": "^3.0.0",
|
|
24
24
|
"commander": "^11.0.0",
|
|
25
|
-
"@fgv/ts-extras": "5.1.0-
|
|
26
|
-
"@fgv/ts-utils": "5.1.0-
|
|
27
|
-
"@fgv/ts-json-base": "5.1.0-
|
|
25
|
+
"@fgv/ts-extras": "5.1.0-33",
|
|
26
|
+
"@fgv/ts-utils": "5.1.0-33",
|
|
27
|
+
"@fgv/ts-json-base": "5.1.0-33"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rushstack/eslint-config": "4.6.4",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript": "5.9.3",
|
|
39
39
|
"@types/heft-jest": "1.0.6",
|
|
40
40
|
"ts-jest": "^29.4.6",
|
|
41
|
-
"@fgv/ts-utils-jest": "5.1.0-
|
|
41
|
+
"@fgv/ts-utils-jest": "5.1.0-33"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
package/rush-logs/ks.build.log
CHANGED
|
@@ -3,5 +3,5 @@ Invoking: heft build --clean
|
|
|
3
3
|
[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.
|
|
4
4
|
[build:typescript] Using TypeScript version 5.9.3
|
|
5
5
|
[build:lint] Using ESLint version 9.39.4
|
|
6
|
-
---- build finished (12.
|
|
7
|
-
-------------------- Finished (12.
|
|
6
|
+
---- build finished (12.387s) ----
|
|
7
|
+
-------------------- Finished (12.391s) --------------------
|