Validate non-empty runtime websocket auth token

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-09 23:15:48 +00:00
1 parent e9cbb40c3d
commit ce6e47e35d
2 files changed
+14 -1

No files matched your search

+10
View File
@@ -106,6 +106,16 @@ afterEach(async () => {
});
describe("runtimeApiServer", () => {
it("rejects empty auth token configuration", async () => {
await expect(
startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
authToken: " ",
}),
).rejects.toThrow("Invalid runtime auth token");
});
it("responds to todos.list over websocket RPC", async () => {
const server = await startRuntimeApiServer({
port: 0,
+4 -1
View File
@@ -278,7 +278,10 @@ export async function startRuntimeApiServer(
options: RuntimeApiServerOptions,
): Promise<RuntimeApiServer> {
const launchCwd = path.resolve(options.launchCwd);
const authToken = options.authToken;
const authToken = options.authToken?.trim();
if (options.authToken !== undefined && !authToken) {
throw new Error("Invalid runtime auth token: expected non-empty string.");
}
const bootstrapSessionTimeoutMs =
options.bootstrapSessionTimeoutMs ?? BOOTSTRAP_SESSION_TIMEOUT_MS;
const providerManager = new ProviderManager();