claude-flow 3.63.2 → 3.63.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 (62) hide show
  1. package/.claude/proven-config.json +1 -1
  2. package/node_modules/@claude-flow/mcp/dist/sampling.js +1 -1
  3. package/node_modules/@claude-flow/mcp/dist/sampling.js.map +1 -1
  4. package/node_modules/@claude-flow/mcp/dist/server.d.ts.map +1 -1
  5. package/node_modules/@claude-flow/mcp/dist/server.js +2 -0
  6. package/node_modules/@claude-flow/mcp/dist/server.js.map +1 -1
  7. package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts +17 -0
  8. package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts.map +1 -0
  9. package/node_modules/@claude-flow/mcp/dist/transport/guard.js +43 -0
  10. package/node_modules/@claude-flow/mcp/dist/transport/guard.js.map +1 -0
  11. package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts +2 -0
  12. package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts.map +1 -1
  13. package/node_modules/@claude-flow/mcp/dist/transport/http.js +15 -0
  14. package/node_modules/@claude-flow/mcp/dist/transport/http.js.map +1 -1
  15. package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts +6 -0
  16. package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts.map +1 -1
  17. package/node_modules/@claude-flow/mcp/dist/transport/websocket.js +30 -1
  18. package/node_modules/@claude-flow/mcp/dist/transport/websocket.js.map +1 -1
  19. package/node_modules/@claude-flow/mcp/dist/types.d.ts +2 -0
  20. package/node_modules/@claude-flow/mcp/dist/types.d.ts.map +1 -1
  21. package/node_modules/@claude-flow/mcp/dist/types.js.map +1 -1
  22. package/node_modules/@claude-flow/mcp/package.json +1 -1
  23. package/node_modules/@claude-flow/plugin-agent-federation/README.md +1 -1
  24. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +1 -1
  25. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -1
  26. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +0 -1
  27. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -1
  28. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +11 -2
  29. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -1
  30. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +8 -0
  31. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -1
  32. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +11 -1
  33. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -1
  34. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +4 -0
  35. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -1
  36. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +16 -3
  37. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -1
  38. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -1
  39. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +17 -4
  40. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -1
  41. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -1
  42. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +3 -1
  43. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -1
  44. package/node_modules/@claude-flow/plugin-agent-federation/package.json +1 -1
  45. package/package.json +4 -4
  46. package/v3/@claude-flow/cli/dist/src/commands/config.js +1 -1
  47. package/v3/@claude-flow/cli/dist/src/commands/mcp.js +12 -1
  48. package/v3/@claude-flow/cli/dist/src/mcp-server.d.ts +9 -0
  49. package/v3/@claude-flow/cli/dist/src/mcp-server.js +24 -6
  50. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-federation.js +8 -2
  51. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-tools.js +10 -2
  52. package/v3/@claude-flow/cli/dist/src/services/headless-worker-executor.js +1 -1
  53. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.d.ts +3 -4
  54. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.js +28 -7
  55. package/v3/@claude-flow/cli/package.json +4 -4
  56. package/v3/@claude-flow/shared/dist/mcp/transport/guard.d.ts +17 -0
  57. package/v3/@claude-flow/shared/dist/mcp/transport/guard.js +43 -0
  58. package/v3/@claude-flow/shared/dist/mcp/transport/http.d.ts +2 -0
  59. package/v3/@claude-flow/shared/dist/mcp/transport/http.js +15 -1
  60. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +6 -0
  61. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.js +24 -1
  62. package/v3/@claude-flow/shared/package.json +1 -1
@@ -26,6 +26,10 @@ export interface WebSocketTransportConfig {
26
26
  heartbeatTimeout?: number;
27
27
  maxMessageSize?: number;
28
28
  auth?: AuthConfig;
29
+ /** Accept a non-loopback bind with no token. */
30
+ allowUnauthenticated?: boolean;
31
+ /** Browser origins allowed to connect, by exact name. */
32
+ allowedOrigins?: string[];
29
33
  enableBinaryMode?: boolean;
30
34
  }
31
35
  /**
@@ -107,6 +111,8 @@ export declare class WebSocketTransport extends EventEmitter implements ITranspo
107
111
  /**
108
112
  * Handle incoming message
109
113
  */
114
+ /** Token from `Authorization: Bearer` or `?token=`, compared in constant time. */
115
+ private upgradeHasValidToken;
110
116
  private handleMessage;
111
117
  /**
112
118
  * Parse incoming message
@@ -14,6 +14,8 @@
14
14
  import { EventEmitter } from 'events';
15
15
  import { WebSocketServer, WebSocket } from 'ws';
16
16
  import { createServer } from 'http';
17
+ import { createHash, timingSafeEqual } from 'node:crypto';
18
+ import { assertSafeBind, refuseOpenRequest } from './guard.js';
17
19
  /**
18
20
  * WebSocket Transport Implementation
19
21
  */
@@ -51,6 +53,7 @@ export class WebSocketTransport extends EventEmitter {
51
53
  port: this.config.port,
52
54
  path: this.config.path || '/ws',
53
55
  });
56
+ assertSafeBind(this.config.host, this.config.auth?.enabled === true, this.config.allowUnauthenticated);
54
57
  // Create HTTP server for WebSocket upgrade
55
58
  this.server = createServer((req, res) => {
56
59
  // Simple HTTP response for non-WebSocket requests
@@ -63,6 +66,9 @@ export class WebSocketTransport extends EventEmitter {
63
66
  path: this.config.path || '/ws',
64
67
  maxPayload: this.config.maxMessageSize || 10 * 1024 * 1024,
65
68
  perMessageDeflate: true, // Enable compression
69
+ verifyClient: (info) => this.config.auth?.enabled === true
70
+ ? this.upgradeHasValidToken(info.req)
71
+ : refuseOpenRequest(info.req, this.config.host, this.config.allowedOrigins) === undefined,
66
72
  });
67
73
  this.setupWebSocketHandlers();
68
74
  this.startHeartbeat();
@@ -225,7 +231,8 @@ export class WebSocketTransport extends EventEmitter {
225
231
  lastActivity: new Date(),
226
232
  messageCount: 0,
227
233
  isAlive: true,
228
- isAuthenticated: !this.config.auth?.enabled,
234
+ // With a token configured the upgrade itself was authenticated (verifyClient).
235
+ isAuthenticated: true,
229
236
  };
230
237
  this.clients.set(clientId, client);
231
238
  this.totalConnections++;
@@ -264,6 +271,22 @@ export class WebSocketTransport extends EventEmitter {
264
271
  /**
265
272
  * Handle incoming message
266
273
  */
274
+ /** Token from `Authorization: Bearer` or `?token=`, compared in constant time. */
275
+ upgradeHasValidToken(req) {
276
+ const header = req.headers.authorization;
277
+ const fromHeader = typeof header === 'string' ? header.match(/^Bearer\s+(.+)$/i)?.[1] : undefined;
278
+ const fromQuery = new URL(req.url ?? '', 'http://localhost').searchParams.get('token') ?? undefined;
279
+ const given = fromHeader ?? fromQuery;
280
+ if (!given)
281
+ return false;
282
+ const digest = (v) => createHash('sha256').update(v, 'utf8').digest();
283
+ let ok = false;
284
+ for (const valid of this.config.auth?.tokens ?? []) {
285
+ if (timingSafeEqual(digest(given), digest(valid)))
286
+ ok = true;
287
+ }
288
+ return ok;
289
+ }
267
290
  async handleMessage(client, data) {
268
291
  client.lastActivity = new Date();
269
292
  client.messageCount++;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/shared",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "type": "module",
5
5
  "description": "Shared module - common types, events, utilities, core interfaces",
6
6
  "main": "dist/index.js",