@uipath/cli 1.203.0-preview.182 → 1.203.0-preview.203
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/THIRD-PARTY-NOTICES.md +109 -4
- package/dist/{cli-v2cbt36x.js → cli-2nmaevwc.js} +2 -2
- package/dist/{index-r3carw1e.js → index-7kfg2zz1.js} +1437 -617
- package/dist/{index-pxqxy1sx.js → index-ttatj0sp.js} +150 -18
- package/dist/{index-4q45kdqv.js → index-z0m79t8p.js} +3 -3
- package/dist/index.js +3 -3
- package/dist/{mcp-z5911fjd.js → mcp-g5sxmbpy.js} +8 -7
- package/dist/{server-mk7sear1.js → server-82exah8x.js} +2 -2
- package/dist/{updateService-chd3q3v4.js → updateService-e4yhztgq.js} +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,8 @@ var require_symbols = __commonJS(function(exports, module) {
|
|
|
10
10
|
kDestroy: Symbol("destroy"),
|
|
11
11
|
kDispatch: Symbol("dispatch"),
|
|
12
12
|
kUrl: Symbol("url"),
|
|
13
|
+
kRequestOrigin: Symbol("request origin"),
|
|
14
|
+
kOriginless: Symbol("originless"),
|
|
13
15
|
kWriting: Symbol("writing"),
|
|
14
16
|
kResuming: Symbol("resuming"),
|
|
15
17
|
kQueue: Symbol("queue"),
|
|
@@ -1212,35 +1214,6 @@ var require_util = __commonJS(function(exports, module) {
|
|
|
1212
1214
|
bytesRead: socket.bytesRead
|
|
1213
1215
|
};
|
|
1214
1216
|
}
|
|
1215
|
-
function ReadableStreamFrom(iterable) {
|
|
1216
|
-
let iterator;
|
|
1217
|
-
return new ReadableStream({
|
|
1218
|
-
start() {
|
|
1219
|
-
iterator = iterable[Symbol.asyncIterator]();
|
|
1220
|
-
},
|
|
1221
|
-
pull(controller) {
|
|
1222
|
-
return iterator.next().then(({ done, value }) => {
|
|
1223
|
-
if (done) {
|
|
1224
|
-
return queueMicrotask(() => {
|
|
1225
|
-
controller.close();
|
|
1226
|
-
controller.byobRequest?.respond(0);
|
|
1227
|
-
});
|
|
1228
|
-
} else {
|
|
1229
|
-
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
1230
|
-
if (buf.byteLength) {
|
|
1231
|
-
return controller.enqueue(new Uint8Array(buf));
|
|
1232
|
-
} else {
|
|
1233
|
-
return this.pull(controller);
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
1237
|
-
},
|
|
1238
|
-
cancel() {
|
|
1239
|
-
return iterator.return();
|
|
1240
|
-
},
|
|
1241
|
-
type: "bytes"
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
1217
|
function isFormDataLike(object) {
|
|
1245
1218
|
return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
|
|
1246
1219
|
}
|
|
@@ -1689,7 +1662,6 @@ var require_util = __commonJS(function(exports, module) {
|
|
|
1689
1662
|
destroy,
|
|
1690
1663
|
bodyLength,
|
|
1691
1664
|
deepClone,
|
|
1692
|
-
ReadableStreamFrom,
|
|
1693
1665
|
isBuffer,
|
|
1694
1666
|
assertRequestHandler,
|
|
1695
1667
|
getSocketInfo,
|
|
@@ -2177,15 +2149,26 @@ var require_request = __commonJS(function(exports, module) {
|
|
|
2177
2149
|
return false;
|
|
2178
2150
|
}
|
|
2179
2151
|
}
|
|
2180
|
-
onRequestUpgrade(statusCode, headers, socket) {
|
|
2152
|
+
onRequestUpgrade(statusCode, headers, socket, statusText = "") {
|
|
2153
|
+
this.onFinally();
|
|
2181
2154
|
assert(!this.aborted);
|
|
2182
2155
|
assert(!this.completed);
|
|
2156
|
+
if (channels.headers.hasSubscribers) {
|
|
2157
|
+
channels.headers.publish({ request: this, response: { statusCode, headers, statusText } });
|
|
2158
|
+
}
|
|
2183
2159
|
const controller = this[kController];
|
|
2184
2160
|
if (controller) {
|
|
2185
2161
|
controller.rawHeaders = headers;
|
|
2186
2162
|
}
|
|
2187
2163
|
const parsedHeaders = Array.isArray(headers) ? parseHeaders(headers) : headers;
|
|
2188
|
-
|
|
2164
|
+
const result = this[kHandler].onRequestUpgrade?.(controller, statusCode, parsedHeaders, socket);
|
|
2165
|
+
if (!this.aborted) {
|
|
2166
|
+
this.completed = true;
|
|
2167
|
+
if (channels.trailers.hasSubscribers) {
|
|
2168
|
+
channels.trailers.publish({ request: this, trailers: [] });
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
return result;
|
|
2189
2172
|
}
|
|
2190
2173
|
onResponseEnd(trailers) {
|
|
2191
2174
|
this.onFinally();
|
|
@@ -2326,6 +2309,7 @@ var require_request = __commonJS(function(exports, module) {
|
|
|
2326
2309
|
// ../../node_modules/undici/lib/dispatcher/dispatcher.js
|
|
2327
2310
|
var require_dispatcher = __commonJS(function(exports, module) {
|
|
2328
2311
|
var EventEmitter = __require("node:events");
|
|
2312
|
+
var { kOriginless, kUrl } = require_symbols();
|
|
2329
2313
|
|
|
2330
2314
|
class Dispatcher extends EventEmitter {
|
|
2331
2315
|
dispatch() {
|
|
@@ -2339,6 +2323,7 @@ var require_dispatcher = __commonJS(function(exports, module) {
|
|
|
2339
2323
|
}
|
|
2340
2324
|
compose(...args) {
|
|
2341
2325
|
const interceptors = Array.isArray(args[0]) ? args[0] : args;
|
|
2326
|
+
const interceptorOrigin = this[kOriginless] === true ? null : this[kUrl]?.origin;
|
|
2342
2327
|
let dispatch = this.dispatch.bind(this);
|
|
2343
2328
|
for (const interceptor of interceptors) {
|
|
2344
2329
|
if (interceptor == null) {
|
|
@@ -2347,11 +2332,19 @@ var require_dispatcher = __commonJS(function(exports, module) {
|
|
|
2347
2332
|
if (typeof interceptor !== "function") {
|
|
2348
2333
|
throw new TypeError(`invalid interceptor, expected function received ${typeof interceptor}`);
|
|
2349
2334
|
}
|
|
2350
|
-
dispatch = interceptor(dispatch);
|
|
2335
|
+
dispatch = interceptor(dispatch, interceptorOrigin);
|
|
2351
2336
|
if (dispatch == null || typeof dispatch !== "function" || dispatch.length !== 2) {
|
|
2352
2337
|
throw new TypeError("invalid interceptor");
|
|
2353
2338
|
}
|
|
2354
2339
|
}
|
|
2340
|
+
const originalDispatch = dispatch;
|
|
2341
|
+
const self = this;
|
|
2342
|
+
dispatch = function(opts, handler) {
|
|
2343
|
+
if (opts && typeof opts === "object" && !opts.origin && self[kUrl]) {
|
|
2344
|
+
opts = Object.assign({}, opts, { origin: self[kUrl].origin });
|
|
2345
|
+
}
|
|
2346
|
+
return originalDispatch(opts, handler);
|
|
2347
|
+
};
|
|
2355
2348
|
return new Proxy(this, {
|
|
2356
2349
|
get: (target, key) => key === "dispatch" ? dispatch : target[key]
|
|
2357
2350
|
});
|
|
@@ -2362,6 +2355,7 @@ var require_dispatcher = __commonJS(function(exports, module) {
|
|
|
2362
2355
|
|
|
2363
2356
|
// ../../node_modules/undici/lib/dispatcher/dispatcher-base.js
|
|
2364
2357
|
var require_dispatcher_base = __commonJS(function(exports, module) {
|
|
2358
|
+
var buffer = __require("node:buffer");
|
|
2365
2359
|
var Dispatcher = require_dispatcher();
|
|
2366
2360
|
var {
|
|
2367
2361
|
ClientDestroyedError,
|
|
@@ -2372,6 +2366,7 @@ var require_dispatcher_base = __commonJS(function(exports, module) {
|
|
|
2372
2366
|
var kOnDestroyed = Symbol("onDestroyed");
|
|
2373
2367
|
var kOnClosed = Symbol("onClosed");
|
|
2374
2368
|
var kWebSocketOptions = Symbol("webSocketOptions");
|
|
2369
|
+
var kEventSourceOptions = Symbol("eventSourceOptions");
|
|
2375
2370
|
|
|
2376
2371
|
class DispatcherBase extends Dispatcher {
|
|
2377
2372
|
[kDestroyed] = false;
|
|
@@ -2381,6 +2376,7 @@ var require_dispatcher_base = __commonJS(function(exports, module) {
|
|
|
2381
2376
|
constructor(opts) {
|
|
2382
2377
|
super();
|
|
2383
2378
|
this[kWebSocketOptions] = opts?.webSocket ?? {};
|
|
2379
|
+
this[kEventSourceOptions] = opts?.eventSource ?? {};
|
|
2384
2380
|
}
|
|
2385
2381
|
get webSocketOptions() {
|
|
2386
2382
|
return {
|
|
@@ -2388,6 +2384,11 @@ var require_dispatcher_base = __commonJS(function(exports, module) {
|
|
|
2388
2384
|
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
|
2389
2385
|
};
|
|
2390
2386
|
}
|
|
2387
|
+
get eventSourceOptions() {
|
|
2388
|
+
return {
|
|
2389
|
+
maxEventSize: this[kEventSourceOptions].maxEventSize ?? buffer.kStringMaxLength
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2391
2392
|
get destroyed() {
|
|
2392
2393
|
return this[kDestroyed];
|
|
2393
2394
|
}
|
|
@@ -3540,6 +3541,10 @@ var require_infra = __commonJS(function(exports, module) {
|
|
|
3540
3541
|
assert(!invalidIsomorphicEncodeValueRegex.test(input));
|
|
3541
3542
|
return input;
|
|
3542
3543
|
}
|
|
3544
|
+
var nonASCIIRegex = /[^\x00-\x7F]/;
|
|
3545
|
+
function asciiLowercase(str) {
|
|
3546
|
+
return nonASCIIRegex.test(str) ? str.replace(/[A-Z]+/g, (upper) => upper.toLowerCase()) : str.toLowerCase();
|
|
3547
|
+
}
|
|
3543
3548
|
function parseJSONFromBytes(bytes) {
|
|
3544
3549
|
return JSON.parse(utf8DecodeBytes(bytes));
|
|
3545
3550
|
}
|
|
@@ -3554,7 +3559,7 @@ var require_infra = __commonJS(function(exports, module) {
|
|
|
3554
3559
|
lead++;
|
|
3555
3560
|
}
|
|
3556
3561
|
if (trailing) {
|
|
3557
|
-
while (trail
|
|
3562
|
+
while (trail >= lead && predicate(str.charCodeAt(trail)))
|
|
3558
3563
|
trail--;
|
|
3559
3564
|
}
|
|
3560
3565
|
return lead === 0 && trail === str.length - 1 ? str : str.slice(lead, trail + 1);
|
|
@@ -3568,6 +3573,7 @@ var require_infra = __commonJS(function(exports, module) {
|
|
|
3568
3573
|
return result;
|
|
3569
3574
|
}
|
|
3570
3575
|
module.exports = {
|
|
3576
|
+
asciiLowercase,
|
|
3571
3577
|
collectASequenceOfCodePoints,
|
|
3572
3578
|
collectASequenceOfCodePointsFast,
|
|
3573
3579
|
forgivingBase64,
|
|
@@ -3584,9 +3590,9 @@ var require_infra = __commonJS(function(exports, module) {
|
|
|
3584
3590
|
// ../../node_modules/undici/lib/web/fetch/data-url.js
|
|
3585
3591
|
var require_data_url = __commonJS(function(exports, module) {
|
|
3586
3592
|
var assert = __require("node:assert");
|
|
3587
|
-
var { forgivingBase64, collectASequenceOfCodePoints, collectASequenceOfCodePointsFast, isomorphicDecode, removeASCIIWhitespace, removeChars } = require_infra();
|
|
3593
|
+
var { asciiLowercase, forgivingBase64, collectASequenceOfCodePoints, collectASequenceOfCodePointsFast, isomorphicDecode, removeASCIIWhitespace, removeChars } = require_infra();
|
|
3588
3594
|
var encoder = new TextEncoder;
|
|
3589
|
-
var HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_
|
|
3595
|
+
var HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_`|~A-Za-z0-9]+$/u;
|
|
3590
3596
|
var HTTP_WHITESPACE_REGEX = /[\u000A\u000D\u0009\u0020]/u;
|
|
3591
3597
|
var HTTP_QUOTED_STRING_TOKENS = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/u;
|
|
3592
3598
|
function dataURLProcessor(dataURL) {
|
|
@@ -3603,7 +3609,7 @@ var require_data_url = __commonJS(function(exports, module) {
|
|
|
3603
3609
|
position.position++;
|
|
3604
3610
|
const encodedBody = input.slice(mimeTypeLength + 1);
|
|
3605
3611
|
let body = stringPercentDecode(encodedBody);
|
|
3606
|
-
if (
|
|
3612
|
+
if (/;\u0020*[Bb][Aa][Ss][Ee]64$/u.test(mimeType)) {
|
|
3607
3613
|
const stringBody = isomorphicDecode(body);
|
|
3608
3614
|
body = forgivingBase64(stringBody);
|
|
3609
3615
|
if (body === "failure") {
|
|
@@ -3679,8 +3685,8 @@ var require_data_url = __commonJS(function(exports, module) {
|
|
|
3679
3685
|
if (subtype.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(subtype)) {
|
|
3680
3686
|
return "failure";
|
|
3681
3687
|
}
|
|
3682
|
-
const typeLowercase = type
|
|
3683
|
-
const subtypeLowercase = subtype
|
|
3688
|
+
const typeLowercase = asciiLowercase(type);
|
|
3689
|
+
const subtypeLowercase = asciiLowercase(subtype);
|
|
3684
3690
|
const mimeType = {
|
|
3685
3691
|
type: typeLowercase,
|
|
3686
3692
|
subtype: subtypeLowercase,
|
|
@@ -3691,7 +3697,7 @@ var require_data_url = __commonJS(function(exports, module) {
|
|
|
3691
3697
|
position.position++;
|
|
3692
3698
|
collectASequenceOfCodePoints((char) => HTTP_WHITESPACE_REGEX.test(char), input, position);
|
|
3693
3699
|
let parameterName = collectASequenceOfCodePoints((char) => char !== ";" && char !== "=", input, position);
|
|
3694
|
-
parameterName = parameterName
|
|
3700
|
+
parameterName = asciiLowercase(parameterName);
|
|
3695
3701
|
if (position.position < input.length) {
|
|
3696
3702
|
if (input[position.position] === ";") {
|
|
3697
3703
|
continue;
|
|
@@ -3856,23 +3862,13 @@ var require_webidl = __commonJS(function(exports, module) {
|
|
|
3856
3862
|
message: `"${context.value}" is an invalid ${context.type}.`
|
|
3857
3863
|
});
|
|
3858
3864
|
};
|
|
3859
|
-
webidl.brandCheck = function(V,
|
|
3860
|
-
if (!
|
|
3865
|
+
webidl.brandCheck = function(V, is) {
|
|
3866
|
+
if (!is(V)) {
|
|
3861
3867
|
const err = new TypeError("Illegal invocation");
|
|
3862
3868
|
err.code = "ERR_INVALID_THIS";
|
|
3863
3869
|
throw err;
|
|
3864
3870
|
}
|
|
3865
3871
|
};
|
|
3866
|
-
webidl.brandCheckMultiple = function(List) {
|
|
3867
|
-
const prototypes = List.map((c) => webidl.util.MakeTypeAssertion(c));
|
|
3868
|
-
return (V) => {
|
|
3869
|
-
if (prototypes.every((typeCheck) => !typeCheck(V))) {
|
|
3870
|
-
const err = new TypeError("Illegal invocation");
|
|
3871
|
-
err.code = "ERR_INVALID_THIS";
|
|
3872
|
-
throw err;
|
|
3873
|
-
}
|
|
3874
|
-
};
|
|
3875
|
-
};
|
|
3876
3872
|
webidl.argumentLengthCheck = function({ length }, min, ctx) {
|
|
3877
3873
|
if (length < min) {
|
|
3878
3874
|
throw webidl.errors.exception({
|
|
@@ -4412,7 +4408,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4412
4408
|
var { getGlobalOrigin } = require_global();
|
|
4413
4409
|
var { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
|
|
4414
4410
|
var { performance: performance2 } = __require("node:perf_hooks");
|
|
4415
|
-
var {
|
|
4411
|
+
var { isValidHTTPToken, normalizedMethodRecordsBase } = require_util();
|
|
4416
4412
|
var assert = __require("node:assert");
|
|
4417
4413
|
var { isUint8Array } = __require("node:util/types");
|
|
4418
4414
|
var { webidl } = require_webidl();
|
|
@@ -4507,6 +4503,9 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4507
4503
|
return "success";
|
|
4508
4504
|
}
|
|
4509
4505
|
function appendFetchMetadata(httpRequest) {
|
|
4506
|
+
if (!isURLPotentiallyTrustworthy(requestCurrentURL(httpRequest))) {
|
|
4507
|
+
return;
|
|
4508
|
+
}
|
|
4510
4509
|
let header = null;
|
|
4511
4510
|
header = httpRequest.mode;
|
|
4512
4511
|
httpRequest.headersList.set("sec-fetch-mode", header, true);
|
|
@@ -4795,7 +4794,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4795
4794
|
return new FastIterableIterator(target, kind);
|
|
4796
4795
|
};
|
|
4797
4796
|
}
|
|
4798
|
-
function iteratorMixin(name, object, kInternalIterator, keyIndex = 0, valueIndex = 1) {
|
|
4797
|
+
function iteratorMixin(name, object, kInternalIterator, keyIndex = 0, valueIndex = 1, brandCheck) {
|
|
4799
4798
|
const makeIterator = createIterator(name, kInternalIterator, keyIndex, valueIndex);
|
|
4800
4799
|
const properties = {
|
|
4801
4800
|
keys: {
|
|
@@ -4803,7 +4802,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4803
4802
|
enumerable: true,
|
|
4804
4803
|
configurable: true,
|
|
4805
4804
|
value: function keys() {
|
|
4806
|
-
webidl.brandCheck(this,
|
|
4805
|
+
webidl.brandCheck(this, brandCheck);
|
|
4807
4806
|
return makeIterator(this, "key");
|
|
4808
4807
|
}
|
|
4809
4808
|
},
|
|
@@ -4812,7 +4811,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4812
4811
|
enumerable: true,
|
|
4813
4812
|
configurable: true,
|
|
4814
4813
|
value: function values() {
|
|
4815
|
-
webidl.brandCheck(this,
|
|
4814
|
+
webidl.brandCheck(this, brandCheck);
|
|
4816
4815
|
return makeIterator(this, "value");
|
|
4817
4816
|
}
|
|
4818
4817
|
},
|
|
@@ -4821,7 +4820,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4821
4820
|
enumerable: true,
|
|
4822
4821
|
configurable: true,
|
|
4823
4822
|
value: function entries() {
|
|
4824
|
-
webidl.brandCheck(this,
|
|
4823
|
+
webidl.brandCheck(this, brandCheck);
|
|
4825
4824
|
return makeIterator(this, "key+value");
|
|
4826
4825
|
}
|
|
4827
4826
|
},
|
|
@@ -4830,7 +4829,7 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
4830
4829
|
enumerable: true,
|
|
4831
4830
|
configurable: true,
|
|
4832
4831
|
value: function forEach(callbackfn, thisArg = globalThis) {
|
|
4833
|
-
webidl.brandCheck(this,
|
|
4832
|
+
webidl.brandCheck(this, brandCheck);
|
|
4834
4833
|
webidl.argumentLengthCheck(arguments, 1, `${name}.forEach`);
|
|
4835
4834
|
if (typeof callbackfn !== "function") {
|
|
4836
4835
|
throw new TypeError(`Failed to execute 'forEach' on '${name}': parameter 1 is not of type 'Function'.`);
|
|
@@ -5080,7 +5079,6 @@ var require_util2 = __commonJS(function(exports, module) {
|
|
|
5080
5079
|
isAborted,
|
|
5081
5080
|
isCancelled,
|
|
5082
5081
|
isValidEncodedURL,
|
|
5083
|
-
ReadableStreamFrom,
|
|
5084
5082
|
tryUpgradeRequestToAPotentiallyTrustworthyURL,
|
|
5085
5083
|
clampAndCoarsenConnectionTimingInfo,
|
|
5086
5084
|
coarsenedSharedCurrentTime,
|
|
@@ -5186,6 +5184,9 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5186
5184
|
var nodeUtil = __require("node:util");
|
|
5187
5185
|
var { runtimeFeatures } = require_runtime_features();
|
|
5188
5186
|
var random = runtimeFeatures.has("crypto") ? __require("node:crypto").randomInt : (max) => Math.floor(Math.random() * max);
|
|
5187
|
+
var getFormDataState;
|
|
5188
|
+
var setFormDataState;
|
|
5189
|
+
var getFormDataBoundary;
|
|
5189
5190
|
|
|
5190
5191
|
class FormData {
|
|
5191
5192
|
#state = [];
|
|
@@ -5201,7 +5202,7 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5201
5202
|
}
|
|
5202
5203
|
}
|
|
5203
5204
|
append(name, value, filename = undefined) {
|
|
5204
|
-
webidl.brandCheck(this, FormData);
|
|
5205
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5205
5206
|
const prefix = "FormData.append";
|
|
5206
5207
|
webidl.argumentLengthCheck(arguments, 2, prefix);
|
|
5207
5208
|
name = webidl.converters.USVString(name);
|
|
@@ -5217,14 +5218,14 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5217
5218
|
this.#state.push(entry);
|
|
5218
5219
|
}
|
|
5219
5220
|
delete(name) {
|
|
5220
|
-
webidl.brandCheck(this, FormData);
|
|
5221
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5221
5222
|
const prefix = "FormData.delete";
|
|
5222
5223
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
5223
5224
|
name = webidl.converters.USVString(name);
|
|
5224
5225
|
this.#state = this.#state.filter((entry) => entry.name !== name);
|
|
5225
5226
|
}
|
|
5226
5227
|
get(name) {
|
|
5227
|
-
webidl.brandCheck(this, FormData);
|
|
5228
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5228
5229
|
const prefix = "FormData.get";
|
|
5229
5230
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
5230
5231
|
name = webidl.converters.USVString(name);
|
|
@@ -5235,21 +5236,21 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5235
5236
|
return this.#state[idx].value;
|
|
5236
5237
|
}
|
|
5237
5238
|
getAll(name) {
|
|
5238
|
-
webidl.brandCheck(this, FormData);
|
|
5239
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5239
5240
|
const prefix = "FormData.getAll";
|
|
5240
5241
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
5241
5242
|
name = webidl.converters.USVString(name);
|
|
5242
5243
|
return this.#state.filter((entry) => entry.name === name).map((entry) => entry.value);
|
|
5243
5244
|
}
|
|
5244
5245
|
has(name) {
|
|
5245
|
-
webidl.brandCheck(this, FormData);
|
|
5246
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5246
5247
|
const prefix = "FormData.has";
|
|
5247
5248
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
5248
5249
|
name = webidl.converters.USVString(name);
|
|
5249
5250
|
return this.#state.findIndex((entry) => entry.name === name) !== -1;
|
|
5250
5251
|
}
|
|
5251
5252
|
set(name, value, filename = undefined) {
|
|
5252
|
-
webidl.brandCheck(this, FormData);
|
|
5253
|
+
webidl.brandCheck(this, webidl.is.FormData);
|
|
5253
5254
|
const prefix = "FormData.set";
|
|
5254
5255
|
webidl.argumentLengthCheck(arguments, 2, prefix);
|
|
5255
5256
|
name = webidl.converters.USVString(name);
|
|
@@ -5291,24 +5292,20 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5291
5292
|
const output = nodeUtil.formatWithOptions(options, state);
|
|
5292
5293
|
return `FormData ${output.slice(output.indexOf("]") + 2)}`;
|
|
5293
5294
|
}
|
|
5294
|
-
static
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
return
|
|
5304
|
-
|
|
5295
|
+
static {
|
|
5296
|
+
getFormDataState = (formData) => formData.#state;
|
|
5297
|
+
setFormDataState = (formData, newState) => {
|
|
5298
|
+
formData.#state = newState;
|
|
5299
|
+
};
|
|
5300
|
+
getFormDataBoundary = (formData) => {
|
|
5301
|
+
return formData.#boundary ??= `----formdata-undici-0${`${random(100000000000)}`.padStart(11, "0")}`;
|
|
5302
|
+
};
|
|
5303
|
+
webidl.is.FormData = (arg) => {
|
|
5304
|
+
return arg != null && typeof arg === "object" && #state in arg;
|
|
5305
|
+
};
|
|
5305
5306
|
}
|
|
5306
5307
|
}
|
|
5307
|
-
|
|
5308
|
-
Reflect.deleteProperty(FormData, "getFormDataState");
|
|
5309
|
-
Reflect.deleteProperty(FormData, "setFormDataState");
|
|
5310
|
-
Reflect.deleteProperty(FormData, "getFormDataBoundary");
|
|
5311
|
-
iteratorMixin("FormData", FormData, getFormDataState, "name", "value");
|
|
5308
|
+
iteratorMixin("FormData", FormData, getFormDataState, "name", "value", webidl.is.FormData);
|
|
5312
5309
|
Object.defineProperties(FormData.prototype, {
|
|
5313
5310
|
append: kEnumerableProperty,
|
|
5314
5311
|
delete: kEnumerableProperty,
|
|
@@ -5336,7 +5333,6 @@ var require_formdata = __commonJS(function(exports, module) {
|
|
|
5336
5333
|
}
|
|
5337
5334
|
return { name, value };
|
|
5338
5335
|
}
|
|
5339
|
-
webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData);
|
|
5340
5336
|
module.exports = { FormData, makeEntry, setFormDataState, getFormDataBoundary };
|
|
5341
5337
|
});
|
|
5342
5338
|
|
|
@@ -5602,7 +5598,6 @@ var require_formdata_parser = __commonJS(function(exports, module) {
|
|
|
5602
5598
|
var require_body = __commonJS(function(exports, module) {
|
|
5603
5599
|
var util = require_util();
|
|
5604
5600
|
var {
|
|
5605
|
-
ReadableStreamFrom,
|
|
5606
5601
|
readableStreamClose,
|
|
5607
5602
|
fullyReadBody,
|
|
5608
5603
|
extractMimeType
|
|
@@ -5719,7 +5714,14 @@ ${normalizeLinefeeds(value)}\r
|
|
|
5719
5714
|
if (util.isDisturbed(object) || object.locked) {
|
|
5720
5715
|
throw new TypeError("Response body object should not be disturbed or locked");
|
|
5721
5716
|
}
|
|
5722
|
-
stream = webidl.is.ReadableStream(object) ? object :
|
|
5717
|
+
stream = webidl.is.ReadableStream(object) ? object : ReadableStream.from(object).pipeThrough(new TransformStream({
|
|
5718
|
+
transform(chunk, controller2) {
|
|
5719
|
+
const bytes = isUint8Array(chunk) ? chunk : Buffer.from(chunk);
|
|
5720
|
+
if (bytes.byteLength) {
|
|
5721
|
+
controller2.enqueue(bytes);
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5724
|
+
}));
|
|
5723
5725
|
}
|
|
5724
5726
|
if (typeof source === "string" || isUint8Array(source)) {
|
|
5725
5727
|
action = () => {
|
|
@@ -5764,7 +5766,7 @@ ${normalizeLinefeeds(value)}\r
|
|
|
5764
5766
|
source: body.source
|
|
5765
5767
|
};
|
|
5766
5768
|
}
|
|
5767
|
-
function bodyMixinMethods(
|
|
5769
|
+
function bodyMixinMethods(brandCheck, getInternalState) {
|
|
5768
5770
|
const methods = {
|
|
5769
5771
|
blob() {
|
|
5770
5772
|
return consumeBody(this, (bytes) => {
|
|
@@ -5775,18 +5777,18 @@ ${normalizeLinefeeds(value)}\r
|
|
|
5775
5777
|
mimeType = serializeAMimeType(mimeType);
|
|
5776
5778
|
}
|
|
5777
5779
|
return new Blob([bytes], { type: mimeType });
|
|
5778
|
-
},
|
|
5780
|
+
}, brandCheck, getInternalState);
|
|
5779
5781
|
},
|
|
5780
5782
|
arrayBuffer() {
|
|
5781
5783
|
return consumeBody(this, (bytes) => {
|
|
5782
5784
|
return new Uint8Array(bytes).buffer;
|
|
5783
|
-
},
|
|
5785
|
+
}, brandCheck, getInternalState);
|
|
5784
5786
|
},
|
|
5785
5787
|
text() {
|
|
5786
|
-
return consumeBody(this, utf8DecodeBytes,
|
|
5788
|
+
return consumeBody(this, utf8DecodeBytes, brandCheck, getInternalState);
|
|
5787
5789
|
},
|
|
5788
5790
|
json() {
|
|
5789
|
-
return consumeBody(this, parseJSONFromBytes,
|
|
5791
|
+
return consumeBody(this, parseJSONFromBytes, brandCheck, getInternalState);
|
|
5790
5792
|
},
|
|
5791
5793
|
formData() {
|
|
5792
5794
|
return consumeBody(this, (value) => {
|
|
@@ -5810,12 +5812,12 @@ ${normalizeLinefeeds(value)}\r
|
|
|
5810
5812
|
}
|
|
5811
5813
|
}
|
|
5812
5814
|
throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".');
|
|
5813
|
-
},
|
|
5815
|
+
}, brandCheck, getInternalState);
|
|
5814
5816
|
},
|
|
5815
5817
|
bytes() {
|
|
5816
5818
|
return consumeBody(this, (bytes) => {
|
|
5817
5819
|
return new Uint8Array(bytes);
|
|
5818
|
-
},
|
|
5820
|
+
}, brandCheck, getInternalState);
|
|
5819
5821
|
},
|
|
5820
5822
|
textStream() {
|
|
5821
5823
|
const this_ = getInternalState(this);
|
|
@@ -5843,12 +5845,12 @@ ${normalizeLinefeeds(value)}\r
|
|
|
5843
5845
|
};
|
|
5844
5846
|
return methods;
|
|
5845
5847
|
}
|
|
5846
|
-
function mixinBody(prototype, getInternalState) {
|
|
5847
|
-
Object.assign(prototype.prototype, bodyMixinMethods(
|
|
5848
|
+
function mixinBody(prototype, getInternalState, brandCheck) {
|
|
5849
|
+
Object.assign(prototype.prototype, bodyMixinMethods(brandCheck, getInternalState));
|
|
5848
5850
|
}
|
|
5849
|
-
function consumeBody(object, convertBytesToJSValue,
|
|
5851
|
+
function consumeBody(object, convertBytesToJSValue, brandCheck, getInternalState) {
|
|
5850
5852
|
try {
|
|
5851
|
-
webidl.brandCheck(object,
|
|
5853
|
+
webidl.brandCheck(object, brandCheck);
|
|
5852
5854
|
} catch (e) {
|
|
5853
5855
|
return Promise.reject(e);
|
|
5854
5856
|
}
|
|
@@ -5959,7 +5961,13 @@ var require_client_h1 = __commonJS(function(exports, module) {
|
|
|
5959
5961
|
function lazyllhttp() {
|
|
5960
5962
|
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : undefined;
|
|
5961
5963
|
let mod;
|
|
5962
|
-
let useWasmSIMD =
|
|
5964
|
+
let useWasmSIMD = true;
|
|
5965
|
+
if (process.arch === "ppc64") {
|
|
5966
|
+
const [major, minor] = process.versions.node.split(".").map((n) => parseInt(n, 10));
|
|
5967
|
+
if (major < 24 || major === 24 && minor < 12) {
|
|
5968
|
+
useWasmSIMD = false;
|
|
5969
|
+
}
|
|
5970
|
+
}
|
|
5963
5971
|
if (process.env.UNDICI_NO_WASM_SIMD === "1") {
|
|
5964
5972
|
useWasmSIMD = false;
|
|
5965
5973
|
} else if (process.env.UNDICI_NO_WASM_SIMD === "0") {
|
|
@@ -6260,7 +6268,7 @@ var require_client_h1 = __commonJS(function(exports, module) {
|
|
|
6260
6268
|
}
|
|
6261
6269
|
}
|
|
6262
6270
|
onUpgrade(head) {
|
|
6263
|
-
const { upgrade, client, socket, headers, statusCode } = this;
|
|
6271
|
+
const { upgrade, client, socket, headers, statusCode, statusText } = this;
|
|
6264
6272
|
assert(upgrade);
|
|
6265
6273
|
assert(client[kSocket] === socket);
|
|
6266
6274
|
assert(!socket.destroyed);
|
|
@@ -6285,8 +6293,9 @@ var require_client_h1 = __commonJS(function(exports, module) {
|
|
|
6285
6293
|
client[kQueue][client[kRunningIdx]++] = null;
|
|
6286
6294
|
client.emit("disconnect", client[kUrl], [client], new InformationalError("upgrade"));
|
|
6287
6295
|
try {
|
|
6288
|
-
request.onRequestUpgrade(statusCode, headers, socket);
|
|
6296
|
+
request.onRequestUpgrade(statusCode, headers, socket, statusText);
|
|
6289
6297
|
} catch (err) {
|
|
6298
|
+
util.errorRequest(client, request, err);
|
|
6290
6299
|
util.destroy(socket, err);
|
|
6291
6300
|
}
|
|
6292
6301
|
client[kResume]();
|
|
@@ -6589,21 +6598,20 @@ var require_client_h1 = __commonJS(function(exports, module) {
|
|
|
6589
6598
|
}
|
|
6590
6599
|
function clearIdleSocketValidation(socket) {
|
|
6591
6600
|
if (socket[kIdleSocketValidationTimeout]) {
|
|
6592
|
-
|
|
6601
|
+
clearImmediate(socket[kIdleSocketValidationTimeout]);
|
|
6593
6602
|
socket[kIdleSocketValidationTimeout] = null;
|
|
6594
6603
|
}
|
|
6595
6604
|
socket[kIdleSocketValidation] = 0;
|
|
6596
6605
|
}
|
|
6597
6606
|
function scheduleIdleSocketValidation(client, socket) {
|
|
6598
6607
|
socket[kIdleSocketValidation] = 1;
|
|
6599
|
-
socket[kIdleSocketValidationTimeout] =
|
|
6608
|
+
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
|
|
6600
6609
|
socket[kIdleSocketValidationTimeout] = null;
|
|
6601
6610
|
socket[kIdleSocketValidation] = 2;
|
|
6602
6611
|
if (client[kSocket] === socket && !socket.destroyed) {
|
|
6603
6612
|
client[kResume]();
|
|
6604
6613
|
}
|
|
6605
|
-
}
|
|
6606
|
-
socket[kIdleSocketValidationTimeout].unref?.();
|
|
6614
|
+
});
|
|
6607
6615
|
}
|
|
6608
6616
|
function resumeH1(client) {
|
|
6609
6617
|
const socket = client[kSocket];
|
|
@@ -7085,12 +7093,14 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7085
7093
|
var util = require_util();
|
|
7086
7094
|
var {
|
|
7087
7095
|
RequestContentLengthMismatchError,
|
|
7096
|
+
ResponseContentLengthMismatchError,
|
|
7088
7097
|
RequestAbortedError,
|
|
7089
7098
|
SocketError,
|
|
7090
7099
|
InformationalError,
|
|
7091
7100
|
InvalidArgumentError,
|
|
7092
7101
|
HeadersTimeoutError,
|
|
7093
|
-
BodyTimeoutError
|
|
7102
|
+
BodyTimeoutError,
|
|
7103
|
+
ResponseExceededMaxSizeError
|
|
7094
7104
|
} = require_errors();
|
|
7095
7105
|
var {
|
|
7096
7106
|
kUrl,
|
|
@@ -7119,7 +7129,8 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7119
7129
|
kRemoteSettings,
|
|
7120
7130
|
kHTTP2Stream,
|
|
7121
7131
|
kHTTP2SessionState,
|
|
7122
|
-
kHTTP2Options
|
|
7132
|
+
kHTTP2Options,
|
|
7133
|
+
kMaxResponseSize
|
|
7123
7134
|
} = require_symbols();
|
|
7124
7135
|
var { channels } = require_diagnostics();
|
|
7125
7136
|
var kOpenStreams = Symbol("open streams");
|
|
@@ -7231,6 +7242,10 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7231
7242
|
const { body } = request;
|
|
7232
7243
|
return body == null || util.isBuffer(body) || util.isBlobLike(body);
|
|
7233
7244
|
}
|
|
7245
|
+
function hasResponseStarted(request) {
|
|
7246
|
+
const state = request[kRequestStream]?.[kRequestStreamState];
|
|
7247
|
+
return state?.responseReceived === true;
|
|
7248
|
+
}
|
|
7234
7249
|
function registerGoAwayRefusal(request) {
|
|
7235
7250
|
const attempts = (request[kGoAwayReplayAttempts] ?? 0) + 1;
|
|
7236
7251
|
request[kGoAwayReplayAttempts] = attempts;
|
|
@@ -7362,7 +7377,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7362
7377
|
const socket = client[kSocket];
|
|
7363
7378
|
const session = client[kHTTP2Session];
|
|
7364
7379
|
if (socket?.destroyed === false) {
|
|
7365
|
-
if (
|
|
7380
|
+
if (session[kOpenStreams] === 0 && client[kSize] === 0) {
|
|
7366
7381
|
unrefH2Session(session);
|
|
7367
7382
|
} else {
|
|
7368
7383
|
refH2Session(session);
|
|
@@ -7516,8 +7531,9 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7516
7531
|
for (let i = pendingIdx;i < previousPendingIdx; i++) {
|
|
7517
7532
|
const request = client[kQueue][i];
|
|
7518
7533
|
if (request != null) {
|
|
7534
|
+
const responseStarted = hasResponseStarted(request);
|
|
7519
7535
|
streamsToClose.push(detachRequestStreamForClose(request));
|
|
7520
|
-
if (canReplayRequest(request) && registerGoAwayRefusal(request)) {
|
|
7536
|
+
if (!responseStarted && canReplayRequest(request) && registerGoAwayRefusal(request)) {
|
|
7521
7537
|
retriableRequests.push(request);
|
|
7522
7538
|
} else {
|
|
7523
7539
|
util.errorRequest(client, request, err);
|
|
@@ -7608,9 +7624,10 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7608
7624
|
function noop() {}
|
|
7609
7625
|
function closeStreamSession(stream) {
|
|
7610
7626
|
const session = stream[kHTTP2Session];
|
|
7627
|
+
const client = session[kClient];
|
|
7611
7628
|
stream[kHTTP2Session] = null;
|
|
7612
7629
|
session[kOpenStreams] -= 1;
|
|
7613
|
-
if (session[kOpenStreams] === 0) {
|
|
7630
|
+
if (session[kOpenStreams] === 0 && (client[kSize] === 0 || session[kReceivedGoAway])) {
|
|
7614
7631
|
unrefH2Session(session);
|
|
7615
7632
|
setHttp2IdleTimeout(session);
|
|
7616
7633
|
}
|
|
@@ -7721,8 +7738,13 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7721
7738
|
state.responseReceived = true;
|
|
7722
7739
|
const statusCode = headers[HTTP2_HEADER_STATUS];
|
|
7723
7740
|
delete headers[HTTP2_HEADER_STATUS];
|
|
7724
|
-
|
|
7725
|
-
|
|
7741
|
+
try {
|
|
7742
|
+
request.onRequestUpgrade(statusCode, headers, stream);
|
|
7743
|
+
} catch (err) {
|
|
7744
|
+
state.abort(err);
|
|
7745
|
+
return;
|
|
7746
|
+
}
|
|
7747
|
+
if (request.aborted) {
|
|
7726
7748
|
return;
|
|
7727
7749
|
}
|
|
7728
7750
|
removeUpgradeStreamListeners(stream);
|
|
@@ -7789,13 +7811,16 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7789
7811
|
const state = {
|
|
7790
7812
|
abort: null,
|
|
7791
7813
|
body: request.body,
|
|
7814
|
+
bytesRead: 0,
|
|
7792
7815
|
client,
|
|
7793
7816
|
contentLength: null,
|
|
7794
7817
|
expectsPayload: false,
|
|
7818
|
+
maxResponseSize: client[kMaxResponseSize],
|
|
7795
7819
|
request,
|
|
7796
7820
|
headersTimeout,
|
|
7797
7821
|
bodyTimeout,
|
|
7798
7822
|
requestFinalized: false,
|
|
7823
|
+
responseContentLength: null,
|
|
7799
7824
|
responseReceived: false,
|
|
7800
7825
|
bodySent: false,
|
|
7801
7826
|
pendingEnd: false,
|
|
@@ -7930,6 +7955,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7930
7955
|
stream.once("continue", writeBodyH2);
|
|
7931
7956
|
}
|
|
7932
7957
|
stream.on("response", onResponse);
|
|
7958
|
+
stream.on("headers", onInterimResponse);
|
|
7933
7959
|
stream.on("end", onEnd);
|
|
7934
7960
|
stream.on("error", onError);
|
|
7935
7961
|
stream.on("frameError", onFrameError);
|
|
@@ -7947,6 +7973,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7947
7973
|
stream.off("error", noop);
|
|
7948
7974
|
stream.off("continue", writeBodyH2);
|
|
7949
7975
|
stream.off("response", onResponse);
|
|
7976
|
+
stream.off("headers", onInterimResponse);
|
|
7950
7977
|
stream.off("end", onEnd);
|
|
7951
7978
|
stream.off("error", onError);
|
|
7952
7979
|
stream.off("frameError", onFrameError);
|
|
@@ -7978,14 +8005,37 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7978
8005
|
if (state == null) {
|
|
7979
8006
|
return;
|
|
7980
8007
|
}
|
|
7981
|
-
const { request } = state;
|
|
8008
|
+
const { request, maxResponseSize, responseContentLength } = state;
|
|
7982
8009
|
if (request.aborted || request.completed) {
|
|
7983
8010
|
return;
|
|
7984
8011
|
}
|
|
8012
|
+
if (responseContentLength != null && state.bytesRead + chunk.length > responseContentLength) {
|
|
8013
|
+
state.abort(new ResponseContentLengthMismatchError);
|
|
8014
|
+
return;
|
|
8015
|
+
}
|
|
8016
|
+
if (maxResponseSize > -1 && state.bytesRead + chunk.length > maxResponseSize) {
|
|
8017
|
+
state.abort(new ResponseExceededMaxSizeError);
|
|
8018
|
+
return;
|
|
8019
|
+
}
|
|
8020
|
+
state.bytesRead += chunk.length;
|
|
7985
8021
|
if (request.onResponseData(chunk) === false) {
|
|
7986
8022
|
stream.pause();
|
|
7987
8023
|
}
|
|
7988
8024
|
}
|
|
8025
|
+
function onInterimResponse(headers) {
|
|
8026
|
+
const stream = this;
|
|
8027
|
+
const state = stream[kRequestStreamState];
|
|
8028
|
+
if (state == null) {
|
|
8029
|
+
return;
|
|
8030
|
+
}
|
|
8031
|
+
const { request } = state;
|
|
8032
|
+
if (request.aborted || request.completed) {
|
|
8033
|
+
return;
|
|
8034
|
+
}
|
|
8035
|
+
const statusCode = headers[HTTP2_HEADER_STATUS];
|
|
8036
|
+
delete headers[HTTP2_HEADER_STATUS];
|
|
8037
|
+
request.onResponseStart(Number(statusCode), headers, noop, "");
|
|
8038
|
+
}
|
|
7989
8039
|
function onResponse(headers) {
|
|
7990
8040
|
const stream = this;
|
|
7991
8041
|
const state = stream[kRequestStreamState];
|
|
@@ -7998,10 +8048,14 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
7998
8048
|
stream.removeListener("continue", writeBodyH2);
|
|
7999
8049
|
stream.end();
|
|
8000
8050
|
}
|
|
8001
|
-
const statusCode = headers[HTTP2_HEADER_STATUS];
|
|
8051
|
+
const statusCode = Number(headers[HTTP2_HEADER_STATUS]);
|
|
8002
8052
|
delete headers[HTTP2_HEADER_STATUS];
|
|
8003
8053
|
request.onResponseStarted();
|
|
8004
8054
|
state.responseReceived = true;
|
|
8055
|
+
if (request.method !== "HEAD" && statusCode !== 304) {
|
|
8056
|
+
const contentLength = headers[HTTP2_HEADER_CONTENT_LENGTH];
|
|
8057
|
+
state.responseContentLength = contentLength == null ? null : Number(contentLength);
|
|
8058
|
+
}
|
|
8005
8059
|
if (state.headersTimeout || state.bodyTimeout) {
|
|
8006
8060
|
stream.setTimeout(state.bodyTimeout);
|
|
8007
8061
|
}
|
|
@@ -8009,7 +8063,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
8009
8063
|
releaseRequestStream(stream);
|
|
8010
8064
|
return;
|
|
8011
8065
|
}
|
|
8012
|
-
if (request.onResponseStart(
|
|
8066
|
+
if (request.onResponseStart(statusCode, headers, stream.resume.bind(stream), "") === false) {
|
|
8013
8067
|
stream.pause();
|
|
8014
8068
|
}
|
|
8015
8069
|
stream.on("data", onData);
|
|
@@ -8024,6 +8078,10 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
8024
8078
|
stream.off("end", onEnd);
|
|
8025
8079
|
if (state.responseReceived) {
|
|
8026
8080
|
if (!request.aborted && !request.completed) {
|
|
8081
|
+
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
8082
|
+
state.abort(new ResponseContentLengthMismatchError);
|
|
8083
|
+
return;
|
|
8084
|
+
}
|
|
8027
8085
|
state.pendingEnd = true;
|
|
8028
8086
|
completeRequestStream.call(stream);
|
|
8029
8087
|
}
|
|
@@ -8052,6 +8110,9 @@ var require_client_h2 = __commonJS(function(exports, module) {
|
|
|
8052
8110
|
return;
|
|
8053
8111
|
}
|
|
8054
8112
|
stream.off("error", onError);
|
|
8113
|
+
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
8114
|
+
err = new ResponseContentLengthMismatchError;
|
|
8115
|
+
}
|
|
8055
8116
|
if (typeof stream.rstCode === "number" && stream.rstCode !== NGHTTP2_NO_ERROR) {
|
|
8056
8117
|
err.http2ErrorCode = stream.rstCode;
|
|
8057
8118
|
}
|
|
@@ -8339,7 +8400,8 @@ var require_client = __commonJS(function(exports, module) {
|
|
|
8339
8400
|
connectionWindowSize,
|
|
8340
8401
|
pingInterval,
|
|
8341
8402
|
webSocket,
|
|
8342
|
-
h2Options
|
|
8403
|
+
h2Options,
|
|
8404
|
+
eventSource
|
|
8343
8405
|
} = {}) {
|
|
8344
8406
|
if (keepAlive !== undefined) {
|
|
8345
8407
|
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
|
@@ -8410,7 +8472,7 @@ var require_client = __commonJS(function(exports, module) {
|
|
|
8410
8472
|
if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
|
|
8411
8473
|
throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
|
|
8412
8474
|
}
|
|
8413
|
-
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.
|
|
8475
|
+
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.maxConcurrentStreams) || h2Options.maxConcurrentStreams < 1)) {
|
|
8414
8476
|
throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
|
|
8415
8477
|
}
|
|
8416
8478
|
if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
|
|
@@ -8442,7 +8504,7 @@ var require_client = __commonJS(function(exports, module) {
|
|
|
8442
8504
|
}
|
|
8443
8505
|
}
|
|
8444
8506
|
}
|
|
8445
|
-
super({ webSocket });
|
|
8507
|
+
super({ webSocket, eventSource });
|
|
8446
8508
|
if (typeof connect2 !== "function") {
|
|
8447
8509
|
connect2 = buildConnector({
|
|
8448
8510
|
...tls,
|
|
@@ -8759,6 +8821,10 @@ var require_client = __commonJS(function(exports, module) {
|
|
|
8759
8821
|
if (request === null) {
|
|
8760
8822
|
return;
|
|
8761
8823
|
}
|
|
8824
|
+
if (request.aborted) {
|
|
8825
|
+
client[kQueue].splice(client[kPendingIdx], 1);
|
|
8826
|
+
continue;
|
|
8827
|
+
}
|
|
8762
8828
|
if (client[kUrl].protocol === "https:" && client[kServerName] !== request.servername) {
|
|
8763
8829
|
if (client[kRunning] > 0) {
|
|
8764
8830
|
return;
|
|
@@ -8862,6 +8928,9 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
8862
8928
|
var kOnConnect = Symbol("onConnect");
|
|
8863
8929
|
var kOnDisconnect = Symbol("onDisconnect");
|
|
8864
8930
|
var kOnConnectionError = Symbol("onConnectionError");
|
|
8931
|
+
var kOnClientBusy = Symbol("on client busy");
|
|
8932
|
+
var kOnClientDrain = Symbol("on client drain");
|
|
8933
|
+
var kDrainQueue = Symbol("drain queue");
|
|
8865
8934
|
var kGetDispatcher = Symbol("get dispatcher");
|
|
8866
8935
|
var kHasDispatcher = Symbol("has dispatcher");
|
|
8867
8936
|
var kAddClient = Symbol("add client");
|
|
@@ -8873,8 +8942,12 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
8873
8942
|
[kClients] = [];
|
|
8874
8943
|
[kNeedDrain] = false;
|
|
8875
8944
|
[kOnDrain](client, origin, targets) {
|
|
8945
|
+
if (client.closed || client.destroyed) {
|
|
8946
|
+
return;
|
|
8947
|
+
}
|
|
8876
8948
|
const queue = this[kQueue];
|
|
8877
8949
|
let needDrain = false;
|
|
8950
|
+
this[kOnClientDrain](client);
|
|
8878
8951
|
while (!needDrain) {
|
|
8879
8952
|
const item = queue.shift();
|
|
8880
8953
|
if (!item) {
|
|
@@ -8884,6 +8957,9 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
8884
8957
|
needDrain = !client.dispatch(item.opts, item.handler);
|
|
8885
8958
|
}
|
|
8886
8959
|
client[kNeedDrain] = needDrain;
|
|
8960
|
+
if (needDrain) {
|
|
8961
|
+
this[kOnClientBusy](client);
|
|
8962
|
+
}
|
|
8887
8963
|
if (!needDrain && this[kNeedDrain]) {
|
|
8888
8964
|
this[kNeedDrain] = false;
|
|
8889
8965
|
this.emit("drain", origin, [this, ...targets]);
|
|
@@ -8899,6 +8975,43 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
8899
8975
|
return Promise.all(closeAll).then(this[kClosedResolve]);
|
|
8900
8976
|
}
|
|
8901
8977
|
}
|
|
8978
|
+
[kOnClientBusy]() {}
|
|
8979
|
+
[kOnClientDrain]() {}
|
|
8980
|
+
[kDrainQueue](origin, targets) {
|
|
8981
|
+
const queue = this[kQueue];
|
|
8982
|
+
let hasDispatcher = true;
|
|
8983
|
+
while (!queue.isEmpty()) {
|
|
8984
|
+
const dispatcher = this[kGetDispatcher]();
|
|
8985
|
+
if (!dispatcher) {
|
|
8986
|
+
hasDispatcher = false;
|
|
8987
|
+
break;
|
|
8988
|
+
}
|
|
8989
|
+
const item = queue.shift();
|
|
8990
|
+
this[kQueued]--;
|
|
8991
|
+
if (!dispatcher.dispatch(item.opts, item.handler)) {
|
|
8992
|
+
dispatcher[kNeedDrain] = true;
|
|
8993
|
+
this[kOnClientBusy](dispatcher);
|
|
8994
|
+
hasDispatcher = this[kHasDispatcher]();
|
|
8995
|
+
if (!hasDispatcher) {
|
|
8996
|
+
break;
|
|
8997
|
+
}
|
|
8998
|
+
}
|
|
8999
|
+
}
|
|
9000
|
+
if (hasDispatcher && this[kNeedDrain]) {
|
|
9001
|
+
this[kNeedDrain] = false;
|
|
9002
|
+
this.emit("drain", origin, [this, ...targets]);
|
|
9003
|
+
}
|
|
9004
|
+
if (this[kClosedResolve] && queue.isEmpty()) {
|
|
9005
|
+
const closeAll = [];
|
|
9006
|
+
for (let i = 0;i < this[kClients].length; i++) {
|
|
9007
|
+
const client = this[kClients][i];
|
|
9008
|
+
if (!client.destroyed) {
|
|
9009
|
+
closeAll.push(client.close());
|
|
9010
|
+
}
|
|
9011
|
+
}
|
|
9012
|
+
return Promise.all(closeAll).then(this[kClosedResolve]);
|
|
9013
|
+
}
|
|
9014
|
+
}
|
|
8902
9015
|
[kOnConnect] = (origin, targets) => {
|
|
8903
9016
|
this.emit("connect", origin, [this, ...targets]);
|
|
8904
9017
|
};
|
|
@@ -8987,6 +9100,7 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
8987
9100
|
this[kQueued]++;
|
|
8988
9101
|
} else if (!dispatcher.dispatch(opts, handler)) {
|
|
8989
9102
|
dispatcher[kNeedDrain] = true;
|
|
9103
|
+
this[kOnClientBusy](dispatcher);
|
|
8990
9104
|
this[kNeedDrain] = !this[kHasDispatcher]();
|
|
8991
9105
|
}
|
|
8992
9106
|
return !this[kNeedDrain];
|
|
@@ -9005,7 +9119,7 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
9005
9119
|
this[kClients].push(client);
|
|
9006
9120
|
if (this[kNeedDrain]) {
|
|
9007
9121
|
queueMicrotask(() => {
|
|
9008
|
-
if (this[kNeedDrain]) {
|
|
9122
|
+
if (this[kNeedDrain] && !client[kNeedDrain]) {
|
|
9009
9123
|
this[kOnDrain](client, client[kUrl], [client, this]);
|
|
9010
9124
|
}
|
|
9011
9125
|
});
|
|
@@ -9027,6 +9141,9 @@ var require_pool_base = __commonJS(function(exports, module) {
|
|
|
9027
9141
|
kNeedDrain,
|
|
9028
9142
|
kAddClient,
|
|
9029
9143
|
kRemoveClient,
|
|
9144
|
+
kDrainQueue,
|
|
9145
|
+
kOnClientBusy,
|
|
9146
|
+
kOnClientDrain,
|
|
9030
9147
|
kGetDispatcher,
|
|
9031
9148
|
kHasDispatcher
|
|
9032
9149
|
};
|
|
@@ -9039,6 +9156,9 @@ var require_pool = __commonJS(function(exports, module) {
|
|
|
9039
9156
|
kClients,
|
|
9040
9157
|
kNeedDrain,
|
|
9041
9158
|
kAddClient,
|
|
9159
|
+
kDrainQueue,
|
|
9160
|
+
kOnClientBusy,
|
|
9161
|
+
kOnClientDrain,
|
|
9042
9162
|
kGetDispatcher,
|
|
9043
9163
|
kHasDispatcher,
|
|
9044
9164
|
kRemoveClient
|
|
@@ -9048,14 +9168,27 @@ var require_pool = __commonJS(function(exports, module) {
|
|
|
9048
9168
|
InvalidArgumentError
|
|
9049
9169
|
} = require_errors();
|
|
9050
9170
|
var util = require_util();
|
|
9051
|
-
var { kUrl } = require_symbols();
|
|
9171
|
+
var { kConnecting, kHTTPContext, kUrl } = require_symbols();
|
|
9052
9172
|
var buildConnector = require_connect();
|
|
9053
9173
|
var kOptions = Symbol("options");
|
|
9054
9174
|
var kConnections = Symbol("connections");
|
|
9055
9175
|
var kFactory = Symbol("factory");
|
|
9176
|
+
var kProtocol = Symbol("protocol");
|
|
9177
|
+
var kProtocolProbe = Symbol("protocol probe");
|
|
9056
9178
|
function defaultFactory(origin, opts) {
|
|
9057
9179
|
return new Client(origin, opts);
|
|
9058
9180
|
}
|
|
9181
|
+
function shouldCreateProtocolProbe(pool, dispatcher) {
|
|
9182
|
+
return dispatcher instanceof Client && pool[kProtocol] !== "h1" && (pool[kOptions].useH2c === true || pool[kUrl].protocol === "https:" && pool[kOptions].allowH2 !== false);
|
|
9183
|
+
}
|
|
9184
|
+
function createClient(pool) {
|
|
9185
|
+
const dispatcher = pool[kFactory](pool[kUrl], pool[kOptions]);
|
|
9186
|
+
if (shouldCreateProtocolProbe(pool, dispatcher)) {
|
|
9187
|
+
pool[kProtocolProbe] = dispatcher;
|
|
9188
|
+
}
|
|
9189
|
+
pool[kAddClient](dispatcher);
|
|
9190
|
+
return dispatcher;
|
|
9191
|
+
}
|
|
9059
9192
|
|
|
9060
9193
|
class Pool extends PoolBase {
|
|
9061
9194
|
constructor(origin, {
|
|
@@ -9099,22 +9232,58 @@ var require_pool = __commonJS(function(exports, module) {
|
|
|
9099
9232
|
this[kUrl] = util.parseOrigin(origin);
|
|
9100
9233
|
this[kOptions] = { ...util.deepClone(options), connect, allowH2, useH2c, clientTtl, socketPath };
|
|
9101
9234
|
this[kFactory] = factory;
|
|
9235
|
+
this[kProtocol] = null;
|
|
9236
|
+
this[kProtocolProbe] = null;
|
|
9102
9237
|
this.on("connect", (origin2, targets) => {
|
|
9103
9238
|
if (clientTtl != null && clientTtl > 0) {
|
|
9104
9239
|
for (const target of targets) {
|
|
9105
9240
|
Object.assign(target, { ttl: Date.now() });
|
|
9106
9241
|
}
|
|
9107
9242
|
}
|
|
9243
|
+
const client = targets[targets.length - 1];
|
|
9244
|
+
if (client instanceof Client) {
|
|
9245
|
+
this[kProtocol] = client[kHTTPContext]?.version;
|
|
9246
|
+
}
|
|
9247
|
+
if (client === this[kProtocolProbe]) {
|
|
9248
|
+
if (this[kProtocol] !== "h2") {
|
|
9249
|
+
this[kProtocolProbe] = null;
|
|
9250
|
+
this[kDrainQueue](origin2, targets.slice(1));
|
|
9251
|
+
}
|
|
9252
|
+
}
|
|
9108
9253
|
});
|
|
9109
|
-
this.on("
|
|
9254
|
+
this.on("disconnect", (origin2, targets) => {
|
|
9255
|
+
if (targets.includes(this[kProtocolProbe])) {
|
|
9256
|
+
this[kProtocolProbe] = null;
|
|
9257
|
+
this[kDrainQueue](origin2, targets.slice(1));
|
|
9258
|
+
}
|
|
9259
|
+
});
|
|
9260
|
+
this.on("connectionError", (origin2, targets) => {
|
|
9261
|
+
let resumeQueued = false;
|
|
9110
9262
|
for (const target of targets) {
|
|
9263
|
+
if (target === this[kProtocolProbe]) {
|
|
9264
|
+
this[kProtocolProbe] = null;
|
|
9265
|
+
resumeQueued = true;
|
|
9266
|
+
}
|
|
9111
9267
|
const idx = this[kClients].indexOf(target);
|
|
9112
9268
|
if (idx !== -1) {
|
|
9113
9269
|
this[kClients].splice(idx, 1);
|
|
9114
9270
|
}
|
|
9115
9271
|
}
|
|
9272
|
+
if (resumeQueued) {
|
|
9273
|
+
this[kDrainQueue](origin2, targets.slice(1));
|
|
9274
|
+
}
|
|
9116
9275
|
});
|
|
9117
9276
|
}
|
|
9277
|
+
[kOnClientBusy](client) {
|
|
9278
|
+
if (this[kProtocolProbe] === null && client[kConnecting] && shouldCreateProtocolProbe(this, client)) {
|
|
9279
|
+
this[kProtocolProbe] = client;
|
|
9280
|
+
}
|
|
9281
|
+
}
|
|
9282
|
+
[kOnClientDrain](client) {
|
|
9283
|
+
if (client === this[kProtocolProbe]) {
|
|
9284
|
+
this[kProtocolProbe] = null;
|
|
9285
|
+
}
|
|
9286
|
+
}
|
|
9118
9287
|
[kGetDispatcher]() {
|
|
9119
9288
|
const clientTtlOption = this[kOptions].clientTtl;
|
|
9120
9289
|
for (let i = 0;i < this[kClients].length; i++) {
|
|
@@ -9126,10 +9295,11 @@ var require_pool = __commonJS(function(exports, module) {
|
|
|
9126
9295
|
return client;
|
|
9127
9296
|
}
|
|
9128
9297
|
}
|
|
9298
|
+
if (this[kProtocolProbe] !== null) {
|
|
9299
|
+
return;
|
|
9300
|
+
}
|
|
9129
9301
|
if (!this[kConnections] || this[kClients].length < this[kConnections]) {
|
|
9130
|
-
|
|
9131
|
-
this[kAddClient](dispatcher);
|
|
9132
|
-
return dispatcher;
|
|
9302
|
+
return createClient(this);
|
|
9133
9303
|
}
|
|
9134
9304
|
}
|
|
9135
9305
|
[kHasDispatcher]() {
|
|
@@ -9143,9 +9313,11 @@ var require_pool = __commonJS(function(exports, module) {
|
|
|
9143
9313
|
return true;
|
|
9144
9314
|
}
|
|
9145
9315
|
}
|
|
9316
|
+
if (this[kProtocolProbe] !== null) {
|
|
9317
|
+
return false;
|
|
9318
|
+
}
|
|
9146
9319
|
if (!this[kConnections] || this[kClients].length < this[kConnections]) {
|
|
9147
|
-
|
|
9148
|
-
this[kAddClient](dispatcher);
|
|
9320
|
+
createClient(this);
|
|
9149
9321
|
return true;
|
|
9150
9322
|
}
|
|
9151
9323
|
return false;
|
|
@@ -9169,7 +9341,7 @@ var require_balanced_pool = __commonJS(function(exports, module) {
|
|
|
9169
9341
|
kGetDispatcher
|
|
9170
9342
|
} = require_pool_base();
|
|
9171
9343
|
var Pool = require_pool();
|
|
9172
|
-
var { kUrl } = require_symbols();
|
|
9344
|
+
var { kOriginless, kUrl } = require_symbols();
|
|
9173
9345
|
var util = require_util();
|
|
9174
9346
|
var kFactory = Symbol("factory");
|
|
9175
9347
|
var kOptions = Symbol("options");
|
|
@@ -9194,12 +9366,17 @@ var require_balanced_pool = __commonJS(function(exports, module) {
|
|
|
9194
9366
|
}
|
|
9195
9367
|
|
|
9196
9368
|
class BalancedPool extends PoolBase {
|
|
9197
|
-
constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
|
|
9369
|
+
constructor(upstreams = [], { factory = defaultFactory, connect, tls, ...opts } = {}) {
|
|
9198
9370
|
if (typeof factory !== "function") {
|
|
9199
9371
|
throw new InvalidArgumentError("factory must be a function.");
|
|
9200
9372
|
}
|
|
9201
|
-
super();
|
|
9202
|
-
this[
|
|
9373
|
+
super(opts);
|
|
9374
|
+
this[kOriginless] = true;
|
|
9375
|
+
if (connect && typeof connect !== "function")
|
|
9376
|
+
connect = { ...connect };
|
|
9377
|
+
if (tls && typeof tls !== "function")
|
|
9378
|
+
tls = { ...tls };
|
|
9379
|
+
this[kOptions] = { ...util.deepClone(opts), connect, tls };
|
|
9203
9380
|
this[kIndex] = -1;
|
|
9204
9381
|
this[kCurrentWeight] = 0;
|
|
9205
9382
|
this[kMaxWeightPerServer] = this[kOptions].maxWeightPerServer || 100;
|
|
@@ -9359,7 +9536,7 @@ var require_round_robin_pool = __commonJS(function(exports, module) {
|
|
|
9359
9536
|
...connect
|
|
9360
9537
|
});
|
|
9361
9538
|
}
|
|
9362
|
-
super();
|
|
9539
|
+
super(options);
|
|
9363
9540
|
this[kConnections] = connections || null;
|
|
9364
9541
|
this[kUrl] = util.parseOrigin(origin);
|
|
9365
9542
|
this[kOptions] = { ...util.deepClone(options), connect, allowH2, clientTtl, socketPath };
|
|
@@ -9436,7 +9613,7 @@ var require_round_robin_pool = __commonJS(function(exports, module) {
|
|
|
9436
9613
|
// ../../node_modules/undici/lib/dispatcher/agent.js
|
|
9437
9614
|
var require_agent = __commonJS(function(exports, module) {
|
|
9438
9615
|
var { InvalidArgumentError, MaxOriginsReachedError } = require_errors();
|
|
9439
|
-
var { kBusy, kClients, kConnected, kRunning, kClose, kDestroy, kDispatch, kUrl } = require_symbols();
|
|
9616
|
+
var { kBusy, kClients, kConnected, kRunning, kPending, kClose, kDestroy, kDispatch, kUrl } = require_symbols();
|
|
9440
9617
|
var DispatcherBase = require_dispatcher_base();
|
|
9441
9618
|
var Pool = require_pool();
|
|
9442
9619
|
var Client = require_client();
|
|
@@ -9510,7 +9687,7 @@ var require_agent = __commonJS(function(exports, module) {
|
|
|
9510
9687
|
if (this[kClients].get(key) !== dispatcher) {
|
|
9511
9688
|
return;
|
|
9512
9689
|
}
|
|
9513
|
-
if (dispatcher[kConnected] > 0 || dispatcher[kBusy]) {
|
|
9690
|
+
if (dispatcher[kConnected] > 0 || dispatcher[kBusy] || dispatcher[kPending] > 0) {
|
|
9514
9691
|
return;
|
|
9515
9692
|
}
|
|
9516
9693
|
this[kClients].delete(key);
|
|
@@ -9574,6 +9751,7 @@ var require_dispatcher1_wrapper = __commonJS(function(exports, module) {
|
|
|
9574
9751
|
var Dispatcher = require_dispatcher();
|
|
9575
9752
|
var { InvalidArgumentError } = require_errors();
|
|
9576
9753
|
var { toRawHeaders } = require_util();
|
|
9754
|
+
var { kOriginless, kUrl } = require_symbols();
|
|
9577
9755
|
|
|
9578
9756
|
class LegacyHandlerWrapper {
|
|
9579
9757
|
#handler;
|
|
@@ -9627,6 +9805,8 @@ var require_dispatcher1_wrapper = __commonJS(function(exports, module) {
|
|
|
9627
9805
|
throw new InvalidArgumentError("Argument dispatcher must implement dispatch");
|
|
9628
9806
|
}
|
|
9629
9807
|
this.#dispatcher = dispatcher;
|
|
9808
|
+
this[kUrl] = dispatcher[kUrl];
|
|
9809
|
+
this[kOriginless] = dispatcher[kOriginless];
|
|
9630
9810
|
}
|
|
9631
9811
|
static wrapHandler(handler) {
|
|
9632
9812
|
if (!handler || typeof handler !== "object") {
|
|
@@ -10106,25 +10286,32 @@ var require_socks5_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10106
10286
|
var { URL: URL2 } = __require("node:url");
|
|
10107
10287
|
var tls;
|
|
10108
10288
|
var DispatcherBase = require_dispatcher_base();
|
|
10109
|
-
var { InvalidArgumentError } = require_errors();
|
|
10289
|
+
var { ConnectTimeoutError, InvalidArgumentError } = require_errors();
|
|
10110
10290
|
var { Socks5Client, STATES } = require_socks5_client();
|
|
10111
10291
|
var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
|
|
10112
10292
|
var Pool = require_pool();
|
|
10113
10293
|
var buildConnector = require_connect();
|
|
10294
|
+
var { setupConnectTimeout } = require_util();
|
|
10114
10295
|
var { debuglog } = __require("node:util");
|
|
10115
10296
|
var debug = debuglog("undici:socks5-proxy");
|
|
10297
|
+
var DEFAULT_SOCKS5_CONNECT_TIMEOUT = 5000;
|
|
10116
10298
|
var kProxyUrl = Symbol("proxy url");
|
|
10117
10299
|
var kProxyHeaders = Symbol("proxy headers");
|
|
10118
10300
|
var kProxyAuth = Symbol("proxy auth");
|
|
10119
10301
|
var kProxyProtocol = Symbol("proxy protocol");
|
|
10120
10302
|
var kPools = Symbol("pools");
|
|
10121
10303
|
var kConnector = Symbol("connector");
|
|
10304
|
+
var kConnectTimeout = Symbol("connect timeout");
|
|
10122
10305
|
var kRequestTls = Symbol("request tls settings");
|
|
10306
|
+
var kRequestTlsTimeout = Symbol("request tls timeout");
|
|
10307
|
+
function createConnectTimeoutError(hostname, port, timeout) {
|
|
10308
|
+
return new ConnectTimeoutError(`Connect Timeout Error (attempted address: ${hostname}:${port}, timeout: ${timeout}ms)`);
|
|
10309
|
+
}
|
|
10123
10310
|
var experimentalWarningEmitted = false;
|
|
10124
10311
|
|
|
10125
10312
|
class Socks5ProxyAgent extends DispatcherBase {
|
|
10126
10313
|
constructor(proxyUrl, options = {}) {
|
|
10127
|
-
super();
|
|
10314
|
+
super(options);
|
|
10128
10315
|
if (!experimentalWarningEmitted) {
|
|
10129
10316
|
process.emitWarning("SOCKS5 proxy support is experimental and subject to change", "ExperimentalWarning");
|
|
10130
10317
|
experimentalWarningEmitted = true;
|
|
@@ -10139,13 +10326,29 @@ var require_socks5_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10139
10326
|
this[kProxyUrl] = url;
|
|
10140
10327
|
this[kProxyHeaders] = options.headers || {};
|
|
10141
10328
|
this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
|
|
10142
|
-
|
|
10329
|
+
const connectTimeout = options.connectTimeout ?? DEFAULT_SOCKS5_CONNECT_TIMEOUT;
|
|
10330
|
+
if (!Number.isFinite(connectTimeout) || connectTimeout < 0) {
|
|
10331
|
+
throw new InvalidArgumentError("invalid connectTimeout");
|
|
10332
|
+
}
|
|
10333
|
+
this[kConnectTimeout] = connectTimeout;
|
|
10334
|
+
const { timeout, ...requestTls } = options.requestTls || {};
|
|
10335
|
+
const requestTlsTimeout = timeout ?? connectTimeout;
|
|
10336
|
+
if (!Number.isFinite(requestTlsTimeout) || requestTlsTimeout < 0) {
|
|
10337
|
+
throw new InvalidArgumentError("invalid requestTls.timeout");
|
|
10338
|
+
}
|
|
10339
|
+
this[kRequestTls] = requestTls;
|
|
10340
|
+
this[kRequestTlsTimeout] = requestTlsTimeout;
|
|
10143
10341
|
this[kProxyAuth] = {
|
|
10144
10342
|
username: options.username || (url.username ? decodeURIComponent(url.username) : null),
|
|
10145
10343
|
password: options.password || (url.password ? decodeURIComponent(url.password) : null)
|
|
10146
10344
|
};
|
|
10345
|
+
const proxyTlsTimeout = options.proxyTls?.timeout ?? connectTimeout;
|
|
10346
|
+
if (!Number.isFinite(proxyTlsTimeout) || proxyTlsTimeout < 0) {
|
|
10347
|
+
throw new InvalidArgumentError("invalid proxyTls.timeout");
|
|
10348
|
+
}
|
|
10147
10349
|
this[kConnector] = options.connect || buildConnector({
|
|
10148
10350
|
...options.proxyTls,
|
|
10351
|
+
timeout: proxyTlsTimeout,
|
|
10149
10352
|
servername: options.proxyTls?.servername || url.hostname
|
|
10150
10353
|
});
|
|
10151
10354
|
this[kPools] = new Map;
|
|
@@ -10175,17 +10378,22 @@ var require_socks5_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10175
10378
|
});
|
|
10176
10379
|
await socks5Client.handshake();
|
|
10177
10380
|
const authenticationReady = Promise.withResolvers();
|
|
10178
|
-
const authenticationTimeout = setTimeout(() => {
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10381
|
+
const authenticationTimeout = this[kConnectTimeout] === 0 ? null : setTimeout(() => {
|
|
10382
|
+
cleanupAuthenticationListeners();
|
|
10383
|
+
socks5Client.destroy();
|
|
10384
|
+
authenticationReady.reject(createConnectTimeoutError(proxyHost, proxyPort, this[kConnectTimeout]));
|
|
10385
|
+
}, this[kConnectTimeout]);
|
|
10386
|
+
const cleanupAuthenticationListeners = () => {
|
|
10182
10387
|
clearTimeout(authenticationTimeout);
|
|
10388
|
+
socks5Client.removeListener("authenticated", onAuthenticated);
|
|
10183
10389
|
socks5Client.removeListener("error", onAuthenticationError);
|
|
10390
|
+
};
|
|
10391
|
+
const onAuthenticated = () => {
|
|
10392
|
+
cleanupAuthenticationListeners();
|
|
10184
10393
|
authenticationReady.resolve();
|
|
10185
10394
|
};
|
|
10186
10395
|
const onAuthenticationError = (err) => {
|
|
10187
|
-
|
|
10188
|
-
socks5Client.removeListener("authenticated", onAuthenticated);
|
|
10396
|
+
cleanupAuthenticationListeners();
|
|
10189
10397
|
authenticationReady.reject(err);
|
|
10190
10398
|
};
|
|
10191
10399
|
if (socks5Client.state === STATES.AUTHENTICATED) {
|
|
@@ -10198,18 +10406,23 @@ var require_socks5_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10198
10406
|
await authenticationReady.promise;
|
|
10199
10407
|
await socks5Client.connect(targetHost, targetPort);
|
|
10200
10408
|
const connectionReady = Promise.withResolvers();
|
|
10201
|
-
const connectionTimeout = setTimeout(() => {
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10409
|
+
const connectionTimeout = this[kConnectTimeout] === 0 ? null : setTimeout(() => {
|
|
10410
|
+
cleanupConnectionListeners();
|
|
10411
|
+
socks5Client.destroy();
|
|
10412
|
+
connectionReady.reject(createConnectTimeoutError(targetHost, targetPort, this[kConnectTimeout]));
|
|
10413
|
+
}, this[kConnectTimeout]);
|
|
10414
|
+
const cleanupConnectionListeners = () => {
|
|
10206
10415
|
clearTimeout(connectionTimeout);
|
|
10416
|
+
socks5Client.removeListener("connected", onConnected);
|
|
10207
10417
|
socks5Client.removeListener("error", onConnectionError);
|
|
10418
|
+
};
|
|
10419
|
+
const onConnected = (info) => {
|
|
10420
|
+
debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
|
|
10421
|
+
cleanupConnectionListeners();
|
|
10208
10422
|
connectionReady.resolve();
|
|
10209
10423
|
};
|
|
10210
10424
|
const onConnectionError = (err) => {
|
|
10211
|
-
|
|
10212
|
-
socks5Client.removeListener("connected", onConnected);
|
|
10425
|
+
cleanupConnectionListeners();
|
|
10213
10426
|
connectionReady.reject(err);
|
|
10214
10427
|
};
|
|
10215
10428
|
socks5Client.once("connected", onConnected);
|
|
@@ -10246,8 +10459,26 @@ var require_socks5_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10246
10459
|
servername: this[kRequestTls]?.servername || targetHost
|
|
10247
10460
|
});
|
|
10248
10461
|
const tlsReady = Promise.withResolvers();
|
|
10249
|
-
|
|
10250
|
-
|
|
10462
|
+
const cleanupTlsListeners = () => {
|
|
10463
|
+
queueMicrotask(clearTlsTimeout);
|
|
10464
|
+
finalSocket.removeListener("secureConnect", onSecureConnect);
|
|
10465
|
+
finalSocket.removeListener("error", onTlsError);
|
|
10466
|
+
};
|
|
10467
|
+
const onSecureConnect = () => {
|
|
10468
|
+
cleanupTlsListeners();
|
|
10469
|
+
tlsReady.resolve();
|
|
10470
|
+
};
|
|
10471
|
+
const onTlsError = (err) => {
|
|
10472
|
+
cleanupTlsListeners();
|
|
10473
|
+
tlsReady.reject(err);
|
|
10474
|
+
};
|
|
10475
|
+
const clearTlsTimeout = setupConnectTimeout(new WeakRef(finalSocket), {
|
|
10476
|
+
timeout: this[kRequestTlsTimeout],
|
|
10477
|
+
hostname: targetHost,
|
|
10478
|
+
port: targetPort
|
|
10479
|
+
});
|
|
10480
|
+
finalSocket.once("secureConnect", onSecureConnect);
|
|
10481
|
+
finalSocket.once("error", onTlsError);
|
|
10251
10482
|
await tlsReady.promise;
|
|
10252
10483
|
}
|
|
10253
10484
|
callback(null, finalSocket);
|
|
@@ -10315,6 +10546,7 @@ var require_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10315
10546
|
var Client = require_client();
|
|
10316
10547
|
var { channels } = require_diagnostics();
|
|
10317
10548
|
var Socks5ProxyAgent = require_socks5_proxy_agent();
|
|
10549
|
+
var { hasSafeIterator } = require_util();
|
|
10318
10550
|
var kAgent = Symbol("proxy agent");
|
|
10319
10551
|
var kClient = Symbol("proxy client");
|
|
10320
10552
|
var kProxyHeaders = Symbol("proxy headers");
|
|
@@ -10403,7 +10635,7 @@ var require_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10403
10635
|
throw new InvalidArgumentError("Proxy opts.clientFactory must be a function.");
|
|
10404
10636
|
}
|
|
10405
10637
|
const { proxyTunnel, connectTimeout } = opts;
|
|
10406
|
-
super();
|
|
10638
|
+
super(opts);
|
|
10407
10639
|
const url = this.#getUrl(opts);
|
|
10408
10640
|
const { href, origin, port, protocol, username, password, hostname: proxyHostname } = url;
|
|
10409
10641
|
this[kProxy] = { uri: href, protocol };
|
|
@@ -10436,6 +10668,7 @@ var require_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10436
10668
|
factory: agentFactory,
|
|
10437
10669
|
username: opts.username || username,
|
|
10438
10670
|
password: opts.password || password,
|
|
10671
|
+
connectTimeout,
|
|
10439
10672
|
proxyTls: opts.proxyTls,
|
|
10440
10673
|
requestTls: opts.requestTls
|
|
10441
10674
|
});
|
|
@@ -10570,6 +10803,25 @@ var require_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10570
10803
|
}
|
|
10571
10804
|
return headersPair;
|
|
10572
10805
|
}
|
|
10806
|
+
if (headers && typeof headers === "object" && hasSafeIterator(headers)) {
|
|
10807
|
+
const headersPair = {};
|
|
10808
|
+
for (const [key, value] of headers) {
|
|
10809
|
+
if (!Object.hasOwn(headersPair, key)) {
|
|
10810
|
+
headersPair[key] = value;
|
|
10811
|
+
continue;
|
|
10812
|
+
}
|
|
10813
|
+
const previous = headersPair[key];
|
|
10814
|
+
const values = [];
|
|
10815
|
+
if (previous !== undefined) {
|
|
10816
|
+
values.push(...Array.isArray(previous) ? previous : [previous]);
|
|
10817
|
+
}
|
|
10818
|
+
if (value !== undefined) {
|
|
10819
|
+
values.push(...Array.isArray(value) ? value : [value]);
|
|
10820
|
+
}
|
|
10821
|
+
headersPair[key] = values.length > 1 ? values : values[0];
|
|
10822
|
+
}
|
|
10823
|
+
return headersPair;
|
|
10824
|
+
}
|
|
10573
10825
|
return headers;
|
|
10574
10826
|
}
|
|
10575
10827
|
function throwIfProxyAuthIsSent(headers) {
|
|
@@ -10604,7 +10856,7 @@ var require_env_http_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10604
10856
|
#noProxyEntries = null;
|
|
10605
10857
|
#opts = null;
|
|
10606
10858
|
constructor(opts = {}) {
|
|
10607
|
-
super();
|
|
10859
|
+
super(opts);
|
|
10608
10860
|
this.#opts = opts;
|
|
10609
10861
|
const { httpProxy, httpsProxy, noProxy, ...agentOpts } = opts;
|
|
10610
10862
|
this[kNoProxyAgent] = new Agent(agentOpts);
|
|
@@ -10644,6 +10896,9 @@ var require_env_http_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10644
10896
|
#getProxyAgentForUrl(url) {
|
|
10645
10897
|
let { protocol, host: hostname, port } = url;
|
|
10646
10898
|
hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
|
|
10899
|
+
if (hostname.length > 1 && hostname.charCodeAt(hostname.length - 1) === 46) {
|
|
10900
|
+
hostname = hostname.slice(0, -1);
|
|
10901
|
+
}
|
|
10647
10902
|
port = Number.parseInt(port, 10) || DEFAULT_PORTS[protocol] || 0;
|
|
10648
10903
|
if (!this.#shouldProxy(hostname, port)) {
|
|
10649
10904
|
return this[kNoProxyAgent];
|
|
@@ -10660,15 +10915,18 @@ var require_env_http_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10660
10915
|
if (this.#noProxyEntries.length === 0) {
|
|
10661
10916
|
return true;
|
|
10662
10917
|
}
|
|
10663
|
-
if (this.#noProxyValue === "*") {
|
|
10664
|
-
return false;
|
|
10665
|
-
}
|
|
10666
10918
|
for (let i = 0;i < this.#noProxyEntries.length; i++) {
|
|
10667
10919
|
const entry = this.#noProxyEntries[i];
|
|
10920
|
+
if (entry.hostname === "*") {
|
|
10921
|
+
if (entry.port && entry.port !== port) {
|
|
10922
|
+
continue;
|
|
10923
|
+
}
|
|
10924
|
+
return false;
|
|
10925
|
+
}
|
|
10668
10926
|
if (entry.port && entry.port !== port) {
|
|
10669
10927
|
continue;
|
|
10670
10928
|
}
|
|
10671
|
-
if (hostname === entry.hostname) {
|
|
10929
|
+
if (!entry.wildcard && hostname === entry.hostname) {
|
|
10672
10930
|
return false;
|
|
10673
10931
|
}
|
|
10674
10932
|
if (hostname.slice(-(entry.hostname.length + 1)) === `.${entry.hostname}`) {
|
|
@@ -10698,9 +10956,11 @@ var require_env_http_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10698
10956
|
hostname = parsed ? parsed[1] : unbracketed;
|
|
10699
10957
|
port = parsed ? Number.parseInt(parsed[2], 10) : 0;
|
|
10700
10958
|
}
|
|
10959
|
+
const wildcard = entry.charCodeAt(0) === 42;
|
|
10701
10960
|
noProxyEntries.push({
|
|
10702
|
-
hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
|
|
10703
|
-
port
|
|
10961
|
+
hostname: hostname.replace(/^\*?\./, "").replace(/^(.+)\.$/, "$1").toLowerCase(),
|
|
10962
|
+
port,
|
|
10963
|
+
wildcard
|
|
10704
10964
|
});
|
|
10705
10965
|
}
|
|
10706
10966
|
this.#noProxyValue = noProxyValue;
|
|
@@ -10723,7 +10983,7 @@ var require_env_http_proxy_agent = __commonJS(function(exports, module) {
|
|
|
10723
10983
|
var require_retry_handler = __commonJS(function(exports, module) {
|
|
10724
10984
|
var assert = __require("node:assert");
|
|
10725
10985
|
var { kRetryHandlerDefaultRetry } = require_symbols();
|
|
10726
|
-
var { RequestRetryError } = require_errors();
|
|
10986
|
+
var { RequestRetryError, RequestAbortedError } = require_errors();
|
|
10727
10987
|
var {
|
|
10728
10988
|
isDisturbed,
|
|
10729
10989
|
parseRangeHeader,
|
|
@@ -10752,32 +11012,57 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10752
11012
|
}
|
|
10753
11013
|
|
|
10754
11014
|
class RetryController {
|
|
10755
|
-
|
|
10756
|
-
|
|
11015
|
+
#onAbort;
|
|
11016
|
+
#paused = false;
|
|
11017
|
+
#target = null;
|
|
11018
|
+
constructor(onAbort) {
|
|
11019
|
+
this.#onAbort = onAbort;
|
|
11020
|
+
}
|
|
11021
|
+
set target(target) {
|
|
11022
|
+
this.#target = target;
|
|
11023
|
+
if (this.#paused) {
|
|
11024
|
+
target?.pause();
|
|
11025
|
+
}
|
|
11026
|
+
}
|
|
11027
|
+
get target() {
|
|
11028
|
+
return this.#target;
|
|
10757
11029
|
}
|
|
10758
11030
|
pause() {
|
|
10759
|
-
this
|
|
11031
|
+
this.#paused = true;
|
|
11032
|
+
this.#target?.pause();
|
|
10760
11033
|
}
|
|
10761
11034
|
resume() {
|
|
10762
|
-
this
|
|
11035
|
+
this.#paused = false;
|
|
11036
|
+
this.#target?.resume();
|
|
10763
11037
|
}
|
|
10764
11038
|
abort(reason) {
|
|
10765
|
-
this
|
|
11039
|
+
this.#target?.abort(reason);
|
|
11040
|
+
this.#onAbort(reason);
|
|
10766
11041
|
}
|
|
10767
11042
|
get paused() {
|
|
10768
|
-
return this
|
|
11043
|
+
return this.#paused || (this.#target?.paused ?? false);
|
|
10769
11044
|
}
|
|
10770
11045
|
get aborted() {
|
|
10771
|
-
return this
|
|
11046
|
+
return this.#target?.aborted ?? false;
|
|
10772
11047
|
}
|
|
10773
11048
|
get reason() {
|
|
10774
|
-
return this
|
|
11049
|
+
return this.#target?.reason ?? null;
|
|
10775
11050
|
}
|
|
10776
11051
|
get rawHeaders() {
|
|
10777
|
-
return this
|
|
11052
|
+
return this.#target?.rawHeaders ?? null;
|
|
11053
|
+
}
|
|
11054
|
+
set rawHeaders(value) {
|
|
11055
|
+
if (this.#target) {
|
|
11056
|
+
this.#target.rawHeaders = value;
|
|
11057
|
+
}
|
|
10778
11058
|
}
|
|
10779
11059
|
get rawTrailers() {
|
|
10780
|
-
return this
|
|
11060
|
+
return this.#target?.rawTrailers ?? null;
|
|
11061
|
+
}
|
|
11062
|
+
set rawTrailers(value) {
|
|
11063
|
+
if (this.#target) {
|
|
11064
|
+
this.#target.rawTrailers = value;
|
|
11065
|
+
}
|
|
10781
11066
|
}
|
|
10782
11067
|
}
|
|
10783
11068
|
|
|
@@ -10830,13 +11115,24 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10830
11115
|
this.etag = null;
|
|
10831
11116
|
this.statusCode = null;
|
|
10832
11117
|
this.headers = null;
|
|
10833
|
-
this.controllerProxy = new RetryController;
|
|
11118
|
+
this.controllerProxy = new RetryController((reason) => this.#onAbort(reason));
|
|
11119
|
+
this.retryPending = false;
|
|
11120
|
+
this.retryTimer = null;
|
|
11121
|
+
this.pendingResponseData = null;
|
|
11122
|
+
this.pendingResponseTrailers = null;
|
|
11123
|
+
this.pendingResponseEnded = false;
|
|
11124
|
+
this.aborted = false;
|
|
10834
11125
|
}
|
|
10835
11126
|
onResponseStartWithRetry(controller, statusCode, headers, statusMessage, err) {
|
|
10836
11127
|
if (this.retryOpts.throwOnError) {
|
|
10837
11128
|
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
|
|
10838
|
-
this.headersSent
|
|
10839
|
-
|
|
11129
|
+
if (this.headersSent) {
|
|
11130
|
+
this.handler.onResponseError?.(this.controllerProxy, err);
|
|
11131
|
+
} else {
|
|
11132
|
+
this.headersSent = true;
|
|
11133
|
+
this.checkpointResponseEnd(headers);
|
|
11134
|
+
this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
|
|
11135
|
+
}
|
|
10840
11136
|
} else {
|
|
10841
11137
|
this.error = err;
|
|
10842
11138
|
}
|
|
@@ -10844,24 +11140,64 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10844
11140
|
}
|
|
10845
11141
|
if (isDisturbed(this.opts.body)) {
|
|
10846
11142
|
this.headersSent = true;
|
|
11143
|
+
this.checkpointResponseEnd(headers);
|
|
10847
11144
|
this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
|
|
10848
11145
|
return;
|
|
10849
11146
|
}
|
|
10850
11147
|
function shouldRetry(passedErr) {
|
|
11148
|
+
if (this.aborted) {
|
|
11149
|
+
return;
|
|
11150
|
+
}
|
|
11151
|
+
this.retryPending = false;
|
|
11152
|
+
this.retryTimer = null;
|
|
11153
|
+
const pendingData = this.pendingResponseData;
|
|
11154
|
+
const pendingTrailers = this.pendingResponseTrailers;
|
|
11155
|
+
const pendingEnd = this.pendingResponseEnded;
|
|
11156
|
+
this.pendingResponseData = null;
|
|
11157
|
+
this.pendingResponseTrailers = null;
|
|
11158
|
+
this.pendingResponseEnded = false;
|
|
10851
11159
|
if (passedErr) {
|
|
10852
|
-
this.headersSent
|
|
10853
|
-
|
|
11160
|
+
if (this.headersSent) {
|
|
11161
|
+
this.handler.onResponseError?.(this.controllerProxy, passedErr);
|
|
11162
|
+
} else {
|
|
11163
|
+
this.headersSent = true;
|
|
11164
|
+
this.checkpointResponseEnd(headers);
|
|
11165
|
+
this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
|
|
11166
|
+
controller.resume();
|
|
11167
|
+
if (pendingEnd) {
|
|
11168
|
+
for (const chunk of pendingData) {
|
|
11169
|
+
this.onResponseData(controller, chunk);
|
|
11170
|
+
}
|
|
11171
|
+
this.onResponseEnd(controller, pendingTrailers);
|
|
11172
|
+
}
|
|
11173
|
+
return;
|
|
11174
|
+
}
|
|
10854
11175
|
controller.resume();
|
|
10855
11176
|
return;
|
|
10856
11177
|
}
|
|
10857
11178
|
this.error = err;
|
|
10858
11179
|
controller.resume();
|
|
11180
|
+
if (pendingEnd) {
|
|
11181
|
+
this.onResponseEnd(controller, pendingTrailers);
|
|
11182
|
+
}
|
|
10859
11183
|
}
|
|
10860
11184
|
controller.pause();
|
|
10861
|
-
this.
|
|
11185
|
+
this.retryPending = true;
|
|
11186
|
+
this.pendingResponseData = [];
|
|
11187
|
+
this.pendingResponseTrailers = null;
|
|
11188
|
+
this.pendingResponseEnded = false;
|
|
11189
|
+
this.retryTimer = this.retryOpts.retry(err, {
|
|
10862
11190
|
state: { counter: this.retryCount },
|
|
10863
11191
|
opts: { retryOptions: this.retryOpts, ...this.opts }
|
|
10864
|
-
}, shouldRetry.bind(this));
|
|
11192
|
+
}, shouldRetry.bind(this)) ?? null;
|
|
11193
|
+
}
|
|
11194
|
+
checkpointResponseEnd(headers) {
|
|
11195
|
+
if (this.end == null && this.opts.method !== "HEAD") {
|
|
11196
|
+
const contentLength = headers["content-length"];
|
|
11197
|
+
this.end = contentLength != null ? Number(contentLength) - 1 : null;
|
|
11198
|
+
assert(this.end == null || Number.isFinite(this.end), "invalid content-length");
|
|
11199
|
+
this.resume = this.end != null;
|
|
11200
|
+
}
|
|
10865
11201
|
}
|
|
10866
11202
|
onRequestStart(controller, context) {
|
|
10867
11203
|
this.controllerProxy.target = controller;
|
|
@@ -10869,6 +11205,12 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10869
11205
|
this.handler.onRequestStart?.(this.controllerProxy, context);
|
|
10870
11206
|
}
|
|
10871
11207
|
}
|
|
11208
|
+
onBodySent(chunk) {
|
|
11209
|
+
this.handler.onBodySent?.(chunk);
|
|
11210
|
+
}
|
|
11211
|
+
onRequestSent() {
|
|
11212
|
+
this.handler.onRequestSent?.();
|
|
11213
|
+
}
|
|
10872
11214
|
onRequestUpgrade(_controller, statusCode, headers, socket) {
|
|
10873
11215
|
this.handler.onRequestUpgrade?.(this.controllerProxy, statusCode, headers, socket);
|
|
10874
11216
|
}
|
|
@@ -10882,7 +11224,8 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10882
11224
|
timeoutFactor,
|
|
10883
11225
|
statusCodes,
|
|
10884
11226
|
errorCodes,
|
|
10885
|
-
methods
|
|
11227
|
+
methods,
|
|
11228
|
+
retryAfter
|
|
10886
11229
|
} = retryOptions;
|
|
10887
11230
|
const { counter } = state;
|
|
10888
11231
|
if (code && code !== "UND_ERR_REQ_RETRY" && !errorCodes.includes(code)) {
|
|
@@ -10901,13 +11244,13 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10901
11244
|
cb(err);
|
|
10902
11245
|
return;
|
|
10903
11246
|
}
|
|
10904
|
-
let retryAfterHeader = headers?.["retry-after"];
|
|
11247
|
+
let retryAfterHeader = retryAfter === false ? undefined : headers?.["retry-after"];
|
|
10905
11248
|
if (retryAfterHeader) {
|
|
10906
11249
|
retryAfterHeader = Number(retryAfterHeader);
|
|
10907
11250
|
retryAfterHeader = Number.isNaN(retryAfterHeader) ? calculateRetryAfterHeader(headers["retry-after"]) : retryAfterHeader * 1000;
|
|
10908
11251
|
}
|
|
10909
11252
|
const retryTimeout = retryAfterHeader === 0 ? 0 : retryAfterHeader > 0 ? Math.min(retryAfterHeader, maxTimeout) : Math.min(minTimeout * timeoutFactor ** (counter - 1), maxTimeout);
|
|
10910
|
-
setTimeout(() => cb(null), retryTimeout);
|
|
11253
|
+
return setTimeout(() => cb(null), retryTimeout);
|
|
10911
11254
|
}
|
|
10912
11255
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
10913
11256
|
if (statusCode < 200) {
|
|
@@ -10918,16 +11261,6 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10918
11261
|
this.retryCount += 1;
|
|
10919
11262
|
this.statusCode = statusCode;
|
|
10920
11263
|
this.headers = headers;
|
|
10921
|
-
if (statusCode >= 300) {
|
|
10922
|
-
const err = new RequestRetryError("Request failed", statusCode, {
|
|
10923
|
-
headers,
|
|
10924
|
-
data: {
|
|
10925
|
-
count: this.retryCount
|
|
10926
|
-
}
|
|
10927
|
-
});
|
|
10928
|
-
this.onResponseStartWithRetry(controller, statusCode, headers, statusMessage, err);
|
|
10929
|
-
return;
|
|
10930
|
-
}
|
|
10931
11264
|
if (this.headersSent) {
|
|
10932
11265
|
if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) {
|
|
10933
11266
|
throw new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, {
|
|
@@ -10950,8 +11283,22 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10950
11283
|
}
|
|
10951
11284
|
validatePartialResponseContentLength(headers, contentRange, statusCode, this.retryCount);
|
|
10952
11285
|
const { start, size, end = size ? size - 1 : null } = contentRange;
|
|
10953
|
-
|
|
10954
|
-
|
|
11286
|
+
if (this.start !== start || this.end != null && this.end !== end) {
|
|
11287
|
+
throw new RequestRetryError("Content-Range mismatch", statusCode, {
|
|
11288
|
+
headers,
|
|
11289
|
+
data: { count: this.retryCount }
|
|
11290
|
+
});
|
|
11291
|
+
}
|
|
11292
|
+
return;
|
|
11293
|
+
}
|
|
11294
|
+
if (statusCode >= 300) {
|
|
11295
|
+
const err = new RequestRetryError("Request failed", statusCode, {
|
|
11296
|
+
headers,
|
|
11297
|
+
data: {
|
|
11298
|
+
count: this.retryCount
|
|
11299
|
+
}
|
|
11300
|
+
});
|
|
11301
|
+
this.onResponseStartWithRetry(controller, statusCode, headers, statusMessage, err);
|
|
10955
11302
|
return;
|
|
10956
11303
|
}
|
|
10957
11304
|
if (this.end == null) {
|
|
@@ -10990,6 +11337,10 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10990
11337
|
}
|
|
10991
11338
|
}
|
|
10992
11339
|
onResponseData(_controller, chunk) {
|
|
11340
|
+
if (this.pendingResponseData !== null) {
|
|
11341
|
+
this.pendingResponseData.push(chunk);
|
|
11342
|
+
return;
|
|
11343
|
+
}
|
|
10993
11344
|
if (this.error) {
|
|
10994
11345
|
return;
|
|
10995
11346
|
}
|
|
@@ -10997,6 +11348,11 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
10997
11348
|
this.handler.onResponseData?.(this.controllerProxy, chunk);
|
|
10998
11349
|
}
|
|
10999
11350
|
onResponseEnd(_controller, trailers) {
|
|
11351
|
+
if (this.pendingResponseData !== null) {
|
|
11352
|
+
this.pendingResponseTrailers = trailers;
|
|
11353
|
+
this.pendingResponseEnded = true;
|
|
11354
|
+
return;
|
|
11355
|
+
}
|
|
11000
11356
|
if (this.error && this.retryOpts.throwOnError) {
|
|
11001
11357
|
throw this.error;
|
|
11002
11358
|
}
|
|
@@ -11036,12 +11392,20 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
11036
11392
|
}
|
|
11037
11393
|
}
|
|
11038
11394
|
onResponseError(controller, err) {
|
|
11039
|
-
if (
|
|
11395
|
+
if (this.aborted) {
|
|
11396
|
+
return;
|
|
11397
|
+
}
|
|
11398
|
+
if (controller?.aborted || isDisturbed(this.opts.body) || this.headersSent && !this.resume) {
|
|
11040
11399
|
this.handler.onResponseError?.(this.controllerProxy, err);
|
|
11041
11400
|
return;
|
|
11042
11401
|
}
|
|
11043
11402
|
function shouldRetry(returnedErr) {
|
|
11044
|
-
if (
|
|
11403
|
+
if (this.aborted) {
|
|
11404
|
+
return;
|
|
11405
|
+
}
|
|
11406
|
+
this.retryPending = false;
|
|
11407
|
+
this.retryTimer = null;
|
|
11408
|
+
if (!returnedErr) {
|
|
11045
11409
|
this.retry();
|
|
11046
11410
|
return;
|
|
11047
11411
|
}
|
|
@@ -11052,10 +11416,24 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
11052
11416
|
} else {
|
|
11053
11417
|
this.retryCount += 1;
|
|
11054
11418
|
}
|
|
11055
|
-
this.
|
|
11419
|
+
this.retryPending = true;
|
|
11420
|
+
this.retryTimer = this.retryOpts.retry(err, {
|
|
11056
11421
|
state: { counter: this.retryCount },
|
|
11057
11422
|
opts: { retryOptions: this.retryOpts, ...this.opts }
|
|
11058
|
-
}, shouldRetry.bind(this));
|
|
11423
|
+
}, shouldRetry.bind(this)) ?? null;
|
|
11424
|
+
}
|
|
11425
|
+
#onAbort(reason) {
|
|
11426
|
+
if (!this.retryPending) {
|
|
11427
|
+
return;
|
|
11428
|
+
}
|
|
11429
|
+
this.aborted = true;
|
|
11430
|
+
this.retryPending = false;
|
|
11431
|
+
clearTimeout(this.retryTimer);
|
|
11432
|
+
this.retryTimer = null;
|
|
11433
|
+
this.pendingResponseData = null;
|
|
11434
|
+
this.pendingResponseTrailers = null;
|
|
11435
|
+
this.pendingResponseEnded = false;
|
|
11436
|
+
this.handler.onResponseError?.(this.controllerProxy, reason ?? new RequestAbortedError);
|
|
11059
11437
|
}
|
|
11060
11438
|
}
|
|
11061
11439
|
module.exports = RetryHandler;
|
|
@@ -11065,6 +11443,7 @@ var require_retry_handler = __commonJS(function(exports, module) {
|
|
|
11065
11443
|
var require_retry_agent = __commonJS(function(exports, module) {
|
|
11066
11444
|
var Dispatcher = require_dispatcher();
|
|
11067
11445
|
var RetryHandler = require_retry_handler();
|
|
11446
|
+
var { kOriginless, kUrl } = require_symbols();
|
|
11068
11447
|
|
|
11069
11448
|
class RetryAgent extends Dispatcher {
|
|
11070
11449
|
#agent = null;
|
|
@@ -11073,6 +11452,8 @@ var require_retry_agent = __commonJS(function(exports, module) {
|
|
|
11073
11452
|
super(options);
|
|
11074
11453
|
this.#agent = agent;
|
|
11075
11454
|
this.#options = options;
|
|
11455
|
+
this[kUrl] = agent[kUrl];
|
|
11456
|
+
this[kOriginless] = agent[kOriginless];
|
|
11076
11457
|
}
|
|
11077
11458
|
dispatch(opts, handler) {
|
|
11078
11459
|
const retry = new RetryHandler({
|
|
@@ -11138,7 +11519,6 @@ var require_readable = __commonJS(function(exports, module) {
|
|
|
11138
11519
|
var { Readable } = __require("node:stream");
|
|
11139
11520
|
var { RequestAbortedError, NotSupportedError, InvalidArgumentError, AbortError } = require_errors();
|
|
11140
11521
|
var util = require_util();
|
|
11141
|
-
var { ReadableStreamFrom } = require_util();
|
|
11142
11522
|
var kConsume = Symbol("kConsume");
|
|
11143
11523
|
var kReading = Symbol("kReading");
|
|
11144
11524
|
var kBody = Symbol("kBody");
|
|
@@ -11238,7 +11618,7 @@ var require_readable = __commonJS(function(exports, module) {
|
|
|
11238
11618
|
}
|
|
11239
11619
|
get body() {
|
|
11240
11620
|
if (!this[kBody]) {
|
|
11241
|
-
this[kBody] =
|
|
11621
|
+
this[kBody] = ReadableStream.from(this);
|
|
11242
11622
|
if (this[kConsume]) {
|
|
11243
11623
|
this[kBody].getReader();
|
|
11244
11624
|
assert(this[kBody].locked);
|
|
@@ -12608,8 +12988,7 @@ var require_mock_utils = __commonJS(function(exports, module) {
|
|
|
12608
12988
|
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
12609
12989
|
return;
|
|
12610
12990
|
}
|
|
12611
|
-
mockDispatch2
|
|
12612
|
-
dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
|
|
12991
|
+
dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler, { ...responseDefaults, ...resolvedData });
|
|
12613
12992
|
}, (error) => {
|
|
12614
12993
|
handler.onResponseError(null, error);
|
|
12615
12994
|
});
|
|
@@ -12618,12 +12997,13 @@ var require_mock_utils = __commonJS(function(exports, module) {
|
|
|
12618
12997
|
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
12619
12998
|
throw new InvalidArgumentError("reply options callback must return an object");
|
|
12620
12999
|
}
|
|
12621
|
-
mockDispatch2
|
|
13000
|
+
return dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler, { ...responseDefaults, ...callbackResult });
|
|
12622
13001
|
}
|
|
12623
13002
|
return dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
|
|
12624
13003
|
}
|
|
12625
|
-
function dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler) {
|
|
12626
|
-
const { data:
|
|
13004
|
+
function dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler, resolvedResponse) {
|
|
13005
|
+
const { data: responseData, delay } = mockDispatch2;
|
|
13006
|
+
const response = resolvedResponse ?? responseData;
|
|
12627
13007
|
if (response.error !== null) {
|
|
12628
13008
|
deleteMockDispatch(mockDispatches, key);
|
|
12629
13009
|
handler.onResponseError(null, response.error);
|
|
@@ -12696,8 +13076,7 @@ var require_mock_utils = __commonJS(function(exports, module) {
|
|
|
12696
13076
|
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
12697
13077
|
return;
|
|
12698
13078
|
}
|
|
12699
|
-
|
|
12700
|
-
handleReply(dispatches, mockDispatch2.data);
|
|
13079
|
+
handleReply(dispatches, { ...responseDefaults, ...resolvedData });
|
|
12701
13080
|
}, (err) => {
|
|
12702
13081
|
handler.onResponseError(null, err);
|
|
12703
13082
|
});
|
|
@@ -12706,8 +13085,7 @@ var require_mock_utils = __commonJS(function(exports, module) {
|
|
|
12706
13085
|
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
12707
13086
|
throw new InvalidArgumentError("reply options callback must return an object");
|
|
12708
13087
|
}
|
|
12709
|
-
|
|
12710
|
-
handleReply(dispatches, mockDispatch2.data);
|
|
13088
|
+
handleReply(dispatches, { ...responseDefaults, ...callbackResult });
|
|
12711
13089
|
return;
|
|
12712
13090
|
}
|
|
12713
13091
|
if (typeof delay === "number" && delay > 0) {
|
|
@@ -12732,13 +13110,13 @@ var require_mock_utils = __commonJS(function(exports, module) {
|
|
|
12732
13110
|
if (aborted) {
|
|
12733
13111
|
return;
|
|
12734
13112
|
}
|
|
12735
|
-
const
|
|
13113
|
+
const responseData2 = getResponseData(body);
|
|
12736
13114
|
const responseHeaders = generateKeyValues(headers ?? {});
|
|
12737
13115
|
const responseTrailers = generateKeyValues(trailers ?? {});
|
|
12738
13116
|
controller.rawHeaders = responseHeaders;
|
|
12739
13117
|
controller.rawTrailers = responseTrailers;
|
|
12740
13118
|
handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
|
|
12741
|
-
handler.onResponseData?.(controller, Buffer.from(
|
|
13119
|
+
handler.onResponseData?.(controller, Buffer.from(responseData2));
|
|
12742
13120
|
handler.onResponseEnd?.(controller, parseHeaders(responseTrailers));
|
|
12743
13121
|
deleteMockDispatch(mockDispatches2, key);
|
|
12744
13122
|
}
|
|
@@ -13450,10 +13828,18 @@ var require_mock_agent = __commonJS(function(exports, module) {
|
|
|
13450
13828
|
}
|
|
13451
13829
|
dispatch(opts, handler) {
|
|
13452
13830
|
opts.origin = normalizeOrigin(opts.origin);
|
|
13453
|
-
this.get(opts.origin);
|
|
13831
|
+
const mockDispatcher = this.get(opts.origin);
|
|
13454
13832
|
this[kMockAgentAddCallHistoryLog](opts);
|
|
13455
13833
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
13456
13834
|
const dispatchOpts = { ...opts };
|
|
13835
|
+
if (dispatchOpts.allowH2 === false) {
|
|
13836
|
+
const http1OnlyKey = `${dispatchOpts.origin}#http1-only`;
|
|
13837
|
+
if (!this[kClients].has(http1OnlyKey)) {
|
|
13838
|
+
const http1OnlyDispatcher = this[kFactory](dispatchOpts.origin);
|
|
13839
|
+
http1OnlyDispatcher[kDispatches] = mockDispatcher[kDispatches];
|
|
13840
|
+
this[kMockAgentSet](http1OnlyKey, http1OnlyDispatcher);
|
|
13841
|
+
}
|
|
13842
|
+
}
|
|
13457
13843
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
13458
13844
|
const [path, searchParams] = dispatchOpts.path.split("?");
|
|
13459
13845
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
@@ -14278,7 +14664,12 @@ var require_decorator_handler = __commonJS(function(exports, module) {
|
|
|
14278
14664
|
this.#onErrorCalled = true;
|
|
14279
14665
|
return this.#handler.onResponseError?.(...args);
|
|
14280
14666
|
}
|
|
14281
|
-
onBodySent() {
|
|
14667
|
+
onBodySent(...args) {
|
|
14668
|
+
return this.#handler.onBodySent?.(...args);
|
|
14669
|
+
}
|
|
14670
|
+
onRequestSent(...args) {
|
|
14671
|
+
return this.#handler.onRequestSent?.(...args);
|
|
14672
|
+
}
|
|
14282
14673
|
};
|
|
14283
14674
|
});
|
|
14284
14675
|
|
|
@@ -14287,6 +14678,7 @@ var require_redirect_handler = __commonJS(function(exports, module) {
|
|
|
14287
14678
|
var util = require_util();
|
|
14288
14679
|
var assert = __require("node:assert");
|
|
14289
14680
|
var { InvalidArgumentError } = require_errors();
|
|
14681
|
+
var { kRequestOrigin } = require_symbols();
|
|
14290
14682
|
var redirectableStatusCodes = [300, 301, 302, 303, 307, 308];
|
|
14291
14683
|
var noop = () => {};
|
|
14292
14684
|
|
|
@@ -14319,10 +14711,20 @@ var require_redirect_handler = __commonJS(function(exports, module) {
|
|
|
14319
14711
|
onRequestStart(controller, context) {
|
|
14320
14712
|
this.handler.onRequestStart?.(controller, { ...context, history: this.history });
|
|
14321
14713
|
}
|
|
14714
|
+
onBodySent(chunk) {
|
|
14715
|
+
this.handler.onBodySent?.(chunk);
|
|
14716
|
+
}
|
|
14717
|
+
onRequestSent() {
|
|
14718
|
+
this.handler.onRequestSent?.();
|
|
14719
|
+
}
|
|
14322
14720
|
onRequestUpgrade(controller, statusCode, headers, socket) {
|
|
14323
14721
|
this.handler.onRequestUpgrade?.(controller, statusCode, headers, socket);
|
|
14324
14722
|
}
|
|
14325
14723
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
14724
|
+
if (statusCode < 200) {
|
|
14725
|
+
this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
|
|
14726
|
+
return;
|
|
14727
|
+
}
|
|
14326
14728
|
if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
|
|
14327
14729
|
throw new Error("max redirects");
|
|
14328
14730
|
}
|
|
@@ -14343,14 +14745,16 @@ var require_redirect_handler = __commonJS(function(exports, module) {
|
|
|
14343
14745
|
this.opts.body = null;
|
|
14344
14746
|
}
|
|
14345
14747
|
this.location = this.history.length >= this.maxRedirections || util.isDisturbed(this.opts.body) || redirectableStatusCodes.indexOf(statusCode) === -1 ? null : headers.location;
|
|
14346
|
-
|
|
14347
|
-
|
|
14748
|
+
const requestOrigin = this.opts[kRequestOrigin] === undefined ? this.opts.origin : this.opts[kRequestOrigin];
|
|
14749
|
+
if (requestOrigin) {
|
|
14750
|
+
this.history.push(new URL(this.opts.path, requestOrigin));
|
|
14348
14751
|
}
|
|
14349
14752
|
if (!this.location) {
|
|
14350
14753
|
this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
|
|
14351
14754
|
return;
|
|
14352
14755
|
}
|
|
14353
|
-
const
|
|
14756
|
+
const baseUrl = requestOrigin ? new URL(this.opts.path, requestOrigin) : undefined;
|
|
14757
|
+
const { origin, pathname, search } = util.parseURL(new URL(this.location, baseUrl));
|
|
14354
14758
|
const path = search ? `${pathname}${search}` : pathname;
|
|
14355
14759
|
const redirectUrlString = `${origin}${path}`;
|
|
14356
14760
|
for (const historyUrl of this.history) {
|
|
@@ -14358,9 +14762,10 @@ var require_redirect_handler = __commonJS(function(exports, module) {
|
|
|
14358
14762
|
throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
14359
14763
|
}
|
|
14360
14764
|
}
|
|
14361
|
-
this.opts.headers = cleanRequestHeaders(this.opts.headers, removeContentHeaders,
|
|
14765
|
+
this.opts.headers = cleanRequestHeaders(this.opts.headers, removeContentHeaders, requestOrigin !== origin, this.stripHeadersOnRedirect, this.stripHeadersOnCrossOriginRedirect);
|
|
14362
14766
|
this.opts.path = path;
|
|
14363
14767
|
this.opts.origin = origin;
|
|
14768
|
+
this.opts[kRequestOrigin] = origin;
|
|
14364
14769
|
this.opts.query = null;
|
|
14365
14770
|
}
|
|
14366
14771
|
onResponseData(controller, chunk) {
|
|
@@ -14556,7 +14961,6 @@ var require_dump = __commonJS(function(exports, module) {
|
|
|
14556
14961
|
#maxSize = 1024 * 1024;
|
|
14557
14962
|
#dumped = false;
|
|
14558
14963
|
#size = 0;
|
|
14559
|
-
#controller = null;
|
|
14560
14964
|
aborted = false;
|
|
14561
14965
|
reason = false;
|
|
14562
14966
|
constructor({ maxSize, signal }, handler) {
|
|
@@ -14572,7 +14976,6 @@ var require_dump = __commonJS(function(exports, module) {
|
|
|
14572
14976
|
}
|
|
14573
14977
|
onRequestStart(controller, context) {
|
|
14574
14978
|
controller.abort = this.#abort.bind(this);
|
|
14575
|
-
this.#controller = controller;
|
|
14576
14979
|
return super.onRequestStart(controller, context);
|
|
14577
14980
|
}
|
|
14578
14981
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
@@ -14586,33 +14989,24 @@ var require_dump = __commonJS(function(exports, module) {
|
|
|
14586
14989
|
return super.onResponseStart(controller, statusCode, headers, statusMessage);
|
|
14587
14990
|
}
|
|
14588
14991
|
onResponseError(controller, err) {
|
|
14589
|
-
|
|
14590
|
-
return;
|
|
14591
|
-
}
|
|
14592
|
-
err = this.#controller?.reason ?? err;
|
|
14593
|
-
super.onResponseError(controller, err);
|
|
14992
|
+
super.onResponseError(controller, this.aborted === true ? this.reason : err);
|
|
14594
14993
|
}
|
|
14595
14994
|
onResponseData(controller, chunk) {
|
|
14596
14995
|
this.#size = this.#size + chunk.length;
|
|
14597
|
-
if (this.#size
|
|
14996
|
+
if (this.#size > this.#maxSize) {
|
|
14997
|
+
throw new RequestAbortedError(`Response size (${this.#size}) larger than maxSize (${this.#maxSize})`);
|
|
14998
|
+
}
|
|
14999
|
+
if (this.#size === this.#maxSize) {
|
|
14598
15000
|
this.#dumped = true;
|
|
14599
|
-
if (this.aborted === true) {
|
|
14600
|
-
super.onResponseError(controller, this.reason);
|
|
14601
|
-
} else {
|
|
14602
|
-
super.onResponseEnd(controller, {});
|
|
14603
|
-
}
|
|
14604
15001
|
}
|
|
14605
15002
|
return true;
|
|
14606
15003
|
}
|
|
14607
15004
|
onResponseEnd(controller, trailers) {
|
|
14608
|
-
if (this
|
|
14609
|
-
return;
|
|
14610
|
-
}
|
|
14611
|
-
if (this.#controller.aborted === true) {
|
|
15005
|
+
if (this.aborted === true) {
|
|
14612
15006
|
super.onResponseError(controller, this.reason);
|
|
14613
15007
|
return;
|
|
14614
15008
|
}
|
|
14615
|
-
super.onResponseEnd(controller, trailers);
|
|
15009
|
+
super.onResponseEnd(controller, this.#dumped ? {} : trailers);
|
|
14616
15010
|
}
|
|
14617
15011
|
}
|
|
14618
15012
|
function createDumpInterceptor({ maxSize: defaultMaxSize } = {
|
|
@@ -14635,6 +15029,7 @@ var require_dns = __commonJS(function(exports, module) {
|
|
|
14635
15029
|
var { lookup } = __require("node:dns");
|
|
14636
15030
|
var DecoratorHandler = require_decorator_handler();
|
|
14637
15031
|
var { InvalidArgumentError, InformationalError } = require_errors();
|
|
15032
|
+
var { kRequestOrigin } = require_symbols();
|
|
14638
15033
|
var maxInt = Math.pow(2, 31) - 1;
|
|
14639
15034
|
function hasSafeIterator(headers) {
|
|
14640
15035
|
const prototype = Object.getPrototypeOf(headers);
|
|
@@ -14958,6 +15353,7 @@ var require_dns = __commonJS(function(exports, module) {
|
|
|
14958
15353
|
const dispatchOpts = {
|
|
14959
15354
|
...this.#opts,
|
|
14960
15355
|
origin: `${this.#origin.protocol}//${ip.family === 6 ? `[${ip.address}]` : ip.address}${port}`,
|
|
15356
|
+
[kRequestOrigin]: this.#opts[kRequestOrigin] === undefined ? this.#origin : this.#opts[kRequestOrigin],
|
|
14961
15357
|
headers: withHostHeader(this.#origin.host, this.#opts.headers)
|
|
14962
15358
|
};
|
|
14963
15359
|
this.#dispatch(dispatchOpts, this);
|
|
@@ -15032,6 +15428,7 @@ var require_dns = __commonJS(function(exports, module) {
|
|
|
15032
15428
|
...origDispatchOpts,
|
|
15033
15429
|
servername: origin.hostname,
|
|
15034
15430
|
origin: newOrigin.origin,
|
|
15431
|
+
[kRequestOrigin]: origDispatchOpts[kRequestOrigin] === undefined ? origin : origDispatchOpts[kRequestOrigin],
|
|
15035
15432
|
headers: withHostHeader(origin.host, origDispatchOpts.headers)
|
|
15036
15433
|
};
|
|
15037
15434
|
dispatch(dispatchOpts, instance.getHandler({ origin, dispatch, handler, newOrigin }, origDispatchOpts));
|
|
@@ -15051,6 +15448,7 @@ var require_cache = __commonJS(function(exports, module) {
|
|
|
15051
15448
|
isValidHTTPToken
|
|
15052
15449
|
} = require_util();
|
|
15053
15450
|
var { serializePathWithQuery } = require_util();
|
|
15451
|
+
var { kRequestOrigin } = require_symbols();
|
|
15054
15452
|
var MAX_DELTA_SECONDS = 2147483647;
|
|
15055
15453
|
var RESTRICTIVE_DIRECTIVE_NAMES = ["no-store", "private", "no-cache"];
|
|
15056
15454
|
var kInvalidCacheControlDirectives = Symbol("invalid cache-control directives");
|
|
@@ -15162,14 +15560,39 @@ var require_cache = __commonJS(function(exports, module) {
|
|
|
15162
15560
|
return tokenOnlyKey;
|
|
15163
15561
|
}
|
|
15164
15562
|
}
|
|
15165
|
-
function
|
|
15166
|
-
const origin = opts
|
|
15563
|
+
function getRequestOrigin(opts) {
|
|
15564
|
+
const origin = opts[kRequestOrigin] === undefined ? opts.origin : opts[kRequestOrigin];
|
|
15565
|
+
return typeof origin === "string" || origin instanceof URL ? origin : null;
|
|
15566
|
+
}
|
|
15567
|
+
function getInterceptorOrigin(opts, interceptorOrigin) {
|
|
15568
|
+
const requestOrigin = getRequestOrigin(opts);
|
|
15569
|
+
if (interceptorOrigin === undefined) {
|
|
15570
|
+
return requestOrigin;
|
|
15571
|
+
}
|
|
15572
|
+
if (interceptorOrigin === null) {
|
|
15573
|
+
return null;
|
|
15574
|
+
}
|
|
15575
|
+
if (requestOrigin) {
|
|
15576
|
+
try {
|
|
15577
|
+
if (new URL(requestOrigin).origin !== interceptorOrigin) {
|
|
15578
|
+
return null;
|
|
15579
|
+
}
|
|
15580
|
+
} catch {
|
|
15581
|
+
return interceptorOrigin;
|
|
15582
|
+
}
|
|
15583
|
+
}
|
|
15584
|
+
return interceptorOrigin;
|
|
15585
|
+
}
|
|
15586
|
+
function makeCacheKey(opts, origin = getRequestOrigin(opts)) {
|
|
15587
|
+
if (!origin) {
|
|
15588
|
+
throw new Error("opts.origin is undefined");
|
|
15589
|
+
}
|
|
15167
15590
|
let fullPath = opts.path || "/";
|
|
15168
15591
|
if (opts.query && !pathHasQueryOrFragment(fullPath)) {
|
|
15169
15592
|
fullPath = serializePathWithQuery(fullPath, opts.query);
|
|
15170
15593
|
}
|
|
15171
15594
|
return {
|
|
15172
|
-
origin,
|
|
15595
|
+
origin: origin.toString(),
|
|
15173
15596
|
method: opts.method,
|
|
15174
15597
|
path: fullPath,
|
|
15175
15598
|
headers: opts.headers
|
|
@@ -15540,6 +15963,8 @@ var require_cache = __commonJS(function(exports, module) {
|
|
|
15540
15963
|
return JSON.stringify([cacheKey.origin, cacheKey.method, cacheKey.path, headers]);
|
|
15541
15964
|
}
|
|
15542
15965
|
module.exports = {
|
|
15966
|
+
getInterceptorOrigin,
|
|
15967
|
+
getRequestOrigin,
|
|
15543
15968
|
makeCacheKey,
|
|
15544
15969
|
normalizeHeaders,
|
|
15545
15970
|
assertCacheKey,
|
|
@@ -16177,6 +16602,12 @@ var require_cache_handler = __commonJS(function(exports, module) {
|
|
|
16177
16602
|
this.#writeStream = undefined;
|
|
16178
16603
|
this.#handler.onRequestStart?.(controller, context);
|
|
16179
16604
|
}
|
|
16605
|
+
onBodySent(chunk) {
|
|
16606
|
+
this.#handler.onBodySent?.(chunk);
|
|
16607
|
+
}
|
|
16608
|
+
onRequestSent() {
|
|
16609
|
+
this.#handler.onRequestSent?.();
|
|
16610
|
+
}
|
|
16180
16611
|
onRequestUpgrade(controller, statusCode, headers, socket) {
|
|
16181
16612
|
this.#handler.onRequestUpgrade?.(controller, statusCode, headers, socket);
|
|
16182
16613
|
}
|
|
@@ -16188,6 +16619,11 @@ var require_cache_handler = __commonJS(function(exports, module) {
|
|
|
16188
16619
|
return downstreamOnHeaders();
|
|
16189
16620
|
}
|
|
16190
16621
|
const cacheControlHeader = resHeaders["cache-control"];
|
|
16622
|
+
const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
|
|
16623
|
+
if (revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives)) {
|
|
16624
|
+
deleteCachedValue(this.#store, this.#cacheKey);
|
|
16625
|
+
return downstreamOnHeaders();
|
|
16626
|
+
}
|
|
16191
16627
|
const heuristicallyCacheable = resHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, statusCode);
|
|
16192
16628
|
if (!cacheControlHeader && !resHeaders["expires"] && !heuristicallyCacheable && !this.#cacheByDefault) {
|
|
16193
16629
|
if (statusCode === 304 && resHeaders.vary && isInvalidOrWildcardVaryHeader(resHeaders.vary)) {
|
|
@@ -16195,8 +16631,7 @@ var require_cache_handler = __commonJS(function(exports, module) {
|
|
|
16195
16631
|
}
|
|
16196
16632
|
return downstreamOnHeaders();
|
|
16197
16633
|
}
|
|
16198
|
-
|
|
16199
|
-
if (!canCacheResponse(this.#cacheType, statusCode, resHeaders, cacheControlDirectives, this.#cacheKey.headers)) {
|
|
16634
|
+
if (!canCacheResponse(this.#cacheType, this.#cacheKey.method, statusCode, resHeaders, cacheControlDirectives, this.#cacheKey.headers)) {
|
|
16200
16635
|
if (statusCode === 304 && (cacheControlHeader || revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives))) {
|
|
16201
16636
|
deleteCachedValue(this.#store, this.#cacheKey);
|
|
16202
16637
|
}
|
|
@@ -16360,9 +16795,12 @@ var require_cache_handler = __commonJS(function(exports, module) {
|
|
|
16360
16795
|
}
|
|
16361
16796
|
}
|
|
16362
16797
|
function revalidationResponseDisallowsCachedReuse(cacheType, resHeaders, cacheControlDirectives) {
|
|
16363
|
-
return cacheControlDirectives["no-store"] === true || cacheType === "shared" && cacheControlDirectives.private === true || (resHeaders.vary ? isInvalidOrWildcardVaryHeader(resHeaders.vary) : false);
|
|
16798
|
+
return cacheControlDirectives["no-store"] === true || cacheType === "shared" && (cacheControlDirectives.private === true || Object.hasOwn(resHeaders, "set-cookie")) || (resHeaders.vary ? isInvalidOrWildcardVaryHeader(resHeaders.vary) : false);
|
|
16364
16799
|
}
|
|
16365
|
-
function canCacheResponse(cacheType, statusCode, resHeaders, cacheControlDirectives, reqHeaders) {
|
|
16800
|
+
function canCacheResponse(cacheType, method, statusCode, resHeaders, cacheControlDirectives, reqHeaders) {
|
|
16801
|
+
if (!arrayIncludes(util.safeHTTPMethods, method)) {
|
|
16802
|
+
return false;
|
|
16803
|
+
}
|
|
16366
16804
|
if (statusCode < 200 || arrayIncludes(NOT_UNDERSTOOD_STATUS_CODES, statusCode)) {
|
|
16367
16805
|
return false;
|
|
16368
16806
|
}
|
|
@@ -16372,7 +16810,7 @@ var require_cache_handler = __commonJS(function(exports, module) {
|
|
|
16372
16810
|
if (cacheControlDirectives["no-store"]) {
|
|
16373
16811
|
return false;
|
|
16374
16812
|
}
|
|
16375
|
-
if (cacheType === "shared" && cacheControlDirectives.private === true) {
|
|
16813
|
+
if (cacheType === "shared" && (cacheControlDirectives.private === true || Object.hasOwn(resHeaders, "set-cookie"))) {
|
|
16376
16814
|
return false;
|
|
16377
16815
|
}
|
|
16378
16816
|
if (resHeaders.vary && hasVaryStar(resHeaders.vary)) {
|
|
@@ -16655,7 +17093,7 @@ var require_memory_cache_store = __commonJS(function(exports, module) {
|
|
|
16655
17093
|
store.#hasEmittedMaxSizeEvent = true;
|
|
16656
17094
|
}
|
|
16657
17095
|
for (const [key2, entries2] of store.#entries) {
|
|
16658
|
-
for (const entry2 of entries2.splice(0, entries2.length / 2)) {
|
|
17096
|
+
for (const entry2 of entries2.splice(0, Math.ceil(entries2.length / 2))) {
|
|
16659
17097
|
store.#size -= entry2.size;
|
|
16660
17098
|
store.#count -= 1;
|
|
16661
17099
|
}
|
|
@@ -16805,7 +17243,16 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
16805
17243
|
var CacheHandler = require_cache_handler();
|
|
16806
17244
|
var MemoryCacheStore = require_memory_cache_store();
|
|
16807
17245
|
var CacheRevalidationHandler = require_cache_revalidation_handler();
|
|
16808
|
-
var {
|
|
17246
|
+
var {
|
|
17247
|
+
assertCacheStore,
|
|
17248
|
+
assertCacheMethods,
|
|
17249
|
+
getInterceptorOrigin,
|
|
17250
|
+
makeCacheKey,
|
|
17251
|
+
normalizeHeaders,
|
|
17252
|
+
parseCacheControlHeader,
|
|
17253
|
+
isInvalidOrWildcardVaryHeader,
|
|
17254
|
+
parseVaryHeader
|
|
17255
|
+
} = require_cache();
|
|
16809
17256
|
var { AbortError } = require_errors();
|
|
16810
17257
|
var { parseHttpDate } = require_date();
|
|
16811
17258
|
function assertCacheOrigins(origins, name) {
|
|
@@ -16869,7 +17316,7 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
16869
17316
|
return result.cacheControlDirectives?.["must-revalidate"] === true || cacheType === "shared" && (result.cacheControlDirectives?.["proxy-revalidate"] === true || result.cacheControlDirectives?.["s-maxage"] !== undefined);
|
|
16870
17317
|
}
|
|
16871
17318
|
function revalidationResponseDisallowsCachedReuse(cacheType, headers) {
|
|
16872
|
-
if (headers.vary && isInvalidOrWildcardVaryHeader(headers.vary)) {
|
|
17319
|
+
if (headers.vary && isInvalidOrWildcardVaryHeader(headers.vary) || cacheType === "shared" && Object.hasOwn(headers, "set-cookie")) {
|
|
16873
17320
|
return true;
|
|
16874
17321
|
}
|
|
16875
17322
|
const cacheControl = headers["cache-control"];
|
|
@@ -16882,6 +17329,17 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
16882
17329
|
function revalidationResponseUpdatesCacheControl(headers) {
|
|
16883
17330
|
return headers["cache-control"] !== undefined;
|
|
16884
17331
|
}
|
|
17332
|
+
function revalidationResponseAddsVary(result, varyDirectives) {
|
|
17333
|
+
if (!varyDirectives) {
|
|
17334
|
+
return false;
|
|
17335
|
+
}
|
|
17336
|
+
for (const key in varyDirectives) {
|
|
17337
|
+
if (result.vary == null || !Object.hasOwn(result.vary, key)) {
|
|
17338
|
+
return true;
|
|
17339
|
+
}
|
|
17340
|
+
}
|
|
17341
|
+
return false;
|
|
17342
|
+
}
|
|
16885
17343
|
function deleteCachedValue(store, cacheKey) {
|
|
16886
17344
|
try {
|
|
16887
17345
|
store.delete(cacheKey)?.catch?.(nop);
|
|
@@ -16976,6 +17434,7 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
16976
17434
|
const stream = util.isStream(result.body) ? result.body : Readable.from(result.body ?? []);
|
|
16977
17435
|
assert(!stream.destroyed, "stream should not be destroyed");
|
|
16978
17436
|
assert(!stream.readableDidRead, "stream should not be readableDidRead");
|
|
17437
|
+
let aborted = false;
|
|
16979
17438
|
const controller = {
|
|
16980
17439
|
rawHeaders: [],
|
|
16981
17440
|
rawTrailers: [],
|
|
@@ -16989,12 +17448,13 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
16989
17448
|
return stream.isPaused();
|
|
16990
17449
|
},
|
|
16991
17450
|
get aborted() {
|
|
16992
|
-
return
|
|
17451
|
+
return aborted;
|
|
16993
17452
|
},
|
|
16994
17453
|
get reason() {
|
|
16995
17454
|
return stream.errored;
|
|
16996
17455
|
},
|
|
16997
17456
|
abort(reason) {
|
|
17457
|
+
aborted = true;
|
|
16998
17458
|
stream.destroy(reason ?? new AbortError);
|
|
16999
17459
|
}
|
|
17000
17460
|
};
|
|
@@ -17033,6 +17493,13 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
17033
17493
|
if (!result) {
|
|
17034
17494
|
return handleUncachedResponse(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl);
|
|
17035
17495
|
}
|
|
17496
|
+
if (globalOpts.type === "shared" && Object.hasOwn(result.headers, "set-cookie")) {
|
|
17497
|
+
if (util.isStream(result.body)) {
|
|
17498
|
+
result.body.on("error", nop).destroy();
|
|
17499
|
+
}
|
|
17500
|
+
deleteCachedValue(globalOpts.store, cacheKey);
|
|
17501
|
+
return handleUncachedResponse(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl);
|
|
17502
|
+
}
|
|
17036
17503
|
const now = Date.now();
|
|
17037
17504
|
if (now > result.deleteAt) {
|
|
17038
17505
|
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
@@ -17086,6 +17553,12 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
17086
17553
|
}
|
|
17087
17554
|
if (revalidationResponseUpdatesCacheControl(headers2)) {
|
|
17088
17555
|
deleteCachedValue(globalOpts.store, cacheKey);
|
|
17556
|
+
} else if (revalidationResponseAddsVary(result, headers2.vary ? parseVaryHeader(headers2.vary, opts.headers) : undefined)) {
|
|
17557
|
+
if (util.isStream(result.body)) {
|
|
17558
|
+
result.body.on("error", nop).destroy();
|
|
17559
|
+
}
|
|
17560
|
+
deleteCachedValue(globalOpts.store, cacheKey);
|
|
17561
|
+
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
17089
17562
|
}
|
|
17090
17563
|
}
|
|
17091
17564
|
sendCachedValue(handler, opts, result, age, context, stale);
|
|
@@ -17132,25 +17605,23 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
17132
17605
|
safeMethodsToNotCache.push(method);
|
|
17133
17606
|
}
|
|
17134
17607
|
}
|
|
17135
|
-
return (dispatch) => {
|
|
17608
|
+
return (dispatch, interceptorOrigin) => {
|
|
17136
17609
|
return (opts2, handler) => {
|
|
17137
|
-
|
|
17610
|
+
const requestOrigin = getInterceptorOrigin(opts2, interceptorOrigin);
|
|
17611
|
+
if (!requestOrigin || arrayIncludes(safeMethodsToNotCache, opts2.method)) {
|
|
17138
17612
|
return dispatch(opts2, handler);
|
|
17139
17613
|
}
|
|
17140
17614
|
if (origins !== undefined) {
|
|
17141
|
-
|
|
17142
|
-
return dispatch(opts2, handler);
|
|
17143
|
-
}
|
|
17144
|
-
const requestOrigin = opts2.origin.toString().toLowerCase();
|
|
17615
|
+
const normalizedRequestOrigin = requestOrigin.toString().toLowerCase();
|
|
17145
17616
|
let isAllowed = false;
|
|
17146
17617
|
for (let i = 0;i < origins.length; i++) {
|
|
17147
17618
|
const allowed = origins[i];
|
|
17148
17619
|
if (typeof allowed === "string") {
|
|
17149
|
-
if (allowed.toLowerCase() ===
|
|
17620
|
+
if (allowed.toLowerCase() === normalizedRequestOrigin) {
|
|
17150
17621
|
isAllowed = true;
|
|
17151
17622
|
break;
|
|
17152
17623
|
}
|
|
17153
|
-
} else if (allowed.test(
|
|
17624
|
+
} else if (allowed.test(normalizedRequestOrigin)) {
|
|
17154
17625
|
isAllowed = true;
|
|
17155
17626
|
break;
|
|
17156
17627
|
}
|
|
@@ -17167,7 +17638,10 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
17167
17638
|
if (reqCacheControl?.["no-store"]) {
|
|
17168
17639
|
return dispatch(opts2, handler);
|
|
17169
17640
|
}
|
|
17170
|
-
const cacheKey = makeCacheKey(opts2);
|
|
17641
|
+
const cacheKey = makeCacheKey(opts2, requestOrigin);
|
|
17642
|
+
if (!arrayIncludes(util.safeHTTPMethods, opts2.method)) {
|
|
17643
|
+
return dispatch(opts2, new CacheHandler(globalOpts, cacheKey, handler));
|
|
17644
|
+
}
|
|
17171
17645
|
const result = store.get(cacheKey);
|
|
17172
17646
|
if (result && typeof result.then === "function") {
|
|
17173
17647
|
return result.then((result2) => handleResult(dispatch, globalOpts, cacheKey, handler, opts2, reqCacheControl, result2));
|
|
@@ -17182,9 +17656,67 @@ var require_cache2 = __commonJS(function(exports, module) {
|
|
|
17182
17656
|
// ../../node_modules/undici/lib/interceptor/decompress.js
|
|
17183
17657
|
var require_decompress = __commonJS(function(exports, module) {
|
|
17184
17658
|
var { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = __require("node:zlib");
|
|
17185
|
-
var { pipeline } = __require("node:stream");
|
|
17659
|
+
var { pipeline, Transform: TransformStream2 } = __require("node:stream");
|
|
17660
|
+
var { InvalidArgumentError, ResponseExceededMaxSizeError } = require_errors();
|
|
17186
17661
|
var DecoratorHandler = require_decorator_handler();
|
|
17662
|
+
|
|
17663
|
+
class DecompressController {
|
|
17664
|
+
#onPause;
|
|
17665
|
+
#onResume;
|
|
17666
|
+
#onAbort;
|
|
17667
|
+
#paused = false;
|
|
17668
|
+
constructor(onPause, onResume, onAbort) {
|
|
17669
|
+
this.#onPause = onPause;
|
|
17670
|
+
this.#onResume = onResume;
|
|
17671
|
+
this.#onAbort = onAbort;
|
|
17672
|
+
this.target = null;
|
|
17673
|
+
}
|
|
17674
|
+
pause() {
|
|
17675
|
+
if (this.#paused) {
|
|
17676
|
+
return;
|
|
17677
|
+
}
|
|
17678
|
+
this.#paused = true;
|
|
17679
|
+
this.#onPause();
|
|
17680
|
+
}
|
|
17681
|
+
resume() {
|
|
17682
|
+
if (!this.#paused) {
|
|
17683
|
+
return;
|
|
17684
|
+
}
|
|
17685
|
+
this.#paused = false;
|
|
17686
|
+
this.#onResume();
|
|
17687
|
+
}
|
|
17688
|
+
abort(reason) {
|
|
17689
|
+
this.target?.abort(reason);
|
|
17690
|
+
this.#onAbort(reason);
|
|
17691
|
+
}
|
|
17692
|
+
get paused() {
|
|
17693
|
+
return this.#paused;
|
|
17694
|
+
}
|
|
17695
|
+
get aborted() {
|
|
17696
|
+
return this.target?.aborted ?? false;
|
|
17697
|
+
}
|
|
17698
|
+
get reason() {
|
|
17699
|
+
return this.target?.reason ?? null;
|
|
17700
|
+
}
|
|
17701
|
+
get rawHeaders() {
|
|
17702
|
+
return this.target?.rawHeaders ?? null;
|
|
17703
|
+
}
|
|
17704
|
+
set rawHeaders(value) {
|
|
17705
|
+
if (this.target) {
|
|
17706
|
+
this.target.rawHeaders = value;
|
|
17707
|
+
}
|
|
17708
|
+
}
|
|
17709
|
+
get rawTrailers() {
|
|
17710
|
+
return this.target?.rawTrailers ?? null;
|
|
17711
|
+
}
|
|
17712
|
+
set rawTrailers(value) {
|
|
17713
|
+
if (this.target) {
|
|
17714
|
+
this.target.rawTrailers = value;
|
|
17715
|
+
}
|
|
17716
|
+
}
|
|
17717
|
+
}
|
|
17187
17718
|
var supportedEncodings = {
|
|
17719
|
+
__proto__: null,
|
|
17188
17720
|
gzip: createGunzip,
|
|
17189
17721
|
"x-gzip": createGunzip,
|
|
17190
17722
|
br: createBrotliDecompress,
|
|
@@ -17194,6 +17726,21 @@ var require_decompress = __commonJS(function(exports, module) {
|
|
|
17194
17726
|
zstd: createZstdDecompress
|
|
17195
17727
|
};
|
|
17196
17728
|
var defaultSkipStatusCodes = [204, 304];
|
|
17729
|
+
var defaultMaxSize = 0;
|
|
17730
|
+
function createMaxSizeLimiter(maxSize) {
|
|
17731
|
+
let size = 0;
|
|
17732
|
+
return new TransformStream2({
|
|
17733
|
+
transform(chunk, _encoding, callback) {
|
|
17734
|
+
const decompressedSize = size + chunk.length;
|
|
17735
|
+
if (decompressedSize > maxSize) {
|
|
17736
|
+
callback(new ResponseExceededMaxSizeError(`Decompressed response size (${decompressedSize}) exceeded maxSize (${maxSize})`));
|
|
17737
|
+
return;
|
|
17738
|
+
}
|
|
17739
|
+
size = decompressedSize;
|
|
17740
|
+
callback(null, chunk);
|
|
17741
|
+
}
|
|
17742
|
+
});
|
|
17743
|
+
}
|
|
17197
17744
|
var warningEmitted = false;
|
|
17198
17745
|
|
|
17199
17746
|
class DecompressHandler extends DecoratorHandler {
|
|
@@ -17201,10 +17748,105 @@ var require_decompress = __commonJS(function(exports, module) {
|
|
|
17201
17748
|
#trailers;
|
|
17202
17749
|
#skipStatusCodes;
|
|
17203
17750
|
#skipErrorResponses;
|
|
17204
|
-
|
|
17751
|
+
#maxSize;
|
|
17752
|
+
#decompressedSize = 0;
|
|
17753
|
+
#terminated = false;
|
|
17754
|
+
#inputEnded = false;
|
|
17755
|
+
#inputBackpressured = false;
|
|
17756
|
+
#upstreamPaused = false;
|
|
17757
|
+
#draining = false;
|
|
17758
|
+
#drainRequested = false;
|
|
17759
|
+
#completionPending = false;
|
|
17760
|
+
#finalDecompressor;
|
|
17761
|
+
#controller;
|
|
17762
|
+
constructor(handler, { skipStatusCodes = defaultSkipStatusCodes, skipErrorResponses = true, maxSize = defaultMaxSize } = {}) {
|
|
17763
|
+
if (!Number.isSafeInteger(maxSize) || maxSize < 0) {
|
|
17764
|
+
throw new InvalidArgumentError("maxSize must be a non-negative integer");
|
|
17765
|
+
}
|
|
17205
17766
|
super(handler);
|
|
17206
17767
|
this.#skipStatusCodes = skipStatusCodes;
|
|
17207
17768
|
this.#skipErrorResponses = skipErrorResponses;
|
|
17769
|
+
this.#maxSize = maxSize;
|
|
17770
|
+
this.#controller = new DecompressController(() => this.#onDownstreamPause(), () => this.#onDownstreamResume(), (reason) => {
|
|
17771
|
+
if (this.#inputEnded && !this.#terminated) {
|
|
17772
|
+
this.onResponseError(this.#controller, reason);
|
|
17773
|
+
}
|
|
17774
|
+
});
|
|
17775
|
+
}
|
|
17776
|
+
#onDownstreamPause() {
|
|
17777
|
+
this.#pauseUpstream();
|
|
17778
|
+
}
|
|
17779
|
+
#onDownstreamResume() {
|
|
17780
|
+
const drainWasDeferred = this.#draining;
|
|
17781
|
+
this.#drainOutput();
|
|
17782
|
+
if (!drainWasDeferred) {
|
|
17783
|
+
this.#resumeUpstreamIfNeeded();
|
|
17784
|
+
this.#finishIfReady();
|
|
17785
|
+
}
|
|
17786
|
+
}
|
|
17787
|
+
#pauseUpstream() {
|
|
17788
|
+
if (!this.#upstreamPaused && !this.#terminated) {
|
|
17789
|
+
this.#upstreamPaused = true;
|
|
17790
|
+
this.#controller.target?.pause();
|
|
17791
|
+
}
|
|
17792
|
+
}
|
|
17793
|
+
#resumeUpstreamIfNeeded() {
|
|
17794
|
+
if (this.#upstreamPaused && !this.#controller.paused && !this.#inputBackpressured) {
|
|
17795
|
+
this.#upstreamPaused = false;
|
|
17796
|
+
if (!this.#inputEnded) {
|
|
17797
|
+
this.#controller.target?.resume();
|
|
17798
|
+
}
|
|
17799
|
+
}
|
|
17800
|
+
}
|
|
17801
|
+
#drainOutput() {
|
|
17802
|
+
if (this.#terminated || this.#controller.paused || !this.#finalDecompressor) {
|
|
17803
|
+
return;
|
|
17804
|
+
}
|
|
17805
|
+
if (this.#draining) {
|
|
17806
|
+
this.#drainRequested = true;
|
|
17807
|
+
return;
|
|
17808
|
+
}
|
|
17809
|
+
this.#draining = true;
|
|
17810
|
+
try {
|
|
17811
|
+
do {
|
|
17812
|
+
this.#drainRequested = false;
|
|
17813
|
+
let chunk;
|
|
17814
|
+
while (!this.#terminated && !this.#controller.paused && (chunk = this.#finalDecompressor.read()) !== null) {
|
|
17815
|
+
if (this.#maxSize > 0) {
|
|
17816
|
+
const decompressedSize = this.#decompressedSize + chunk.length;
|
|
17817
|
+
if (decompressedSize > this.#maxSize) {
|
|
17818
|
+
this.#fail(new ResponseExceededMaxSizeError(`Decompressed response size (${decompressedSize}) exceeded maxSize (${this.#maxSize})`));
|
|
17819
|
+
return;
|
|
17820
|
+
}
|
|
17821
|
+
this.#decompressedSize = decompressedSize;
|
|
17822
|
+
}
|
|
17823
|
+
const result = super.onResponseData(this.#controller, chunk);
|
|
17824
|
+
if (result === false && !this.#controller.paused) {
|
|
17825
|
+
this.#controller.pause();
|
|
17826
|
+
}
|
|
17827
|
+
}
|
|
17828
|
+
} while (this.#drainRequested && !this.#terminated && !this.#controller.paused);
|
|
17829
|
+
} finally {
|
|
17830
|
+
this.#draining = false;
|
|
17831
|
+
}
|
|
17832
|
+
this.#resumeUpstreamIfNeeded();
|
|
17833
|
+
this.#finishIfReady();
|
|
17834
|
+
}
|
|
17835
|
+
#finishIfReady() {
|
|
17836
|
+
if (this.#terminated || !this.#completionPending || this.#controller.paused || this.#draining) {
|
|
17837
|
+
return;
|
|
17838
|
+
}
|
|
17839
|
+
this.#terminated = true;
|
|
17840
|
+
this.#cleanupDecompressors();
|
|
17841
|
+
super.onResponseEnd(this.#controller, this.#trailers);
|
|
17842
|
+
}
|
|
17843
|
+
#onDecompressionEnd() {
|
|
17844
|
+
if (this.#terminated) {
|
|
17845
|
+
return;
|
|
17846
|
+
}
|
|
17847
|
+
this.#completionPending = true;
|
|
17848
|
+
this.#drainOutput();
|
|
17849
|
+
this.#finishIfReady();
|
|
17208
17850
|
}
|
|
17209
17851
|
#shouldSkipDecompression(contentEncoding, statusCode) {
|
|
17210
17852
|
if (!contentEncoding || statusCode < 200)
|
|
@@ -17232,57 +17874,91 @@ var require_decompress = __commonJS(function(exports, module) {
|
|
|
17232
17874
|
}
|
|
17233
17875
|
decompressors.push(supportedEncodings[encoding]());
|
|
17234
17876
|
}
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
break;
|
|
17244
|
-
}
|
|
17877
|
+
if (decompressors.length < 2) {
|
|
17878
|
+
return decompressors;
|
|
17879
|
+
}
|
|
17880
|
+
const streams = [];
|
|
17881
|
+
for (let i = 0;i < decompressors.length; i++) {
|
|
17882
|
+
streams.push(decompressors[i]);
|
|
17883
|
+
if (i < decompressors.length - 1 && this.#maxSize > 0) {
|
|
17884
|
+
streams.push(createMaxSizeLimiter(this.#maxSize));
|
|
17245
17885
|
}
|
|
17246
|
-
}
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17886
|
+
}
|
|
17887
|
+
return streams;
|
|
17888
|
+
}
|
|
17889
|
+
#fail(error) {
|
|
17890
|
+
if (this.#terminated) {
|
|
17891
|
+
return;
|
|
17892
|
+
}
|
|
17893
|
+
if (this.#inputEnded) {
|
|
17894
|
+
this.onResponseError(this.#controller, error);
|
|
17895
|
+
} else {
|
|
17896
|
+
this.#controller.abort(error);
|
|
17897
|
+
}
|
|
17898
|
+
}
|
|
17899
|
+
#setupDecompressorEvents(decompressor) {
|
|
17900
|
+
this.#finalDecompressor = decompressor;
|
|
17901
|
+
decompressor.on("readable", () => this.#drainOutput());
|
|
17902
|
+
decompressor.on("error", (error) => this.#fail(error));
|
|
17250
17903
|
}
|
|
17251
|
-
#setupSingleDecompressor(
|
|
17904
|
+
#setupSingleDecompressor() {
|
|
17252
17905
|
const decompressor = this.#decompressors[0];
|
|
17253
|
-
this.#setupDecompressorEvents(decompressor
|
|
17254
|
-
decompressor.on("end", () =>
|
|
17255
|
-
super.onResponseEnd(controller, this.#trailers);
|
|
17256
|
-
});
|
|
17906
|
+
this.#setupDecompressorEvents(decompressor);
|
|
17907
|
+
decompressor.on("end", () => this.#onDecompressionEnd());
|
|
17257
17908
|
}
|
|
17258
|
-
#setupMultipleDecompressors(
|
|
17909
|
+
#setupMultipleDecompressors() {
|
|
17259
17910
|
const lastDecompressor = this.#decompressors[this.#decompressors.length - 1];
|
|
17260
|
-
this.#setupDecompressorEvents(lastDecompressor
|
|
17911
|
+
this.#setupDecompressorEvents(lastDecompressor);
|
|
17261
17912
|
pipeline(this.#decompressors, (err) => {
|
|
17913
|
+
if (this.#terminated) {
|
|
17914
|
+
return;
|
|
17915
|
+
}
|
|
17262
17916
|
if (err) {
|
|
17263
|
-
|
|
17917
|
+
this.#fail(err);
|
|
17918
|
+
return;
|
|
17919
|
+
}
|
|
17920
|
+
this.#onDecompressionEnd();
|
|
17921
|
+
});
|
|
17922
|
+
}
|
|
17923
|
+
#setupInputBackpressure() {
|
|
17924
|
+
const decompressor = this.#decompressors[0];
|
|
17925
|
+
decompressor.on("drain", () => {
|
|
17926
|
+
if (this.#terminated) {
|
|
17264
17927
|
return;
|
|
17265
17928
|
}
|
|
17266
|
-
|
|
17929
|
+
this.#inputBackpressured = false;
|
|
17930
|
+
if (!this.#controller.paused) {
|
|
17931
|
+
this.#drainOutput();
|
|
17932
|
+
this.#resumeUpstreamIfNeeded();
|
|
17933
|
+
}
|
|
17267
17934
|
});
|
|
17268
17935
|
}
|
|
17269
17936
|
#cleanupDecompressors() {
|
|
17270
17937
|
this.#decompressors.length = 0;
|
|
17938
|
+
this.#finalDecompressor = undefined;
|
|
17939
|
+
}
|
|
17940
|
+
onRequestStart(controller, context) {
|
|
17941
|
+
this.#controller.target = controller;
|
|
17942
|
+
return super.onRequestStart(this.#controller, context);
|
|
17943
|
+
}
|
|
17944
|
+
onRequestUpgrade(controller, statusCode, headers, socket) {
|
|
17945
|
+
return super.onRequestUpgrade(this.#controller, statusCode, headers, socket);
|
|
17271
17946
|
}
|
|
17272
17947
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
17273
|
-
const
|
|
17948
|
+
const rawContentEncoding = headers["content-encoding"];
|
|
17949
|
+
const contentEncoding = Array.isArray(rawContentEncoding) ? rawContentEncoding.join(",") : rawContentEncoding;
|
|
17274
17950
|
if (this.#shouldSkipDecompression(contentEncoding, statusCode)) {
|
|
17275
|
-
return super.onResponseStart(controller, statusCode, headers, statusMessage);
|
|
17951
|
+
return super.onResponseStart(this.#controller, statusCode, headers, statusMessage);
|
|
17276
17952
|
}
|
|
17277
17953
|
const decompressors = this.#createDecompressionChain(contentEncoding.toLowerCase());
|
|
17278
17954
|
if (decompressors.length === 0) {
|
|
17279
17955
|
this.#cleanupDecompressors();
|
|
17280
|
-
return super.onResponseStart(controller, statusCode, headers, statusMessage);
|
|
17956
|
+
return super.onResponseStart(this.#controller, statusCode, headers, statusMessage);
|
|
17281
17957
|
}
|
|
17282
17958
|
this.#decompressors = decompressors;
|
|
17283
17959
|
const { "content-encoding": _, "content-length": __, ...newHeaders } = headers;
|
|
17284
|
-
if (controller
|
|
17285
|
-
const rawHeaders = controller.rawHeaders;
|
|
17960
|
+
if (this.#controller.rawHeaders) {
|
|
17961
|
+
const rawHeaders = this.#controller.rawHeaders;
|
|
17286
17962
|
if (Array.isArray(rawHeaders)) {
|
|
17287
17963
|
const filteredHeaders = [];
|
|
17288
17964
|
for (let i = 0;i < rawHeaders.length; i += 2) {
|
|
@@ -17294,7 +17970,7 @@ var require_decompress = __commonJS(function(exports, module) {
|
|
|
17294
17970
|
}
|
|
17295
17971
|
filteredHeaders.push(rawHeaders[i], rawHeaders[i + 1]);
|
|
17296
17972
|
}
|
|
17297
|
-
|
|
17973
|
+
rawHeaders.splice(0, rawHeaders.length, ...filteredHeaders);
|
|
17298
17974
|
} else if (typeof rawHeaders === "object") {
|
|
17299
17975
|
for (const name of Object.keys(rawHeaders)) {
|
|
17300
17976
|
const lowerName = name.toLowerCase();
|
|
@@ -17304,37 +17980,43 @@ var require_decompress = __commonJS(function(exports, module) {
|
|
|
17304
17980
|
}
|
|
17305
17981
|
}
|
|
17306
17982
|
}
|
|
17983
|
+
this.#setupInputBackpressure();
|
|
17307
17984
|
if (this.#decompressors.length === 1) {
|
|
17308
|
-
this.#setupSingleDecompressor(
|
|
17985
|
+
this.#setupSingleDecompressor();
|
|
17309
17986
|
} else {
|
|
17310
|
-
this.#setupMultipleDecompressors(
|
|
17987
|
+
this.#setupMultipleDecompressors();
|
|
17311
17988
|
}
|
|
17312
|
-
return super.onResponseStart(controller, statusCode, newHeaders, statusMessage);
|
|
17989
|
+
return super.onResponseStart(this.#controller, statusCode, newHeaders, statusMessage);
|
|
17313
17990
|
}
|
|
17314
17991
|
onResponseData(controller, chunk) {
|
|
17315
17992
|
if (this.#decompressors.length > 0) {
|
|
17316
|
-
this.#decompressors[0].write(chunk)
|
|
17993
|
+
if (!this.#decompressors[0].write(chunk)) {
|
|
17994
|
+
this.#inputBackpressured = true;
|
|
17995
|
+
this.#pauseUpstream();
|
|
17996
|
+
}
|
|
17317
17997
|
return;
|
|
17318
17998
|
}
|
|
17319
|
-
super.onResponseData(controller, chunk);
|
|
17999
|
+
return super.onResponseData(this.#controller, chunk);
|
|
17320
18000
|
}
|
|
17321
18001
|
onResponseEnd(controller, trailers) {
|
|
17322
18002
|
if (this.#decompressors.length > 0) {
|
|
18003
|
+
this.#inputEnded = true;
|
|
17323
18004
|
this.#trailers = trailers;
|
|
17324
18005
|
this.#decompressors[0].end();
|
|
17325
|
-
this.#cleanupDecompressors();
|
|
17326
18006
|
return;
|
|
17327
18007
|
}
|
|
17328
|
-
super.onResponseEnd(controller, trailers);
|
|
18008
|
+
return super.onResponseEnd(this.#controller, trailers);
|
|
17329
18009
|
}
|
|
17330
18010
|
onResponseError(controller, err) {
|
|
17331
|
-
if (this.#
|
|
17332
|
-
|
|
17333
|
-
decompressor.destroy(err);
|
|
17334
|
-
}
|
|
17335
|
-
this.#cleanupDecompressors();
|
|
18011
|
+
if (this.#terminated) {
|
|
18012
|
+
return;
|
|
17336
18013
|
}
|
|
17337
|
-
|
|
18014
|
+
this.#terminated = true;
|
|
18015
|
+
for (const decompressor of this.#decompressors) {
|
|
18016
|
+
decompressor.destroy();
|
|
18017
|
+
}
|
|
18018
|
+
this.#cleanupDecompressors();
|
|
18019
|
+
super.onResponseError(this.#controller, err);
|
|
17338
18020
|
}
|
|
17339
18021
|
}
|
|
17340
18022
|
function createDecompressInterceptor(options = {}) {
|
|
@@ -17461,8 +18143,9 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17461
18143
|
if (this.#aborted || this.#completed) {
|
|
17462
18144
|
return;
|
|
17463
18145
|
}
|
|
17464
|
-
this.#
|
|
18146
|
+
this.#cleanup();
|
|
17465
18147
|
this.#primaryHandler.onResponseEnd?.(controller, trailers);
|
|
18148
|
+
this.#completed = true;
|
|
17466
18149
|
for (const waitingHandler of this.#waitingHandlers) {
|
|
17467
18150
|
if (waitingHandler.done || waitingHandler.controller.aborted) {
|
|
17468
18151
|
waitingHandler.done = true;
|
|
@@ -17473,17 +18156,18 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17473
18156
|
waitingHandler.done = true;
|
|
17474
18157
|
continue;
|
|
17475
18158
|
}
|
|
17476
|
-
if (waitingHandler.controller.paused
|
|
18159
|
+
if (waitingHandler.controller.paused) {
|
|
17477
18160
|
waitingHandler.pendingTrailers = trailers;
|
|
17478
18161
|
continue;
|
|
17479
18162
|
}
|
|
17480
18163
|
try {
|
|
17481
18164
|
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, trailers);
|
|
17482
|
-
} catch {
|
|
18165
|
+
} catch (err) {
|
|
18166
|
+
this.#errorWaitingHandler(waitingHandler, err);
|
|
18167
|
+
}
|
|
17483
18168
|
waitingHandler.done = true;
|
|
17484
18169
|
}
|
|
17485
18170
|
this.#pruneDoneWaitingHandlers();
|
|
17486
|
-
this.#onComplete?.();
|
|
17487
18171
|
}
|
|
17488
18172
|
onResponseError(controller, err) {
|
|
17489
18173
|
if (this.#completed) {
|
|
@@ -17491,12 +18175,17 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17491
18175
|
}
|
|
17492
18176
|
this.#aborted = true;
|
|
17493
18177
|
this.#completed = true;
|
|
18178
|
+
this.#cleanup();
|
|
17494
18179
|
this.#primaryHandler.onResponseError?.(controller, err);
|
|
17495
18180
|
for (const waitingHandler of this.#waitingHandlers) {
|
|
17496
18181
|
this.#errorWaitingHandler(waitingHandler, err);
|
|
17497
18182
|
}
|
|
17498
18183
|
this.#waitingHandlers = [];
|
|
17499
|
-
|
|
18184
|
+
}
|
|
18185
|
+
#cleanup() {
|
|
18186
|
+
const onComplete = this.#onComplete;
|
|
18187
|
+
this.#onComplete = null;
|
|
18188
|
+
onComplete?.();
|
|
17500
18189
|
}
|
|
17501
18190
|
#createWaitingHandler(handler) {
|
|
17502
18191
|
const waitingHandler = {
|
|
@@ -17522,7 +18211,9 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17522
18211
|
if (this.#completed && waitingHandler.pendingTrailers && waitingHandler.bufferedChunks.length === 0 && !state.paused && !state.aborted) {
|
|
17523
18212
|
try {
|
|
17524
18213
|
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, waitingHandler.pendingTrailers);
|
|
17525
|
-
} catch {
|
|
18214
|
+
} catch (err) {
|
|
18215
|
+
this.#errorWaitingHandler(waitingHandler, err);
|
|
18216
|
+
}
|
|
17526
18217
|
waitingHandler.pendingTrailers = null;
|
|
17527
18218
|
waitingHandler.done = true;
|
|
17528
18219
|
}
|
|
@@ -17543,12 +18234,18 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17543
18234
|
return state.reason;
|
|
17544
18235
|
},
|
|
17545
18236
|
abort: (reason) => {
|
|
18237
|
+
if (state.aborted) {
|
|
18238
|
+
return;
|
|
18239
|
+
}
|
|
17546
18240
|
state.aborted = true;
|
|
17547
18241
|
state.reason = reason ?? null;
|
|
17548
18242
|
waitingHandler.done = true;
|
|
17549
18243
|
waitingHandler.pendingTrailers = null;
|
|
17550
18244
|
waitingHandler.bufferedChunks = [];
|
|
17551
18245
|
waitingHandler.bufferedBytes = 0;
|
|
18246
|
+
try {
|
|
18247
|
+
handler.onResponseError?.(waitingHandler.controller, state.reason ?? new RequestAbortedError);
|
|
18248
|
+
} catch {}
|
|
17552
18249
|
}
|
|
17553
18250
|
};
|
|
17554
18251
|
return waitingHandler;
|
|
@@ -17565,7 +18262,7 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17565
18262
|
waitingHandler.bufferedBytes += bufferedChunk.length;
|
|
17566
18263
|
if (waitingHandler.bufferedBytes > this.#maxBufferSize) {
|
|
17567
18264
|
const err = new RequestAbortedError(`Deduplicated waiting handler exceeded maxBufferSize (${this.#maxBufferSize} bytes) while paused`);
|
|
17568
|
-
|
|
18265
|
+
waitingHandler.controller.abort(err);
|
|
17569
18266
|
}
|
|
17570
18267
|
}
|
|
17571
18268
|
#flushWaitingHandler(waitingHandler) {
|
|
@@ -17594,7 +18291,6 @@ var require_deduplication_handler = __commonJS(function(exports, module) {
|
|
|
17594
18291
|
waitingHandler.bufferedChunks = [];
|
|
17595
18292
|
waitingHandler.bufferedBytes = 0;
|
|
17596
18293
|
try {
|
|
17597
|
-
waitingHandler.controller.abort(err);
|
|
17598
18294
|
waitingHandler.handler.onResponseError?.(waitingHandler.controller, err);
|
|
17599
18295
|
} catch {}
|
|
17600
18296
|
}
|
|
@@ -17610,7 +18306,7 @@ var require_deduplicate = __commonJS(function(exports, module) {
|
|
|
17610
18306
|
var diagnosticsChannel = __require("node:diagnostics_channel");
|
|
17611
18307
|
var util = require_util();
|
|
17612
18308
|
var DeduplicationHandler = require_deduplication_handler();
|
|
17613
|
-
var { normalizeHeaders, makeCacheKey, makeDeduplicationKey } = require_cache();
|
|
18309
|
+
var { getInterceptorOrigin, normalizeHeaders, makeCacheKey, makeDeduplicationKey } = require_cache();
|
|
17614
18310
|
var pendingRequestsChannel = diagnosticsChannel.channel("undici:request:pending-requests");
|
|
17615
18311
|
module.exports = (opts = {}) => {
|
|
17616
18312
|
const {
|
|
@@ -17642,9 +18338,10 @@ var require_deduplicate = __commonJS(function(exports, module) {
|
|
|
17642
18338
|
const skipHeaderNamesSet = new Set(skipHeaderNames.map((name) => name.toLowerCase()));
|
|
17643
18339
|
const excludeHeaderNamesSet = new Set(excludeHeaderNames.map((name) => name.toLowerCase()));
|
|
17644
18340
|
const pendingRequests = new Map;
|
|
17645
|
-
return (dispatch) => {
|
|
18341
|
+
return (dispatch, interceptorOrigin) => {
|
|
17646
18342
|
return (opts2, handler) => {
|
|
17647
|
-
|
|
18343
|
+
const requestOrigin = getInterceptorOrigin(opts2, interceptorOrigin);
|
|
18344
|
+
if (!requestOrigin || opts2.upgrade || methods.includes(opts2.method) === false) {
|
|
17648
18345
|
return dispatch(opts2, handler);
|
|
17649
18346
|
}
|
|
17650
18347
|
opts2 = {
|
|
@@ -17658,7 +18355,7 @@ var require_deduplicate = __commonJS(function(exports, module) {
|
|
|
17658
18355
|
}
|
|
17659
18356
|
}
|
|
17660
18357
|
}
|
|
17661
|
-
const cacheKey = makeCacheKey(opts2);
|
|
18358
|
+
const cacheKey = makeCacheKey(opts2, requestOrigin);
|
|
17662
18359
|
const dedupeKey = makeDeduplicationKey(cacheKey, excludeHeaderNamesSet);
|
|
17663
18360
|
const pendingHandler = pendingRequests.get(dedupeKey);
|
|
17664
18361
|
if (pendingHandler) {
|
|
@@ -18196,6 +18893,10 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18196
18893
|
}
|
|
18197
18894
|
}
|
|
18198
18895
|
}
|
|
18896
|
+
var getHeadersGuard;
|
|
18897
|
+
var setHeadersGuard;
|
|
18898
|
+
var getHeadersList;
|
|
18899
|
+
var setHeadersList;
|
|
18199
18900
|
|
|
18200
18901
|
class Headers {
|
|
18201
18902
|
#guard;
|
|
@@ -18213,7 +18914,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18213
18914
|
}
|
|
18214
18915
|
}
|
|
18215
18916
|
append(name, value) {
|
|
18216
|
-
webidl.brandCheck(this, Headers);
|
|
18917
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18217
18918
|
webidl.argumentLengthCheck(arguments, 2, "Headers.append");
|
|
18218
18919
|
const prefix = "Headers.append";
|
|
18219
18920
|
name = webidl.converters.ByteString(name, prefix, "name");
|
|
@@ -18221,7 +18922,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18221
18922
|
return appendHeader(this, name, value);
|
|
18222
18923
|
}
|
|
18223
18924
|
delete(name) {
|
|
18224
|
-
webidl.brandCheck(this, Headers);
|
|
18925
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18225
18926
|
webidl.argumentLengthCheck(arguments, 1, "Headers.delete");
|
|
18226
18927
|
const prefix = "Headers.delete";
|
|
18227
18928
|
name = webidl.converters.ByteString(name, prefix, "name");
|
|
@@ -18241,7 +18942,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18241
18942
|
this.#headersList.delete(name, false);
|
|
18242
18943
|
}
|
|
18243
18944
|
get(name) {
|
|
18244
|
-
webidl.brandCheck(this, Headers);
|
|
18945
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18245
18946
|
webidl.argumentLengthCheck(arguments, 1, "Headers.get");
|
|
18246
18947
|
const prefix = "Headers.get";
|
|
18247
18948
|
name = webidl.converters.ByteString(name, prefix, "name");
|
|
@@ -18255,7 +18956,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18255
18956
|
return this.#headersList.get(name, false);
|
|
18256
18957
|
}
|
|
18257
18958
|
has(name) {
|
|
18258
|
-
webidl.brandCheck(this, Headers);
|
|
18959
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18259
18960
|
webidl.argumentLengthCheck(arguments, 1, "Headers.has");
|
|
18260
18961
|
const prefix = "Headers.has";
|
|
18261
18962
|
name = webidl.converters.ByteString(name, prefix, "name");
|
|
@@ -18269,7 +18970,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18269
18970
|
return this.#headersList.contains(name, false);
|
|
18270
18971
|
}
|
|
18271
18972
|
set(name, value) {
|
|
18272
|
-
webidl.brandCheck(this, Headers);
|
|
18973
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18273
18974
|
webidl.argumentLengthCheck(arguments, 2, "Headers.set");
|
|
18274
18975
|
const prefix = "Headers.set";
|
|
18275
18976
|
name = webidl.converters.ByteString(name, prefix, "name");
|
|
@@ -18294,7 +18995,7 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18294
18995
|
this.#headersList.set(name, value, false);
|
|
18295
18996
|
}
|
|
18296
18997
|
getSetCookie() {
|
|
18297
|
-
webidl.brandCheck(this, Headers);
|
|
18998
|
+
webidl.brandCheck(this, webidl.is.Headers);
|
|
18298
18999
|
const list = this.#headersList.cookies;
|
|
18299
19000
|
if (list) {
|
|
18300
19001
|
return [...list];
|
|
@@ -18305,25 +19006,21 @@ var require_headers = __commonJS(function(exports, module) {
|
|
|
18305
19006
|
options.depth ??= depth;
|
|
18306
19007
|
return `Headers ${util.formatWithOptions(options, this.#headersList.entries)}`;
|
|
18307
19008
|
}
|
|
18308
|
-
static
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
19009
|
+
static {
|
|
19010
|
+
getHeadersGuard = (headers) => headers.#guard;
|
|
19011
|
+
setHeadersGuard = (headers, guard) => {
|
|
19012
|
+
headers.#guard = guard;
|
|
19013
|
+
};
|
|
19014
|
+
getHeadersList = (headers) => headers.#headersList;
|
|
19015
|
+
setHeadersList = (target, list) => {
|
|
19016
|
+
target.#headersList = list;
|
|
19017
|
+
};
|
|
19018
|
+
webidl.is.Headers = (arg) => {
|
|
19019
|
+
return arg != null && typeof arg === "object" && #guard in arg;
|
|
19020
|
+
};
|
|
18319
19021
|
}
|
|
18320
19022
|
}
|
|
18321
|
-
|
|
18322
|
-
Reflect.deleteProperty(Headers, "getHeadersGuard");
|
|
18323
|
-
Reflect.deleteProperty(Headers, "setHeadersGuard");
|
|
18324
|
-
Reflect.deleteProperty(Headers, "getHeadersList");
|
|
18325
|
-
Reflect.deleteProperty(Headers, "setHeadersList");
|
|
18326
|
-
iteratorMixin("Headers", Headers, headersListSortAndCombine, 0, 1);
|
|
19023
|
+
iteratorMixin("Headers", Headers, headersListSortAndCombine, 0, 1, webidl.is.Headers);
|
|
18327
19024
|
Object.defineProperties(Headers.prototype, {
|
|
18328
19025
|
append: kEnumerableProperty,
|
|
18329
19026
|
delete: kEnumerableProperty,
|
|
@@ -18394,6 +19091,10 @@ var require_response = __commonJS(function(exports, module) {
|
|
|
18394
19091
|
var assert = __require("node:assert");
|
|
18395
19092
|
var { isomorphicEncode, serializeJavascriptValueToJSONString } = require_infra();
|
|
18396
19093
|
var textEncoder = new TextEncoder("utf-8");
|
|
19094
|
+
var getResponseHeaders;
|
|
19095
|
+
var setResponseHeaders;
|
|
19096
|
+
var getResponseState;
|
|
19097
|
+
var setResponseState;
|
|
18397
19098
|
|
|
18398
19099
|
class Response {
|
|
18399
19100
|
#headers;
|
|
@@ -18451,11 +19152,11 @@ var require_response = __commonJS(function(exports, module) {
|
|
|
18451
19152
|
initializeResponse(this, init, bodyWithType);
|
|
18452
19153
|
}
|
|
18453
19154
|
get type() {
|
|
18454
|
-
webidl.brandCheck(this, Response);
|
|
19155
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18455
19156
|
return this.#state.type;
|
|
18456
19157
|
}
|
|
18457
19158
|
get url() {
|
|
18458
|
-
webidl.brandCheck(this, Response);
|
|
19159
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18459
19160
|
const urlList = this.#state.urlList;
|
|
18460
19161
|
const url = urlList[urlList.length - 1] ?? null;
|
|
18461
19162
|
if (url === null) {
|
|
@@ -18464,35 +19165,35 @@ var require_response = __commonJS(function(exports, module) {
|
|
|
18464
19165
|
return URLSerializer(url, true);
|
|
18465
19166
|
}
|
|
18466
19167
|
get redirected() {
|
|
18467
|
-
webidl.brandCheck(this, Response);
|
|
19168
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18468
19169
|
return this.#state.urlList.length > 1;
|
|
18469
19170
|
}
|
|
18470
19171
|
get status() {
|
|
18471
|
-
webidl.brandCheck(this, Response);
|
|
19172
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18472
19173
|
return this.#state.status;
|
|
18473
19174
|
}
|
|
18474
19175
|
get ok() {
|
|
18475
|
-
webidl.brandCheck(this, Response);
|
|
19176
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18476
19177
|
return this.#state.status >= 200 && this.#state.status <= 299;
|
|
18477
19178
|
}
|
|
18478
19179
|
get statusText() {
|
|
18479
|
-
webidl.brandCheck(this, Response);
|
|
19180
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18480
19181
|
return this.#state.statusText;
|
|
18481
19182
|
}
|
|
18482
19183
|
get headers() {
|
|
18483
|
-
webidl.brandCheck(this, Response);
|
|
19184
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18484
19185
|
return this.#headers;
|
|
18485
19186
|
}
|
|
18486
19187
|
get body() {
|
|
18487
|
-
webidl.brandCheck(this, Response);
|
|
19188
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18488
19189
|
return this.#state.body ? this.#state.body.stream : null;
|
|
18489
19190
|
}
|
|
18490
19191
|
get bodyUsed() {
|
|
18491
|
-
webidl.brandCheck(this, Response);
|
|
19192
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18492
19193
|
return !!this.#state.body && util.isDisturbed(this.#state.body.stream);
|
|
18493
19194
|
}
|
|
18494
19195
|
clone() {
|
|
18495
|
-
webidl.brandCheck(this, Response);
|
|
19196
|
+
webidl.brandCheck(this, webidl.is.Response);
|
|
18496
19197
|
if (bodyUnusable(this.#state)) {
|
|
18497
19198
|
throw webidl.errors.exception({
|
|
18498
19199
|
header: "Response.clone",
|
|
@@ -18523,25 +19224,25 @@ var require_response = __commonJS(function(exports, module) {
|
|
|
18523
19224
|
};
|
|
18524
19225
|
return `Response ${nodeUtil.formatWithOptions(options, properties)}`;
|
|
18525
19226
|
}
|
|
18526
|
-
static
|
|
18527
|
-
|
|
18528
|
-
|
|
18529
|
-
|
|
18530
|
-
|
|
18531
|
-
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
19227
|
+
static {
|
|
19228
|
+
getResponseHeaders = (response) => {
|
|
19229
|
+
return response.#headers;
|
|
19230
|
+
};
|
|
19231
|
+
setResponseHeaders = (response, newHeaders) => {
|
|
19232
|
+
response.#headers = newHeaders;
|
|
19233
|
+
};
|
|
19234
|
+
getResponseState = (response) => {
|
|
19235
|
+
return response.#state;
|
|
19236
|
+
};
|
|
19237
|
+
setResponseState = (response, newState) => {
|
|
19238
|
+
response.#state = newState;
|
|
19239
|
+
};
|
|
19240
|
+
webidl.is.Response = (arg) => {
|
|
19241
|
+
return arg != null && typeof arg === "object" && #state in arg;
|
|
19242
|
+
};
|
|
18537
19243
|
}
|
|
18538
19244
|
}
|
|
18539
|
-
|
|
18540
|
-
Reflect.deleteProperty(Response, "getResponseHeaders");
|
|
18541
|
-
Reflect.deleteProperty(Response, "setResponseHeaders");
|
|
18542
|
-
Reflect.deleteProperty(Response, "getResponseState");
|
|
18543
|
-
Reflect.deleteProperty(Response, "setResponseState");
|
|
18544
|
-
mixinBody(Response, getResponseState);
|
|
19245
|
+
mixinBody(Response, getResponseState, webidl.is.Response);
|
|
18545
19246
|
Object.defineProperties(Response.prototype, {
|
|
18546
19247
|
type: kEnumerableProperty,
|
|
18547
19248
|
url: kEnumerableProperty,
|
|
@@ -18738,7 +19439,6 @@ var require_response = __commonJS(function(exports, module) {
|
|
|
18738
19439
|
converter: webidl.converters.HeadersInit
|
|
18739
19440
|
}
|
|
18740
19441
|
]);
|
|
18741
|
-
webidl.is.Response = webidl.util.MakeTypeAssertion(Response);
|
|
18742
19442
|
module.exports = {
|
|
18743
19443
|
isNetworkError,
|
|
18744
19444
|
makeNetworkError,
|
|
@@ -18815,6 +19515,13 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
18815
19515
|
}
|
|
18816
19516
|
}
|
|
18817
19517
|
var patchMethodWarning = false;
|
|
19518
|
+
var setRequestSignal;
|
|
19519
|
+
var getRequestDispatcher;
|
|
19520
|
+
var setRequestDispatcher;
|
|
19521
|
+
var setRequestHeaders;
|
|
19522
|
+
var getRequestState;
|
|
19523
|
+
var setRequestState;
|
|
19524
|
+
var removeRequestAbortListener;
|
|
18818
19525
|
|
|
18819
19526
|
class Request {
|
|
18820
19527
|
#signal;
|
|
@@ -19060,23 +19767,23 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19060
19767
|
this.#state.body = finalBody;
|
|
19061
19768
|
}
|
|
19062
19769
|
get method() {
|
|
19063
|
-
webidl.brandCheck(this, Request);
|
|
19770
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19064
19771
|
return this.#state.method;
|
|
19065
19772
|
}
|
|
19066
19773
|
get url() {
|
|
19067
|
-
webidl.brandCheck(this, Request);
|
|
19774
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19068
19775
|
return URLSerializer(this.#state.url);
|
|
19069
19776
|
}
|
|
19070
19777
|
get headers() {
|
|
19071
|
-
webidl.brandCheck(this, Request);
|
|
19778
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19072
19779
|
return this.#headers;
|
|
19073
19780
|
}
|
|
19074
19781
|
get destination() {
|
|
19075
|
-
webidl.brandCheck(this, Request);
|
|
19782
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19076
19783
|
return this.#state.destination;
|
|
19077
19784
|
}
|
|
19078
19785
|
get referrer() {
|
|
19079
|
-
webidl.brandCheck(this, Request);
|
|
19786
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19080
19787
|
if (this.#state.referrer === "no-referrer") {
|
|
19081
19788
|
return "";
|
|
19082
19789
|
}
|
|
@@ -19086,59 +19793,59 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19086
19793
|
return this.#state.referrer.toString();
|
|
19087
19794
|
}
|
|
19088
19795
|
get referrerPolicy() {
|
|
19089
|
-
webidl.brandCheck(this, Request);
|
|
19796
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19090
19797
|
return this.#state.referrerPolicy;
|
|
19091
19798
|
}
|
|
19092
19799
|
get mode() {
|
|
19093
|
-
webidl.brandCheck(this, Request);
|
|
19800
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19094
19801
|
return this.#state.mode;
|
|
19095
19802
|
}
|
|
19096
19803
|
get credentials() {
|
|
19097
|
-
webidl.brandCheck(this, Request);
|
|
19804
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19098
19805
|
return this.#state.credentials;
|
|
19099
19806
|
}
|
|
19100
19807
|
get cache() {
|
|
19101
|
-
webidl.brandCheck(this, Request);
|
|
19808
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19102
19809
|
return this.#state.cache;
|
|
19103
19810
|
}
|
|
19104
19811
|
get redirect() {
|
|
19105
|
-
webidl.brandCheck(this, Request);
|
|
19812
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19106
19813
|
return this.#state.redirect;
|
|
19107
19814
|
}
|
|
19108
19815
|
get integrity() {
|
|
19109
|
-
webidl.brandCheck(this, Request);
|
|
19816
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19110
19817
|
return this.#state.integrity;
|
|
19111
19818
|
}
|
|
19112
19819
|
get keepalive() {
|
|
19113
|
-
webidl.brandCheck(this, Request);
|
|
19820
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19114
19821
|
return this.#state.keepalive;
|
|
19115
19822
|
}
|
|
19116
19823
|
get isReloadNavigation() {
|
|
19117
|
-
webidl.brandCheck(this, Request);
|
|
19824
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19118
19825
|
return this.#state.reloadNavigation;
|
|
19119
19826
|
}
|
|
19120
19827
|
get isHistoryNavigation() {
|
|
19121
|
-
webidl.brandCheck(this, Request);
|
|
19828
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19122
19829
|
return this.#state.historyNavigation;
|
|
19123
19830
|
}
|
|
19124
19831
|
get signal() {
|
|
19125
|
-
webidl.brandCheck(this, Request);
|
|
19832
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19126
19833
|
return this.#signal;
|
|
19127
19834
|
}
|
|
19128
19835
|
get body() {
|
|
19129
|
-
webidl.brandCheck(this, Request);
|
|
19836
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19130
19837
|
return this.#state.body ? this.#state.body.stream : null;
|
|
19131
19838
|
}
|
|
19132
19839
|
get bodyUsed() {
|
|
19133
|
-
webidl.brandCheck(this, Request);
|
|
19840
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19134
19841
|
return !!this.#state.body && util.isDisturbed(this.#state.body.stream);
|
|
19135
19842
|
}
|
|
19136
19843
|
get duplex() {
|
|
19137
|
-
webidl.brandCheck(this, Request);
|
|
19844
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19138
19845
|
return "half";
|
|
19139
19846
|
}
|
|
19140
19847
|
clone() {
|
|
19141
|
-
webidl.brandCheck(this, Request);
|
|
19848
|
+
webidl.brandCheck(this, webidl.is.Request);
|
|
19142
19849
|
if (bodyUnusable(this.#state)) {
|
|
19143
19850
|
throw new TypeError("unusable");
|
|
19144
19851
|
}
|
|
@@ -19182,38 +19889,34 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19182
19889
|
};
|
|
19183
19890
|
return `Request ${nodeUtil.formatWithOptions(options, properties)}`;
|
|
19184
19891
|
}
|
|
19185
|
-
static
|
|
19186
|
-
|
|
19187
|
-
|
|
19188
|
-
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
|
|
19193
|
-
|
|
19194
|
-
|
|
19195
|
-
|
|
19196
|
-
|
|
19197
|
-
|
|
19198
|
-
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19892
|
+
static {
|
|
19893
|
+
setRequestSignal = (request, newSignal) => {
|
|
19894
|
+
request.#signal = newSignal;
|
|
19895
|
+
};
|
|
19896
|
+
getRequestDispatcher = (request) => {
|
|
19897
|
+
return request.#dispatcher;
|
|
19898
|
+
};
|
|
19899
|
+
setRequestDispatcher = (request, newDispatcher) => {
|
|
19900
|
+
request.#dispatcher = newDispatcher;
|
|
19901
|
+
};
|
|
19902
|
+
setRequestHeaders = (request, newHeaders) => {
|
|
19903
|
+
request.#headers = newHeaders;
|
|
19904
|
+
};
|
|
19905
|
+
getRequestState = (request) => {
|
|
19906
|
+
return request.#state;
|
|
19907
|
+
};
|
|
19908
|
+
setRequestState = (request, newState) => {
|
|
19909
|
+
request.#state = newState;
|
|
19910
|
+
};
|
|
19911
|
+
removeRequestAbortListener = (request) => {
|
|
19912
|
+
request.#abortCleanup?.();
|
|
19913
|
+
};
|
|
19914
|
+
webidl.is.Request = (arg) => {
|
|
19915
|
+
return arg != null && typeof arg === "object" && #state in arg;
|
|
19916
|
+
};
|
|
19206
19917
|
}
|
|
19207
19918
|
}
|
|
19208
|
-
|
|
19209
|
-
Reflect.deleteProperty(Request, "setRequestSignal");
|
|
19210
|
-
Reflect.deleteProperty(Request, "getRequestDispatcher");
|
|
19211
|
-
Reflect.deleteProperty(Request, "setRequestDispatcher");
|
|
19212
|
-
Reflect.deleteProperty(Request, "setRequestHeaders");
|
|
19213
|
-
Reflect.deleteProperty(Request, "getRequestState");
|
|
19214
|
-
Reflect.deleteProperty(Request, "setRequestState");
|
|
19215
|
-
Reflect.deleteProperty(Request, "removeRequestAbortListener");
|
|
19216
|
-
mixinBody(Request, getRequestState);
|
|
19919
|
+
mixinBody(Request, getRequestState, webidl.is.Request);
|
|
19217
19920
|
function makeRequest(init) {
|
|
19218
19921
|
return {
|
|
19219
19922
|
method: init.method ?? "GET",
|
|
@@ -19228,7 +19931,7 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19228
19931
|
serviceWorkers: init.serviceWorkers ?? "all",
|
|
19229
19932
|
initiator: init.initiator ?? "",
|
|
19230
19933
|
destination: init.destination ?? "",
|
|
19231
|
-
priority: init.priority ??
|
|
19934
|
+
priority: init.priority ?? "auto",
|
|
19232
19935
|
origin: init.origin ?? "client",
|
|
19233
19936
|
policyContainer: init.policyContainer ?? "client",
|
|
19234
19937
|
referrer: init.referrer ?? "client",
|
|
@@ -19302,7 +20005,6 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19302
20005
|
configurable: true
|
|
19303
20006
|
}
|
|
19304
20007
|
});
|
|
19305
|
-
webidl.is.Request = webidl.util.MakeTypeAssertion(Request);
|
|
19306
20008
|
webidl.converters.RequestInfo = function(V) {
|
|
19307
20009
|
if (typeof V === "string") {
|
|
19308
20010
|
return webidl.converters.USVString(V);
|
|
@@ -19382,8 +20084,7 @@ var require_request2 = __commonJS(function(exports, module) {
|
|
|
19382
20084
|
{
|
|
19383
20085
|
key: "priority",
|
|
19384
20086
|
converter: webidl.converters.DOMString,
|
|
19385
|
-
allowedValues: ["high", "low", "auto"]
|
|
19386
|
-
defaultValue: () => "auto"
|
|
20087
|
+
allowedValues: ["high", "low", "auto"]
|
|
19387
20088
|
}
|
|
19388
20089
|
]);
|
|
19389
20090
|
module.exports = {
|
|
@@ -19581,6 +20282,7 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
19581
20282
|
var EE = __require("node:events");
|
|
19582
20283
|
var { Readable, pipeline, finished, isErrored, isReadable } = __require("node:stream");
|
|
19583
20284
|
var { addAbortListener, bufferToLowerCasedHeaderName } = require_util();
|
|
20285
|
+
var { SocketError } = require_errors();
|
|
19584
20286
|
var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
|
|
19585
20287
|
var { getGlobalDispatcher } = require_global2();
|
|
19586
20288
|
var { webidl } = require_webidl();
|
|
@@ -19909,7 +20611,7 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
19909
20611
|
}
|
|
19910
20612
|
}
|
|
19911
20613
|
function schemeFetch(fetchParams) {
|
|
19912
|
-
if (isCancelled(fetchParams)
|
|
20614
|
+
if (isCancelled(fetchParams)) {
|
|
19913
20615
|
return Promise.resolve(makeAppropriateNetworkError(fetchParams));
|
|
19914
20616
|
}
|
|
19915
20617
|
const { request } = fetchParams;
|
|
@@ -20007,11 +20709,11 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20007
20709
|
}
|
|
20008
20710
|
function fetchFinale(fetchParams, response) {
|
|
20009
20711
|
let timingInfo = fetchParams.timingInfo;
|
|
20712
|
+
if (fetchParams.request.destination === "document") {
|
|
20713
|
+
fetchParams.controller.fullTimingInfo = timingInfo;
|
|
20714
|
+
}
|
|
20010
20715
|
const processResponseEndOfBody = () => {
|
|
20011
20716
|
const unsafeEndTime = Date.now();
|
|
20012
|
-
if (fetchParams.request.destination === "document") {
|
|
20013
|
-
fetchParams.controller.fullTimingInfo = timingInfo;
|
|
20014
|
-
}
|
|
20015
20717
|
fetchParams.controller.reportTimingSteps = () => {
|
|
20016
20718
|
if (!urlIsHttpHttpsScheme(fetchParams.request.url)) {
|
|
20017
20719
|
return;
|
|
@@ -20060,6 +20762,15 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20060
20762
|
processResponseEndOfBody();
|
|
20061
20763
|
});
|
|
20062
20764
|
}
|
|
20765
|
+
if (fetchParams.processResponseConsumeBody != null) {
|
|
20766
|
+
const processBody = (nullOrBytes) => fetchParams.processResponseConsumeBody(response, nullOrBytes);
|
|
20767
|
+
const processBodyError = () => fetchParams.processResponseConsumeBody(response, "failure");
|
|
20768
|
+
if (internalResponse.body == null) {
|
|
20769
|
+
queueMicrotask(() => processBody(null));
|
|
20770
|
+
} else {
|
|
20771
|
+
fullyReadBody(internalResponse.body, processBody, processBodyError);
|
|
20772
|
+
}
|
|
20773
|
+
}
|
|
20063
20774
|
}
|
|
20064
20775
|
async function httpFetch(fetchParams) {
|
|
20065
20776
|
const request = fetchParams.request;
|
|
@@ -20084,7 +20795,7 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20084
20795
|
}
|
|
20085
20796
|
if (redirectStatusSet.has(actualResponse.status)) {
|
|
20086
20797
|
if (request.redirect !== "manual") {
|
|
20087
|
-
fetchParams.controller.connection.destroy(
|
|
20798
|
+
fetchParams.controller.connection.destroy();
|
|
20088
20799
|
}
|
|
20089
20800
|
if (request.redirect === "error") {
|
|
20090
20801
|
response = makeNetworkError("unexpected redirect");
|
|
@@ -20291,12 +21002,10 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20291
21002
|
fetchParams.controller.connection = {
|
|
20292
21003
|
abort: null,
|
|
20293
21004
|
destroyed: false,
|
|
20294
|
-
destroy(err
|
|
21005
|
+
destroy(err) {
|
|
20295
21006
|
if (!this.destroyed) {
|
|
20296
21007
|
this.destroyed = true;
|
|
20297
|
-
|
|
20298
|
-
this.abort?.(err ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
20299
|
-
}
|
|
21008
|
+
this.abort?.(err ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
20300
21009
|
}
|
|
20301
21010
|
}
|
|
20302
21011
|
};
|
|
@@ -20553,7 +21262,7 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20553
21262
|
fetchParams.controller.ended = true;
|
|
20554
21263
|
this.body?.push(null);
|
|
20555
21264
|
},
|
|
20556
|
-
onResponseError(
|
|
21265
|
+
onResponseError(controller, error) {
|
|
20557
21266
|
if (this.abort) {
|
|
20558
21267
|
fetchParams.controller.off("terminated", this.abort);
|
|
20559
21268
|
}
|
|
@@ -20562,11 +21271,16 @@ var require_fetch = __commonJS(function(exports, module) {
|
|
|
20562
21271
|
return;
|
|
20563
21272
|
}
|
|
20564
21273
|
this.body?.destroy(error);
|
|
20565
|
-
|
|
21274
|
+
if (!controller?.aborted) {
|
|
21275
|
+
fetchParams.controller.terminate(error);
|
|
21276
|
+
}
|
|
20566
21277
|
reject(error);
|
|
20567
21278
|
},
|
|
20568
21279
|
onRequestUpgrade(controller, status, headers, socket) {
|
|
20569
21280
|
if (socket.session != null && status !== 200 || socket.session == null && status !== 101) {
|
|
21281
|
+
if (socket.session != null) {
|
|
21282
|
+
controller.abort(new SocketError("bad upgrade", null));
|
|
21283
|
+
}
|
|
20570
21284
|
return false;
|
|
20571
21285
|
}
|
|
20572
21286
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
@@ -20641,7 +21355,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20641
21355
|
this.#relevantRequestResponseList = arguments[1];
|
|
20642
21356
|
}
|
|
20643
21357
|
async match(request, options = {}) {
|
|
20644
|
-
webidl.brandCheck(this, Cache);
|
|
21358
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20645
21359
|
const prefix = "Cache.match";
|
|
20646
21360
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
20647
21361
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -20653,7 +21367,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20653
21367
|
return p[0];
|
|
20654
21368
|
}
|
|
20655
21369
|
async matchAll(request = undefined, options = {}) {
|
|
20656
|
-
webidl.brandCheck(this, Cache);
|
|
21370
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20657
21371
|
const prefix = "Cache.matchAll";
|
|
20658
21372
|
if (request !== undefined)
|
|
20659
21373
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -20661,7 +21375,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20661
21375
|
return this.#internalMatchAll(request, options);
|
|
20662
21376
|
}
|
|
20663
21377
|
async add(request) {
|
|
20664
|
-
webidl.brandCheck(this, Cache);
|
|
21378
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20665
21379
|
const prefix = "Cache.add";
|
|
20666
21380
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
20667
21381
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -20670,7 +21384,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20670
21384
|
return await responseArrayPromise;
|
|
20671
21385
|
}
|
|
20672
21386
|
async addAll(requests) {
|
|
20673
|
-
webidl.brandCheck(this, Cache);
|
|
21387
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20674
21388
|
const prefix = "Cache.addAll";
|
|
20675
21389
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
20676
21390
|
const responsePromises = [];
|
|
@@ -20732,7 +21446,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20732
21446
|
}
|
|
20733
21447
|
}
|
|
20734
21448
|
},
|
|
20735
|
-
|
|
21449
|
+
processResponseConsumeBody(response) {
|
|
20736
21450
|
if (response.aborted) {
|
|
20737
21451
|
responsePromise.reject(new DOMException("aborted", "AbortError"));
|
|
20738
21452
|
return;
|
|
@@ -20772,7 +21486,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20772
21486
|
return cacheJobPromise.promise;
|
|
20773
21487
|
}
|
|
20774
21488
|
async put(request, response) {
|
|
20775
|
-
webidl.brandCheck(this, Cache);
|
|
21489
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20776
21490
|
const prefix = "Cache.put";
|
|
20777
21491
|
webidl.argumentLengthCheck(arguments, 2, prefix);
|
|
20778
21492
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -20850,7 +21564,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20850
21564
|
return cacheJobPromise.promise;
|
|
20851
21565
|
}
|
|
20852
21566
|
async delete(request, options = {}) {
|
|
20853
|
-
webidl.brandCheck(this, Cache);
|
|
21567
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20854
21568
|
const prefix = "Cache.delete";
|
|
20855
21569
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
20856
21570
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -20890,7 +21604,7 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
20890
21604
|
return cacheJobPromise.promise;
|
|
20891
21605
|
}
|
|
20892
21606
|
async keys(request = undefined, options = {}) {
|
|
20893
|
-
webidl.brandCheck(this, Cache);
|
|
21607
|
+
webidl.brandCheck(this, webidl.is.Cache);
|
|
20894
21608
|
const prefix = "Cache.keys";
|
|
20895
21609
|
if (request !== undefined)
|
|
20896
21610
|
request = webidl.converters.RequestInfo(request);
|
|
@@ -21075,6 +21789,11 @@ var require_cache3 = __commonJS(function(exports, module) {
|
|
|
21075
21789
|
}
|
|
21076
21790
|
return Object.freeze(responseList);
|
|
21077
21791
|
}
|
|
21792
|
+
static {
|
|
21793
|
+
webidl.is.Cache = (arg) => {
|
|
21794
|
+
return arg != null && typeof arg === "object" && #relevantRequestResponseList in arg;
|
|
21795
|
+
};
|
|
21796
|
+
}
|
|
21078
21797
|
}
|
|
21079
21798
|
Object.defineProperties(Cache.prototype, {
|
|
21080
21799
|
[Symbol.toStringTag]: {
|
|
@@ -21137,7 +21856,7 @@ var require_cachestorage = __commonJS(function(exports, module) {
|
|
|
21137
21856
|
webidl.util.markAsUncloneable(this);
|
|
21138
21857
|
}
|
|
21139
21858
|
async match(request, options = {}) {
|
|
21140
|
-
webidl.brandCheck(this, CacheStorage);
|
|
21859
|
+
webidl.brandCheck(this, webidl.is.CacheStorage);
|
|
21141
21860
|
webidl.argumentLengthCheck(arguments, 1, "CacheStorage.match");
|
|
21142
21861
|
request = webidl.converters.RequestInfo(request);
|
|
21143
21862
|
options = webidl.converters.MultiCacheQueryOptions(options);
|
|
@@ -21158,14 +21877,14 @@ var require_cachestorage = __commonJS(function(exports, module) {
|
|
|
21158
21877
|
}
|
|
21159
21878
|
}
|
|
21160
21879
|
async has(cacheName) {
|
|
21161
|
-
webidl.brandCheck(this, CacheStorage);
|
|
21880
|
+
webidl.brandCheck(this, webidl.is.CacheStorage);
|
|
21162
21881
|
const prefix = "CacheStorage.has";
|
|
21163
21882
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
21164
21883
|
cacheName = webidl.converters.DOMString(cacheName, prefix, "cacheName");
|
|
21165
21884
|
return this.#caches.has(cacheName);
|
|
21166
21885
|
}
|
|
21167
21886
|
async open(cacheName) {
|
|
21168
|
-
webidl.brandCheck(this, CacheStorage);
|
|
21887
|
+
webidl.brandCheck(this, webidl.is.CacheStorage);
|
|
21169
21888
|
const prefix = "CacheStorage.open";
|
|
21170
21889
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
21171
21890
|
cacheName = webidl.converters.DOMString(cacheName, prefix, "cacheName");
|
|
@@ -21178,17 +21897,22 @@ var require_cachestorage = __commonJS(function(exports, module) {
|
|
|
21178
21897
|
return new Cache(kConstruct, cache);
|
|
21179
21898
|
}
|
|
21180
21899
|
async delete(cacheName) {
|
|
21181
|
-
webidl.brandCheck(this, CacheStorage);
|
|
21900
|
+
webidl.brandCheck(this, webidl.is.CacheStorage);
|
|
21182
21901
|
const prefix = "CacheStorage.delete";
|
|
21183
21902
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
21184
21903
|
cacheName = webidl.converters.DOMString(cacheName, prefix, "cacheName");
|
|
21185
21904
|
return this.#caches.delete(cacheName);
|
|
21186
21905
|
}
|
|
21187
21906
|
async keys() {
|
|
21188
|
-
webidl.brandCheck(this, CacheStorage);
|
|
21907
|
+
webidl.brandCheck(this, webidl.is.CacheStorage);
|
|
21189
21908
|
const keys = this.#caches.keys();
|
|
21190
21909
|
return [...keys];
|
|
21191
21910
|
}
|
|
21911
|
+
static {
|
|
21912
|
+
webidl.is.CacheStorage = (arg) => {
|
|
21913
|
+
return arg != null && typeof arg === "object" && #caches in arg;
|
|
21914
|
+
};
|
|
21915
|
+
}
|
|
21192
21916
|
}
|
|
21193
21917
|
Object.defineProperties(CacheStorage.prototype, {
|
|
21194
21918
|
[Symbol.toStringTag]: {
|
|
@@ -21365,7 +22089,7 @@ var require_util4 = __commonJS(function(exports, module) {
|
|
|
21365
22089
|
validateCookiePath(cookie.path);
|
|
21366
22090
|
out.push(`Path=${cookie.path}`);
|
|
21367
22091
|
}
|
|
21368
|
-
if (cookie.expires && cookie.expires.toString() !== "Invalid Date") {
|
|
22092
|
+
if (cookie.expires != null && cookie.expires.toString() !== "Invalid Date") {
|
|
21369
22093
|
out.push(`Expires=${toIMFDate(cookie.expires)}`);
|
|
21370
22094
|
}
|
|
21371
22095
|
if (cookie.sameSite) {
|
|
@@ -21434,82 +22158,85 @@ var require_parse = __commonJS(function(exports, module) {
|
|
|
21434
22158
|
};
|
|
21435
22159
|
}
|
|
21436
22160
|
function parseUnparsedAttributes(unparsedAttributes, cookieAttributeList = {}) {
|
|
21437
|
-
|
|
21438
|
-
|
|
21439
|
-
|
|
21440
|
-
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
|
|
21445
|
-
|
|
21446
|
-
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21452
|
-
|
|
21453
|
-
|
|
21454
|
-
|
|
21455
|
-
|
|
21456
|
-
|
|
21457
|
-
attributeName = cookieAv;
|
|
21458
|
-
}
|
|
21459
|
-
attributeName = attributeName.trim();
|
|
21460
|
-
attributeValue = attributeValue.trim();
|
|
21461
|
-
if (attributeValue.length > maxAttributeValueSize) {
|
|
21462
|
-
return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList);
|
|
21463
|
-
}
|
|
21464
|
-
const attributeNameLowercase = attributeName.toLowerCase();
|
|
21465
|
-
if (attributeNameLowercase === "expires") {
|
|
21466
|
-
const expiryTime = new Date(attributeValue);
|
|
21467
|
-
if (!Number.isNaN(expiryTime.getTime())) {
|
|
21468
|
-
cookieAttributeList.expires = expiryTime;
|
|
21469
|
-
}
|
|
21470
|
-
} else if (attributeNameLowercase === "max-age") {
|
|
21471
|
-
const charCode = attributeValue.charCodeAt(0);
|
|
21472
|
-
if ((charCode < 48 || charCode > 57) && attributeValue[0] !== "-") {
|
|
21473
|
-
return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList);
|
|
21474
|
-
}
|
|
21475
|
-
if (!/^\d+$/.test(attributeValue)) {
|
|
21476
|
-
return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList);
|
|
21477
|
-
}
|
|
21478
|
-
const deltaSeconds = Number(attributeValue);
|
|
21479
|
-
cookieAttributeList.maxAge = deltaSeconds;
|
|
21480
|
-
} else if (attributeNameLowercase === "domain") {
|
|
21481
|
-
let cookieDomain = attributeValue;
|
|
21482
|
-
if (cookieDomain[0] === ".") {
|
|
21483
|
-
cookieDomain = cookieDomain.slice(1);
|
|
21484
|
-
}
|
|
21485
|
-
cookieDomain = cookieDomain.toLowerCase();
|
|
21486
|
-
cookieAttributeList.domain = cookieDomain;
|
|
21487
|
-
} else if (attributeNameLowercase === "path") {
|
|
21488
|
-
let cookiePath = "";
|
|
21489
|
-
if (attributeValue.length === 0 || attributeValue[0] !== "/") {
|
|
21490
|
-
cookiePath = "/";
|
|
22161
|
+
while (true) {
|
|
22162
|
+
if (unparsedAttributes.length === 0) {
|
|
22163
|
+
return cookieAttributeList;
|
|
22164
|
+
}
|
|
22165
|
+
assert(unparsedAttributes[0] === ";");
|
|
22166
|
+
unparsedAttributes = unparsedAttributes.slice(1);
|
|
22167
|
+
let cookieAv = "";
|
|
22168
|
+
if (unparsedAttributes.includes(";")) {
|
|
22169
|
+
cookieAv = collectASequenceOfCodePointsFast(";", unparsedAttributes, { position: 0 });
|
|
22170
|
+
unparsedAttributes = unparsedAttributes.slice(cookieAv.length);
|
|
22171
|
+
} else {
|
|
22172
|
+
cookieAv = unparsedAttributes;
|
|
22173
|
+
unparsedAttributes = "";
|
|
22174
|
+
}
|
|
22175
|
+
let attributeName = "";
|
|
22176
|
+
let attributeValue = "";
|
|
22177
|
+
if (cookieAv.includes("=")) {
|
|
22178
|
+
const position = { position: 0 };
|
|
22179
|
+
attributeName = collectASequenceOfCodePointsFast("=", cookieAv, position);
|
|
22180
|
+
attributeValue = cookieAv.slice(position.position + 1);
|
|
21491
22181
|
} else {
|
|
21492
|
-
|
|
21493
|
-
}
|
|
21494
|
-
|
|
21495
|
-
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
|
|
21500
|
-
|
|
21501
|
-
|
|
21502
|
-
|
|
21503
|
-
|
|
21504
|
-
|
|
21505
|
-
} else if (
|
|
21506
|
-
|
|
22182
|
+
attributeName = cookieAv;
|
|
22183
|
+
}
|
|
22184
|
+
attributeName = attributeName.trim();
|
|
22185
|
+
attributeValue = attributeValue.trim();
|
|
22186
|
+
if (attributeValue.length > maxAttributeValueSize) {
|
|
22187
|
+
continue;
|
|
22188
|
+
}
|
|
22189
|
+
const attributeNameLowercase = attributeName.toLowerCase();
|
|
22190
|
+
if (attributeNameLowercase === "expires") {
|
|
22191
|
+
const expiryTime = new Date(attributeValue);
|
|
22192
|
+
if (!Number.isNaN(expiryTime.getTime())) {
|
|
22193
|
+
cookieAttributeList.expires = expiryTime;
|
|
22194
|
+
}
|
|
22195
|
+
} else if (attributeNameLowercase === "max-age") {
|
|
22196
|
+
const charCode = attributeValue.charCodeAt(0);
|
|
22197
|
+
const startsWithDigit = charCode >= 48 && charCode <= 57;
|
|
22198
|
+
const startsWithSignedDigit = attributeValue[0] === "-" && attributeValue.length > 1;
|
|
22199
|
+
if (!startsWithDigit && !startsWithSignedDigit) {
|
|
22200
|
+
continue;
|
|
22201
|
+
}
|
|
22202
|
+
if (/[^\d]/.test(attributeValue.slice(1))) {
|
|
22203
|
+
continue;
|
|
22204
|
+
}
|
|
22205
|
+
const deltaSeconds = Number(attributeValue);
|
|
22206
|
+
cookieAttributeList.maxAge = deltaSeconds;
|
|
22207
|
+
} else if (attributeNameLowercase === "domain") {
|
|
22208
|
+
let cookieDomain = attributeValue;
|
|
22209
|
+
if (cookieDomain[0] === ".") {
|
|
22210
|
+
cookieDomain = cookieDomain.slice(1);
|
|
22211
|
+
}
|
|
22212
|
+
cookieDomain = cookieDomain.toLowerCase();
|
|
22213
|
+
cookieAttributeList.domain = cookieDomain;
|
|
22214
|
+
} else if (attributeNameLowercase === "path") {
|
|
22215
|
+
let cookiePath = "";
|
|
22216
|
+
if (attributeValue.length === 0 || attributeValue[0] !== "/") {
|
|
22217
|
+
cookiePath = "/";
|
|
22218
|
+
} else {
|
|
22219
|
+
cookiePath = attributeValue;
|
|
22220
|
+
}
|
|
22221
|
+
cookieAttributeList.path = cookiePath;
|
|
22222
|
+
} else if (attributeNameLowercase === "secure") {
|
|
22223
|
+
cookieAttributeList.secure = true;
|
|
22224
|
+
} else if (attributeNameLowercase === "httponly") {
|
|
22225
|
+
cookieAttributeList.httpOnly = true;
|
|
22226
|
+
} else if (attributeNameLowercase === "samesite") {
|
|
22227
|
+
const attributeValueLowercase = attributeValue.toLowerCase();
|
|
22228
|
+
if (attributeValueLowercase === "none") {
|
|
22229
|
+
cookieAttributeList.sameSite = "None";
|
|
22230
|
+
} else if (attributeValueLowercase === "strict") {
|
|
22231
|
+
cookieAttributeList.sameSite = "Strict";
|
|
22232
|
+
} else if (attributeValueLowercase === "lax") {
|
|
22233
|
+
cookieAttributeList.sameSite = "Lax";
|
|
22234
|
+
}
|
|
22235
|
+
} else {
|
|
22236
|
+
cookieAttributeList.unparsed ??= [];
|
|
22237
|
+
cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
|
|
21507
22238
|
}
|
|
21508
|
-
} else {
|
|
21509
|
-
cookieAttributeList.unparsed ??= [];
|
|
21510
|
-
cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
|
|
21511
22239
|
}
|
|
21512
|
-
return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList);
|
|
21513
22240
|
}
|
|
21514
22241
|
module.exports = {
|
|
21515
22242
|
parseSetCookie,
|
|
@@ -21522,13 +22249,20 @@ var require_cookies = __commonJS(function(exports, module) {
|
|
|
21522
22249
|
var { parseSetCookie } = require_parse();
|
|
21523
22250
|
var { stringify } = require_util4();
|
|
21524
22251
|
var { webidl } = require_webidl();
|
|
21525
|
-
var
|
|
21526
|
-
var
|
|
22252
|
+
var globalHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.util.MakeTypeAssertion(globalThis.Headers));
|
|
22253
|
+
var undiciHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.is.Headers);
|
|
22254
|
+
function brandCheckHeaders(arg) {
|
|
22255
|
+
try {
|
|
22256
|
+
undiciHeadersBrandCheck(arg);
|
|
22257
|
+
return;
|
|
22258
|
+
} catch {}
|
|
22259
|
+
globalHeadersBrandCheck(arg);
|
|
22260
|
+
}
|
|
21527
22261
|
function getCookies(headers) {
|
|
21528
22262
|
webidl.argumentLengthCheck(arguments, 1, "getCookies");
|
|
21529
|
-
|
|
22263
|
+
brandCheckHeaders(headers);
|
|
21530
22264
|
const cookie = headers.get("cookie");
|
|
21531
|
-
const out = {};
|
|
22265
|
+
const out = { __proto__: null };
|
|
21532
22266
|
if (!cookie) {
|
|
21533
22267
|
return out;
|
|
21534
22268
|
}
|
|
@@ -21539,7 +22273,7 @@ var require_cookies = __commonJS(function(exports, module) {
|
|
|
21539
22273
|
return out;
|
|
21540
22274
|
}
|
|
21541
22275
|
function deleteCookie(headers, name, attributes) {
|
|
21542
|
-
|
|
22276
|
+
brandCheckHeaders(headers);
|
|
21543
22277
|
const prefix = "deleteCookie";
|
|
21544
22278
|
webidl.argumentLengthCheck(arguments, 2, prefix);
|
|
21545
22279
|
name = webidl.converters.DOMString(name, prefix, "name");
|
|
@@ -21553,7 +22287,7 @@ var require_cookies = __commonJS(function(exports, module) {
|
|
|
21553
22287
|
}
|
|
21554
22288
|
function getSetCookies(headers) {
|
|
21555
22289
|
webidl.argumentLengthCheck(arguments, 1, "getSetCookies");
|
|
21556
|
-
|
|
22290
|
+
brandCheckHeaders(headers);
|
|
21557
22291
|
const cookies = headers.getSetCookie();
|
|
21558
22292
|
if (!cookies) {
|
|
21559
22293
|
return [];
|
|
@@ -21566,7 +22300,7 @@ var require_cookies = __commonJS(function(exports, module) {
|
|
|
21566
22300
|
}
|
|
21567
22301
|
function setCookie(headers, cookie) {
|
|
21568
22302
|
webidl.argumentLengthCheck(arguments, 2, "setCookie");
|
|
21569
|
-
|
|
22303
|
+
brandCheckHeaders(headers);
|
|
21570
22304
|
cookie = webidl.converters.Cookie(cookie);
|
|
21571
22305
|
const str = stringify(cookie);
|
|
21572
22306
|
if (str) {
|
|
@@ -21654,6 +22388,7 @@ var require_events = __commonJS(function(exports, module) {
|
|
|
21654
22388
|
var { webidl } = require_webidl();
|
|
21655
22389
|
var { kEnumerableProperty } = require_util();
|
|
21656
22390
|
var { kConstruct } = require_symbols();
|
|
22391
|
+
var createFastMessageEvent;
|
|
21657
22392
|
|
|
21658
22393
|
class MessageEvent extends Event {
|
|
21659
22394
|
#eventInit;
|
|
@@ -21672,30 +22407,30 @@ var require_events = __commonJS(function(exports, module) {
|
|
|
21672
22407
|
webidl.util.markAsUncloneable(this);
|
|
21673
22408
|
}
|
|
21674
22409
|
get data() {
|
|
21675
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22410
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21676
22411
|
return this.#eventInit.data;
|
|
21677
22412
|
}
|
|
21678
22413
|
get origin() {
|
|
21679
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22414
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21680
22415
|
return this.#eventInit.origin;
|
|
21681
22416
|
}
|
|
21682
22417
|
get lastEventId() {
|
|
21683
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22418
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21684
22419
|
return this.#eventInit.lastEventId;
|
|
21685
22420
|
}
|
|
21686
22421
|
get source() {
|
|
21687
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22422
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21688
22423
|
return this.#eventInit.source;
|
|
21689
22424
|
}
|
|
21690
22425
|
get ports() {
|
|
21691
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22426
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21692
22427
|
if (!Object.isFrozen(this.#eventInit.ports)) {
|
|
21693
22428
|
Object.freeze(this.#eventInit.ports);
|
|
21694
22429
|
}
|
|
21695
22430
|
return this.#eventInit.ports;
|
|
21696
22431
|
}
|
|
21697
22432
|
initMessageEvent(type, bubbles = false, cancelable = false, data = null, origin = "", lastEventId = "", source = null, ports = []) {
|
|
21698
|
-
webidl.brandCheck(this, MessageEvent);
|
|
22433
|
+
webidl.brandCheck(this, webidl.is.MessageEvent);
|
|
21699
22434
|
webidl.argumentLengthCheck(arguments, 1, "MessageEvent.initMessageEvent");
|
|
21700
22435
|
return new MessageEvent(type, {
|
|
21701
22436
|
bubbles,
|
|
@@ -21707,19 +22442,22 @@ var require_events = __commonJS(function(exports, module) {
|
|
|
21707
22442
|
ports
|
|
21708
22443
|
});
|
|
21709
22444
|
}
|
|
21710
|
-
static
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
22445
|
+
static {
|
|
22446
|
+
createFastMessageEvent = (type, init) => {
|
|
22447
|
+
const messageEvent = new MessageEvent(kConstruct, type, init);
|
|
22448
|
+
messageEvent.#eventInit = init;
|
|
22449
|
+
messageEvent.#eventInit.data ??= null;
|
|
22450
|
+
messageEvent.#eventInit.origin ??= "";
|
|
22451
|
+
messageEvent.#eventInit.lastEventId ??= "";
|
|
22452
|
+
messageEvent.#eventInit.source ??= null;
|
|
22453
|
+
messageEvent.#eventInit.ports ??= [];
|
|
22454
|
+
return messageEvent;
|
|
22455
|
+
};
|
|
22456
|
+
webidl.is.MessageEvent = (arg) => {
|
|
22457
|
+
return arg != null && typeof arg === "object" && #eventInit in arg;
|
|
22458
|
+
};
|
|
21719
22459
|
}
|
|
21720
22460
|
}
|
|
21721
|
-
var { createFastMessageEvent } = MessageEvent;
|
|
21722
|
-
delete MessageEvent.createFastMessageEvent;
|
|
21723
22461
|
|
|
21724
22462
|
class CloseEvent extends Event {
|
|
21725
22463
|
#eventInit;
|
|
@@ -21733,17 +22471,22 @@ var require_events = __commonJS(function(exports, module) {
|
|
|
21733
22471
|
webidl.util.markAsUncloneable(this);
|
|
21734
22472
|
}
|
|
21735
22473
|
get wasClean() {
|
|
21736
|
-
webidl.brandCheck(this, CloseEvent);
|
|
22474
|
+
webidl.brandCheck(this, webidl.is.CloseEvent);
|
|
21737
22475
|
return this.#eventInit.wasClean;
|
|
21738
22476
|
}
|
|
21739
22477
|
get code() {
|
|
21740
|
-
webidl.brandCheck(this, CloseEvent);
|
|
22478
|
+
webidl.brandCheck(this, webidl.is.CloseEvent);
|
|
21741
22479
|
return this.#eventInit.code;
|
|
21742
22480
|
}
|
|
21743
22481
|
get reason() {
|
|
21744
|
-
webidl.brandCheck(this, CloseEvent);
|
|
22482
|
+
webidl.brandCheck(this, webidl.is.CloseEvent);
|
|
21745
22483
|
return this.#eventInit.reason;
|
|
21746
22484
|
}
|
|
22485
|
+
static {
|
|
22486
|
+
webidl.is.CloseEvent = (arg) => {
|
|
22487
|
+
return arg != null && typeof arg === "object" && #eventInit in arg;
|
|
22488
|
+
};
|
|
22489
|
+
}
|
|
21747
22490
|
}
|
|
21748
22491
|
|
|
21749
22492
|
class ErrorEvent extends Event {
|
|
@@ -21758,25 +22501,30 @@ var require_events = __commonJS(function(exports, module) {
|
|
|
21758
22501
|
this.#eventInit = eventInitDict;
|
|
21759
22502
|
}
|
|
21760
22503
|
get message() {
|
|
21761
|
-
webidl.brandCheck(this, ErrorEvent);
|
|
22504
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent);
|
|
21762
22505
|
return this.#eventInit.message;
|
|
21763
22506
|
}
|
|
21764
22507
|
get filename() {
|
|
21765
|
-
webidl.brandCheck(this, ErrorEvent);
|
|
22508
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent);
|
|
21766
22509
|
return this.#eventInit.filename;
|
|
21767
22510
|
}
|
|
21768
22511
|
get lineno() {
|
|
21769
|
-
webidl.brandCheck(this, ErrorEvent);
|
|
22512
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent);
|
|
21770
22513
|
return this.#eventInit.lineno;
|
|
21771
22514
|
}
|
|
21772
22515
|
get colno() {
|
|
21773
|
-
webidl.brandCheck(this, ErrorEvent);
|
|
22516
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent);
|
|
21774
22517
|
return this.#eventInit.colno;
|
|
21775
22518
|
}
|
|
21776
22519
|
get error() {
|
|
21777
|
-
webidl.brandCheck(this, ErrorEvent);
|
|
22520
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent);
|
|
21778
22521
|
return this.#eventInit.error;
|
|
21779
22522
|
}
|
|
22523
|
+
static {
|
|
22524
|
+
webidl.is.ErrorEvent = (arg) => {
|
|
22525
|
+
return arg != null && typeof arg === "object" && #eventInit in arg;
|
|
22526
|
+
};
|
|
22527
|
+
}
|
|
21780
22528
|
}
|
|
21781
22529
|
Object.defineProperties(MessageEvent.prototype, {
|
|
21782
22530
|
[Symbol.toStringTag]: {
|
|
@@ -22253,11 +23001,11 @@ var require_connection = __commonJS(function(exports, module) {
|
|
|
22253
23001
|
processResponse(response) {
|
|
22254
23002
|
if (response.type === "error" || response.status !== 101) {
|
|
22255
23003
|
if (response.socket?.session == null) {
|
|
22256
|
-
|
|
23004
|
+
failHandshake(handler, response, 1002, "Received network error or non-101 status code.", response.error);
|
|
22257
23005
|
return;
|
|
22258
23006
|
}
|
|
22259
23007
|
if (response.status !== 200) {
|
|
22260
|
-
|
|
23008
|
+
failHandshake(handler, response, 1002, "Received network error or non-200 status code.", response.error);
|
|
22261
23009
|
return;
|
|
22262
23010
|
}
|
|
22263
23011
|
}
|
|
@@ -22266,40 +23014,45 @@ var require_connection = __commonJS(function(exports, module) {
|
|
|
22266
23014
|
warningEmitted = true;
|
|
22267
23015
|
}
|
|
22268
23016
|
if (protocols.length !== 0 && !response.headersList.get("Sec-WebSocket-Protocol")) {
|
|
22269
|
-
|
|
23017
|
+
failHandshake(handler, response, 1002, "Server did not respond with sent protocols.");
|
|
22270
23018
|
return;
|
|
22271
23019
|
}
|
|
22272
23020
|
if (response.socket.session == null && response.headersList.get("Upgrade")?.toLowerCase() !== "websocket") {
|
|
22273
|
-
|
|
23021
|
+
failHandshake(handler, response, 1002, 'Server did not set Upgrade header to "websocket".');
|
|
22274
23022
|
return;
|
|
22275
23023
|
}
|
|
22276
23024
|
if (response.socket.session == null && response.headersList.get("Connection")?.toLowerCase() !== "upgrade") {
|
|
22277
|
-
|
|
23025
|
+
failHandshake(handler, response, 1002, 'Server did not set Connection header to "upgrade".');
|
|
22278
23026
|
return;
|
|
22279
23027
|
}
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
-
|
|
22283
|
-
|
|
22284
|
-
|
|
23028
|
+
if (response.socket.session == null) {
|
|
23029
|
+
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
23030
|
+
const digest = crypto.hash("sha1", keyValue + uid, "base64");
|
|
23031
|
+
if (secWSAccept !== digest) {
|
|
23032
|
+
failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
23033
|
+
return;
|
|
23034
|
+
}
|
|
22285
23035
|
}
|
|
22286
23036
|
const secExtension = response.headersList.get("Sec-WebSocket-Extensions");
|
|
22287
23037
|
let extensions;
|
|
22288
23038
|
if (secExtension !== null) {
|
|
22289
23039
|
extensions = parseExtensions(secExtension);
|
|
22290
23040
|
if (!extensions.has("permessage-deflate")) {
|
|
22291
|
-
|
|
23041
|
+
failHandshake(handler, response, 1002, "Sec-WebSocket-Extensions header does not match.");
|
|
22292
23042
|
return;
|
|
22293
23043
|
}
|
|
22294
23044
|
}
|
|
22295
23045
|
const secProtocol = response.headersList.get("Sec-WebSocket-Protocol");
|
|
22296
23046
|
if (secProtocol !== null) {
|
|
22297
23047
|
const requestProtocols = getDecodeSplit("sec-websocket-protocol", request.headersList);
|
|
22298
|
-
if (!requestProtocols.includes(secProtocol)) {
|
|
22299
|
-
|
|
23048
|
+
if (requestProtocols === null || !requestProtocols.includes(secProtocol)) {
|
|
23049
|
+
failHandshake(handler, response, 1002, "Protocol was not set in the opening handshake.");
|
|
22300
23050
|
return;
|
|
22301
23051
|
}
|
|
22302
23052
|
}
|
|
23053
|
+
if (response.socket.session != null) {
|
|
23054
|
+
response.socket.allowHalfOpen = false;
|
|
23055
|
+
}
|
|
22303
23056
|
response.socket.on("data", handler.onSocketData);
|
|
22304
23057
|
response.socket.on("close", handler.onSocketClose);
|
|
22305
23058
|
response.socket.on("error", handler.onSocketError);
|
|
@@ -22342,6 +23095,12 @@ var require_connection = __commonJS(function(exports, module) {
|
|
|
22342
23095
|
object.readyState = states.CLOSING;
|
|
22343
23096
|
}
|
|
22344
23097
|
}
|
|
23098
|
+
function failHandshake(handler, response, code, reason, cause) {
|
|
23099
|
+
if (response.socket?.session != null && !response.socket.destroyed) {
|
|
23100
|
+
response.socket.destroy();
|
|
23101
|
+
}
|
|
23102
|
+
failWebsocketConnection(handler, code, reason, cause);
|
|
23103
|
+
}
|
|
22345
23104
|
function failWebsocketConnection(handler, code, reason, cause) {
|
|
22346
23105
|
if (isEstablished(handler.readyState)) {
|
|
22347
23106
|
closeWebSocketConnection(handler, code, reason, false);
|
|
@@ -22401,6 +23160,7 @@ var require_permessage_deflate = __commonJS(function(exports, module) {
|
|
|
22401
23160
|
if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
|
|
22402
23161
|
callback(new MessageSizeExceededError);
|
|
22403
23162
|
this.#inflate.removeAllListeners();
|
|
23163
|
+
this.#inflate.destroy();
|
|
22404
23164
|
this.#inflate = null;
|
|
22405
23165
|
return;
|
|
22406
23166
|
}
|
|
@@ -22673,6 +23433,7 @@ var require_receiver = __commonJS(function(exports, module) {
|
|
|
22673
23433
|
}
|
|
22674
23434
|
consumeFragments() {
|
|
22675
23435
|
const fragments = this.#fragments;
|
|
23436
|
+
this.#info.compressed = false;
|
|
22676
23437
|
if (fragments.length === 1) {
|
|
22677
23438
|
this.#fragmentsBytes = 0;
|
|
22678
23439
|
return fragments.shift();
|
|
@@ -22860,6 +23621,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
22860
23621
|
var { channels } = require_diagnostics();
|
|
22861
23622
|
var kRef = Symbol.for("nodejs.ref");
|
|
22862
23623
|
var kUnref = Symbol.for("nodejs.unref");
|
|
23624
|
+
var ping;
|
|
22863
23625
|
function getSocketAddress(socket) {
|
|
22864
23626
|
if (typeof socket?.address === "function") {
|
|
22865
23627
|
return socket.address();
|
|
@@ -22951,17 +23713,15 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
22951
23713
|
this.#binaryType = "blob";
|
|
22952
23714
|
}
|
|
22953
23715
|
[kRef]() {
|
|
22954
|
-
webidl.brandCheck(this, WebSocket);
|
|
22955
23716
|
this.#refed = true;
|
|
22956
23717
|
this.#handler.socket?.ref?.();
|
|
22957
23718
|
}
|
|
22958
23719
|
[kUnref]() {
|
|
22959
|
-
webidl.brandCheck(this, WebSocket);
|
|
22960
23720
|
this.#refed = false;
|
|
22961
23721
|
this.#handler.socket?.unref?.();
|
|
22962
23722
|
}
|
|
22963
23723
|
close(code = undefined, reason = undefined) {
|
|
22964
|
-
webidl.brandCheck(this, WebSocket);
|
|
23724
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
22965
23725
|
const prefix = "WebSocket.close";
|
|
22966
23726
|
if (code !== undefined) {
|
|
22967
23727
|
code = webidl.converters["unsigned short"](code, prefix, "code", webidl.attributes.Clamp);
|
|
@@ -22974,7 +23734,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
22974
23734
|
closeWebSocketConnection(this.#handler, code, reason, true);
|
|
22975
23735
|
}
|
|
22976
23736
|
send(data) {
|
|
22977
|
-
webidl.brandCheck(this, WebSocket);
|
|
23737
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
22978
23738
|
const prefix = "WebSocket.send";
|
|
22979
23739
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
22980
23740
|
data = webidl.converters.WebSocketSendData(data, prefix, "data");
|
|
@@ -23008,31 +23768,31 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23008
23768
|
}
|
|
23009
23769
|
}
|
|
23010
23770
|
get readyState() {
|
|
23011
|
-
webidl.brandCheck(this, WebSocket);
|
|
23771
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23012
23772
|
return this.#handler.readyState;
|
|
23013
23773
|
}
|
|
23014
23774
|
get bufferedAmount() {
|
|
23015
|
-
webidl.brandCheck(this, WebSocket);
|
|
23775
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23016
23776
|
return this.#bufferedAmount;
|
|
23017
23777
|
}
|
|
23018
23778
|
get url() {
|
|
23019
|
-
webidl.brandCheck(this, WebSocket);
|
|
23779
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23020
23780
|
return URLSerializer(this.#url);
|
|
23021
23781
|
}
|
|
23022
23782
|
get extensions() {
|
|
23023
|
-
webidl.brandCheck(this, WebSocket);
|
|
23783
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23024
23784
|
return this.#extensions;
|
|
23025
23785
|
}
|
|
23026
23786
|
get protocol() {
|
|
23027
|
-
webidl.brandCheck(this, WebSocket);
|
|
23787
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23028
23788
|
return this.#protocol;
|
|
23029
23789
|
}
|
|
23030
23790
|
get onopen() {
|
|
23031
|
-
webidl.brandCheck(this, WebSocket);
|
|
23791
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23032
23792
|
return this.#events.open;
|
|
23033
23793
|
}
|
|
23034
23794
|
set onopen(fn) {
|
|
23035
|
-
webidl.brandCheck(this, WebSocket);
|
|
23795
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23036
23796
|
if (this.#events.open) {
|
|
23037
23797
|
this.removeEventListener("open", this.#events.open);
|
|
23038
23798
|
}
|
|
@@ -23045,11 +23805,11 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23045
23805
|
}
|
|
23046
23806
|
}
|
|
23047
23807
|
get onerror() {
|
|
23048
|
-
webidl.brandCheck(this, WebSocket);
|
|
23808
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23049
23809
|
return this.#events.error;
|
|
23050
23810
|
}
|
|
23051
23811
|
set onerror(fn) {
|
|
23052
|
-
webidl.brandCheck(this, WebSocket);
|
|
23812
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23053
23813
|
if (this.#events.error) {
|
|
23054
23814
|
this.removeEventListener("error", this.#events.error);
|
|
23055
23815
|
}
|
|
@@ -23062,11 +23822,11 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23062
23822
|
}
|
|
23063
23823
|
}
|
|
23064
23824
|
get onclose() {
|
|
23065
|
-
webidl.brandCheck(this, WebSocket);
|
|
23825
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23066
23826
|
return this.#events.close;
|
|
23067
23827
|
}
|
|
23068
23828
|
set onclose(fn) {
|
|
23069
|
-
webidl.brandCheck(this, WebSocket);
|
|
23829
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23070
23830
|
if (this.#events.close) {
|
|
23071
23831
|
this.removeEventListener("close", this.#events.close);
|
|
23072
23832
|
}
|
|
@@ -23079,11 +23839,11 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23079
23839
|
}
|
|
23080
23840
|
}
|
|
23081
23841
|
get onmessage() {
|
|
23082
|
-
webidl.brandCheck(this, WebSocket);
|
|
23842
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23083
23843
|
return this.#events.message;
|
|
23084
23844
|
}
|
|
23085
23845
|
set onmessage(fn) {
|
|
23086
|
-
webidl.brandCheck(this, WebSocket);
|
|
23846
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23087
23847
|
if (this.#events.message) {
|
|
23088
23848
|
this.removeEventListener("message", this.#events.message);
|
|
23089
23849
|
}
|
|
@@ -23096,11 +23856,11 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23096
23856
|
}
|
|
23097
23857
|
}
|
|
23098
23858
|
get binaryType() {
|
|
23099
|
-
webidl.brandCheck(this, WebSocket);
|
|
23859
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23100
23860
|
return this.#binaryType;
|
|
23101
23861
|
}
|
|
23102
23862
|
set binaryType(type) {
|
|
23103
|
-
webidl.brandCheck(this, WebSocket);
|
|
23863
|
+
webidl.brandCheck(this, webidl.is.WebSocket);
|
|
23104
23864
|
if (type !== "blob" && type !== "arraybuffer") {
|
|
23105
23865
|
this.#binaryType = "blob";
|
|
23106
23866
|
} else {
|
|
@@ -23203,23 +23963,26 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
23203
23963
|
});
|
|
23204
23964
|
}
|
|
23205
23965
|
}
|
|
23206
|
-
static
|
|
23207
|
-
|
|
23208
|
-
if (buffer
|
|
23209
|
-
|
|
23966
|
+
static {
|
|
23967
|
+
ping = (ws, buffer) => {
|
|
23968
|
+
if (Buffer.isBuffer(buffer)) {
|
|
23969
|
+
if (buffer.length > 125) {
|
|
23970
|
+
throw new TypeError("A PING frame cannot have a body larger than 125 bytes.");
|
|
23971
|
+
}
|
|
23972
|
+
} else if (buffer !== undefined) {
|
|
23973
|
+
throw new TypeError("Expected buffer payload");
|
|
23210
23974
|
}
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23975
|
+
const readyState = ws.#handler.readyState;
|
|
23976
|
+
if (isEstablished(readyState) && !isClosing(readyState) && !isClosed(readyState)) {
|
|
23977
|
+
const frame = new WebsocketFrameSend(buffer);
|
|
23978
|
+
ws.#handler.socket.write(frame.createFrame(opcodes.PING));
|
|
23979
|
+
}
|
|
23980
|
+
};
|
|
23981
|
+
webidl.is.WebSocket = (arg) => {
|
|
23982
|
+
return arg != null && typeof arg === "object" && #handler in arg;
|
|
23983
|
+
};
|
|
23219
23984
|
}
|
|
23220
23985
|
}
|
|
23221
|
-
var { ping } = WebSocket;
|
|
23222
|
-
Reflect.deleteProperty(WebSocket, "ping");
|
|
23223
23986
|
WebSocket.CONNECTING = WebSocket.prototype.CONNECTING = states.CONNECTING;
|
|
23224
23987
|
WebSocket.OPEN = WebSocket.prototype.OPEN = states.OPEN;
|
|
23225
23988
|
WebSocket.CLOSING = WebSocket.prototype.CLOSING = states.CLOSING;
|
|
@@ -23324,6 +24087,7 @@ var require_websocketerror = __commonJS(function(exports, module) {
|
|
|
23324
24087
|
}
|
|
23325
24088
|
});
|
|
23326
24089
|
}
|
|
24090
|
+
var createUnvalidatedWebSocketError;
|
|
23327
24091
|
|
|
23328
24092
|
class WebSocketError extends createInheritableDOMException() {
|
|
23329
24093
|
#closeCode;
|
|
@@ -23351,15 +24115,18 @@ var require_websocketerror = __commonJS(function(exports, module) {
|
|
|
23351
24115
|
get reason() {
|
|
23352
24116
|
return this.#reason;
|
|
23353
24117
|
}
|
|
23354
|
-
static
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
24118
|
+
static {
|
|
24119
|
+
createUnvalidatedWebSocketError = (message, code, reason) => {
|
|
24120
|
+
const error = new WebSocketError(message, kConstruct);
|
|
24121
|
+
error.#closeCode = code;
|
|
24122
|
+
error.#reason = reason;
|
|
24123
|
+
return error;
|
|
24124
|
+
};
|
|
24125
|
+
webidl.is.WebSocketError = (arg) => {
|
|
24126
|
+
return arg != null && typeof arg === "object" && #reason in arg;
|
|
24127
|
+
};
|
|
23359
24128
|
}
|
|
23360
24129
|
}
|
|
23361
|
-
var { createUnvalidatedWebSocketError } = WebSocketError;
|
|
23362
|
-
delete WebSocketError.createUnvalidatedWebSocketError;
|
|
23363
24130
|
Object.defineProperties(WebSocketError.prototype, {
|
|
23364
24131
|
closeCode: kEnumerableProperty,
|
|
23365
24132
|
reason: kEnumerableProperty,
|
|
@@ -23370,7 +24137,6 @@ var require_websocketerror = __commonJS(function(exports, module) {
|
|
|
23370
24137
|
configurable: true
|
|
23371
24138
|
}
|
|
23372
24139
|
});
|
|
23373
|
-
webidl.is.WebSocketError = webidl.util.MakeTypeAssertion(WebSocketError);
|
|
23374
24140
|
module.exports = { WebSocketError, createUnvalidatedWebSocketError };
|
|
23375
24141
|
});
|
|
23376
24142
|
|
|
@@ -23396,7 +24162,7 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23396
24162
|
#closedPromise;
|
|
23397
24163
|
#readableStream;
|
|
23398
24164
|
#readableStreamController;
|
|
23399
|
-
#
|
|
24165
|
+
#writableStreamController;
|
|
23400
24166
|
#handshakeAborted = false;
|
|
23401
24167
|
#handler = {
|
|
23402
24168
|
onConnectionEstablished: (response, extensions) => this.#onConnectionEstablished(response, extensions),
|
|
@@ -23415,7 +24181,7 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23415
24181
|
}
|
|
23416
24182
|
this.#handler.socket.destroy();
|
|
23417
24183
|
},
|
|
23418
|
-
onSocketClose: () => this.#onSocketClose(),
|
|
24184
|
+
onSocketClose: () => queueMicrotask(() => this.#onSocketClose()),
|
|
23419
24185
|
onPing: () => {},
|
|
23420
24186
|
onPong: () => {},
|
|
23421
24187
|
readyState: states.CONNECTING,
|
|
@@ -23510,6 +24276,8 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23510
24276
|
this.#handler.socket.write(frame.createFrame(opcode), () => {
|
|
23511
24277
|
promise.resolve(undefined);
|
|
23512
24278
|
});
|
|
24279
|
+
} else {
|
|
24280
|
+
promise.resolve(undefined);
|
|
23513
24281
|
}
|
|
23514
24282
|
return promise.promise;
|
|
23515
24283
|
}
|
|
@@ -23525,21 +24293,24 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23525
24293
|
parser.on("error", (err) => this.#handler.onParserError(err));
|
|
23526
24294
|
this.#parser = parser;
|
|
23527
24295
|
this.#handler.readyState = states.OPEN;
|
|
23528
|
-
const extensions =
|
|
24296
|
+
const extensions = response.headersList.get("sec-websocket-extensions") ?? "";
|
|
23529
24297
|
const protocol = response.headersList.get("sec-websocket-protocol") ?? "";
|
|
23530
24298
|
const readable = new ReadableStream({
|
|
23531
24299
|
start: (controller) => {
|
|
23532
24300
|
this.#readableStreamController = controller;
|
|
23533
24301
|
},
|
|
24302
|
+
pull: () => this.#pull(),
|
|
23534
24303
|
cancel: (reason) => this.#cancel(reason)
|
|
23535
24304
|
});
|
|
23536
24305
|
const writable = new WritableStream({
|
|
24306
|
+
start: (controller) => {
|
|
24307
|
+
this.#writableStreamController = controller;
|
|
24308
|
+
},
|
|
23537
24309
|
write: (chunk) => this.#write(chunk),
|
|
23538
24310
|
close: () => closeWebSocketConnection(this.#handler, null, null),
|
|
23539
24311
|
abort: (reason) => this.#closeUsingReason(reason)
|
|
23540
24312
|
});
|
|
23541
24313
|
this.#readableStream = readable;
|
|
23542
|
-
this.#writableStream = writable;
|
|
23543
24314
|
this.#openedPromise.resolve({
|
|
23544
24315
|
extensions,
|
|
23545
24316
|
protocol,
|
|
@@ -23563,6 +24334,9 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23563
24334
|
chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
23564
24335
|
}
|
|
23565
24336
|
this.#readableStreamController.enqueue(chunk);
|
|
24337
|
+
if (this.#readableStreamController.desiredSize <= 0) {
|
|
24338
|
+
this.#handler.socket.pause();
|
|
24339
|
+
}
|
|
23566
24340
|
}
|
|
23567
24341
|
#onSocketClose() {
|
|
23568
24342
|
const wasClean = this.#handler.closeState.has(sentCloseFrameState.SENT) && this.#handler.closeState.has(sentCloseFrameState.RECEIVED);
|
|
@@ -23575,15 +24349,13 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23575
24349
|
}
|
|
23576
24350
|
const result = this.#parser?.closingInfo;
|
|
23577
24351
|
let code = result?.code ?? 1005;
|
|
23578
|
-
if (!this.#handler.closeState.has(sentCloseFrameState.
|
|
24352
|
+
if (!this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
23579
24353
|
code = 1006;
|
|
23580
24354
|
}
|
|
23581
24355
|
const reason = result?.reason == null ? "" : utf8DecodeBytes(Buffer.from(result.reason));
|
|
23582
24356
|
if (wasClean) {
|
|
23583
24357
|
readableStreamClose(this.#readableStreamController);
|
|
23584
|
-
|
|
23585
|
-
this.#writableStream.abort(new DOMException("A closed WebSocketStream cannot be written to", "InvalidStateError"));
|
|
23586
|
-
}
|
|
24358
|
+
this.#writableStreamController.error(new DOMException("A closed WebSocketStream cannot be written to", "InvalidStateError"));
|
|
23587
24359
|
this.#closedPromise.resolve({
|
|
23588
24360
|
closeCode: code,
|
|
23589
24361
|
reason
|
|
@@ -23591,7 +24363,7 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23591
24363
|
} else {
|
|
23592
24364
|
const error = createUnvalidatedWebSocketError("unclean close", code, reason);
|
|
23593
24365
|
this.#readableStreamController?.error(error);
|
|
23594
|
-
this.#
|
|
24366
|
+
this.#writableStreamController?.error(error);
|
|
23595
24367
|
this.#closedPromise.reject(error);
|
|
23596
24368
|
}
|
|
23597
24369
|
}
|
|
@@ -23604,6 +24376,9 @@ var require_websocketstream = __commonJS(function(exports, module) {
|
|
|
23604
24376
|
}
|
|
23605
24377
|
closeWebSocketConnection(this.#handler, code, reasonString);
|
|
23606
24378
|
}
|
|
24379
|
+
#pull() {
|
|
24380
|
+
this.#handler.socket.resume();
|
|
24381
|
+
}
|
|
23607
24382
|
#cancel(reason) {
|
|
23608
24383
|
this.#closeUsingReason(reason);
|
|
23609
24384
|
}
|
|
@@ -23693,6 +24468,7 @@ var require_util6 = __commonJS(function(exports, module) {
|
|
|
23693
24468
|
|
|
23694
24469
|
// ../../node_modules/undici/lib/web/eventsource/eventsource-stream.js
|
|
23695
24470
|
var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
24471
|
+
var buffer = __require("node:buffer");
|
|
23696
24472
|
var { Transform } = __require("node:stream");
|
|
23697
24473
|
var { isASCIINumber, isValidLastEventId } = require_util6();
|
|
23698
24474
|
var BOM = [239, 187, 191];
|
|
@@ -23700,24 +24476,25 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23700
24476
|
var CR = 13;
|
|
23701
24477
|
var COLON = 58;
|
|
23702
24478
|
var SPACE = 32;
|
|
24479
|
+
var defaultMaxEventSize = buffer.kStringMaxLength;
|
|
23703
24480
|
var DATA = Buffer.from("data");
|
|
23704
24481
|
var EVENT = Buffer.from("event");
|
|
23705
24482
|
var ID = Buffer.from("id");
|
|
23706
24483
|
var RETRY = Buffer.from("retry");
|
|
23707
|
-
function isASCIINumberBytes(
|
|
23708
|
-
if (start >=
|
|
24484
|
+
function isASCIINumberBytes(buffer2, start) {
|
|
24485
|
+
if (start >= buffer2.length) {
|
|
23709
24486
|
return false;
|
|
23710
24487
|
}
|
|
23711
|
-
for (let i = start;i <
|
|
23712
|
-
if (
|
|
24488
|
+
for (let i = start;i < buffer2.length; i++) {
|
|
24489
|
+
if (buffer2[i] < 48 || buffer2[i] > 57) {
|
|
23713
24490
|
return false;
|
|
23714
24491
|
}
|
|
23715
24492
|
}
|
|
23716
24493
|
return true;
|
|
23717
24494
|
}
|
|
23718
|
-
function isValidLastEventIdBytes(
|
|
23719
|
-
for (let i = start;i <
|
|
23720
|
-
if (
|
|
24495
|
+
function isValidLastEventIdBytes(buffer2, start) {
|
|
24496
|
+
for (let i = start;i < buffer2.length; i++) {
|
|
24497
|
+
if (buffer2[i] === 0) {
|
|
23721
24498
|
return false;
|
|
23722
24499
|
}
|
|
23723
24500
|
}
|
|
@@ -23734,6 +24511,11 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23734
24511
|
}
|
|
23735
24512
|
return true;
|
|
23736
24513
|
}
|
|
24514
|
+
function createMaxEventSizeExceededError() {
|
|
24515
|
+
const error = new Error("EventSource message size exceeded");
|
|
24516
|
+
error.aborted = false;
|
|
24517
|
+
return error;
|
|
24518
|
+
}
|
|
23737
24519
|
|
|
23738
24520
|
class EventSourceStream extends Transform {
|
|
23739
24521
|
state;
|
|
@@ -23745,6 +24527,8 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23745
24527
|
pos = 0;
|
|
23746
24528
|
lineChunkIndex = 0;
|
|
23747
24529
|
linePos = 0;
|
|
24530
|
+
eventDataSize = 0;
|
|
24531
|
+
maxEventSize;
|
|
23748
24532
|
event = {
|
|
23749
24533
|
data: undefined,
|
|
23750
24534
|
event: undefined,
|
|
@@ -23755,6 +24539,7 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23755
24539
|
options.readableObjectMode = true;
|
|
23756
24540
|
super(options);
|
|
23757
24541
|
this.state = options.eventSourceSettings || {};
|
|
24542
|
+
this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize;
|
|
23758
24543
|
if (options.push) {
|
|
23759
24544
|
this.push = options.push;
|
|
23760
24545
|
}
|
|
@@ -23800,7 +24585,12 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23800
24585
|
if (byte === CR) {
|
|
23801
24586
|
this.crlfCheck = true;
|
|
23802
24587
|
}
|
|
23803
|
-
|
|
24588
|
+
try {
|
|
24589
|
+
this.parseLine(this.readLine(), this.event);
|
|
24590
|
+
} catch (error) {
|
|
24591
|
+
callback(error);
|
|
24592
|
+
return;
|
|
24593
|
+
}
|
|
23804
24594
|
this.consumeCurrentByte();
|
|
23805
24595
|
this.eventEndCheck = true;
|
|
23806
24596
|
continue;
|
|
@@ -23827,6 +24617,11 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23827
24617
|
}
|
|
23828
24618
|
}
|
|
23829
24619
|
if (isFieldName(line, fieldLength, DATA)) {
|
|
24620
|
+
const valueBytes = line.length - valueStart;
|
|
24621
|
+
const eventDataSize = this.eventDataSize + (event.data === undefined ? 0 : 1) + valueBytes;
|
|
24622
|
+
if (this.maxEventSize > 0 && eventDataSize > this.maxEventSize) {
|
|
24623
|
+
throw createMaxEventSizeExceededError();
|
|
24624
|
+
}
|
|
23830
24625
|
const value = line.toString("utf8", valueStart);
|
|
23831
24626
|
if (event.data === undefined) {
|
|
23832
24627
|
event.data = value;
|
|
@@ -23834,6 +24629,7 @@ var require_eventsource_stream = __commonJS(function(exports, module) {
|
|
|
23834
24629
|
event.data += `
|
|
23835
24630
|
${value}`;
|
|
23836
24631
|
}
|
|
24632
|
+
this.eventDataSize = eventDataSize;
|
|
23837
24633
|
return;
|
|
23838
24634
|
}
|
|
23839
24635
|
if (isFieldName(line, fieldLength, RETRY)) {
|
|
@@ -23878,6 +24674,7 @@ ${value}`;
|
|
|
23878
24674
|
this.event.event = undefined;
|
|
23879
24675
|
this.event.id = undefined;
|
|
23880
24676
|
this.event.retry = undefined;
|
|
24677
|
+
this.eventDataSize = 0;
|
|
23881
24678
|
}
|
|
23882
24679
|
hasPendingEvent() {
|
|
23883
24680
|
return this.event.data !== undefined || this.event.event !== undefined || this.event.id !== undefined || this.event.retry !== undefined;
|
|
@@ -24004,9 +24801,12 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24004
24801
|
var { parseMIMEType } = require_data_url();
|
|
24005
24802
|
var { createFastMessageEvent } = require_events();
|
|
24006
24803
|
var { isNetworkError } = require_response();
|
|
24007
|
-
var { kEnumerableProperty } = require_util();
|
|
24804
|
+
var { isValidHeaderValue, kEnumerableProperty } = require_util();
|
|
24008
24805
|
var { environmentSettingsObject } = require_util2();
|
|
24009
24806
|
var { createPotentialCORSRequest } = require_util6();
|
|
24807
|
+
var { getGlobalDispatcher } = require_global2();
|
|
24808
|
+
var { isomorphicDecode } = require_infra();
|
|
24809
|
+
var textEncoder = new TextEncoder;
|
|
24010
24810
|
var experimentalWarned = false;
|
|
24011
24811
|
var defaultReconnectionTime = 3000;
|
|
24012
24812
|
var CONNECTING = 0;
|
|
@@ -24069,12 +24869,15 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24069
24869
|
this.#connect();
|
|
24070
24870
|
}
|
|
24071
24871
|
get readyState() {
|
|
24872
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24072
24873
|
return this.#readyState;
|
|
24073
24874
|
}
|
|
24074
24875
|
get url() {
|
|
24876
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24075
24877
|
return this.#url;
|
|
24076
24878
|
}
|
|
24077
24879
|
get withCredentials() {
|
|
24880
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24078
24881
|
return this.#withCredentials;
|
|
24079
24882
|
}
|
|
24080
24883
|
#connect() {
|
|
@@ -24115,6 +24918,7 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24115
24918
|
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
|
24116
24919
|
const eventSourceStream = new EventSourceStream({
|
|
24117
24920
|
eventSourceSettings: this.#state,
|
|
24921
|
+
maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,
|
|
24118
24922
|
push: (event) => {
|
|
24119
24923
|
this.dispatchEvent(createFastMessageEvent(event.type, event.options));
|
|
24120
24924
|
}
|
|
@@ -24136,14 +24940,18 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24136
24940
|
setTimeout(() => {
|
|
24137
24941
|
if (this.#readyState !== CONNECTING)
|
|
24138
24942
|
return;
|
|
24943
|
+
this.#request.headersList.delete("last-event-id", true);
|
|
24139
24944
|
if (this.#state.lastEventId.length) {
|
|
24140
|
-
|
|
24945
|
+
const lastEventId = isomorphicDecode(textEncoder.encode(this.#state.lastEventId));
|
|
24946
|
+
if (isValidHeaderValue(lastEventId)) {
|
|
24947
|
+
this.#request.headersList.set("last-event-id", lastEventId, true);
|
|
24948
|
+
}
|
|
24141
24949
|
}
|
|
24142
24950
|
this.#connect();
|
|
24143
24951
|
}, this.#state.reconnectionTime)?.unref();
|
|
24144
24952
|
}
|
|
24145
24953
|
close() {
|
|
24146
|
-
webidl.brandCheck(this, EventSource);
|
|
24954
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24147
24955
|
if (this.#readyState === CLOSED)
|
|
24148
24956
|
return;
|
|
24149
24957
|
this.#readyState = CLOSED;
|
|
@@ -24151,9 +24959,11 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24151
24959
|
this.#request = null;
|
|
24152
24960
|
}
|
|
24153
24961
|
get onopen() {
|
|
24962
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24154
24963
|
return this.#events.open;
|
|
24155
24964
|
}
|
|
24156
24965
|
set onopen(fn) {
|
|
24966
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24157
24967
|
if (this.#events.open) {
|
|
24158
24968
|
this.removeEventListener("open", this.#events.open);
|
|
24159
24969
|
}
|
|
@@ -24166,9 +24976,11 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24166
24976
|
}
|
|
24167
24977
|
}
|
|
24168
24978
|
get onmessage() {
|
|
24979
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24169
24980
|
return this.#events.message;
|
|
24170
24981
|
}
|
|
24171
24982
|
set onmessage(fn) {
|
|
24983
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24172
24984
|
if (this.#events.message) {
|
|
24173
24985
|
this.removeEventListener("message", this.#events.message);
|
|
24174
24986
|
}
|
|
@@ -24181,9 +24993,11 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24181
24993
|
}
|
|
24182
24994
|
}
|
|
24183
24995
|
get onerror() {
|
|
24996
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24184
24997
|
return this.#events.error;
|
|
24185
24998
|
}
|
|
24186
24999
|
set onerror(fn) {
|
|
25000
|
+
webidl.brandCheck(this, webidl.is.EventSource);
|
|
24187
25001
|
if (this.#events.error) {
|
|
24188
25002
|
this.removeEventListener("error", this.#events.error);
|
|
24189
25003
|
}
|
|
@@ -24195,6 +25009,11 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24195
25009
|
this.#events.error = null;
|
|
24196
25010
|
}
|
|
24197
25011
|
}
|
|
25012
|
+
static {
|
|
25013
|
+
webidl.is.EventSource = (arg) => {
|
|
25014
|
+
return arg != null && typeof arg === "object" && #events in arg;
|
|
25015
|
+
};
|
|
25016
|
+
}
|
|
24198
25017
|
}
|
|
24199
25018
|
var constantsPropertyDescriptors = {
|
|
24200
25019
|
CONNECTING: {
|
|
@@ -24238,7 +25057,8 @@ var require_eventsource = __commonJS(function(exports, module) {
|
|
|
24238
25057
|
},
|
|
24239
25058
|
{
|
|
24240
25059
|
key: "dispatcher",
|
|
24241
|
-
converter: webidl.converters.any
|
|
25060
|
+
converter: webidl.converters.any,
|
|
25061
|
+
defaultValue: () => getGlobalDispatcher()
|
|
24242
25062
|
},
|
|
24243
25063
|
{
|
|
24244
25064
|
key: "node",
|
|
@@ -24693,4 +25513,4 @@ export default {
|
|
|
24693
25513
|
}
|
|
24694
25514
|
};
|
|
24695
25515
|
|
|
24696
|
-
//# debugId=
|
|
25516
|
+
//# debugId=9BCC838F27888F1964756E2164756E21
|