@swiftbaseio/admin-sdk 1.1.0 → 1.2.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/dist/index.cjs +454 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -8
- package/dist/index.d.ts +111 -8
- package/dist/index.js +450 -240
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -271,110 +271,19 @@ var init_getaccesstoken = __esm({
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
// node_modules/ws/lib/
|
|
275
|
-
var require_stream = __commonJS({
|
|
276
|
-
"node_modules/ws/lib/stream.js"(exports, module) {
|
|
277
|
-
"use strict";
|
|
278
|
-
var { Duplex } = __require("stream");
|
|
279
|
-
function emitClose(stream) {
|
|
280
|
-
stream.emit("close");
|
|
281
|
-
}
|
|
282
|
-
function duplexOnEnd() {
|
|
283
|
-
if (!this.destroyed && this._writableState.finished) {
|
|
284
|
-
this.destroy();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
function duplexOnError(err) {
|
|
288
|
-
this.removeListener("error", duplexOnError);
|
|
289
|
-
this.destroy();
|
|
290
|
-
if (this.listenerCount("error") === 0) {
|
|
291
|
-
this.emit("error", err);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function createWebSocketStream2(ws, options) {
|
|
295
|
-
let terminateOnDestroy = true;
|
|
296
|
-
const duplex = new Duplex(__spreadProps(__spreadValues({}, options), {
|
|
297
|
-
autoDestroy: false,
|
|
298
|
-
emitClose: false,
|
|
299
|
-
objectMode: false,
|
|
300
|
-
writableObjectMode: false
|
|
301
|
-
}));
|
|
302
|
-
ws.on("message", function message(msg, isBinary) {
|
|
303
|
-
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
304
|
-
if (!duplex.push(data)) ws.pause();
|
|
305
|
-
});
|
|
306
|
-
ws.once("error", function error(err) {
|
|
307
|
-
if (duplex.destroyed) return;
|
|
308
|
-
terminateOnDestroy = false;
|
|
309
|
-
duplex.destroy(err);
|
|
310
|
-
});
|
|
311
|
-
ws.once("close", function close() {
|
|
312
|
-
if (duplex.destroyed) return;
|
|
313
|
-
duplex.push(null);
|
|
314
|
-
});
|
|
315
|
-
duplex._destroy = function(err, callback) {
|
|
316
|
-
if (ws.readyState === ws.CLOSED) {
|
|
317
|
-
callback(err);
|
|
318
|
-
process.nextTick(emitClose, duplex);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
let called = false;
|
|
322
|
-
ws.once("error", function error(err2) {
|
|
323
|
-
called = true;
|
|
324
|
-
callback(err2);
|
|
325
|
-
});
|
|
326
|
-
ws.once("close", function close() {
|
|
327
|
-
if (!called) callback(err);
|
|
328
|
-
process.nextTick(emitClose, duplex);
|
|
329
|
-
});
|
|
330
|
-
if (terminateOnDestroy) ws.terminate();
|
|
331
|
-
};
|
|
332
|
-
duplex._final = function(callback) {
|
|
333
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
334
|
-
ws.once("open", function open() {
|
|
335
|
-
duplex._final(callback);
|
|
336
|
-
});
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
if (ws._socket === null) return;
|
|
340
|
-
if (ws._socket._writableState.finished) {
|
|
341
|
-
callback();
|
|
342
|
-
if (duplex._readableState.endEmitted) duplex.destroy();
|
|
343
|
-
} else {
|
|
344
|
-
ws._socket.once("finish", function finish() {
|
|
345
|
-
callback();
|
|
346
|
-
});
|
|
347
|
-
ws.close();
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
duplex._read = function() {
|
|
351
|
-
if (ws.isPaused) ws.resume();
|
|
352
|
-
};
|
|
353
|
-
duplex._write = function(chunk, encoding, callback) {
|
|
354
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
355
|
-
ws.once("open", function open() {
|
|
356
|
-
duplex._write(chunk, encoding, callback);
|
|
357
|
-
});
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
ws.send(chunk, callback);
|
|
361
|
-
};
|
|
362
|
-
duplex.on("end", duplexOnEnd);
|
|
363
|
-
duplex.on("error", duplexOnError);
|
|
364
|
-
return duplex;
|
|
365
|
-
}
|
|
366
|
-
module.exports = createWebSocketStream2;
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
// node_modules/ws/lib/constants.js
|
|
274
|
+
// ../node_modules/ws/lib/constants.js
|
|
371
275
|
var require_constants = __commonJS({
|
|
372
|
-
"node_modules/ws/lib/constants.js"(exports, module) {
|
|
276
|
+
"../node_modules/ws/lib/constants.js"(exports, module) {
|
|
373
277
|
"use strict";
|
|
278
|
+
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
279
|
+
var hasBlob = typeof Blob !== "undefined";
|
|
280
|
+
if (hasBlob) BINARY_TYPES.push("blob");
|
|
374
281
|
module.exports = {
|
|
375
|
-
BINARY_TYPES
|
|
282
|
+
BINARY_TYPES,
|
|
283
|
+
CLOSE_TIMEOUT: 3e4,
|
|
376
284
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
377
285
|
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
286
|
+
hasBlob,
|
|
378
287
|
kForOnEventAttribute: /* @__PURE__ */ Symbol("kIsForOnEventAttribute"),
|
|
379
288
|
kListener: /* @__PURE__ */ Symbol("kListener"),
|
|
380
289
|
kStatusCode: /* @__PURE__ */ Symbol("status-code"),
|
|
@@ -385,9 +294,9 @@ var require_constants = __commonJS({
|
|
|
385
294
|
}
|
|
386
295
|
});
|
|
387
296
|
|
|
388
|
-
// node_modules/ws/lib/buffer-util.js
|
|
297
|
+
// ../node_modules/ws/lib/buffer-util.js
|
|
389
298
|
var require_buffer_util = __commonJS({
|
|
390
|
-
"node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
299
|
+
"../node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
391
300
|
"use strict";
|
|
392
301
|
var { EMPTY_BUFFER } = require_constants();
|
|
393
302
|
var FastBuffer = Buffer[Symbol.species];
|
|
@@ -460,9 +369,9 @@ var require_buffer_util = __commonJS({
|
|
|
460
369
|
}
|
|
461
370
|
});
|
|
462
371
|
|
|
463
|
-
// node_modules/ws/lib/limiter.js
|
|
372
|
+
// ../node_modules/ws/lib/limiter.js
|
|
464
373
|
var require_limiter = __commonJS({
|
|
465
|
-
"node_modules/ws/lib/limiter.js"(exports, module) {
|
|
374
|
+
"../node_modules/ws/lib/limiter.js"(exports, module) {
|
|
466
375
|
"use strict";
|
|
467
376
|
var kDone = /* @__PURE__ */ Symbol("kDone");
|
|
468
377
|
var kRun = /* @__PURE__ */ Symbol("kRun");
|
|
@@ -510,9 +419,9 @@ var require_limiter = __commonJS({
|
|
|
510
419
|
}
|
|
511
420
|
});
|
|
512
421
|
|
|
513
|
-
// node_modules/ws/lib/permessage-deflate.js
|
|
422
|
+
// ../node_modules/ws/lib/permessage-deflate.js
|
|
514
423
|
var require_permessage_deflate = __commonJS({
|
|
515
|
-
"node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
424
|
+
"../node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
516
425
|
"use strict";
|
|
517
426
|
var zlib = __require("zlib");
|
|
518
427
|
var bufferUtil = require_buffer_util();
|
|
@@ -526,7 +435,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
526
435
|
var kBuffers = /* @__PURE__ */ Symbol("buffers");
|
|
527
436
|
var kError = /* @__PURE__ */ Symbol("error");
|
|
528
437
|
var zlibLimiter;
|
|
529
|
-
var
|
|
438
|
+
var PerMessageDeflate2 = class {
|
|
530
439
|
/**
|
|
531
440
|
* Creates a PerMessageDeflate instance.
|
|
532
441
|
*
|
|
@@ -537,6 +446,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
537
446
|
* acknowledge disabling of client context takeover
|
|
538
447
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
539
448
|
* calls to zlib
|
|
449
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
450
|
+
* server or client mode
|
|
451
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
540
452
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
541
453
|
* use of a custom server window size
|
|
542
454
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -547,15 +459,12 @@ var require_permessage_deflate = __commonJS({
|
|
|
547
459
|
* deflate
|
|
548
460
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
549
461
|
* inflate
|
|
550
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
551
|
-
* client mode
|
|
552
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
553
462
|
*/
|
|
554
|
-
constructor(options
|
|
555
|
-
this._maxPayload = maxPayload | 0;
|
|
463
|
+
constructor(options) {
|
|
556
464
|
this._options = options || {};
|
|
557
465
|
this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
|
|
558
|
-
this.
|
|
466
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
467
|
+
this._isServer = !!this._options.isServer;
|
|
559
468
|
this._deflate = null;
|
|
560
469
|
this._inflate = null;
|
|
561
470
|
this.params = null;
|
|
@@ -862,7 +771,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
862
771
|
});
|
|
863
772
|
}
|
|
864
773
|
};
|
|
865
|
-
module.exports =
|
|
774
|
+
module.exports = PerMessageDeflate2;
|
|
866
775
|
function deflateOnData(chunk) {
|
|
867
776
|
this[kBuffers].push(chunk);
|
|
868
777
|
this[kTotalLength] += chunk.length;
|
|
@@ -881,17 +790,22 @@ var require_permessage_deflate = __commonJS({
|
|
|
881
790
|
}
|
|
882
791
|
function inflateOnError(err) {
|
|
883
792
|
this[kPerMessageDeflate]._inflate = null;
|
|
793
|
+
if (this[kError]) {
|
|
794
|
+
this[kCallback](this[kError]);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
884
797
|
err[kStatusCode] = 1007;
|
|
885
798
|
this[kCallback](err);
|
|
886
799
|
}
|
|
887
800
|
}
|
|
888
801
|
});
|
|
889
802
|
|
|
890
|
-
// node_modules/ws/lib/validation.js
|
|
803
|
+
// ../node_modules/ws/lib/validation.js
|
|
891
804
|
var require_validation = __commonJS({
|
|
892
|
-
"node_modules/ws/lib/validation.js"(exports, module) {
|
|
805
|
+
"../node_modules/ws/lib/validation.js"(exports, module) {
|
|
893
806
|
"use strict";
|
|
894
807
|
var { isUtf8 } = __require("buffer");
|
|
808
|
+
var { hasBlob } = require_constants();
|
|
895
809
|
var tokenChars = [
|
|
896
810
|
0,
|
|
897
811
|
0,
|
|
@@ -1062,7 +976,11 @@ var require_validation = __commonJS({
|
|
|
1062
976
|
}
|
|
1063
977
|
return true;
|
|
1064
978
|
}
|
|
979
|
+
function isBlob(value) {
|
|
980
|
+
return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
|
|
981
|
+
}
|
|
1065
982
|
module.exports = {
|
|
983
|
+
isBlob,
|
|
1066
984
|
isValidStatusCode,
|
|
1067
985
|
isValidUTF8: _isValidUTF8,
|
|
1068
986
|
tokenChars
|
|
@@ -1083,12 +1001,12 @@ var require_validation = __commonJS({
|
|
|
1083
1001
|
}
|
|
1084
1002
|
});
|
|
1085
1003
|
|
|
1086
|
-
// node_modules/ws/lib/receiver.js
|
|
1004
|
+
// ../node_modules/ws/lib/receiver.js
|
|
1087
1005
|
var require_receiver = __commonJS({
|
|
1088
|
-
"node_modules/ws/lib/receiver.js"(exports, module) {
|
|
1006
|
+
"../node_modules/ws/lib/receiver.js"(exports, module) {
|
|
1089
1007
|
"use strict";
|
|
1090
1008
|
var { Writable } = __require("stream");
|
|
1091
|
-
var
|
|
1009
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1092
1010
|
var {
|
|
1093
1011
|
BINARY_TYPES,
|
|
1094
1012
|
EMPTY_BUFFER,
|
|
@@ -1118,6 +1036,10 @@ var require_receiver = __commonJS({
|
|
|
1118
1036
|
* extensions
|
|
1119
1037
|
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
1120
1038
|
* client or server mode
|
|
1039
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
1040
|
+
* buffered data chunks
|
|
1041
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
1042
|
+
* fragments
|
|
1121
1043
|
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
1122
1044
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
1123
1045
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -1128,6 +1050,8 @@ var require_receiver = __commonJS({
|
|
|
1128
1050
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
1129
1051
|
this._extensions = options.extensions || {};
|
|
1130
1052
|
this._isServer = !!options.isServer;
|
|
1053
|
+
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
1054
|
+
this._maxFragments = options.maxFragments | 0;
|
|
1131
1055
|
this._maxPayload = options.maxPayload | 0;
|
|
1132
1056
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
1133
1057
|
this[kWebSocket] = void 0;
|
|
@@ -1142,6 +1066,7 @@ var require_receiver = __commonJS({
|
|
|
1142
1066
|
this._opcode = 0;
|
|
1143
1067
|
this._totalPayloadLength = 0;
|
|
1144
1068
|
this._messageLength = 0;
|
|
1069
|
+
this._numFragments = 0;
|
|
1145
1070
|
this._fragments = [];
|
|
1146
1071
|
this._errored = false;
|
|
1147
1072
|
this._loop = false;
|
|
@@ -1157,6 +1082,18 @@ var require_receiver = __commonJS({
|
|
|
1157
1082
|
*/
|
|
1158
1083
|
_write(chunk, encoding, cb) {
|
|
1159
1084
|
if (this._opcode === 8 && this._state == GET_INFO) return cb();
|
|
1085
|
+
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
1086
|
+
cb(
|
|
1087
|
+
this.createError(
|
|
1088
|
+
RangeError,
|
|
1089
|
+
"Too many buffered chunks",
|
|
1090
|
+
false,
|
|
1091
|
+
1008,
|
|
1092
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1093
|
+
)
|
|
1094
|
+
);
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1160
1097
|
this._bufferedBytes += chunk.length;
|
|
1161
1098
|
this._buffers.push(chunk);
|
|
1162
1099
|
this.startLoop(cb);
|
|
@@ -1255,7 +1192,7 @@ var require_receiver = __commonJS({
|
|
|
1255
1192
|
return;
|
|
1256
1193
|
}
|
|
1257
1194
|
const compressed = (buf[0] & 64) === 64;
|
|
1258
|
-
if (compressed && !this._extensions[
|
|
1195
|
+
if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
|
|
1259
1196
|
const error = this.createError(
|
|
1260
1197
|
RangeError,
|
|
1261
1198
|
"RSV1 must be clear",
|
|
@@ -1480,6 +1417,17 @@ var require_receiver = __commonJS({
|
|
|
1480
1417
|
this.controlMessage(data, cb);
|
|
1481
1418
|
return;
|
|
1482
1419
|
}
|
|
1420
|
+
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
1421
|
+
const error = this.createError(
|
|
1422
|
+
RangeError,
|
|
1423
|
+
"Too many message fragments",
|
|
1424
|
+
false,
|
|
1425
|
+
1008,
|
|
1426
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1427
|
+
);
|
|
1428
|
+
cb(error);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1483
1431
|
if (this._compressed) {
|
|
1484
1432
|
this._state = INFLATING;
|
|
1485
1433
|
this.decompress(data, cb);
|
|
@@ -1499,7 +1447,7 @@ var require_receiver = __commonJS({
|
|
|
1499
1447
|
* @private
|
|
1500
1448
|
*/
|
|
1501
1449
|
decompress(data, cb) {
|
|
1502
|
-
const perMessageDeflate = this._extensions[
|
|
1450
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1503
1451
|
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
1504
1452
|
if (err) return cb(err);
|
|
1505
1453
|
if (buf.length) {
|
|
@@ -1537,6 +1485,7 @@ var require_receiver = __commonJS({
|
|
|
1537
1485
|
this._totalPayloadLength = 0;
|
|
1538
1486
|
this._messageLength = 0;
|
|
1539
1487
|
this._fragmented = 0;
|
|
1488
|
+
this._numFragments = 0;
|
|
1540
1489
|
this._fragments = [];
|
|
1541
1490
|
if (this._opcode === 2) {
|
|
1542
1491
|
let data;
|
|
@@ -1544,6 +1493,8 @@ var require_receiver = __commonJS({
|
|
|
1544
1493
|
data = concat(fragments, messageLength);
|
|
1545
1494
|
} else if (this._binaryType === "arraybuffer") {
|
|
1546
1495
|
data = toArrayBuffer(concat(fragments, messageLength));
|
|
1496
|
+
} else if (this._binaryType === "blob") {
|
|
1497
|
+
data = new Blob(fragments);
|
|
1547
1498
|
} else {
|
|
1548
1499
|
data = fragments;
|
|
1549
1500
|
}
|
|
@@ -1673,21 +1624,27 @@ var require_receiver = __commonJS({
|
|
|
1673
1624
|
}
|
|
1674
1625
|
});
|
|
1675
1626
|
|
|
1676
|
-
// node_modules/ws/lib/sender.js
|
|
1627
|
+
// ../node_modules/ws/lib/sender.js
|
|
1677
1628
|
var require_sender = __commonJS({
|
|
1678
|
-
"node_modules/ws/lib/sender.js"(exports, module) {
|
|
1629
|
+
"../node_modules/ws/lib/sender.js"(exports, module) {
|
|
1679
1630
|
"use strict";
|
|
1680
1631
|
var { Duplex } = __require("stream");
|
|
1681
1632
|
var { randomFillSync } = __require("crypto");
|
|
1682
|
-
var
|
|
1683
|
-
|
|
1684
|
-
|
|
1633
|
+
var {
|
|
1634
|
+
types: { isUint8Array }
|
|
1635
|
+
} = __require("util");
|
|
1636
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1637
|
+
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1638
|
+
var { isBlob, isValidStatusCode } = require_validation();
|
|
1685
1639
|
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
1686
1640
|
var kByteLength = /* @__PURE__ */ Symbol("kByteLength");
|
|
1687
1641
|
var maskBuffer = Buffer.alloc(4);
|
|
1688
1642
|
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
1689
1643
|
var randomPool;
|
|
1690
1644
|
var randomPoolPointer = RANDOM_POOL_SIZE;
|
|
1645
|
+
var DEFAULT = 0;
|
|
1646
|
+
var DEFLATING = 1;
|
|
1647
|
+
var GET_BLOB_DATA = 2;
|
|
1691
1648
|
var Sender2 = class _Sender {
|
|
1692
1649
|
/**
|
|
1693
1650
|
* Creates a Sender instance.
|
|
@@ -1707,8 +1664,10 @@ var require_sender = __commonJS({
|
|
|
1707
1664
|
this._firstFragment = true;
|
|
1708
1665
|
this._compress = false;
|
|
1709
1666
|
this._bufferedBytes = 0;
|
|
1710
|
-
this._deflating = false;
|
|
1711
1667
|
this._queue = [];
|
|
1668
|
+
this._state = DEFAULT;
|
|
1669
|
+
this.onerror = NOOP;
|
|
1670
|
+
this[kWebSocket] = void 0;
|
|
1712
1671
|
}
|
|
1713
1672
|
/**
|
|
1714
1673
|
* Frames a piece of data according to the HyBi WebSocket protocol.
|
|
@@ -1827,8 +1786,10 @@ var require_sender = __commonJS({
|
|
|
1827
1786
|
buf.writeUInt16BE(code, 0);
|
|
1828
1787
|
if (typeof data === "string") {
|
|
1829
1788
|
buf.write(data, 2);
|
|
1830
|
-
} else {
|
|
1789
|
+
} else if (isUint8Array(data)) {
|
|
1831
1790
|
buf.set(data, 2);
|
|
1791
|
+
} else {
|
|
1792
|
+
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
1832
1793
|
}
|
|
1833
1794
|
}
|
|
1834
1795
|
const options = {
|
|
@@ -1841,7 +1802,7 @@ var require_sender = __commonJS({
|
|
|
1841
1802
|
readOnly: false,
|
|
1842
1803
|
rsv1: false
|
|
1843
1804
|
};
|
|
1844
|
-
if (this.
|
|
1805
|
+
if (this._state !== DEFAULT) {
|
|
1845
1806
|
this.enqueue([this.dispatch, buf, false, options, cb]);
|
|
1846
1807
|
} else {
|
|
1847
1808
|
this.sendFrame(_Sender.frame(buf, options), cb);
|
|
@@ -1861,6 +1822,9 @@ var require_sender = __commonJS({
|
|
|
1861
1822
|
if (typeof data === "string") {
|
|
1862
1823
|
byteLength = Buffer.byteLength(data);
|
|
1863
1824
|
readOnly = false;
|
|
1825
|
+
} else if (isBlob(data)) {
|
|
1826
|
+
byteLength = data.size;
|
|
1827
|
+
readOnly = false;
|
|
1864
1828
|
} else {
|
|
1865
1829
|
data = toBuffer(data);
|
|
1866
1830
|
byteLength = data.length;
|
|
@@ -1879,7 +1843,13 @@ var require_sender = __commonJS({
|
|
|
1879
1843
|
readOnly,
|
|
1880
1844
|
rsv1: false
|
|
1881
1845
|
};
|
|
1882
|
-
if (
|
|
1846
|
+
if (isBlob(data)) {
|
|
1847
|
+
if (this._state !== DEFAULT) {
|
|
1848
|
+
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
1849
|
+
} else {
|
|
1850
|
+
this.getBlobData(data, false, options, cb);
|
|
1851
|
+
}
|
|
1852
|
+
} else if (this._state !== DEFAULT) {
|
|
1883
1853
|
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
1884
1854
|
} else {
|
|
1885
1855
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
@@ -1899,6 +1869,9 @@ var require_sender = __commonJS({
|
|
|
1899
1869
|
if (typeof data === "string") {
|
|
1900
1870
|
byteLength = Buffer.byteLength(data);
|
|
1901
1871
|
readOnly = false;
|
|
1872
|
+
} else if (isBlob(data)) {
|
|
1873
|
+
byteLength = data.size;
|
|
1874
|
+
readOnly = false;
|
|
1902
1875
|
} else {
|
|
1903
1876
|
data = toBuffer(data);
|
|
1904
1877
|
byteLength = data.length;
|
|
@@ -1917,7 +1890,13 @@ var require_sender = __commonJS({
|
|
|
1917
1890
|
readOnly,
|
|
1918
1891
|
rsv1: false
|
|
1919
1892
|
};
|
|
1920
|
-
if (
|
|
1893
|
+
if (isBlob(data)) {
|
|
1894
|
+
if (this._state !== DEFAULT) {
|
|
1895
|
+
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
1896
|
+
} else {
|
|
1897
|
+
this.getBlobData(data, false, options, cb);
|
|
1898
|
+
}
|
|
1899
|
+
} else if (this._state !== DEFAULT) {
|
|
1921
1900
|
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
1922
1901
|
} else {
|
|
1923
1902
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
@@ -1940,7 +1919,7 @@ var require_sender = __commonJS({
|
|
|
1940
1919
|
* @public
|
|
1941
1920
|
*/
|
|
1942
1921
|
send(data, options, cb) {
|
|
1943
|
-
const perMessageDeflate = this._extensions[
|
|
1922
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1944
1923
|
let opcode = options.binary ? 2 : 1;
|
|
1945
1924
|
let rsv1 = options.compress;
|
|
1946
1925
|
let byteLength;
|
|
@@ -1948,6 +1927,9 @@ var require_sender = __commonJS({
|
|
|
1948
1927
|
if (typeof data === "string") {
|
|
1949
1928
|
byteLength = Buffer.byteLength(data);
|
|
1950
1929
|
readOnly = false;
|
|
1930
|
+
} else if (isBlob(data)) {
|
|
1931
|
+
byteLength = data.size;
|
|
1932
|
+
readOnly = false;
|
|
1951
1933
|
} else {
|
|
1952
1934
|
data = toBuffer(data);
|
|
1953
1935
|
byteLength = data.length;
|
|
@@ -1964,38 +1946,75 @@ var require_sender = __commonJS({
|
|
|
1964
1946
|
opcode = 0;
|
|
1965
1947
|
}
|
|
1966
1948
|
if (options.fin) this._firstFragment = true;
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
if (this.
|
|
1979
|
-
this.enqueue([this.
|
|
1949
|
+
const opts = {
|
|
1950
|
+
[kByteLength]: byteLength,
|
|
1951
|
+
fin: options.fin,
|
|
1952
|
+
generateMask: this._generateMask,
|
|
1953
|
+
mask: options.mask,
|
|
1954
|
+
maskBuffer: this._maskBuffer,
|
|
1955
|
+
opcode,
|
|
1956
|
+
readOnly,
|
|
1957
|
+
rsv1
|
|
1958
|
+
};
|
|
1959
|
+
if (isBlob(data)) {
|
|
1960
|
+
if (this._state !== DEFAULT) {
|
|
1961
|
+
this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
|
|
1980
1962
|
} else {
|
|
1981
|
-
this.
|
|
1963
|
+
this.getBlobData(data, this._compress, opts, cb);
|
|
1982
1964
|
}
|
|
1965
|
+
} else if (this._state !== DEFAULT) {
|
|
1966
|
+
this.enqueue([this.dispatch, data, this._compress, opts, cb]);
|
|
1983
1967
|
} else {
|
|
1984
|
-
this.
|
|
1985
|
-
_Sender.frame(data, {
|
|
1986
|
-
[kByteLength]: byteLength,
|
|
1987
|
-
fin: options.fin,
|
|
1988
|
-
generateMask: this._generateMask,
|
|
1989
|
-
mask: options.mask,
|
|
1990
|
-
maskBuffer: this._maskBuffer,
|
|
1991
|
-
opcode,
|
|
1992
|
-
readOnly,
|
|
1993
|
-
rsv1: false
|
|
1994
|
-
}),
|
|
1995
|
-
cb
|
|
1996
|
-
);
|
|
1968
|
+
this.dispatch(data, this._compress, opts, cb);
|
|
1997
1969
|
}
|
|
1998
1970
|
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Gets the contents of a blob as binary data.
|
|
1973
|
+
*
|
|
1974
|
+
* @param {Blob} blob The blob
|
|
1975
|
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
|
1976
|
+
* the data
|
|
1977
|
+
* @param {Object} options Options object
|
|
1978
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
1979
|
+
* FIN bit
|
|
1980
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
1981
|
+
* masking key
|
|
1982
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
1983
|
+
* `data`
|
|
1984
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
1985
|
+
* key
|
|
1986
|
+
* @param {Number} options.opcode The opcode
|
|
1987
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
1988
|
+
* modified
|
|
1989
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
1990
|
+
* RSV1 bit
|
|
1991
|
+
* @param {Function} [cb] Callback
|
|
1992
|
+
* @private
|
|
1993
|
+
*/
|
|
1994
|
+
getBlobData(blob2, compress, options, cb) {
|
|
1995
|
+
this._bufferedBytes += options[kByteLength];
|
|
1996
|
+
this._state = GET_BLOB_DATA;
|
|
1997
|
+
blob2.arrayBuffer().then((arrayBuffer) => {
|
|
1998
|
+
if (this._socket.destroyed) {
|
|
1999
|
+
const err = new Error(
|
|
2000
|
+
"The socket was closed while the blob was being read"
|
|
2001
|
+
);
|
|
2002
|
+
process.nextTick(callCallbacks, this, err, cb);
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
this._bufferedBytes -= options[kByteLength];
|
|
2006
|
+
const data = toBuffer(arrayBuffer);
|
|
2007
|
+
if (!compress) {
|
|
2008
|
+
this._state = DEFAULT;
|
|
2009
|
+
this.sendFrame(_Sender.frame(data, options), cb);
|
|
2010
|
+
this.dequeue();
|
|
2011
|
+
} else {
|
|
2012
|
+
this.dispatch(data, compress, options, cb);
|
|
2013
|
+
}
|
|
2014
|
+
}).catch((err) => {
|
|
2015
|
+
process.nextTick(onError, this, err, cb);
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
1999
2018
|
/**
|
|
2000
2019
|
* Dispatches a message.
|
|
2001
2020
|
*
|
|
@@ -2024,24 +2043,19 @@ var require_sender = __commonJS({
|
|
|
2024
2043
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
2025
2044
|
return;
|
|
2026
2045
|
}
|
|
2027
|
-
const perMessageDeflate = this._extensions[
|
|
2046
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
2028
2047
|
this._bufferedBytes += options[kByteLength];
|
|
2029
|
-
this.
|
|
2048
|
+
this._state = DEFLATING;
|
|
2030
2049
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
2031
2050
|
if (this._socket.destroyed) {
|
|
2032
2051
|
const err = new Error(
|
|
2033
2052
|
"The socket was closed while data was being compressed"
|
|
2034
2053
|
);
|
|
2035
|
-
|
|
2036
|
-
for (let i = 0; i < this._queue.length; i++) {
|
|
2037
|
-
const params = this._queue[i];
|
|
2038
|
-
const callback = params[params.length - 1];
|
|
2039
|
-
if (typeof callback === "function") callback(err);
|
|
2040
|
-
}
|
|
2054
|
+
callCallbacks(this, err, cb);
|
|
2041
2055
|
return;
|
|
2042
2056
|
}
|
|
2043
2057
|
this._bufferedBytes -= options[kByteLength];
|
|
2044
|
-
this.
|
|
2058
|
+
this._state = DEFAULT;
|
|
2045
2059
|
options.readOnly = false;
|
|
2046
2060
|
this.sendFrame(_Sender.frame(buf, options), cb);
|
|
2047
2061
|
this.dequeue();
|
|
@@ -2053,7 +2067,7 @@ var require_sender = __commonJS({
|
|
|
2053
2067
|
* @private
|
|
2054
2068
|
*/
|
|
2055
2069
|
dequeue() {
|
|
2056
|
-
while (
|
|
2070
|
+
while (this._state === DEFAULT && this._queue.length) {
|
|
2057
2071
|
const params = this._queue.shift();
|
|
2058
2072
|
this._bufferedBytes -= params[3][kByteLength];
|
|
2059
2073
|
Reflect.apply(params[0], this, params.slice(1));
|
|
@@ -2072,7 +2086,7 @@ var require_sender = __commonJS({
|
|
|
2072
2086
|
/**
|
|
2073
2087
|
* Sends a frame.
|
|
2074
2088
|
*
|
|
2075
|
-
* @param {Buffer[]} list The frame to send
|
|
2089
|
+
* @param {(Buffer | String)[]} list The frame to send
|
|
2076
2090
|
* @param {Function} [cb] Callback
|
|
2077
2091
|
* @private
|
|
2078
2092
|
*/
|
|
@@ -2088,12 +2102,24 @@ var require_sender = __commonJS({
|
|
|
2088
2102
|
}
|
|
2089
2103
|
};
|
|
2090
2104
|
module.exports = Sender2;
|
|
2105
|
+
function callCallbacks(sender, err, cb) {
|
|
2106
|
+
if (typeof cb === "function") cb(err);
|
|
2107
|
+
for (let i = 0; i < sender._queue.length; i++) {
|
|
2108
|
+
const params = sender._queue[i];
|
|
2109
|
+
const callback = params[params.length - 1];
|
|
2110
|
+
if (typeof callback === "function") callback(err);
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
function onError(sender, err, cb) {
|
|
2114
|
+
callCallbacks(sender, err, cb);
|
|
2115
|
+
sender.onerror(err);
|
|
2116
|
+
}
|
|
2091
2117
|
}
|
|
2092
2118
|
});
|
|
2093
2119
|
|
|
2094
|
-
// node_modules/ws/lib/event-target.js
|
|
2120
|
+
// ../node_modules/ws/lib/event-target.js
|
|
2095
2121
|
var require_event_target = __commonJS({
|
|
2096
|
-
"node_modules/ws/lib/event-target.js"(exports, module) {
|
|
2122
|
+
"../node_modules/ws/lib/event-target.js"(exports, module) {
|
|
2097
2123
|
"use strict";
|
|
2098
2124
|
var { kForOnEventAttribute, kListener } = require_constants();
|
|
2099
2125
|
var kCode = /* @__PURE__ */ Symbol("kCode");
|
|
@@ -2320,9 +2346,9 @@ var require_event_target = __commonJS({
|
|
|
2320
2346
|
}
|
|
2321
2347
|
});
|
|
2322
2348
|
|
|
2323
|
-
// node_modules/ws/lib/extension.js
|
|
2349
|
+
// ../node_modules/ws/lib/extension.js
|
|
2324
2350
|
var require_extension = __commonJS({
|
|
2325
|
-
"node_modules/ws/lib/extension.js"(exports, module) {
|
|
2351
|
+
"../node_modules/ws/lib/extension.js"(exports, module) {
|
|
2326
2352
|
"use strict";
|
|
2327
2353
|
var { tokenChars } = require_validation();
|
|
2328
2354
|
function push(dest, name, elem) {
|
|
@@ -2455,11 +2481,11 @@ var require_extension = __commonJS({
|
|
|
2455
2481
|
return offers;
|
|
2456
2482
|
}
|
|
2457
2483
|
function format(extensions) {
|
|
2458
|
-
return Object.keys(extensions).map((
|
|
2459
|
-
let configurations = extensions[
|
|
2484
|
+
return Object.keys(extensions).map((extension2) => {
|
|
2485
|
+
let configurations = extensions[extension2];
|
|
2460
2486
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2461
2487
|
return configurations.map((params) => {
|
|
2462
|
-
return [
|
|
2488
|
+
return [extension2].concat(
|
|
2463
2489
|
Object.keys(params).map((k) => {
|
|
2464
2490
|
let values = params[k];
|
|
2465
2491
|
if (!Array.isArray(values)) values = [values];
|
|
@@ -2473,9 +2499,9 @@ var require_extension = __commonJS({
|
|
|
2473
2499
|
}
|
|
2474
2500
|
});
|
|
2475
2501
|
|
|
2476
|
-
// node_modules/ws/lib/websocket.js
|
|
2502
|
+
// ../node_modules/ws/lib/websocket.js
|
|
2477
2503
|
var require_websocket = __commonJS({
|
|
2478
|
-
"node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2504
|
+
"../node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2479
2505
|
"use strict";
|
|
2480
2506
|
var EventEmitter = __require("events");
|
|
2481
2507
|
var https = __require("https");
|
|
@@ -2485,11 +2511,13 @@ var require_websocket = __commonJS({
|
|
|
2485
2511
|
var { randomBytes, createHash } = __require("crypto");
|
|
2486
2512
|
var { Duplex, Readable } = __require("stream");
|
|
2487
2513
|
var { URL: URL2 } = __require("url");
|
|
2488
|
-
var
|
|
2514
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
2489
2515
|
var Receiver2 = require_receiver();
|
|
2490
2516
|
var Sender2 = require_sender();
|
|
2517
|
+
var { isBlob } = require_validation();
|
|
2491
2518
|
var {
|
|
2492
2519
|
BINARY_TYPES,
|
|
2520
|
+
CLOSE_TIMEOUT,
|
|
2493
2521
|
EMPTY_BUFFER,
|
|
2494
2522
|
GUID,
|
|
2495
2523
|
kForOnEventAttribute,
|
|
@@ -2503,7 +2531,6 @@ var require_websocket = __commonJS({
|
|
|
2503
2531
|
} = require_event_target();
|
|
2504
2532
|
var { format, parse } = require_extension();
|
|
2505
2533
|
var { toBuffer } = require_buffer_util();
|
|
2506
|
-
var closeTimeout = 30 * 1e3;
|
|
2507
2534
|
var kAborted = /* @__PURE__ */ Symbol("kAborted");
|
|
2508
2535
|
var protocolVersions = [8, 13];
|
|
2509
2536
|
var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
@@ -2524,6 +2551,7 @@ var require_websocket = __commonJS({
|
|
|
2524
2551
|
this._closeFrameSent = false;
|
|
2525
2552
|
this._closeMessage = EMPTY_BUFFER;
|
|
2526
2553
|
this._closeTimer = null;
|
|
2554
|
+
this._errorEmitted = false;
|
|
2527
2555
|
this._extensions = {};
|
|
2528
2556
|
this._paused = false;
|
|
2529
2557
|
this._protocol = "";
|
|
@@ -2548,13 +2576,13 @@ var require_websocket = __commonJS({
|
|
|
2548
2576
|
initAsClient(this, address, protocols, options);
|
|
2549
2577
|
} else {
|
|
2550
2578
|
this._autoPong = options.autoPong;
|
|
2579
|
+
this._closeTimeout = options.closeTimeout;
|
|
2551
2580
|
this._isServer = true;
|
|
2552
2581
|
}
|
|
2553
2582
|
}
|
|
2554
2583
|
/**
|
|
2555
|
-
*
|
|
2556
|
-
*
|
|
2557
|
-
* type).
|
|
2584
|
+
* For historical reasons, the custom "nodebuffer" type is used by the default
|
|
2585
|
+
* instead of "blob".
|
|
2558
2586
|
*
|
|
2559
2587
|
* @type {String}
|
|
2560
2588
|
*/
|
|
@@ -2642,6 +2670,10 @@ var require_websocket = __commonJS({
|
|
|
2642
2670
|
* multiple times in the same tick
|
|
2643
2671
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
2644
2672
|
* masking key
|
|
2673
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
2674
|
+
* buffered data chunks
|
|
2675
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
2676
|
+
* fragments
|
|
2645
2677
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
2646
2678
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
2647
2679
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -2653,13 +2685,17 @@ var require_websocket = __commonJS({
|
|
|
2653
2685
|
binaryType: this.binaryType,
|
|
2654
2686
|
extensions: this._extensions,
|
|
2655
2687
|
isServer: this._isServer,
|
|
2688
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
2689
|
+
maxFragments: options.maxFragments,
|
|
2656
2690
|
maxPayload: options.maxPayload,
|
|
2657
2691
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2658
2692
|
});
|
|
2659
|
-
|
|
2693
|
+
const sender = new Sender2(socket, this._extensions, options.generateMask);
|
|
2660
2694
|
this._receiver = receiver;
|
|
2695
|
+
this._sender = sender;
|
|
2661
2696
|
this._socket = socket;
|
|
2662
2697
|
receiver[kWebSocket] = this;
|
|
2698
|
+
sender[kWebSocket] = this;
|
|
2663
2699
|
socket[kWebSocket] = this;
|
|
2664
2700
|
receiver.on("conclude", receiverOnConclude);
|
|
2665
2701
|
receiver.on("drain", receiverOnDrain);
|
|
@@ -2667,6 +2703,7 @@ var require_websocket = __commonJS({
|
|
|
2667
2703
|
receiver.on("message", receiverOnMessage);
|
|
2668
2704
|
receiver.on("ping", receiverOnPing);
|
|
2669
2705
|
receiver.on("pong", receiverOnPong);
|
|
2706
|
+
sender.onerror = senderOnError;
|
|
2670
2707
|
if (socket.setTimeout) socket.setTimeout(0);
|
|
2671
2708
|
if (socket.setNoDelay) socket.setNoDelay();
|
|
2672
2709
|
if (head.length > 0) socket.unshift(head);
|
|
@@ -2688,8 +2725,8 @@ var require_websocket = __commonJS({
|
|
|
2688
2725
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2689
2726
|
return;
|
|
2690
2727
|
}
|
|
2691
|
-
if (this._extensions[
|
|
2692
|
-
this._extensions[
|
|
2728
|
+
if (this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2729
|
+
this._extensions[PerMessageDeflate2.extensionName].cleanup();
|
|
2693
2730
|
}
|
|
2694
2731
|
this._receiver.removeAllListeners();
|
|
2695
2732
|
this._readyState = _WebSocket.CLOSED;
|
|
@@ -2736,10 +2773,7 @@ var require_websocket = __commonJS({
|
|
|
2736
2773
|
this._socket.end();
|
|
2737
2774
|
}
|
|
2738
2775
|
});
|
|
2739
|
-
this
|
|
2740
|
-
this._socket.destroy.bind(this._socket),
|
|
2741
|
-
closeTimeout
|
|
2742
|
-
);
|
|
2776
|
+
setCloseTimer(this);
|
|
2743
2777
|
}
|
|
2744
2778
|
/**
|
|
2745
2779
|
* Pause the socket.
|
|
@@ -2853,7 +2887,7 @@ var require_websocket = __commonJS({
|
|
|
2853
2887
|
compress: true,
|
|
2854
2888
|
fin: true
|
|
2855
2889
|
}, options);
|
|
2856
|
-
if (!this._extensions[
|
|
2890
|
+
if (!this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2857
2891
|
opts.compress = false;
|
|
2858
2892
|
}
|
|
2859
2893
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
@@ -2949,7 +2983,10 @@ var require_websocket = __commonJS({
|
|
|
2949
2983
|
const opts = __spreadProps(__spreadValues({
|
|
2950
2984
|
allowSynchronousEvents: true,
|
|
2951
2985
|
autoPong: true,
|
|
2986
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
2952
2987
|
protocolVersion: protocolVersions[1],
|
|
2988
|
+
maxBufferedChunks: 256 * 1024,
|
|
2989
|
+
maxFragments: 16 * 1024,
|
|
2953
2990
|
maxPayload: 100 * 1024 * 1024,
|
|
2954
2991
|
skipUTF8Validation: false,
|
|
2955
2992
|
perMessageDeflate: true,
|
|
@@ -2966,6 +3003,7 @@ var require_websocket = __commonJS({
|
|
|
2966
3003
|
port: void 0
|
|
2967
3004
|
});
|
|
2968
3005
|
websocket._autoPong = opts.autoPong;
|
|
3006
|
+
websocket._closeTimeout = opts.closeTimeout;
|
|
2969
3007
|
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
2970
3008
|
throw new RangeError(
|
|
2971
3009
|
`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
|
|
@@ -2991,7 +3029,7 @@ var require_websocket = __commonJS({
|
|
|
2991
3029
|
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
2992
3030
|
let invalidUrlMessage;
|
|
2993
3031
|
if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
|
|
2994
|
-
invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`;
|
|
3032
|
+
invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;
|
|
2995
3033
|
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
2996
3034
|
invalidUrlMessage = "The URL's pathname is empty";
|
|
2997
3035
|
} else if (parsedUrl.hash) {
|
|
@@ -3024,13 +3062,12 @@ var require_websocket = __commonJS({
|
|
|
3024
3062
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
3025
3063
|
opts.timeout = opts.handshakeTimeout;
|
|
3026
3064
|
if (opts.perMessageDeflate) {
|
|
3027
|
-
perMessageDeflate = new
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
);
|
|
3065
|
+
perMessageDeflate = new PerMessageDeflate2(__spreadProps(__spreadValues({}, opts.perMessageDeflate), {
|
|
3066
|
+
isServer: false,
|
|
3067
|
+
maxPayload: opts.maxPayload
|
|
3068
|
+
}));
|
|
3032
3069
|
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
3033
|
-
[
|
|
3070
|
+
[PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
|
|
3034
3071
|
});
|
|
3035
3072
|
}
|
|
3036
3073
|
if (protocols.length) {
|
|
@@ -3173,23 +3210,25 @@ var require_websocket = __commonJS({
|
|
|
3173
3210
|
return;
|
|
3174
3211
|
}
|
|
3175
3212
|
const extensionNames = Object.keys(extensions);
|
|
3176
|
-
if (extensionNames.length !== 1 || extensionNames[0] !==
|
|
3213
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
|
|
3177
3214
|
const message = "Server indicated an extension that was not requested";
|
|
3178
3215
|
abortHandshake(websocket, socket, message);
|
|
3179
3216
|
return;
|
|
3180
3217
|
}
|
|
3181
3218
|
try {
|
|
3182
|
-
perMessageDeflate.accept(extensions[
|
|
3219
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
|
|
3183
3220
|
} catch (err) {
|
|
3184
3221
|
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
3185
3222
|
abortHandshake(websocket, socket, message);
|
|
3186
3223
|
return;
|
|
3187
3224
|
}
|
|
3188
|
-
websocket._extensions[
|
|
3225
|
+
websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3189
3226
|
}
|
|
3190
3227
|
websocket.setSocket(socket, head, {
|
|
3191
3228
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
3192
3229
|
generateMask: opts.generateMask,
|
|
3230
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
3231
|
+
maxFragments: opts.maxFragments,
|
|
3193
3232
|
maxPayload: opts.maxPayload,
|
|
3194
3233
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
3195
3234
|
});
|
|
@@ -3202,6 +3241,7 @@ var require_websocket = __commonJS({
|
|
|
3202
3241
|
}
|
|
3203
3242
|
function emitErrorAndClose(websocket, err) {
|
|
3204
3243
|
websocket._readyState = WebSocket3.CLOSING;
|
|
3244
|
+
websocket._errorEmitted = true;
|
|
3205
3245
|
websocket.emit("error", err);
|
|
3206
3246
|
websocket.emitClose();
|
|
3207
3247
|
}
|
|
@@ -3235,7 +3275,7 @@ var require_websocket = __commonJS({
|
|
|
3235
3275
|
}
|
|
3236
3276
|
function sendAfterClose(websocket, data, cb) {
|
|
3237
3277
|
if (data) {
|
|
3238
|
-
const length = toBuffer(data).length;
|
|
3278
|
+
const length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
3239
3279
|
if (websocket._socket) websocket._sender._bufferedBytes += length;
|
|
3240
3280
|
else websocket._bufferedAmount += length;
|
|
3241
3281
|
}
|
|
@@ -3268,7 +3308,10 @@ var require_websocket = __commonJS({
|
|
|
3268
3308
|
process.nextTick(resume, websocket._socket);
|
|
3269
3309
|
websocket.close(err[kStatusCode]);
|
|
3270
3310
|
}
|
|
3271
|
-
websocket.
|
|
3311
|
+
if (!websocket._errorEmitted) {
|
|
3312
|
+
websocket._errorEmitted = true;
|
|
3313
|
+
websocket.emit("error", err);
|
|
3314
|
+
}
|
|
3272
3315
|
}
|
|
3273
3316
|
function receiverOnFinish() {
|
|
3274
3317
|
this[kWebSocket].emitClose();
|
|
@@ -3287,14 +3330,33 @@ var require_websocket = __commonJS({
|
|
|
3287
3330
|
function resume(stream) {
|
|
3288
3331
|
stream.resume();
|
|
3289
3332
|
}
|
|
3333
|
+
function senderOnError(err) {
|
|
3334
|
+
const websocket = this[kWebSocket];
|
|
3335
|
+
if (websocket.readyState === WebSocket3.CLOSED) return;
|
|
3336
|
+
if (websocket.readyState === WebSocket3.OPEN) {
|
|
3337
|
+
websocket._readyState = WebSocket3.CLOSING;
|
|
3338
|
+
setCloseTimer(websocket);
|
|
3339
|
+
}
|
|
3340
|
+
this._socket.end();
|
|
3341
|
+
if (!websocket._errorEmitted) {
|
|
3342
|
+
websocket._errorEmitted = true;
|
|
3343
|
+
websocket.emit("error", err);
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
function setCloseTimer(websocket) {
|
|
3347
|
+
websocket._closeTimer = setTimeout(
|
|
3348
|
+
websocket._socket.destroy.bind(websocket._socket),
|
|
3349
|
+
websocket._closeTimeout
|
|
3350
|
+
);
|
|
3351
|
+
}
|
|
3290
3352
|
function socketOnClose() {
|
|
3291
3353
|
const websocket = this[kWebSocket];
|
|
3292
3354
|
this.removeListener("close", socketOnClose);
|
|
3293
3355
|
this.removeListener("data", socketOnData);
|
|
3294
3356
|
this.removeListener("end", socketOnEnd);
|
|
3295
3357
|
websocket._readyState = WebSocket3.CLOSING;
|
|
3296
|
-
|
|
3297
|
-
|
|
3358
|
+
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
3359
|
+
const chunk = this.read(this._readableState.length);
|
|
3298
3360
|
websocket._receiver.write(chunk);
|
|
3299
3361
|
}
|
|
3300
3362
|
websocket._receiver.end();
|
|
@@ -3330,9 +3392,106 @@ var require_websocket = __commonJS({
|
|
|
3330
3392
|
}
|
|
3331
3393
|
});
|
|
3332
3394
|
|
|
3333
|
-
// node_modules/ws/lib/
|
|
3395
|
+
// ../node_modules/ws/lib/stream.js
|
|
3396
|
+
var require_stream = __commonJS({
|
|
3397
|
+
"../node_modules/ws/lib/stream.js"(exports, module) {
|
|
3398
|
+
"use strict";
|
|
3399
|
+
var WebSocket3 = require_websocket();
|
|
3400
|
+
var { Duplex } = __require("stream");
|
|
3401
|
+
function emitClose(stream) {
|
|
3402
|
+
stream.emit("close");
|
|
3403
|
+
}
|
|
3404
|
+
function duplexOnEnd() {
|
|
3405
|
+
if (!this.destroyed && this._writableState.finished) {
|
|
3406
|
+
this.destroy();
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
function duplexOnError(err) {
|
|
3410
|
+
this.removeListener("error", duplexOnError);
|
|
3411
|
+
this.destroy();
|
|
3412
|
+
if (this.listenerCount("error") === 0) {
|
|
3413
|
+
this.emit("error", err);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
function createWebSocketStream2(ws, options) {
|
|
3417
|
+
let terminateOnDestroy = true;
|
|
3418
|
+
const duplex = new Duplex(__spreadProps(__spreadValues({}, options), {
|
|
3419
|
+
autoDestroy: false,
|
|
3420
|
+
emitClose: false,
|
|
3421
|
+
objectMode: false,
|
|
3422
|
+
writableObjectMode: false
|
|
3423
|
+
}));
|
|
3424
|
+
ws.on("message", function message(msg, isBinary) {
|
|
3425
|
+
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
3426
|
+
if (!duplex.push(data)) ws.pause();
|
|
3427
|
+
});
|
|
3428
|
+
ws.once("error", function error(err) {
|
|
3429
|
+
if (duplex.destroyed) return;
|
|
3430
|
+
terminateOnDestroy = false;
|
|
3431
|
+
duplex.destroy(err);
|
|
3432
|
+
});
|
|
3433
|
+
ws.once("close", function close() {
|
|
3434
|
+
if (duplex.destroyed) return;
|
|
3435
|
+
duplex.push(null);
|
|
3436
|
+
});
|
|
3437
|
+
duplex._destroy = function(err, callback) {
|
|
3438
|
+
if (ws.readyState === ws.CLOSED) {
|
|
3439
|
+
callback(err);
|
|
3440
|
+
process.nextTick(emitClose, duplex);
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
let called = false;
|
|
3444
|
+
ws.once("error", function error(err2) {
|
|
3445
|
+
called = true;
|
|
3446
|
+
callback(err2);
|
|
3447
|
+
});
|
|
3448
|
+
ws.once("close", function close() {
|
|
3449
|
+
if (!called) callback(err);
|
|
3450
|
+
process.nextTick(emitClose, duplex);
|
|
3451
|
+
});
|
|
3452
|
+
if (terminateOnDestroy) ws.terminate();
|
|
3453
|
+
};
|
|
3454
|
+
duplex._final = function(callback) {
|
|
3455
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
3456
|
+
ws.once("open", function open() {
|
|
3457
|
+
duplex._final(callback);
|
|
3458
|
+
});
|
|
3459
|
+
return;
|
|
3460
|
+
}
|
|
3461
|
+
if (ws._socket === null) return;
|
|
3462
|
+
if (ws._socket._writableState.finished) {
|
|
3463
|
+
callback();
|
|
3464
|
+
if (duplex._readableState.endEmitted) duplex.destroy();
|
|
3465
|
+
} else {
|
|
3466
|
+
ws._socket.once("finish", function finish() {
|
|
3467
|
+
callback();
|
|
3468
|
+
});
|
|
3469
|
+
ws.close();
|
|
3470
|
+
}
|
|
3471
|
+
};
|
|
3472
|
+
duplex._read = function() {
|
|
3473
|
+
if (ws.isPaused) ws.resume();
|
|
3474
|
+
};
|
|
3475
|
+
duplex._write = function(chunk, encoding, callback) {
|
|
3476
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
3477
|
+
ws.once("open", function open() {
|
|
3478
|
+
duplex._write(chunk, encoding, callback);
|
|
3479
|
+
});
|
|
3480
|
+
return;
|
|
3481
|
+
}
|
|
3482
|
+
ws.send(chunk, callback);
|
|
3483
|
+
};
|
|
3484
|
+
duplex.on("end", duplexOnEnd);
|
|
3485
|
+
duplex.on("error", duplexOnError);
|
|
3486
|
+
return duplex;
|
|
3487
|
+
}
|
|
3488
|
+
module.exports = createWebSocketStream2;
|
|
3489
|
+
}
|
|
3490
|
+
});
|
|
3491
|
+
|
|
3492
|
+
// ../node_modules/ws/lib/subprotocol.js
|
|
3334
3493
|
var require_subprotocol = __commonJS({
|
|
3335
|
-
"node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
3494
|
+
"../node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
3336
3495
|
"use strict";
|
|
3337
3496
|
var { tokenChars } = require_validation();
|
|
3338
3497
|
function parse(header) {
|
|
@@ -3375,19 +3534,19 @@ var require_subprotocol = __commonJS({
|
|
|
3375
3534
|
}
|
|
3376
3535
|
});
|
|
3377
3536
|
|
|
3378
|
-
// node_modules/ws/lib/websocket-server.js
|
|
3537
|
+
// ../node_modules/ws/lib/websocket-server.js
|
|
3379
3538
|
var require_websocket_server = __commonJS({
|
|
3380
|
-
"node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3539
|
+
"../node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3381
3540
|
"use strict";
|
|
3382
3541
|
var EventEmitter = __require("events");
|
|
3383
3542
|
var http = __require("http");
|
|
3384
3543
|
var { Duplex } = __require("stream");
|
|
3385
3544
|
var { createHash } = __require("crypto");
|
|
3386
|
-
var
|
|
3387
|
-
var
|
|
3388
|
-
var
|
|
3545
|
+
var extension2 = require_extension();
|
|
3546
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3547
|
+
var subprotocol2 = require_subprotocol();
|
|
3389
3548
|
var WebSocket3 = require_websocket();
|
|
3390
|
-
var { GUID, kWebSocket } = require_constants();
|
|
3549
|
+
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
|
|
3391
3550
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
3392
3551
|
var RUNNING = 0;
|
|
3393
3552
|
var CLOSING = 1;
|
|
@@ -3406,8 +3565,15 @@ var require_websocket_server = __commonJS({
|
|
|
3406
3565
|
* pending connections
|
|
3407
3566
|
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
|
3408
3567
|
* track clients
|
|
3568
|
+
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
|
|
3569
|
+
* wait for the closing handshake to finish after `websocket.close()` is
|
|
3570
|
+
* called
|
|
3409
3571
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3410
3572
|
* @param {String} [options.host] The hostname where to bind the server
|
|
3573
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
3574
|
+
* buffered data chunks
|
|
3575
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
3576
|
+
* fragments
|
|
3411
3577
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3412
3578
|
* size
|
|
3413
3579
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -3429,11 +3595,14 @@ var require_websocket_server = __commonJS({
|
|
|
3429
3595
|
options = __spreadValues({
|
|
3430
3596
|
allowSynchronousEvents: true,
|
|
3431
3597
|
autoPong: true,
|
|
3598
|
+
maxBufferedChunks: 256 * 1024,
|
|
3599
|
+
maxFragments: 16 * 1024,
|
|
3432
3600
|
maxPayload: 100 * 1024 * 1024,
|
|
3433
3601
|
skipUTF8Validation: false,
|
|
3434
3602
|
perMessageDeflate: false,
|
|
3435
3603
|
handleProtocols: null,
|
|
3436
3604
|
clientTracking: true,
|
|
3605
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
3437
3606
|
verifyClient: null,
|
|
3438
3607
|
noServer: false,
|
|
3439
3608
|
backlog: null,
|
|
@@ -3588,9 +3757,11 @@ var require_websocket_server = __commonJS({
|
|
|
3588
3757
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
3589
3758
|
return;
|
|
3590
3759
|
}
|
|
3591
|
-
if (version !==
|
|
3760
|
+
if (version !== 13 && version !== 8) {
|
|
3592
3761
|
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
3593
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message
|
|
3762
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
3763
|
+
"Sec-WebSocket-Version": "13, 8"
|
|
3764
|
+
});
|
|
3594
3765
|
return;
|
|
3595
3766
|
}
|
|
3596
3767
|
if (!this.shouldHandle(req)) {
|
|
@@ -3601,7 +3772,7 @@ var require_websocket_server = __commonJS({
|
|
|
3601
3772
|
let protocols = /* @__PURE__ */ new Set();
|
|
3602
3773
|
if (secWebSocketProtocol !== void 0) {
|
|
3603
3774
|
try {
|
|
3604
|
-
protocols =
|
|
3775
|
+
protocols = subprotocol2.parse(secWebSocketProtocol);
|
|
3605
3776
|
} catch (err) {
|
|
3606
3777
|
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
3607
3778
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
@@ -3611,16 +3782,15 @@ var require_websocket_server = __commonJS({
|
|
|
3611
3782
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
3612
3783
|
const extensions = {};
|
|
3613
3784
|
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
3614
|
-
const perMessageDeflate = new
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
);
|
|
3785
|
+
const perMessageDeflate = new PerMessageDeflate2(__spreadProps(__spreadValues({}, this.options.perMessageDeflate), {
|
|
3786
|
+
isServer: true,
|
|
3787
|
+
maxPayload: this.options.maxPayload
|
|
3788
|
+
}));
|
|
3619
3789
|
try {
|
|
3620
|
-
const offers =
|
|
3621
|
-
if (offers[
|
|
3622
|
-
perMessageDeflate.accept(offers[
|
|
3623
|
-
extensions[
|
|
3790
|
+
const offers = extension2.parse(secWebSocketExtensions);
|
|
3791
|
+
if (offers[PerMessageDeflate2.extensionName]) {
|
|
3792
|
+
perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
|
|
3793
|
+
extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3624
3794
|
}
|
|
3625
3795
|
} catch (err) {
|
|
3626
3796
|
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
@@ -3691,10 +3861,10 @@ var require_websocket_server = __commonJS({
|
|
|
3691
3861
|
ws._protocol = protocol;
|
|
3692
3862
|
}
|
|
3693
3863
|
}
|
|
3694
|
-
if (extensions[
|
|
3695
|
-
const params = extensions[
|
|
3696
|
-
const value =
|
|
3697
|
-
[
|
|
3864
|
+
if (extensions[PerMessageDeflate2.extensionName]) {
|
|
3865
|
+
const params = extensions[PerMessageDeflate2.extensionName].params;
|
|
3866
|
+
const value = extension2.format({
|
|
3867
|
+
[PerMessageDeflate2.extensionName]: [params]
|
|
3698
3868
|
});
|
|
3699
3869
|
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
3700
3870
|
ws._extensions = extensions;
|
|
@@ -3704,6 +3874,8 @@ var require_websocket_server = __commonJS({
|
|
|
3704
3874
|
socket.removeListener("error", socketOnError);
|
|
3705
3875
|
ws.setSocket(socket, head, {
|
|
3706
3876
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
3877
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
3878
|
+
maxFragments: this.options.maxFragments,
|
|
3707
3879
|
maxPayload: this.options.maxPayload,
|
|
3708
3880
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
3709
3881
|
});
|
|
@@ -3748,35 +3920,41 @@ var require_websocket_server = __commonJS({
|
|
|
3748
3920
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
|
|
3749
3921
|
);
|
|
3750
3922
|
}
|
|
3751
|
-
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
3923
|
+
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
|
|
3752
3924
|
if (server.listenerCount("wsClientError")) {
|
|
3753
3925
|
const err = new Error(message);
|
|
3754
3926
|
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
3755
3927
|
server.emit("wsClientError", err, socket, req);
|
|
3756
3928
|
} else {
|
|
3757
|
-
abortHandshake(socket, code, message);
|
|
3929
|
+
abortHandshake(socket, code, message, headers);
|
|
3758
3930
|
}
|
|
3759
3931
|
}
|
|
3760
3932
|
}
|
|
3761
3933
|
});
|
|
3762
3934
|
|
|
3763
|
-
// node_modules/ws/wrapper.mjs
|
|
3935
|
+
// ../node_modules/ws/wrapper.mjs
|
|
3764
3936
|
var wrapper_exports = {};
|
|
3765
3937
|
__export(wrapper_exports, {
|
|
3938
|
+
PerMessageDeflate: () => import_permessage_deflate.default,
|
|
3766
3939
|
Receiver: () => import_receiver.default,
|
|
3767
3940
|
Sender: () => import_sender.default,
|
|
3768
3941
|
WebSocket: () => import_websocket.default,
|
|
3769
3942
|
WebSocketServer: () => import_websocket_server.default,
|
|
3770
3943
|
createWebSocketStream: () => import_stream.default,
|
|
3771
|
-
default: () => wrapper_default
|
|
3944
|
+
default: () => wrapper_default,
|
|
3945
|
+
extension: () => import_extension.default,
|
|
3946
|
+
subprotocol: () => import_subprotocol.default
|
|
3772
3947
|
});
|
|
3773
|
-
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
|
|
3948
|
+
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
|
|
3774
3949
|
var init_wrapper = __esm({
|
|
3775
|
-
"node_modules/ws/wrapper.mjs"() {
|
|
3950
|
+
"../node_modules/ws/wrapper.mjs"() {
|
|
3776
3951
|
"use strict";
|
|
3777
3952
|
import_stream = __toESM(require_stream(), 1);
|
|
3953
|
+
import_extension = __toESM(require_extension(), 1);
|
|
3954
|
+
import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
3778
3955
|
import_receiver = __toESM(require_receiver(), 1);
|
|
3779
3956
|
import_sender = __toESM(require_sender(), 1);
|
|
3957
|
+
import_subprotocol = __toESM(require_subprotocol(), 1);
|
|
3780
3958
|
import_websocket = __toESM(require_websocket(), 1);
|
|
3781
3959
|
import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
3782
3960
|
wrapper_default = import_websocket.default;
|
|
@@ -3928,6 +4106,29 @@ var makeRequest = (method, path, params, body) => __async(null, null, function*
|
|
|
3928
4106
|
}
|
|
3929
4107
|
});
|
|
3930
4108
|
|
|
4109
|
+
// src/identity/scopes.ts
|
|
4110
|
+
function customScope(name) {
|
|
4111
|
+
const clean = String(name || "").trim().toLowerCase();
|
|
4112
|
+
return clean.startsWith("custom:") ? clean : `custom:${clean}`;
|
|
4113
|
+
}
|
|
4114
|
+
function getScopes(projectId) {
|
|
4115
|
+
return __async(this, null, function* () {
|
|
4116
|
+
return yield makeRequest("get" /* GET */, "/api/identity/scopes", { projectId });
|
|
4117
|
+
});
|
|
4118
|
+
}
|
|
4119
|
+
function createCustomScope(input) {
|
|
4120
|
+
return __async(this, null, function* () {
|
|
4121
|
+
return yield makeRequest("post" /* POST */, "/api/identity/scopes", void 0, __spreadProps(__spreadValues({}, input), {
|
|
4122
|
+
name: customScope(input.name)
|
|
4123
|
+
}));
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
function deleteCustomScope(id) {
|
|
4127
|
+
return __async(this, null, function* () {
|
|
4128
|
+
yield makeRequest("delete" /* DELETE */, `/api/identity/scopes/${id}`);
|
|
4129
|
+
});
|
|
4130
|
+
}
|
|
4131
|
+
|
|
3931
4132
|
// src/auth/index.ts
|
|
3932
4133
|
init_login();
|
|
3933
4134
|
init_getaccesstoken();
|
|
@@ -3947,11 +4148,16 @@ var verifyToken = (token) => __async(null, null, function* () {
|
|
|
3947
4148
|
});
|
|
3948
4149
|
|
|
3949
4150
|
// src/auth/verifyservicetoken.ts
|
|
3950
|
-
var verifyServiceToken = (token,
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
scope
|
|
3954
|
-
})
|
|
4151
|
+
var verifyServiceToken = (token, scopeOrOptions) => __async(null, null, function* () {
|
|
4152
|
+
const body = { token };
|
|
4153
|
+
if (typeof scopeOrOptions === "string") {
|
|
4154
|
+
body.scope = scopeOrOptions;
|
|
4155
|
+
} else if (scopeOrOptions && typeof scopeOrOptions === "object") {
|
|
4156
|
+
if (scopeOrOptions.scope) body.scope = scopeOrOptions.scope;
|
|
4157
|
+
if (scopeOrOptions.scopes) body.scopes = scopeOrOptions.scopes;
|
|
4158
|
+
if (scopeOrOptions.match) body.match = scopeOrOptions.match;
|
|
4159
|
+
}
|
|
4160
|
+
return yield makeRequest("post" /* POST */, "/api/verify-service-token", void 0, body);
|
|
3955
4161
|
});
|
|
3956
4162
|
|
|
3957
4163
|
// src/identity/index.ts
|
|
@@ -5927,11 +6133,14 @@ export {
|
|
|
5927
6133
|
blob,
|
|
5928
6134
|
boolean,
|
|
5929
6135
|
changePassword,
|
|
6136
|
+
createCustomScope,
|
|
5930
6137
|
createRole,
|
|
5931
6138
|
createService,
|
|
5932
6139
|
createUser,
|
|
6140
|
+
customScope,
|
|
5933
6141
|
db,
|
|
5934
6142
|
defineTable,
|
|
6143
|
+
deleteCustomScope,
|
|
5935
6144
|
deleteRole,
|
|
5936
6145
|
deleteService,
|
|
5937
6146
|
deleteUser,
|
|
@@ -5941,6 +6150,7 @@ export {
|
|
|
5941
6150
|
getConfiguration,
|
|
5942
6151
|
getProfile,
|
|
5943
6152
|
getRoles,
|
|
6153
|
+
getScopes,
|
|
5944
6154
|
getServices,
|
|
5945
6155
|
getUsers,
|
|
5946
6156
|
initializeSdk,
|