Skip to content

Commit 3dad5d2

Browse files
adolagoclaude
andcommitted
Port 3 upstream PRs for onboarding/daemon/CLI delta (Lane 12)
- Guard resolveUserPath against undefined input (anomalyco#10176): return process.cwd() when input is falsy in utils.ts, config/paths.ts, and daemon/paths.ts to prevent TypeError crashes from 60+ call sites - Bump minimum Node.js from 22.0.0 to 22.12.0 (anomalyco#5370): update MIN_NODE in runtime-guard.ts and error message to avoid confusing module-not-found errors on older 22.x versions - Remove query-parameter token acceptance (anomalyco#9436): drop ?token= fallback from extractHookToken() and deprecation warning from server-http.ts; remove token param from ensureTailscaleEndpoint(); tokens must now use Authorization: Bearer or X-Zee-Token header Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 7ba5677 commit 3dad5d2

12 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎packages/personas/zee/src/config/paths.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function resolveStateDir(
4747
}
4848

4949
function resolveUserPath(input: string): string {
50+
if (!input) return process.cwd();
5051
const trimmed = input.trim();
5152
if (!trimmed) return trimmed;
5253
if (trimmed.startsWith("~")) {

‎packages/personas/zee/src/daemon/paths.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function resolveHomeDir(env: Record<string, string | undefined>): string
1313
}
1414

1515
export function resolveUserPathWithHome(input: string, home?: string): string {
16+
if (!input) return process.cwd();
1617
const trimmed = input.trim();
1718
if (!trimmed) return trimmed;
1819
if (trimmed.startsWith("~")) {

‎packages/personas/zee/src/daemon/runtime-paths.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("resolvePreferredNodePath", () => {
2828
throw new Error("missing");
2929
});
3030

31-
const execFile = vi.fn().mockResolvedValue({ stdout: "22.1.0\n", stderr: "" });
31+
const execFile = vi.fn().mockResolvedValue({ stdout: "22.12.0\n", stderr: "" });
3232

3333
const result = await resolvePreferredNodePath({
3434
env: {},
@@ -86,7 +86,7 @@ describe("resolveSystemNodeInfo", () => {
8686
throw new Error("missing");
8787
});
8888

89-
const execFile = vi.fn().mockResolvedValue({ stdout: "22.0.0\n", stderr: "" });
89+
const execFile = vi.fn().mockResolvedValue({ stdout: "22.12.0\n", stderr: "" });
9090

9191
const result = await resolveSystemNodeInfo({
9292
env: {},
@@ -96,7 +96,7 @@ describe("resolveSystemNodeInfo", () => {
9696

9797
expect(result).toEqual({
9898
path: linuxNode,
99-
version: "22.0.0",
99+
version: "22.12.0",
100100
supported: true,
101101
});
102102
});

‎packages/personas/zee/src/gateway/hooks.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export function extractHookToken(req: IncomingMessage, url: URL): HookTokenResul
6161
? headerTokenValue.join(", ").trim()
6262
: "";
6363
if (headerToken) return { token: headerToken, fromQuery: false };
64-
const queryToken = url.searchParams.get("token");
65-
if (queryToken) return { token: queryToken.trim(), fromQuery: true };
6664
return { token: undefined, fromQuery: false };
6765
}
6866

‎packages/personas/zee/src/gateway/server-http.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,13 @@ export function createHooksRequestHandler(
7171
return false;
7272
}
7373

74-
const { token, fromQuery } = extractHookToken(req, url);
74+
const { token } = extractHookToken(req, url);
7575
if (!token || token !== hooksConfig.token) {
7676
res.statusCode = 401;
7777
res.setHeader("Content-Type", "text/plain; charset=utf-8");
7878
res.end("Unauthorized");
7979
return true;
8080
}
81-
if (fromQuery) {
82-
logHooks.warn(
83-
"Hook token provided via query parameter is deprecated for security reasons. " +
84-
"Tokens in URLs appear in logs, browser history, and referrer headers. " +
85-
"Use Authorization: Bearer <token> or X-Zee-Token header instead.",
86-
);
87-
}
88-
8981
if (req.method !== "POST") {
9082
res.statusCode = 405;
9183
res.setHeader("Allow", "POST");

‎packages/personas/zee/src/gateway/server.hooks.e2e.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,13 @@ describe("gateway server hooks", () => {
8383
expect(call?.job?.payload?.model).toBe("openai/gpt-4.1-mini");
8484
drainSystemEvents(resolveMainKey());
8585

86+
// Query-parameter tokens are no longer accepted; must use header auth.
8687
const resQuery = await fetch(`http://127.0.0.1:${port}/hooks/wake?token=hook-secret`, {
8788
method: "POST",
8889
headers: { "Content-Type": "application/json" },
8990
body: JSON.stringify({ text: "Query auth" }),
9091
});
91-
expect(resQuery.status).toBe(200);
92-
const queryEvents = await waitForSystemEvent();
93-
expect(queryEvents.some((e) => e.includes("Query auth"))).toBe(true);
94-
drainSystemEvents(resolveMainKey());
92+
expect(resQuery.status).toBe(401);
9593

9694
const resBadChannel = await fetch(`http://127.0.0.1:${port}/hooks/agent`, {
9795
method: "POST",

‎packages/personas/zee/src/hooks/gmail-ops.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
192192
path: tailscalePath,
193193
port: servePort,
194194
target: normalizedTailscaleTarget,
195-
token: pushToken,
196195
});
197196

198197
if (!pushEndpoint) {

‎packages/personas/zee/src/hooks/gmail-setup-utils.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ export async function ensureTailscaleEndpoint(params: {
215215
path: string;
216216
port?: number;
217217
target?: string;
218-
token?: string;
219218
}): Promise<string> {
220219
if (params.mode === "off") return "";
221220

@@ -259,7 +258,8 @@ export async function ensureTailscaleEndpoint(params: {
259258

260259
const baseUrl = `https://${dnsName}${pathArg}`;
261260
// Funnel/serve strips pathArg before proxying; keep it only in the public URL.
262-
return params.token ? `${baseUrl}?token=${params.token}` : baseUrl;
261+
// Token must be sent via Authorization header, not query parameter.
262+
return baseUrl;
263263
}
264264

265265
export async function resolveProjectIdFromGogCredentials(): Promise<string | null> {

‎packages/personas/zee/src/infra/runtime-guard.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ describe("runtime-guard", () => {
3131
it("validates runtime thresholds", () => {
3232
const nodeOk: RuntimeDetails = {
3333
kind: "node",
34-
version: "22.0.0",
34+
version: "22.12.0",
3535
execPath: "/usr/bin/node",
3636
pathEnv: "/usr/bin",
3737
};
3838
const nodeOld: RuntimeDetails = { ...nodeOk, version: "21.9.0" };
39+
const nodeBelowMinor: RuntimeDetails = { ...nodeOk, version: "22.11.0" };
3940
const unknown: RuntimeDetails = {
4041
kind: "unknown",
4142
version: null,
@@ -44,6 +45,7 @@ describe("runtime-guard", () => {
4445
};
4546
expect(runtimeSatisfies(nodeOk)).toBe(true);
4647
expect(runtimeSatisfies(nodeOld)).toBe(false);
48+
expect(runtimeSatisfies(nodeBelowMinor)).toBe(false);
4749
expect(runtimeSatisfies(unknown)).toBe(false);
4850
});
4951

@@ -74,7 +76,7 @@ describe("runtime-guard", () => {
7476
const details: RuntimeDetails = {
7577
...detectRuntime(),
7678
kind: "node",
77-
version: "22.0.0",
79+
version: "22.12.0",
7880
execPath: "/usr/bin/node",
7981
};
8082
expect(() => assertSupportedRuntime(runtime, details)).not.toThrow();

‎packages/personas/zee/src/infra/runtime-guard.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Semver = {
1010
patch: number;
1111
};
1212

13-
const MIN_NODE: Semver = { major: 22, minor: 0, patch: 0 };
13+
const MIN_NODE: Semver = { major: 22, minor: 12, patch: 0 };
1414

1515
export type RuntimeDetails = {
1616
kind: RuntimeKind;
@@ -75,7 +75,7 @@ export function assertSupportedRuntime(
7575

7676
runtime.error(
7777
[
78-
"zee requires Node >=22.0.0.",
78+
"zee requires Node >=22.12.0.",
7979
`Detected: ${runtimeLabel} (exec: ${execLabel}).`,
8080
`PATH searched: ${details.pathEnv}`,
8181
"Install Node: https://nodejs.org/en/download",

0 commit comments

Comments
 (0)