Skip to content

Commit abed70c

Browse files
Merge fa3f5e8 into 6f35f96
2 parents 6f35f96 + fa3f5e8 commit abed70c

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/commands/configure.gateway.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { RuntimeEnv } from "../runtime.js";
55

66
const mocks = vi.hoisted(() => ({
77
text: vi.fn(),
8+
password: vi.fn(),
89
select: vi.fn(),
910
confirm: vi.fn(),
1011
resolveGatewayPort: vi.fn(),
@@ -24,6 +25,7 @@ vi.mock("../config/config.js", async (importActual) => {
2425

2526
vi.mock("./configure.shared.js", () => ({
2627
text: mocks.text,
28+
password: mocks.password,
2729
select: mocks.select,
2830
confirm: mocks.confirm,
2931
}));
@@ -77,6 +79,7 @@ async function runGatewayPrompt(params: {
7779
return input.initialValue ?? input.options[0]?.value;
7880
});
7981
mocks.text.mockImplementation(async () => params.textQueue.shift());
82+
mocks.password.mockImplementation(async () => params.textQueue.shift());
8083
mocks.randomToken.mockReturnValue(params.randomToken ?? "generated-token");
8184
mocks.confirm.mockResolvedValue(params.confirmResult ?? true);
8285
mocks.buildGatewayAuthConfig.mockImplementation((input) =>

src/commands/configure.gateway.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { findTailscaleBinary } from "../infra/tailscale.js";
2121
import type { RuntimeEnv } from "../runtime.js";
2222
import { resolveDefaultSecretProviderAlias } from "../secrets/ref-contract.js";
2323
import { buildGatewayAuthConfig } from "./configure.gateway-auth.js";
24-
import { confirm, select, text } from "./configure.shared.js";
24+
import { confirm, password, select, text } from "./configure.shared.js";
2525
import {
2626
guardCancel,
2727
normalizeGatewayTokenInput,
@@ -245,14 +245,14 @@ export async function promptGatewayConfig(
245245
}
246246

247247
if (authMode === "password") {
248-
const password = guardCancel(
249-
await text({
248+
const passwordInput = guardCancel(
249+
await password({
250250
message: "Gateway password",
251251
validate: validateGatewayPasswordInput,
252252
}),
253253
runtime,
254254
);
255-
gatewayPassword = normalizeOptionalString(password) ?? "";
255+
gatewayPassword = normalizeOptionalString(passwordInput) ?? "";
256256
}
257257

258258
if (authMode === "trusted-proxy") {

src/commands/configure.shared.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
confirm as clackConfirm,
44
intro as clackIntro,
55
outro as clackOutro,
6+
password as clackPassword,
67
select as clackSelect,
78
text as clackText,
89
} from "@clack/prompts";
@@ -89,6 +90,12 @@ export const text = (params: Parameters<typeof clackText>[0]) =>
8990
...params,
9091
message: stylePromptMessage(params.message),
9192
});
93+
/** Styled password prompt wrapper. Echoes bullets so secrets never appear in cleartext. */
94+
export const password = (params: Parameters<typeof clackPassword>[0]) =>
95+
clackPassword({
96+
...params,
97+
message: stylePromptMessage(params.message),
98+
});
9299
/** Styled confirm prompt wrapper. */
93100
export const confirm = (params: Parameters<typeof clackConfirm>[0]) =>
94101
clackConfirm({

src/commands/configure.wizard.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const mocks = vi.hoisted(() => {
1010
clackSelect: vi.fn(),
1111
clackText: vi.fn(),
1212
clackConfirm: vi.fn(),
13+
clackPassword: vi.fn(),
1314
resolveSearchProviderOptions: vi.fn(),
1415
resolvePluginContributionOwners: vi.fn(),
1516
setupSearch: vi.fn(),
@@ -46,6 +47,7 @@ vi.mock("@clack/prompts", () => ({
4647
select: mocks.clackSelect,
4748
text: mocks.clackText,
4849
confirm: mocks.clackConfirm,
50+
password: mocks.clackPassword,
4951
}));
5052

5153
vi.mock("../config/config.js", () => ({

0 commit comments

Comments
 (0)