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.
- package/.claude/proven-config.json +1 -1
- package/node_modules/@claude-flow/mcp/dist/sampling.js +1 -1
- package/node_modules/@claude-flow/mcp/dist/sampling.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/server.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/server.js +2 -0
- package/node_modules/@claude-flow/mcp/dist/server.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts +17 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.js +43 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts +2 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/http.js +15 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts +6 -0
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js +30 -1
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/types.d.ts +2 -0
- package/node_modules/@claude-flow/mcp/dist/types.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/types.js.map +1 -1
- package/node_modules/@claude-flow/mcp/package.json +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/README.md +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +0 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +11 -2
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +8 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +11 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +4 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +16 -3
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +17 -4
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +3 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +1 -1
- package/package.json +4 -4
- package/v3/@claude-flow/cli/dist/src/commands/config.js +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/mcp.js +12 -1
- package/v3/@claude-flow/cli/dist/src/mcp-server.d.ts +9 -0
- package/v3/@claude-flow/cli/dist/src/mcp-server.js +24 -6
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-federation.js +8 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-tools.js +10 -2
- package/v3/@claude-flow/cli/dist/src/services/headless-worker-executor.js +1 -1
- package/v3/@claude-flow/cli/dist/src/services/worker-daemon.d.ts +3 -4
- package/v3/@claude-flow/cli/dist/src/services/worker-daemon.js +28 -7
- package/v3/@claude-flow/cli/package.json +4 -4
- package/v3/@claude-flow/shared/dist/mcp/transport/guard.d.ts +17 -0
- package/v3/@claude-flow/shared/dist/mcp/transport/guard.js +43 -0
- package/v3/@claude-flow/shared/dist/mcp/transport/http.d.ts +2 -0
- package/v3/@claude-flow/shared/dist/mcp/transport/http.js +15 -1
- package/v3/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +6 -0
- package/v3/@claude-flow/shared/dist/mcp/transport/websocket.js +24 -1
- 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
|
-
|
|
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++;
|