mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
* feat(auth): authenticate daemon clients through hello Give local CLI and desktop clients a per-run credential while remote clients send the host password inside the protocol. Keep relay passwordless admission for this mobile release so existing saved hosts keep working until the follow-up enforcement release. Move password recovery for saved hosts into host settings and keep pairing credentials in the add flow. Include isolated web QA evidence for both flows. * fix(auth): preserve Hub bootstrap and local credential expectations Hub-owned sockets already carry admission; keep their hello handling synchronous through session bootstrap while resolving credentials asynchronously for ordinary sockets. Keep the resolver out of lightweight configuration imports. Update CLI expectations for same-home credentials, let a rejected connection yield to another usable connection, and clear pairing secrets when add-flow targets change. * fix(pairing): retain passwords across edits to the same target Track the last valid pairing host while a URI is edited. This preserves an entered password for whitespace and partial edits but clears it when a different host becomes the target. * test(auth): align local credential checks across platforms Expect the CLI to authenticate through the credential in its selected home, and verify POSIX file modes only where Node exposes them. * feat(app): move host password into a settings row with a modal The host page rendered an always-visible password form above Name on every host. Replace it with a Password row under a Security section below Appearance; tapping it opens a modal with Save and, when a password is saved, Clear. The connection-error callout keeps its guidance and gains a Set password button that opens the same modal. Drop the unused pairing.hostPassword body/reopen/saveError strings. * chore: remove committed QA screenshots QA evidence stays out of the repository; the PR body describes it in words. * feat(app): keep the host password out of the host page The saved password is connection data, entered only when a host is added. A Password setting on the host page reads as the daemon's own password, so the row, modal, and callout button are gone. A rejected host shows the daemon's reason with guidance to remove the host and add it again with the password. useHostMutations no longer exposes setHostPassword; relay imports still set it inside the runtime. * feat(app): show host connection errors in an error alert HostConnectionError renders the existing Alert with the connection error as its title. Auth rejections add the re-add guidance as the description; other errors show the title only. The Overview and Connections pages share it. * style(app): soften alert borders to half-opacity accent * feat(app): size alerts on the button scale Alert takes a size prop (xs/sm/md/lg, default md) whose geometry lives next to the button's in control-geometry: one font size for title and description, the button icon size centered on the first text line, button padding and radius, and a one-line alert as tall as the button of the same size. Consumers pick sm among settings rows, cards, panels, and modals, and md when the alert is the whole page or sheet state. * style(app): roomier, rounder alerts with a tight title block Alert sm padding returns to the original 12/16 and every size is at least borderRadius.xl. Title and description sit a small gap apart with no line height override. The icon slot carries a zero-width text strut in the alert's font so the icon centers on the first line for titled, title-only, and description-only alerts. * refactor(app): align the alert icon with a centered lead row Drop the zero-width strut. The icon and the alert's first text (title, else description) share one row centered on each other; the description and actions sit below, indented by the icon slot width plus gap so they start at the lead text's left edge. * refactor(app): drop the unused Alert icon override
138 lines
4.4 KiB
TypeScript
138 lines
4.4 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
|
|
import assert from "node:assert";
|
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import type { Command } from "commander";
|
|
import { isBearerTokenValidAsync } from "@getpaseo/server/auth";
|
|
import { runLocalPaseo } from "./helpers/local-cli.ts";
|
|
import {
|
|
runSetPasswordCommand,
|
|
setDaemonPasswordInConfig,
|
|
type PromptPassword,
|
|
} from "../src/commands/daemon/set-password.ts";
|
|
|
|
console.log("=== Daemon Set Password Command ===\n");
|
|
|
|
const root = await mkdtemp(join(tmpdir(), "paseo-set-password-"));
|
|
const paseoHome = join(root, ".paseo");
|
|
|
|
function promptSequence(values: string[]): PromptPassword {
|
|
return async () => {
|
|
const value = values.shift();
|
|
if (value === undefined) {
|
|
throw new Error("prompt called too many times");
|
|
}
|
|
return value;
|
|
};
|
|
}
|
|
|
|
try {
|
|
{
|
|
console.log("Test 1: setDaemonPasswordInConfig writes hash and preserves config fields");
|
|
await mkdir(paseoHome, { recursive: true });
|
|
await writeFile(
|
|
join(paseoHome, "config.json"),
|
|
`${JSON.stringify(
|
|
{
|
|
version: 1,
|
|
daemon: {
|
|
listen: "127.0.0.1:9999",
|
|
relay: { enabled: false },
|
|
},
|
|
app: { baseUrl: "https://app.paseo.sh" },
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
|
|
const result = await setDaemonPasswordInConfig("shared-secret", { home: paseoHome });
|
|
const config = JSON.parse(await readFile(join(paseoHome, "config.json"), "utf-8"));
|
|
|
|
assert.strictEqual(result.configPath, join(paseoHome, "config.json"));
|
|
assert.strictEqual(
|
|
result.restartCommand,
|
|
`paseo daemon restart --home ${JSON.stringify(paseoHome)}`,
|
|
);
|
|
assert.strictEqual(config.daemon.listen, "127.0.0.1:9999");
|
|
assert.strictEqual(config.daemon.relay.enabled, false);
|
|
assert.notStrictEqual(config.daemon.auth.password, "shared-secret");
|
|
assert.match(config.daemon.auth.password, /^\$2[aby]\$12\$/);
|
|
assert.strictEqual(
|
|
await isBearerTokenValidAsync({
|
|
password: config.daemon.auth.password,
|
|
token: "shared-secret",
|
|
}),
|
|
true,
|
|
);
|
|
console.log("✓ set-password writes bcrypt hash without clobbering config\n");
|
|
}
|
|
|
|
{
|
|
console.log("Test 2: command prompts twice and accepts matching confirmation");
|
|
const result = await runSetPasswordCommand(
|
|
{
|
|
home: paseoHome,
|
|
daemonTarget: { kind: "instance", home: paseoHome },
|
|
promptPassword: promptSequence(["new-secret", "new-secret"]),
|
|
},
|
|
{} as Command,
|
|
);
|
|
const config = JSON.parse(await readFile(join(paseoHome, "config.json"), "utf-8"));
|
|
|
|
assert.strictEqual(result.data.action, "password_set");
|
|
assert.strictEqual(
|
|
await isBearerTokenValidAsync({ password: config.daemon.auth.password, token: "new-secret" }),
|
|
true,
|
|
);
|
|
console.log("✓ command accepts matching confirmation\n");
|
|
}
|
|
|
|
{
|
|
console.log("Test 3: command refuses mismatched confirmation");
|
|
await assert.rejects(
|
|
runSetPasswordCommand(
|
|
{
|
|
home: paseoHome,
|
|
daemonTarget: { kind: "instance", home: paseoHome },
|
|
promptPassword: promptSequence(["first-secret", "second-secret"]),
|
|
},
|
|
{} as Command,
|
|
),
|
|
(error: unknown) =>
|
|
typeof error === "object" &&
|
|
error !== null &&
|
|
"code" in error &&
|
|
error.code === "PASSWORD_MISMATCH",
|
|
);
|
|
console.log("✓ command refuses password mismatch\n");
|
|
}
|
|
|
|
{
|
|
console.log("Test 4: piped stdin fails with a message instead of exiting silently");
|
|
const pipedHome = join(root, "piped");
|
|
await mkdir(pipedHome, { recursive: true });
|
|
const run = runLocalPaseo(["daemon", "set-password", "--home", pipedHome, "--json"]);
|
|
run.stdin.end("x\nx\n");
|
|
const result = await run;
|
|
|
|
assert.strictEqual(result.exitCode, 1, result.stderr);
|
|
const error = JSON.parse(result.stderr).error as {
|
|
code: string;
|
|
message: string;
|
|
details: string;
|
|
};
|
|
assert.strictEqual(error.code, "PASSWORD_TTY_REQUIRED");
|
|
assert.match(error.message, /needs a terminal/);
|
|
assert.match(error.details, /PASEO_PASSWORD/);
|
|
await assert.rejects(readFile(join(pipedHome, "config.json"), "utf-8"));
|
|
console.log("✓ piped stdin reports that a terminal is required\n");
|
|
}
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
|
|
console.log("=== Daemon Set Password Command Tests Passed ===");
|