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
150 lines
5.8 KiB
TypeScript
150 lines
5.8 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
|
|
import assert from "node:assert";
|
|
import { mkdtemp, mkdir, writeFile, readFile, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { runLocalPaseo } from "./helpers/local-cli.ts";
|
|
import { startTestDaemon } from "./helpers/test-daemon.ts";
|
|
|
|
console.log("=== Daemon Status Auth ===\n");
|
|
|
|
const daemon = await startTestDaemon({
|
|
env: { PASEO_PASSWORD: "shared-secret" },
|
|
});
|
|
|
|
try {
|
|
{
|
|
console.log("Test 1: local status uses the daemon's local credential");
|
|
const result = await runLocalPaseo(["daemon", "status", "--json"], {
|
|
PASEO_HOME: daemon.paseoHome,
|
|
PASEO_HOST: "",
|
|
PASEO_PASSWORD: "",
|
|
});
|
|
|
|
assert.strictEqual(result.exitCode, 0, "status should still succeed");
|
|
const status = JSON.parse(result.stdout);
|
|
|
|
assert.strictEqual(status.localDaemon, "running");
|
|
assert.strictEqual(status.connectedDaemon, "reachable");
|
|
assert(!("runningAgents" in status), "status should not fetch agent counts");
|
|
assert(!("idleAgents" in status), "status should not fetch agent counts");
|
|
assert.doesNotMatch(status.note ?? "", /Password required|not reachable/i);
|
|
console.log("✓ missing password uses local credential\n");
|
|
}
|
|
|
|
{
|
|
console.log("Test 2: status reports rejected supplied password separately");
|
|
const result = await runLocalPaseo(["daemon", "status", "--json"], {
|
|
PASEO_HOME: daemon.paseoHome,
|
|
PASEO_HOST: "",
|
|
PASEO_PASSWORD: "wrong-secret",
|
|
});
|
|
|
|
assert.strictEqual(result.exitCode, 0, "status should still succeed");
|
|
const status = JSON.parse(result.stdout);
|
|
|
|
assert.strictEqual(status.localDaemon, "running");
|
|
assert.strictEqual(status.connectedDaemon, "auth_failed");
|
|
assert.match(status.note, /Incorrect password/i);
|
|
assert.doesNotMatch(status.note, /not reachable/i);
|
|
console.log("✓ wrong password reports auth_failed\n");
|
|
}
|
|
|
|
{
|
|
console.log("Test 3: status reaches the same daemon when password is supplied");
|
|
const result = await runLocalPaseo(["daemon", "status", "--json"], {
|
|
PASEO_HOME: daemon.paseoHome,
|
|
PASEO_HOST: "",
|
|
PASEO_PASSWORD: "shared-secret",
|
|
});
|
|
|
|
assert.strictEqual(result.exitCode, 0, "status should succeed with password");
|
|
const status = JSON.parse(result.stdout);
|
|
|
|
assert.strictEqual(status.localDaemon, "running");
|
|
assert.strictEqual(status.connectedDaemon, "reachable");
|
|
assert(!("runningAgents" in status), "status should not fetch agent counts");
|
|
assert(!("idleAgents" in status), "status should not fetch agent counts");
|
|
console.log("✓ password-authenticated status remains reachable\n");
|
|
}
|
|
} finally {
|
|
await daemon.stop();
|
|
}
|
|
|
|
// POSIX executable probing executes --version; Windows resolves executables differently.
|
|
if (process.platform !== "win32") {
|
|
const root = await mkdtemp(join(tmpdir(), "paseo status slow provider "));
|
|
const home = join(root, "daemon");
|
|
const workDir = join(root, "work");
|
|
const provider = join(root, "slow-provider");
|
|
const marker = join(root, "availability.log");
|
|
let slowDaemon: Awaited<ReturnType<typeof startTestDaemon>> | undefined;
|
|
try {
|
|
await mkdir(home);
|
|
await mkdir(workDir);
|
|
await writeFile(
|
|
provider,
|
|
`#!${process.execPath}
|
|
import('node:fs').then(({appendFileSync}) => {
|
|
appendFileSync(${JSON.stringify(marker)}, JSON.stringify(process.argv.slice(2)) + "\\n");
|
|
setTimeout(() => console.log('provider 1.0.0'), 1800);
|
|
});
|
|
`,
|
|
{ mode: 0o700 },
|
|
);
|
|
await writeFile(
|
|
join(home, "config.json"),
|
|
JSON.stringify({
|
|
version: 1,
|
|
agents: { providers: { claude: { command: { mode: "replace", argv: [provider] } } } },
|
|
}),
|
|
);
|
|
slowDaemon = await startTestDaemon({
|
|
paseoHome: home,
|
|
workDir,
|
|
env: { PASEO_PASSWORD: "shared-secret" },
|
|
});
|
|
console.log("Test 4: local status separates authenticated reachability from slow details");
|
|
const local = await runLocalPaseo(["daemon", "status", "--home", home, "--json"], {
|
|
PASEO_PASSWORD: "shared-secret",
|
|
});
|
|
assert.strictEqual(local.exitCode, 0, local.stderr);
|
|
const status = JSON.parse(local.stdout);
|
|
assert.strictEqual(status.localDaemon, "running");
|
|
assert.strictEqual(status.connectedDaemon, "reachable", JSON.stringify(status));
|
|
assert.strictEqual(typeof status.serverId, "string");
|
|
assert.match(status.note, /DAEMON_REQUEST_TIMEOUT/);
|
|
assert.match(status.note, /Status details unavailable/);
|
|
assert(!("workerPid" in status), "must not invent worker facts");
|
|
assert(!("providers" in status), "must not invent provider facts");
|
|
assert.match(
|
|
await readFile(marker, "utf8"),
|
|
/\["--version"\]/,
|
|
"the public provider executable was actually probed",
|
|
);
|
|
console.log("✓ local authenticated connection remains reachable when details time out\n");
|
|
|
|
console.log("Test 5: explicit endpoint status remains an error when details time out");
|
|
const remote = await runLocalPaseo(
|
|
["daemon", "status", "--host", `127.0.0.1:${slowDaemon.port}`, "--json"],
|
|
{ PASEO_PASSWORD: "shared-secret" },
|
|
);
|
|
assert.notStrictEqual(remote.exitCode, 0);
|
|
const { error } = JSON.parse(remote.stderr);
|
|
assert.strictEqual(error.code, "DAEMON_REQUEST_TIMEOUT");
|
|
assert.match(error.message, /Status details unavailable/);
|
|
assert.strictEqual(error.details.connectedDaemon, "reachable");
|
|
assert.strictEqual(error.details.serverId, status.serverId);
|
|
assert(!("home" in error.details), "endpoint observation must not invent local ownership");
|
|
assert(!("workerPid" in error.details));
|
|
assert(!("providers" in error.details));
|
|
console.log("✓ failed remote query retains its error and authenticated connection fact\n");
|
|
} finally {
|
|
await slowDaemon?.stop();
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
console.log("=== Daemon Status Auth Tests Passed ===");
|