@veryfront/ext-node-websocket-ws 0.1.1289-rc.26248 → 0.1.1289-rc.26253
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/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +130 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -3
- package/esm/portable-runtime.generated.d.ts +11 -0
- package/esm/portable-runtime.generated.d.ts.map +1 -0
- package/esm/portable-runtime.generated.js +910 -0
- package/esm/portable.d.ts +4 -0
- package/esm/portable.d.ts.map +1 -0
- package/esm/portable.js +6 -0
- package/esm/provider.d.ts +4 -0
- package/esm/provider.d.ts.map +1 -0
- package/esm/provider.js +12 -0
- package/package.json +7 -3
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
// deno-lint-ignore-file -- Verified generated upstream WebSocket bundle.
|
|
3
|
+
/**
|
|
4
|
+
* Official ws@8.21.1, with optional native accelerators disabled at build time.
|
|
5
|
+
* Package integrity: sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==
|
|
6
|
+
* Upstream source SHA-256: 42934414004ba40e5be9f6b82aed4870b363e493bbbf5655d057c08bb02ac94e
|
|
7
|
+
* Bundle SHA-256: d85325b139a055afa6f1f9dd6ac94179461fdf264a2f548220037ed6f92c2fbb
|
|
8
|
+
* Generated by extensions/ext-node-websocket-ws/scripts/prebundle.ts.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
11
|
+
* Copyright (c) 2013 Arnout Kazemier and contributors
|
|
12
|
+
* Copyright (c) 2016 Luigi Pinca and contributors
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
15
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
16
|
+
* the Software without restriction, including without limitation the rights to
|
|
17
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
18
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
* copies or substantial portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
26
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
27
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
28
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
29
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
import { createRequire } from "node:module";
|
|
33
|
+
const require = createRequire(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
34
|
+
var Ht = Object.create;
|
|
35
|
+
var qe = Object.defineProperty;
|
|
36
|
+
var Yt = Object.getOwnPropertyDescriptor;
|
|
37
|
+
var Kt = Object.getOwnPropertyNames;
|
|
38
|
+
var Xt = Object.getPrototypeOf, Zt = Object.prototype.hasOwnProperty;
|
|
39
|
+
var g = (t => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, { get: (e, s) => (typeof require < "u" ? require : e)[s] }) : t)(function (t) { if (typeof require < "u")
|
|
40
|
+
return require.apply(this, arguments); throw Error('Dynamic require of "' + t + '" is not supported'); });
|
|
41
|
+
var S = (t, e) => () => { try {
|
|
42
|
+
return e || t((e = { exports: {} }).exports, e), e.exports;
|
|
43
|
+
}
|
|
44
|
+
catch (s) {
|
|
45
|
+
throw e = 0, s;
|
|
46
|
+
} };
|
|
47
|
+
var Qt = (t, e, s, r) => { if (e && typeof e == "object" || typeof e == "function")
|
|
48
|
+
for (let i of Kt(e))
|
|
49
|
+
!Zt.call(t, i) && i !== s && qe(t, i, { get: () => e[i], enumerable: !(r = Yt(e, i)) || r.enumerable }); return t; };
|
|
50
|
+
var N = (t, e, s) => (s = t != null ? Ht(Xt(t)) : {}, Qt(e || !t || !t.__esModule ? qe(s, "default", { value: t, enumerable: !0 }) : s, t));
|
|
51
|
+
var O = S((Lr, je) => {
|
|
52
|
+
"use strict";
|
|
53
|
+
var Ge = ["nodebuffer", "arraybuffer", "fragments"], $e = typeof Blob < "u";
|
|
54
|
+
$e && Ge.push("blob");
|
|
55
|
+
je.exports = { BINARY_TYPES: Ge, CLOSE_TIMEOUT: 3e4, EMPTY_BUFFER: Buffer.alloc(0), GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", hasBlob: $e, kForOnEventAttribute: Symbol("kIsForOnEventAttribute"), kListener: Symbol("kListener"), kStatusCode: Symbol("status-code"), kWebSocket: Symbol("websocket"), NOOP: () => { } };
|
|
56
|
+
});
|
|
57
|
+
var X = S((Nr, Ve) => {
|
|
58
|
+
"use strict";
|
|
59
|
+
var { EMPTY_BUFFER: Jt } = O(), ge = Buffer[Symbol.species];
|
|
60
|
+
function es(t, e) { if (t.length === 0)
|
|
61
|
+
return Jt; if (t.length === 1)
|
|
62
|
+
return t[0]; let s = Buffer.allocUnsafe(e), r = 0; for (let i = 0; i < t.length; i++) {
|
|
63
|
+
let n = t[i];
|
|
64
|
+
s.set(n, r), r += n.length;
|
|
65
|
+
} return r < e ? new ge(s.buffer, s.byteOffset, r) : s; }
|
|
66
|
+
function ts(t, e, s, r, i) { for (let n = 0; n < i; n++)
|
|
67
|
+
s[r + n] = t[n] ^ e[n & 3]; }
|
|
68
|
+
function ss(t, e) { for (let s = 0; s < t.length; s++)
|
|
69
|
+
t[s] ^= e[s & 3]; }
|
|
70
|
+
function rs(t) { return t.length === t.buffer.byteLength ? t.buffer : t.buffer.slice(t.byteOffset, t.byteOffset + t.length); }
|
|
71
|
+
function ye(t) { if (ye.readOnly = !0, Buffer.isBuffer(t))
|
|
72
|
+
return t; let e; return t instanceof ArrayBuffer ? e = new ge(t) : ArrayBuffer.isView(t) ? e = new ge(t.buffer, t.byteOffset, t.byteLength) : (e = Buffer.from(t), ye.readOnly = !1), e; }
|
|
73
|
+
Ve.exports = { concat: es, mask: ts, toArrayBuffer: rs, toBuffer: ye, unmask: ss };
|
|
74
|
+
});
|
|
75
|
+
var Ye = S((Pr, He) => {
|
|
76
|
+
"use strict";
|
|
77
|
+
var ze = Symbol("kDone"), xe = Symbol("kRun"), Se = class {
|
|
78
|
+
constructor(e) { this[ze] = () => { this.pending--, this[xe](); }, this.concurrency = e || 1 / 0, this.jobs = [], this.pending = 0; }
|
|
79
|
+
add(e) { this.jobs.push(e), this[xe](); }
|
|
80
|
+
[xe]() { if (this.pending !== this.concurrency && this.jobs.length) {
|
|
81
|
+
let e = this.jobs.shift();
|
|
82
|
+
this.pending++, e(this[ze]);
|
|
83
|
+
} }
|
|
84
|
+
};
|
|
85
|
+
He.exports = Se;
|
|
86
|
+
});
|
|
87
|
+
var G = S((Br, Qe) => {
|
|
88
|
+
"use strict";
|
|
89
|
+
var Z = g("zlib"), Ke = X(), is = Ye(), { kStatusCode: Xe } = O(), ns = Buffer[Symbol.species], os = Buffer.from([0, 0, 255, 255]), ie = Symbol("permessage-deflate"), T = Symbol("total-length"), W = Symbol("callback"), P = Symbol("buffers"), q = Symbol("error"), re, Ee = class {
|
|
90
|
+
constructor(e) { if (this._options = e || {}, this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024, this._maxPayload = this._options.maxPayload | 0, this._isServer = !!this._options.isServer, this._deflate = null, this._inflate = null, this.params = null, !re) {
|
|
91
|
+
let s = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
|
92
|
+
re = new is(s);
|
|
93
|
+
} }
|
|
94
|
+
static get extensionName() { return "permessage-deflate"; }
|
|
95
|
+
offer() { let e = {}; return this._options.serverNoContextTakeover && (e.server_no_context_takeover = !0), this._options.clientNoContextTakeover && (e.client_no_context_takeover = !0), this._options.serverMaxWindowBits && (e.server_max_window_bits = this._options.serverMaxWindowBits), this._options.clientMaxWindowBits ? e.client_max_window_bits = this._options.clientMaxWindowBits : this._options.clientMaxWindowBits == null && (e.client_max_window_bits = !0), e; }
|
|
96
|
+
accept(e) { return e = this.normalizeParams(e), this.params = this._isServer ? this.acceptAsServer(e) : this.acceptAsClient(e), this.params; }
|
|
97
|
+
cleanup() { if (this._inflate && (this._inflate.close(), this._inflate = null), this._deflate) {
|
|
98
|
+
let e = this._deflate[W];
|
|
99
|
+
this._deflate.close(), this._deflate = null, e && e(new Error("The deflate stream was closed while data was being processed"));
|
|
100
|
+
} }
|
|
101
|
+
acceptAsServer(e) { let s = this._options, r = e.find(i => !(s.serverNoContextTakeover === !1 && i.server_no_context_takeover || i.server_max_window_bits && (s.serverMaxWindowBits === !1 || typeof s.serverMaxWindowBits == "number" && s.serverMaxWindowBits > i.server_max_window_bits) || typeof s.clientMaxWindowBits == "number" && !i.client_max_window_bits)); if (!r)
|
|
102
|
+
throw new Error("None of the extension offers can be accepted"); return s.serverNoContextTakeover && (r.server_no_context_takeover = !0), s.clientNoContextTakeover && (r.client_no_context_takeover = !0), typeof s.serverMaxWindowBits == "number" && (r.server_max_window_bits = s.serverMaxWindowBits), typeof s.clientMaxWindowBits == "number" ? r.client_max_window_bits = s.clientMaxWindowBits : (r.client_max_window_bits === !0 || s.clientMaxWindowBits === !1) && delete r.client_max_window_bits, r; }
|
|
103
|
+
acceptAsClient(e) { let s = e[0]; if (this._options.clientNoContextTakeover === !1 && s.client_no_context_takeover)
|
|
104
|
+
throw new Error('Unexpected parameter "client_no_context_takeover"'); if (!s.client_max_window_bits)
|
|
105
|
+
typeof this._options.clientMaxWindowBits == "number" && (s.client_max_window_bits = this._options.clientMaxWindowBits);
|
|
106
|
+
else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && s.client_max_window_bits > this._options.clientMaxWindowBits)
|
|
107
|
+
throw new Error('Unexpected or invalid parameter "client_max_window_bits"'); return s; }
|
|
108
|
+
normalizeParams(e) { return e.forEach(s => { Object.keys(s).forEach(r => { let i = s[r]; if (i.length > 1)
|
|
109
|
+
throw new Error(`Parameter "${r}" must have only a single value`); if (i = i[0], r === "client_max_window_bits") {
|
|
110
|
+
if (i !== !0) {
|
|
111
|
+
let n = +i;
|
|
112
|
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
|
113
|
+
throw new TypeError(`Invalid value for parameter "${r}": ${i}`);
|
|
114
|
+
i = n;
|
|
115
|
+
}
|
|
116
|
+
else if (!this._isServer)
|
|
117
|
+
throw new TypeError(`Invalid value for parameter "${r}": ${i}`);
|
|
118
|
+
}
|
|
119
|
+
else if (r === "server_max_window_bits") {
|
|
120
|
+
let n = +i;
|
|
121
|
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
|
122
|
+
throw new TypeError(`Invalid value for parameter "${r}": ${i}`);
|
|
123
|
+
i = n;
|
|
124
|
+
}
|
|
125
|
+
else if (r === "client_no_context_takeover" || r === "server_no_context_takeover") {
|
|
126
|
+
if (i !== !0)
|
|
127
|
+
throw new TypeError(`Invalid value for parameter "${r}": ${i}`);
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
throw new Error(`Unknown parameter "${r}"`); s[r] = i; }); }), e; }
|
|
131
|
+
decompress(e, s, r) { re.add(i => { this._decompress(e, s, (n, o) => { i(), r(n, o); }); }); }
|
|
132
|
+
compress(e, s, r) { re.add(i => { this._compress(e, s, (n, o) => { i(), r(n, o); }); }); }
|
|
133
|
+
_decompress(e, s, r) { let i = this._isServer ? "client" : "server"; if (!this._inflate) {
|
|
134
|
+
let n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? Z.Z_DEFAULT_WINDOWBITS : this.params[n];
|
|
135
|
+
this._inflate = Z.createInflateRaw({ ...this._options.zlibInflateOptions, windowBits: o }), this._inflate[ie] = this, this._inflate[T] = 0, this._inflate[P] = [], this._inflate.on("error", fs), this._inflate.on("data", Ze);
|
|
136
|
+
} this._inflate[W] = r, this._inflate.write(e), s && this._inflate.write(os), this._inflate.flush(() => { let n = this._inflate[q]; if (n) {
|
|
137
|
+
this._inflate.close(), this._inflate = null, r(n);
|
|
138
|
+
return;
|
|
139
|
+
} let o = Ke.concat(this._inflate[P], this._inflate[T]); this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[T] = 0, this._inflate[P] = [], s && this.params[`${i}_no_context_takeover`] && this._inflate.reset()), r(null, o); }); }
|
|
140
|
+
_compress(e, s, r) { let i = this._isServer ? "server" : "client"; if (!this._deflate) {
|
|
141
|
+
let n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? Z.Z_DEFAULT_WINDOWBITS : this.params[n];
|
|
142
|
+
this._deflate = Z.createDeflateRaw({ ...this._options.zlibDeflateOptions, windowBits: o }), this._deflate[T] = 0, this._deflate[P] = [], this._deflate.on("data", as);
|
|
143
|
+
} this._deflate[W] = r, this._deflate.write(e), this._deflate.flush(Z.Z_SYNC_FLUSH, () => { if (!this._deflate)
|
|
144
|
+
return; let n = Ke.concat(this._deflate[P], this._deflate[T]); s && (n = new ns(n.buffer, n.byteOffset, n.length - 4)), this._deflate[W] = null, this._deflate[T] = 0, this._deflate[P] = [], s && this.params[`${i}_no_context_takeover`] && this._deflate.reset(), r(null, n); }); }
|
|
145
|
+
};
|
|
146
|
+
Qe.exports = Ee;
|
|
147
|
+
function as(t) { this[P].push(t), this[T] += t.length; }
|
|
148
|
+
function Ze(t) { if (this[T] += t.length, this[ie]._maxPayload < 1 || this[T] <= this[ie]._maxPayload) {
|
|
149
|
+
this[P].push(t);
|
|
150
|
+
return;
|
|
151
|
+
} this[q] = new RangeError("Max payload size exceeded"), this[q].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[q][Xe] = 1009, this.removeListener("data", Ze), this.reset(); }
|
|
152
|
+
function fs(t) { if (this[ie]._inflate = null, this[q]) {
|
|
153
|
+
this[W](this[q]);
|
|
154
|
+
return;
|
|
155
|
+
} t[Xe] = 1007, this[W](t); }
|
|
156
|
+
});
|
|
157
|
+
var $ = S((Rr, be) => {
|
|
158
|
+
"use strict";
|
|
159
|
+
var { isUtf8: Je } = g("buffer"), { hasBlob: ls } = O(), hs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0];
|
|
160
|
+
function cs(t) { return t >= 1e3 && t <= 1014 && t !== 1004 && t !== 1005 && t !== 1006 || t >= 3e3 && t <= 4999; }
|
|
161
|
+
function et(t) { let e = t.length, s = 0; for (; s < e;)
|
|
162
|
+
if ((t[s] & 128) === 0)
|
|
163
|
+
s++;
|
|
164
|
+
else if ((t[s] & 224) === 192) {
|
|
165
|
+
if (s + 1 === e || (t[s + 1] & 192) !== 128 || (t[s] & 254) === 192)
|
|
166
|
+
return !1;
|
|
167
|
+
s += 2;
|
|
168
|
+
}
|
|
169
|
+
else if ((t[s] & 240) === 224) {
|
|
170
|
+
if (s + 2 >= e || (t[s + 1] & 192) !== 128 || (t[s + 2] & 192) !== 128 || t[s] === 224 && (t[s + 1] & 224) === 128 || t[s] === 237 && (t[s + 1] & 224) === 160)
|
|
171
|
+
return !1;
|
|
172
|
+
s += 3;
|
|
173
|
+
}
|
|
174
|
+
else if ((t[s] & 248) === 240) {
|
|
175
|
+
if (s + 3 >= e || (t[s + 1] & 192) !== 128 || (t[s + 2] & 192) !== 128 || (t[s + 3] & 192) !== 128 || t[s] === 240 && (t[s + 1] & 240) === 128 || t[s] === 244 && t[s + 1] > 143 || t[s] > 244)
|
|
176
|
+
return !1;
|
|
177
|
+
s += 4;
|
|
178
|
+
}
|
|
179
|
+
else
|
|
180
|
+
return !1; return !0; }
|
|
181
|
+
function us(t) { return ls && typeof t == "object" && typeof t.arrayBuffer == "function" && typeof t.type == "string" && typeof t.stream == "function" && (t[Symbol.toStringTag] === "Blob" || t[Symbol.toStringTag] === "File"); }
|
|
182
|
+
be.exports = { isBlob: us, isValidStatusCode: cs, isValidUTF8: et, tokenChars: hs };
|
|
183
|
+
Je && (be.exports.isValidUTF8 = function (t) { return t.length < 24 ? et(t) : Je(t); });
|
|
184
|
+
});
|
|
185
|
+
var Te = S((Ur, at) => {
|
|
186
|
+
"use strict";
|
|
187
|
+
var { Writable: ds } = g("stream"), tt = G(), { BINARY_TYPES: _s, EMPTY_BUFFER: st, kStatusCode: ms, kWebSocket: ps } = O(), { concat: ve, toArrayBuffer: gs, unmask: ys } = X(), { isValidStatusCode: xs, isValidUTF8: rt } = $(), ne = Buffer[Symbol.species], b = 0, it = 1, nt = 2, ot = 3, we = 4, ke = 5, oe = 6, Oe = class extends ds {
|
|
188
|
+
constructor(e = {}) { super(), this._allowSynchronousEvents = e.allowSynchronousEvents !== void 0 ? e.allowSynchronousEvents : !0, this._binaryType = e.binaryType || _s[0], this._extensions = e.extensions || {}, this._isServer = !!e.isServer, this._maxBufferedChunks = e.maxBufferedChunks | 0, this._maxFragments = e.maxFragments | 0, this._maxPayload = e.maxPayload | 0, this._skipUTF8Validation = !!e.skipUTF8Validation, this[ps] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._numFragments = 0, this._fragments = [], this._errored = !1, this._loop = !1, this._state = b; }
|
|
189
|
+
_write(e, s, r) { if (this._opcode === 8 && this._state == b)
|
|
190
|
+
return r(); if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
191
|
+
r(this.createError(RangeError, "Too many buffered chunks", !1, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
192
|
+
return;
|
|
193
|
+
} this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(r); }
|
|
194
|
+
consume(e) { if (this._bufferedBytes -= e, e === this._buffers[0].length)
|
|
195
|
+
return this._buffers.shift(); if (e < this._buffers[0].length) {
|
|
196
|
+
let r = this._buffers[0];
|
|
197
|
+
return this._buffers[0] = new ne(r.buffer, r.byteOffset + e, r.length - e), new ne(r.buffer, r.byteOffset, e);
|
|
198
|
+
} let s = Buffer.allocUnsafe(e); do {
|
|
199
|
+
let r = this._buffers[0], i = s.length - e;
|
|
200
|
+
e >= r.length ? s.set(this._buffers.shift(), i) : (s.set(new Uint8Array(r.buffer, r.byteOffset, e), i), this._buffers[0] = new ne(r.buffer, r.byteOffset + e, r.length - e)), e -= r.length;
|
|
201
|
+
} while (e > 0); return s; }
|
|
202
|
+
startLoop(e) { this._loop = !0; do
|
|
203
|
+
switch (this._state) {
|
|
204
|
+
case b:
|
|
205
|
+
this.getInfo(e);
|
|
206
|
+
break;
|
|
207
|
+
case it:
|
|
208
|
+
this.getPayloadLength16(e);
|
|
209
|
+
break;
|
|
210
|
+
case nt:
|
|
211
|
+
this.getPayloadLength64(e);
|
|
212
|
+
break;
|
|
213
|
+
case ot:
|
|
214
|
+
this.getMask();
|
|
215
|
+
break;
|
|
216
|
+
case we:
|
|
217
|
+
this.getData(e);
|
|
218
|
+
break;
|
|
219
|
+
case ke:
|
|
220
|
+
case oe:
|
|
221
|
+
this._loop = !1;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
while (this._loop); this._errored || e(); }
|
|
225
|
+
getInfo(e) { if (this._bufferedBytes < 2) {
|
|
226
|
+
this._loop = !1;
|
|
227
|
+
return;
|
|
228
|
+
} let s = this.consume(2); if ((s[0] & 48) !== 0) {
|
|
229
|
+
let i = this.createError(RangeError, "RSV2 and RSV3 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
|
|
230
|
+
e(i);
|
|
231
|
+
return;
|
|
232
|
+
} let r = (s[0] & 64) === 64; if (r && !this._extensions[tt.extensionName]) {
|
|
233
|
+
let i = this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
234
|
+
e(i);
|
|
235
|
+
return;
|
|
236
|
+
} if (this._fin = (s[0] & 128) === 128, this._opcode = s[0] & 15, this._payloadLength = s[1] & 127, this._opcode === 0) {
|
|
237
|
+
if (r) {
|
|
238
|
+
let i = this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
239
|
+
e(i);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!this._fragmented) {
|
|
243
|
+
let i = this.createError(RangeError, "invalid opcode 0", !0, 1002, "WS_ERR_INVALID_OPCODE");
|
|
244
|
+
e(i);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
this._opcode = this._fragmented;
|
|
248
|
+
}
|
|
249
|
+
else if (this._opcode === 1 || this._opcode === 2) {
|
|
250
|
+
if (this._fragmented) {
|
|
251
|
+
let i = this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, "WS_ERR_INVALID_OPCODE");
|
|
252
|
+
e(i);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this._compressed = r;
|
|
256
|
+
}
|
|
257
|
+
else if (this._opcode > 7 && this._opcode < 11) {
|
|
258
|
+
if (!this._fin) {
|
|
259
|
+
let i = this.createError(RangeError, "FIN must be set", !0, 1002, "WS_ERR_EXPECTED_FIN");
|
|
260
|
+
e(i);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (r) {
|
|
264
|
+
let i = this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
265
|
+
e(i);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
269
|
+
let i = this.createError(RangeError, `invalid payload length ${this._payloadLength}`, !0, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
|
|
270
|
+
e(i);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
let i = this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, "WS_ERR_INVALID_OPCODE");
|
|
276
|
+
e(i);
|
|
277
|
+
return;
|
|
278
|
+
} if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (s[1] & 128) === 128, this._isServer) {
|
|
279
|
+
if (!this._masked) {
|
|
280
|
+
let i = this.createError(RangeError, "MASK must be set", !0, 1002, "WS_ERR_EXPECTED_MASK");
|
|
281
|
+
e(i);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (this._masked) {
|
|
286
|
+
let i = this.createError(RangeError, "MASK must be clear", !0, 1002, "WS_ERR_UNEXPECTED_MASK");
|
|
287
|
+
e(i);
|
|
288
|
+
return;
|
|
289
|
+
} this._payloadLength === 126 ? this._state = it : this._payloadLength === 127 ? this._state = nt : this.haveLength(e); }
|
|
290
|
+
getPayloadLength16(e) { if (this._bufferedBytes < 2) {
|
|
291
|
+
this._loop = !1;
|
|
292
|
+
return;
|
|
293
|
+
} this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength(e); }
|
|
294
|
+
getPayloadLength64(e) { if (this._bufferedBytes < 8) {
|
|
295
|
+
this._loop = !1;
|
|
296
|
+
return;
|
|
297
|
+
} let s = this.consume(8), r = s.readUInt32BE(0); if (r > Math.pow(2, 21) - 1) {
|
|
298
|
+
let i = this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", !1, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
|
|
299
|
+
e(i);
|
|
300
|
+
return;
|
|
301
|
+
} this._payloadLength = r * Math.pow(2, 32) + s.readUInt32BE(4), this.haveLength(e); }
|
|
302
|
+
haveLength(e) { if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0)) {
|
|
303
|
+
let s = this.createError(RangeError, "Max payload size exceeded", !1, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
304
|
+
e(s);
|
|
305
|
+
return;
|
|
306
|
+
} this._masked ? this._state = ot : this._state = we; }
|
|
307
|
+
getMask() { if (this._bufferedBytes < 4) {
|
|
308
|
+
this._loop = !1;
|
|
309
|
+
return;
|
|
310
|
+
} this._mask = this.consume(4), this._state = we; }
|
|
311
|
+
getData(e) { let s = st; if (this._payloadLength) {
|
|
312
|
+
if (this._bufferedBytes < this._payloadLength) {
|
|
313
|
+
this._loop = !1;
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
s = this.consume(this._payloadLength), this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 && ys(s, this._mask);
|
|
317
|
+
} if (this._opcode > 7) {
|
|
318
|
+
this.controlMessage(s, e);
|
|
319
|
+
return;
|
|
320
|
+
} if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
321
|
+
let r = this.createError(RangeError, "Too many message fragments", !1, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
|
|
322
|
+
e(r);
|
|
323
|
+
return;
|
|
324
|
+
} if (this._compressed) {
|
|
325
|
+
this._state = ke, this.decompress(s, e);
|
|
326
|
+
return;
|
|
327
|
+
} s.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(s)), this.dataMessage(e); }
|
|
328
|
+
decompress(e, s) { this._extensions[tt.extensionName].decompress(e, this._fin, (i, n) => { if (i)
|
|
329
|
+
return s(i); if (n.length) {
|
|
330
|
+
if (this._messageLength += n.length, this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
331
|
+
let o = this.createError(RangeError, "Max payload size exceeded", !1, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
332
|
+
s(o);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
this._fragments.push(n);
|
|
336
|
+
} this.dataMessage(s), this._state === b && this.startLoop(s); }); }
|
|
337
|
+
dataMessage(e) { if (!this._fin) {
|
|
338
|
+
this._state = b;
|
|
339
|
+
return;
|
|
340
|
+
} let s = this._messageLength, r = this._fragments; if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._numFragments = 0, this._fragments = [], this._opcode === 2) {
|
|
341
|
+
let i;
|
|
342
|
+
this._binaryType === "nodebuffer" ? i = ve(r, s) : this._binaryType === "arraybuffer" ? i = gs(ve(r, s)) : this._binaryType === "blob" ? i = new Blob(r) : i = r, this._allowSynchronousEvents ? (this.emit("message", i, !0), this._state = b) : (this._state = oe, setImmediate(() => { this.emit("message", i, !0), this._state = b, this.startLoop(e); }));
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
let i = ve(r, s);
|
|
346
|
+
if (!this._skipUTF8Validation && !rt(i)) {
|
|
347
|
+
let n = this.createError(Error, "invalid UTF-8 sequence", !0, 1007, "WS_ERR_INVALID_UTF8");
|
|
348
|
+
e(n);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this._state === ke || this._allowSynchronousEvents ? (this.emit("message", i, !1), this._state = b) : (this._state = oe, setImmediate(() => { this.emit("message", i, !1), this._state = b, this.startLoop(e); }));
|
|
352
|
+
} }
|
|
353
|
+
controlMessage(e, s) { if (this._opcode === 8) {
|
|
354
|
+
if (e.length === 0)
|
|
355
|
+
this._loop = !1, this.emit("conclude", 1005, st), this.end();
|
|
356
|
+
else {
|
|
357
|
+
let r = e.readUInt16BE(0);
|
|
358
|
+
if (!xs(r)) {
|
|
359
|
+
let n = this.createError(RangeError, `invalid status code ${r}`, !0, 1002, "WS_ERR_INVALID_CLOSE_CODE");
|
|
360
|
+
s(n);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
let i = new ne(e.buffer, e.byteOffset + 2, e.length - 2);
|
|
364
|
+
if (!this._skipUTF8Validation && !rt(i)) {
|
|
365
|
+
let n = this.createError(Error, "invalid UTF-8 sequence", !0, 1007, "WS_ERR_INVALID_UTF8");
|
|
366
|
+
s(n);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this._loop = !1, this.emit("conclude", r, i), this.end();
|
|
370
|
+
}
|
|
371
|
+
this._state = b;
|
|
372
|
+
return;
|
|
373
|
+
} this._allowSynchronousEvents ? (this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = b) : (this._state = oe, setImmediate(() => { this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = b, this.startLoop(s); })); }
|
|
374
|
+
createError(e, s, r, i, n) { this._loop = !1, this._errored = !0; let o = new e(r ? `Invalid WebSocket frame: ${s}` : s); return Error.captureStackTrace(o, this.createError), o.code = n, o[ms] = i, o; }
|
|
375
|
+
};
|
|
376
|
+
at.exports = Oe;
|
|
377
|
+
});
|
|
378
|
+
var Ne = S((Dr, ht) => {
|
|
379
|
+
"use strict";
|
|
380
|
+
var { Duplex: Ir } = g("stream"), { randomFillSync: Ss } = g("crypto"), { types: { isUint8Array: Es } } = g("util"), ft = G(), { EMPTY_BUFFER: bs, kWebSocket: vs, NOOP: ws } = O(), { isBlob: j, isValidStatusCode: ks } = $(), { mask: lt, toBuffer: R } = X(), v = Symbol("kByteLength"), Os = Buffer.alloc(4), ae = 8 * 1024, U, V = ae, w = 0, Ts = 1, Cs = 2, Ce = class t {
|
|
381
|
+
constructor(e, s, r) { this._extensions = s || {}, r && (this._generateMask = r, this._maskBuffer = Buffer.alloc(4)), this._socket = e, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._queue = [], this._state = w, this.onerror = ws, this[vs] = void 0; }
|
|
382
|
+
static frame(e, s) { let r, i = !1, n = 2, o = !1; s.mask && (r = s.maskBuffer || Os, s.generateMask ? s.generateMask(r) : (V === ae && (U === void 0 && (U = Buffer.alloc(ae)), Ss(U, 0, ae), V = 0), r[0] = U[V++], r[1] = U[V++], r[2] = U[V++], r[3] = U[V++]), o = (r[0] | r[1] | r[2] | r[3]) === 0, n = 6); let f; typeof e == "string" ? (!s.mask || o) && s[v] !== void 0 ? f = s[v] : (e = Buffer.from(e), f = e.length) : (f = e.length, i = s.mask && s.readOnly && !o); let l = f; f >= 65536 ? (n += 8, l = 127) : f > 125 && (n += 2, l = 126); let a = Buffer.allocUnsafe(i ? f + n : n); return a[0] = s.fin ? s.opcode | 128 : s.opcode, s.rsv1 && (a[0] |= 64), a[1] = l, l === 126 ? a.writeUInt16BE(f, 2) : l === 127 && (a[2] = a[3] = 0, a.writeUIntBE(f, 4, 6)), s.mask ? (a[1] |= 128, a[n - 4] = r[0], a[n - 3] = r[1], a[n - 2] = r[2], a[n - 1] = r[3], o ? [a, e] : i ? (lt(e, r, a, n, f), [a]) : (lt(e, r, e, 0, f), [a, e])) : [a, e]; }
|
|
383
|
+
close(e, s, r, i) { let n; if (e === void 0)
|
|
384
|
+
n = bs;
|
|
385
|
+
else {
|
|
386
|
+
if (typeof e != "number" || !ks(e))
|
|
387
|
+
throw new TypeError("First argument must be a valid error code number");
|
|
388
|
+
if (s === void 0 || !s.length)
|
|
389
|
+
n = Buffer.allocUnsafe(2), n.writeUInt16BE(e, 0);
|
|
390
|
+
else {
|
|
391
|
+
let f = Buffer.byteLength(s);
|
|
392
|
+
if (f > 123)
|
|
393
|
+
throw new RangeError("The message must not be greater than 123 bytes");
|
|
394
|
+
if (n = Buffer.allocUnsafe(2 + f), n.writeUInt16BE(e, 0), typeof s == "string")
|
|
395
|
+
n.write(s, 2);
|
|
396
|
+
else if (Es(s))
|
|
397
|
+
n.set(s, 2);
|
|
398
|
+
else
|
|
399
|
+
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
400
|
+
}
|
|
401
|
+
} let o = { [v]: n.length, fin: !0, generateMask: this._generateMask, mask: r, maskBuffer: this._maskBuffer, opcode: 8, readOnly: !1, rsv1: !1 }; this._state !== w ? this.enqueue([this.dispatch, n, !1, o, i]) : this.sendFrame(t.frame(n, o), i); }
|
|
402
|
+
ping(e, s, r) { let i, n; if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : j(e) ? (i = e.size, n = !1) : (e = R(e), i = e.length, n = R.readOnly), i > 125)
|
|
403
|
+
throw new RangeError("The data size must not be greater than 125 bytes"); let o = { [v]: i, fin: !0, generateMask: this._generateMask, mask: s, maskBuffer: this._maskBuffer, opcode: 9, readOnly: n, rsv1: !1 }; j(e) ? this._state !== w ? this.enqueue([this.getBlobData, e, !1, o, r]) : this.getBlobData(e, !1, o, r) : this._state !== w ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(t.frame(e, o), r); }
|
|
404
|
+
pong(e, s, r) { let i, n; if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : j(e) ? (i = e.size, n = !1) : (e = R(e), i = e.length, n = R.readOnly), i > 125)
|
|
405
|
+
throw new RangeError("The data size must not be greater than 125 bytes"); let o = { [v]: i, fin: !0, generateMask: this._generateMask, mask: s, maskBuffer: this._maskBuffer, opcode: 10, readOnly: n, rsv1: !1 }; j(e) ? this._state !== w ? this.enqueue([this.getBlobData, e, !1, o, r]) : this.getBlobData(e, !1, o, r) : this._state !== w ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(t.frame(e, o), r); }
|
|
406
|
+
send(e, s, r) { let i = this._extensions[ft.extensionName], n = s.binary ? 2 : 1, o = s.compress, f, l; typeof e == "string" ? (f = Buffer.byteLength(e), l = !1) : j(e) ? (f = e.size, l = !1) : (e = R(e), f = e.length, l = R.readOnly), this._firstFragment ? (this._firstFragment = !1, o && i && i.params[i._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (o = f >= i._threshold), this._compress = o) : (o = !1, n = 0), s.fin && (this._firstFragment = !0); let a = { [v]: f, fin: s.fin, generateMask: this._generateMask, mask: s.mask, maskBuffer: this._maskBuffer, opcode: n, readOnly: l, rsv1: o }; j(e) ? this._state !== w ? this.enqueue([this.getBlobData, e, this._compress, a, r]) : this.getBlobData(e, this._compress, a, r) : this._state !== w ? this.enqueue([this.dispatch, e, this._compress, a, r]) : this.dispatch(e, this._compress, a, r); }
|
|
407
|
+
getBlobData(e, s, r, i) { this._bufferedBytes += r[v], this._state = Cs, e.arrayBuffer().then(n => { if (this._socket.destroyed) {
|
|
408
|
+
let f = new Error("The socket was closed while the blob was being read");
|
|
409
|
+
process.nextTick(Le, this, f, i);
|
|
410
|
+
return;
|
|
411
|
+
} this._bufferedBytes -= r[v]; let o = R(n); s ? this.dispatch(o, s, r, i) : (this._state = w, this.sendFrame(t.frame(o, r), i), this.dequeue()); }).catch(n => { process.nextTick(Ls, this, n, i); }); }
|
|
412
|
+
dispatch(e, s, r, i) { if (!s) {
|
|
413
|
+
this.sendFrame(t.frame(e, r), i);
|
|
414
|
+
return;
|
|
415
|
+
} let n = this._extensions[ft.extensionName]; this._bufferedBytes += r[v], this._state = Ts, n.compress(e, r.fin, (o, f) => { if (this._socket.destroyed) {
|
|
416
|
+
let l = new Error("The socket was closed while data was being compressed");
|
|
417
|
+
Le(this, l, i);
|
|
418
|
+
return;
|
|
419
|
+
} this._bufferedBytes -= r[v], this._state = w, r.readOnly = !1, this.sendFrame(t.frame(f, r), i), this.dequeue(); }); }
|
|
420
|
+
dequeue() { for (; this._state === w && this._queue.length;) {
|
|
421
|
+
let e = this._queue.shift();
|
|
422
|
+
this._bufferedBytes -= e[3][v], Reflect.apply(e[0], this, e.slice(1));
|
|
423
|
+
} }
|
|
424
|
+
enqueue(e) { this._bufferedBytes += e[3][v], this._queue.push(e); }
|
|
425
|
+
sendFrame(e, s) { e.length === 2 ? (this._socket.cork(), this._socket.write(e[0]), this._socket.write(e[1], s), this._socket.uncork()) : this._socket.write(e[0], s); }
|
|
426
|
+
};
|
|
427
|
+
ht.exports = Ce;
|
|
428
|
+
function Le(t, e, s) { typeof s == "function" && s(e); for (let r = 0; r < t._queue.length; r++) {
|
|
429
|
+
let i = t._queue[r], n = i[i.length - 1];
|
|
430
|
+
typeof n == "function" && n(e);
|
|
431
|
+
} }
|
|
432
|
+
function Ls(t, e, s) { Le(t, e, s), t.onerror(e); }
|
|
433
|
+
});
|
|
434
|
+
var xt = S((Fr, yt) => {
|
|
435
|
+
"use strict";
|
|
436
|
+
var { kForOnEventAttribute: Q, kListener: Pe } = O(), ct = Symbol("kCode"), ut = Symbol("kData"), dt = Symbol("kError"), _t = Symbol("kMessage"), mt = Symbol("kReason"), z = Symbol("kTarget"), pt = Symbol("kType"), gt = Symbol("kWasClean"), C = class {
|
|
437
|
+
constructor(e) { this[z] = null, this[pt] = e; }
|
|
438
|
+
get target() { return this[z]; }
|
|
439
|
+
get type() { return this[pt]; }
|
|
440
|
+
};
|
|
441
|
+
Object.defineProperty(C.prototype, "target", { enumerable: !0 });
|
|
442
|
+
Object.defineProperty(C.prototype, "type", { enumerable: !0 });
|
|
443
|
+
var I = class extends C {
|
|
444
|
+
constructor(e, s = {}) { super(e), this[ct] = s.code === void 0 ? 0 : s.code, this[mt] = s.reason === void 0 ? "" : s.reason, this[gt] = s.wasClean === void 0 ? !1 : s.wasClean; }
|
|
445
|
+
get code() { return this[ct]; }
|
|
446
|
+
get reason() { return this[mt]; }
|
|
447
|
+
get wasClean() { return this[gt]; }
|
|
448
|
+
};
|
|
449
|
+
Object.defineProperty(I.prototype, "code", { enumerable: !0 });
|
|
450
|
+
Object.defineProperty(I.prototype, "reason", { enumerable: !0 });
|
|
451
|
+
Object.defineProperty(I.prototype, "wasClean", { enumerable: !0 });
|
|
452
|
+
var H = class extends C {
|
|
453
|
+
constructor(e, s = {}) { super(e), this[dt] = s.error === void 0 ? null : s.error, this[_t] = s.message === void 0 ? "" : s.message; }
|
|
454
|
+
get error() { return this[dt]; }
|
|
455
|
+
get message() { return this[_t]; }
|
|
456
|
+
};
|
|
457
|
+
Object.defineProperty(H.prototype, "error", { enumerable: !0 });
|
|
458
|
+
Object.defineProperty(H.prototype, "message", { enumerable: !0 });
|
|
459
|
+
var J = class extends C {
|
|
460
|
+
constructor(e, s = {}) { super(e), this[ut] = s.data === void 0 ? null : s.data; }
|
|
461
|
+
get data() { return this[ut]; }
|
|
462
|
+
};
|
|
463
|
+
Object.defineProperty(J.prototype, "data", { enumerable: !0 });
|
|
464
|
+
var Ns = { addEventListener(t, e, s = {}) { for (let i of this.listeners(t))
|
|
465
|
+
if (!s[Q] && i[Pe] === e && !i[Q])
|
|
466
|
+
return; let r; if (t === "message")
|
|
467
|
+
r = function (n, o) { let f = new J("message", { data: o ? n : n.toString() }); f[z] = this, fe(e, this, f); };
|
|
468
|
+
else if (t === "close")
|
|
469
|
+
r = function (n, o) { let f = new I("close", { code: n, reason: o.toString(), wasClean: this._closeFrameReceived && this._closeFrameSent }); f[z] = this, fe(e, this, f); };
|
|
470
|
+
else if (t === "error")
|
|
471
|
+
r = function (n) { let o = new H("error", { error: n, message: n.message }); o[z] = this, fe(e, this, o); };
|
|
472
|
+
else if (t === "open")
|
|
473
|
+
r = function () { let n = new C("open"); n[z] = this, fe(e, this, n); };
|
|
474
|
+
else
|
|
475
|
+
return; r[Q] = !!s[Q], r[Pe] = e, s.once ? this.once(t, r) : this.on(t, r); }, removeEventListener(t, e) { for (let s of this.listeners(t))
|
|
476
|
+
if (s[Pe] === e && !s[Q]) {
|
|
477
|
+
this.removeListener(t, s);
|
|
478
|
+
break;
|
|
479
|
+
} } };
|
|
480
|
+
yt.exports = { CloseEvent: I, ErrorEvent: H, Event: C, EventTarget: Ns, MessageEvent: J };
|
|
481
|
+
function fe(t, e, s) { typeof t == "object" && t.handleEvent ? t.handleEvent.call(t, s) : t.call(e, s); }
|
|
482
|
+
});
|
|
483
|
+
var le = S((Mr, St) => {
|
|
484
|
+
"use strict";
|
|
485
|
+
var { tokenChars: ee } = $();
|
|
486
|
+
function k(t, e, s) { t[e] === void 0 ? t[e] = [s] : t[e].push(s); }
|
|
487
|
+
function Ps(t) { let e = Object.create(null), s = Object.create(null), r = !1, i = !1, n = !1, o, f, l = -1, a = -1, h = -1, c = 0; for (; c < t.length; c++)
|
|
488
|
+
if (a = t.charCodeAt(c), o === void 0)
|
|
489
|
+
if (h === -1 && ee[a] === 1)
|
|
490
|
+
l === -1 && (l = c);
|
|
491
|
+
else if (c !== 0 && (a === 32 || a === 9))
|
|
492
|
+
h === -1 && l !== -1 && (h = c);
|
|
493
|
+
else if (a === 59 || a === 44) {
|
|
494
|
+
if (l === -1)
|
|
495
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
496
|
+
h === -1 && (h = c);
|
|
497
|
+
let p = t.slice(l, h);
|
|
498
|
+
a === 44 ? (k(e, p, s), s = Object.create(null)) : o = p, l = h = -1;
|
|
499
|
+
}
|
|
500
|
+
else
|
|
501
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
502
|
+
else if (f === void 0)
|
|
503
|
+
if (h === -1 && ee[a] === 1)
|
|
504
|
+
l === -1 && (l = c);
|
|
505
|
+
else if (a === 32 || a === 9)
|
|
506
|
+
h === -1 && l !== -1 && (h = c);
|
|
507
|
+
else if (a === 59 || a === 44) {
|
|
508
|
+
if (l === -1)
|
|
509
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
510
|
+
h === -1 && (h = c), k(s, t.slice(l, h), !0), a === 44 && (k(e, o, s), s = Object.create(null), o = void 0), l = h = -1;
|
|
511
|
+
}
|
|
512
|
+
else if (a === 61 && l !== -1 && h === -1)
|
|
513
|
+
f = t.slice(l, c), l = h = -1;
|
|
514
|
+
else
|
|
515
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
516
|
+
else if (i) {
|
|
517
|
+
if (ee[a] !== 1)
|
|
518
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
519
|
+
l === -1 ? l = c : r || (r = !0), i = !1;
|
|
520
|
+
}
|
|
521
|
+
else if (n)
|
|
522
|
+
if (ee[a] === 1)
|
|
523
|
+
l === -1 && (l = c);
|
|
524
|
+
else if (a === 34 && l !== -1)
|
|
525
|
+
n = !1, h = c;
|
|
526
|
+
else if (a === 92)
|
|
527
|
+
i = !0;
|
|
528
|
+
else
|
|
529
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
530
|
+
else if (a === 34 && t.charCodeAt(c - 1) === 61)
|
|
531
|
+
n = !0;
|
|
532
|
+
else if (h === -1 && ee[a] === 1)
|
|
533
|
+
l === -1 && (l = c);
|
|
534
|
+
else if (l !== -1 && (a === 32 || a === 9))
|
|
535
|
+
h === -1 && (h = c);
|
|
536
|
+
else if (a === 59 || a === 44) {
|
|
537
|
+
if (l === -1)
|
|
538
|
+
throw new SyntaxError(`Unexpected character at index ${c}`);
|
|
539
|
+
h === -1 && (h = c);
|
|
540
|
+
let p = t.slice(l, h);
|
|
541
|
+
r && (p = p.replace(/\\/g, ""), r = !1), k(s, f, p), a === 44 && (k(e, o, s), s = Object.create(null), o = void 0), f = void 0, l = h = -1;
|
|
542
|
+
}
|
|
543
|
+
else
|
|
544
|
+
throw new SyntaxError(`Unexpected character at index ${c}`); if (l === -1 || n || a === 32 || a === 9)
|
|
545
|
+
throw new SyntaxError("Unexpected end of input"); h === -1 && (h = c); let _ = t.slice(l, h); return o === void 0 ? k(e, _, s) : (f === void 0 ? k(s, _, !0) : r ? k(s, f, _.replace(/\\/g, "")) : k(s, f, _), k(e, o, s)), e; }
|
|
546
|
+
function Bs(t) { return Object.keys(t).map(e => { let s = t[e]; return Array.isArray(s) || (s = [s]), s.map(r => [e].concat(Object.keys(r).map(i => { let n = r[i]; return Array.isArray(n) || (n = [n]), n.map(o => o === !0 ? i : `${i}=${o}`).join("; "); })).join("; ")).join(", "); }).join(", "); }
|
|
547
|
+
St.exports = { format: Bs, parse: Ps };
|
|
548
|
+
});
|
|
549
|
+
var de = S((qr, Bt) => {
|
|
550
|
+
"use strict";
|
|
551
|
+
var Rs = g("events"), Us = g("https"), Is = g("http"), vt = g("net"), Ds = g("tls"), { randomBytes: Fs, createHash: Ms } = g("crypto"), { Duplex: Ar, Readable: Wr } = g("stream"), { URL: Be } = g("url"), B = G(), As = Te(), Ws = Ne(), { isBlob: qs } = $(), { BINARY_TYPES: Et, CLOSE_TIMEOUT: Gs, EMPTY_BUFFER: he, GUID: $s, kForOnEventAttribute: Re, kListener: js, kStatusCode: Vs, kWebSocket: y, NOOP: wt } = O(), { EventTarget: { addEventListener: zs, removeEventListener: Hs } } = xt(), { format: Ys, parse: Ks } = le(), { toBuffer: Xs } = X(), kt = Symbol("kAborted"), Ue = [8, 13], L = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], Zs = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/, d = class t extends Rs {
|
|
552
|
+
constructor(e, s, r) { super(), this._binaryType = Et[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = he, this._closeTimer = null, this._errorEmitted = !1, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = t.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, e !== null ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, s === void 0 ? s = [] : Array.isArray(s) || (typeof s == "object" && s !== null ? (r = s, s = []) : s = [s]), Ot(this, e, s, r)) : (this._autoPong = r.autoPong, this._closeTimeout = r.closeTimeout, this._isServer = !0); }
|
|
553
|
+
get binaryType() { return this._binaryType; }
|
|
554
|
+
set binaryType(e) { Et.includes(e) && (this._binaryType = e, this._receiver && (this._receiver._binaryType = e)); }
|
|
555
|
+
get bufferedAmount() { return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount; }
|
|
556
|
+
get extensions() { return Object.keys(this._extensions).join(); }
|
|
557
|
+
get isPaused() { return this._paused; }
|
|
558
|
+
get onclose() { return null; }
|
|
559
|
+
get onerror() { return null; }
|
|
560
|
+
get onopen() { return null; }
|
|
561
|
+
get onmessage() { return null; }
|
|
562
|
+
get protocol() { return this._protocol; }
|
|
563
|
+
get readyState() { return this._readyState; }
|
|
564
|
+
get url() { return this._url; }
|
|
565
|
+
setSocket(e, s, r) { let i = new As({ allowSynchronousEvents: r.allowSynchronousEvents, binaryType: this.binaryType, extensions: this._extensions, isServer: this._isServer, maxBufferedChunks: r.maxBufferedChunks, maxFragments: r.maxFragments, maxPayload: r.maxPayload, skipUTF8Validation: r.skipUTF8Validation }), n = new Ws(e, this._extensions, r.generateMask); this._receiver = i, this._sender = n, this._socket = e, i[y] = this, n[y] = this, e[y] = this, i.on("conclude", er), i.on("drain", tr), i.on("error", sr), i.on("message", rr), i.on("ping", ir), i.on("pong", nr), n.onerror = or, e.setTimeout && e.setTimeout(0), e.setNoDelay && e.setNoDelay(), s.length > 0 && e.unshift(s), e.on("close", Lt), e.on("data", ue), e.on("end", Nt), e.on("error", Pt), this._readyState = t.OPEN, this.emit("open"); }
|
|
566
|
+
emitClose() { if (!this._socket) {
|
|
567
|
+
this._readyState = t.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
|
568
|
+
return;
|
|
569
|
+
} this._extensions[B.extensionName] && this._extensions[B.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = t.CLOSED, this.emit("close", this._closeCode, this._closeMessage); }
|
|
570
|
+
close(e, s) { if (this.readyState !== t.CLOSED) {
|
|
571
|
+
if (this.readyState === t.CONNECTING) {
|
|
572
|
+
E(this, this._req, "WebSocket was closed before the connection was established");
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (this.readyState === t.CLOSING) {
|
|
576
|
+
this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
this._readyState = t.CLOSING, this._sender.close(e, s, !this._isServer, r => { r || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end()); }), Ct(this);
|
|
580
|
+
} }
|
|
581
|
+
pause() { this.readyState === t.CONNECTING || this.readyState === t.CLOSED || (this._paused = !0, this._socket.pause()); }
|
|
582
|
+
ping(e, s, r) { if (this.readyState === t.CONNECTING)
|
|
583
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); if (typeof e == "function" ? (r = e, e = s = void 0) : typeof s == "function" && (r = s, s = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== t.OPEN) {
|
|
584
|
+
Ie(this, e, r);
|
|
585
|
+
return;
|
|
586
|
+
} s === void 0 && (s = !this._isServer), this._sender.ping(e || he, s, r); }
|
|
587
|
+
pong(e, s, r) { if (this.readyState === t.CONNECTING)
|
|
588
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); if (typeof e == "function" ? (r = e, e = s = void 0) : typeof s == "function" && (r = s, s = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== t.OPEN) {
|
|
589
|
+
Ie(this, e, r);
|
|
590
|
+
return;
|
|
591
|
+
} s === void 0 && (s = !this._isServer), this._sender.pong(e || he, s, r); }
|
|
592
|
+
resume() { this.readyState === t.CONNECTING || this.readyState === t.CLOSED || (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume()); }
|
|
593
|
+
send(e, s, r) { if (this.readyState === t.CONNECTING)
|
|
594
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); if (typeof s == "function" && (r = s, s = {}), typeof e == "number" && (e = e.toString()), this.readyState !== t.OPEN) {
|
|
595
|
+
Ie(this, e, r);
|
|
596
|
+
return;
|
|
597
|
+
} let i = { binary: typeof e != "string", mask: !this._isServer, compress: !0, fin: !0, ...s }; this._extensions[B.extensionName] || (i.compress = !1), this._sender.send(e || he, i, r); }
|
|
598
|
+
terminate() { if (this.readyState !== t.CLOSED) {
|
|
599
|
+
if (this.readyState === t.CONNECTING) {
|
|
600
|
+
E(this, this._req, "WebSocket was closed before the connection was established");
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
this._socket && (this._readyState = t.CLOSING, this._socket.destroy());
|
|
604
|
+
} }
|
|
605
|
+
};
|
|
606
|
+
Object.defineProperty(d, "CONNECTING", { enumerable: !0, value: L.indexOf("CONNECTING") });
|
|
607
|
+
Object.defineProperty(d.prototype, "CONNECTING", { enumerable: !0, value: L.indexOf("CONNECTING") });
|
|
608
|
+
Object.defineProperty(d, "OPEN", { enumerable: !0, value: L.indexOf("OPEN") });
|
|
609
|
+
Object.defineProperty(d.prototype, "OPEN", { enumerable: !0, value: L.indexOf("OPEN") });
|
|
610
|
+
Object.defineProperty(d, "CLOSING", { enumerable: !0, value: L.indexOf("CLOSING") });
|
|
611
|
+
Object.defineProperty(d.prototype, "CLOSING", { enumerable: !0, value: L.indexOf("CLOSING") });
|
|
612
|
+
Object.defineProperty(d, "CLOSED", { enumerable: !0, value: L.indexOf("CLOSED") });
|
|
613
|
+
Object.defineProperty(d.prototype, "CLOSED", { enumerable: !0, value: L.indexOf("CLOSED") });
|
|
614
|
+
["binaryType", "bufferedAmount", "extensions", "isPaused", "protocol", "readyState", "url"].forEach(t => { Object.defineProperty(d.prototype, t, { enumerable: !0 }); });
|
|
615
|
+
["open", "error", "close", "message"].forEach(t => { Object.defineProperty(d.prototype, `on${t}`, { enumerable: !0, get() { for (let e of this.listeners(t))
|
|
616
|
+
if (e[Re])
|
|
617
|
+
return e[js]; return null; }, set(e) { for (let s of this.listeners(t))
|
|
618
|
+
if (s[Re]) {
|
|
619
|
+
this.removeListener(t, s);
|
|
620
|
+
break;
|
|
621
|
+
} typeof e == "function" && this.addEventListener(t, e, { [Re]: !0 }); } }); });
|
|
622
|
+
d.prototype.addEventListener = zs;
|
|
623
|
+
d.prototype.removeEventListener = Hs;
|
|
624
|
+
Bt.exports = d;
|
|
625
|
+
function Ot(t, e, s, r) { let i = { allowSynchronousEvents: !0, autoPong: !0, closeTimeout: Gs, protocolVersion: Ue[1], maxBufferedChunks: 262144, maxFragments: 16384, maxPayload: 104857600, skipUTF8Validation: !1, perMessageDeflate: !0, followRedirects: !1, maxRedirects: 10, ...r, socketPath: void 0, hostname: void 0, protocol: void 0, timeout: void 0, method: "GET", host: void 0, path: void 0, port: void 0 }; if (t._autoPong = i.autoPong, t._closeTimeout = i.closeTimeout, !Ue.includes(i.protocolVersion))
|
|
626
|
+
throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Ue.join(", ")})`); let n; if (e instanceof Be)
|
|
627
|
+
n = e;
|
|
628
|
+
else
|
|
629
|
+
try {
|
|
630
|
+
n = new Be(e);
|
|
631
|
+
}
|
|
632
|
+
catch {
|
|
633
|
+
throw new SyntaxError(`Invalid URL: ${e}`);
|
|
634
|
+
} n.protocol === "http:" ? n.protocol = "ws:" : n.protocol === "https:" && (n.protocol = "wss:"), t._url = n.href; let o = n.protocol === "wss:", f = n.protocol === "ws+unix:", l; if (n.protocol !== "ws:" && !o && !f ? l = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"` : f && !n.pathname ? l = "The URL's pathname is empty" : n.hash && (l = "The URL contains a fragment identifier"), l) {
|
|
635
|
+
let u = new SyntaxError(l);
|
|
636
|
+
if (t._redirects === 0)
|
|
637
|
+
throw u;
|
|
638
|
+
ce(t, u);
|
|
639
|
+
return;
|
|
640
|
+
} let a = o ? 443 : 80, h = Fs(16).toString("base64"), c = o ? Us.request : Is.request, _ = new Set, p; if (i.createConnection = i.createConnection || (o ? Js : Qs), i.defaultPort = i.defaultPort || a, i.port = n.port || a, i.host = n.hostname.startsWith("[") ? n.hostname.slice(1, -1) : n.hostname, i.headers = { ...i.headers, "Sec-WebSocket-Version": i.protocolVersion, "Sec-WebSocket-Key": h, Connection: "Upgrade", Upgrade: "websocket" }, i.path = n.pathname + n.search, i.timeout = i.handshakeTimeout, i.perMessageDeflate && (p = new B({ ...i.perMessageDeflate, isServer: !1, maxPayload: i.maxPayload }), i.headers["Sec-WebSocket-Extensions"] = Ys({ [B.extensionName]: p.offer() })), s.length) {
|
|
641
|
+
for (let u of s) {
|
|
642
|
+
if (typeof u != "string" || !Zs.test(u) || _.has(u))
|
|
643
|
+
throw new SyntaxError("An invalid or duplicated subprotocol was specified");
|
|
644
|
+
_.add(u);
|
|
645
|
+
}
|
|
646
|
+
i.headers["Sec-WebSocket-Protocol"] = s.join(",");
|
|
647
|
+
} if (i.origin && (i.protocolVersion < 13 ? i.headers["Sec-WebSocket-Origin"] = i.origin : i.headers.Origin = i.origin), (n.username || n.password) && (i.auth = `${n.username}:${n.password}`), f) {
|
|
648
|
+
let u = i.path.split(":");
|
|
649
|
+
i.socketPath = u[0], i.path = u[1];
|
|
650
|
+
} let m; if (i.followRedirects) {
|
|
651
|
+
if (t._redirects === 0) {
|
|
652
|
+
t._originalIpc = f, t._originalSecure = o, t._originalHostOrSocketPath = f ? i.socketPath : n.host;
|
|
653
|
+
let u = r && r.headers;
|
|
654
|
+
if (r = { ...r, headers: {} }, u)
|
|
655
|
+
for (let [x, M] of Object.entries(u))
|
|
656
|
+
r.headers[x.toLowerCase()] = M;
|
|
657
|
+
}
|
|
658
|
+
else if (t.listenerCount("redirect") === 0) {
|
|
659
|
+
let u = f ? t._originalIpc ? i.socketPath === t._originalHostOrSocketPath : !1 : t._originalIpc ? !1 : n.host === t._originalHostOrSocketPath;
|
|
660
|
+
(!u || t._originalSecure && !o) && (delete i.headers.authorization, delete i.headers.cookie, u || delete i.headers.host, i.auth = void 0);
|
|
661
|
+
}
|
|
662
|
+
i.auth && !r.headers.authorization && (r.headers.authorization = "Basic " + Buffer.from(i.auth).toString("base64")), m = t._req = c(i), t._redirects && t.emit("redirect", t.url, m);
|
|
663
|
+
}
|
|
664
|
+
else
|
|
665
|
+
m = t._req = c(i); i.timeout && m.on("timeout", () => { E(t, m, "Opening handshake has timed out"); }), m.on("error", u => { m === null || m[kt] || (m = t._req = null, ce(t, u)); }), m.on("response", u => { let x = u.headers.location, M = u.statusCode; if (x && i.followRedirects && M >= 300 && M < 400) {
|
|
666
|
+
if (++t._redirects > i.maxRedirects) {
|
|
667
|
+
E(t, m, "Maximum redirects exceeded");
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
m.abort();
|
|
671
|
+
let Y;
|
|
672
|
+
try {
|
|
673
|
+
Y = new Be(x, e);
|
|
674
|
+
}
|
|
675
|
+
catch {
|
|
676
|
+
let A = new SyntaxError(`Invalid URL: ${x}`);
|
|
677
|
+
ce(t, A);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
Ot(t, Y, s, r);
|
|
681
|
+
}
|
|
682
|
+
else
|
|
683
|
+
t.emit("unexpected-response", m, u) || E(t, m, `Unexpected server response: ${u.statusCode}`); }), m.on("upgrade", (u, x, M) => { if (t.emit("upgrade", u), t.readyState !== d.CONNECTING)
|
|
684
|
+
return; m = t._req = null; let Y = u.headers.upgrade; if (Y === void 0 || Y.toLowerCase() !== "websocket") {
|
|
685
|
+
E(t, x, "Invalid Upgrade header");
|
|
686
|
+
return;
|
|
687
|
+
} let Me = Ms("sha1").update(h + $s).digest("base64"); if (u.headers["sec-websocket-accept"] !== Me) {
|
|
688
|
+
E(t, x, "Invalid Sec-WebSocket-Accept header");
|
|
689
|
+
return;
|
|
690
|
+
} let A = u.headers["sec-websocket-protocol"], K; if (A !== void 0 ? _.size ? _.has(A) || (K = "Server sent an invalid subprotocol") : K = "Server sent a subprotocol but none was requested" : _.size && (K = "Server sent no subprotocol"), K) {
|
|
691
|
+
E(t, x, K);
|
|
692
|
+
return;
|
|
693
|
+
} A && (t._protocol = A); let Ae = u.headers["sec-websocket-extensions"]; if (Ae !== void 0) {
|
|
694
|
+
if (!p) {
|
|
695
|
+
E(t, x, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
let me;
|
|
699
|
+
try {
|
|
700
|
+
me = Ks(Ae);
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
E(t, x, "Invalid Sec-WebSocket-Extensions header");
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
let We = Object.keys(me);
|
|
707
|
+
if (We.length !== 1 || We[0] !== B.extensionName) {
|
|
708
|
+
E(t, x, "Server indicated an extension that was not requested");
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
try {
|
|
712
|
+
p.accept(me[B.extensionName]);
|
|
713
|
+
}
|
|
714
|
+
catch {
|
|
715
|
+
E(t, x, "Invalid Sec-WebSocket-Extensions header");
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
t._extensions[B.extensionName] = p;
|
|
719
|
+
} t.setSocket(x, M, { allowSynchronousEvents: i.allowSynchronousEvents, generateMask: i.generateMask, maxBufferedChunks: i.maxBufferedChunks, maxFragments: i.maxFragments, maxPayload: i.maxPayload, skipUTF8Validation: i.skipUTF8Validation }); }), i.finishRequest ? i.finishRequest(m, t) : m.end(); }
|
|
720
|
+
function ce(t, e) { t._readyState = d.CLOSING, t._errorEmitted = !0, t.emit("error", e), t.emitClose(); }
|
|
721
|
+
function Qs(t) { return t.path = t.socketPath, vt.connect(t); }
|
|
722
|
+
function Js(t) { return t.path = void 0, !t.servername && t.servername !== "" && (t.servername = vt.isIP(t.host) ? "" : t.host), Ds.connect(t); }
|
|
723
|
+
function E(t, e, s) { t._readyState = d.CLOSING; let r = new Error(s); Error.captureStackTrace(r, E), e.setHeader ? (e[kt] = !0, e.abort(), e.socket && !e.socket.destroyed && e.socket.destroy(), process.nextTick(ce, t, r)) : (e.destroy(r), e.once("error", t.emit.bind(t, "error")), e.once("close", t.emitClose.bind(t))); }
|
|
724
|
+
function Ie(t, e, s) { if (e) {
|
|
725
|
+
let r = qs(e) ? e.size : Xs(e).length;
|
|
726
|
+
t._socket ? t._sender._bufferedBytes += r : t._bufferedAmount += r;
|
|
727
|
+
} if (s) {
|
|
728
|
+
let r = new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);
|
|
729
|
+
process.nextTick(s, r);
|
|
730
|
+
} }
|
|
731
|
+
function er(t, e) { let s = this[y]; s._closeFrameReceived = !0, s._closeMessage = e, s._closeCode = t, s._socket[y] !== void 0 && (s._socket.removeListener("data", ue), process.nextTick(Tt, s._socket), t === 1005 ? s.close() : s.close(t, e)); }
|
|
732
|
+
function tr() { let t = this[y]; t.isPaused || t._socket.resume(); }
|
|
733
|
+
function sr(t) { let e = this[y]; e._socket[y] !== void 0 && (e._socket.removeListener("data", ue), process.nextTick(Tt, e._socket), e.close(t[Vs])), e._errorEmitted || (e._errorEmitted = !0, e.emit("error", t)); }
|
|
734
|
+
function bt() { this[y].emitClose(); }
|
|
735
|
+
function rr(t, e) { this[y].emit("message", t, e); }
|
|
736
|
+
function ir(t) { let e = this[y]; e._autoPong && e.pong(t, !this._isServer, wt), e.emit("ping", t); }
|
|
737
|
+
function nr(t) { this[y].emit("pong", t); }
|
|
738
|
+
function Tt(t) { t.resume(); }
|
|
739
|
+
function or(t) { let e = this[y]; e.readyState !== d.CLOSED && (e.readyState === d.OPEN && (e._readyState = d.CLOSING, Ct(e)), this._socket.end(), e._errorEmitted || (e._errorEmitted = !0, e.emit("error", t))); }
|
|
740
|
+
function Ct(t) { t._closeTimer = setTimeout(t._socket.destroy.bind(t._socket), t._closeTimeout); }
|
|
741
|
+
function Lt() { let t = this[y]; if (this.removeListener("close", Lt), this.removeListener("data", ue), this.removeListener("end", Nt), t._readyState = d.CLOSING, !this._readableState.endEmitted && !t._closeFrameReceived && !t._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
742
|
+
let e = this.read(this._readableState.length);
|
|
743
|
+
t._receiver.write(e);
|
|
744
|
+
} t._receiver.end(), this[y] = void 0, clearTimeout(t._closeTimer), t._receiver._writableState.finished || t._receiver._writableState.errorEmitted ? t.emitClose() : (t._receiver.on("error", bt), t._receiver.on("finish", bt)); }
|
|
745
|
+
function ue(t) { this[y]._receiver.write(t) || this.pause(); }
|
|
746
|
+
function Nt() { let t = this[y]; t._readyState = d.CLOSING, t._receiver.end(), this.end(); }
|
|
747
|
+
function Pt() { let t = this[y]; this.removeListener("error", Pt), this.on("error", wt), t && (t._readyState = d.CLOSING, this.destroy()); }
|
|
748
|
+
});
|
|
749
|
+
var Dt = S(($r, It) => {
|
|
750
|
+
"use strict";
|
|
751
|
+
var Gr = de(), { Duplex: ar } = g("stream");
|
|
752
|
+
function Rt(t) { t.emit("close"); }
|
|
753
|
+
function fr() { !this.destroyed && this._writableState.finished && this.destroy(); }
|
|
754
|
+
function Ut(t) { this.removeListener("error", Ut), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", t); }
|
|
755
|
+
function lr(t, e) { let s = !0, r = new ar({ ...e, autoDestroy: !1, emitClose: !1, objectMode: !1, writableObjectMode: !1 }); return t.on("message", function (n, o) { let f = !o && r._readableState.objectMode ? n.toString() : n; r.push(f) || t.pause(); }), t.once("error", function (n) { r.destroyed || (s = !1, r.destroy(n)); }), t.once("close", function () { r.destroyed || r.push(null); }), r._destroy = function (i, n) { if (t.readyState === t.CLOSED) {
|
|
756
|
+
n(i), process.nextTick(Rt, r);
|
|
757
|
+
return;
|
|
758
|
+
} let o = !1; t.once("error", function (l) { o = !0, n(l); }), t.once("close", function () { o || n(i), process.nextTick(Rt, r); }), s && t.terminate(); }, r._final = function (i) { if (t.readyState === t.CONNECTING) {
|
|
759
|
+
t.once("open", function () { r._final(i); });
|
|
760
|
+
return;
|
|
761
|
+
} t._socket !== null && (t._socket._writableState.finished ? (i(), r._readableState.endEmitted && r.destroy()) : (t._socket.once("finish", function () { i(); }), t.close())); }, r._read = function () { t.isPaused && t.resume(); }, r._write = function (i, n, o) { if (t.readyState === t.CONNECTING) {
|
|
762
|
+
t.once("open", function () { r._write(i, n, o); });
|
|
763
|
+
return;
|
|
764
|
+
} t.send(i, o); }, r.on("end", fr), r.on("error", Ut), r; }
|
|
765
|
+
It.exports = lr;
|
|
766
|
+
});
|
|
767
|
+
var De = S((jr, Ft) => {
|
|
768
|
+
"use strict";
|
|
769
|
+
var { tokenChars: hr } = $();
|
|
770
|
+
function cr(t) { let e = new Set, s = -1, r = -1, i = 0; for (i; i < t.length; i++) {
|
|
771
|
+
let o = t.charCodeAt(i);
|
|
772
|
+
if (r === -1 && hr[o] === 1)
|
|
773
|
+
s === -1 && (s = i);
|
|
774
|
+
else if (i !== 0 && (o === 32 || o === 9))
|
|
775
|
+
r === -1 && s !== -1 && (r = i);
|
|
776
|
+
else if (o === 44) {
|
|
777
|
+
if (s === -1)
|
|
778
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
779
|
+
r === -1 && (r = i);
|
|
780
|
+
let f = t.slice(s, r);
|
|
781
|
+
if (e.has(f))
|
|
782
|
+
throw new SyntaxError(`The "${f}" subprotocol is duplicated`);
|
|
783
|
+
e.add(f), s = r = -1;
|
|
784
|
+
}
|
|
785
|
+
else
|
|
786
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
787
|
+
} if (s === -1 || r !== -1)
|
|
788
|
+
throw new SyntaxError("Unexpected end of input"); let n = t.slice(s, i); if (e.has(n))
|
|
789
|
+
throw new SyntaxError(`The "${n}" subprotocol is duplicated`); return e.add(n), e; }
|
|
790
|
+
Ft.exports = { parse: cr };
|
|
791
|
+
});
|
|
792
|
+
var jt = S((zr, $t) => {
|
|
793
|
+
"use strict";
|
|
794
|
+
var ur = g("events"), _e = g("http"), { Duplex: Vr } = g("stream"), { createHash: dr } = g("crypto"), Mt = le(), D = G(), _r = De(), mr = de(), { CLOSE_TIMEOUT: pr, GUID: gr, kWebSocket: yr } = O(), xr = /^[+/0-9A-Za-z]{22}==$/, At = 0, Wt = 1, Gt = 2, Fe = class extends ur {
|
|
795
|
+
constructor(e, s) { if (super(), e = { allowSynchronousEvents: !0, autoPong: !0, maxBufferedChunks: 256 * 1024, maxFragments: 16 * 1024, maxPayload: 100 * 1024 * 1024, skipUTF8Validation: !1, perMessageDeflate: !1, handleProtocols: null, clientTracking: !0, closeTimeout: pr, verifyClient: null, noServer: !1, backlog: null, server: null, host: null, path: null, port: null, WebSocket: mr, ...e }, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer)
|
|
796
|
+
throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified'); if (e.port != null ? (this._server = _e.createServer((r, i) => { let n = _e.STATUS_CODES[426]; i.writeHead(426, { "Content-Length": n.length, "Content-Type": "text/plain" }), i.end(n); }), this._server.listen(e.port, e.host, e.backlog, s)) : e.server && (this._server = e.server), this._server) {
|
|
797
|
+
let r = this.emit.bind(this, "connection");
|
|
798
|
+
this._removeListeners = Sr(this._server, { listening: this.emit.bind(this, "listening"), error: this.emit.bind(this, "error"), upgrade: (i, n, o) => { this.handleUpgrade(i, n, o, r); } });
|
|
799
|
+
} e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = new Set, this._shouldEmitClose = !1), this.options = e, this._state = At; }
|
|
800
|
+
address() { if (this.options.noServer)
|
|
801
|
+
throw new Error('The server is operating in "noServer" mode'); return this._server ? this._server.address() : null; }
|
|
802
|
+
close(e) { if (this._state === Gt) {
|
|
803
|
+
e && this.once("close", () => { e(new Error("The server is not running")); }), process.nextTick(te, this);
|
|
804
|
+
return;
|
|
805
|
+
} if (e && this.once("close", e), this._state !== Wt)
|
|
806
|
+
if (this._state = Wt, this.options.noServer || this.options.server)
|
|
807
|
+
this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients ? this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(te, this) : process.nextTick(te, this);
|
|
808
|
+
else {
|
|
809
|
+
let s = this._server;
|
|
810
|
+
this._removeListeners(), this._removeListeners = this._server = null, s.close(() => { te(this); });
|
|
811
|
+
} }
|
|
812
|
+
shouldHandle(e) { if (this.options.path) {
|
|
813
|
+
let s = e.url.indexOf("?");
|
|
814
|
+
if ((s !== -1 ? e.url.slice(0, s) : e.url) !== this.options.path)
|
|
815
|
+
return !1;
|
|
816
|
+
} return !0; }
|
|
817
|
+
handleUpgrade(e, s, r, i) { s.on("error", qt); let n = e.headers["sec-websocket-key"], o = e.headers.upgrade, f = +e.headers["sec-websocket-version"]; if (e.method !== "GET") {
|
|
818
|
+
F(this, e, s, 405, "Invalid HTTP method");
|
|
819
|
+
return;
|
|
820
|
+
} if (o === void 0 || o.toLowerCase() !== "websocket") {
|
|
821
|
+
F(this, e, s, 400, "Invalid Upgrade header");
|
|
822
|
+
return;
|
|
823
|
+
} if (n === void 0 || !xr.test(n)) {
|
|
824
|
+
F(this, e, s, 400, "Missing or invalid Sec-WebSocket-Key header");
|
|
825
|
+
return;
|
|
826
|
+
} if (f !== 13 && f !== 8) {
|
|
827
|
+
F(this, e, s, 400, "Missing or invalid Sec-WebSocket-Version header", { "Sec-WebSocket-Version": "13, 8" });
|
|
828
|
+
return;
|
|
829
|
+
} if (!this.shouldHandle(e)) {
|
|
830
|
+
se(s, 400);
|
|
831
|
+
return;
|
|
832
|
+
} let l = e.headers["sec-websocket-protocol"], a = new Set; if (l !== void 0)
|
|
833
|
+
try {
|
|
834
|
+
a = _r.parse(l);
|
|
835
|
+
}
|
|
836
|
+
catch {
|
|
837
|
+
F(this, e, s, 400, "Invalid Sec-WebSocket-Protocol header");
|
|
838
|
+
return;
|
|
839
|
+
} let h = e.headers["sec-websocket-extensions"], c = {}; if (this.options.perMessageDeflate && h !== void 0) {
|
|
840
|
+
let _ = new D({ ...this.options.perMessageDeflate, isServer: !0, maxPayload: this.options.maxPayload });
|
|
841
|
+
try {
|
|
842
|
+
let p = Mt.parse(h);
|
|
843
|
+
p[D.extensionName] && (_.accept(p[D.extensionName]), c[D.extensionName] = _);
|
|
844
|
+
}
|
|
845
|
+
catch {
|
|
846
|
+
F(this, e, s, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
} if (this.options.verifyClient) {
|
|
850
|
+
let _ = { origin: e.headers[`${f === 8 ? "sec-websocket-origin" : "origin"}`], secure: !!(e.socket.authorized || e.socket.encrypted), req: e };
|
|
851
|
+
if (this.options.verifyClient.length === 2) {
|
|
852
|
+
this.options.verifyClient(_, (p, m, u, x) => { if (!p)
|
|
853
|
+
return se(s, m || 401, u, x); this.completeUpgrade(c, n, a, e, s, r, i); });
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
if (!this.options.verifyClient(_))
|
|
857
|
+
return se(s, 401);
|
|
858
|
+
} this.completeUpgrade(c, n, a, e, s, r, i); }
|
|
859
|
+
completeUpgrade(e, s, r, i, n, o, f) {
|
|
860
|
+
if (!n.readable || !n.writable)
|
|
861
|
+
return n.destroy();
|
|
862
|
+
if (n[yr])
|
|
863
|
+
throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");
|
|
864
|
+
if (this._state > At)
|
|
865
|
+
return se(n, 503);
|
|
866
|
+
let a = ["HTTP/1.1 101 Switching Protocols", "Upgrade: websocket", "Connection: Upgrade", `Sec-WebSocket-Accept: ${dr("sha1").update(s + gr).digest("base64")}`], h = new this.options.WebSocket(null, void 0, this.options);
|
|
867
|
+
if (r.size) {
|
|
868
|
+
let c = this.options.handleProtocols ? this.options.handleProtocols(r, i) : r.values().next().value;
|
|
869
|
+
c && (a.push(`Sec-WebSocket-Protocol: ${c}`), h._protocol = c);
|
|
870
|
+
}
|
|
871
|
+
if (e[D.extensionName]) {
|
|
872
|
+
let c = e[D.extensionName].params, _ = Mt.format({ [D.extensionName]: [c] });
|
|
873
|
+
a.push(`Sec-WebSocket-Extensions: ${_}`), h._extensions = e;
|
|
874
|
+
}
|
|
875
|
+
this.emit("headers", a, i), n.write(a.concat(`\r
|
|
876
|
+
`).join(`\r
|
|
877
|
+
`)), n.removeListener("error", qt), h.setSocket(n, o, { allowSynchronousEvents: this.options.allowSynchronousEvents, maxBufferedChunks: this.options.maxBufferedChunks, maxFragments: this.options.maxFragments, maxPayload: this.options.maxPayload, skipUTF8Validation: this.options.skipUTF8Validation }), this.clients && (this.clients.add(h), h.on("close", () => { this.clients.delete(h), this._shouldEmitClose && !this.clients.size && process.nextTick(te, this); })), f(h, i);
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
$t.exports = Fe;
|
|
881
|
+
function Sr(t, e) { for (let s of Object.keys(e))
|
|
882
|
+
t.on(s, e[s]); return function () { for (let r of Object.keys(e))
|
|
883
|
+
t.removeListener(r, e[r]); }; }
|
|
884
|
+
function te(t) { t._state = Gt, t.emit("close"); }
|
|
885
|
+
function qt() { this.destroy(); }
|
|
886
|
+
function se(t, e, s, r) {
|
|
887
|
+
s = s || _e.STATUS_CODES[e], r = { Connection: "close", "Content-Type": "text/html", "Content-Length": Buffer.byteLength(s), ...r }, t.once("finish", t.destroy), t.end(`HTTP/1.1 ${e} ${_e.STATUS_CODES[e]}\r
|
|
888
|
+
` + Object.keys(r).map(i => `${i}: ${r[i]}`).join(`\r
|
|
889
|
+
`) + `\r
|
|
890
|
+
\r
|
|
891
|
+
` + s);
|
|
892
|
+
}
|
|
893
|
+
function F(t, e, s, r, i, n) { if (t.listenerCount("wsClientError")) {
|
|
894
|
+
let o = new Error(i);
|
|
895
|
+
Error.captureStackTrace(o, F), t.emit("wsClientError", o, s, e);
|
|
896
|
+
}
|
|
897
|
+
else
|
|
898
|
+
se(s, r, i, n); }
|
|
899
|
+
});
|
|
900
|
+
var Er = N(Dt(), 1), br = N(le(), 1), vr = N(G(), 1), wr = N(Te(), 1), kr = N(Ne(), 1), Or = N(De(), 1), Vt = N(de(), 1), Tr = N(jt(), 1);
|
|
901
|
+
var Hr = Vt.default;
|
|
902
|
+
var export_PerMessageDeflate = vr.default;
|
|
903
|
+
var export_Receiver = wr.default;
|
|
904
|
+
var export_Sender = kr.default;
|
|
905
|
+
var export_WebSocket = Vt.default;
|
|
906
|
+
var export_WebSocketServer = Tr.default;
|
|
907
|
+
var export_createWebSocketStream = Er.default;
|
|
908
|
+
var export_extension = br.default;
|
|
909
|
+
var export_subprotocol = Or.default;
|
|
910
|
+
export { export_PerMessageDeflate as PerMessageDeflate, export_Receiver as Receiver, export_Sender as Sender, export_WebSocket as WebSocket, export_WebSocketServer as WebSocketServer, export_createWebSocketStream as createWebSocketStream, Hr as default, export_extension as extension, export_subprotocol as subprotocol };
|