fix: allow clawdbot-ios gateway client id
The iOS app currently identifies as clientId=clawdbot-ios when connecting in node mode. Add this ID to the allowed gateway client IDs so the handshake schema accepts it. Also fixes a TS strictness issue in auto-reply status formatting (parts filter) that caused > clawdbot@2026.1.20 build /Users/vignesh/clawd/clawdbot-upstream > tsc -p tsconfig.json && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts [copy-hook-metadata] Copied boot-md/HOOK.md [copy-hook-metadata] Copied command-logger/HOOK.md [copy-hook-metadata] Copied session-memory/HOOK.md [copy-hook-metadata] Copied soul-evil/HOOK.md [copy-hook-metadata] Done to fail.
This commit is contained in:
committed by
Peter Steinberger
parent
de0a488985
commit
31462f64d8
@@ -5,6 +5,7 @@ export const GATEWAY_CLIENT_IDS = {
|
|||||||
CLI: "cli",
|
CLI: "cli",
|
||||||
GATEWAY_CLIENT: "gateway-client",
|
GATEWAY_CLIENT: "gateway-client",
|
||||||
MACOS_APP: "clawdbot-macos",
|
MACOS_APP: "clawdbot-macos",
|
||||||
|
IOS_APP: "clawdbot-ios",
|
||||||
NODE_HOST: "node-host",
|
NODE_HOST: "node-host",
|
||||||
TEST: "test",
|
TEST: "test",
|
||||||
FINGERPRINT: "fingerprint",
|
FINGERPRINT: "fingerprint",
|
||||||
|
|||||||
65
src/gateway/server.ios-client-id.test.ts
Normal file
65
src/gateway/server.ios-client-id.test.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { test } from "vitest";
|
||||||
|
import WebSocket from "ws";
|
||||||
|
|
||||||
|
import { PROTOCOL_VERSION } from "./protocol/index.js";
|
||||||
|
import { getFreePort, onceMessage, startGatewayServer } from "./test-helpers.server.js";
|
||||||
|
|
||||||
|
function connectReq(
|
||||||
|
ws: WebSocket,
|
||||||
|
params: { token?: string; password?: string } = {},
|
||||||
|
): Promise<{ ok: boolean; error?: { message?: string } }> {
|
||||||
|
const id = `c-${Math.random().toString(16).slice(2)}`;
|
||||||
|
ws.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: "req",
|
||||||
|
id,
|
||||||
|
method: "connect",
|
||||||
|
params: {
|
||||||
|
minProtocol: PROTOCOL_VERSION,
|
||||||
|
maxProtocol: PROTOCOL_VERSION,
|
||||||
|
client: {
|
||||||
|
id: "clawdbot-ios",
|
||||||
|
version: "dev",
|
||||||
|
platform: "ios",
|
||||||
|
mode: "node",
|
||||||
|
},
|
||||||
|
auth: {
|
||||||
|
token: params.token,
|
||||||
|
password: params.password,
|
||||||
|
},
|
||||||
|
role: "node",
|
||||||
|
scopes: [],
|
||||||
|
caps: ["canvas"],
|
||||||
|
commands: ["system.notify"],
|
||||||
|
permissions: {},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return onceMessage(
|
||||||
|
ws,
|
||||||
|
(o) => (o as { type?: string }).type === "res" && (o as { id?: string }).id === id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
test("accepts clawdbot-ios 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);
|
||||||
|
// 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();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user