Validate runtime auth token type at startup

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 03:27:43 +00:00
1 parent 665b435ca4
commit e0b1b7a44d
2 files changed
+13

No files matched your search

+10
View File
@@ -317,6 +317,16 @@ describe("runtimeApiServer", () => {
).rejects.toThrow("Invalid runtime auth token");
});
it("rejects non-string auth token configuration", async () => {
await expect(
startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
authToken: 123 as unknown as string,
}),
).rejects.toThrow("Invalid runtime auth token");
});
it("accepts websocket connections without token when auth is disabled", async () => {
const server = await startRuntimeApiServer({
port: 0,
+3
View File
@@ -344,6 +344,9 @@ export async function startRuntimeApiServer(
throw new Error("Invalid runtime port: expected integer between 0 and 65535.");
}
const launchCwd = resolveExistingDirectory(options.launchCwd, "Invalid launchCwd");
if (options.authToken !== undefined && typeof options.authToken !== "string") {
throw new Error("Invalid runtime auth token: expected non-empty string.");
}
const authToken = options.authToken?.trim();
if (options.authToken !== undefined && !authToken) {
throw new Error("Invalid runtime auth token: expected non-empty string.");