node-ws-over-trystero 0.0.0 → 0.1.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/COPYING.LESSER +165 -0
- package/LICENSE +674 -0
- package/README.md +85 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +105 -0
- package/dist/server.js.map +1 -0
- package/dist/socket.d.ts +162 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +278 -0
- package/dist/socket.js.map +1 -0
- package/package.json +24 -7
package/dist/socket.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `ws`-server-shaped socket over one trystero peer.
|
|
3
|
+
*
|
|
4
|
+
* This is the mirror of `Wsp2pSocket` in `websocket-over-trystero`: same pipe,
|
|
5
|
+
* opposite role. It exists so a Node server built on `ws` — Colyseus's own
|
|
6
|
+
* `@colyseus/ws-transport` among them — can serve a peer as if it had arrived on
|
|
7
|
+
* a TCP upgrade, without reimplementing that server's client lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* `ws` usage this covers, taken from what `@colyseus/ws-transport` actually
|
|
10
|
+
* touches: `readyState`, `send(data, opts, cb)`, `close(code, reason)`,
|
|
11
|
+
* `terminate()`, `ping()` (it expects a `pong`), `on("message" | "close" |
|
|
12
|
+
* "error" | "pong")`, `pingCount`, and `_socket.remoteAddress`.
|
|
13
|
+
*
|
|
14
|
+
* It is not a real socket: there is no framing, no backpressure
|
|
15
|
+
* (`bufferedAmount` is always 0), and `maxPayload` — enforced inside `ws`'s own
|
|
16
|
+
* receiver — does not apply, so a message larger than the server's configured
|
|
17
|
+
* maximum is not truncated.
|
|
18
|
+
*/
|
|
19
|
+
import { EventEmitter } from "node:events";
|
|
20
|
+
import { toBytes } from "websocket-over-trystero";
|
|
21
|
+
/** ReadyState values from `ws`. */
|
|
22
|
+
const OPEN = 1;
|
|
23
|
+
const CLOSED = 3;
|
|
24
|
+
/**
|
|
25
|
+
* A `ws`-server-shaped socket for one trystero peer. Created by the
|
|
26
|
+
* {@link TrysteroServer} when a peer's first bytes arrive; consumers see a
|
|
27
|
+
* familiar `ws` socket (`on("message")`, `send`, `close`, `ping`).
|
|
28
|
+
*/
|
|
29
|
+
export class PeerWebSocket extends EventEmitter {
|
|
30
|
+
peer;
|
|
31
|
+
readyState = OPEN;
|
|
32
|
+
/** Written and read by `@colyseus/ws-transport`'s heartbeat. */
|
|
33
|
+
pingCount = 0;
|
|
34
|
+
protocol = "";
|
|
35
|
+
bufferedAmount = 0;
|
|
36
|
+
/** DOM field; the pipe is byte-oriented, so arraybuffer is all we deliver. */
|
|
37
|
+
binaryType = "arraybuffer";
|
|
38
|
+
/** Read when a server builds an auth context from the socket. */
|
|
39
|
+
_socket = { remoteAddress: "d3f-p2p" };
|
|
40
|
+
closed = false;
|
|
41
|
+
/** DOM event listeners, mirrored per type (NOT `EventEmitter.listeners()`). */
|
|
42
|
+
domListeners = new Map();
|
|
43
|
+
/** Replay for late "open"/"close" subscribers (the socket starts OPEN). */
|
|
44
|
+
lastCloseEvent = null;
|
|
45
|
+
_onopen = null;
|
|
46
|
+
_onmessage = null;
|
|
47
|
+
_onclose = null;
|
|
48
|
+
_onerror = null;
|
|
49
|
+
constructor(peer) {
|
|
50
|
+
super();
|
|
51
|
+
this.peer = peer;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* DOM `on*` properties (vtlsp assigns them). Setting `onopen` while the
|
|
55
|
+
* socket is already OPEN — the normal case here — replays it once.
|
|
56
|
+
*/
|
|
57
|
+
get onopen() { return this._onopen; }
|
|
58
|
+
set onopen(fn) {
|
|
59
|
+
this._onopen = fn;
|
|
60
|
+
if (fn && this.readyState === OPEN && !this.closed)
|
|
61
|
+
queueMicrotask(() => fn({ type: "open" }));
|
|
62
|
+
}
|
|
63
|
+
get onmessage() { return this._onmessage; }
|
|
64
|
+
set onmessage(fn) { this._onmessage = fn; }
|
|
65
|
+
get onclose() { return this._onclose; }
|
|
66
|
+
set onclose(fn) {
|
|
67
|
+
this._onclose = fn;
|
|
68
|
+
if (fn && this.lastCloseEvent) {
|
|
69
|
+
const ev = this.lastCloseEvent;
|
|
70
|
+
queueMicrotask(() => fn(ev));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
get onerror() { return this._onerror; }
|
|
74
|
+
set onerror(fn) { this._onerror = fn; }
|
|
75
|
+
/**
|
|
76
|
+
* DOM `addEventListener` (NOT Node's `on()` alias — plain EventEmitter has
|
|
77
|
+
* no such member): DOM consumers get `emit()`-independent listeners with
|
|
78
|
+
* `removeEventListener` symmetry; ws-style consumers keep `on()`/`emit()`.
|
|
79
|
+
*/
|
|
80
|
+
addEventListener(type, listener) {
|
|
81
|
+
let set = this.domListeners.get(type);
|
|
82
|
+
if (!set)
|
|
83
|
+
this.domListeners.set(type, (set = new Set()));
|
|
84
|
+
set.add(listener);
|
|
85
|
+
if (type === "open" && this.readyState === OPEN && !this.closed) {
|
|
86
|
+
queueMicrotask(() => this.dispatch("open", { type: "open" }));
|
|
87
|
+
}
|
|
88
|
+
else if (type === "close" && this.lastCloseEvent) {
|
|
89
|
+
const ev = this.lastCloseEvent;
|
|
90
|
+
queueMicrotask(() => this.dispatch("close", ev));
|
|
91
|
+
}
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/** Remove a listener previously added with {@link addEventListener}. */
|
|
95
|
+
removeEventListener(type, listener) {
|
|
96
|
+
const set = this.domListeners.get(type);
|
|
97
|
+
if (set?.delete(listener) && set.size === 0)
|
|
98
|
+
this.domListeners.delete(type);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
dispatch(type, ev) {
|
|
102
|
+
// Both surfaces from one source of truth: prop handler + listeners.
|
|
103
|
+
if (type === "open")
|
|
104
|
+
this._onopen?.(ev);
|
|
105
|
+
else if (type === "message")
|
|
106
|
+
this._onmessage?.(ev);
|
|
107
|
+
else if (type === "close")
|
|
108
|
+
this._onclose?.(ev);
|
|
109
|
+
else if (type === "error")
|
|
110
|
+
this._onerror?.(ev);
|
|
111
|
+
const set = this.domListeners.get(type);
|
|
112
|
+
if (!set)
|
|
113
|
+
return;
|
|
114
|
+
// Snapshot: a listener may remove itself mid-dispatch (DOM semantics).
|
|
115
|
+
for (const fn of [...set])
|
|
116
|
+
fn(ev);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Recover the exact LSP frame from a Node Buffer-pool slab leak.
|
|
120
|
+
*
|
|
121
|
+
* `@valtown/ls-ws-server`'s writable chunks with
|
|
122
|
+
* `Buffer.slice(i, end).buffer` — for a pool-backed Buffer `.buffer` is
|
|
123
|
+
* the ENTIRE ~64KB pool (stale bytes before/after the logical view), so
|
|
124
|
+
* the far end receives `[garbage][Content-Length frame][garbage]` and its
|
|
125
|
+
* strict reader never parses it (initialize hangs forever). A `ws` shim
|
|
126
|
+
* must deliver the intended BYTES: when the payload does not start with a
|
|
127
|
+
* frame but clearly CONTAINS one (header parses, body is JSON, bounded
|
|
128
|
+
* search), trim to exactly that frame; anything else passes through
|
|
129
|
+
* untouched (game msgpack is never touched — it neither starts with nor
|
|
130
|
+
* validates as an LSP frame).
|
|
131
|
+
*/
|
|
132
|
+
static recoverLspFrame(data) {
|
|
133
|
+
const HEAD = "Content-Length:";
|
|
134
|
+
const ascii = Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString("latin1");
|
|
135
|
+
const parts = [];
|
|
136
|
+
let consumedEnd = 0;
|
|
137
|
+
let idx = ascii.indexOf(HEAD);
|
|
138
|
+
// Bounded scan: the Node pool slab can hold stale frames anywhere in
|
|
139
|
+
// its ~64KB (observed frame offsets from ~112 to ~30000), so search
|
|
140
|
+
// the WHOLE buffer and keep every frame that validates. Stale frames
|
|
141
|
+
// carry OLD ids the far end already consumed — vscode-jsonrpc ignores
|
|
142
|
+
// them — while the fresh frame resolves the pending request.
|
|
143
|
+
let guard = 0;
|
|
144
|
+
while (idx >= 0 && guard++ < 8) {
|
|
145
|
+
const headerEnd = ascii.indexOf("\r\n\r\n", idx);
|
|
146
|
+
if (headerEnd < 0)
|
|
147
|
+
break;
|
|
148
|
+
const n = Number.parseInt(ascii.slice(idx + HEAD.length, headerEnd).trim(), 10);
|
|
149
|
+
const bodyStart = headerEnd + 4;
|
|
150
|
+
const frameEnd = bodyStart + n;
|
|
151
|
+
if (Number.isFinite(n) && n > 0 && frameEnd <= data.length) {
|
|
152
|
+
const body = Buffer.from(data.buffer, data.byteOffset + bodyStart, n).toString("utf8");
|
|
153
|
+
try {
|
|
154
|
+
JSON.parse(body);
|
|
155
|
+
parts.push(data.subarray(idx, frameEnd));
|
|
156
|
+
consumedEnd = frameEnd;
|
|
157
|
+
idx = ascii.indexOf(HEAD, frameEnd);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
catch { /* not a real frame — keep scanning */ }
|
|
161
|
+
}
|
|
162
|
+
idx = ascii.indexOf(HEAD, idx + HEAD.length);
|
|
163
|
+
}
|
|
164
|
+
if (parts.length === 0)
|
|
165
|
+
return data;
|
|
166
|
+
const [first] = parts;
|
|
167
|
+
if (parts.length === 1 && first && first.byteOffset === data.byteOffset && consumedEnd === data.byteLength) {
|
|
168
|
+
return data; // already an exact frame, untouched
|
|
169
|
+
}
|
|
170
|
+
let total = 0;
|
|
171
|
+
for (const p of parts)
|
|
172
|
+
total += p.byteLength;
|
|
173
|
+
const out = new Uint8Array(total);
|
|
174
|
+
let off = 0;
|
|
175
|
+
for (const p of parts) {
|
|
176
|
+
out.set(p, off);
|
|
177
|
+
off += p.byteLength;
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Send bytes to the peer. `callback` (the ws-style third argument) fires with
|
|
183
|
+
* an error if the socket is closed or the underlying send rejects.
|
|
184
|
+
*/
|
|
185
|
+
send(data, _options, callback) {
|
|
186
|
+
let payload;
|
|
187
|
+
try {
|
|
188
|
+
payload = typeof data === "string" ? new TextEncoder().encode(data)
|
|
189
|
+
: data instanceof ArrayBuffer ? new Uint8Array(data)
|
|
190
|
+
: ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
|
|
191
|
+
: undefined;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
payload = undefined;
|
|
195
|
+
}
|
|
196
|
+
if (payload)
|
|
197
|
+
payload = PeerWebSocket.recoverLspFrame(payload);
|
|
198
|
+
if (this.closed) {
|
|
199
|
+
callback?.(new Error("socket is closed"));
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const result = this.peer.send(toBytes(payload ?? data));
|
|
203
|
+
// A transport that hands back a Promise (the trystero datachannel
|
|
204
|
+
// send) can fail AFTER this call returns. Surface that instead of
|
|
205
|
+
// dropping it: the DOM-style "error" event for
|
|
206
|
+
// addEventListener/onerror consumers, and the ws-style callback
|
|
207
|
+
// error for the @colyseus/ws-transport send path.
|
|
208
|
+
if (result instanceof Promise) {
|
|
209
|
+
result.then(() => callback?.(), (err) => {
|
|
210
|
+
this.error(err);
|
|
211
|
+
callback?.(err instanceof Error ? err : new Error(String(err)));
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
callback?.();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Servers ping on an interval and terminate clients that stop answering, so a
|
|
220
|
+
* pong has to come back. There is no transport-level ping to make — WebRTC
|
|
221
|
+
* keeps the link alive — so answer at once.
|
|
222
|
+
*/
|
|
223
|
+
ping() {
|
|
224
|
+
queueMicrotask(() => this.emit("pong"));
|
|
225
|
+
}
|
|
226
|
+
/** Close the socket (code 1006 for {@link terminate}), notifying the peer. */
|
|
227
|
+
close(code = 1000, reason = "") {
|
|
228
|
+
if (this.closed)
|
|
229
|
+
return;
|
|
230
|
+
this.closed = true;
|
|
231
|
+
this.readyState = CLOSED;
|
|
232
|
+
// Tell the peer, so a client blocked in `leave()` actually returns. The
|
|
233
|
+
// far end's own close is a no-op by then, so this cannot ping-pong.
|
|
234
|
+
this.peer.close(code, reason);
|
|
235
|
+
this.emit("close", code, Buffer.from(reason));
|
|
236
|
+
this.dispatchCloseEvent(code, reason);
|
|
237
|
+
}
|
|
238
|
+
/** Abruptly terminate the socket, as `ws` does (close code 1006). */
|
|
239
|
+
terminate() {
|
|
240
|
+
this.close(1006, "terminated");
|
|
241
|
+
}
|
|
242
|
+
/** A transport-level error surfaced to DOM-style consumers. */
|
|
243
|
+
error(err) {
|
|
244
|
+
this.dispatch("error", { type: "error", error: err });
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The peer told us it is closing. Emit the close for the server, but do NOT
|
|
248
|
+
* tell the peer back: the notification would arrive after a reconnecting
|
|
249
|
+
* client has already registered its next socket, and close that one instead.
|
|
250
|
+
* (The mirror case is fine — a socket closed by a remote close never
|
|
251
|
+
* notifies, so the two directions stay balanced.)
|
|
252
|
+
*/
|
|
253
|
+
peerClosed(code = 1000, reason = "") {
|
|
254
|
+
if (this.closed)
|
|
255
|
+
return;
|
|
256
|
+
this.closed = true;
|
|
257
|
+
this.readyState = CLOSED;
|
|
258
|
+
this.emit("close", code, Buffer.from(reason));
|
|
259
|
+
this.dispatchCloseEvent(code, reason);
|
|
260
|
+
}
|
|
261
|
+
/** Bytes arrived from the peer: deliver them as a `ws` message would. */
|
|
262
|
+
deliver(bytes) {
|
|
263
|
+
if (this.closed)
|
|
264
|
+
return;
|
|
265
|
+
this.emit("message", Buffer.from(bytes), true);
|
|
266
|
+
// DOM side: a fresh ArrayBuffer copy — `bytes.buffer` may be a shared
|
|
267
|
+
// slice view, and JSON-RPC framing only needs its own bytes anyway.
|
|
268
|
+
const copy = new ArrayBuffer(bytes.byteLength);
|
|
269
|
+
new Uint8Array(copy).set(bytes);
|
|
270
|
+
this.dispatch("message", { type: "message", data: copy });
|
|
271
|
+
}
|
|
272
|
+
dispatchCloseEvent(code, reason) {
|
|
273
|
+
const ev = { type: "close", code, reason, wasClean: code === 1000 };
|
|
274
|
+
this.lastCloseEvent = ev;
|
|
275
|
+
this.dispatch("close", ev);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=socket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,mCAAmC;AACnC,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,MAAM,GAAG,CAAC,CAAC;AA4BjB;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAqBjB,IAAI;IApBjC,UAAU,GAAG,IAAI,CAAC;IAClB,gEAAgE;IAChE,SAAS,GAAG,CAAC,CAAC;IACd,QAAQ,GAAG,EAAE,CAAC;IACd,cAAc,GAAG,CAAC,CAAC;IACnB,8EAA8E;IAC9E,UAAU,GAAG,aAAa,CAAC;IAC3B,iEAAiE;IACxD,OAAO,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IAExC,MAAM,GAAG,KAAK,CAAC;IACvB,+EAA+E;IACvE,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC5D,2EAA2E;IACnE,cAAc,GAAoD,IAAI,CAAC;IACvE,OAAO,GAA4C,IAAI,CAAC;IACxD,UAAU,GAAsE,IAAI,CAAC;IACrF,QAAQ,GAAoE,IAAI,CAAC;IACjF,QAAQ,GAAoE,IAAI,CAAC;IAEzF,YAA6B,IAAgB;QAC5C,KAAK,EAAE,CAAC;oBADoB,IAAI;IAEjC,CAAC;IAED;;;OAGG;IACH,IAAI,MAAM,KA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2
2
|
"name": "node-ws-over-trystero",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"keywords": [],
|
|
7
|
-
"author": "",
|
|
8
|
-
"license": "ISC",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
9
5
|
"type": "module",
|
|
6
|
+
"description": "ws-server-shaped sockets over trystero data channels",
|
|
7
|
+
"license": "LGPL-3.0-or-later",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"COPYING.LESSER"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"websocket-over-trystero": "0.1.1"
|
|
26
|
+
},
|
|
10
27
|
"scripts": {
|
|
11
|
-
"
|
|
28
|
+
"build": "tsc -p tsconfig.build.json && node scripts/verify-dist.mjs"
|
|
12
29
|
}
|
|
13
30
|
}
|