fix: allow mobile node client ids (#1354) (thanks @vignesh07)

This commit is contained in:
Peter Steinberger
2026-01-21 04:47:09 +00:00
parent 31462f64d8
commit 34a126a6d7
4 changed files with 29 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ Docs: https://docs.clawd.bot
- CLI: keep `clawdbot logs` output resilient to broken pipes while preserving progress output. - CLI: keep `clawdbot logs` output resilient to broken pipes while preserving progress output.
- Model catalog: avoid caching import failures, log transient discovery errors, and keep partial results. (#1332) — thanks @dougvk. - Model catalog: avoid caching import failures, log transient discovery errors, and keep partial results. (#1332) — thanks @dougvk.
- Doctor: clarify plugin auto-enable hint text in the startup banner. - Doctor: clarify plugin auto-enable hint text in the startup banner.
- Gateway: allow mobile node client ids for iOS + Android handshake validation. (#1354) — thanks @vignesh07.
- Gateway: clarify unauthorized handshake responses with token/password mismatch guidance. - Gateway: clarify unauthorized handshake responses with token/password mismatch guidance.
- Gateway: clarify connect/validation errors for gateway params. (#1347) — thanks @vignesh07. - Gateway: clarify connect/validation errors for gateway params. (#1347) — thanks @vignesh07.
- Gateway: preserve restart wake routing + thread replies across restarts. (#1337) — thanks @John-Rood. - Gateway: preserve restart wake routing + thread replies across restarts. (#1337) — thanks @John-Rood.

View File

@@ -529,7 +529,7 @@ class NodeRuntime(context: Context) {
caps = buildCapabilities(), caps = buildCapabilities(),
commands = buildInvokeCommands(), commands = buildInvokeCommands(),
permissions = emptyMap(), permissions = emptyMap(),
client = buildClientInfo(clientId = "node-host", clientMode = "node"), client = buildClientInfo(clientId = "clawdbot-android", clientMode = "node"),
userAgent = buildUserAgent(), userAgent = buildUserAgent(),
) )
} }

View File

@@ -6,6 +6,7 @@ export const GATEWAY_CLIENT_IDS = {
GATEWAY_CLIENT: "gateway-client", GATEWAY_CLIENT: "gateway-client",
MACOS_APP: "clawdbot-macos", MACOS_APP: "clawdbot-macos",
IOS_APP: "clawdbot-ios", IOS_APP: "clawdbot-ios",
ANDROID_APP: "clawdbot-android",
NODE_HOST: "node-host", NODE_HOST: "node-host",
TEST: "test", TEST: "test",
FINGERPRINT: "fingerprint", FINGERPRINT: "fingerprint",

View File

@@ -6,7 +6,7 @@ import { getFreePort, onceMessage, startGatewayServer } from "./test-helpers.ser
function connectReq( function connectReq(
ws: WebSocket, ws: WebSocket,
params: { token?: string; password?: string } = {}, params: { clientId: string; platform: string; token?: string; password?: string },
): Promise<{ ok: boolean; error?: { message?: string } }> { ): Promise<{ ok: boolean; error?: { message?: string } }> {
const id = `c-${Math.random().toString(16).slice(2)}`; const id = `c-${Math.random().toString(16).slice(2)}`;
ws.send( ws.send(
@@ -18,9 +18,9 @@ function connectReq(
minProtocol: PROTOCOL_VERSION, minProtocol: PROTOCOL_VERSION,
maxProtocol: PROTOCOL_VERSION, maxProtocol: PROTOCOL_VERSION,
client: { client: {
id: "clawdbot-ios", id: params.clientId,
version: "dev", version: "dev",
platform: "ios", platform: params.platform,
mode: "node", mode: "node",
}, },
auth: { auth: {
@@ -48,7 +48,29 @@ test("accepts clawdbot-ios as a valid gateway client id", async () => {
const ws = new WebSocket(`ws://127.0.0.1:${port}`); const ws = new WebSocket(`ws://127.0.0.1:${port}`);
await new Promise<void>((resolve) => ws.once("open", resolve)); await new Promise<void>((resolve) => ws.once("open", resolve));
const res = await connectReq(ws); const res = await connectReq(ws, { clientId: "clawdbot-ios", platform: "ios" });
// We don't care if auth fails here; we only care that schema validation accepts the client id.
// A schema rejection would close the socket before sending a response.
if (!res.ok) {
// allow unauthorized error when gateway requires auth
// but reject schema validation errors
const message = String(res.error?.message ?? "");
if (message.includes("invalid connect params")) {
throw new Error(message);
}
}
ws.close();
await server.close();
});
test("accepts clawdbot-android as a valid gateway client id", async () => {
const port = await getFreePort();
const server = await startGatewayServer(port);
const ws = new WebSocket(`ws://127.0.0.1:${port}`);
await new Promise<void>((resolve) => ws.once("open", resolve));
const res = await connectReq(ws, { clientId: "clawdbot-android", platform: "android" });
// We don't care if auth fails here; we only care that schema validation accepts the client id. // We don't care if auth fails here; we only care that schema validation accepts the client id.
// A schema rejection would close the socket before sending a response. // A schema rejection would close the socket before sending a response.
if (!res.ok) { if (!res.ok) {