@indigoai-us/hq-cli 5.12.4 → 5.12.5
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/commands/secrets.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b75c8495-7e0e-53f8-a0d2-c92a993e6492")}catch(e){}}();
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import * as readline from "node:readline";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -467,7 +467,6 @@ export function registerSecretsCommand(program) {
|
|
|
467
467
|
.option("--expires <duration>", "Token expiry duration (e.g. 24h, 2d, 30m)", "24h")
|
|
468
468
|
.action(async (name, opts) => {
|
|
469
469
|
try {
|
|
470
|
-
rejectIfPersonal(secrets.opts(), "generate-link");
|
|
471
470
|
if (!SECRET_NAME_PATTERN.test(name)) {
|
|
472
471
|
console.error(chalk.red(`Invalid secret name '${name}': must match ^[A-Z][A-Z0-9_]*(/[A-Z][A-Z0-9_]+)*$ (e.g. MY_API_KEY or DEV/MY_KEY)`));
|
|
473
472
|
process.exit(1);
|
|
@@ -713,4 +712,4 @@ export function registerSecretsCommand(program) {
|
|
|
713
712
|
});
|
|
714
713
|
}
|
|
715
714
|
//# sourceMappingURL=secrets.js.map
|
|
716
|
-
//# debugId=
|
|
715
|
+
//# debugId=b75c8495-7e0e-53f8-a0d2-c92a993e6492
|
package/package.json
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterEach,
|
|
3
|
+
beforeEach,
|
|
4
|
+
describe,
|
|
5
|
+
expect,
|
|
6
|
+
it,
|
|
7
|
+
vi,
|
|
8
|
+
type MockInstance,
|
|
9
|
+
} from "vitest";
|
|
10
|
+
|
|
11
|
+
vi.mock("../utils/cognito-session.js", async (importOriginal) => {
|
|
12
|
+
const original = (await importOriginal()) as Record<string, unknown>;
|
|
13
|
+
return {
|
|
14
|
+
...original,
|
|
15
|
+
ensureCognitoToken: vi.fn(async () => "test-token"),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
vi.mock("../utils/vault-api.js", async (importOriginal) => {
|
|
20
|
+
const original = (await importOriginal()) as Record<string, unknown>;
|
|
21
|
+
return {
|
|
22
|
+
...original,
|
|
23
|
+
getEntityUid: vi.fn(async () => "prs_alice"),
|
|
24
|
+
vaultApiFetch: vi.fn(async () =>
|
|
25
|
+
new Response(
|
|
26
|
+
JSON.stringify({
|
|
27
|
+
url: "https://hq.example/secrets-input/tok_secret",
|
|
28
|
+
expiresAt: "2026-05-12T12:00:00.000Z",
|
|
29
|
+
secretName: "MY_KEY",
|
|
30
|
+
}),
|
|
31
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
import { Command } from "commander";
|
|
38
|
+
import { registerSecretsCommand } from "./secrets.js";
|
|
39
|
+
import { getEntityUid, vaultApiFetch } from "../utils/vault-api.js";
|
|
40
|
+
|
|
41
|
+
let logSpy: MockInstance<typeof console.log>;
|
|
42
|
+
let errSpy: MockInstance<typeof console.error>;
|
|
43
|
+
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
vi.clearAllMocks();
|
|
46
|
+
logSpy = vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
47
|
+
errSpy = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
vi.restoreAllMocks();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function buildProgram(): Command {
|
|
55
|
+
const program = new Command();
|
|
56
|
+
program.exitOverride();
|
|
57
|
+
program.configureOutput({
|
|
58
|
+
writeOut: () => undefined,
|
|
59
|
+
writeErr: () => undefined,
|
|
60
|
+
});
|
|
61
|
+
registerSecretsCommand(program);
|
|
62
|
+
return program;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe("secrets generate-link", () => {
|
|
66
|
+
it("mints one-time submission links for personal secrets", async () => {
|
|
67
|
+
const program = buildProgram();
|
|
68
|
+
|
|
69
|
+
await program.parseAsync([
|
|
70
|
+
"node",
|
|
71
|
+
"hq",
|
|
72
|
+
"secrets",
|
|
73
|
+
"--personal",
|
|
74
|
+
"generate-link",
|
|
75
|
+
"MY_KEY",
|
|
76
|
+
"--expires",
|
|
77
|
+
"30m",
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
expect(getEntityUid).toHaveBeenCalledWith("test-token", {
|
|
81
|
+
personal: true,
|
|
82
|
+
companySlug: undefined,
|
|
83
|
+
});
|
|
84
|
+
expect(vaultApiFetch).toHaveBeenCalledWith({
|
|
85
|
+
token: "test-token",
|
|
86
|
+
path: "/secrets/prs_alice/name/MY_KEY",
|
|
87
|
+
method: "POST",
|
|
88
|
+
body: { expiresInMs: 30 * 60 * 1000 },
|
|
89
|
+
query: { action: "generate-token" },
|
|
90
|
+
});
|
|
91
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
92
|
+
expect.stringContaining("Secret input link generated"),
|
|
93
|
+
);
|
|
94
|
+
expect(errSpy).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
});
|
package/src/commands/secrets.ts
CHANGED
|
@@ -615,8 +615,6 @@ export function registerSecretsCommand(program: Command): void {
|
|
|
615
615
|
.option("--expires <duration>", "Token expiry duration (e.g. 24h, 2d, 30m)", "24h")
|
|
616
616
|
.action(async (name: string, opts: { expires: string }) => {
|
|
617
617
|
try {
|
|
618
|
-
rejectIfPersonal(secrets.opts(), "generate-link");
|
|
619
|
-
|
|
620
618
|
if (!SECRET_NAME_PATTERN.test(name)) {
|
|
621
619
|
console.error(chalk.red(`Invalid secret name '${name}': must match ^[A-Z][A-Z0-9_]*(/[A-Z][A-Z0-9_]+)*$ (e.g. MY_API_KEY or DEV/MY_KEY)`));
|
|
622
620
|
process.exit(1);
|