@p697/clawket 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +40 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1827,7 +1827,7 @@ var BridgeRuntime = class {
1827
1827
  return;
1828
1828
  this.stopped = false;
1829
1829
  this.updateSnapshot({ running: true, gatewayUrl: this.options.gatewayUrl });
1830
- this.log(`runtime starting gatewayId=${this.options.config.gatewayId} gatewayUrl=${this.options.gatewayUrl}`);
1830
+ this.log(`runtime starting gatewayUrl=${redactGatewayWsUrl(this.options.gatewayUrl)}`);
1831
1831
  void this.connectRelay();
1832
1832
  }
1833
1833
  async stop() {
@@ -2030,7 +2030,7 @@ var BridgeRuntime = class {
2030
2030
  }
2031
2031
  try {
2032
2032
  const issued = await issueOpenClawBootstrapToken(parsed.value);
2033
- this.log(`relay bootstrap token issued requestId=${requestId} deviceId=${parsed.value.deviceId} targetClientId=${replyTargetClientId || "<none>"} expiresAtMs=${issued.expiresAtMs}`);
2033
+ this.log(`relay bootstrap token issued requestId=${requestId} targetClientId=${replyTargetClientId || "<none>"} expiresAtMs=${issued.expiresAtMs}`);
2034
2034
  this.sendRelayControl({
2035
2035
  event: "bootstrap.issued",
2036
2036
  requestId,
@@ -2087,7 +2087,7 @@ var BridgeRuntime = class {
2087
2087
  if (this.stopped || !this.isRelayOpen() || this.gatewayConnecting || this.isGatewayOpen() || this.gatewayCloseBoundaryPending)
2088
2088
  return;
2089
2089
  this.gatewayConnecting = true;
2090
- this.log(`gateway connect start url=${this.options.gatewayUrl}`);
2090
+ this.log(`gateway connect start url=${redactGatewayWsUrl(this.options.gatewayUrl)}`);
2091
2091
  const gateway = this.createWebSocket(this.options.gatewayUrl);
2092
2092
  this.gatewaySocket = gateway;
2093
2093
  gateway.once("open", () => {
@@ -2279,13 +2279,13 @@ var BridgeRuntime = class {
2279
2279
  return;
2280
2280
  this.inFlightConnectHandshakes.delete(response.id);
2281
2281
  const detail = response.ok ? "ok=true" : `ok=false errorCode=${response.errorCode ?? "<none>"} errorMessage=${response.errorMessage ?? "<none>"}`;
2282
- this.log(`gateway connect response reqId=${response.id} method=${pending.method} elapsedMs=${Date.now() - pending.startedAtMs} ${detail}`);
2282
+ this.log(`gateway connect response reqId=<redacted> method=${pending.method} elapsedMs=${Date.now() - pending.startedAtMs} ${detail}`);
2283
2283
  }
2284
2284
  clearInFlightConnectHandshakes(reason) {
2285
2285
  if (this.inFlightConnectHandshakes.size === 0)
2286
2286
  return;
2287
2287
  for (const [requestId, pending] of this.inFlightConnectHandshakes.entries()) {
2288
- this.log(`gateway connect response missing reqId=${requestId} method=${pending.method} elapsedMs=${Date.now() - pending.startedAtMs} reason=${reason}`);
2288
+ this.log(`gateway connect response missing reqId=<redacted> method=${pending.method} elapsedMs=${Date.now() - pending.startedAtMs} reason=${reason}`);
2289
2289
  }
2290
2290
  this.inFlightConnectHandshakes.clear();
2291
2291
  }
@@ -2343,7 +2343,7 @@ var BridgeRuntime = class {
2343
2343
  if (pending.slowWarningLogged || elapsedMs < warnDelayMs)
2344
2344
  continue;
2345
2345
  pending.slowWarningLogged = true;
2346
- this.log(`gateway connect still pending reqId=${requestId} method=${pending.method} elapsedMs=${elapsedMs}`);
2346
+ this.log(`gateway connect still pending reqId=<redacted> method=${pending.method} elapsedMs=${elapsedMs}`);
2347
2347
  }
2348
2348
  }
2349
2349
  pushPendingGatewayMessage(message) {
@@ -2401,7 +2401,7 @@ var BridgeRuntime = class {
2401
2401
  this.options.onStatus?.(this.getSnapshot());
2402
2402
  }
2403
2403
  log(line) {
2404
- this.options.onLog?.(line);
2404
+ this.options.onLog?.(sanitizeRuntimeLogLine(line));
2405
2405
  }
2406
2406
  isRelayOpen() {
2407
2407
  return this.relaySocket?.readyState === WebSocket.OPEN;
@@ -2523,7 +2523,7 @@ function patchConnectRequestGatewayAuth(text, openClawInfo) {
2523
2523
  function formatConnectHandshakeMetaForLog(meta) {
2524
2524
  if (!meta)
2525
2525
  return "";
2526
- return ` method=${meta.method} reqId=${meta.id ?? "<none>"} noncePresent=${meta.noncePresent} nonceLength=${meta.nonceLength ?? 0} authFields=${meta.authFields.length > 0 ? meta.authFields.join(",") : "<none>"}`;
2526
+ return ` method=${meta.method} reqId=${meta.id ? "<redacted>" : "<none>"} noncePresent=${meta.noncePresent} nonceLength=${meta.nonceLength ?? 0} authFields=${meta.authFields.length > 0 ? meta.authFields.join(",") : "<none>"}`;
2527
2527
  }
2528
2528
  function parseBootstrapRequestPayload(payload) {
2529
2529
  if (!payload) {
@@ -2600,9 +2600,7 @@ function redactRelayWsUrl(rawUrl) {
2600
2600
  if (parsed.password) {
2601
2601
  parsed.password = "<redacted>";
2602
2602
  }
2603
- if (parsed.searchParams.has("token")) {
2604
- parsed.searchParams.set("token", "<redacted>");
2605
- }
2603
+ stripSensitiveSearchParams(parsed);
2606
2604
  return parsed.toString();
2607
2605
  }
2608
2606
  function redactAuthorizationHeader(value) {
@@ -2611,6 +2609,27 @@ function redactAuthorizationHeader(value) {
2611
2609
  return "<none>";
2612
2610
  return /^Bearer\s+/i.test(trimmed) ? "Bearer <redacted>" : "<redacted>";
2613
2611
  }
2612
+ function sanitizeRuntimeLogLine(line) {
2613
+ return line.replace(/\b(gatewayId|instanceId|clientId|sourceClientId|targetClientId|deviceId|requestId|reqId|traceId)=([^\s]+)/g, "$1=<redacted>").replace(/\b(gw_[a-z0-9]+|grs_[A-Za-z0-9_-]+|gct_[A-Za-z0-9_-]+)\b/g, "<redacted>");
2614
+ }
2615
+ function redactGatewayWsUrl(rawUrl) {
2616
+ const parsed = new URL(rawUrl);
2617
+ if (parsed.username) {
2618
+ parsed.username = "<redacted>";
2619
+ }
2620
+ if (parsed.password) {
2621
+ parsed.password = "<redacted>";
2622
+ }
2623
+ parsed.hostname = "<redacted-host>";
2624
+ stripSensitiveSearchParams(parsed);
2625
+ return parsed.toString();
2626
+ }
2627
+ function stripSensitiveSearchParams(parsed) {
2628
+ const sensitiveKeys = ["token", "password", "gatewayId", "clientId", "requestId", "reqId", "traceId"];
2629
+ for (const key of sensitiveKeys) {
2630
+ parsed.searchParams.delete(key);
2631
+ }
2632
+ }
2614
2633
  function normalizeText(data) {
2615
2634
  if (typeof data === "string")
2616
2635
  return data;
@@ -3261,7 +3280,7 @@ async function main() {
3261
3280
  console.log("Starting bridge runtime. Press Ctrl+C to stop.");
3262
3281
  console.log("");
3263
3282
  } else {
3264
- emitRuntimeLine(`Starting Clawket service runtime for gateway ${config.gatewayId}`);
3283
+ emitRuntimeLine("Starting Clawket service runtime.");
3265
3284
  }
3266
3285
  if (isServiceMode) {
3267
3286
  writeServiceState();
@@ -3270,17 +3289,21 @@ async function main() {
3270
3289
  config,
3271
3290
  gatewayUrl,
3272
3291
  onLog: (line) => {
3273
- emitRuntimeLine(`[clawket] ${line}`);
3292
+ emitRuntimeLine(sanitizeRuntimeLogLine(`[clawket] ${line}`));
3274
3293
  },
3275
3294
  onStatus: (snapshot) => {
3276
3295
  if (snapshot.lastError) {
3277
- emitRuntimeLine(`[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount} error=${snapshot.lastError}`);
3296
+ emitRuntimeLine(sanitizeRuntimeLogLine(
3297
+ `[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount} error=${snapshot.lastError}`
3298
+ ));
3278
3299
  return;
3279
3300
  }
3280
- emitRuntimeLine(`[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount}`);
3301
+ emitRuntimeLine(sanitizeRuntimeLogLine(
3302
+ `[status] relay=${snapshot.relayConnected ? "up" : "down"} gateway=${snapshot.gatewayConnected ? "up" : "down"} clients=${snapshot.clientCount}`
3303
+ ));
3281
3304
  },
3282
- onPendingPairRequest: (request) => {
3283
- emitRuntimeLine(`[pair-request] requestId=${request.requestId} deviceId=${request.deviceId || "<unknown>"} name=${request.displayName ?? "<unknown>"}`);
3305
+ onPendingPairRequest: () => {
3306
+ emitRuntimeLine("[pair-request] pending");
3284
3307
  }
3285
3308
  });
3286
3309
  runtime.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p697/clawket",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Clawket CLI for pairing and running the Relay bridge runtime",