@base44-preview/cli 0.2.3-pr.659.75c0aac → 0.2.3-pr.679.6c901cc
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/cli/index.js +520 -3195
- package/dist/cli/index.js.map +15 -27
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -171420,2889 +171420,6 @@ var require_tmp = __commonJS(function(exports, module) {
|
|
|
171420
171420
|
exports.setGracefulCleanup = setGracefulCleanup;
|
|
171421
171421
|
});
|
|
171422
171422
|
|
|
171423
|
-
// ../../node_modules/ws/lib/constants.js
|
|
171424
|
-
var require_constants6 = __commonJS(function(exports, module) {
|
|
171425
|
-
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
171426
|
-
var hasBlob = typeof Blob !== "undefined";
|
|
171427
|
-
if (hasBlob)
|
|
171428
|
-
BINARY_TYPES.push("blob");
|
|
171429
|
-
module.exports = {
|
|
171430
|
-
BINARY_TYPES,
|
|
171431
|
-
CLOSE_TIMEOUT: 30000,
|
|
171432
|
-
EMPTY_BUFFER: Buffer.alloc(0),
|
|
171433
|
-
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
171434
|
-
hasBlob,
|
|
171435
|
-
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
|
171436
|
-
kListener: Symbol("kListener"),
|
|
171437
|
-
kStatusCode: Symbol("status-code"),
|
|
171438
|
-
kWebSocket: Symbol("websocket"),
|
|
171439
|
-
NOOP: () => {}
|
|
171440
|
-
};
|
|
171441
|
-
});
|
|
171442
|
-
|
|
171443
|
-
// ../../node_modules/ws/lib/buffer-util.js
|
|
171444
|
-
var require_buffer_util = __commonJS(function(exports, module) {
|
|
171445
|
-
var { EMPTY_BUFFER } = require_constants6();
|
|
171446
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
171447
|
-
function concat(list, totalLength) {
|
|
171448
|
-
if (list.length === 0)
|
|
171449
|
-
return EMPTY_BUFFER;
|
|
171450
|
-
if (list.length === 1)
|
|
171451
|
-
return list[0];
|
|
171452
|
-
const target = Buffer.allocUnsafe(totalLength);
|
|
171453
|
-
let offset = 0;
|
|
171454
|
-
for (let i = 0;i < list.length; i++) {
|
|
171455
|
-
const buf = list[i];
|
|
171456
|
-
target.set(buf, offset);
|
|
171457
|
-
offset += buf.length;
|
|
171458
|
-
}
|
|
171459
|
-
if (offset < totalLength) {
|
|
171460
|
-
return new FastBuffer(target.buffer, target.byteOffset, offset);
|
|
171461
|
-
}
|
|
171462
|
-
return target;
|
|
171463
|
-
}
|
|
171464
|
-
function _mask(source, mask, output, offset, length) {
|
|
171465
|
-
for (let i = 0;i < length; i++) {
|
|
171466
|
-
output[offset + i] = source[i] ^ mask[i & 3];
|
|
171467
|
-
}
|
|
171468
|
-
}
|
|
171469
|
-
function _unmask(buffer, mask) {
|
|
171470
|
-
for (let i = 0;i < buffer.length; i++) {
|
|
171471
|
-
buffer[i] ^= mask[i & 3];
|
|
171472
|
-
}
|
|
171473
|
-
}
|
|
171474
|
-
function toArrayBuffer(buf) {
|
|
171475
|
-
if (buf.length === buf.buffer.byteLength) {
|
|
171476
|
-
return buf.buffer;
|
|
171477
|
-
}
|
|
171478
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
171479
|
-
}
|
|
171480
|
-
function toBuffer(data) {
|
|
171481
|
-
toBuffer.readOnly = true;
|
|
171482
|
-
if (Buffer.isBuffer(data))
|
|
171483
|
-
return data;
|
|
171484
|
-
let buf;
|
|
171485
|
-
if (data instanceof ArrayBuffer) {
|
|
171486
|
-
buf = new FastBuffer(data);
|
|
171487
|
-
} else if (ArrayBuffer.isView(data)) {
|
|
171488
|
-
buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
|
|
171489
|
-
} else {
|
|
171490
|
-
buf = Buffer.from(data);
|
|
171491
|
-
toBuffer.readOnly = false;
|
|
171492
|
-
}
|
|
171493
|
-
return buf;
|
|
171494
|
-
}
|
|
171495
|
-
module.exports = {
|
|
171496
|
-
concat,
|
|
171497
|
-
mask: _mask,
|
|
171498
|
-
toArrayBuffer,
|
|
171499
|
-
toBuffer,
|
|
171500
|
-
unmask: _unmask
|
|
171501
|
-
};
|
|
171502
|
-
if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
171503
|
-
try {
|
|
171504
|
-
const bufferUtil = (()=>{throw new Error("Cannot require module "+"bufferutil");})();
|
|
171505
|
-
module.exports.mask = function(source, mask2, output, offset, length) {
|
|
171506
|
-
if (length < 48)
|
|
171507
|
-
_mask(source, mask2, output, offset, length);
|
|
171508
|
-
else
|
|
171509
|
-
bufferUtil.mask(source, mask2, output, offset, length);
|
|
171510
|
-
};
|
|
171511
|
-
module.exports.unmask = function(buffer, mask) {
|
|
171512
|
-
if (buffer.length < 32)
|
|
171513
|
-
_unmask(buffer, mask);
|
|
171514
|
-
else
|
|
171515
|
-
bufferUtil.unmask(buffer, mask);
|
|
171516
|
-
};
|
|
171517
|
-
} catch (e) {}
|
|
171518
|
-
}
|
|
171519
|
-
});
|
|
171520
|
-
|
|
171521
|
-
// ../../node_modules/ws/lib/limiter.js
|
|
171522
|
-
var require_limiter = __commonJS(function(exports, module) {
|
|
171523
|
-
var kDone = Symbol("kDone");
|
|
171524
|
-
var kRun = Symbol("kRun");
|
|
171525
|
-
|
|
171526
|
-
class Limiter {
|
|
171527
|
-
constructor(concurrency) {
|
|
171528
|
-
this[kDone] = () => {
|
|
171529
|
-
this.pending--;
|
|
171530
|
-
this[kRun]();
|
|
171531
|
-
};
|
|
171532
|
-
this.concurrency = concurrency || Infinity;
|
|
171533
|
-
this.jobs = [];
|
|
171534
|
-
this.pending = 0;
|
|
171535
|
-
}
|
|
171536
|
-
add(job) {
|
|
171537
|
-
this.jobs.push(job);
|
|
171538
|
-
this[kRun]();
|
|
171539
|
-
}
|
|
171540
|
-
[kRun]() {
|
|
171541
|
-
if (this.pending === this.concurrency)
|
|
171542
|
-
return;
|
|
171543
|
-
if (this.jobs.length) {
|
|
171544
|
-
const job = this.jobs.shift();
|
|
171545
|
-
this.pending++;
|
|
171546
|
-
job(this[kDone]);
|
|
171547
|
-
}
|
|
171548
|
-
}
|
|
171549
|
-
}
|
|
171550
|
-
module.exports = Limiter;
|
|
171551
|
-
});
|
|
171552
|
-
|
|
171553
|
-
// ../../node_modules/ws/lib/permessage-deflate.js
|
|
171554
|
-
var require_permessage_deflate = __commonJS(function(exports, module) {
|
|
171555
|
-
var zlib = __require("zlib");
|
|
171556
|
-
var bufferUtil = require_buffer_util();
|
|
171557
|
-
var Limiter = require_limiter();
|
|
171558
|
-
var { kStatusCode } = require_constants6();
|
|
171559
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
171560
|
-
var TRAILER = Buffer.from([0, 0, 255, 255]);
|
|
171561
|
-
var kPerMessageDeflate = Symbol("permessage-deflate");
|
|
171562
|
-
var kTotalLength = Symbol("total-length");
|
|
171563
|
-
var kCallback = Symbol("callback");
|
|
171564
|
-
var kBuffers = Symbol("buffers");
|
|
171565
|
-
var kError = Symbol("error");
|
|
171566
|
-
var zlibLimiter;
|
|
171567
|
-
|
|
171568
|
-
class PerMessageDeflate {
|
|
171569
|
-
constructor(options) {
|
|
171570
|
-
this._options = options || {};
|
|
171571
|
-
this._threshold = this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
171572
|
-
this._maxPayload = this._options.maxPayload | 0;
|
|
171573
|
-
this._isServer = !!this._options.isServer;
|
|
171574
|
-
this._deflate = null;
|
|
171575
|
-
this._inflate = null;
|
|
171576
|
-
this.params = null;
|
|
171577
|
-
if (!zlibLimiter) {
|
|
171578
|
-
const concurrency = this._options.concurrencyLimit !== undefined ? this._options.concurrencyLimit : 10;
|
|
171579
|
-
zlibLimiter = new Limiter(concurrency);
|
|
171580
|
-
}
|
|
171581
|
-
}
|
|
171582
|
-
static get extensionName() {
|
|
171583
|
-
return "permessage-deflate";
|
|
171584
|
-
}
|
|
171585
|
-
offer() {
|
|
171586
|
-
const params = {};
|
|
171587
|
-
if (this._options.serverNoContextTakeover) {
|
|
171588
|
-
params.server_no_context_takeover = true;
|
|
171589
|
-
}
|
|
171590
|
-
if (this._options.clientNoContextTakeover) {
|
|
171591
|
-
params.client_no_context_takeover = true;
|
|
171592
|
-
}
|
|
171593
|
-
if (this._options.serverMaxWindowBits) {
|
|
171594
|
-
params.server_max_window_bits = this._options.serverMaxWindowBits;
|
|
171595
|
-
}
|
|
171596
|
-
if (this._options.clientMaxWindowBits) {
|
|
171597
|
-
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
171598
|
-
} else if (this._options.clientMaxWindowBits == null) {
|
|
171599
|
-
params.client_max_window_bits = true;
|
|
171600
|
-
}
|
|
171601
|
-
return params;
|
|
171602
|
-
}
|
|
171603
|
-
accept(configurations) {
|
|
171604
|
-
configurations = this.normalizeParams(configurations);
|
|
171605
|
-
this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
|
|
171606
|
-
return this.params;
|
|
171607
|
-
}
|
|
171608
|
-
cleanup() {
|
|
171609
|
-
if (this._inflate) {
|
|
171610
|
-
this._inflate.close();
|
|
171611
|
-
this._inflate = null;
|
|
171612
|
-
}
|
|
171613
|
-
if (this._deflate) {
|
|
171614
|
-
const callback = this._deflate[kCallback];
|
|
171615
|
-
this._deflate.close();
|
|
171616
|
-
this._deflate = null;
|
|
171617
|
-
if (callback) {
|
|
171618
|
-
callback(new Error("The deflate stream was closed while data was being processed"));
|
|
171619
|
-
}
|
|
171620
|
-
}
|
|
171621
|
-
}
|
|
171622
|
-
acceptAsServer(offers) {
|
|
171623
|
-
const opts = this._options;
|
|
171624
|
-
const accepted = offers.find((params) => {
|
|
171625
|
-
if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
|
|
171626
|
-
return false;
|
|
171627
|
-
}
|
|
171628
|
-
return true;
|
|
171629
|
-
});
|
|
171630
|
-
if (!accepted) {
|
|
171631
|
-
throw new Error("None of the extension offers can be accepted");
|
|
171632
|
-
}
|
|
171633
|
-
if (opts.serverNoContextTakeover) {
|
|
171634
|
-
accepted.server_no_context_takeover = true;
|
|
171635
|
-
}
|
|
171636
|
-
if (opts.clientNoContextTakeover) {
|
|
171637
|
-
accepted.client_no_context_takeover = true;
|
|
171638
|
-
}
|
|
171639
|
-
if (typeof opts.serverMaxWindowBits === "number") {
|
|
171640
|
-
accepted.server_max_window_bits = opts.serverMaxWindowBits;
|
|
171641
|
-
}
|
|
171642
|
-
if (typeof opts.clientMaxWindowBits === "number") {
|
|
171643
|
-
accepted.client_max_window_bits = opts.clientMaxWindowBits;
|
|
171644
|
-
} else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
|
|
171645
|
-
delete accepted.client_max_window_bits;
|
|
171646
|
-
}
|
|
171647
|
-
return accepted;
|
|
171648
|
-
}
|
|
171649
|
-
acceptAsClient(response) {
|
|
171650
|
-
const params = response[0];
|
|
171651
|
-
if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
|
|
171652
|
-
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
|
171653
|
-
}
|
|
171654
|
-
if (!params.client_max_window_bits) {
|
|
171655
|
-
if (typeof this._options.clientMaxWindowBits === "number") {
|
|
171656
|
-
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
171657
|
-
}
|
|
171658
|
-
} else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
|
|
171659
|
-
throw new Error('Unexpected or invalid parameter "client_max_window_bits"');
|
|
171660
|
-
}
|
|
171661
|
-
return params;
|
|
171662
|
-
}
|
|
171663
|
-
normalizeParams(configurations) {
|
|
171664
|
-
configurations.forEach((params) => {
|
|
171665
|
-
Object.keys(params).forEach((key) => {
|
|
171666
|
-
let value = params[key];
|
|
171667
|
-
if (value.length > 1) {
|
|
171668
|
-
throw new Error(`Parameter "${key}" must have only a single value`);
|
|
171669
|
-
}
|
|
171670
|
-
value = value[0];
|
|
171671
|
-
if (key === "client_max_window_bits") {
|
|
171672
|
-
if (value !== true) {
|
|
171673
|
-
const num = +value;
|
|
171674
|
-
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
171675
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
171676
|
-
}
|
|
171677
|
-
value = num;
|
|
171678
|
-
} else if (!this._isServer) {
|
|
171679
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
171680
|
-
}
|
|
171681
|
-
} else if (key === "server_max_window_bits") {
|
|
171682
|
-
const num = +value;
|
|
171683
|
-
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
171684
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
171685
|
-
}
|
|
171686
|
-
value = num;
|
|
171687
|
-
} else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
|
|
171688
|
-
if (value !== true) {
|
|
171689
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
171690
|
-
}
|
|
171691
|
-
} else {
|
|
171692
|
-
throw new Error(`Unknown parameter "${key}"`);
|
|
171693
|
-
}
|
|
171694
|
-
params[key] = value;
|
|
171695
|
-
});
|
|
171696
|
-
});
|
|
171697
|
-
return configurations;
|
|
171698
|
-
}
|
|
171699
|
-
decompress(data, fin, callback) {
|
|
171700
|
-
zlibLimiter.add((done) => {
|
|
171701
|
-
this._decompress(data, fin, (err, result) => {
|
|
171702
|
-
done();
|
|
171703
|
-
callback(err, result);
|
|
171704
|
-
});
|
|
171705
|
-
});
|
|
171706
|
-
}
|
|
171707
|
-
compress(data, fin, callback) {
|
|
171708
|
-
zlibLimiter.add((done) => {
|
|
171709
|
-
this._compress(data, fin, (err, result) => {
|
|
171710
|
-
done();
|
|
171711
|
-
callback(err, result);
|
|
171712
|
-
});
|
|
171713
|
-
});
|
|
171714
|
-
}
|
|
171715
|
-
_decompress(data, fin, callback) {
|
|
171716
|
-
const endpoint = this._isServer ? "client" : "server";
|
|
171717
|
-
if (!this._inflate) {
|
|
171718
|
-
const key = `${endpoint}_max_window_bits`;
|
|
171719
|
-
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
171720
|
-
this._inflate = zlib.createInflateRaw({
|
|
171721
|
-
...this._options.zlibInflateOptions,
|
|
171722
|
-
windowBits
|
|
171723
|
-
});
|
|
171724
|
-
this._inflate[kPerMessageDeflate] = this;
|
|
171725
|
-
this._inflate[kTotalLength] = 0;
|
|
171726
|
-
this._inflate[kBuffers] = [];
|
|
171727
|
-
this._inflate.on("error", inflateOnError);
|
|
171728
|
-
this._inflate.on("data", inflateOnData);
|
|
171729
|
-
}
|
|
171730
|
-
this._inflate[kCallback] = callback;
|
|
171731
|
-
this._inflate.write(data);
|
|
171732
|
-
if (fin)
|
|
171733
|
-
this._inflate.write(TRAILER);
|
|
171734
|
-
this._inflate.flush(() => {
|
|
171735
|
-
const err = this._inflate[kError];
|
|
171736
|
-
if (err) {
|
|
171737
|
-
this._inflate.close();
|
|
171738
|
-
this._inflate = null;
|
|
171739
|
-
callback(err);
|
|
171740
|
-
return;
|
|
171741
|
-
}
|
|
171742
|
-
const data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
171743
|
-
if (this._inflate._readableState.endEmitted) {
|
|
171744
|
-
this._inflate.close();
|
|
171745
|
-
this._inflate = null;
|
|
171746
|
-
} else {
|
|
171747
|
-
this._inflate[kTotalLength] = 0;
|
|
171748
|
-
this._inflate[kBuffers] = [];
|
|
171749
|
-
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
171750
|
-
this._inflate.reset();
|
|
171751
|
-
}
|
|
171752
|
-
}
|
|
171753
|
-
callback(null, data);
|
|
171754
|
-
});
|
|
171755
|
-
}
|
|
171756
|
-
_compress(data, fin, callback) {
|
|
171757
|
-
const endpoint = this._isServer ? "server" : "client";
|
|
171758
|
-
if (!this._deflate) {
|
|
171759
|
-
const key = `${endpoint}_max_window_bits`;
|
|
171760
|
-
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
171761
|
-
this._deflate = zlib.createDeflateRaw({
|
|
171762
|
-
...this._options.zlibDeflateOptions,
|
|
171763
|
-
windowBits
|
|
171764
|
-
});
|
|
171765
|
-
this._deflate[kTotalLength] = 0;
|
|
171766
|
-
this._deflate[kBuffers] = [];
|
|
171767
|
-
this._deflate.on("data", deflateOnData);
|
|
171768
|
-
}
|
|
171769
|
-
this._deflate[kCallback] = callback;
|
|
171770
|
-
this._deflate.write(data);
|
|
171771
|
-
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
171772
|
-
if (!this._deflate) {
|
|
171773
|
-
return;
|
|
171774
|
-
}
|
|
171775
|
-
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
171776
|
-
if (fin) {
|
|
171777
|
-
data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
|
|
171778
|
-
}
|
|
171779
|
-
this._deflate[kCallback] = null;
|
|
171780
|
-
this._deflate[kTotalLength] = 0;
|
|
171781
|
-
this._deflate[kBuffers] = [];
|
|
171782
|
-
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
171783
|
-
this._deflate.reset();
|
|
171784
|
-
}
|
|
171785
|
-
callback(null, data);
|
|
171786
|
-
});
|
|
171787
|
-
}
|
|
171788
|
-
}
|
|
171789
|
-
module.exports = PerMessageDeflate;
|
|
171790
|
-
function deflateOnData(chunk) {
|
|
171791
|
-
this[kBuffers].push(chunk);
|
|
171792
|
-
this[kTotalLength] += chunk.length;
|
|
171793
|
-
}
|
|
171794
|
-
function inflateOnData(chunk) {
|
|
171795
|
-
this[kTotalLength] += chunk.length;
|
|
171796
|
-
if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
|
|
171797
|
-
this[kBuffers].push(chunk);
|
|
171798
|
-
return;
|
|
171799
|
-
}
|
|
171800
|
-
this[kError] = new RangeError("Max payload size exceeded");
|
|
171801
|
-
this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
|
|
171802
|
-
this[kError][kStatusCode] = 1009;
|
|
171803
|
-
this.removeListener("data", inflateOnData);
|
|
171804
|
-
this.reset();
|
|
171805
|
-
}
|
|
171806
|
-
function inflateOnError(err) {
|
|
171807
|
-
this[kPerMessageDeflate]._inflate = null;
|
|
171808
|
-
if (this[kError]) {
|
|
171809
|
-
this[kCallback](this[kError]);
|
|
171810
|
-
return;
|
|
171811
|
-
}
|
|
171812
|
-
err[kStatusCode] = 1007;
|
|
171813
|
-
this[kCallback](err);
|
|
171814
|
-
}
|
|
171815
|
-
});
|
|
171816
|
-
|
|
171817
|
-
// ../../node_modules/ws/lib/validation.js
|
|
171818
|
-
var require_validation = __commonJS(function(exports, module) {
|
|
171819
|
-
var { isUtf8 } = __require("buffer");
|
|
171820
|
-
var { hasBlob } = require_constants6();
|
|
171821
|
-
var tokenChars = [
|
|
171822
|
-
0,
|
|
171823
|
-
0,
|
|
171824
|
-
0,
|
|
171825
|
-
0,
|
|
171826
|
-
0,
|
|
171827
|
-
0,
|
|
171828
|
-
0,
|
|
171829
|
-
0,
|
|
171830
|
-
0,
|
|
171831
|
-
0,
|
|
171832
|
-
0,
|
|
171833
|
-
0,
|
|
171834
|
-
0,
|
|
171835
|
-
0,
|
|
171836
|
-
0,
|
|
171837
|
-
0,
|
|
171838
|
-
0,
|
|
171839
|
-
0,
|
|
171840
|
-
0,
|
|
171841
|
-
0,
|
|
171842
|
-
0,
|
|
171843
|
-
0,
|
|
171844
|
-
0,
|
|
171845
|
-
0,
|
|
171846
|
-
0,
|
|
171847
|
-
0,
|
|
171848
|
-
0,
|
|
171849
|
-
0,
|
|
171850
|
-
0,
|
|
171851
|
-
0,
|
|
171852
|
-
0,
|
|
171853
|
-
0,
|
|
171854
|
-
0,
|
|
171855
|
-
1,
|
|
171856
|
-
0,
|
|
171857
|
-
1,
|
|
171858
|
-
1,
|
|
171859
|
-
1,
|
|
171860
|
-
1,
|
|
171861
|
-
1,
|
|
171862
|
-
0,
|
|
171863
|
-
0,
|
|
171864
|
-
1,
|
|
171865
|
-
1,
|
|
171866
|
-
0,
|
|
171867
|
-
1,
|
|
171868
|
-
1,
|
|
171869
|
-
0,
|
|
171870
|
-
1,
|
|
171871
|
-
1,
|
|
171872
|
-
1,
|
|
171873
|
-
1,
|
|
171874
|
-
1,
|
|
171875
|
-
1,
|
|
171876
|
-
1,
|
|
171877
|
-
1,
|
|
171878
|
-
1,
|
|
171879
|
-
1,
|
|
171880
|
-
0,
|
|
171881
|
-
0,
|
|
171882
|
-
0,
|
|
171883
|
-
0,
|
|
171884
|
-
0,
|
|
171885
|
-
0,
|
|
171886
|
-
0,
|
|
171887
|
-
1,
|
|
171888
|
-
1,
|
|
171889
|
-
1,
|
|
171890
|
-
1,
|
|
171891
|
-
1,
|
|
171892
|
-
1,
|
|
171893
|
-
1,
|
|
171894
|
-
1,
|
|
171895
|
-
1,
|
|
171896
|
-
1,
|
|
171897
|
-
1,
|
|
171898
|
-
1,
|
|
171899
|
-
1,
|
|
171900
|
-
1,
|
|
171901
|
-
1,
|
|
171902
|
-
1,
|
|
171903
|
-
1,
|
|
171904
|
-
1,
|
|
171905
|
-
1,
|
|
171906
|
-
1,
|
|
171907
|
-
1,
|
|
171908
|
-
1,
|
|
171909
|
-
1,
|
|
171910
|
-
1,
|
|
171911
|
-
1,
|
|
171912
|
-
1,
|
|
171913
|
-
0,
|
|
171914
|
-
0,
|
|
171915
|
-
0,
|
|
171916
|
-
1,
|
|
171917
|
-
1,
|
|
171918
|
-
1,
|
|
171919
|
-
1,
|
|
171920
|
-
1,
|
|
171921
|
-
1,
|
|
171922
|
-
1,
|
|
171923
|
-
1,
|
|
171924
|
-
1,
|
|
171925
|
-
1,
|
|
171926
|
-
1,
|
|
171927
|
-
1,
|
|
171928
|
-
1,
|
|
171929
|
-
1,
|
|
171930
|
-
1,
|
|
171931
|
-
1,
|
|
171932
|
-
1,
|
|
171933
|
-
1,
|
|
171934
|
-
1,
|
|
171935
|
-
1,
|
|
171936
|
-
1,
|
|
171937
|
-
1,
|
|
171938
|
-
1,
|
|
171939
|
-
1,
|
|
171940
|
-
1,
|
|
171941
|
-
1,
|
|
171942
|
-
1,
|
|
171943
|
-
1,
|
|
171944
|
-
1,
|
|
171945
|
-
0,
|
|
171946
|
-
1,
|
|
171947
|
-
0,
|
|
171948
|
-
1,
|
|
171949
|
-
0
|
|
171950
|
-
];
|
|
171951
|
-
function isValidStatusCode(code) {
|
|
171952
|
-
return code >= 1000 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3000 && code <= 4999;
|
|
171953
|
-
}
|
|
171954
|
-
function _isValidUTF8(buf) {
|
|
171955
|
-
const len = buf.length;
|
|
171956
|
-
let i = 0;
|
|
171957
|
-
while (i < len) {
|
|
171958
|
-
if ((buf[i] & 128) === 0) {
|
|
171959
|
-
i++;
|
|
171960
|
-
} else if ((buf[i] & 224) === 192) {
|
|
171961
|
-
if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
|
|
171962
|
-
return false;
|
|
171963
|
-
}
|
|
171964
|
-
i += 2;
|
|
171965
|
-
} else if ((buf[i] & 240) === 224) {
|
|
171966
|
-
if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) {
|
|
171967
|
-
return false;
|
|
171968
|
-
}
|
|
171969
|
-
i += 3;
|
|
171970
|
-
} else if ((buf[i] & 248) === 240) {
|
|
171971
|
-
if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
|
|
171972
|
-
return false;
|
|
171973
|
-
}
|
|
171974
|
-
i += 4;
|
|
171975
|
-
} else {
|
|
171976
|
-
return false;
|
|
171977
|
-
}
|
|
171978
|
-
}
|
|
171979
|
-
return true;
|
|
171980
|
-
}
|
|
171981
|
-
function isBlob(value) {
|
|
171982
|
-
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");
|
|
171983
|
-
}
|
|
171984
|
-
module.exports = {
|
|
171985
|
-
isBlob,
|
|
171986
|
-
isValidStatusCode,
|
|
171987
|
-
isValidUTF8: _isValidUTF8,
|
|
171988
|
-
tokenChars
|
|
171989
|
-
};
|
|
171990
|
-
if (isUtf8) {
|
|
171991
|
-
module.exports.isValidUTF8 = function(buf) {
|
|
171992
|
-
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
171993
|
-
};
|
|
171994
|
-
} else if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
171995
|
-
try {
|
|
171996
|
-
const isValidUTF8 = (()=>{throw new Error("Cannot require module "+"utf-8-validate");})();
|
|
171997
|
-
module.exports.isValidUTF8 = function(buf) {
|
|
171998
|
-
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
171999
|
-
};
|
|
172000
|
-
} catch (e) {}
|
|
172001
|
-
}
|
|
172002
|
-
});
|
|
172003
|
-
|
|
172004
|
-
// ../../node_modules/ws/lib/receiver.js
|
|
172005
|
-
var require_receiver = __commonJS(function(exports, module) {
|
|
172006
|
-
var { Writable } = __require("stream");
|
|
172007
|
-
var PerMessageDeflate = require_permessage_deflate();
|
|
172008
|
-
var {
|
|
172009
|
-
BINARY_TYPES,
|
|
172010
|
-
EMPTY_BUFFER,
|
|
172011
|
-
kStatusCode,
|
|
172012
|
-
kWebSocket
|
|
172013
|
-
} = require_constants6();
|
|
172014
|
-
var { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
172015
|
-
var { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
172016
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
172017
|
-
var GET_INFO = 0;
|
|
172018
|
-
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
172019
|
-
var GET_PAYLOAD_LENGTH_64 = 2;
|
|
172020
|
-
var GET_MASK = 3;
|
|
172021
|
-
var GET_DATA = 4;
|
|
172022
|
-
var INFLATING = 5;
|
|
172023
|
-
var DEFER_EVENT = 6;
|
|
172024
|
-
|
|
172025
|
-
class Receiver extends Writable {
|
|
172026
|
-
constructor(options = {}) {
|
|
172027
|
-
super();
|
|
172028
|
-
this._allowSynchronousEvents = options.allowSynchronousEvents !== undefined ? options.allowSynchronousEvents : true;
|
|
172029
|
-
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
172030
|
-
this._extensions = options.extensions || {};
|
|
172031
|
-
this._isServer = !!options.isServer;
|
|
172032
|
-
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
172033
|
-
this._maxFragments = options.maxFragments | 0;
|
|
172034
|
-
this._maxPayload = options.maxPayload | 0;
|
|
172035
|
-
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
172036
|
-
this[kWebSocket] = undefined;
|
|
172037
|
-
this._bufferedBytes = 0;
|
|
172038
|
-
this._buffers = [];
|
|
172039
|
-
this._compressed = false;
|
|
172040
|
-
this._payloadLength = 0;
|
|
172041
|
-
this._mask = undefined;
|
|
172042
|
-
this._fragmented = 0;
|
|
172043
|
-
this._masked = false;
|
|
172044
|
-
this._fin = false;
|
|
172045
|
-
this._opcode = 0;
|
|
172046
|
-
this._totalPayloadLength = 0;
|
|
172047
|
-
this._messageLength = 0;
|
|
172048
|
-
this._fragments = [];
|
|
172049
|
-
this._errored = false;
|
|
172050
|
-
this._loop = false;
|
|
172051
|
-
this._state = GET_INFO;
|
|
172052
|
-
}
|
|
172053
|
-
_write(chunk, encoding, cb) {
|
|
172054
|
-
if (this._opcode === 8 && this._state == GET_INFO)
|
|
172055
|
-
return cb();
|
|
172056
|
-
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
172057
|
-
cb(this.createError(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
172058
|
-
return;
|
|
172059
|
-
}
|
|
172060
|
-
this._bufferedBytes += chunk.length;
|
|
172061
|
-
this._buffers.push(chunk);
|
|
172062
|
-
this.startLoop(cb);
|
|
172063
|
-
}
|
|
172064
|
-
consume(n) {
|
|
172065
|
-
this._bufferedBytes -= n;
|
|
172066
|
-
if (n === this._buffers[0].length)
|
|
172067
|
-
return this._buffers.shift();
|
|
172068
|
-
if (n < this._buffers[0].length) {
|
|
172069
|
-
const buf = this._buffers[0];
|
|
172070
|
-
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
172071
|
-
return new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
172072
|
-
}
|
|
172073
|
-
const dst = Buffer.allocUnsafe(n);
|
|
172074
|
-
do {
|
|
172075
|
-
const buf = this._buffers[0];
|
|
172076
|
-
const offset = dst.length - n;
|
|
172077
|
-
if (n >= buf.length) {
|
|
172078
|
-
dst.set(this._buffers.shift(), offset);
|
|
172079
|
-
} else {
|
|
172080
|
-
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
|
172081
|
-
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
172082
|
-
}
|
|
172083
|
-
n -= buf.length;
|
|
172084
|
-
} while (n > 0);
|
|
172085
|
-
return dst;
|
|
172086
|
-
}
|
|
172087
|
-
startLoop(cb) {
|
|
172088
|
-
this._loop = true;
|
|
172089
|
-
do {
|
|
172090
|
-
switch (this._state) {
|
|
172091
|
-
case GET_INFO:
|
|
172092
|
-
this.getInfo(cb);
|
|
172093
|
-
break;
|
|
172094
|
-
case GET_PAYLOAD_LENGTH_16:
|
|
172095
|
-
this.getPayloadLength16(cb);
|
|
172096
|
-
break;
|
|
172097
|
-
case GET_PAYLOAD_LENGTH_64:
|
|
172098
|
-
this.getPayloadLength64(cb);
|
|
172099
|
-
break;
|
|
172100
|
-
case GET_MASK:
|
|
172101
|
-
this.getMask();
|
|
172102
|
-
break;
|
|
172103
|
-
case GET_DATA:
|
|
172104
|
-
this.getData(cb);
|
|
172105
|
-
break;
|
|
172106
|
-
case INFLATING:
|
|
172107
|
-
case DEFER_EVENT:
|
|
172108
|
-
this._loop = false;
|
|
172109
|
-
return;
|
|
172110
|
-
}
|
|
172111
|
-
} while (this._loop);
|
|
172112
|
-
if (!this._errored)
|
|
172113
|
-
cb();
|
|
172114
|
-
}
|
|
172115
|
-
getInfo(cb) {
|
|
172116
|
-
if (this._bufferedBytes < 2) {
|
|
172117
|
-
this._loop = false;
|
|
172118
|
-
return;
|
|
172119
|
-
}
|
|
172120
|
-
const buf = this.consume(2);
|
|
172121
|
-
if ((buf[0] & 48) !== 0) {
|
|
172122
|
-
const error = this.createError(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
|
|
172123
|
-
cb(error);
|
|
172124
|
-
return;
|
|
172125
|
-
}
|
|
172126
|
-
const compressed = (buf[0] & 64) === 64;
|
|
172127
|
-
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
172128
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
172129
|
-
cb(error);
|
|
172130
|
-
return;
|
|
172131
|
-
}
|
|
172132
|
-
this._fin = (buf[0] & 128) === 128;
|
|
172133
|
-
this._opcode = buf[0] & 15;
|
|
172134
|
-
this._payloadLength = buf[1] & 127;
|
|
172135
|
-
if (this._opcode === 0) {
|
|
172136
|
-
if (compressed) {
|
|
172137
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
172138
|
-
cb(error);
|
|
172139
|
-
return;
|
|
172140
|
-
}
|
|
172141
|
-
if (!this._fragmented) {
|
|
172142
|
-
const error = this.createError(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
172143
|
-
cb(error);
|
|
172144
|
-
return;
|
|
172145
|
-
}
|
|
172146
|
-
this._opcode = this._fragmented;
|
|
172147
|
-
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
172148
|
-
if (this._fragmented) {
|
|
172149
|
-
const error = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
172150
|
-
cb(error);
|
|
172151
|
-
return;
|
|
172152
|
-
}
|
|
172153
|
-
this._compressed = compressed;
|
|
172154
|
-
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
172155
|
-
if (!this._fin) {
|
|
172156
|
-
const error = this.createError(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN");
|
|
172157
|
-
cb(error);
|
|
172158
|
-
return;
|
|
172159
|
-
}
|
|
172160
|
-
if (compressed) {
|
|
172161
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
172162
|
-
cb(error);
|
|
172163
|
-
return;
|
|
172164
|
-
}
|
|
172165
|
-
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
172166
|
-
const error = this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
|
|
172167
|
-
cb(error);
|
|
172168
|
-
return;
|
|
172169
|
-
}
|
|
172170
|
-
} else {
|
|
172171
|
-
const error = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
172172
|
-
cb(error);
|
|
172173
|
-
return;
|
|
172174
|
-
}
|
|
172175
|
-
if (!this._fin && !this._fragmented)
|
|
172176
|
-
this._fragmented = this._opcode;
|
|
172177
|
-
this._masked = (buf[1] & 128) === 128;
|
|
172178
|
-
if (this._isServer) {
|
|
172179
|
-
if (!this._masked) {
|
|
172180
|
-
const error = this.createError(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK");
|
|
172181
|
-
cb(error);
|
|
172182
|
-
return;
|
|
172183
|
-
}
|
|
172184
|
-
} else if (this._masked) {
|
|
172185
|
-
const error = this.createError(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK");
|
|
172186
|
-
cb(error);
|
|
172187
|
-
return;
|
|
172188
|
-
}
|
|
172189
|
-
if (this._payloadLength === 126)
|
|
172190
|
-
this._state = GET_PAYLOAD_LENGTH_16;
|
|
172191
|
-
else if (this._payloadLength === 127)
|
|
172192
|
-
this._state = GET_PAYLOAD_LENGTH_64;
|
|
172193
|
-
else
|
|
172194
|
-
this.haveLength(cb);
|
|
172195
|
-
}
|
|
172196
|
-
getPayloadLength16(cb) {
|
|
172197
|
-
if (this._bufferedBytes < 2) {
|
|
172198
|
-
this._loop = false;
|
|
172199
|
-
return;
|
|
172200
|
-
}
|
|
172201
|
-
this._payloadLength = this.consume(2).readUInt16BE(0);
|
|
172202
|
-
this.haveLength(cb);
|
|
172203
|
-
}
|
|
172204
|
-
getPayloadLength64(cb) {
|
|
172205
|
-
if (this._bufferedBytes < 8) {
|
|
172206
|
-
this._loop = false;
|
|
172207
|
-
return;
|
|
172208
|
-
}
|
|
172209
|
-
const buf = this.consume(8);
|
|
172210
|
-
const num = buf.readUInt32BE(0);
|
|
172211
|
-
if (num > Math.pow(2, 53 - 32) - 1) {
|
|
172212
|
-
const error = this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
|
|
172213
|
-
cb(error);
|
|
172214
|
-
return;
|
|
172215
|
-
}
|
|
172216
|
-
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
172217
|
-
this.haveLength(cb);
|
|
172218
|
-
}
|
|
172219
|
-
haveLength(cb) {
|
|
172220
|
-
if (this._payloadLength && this._opcode < 8) {
|
|
172221
|
-
this._totalPayloadLength += this._payloadLength;
|
|
172222
|
-
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
172223
|
-
const error = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
172224
|
-
cb(error);
|
|
172225
|
-
return;
|
|
172226
|
-
}
|
|
172227
|
-
}
|
|
172228
|
-
if (this._masked)
|
|
172229
|
-
this._state = GET_MASK;
|
|
172230
|
-
else
|
|
172231
|
-
this._state = GET_DATA;
|
|
172232
|
-
}
|
|
172233
|
-
getMask() {
|
|
172234
|
-
if (this._bufferedBytes < 4) {
|
|
172235
|
-
this._loop = false;
|
|
172236
|
-
return;
|
|
172237
|
-
}
|
|
172238
|
-
this._mask = this.consume(4);
|
|
172239
|
-
this._state = GET_DATA;
|
|
172240
|
-
}
|
|
172241
|
-
getData(cb) {
|
|
172242
|
-
let data = EMPTY_BUFFER;
|
|
172243
|
-
if (this._payloadLength) {
|
|
172244
|
-
if (this._bufferedBytes < this._payloadLength) {
|
|
172245
|
-
this._loop = false;
|
|
172246
|
-
return;
|
|
172247
|
-
}
|
|
172248
|
-
data = this.consume(this._payloadLength);
|
|
172249
|
-
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
|
|
172250
|
-
unmask(data, this._mask);
|
|
172251
|
-
}
|
|
172252
|
-
}
|
|
172253
|
-
if (this._opcode > 7) {
|
|
172254
|
-
this.controlMessage(data, cb);
|
|
172255
|
-
return;
|
|
172256
|
-
}
|
|
172257
|
-
if (this._compressed) {
|
|
172258
|
-
this._state = INFLATING;
|
|
172259
|
-
this.decompress(data, cb);
|
|
172260
|
-
return;
|
|
172261
|
-
}
|
|
172262
|
-
if (data.length) {
|
|
172263
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
172264
|
-
const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
|
|
172265
|
-
cb(error);
|
|
172266
|
-
return;
|
|
172267
|
-
}
|
|
172268
|
-
this._messageLength = this._totalPayloadLength;
|
|
172269
|
-
this._fragments.push(data);
|
|
172270
|
-
}
|
|
172271
|
-
this.dataMessage(cb);
|
|
172272
|
-
}
|
|
172273
|
-
decompress(data, cb) {
|
|
172274
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
172275
|
-
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
172276
|
-
if (err)
|
|
172277
|
-
return cb(err);
|
|
172278
|
-
if (buf.length) {
|
|
172279
|
-
this._messageLength += buf.length;
|
|
172280
|
-
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
172281
|
-
const error = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
172282
|
-
cb(error);
|
|
172283
|
-
return;
|
|
172284
|
-
}
|
|
172285
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
172286
|
-
const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
|
|
172287
|
-
cb(error);
|
|
172288
|
-
return;
|
|
172289
|
-
}
|
|
172290
|
-
this._fragments.push(buf);
|
|
172291
|
-
}
|
|
172292
|
-
this.dataMessage(cb);
|
|
172293
|
-
if (this._state === GET_INFO)
|
|
172294
|
-
this.startLoop(cb);
|
|
172295
|
-
});
|
|
172296
|
-
}
|
|
172297
|
-
dataMessage(cb) {
|
|
172298
|
-
if (!this._fin) {
|
|
172299
|
-
this._state = GET_INFO;
|
|
172300
|
-
return;
|
|
172301
|
-
}
|
|
172302
|
-
const messageLength = this._messageLength;
|
|
172303
|
-
const fragments = this._fragments;
|
|
172304
|
-
this._totalPayloadLength = 0;
|
|
172305
|
-
this._messageLength = 0;
|
|
172306
|
-
this._fragmented = 0;
|
|
172307
|
-
this._fragments = [];
|
|
172308
|
-
if (this._opcode === 2) {
|
|
172309
|
-
let data;
|
|
172310
|
-
if (this._binaryType === "nodebuffer") {
|
|
172311
|
-
data = concat(fragments, messageLength);
|
|
172312
|
-
} else if (this._binaryType === "arraybuffer") {
|
|
172313
|
-
data = toArrayBuffer(concat(fragments, messageLength));
|
|
172314
|
-
} else if (this._binaryType === "blob") {
|
|
172315
|
-
data = new Blob(fragments);
|
|
172316
|
-
} else {
|
|
172317
|
-
data = fragments;
|
|
172318
|
-
}
|
|
172319
|
-
if (this._allowSynchronousEvents) {
|
|
172320
|
-
this.emit("message", data, true);
|
|
172321
|
-
this._state = GET_INFO;
|
|
172322
|
-
} else {
|
|
172323
|
-
this._state = DEFER_EVENT;
|
|
172324
|
-
setImmediate(() => {
|
|
172325
|
-
this.emit("message", data, true);
|
|
172326
|
-
this._state = GET_INFO;
|
|
172327
|
-
this.startLoop(cb);
|
|
172328
|
-
});
|
|
172329
|
-
}
|
|
172330
|
-
} else {
|
|
172331
|
-
const buf = concat(fragments, messageLength);
|
|
172332
|
-
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
172333
|
-
const error = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
172334
|
-
cb(error);
|
|
172335
|
-
return;
|
|
172336
|
-
}
|
|
172337
|
-
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
172338
|
-
this.emit("message", buf, false);
|
|
172339
|
-
this._state = GET_INFO;
|
|
172340
|
-
} else {
|
|
172341
|
-
this._state = DEFER_EVENT;
|
|
172342
|
-
setImmediate(() => {
|
|
172343
|
-
this.emit("message", buf, false);
|
|
172344
|
-
this._state = GET_INFO;
|
|
172345
|
-
this.startLoop(cb);
|
|
172346
|
-
});
|
|
172347
|
-
}
|
|
172348
|
-
}
|
|
172349
|
-
}
|
|
172350
|
-
controlMessage(data, cb) {
|
|
172351
|
-
if (this._opcode === 8) {
|
|
172352
|
-
if (data.length === 0) {
|
|
172353
|
-
this._loop = false;
|
|
172354
|
-
this.emit("conclude", 1005, EMPTY_BUFFER);
|
|
172355
|
-
this.end();
|
|
172356
|
-
} else {
|
|
172357
|
-
const code = data.readUInt16BE(0);
|
|
172358
|
-
if (!isValidStatusCode(code)) {
|
|
172359
|
-
const error = this.createError(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE");
|
|
172360
|
-
cb(error);
|
|
172361
|
-
return;
|
|
172362
|
-
}
|
|
172363
|
-
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
172364
|
-
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
172365
|
-
const error = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
172366
|
-
cb(error);
|
|
172367
|
-
return;
|
|
172368
|
-
}
|
|
172369
|
-
this._loop = false;
|
|
172370
|
-
this.emit("conclude", code, buf);
|
|
172371
|
-
this.end();
|
|
172372
|
-
}
|
|
172373
|
-
this._state = GET_INFO;
|
|
172374
|
-
return;
|
|
172375
|
-
}
|
|
172376
|
-
if (this._allowSynchronousEvents) {
|
|
172377
|
-
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
172378
|
-
this._state = GET_INFO;
|
|
172379
|
-
} else {
|
|
172380
|
-
this._state = DEFER_EVENT;
|
|
172381
|
-
setImmediate(() => {
|
|
172382
|
-
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
172383
|
-
this._state = GET_INFO;
|
|
172384
|
-
this.startLoop(cb);
|
|
172385
|
-
});
|
|
172386
|
-
}
|
|
172387
|
-
}
|
|
172388
|
-
createError(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
172389
|
-
this._loop = false;
|
|
172390
|
-
this._errored = true;
|
|
172391
|
-
const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
172392
|
-
Error.captureStackTrace(err, this.createError);
|
|
172393
|
-
err.code = errorCode;
|
|
172394
|
-
err[kStatusCode] = statusCode;
|
|
172395
|
-
return err;
|
|
172396
|
-
}
|
|
172397
|
-
}
|
|
172398
|
-
module.exports = Receiver;
|
|
172399
|
-
});
|
|
172400
|
-
|
|
172401
|
-
// ../../node_modules/ws/lib/sender.js
|
|
172402
|
-
var require_sender = __commonJS(function(exports, module) {
|
|
172403
|
-
var { Duplex } = __require("stream");
|
|
172404
|
-
var { randomFillSync } = __require("crypto");
|
|
172405
|
-
var {
|
|
172406
|
-
types: { isUint8Array }
|
|
172407
|
-
} = __require("util");
|
|
172408
|
-
var PerMessageDeflate = require_permessage_deflate();
|
|
172409
|
-
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants6();
|
|
172410
|
-
var { isBlob, isValidStatusCode } = require_validation();
|
|
172411
|
-
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
172412
|
-
var kByteLength = Symbol("kByteLength");
|
|
172413
|
-
var maskBuffer = Buffer.alloc(4);
|
|
172414
|
-
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
172415
|
-
var randomPool;
|
|
172416
|
-
var randomPoolPointer = RANDOM_POOL_SIZE;
|
|
172417
|
-
var DEFAULT = 0;
|
|
172418
|
-
var DEFLATING = 1;
|
|
172419
|
-
var GET_BLOB_DATA = 2;
|
|
172420
|
-
|
|
172421
|
-
class Sender {
|
|
172422
|
-
constructor(socket, extensions, generateMask) {
|
|
172423
|
-
this._extensions = extensions || {};
|
|
172424
|
-
if (generateMask) {
|
|
172425
|
-
this._generateMask = generateMask;
|
|
172426
|
-
this._maskBuffer = Buffer.alloc(4);
|
|
172427
|
-
}
|
|
172428
|
-
this._socket = socket;
|
|
172429
|
-
this._firstFragment = true;
|
|
172430
|
-
this._compress = false;
|
|
172431
|
-
this._bufferedBytes = 0;
|
|
172432
|
-
this._queue = [];
|
|
172433
|
-
this._state = DEFAULT;
|
|
172434
|
-
this.onerror = NOOP;
|
|
172435
|
-
this[kWebSocket] = undefined;
|
|
172436
|
-
}
|
|
172437
|
-
static frame(data, options) {
|
|
172438
|
-
let mask;
|
|
172439
|
-
let merge = false;
|
|
172440
|
-
let offset = 2;
|
|
172441
|
-
let skipMasking = false;
|
|
172442
|
-
if (options.mask) {
|
|
172443
|
-
mask = options.maskBuffer || maskBuffer;
|
|
172444
|
-
if (options.generateMask) {
|
|
172445
|
-
options.generateMask(mask);
|
|
172446
|
-
} else {
|
|
172447
|
-
if (randomPoolPointer === RANDOM_POOL_SIZE) {
|
|
172448
|
-
if (randomPool === undefined) {
|
|
172449
|
-
randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
|
|
172450
|
-
}
|
|
172451
|
-
randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
|
|
172452
|
-
randomPoolPointer = 0;
|
|
172453
|
-
}
|
|
172454
|
-
mask[0] = randomPool[randomPoolPointer++];
|
|
172455
|
-
mask[1] = randomPool[randomPoolPointer++];
|
|
172456
|
-
mask[2] = randomPool[randomPoolPointer++];
|
|
172457
|
-
mask[3] = randomPool[randomPoolPointer++];
|
|
172458
|
-
}
|
|
172459
|
-
skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
|
|
172460
|
-
offset = 6;
|
|
172461
|
-
}
|
|
172462
|
-
let dataLength;
|
|
172463
|
-
if (typeof data === "string") {
|
|
172464
|
-
if ((!options.mask || skipMasking) && options[kByteLength] !== undefined) {
|
|
172465
|
-
dataLength = options[kByteLength];
|
|
172466
|
-
} else {
|
|
172467
|
-
data = Buffer.from(data);
|
|
172468
|
-
dataLength = data.length;
|
|
172469
|
-
}
|
|
172470
|
-
} else {
|
|
172471
|
-
dataLength = data.length;
|
|
172472
|
-
merge = options.mask && options.readOnly && !skipMasking;
|
|
172473
|
-
}
|
|
172474
|
-
let payloadLength = dataLength;
|
|
172475
|
-
if (dataLength >= 65536) {
|
|
172476
|
-
offset += 8;
|
|
172477
|
-
payloadLength = 127;
|
|
172478
|
-
} else if (dataLength > 125) {
|
|
172479
|
-
offset += 2;
|
|
172480
|
-
payloadLength = 126;
|
|
172481
|
-
}
|
|
172482
|
-
const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
|
|
172483
|
-
target[0] = options.fin ? options.opcode | 128 : options.opcode;
|
|
172484
|
-
if (options.rsv1)
|
|
172485
|
-
target[0] |= 64;
|
|
172486
|
-
target[1] = payloadLength;
|
|
172487
|
-
if (payloadLength === 126) {
|
|
172488
|
-
target.writeUInt16BE(dataLength, 2);
|
|
172489
|
-
} else if (payloadLength === 127) {
|
|
172490
|
-
target[2] = target[3] = 0;
|
|
172491
|
-
target.writeUIntBE(dataLength, 4, 6);
|
|
172492
|
-
}
|
|
172493
|
-
if (!options.mask)
|
|
172494
|
-
return [target, data];
|
|
172495
|
-
target[1] |= 128;
|
|
172496
|
-
target[offset - 4] = mask[0];
|
|
172497
|
-
target[offset - 3] = mask[1];
|
|
172498
|
-
target[offset - 2] = mask[2];
|
|
172499
|
-
target[offset - 1] = mask[3];
|
|
172500
|
-
if (skipMasking)
|
|
172501
|
-
return [target, data];
|
|
172502
|
-
if (merge) {
|
|
172503
|
-
applyMask(data, mask, target, offset, dataLength);
|
|
172504
|
-
return [target];
|
|
172505
|
-
}
|
|
172506
|
-
applyMask(data, mask, data, 0, dataLength);
|
|
172507
|
-
return [target, data];
|
|
172508
|
-
}
|
|
172509
|
-
close(code, data, mask, cb) {
|
|
172510
|
-
let buf;
|
|
172511
|
-
if (code === undefined) {
|
|
172512
|
-
buf = EMPTY_BUFFER;
|
|
172513
|
-
} else if (typeof code !== "number" || !isValidStatusCode(code)) {
|
|
172514
|
-
throw new TypeError("First argument must be a valid error code number");
|
|
172515
|
-
} else if (data === undefined || !data.length) {
|
|
172516
|
-
buf = Buffer.allocUnsafe(2);
|
|
172517
|
-
buf.writeUInt16BE(code, 0);
|
|
172518
|
-
} else {
|
|
172519
|
-
const length = Buffer.byteLength(data);
|
|
172520
|
-
if (length > 123) {
|
|
172521
|
-
throw new RangeError("The message must not be greater than 123 bytes");
|
|
172522
|
-
}
|
|
172523
|
-
buf = Buffer.allocUnsafe(2 + length);
|
|
172524
|
-
buf.writeUInt16BE(code, 0);
|
|
172525
|
-
if (typeof data === "string") {
|
|
172526
|
-
buf.write(data, 2);
|
|
172527
|
-
} else if (isUint8Array(data)) {
|
|
172528
|
-
buf.set(data, 2);
|
|
172529
|
-
} else {
|
|
172530
|
-
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
172531
|
-
}
|
|
172532
|
-
}
|
|
172533
|
-
const options = {
|
|
172534
|
-
[kByteLength]: buf.length,
|
|
172535
|
-
fin: true,
|
|
172536
|
-
generateMask: this._generateMask,
|
|
172537
|
-
mask,
|
|
172538
|
-
maskBuffer: this._maskBuffer,
|
|
172539
|
-
opcode: 8,
|
|
172540
|
-
readOnly: false,
|
|
172541
|
-
rsv1: false
|
|
172542
|
-
};
|
|
172543
|
-
if (this._state !== DEFAULT) {
|
|
172544
|
-
this.enqueue([this.dispatch, buf, false, options, cb]);
|
|
172545
|
-
} else {
|
|
172546
|
-
this.sendFrame(Sender.frame(buf, options), cb);
|
|
172547
|
-
}
|
|
172548
|
-
}
|
|
172549
|
-
ping(data, mask, cb) {
|
|
172550
|
-
let byteLength;
|
|
172551
|
-
let readOnly;
|
|
172552
|
-
if (typeof data === "string") {
|
|
172553
|
-
byteLength = Buffer.byteLength(data);
|
|
172554
|
-
readOnly = false;
|
|
172555
|
-
} else if (isBlob(data)) {
|
|
172556
|
-
byteLength = data.size;
|
|
172557
|
-
readOnly = false;
|
|
172558
|
-
} else {
|
|
172559
|
-
data = toBuffer(data);
|
|
172560
|
-
byteLength = data.length;
|
|
172561
|
-
readOnly = toBuffer.readOnly;
|
|
172562
|
-
}
|
|
172563
|
-
if (byteLength > 125) {
|
|
172564
|
-
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
172565
|
-
}
|
|
172566
|
-
const options = {
|
|
172567
|
-
[kByteLength]: byteLength,
|
|
172568
|
-
fin: true,
|
|
172569
|
-
generateMask: this._generateMask,
|
|
172570
|
-
mask,
|
|
172571
|
-
maskBuffer: this._maskBuffer,
|
|
172572
|
-
opcode: 9,
|
|
172573
|
-
readOnly,
|
|
172574
|
-
rsv1: false
|
|
172575
|
-
};
|
|
172576
|
-
if (isBlob(data)) {
|
|
172577
|
-
if (this._state !== DEFAULT) {
|
|
172578
|
-
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
172579
|
-
} else {
|
|
172580
|
-
this.getBlobData(data, false, options, cb);
|
|
172581
|
-
}
|
|
172582
|
-
} else if (this._state !== DEFAULT) {
|
|
172583
|
-
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
172584
|
-
} else {
|
|
172585
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
172586
|
-
}
|
|
172587
|
-
}
|
|
172588
|
-
pong(data, mask, cb) {
|
|
172589
|
-
let byteLength;
|
|
172590
|
-
let readOnly;
|
|
172591
|
-
if (typeof data === "string") {
|
|
172592
|
-
byteLength = Buffer.byteLength(data);
|
|
172593
|
-
readOnly = false;
|
|
172594
|
-
} else if (isBlob(data)) {
|
|
172595
|
-
byteLength = data.size;
|
|
172596
|
-
readOnly = false;
|
|
172597
|
-
} else {
|
|
172598
|
-
data = toBuffer(data);
|
|
172599
|
-
byteLength = data.length;
|
|
172600
|
-
readOnly = toBuffer.readOnly;
|
|
172601
|
-
}
|
|
172602
|
-
if (byteLength > 125) {
|
|
172603
|
-
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
172604
|
-
}
|
|
172605
|
-
const options = {
|
|
172606
|
-
[kByteLength]: byteLength,
|
|
172607
|
-
fin: true,
|
|
172608
|
-
generateMask: this._generateMask,
|
|
172609
|
-
mask,
|
|
172610
|
-
maskBuffer: this._maskBuffer,
|
|
172611
|
-
opcode: 10,
|
|
172612
|
-
readOnly,
|
|
172613
|
-
rsv1: false
|
|
172614
|
-
};
|
|
172615
|
-
if (isBlob(data)) {
|
|
172616
|
-
if (this._state !== DEFAULT) {
|
|
172617
|
-
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
172618
|
-
} else {
|
|
172619
|
-
this.getBlobData(data, false, options, cb);
|
|
172620
|
-
}
|
|
172621
|
-
} else if (this._state !== DEFAULT) {
|
|
172622
|
-
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
172623
|
-
} else {
|
|
172624
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
172625
|
-
}
|
|
172626
|
-
}
|
|
172627
|
-
send(data, options, cb) {
|
|
172628
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
172629
|
-
let opcode = options.binary ? 2 : 1;
|
|
172630
|
-
let rsv1 = options.compress;
|
|
172631
|
-
let byteLength;
|
|
172632
|
-
let readOnly;
|
|
172633
|
-
if (typeof data === "string") {
|
|
172634
|
-
byteLength = Buffer.byteLength(data);
|
|
172635
|
-
readOnly = false;
|
|
172636
|
-
} else if (isBlob(data)) {
|
|
172637
|
-
byteLength = data.size;
|
|
172638
|
-
readOnly = false;
|
|
172639
|
-
} else {
|
|
172640
|
-
data = toBuffer(data);
|
|
172641
|
-
byteLength = data.length;
|
|
172642
|
-
readOnly = toBuffer.readOnly;
|
|
172643
|
-
}
|
|
172644
|
-
if (this._firstFragment) {
|
|
172645
|
-
this._firstFragment = false;
|
|
172646
|
-
if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
|
|
172647
|
-
rsv1 = byteLength >= perMessageDeflate._threshold;
|
|
172648
|
-
}
|
|
172649
|
-
this._compress = rsv1;
|
|
172650
|
-
} else {
|
|
172651
|
-
rsv1 = false;
|
|
172652
|
-
opcode = 0;
|
|
172653
|
-
}
|
|
172654
|
-
if (options.fin)
|
|
172655
|
-
this._firstFragment = true;
|
|
172656
|
-
const opts = {
|
|
172657
|
-
[kByteLength]: byteLength,
|
|
172658
|
-
fin: options.fin,
|
|
172659
|
-
generateMask: this._generateMask,
|
|
172660
|
-
mask: options.mask,
|
|
172661
|
-
maskBuffer: this._maskBuffer,
|
|
172662
|
-
opcode,
|
|
172663
|
-
readOnly,
|
|
172664
|
-
rsv1
|
|
172665
|
-
};
|
|
172666
|
-
if (isBlob(data)) {
|
|
172667
|
-
if (this._state !== DEFAULT) {
|
|
172668
|
-
this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
|
|
172669
|
-
} else {
|
|
172670
|
-
this.getBlobData(data, this._compress, opts, cb);
|
|
172671
|
-
}
|
|
172672
|
-
} else if (this._state !== DEFAULT) {
|
|
172673
|
-
this.enqueue([this.dispatch, data, this._compress, opts, cb]);
|
|
172674
|
-
} else {
|
|
172675
|
-
this.dispatch(data, this._compress, opts, cb);
|
|
172676
|
-
}
|
|
172677
|
-
}
|
|
172678
|
-
getBlobData(blob, compress, options, cb) {
|
|
172679
|
-
this._bufferedBytes += options[kByteLength];
|
|
172680
|
-
this._state = GET_BLOB_DATA;
|
|
172681
|
-
blob.arrayBuffer().then((arrayBuffer) => {
|
|
172682
|
-
if (this._socket.destroyed) {
|
|
172683
|
-
const err = new Error("The socket was closed while the blob was being read");
|
|
172684
|
-
process.nextTick(callCallbacks, this, err, cb);
|
|
172685
|
-
return;
|
|
172686
|
-
}
|
|
172687
|
-
this._bufferedBytes -= options[kByteLength];
|
|
172688
|
-
const data = toBuffer(arrayBuffer);
|
|
172689
|
-
if (!compress) {
|
|
172690
|
-
this._state = DEFAULT;
|
|
172691
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
172692
|
-
this.dequeue();
|
|
172693
|
-
} else {
|
|
172694
|
-
this.dispatch(data, compress, options, cb);
|
|
172695
|
-
}
|
|
172696
|
-
}).catch((err) => {
|
|
172697
|
-
process.nextTick(onError, this, err, cb);
|
|
172698
|
-
});
|
|
172699
|
-
}
|
|
172700
|
-
dispatch(data, compress, options, cb) {
|
|
172701
|
-
if (!compress) {
|
|
172702
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
172703
|
-
return;
|
|
172704
|
-
}
|
|
172705
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
172706
|
-
this._bufferedBytes += options[kByteLength];
|
|
172707
|
-
this._state = DEFLATING;
|
|
172708
|
-
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
172709
|
-
if (this._socket.destroyed) {
|
|
172710
|
-
const err = new Error("The socket was closed while data was being compressed");
|
|
172711
|
-
callCallbacks(this, err, cb);
|
|
172712
|
-
return;
|
|
172713
|
-
}
|
|
172714
|
-
this._bufferedBytes -= options[kByteLength];
|
|
172715
|
-
this._state = DEFAULT;
|
|
172716
|
-
options.readOnly = false;
|
|
172717
|
-
this.sendFrame(Sender.frame(buf, options), cb);
|
|
172718
|
-
this.dequeue();
|
|
172719
|
-
});
|
|
172720
|
-
}
|
|
172721
|
-
dequeue() {
|
|
172722
|
-
while (this._state === DEFAULT && this._queue.length) {
|
|
172723
|
-
const params = this._queue.shift();
|
|
172724
|
-
this._bufferedBytes -= params[3][kByteLength];
|
|
172725
|
-
Reflect.apply(params[0], this, params.slice(1));
|
|
172726
|
-
}
|
|
172727
|
-
}
|
|
172728
|
-
enqueue(params) {
|
|
172729
|
-
this._bufferedBytes += params[3][kByteLength];
|
|
172730
|
-
this._queue.push(params);
|
|
172731
|
-
}
|
|
172732
|
-
sendFrame(list, cb) {
|
|
172733
|
-
if (list.length === 2) {
|
|
172734
|
-
this._socket.cork();
|
|
172735
|
-
this._socket.write(list[0]);
|
|
172736
|
-
this._socket.write(list[1], cb);
|
|
172737
|
-
this._socket.uncork();
|
|
172738
|
-
} else {
|
|
172739
|
-
this._socket.write(list[0], cb);
|
|
172740
|
-
}
|
|
172741
|
-
}
|
|
172742
|
-
}
|
|
172743
|
-
module.exports = Sender;
|
|
172744
|
-
function callCallbacks(sender, err, cb) {
|
|
172745
|
-
if (typeof cb === "function")
|
|
172746
|
-
cb(err);
|
|
172747
|
-
for (let i = 0;i < sender._queue.length; i++) {
|
|
172748
|
-
const params = sender._queue[i];
|
|
172749
|
-
const callback = params[params.length - 1];
|
|
172750
|
-
if (typeof callback === "function")
|
|
172751
|
-
callback(err);
|
|
172752
|
-
}
|
|
172753
|
-
}
|
|
172754
|
-
function onError(sender, err, cb) {
|
|
172755
|
-
callCallbacks(sender, err, cb);
|
|
172756
|
-
sender.onerror(err);
|
|
172757
|
-
}
|
|
172758
|
-
});
|
|
172759
|
-
|
|
172760
|
-
// ../../node_modules/ws/lib/event-target.js
|
|
172761
|
-
var require_event_target = __commonJS(function(exports, module) {
|
|
172762
|
-
var { kForOnEventAttribute, kListener } = require_constants6();
|
|
172763
|
-
var kCode = Symbol("kCode");
|
|
172764
|
-
var kData = Symbol("kData");
|
|
172765
|
-
var kError = Symbol("kError");
|
|
172766
|
-
var kMessage = Symbol("kMessage");
|
|
172767
|
-
var kReason = Symbol("kReason");
|
|
172768
|
-
var kTarget = Symbol("kTarget");
|
|
172769
|
-
var kType = Symbol("kType");
|
|
172770
|
-
var kWasClean = Symbol("kWasClean");
|
|
172771
|
-
|
|
172772
|
-
class Event2 {
|
|
172773
|
-
constructor(type) {
|
|
172774
|
-
this[kTarget] = null;
|
|
172775
|
-
this[kType] = type;
|
|
172776
|
-
}
|
|
172777
|
-
get target() {
|
|
172778
|
-
return this[kTarget];
|
|
172779
|
-
}
|
|
172780
|
-
get type() {
|
|
172781
|
-
return this[kType];
|
|
172782
|
-
}
|
|
172783
|
-
}
|
|
172784
|
-
Object.defineProperty(Event2.prototype, "target", { enumerable: true });
|
|
172785
|
-
Object.defineProperty(Event2.prototype, "type", { enumerable: true });
|
|
172786
|
-
|
|
172787
|
-
class CloseEvent extends Event2 {
|
|
172788
|
-
constructor(type, options = {}) {
|
|
172789
|
-
super(type);
|
|
172790
|
-
this[kCode] = options.code === undefined ? 0 : options.code;
|
|
172791
|
-
this[kReason] = options.reason === undefined ? "" : options.reason;
|
|
172792
|
-
this[kWasClean] = options.wasClean === undefined ? false : options.wasClean;
|
|
172793
|
-
}
|
|
172794
|
-
get code() {
|
|
172795
|
-
return this[kCode];
|
|
172796
|
-
}
|
|
172797
|
-
get reason() {
|
|
172798
|
-
return this[kReason];
|
|
172799
|
-
}
|
|
172800
|
-
get wasClean() {
|
|
172801
|
-
return this[kWasClean];
|
|
172802
|
-
}
|
|
172803
|
-
}
|
|
172804
|
-
Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
|
|
172805
|
-
Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
|
|
172806
|
-
Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
|
|
172807
|
-
|
|
172808
|
-
class ErrorEvent extends Event2 {
|
|
172809
|
-
constructor(type, options = {}) {
|
|
172810
|
-
super(type);
|
|
172811
|
-
this[kError] = options.error === undefined ? null : options.error;
|
|
172812
|
-
this[kMessage] = options.message === undefined ? "" : options.message;
|
|
172813
|
-
}
|
|
172814
|
-
get error() {
|
|
172815
|
-
return this[kError];
|
|
172816
|
-
}
|
|
172817
|
-
get message() {
|
|
172818
|
-
return this[kMessage];
|
|
172819
|
-
}
|
|
172820
|
-
}
|
|
172821
|
-
Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
|
|
172822
|
-
Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
|
|
172823
|
-
|
|
172824
|
-
class MessageEvent extends Event2 {
|
|
172825
|
-
constructor(type, options = {}) {
|
|
172826
|
-
super(type);
|
|
172827
|
-
this[kData] = options.data === undefined ? null : options.data;
|
|
172828
|
-
}
|
|
172829
|
-
get data() {
|
|
172830
|
-
return this[kData];
|
|
172831
|
-
}
|
|
172832
|
-
}
|
|
172833
|
-
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
172834
|
-
var EventTarget = {
|
|
172835
|
-
addEventListener(type, handler, options = {}) {
|
|
172836
|
-
for (const listener of this.listeners(type)) {
|
|
172837
|
-
if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
172838
|
-
return;
|
|
172839
|
-
}
|
|
172840
|
-
}
|
|
172841
|
-
let wrapper;
|
|
172842
|
-
if (type === "message") {
|
|
172843
|
-
wrapper = function onMessage(data, isBinary) {
|
|
172844
|
-
const event = new MessageEvent("message", {
|
|
172845
|
-
data: isBinary ? data : data.toString()
|
|
172846
|
-
});
|
|
172847
|
-
event[kTarget] = this;
|
|
172848
|
-
callListener(handler, this, event);
|
|
172849
|
-
};
|
|
172850
|
-
} else if (type === "close") {
|
|
172851
|
-
wrapper = function onClose(code, message) {
|
|
172852
|
-
const event = new CloseEvent("close", {
|
|
172853
|
-
code,
|
|
172854
|
-
reason: message.toString(),
|
|
172855
|
-
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
172856
|
-
});
|
|
172857
|
-
event[kTarget] = this;
|
|
172858
|
-
callListener(handler, this, event);
|
|
172859
|
-
};
|
|
172860
|
-
} else if (type === "error") {
|
|
172861
|
-
wrapper = function onError(error) {
|
|
172862
|
-
const event = new ErrorEvent("error", {
|
|
172863
|
-
error,
|
|
172864
|
-
message: error.message
|
|
172865
|
-
});
|
|
172866
|
-
event[kTarget] = this;
|
|
172867
|
-
callListener(handler, this, event);
|
|
172868
|
-
};
|
|
172869
|
-
} else if (type === "open") {
|
|
172870
|
-
wrapper = function onOpen() {
|
|
172871
|
-
const event = new Event2("open");
|
|
172872
|
-
event[kTarget] = this;
|
|
172873
|
-
callListener(handler, this, event);
|
|
172874
|
-
};
|
|
172875
|
-
} else {
|
|
172876
|
-
return;
|
|
172877
|
-
}
|
|
172878
|
-
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
172879
|
-
wrapper[kListener] = handler;
|
|
172880
|
-
if (options.once) {
|
|
172881
|
-
this.once(type, wrapper);
|
|
172882
|
-
} else {
|
|
172883
|
-
this.on(type, wrapper);
|
|
172884
|
-
}
|
|
172885
|
-
},
|
|
172886
|
-
removeEventListener(type, handler) {
|
|
172887
|
-
for (const listener of this.listeners(type)) {
|
|
172888
|
-
if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
172889
|
-
this.removeListener(type, listener);
|
|
172890
|
-
break;
|
|
172891
|
-
}
|
|
172892
|
-
}
|
|
172893
|
-
}
|
|
172894
|
-
};
|
|
172895
|
-
module.exports = {
|
|
172896
|
-
CloseEvent,
|
|
172897
|
-
ErrorEvent,
|
|
172898
|
-
Event: Event2,
|
|
172899
|
-
EventTarget,
|
|
172900
|
-
MessageEvent
|
|
172901
|
-
};
|
|
172902
|
-
function callListener(listener, thisArg, event) {
|
|
172903
|
-
if (typeof listener === "object" && listener.handleEvent) {
|
|
172904
|
-
listener.handleEvent.call(listener, event);
|
|
172905
|
-
} else {
|
|
172906
|
-
listener.call(thisArg, event);
|
|
172907
|
-
}
|
|
172908
|
-
}
|
|
172909
|
-
});
|
|
172910
|
-
|
|
172911
|
-
// ../../node_modules/ws/lib/extension.js
|
|
172912
|
-
var require_extension = __commonJS(function(exports, module) {
|
|
172913
|
-
var { tokenChars } = require_validation();
|
|
172914
|
-
function push(dest, name, elem) {
|
|
172915
|
-
if (dest[name] === undefined)
|
|
172916
|
-
dest[name] = [elem];
|
|
172917
|
-
else
|
|
172918
|
-
dest[name].push(elem);
|
|
172919
|
-
}
|
|
172920
|
-
function parse(header) {
|
|
172921
|
-
const offers = Object.create(null);
|
|
172922
|
-
let params = Object.create(null);
|
|
172923
|
-
let mustUnescape = false;
|
|
172924
|
-
let isEscaping = false;
|
|
172925
|
-
let inQuotes = false;
|
|
172926
|
-
let extensionName;
|
|
172927
|
-
let paramName;
|
|
172928
|
-
let start = -1;
|
|
172929
|
-
let code = -1;
|
|
172930
|
-
let end = -1;
|
|
172931
|
-
let i = 0;
|
|
172932
|
-
for (;i < header.length; i++) {
|
|
172933
|
-
code = header.charCodeAt(i);
|
|
172934
|
-
if (extensionName === undefined) {
|
|
172935
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
172936
|
-
if (start === -1)
|
|
172937
|
-
start = i;
|
|
172938
|
-
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
172939
|
-
if (end === -1 && start !== -1)
|
|
172940
|
-
end = i;
|
|
172941
|
-
} else if (code === 59 || code === 44) {
|
|
172942
|
-
if (start === -1) {
|
|
172943
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
172944
|
-
}
|
|
172945
|
-
if (end === -1)
|
|
172946
|
-
end = i;
|
|
172947
|
-
const name = header.slice(start, end);
|
|
172948
|
-
if (code === 44) {
|
|
172949
|
-
push(offers, name, params);
|
|
172950
|
-
params = Object.create(null);
|
|
172951
|
-
} else {
|
|
172952
|
-
extensionName = name;
|
|
172953
|
-
}
|
|
172954
|
-
start = end = -1;
|
|
172955
|
-
} else {
|
|
172956
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
172957
|
-
}
|
|
172958
|
-
} else if (paramName === undefined) {
|
|
172959
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
172960
|
-
if (start === -1)
|
|
172961
|
-
start = i;
|
|
172962
|
-
} else if (code === 32 || code === 9) {
|
|
172963
|
-
if (end === -1 && start !== -1)
|
|
172964
|
-
end = i;
|
|
172965
|
-
} else if (code === 59 || code === 44) {
|
|
172966
|
-
if (start === -1) {
|
|
172967
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
172968
|
-
}
|
|
172969
|
-
if (end === -1)
|
|
172970
|
-
end = i;
|
|
172971
|
-
push(params, header.slice(start, end), true);
|
|
172972
|
-
if (code === 44) {
|
|
172973
|
-
push(offers, extensionName, params);
|
|
172974
|
-
params = Object.create(null);
|
|
172975
|
-
extensionName = undefined;
|
|
172976
|
-
}
|
|
172977
|
-
start = end = -1;
|
|
172978
|
-
} else if (code === 61 && start !== -1 && end === -1) {
|
|
172979
|
-
paramName = header.slice(start, i);
|
|
172980
|
-
start = end = -1;
|
|
172981
|
-
} else {
|
|
172982
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
172983
|
-
}
|
|
172984
|
-
} else {
|
|
172985
|
-
if (isEscaping) {
|
|
172986
|
-
if (tokenChars[code] !== 1) {
|
|
172987
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
172988
|
-
}
|
|
172989
|
-
if (start === -1)
|
|
172990
|
-
start = i;
|
|
172991
|
-
else if (!mustUnescape)
|
|
172992
|
-
mustUnescape = true;
|
|
172993
|
-
isEscaping = false;
|
|
172994
|
-
} else if (inQuotes) {
|
|
172995
|
-
if (tokenChars[code] === 1) {
|
|
172996
|
-
if (start === -1)
|
|
172997
|
-
start = i;
|
|
172998
|
-
} else if (code === 34 && start !== -1) {
|
|
172999
|
-
inQuotes = false;
|
|
173000
|
-
end = i;
|
|
173001
|
-
} else if (code === 92) {
|
|
173002
|
-
isEscaping = true;
|
|
173003
|
-
} else {
|
|
173004
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
173005
|
-
}
|
|
173006
|
-
} else if (code === 34 && header.charCodeAt(i - 1) === 61) {
|
|
173007
|
-
inQuotes = true;
|
|
173008
|
-
} else if (end === -1 && tokenChars[code] === 1) {
|
|
173009
|
-
if (start === -1)
|
|
173010
|
-
start = i;
|
|
173011
|
-
} else if (start !== -1 && (code === 32 || code === 9)) {
|
|
173012
|
-
if (end === -1)
|
|
173013
|
-
end = i;
|
|
173014
|
-
} else if (code === 59 || code === 44) {
|
|
173015
|
-
if (start === -1) {
|
|
173016
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
173017
|
-
}
|
|
173018
|
-
if (end === -1)
|
|
173019
|
-
end = i;
|
|
173020
|
-
let value = header.slice(start, end);
|
|
173021
|
-
if (mustUnescape) {
|
|
173022
|
-
value = value.replace(/\\/g, "");
|
|
173023
|
-
mustUnescape = false;
|
|
173024
|
-
}
|
|
173025
|
-
push(params, paramName, value);
|
|
173026
|
-
if (code === 44) {
|
|
173027
|
-
push(offers, extensionName, params);
|
|
173028
|
-
params = Object.create(null);
|
|
173029
|
-
extensionName = undefined;
|
|
173030
|
-
}
|
|
173031
|
-
paramName = undefined;
|
|
173032
|
-
start = end = -1;
|
|
173033
|
-
} else {
|
|
173034
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
173035
|
-
}
|
|
173036
|
-
}
|
|
173037
|
-
}
|
|
173038
|
-
if (start === -1 || inQuotes || code === 32 || code === 9) {
|
|
173039
|
-
throw new SyntaxError("Unexpected end of input");
|
|
173040
|
-
}
|
|
173041
|
-
if (end === -1)
|
|
173042
|
-
end = i;
|
|
173043
|
-
const token = header.slice(start, end);
|
|
173044
|
-
if (extensionName === undefined) {
|
|
173045
|
-
push(offers, token, params);
|
|
173046
|
-
} else {
|
|
173047
|
-
if (paramName === undefined) {
|
|
173048
|
-
push(params, token, true);
|
|
173049
|
-
} else if (mustUnescape) {
|
|
173050
|
-
push(params, paramName, token.replace(/\\/g, ""));
|
|
173051
|
-
} else {
|
|
173052
|
-
push(params, paramName, token);
|
|
173053
|
-
}
|
|
173054
|
-
push(offers, extensionName, params);
|
|
173055
|
-
}
|
|
173056
|
-
return offers;
|
|
173057
|
-
}
|
|
173058
|
-
function format(extensions) {
|
|
173059
|
-
return Object.keys(extensions).map((extension) => {
|
|
173060
|
-
let configurations = extensions[extension];
|
|
173061
|
-
if (!Array.isArray(configurations))
|
|
173062
|
-
configurations = [configurations];
|
|
173063
|
-
return configurations.map((params) => {
|
|
173064
|
-
return [extension].concat(Object.keys(params).map((k) => {
|
|
173065
|
-
let values = params[k];
|
|
173066
|
-
if (!Array.isArray(values))
|
|
173067
|
-
values = [values];
|
|
173068
|
-
return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
173069
|
-
})).join("; ");
|
|
173070
|
-
}).join(", ");
|
|
173071
|
-
}).join(", ");
|
|
173072
|
-
}
|
|
173073
|
-
module.exports = { format, parse };
|
|
173074
|
-
});
|
|
173075
|
-
|
|
173076
|
-
// ../../node_modules/ws/lib/websocket.js
|
|
173077
|
-
var require_websocket = __commonJS(function(exports, module) {
|
|
173078
|
-
var EventEmitter = __require("events");
|
|
173079
|
-
var https = __require("https");
|
|
173080
|
-
var http = __require("http");
|
|
173081
|
-
var net = __require("net");
|
|
173082
|
-
var tls = __require("tls");
|
|
173083
|
-
var { randomBytes, createHash } = __require("crypto");
|
|
173084
|
-
var { Duplex, Readable } = __require("stream");
|
|
173085
|
-
var { URL: URL2 } = __require("url");
|
|
173086
|
-
var PerMessageDeflate = require_permessage_deflate();
|
|
173087
|
-
var Receiver = require_receiver();
|
|
173088
|
-
var Sender = require_sender();
|
|
173089
|
-
var { isBlob } = require_validation();
|
|
173090
|
-
var {
|
|
173091
|
-
BINARY_TYPES,
|
|
173092
|
-
CLOSE_TIMEOUT,
|
|
173093
|
-
EMPTY_BUFFER,
|
|
173094
|
-
GUID,
|
|
173095
|
-
kForOnEventAttribute,
|
|
173096
|
-
kListener,
|
|
173097
|
-
kStatusCode,
|
|
173098
|
-
kWebSocket,
|
|
173099
|
-
NOOP
|
|
173100
|
-
} = require_constants6();
|
|
173101
|
-
var {
|
|
173102
|
-
EventTarget: { addEventListener, removeEventListener }
|
|
173103
|
-
} = require_event_target();
|
|
173104
|
-
var { format, parse } = require_extension();
|
|
173105
|
-
var { toBuffer } = require_buffer_util();
|
|
173106
|
-
var kAborted = Symbol("kAborted");
|
|
173107
|
-
var protocolVersions = [8, 13];
|
|
173108
|
-
var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
173109
|
-
var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
173110
|
-
|
|
173111
|
-
class WebSocket extends EventEmitter {
|
|
173112
|
-
constructor(address, protocols, options) {
|
|
173113
|
-
super();
|
|
173114
|
-
this._binaryType = BINARY_TYPES[0];
|
|
173115
|
-
this._closeCode = 1006;
|
|
173116
|
-
this._closeFrameReceived = false;
|
|
173117
|
-
this._closeFrameSent = false;
|
|
173118
|
-
this._closeMessage = EMPTY_BUFFER;
|
|
173119
|
-
this._closeTimer = null;
|
|
173120
|
-
this._errorEmitted = false;
|
|
173121
|
-
this._extensions = {};
|
|
173122
|
-
this._paused = false;
|
|
173123
|
-
this._protocol = "";
|
|
173124
|
-
this._readyState = WebSocket.CONNECTING;
|
|
173125
|
-
this._receiver = null;
|
|
173126
|
-
this._sender = null;
|
|
173127
|
-
this._socket = null;
|
|
173128
|
-
if (address !== null) {
|
|
173129
|
-
this._bufferedAmount = 0;
|
|
173130
|
-
this._isServer = false;
|
|
173131
|
-
this._redirects = 0;
|
|
173132
|
-
if (protocols === undefined) {
|
|
173133
|
-
protocols = [];
|
|
173134
|
-
} else if (!Array.isArray(protocols)) {
|
|
173135
|
-
if (typeof protocols === "object" && protocols !== null) {
|
|
173136
|
-
options = protocols;
|
|
173137
|
-
protocols = [];
|
|
173138
|
-
} else {
|
|
173139
|
-
protocols = [protocols];
|
|
173140
|
-
}
|
|
173141
|
-
}
|
|
173142
|
-
initAsClient(this, address, protocols, options);
|
|
173143
|
-
} else {
|
|
173144
|
-
this._autoPong = options.autoPong;
|
|
173145
|
-
this._closeTimeout = options.closeTimeout;
|
|
173146
|
-
this._isServer = true;
|
|
173147
|
-
}
|
|
173148
|
-
}
|
|
173149
|
-
get binaryType() {
|
|
173150
|
-
return this._binaryType;
|
|
173151
|
-
}
|
|
173152
|
-
set binaryType(type) {
|
|
173153
|
-
if (!BINARY_TYPES.includes(type))
|
|
173154
|
-
return;
|
|
173155
|
-
this._binaryType = type;
|
|
173156
|
-
if (this._receiver)
|
|
173157
|
-
this._receiver._binaryType = type;
|
|
173158
|
-
}
|
|
173159
|
-
get bufferedAmount() {
|
|
173160
|
-
if (!this._socket)
|
|
173161
|
-
return this._bufferedAmount;
|
|
173162
|
-
return this._socket._writableState.length + this._sender._bufferedBytes;
|
|
173163
|
-
}
|
|
173164
|
-
get extensions() {
|
|
173165
|
-
return Object.keys(this._extensions).join();
|
|
173166
|
-
}
|
|
173167
|
-
get isPaused() {
|
|
173168
|
-
return this._paused;
|
|
173169
|
-
}
|
|
173170
|
-
get onclose() {
|
|
173171
|
-
return null;
|
|
173172
|
-
}
|
|
173173
|
-
get onerror() {
|
|
173174
|
-
return null;
|
|
173175
|
-
}
|
|
173176
|
-
get onopen() {
|
|
173177
|
-
return null;
|
|
173178
|
-
}
|
|
173179
|
-
get onmessage() {
|
|
173180
|
-
return null;
|
|
173181
|
-
}
|
|
173182
|
-
get protocol() {
|
|
173183
|
-
return this._protocol;
|
|
173184
|
-
}
|
|
173185
|
-
get readyState() {
|
|
173186
|
-
return this._readyState;
|
|
173187
|
-
}
|
|
173188
|
-
get url() {
|
|
173189
|
-
return this._url;
|
|
173190
|
-
}
|
|
173191
|
-
setSocket(socket, head, options) {
|
|
173192
|
-
const receiver = new Receiver({
|
|
173193
|
-
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
173194
|
-
binaryType: this.binaryType,
|
|
173195
|
-
extensions: this._extensions,
|
|
173196
|
-
isServer: this._isServer,
|
|
173197
|
-
maxBufferedChunks: options.maxBufferedChunks,
|
|
173198
|
-
maxFragments: options.maxFragments,
|
|
173199
|
-
maxPayload: options.maxPayload,
|
|
173200
|
-
skipUTF8Validation: options.skipUTF8Validation
|
|
173201
|
-
});
|
|
173202
|
-
const sender = new Sender(socket, this._extensions, options.generateMask);
|
|
173203
|
-
this._receiver = receiver;
|
|
173204
|
-
this._sender = sender;
|
|
173205
|
-
this._socket = socket;
|
|
173206
|
-
receiver[kWebSocket] = this;
|
|
173207
|
-
sender[kWebSocket] = this;
|
|
173208
|
-
socket[kWebSocket] = this;
|
|
173209
|
-
receiver.on("conclude", receiverOnConclude);
|
|
173210
|
-
receiver.on("drain", receiverOnDrain);
|
|
173211
|
-
receiver.on("error", receiverOnError);
|
|
173212
|
-
receiver.on("message", receiverOnMessage);
|
|
173213
|
-
receiver.on("ping", receiverOnPing);
|
|
173214
|
-
receiver.on("pong", receiverOnPong);
|
|
173215
|
-
sender.onerror = senderOnError;
|
|
173216
|
-
if (socket.setTimeout)
|
|
173217
|
-
socket.setTimeout(0);
|
|
173218
|
-
if (socket.setNoDelay)
|
|
173219
|
-
socket.setNoDelay();
|
|
173220
|
-
if (head.length > 0)
|
|
173221
|
-
socket.unshift(head);
|
|
173222
|
-
socket.on("close", socketOnClose);
|
|
173223
|
-
socket.on("data", socketOnData);
|
|
173224
|
-
socket.on("end", socketOnEnd);
|
|
173225
|
-
socket.on("error", socketOnError);
|
|
173226
|
-
this._readyState = WebSocket.OPEN;
|
|
173227
|
-
this.emit("open");
|
|
173228
|
-
}
|
|
173229
|
-
emitClose() {
|
|
173230
|
-
if (!this._socket) {
|
|
173231
|
-
this._readyState = WebSocket.CLOSED;
|
|
173232
|
-
this.emit("close", this._closeCode, this._closeMessage);
|
|
173233
|
-
return;
|
|
173234
|
-
}
|
|
173235
|
-
if (this._extensions[PerMessageDeflate.extensionName]) {
|
|
173236
|
-
this._extensions[PerMessageDeflate.extensionName].cleanup();
|
|
173237
|
-
}
|
|
173238
|
-
this._receiver.removeAllListeners();
|
|
173239
|
-
this._readyState = WebSocket.CLOSED;
|
|
173240
|
-
this.emit("close", this._closeCode, this._closeMessage);
|
|
173241
|
-
}
|
|
173242
|
-
close(code, data) {
|
|
173243
|
-
if (this.readyState === WebSocket.CLOSED)
|
|
173244
|
-
return;
|
|
173245
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
173246
|
-
const msg = "WebSocket was closed before the connection was established";
|
|
173247
|
-
abortHandshake(this, this._req, msg);
|
|
173248
|
-
return;
|
|
173249
|
-
}
|
|
173250
|
-
if (this.readyState === WebSocket.CLOSING) {
|
|
173251
|
-
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
|
|
173252
|
-
this._socket.end();
|
|
173253
|
-
}
|
|
173254
|
-
return;
|
|
173255
|
-
}
|
|
173256
|
-
this._readyState = WebSocket.CLOSING;
|
|
173257
|
-
this._sender.close(code, data, !this._isServer, (err) => {
|
|
173258
|
-
if (err)
|
|
173259
|
-
return;
|
|
173260
|
-
this._closeFrameSent = true;
|
|
173261
|
-
if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
|
|
173262
|
-
this._socket.end();
|
|
173263
|
-
}
|
|
173264
|
-
});
|
|
173265
|
-
setCloseTimer(this);
|
|
173266
|
-
}
|
|
173267
|
-
pause() {
|
|
173268
|
-
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) {
|
|
173269
|
-
return;
|
|
173270
|
-
}
|
|
173271
|
-
this._paused = true;
|
|
173272
|
-
this._socket.pause();
|
|
173273
|
-
}
|
|
173274
|
-
ping(data, mask, cb) {
|
|
173275
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
173276
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
173277
|
-
}
|
|
173278
|
-
if (typeof data === "function") {
|
|
173279
|
-
cb = data;
|
|
173280
|
-
data = mask = undefined;
|
|
173281
|
-
} else if (typeof mask === "function") {
|
|
173282
|
-
cb = mask;
|
|
173283
|
-
mask = undefined;
|
|
173284
|
-
}
|
|
173285
|
-
if (typeof data === "number")
|
|
173286
|
-
data = data.toString();
|
|
173287
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
173288
|
-
sendAfterClose(this, data, cb);
|
|
173289
|
-
return;
|
|
173290
|
-
}
|
|
173291
|
-
if (mask === undefined)
|
|
173292
|
-
mask = !this._isServer;
|
|
173293
|
-
this._sender.ping(data || EMPTY_BUFFER, mask, cb);
|
|
173294
|
-
}
|
|
173295
|
-
pong(data, mask, cb) {
|
|
173296
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
173297
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
173298
|
-
}
|
|
173299
|
-
if (typeof data === "function") {
|
|
173300
|
-
cb = data;
|
|
173301
|
-
data = mask = undefined;
|
|
173302
|
-
} else if (typeof mask === "function") {
|
|
173303
|
-
cb = mask;
|
|
173304
|
-
mask = undefined;
|
|
173305
|
-
}
|
|
173306
|
-
if (typeof data === "number")
|
|
173307
|
-
data = data.toString();
|
|
173308
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
173309
|
-
sendAfterClose(this, data, cb);
|
|
173310
|
-
return;
|
|
173311
|
-
}
|
|
173312
|
-
if (mask === undefined)
|
|
173313
|
-
mask = !this._isServer;
|
|
173314
|
-
this._sender.pong(data || EMPTY_BUFFER, mask, cb);
|
|
173315
|
-
}
|
|
173316
|
-
resume() {
|
|
173317
|
-
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) {
|
|
173318
|
-
return;
|
|
173319
|
-
}
|
|
173320
|
-
this._paused = false;
|
|
173321
|
-
if (!this._receiver._writableState.needDrain)
|
|
173322
|
-
this._socket.resume();
|
|
173323
|
-
}
|
|
173324
|
-
send(data, options, cb) {
|
|
173325
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
173326
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
173327
|
-
}
|
|
173328
|
-
if (typeof options === "function") {
|
|
173329
|
-
cb = options;
|
|
173330
|
-
options = {};
|
|
173331
|
-
}
|
|
173332
|
-
if (typeof data === "number")
|
|
173333
|
-
data = data.toString();
|
|
173334
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
173335
|
-
sendAfterClose(this, data, cb);
|
|
173336
|
-
return;
|
|
173337
|
-
}
|
|
173338
|
-
const opts = {
|
|
173339
|
-
binary: typeof data !== "string",
|
|
173340
|
-
mask: !this._isServer,
|
|
173341
|
-
compress: true,
|
|
173342
|
-
fin: true,
|
|
173343
|
-
...options
|
|
173344
|
-
};
|
|
173345
|
-
if (!this._extensions[PerMessageDeflate.extensionName]) {
|
|
173346
|
-
opts.compress = false;
|
|
173347
|
-
}
|
|
173348
|
-
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
173349
|
-
}
|
|
173350
|
-
terminate() {
|
|
173351
|
-
if (this.readyState === WebSocket.CLOSED)
|
|
173352
|
-
return;
|
|
173353
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
173354
|
-
const msg = "WebSocket was closed before the connection was established";
|
|
173355
|
-
abortHandshake(this, this._req, msg);
|
|
173356
|
-
return;
|
|
173357
|
-
}
|
|
173358
|
-
if (this._socket) {
|
|
173359
|
-
this._readyState = WebSocket.CLOSING;
|
|
173360
|
-
this._socket.destroy();
|
|
173361
|
-
}
|
|
173362
|
-
}
|
|
173363
|
-
}
|
|
173364
|
-
Object.defineProperty(WebSocket, "CONNECTING", {
|
|
173365
|
-
enumerable: true,
|
|
173366
|
-
value: readyStates.indexOf("CONNECTING")
|
|
173367
|
-
});
|
|
173368
|
-
Object.defineProperty(WebSocket.prototype, "CONNECTING", {
|
|
173369
|
-
enumerable: true,
|
|
173370
|
-
value: readyStates.indexOf("CONNECTING")
|
|
173371
|
-
});
|
|
173372
|
-
Object.defineProperty(WebSocket, "OPEN", {
|
|
173373
|
-
enumerable: true,
|
|
173374
|
-
value: readyStates.indexOf("OPEN")
|
|
173375
|
-
});
|
|
173376
|
-
Object.defineProperty(WebSocket.prototype, "OPEN", {
|
|
173377
|
-
enumerable: true,
|
|
173378
|
-
value: readyStates.indexOf("OPEN")
|
|
173379
|
-
});
|
|
173380
|
-
Object.defineProperty(WebSocket, "CLOSING", {
|
|
173381
|
-
enumerable: true,
|
|
173382
|
-
value: readyStates.indexOf("CLOSING")
|
|
173383
|
-
});
|
|
173384
|
-
Object.defineProperty(WebSocket.prototype, "CLOSING", {
|
|
173385
|
-
enumerable: true,
|
|
173386
|
-
value: readyStates.indexOf("CLOSING")
|
|
173387
|
-
});
|
|
173388
|
-
Object.defineProperty(WebSocket, "CLOSED", {
|
|
173389
|
-
enumerable: true,
|
|
173390
|
-
value: readyStates.indexOf("CLOSED")
|
|
173391
|
-
});
|
|
173392
|
-
Object.defineProperty(WebSocket.prototype, "CLOSED", {
|
|
173393
|
-
enumerable: true,
|
|
173394
|
-
value: readyStates.indexOf("CLOSED")
|
|
173395
|
-
});
|
|
173396
|
-
[
|
|
173397
|
-
"binaryType",
|
|
173398
|
-
"bufferedAmount",
|
|
173399
|
-
"extensions",
|
|
173400
|
-
"isPaused",
|
|
173401
|
-
"protocol",
|
|
173402
|
-
"readyState",
|
|
173403
|
-
"url"
|
|
173404
|
-
].forEach((property) => {
|
|
173405
|
-
Object.defineProperty(WebSocket.prototype, property, { enumerable: true });
|
|
173406
|
-
});
|
|
173407
|
-
["open", "error", "close", "message"].forEach((method) => {
|
|
173408
|
-
Object.defineProperty(WebSocket.prototype, `on${method}`, {
|
|
173409
|
-
enumerable: true,
|
|
173410
|
-
get() {
|
|
173411
|
-
for (const listener of this.listeners(method)) {
|
|
173412
|
-
if (listener[kForOnEventAttribute])
|
|
173413
|
-
return listener[kListener];
|
|
173414
|
-
}
|
|
173415
|
-
return null;
|
|
173416
|
-
},
|
|
173417
|
-
set(handler) {
|
|
173418
|
-
for (const listener of this.listeners(method)) {
|
|
173419
|
-
if (listener[kForOnEventAttribute]) {
|
|
173420
|
-
this.removeListener(method, listener);
|
|
173421
|
-
break;
|
|
173422
|
-
}
|
|
173423
|
-
}
|
|
173424
|
-
if (typeof handler !== "function")
|
|
173425
|
-
return;
|
|
173426
|
-
this.addEventListener(method, handler, {
|
|
173427
|
-
[kForOnEventAttribute]: true
|
|
173428
|
-
});
|
|
173429
|
-
}
|
|
173430
|
-
});
|
|
173431
|
-
});
|
|
173432
|
-
WebSocket.prototype.addEventListener = addEventListener;
|
|
173433
|
-
WebSocket.prototype.removeEventListener = removeEventListener;
|
|
173434
|
-
module.exports = WebSocket;
|
|
173435
|
-
function initAsClient(websocket, address, protocols, options) {
|
|
173436
|
-
const opts = {
|
|
173437
|
-
allowSynchronousEvents: true,
|
|
173438
|
-
autoPong: true,
|
|
173439
|
-
closeTimeout: CLOSE_TIMEOUT,
|
|
173440
|
-
protocolVersion: protocolVersions[1],
|
|
173441
|
-
maxBufferedChunks: 1024 * 1024,
|
|
173442
|
-
maxFragments: 128 * 1024,
|
|
173443
|
-
maxPayload: 100 * 1024 * 1024,
|
|
173444
|
-
skipUTF8Validation: false,
|
|
173445
|
-
perMessageDeflate: true,
|
|
173446
|
-
followRedirects: false,
|
|
173447
|
-
maxRedirects: 10,
|
|
173448
|
-
...options,
|
|
173449
|
-
socketPath: undefined,
|
|
173450
|
-
hostname: undefined,
|
|
173451
|
-
protocol: undefined,
|
|
173452
|
-
timeout: undefined,
|
|
173453
|
-
method: "GET",
|
|
173454
|
-
host: undefined,
|
|
173455
|
-
path: undefined,
|
|
173456
|
-
port: undefined
|
|
173457
|
-
};
|
|
173458
|
-
websocket._autoPong = opts.autoPong;
|
|
173459
|
-
websocket._closeTimeout = opts.closeTimeout;
|
|
173460
|
-
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
173461
|
-
throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} ` + `(supported versions: ${protocolVersions.join(", ")})`);
|
|
173462
|
-
}
|
|
173463
|
-
let parsedUrl;
|
|
173464
|
-
if (address instanceof URL2) {
|
|
173465
|
-
parsedUrl = address;
|
|
173466
|
-
} else {
|
|
173467
|
-
try {
|
|
173468
|
-
parsedUrl = new URL2(address);
|
|
173469
|
-
} catch {
|
|
173470
|
-
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
173471
|
-
}
|
|
173472
|
-
}
|
|
173473
|
-
if (parsedUrl.protocol === "http:") {
|
|
173474
|
-
parsedUrl.protocol = "ws:";
|
|
173475
|
-
} else if (parsedUrl.protocol === "https:") {
|
|
173476
|
-
parsedUrl.protocol = "wss:";
|
|
173477
|
-
}
|
|
173478
|
-
websocket._url = parsedUrl.href;
|
|
173479
|
-
const isSecure = parsedUrl.protocol === "wss:";
|
|
173480
|
-
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
173481
|
-
let invalidUrlMessage;
|
|
173482
|
-
if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
|
|
173483
|
-
invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", ` + '"http:", "https:", or "ws+unix:"';
|
|
173484
|
-
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
173485
|
-
invalidUrlMessage = "The URL's pathname is empty";
|
|
173486
|
-
} else if (parsedUrl.hash) {
|
|
173487
|
-
invalidUrlMessage = "The URL contains a fragment identifier";
|
|
173488
|
-
}
|
|
173489
|
-
if (invalidUrlMessage) {
|
|
173490
|
-
const err = new SyntaxError(invalidUrlMessage);
|
|
173491
|
-
if (websocket._redirects === 0) {
|
|
173492
|
-
throw err;
|
|
173493
|
-
} else {
|
|
173494
|
-
emitErrorAndClose(websocket, err);
|
|
173495
|
-
return;
|
|
173496
|
-
}
|
|
173497
|
-
}
|
|
173498
|
-
const defaultPort = isSecure ? 443 : 80;
|
|
173499
|
-
const key = randomBytes(16).toString("base64");
|
|
173500
|
-
const request3 = isSecure ? https.request : http.request;
|
|
173501
|
-
const protocolSet = new Set;
|
|
173502
|
-
let perMessageDeflate;
|
|
173503
|
-
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
173504
|
-
opts.defaultPort = opts.defaultPort || defaultPort;
|
|
173505
|
-
opts.port = parsedUrl.port || defaultPort;
|
|
173506
|
-
opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
|
|
173507
|
-
opts.headers = {
|
|
173508
|
-
...opts.headers,
|
|
173509
|
-
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
173510
|
-
"Sec-WebSocket-Key": key,
|
|
173511
|
-
Connection: "Upgrade",
|
|
173512
|
-
Upgrade: "websocket"
|
|
173513
|
-
};
|
|
173514
|
-
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
173515
|
-
opts.timeout = opts.handshakeTimeout;
|
|
173516
|
-
if (opts.perMessageDeflate) {
|
|
173517
|
-
perMessageDeflate = new PerMessageDeflate({
|
|
173518
|
-
...opts.perMessageDeflate,
|
|
173519
|
-
isServer: false,
|
|
173520
|
-
maxPayload: opts.maxPayload
|
|
173521
|
-
});
|
|
173522
|
-
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
173523
|
-
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
173524
|
-
});
|
|
173525
|
-
}
|
|
173526
|
-
if (protocols.length) {
|
|
173527
|
-
for (const protocol of protocols) {
|
|
173528
|
-
if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
|
|
173529
|
-
throw new SyntaxError("An invalid or duplicated subprotocol was specified");
|
|
173530
|
-
}
|
|
173531
|
-
protocolSet.add(protocol);
|
|
173532
|
-
}
|
|
173533
|
-
opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
|
|
173534
|
-
}
|
|
173535
|
-
if (opts.origin) {
|
|
173536
|
-
if (opts.protocolVersion < 13) {
|
|
173537
|
-
opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
173538
|
-
} else {
|
|
173539
|
-
opts.headers.Origin = opts.origin;
|
|
173540
|
-
}
|
|
173541
|
-
}
|
|
173542
|
-
if (parsedUrl.username || parsedUrl.password) {
|
|
173543
|
-
opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
173544
|
-
}
|
|
173545
|
-
if (isIpcUrl) {
|
|
173546
|
-
const parts = opts.path.split(":");
|
|
173547
|
-
opts.socketPath = parts[0];
|
|
173548
|
-
opts.path = parts[1];
|
|
173549
|
-
}
|
|
173550
|
-
let req;
|
|
173551
|
-
if (opts.followRedirects) {
|
|
173552
|
-
if (websocket._redirects === 0) {
|
|
173553
|
-
websocket._originalIpc = isIpcUrl;
|
|
173554
|
-
websocket._originalSecure = isSecure;
|
|
173555
|
-
websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
|
|
173556
|
-
const headers = options && options.headers;
|
|
173557
|
-
options = { ...options, headers: {} };
|
|
173558
|
-
if (headers) {
|
|
173559
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
173560
|
-
options.headers[key.toLowerCase()] = value;
|
|
173561
|
-
}
|
|
173562
|
-
}
|
|
173563
|
-
} else if (websocket.listenerCount("redirect") === 0) {
|
|
173564
|
-
const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
173565
|
-
if (!isSameHost || websocket._originalSecure && !isSecure) {
|
|
173566
|
-
delete opts.headers.authorization;
|
|
173567
|
-
delete opts.headers.cookie;
|
|
173568
|
-
if (!isSameHost)
|
|
173569
|
-
delete opts.headers.host;
|
|
173570
|
-
opts.auth = undefined;
|
|
173571
|
-
}
|
|
173572
|
-
}
|
|
173573
|
-
if (opts.auth && !options.headers.authorization) {
|
|
173574
|
-
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
173575
|
-
}
|
|
173576
|
-
req = websocket._req = request3(opts);
|
|
173577
|
-
if (websocket._redirects) {
|
|
173578
|
-
websocket.emit("redirect", websocket.url, req);
|
|
173579
|
-
}
|
|
173580
|
-
} else {
|
|
173581
|
-
req = websocket._req = request3(opts);
|
|
173582
|
-
}
|
|
173583
|
-
if (opts.timeout) {
|
|
173584
|
-
req.on("timeout", () => {
|
|
173585
|
-
abortHandshake(websocket, req, "Opening handshake has timed out");
|
|
173586
|
-
});
|
|
173587
|
-
}
|
|
173588
|
-
req.on("error", (err) => {
|
|
173589
|
-
if (req === null || req[kAborted])
|
|
173590
|
-
return;
|
|
173591
|
-
req = websocket._req = null;
|
|
173592
|
-
emitErrorAndClose(websocket, err);
|
|
173593
|
-
});
|
|
173594
|
-
req.on("response", (res) => {
|
|
173595
|
-
const location2 = res.headers.location;
|
|
173596
|
-
const statusCode = res.statusCode;
|
|
173597
|
-
if (location2 && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
173598
|
-
if (++websocket._redirects > opts.maxRedirects) {
|
|
173599
|
-
abortHandshake(websocket, req, "Maximum redirects exceeded");
|
|
173600
|
-
return;
|
|
173601
|
-
}
|
|
173602
|
-
req.abort();
|
|
173603
|
-
let addr;
|
|
173604
|
-
try {
|
|
173605
|
-
addr = new URL2(location2, address);
|
|
173606
|
-
} catch (e) {
|
|
173607
|
-
const err = new SyntaxError(`Invalid URL: ${location2}`);
|
|
173608
|
-
emitErrorAndClose(websocket, err);
|
|
173609
|
-
return;
|
|
173610
|
-
}
|
|
173611
|
-
initAsClient(websocket, addr, protocols, options);
|
|
173612
|
-
} else if (!websocket.emit("unexpected-response", req, res)) {
|
|
173613
|
-
abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
173614
|
-
}
|
|
173615
|
-
});
|
|
173616
|
-
req.on("upgrade", (res, socket, head) => {
|
|
173617
|
-
websocket.emit("upgrade", res);
|
|
173618
|
-
if (websocket.readyState !== WebSocket.CONNECTING)
|
|
173619
|
-
return;
|
|
173620
|
-
req = websocket._req = null;
|
|
173621
|
-
const upgrade = res.headers.upgrade;
|
|
173622
|
-
if (upgrade === undefined || upgrade.toLowerCase() !== "websocket") {
|
|
173623
|
-
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
173624
|
-
return;
|
|
173625
|
-
}
|
|
173626
|
-
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
173627
|
-
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
173628
|
-
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
173629
|
-
return;
|
|
173630
|
-
}
|
|
173631
|
-
const serverProt = res.headers["sec-websocket-protocol"];
|
|
173632
|
-
let protError;
|
|
173633
|
-
if (serverProt !== undefined) {
|
|
173634
|
-
if (!protocolSet.size) {
|
|
173635
|
-
protError = "Server sent a subprotocol but none was requested";
|
|
173636
|
-
} else if (!protocolSet.has(serverProt)) {
|
|
173637
|
-
protError = "Server sent an invalid subprotocol";
|
|
173638
|
-
}
|
|
173639
|
-
} else if (protocolSet.size) {
|
|
173640
|
-
protError = "Server sent no subprotocol";
|
|
173641
|
-
}
|
|
173642
|
-
if (protError) {
|
|
173643
|
-
abortHandshake(websocket, socket, protError);
|
|
173644
|
-
return;
|
|
173645
|
-
}
|
|
173646
|
-
if (serverProt)
|
|
173647
|
-
websocket._protocol = serverProt;
|
|
173648
|
-
const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
|
|
173649
|
-
if (secWebSocketExtensions !== undefined) {
|
|
173650
|
-
if (!perMessageDeflate) {
|
|
173651
|
-
const message = "Server sent a Sec-WebSocket-Extensions header but no extension " + "was requested";
|
|
173652
|
-
abortHandshake(websocket, socket, message);
|
|
173653
|
-
return;
|
|
173654
|
-
}
|
|
173655
|
-
let extensions;
|
|
173656
|
-
try {
|
|
173657
|
-
extensions = parse(secWebSocketExtensions);
|
|
173658
|
-
} catch (err) {
|
|
173659
|
-
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
173660
|
-
abortHandshake(websocket, socket, message);
|
|
173661
|
-
return;
|
|
173662
|
-
}
|
|
173663
|
-
const extensionNames = Object.keys(extensions);
|
|
173664
|
-
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
|
|
173665
|
-
const message = "Server indicated an extension that was not requested";
|
|
173666
|
-
abortHandshake(websocket, socket, message);
|
|
173667
|
-
return;
|
|
173668
|
-
}
|
|
173669
|
-
try {
|
|
173670
|
-
perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
|
|
173671
|
-
} catch (err) {
|
|
173672
|
-
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
173673
|
-
abortHandshake(websocket, socket, message);
|
|
173674
|
-
return;
|
|
173675
|
-
}
|
|
173676
|
-
websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
173677
|
-
}
|
|
173678
|
-
websocket.setSocket(socket, head, {
|
|
173679
|
-
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
173680
|
-
generateMask: opts.generateMask,
|
|
173681
|
-
maxBufferedChunks: opts.maxBufferedChunks,
|
|
173682
|
-
maxFragments: opts.maxFragments,
|
|
173683
|
-
maxPayload: opts.maxPayload,
|
|
173684
|
-
skipUTF8Validation: opts.skipUTF8Validation
|
|
173685
|
-
});
|
|
173686
|
-
});
|
|
173687
|
-
if (opts.finishRequest) {
|
|
173688
|
-
opts.finishRequest(req, websocket);
|
|
173689
|
-
} else {
|
|
173690
|
-
req.end();
|
|
173691
|
-
}
|
|
173692
|
-
}
|
|
173693
|
-
function emitErrorAndClose(websocket, err) {
|
|
173694
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173695
|
-
websocket._errorEmitted = true;
|
|
173696
|
-
websocket.emit("error", err);
|
|
173697
|
-
websocket.emitClose();
|
|
173698
|
-
}
|
|
173699
|
-
function netConnect(options) {
|
|
173700
|
-
options.path = options.socketPath;
|
|
173701
|
-
return net.connect(options);
|
|
173702
|
-
}
|
|
173703
|
-
function tlsConnect(options) {
|
|
173704
|
-
options.path = undefined;
|
|
173705
|
-
if (!options.servername && options.servername !== "") {
|
|
173706
|
-
options.servername = net.isIP(options.host) ? "" : options.host;
|
|
173707
|
-
}
|
|
173708
|
-
return tls.connect(options);
|
|
173709
|
-
}
|
|
173710
|
-
function abortHandshake(websocket, stream, message) {
|
|
173711
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173712
|
-
const err = new Error(message);
|
|
173713
|
-
Error.captureStackTrace(err, abortHandshake);
|
|
173714
|
-
if (stream.setHeader) {
|
|
173715
|
-
stream[kAborted] = true;
|
|
173716
|
-
stream.abort();
|
|
173717
|
-
if (stream.socket && !stream.socket.destroyed) {
|
|
173718
|
-
stream.socket.destroy();
|
|
173719
|
-
}
|
|
173720
|
-
process.nextTick(emitErrorAndClose, websocket, err);
|
|
173721
|
-
} else {
|
|
173722
|
-
stream.destroy(err);
|
|
173723
|
-
stream.once("error", websocket.emit.bind(websocket, "error"));
|
|
173724
|
-
stream.once("close", websocket.emitClose.bind(websocket));
|
|
173725
|
-
}
|
|
173726
|
-
}
|
|
173727
|
-
function sendAfterClose(websocket, data, cb) {
|
|
173728
|
-
if (data) {
|
|
173729
|
-
const length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
173730
|
-
if (websocket._socket)
|
|
173731
|
-
websocket._sender._bufferedBytes += length;
|
|
173732
|
-
else
|
|
173733
|
-
websocket._bufferedAmount += length;
|
|
173734
|
-
}
|
|
173735
|
-
if (cb) {
|
|
173736
|
-
const err = new Error(`WebSocket is not open: readyState ${websocket.readyState} ` + `(${readyStates[websocket.readyState]})`);
|
|
173737
|
-
process.nextTick(cb, err);
|
|
173738
|
-
}
|
|
173739
|
-
}
|
|
173740
|
-
function receiverOnConclude(code, reason) {
|
|
173741
|
-
const websocket = this[kWebSocket];
|
|
173742
|
-
websocket._closeFrameReceived = true;
|
|
173743
|
-
websocket._closeMessage = reason;
|
|
173744
|
-
websocket._closeCode = code;
|
|
173745
|
-
if (websocket._socket[kWebSocket] === undefined)
|
|
173746
|
-
return;
|
|
173747
|
-
websocket._socket.removeListener("data", socketOnData);
|
|
173748
|
-
process.nextTick(resume, websocket._socket);
|
|
173749
|
-
if (code === 1005)
|
|
173750
|
-
websocket.close();
|
|
173751
|
-
else
|
|
173752
|
-
websocket.close(code, reason);
|
|
173753
|
-
}
|
|
173754
|
-
function receiverOnDrain() {
|
|
173755
|
-
const websocket = this[kWebSocket];
|
|
173756
|
-
if (!websocket.isPaused)
|
|
173757
|
-
websocket._socket.resume();
|
|
173758
|
-
}
|
|
173759
|
-
function receiverOnError(err) {
|
|
173760
|
-
const websocket = this[kWebSocket];
|
|
173761
|
-
if (websocket._socket[kWebSocket] !== undefined) {
|
|
173762
|
-
websocket._socket.removeListener("data", socketOnData);
|
|
173763
|
-
process.nextTick(resume, websocket._socket);
|
|
173764
|
-
websocket.close(err[kStatusCode]);
|
|
173765
|
-
}
|
|
173766
|
-
if (!websocket._errorEmitted) {
|
|
173767
|
-
websocket._errorEmitted = true;
|
|
173768
|
-
websocket.emit("error", err);
|
|
173769
|
-
}
|
|
173770
|
-
}
|
|
173771
|
-
function receiverOnFinish() {
|
|
173772
|
-
this[kWebSocket].emitClose();
|
|
173773
|
-
}
|
|
173774
|
-
function receiverOnMessage(data, isBinary) {
|
|
173775
|
-
this[kWebSocket].emit("message", data, isBinary);
|
|
173776
|
-
}
|
|
173777
|
-
function receiverOnPing(data) {
|
|
173778
|
-
const websocket = this[kWebSocket];
|
|
173779
|
-
if (websocket._autoPong)
|
|
173780
|
-
websocket.pong(data, !this._isServer, NOOP);
|
|
173781
|
-
websocket.emit("ping", data);
|
|
173782
|
-
}
|
|
173783
|
-
function receiverOnPong(data) {
|
|
173784
|
-
this[kWebSocket].emit("pong", data);
|
|
173785
|
-
}
|
|
173786
|
-
function resume(stream) {
|
|
173787
|
-
stream.resume();
|
|
173788
|
-
}
|
|
173789
|
-
function senderOnError(err) {
|
|
173790
|
-
const websocket = this[kWebSocket];
|
|
173791
|
-
if (websocket.readyState === WebSocket.CLOSED)
|
|
173792
|
-
return;
|
|
173793
|
-
if (websocket.readyState === WebSocket.OPEN) {
|
|
173794
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173795
|
-
setCloseTimer(websocket);
|
|
173796
|
-
}
|
|
173797
|
-
this._socket.end();
|
|
173798
|
-
if (!websocket._errorEmitted) {
|
|
173799
|
-
websocket._errorEmitted = true;
|
|
173800
|
-
websocket.emit("error", err);
|
|
173801
|
-
}
|
|
173802
|
-
}
|
|
173803
|
-
function setCloseTimer(websocket) {
|
|
173804
|
-
websocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);
|
|
173805
|
-
}
|
|
173806
|
-
function socketOnClose() {
|
|
173807
|
-
const websocket = this[kWebSocket];
|
|
173808
|
-
this.removeListener("close", socketOnClose);
|
|
173809
|
-
this.removeListener("data", socketOnData);
|
|
173810
|
-
this.removeListener("end", socketOnEnd);
|
|
173811
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173812
|
-
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
173813
|
-
const chunk = this.read(this._readableState.length);
|
|
173814
|
-
websocket._receiver.write(chunk);
|
|
173815
|
-
}
|
|
173816
|
-
websocket._receiver.end();
|
|
173817
|
-
this[kWebSocket] = undefined;
|
|
173818
|
-
clearTimeout(websocket._closeTimer);
|
|
173819
|
-
if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
|
|
173820
|
-
websocket.emitClose();
|
|
173821
|
-
} else {
|
|
173822
|
-
websocket._receiver.on("error", receiverOnFinish);
|
|
173823
|
-
websocket._receiver.on("finish", receiverOnFinish);
|
|
173824
|
-
}
|
|
173825
|
-
}
|
|
173826
|
-
function socketOnData(chunk) {
|
|
173827
|
-
if (!this[kWebSocket]._receiver.write(chunk)) {
|
|
173828
|
-
this.pause();
|
|
173829
|
-
}
|
|
173830
|
-
}
|
|
173831
|
-
function socketOnEnd() {
|
|
173832
|
-
const websocket = this[kWebSocket];
|
|
173833
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173834
|
-
websocket._receiver.end();
|
|
173835
|
-
this.end();
|
|
173836
|
-
}
|
|
173837
|
-
function socketOnError() {
|
|
173838
|
-
const websocket = this[kWebSocket];
|
|
173839
|
-
this.removeListener("error", socketOnError);
|
|
173840
|
-
this.on("error", NOOP);
|
|
173841
|
-
if (websocket) {
|
|
173842
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
173843
|
-
this.destroy();
|
|
173844
|
-
}
|
|
173845
|
-
}
|
|
173846
|
-
});
|
|
173847
|
-
|
|
173848
|
-
// ../../node_modules/ws/lib/stream.js
|
|
173849
|
-
var require_stream6 = __commonJS(function(exports, module) {
|
|
173850
|
-
var WebSocket = require_websocket();
|
|
173851
|
-
var { Duplex } = __require("stream");
|
|
173852
|
-
function emitClose(stream) {
|
|
173853
|
-
stream.emit("close");
|
|
173854
|
-
}
|
|
173855
|
-
function duplexOnEnd() {
|
|
173856
|
-
if (!this.destroyed && this._writableState.finished) {
|
|
173857
|
-
this.destroy();
|
|
173858
|
-
}
|
|
173859
|
-
}
|
|
173860
|
-
function duplexOnError(err) {
|
|
173861
|
-
this.removeListener("error", duplexOnError);
|
|
173862
|
-
this.destroy();
|
|
173863
|
-
if (this.listenerCount("error") === 0) {
|
|
173864
|
-
this.emit("error", err);
|
|
173865
|
-
}
|
|
173866
|
-
}
|
|
173867
|
-
function createWebSocketStream(ws, options) {
|
|
173868
|
-
let terminateOnDestroy = true;
|
|
173869
|
-
const duplex = new Duplex({
|
|
173870
|
-
...options,
|
|
173871
|
-
autoDestroy: false,
|
|
173872
|
-
emitClose: false,
|
|
173873
|
-
objectMode: false,
|
|
173874
|
-
writableObjectMode: false
|
|
173875
|
-
});
|
|
173876
|
-
ws.on("message", function message(msg, isBinary) {
|
|
173877
|
-
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
173878
|
-
if (!duplex.push(data))
|
|
173879
|
-
ws.pause();
|
|
173880
|
-
});
|
|
173881
|
-
ws.once("error", function error(err) {
|
|
173882
|
-
if (duplex.destroyed)
|
|
173883
|
-
return;
|
|
173884
|
-
terminateOnDestroy = false;
|
|
173885
|
-
duplex.destroy(err);
|
|
173886
|
-
});
|
|
173887
|
-
ws.once("close", function close() {
|
|
173888
|
-
if (duplex.destroyed)
|
|
173889
|
-
return;
|
|
173890
|
-
duplex.push(null);
|
|
173891
|
-
});
|
|
173892
|
-
duplex._destroy = function(err, callback) {
|
|
173893
|
-
if (ws.readyState === ws.CLOSED) {
|
|
173894
|
-
callback(err);
|
|
173895
|
-
process.nextTick(emitClose, duplex);
|
|
173896
|
-
return;
|
|
173897
|
-
}
|
|
173898
|
-
let called = false;
|
|
173899
|
-
ws.once("error", function error(err) {
|
|
173900
|
-
called = true;
|
|
173901
|
-
callback(err);
|
|
173902
|
-
});
|
|
173903
|
-
ws.once("close", function close() {
|
|
173904
|
-
if (!called)
|
|
173905
|
-
callback(err);
|
|
173906
|
-
process.nextTick(emitClose, duplex);
|
|
173907
|
-
});
|
|
173908
|
-
if (terminateOnDestroy)
|
|
173909
|
-
ws.terminate();
|
|
173910
|
-
};
|
|
173911
|
-
duplex._final = function(callback) {
|
|
173912
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
173913
|
-
ws.once("open", function open() {
|
|
173914
|
-
duplex._final(callback);
|
|
173915
|
-
});
|
|
173916
|
-
return;
|
|
173917
|
-
}
|
|
173918
|
-
if (ws._socket === null)
|
|
173919
|
-
return;
|
|
173920
|
-
if (ws._socket._writableState.finished) {
|
|
173921
|
-
callback();
|
|
173922
|
-
if (duplex._readableState.endEmitted)
|
|
173923
|
-
duplex.destroy();
|
|
173924
|
-
} else {
|
|
173925
|
-
ws._socket.once("finish", function finish() {
|
|
173926
|
-
callback();
|
|
173927
|
-
});
|
|
173928
|
-
ws.close();
|
|
173929
|
-
}
|
|
173930
|
-
};
|
|
173931
|
-
duplex._read = function() {
|
|
173932
|
-
if (ws.isPaused)
|
|
173933
|
-
ws.resume();
|
|
173934
|
-
};
|
|
173935
|
-
duplex._write = function(chunk, encoding, callback) {
|
|
173936
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
173937
|
-
ws.once("open", function open() {
|
|
173938
|
-
duplex._write(chunk, encoding, callback);
|
|
173939
|
-
});
|
|
173940
|
-
return;
|
|
173941
|
-
}
|
|
173942
|
-
ws.send(chunk, callback);
|
|
173943
|
-
};
|
|
173944
|
-
duplex.on("end", duplexOnEnd);
|
|
173945
|
-
duplex.on("error", duplexOnError);
|
|
173946
|
-
return duplex;
|
|
173947
|
-
}
|
|
173948
|
-
module.exports = createWebSocketStream;
|
|
173949
|
-
});
|
|
173950
|
-
|
|
173951
|
-
// ../../node_modules/ws/lib/subprotocol.js
|
|
173952
|
-
var require_subprotocol = __commonJS(function(exports, module) {
|
|
173953
|
-
var { tokenChars } = require_validation();
|
|
173954
|
-
function parse(header) {
|
|
173955
|
-
const protocols = new Set;
|
|
173956
|
-
let start = -1;
|
|
173957
|
-
let end = -1;
|
|
173958
|
-
let i = 0;
|
|
173959
|
-
for (i;i < header.length; i++) {
|
|
173960
|
-
const code = header.charCodeAt(i);
|
|
173961
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
173962
|
-
if (start === -1)
|
|
173963
|
-
start = i;
|
|
173964
|
-
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
173965
|
-
if (end === -1 && start !== -1)
|
|
173966
|
-
end = i;
|
|
173967
|
-
} else if (code === 44) {
|
|
173968
|
-
if (start === -1) {
|
|
173969
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
173970
|
-
}
|
|
173971
|
-
if (end === -1)
|
|
173972
|
-
end = i;
|
|
173973
|
-
const protocol = header.slice(start, end);
|
|
173974
|
-
if (protocols.has(protocol)) {
|
|
173975
|
-
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
173976
|
-
}
|
|
173977
|
-
protocols.add(protocol);
|
|
173978
|
-
start = end = -1;
|
|
173979
|
-
} else {
|
|
173980
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
173981
|
-
}
|
|
173982
|
-
}
|
|
173983
|
-
if (start === -1 || end !== -1) {
|
|
173984
|
-
throw new SyntaxError("Unexpected end of input");
|
|
173985
|
-
}
|
|
173986
|
-
const protocol = header.slice(start, i);
|
|
173987
|
-
if (protocols.has(protocol)) {
|
|
173988
|
-
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
173989
|
-
}
|
|
173990
|
-
protocols.add(protocol);
|
|
173991
|
-
return protocols;
|
|
173992
|
-
}
|
|
173993
|
-
module.exports = { parse };
|
|
173994
|
-
});
|
|
173995
|
-
|
|
173996
|
-
// ../../node_modules/ws/lib/websocket-server.js
|
|
173997
|
-
var require_websocket_server = __commonJS(function(exports, module) {
|
|
173998
|
-
var EventEmitter = __require("events");
|
|
173999
|
-
var http = __require("http");
|
|
174000
|
-
var { Duplex } = __require("stream");
|
|
174001
|
-
var { createHash } = __require("crypto");
|
|
174002
|
-
var extension = require_extension();
|
|
174003
|
-
var PerMessageDeflate = require_permessage_deflate();
|
|
174004
|
-
var subprotocol = require_subprotocol();
|
|
174005
|
-
var WebSocket = require_websocket();
|
|
174006
|
-
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants6();
|
|
174007
|
-
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
174008
|
-
var RUNNING = 0;
|
|
174009
|
-
var CLOSING = 1;
|
|
174010
|
-
var CLOSED = 2;
|
|
174011
|
-
|
|
174012
|
-
class WebSocketServer extends EventEmitter {
|
|
174013
|
-
constructor(options, callback) {
|
|
174014
|
-
super();
|
|
174015
|
-
options = {
|
|
174016
|
-
allowSynchronousEvents: true,
|
|
174017
|
-
autoPong: true,
|
|
174018
|
-
maxBufferedChunks: 1024 * 1024,
|
|
174019
|
-
maxFragments: 128 * 1024,
|
|
174020
|
-
maxPayload: 100 * 1024 * 1024,
|
|
174021
|
-
skipUTF8Validation: false,
|
|
174022
|
-
perMessageDeflate: false,
|
|
174023
|
-
handleProtocols: null,
|
|
174024
|
-
clientTracking: true,
|
|
174025
|
-
closeTimeout: CLOSE_TIMEOUT,
|
|
174026
|
-
verifyClient: null,
|
|
174027
|
-
noServer: false,
|
|
174028
|
-
backlog: null,
|
|
174029
|
-
server: null,
|
|
174030
|
-
host: null,
|
|
174031
|
-
path: null,
|
|
174032
|
-
port: null,
|
|
174033
|
-
WebSocket,
|
|
174034
|
-
...options
|
|
174035
|
-
};
|
|
174036
|
-
if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
|
|
174037
|
-
throw new TypeError('One and only one of the "port", "server", or "noServer" options ' + "must be specified");
|
|
174038
|
-
}
|
|
174039
|
-
if (options.port != null) {
|
|
174040
|
-
this._server = http.createServer((req, res) => {
|
|
174041
|
-
const body = http.STATUS_CODES[426];
|
|
174042
|
-
res.writeHead(426, {
|
|
174043
|
-
"Content-Length": body.length,
|
|
174044
|
-
"Content-Type": "text/plain"
|
|
174045
|
-
});
|
|
174046
|
-
res.end(body);
|
|
174047
|
-
});
|
|
174048
|
-
this._server.listen(options.port, options.host, options.backlog, callback);
|
|
174049
|
-
} else if (options.server) {
|
|
174050
|
-
this._server = options.server;
|
|
174051
|
-
}
|
|
174052
|
-
if (this._server) {
|
|
174053
|
-
const emitConnection = this.emit.bind(this, "connection");
|
|
174054
|
-
this._removeListeners = addListeners(this._server, {
|
|
174055
|
-
listening: this.emit.bind(this, "listening"),
|
|
174056
|
-
error: this.emit.bind(this, "error"),
|
|
174057
|
-
upgrade: (req, socket, head) => {
|
|
174058
|
-
this.handleUpgrade(req, socket, head, emitConnection);
|
|
174059
|
-
}
|
|
174060
|
-
});
|
|
174061
|
-
}
|
|
174062
|
-
if (options.perMessageDeflate === true)
|
|
174063
|
-
options.perMessageDeflate = {};
|
|
174064
|
-
if (options.clientTracking) {
|
|
174065
|
-
this.clients = new Set;
|
|
174066
|
-
this._shouldEmitClose = false;
|
|
174067
|
-
}
|
|
174068
|
-
this.options = options;
|
|
174069
|
-
this._state = RUNNING;
|
|
174070
|
-
}
|
|
174071
|
-
address() {
|
|
174072
|
-
if (this.options.noServer) {
|
|
174073
|
-
throw new Error('The server is operating in "noServer" mode');
|
|
174074
|
-
}
|
|
174075
|
-
if (!this._server)
|
|
174076
|
-
return null;
|
|
174077
|
-
return this._server.address();
|
|
174078
|
-
}
|
|
174079
|
-
close(cb) {
|
|
174080
|
-
if (this._state === CLOSED) {
|
|
174081
|
-
if (cb) {
|
|
174082
|
-
this.once("close", () => {
|
|
174083
|
-
cb(new Error("The server is not running"));
|
|
174084
|
-
});
|
|
174085
|
-
}
|
|
174086
|
-
process.nextTick(emitClose, this);
|
|
174087
|
-
return;
|
|
174088
|
-
}
|
|
174089
|
-
if (cb)
|
|
174090
|
-
this.once("close", cb);
|
|
174091
|
-
if (this._state === CLOSING)
|
|
174092
|
-
return;
|
|
174093
|
-
this._state = CLOSING;
|
|
174094
|
-
if (this.options.noServer || this.options.server) {
|
|
174095
|
-
if (this._server) {
|
|
174096
|
-
this._removeListeners();
|
|
174097
|
-
this._removeListeners = this._server = null;
|
|
174098
|
-
}
|
|
174099
|
-
if (this.clients) {
|
|
174100
|
-
if (!this.clients.size) {
|
|
174101
|
-
process.nextTick(emitClose, this);
|
|
174102
|
-
} else {
|
|
174103
|
-
this._shouldEmitClose = true;
|
|
174104
|
-
}
|
|
174105
|
-
} else {
|
|
174106
|
-
process.nextTick(emitClose, this);
|
|
174107
|
-
}
|
|
174108
|
-
} else {
|
|
174109
|
-
const server = this._server;
|
|
174110
|
-
this._removeListeners();
|
|
174111
|
-
this._removeListeners = this._server = null;
|
|
174112
|
-
server.close(() => {
|
|
174113
|
-
emitClose(this);
|
|
174114
|
-
});
|
|
174115
|
-
}
|
|
174116
|
-
}
|
|
174117
|
-
shouldHandle(req) {
|
|
174118
|
-
if (this.options.path) {
|
|
174119
|
-
const index = req.url.indexOf("?");
|
|
174120
|
-
const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
|
|
174121
|
-
if (pathname !== this.options.path)
|
|
174122
|
-
return false;
|
|
174123
|
-
}
|
|
174124
|
-
return true;
|
|
174125
|
-
}
|
|
174126
|
-
handleUpgrade(req, socket, head, cb) {
|
|
174127
|
-
socket.on("error", socketOnError);
|
|
174128
|
-
const key = req.headers["sec-websocket-key"];
|
|
174129
|
-
const upgrade = req.headers.upgrade;
|
|
174130
|
-
const version = +req.headers["sec-websocket-version"];
|
|
174131
|
-
if (req.method !== "GET") {
|
|
174132
|
-
const message = "Invalid HTTP method";
|
|
174133
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
174134
|
-
return;
|
|
174135
|
-
}
|
|
174136
|
-
if (upgrade === undefined || upgrade.toLowerCase() !== "websocket") {
|
|
174137
|
-
const message = "Invalid Upgrade header";
|
|
174138
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
174139
|
-
return;
|
|
174140
|
-
}
|
|
174141
|
-
if (key === undefined || !keyRegex.test(key)) {
|
|
174142
|
-
const message = "Missing or invalid Sec-WebSocket-Key header";
|
|
174143
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
174144
|
-
return;
|
|
174145
|
-
}
|
|
174146
|
-
if (version !== 13 && version !== 8) {
|
|
174147
|
-
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
174148
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
174149
|
-
"Sec-WebSocket-Version": "13, 8"
|
|
174150
|
-
});
|
|
174151
|
-
return;
|
|
174152
|
-
}
|
|
174153
|
-
if (!this.shouldHandle(req)) {
|
|
174154
|
-
abortHandshake(socket, 400);
|
|
174155
|
-
return;
|
|
174156
|
-
}
|
|
174157
|
-
const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
|
|
174158
|
-
let protocols = new Set;
|
|
174159
|
-
if (secWebSocketProtocol !== undefined) {
|
|
174160
|
-
try {
|
|
174161
|
-
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
174162
|
-
} catch (err) {
|
|
174163
|
-
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
174164
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
174165
|
-
return;
|
|
174166
|
-
}
|
|
174167
|
-
}
|
|
174168
|
-
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
174169
|
-
const extensions = {};
|
|
174170
|
-
if (this.options.perMessageDeflate && secWebSocketExtensions !== undefined) {
|
|
174171
|
-
const perMessageDeflate = new PerMessageDeflate({
|
|
174172
|
-
...this.options.perMessageDeflate,
|
|
174173
|
-
isServer: true,
|
|
174174
|
-
maxPayload: this.options.maxPayload
|
|
174175
|
-
});
|
|
174176
|
-
try {
|
|
174177
|
-
const offers = extension.parse(secWebSocketExtensions);
|
|
174178
|
-
if (offers[PerMessageDeflate.extensionName]) {
|
|
174179
|
-
perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
|
|
174180
|
-
extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
174181
|
-
}
|
|
174182
|
-
} catch (err) {
|
|
174183
|
-
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
174184
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
174185
|
-
return;
|
|
174186
|
-
}
|
|
174187
|
-
}
|
|
174188
|
-
if (this.options.verifyClient) {
|
|
174189
|
-
const info = {
|
|
174190
|
-
origin: req.headers[`${version === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
174191
|
-
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
174192
|
-
req
|
|
174193
|
-
};
|
|
174194
|
-
if (this.options.verifyClient.length === 2) {
|
|
174195
|
-
this.options.verifyClient(info, (verified, code, message, headers) => {
|
|
174196
|
-
if (!verified) {
|
|
174197
|
-
return abortHandshake(socket, code || 401, message, headers);
|
|
174198
|
-
}
|
|
174199
|
-
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
174200
|
-
});
|
|
174201
|
-
return;
|
|
174202
|
-
}
|
|
174203
|
-
if (!this.options.verifyClient(info))
|
|
174204
|
-
return abortHandshake(socket, 401);
|
|
174205
|
-
}
|
|
174206
|
-
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
174207
|
-
}
|
|
174208
|
-
completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
|
|
174209
|
-
if (!socket.readable || !socket.writable)
|
|
174210
|
-
return socket.destroy();
|
|
174211
|
-
if (socket[kWebSocket]) {
|
|
174212
|
-
throw new Error("server.handleUpgrade() was called more than once with the same " + "socket, possibly due to a misconfiguration");
|
|
174213
|
-
}
|
|
174214
|
-
if (this._state > RUNNING)
|
|
174215
|
-
return abortHandshake(socket, 503);
|
|
174216
|
-
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
174217
|
-
const headers = [
|
|
174218
|
-
"HTTP/1.1 101 Switching Protocols",
|
|
174219
|
-
"Upgrade: websocket",
|
|
174220
|
-
"Connection: Upgrade",
|
|
174221
|
-
`Sec-WebSocket-Accept: ${digest}`
|
|
174222
|
-
];
|
|
174223
|
-
const ws = new this.options.WebSocket(null, undefined, this.options);
|
|
174224
|
-
if (protocols.size) {
|
|
174225
|
-
const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
174226
|
-
if (protocol) {
|
|
174227
|
-
headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
|
|
174228
|
-
ws._protocol = protocol;
|
|
174229
|
-
}
|
|
174230
|
-
}
|
|
174231
|
-
if (extensions[PerMessageDeflate.extensionName]) {
|
|
174232
|
-
const params = extensions[PerMessageDeflate.extensionName].params;
|
|
174233
|
-
const value = extension.format({
|
|
174234
|
-
[PerMessageDeflate.extensionName]: [params]
|
|
174235
|
-
});
|
|
174236
|
-
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
174237
|
-
ws._extensions = extensions;
|
|
174238
|
-
}
|
|
174239
|
-
this.emit("headers", headers, req);
|
|
174240
|
-
socket.write(headers.concat(`\r
|
|
174241
|
-
`).join(`\r
|
|
174242
|
-
`));
|
|
174243
|
-
socket.removeListener("error", socketOnError);
|
|
174244
|
-
ws.setSocket(socket, head, {
|
|
174245
|
-
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
174246
|
-
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
174247
|
-
maxFragments: this.options.maxFragments,
|
|
174248
|
-
maxPayload: this.options.maxPayload,
|
|
174249
|
-
skipUTF8Validation: this.options.skipUTF8Validation
|
|
174250
|
-
});
|
|
174251
|
-
if (this.clients) {
|
|
174252
|
-
this.clients.add(ws);
|
|
174253
|
-
ws.on("close", () => {
|
|
174254
|
-
this.clients.delete(ws);
|
|
174255
|
-
if (this._shouldEmitClose && !this.clients.size) {
|
|
174256
|
-
process.nextTick(emitClose, this);
|
|
174257
|
-
}
|
|
174258
|
-
});
|
|
174259
|
-
}
|
|
174260
|
-
cb(ws, req);
|
|
174261
|
-
}
|
|
174262
|
-
}
|
|
174263
|
-
module.exports = WebSocketServer;
|
|
174264
|
-
function addListeners(server, map) {
|
|
174265
|
-
for (const event of Object.keys(map))
|
|
174266
|
-
server.on(event, map[event]);
|
|
174267
|
-
return function removeListeners() {
|
|
174268
|
-
for (const event of Object.keys(map)) {
|
|
174269
|
-
server.removeListener(event, map[event]);
|
|
174270
|
-
}
|
|
174271
|
-
};
|
|
174272
|
-
}
|
|
174273
|
-
function emitClose(server) {
|
|
174274
|
-
server._state = CLOSED;
|
|
174275
|
-
server.emit("close");
|
|
174276
|
-
}
|
|
174277
|
-
function socketOnError() {
|
|
174278
|
-
this.destroy();
|
|
174279
|
-
}
|
|
174280
|
-
function abortHandshake(socket, code, message, headers) {
|
|
174281
|
-
message = message || http.STATUS_CODES[code];
|
|
174282
|
-
headers = {
|
|
174283
|
-
Connection: "close",
|
|
174284
|
-
"Content-Type": "text/html",
|
|
174285
|
-
"Content-Length": Buffer.byteLength(message),
|
|
174286
|
-
...headers
|
|
174287
|
-
};
|
|
174288
|
-
socket.once("finish", socket.destroy);
|
|
174289
|
-
socket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
|
|
174290
|
-
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(`\r
|
|
174291
|
-
`) + `\r
|
|
174292
|
-
\r
|
|
174293
|
-
` + message);
|
|
174294
|
-
}
|
|
174295
|
-
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
|
|
174296
|
-
if (server.listenerCount("wsClientError")) {
|
|
174297
|
-
const err = new Error(message);
|
|
174298
|
-
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
174299
|
-
server.emit("wsClientError", err, socket, req);
|
|
174300
|
-
} else {
|
|
174301
|
-
abortHandshake(socket, code, message, headers);
|
|
174302
|
-
}
|
|
174303
|
-
}
|
|
174304
|
-
});
|
|
174305
|
-
|
|
174306
171423
|
// ../../node_modules/@seald-io/nedb/lib/utils.js
|
|
174307
171424
|
var require_utils11 = __commonJS(function(exports, module) {
|
|
174308
171425
|
var uniq = (array, iteratee) => {
|
|
@@ -196293,7 +193410,7 @@ var require_polling_jsonp = __commonJS(function(exports) {
|
|
|
196293
193410
|
});
|
|
196294
193411
|
|
|
196295
193412
|
// ../../node_modules/engine.io/build/transports/websocket.js
|
|
196296
|
-
var
|
|
193413
|
+
var require_websocket = __commonJS(function(exports) {
|
|
196297
193414
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
196298
193415
|
exports.WebSocket = undefined;
|
|
196299
193416
|
var transport_1 = require_transport();
|
|
@@ -196432,7 +193549,7 @@ var require_transports = __commonJS(function(exports) {
|
|
|
196432
193549
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
196433
193550
|
var polling_1 = require_polling();
|
|
196434
193551
|
var polling_jsonp_1 = require_polling_jsonp();
|
|
196435
|
-
var websocket_1 =
|
|
193552
|
+
var websocket_1 = require_websocket();
|
|
196436
193553
|
var webtransport_1 = require_webtransport();
|
|
196437
193554
|
exports.default = {
|
|
196438
193555
|
polling,
|
|
@@ -196780,7 +193897,7 @@ var require_socket = __commonJS(function(exports) {
|
|
|
196780
193897
|
});
|
|
196781
193898
|
|
|
196782
193899
|
// ../../node_modules/engine.io/node_modules/ws/lib/constants.js
|
|
196783
|
-
var
|
|
193900
|
+
var require_constants6 = __commonJS(function(exports, module) {
|
|
196784
193901
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
196785
193902
|
var hasBlob = typeof Blob !== "undefined";
|
|
196786
193903
|
if (hasBlob)
|
|
@@ -196799,8 +193916,8 @@ var require_constants7 = __commonJS(function(exports, module) {
|
|
|
196799
193916
|
});
|
|
196800
193917
|
|
|
196801
193918
|
// ../../node_modules/engine.io/node_modules/ws/lib/buffer-util.js
|
|
196802
|
-
var
|
|
196803
|
-
var { EMPTY_BUFFER } =
|
|
193919
|
+
var require_buffer_util = __commonJS(function(exports, module) {
|
|
193920
|
+
var { EMPTY_BUFFER } = require_constants6();
|
|
196804
193921
|
var FastBuffer = Buffer[Symbol.species];
|
|
196805
193922
|
function concat(list, totalLength) {
|
|
196806
193923
|
if (list.length === 0)
|
|
@@ -196877,7 +193994,7 @@ var require_buffer_util2 = __commonJS(function(exports, module) {
|
|
|
196877
193994
|
});
|
|
196878
193995
|
|
|
196879
193996
|
// ../../node_modules/engine.io/node_modules/ws/lib/limiter.js
|
|
196880
|
-
var
|
|
193997
|
+
var require_limiter = __commonJS(function(exports, module) {
|
|
196881
193998
|
var kDone = Symbol("kDone");
|
|
196882
193999
|
var kRun = Symbol("kRun");
|
|
196883
194000
|
|
|
@@ -196909,11 +194026,11 @@ var require_limiter2 = __commonJS(function(exports, module) {
|
|
|
196909
194026
|
});
|
|
196910
194027
|
|
|
196911
194028
|
// ../../node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js
|
|
196912
|
-
var
|
|
194029
|
+
var require_permessage_deflate = __commonJS(function(exports, module) {
|
|
196913
194030
|
var zlib = __require("zlib");
|
|
196914
|
-
var bufferUtil =
|
|
196915
|
-
var Limiter =
|
|
196916
|
-
var { kStatusCode } =
|
|
194031
|
+
var bufferUtil = require_buffer_util();
|
|
194032
|
+
var Limiter = require_limiter();
|
|
194033
|
+
var { kStatusCode } = require_constants6();
|
|
196917
194034
|
var FastBuffer = Buffer[Symbol.species];
|
|
196918
194035
|
var TRAILER = Buffer.from([0, 0, 255, 255]);
|
|
196919
194036
|
var kPerMessageDeflate = Symbol("permessage-deflate");
|
|
@@ -197173,9 +194290,9 @@ var require_permessage_deflate2 = __commonJS(function(exports, module) {
|
|
|
197173
194290
|
});
|
|
197174
194291
|
|
|
197175
194292
|
// ../../node_modules/engine.io/node_modules/ws/lib/validation.js
|
|
197176
|
-
var
|
|
194293
|
+
var require_validation = __commonJS(function(exports, module) {
|
|
197177
194294
|
var { isUtf8 } = __require("buffer");
|
|
197178
|
-
var { hasBlob } =
|
|
194295
|
+
var { hasBlob } = require_constants6();
|
|
197179
194296
|
var tokenChars = [
|
|
197180
194297
|
0,
|
|
197181
194298
|
0,
|
|
@@ -197360,17 +194477,17 @@ var require_validation2 = __commonJS(function(exports, module) {
|
|
|
197360
194477
|
});
|
|
197361
194478
|
|
|
197362
194479
|
// ../../node_modules/engine.io/node_modules/ws/lib/receiver.js
|
|
197363
|
-
var
|
|
194480
|
+
var require_receiver = __commonJS(function(exports, module) {
|
|
197364
194481
|
var { Writable } = __require("stream");
|
|
197365
|
-
var PerMessageDeflate =
|
|
194482
|
+
var PerMessageDeflate = require_permessage_deflate();
|
|
197366
194483
|
var {
|
|
197367
194484
|
BINARY_TYPES,
|
|
197368
194485
|
EMPTY_BUFFER,
|
|
197369
194486
|
kStatusCode,
|
|
197370
194487
|
kWebSocket
|
|
197371
|
-
} =
|
|
197372
|
-
var { concat, toArrayBuffer, unmask } =
|
|
197373
|
-
var { isValidStatusCode, isValidUTF8 } =
|
|
194488
|
+
} = require_constants6();
|
|
194489
|
+
var { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
194490
|
+
var { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
197374
194491
|
var FastBuffer = Buffer[Symbol.species];
|
|
197375
194492
|
var GET_INFO = 0;
|
|
197376
194493
|
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
@@ -197741,13 +194858,13 @@ var require_receiver2 = __commonJS(function(exports, module) {
|
|
|
197741
194858
|
});
|
|
197742
194859
|
|
|
197743
194860
|
// ../../node_modules/engine.io/node_modules/ws/lib/sender.js
|
|
197744
|
-
var
|
|
194861
|
+
var require_sender = __commonJS(function(exports, module) {
|
|
197745
194862
|
var { Duplex } = __require("stream");
|
|
197746
194863
|
var { randomFillSync } = __require("crypto");
|
|
197747
|
-
var PerMessageDeflate =
|
|
197748
|
-
var { EMPTY_BUFFER, kWebSocket, NOOP } =
|
|
197749
|
-
var { isBlob, isValidStatusCode } =
|
|
197750
|
-
var { mask: applyMask, toBuffer } =
|
|
194864
|
+
var PerMessageDeflate = require_permessage_deflate();
|
|
194865
|
+
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants6();
|
|
194866
|
+
var { isBlob, isValidStatusCode } = require_validation();
|
|
194867
|
+
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
197751
194868
|
var kByteLength = Symbol("kByteLength");
|
|
197752
194869
|
var maskBuffer = Buffer.alloc(4);
|
|
197753
194870
|
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
@@ -198095,8 +195212,8 @@ var require_sender2 = __commonJS(function(exports, module) {
|
|
|
198095
195212
|
});
|
|
198096
195213
|
|
|
198097
195214
|
// ../../node_modules/engine.io/node_modules/ws/lib/event-target.js
|
|
198098
|
-
var
|
|
198099
|
-
var { kForOnEventAttribute, kListener } =
|
|
195215
|
+
var require_event_target = __commonJS(function(exports, module) {
|
|
195216
|
+
var { kForOnEventAttribute, kListener } = require_constants6();
|
|
198100
195217
|
var kCode = Symbol("kCode");
|
|
198101
195218
|
var kData = Symbol("kData");
|
|
198102
195219
|
var kError = Symbol("kError");
|
|
@@ -198246,8 +195363,8 @@ var require_event_target2 = __commonJS(function(exports, module) {
|
|
|
198246
195363
|
});
|
|
198247
195364
|
|
|
198248
195365
|
// ../../node_modules/engine.io/node_modules/ws/lib/extension.js
|
|
198249
|
-
var
|
|
198250
|
-
var { tokenChars } =
|
|
195366
|
+
var require_extension = __commonJS(function(exports, module) {
|
|
195367
|
+
var { tokenChars } = require_validation();
|
|
198251
195368
|
function push(dest, name, elem) {
|
|
198252
195369
|
if (dest[name] === undefined)
|
|
198253
195370
|
dest[name] = [elem];
|
|
@@ -198411,7 +195528,7 @@ var require_extension2 = __commonJS(function(exports, module) {
|
|
|
198411
195528
|
});
|
|
198412
195529
|
|
|
198413
195530
|
// ../../node_modules/engine.io/node_modules/ws/lib/websocket.js
|
|
198414
|
-
var
|
|
195531
|
+
var require_websocket2 = __commonJS(function(exports, module) {
|
|
198415
195532
|
var EventEmitter = __require("events");
|
|
198416
195533
|
var https = __require("https");
|
|
198417
195534
|
var http = __require("http");
|
|
@@ -198420,10 +195537,10 @@ var require_websocket3 = __commonJS(function(exports, module) {
|
|
|
198420
195537
|
var { randomBytes, createHash } = __require("crypto");
|
|
198421
195538
|
var { Duplex, Readable } = __require("stream");
|
|
198422
195539
|
var { URL: URL2 } = __require("url");
|
|
198423
|
-
var PerMessageDeflate =
|
|
198424
|
-
var Receiver =
|
|
198425
|
-
var Sender =
|
|
198426
|
-
var { isBlob } =
|
|
195540
|
+
var PerMessageDeflate = require_permessage_deflate();
|
|
195541
|
+
var Receiver = require_receiver();
|
|
195542
|
+
var Sender = require_sender();
|
|
195543
|
+
var { isBlob } = require_validation();
|
|
198427
195544
|
var {
|
|
198428
195545
|
BINARY_TYPES,
|
|
198429
195546
|
EMPTY_BUFFER,
|
|
@@ -198433,12 +195550,12 @@ var require_websocket3 = __commonJS(function(exports, module) {
|
|
|
198433
195550
|
kStatusCode,
|
|
198434
195551
|
kWebSocket,
|
|
198435
195552
|
NOOP
|
|
198436
|
-
} =
|
|
195553
|
+
} = require_constants6();
|
|
198437
195554
|
var {
|
|
198438
195555
|
EventTarget: { addEventListener, removeEventListener }
|
|
198439
|
-
} =
|
|
198440
|
-
var { format, parse } =
|
|
198441
|
-
var { toBuffer } =
|
|
195556
|
+
} = require_event_target();
|
|
195557
|
+
var { format, parse } = require_extension();
|
|
195558
|
+
var { toBuffer } = require_buffer_util();
|
|
198442
195559
|
var closeTimeout = 30 * 1000;
|
|
198443
195560
|
var kAborted = Symbol("kAborted");
|
|
198444
195561
|
var protocolVersions = [8, 13];
|
|
@@ -199170,8 +196287,8 @@ var require_websocket3 = __commonJS(function(exports, module) {
|
|
|
199170
196287
|
});
|
|
199171
196288
|
|
|
199172
196289
|
// ../../node_modules/engine.io/node_modules/ws/lib/stream.js
|
|
199173
|
-
var
|
|
199174
|
-
var WebSocket =
|
|
196290
|
+
var require_stream6 = __commonJS(function(exports, module) {
|
|
196291
|
+
var WebSocket = require_websocket2();
|
|
199175
196292
|
var { Duplex } = __require("stream");
|
|
199176
196293
|
function emitClose(stream) {
|
|
199177
196294
|
stream.emit("close");
|
|
@@ -199273,8 +196390,8 @@ var require_stream7 = __commonJS(function(exports, module) {
|
|
|
199273
196390
|
});
|
|
199274
196391
|
|
|
199275
196392
|
// ../../node_modules/engine.io/node_modules/ws/lib/subprotocol.js
|
|
199276
|
-
var
|
|
199277
|
-
var { tokenChars } =
|
|
196393
|
+
var require_subprotocol = __commonJS(function(exports, module) {
|
|
196394
|
+
var { tokenChars } = require_validation();
|
|
199278
196395
|
function parse(header) {
|
|
199279
196396
|
const protocols = new Set;
|
|
199280
196397
|
let start = -1;
|
|
@@ -199318,16 +196435,16 @@ var require_subprotocol2 = __commonJS(function(exports, module) {
|
|
|
199318
196435
|
});
|
|
199319
196436
|
|
|
199320
196437
|
// ../../node_modules/engine.io/node_modules/ws/lib/websocket-server.js
|
|
199321
|
-
var
|
|
196438
|
+
var require_websocket_server = __commonJS(function(exports, module) {
|
|
199322
196439
|
var EventEmitter = __require("events");
|
|
199323
196440
|
var http = __require("http");
|
|
199324
196441
|
var { Duplex } = __require("stream");
|
|
199325
196442
|
var { createHash } = __require("crypto");
|
|
199326
|
-
var extension =
|
|
199327
|
-
var PerMessageDeflate =
|
|
199328
|
-
var subprotocol =
|
|
199329
|
-
var WebSocket =
|
|
199330
|
-
var { GUID, kWebSocket } =
|
|
196443
|
+
var extension = require_extension();
|
|
196444
|
+
var PerMessageDeflate = require_permessage_deflate();
|
|
196445
|
+
var subprotocol = require_subprotocol();
|
|
196446
|
+
var WebSocket = require_websocket2();
|
|
196447
|
+
var { GUID, kWebSocket } = require_constants6();
|
|
199331
196448
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
199332
196449
|
var RUNNING = 0;
|
|
199333
196450
|
var CLOSING = 1;
|
|
@@ -199620,11 +196737,11 @@ var require_websocket_server2 = __commonJS(function(exports, module) {
|
|
|
199620
196737
|
|
|
199621
196738
|
// ../../node_modules/engine.io/node_modules/ws/index.js
|
|
199622
196739
|
var require_ws = __commonJS(function(exports, module) {
|
|
199623
|
-
var WebSocket =
|
|
199624
|
-
WebSocket.createWebSocketStream =
|
|
199625
|
-
WebSocket.Server =
|
|
199626
|
-
WebSocket.Receiver =
|
|
199627
|
-
WebSocket.Sender =
|
|
196740
|
+
var WebSocket = require_websocket2();
|
|
196741
|
+
WebSocket.createWebSocketStream = require_stream6();
|
|
196742
|
+
WebSocket.Server = require_websocket_server();
|
|
196743
|
+
WebSocket.Receiver = require_receiver();
|
|
196744
|
+
WebSocket.Sender = require_sender();
|
|
199628
196745
|
WebSocket.WebSocket = WebSocket;
|
|
199629
196746
|
WebSocket.WebSocketServer = WebSocket.Server;
|
|
199630
196747
|
module.exports = WebSocket;
|
|
@@ -200747,7 +197864,7 @@ var require_polling2 = __commonJS(function(exports) {
|
|
|
200747
197864
|
});
|
|
200748
197865
|
|
|
200749
197866
|
// ../../node_modules/engine.io/build/transports-uws/websocket.js
|
|
200750
|
-
var
|
|
197867
|
+
var require_websocket3 = __commonJS(function(exports) {
|
|
200751
197868
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
200752
197869
|
exports.WebSocket = undefined;
|
|
200753
197870
|
var transport_1 = require_transport();
|
|
@@ -200802,7 +197919,7 @@ var require_websocket4 = __commonJS(function(exports) {
|
|
|
200802
197919
|
var require_transports_uws = __commonJS(function(exports) {
|
|
200803
197920
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
200804
197921
|
var polling_1 = require_polling2();
|
|
200805
|
-
var websocket_1 =
|
|
197922
|
+
var websocket_1 = require_websocket3();
|
|
200806
197923
|
exports.default = {
|
|
200807
197924
|
polling: polling_1.Polling,
|
|
200808
197925
|
websocket: websocket_1.WebSocket
|
|
@@ -202608,7 +199725,7 @@ var require_yeast = __commonJS(function(exports) {
|
|
|
202608
199725
|
});
|
|
202609
199726
|
|
|
202610
199727
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/constants.js
|
|
202611
|
-
var
|
|
199728
|
+
var require_constants7 = __commonJS(function(exports, module) {
|
|
202612
199729
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
202613
199730
|
var hasBlob = typeof Blob !== "undefined";
|
|
202614
199731
|
if (hasBlob)
|
|
@@ -202627,8 +199744,8 @@ var require_constants8 = __commonJS(function(exports, module) {
|
|
|
202627
199744
|
});
|
|
202628
199745
|
|
|
202629
199746
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js
|
|
202630
|
-
var
|
|
202631
|
-
var { EMPTY_BUFFER } =
|
|
199747
|
+
var require_buffer_util2 = __commonJS(function(exports, module) {
|
|
199748
|
+
var { EMPTY_BUFFER } = require_constants7();
|
|
202632
199749
|
var FastBuffer = Buffer[Symbol.species];
|
|
202633
199750
|
function concat(list, totalLength) {
|
|
202634
199751
|
if (list.length === 0)
|
|
@@ -202705,7 +199822,7 @@ var require_buffer_util3 = __commonJS(function(exports, module) {
|
|
|
202705
199822
|
});
|
|
202706
199823
|
|
|
202707
199824
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js
|
|
202708
|
-
var
|
|
199825
|
+
var require_limiter2 = __commonJS(function(exports, module) {
|
|
202709
199826
|
var kDone = Symbol("kDone");
|
|
202710
199827
|
var kRun = Symbol("kRun");
|
|
202711
199828
|
|
|
@@ -202737,11 +199854,11 @@ var require_limiter3 = __commonJS(function(exports, module) {
|
|
|
202737
199854
|
});
|
|
202738
199855
|
|
|
202739
199856
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js
|
|
202740
|
-
var
|
|
199857
|
+
var require_permessage_deflate2 = __commonJS(function(exports, module) {
|
|
202741
199858
|
var zlib = __require("zlib");
|
|
202742
|
-
var bufferUtil =
|
|
202743
|
-
var Limiter =
|
|
202744
|
-
var { kStatusCode } =
|
|
199859
|
+
var bufferUtil = require_buffer_util2();
|
|
199860
|
+
var Limiter = require_limiter2();
|
|
199861
|
+
var { kStatusCode } = require_constants7();
|
|
202745
199862
|
var FastBuffer = Buffer[Symbol.species];
|
|
202746
199863
|
var TRAILER = Buffer.from([0, 0, 255, 255]);
|
|
202747
199864
|
var kPerMessageDeflate = Symbol("permessage-deflate");
|
|
@@ -203001,9 +200118,9 @@ var require_permessage_deflate3 = __commonJS(function(exports, module) {
|
|
|
203001
200118
|
});
|
|
203002
200119
|
|
|
203003
200120
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/validation.js
|
|
203004
|
-
var
|
|
200121
|
+
var require_validation2 = __commonJS(function(exports, module) {
|
|
203005
200122
|
var { isUtf8 } = __require("buffer");
|
|
203006
|
-
var { hasBlob } =
|
|
200123
|
+
var { hasBlob } = require_constants7();
|
|
203007
200124
|
var tokenChars = [
|
|
203008
200125
|
0,
|
|
203009
200126
|
0,
|
|
@@ -203188,17 +200305,17 @@ var require_validation3 = __commonJS(function(exports, module) {
|
|
|
203188
200305
|
});
|
|
203189
200306
|
|
|
203190
200307
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js
|
|
203191
|
-
var
|
|
200308
|
+
var require_receiver2 = __commonJS(function(exports, module) {
|
|
203192
200309
|
var { Writable } = __require("stream");
|
|
203193
|
-
var PerMessageDeflate =
|
|
200310
|
+
var PerMessageDeflate = require_permessage_deflate2();
|
|
203194
200311
|
var {
|
|
203195
200312
|
BINARY_TYPES,
|
|
203196
200313
|
EMPTY_BUFFER,
|
|
203197
200314
|
kStatusCode,
|
|
203198
200315
|
kWebSocket
|
|
203199
|
-
} =
|
|
203200
|
-
var { concat, toArrayBuffer, unmask } =
|
|
203201
|
-
var { isValidStatusCode, isValidUTF8 } =
|
|
200316
|
+
} = require_constants7();
|
|
200317
|
+
var { concat, toArrayBuffer, unmask } = require_buffer_util2();
|
|
200318
|
+
var { isValidStatusCode, isValidUTF8 } = require_validation2();
|
|
203202
200319
|
var FastBuffer = Buffer[Symbol.species];
|
|
203203
200320
|
var GET_INFO = 0;
|
|
203204
200321
|
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
@@ -203569,13 +200686,13 @@ var require_receiver3 = __commonJS(function(exports, module) {
|
|
|
203569
200686
|
});
|
|
203570
200687
|
|
|
203571
200688
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/sender.js
|
|
203572
|
-
var
|
|
200689
|
+
var require_sender2 = __commonJS(function(exports, module) {
|
|
203573
200690
|
var { Duplex } = __require("stream");
|
|
203574
200691
|
var { randomFillSync } = __require("crypto");
|
|
203575
|
-
var PerMessageDeflate =
|
|
203576
|
-
var { EMPTY_BUFFER, kWebSocket, NOOP } =
|
|
203577
|
-
var { isBlob, isValidStatusCode } =
|
|
203578
|
-
var { mask: applyMask, toBuffer } =
|
|
200692
|
+
var PerMessageDeflate = require_permessage_deflate2();
|
|
200693
|
+
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants7();
|
|
200694
|
+
var { isBlob, isValidStatusCode } = require_validation2();
|
|
200695
|
+
var { mask: applyMask, toBuffer } = require_buffer_util2();
|
|
203579
200696
|
var kByteLength = Symbol("kByteLength");
|
|
203580
200697
|
var maskBuffer = Buffer.alloc(4);
|
|
203581
200698
|
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
@@ -203923,8 +201040,8 @@ var require_sender3 = __commonJS(function(exports, module) {
|
|
|
203923
201040
|
});
|
|
203924
201041
|
|
|
203925
201042
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js
|
|
203926
|
-
var
|
|
203927
|
-
var { kForOnEventAttribute, kListener } =
|
|
201043
|
+
var require_event_target2 = __commonJS(function(exports, module) {
|
|
201044
|
+
var { kForOnEventAttribute, kListener } = require_constants7();
|
|
203928
201045
|
var kCode = Symbol("kCode");
|
|
203929
201046
|
var kData = Symbol("kData");
|
|
203930
201047
|
var kError = Symbol("kError");
|
|
@@ -204074,8 +201191,8 @@ var require_event_target3 = __commonJS(function(exports, module) {
|
|
|
204074
201191
|
});
|
|
204075
201192
|
|
|
204076
201193
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/extension.js
|
|
204077
|
-
var
|
|
204078
|
-
var { tokenChars } =
|
|
201194
|
+
var require_extension2 = __commonJS(function(exports, module) {
|
|
201195
|
+
var { tokenChars } = require_validation2();
|
|
204079
201196
|
function push(dest, name, elem) {
|
|
204080
201197
|
if (dest[name] === undefined)
|
|
204081
201198
|
dest[name] = [elem];
|
|
@@ -204239,7 +201356,7 @@ var require_extension3 = __commonJS(function(exports, module) {
|
|
|
204239
201356
|
});
|
|
204240
201357
|
|
|
204241
201358
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js
|
|
204242
|
-
var
|
|
201359
|
+
var require_websocket4 = __commonJS(function(exports, module) {
|
|
204243
201360
|
var EventEmitter = __require("events");
|
|
204244
201361
|
var https = __require("https");
|
|
204245
201362
|
var http = __require("http");
|
|
@@ -204248,10 +201365,10 @@ var require_websocket5 = __commonJS(function(exports, module) {
|
|
|
204248
201365
|
var { randomBytes, createHash } = __require("crypto");
|
|
204249
201366
|
var { Duplex, Readable } = __require("stream");
|
|
204250
201367
|
var { URL: URL2 } = __require("url");
|
|
204251
|
-
var PerMessageDeflate =
|
|
204252
|
-
var Receiver =
|
|
204253
|
-
var Sender =
|
|
204254
|
-
var { isBlob } =
|
|
201368
|
+
var PerMessageDeflate = require_permessage_deflate2();
|
|
201369
|
+
var Receiver = require_receiver2();
|
|
201370
|
+
var Sender = require_sender2();
|
|
201371
|
+
var { isBlob } = require_validation2();
|
|
204255
201372
|
var {
|
|
204256
201373
|
BINARY_TYPES,
|
|
204257
201374
|
EMPTY_BUFFER,
|
|
@@ -204261,12 +201378,12 @@ var require_websocket5 = __commonJS(function(exports, module) {
|
|
|
204261
201378
|
kStatusCode,
|
|
204262
201379
|
kWebSocket,
|
|
204263
201380
|
NOOP
|
|
204264
|
-
} =
|
|
201381
|
+
} = require_constants7();
|
|
204265
201382
|
var {
|
|
204266
201383
|
EventTarget: { addEventListener, removeEventListener }
|
|
204267
|
-
} =
|
|
204268
|
-
var { format, parse } =
|
|
204269
|
-
var { toBuffer } =
|
|
201384
|
+
} = require_event_target2();
|
|
201385
|
+
var { format, parse } = require_extension2();
|
|
201386
|
+
var { toBuffer } = require_buffer_util2();
|
|
204270
201387
|
var closeTimeout = 30 * 1000;
|
|
204271
201388
|
var kAborted = Symbol("kAborted");
|
|
204272
201389
|
var protocolVersions = [8, 13];
|
|
@@ -204998,8 +202115,8 @@ var require_websocket5 = __commonJS(function(exports, module) {
|
|
|
204998
202115
|
});
|
|
204999
202116
|
|
|
205000
202117
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/stream.js
|
|
205001
|
-
var
|
|
205002
|
-
var WebSocket =
|
|
202118
|
+
var require_stream7 = __commonJS(function(exports, module) {
|
|
202119
|
+
var WebSocket = require_websocket4();
|
|
205003
202120
|
var { Duplex } = __require("stream");
|
|
205004
202121
|
function emitClose(stream) {
|
|
205005
202122
|
stream.emit("close");
|
|
@@ -205101,8 +202218,8 @@ var require_stream8 = __commonJS(function(exports, module) {
|
|
|
205101
202218
|
});
|
|
205102
202219
|
|
|
205103
202220
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js
|
|
205104
|
-
var
|
|
205105
|
-
var { tokenChars } =
|
|
202221
|
+
var require_subprotocol2 = __commonJS(function(exports, module) {
|
|
202222
|
+
var { tokenChars } = require_validation2();
|
|
205106
202223
|
function parse(header) {
|
|
205107
202224
|
const protocols = new Set;
|
|
205108
202225
|
let start = -1;
|
|
@@ -205146,16 +202263,16 @@ var require_subprotocol3 = __commonJS(function(exports, module) {
|
|
|
205146
202263
|
});
|
|
205147
202264
|
|
|
205148
202265
|
// ../../node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js
|
|
205149
|
-
var
|
|
202266
|
+
var require_websocket_server2 = __commonJS(function(exports, module) {
|
|
205150
202267
|
var EventEmitter = __require("events");
|
|
205151
202268
|
var http = __require("http");
|
|
205152
202269
|
var { Duplex } = __require("stream");
|
|
205153
202270
|
var { createHash } = __require("crypto");
|
|
205154
|
-
var extension =
|
|
205155
|
-
var PerMessageDeflate =
|
|
205156
|
-
var subprotocol =
|
|
205157
|
-
var WebSocket =
|
|
205158
|
-
var { GUID, kWebSocket } =
|
|
202271
|
+
var extension = require_extension2();
|
|
202272
|
+
var PerMessageDeflate = require_permessage_deflate2();
|
|
202273
|
+
var subprotocol = require_subprotocol2();
|
|
202274
|
+
var WebSocket = require_websocket4();
|
|
202275
|
+
var { GUID, kWebSocket } = require_constants7();
|
|
205159
202276
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
205160
202277
|
var RUNNING = 0;
|
|
205161
202278
|
var CLOSING = 1;
|
|
@@ -205448,11 +202565,11 @@ var require_websocket_server3 = __commonJS(function(exports, module) {
|
|
|
205448
202565
|
|
|
205449
202566
|
// ../../node_modules/socket.io-adapter/node_modules/ws/index.js
|
|
205450
202567
|
var require_ws2 = __commonJS(function(exports, module) {
|
|
205451
|
-
var WebSocket =
|
|
205452
|
-
WebSocket.createWebSocketStream =
|
|
205453
|
-
WebSocket.Server =
|
|
205454
|
-
WebSocket.Receiver =
|
|
205455
|
-
WebSocket.Sender =
|
|
202568
|
+
var WebSocket = require_websocket4();
|
|
202569
|
+
WebSocket.createWebSocketStream = require_stream7();
|
|
202570
|
+
WebSocket.Server = require_websocket_server2();
|
|
202571
|
+
WebSocket.Receiver = require_receiver2();
|
|
202572
|
+
WebSocket.Sender = require_sender2();
|
|
205456
202573
|
WebSocket.WebSocket = WebSocket;
|
|
205457
202574
|
WebSocket.WebSocketServer = WebSocket.Server;
|
|
205458
202575
|
module.exports = WebSocket;
|
|
@@ -231721,7 +228838,7 @@ function normalizeBase44Env() {
|
|
|
231721
228838
|
loadProjectEnvFiles();
|
|
231722
228839
|
|
|
231723
228840
|
// src/cli/index.ts
|
|
231724
|
-
import { dirname as
|
|
228841
|
+
import { dirname as dirname31, join as join42 } from "node:path";
|
|
231725
228842
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
231726
228843
|
|
|
231727
228844
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
@@ -233678,7 +230795,8 @@ var TestOverridesSchema = object({
|
|
|
233678
230795
|
id: string2(),
|
|
233679
230796
|
projectRoot: string2()
|
|
233680
230797
|
}).optional(),
|
|
233681
|
-
latestVersion: string2().nullable().optional()
|
|
230798
|
+
latestVersion: string2().nullable().optional(),
|
|
230799
|
+
claudeBin: string2().optional()
|
|
233682
230800
|
});
|
|
233683
230801
|
|
|
233684
230802
|
// src/core/config.ts
|
|
@@ -242322,7 +239440,6 @@ var package_default = {
|
|
|
242322
239440
|
"@types/ms": "^2.1.0",
|
|
242323
239441
|
"@types/multer": "^2.0.0",
|
|
242324
239442
|
"@types/node": "^22.10.5",
|
|
242325
|
-
"@types/ws": "^8.18.1",
|
|
242326
239443
|
"@vercel/detect-agent": "^1.1.0",
|
|
242327
239444
|
chalk: "^5.6.2",
|
|
242328
239445
|
chokidar: "^5.0.0",
|
|
@@ -242358,7 +239475,6 @@ var package_default = {
|
|
|
242358
239475
|
"tmp-promise": "^3.0.3",
|
|
242359
239476
|
typescript: "^5.7.2",
|
|
242360
239477
|
vitest: "^4.0.16",
|
|
242361
|
-
ws: "8.21.0",
|
|
242362
239478
|
yaml: "^2.8.2",
|
|
242363
239479
|
zod: "^4.3.5"
|
|
242364
239480
|
},
|
|
@@ -249743,6 +246859,23 @@ var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
|
|
|
249743
246859
|
function isGitCommitHash(value) {
|
|
249744
246860
|
return GIT_HASH_PATTERN.test(value);
|
|
249745
246861
|
}
|
|
246862
|
+
async function readGitState(cwd) {
|
|
246863
|
+
const status = await execa("git", ["status", "--porcelain", "--branch"], {
|
|
246864
|
+
cwd,
|
|
246865
|
+
reject: false
|
|
246866
|
+
});
|
|
246867
|
+
if (status.exitCode !== 0)
|
|
246868
|
+
return;
|
|
246869
|
+
const [header = "", ...changes] = status.stdout.split(`
|
|
246870
|
+
`).filter(Boolean);
|
|
246871
|
+
const head = await execa("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
246872
|
+
cwd,
|
|
246873
|
+
reject: false
|
|
246874
|
+
});
|
|
246875
|
+
const branch = head.exitCode === 0 && head.stdout !== "HEAD" ? head.stdout : undefined;
|
|
246876
|
+
const offRemote = branch !== undefined && (!header.includes("...") || /\[(ahead|gone)/.test(header));
|
|
246877
|
+
return { branch, unpushed: changes.length > 0 || offRemote };
|
|
246878
|
+
}
|
|
249746
246879
|
|
|
249747
246880
|
// src/core/site/git-hash.ts
|
|
249748
246881
|
function workerBuildNeedsGitHashError() {
|
|
@@ -267793,17 +264926,12 @@ function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
|
267793
264926
|
// src/cli/dev/dev-server/serve-runner.ts
|
|
267794
264927
|
import { spawn as spawn2 } from "node:child_process";
|
|
267795
264928
|
import process21 from "node:process";
|
|
267796
|
-
var ANSI_PATTERN = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
267797
|
-
var LOCAL_ORIGIN_PATTERN = /https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\]):(\d+)/g;
|
|
267798
264929
|
|
|
267799
264930
|
class ServeRunner {
|
|
267800
264931
|
command;
|
|
267801
264932
|
cwd;
|
|
267802
264933
|
env;
|
|
267803
264934
|
logger;
|
|
267804
|
-
onOrigin;
|
|
267805
|
-
ignorePort;
|
|
267806
|
-
originReported = false;
|
|
267807
264935
|
child;
|
|
267808
264936
|
stopping = false;
|
|
267809
264937
|
stopPromise;
|
|
@@ -267813,8 +264941,6 @@ class ServeRunner {
|
|
|
267813
264941
|
this.cwd = options.cwd;
|
|
267814
264942
|
this.env = options.env;
|
|
267815
264943
|
this.logger = options.logger;
|
|
267816
|
-
this.onOrigin = options.onOrigin;
|
|
267817
|
-
this.ignorePort = options.ignorePort;
|
|
267818
264944
|
}
|
|
267819
264945
|
start() {
|
|
267820
264946
|
if (this.child) {
|
|
@@ -267891,7 +265017,6 @@ class ServeRunner {
|
|
|
267891
265017
|
const lines = data.toString().trimEnd().split(`
|
|
267892
265018
|
`);
|
|
267893
265019
|
for (const line of lines) {
|
|
267894
|
-
this.reportOrigin(line);
|
|
267895
265020
|
if (type === "error") {
|
|
267896
265021
|
this.logger.error(line);
|
|
267897
265022
|
} else {
|
|
@@ -267899,20 +265024,6 @@ class ServeRunner {
|
|
|
267899
265024
|
}
|
|
267900
265025
|
}
|
|
267901
265026
|
}
|
|
267902
|
-
reportOrigin(line) {
|
|
267903
|
-
if (this.originReported || !this.onOrigin) {
|
|
267904
|
-
return;
|
|
267905
|
-
}
|
|
267906
|
-
const matches = line.replace(ANSI_PATTERN, "").matchAll(LOCAL_ORIGIN_PATTERN);
|
|
267907
|
-
for (const [origin, port] of matches) {
|
|
267908
|
-
if (Number(port) === this.ignorePort) {
|
|
267909
|
-
continue;
|
|
267910
|
-
}
|
|
267911
|
-
this.originReported = true;
|
|
267912
|
-
this.onOrigin(origin);
|
|
267913
|
-
return;
|
|
267914
|
-
}
|
|
267915
|
-
}
|
|
267916
265027
|
}
|
|
267917
265028
|
|
|
267918
265029
|
// src/cli/dev/serve-command-runner.ts
|
|
@@ -267920,9 +265031,7 @@ function createServeCommandRunner({
|
|
|
267920
265031
|
serveCommand,
|
|
267921
265032
|
projectRoot,
|
|
267922
265033
|
appId,
|
|
267923
|
-
appBaseUrl
|
|
267924
|
-
onOrigin,
|
|
267925
|
-
ignorePort
|
|
265034
|
+
appBaseUrl
|
|
267926
265035
|
}) {
|
|
267927
265036
|
return new ServeRunner({
|
|
267928
265037
|
command: serveCommand,
|
|
@@ -267931,9 +265040,7 @@ function createServeCommandRunner({
|
|
|
267931
265040
|
VITE_BASE44_APP_ID: appId,
|
|
267932
265041
|
...appBaseUrl ? { VITE_BASE44_APP_BASE_URL: appBaseUrl } : {}
|
|
267933
265042
|
},
|
|
267934
|
-
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
267935
|
-
onOrigin,
|
|
267936
|
-
ignorePort
|
|
265043
|
+
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
267937
265044
|
});
|
|
267938
265045
|
}
|
|
267939
265046
|
|
|
@@ -268700,7 +265807,7 @@ async function getPorts(options) {
|
|
|
268700
265807
|
}
|
|
268701
265808
|
|
|
268702
265809
|
// src/cli/dev/dev-server/main.ts
|
|
268703
|
-
var
|
|
265810
|
+
var import_http_proxy_middleware2 = __toESM(require_dist2(), 1);
|
|
268704
265811
|
|
|
268705
265812
|
// ../../node_modules/tmp-promise/index.js
|
|
268706
265813
|
var { promisify: promisify12 } = __require("util");
|
|
@@ -269265,20 +266372,11 @@ async function createFunctionRuntime(functions, logger, denoWrapperPath) {
|
|
|
269265
266372
|
return new FunctionManager(functions, logger, denoWrapperPath);
|
|
269266
266373
|
}
|
|
269267
266374
|
|
|
269268
|
-
// src/cli/dev/dev-server/routes/
|
|
266375
|
+
// src/cli/dev/dev-server/routes/functions.ts
|
|
266376
|
+
var import_express = __toESM(require_express(), 1);
|
|
269269
266377
|
var import_http_proxy_middleware = __toESM(require_dist2(), 1);
|
|
269270
266378
|
import { ServerResponse } from "node:http";
|
|
269271
266379
|
|
|
269272
|
-
// ../../node_modules/ws/wrapper.mjs
|
|
269273
|
-
var import_stream3 = __toESM(require_stream6(), 1);
|
|
269274
|
-
var import_extension = __toESM(require_extension(), 1);
|
|
269275
|
-
var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
269276
|
-
var import_receiver = __toESM(require_receiver(), 1);
|
|
269277
|
-
var import_sender = __toESM(require_sender(), 1);
|
|
269278
|
-
var import_subprotocol = __toESM(require_subprotocol(), 1);
|
|
269279
|
-
var import_websocket = __toESM(require_websocket(), 1);
|
|
269280
|
-
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
269281
|
-
|
|
269282
266380
|
// src/cli/dev/dev-server/auth/tokens.ts
|
|
269283
266381
|
var import_jsonwebtoken2 = __toESM(require_jsonwebtoken(), 1);
|
|
269284
266382
|
var LOCAL_DEV_SECRET = "LOCAL_DEV_SECRET";
|
|
@@ -269292,132 +266390,11 @@ var createServiceToken = () => createJwtToken(SERVICE_ROLE_EMAIL);
|
|
|
269292
266390
|
var createServiceAuthorizationHeader = () => `Bearer ${createServiceToken()}`;
|
|
269293
266391
|
var isServiceSubject = (subject) => subject === SERVICE_ROLE_EMAIL;
|
|
269294
266392
|
|
|
269295
|
-
// src/cli/dev/dev-server/routes/app-server.ts
|
|
269296
|
-
var PLATFORM_OWNED_SDK_HEADERS = [
|
|
269297
|
-
"base44-app-id",
|
|
269298
|
-
"base44-api-url",
|
|
269299
|
-
"base44-service-authorization",
|
|
269300
|
-
"base44-state",
|
|
269301
|
-
"base44-functions-version",
|
|
269302
|
-
"x-base44-app-url",
|
|
269303
|
-
"x-data-env"
|
|
269304
|
-
];
|
|
269305
|
-
var FORWARDED_HEADER = "base44-dev-forwarded";
|
|
269306
|
-
var PROXY_LOOP_MESSAGE = [
|
|
269307
|
-
"The app dev server sent this request back to the Base44 dev server instead of handling it.",
|
|
269308
|
-
"Its Vite proxy is forwarding all of /api; only /api/apps and /api/app-logs belong to the backend.",
|
|
269309
|
-
"Update @base44/vite-plugin, or narrow the proxy in vite.config.js to those paths."
|
|
269310
|
-
].join(" ");
|
|
269311
|
-
function sdkHeaders(appId, host) {
|
|
269312
|
-
return {
|
|
269313
|
-
"Base44-App-Id": appId,
|
|
269314
|
-
"Base44-Api-Url": `http://${host}`,
|
|
269315
|
-
"Base44-Service-Authorization": createServiceAuthorizationHeader(),
|
|
269316
|
-
[FORWARDED_HEADER]: "1"
|
|
269317
|
-
};
|
|
269318
|
-
}
|
|
269319
|
-
function createAppServerProxy(target, logger) {
|
|
269320
|
-
let origin = "http://127.0.0.1:0";
|
|
269321
|
-
const proxy = import_http_proxy_middleware.createProxyMiddleware({
|
|
269322
|
-
router: () => origin,
|
|
269323
|
-
changeOrigin: true,
|
|
269324
|
-
on: {
|
|
269325
|
-
proxyReq: (proxyReq, req) => {
|
|
269326
|
-
for (const header of PLATFORM_OWNED_SDK_HEADERS) {
|
|
269327
|
-
proxyReq.removeHeader(header);
|
|
269328
|
-
}
|
|
269329
|
-
for (const [name, value] of Object.entries(sdkHeaders(target.appId, req.headers.host))) {
|
|
269330
|
-
proxyReq.setHeader(name, value);
|
|
269331
|
-
}
|
|
269332
|
-
},
|
|
269333
|
-
error: (err, _req, res) => {
|
|
269334
|
-
logger.error("App dev server proxy error:", err);
|
|
269335
|
-
if (res instanceof ServerResponse && !res.headersSent) {
|
|
269336
|
-
res.writeHead(502, { "Content-Type": "application/json" });
|
|
269337
|
-
res.end(JSON.stringify({
|
|
269338
|
-
error: "Failed to proxy request to the app dev server",
|
|
269339
|
-
details: err.message
|
|
269340
|
-
}));
|
|
269341
|
-
}
|
|
269342
|
-
}
|
|
269343
|
-
}
|
|
269344
|
-
});
|
|
269345
|
-
const resolveOrigin = async () => {
|
|
269346
|
-
origin = await target.waitForOrigin();
|
|
269347
|
-
};
|
|
269348
|
-
const middleware = async (req, res, next) => {
|
|
269349
|
-
if (req.headers[FORWARDED_HEADER]) {
|
|
269350
|
-
logger.error(PROXY_LOOP_MESSAGE);
|
|
269351
|
-
res.status(508).json({ error: PROXY_LOOP_MESSAGE });
|
|
269352
|
-
return;
|
|
269353
|
-
}
|
|
269354
|
-
try {
|
|
269355
|
-
await resolveOrigin();
|
|
269356
|
-
} catch (error) {
|
|
269357
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
269358
|
-
logger.error(message);
|
|
269359
|
-
res.status(502).json({ error: message });
|
|
269360
|
-
return;
|
|
269361
|
-
}
|
|
269362
|
-
await proxy(req, res, next);
|
|
269363
|
-
};
|
|
269364
|
-
const relay = new import_websocket_server.default({
|
|
269365
|
-
noServer: true,
|
|
269366
|
-
handleProtocols: (protocols) => [...protocols][0] ?? false
|
|
269367
|
-
});
|
|
269368
|
-
const upgrade = (req, socket, head) => {
|
|
269369
|
-
resolveOrigin().then(() => relay.handleUpgrade(req, socket, head, (client) => relayTo(client, req)), (error) => {
|
|
269370
|
-
logger.error(error instanceof Error ? error.message : String(error));
|
|
269371
|
-
socket.destroy();
|
|
269372
|
-
});
|
|
269373
|
-
};
|
|
269374
|
-
const relayTo = (client, req) => {
|
|
269375
|
-
const forwarded = {};
|
|
269376
|
-
for (let i = 0;i < req.rawHeaders.length; i += 2) {
|
|
269377
|
-
const lower = req.rawHeaders[i].toLowerCase();
|
|
269378
|
-
if (lower === "host" || lower.startsWith("sec-websocket-") || lower === "upgrade" || lower === "connection" || PLATFORM_OWNED_SDK_HEADERS.includes(lower)) {
|
|
269379
|
-
continue;
|
|
269380
|
-
}
|
|
269381
|
-
forwarded[req.rawHeaders[i]] = req.rawHeaders[i + 1];
|
|
269382
|
-
}
|
|
269383
|
-
const upstream = new import_websocket.default(`${origin.replace(/^http/, "ws")}${req.url}`, client.protocol || undefined, {
|
|
269384
|
-
headers: {
|
|
269385
|
-
...forwarded,
|
|
269386
|
-
...sdkHeaders(target.appId, req.headers.host)
|
|
269387
|
-
}
|
|
269388
|
-
});
|
|
269389
|
-
const pending = [];
|
|
269390
|
-
client.on("message", (data, isBinary) => {
|
|
269391
|
-
if (upstream.readyState === import_websocket.default.OPEN) {
|
|
269392
|
-
upstream.send(data, { binary: isBinary });
|
|
269393
|
-
} else {
|
|
269394
|
-
pending.push({ data, isBinary });
|
|
269395
|
-
}
|
|
269396
|
-
});
|
|
269397
|
-
upstream.on("open", () => {
|
|
269398
|
-
for (const { data, isBinary } of pending.splice(0)) {
|
|
269399
|
-
upstream.send(data, { binary: isBinary });
|
|
269400
|
-
}
|
|
269401
|
-
});
|
|
269402
|
-
upstream.on("message", (data, isBinary) => client.send(data, { binary: isBinary }));
|
|
269403
|
-
client.on("close", () => upstream.close());
|
|
269404
|
-
upstream.on("close", () => client.close());
|
|
269405
|
-
upstream.on("error", (error) => {
|
|
269406
|
-
logger.error("App dev server websocket error:", error);
|
|
269407
|
-
client.close();
|
|
269408
|
-
});
|
|
269409
|
-
};
|
|
269410
|
-
return { middleware, upgrade };
|
|
269411
|
-
}
|
|
269412
|
-
|
|
269413
266393
|
// src/cli/dev/dev-server/routes/functions.ts
|
|
269414
|
-
var import_express = __toESM(require_express(), 1);
|
|
269415
|
-
var import_http_proxy_middleware2 = __toESM(require_dist2(), 1);
|
|
269416
|
-
import { ServerResponse as ServerResponse2 } from "node:http";
|
|
269417
266394
|
function createFunctionRouter(manager, logger) {
|
|
269418
266395
|
const router = import_express.Router({ mergeParams: true });
|
|
269419
266396
|
const portsByRequest = new WeakMap;
|
|
269420
|
-
const proxy =
|
|
266397
|
+
const proxy = import_http_proxy_middleware.createProxyMiddleware({
|
|
269421
266398
|
router: (req) => `http://localhost:${portsByRequest.get(req)}`,
|
|
269422
266399
|
changeOrigin: true,
|
|
269423
266400
|
on: {
|
|
@@ -269431,7 +266408,7 @@ function createFunctionRouter(manager, logger) {
|
|
|
269431
266408
|
},
|
|
269432
266409
|
error: (err, _req, res) => {
|
|
269433
266410
|
logger.error("Function proxy error:", err);
|
|
269434
|
-
if (res instanceof
|
|
266411
|
+
if (res instanceof ServerResponse && !res.headersSent) {
|
|
269435
266412
|
res.writeHead(502, { "Content-Type": "application/json" });
|
|
269436
266413
|
res.end(JSON.stringify({
|
|
269437
266414
|
error: "Failed to proxy request to function",
|
|
@@ -269777,10 +266754,9 @@ var import_dist = __toESM(require_dist4(), 1);
|
|
|
269777
266754
|
var { Server, Namespace, Socket } = import_dist.default;
|
|
269778
266755
|
|
|
269779
266756
|
// src/cli/dev/dev-server/realtime.ts
|
|
269780
|
-
var REALTIME_PATH = "/ws-user-apps/socket.io/";
|
|
269781
266757
|
function createRealtimeServer(httpServer) {
|
|
269782
266758
|
const io = new Server(httpServer, {
|
|
269783
|
-
path:
|
|
266759
|
+
path: "/ws-user-apps/socket.io/",
|
|
269784
266760
|
cors: {
|
|
269785
266761
|
origin: /^http:\/\/localhost(:\d+)?$/,
|
|
269786
266762
|
credentials: true
|
|
@@ -272375,7 +269351,6 @@ class WatchBase44 extends EventEmitter4 {
|
|
|
272375
269351
|
// src/cli/dev/dev-server/main.ts
|
|
272376
269352
|
var DEFAULT_PORT = 4400;
|
|
272377
269353
|
var BASE44_APP_URL = "https://base44.app";
|
|
272378
|
-
var PLATFORM_PATH_PATTERN = /^\/api\/(apps|app-logs)(\/|$)/;
|
|
272379
269354
|
async function createDevServer(options) {
|
|
272380
269355
|
const { port: userPort } = options;
|
|
272381
269356
|
const port = userPort ?? await getPorts({
|
|
@@ -272384,7 +269359,7 @@ async function createDevServer(options) {
|
|
|
272384
269359
|
const baseUrl = `http://localhost:${port}`;
|
|
272385
269360
|
const { functions, entities, project, siteUrl } = await options.loadResources();
|
|
272386
269361
|
const app = import_express6.default();
|
|
272387
|
-
const remoteProxy =
|
|
269362
|
+
const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
|
|
272388
269363
|
target: BASE44_APP_URL,
|
|
272389
269364
|
changeOrigin: true
|
|
272390
269365
|
});
|
|
@@ -272446,11 +269421,7 @@ async function createDevServer(options) {
|
|
|
272446
269421
|
app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
|
|
272447
269422
|
const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
|
|
272448
269423
|
app.use("/api/apps/:appId/integrations/custom", customIntegrationRoutes);
|
|
272449
|
-
const appServerProxy = options.appServer ? createAppServerProxy(options.appServer, devLogger) : undefined;
|
|
272450
269424
|
app.use((req, res, next) => {
|
|
272451
|
-
if (appServerProxy && !PLATFORM_PATH_PATTERN.test(req.path)) {
|
|
272452
|
-
return appServerProxy.middleware(req, res, next);
|
|
272453
|
-
}
|
|
272454
269425
|
if (siteUrl && (req.path === "/login" || req.path.startsWith("/login/"))) {
|
|
272455
269426
|
const targetUrl = new URL(req.originalUrl, siteUrl);
|
|
272456
269427
|
devLogger.warn(`"${req.originalUrl}" requires hosted login, redirecting to ${targetUrl.toString()}`);
|
|
@@ -272475,13 +269446,6 @@ async function createDevServer(options) {
|
|
|
272475
269446
|
}
|
|
272476
269447
|
});
|
|
272477
269448
|
});
|
|
272478
|
-
if (appServerProxy) {
|
|
272479
|
-
server.on("upgrade", (req, socket, head) => {
|
|
272480
|
-
if (!req.url?.startsWith(REALTIME_PATH)) {
|
|
272481
|
-
appServerProxy.upgrade(req, socket, head);
|
|
272482
|
-
}
|
|
272483
|
-
});
|
|
272484
|
-
}
|
|
272485
269449
|
const io = createRealtimeServer(server);
|
|
272486
269450
|
emitEntityEvent = (appId, entityName, event) => {
|
|
272487
269451
|
broadcastEntityEvent(io, appId, entityName, event);
|
|
@@ -272555,24 +269519,9 @@ async function createDevServer(options) {
|
|
|
272555
269519
|
}
|
|
272556
269520
|
|
|
272557
269521
|
// src/cli/commands/dev.ts
|
|
272558
|
-
var APP_SERVER_START_TIMEOUT_MS = 120000;
|
|
272559
269522
|
function localServerUrl(port) {
|
|
272560
269523
|
return `http://localhost:${port}`;
|
|
272561
269524
|
}
|
|
272562
|
-
function createAppServerOrigin() {
|
|
272563
|
-
let report;
|
|
272564
|
-
const announced = new Promise((resolve) => {
|
|
272565
|
-
report = resolve;
|
|
272566
|
-
});
|
|
272567
|
-
const timedOut = new Promise((_, reject) => {
|
|
272568
|
-
const timer = setTimeout(() => reject(new Error("The app dev server did not print a local URL, so requests cannot be forwarded to it.")), APP_SERVER_START_TIMEOUT_MS);
|
|
272569
|
-
timer.unref();
|
|
272570
|
-
});
|
|
272571
|
-
return {
|
|
272572
|
-
waitForOrigin: () => Promise.race([announced, timedOut]),
|
|
272573
|
-
report
|
|
272574
|
-
};
|
|
272575
|
-
}
|
|
272576
269525
|
function validateDevOptions(command) {
|
|
272577
269526
|
const { appId } = command.optsWithGlobals();
|
|
272578
269527
|
if (appId !== undefined) {
|
|
@@ -272625,12 +269574,10 @@ async function localDevAction(ctx, app, options) {
|
|
|
272625
269574
|
const siteUrlPromise = getSiteUrl().catch(() => {
|
|
272626
269575
|
return;
|
|
272627
269576
|
});
|
|
272628
|
-
const appServerOrigin = createAppServerOrigin();
|
|
272629
269577
|
const backend = await createDevServer({
|
|
272630
269578
|
log: ctx.log,
|
|
272631
269579
|
port: options.port ? Number(options.port) : undefined,
|
|
272632
269580
|
denoWrapperPath: getDenoWrapperPath(),
|
|
272633
|
-
appServer: site ? { appId: app.id, waitForOrigin: appServerOrigin.waitForOrigin } : undefined,
|
|
272634
269581
|
loadResources: async () => {
|
|
272635
269582
|
const { functions, entities, project } = await readProjectConfig();
|
|
272636
269583
|
const siteUrl = await siteUrlPromise;
|
|
@@ -272642,13 +269589,11 @@ async function localDevAction(ctx, app, options) {
|
|
|
272642
269589
|
const runner = createServeCommandRunner({
|
|
272643
269590
|
...site,
|
|
272644
269591
|
appId: app.id,
|
|
272645
|
-
appBaseUrl: backendUrl
|
|
272646
|
-
onOrigin: appServerOrigin.report,
|
|
272647
|
-
ignorePort: backend.port
|
|
269592
|
+
appBaseUrl: backendUrl
|
|
272648
269593
|
});
|
|
272649
269594
|
startServeCommand(runner, { url: backendUrl, shutdown: backend.shutdown });
|
|
272650
269595
|
}
|
|
272651
|
-
const outroMessage = site ?
|
|
269596
|
+
const outroMessage = site ? "Open your app using the frontend dev server URL" : `Dev server is available at ${theme.colors.links(backendUrl)}`;
|
|
272652
269597
|
return { outroMessage };
|
|
272653
269598
|
}
|
|
272654
269599
|
async function devAction(ctx, options) {
|
|
@@ -272866,6 +269811,385 @@ Examples:
|
|
|
272866
269811
|
$ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
|
|
272867
269812
|
}
|
|
272868
269813
|
|
|
269814
|
+
// src/cli/commands/import.ts
|
|
269815
|
+
var import_ms2 = __toESM(require_ms(), 1);
|
|
269816
|
+
|
|
269817
|
+
// src/core/session-import/api.ts
|
|
269818
|
+
var MAX_SESSION_BYTES = 25 * 1024 * 1024;
|
|
269819
|
+
var SessionImportResponseSchema = object({
|
|
269820
|
+
branch_id: string2(),
|
|
269821
|
+
branch_name: string2(),
|
|
269822
|
+
source: _enum(["claude_code", "codex"]),
|
|
269823
|
+
turn_count: number2(),
|
|
269824
|
+
branch_url: string2()
|
|
269825
|
+
}).transform((data) => ({
|
|
269826
|
+
branchId: data.branch_id,
|
|
269827
|
+
branchName: data.branch_name,
|
|
269828
|
+
source: data.source,
|
|
269829
|
+
turnCount: data.turn_count,
|
|
269830
|
+
branchUrl: data.branch_url
|
|
269831
|
+
}));
|
|
269832
|
+
var ErrorEnvelopeSchema = object({
|
|
269833
|
+
error: object({ code: string2().optional() })
|
|
269834
|
+
});
|
|
269835
|
+
var NETWORK_BLOCKED = "claude.ai is blocking Base44. In this session's environment settings, open Network access, add `app.base44.com` to Allowed domains, save, and try again.";
|
|
269836
|
+
function messageFor(status, code, viaToken) {
|
|
269837
|
+
if (status === 401 && viaToken) {
|
|
269838
|
+
return "This import key expired or was already used. In Base Code, open Import session and copy a new prompt.";
|
|
269839
|
+
}
|
|
269840
|
+
if (status === 403) {
|
|
269841
|
+
return "You don't have edit access to this app, or this key was made for a different app.";
|
|
269842
|
+
}
|
|
269843
|
+
if (status === 404)
|
|
269844
|
+
return "Session import isn't available for this app.";
|
|
269845
|
+
if (status === 413)
|
|
269846
|
+
return "This session is over 25 MB and can't be imported.";
|
|
269847
|
+
if (code === "unsupported_file") {
|
|
269848
|
+
return "That file isn't a Claude Code or Codex session.";
|
|
269849
|
+
}
|
|
269850
|
+
if (code === "repository_mismatch") {
|
|
269851
|
+
return "This session is from a different repository than the app.";
|
|
269852
|
+
}
|
|
269853
|
+
if (status === 429)
|
|
269854
|
+
return "Too many imports. Wait a minute and try again.";
|
|
269855
|
+
return;
|
|
269856
|
+
}
|
|
269857
|
+
async function toImportError(error, viaToken) {
|
|
269858
|
+
if (!(error instanceof HTTPError)) {
|
|
269859
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
269860
|
+
return new ApiError(process.env.CLAUDE_CODE_REMOTE ? NETWORK_BLOCKED : `Couldn't reach Base44: ${reason}`, { hints: [] });
|
|
269861
|
+
}
|
|
269862
|
+
const { status } = error.response;
|
|
269863
|
+
const fallback = await ApiError.fromHttpError(error, "importing session");
|
|
269864
|
+
const envelope = ErrorEnvelopeSchema.safeParse(fallback.responseBody);
|
|
269865
|
+
const code = envelope.success ? envelope.data.error.code : undefined;
|
|
269866
|
+
const blocked = process.env.CLAUDE_CODE_REMOTE && status === 403 && typeof fallback.responseBody !== "object";
|
|
269867
|
+
const known = blocked ? NETWORK_BLOCKED : messageFor(status, code, viaToken);
|
|
269868
|
+
return new ApiError(known ?? fallback.message, {
|
|
269869
|
+
statusCode: status,
|
|
269870
|
+
requestUrl: error.request.url,
|
|
269871
|
+
requestMethod: error.request.method,
|
|
269872
|
+
requestId: fallback.requestId,
|
|
269873
|
+
hints: known ? [] : fallback.hints
|
|
269874
|
+
});
|
|
269875
|
+
}
|
|
269876
|
+
async function uploadSession(appId, content, { token, sourceBranch } = {}) {
|
|
269877
|
+
const form = new FormData;
|
|
269878
|
+
form.append("file", new Blob([content]), "session.jsonl");
|
|
269879
|
+
if (sourceBranch)
|
|
269880
|
+
form.append("source_branch", sourceBranch);
|
|
269881
|
+
let response;
|
|
269882
|
+
try {
|
|
269883
|
+
response = token ? await distribution_default.post(new URL(`/api/apps/${appId}/imported/session-imports`, getBase44ApiUrl()), {
|
|
269884
|
+
body: form,
|
|
269885
|
+
headers: {
|
|
269886
|
+
Authorization: `Bearer ${token}`,
|
|
269887
|
+
"User-Agent": "Base44 CLI"
|
|
269888
|
+
},
|
|
269889
|
+
timeout: 180000
|
|
269890
|
+
}) : await getAppClient().post("imported/session-imports", {
|
|
269891
|
+
body: form,
|
|
269892
|
+
timeout: 180000
|
|
269893
|
+
});
|
|
269894
|
+
} catch (error) {
|
|
269895
|
+
throw await toImportError(error, Boolean(token));
|
|
269896
|
+
}
|
|
269897
|
+
const result = SessionImportResponseSchema.safeParse(await response.json());
|
|
269898
|
+
if (!result.success) {
|
|
269899
|
+
throw new SchemaValidationError("Invalid session import response from server", result.error);
|
|
269900
|
+
}
|
|
269901
|
+
return result.data;
|
|
269902
|
+
}
|
|
269903
|
+
|
|
269904
|
+
// src/core/session-import/sessions.ts
|
|
269905
|
+
import { createReadStream as createReadStream3 } from "node:fs";
|
|
269906
|
+
import { realpath as realpath2, rm as rm5, stat as stat8 } from "node:fs/promises";
|
|
269907
|
+
import { homedir as homedir5 } from "node:os";
|
|
269908
|
+
import { dirname as dirname29, join as join41 } from "node:path";
|
|
269909
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
269910
|
+
var claudeDir = () => process.env.CLAUDE_CONFIG_DIR || join41(homedir5(), ".claude");
|
|
269911
|
+
var codexDir = () => process.env.CODEX_HOME || join41(homedir5(), ".codex");
|
|
269912
|
+
async function scanLines(path, pick, maxLines = Number.POSITIVE_INFINITY) {
|
|
269913
|
+
const lines = createInterface2({ input: createReadStream3(path) });
|
|
269914
|
+
let count = 0;
|
|
269915
|
+
try {
|
|
269916
|
+
for await (const line of lines) {
|
|
269917
|
+
if (++count > maxLines)
|
|
269918
|
+
return;
|
|
269919
|
+
try {
|
|
269920
|
+
const found = pick(JSON.parse(line));
|
|
269921
|
+
if (found !== undefined)
|
|
269922
|
+
return found;
|
|
269923
|
+
} catch {}
|
|
269924
|
+
}
|
|
269925
|
+
} finally {
|
|
269926
|
+
lines.close();
|
|
269927
|
+
}
|
|
269928
|
+
return;
|
|
269929
|
+
}
|
|
269930
|
+
var asRecord = (value) => value && typeof value === "object" ? value : {};
|
|
269931
|
+
var codexCwd = (entry) => entry.type === "session_meta" ? String(asRecord(entry.payload).cwd ?? "") : undefined;
|
|
269932
|
+
async function newest(paths) {
|
|
269933
|
+
let best;
|
|
269934
|
+
for (const path of paths) {
|
|
269935
|
+
const { mtimeMs } = await stat8(path);
|
|
269936
|
+
if (!best || mtimeMs > best.mtime)
|
|
269937
|
+
best = { path, mtime: mtimeMs };
|
|
269938
|
+
}
|
|
269939
|
+
return best?.path;
|
|
269940
|
+
}
|
|
269941
|
+
async function sameDir(a, b) {
|
|
269942
|
+
if (a === b)
|
|
269943
|
+
return true;
|
|
269944
|
+
const [ra, rb] = await Promise.all([
|
|
269945
|
+
realpath2(a).catch(() => a),
|
|
269946
|
+
realpath2(b).catch(() => b)
|
|
269947
|
+
]);
|
|
269948
|
+
return ra === rb;
|
|
269949
|
+
}
|
|
269950
|
+
var codexRollouts = () => globby("sessions/*/*/*/rollout-*.jsonl", {
|
|
269951
|
+
cwd: codexDir(),
|
|
269952
|
+
absolute: true
|
|
269953
|
+
});
|
|
269954
|
+
async function codexRolloutsIn(cwd) {
|
|
269955
|
+
const matches = [];
|
|
269956
|
+
for (const path of await codexRollouts()) {
|
|
269957
|
+
const recorded = await scanLines(path, codexCwd, 1);
|
|
269958
|
+
if (recorded && await sameDir(recorded, cwd))
|
|
269959
|
+
matches.push(path);
|
|
269960
|
+
}
|
|
269961
|
+
return matches;
|
|
269962
|
+
}
|
|
269963
|
+
async function findCurrentSession(cwd) {
|
|
269964
|
+
const claudeId = process.env.CLAUDE_CODE_SESSION_ID;
|
|
269965
|
+
if (claudeId) {
|
|
269966
|
+
const [path] = await globby(`projects/*/${claudeId}.jsonl`, {
|
|
269967
|
+
cwd: claudeDir(),
|
|
269968
|
+
absolute: true
|
|
269969
|
+
});
|
|
269970
|
+
return path;
|
|
269971
|
+
}
|
|
269972
|
+
const codexId = process.env.CODEX_THREAD_ID;
|
|
269973
|
+
if (codexId) {
|
|
269974
|
+
const rollouts = await codexRollouts();
|
|
269975
|
+
return rollouts.find((path) => path.endsWith(`-${codexId}.jsonl`));
|
|
269976
|
+
}
|
|
269977
|
+
return newest(await codexRolloutsIn(cwd));
|
|
269978
|
+
}
|
|
269979
|
+
function claudeUserText(entry) {
|
|
269980
|
+
if (entry.type !== "user" || entry.isMeta || entry.isSidechain)
|
|
269981
|
+
return;
|
|
269982
|
+
const content = asRecord(entry.message).content;
|
|
269983
|
+
return typeof content === "string" && !content.startsWith("<") ? content : undefined;
|
|
269984
|
+
}
|
|
269985
|
+
function codexUserText(entry) {
|
|
269986
|
+
const payload = asRecord(entry.payload);
|
|
269987
|
+
return entry.type === "event_msg" && payload.type === "user_message" ? String(payload.message ?? "") : undefined;
|
|
269988
|
+
}
|
|
269989
|
+
var PICKER_LIMIT = 20;
|
|
269990
|
+
async function listSessions(cwd) {
|
|
269991
|
+
const claudeFolder = cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
269992
|
+
const claude = await globby(`projects/${claudeFolder}/*.jsonl`, {
|
|
269993
|
+
cwd: claudeDir(),
|
|
269994
|
+
absolute: true
|
|
269995
|
+
});
|
|
269996
|
+
const candidates = [
|
|
269997
|
+
...claude.map((path) => ({ tool: "claude_code", path })),
|
|
269998
|
+
...(await codexRolloutsIn(cwd)).map((path) => ({
|
|
269999
|
+
tool: "codex",
|
|
270000
|
+
path
|
|
270001
|
+
}))
|
|
270002
|
+
];
|
|
270003
|
+
const dated = await Promise.all(candidates.map(async (c) => ({
|
|
270004
|
+
...c,
|
|
270005
|
+
updatedAt: (await stat8(c.path)).mtime
|
|
270006
|
+
})));
|
|
270007
|
+
dated.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
270008
|
+
const sessions = [];
|
|
270009
|
+
for (const candidate of dated.slice(0, PICKER_LIMIT)) {
|
|
270010
|
+
const firstMessage = await scanLines(candidate.path, candidate.tool === "claude_code" ? claudeUserText : codexUserText);
|
|
270011
|
+
if (firstMessage)
|
|
270012
|
+
sessions.push({ ...candidate, firstMessage });
|
|
270013
|
+
}
|
|
270014
|
+
return sessions;
|
|
270015
|
+
}
|
|
270016
|
+
var SESSION_ID = /session_[A-Za-z0-9]+/;
|
|
270017
|
+
function parseSessionLink(link) {
|
|
270018
|
+
if (/cshk_/.test(link) || !SESSION_ID.test(link)) {
|
|
270019
|
+
throw new InvalidInputError(`That isn't a claude.ai session address. Copy it from your browser's address bar (not "Copy link").`, { hints: [] });
|
|
270020
|
+
}
|
|
270021
|
+
return link.match(SESSION_ID)[0];
|
|
270022
|
+
}
|
|
270023
|
+
var TELEPORT_PROMPT = "Reply with OK.";
|
|
270024
|
+
var TELEPORT_NOTE = "This session is being continued from another machine";
|
|
270025
|
+
function parseLine(line) {
|
|
270026
|
+
try {
|
|
270027
|
+
return asRecord(JSON.parse(line));
|
|
270028
|
+
} catch {
|
|
270029
|
+
return {};
|
|
270030
|
+
}
|
|
270031
|
+
}
|
|
270032
|
+
function stripTeleportExchange(content) {
|
|
270033
|
+
const lines = content.split(`
|
|
270034
|
+
`);
|
|
270035
|
+
const entries = lines.map(parseLine);
|
|
270036
|
+
const userText = (entry) => entry.type === "user" ? asRecord(entry.message).content : undefined;
|
|
270037
|
+
let end = lines.length;
|
|
270038
|
+
for (let i = lines.length - 1;i >= 0; i--) {
|
|
270039
|
+
if (userText(entries[i] ?? {}) === TELEPORT_PROMPT) {
|
|
270040
|
+
end = i;
|
|
270041
|
+
break;
|
|
270042
|
+
}
|
|
270043
|
+
}
|
|
270044
|
+
return lines.slice(0, end).filter((_, i) => {
|
|
270045
|
+
const entry = entries[i] ?? {};
|
|
270046
|
+
const text = userText(entry);
|
|
270047
|
+
const queued = entry.type === "queue-operation" && entry.content === TELEPORT_PROMPT;
|
|
270048
|
+
const note = typeof text === "string" && text.startsWith(TELEPORT_NOTE);
|
|
270049
|
+
return !queued && !note;
|
|
270050
|
+
}).join(`
|
|
270051
|
+
`);
|
|
270052
|
+
}
|
|
270053
|
+
var NEEDS_CLAUDE = "Claude Code must be installed and signed in to the same claude.ai account to import a claude.ai session.";
|
|
270054
|
+
async function teleportSession(sessionId, cwd) {
|
|
270055
|
+
const origin = await execa("git", ["remote", "get-url", "origin"], {
|
|
270056
|
+
cwd,
|
|
270057
|
+
reject: false
|
|
270058
|
+
});
|
|
270059
|
+
if (origin.exitCode !== 0 || !origin.stdout) {
|
|
270060
|
+
throw new InvalidInputError("Run this from a folder with the app's GitHub repository, so the session can be checked out.");
|
|
270061
|
+
}
|
|
270062
|
+
const tmp = await $dir({ unsafeCleanup: true });
|
|
270063
|
+
const repo = join41(tmp.path, "repo");
|
|
270064
|
+
let projectFolder;
|
|
270065
|
+
try {
|
|
270066
|
+
await execa("git", ["clone", "--quiet", origin.stdout, repo]);
|
|
270067
|
+
const repoReal = await realpath2(repo);
|
|
270068
|
+
const startedAt = Date.now();
|
|
270069
|
+
const claudeBin = getTestOverrides()?.claudeBin ?? "claude";
|
|
270070
|
+
try {
|
|
270071
|
+
await execa(claudeBin, ["--teleport", sessionId, "-p", TELEPORT_PROMPT], {
|
|
270072
|
+
cwd: repo,
|
|
270073
|
+
stdin: "ignore"
|
|
270074
|
+
});
|
|
270075
|
+
} catch {
|
|
270076
|
+
throw new DependencyNotFoundError(NEEDS_CLAUDE, { hints: [] });
|
|
270077
|
+
}
|
|
270078
|
+
const fresh = [];
|
|
270079
|
+
for (const path of await globby("projects/*/*.jsonl", {
|
|
270080
|
+
cwd: claudeDir(),
|
|
270081
|
+
absolute: true
|
|
270082
|
+
})) {
|
|
270083
|
+
if ((await stat8(path)).mtimeMs < startedAt)
|
|
270084
|
+
continue;
|
|
270085
|
+
const sessionCwd = await scanLines(path, (entry) => typeof entry.cwd === "string" ? entry.cwd : undefined, 50);
|
|
270086
|
+
if (sessionCwd === repo || sessionCwd === repoReal)
|
|
270087
|
+
fresh.push(path);
|
|
270088
|
+
}
|
|
270089
|
+
const file = await newest(fresh);
|
|
270090
|
+
if (!file)
|
|
270091
|
+
throw new DependencyNotFoundError(NEEDS_CLAUDE, { hints: [] });
|
|
270092
|
+
projectFolder = dirname29(file);
|
|
270093
|
+
return stripTeleportExchange((await readFile(file)).toString("utf8"));
|
|
270094
|
+
} finally {
|
|
270095
|
+
if (projectFolder)
|
|
270096
|
+
await rm5(projectFolder, { recursive: true, force: true });
|
|
270097
|
+
await tmp.cleanup();
|
|
270098
|
+
}
|
|
270099
|
+
}
|
|
270100
|
+
|
|
270101
|
+
// src/cli/commands/import.ts
|
|
270102
|
+
var TOOL_LABELS = {
|
|
270103
|
+
claude_code: "Claude Code",
|
|
270104
|
+
codex: "Codex"
|
|
270105
|
+
};
|
|
270106
|
+
async function pickSession(cwd) {
|
|
270107
|
+
const sessions = await listSessions(cwd);
|
|
270108
|
+
if (sessions.length === 0) {
|
|
270109
|
+
throw new InvalidInputError("No Claude Code or Codex sessions found in this folder. Pass --file <path>.");
|
|
270110
|
+
}
|
|
270111
|
+
const choice = await Je({
|
|
270112
|
+
message: "Which session do you want to continue in Base Code?",
|
|
270113
|
+
options: sessions.map((session) => ({
|
|
270114
|
+
value: session.path,
|
|
270115
|
+
label: session.firstMessage.replace(/\s+/g, " ").slice(0, 70),
|
|
270116
|
+
hint: `${TOOL_LABELS[session.tool]}, ${import_ms2.default(Date.now() - session.updatedAt.getTime())} ago`
|
|
270117
|
+
}))
|
|
270118
|
+
});
|
|
270119
|
+
if (Ct(choice)) {
|
|
270120
|
+
Ne("Operation cancelled.");
|
|
270121
|
+
throw new CLIExitError(0);
|
|
270122
|
+
}
|
|
270123
|
+
return choice;
|
|
270124
|
+
}
|
|
270125
|
+
async function readSession(ctx, link, options) {
|
|
270126
|
+
const cwd = process.cwd();
|
|
270127
|
+
if (options.file)
|
|
270128
|
+
return readFile(options.file);
|
|
270129
|
+
if (link) {
|
|
270130
|
+
const sessionId = parseSessionLink(link);
|
|
270131
|
+
const content = await ctx.runTask("Downloading the claude.ai session", () => teleportSession(sessionId, cwd));
|
|
270132
|
+
return Buffer.from(content);
|
|
270133
|
+
}
|
|
270134
|
+
if (options.current) {
|
|
270135
|
+
const path = await findCurrentSession(cwd);
|
|
270136
|
+
if (!path) {
|
|
270137
|
+
throw new InvalidInputError("Couldn't find the current session. Run this from inside Claude Code or Codex, or pass --file <path>.", { hints: [] });
|
|
270138
|
+
}
|
|
270139
|
+
return readFile(path);
|
|
270140
|
+
}
|
|
270141
|
+
if (ctx.isNonInteractive || ctx.jsonMode) {
|
|
270142
|
+
throw new InvalidInputError("Choose a session: pass --current, a claude.ai session link, or --file <path>.");
|
|
270143
|
+
}
|
|
270144
|
+
return readFile(await pickSession(cwd));
|
|
270145
|
+
}
|
|
270146
|
+
async function importAction(ctx, link, options, command) {
|
|
270147
|
+
ctx.errorReporter.setContext({
|
|
270148
|
+
command: {
|
|
270149
|
+
name: "import",
|
|
270150
|
+
args: link ? ["[not reported]"] : [],
|
|
270151
|
+
options: {
|
|
270152
|
+
...command.opts(),
|
|
270153
|
+
...options.token ? { token: "[not reported]" } : {}
|
|
270154
|
+
}
|
|
270155
|
+
}
|
|
270156
|
+
});
|
|
270157
|
+
const chosen = [link, options.current, options.file].filter(Boolean).length;
|
|
270158
|
+
if (chosen > 1) {
|
|
270159
|
+
throw new InvalidInputError("Pass only one of: a session link, --current, or --file.");
|
|
270160
|
+
}
|
|
270161
|
+
const appId = requireApp(ctx).id;
|
|
270162
|
+
const content = await readSession(ctx, link, options);
|
|
270163
|
+
if (content.length > MAX_SESSION_BYTES) {
|
|
270164
|
+
throw new InvalidInputError("This session is over 25 MB and can't be imported.", { hints: [] });
|
|
270165
|
+
}
|
|
270166
|
+
const git = link || options.file ? undefined : await readGitState(process.cwd());
|
|
270167
|
+
if (git?.unpushed && !options.skipPushCheck) {
|
|
270168
|
+
throw new InvalidInputError("Your changes aren't on GitHub yet. Ask the user whether to commit and push them (to a new branch if on main or master), then run this again. If they don't want to, run it again with --skip-push-check.", { hints: [] });
|
|
270169
|
+
}
|
|
270170
|
+
const note = git?.unpushed ? "Base Code started from what's on GitHub; your local changes aren't included." : undefined;
|
|
270171
|
+
if (!options.token)
|
|
270172
|
+
await ensureAuth(ctx);
|
|
270173
|
+
ctx.log.info("This uploads the full conversation to Base Code.");
|
|
270174
|
+
const imported = await ctx.runTask("Importing session", () => uploadSession(appId, content, {
|
|
270175
|
+
token: options.token,
|
|
270176
|
+
sourceBranch: git?.branch
|
|
270177
|
+
}));
|
|
270178
|
+
const url = `${getBase44ApiUrl()}${imported.branchUrl}`;
|
|
270179
|
+
return {
|
|
270180
|
+
outroMessage: [
|
|
270181
|
+
`✓ Imported ${imported.turnCount} messages from ${TOOL_LABELS[imported.source]} into branch "${imported.branchName}".`,
|
|
270182
|
+
...note ? [note] : [],
|
|
270183
|
+
`Open it: ${url}`
|
|
270184
|
+
].join(`
|
|
270185
|
+
`),
|
|
270186
|
+
stdout: ctx.jsonMode ? toJsonStdout({ ...imported, url, ...note ? { note } : {} }) : undefined
|
|
270187
|
+
};
|
|
270188
|
+
}
|
|
270189
|
+
function getImportCommand() {
|
|
270190
|
+
return new Base44Command("import", { requireAuth: false }).description("Continue a Claude Code or Codex session in a new Base Code branch").argument("[session-link]", "A claude.ai session address (https://claude.ai/code/session_…)").option("--current", "Import the session this command runs inside").option("--file <path>", "Import this session file as is").option("--skip-push-check", "Import even though local changes aren't on GitHub (they won't be included)").option("--token <key>", "One-time import key from Base Code (no login needed)").action(importAction);
|
|
270191
|
+
}
|
|
270192
|
+
|
|
272869
270193
|
// src/cli/commands/project/eject.ts
|
|
272870
270194
|
import { resolve as resolve20 } from "node:path";
|
|
272871
270195
|
var import_kebabCase2 = __toESM(require_kebabCase(), 1);
|
|
@@ -273029,6 +270353,7 @@ function createProgram(context) {
|
|
|
273029
270353
|
program.addCommand(getExecCommand());
|
|
273030
270354
|
program.addCommand(getDevCommand());
|
|
273031
270355
|
program.addCommand(getLogsCommand());
|
|
270356
|
+
program.addCommand(getImportCommand());
|
|
273032
270357
|
return program;
|
|
273033
270358
|
}
|
|
273034
270359
|
|
|
@@ -273037,7 +270362,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
|
|
|
273037
270362
|
import { release, type } from "node:os";
|
|
273038
270363
|
|
|
273039
270364
|
// ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
273040
|
-
import { dirname as
|
|
270365
|
+
import { dirname as dirname30, posix, sep as sep2 } from "path";
|
|
273041
270366
|
function createModulerModifier() {
|
|
273042
270367
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
273043
270368
|
return async (frames) => {
|
|
@@ -273046,7 +270371,7 @@ function createModulerModifier() {
|
|
|
273046
270371
|
return frames;
|
|
273047
270372
|
};
|
|
273048
270373
|
}
|
|
273049
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
270374
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname30(process.argv[1]) : process.cwd(), isWindows = sep2 === "\\") {
|
|
273050
270375
|
const normalizedBase = isWindows ? normalizeWindowsPath2(basePath) : basePath;
|
|
273051
270376
|
return (filename) => {
|
|
273052
270377
|
if (!filename)
|
|
@@ -275081,8 +272406,8 @@ class ReduceableCache {
|
|
|
275081
272406
|
}
|
|
275082
272407
|
}
|
|
275083
272408
|
// ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
|
|
275084
|
-
import { createReadStream as
|
|
275085
|
-
import { createInterface as
|
|
272409
|
+
import { createReadStream as createReadStream4 } from "node:fs";
|
|
272410
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
275086
272411
|
var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
|
|
275087
272412
|
var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
|
|
275088
272413
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
@@ -275125,8 +272450,8 @@ async function addSourceContext(frames) {
|
|
|
275125
272450
|
}
|
|
275126
272451
|
function getContextLinesFromFile(path, ranges, output) {
|
|
275127
272452
|
return new Promise((resolve) => {
|
|
275128
|
-
const stream =
|
|
275129
|
-
const lineReaded =
|
|
272453
|
+
const stream = createReadStream4(path);
|
|
272454
|
+
const lineReaded = createInterface3({
|
|
275130
272455
|
input: stream
|
|
275131
272456
|
});
|
|
275132
272457
|
function destroyStreamAndResolve() {
|
|
@@ -277035,9 +274360,9 @@ function addCommandInfoToErrorReporter(program, errorReporter) {
|
|
|
277035
274360
|
});
|
|
277036
274361
|
}
|
|
277037
274362
|
// src/cli/index.ts
|
|
277038
|
-
var __dirname4 =
|
|
274363
|
+
var __dirname4 = dirname31(fileURLToPath7(import.meta.url));
|
|
277039
274364
|
async function runCLI(options) {
|
|
277040
|
-
ensureNpmAssets(
|
|
274365
|
+
ensureNpmAssets(join42(__dirname4, "../assets"));
|
|
277041
274366
|
const errorReporter = new ErrorReporter;
|
|
277042
274367
|
errorReporter.registerProcessErrorHandlers();
|
|
277043
274368
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -277076,4 +274401,4 @@ export {
|
|
|
277076
274401
|
runCLI
|
|
277077
274402
|
};
|
|
277078
274403
|
|
|
277079
|
-
//# debugId=
|
|
274404
|
+
//# debugId=0DBD267E70A92BD164756E2164756E21
|