clawmatrix 0.5.0 → 0.5.1
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/package.json +1 -1
- package/src/connection.ts +10 -0
- package/src/peer-manager.ts +7 -3
- package/src/sentinel.ts +1 -1
package/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -269,6 +269,16 @@ export class Connection extends EventEmitter<ConnectionEvents> {
|
|
|
269
269
|
private async onRawMessage(data: unknown) {
|
|
270
270
|
this.lastReceivedAt = Date.now();
|
|
271
271
|
|
|
272
|
+
// Normalize non-Buffer binary types to Buffer.
|
|
273
|
+
// Node.js 24+'s built-in WebSocket (undici) delivers binary frames as Blob
|
|
274
|
+
// (binaryType "blob") or ArrayBuffer (binaryType "arraybuffer").
|
|
275
|
+
// The ws package delivers Buffer (binaryType "nodebuffer").
|
|
276
|
+
if (data instanceof ArrayBuffer) {
|
|
277
|
+
data = Buffer.from(data);
|
|
278
|
+
} else if (typeof Blob !== "undefined" && data instanceof Blob) {
|
|
279
|
+
data = Buffer.from(await data.arrayBuffer());
|
|
280
|
+
}
|
|
281
|
+
|
|
272
282
|
let frame: AnyClusterFrame | undefined;
|
|
273
283
|
|
|
274
284
|
// Binary frame (Buffer) — decrypt directly without base64
|
package/src/peer-manager.ts
CHANGED
|
@@ -643,10 +643,14 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
|
|
|
643
643
|
const attempt = this.reconnectAttempts.get(channelKey) ?? 0;
|
|
644
644
|
debug("peer", `connectToChannel(${nodeId}): attempt=${attempt} url=${url}`);
|
|
645
645
|
|
|
646
|
-
// Use
|
|
647
|
-
|
|
646
|
+
// Use the `ws` package for outbound connections.
|
|
647
|
+
// Node.js 24+'s built-in WebSocket (undici) defaults binaryType to "blob",
|
|
648
|
+
// causing binary frames to arrive as Blob instead of Buffer — which
|
|
649
|
+
// onRawMessage cannot handle, silently dropping encrypted frames (including auth_ok).
|
|
650
|
+
// The `ws` package defaults to binaryType "nodebuffer", avoiding this issue.
|
|
651
|
+
let ws: InstanceType<typeof WsWebSocket>;
|
|
648
652
|
try {
|
|
649
|
-
ws = new
|
|
653
|
+
ws = new WsWebSocket(url, ["graphql-transport-ws"]);
|
|
650
654
|
} catch (err) {
|
|
651
655
|
debug("peer", `connectToChannel(${nodeId}): WebSocket constructor threw: ${err}`);
|
|
652
656
|
this.scheduleChannelReconnect(nodeId, url);
|
package/src/sentinel.ts
CHANGED
|
@@ -177,7 +177,7 @@ function buildCapabilities(): NodeCapabilities {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function connectToPeer(peer: { nodeId: string; url: string }) {
|
|
180
|
-
const ws = new
|
|
180
|
+
const ws = new WsWebSocket(peer.url, ["graphql-transport-ws"]);
|
|
181
181
|
const e2eeOpts: ConnectionE2eeOptions = {
|
|
182
182
|
e2ee: config.e2ee,
|
|
183
183
|
compression: config.compression,
|