@bluelamp/secret-exec 0.4.0 → 0.5.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/bin/bluelamp-secret.mjs +9 -5
- package/dist/index.d.ts +6 -3
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/bin/bluelamp-secret.mjs
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { spawn } from 'node:child_process';
|
|
11
11
|
import { readFile } from 'node:fs/promises';
|
|
12
12
|
import { constants as osConstants } from 'node:os';
|
|
13
|
-
import {
|
|
14
|
-
import { runSecretCopy, runSecretExec, runSecretPut } from '../dist/index.js';
|
|
13
|
+
import { readFreshCliToken } from '@bluelamp/cli-token';
|
|
14
|
+
import { resolvePortalApiBaseUrl, runSecretCopy, runSecretExec, runSecretPut } from '../dist/index.js';
|
|
15
15
|
import { clipboardBackend, consoleIsMine, isWsl, scheduleClear } from '../dist/clipboard.js';
|
|
16
16
|
|
|
17
17
|
// 端末の Ctrl-C は同じプロセスグループの子にも届く=親は受け流して子の終了を待つ。
|
|
@@ -20,11 +20,15 @@ const FORWARDED = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
|
20
20
|
|
|
21
21
|
const argv = process.argv.slice(2);
|
|
22
22
|
|
|
23
|
+
// n=3918: 機体に結んだ札は 1 時間で切れる。延ばす口(ensureFreshCliToken・ロックで機体ごとに 1 か所)を通してから読む。
|
|
24
|
+
// 延ばしの宛先は金庫と同じ base(BLUELAMP_PORTAL_API_BASE_URL → PORTAL_URL → 本番)
|
|
25
|
+
const loadToken = () => readFreshCliToken({ baseUrl: resolvePortalApiBaseUrl(process.env) });
|
|
26
|
+
|
|
23
27
|
const run =
|
|
24
28
|
argv[0] === 'put'
|
|
25
29
|
? runSecretPut(argv, {
|
|
26
30
|
env: process.env,
|
|
27
|
-
loadToken
|
|
31
|
+
loadToken,
|
|
28
32
|
fetch: (url, init) => globalThis.fetch(url, init),
|
|
29
33
|
stdinIsTTY: () => process.stdin.isTTY === true,
|
|
30
34
|
readStdin: async () => {
|
|
@@ -43,7 +47,7 @@ const run =
|
|
|
43
47
|
isWsl: process.platform === 'linux' && isWsl(process.env),
|
|
44
48
|
consoleIsMine: process.platform === 'darwin' && consoleIsMine(),
|
|
45
49
|
},
|
|
46
|
-
loadToken
|
|
50
|
+
loadToken,
|
|
47
51
|
fetch: (url, init) => globalThis.fetch(url, init),
|
|
48
52
|
backend: (kind) => clipboardBackend(kind),
|
|
49
53
|
scheduleClear: (kind, value, seconds) => scheduleClear(kind, value, seconds),
|
|
@@ -54,7 +58,7 @@ const run =
|
|
|
54
58
|
function runExec() {
|
|
55
59
|
return runSecretExec(argv, {
|
|
56
60
|
env: process.env,
|
|
57
|
-
loadToken
|
|
61
|
+
loadToken,
|
|
58
62
|
fetch: (url, init) => globalThis.fetch(url, init),
|
|
59
63
|
spawn: (command, args, options) => spawn(command, args, options),
|
|
60
64
|
stderr: (text) => process.stderr.write(text),
|
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,8 @@ interface ChildLike {
|
|
|
78
78
|
}
|
|
79
79
|
export interface SecretExecDeps {
|
|
80
80
|
env: Readonly<Record<string, string | undefined>>;
|
|
81
|
-
|
|
81
|
+
/** 札を読む(n=3918: 機体の札は延ばしてから読む=bin は readFreshCliToken を渡す)。読めなければ null */
|
|
82
|
+
loadToken: () => Promise<string | null>;
|
|
82
83
|
fetch: FetchLike;
|
|
83
84
|
spawn: (command: string, args: string[], options: {
|
|
84
85
|
stdio: 'inherit';
|
|
@@ -127,7 +128,8 @@ export declare function deriveOrigin(raw: string): string | null;
|
|
|
127
128
|
export declare function parsePutArgs(argv: readonly string[]): PutParseResult;
|
|
128
129
|
export interface SecretPutDeps {
|
|
129
130
|
env: Readonly<Record<string, string | undefined>>;
|
|
130
|
-
|
|
131
|
+
/** 札を読む(n=3918: 機体の札は延ばしてから読む=bin は readFreshCliToken を渡す)。読めなければ null */
|
|
132
|
+
loadToken: () => Promise<string | null>;
|
|
131
133
|
fetch: FetchLike;
|
|
132
134
|
/** 標準入力が端末か */
|
|
133
135
|
stdinIsTTY: () => boolean;
|
|
@@ -147,7 +149,8 @@ export declare function runSecretPut(argv: readonly string[], deps: SecretPutDep
|
|
|
147
149
|
export interface SecretCopyDeps {
|
|
148
150
|
env: Readonly<Record<string, string | undefined>>;
|
|
149
151
|
host: Omit<HostInfo, 'env'>;
|
|
150
|
-
|
|
152
|
+
/** 札を読む(n=3918: 機体の札は延ばしてから読む=bin は readFreshCliToken を渡す)。読めなければ null */
|
|
153
|
+
loadToken: () => Promise<string | null>;
|
|
151
154
|
fetch: FetchLike;
|
|
152
155
|
backend: (kind: DialogKind) => Pick<ClipboardBackend, 'dialog' | 'write'>;
|
|
153
156
|
scheduleClear: (kind: DialogKind, value: string, seconds: number) => Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ export async function runSecretExec(argv, deps) {
|
|
|
176
176
|
deps.stderr(`${PREFIX}${parsed.error}\n${USAGE}`);
|
|
177
177
|
return 2;
|
|
178
178
|
}
|
|
179
|
-
const token = deps.loadToken();
|
|
179
|
+
const token = await deps.loadToken();
|
|
180
180
|
if (!token) {
|
|
181
181
|
deps.stderr(`${PREFIX}未ログインです(bluelamp1 などでログインしてから撃ってください)\n`);
|
|
182
182
|
return 1;
|
|
@@ -350,7 +350,7 @@ export async function runSecretPut(argv, deps) {
|
|
|
350
350
|
deps.stderr(`${PREFIX}標準入力が端末です。値はパイプか --file で渡してください(例: <値を出すコマンド> | bluelamp-secret put ${name})\n`);
|
|
351
351
|
return 2;
|
|
352
352
|
}
|
|
353
|
-
const token = deps.loadToken();
|
|
353
|
+
const token = await deps.loadToken();
|
|
354
354
|
if (!token) {
|
|
355
355
|
deps.stderr(`${PREFIX}未ログインです(bluelamp1 などでログインしてから撃ってください)\n`);
|
|
356
356
|
return 1;
|
|
@@ -443,7 +443,7 @@ export async function runSecretCopy(argv, deps) {
|
|
|
443
443
|
deps.stderr(`${PREFIX}確認の窓を出せないのでコピーしません(${support.reason})\n`);
|
|
444
444
|
return 4;
|
|
445
445
|
}
|
|
446
|
-
const token = deps.loadToken();
|
|
446
|
+
const token = await deps.loadToken();
|
|
447
447
|
if (!token) {
|
|
448
448
|
deps.stderr(`${PREFIX}未ログインです(bluelamp1 などでログインしてから撃ってください)\n`);
|
|
449
449
|
return 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluelamp/secret-exec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "金庫の値を子プロセスの環境変数にだけ入れてコマンドを実行し(exec)、標準入力から金庫へ入れる(put)・持ち主の確認の窓でクリップボードへ入れる(copy)。値を画面・引数・ログに出さない口",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bluelamp",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test": "npm run build && node --test tests/*.test.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@bluelamp/cli-token": "1.0
|
|
44
|
+
"@bluelamp/cli-token": "1.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^22.10.5",
|