@datadog/datadog-ci-plugin-terraform 5.19.0 → 5.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -10914,7 +10914,7 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
10914
10914
  var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10915
10915
  module.exports = {
10916
10916
  "name": "@datadog/datadog-ci-base",
10917
- "version": "5.19.0",
10917
+ "version": "5.20.1",
10918
10918
  "description": "Base package for Datadog CI",
10919
10919
  "license": "Apache-2.0",
10920
10920
  "keywords": ["datadog", "datadog-ci"],
@@ -11011,12 +11011,12 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11011
11011
  "debug": "^4.4.1",
11012
11012
  "deep-extend": "^0.6.0",
11013
11013
  "fast-xml-parser": "^5.7.2",
11014
- "form-data": "^4.0.4",
11014
+ "form-data": "^4.0.6",
11015
11015
  "glob": "^13.0.6",
11016
11016
  "inquirer": "^8.2.7",
11017
11017
  "is-docker": "^4.0.0",
11018
11018
  "jest-diff": "^30.2.0",
11019
- "js-yaml": "^4.1.1",
11019
+ "js-yaml": "^4.2.0",
11020
11020
  "jszip": "^3.10.1",
11021
11021
  "proxy-agent": "^6.4.0",
11022
11022
  "semver": "^7.6.3",
@@ -11024,7 +11024,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11024
11024
  "terminal-link": "^2.1.1",
11025
11025
  "tiny-async-pool": "^2.1.0",
11026
11026
  "typanion": "^3.14.0",
11027
- "undici": "^7.24.6",
11027
+ "undici": "^7.28.0",
11028
11028
  "upath": "^2.0.1"
11029
11029
  },
11030
11030
  "devDependencies": {
@@ -11039,6 +11039,71 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11039
11039
  };
11040
11040
  }));
11041
11041
  //#endregion
11042
+ //#region ../base/dist/constants.js
11043
+ var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
11044
+ Object.defineProperty(exports, "__esModule", { value: true });
11045
+ exports.METHOD_POST = exports.CONTENT_TYPE_VALUE_JSON = exports.CONTENT_TYPE_VALUE_PROTOBUF = exports.CONTENT_TYPE_HEADER = exports.SKIP_VERSION_BANNER_ENV_VAR = exports.LOG_FORMAT_ENV_VAR = exports.FIPS_IGNORE_ERROR_ENV_VAR = exports.FIPS_ENV_VAR = exports.DATADOG_SITES = exports.DATADOG_SITE_US2_GOV = exports.DATADOG_SITE_GOV = exports.DATADOG_SITE_AP2 = exports.DATADOG_SITE_AP1 = exports.DATADOG_SITE_US5 = exports.DATADOG_SITE_US3 = exports.DATADOG_SITE_EU1 = exports.DATADOG_SITE_US1 = void 0;
11046
+ exports.DATADOG_SITE_US1 = "datadoghq.com";
11047
+ exports.DATADOG_SITE_EU1 = "datadoghq.eu";
11048
+ exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
11049
+ exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
11050
+ exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
11051
+ exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
11052
+ exports.DATADOG_SITE_GOV = "ddog-gov.com";
11053
+ exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
11054
+ exports.DATADOG_SITES = [
11055
+ exports.DATADOG_SITE_US1,
11056
+ exports.DATADOG_SITE_EU1,
11057
+ exports.DATADOG_SITE_US3,
11058
+ exports.DATADOG_SITE_US5,
11059
+ exports.DATADOG_SITE_AP1,
11060
+ exports.DATADOG_SITE_AP2,
11061
+ exports.DATADOG_SITE_GOV,
11062
+ exports.DATADOG_SITE_US2_GOV
11063
+ ];
11064
+ exports.FIPS_ENV_VAR = "DATADOG_FIPS";
11065
+ exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
11066
+ exports.LOG_FORMAT_ENV_VAR = "DD_LOG_FORMAT";
11067
+ exports.SKIP_VERSION_BANNER_ENV_VAR = "DD_CI_SKIP_VERSION_BANNER";
11068
+ exports.CONTENT_TYPE_HEADER = "Content-Type";
11069
+ exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
11070
+ exports.CONTENT_TYPE_VALUE_JSON = "application/json";
11071
+ exports.METHOD_POST = "post";
11072
+ }));
11073
+ //#endregion
11074
+ //#region ../base/dist/helpers/env.js
11075
+ var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
11076
+ Object.defineProperty(exports, "__esModule", { value: true });
11077
+ exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
11078
+ const toBoolean = (env) => {
11079
+ if (env === void 0) return;
11080
+ if (env.toLowerCase() === "true" || env === "1") return true;
11081
+ if (env.toLowerCase() === "false" || env === "0") return false;
11082
+ };
11083
+ exports.toBoolean = toBoolean;
11084
+ const toNumber = (env) => {
11085
+ if (env === void 0 || env.trim() === "") return;
11086
+ const number = Number(env);
11087
+ if (isNaN(number)) return;
11088
+ return number;
11089
+ };
11090
+ exports.toNumber = toNumber;
11091
+ const toStringMap = (env) => {
11092
+ if (env === void 0) return;
11093
+ const cleanedEnv = env.replace(/'/g, "\"");
11094
+ try {
11095
+ const parsed = JSON.parse(cleanedEnv);
11096
+ if (typeof parsed === "object" && parsed !== null) {
11097
+ for (const key in parsed) if (typeof parsed[key] !== "string") return;
11098
+ return parsed;
11099
+ }
11100
+ } catch (error) {
11101
+ return;
11102
+ }
11103
+ };
11104
+ exports.toStringMap = toStringMap;
11105
+ }));
11106
+ //#endregion
11042
11107
  //#region ../base/dist/version.js
11043
11108
  var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
11044
11109
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -11047,18 +11112,29 @@ var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
11047
11112
  Object.defineProperty(exports, "__esModule", { value: true });
11048
11113
  exports.printVersion = exports.cliVersion = void 0;
11049
11114
  const chalk_1 = __importDefault(require_source());
11050
- exports.cliVersion = require_package$1().version;
11115
+ const package_json_1 = require_package$1();
11116
+ const constants_1 = require_constants$10();
11117
+ const env_1 = require_env();
11118
+ exports.cliVersion = package_json_1.version;
11051
11119
  /**
11052
- * Prints version in all commands, except version commands.
11120
+ * Logs the version in all commands, except version commands. Routed through the
11121
+ * logger so it respects `--log-format` (a JSON line in JSON mode, dim text otherwise).
11122
+ *
11123
+ * Suppressed entirely when `DD_CI_SKIP_VERSION_BANNER` is `1`/`true`, for callers
11124
+ * that find the per-invocation banner too noisy.
11053
11125
  */
11054
- const printVersion = () => {
11055
- if (!(process.argv.at(-1) === "--version" || process.argv.at(-1) === "version")) process.stdout.write(chalk_1.default.dim(`datadog-ci v${exports.cliVersion}\n`));
11126
+ const printVersion = (logger) => {
11127
+ if ((0, env_1.toBoolean)(process.env[constants_1.SKIP_VERSION_BANNER_ENV_VAR])) return;
11128
+ const lastArg = process.argv.at(-1);
11129
+ if (lastArg === "--version" || lastArg === "version" || lastArg === "--help") return;
11130
+ const banner = `datadog-ci v${exports.cliVersion}`;
11131
+ logger.info(logger.isJsonOutput() ? banner : chalk_1.default.dim(banner));
11056
11132
  };
11057
11133
  exports.printVersion = printVersion;
11058
11134
  }));
11059
11135
  //#endregion
11060
11136
  //#region ../../node_modules/clipanion/lib/constants.js
11061
- var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
11137
+ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
11062
11138
  Object.defineProperty(exports, "__esModule", { value: true });
11063
11139
  const NODE_INITIAL = 0;
11064
11140
  const NODE_SUCCESS = 1;
@@ -11087,7 +11163,7 @@ var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
11087
11163
  //#region ../../node_modules/clipanion/lib/errors.js
11088
11164
  var require_errors$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
11089
11165
  Object.defineProperty(exports, "__esModule", { value: true });
11090
- var constants = require_constants$10();
11166
+ var constants = require_constants$9();
11091
11167
  /**
11092
11168
  * A generic usage error with the name `UsageError`.
11093
11169
  *
@@ -12375,7 +12451,7 @@ var require_Command = /* @__PURE__ */ __commonJSMin(((exports) => {
12375
12451
  //#region ../../node_modules/clipanion/lib/core.js
12376
12452
  var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
12377
12453
  Object.defineProperty(exports, "__esModule", { value: true });
12378
- var constants = require_constants$10();
12454
+ var constants = require_constants$9();
12379
12455
  var errors = require_errors$3();
12380
12456
  function debug(str) {
12381
12457
  if (constants.DEBUG) console.log(str);
@@ -13272,7 +13348,7 @@ var require_HelpCommand = /* @__PURE__ */ __commonJSMin(((exports) => {
13272
13348
  //#region ../../node_modules/clipanion/lib/advanced/Cli.js
13273
13349
  var require_Cli = /* @__PURE__ */ __commonJSMin(((exports) => {
13274
13350
  Object.defineProperty(exports, "__esModule", { value: true });
13275
- var constants = require_constants$10();
13351
+ var constants = require_constants$9();
13276
13352
  var core = require_core$1();
13277
13353
  var format = require_format();
13278
13354
  var platform = require_node$1();
@@ -14959,7 +15035,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14959
15035
  };
14960
15036
  Object.defineProperty(exports, "__esModule", { value: true });
14961
15037
  exports.Agent = void 0;
14962
- const net$11 = __importStar(require("net"));
15038
+ const net$10 = __importStar(require("net"));
14963
15039
  const http$3 = __importStar(require("http"));
14964
15040
  const https_1$2 = require("https");
14965
15041
  __exportStar(require_helpers$2(), exports);
@@ -14984,7 +15060,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14984
15060
  incrementSockets(name) {
14985
15061
  if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
14986
15062
  if (!this.sockets[name]) this.sockets[name] = [];
14987
- const fakeSocket = new net$11.Socket({ writable: false });
15063
+ const fakeSocket = new net$10.Socket({ writable: false });
14988
15064
  this.sockets[name].push(fakeSocket);
14989
15065
  this.totalSocketCount++;
14990
15066
  return fakeSocket;
@@ -15153,7 +15229,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15153
15229
  };
15154
15230
  Object.defineProperty(exports, "__esModule", { value: true });
15155
15231
  exports.HttpProxyAgent = void 0;
15156
- const net$10 = __importStar(require("net"));
15232
+ const net$9 = __importStar(require("net"));
15157
15233
  const tls$3 = __importStar(require("tls"));
15158
15234
  const debug_1 = __importDefault(require_src$1());
15159
15235
  const events_1$3 = require("events");
@@ -15220,7 +15296,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15220
15296
  socket = tls$3.connect(this.connectOpts);
15221
15297
  } else {
15222
15298
  debug("Creating `net.Socket`: %o", this.connectOpts);
15223
- socket = net$10.connect(this.connectOpts);
15299
+ socket = net$9.connect(this.connectOpts);
15224
15300
  }
15225
15301
  await (0, events_1$3.once)(socket, "connect");
15226
15302
  return socket;
@@ -15359,7 +15435,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15359
15435
  };
15360
15436
  Object.defineProperty(exports, "__esModule", { value: true });
15361
15437
  exports.HttpsProxyAgent = void 0;
15362
- const net$9 = __importStar(require("net"));
15438
+ const net$8 = __importStar(require("net"));
15363
15439
  const tls$2 = __importStar(require("tls"));
15364
15440
  const assert_1 = __importDefault(require("assert"));
15365
15441
  const debug_1 = __importDefault(require_src$1());
@@ -15368,7 +15444,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15368
15444
  const parse_proxy_response_1 = require_parse_proxy_response();
15369
15445
  const debug = (0, debug_1.default)("https-proxy-agent");
15370
15446
  const setServernameFromNonIpHost = (options) => {
15371
- if (options.servername === void 0 && options.host && !net$9.isIP(options.host)) return {
15447
+ if (options.servername === void 0 && options.host && !net$8.isIP(options.host)) return {
15372
15448
  ...options,
15373
15449
  servername: options.host
15374
15450
  };
@@ -15415,10 +15491,10 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15415
15491
  socket = tls$2.connect(setServernameFromNonIpHost(this.connectOpts));
15416
15492
  } else {
15417
15493
  debug("Creating `net.Socket`: %o", this.connectOpts);
15418
- socket = net$9.connect(this.connectOpts);
15494
+ socket = net$8.connect(this.connectOpts);
15419
15495
  }
15420
15496
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
15421
- const host = net$9.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15497
+ const host = net$8.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15422
15498
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
15423
15499
  if (proxy.username || proxy.password) {
15424
15500
  const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
@@ -15444,7 +15520,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15444
15520
  return socket;
15445
15521
  }
15446
15522
  socket.destroy();
15447
- const fakeSocket = new net$9.Socket({ writable: false });
15523
+ const fakeSocket = new net$8.Socket({ writable: false });
15448
15524
  fakeSocket.readable = true;
15449
15525
  req.once("socket", (s) => {
15450
15526
  debug("Replaying proxy buffer for failed request");
@@ -16653,7 +16729,7 @@ var require_smartbuffer = /* @__PURE__ */ __commonJSMin(((exports) => {
16653
16729
  }));
16654
16730
  //#endregion
16655
16731
  //#region ../../node_modules/socks/build/common/constants.js
16656
- var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
16732
+ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
16657
16733
  Object.defineProperty(exports, "__esModule", { value: true });
16658
16734
  exports.SOCKS5_NO_ACCEPTABLE_AUTH = exports.SOCKS5_CUSTOM_AUTH_END = exports.SOCKS5_CUSTOM_AUTH_START = exports.SOCKS_INCOMING_PACKET_SIZES = exports.SocksClientState = exports.Socks5Response = exports.Socks5HostType = exports.Socks5Auth = exports.Socks4Response = exports.SocksCommand = exports.ERRORS = exports.DEFAULT_TIMEOUT = void 0;
16659
16735
  exports.DEFAULT_TIMEOUT = 3e4;
@@ -16801,7 +16877,7 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
16801
16877
  }));
16802
16878
  //#endregion
16803
16879
  //#region ../../node_modules/ip-address/dist/v4/constants.js
16804
- var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
16880
+ var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
16805
16881
  Object.defineProperty(exports, "__esModule", { value: true });
16806
16882
  exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = void 0;
16807
16883
  exports.BITS = 32;
@@ -18438,7 +18514,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18438
18514
  Object.defineProperty(exports, "__esModule", { value: true });
18439
18515
  exports.Address4 = void 0;
18440
18516
  const common = __importStar(require_common$1());
18441
- const constants = __importStar(require_constants$8());
18517
+ const constants = __importStar(require_constants$7());
18442
18518
  const address_error_1 = require_address_error();
18443
18519
  const jsbn_1 = require_jsbn();
18444
18520
  const sprintf_js_1 = require_sprintf();
@@ -18714,7 +18790,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18714
18790
  }));
18715
18791
  //#endregion
18716
18792
  //#region ../../node_modules/ip-address/dist/v6/constants.js
18717
- var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
18793
+ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18718
18794
  Object.defineProperty(exports, "__esModule", { value: true });
18719
18795
  exports.RE_URL_WITH_PORT = exports.RE_URL = exports.RE_ZONE_STRING = exports.RE_SUBNET_STRING = exports.RE_BAD_ADDRESS = exports.RE_BAD_CHARACTERS = exports.TYPES = exports.SCOPES = exports.GROUPS = exports.BITS = void 0;
18720
18796
  exports.BITS = 128;
@@ -18868,7 +18944,7 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18868
18944
  };
18869
18945
  Object.defineProperty(exports, "__esModule", { value: true });
18870
18946
  exports.possibleElisions = exports.simpleRegularExpression = exports.ADDRESS_BOUNDARY = exports.padGroup = exports.groupPossibilities = void 0;
18871
- const v6 = __importStar(require_constants$7());
18947
+ const v6 = __importStar(require_constants$6());
18872
18948
  const sprintf_js_1 = require_sprintf();
18873
18949
  function groupPossibilities(possibilities) {
18874
18950
  return (0, sprintf_js_1.sprintf)("(%s)", possibilities.join("|"));
@@ -18948,8 +19024,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18948
19024
  Object.defineProperty(exports, "__esModule", { value: true });
18949
19025
  exports.Address6 = void 0;
18950
19026
  const common = __importStar(require_common$1());
18951
- const constants4 = __importStar(require_constants$8());
18952
- const constants6 = __importStar(require_constants$7());
19027
+ const constants4 = __importStar(require_constants$7());
19028
+ const constants6 = __importStar(require_constants$6());
18953
19029
  const helpers = __importStar(require_helpers$1());
18954
19030
  const ipv4_1 = require_ipv4();
18955
19031
  const regular_expressions_1 = require_regular_expressions();
@@ -19767,10 +19843,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19767
19843
  Object.defineProperty(exports, "__esModule", { value: true });
19768
19844
  exports.ipToBuffer = exports.int32ToIpv4 = exports.ipv4ToInt32 = exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = void 0;
19769
19845
  const util_1 = require_util$8();
19770
- const constants_1 = require_constants$9();
19846
+ const constants_1 = require_constants$8();
19771
19847
  const stream$1 = require("stream");
19772
19848
  const ip_address_1 = require_ip_address();
19773
- const net$8 = require("net");
19849
+ const net$7 = require("net");
19774
19850
  /**
19775
19851
  * Validates the provided SocksClientOptions
19776
19852
  * @param options { SocksClientOptions }
@@ -19848,10 +19924,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19848
19924
  }
19849
19925
  exports.int32ToIpv4 = int32ToIpv4;
19850
19926
  function ipToBuffer(ip) {
19851
- if (net$8.isIPv4(ip)) {
19927
+ if (net$7.isIPv4(ip)) {
19852
19928
  const address = new ip_address_1.Address4(ip);
19853
19929
  return Buffer.from(address.toArray());
19854
- } else if (net$8.isIPv6(ip)) {
19930
+ } else if (net$7.isIPv6(ip)) {
19855
19931
  const address = new ip_address_1.Address6(ip);
19856
19932
  return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
19857
19933
  } else throw new Error("Invalid IP address format");
@@ -19930,9 +20006,9 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
19930
20006
  Object.defineProperty(exports, "__esModule", { value: true });
19931
20007
  exports.SocksClientError = exports.SocksClient = void 0;
19932
20008
  const events_1$2 = require("events");
19933
- const net$7 = require("net");
20009
+ const net$6 = require("net");
19934
20010
  const smart_buffer_1 = require_smartbuffer();
19935
- const constants_1 = require_constants$9();
20011
+ const constants_1 = require_constants$8();
19936
20012
  const helpers_1 = require_helpers();
19937
20013
  const receivebuffer_1 = require_receivebuffer();
19938
20014
  const util_1 = require_util$8();
@@ -20042,10 +20118,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20042
20118
  const buff = new smart_buffer_1.SmartBuffer();
20043
20119
  buff.writeUInt16BE(0);
20044
20120
  buff.writeUInt8(options.frameNumber || 0);
20045
- if (net$7.isIPv4(options.remoteHost.host)) {
20121
+ if (net$6.isIPv4(options.remoteHost.host)) {
20046
20122
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20047
20123
  buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
20048
- } else if (net$7.isIPv6(options.remoteHost.host)) {
20124
+ } else if (net$6.isIPv6(options.remoteHost.host)) {
20049
20125
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20050
20126
  buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
20051
20127
  } else {
@@ -20098,7 +20174,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20098
20174
  const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
20099
20175
  if (timer.unref && typeof timer.unref === "function") timer.unref();
20100
20176
  if (existingSocket) this.socket = existingSocket;
20101
- else this.socket = new net$7.Socket();
20177
+ else this.socket = new net$6.Socket();
20102
20178
  this.socket.once("close", this.onClose);
20103
20179
  this.socket.once("error", this.onError);
20104
20180
  this.socket.once("connect", this.onConnect);
@@ -20210,7 +20286,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20210
20286
  buff.writeUInt8(4);
20211
20287
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20212
20288
  buff.writeUInt16BE(this.options.destination.port);
20213
- if (net$7.isIPv4(this.options.destination.host)) {
20289
+ if (net$6.isIPv4(this.options.destination.host)) {
20214
20290
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20215
20291
  buff.writeStringNT(userId);
20216
20292
  } else {
@@ -20369,10 +20445,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20369
20445
  buff.writeUInt8(5);
20370
20446
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20371
20447
  buff.writeUInt8(0);
20372
- if (net$7.isIPv4(this.options.destination.host)) {
20448
+ if (net$6.isIPv4(this.options.destination.host)) {
20373
20449
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20374
20450
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20375
- } else if (net$7.isIPv6(this.options.destination.host)) {
20451
+ } else if (net$6.isIPv6(this.options.destination.host)) {
20376
20452
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20377
20453
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20378
20454
  } else {
@@ -20582,12 +20658,12 @@ var require_dist$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
20582
20658
  const agent_base_1 = require_dist$11();
20583
20659
  const debug_1 = __importDefault(require_src$1());
20584
20660
  const dns = __importStar(require("dns"));
20585
- const net$6 = __importStar(require("net"));
20661
+ const net$5 = __importStar(require("net"));
20586
20662
  const tls$1 = __importStar(require("tls"));
20587
20663
  const url_1$5 = require("url");
20588
20664
  const debug = (0, debug_1.default)("socks-proxy-agent");
20589
20665
  const setServernameFromNonIpHost = (options) => {
20590
- if (options.servername === void 0 && options.host && !net$6.isIP(options.host)) return {
20666
+ if (options.servername === void 0 && options.host && !net$5.isIP(options.host)) return {
20591
20667
  ...options,
20592
20668
  servername: options.host
20593
20669
  };
@@ -22847,6 +22923,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22847
22923
  function doNothing() {
22848
22924
  /** Do nothing */
22849
22925
  }
22926
+ const maxControlResponseLength = 2 ** 16;
22850
22927
  /**
22851
22928
  * FTPContext holds the control and data sockets of an FTP connection and provides a
22852
22929
  * simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -22973,6 +23050,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22973
23050
  * Send an FTP command without waiting for or handling the result.
22974
23051
  */
22975
23052
  send(command) {
23053
+ if (/[\r\n\0]/.test(command)) throw new Error(`Invalid command: Contains control characters. (${command})`);
22976
23054
  const message = command.startsWith("PASS") ? "> PASS ###" : `> ${command}`;
22977
23055
  this.log(message);
22978
23056
  this._socket.write(command + "\r\n", this.encoding);
@@ -23051,6 +23129,10 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23051
23129
  */
23052
23130
  _onControlSocketData(chunk) {
23053
23131
  this.log(`< ${chunk}`);
23132
+ if (this._partialResponse.length + chunk.length > maxControlResponseLength) {
23133
+ this.closeWithError(/* @__PURE__ */ new Error("FTP control response exceeded maximum allowed size"));
23134
+ return;
23135
+ }
23054
23136
  const completeResponse = this._partialResponse + chunk;
23055
23137
  const parsed = (0, parseControlResponse_1.parseControlResponse)(completeResponse);
23056
23138
  this._partialResponse = parsed.rest;
@@ -23134,6 +23216,61 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23134
23216
  exports.FTPContext = FTPContext;
23135
23217
  }));
23136
23218
  //#endregion
23219
+ //#region ../../node_modules/basic-ftp/dist/netUtils.js
23220
+ var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
23221
+ Object.defineProperty(exports, "__esModule", { value: true });
23222
+ exports.describeTLS = describeTLS;
23223
+ exports.describeAddress = describeAddress;
23224
+ exports.upgradeSocket = upgradeSocket;
23225
+ exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
23226
+ const tls_1$2 = require("tls");
23227
+ /**
23228
+ * Returns a string describing the encryption on a given socket instance.
23229
+ */
23230
+ function describeTLS(socket) {
23231
+ if (socket instanceof tls_1$2.TLSSocket) {
23232
+ const protocol = socket.getProtocol();
23233
+ return protocol ? protocol : "Server socket or disconnected client socket";
23234
+ }
23235
+ return "No encryption";
23236
+ }
23237
+ /**
23238
+ * Returns a string describing the remote address of a socket.
23239
+ */
23240
+ function describeAddress(socket) {
23241
+ if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
23242
+ return `${socket.remoteAddress}:${socket.remotePort}`;
23243
+ }
23244
+ /**
23245
+ * Upgrade a socket connection with TLS.
23246
+ */
23247
+ function upgradeSocket(socket, options) {
23248
+ return new Promise((resolve, reject) => {
23249
+ const tlsOptions = Object.assign({}, options, { socket });
23250
+ const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
23251
+ if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
23252
+ else {
23253
+ tlsSocket.removeAllListeners("error");
23254
+ resolve(tlsSocket);
23255
+ }
23256
+ }).once("error", (error) => {
23257
+ reject(error);
23258
+ });
23259
+ });
23260
+ }
23261
+ /**
23262
+ * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
23263
+ * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
23264
+ *
23265
+ * @param ip The IP as a string, e.g. "192.168.0.1"
23266
+ */
23267
+ function ipIsPrivateV4Address(ip = "") {
23268
+ if (ip.startsWith("::ffff:")) ip = ip.substr(7);
23269
+ const octets = ip.split(".").map((o) => parseInt(o, 10));
23270
+ return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
23271
+ }
23272
+ }));
23273
+ //#endregion
23137
23274
  //#region ../../node_modules/basic-ftp/dist/FileInfo.js
23138
23275
  var require_FileInfo = /* @__PURE__ */ __commonJSMin(((exports) => {
23139
23276
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23669,78 +23806,32 @@ var require_StringWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
23669
23806
  exports.StringWriter = void 0;
23670
23807
  const stream_1$3 = require("stream");
23671
23808
  var StringWriter = class extends stream_1$3.Writable {
23672
- constructor() {
23673
- super(...arguments);
23674
- this.buf = Buffer.alloc(0);
23809
+ constructor(maxByteLength = 1 * 1024 * 1024) {
23810
+ super();
23811
+ this.maxByteLength = maxByteLength;
23812
+ this.byteLength = 0;
23813
+ this.bufs = [];
23675
23814
  }
23676
23815
  _write(chunk, _, callback) {
23677
- if (chunk instanceof Buffer) {
23678
- this.buf = Buffer.concat([this.buf, chunk]);
23679
- callback(null);
23680
- } else callback(/* @__PURE__ */ new Error("StringWriter expects chunks of type 'Buffer'."));
23816
+ if (!(chunk instanceof Buffer)) {
23817
+ callback(/* @__PURE__ */ new Error("StringWriter: expects chunks of type 'Buffer'."));
23818
+ return;
23819
+ }
23820
+ if (this.byteLength + chunk.byteLength > this.maxByteLength) {
23821
+ callback(/* @__PURE__ */ new Error(`StringWriter: Maximum bytes exceeded, maxByteLength=${this.maxByteLength}.`));
23822
+ return;
23823
+ }
23824
+ this.byteLength += chunk.byteLength;
23825
+ this.bufs.push(chunk);
23826
+ callback(null);
23681
23827
  }
23682
23828
  getText(encoding) {
23683
- return this.buf.toString(encoding);
23829
+ return Buffer.concat(this.bufs).toString(encoding);
23684
23830
  }
23685
23831
  };
23686
23832
  exports.StringWriter = StringWriter;
23687
23833
  }));
23688
23834
  //#endregion
23689
- //#region ../../node_modules/basic-ftp/dist/netUtils.js
23690
- var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
23691
- Object.defineProperty(exports, "__esModule", { value: true });
23692
- exports.describeTLS = describeTLS;
23693
- exports.describeAddress = describeAddress;
23694
- exports.upgradeSocket = upgradeSocket;
23695
- exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
23696
- const tls_1$2 = require("tls");
23697
- /**
23698
- * Returns a string describing the encryption on a given socket instance.
23699
- */
23700
- function describeTLS(socket) {
23701
- if (socket instanceof tls_1$2.TLSSocket) {
23702
- const protocol = socket.getProtocol();
23703
- return protocol ? protocol : "Server socket or disconnected client socket";
23704
- }
23705
- return "No encryption";
23706
- }
23707
- /**
23708
- * Returns a string describing the remote address of a socket.
23709
- */
23710
- function describeAddress(socket) {
23711
- if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
23712
- return `${socket.remoteAddress}:${socket.remotePort}`;
23713
- }
23714
- /**
23715
- * Upgrade a socket connection with TLS.
23716
- */
23717
- function upgradeSocket(socket, options) {
23718
- return new Promise((resolve, reject) => {
23719
- const tlsOptions = Object.assign({}, options, { socket });
23720
- const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
23721
- if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
23722
- else {
23723
- tlsSocket.removeAllListeners("error");
23724
- resolve(tlsSocket);
23725
- }
23726
- }).once("error", (error) => {
23727
- reject(error);
23728
- });
23729
- });
23730
- }
23731
- /**
23732
- * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
23733
- * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
23734
- *
23735
- * @param ip The IP as a string, e.g. "192.168.0.1"
23736
- */
23737
- function ipIsPrivateV4Address(ip = "") {
23738
- if (ip.startsWith("::ffff:")) ip = ip.substr(7);
23739
- const octets = ip.split(".").map((o) => parseInt(o, 10));
23740
- return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
23741
- }
23742
- }));
23743
- //#endregion
23744
23835
  //#region ../../node_modules/basic-ftp/dist/transfer.js
23745
23836
  var require_transfer = /* @__PURE__ */ __commonJSMin(((exports) => {
23746
23837
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23986,20 +24077,23 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
23986
24077
  const tls_1 = require("tls");
23987
24078
  const util_1$3 = require("util");
23988
24079
  const FtpContext_1 = require_FtpContext();
24080
+ const netUtils_1 = require_netUtils();
24081
+ const parseControlResponse_1 = require_parseControlResponse();
23989
24082
  const parseList_1 = require_parseList();
24083
+ const parseListMLSD_1 = require_parseListMLSD();
23990
24084
  const ProgressTracker_1 = require_ProgressTracker();
23991
24085
  const StringWriter_1 = require_StringWriter();
23992
- const parseListMLSD_1 = require_parseListMLSD();
23993
- const netUtils_1 = require_netUtils();
23994
24086
  const transfer_1 = require_transfer();
23995
- const parseControlResponse_1 = require_parseControlResponse();
23996
24087
  const fsReadDir = (0, util_1$3.promisify)(fs_1$5.readdir);
23997
24088
  const fsMkDir = (0, util_1$3.promisify)(fs_1$5.mkdir);
23998
24089
  const fsStat = (0, util_1$3.promisify)(fs_1$5.stat);
23999
24090
  const fsOpen = (0, util_1$3.promisify)(fs_1$5.open);
24000
24091
  const fsClose = (0, util_1$3.promisify)(fs_1$5.close);
24001
24092
  const fsUnlink = (0, util_1$3.promisify)(fs_1$5.unlink);
24002
- const defaultClientOptions = { allowSeparateTransferHost: true };
24093
+ const defaultClientOptions = {
24094
+ allowSeparateTransferHost: true,
24095
+ maxListingBytes: 40 * 1024 * 1024
24096
+ };
24003
24097
  const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
24004
24098
  const LIST_COMMANDS_MLSD = () => [
24005
24099
  "MLSD",
@@ -24015,10 +24109,15 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24015
24109
  *
24016
24110
  * @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
24017
24111
  */
24018
- constructor(timeout = 3e4, options = defaultClientOptions) {
24112
+ constructor(timeout = 3e4, userOptions = defaultClientOptions) {
24019
24113
  this.availableListCommands = LIST_COMMANDS_DEFAULT();
24114
+ const options = {
24115
+ ...defaultClientOptions,
24116
+ ...userOptions
24117
+ };
24020
24118
  this.ftp = new FtpContext_1.FTPContext(timeout);
24021
24119
  this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, options.allowSeparateTransferHost ? transfer_1.enterPassiveModeIPv4 : transfer_1.enterPassiveModeIPv4_forceControlHostIP]);
24120
+ this.options = options;
24022
24121
  this.parseList = parseList_1.parseList;
24023
24122
  this._progressTracker = new ProgressTracker_1.ProgressTracker();
24024
24123
  }
@@ -24418,7 +24517,7 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24418
24517
  * @protected
24419
24518
  */
24420
24519
  async _requestListWithCommand(command) {
24421
- const buffer = new StringWriter_1.StringWriter();
24520
+ const buffer = new StringWriter_1.StringWriter(this.options.maxListingBytes);
24422
24521
  await (0, transfer_1.downloadTo)(buffer, {
24423
24522
  ftp: this.ftp,
24424
24523
  tracker: this._progressTracker,
@@ -41721,7 +41820,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41721
41820
  };
41722
41821
  Object.defineProperty(exports, "__esModule", { value: true });
41723
41822
  exports.PacProxyAgent = void 0;
41724
- const net$5 = __importStar(require("net"));
41823
+ const net$4 = __importStar(require("net"));
41725
41824
  const tls = __importStar(require("tls"));
41726
41825
  const crypto$4 = __importStar(require("crypto"));
41727
41826
  const events_1 = require("events");
@@ -41733,7 +41832,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41733
41832
  const quickjs_emscripten_1 = require_dist$3();
41734
41833
  const debug = (0, debug_1.default)("pac-proxy-agent");
41735
41834
  const setServernameFromNonIpHost = (options) => {
41736
- if (options.servername === void 0 && options.host && !net$5.isIP(options.host)) return {
41835
+ if (options.servername === void 0 && options.host && !net$4.isIP(options.host)) return {
41737
41836
  ...options,
41738
41837
  servername: options.host
41739
41838
  };
@@ -41823,7 +41922,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41823
41922
  const isWebSocket = req.getHeader("upgrade") === "websocket";
41824
41923
  const resolver = await this.getResolver();
41825
41924
  const protocol = secureEndpoint ? "https:" : "http:";
41826
- const host = opts.host && net$5.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
41925
+ const host = opts.host && net$4.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
41827
41926
  const defaultPort = secureEndpoint ? 443 : 80;
41828
41927
  const url = Object.assign(new url_1$3.URL(req.path, `${protocol}//${host}`), defaultPort ? void 0 : { port: opts.port });
41829
41928
  debug("url: %s", url);
@@ -41837,7 +41936,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41837
41936
  const [type, target] = proxy.split(/\s+/);
41838
41937
  debug("Attempting to use proxy: %o", proxy);
41839
41938
  if (type === "DIRECT") if (secureEndpoint) socket = tls.connect(setServernameFromNonIpHost(opts));
41840
- else socket = net$5.connect(opts);
41939
+ else socket = net$4.connect(opts);
41841
41940
  else if (type === "SOCKS" || type === "SOCKS5") {
41842
41941
  const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require_dist$8()));
41843
41942
  agent = new SocksProxyAgent(`socks://${target}`, this.opts);
@@ -41865,7 +41964,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41865
41964
  }
41866
41965
  if (agent) {
41867
41966
  const s = await agent.connect(req, opts);
41868
- if (!(s instanceof net$5.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
41967
+ if (!(s instanceof net$4.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
41869
41968
  req.emit("proxy", {
41870
41969
  proxy,
41871
41970
  socket: s
@@ -42793,7 +42892,7 @@ var require_errors$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42793
42892
  }));
42794
42893
  //#endregion
42795
42894
  //#region ../../node_modules/undici/lib/core/constants.js
42796
- var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42895
+ var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42797
42896
  /**
42798
42897
  * @see https://developer.mozilla.org/docs/Web/HTTP/Headers
42799
42898
  */
@@ -42925,7 +43024,7 @@ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42925
43024
  //#endregion
42926
43025
  //#region ../../node_modules/undici/lib/core/tree.js
42927
43026
  var require_tree = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42928
- const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$6();
43027
+ const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$5();
42929
43028
  var TstNode = class TstNode {
42930
43029
  /** @type {any} */
42931
43030
  value = null;
@@ -43047,12 +43146,12 @@ var require_util$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43047
43146
  const { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
43048
43147
  const { IncomingMessage } = require("node:http");
43049
43148
  const stream = require("node:stream");
43050
- const net$4 = require("node:net");
43149
+ const net$3 = require("node:net");
43051
43150
  const { stringify } = require("node:querystring");
43052
43151
  const { EventEmitter: EE$2 } = require("node:events");
43053
43152
  const timers = require_timers();
43054
43153
  const { InvalidArgumentError, ConnectTimeoutError } = require_errors$1();
43055
- const { headerNameLowerCasedRecord } = require_constants$6();
43154
+ const { headerNameLowerCasedRecord } = require_constants$5();
43056
43155
  const { tree } = require_tree();
43057
43156
  const [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
43058
43157
  var BodyAsyncIterable = class {
@@ -43208,7 +43307,7 @@ var require_util$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43208
43307
  if (!host) return null;
43209
43308
  assert$32(typeof host === "string");
43210
43309
  const servername = getHostname(host);
43211
- if (net$4.isIP(servername)) return "";
43310
+ if (net$3.isIP(servername)) return "";
43212
43311
  return servername;
43213
43312
  }
43214
43313
  /**
@@ -44116,8 +44215,16 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44116
44215
  const assert$31 = require("node:assert");
44117
44216
  const { isValidHTTPToken, isValidHeaderValue, isStream, destroy, isBuffer, isFormDataLike, isIterable, hasSafeIterator, isBlobLike, serializePathWithQuery, assertRequestHandler, getServerName, normalizedMethodRecords, getProtocolFromUrlString } = require_util$5();
44118
44217
  const { channels } = require_diagnostics();
44119
- const { headerNameLowerCasedRecord } = require_constants$6();
44218
+ const { headerNameLowerCasedRecord } = require_constants$5();
44120
44219
  const invalidPathRegex = /[^\u0021-\u00ff]/;
44220
+ function isValidContentLengthHeaderValue(val) {
44221
+ if (typeof val !== "string" || val.length === 0) return false;
44222
+ for (let i = 0; i < val.length; i++) {
44223
+ const charCode = val.charCodeAt(i);
44224
+ if (charCode < 48 || charCode > 57) return false;
44225
+ }
44226
+ return true;
44227
+ }
44121
44228
  const kHandler = Symbol("handler");
44122
44229
  var Request = class {
44123
44230
  constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
@@ -44326,8 +44433,8 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44326
44433
  request.host = val;
44327
44434
  } else if (headerName === "content-length") {
44328
44435
  if (request.contentLength !== null) throw new InvalidArgumentError("duplicate content-length header");
44436
+ if (!isValidContentLengthHeaderValue(val)) throw new InvalidArgumentError("invalid content-length header");
44329
44437
  request.contentLength = parseInt(val, 10);
44330
- if (!Number.isFinite(request.contentLength)) throw new InvalidArgumentError("invalid content-length header");
44331
44438
  } else if (request.contentType === null && headerName === "content-type") {
44332
44439
  request.contentType = val;
44333
44440
  request.headers.push(key, val);
@@ -44452,6 +44559,8 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44452
44559
  #aborted = false;
44453
44560
  #abort;
44454
44561
  [kResume] = null;
44562
+ rawHeaders = null;
44563
+ rawTrailers = null;
44455
44564
  constructor(abort) {
44456
44565
  this.#abort = abort;
44457
44566
  }
@@ -44498,10 +44607,12 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44498
44607
  return this.#handler.onResponseStarted?.();
44499
44608
  }
44500
44609
  onUpgrade(statusCode, rawHeaders, socket) {
44610
+ this.#controller.rawHeaders = rawHeaders;
44501
44611
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
44502
44612
  }
44503
44613
  onHeaders(statusCode, rawHeaders, resume, statusMessage) {
44504
44614
  this.#controller[kResume] = resume;
44615
+ this.#controller.rawHeaders = rawHeaders;
44505
44616
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
44506
44617
  return !this.#controller.paused;
44507
44618
  }
@@ -44510,6 +44621,7 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44510
44621
  return !this.#controller.paused;
44511
44622
  }
44512
44623
  onComplete(rawTrailers) {
44624
+ this.#controller.rawTrailers = rawTrailers;
44513
44625
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
44514
44626
  }
44515
44627
  onError(err) {
@@ -44527,6 +44639,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44527
44639
  const { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
44528
44640
  const kOnDestroyed = Symbol("onDestroyed");
44529
44641
  const kOnClosed = Symbol("onClosed");
44642
+ const kWebSocketOptions = Symbol("webSocketOptions");
44530
44643
  var DispatcherBase = class extends Dispatcher {
44531
44644
  /** @type {boolean} */
44532
44645
  [kDestroyed] = false;
@@ -44536,6 +44649,22 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44536
44649
  [kClosed] = false;
44537
44650
  /** @type {Array<Function>|null} */
44538
44651
  [kOnClosed] = null;
44652
+ /**
44653
+ * @param {import('../../types/dispatcher').DispatcherOptions} [opts]
44654
+ */
44655
+ constructor(opts) {
44656
+ super();
44657
+ this[kWebSocketOptions] = opts?.webSocket ?? {};
44658
+ }
44659
+ /**
44660
+ * @returns {import('../../types/dispatcher').WebSocketOptions}
44661
+ */
44662
+ get webSocketOptions() {
44663
+ return {
44664
+ maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
44665
+ maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
44666
+ };
44667
+ }
44539
44668
  /** @returns {boolean} */
44540
44669
  get destroyed() {
44541
44670
  return this[kDestroyed];
@@ -44618,7 +44747,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44618
44747
  //#endregion
44619
44748
  //#region ../../node_modules/undici/lib/core/connect.js
44620
44749
  var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44621
- const net$3 = require("node:net");
44750
+ const net$2 = require("node:net");
44622
44751
  const assert$30 = require("node:assert");
44623
44752
  const util = require_util$5();
44624
44753
  const { InvalidArgumentError } = require_errors$1();
@@ -44639,6 +44768,15 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44639
44768
  }
44640
44769
  set(sessionKey, session) {
44641
44770
  if (this._maxCachedSessions === 0) return;
44771
+ if (this._sessionCache.has(sessionKey)) this._sessionCache.delete(sessionKey);
44772
+ else if (this._sessionCache.size >= this._maxCachedSessions) {
44773
+ for (const [key, ref] of this._sessionCache) if (ref.deref() === void 0) {
44774
+ this._sessionCache.delete(key);
44775
+ return;
44776
+ }
44777
+ const oldest = this._sessionCache.keys().next();
44778
+ if (!oldest.done) this._sessionCache.delete(oldest.value);
44779
+ }
44642
44780
  this._sessionCache.set(sessionKey, new WeakRef(session));
44643
44781
  this._sessionRegistry.register(session, sessionKey);
44644
44782
  }
@@ -44678,7 +44816,7 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44678
44816
  } else {
44679
44817
  assert$30(!httpSocket, "httpSocket can only be sent on TLS update");
44680
44818
  port = port || 80;
44681
- socket = net$3.connect({
44819
+ socket = net$2.connect({
44682
44820
  highWaterMark: 64 * 1024,
44683
44821
  ...options,
44684
44822
  localAddress,
@@ -44731,7 +44869,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
44731
44869
  }));
44732
44870
  //#endregion
44733
44871
  //#region ../../node_modules/undici/lib/llhttp/constants.js
44734
- var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
44872
+ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
44735
44873
  Object.defineProperty(exports, "__esModule", { value: true });
44736
44874
  exports.SPECIAL_HEADERS = exports.MINOR = exports.MAJOR = exports.HTAB_SP_VCHAR_OBS_TEXT = exports.QUOTED_STRING = exports.CONNECTION_TOKEN_CHARS = exports.HEADER_CHARS = exports.TOKEN = exports.HEX = exports.URL_CHAR = exports.USERINFO_CHARS = exports.MARK = exports.ALPHANUM = exports.NUM = exports.HEX_MAP = exports.NUM_MAP = exports.ALPHA = exports.STATUSES_HTTP = exports.H_METHOD_MAP = exports.METHOD_MAP = exports.METHODS_RTSP = exports.METHODS_ICE = exports.METHODS_HTTP = exports.HEADER_STATE = exports.FINISH = exports.STATUSES = exports.METHODS = exports.LENIENT_FLAGS = exports.FLAGS = exports.TYPE = exports.ERROR = void 0;
44737
44875
  const utils_1 = require_utils$1();
@@ -45337,7 +45475,7 @@ var require_llhttp_simd_wasm = /* @__PURE__ */ __commonJSMin(((exports, module)
45337
45475
  }));
45338
45476
  //#endregion
45339
45477
  //#region ../../node_modules/undici/lib/web/fetch/constants.js
45340
- var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45478
+ var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45341
45479
  const corsSafeListedMethods = [
45342
45480
  "GET",
45343
45481
  "HEAD",
@@ -46236,7 +46374,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46236
46374
  lowerBound = 0;
46237
46375
  upperBound = Math.pow(2, bitLength) - 1;
46238
46376
  } else {
46239
- lowerBound = Math.pow(-2, bitLength) - 1;
46377
+ lowerBound = -Math.pow(2, bitLength - 1);
46240
46378
  upperBound = Math.pow(2, bitLength - 1) - 1;
46241
46379
  }
46242
46380
  let x = Number(V);
@@ -46262,7 +46400,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46262
46400
  if (Number.isNaN(x) || x === 0 && Object.is(0, x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) return 0;
46263
46401
  x = webidl.util.IntegerPart(x);
46264
46402
  x = x % Math.pow(2, bitLength);
46265
- if (signedness === "signed" && x >= Math.pow(2, bitLength) - 1) return x - Math.pow(2, bitLength);
46403
+ if (signedness === "signed" && x >= Math.pow(2, bitLength - 1)) return x - Math.pow(2, bitLength);
46266
46404
  return x;
46267
46405
  };
46268
46406
  webidl.util.IntegerPart = function(n) {
@@ -46597,7 +46735,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46597
46735
  var require_util$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46598
46736
  const { Transform: Transform$2 } = require("node:stream");
46599
46737
  const zlib$2 = require("node:zlib");
46600
- const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$4();
46738
+ const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$3();
46601
46739
  const { getGlobalOrigin } = require_global$1();
46602
46740
  const { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
46603
46741
  const { performance: performance$1 } = require("node:perf_hooks");
@@ -47607,7 +47745,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47607
47745
  * Parses content-disposition attributes (e.g., name="value" or filename*=utf-8''encoded)
47608
47746
  * @param {Buffer} input
47609
47747
  * @param {{ position: number }} position
47610
- * @returns {{ name: string, value: string }}
47748
+ * @returns {{ name: string, value: string, extended: boolean } | null}
47611
47749
  */
47612
47750
  function parseContentDispositionAttribute(input, position) {
47613
47751
  if (input[position.position] === 59) position.position++;
@@ -47637,7 +47775,8 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47637
47775
  }
47638
47776
  return {
47639
47777
  name: attrNameStr,
47640
- value
47778
+ value,
47779
+ extended: isExtended
47641
47780
  };
47642
47781
  }
47643
47782
  /**
@@ -47667,17 +47806,24 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47667
47806
  position.position++;
47668
47807
  collectASequenceOfBytes((char) => char === 32 || char === 9, input, position);
47669
47808
  switch (bufferToLowerCasedHeaderName(headerName)) {
47670
- case "content-disposition":
47809
+ case "content-disposition": {
47671
47810
  name = filename = null;
47811
+ let filenameIsExtended = false;
47672
47812
  if (collectASequenceOfBytes((char) => isToken(char), input, position).toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
47673
- while (position.position < input.length && input[position.position] !== 13 && input[position.position + 1] !== 10) {
47813
+ while (position.position < input.length && (input[position.position] !== 13 || input[position.position + 1] !== 10)) {
47674
47814
  const attribute = parseContentDispositionAttribute(input, position);
47675
47815
  if (!attribute) break;
47676
47816
  if (attribute.name === "name") name = attribute.value;
47677
- else if (attribute.name === "filename") filename = attribute.value;
47817
+ else if (attribute.name === "filename") {
47818
+ if (attribute.extended) {
47819
+ filename = attribute.value;
47820
+ filenameIsExtended = true;
47821
+ } else if (!filenameIsExtended) filename = attribute.value;
47822
+ }
47678
47823
  }
47679
47824
  if (name === null) throw parsingError("name attribute is required in content-disposition header");
47680
47825
  break;
47826
+ }
47681
47827
  case "content-type": {
47682
47828
  let headerValue = collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47683
47829
  headerValue = removeChars(headerValue, false, true, (char) => char === 9 || char === 32);
@@ -47692,7 +47838,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47692
47838
  }
47693
47839
  default: collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47694
47840
  }
47695
- if (input[position.position] !== 13 && input[position.position + 1] !== 10) throw parsingError("expected CRLF");
47841
+ if (input[position.position] !== 13 || input[position.position + 1] !== 10) throw parsingError("expected CRLF");
47696
47842
  else position.position += 2;
47697
47843
  }
47698
47844
  }
@@ -48060,17 +48206,20 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48060
48206
  const timers = require_timers();
48061
48207
  const { RequestContentLengthMismatchError, ResponseContentLengthMismatchError, RequestAbortedError, HeadersTimeoutError, HeadersOverflowError, SocketError, InformationalError, BodyTimeoutError, HTTPParserError, ResponseExceededMaxSizeError } = require_errors$1();
48062
48208
  const { kUrl, kReset, kClient, kParser, kBlocking, kRunning, kPending, kSize, kWriting, kQueue, kNoRef, kKeepAliveDefaultTimeout, kHostHeader, kPendingIdx, kRunningIdx, kError, kPipelining, kSocket, kKeepAliveTimeoutValue, kMaxHeadersSize, kKeepAliveMaxTimeout, kKeepAliveTimeoutThreshold, kHeadersTimeout, kBodyTimeout, kStrictContentLength, kMaxRequests, kCounter, kMaxResponseSize, kOnError, kResume, kHTTPContext, kClosed } = require_symbols();
48063
- const constants = require_constants$5();
48209
+ const constants = require_constants$4();
48064
48210
  const EMPTY_BUF = Buffer.alloc(0);
48065
48211
  const FastBuffer = Buffer[Symbol.species];
48066
48212
  const removeAllListeners = util.removeAllListeners;
48213
+ const kIdleSocketValidation = Symbol("kIdleSocketValidation");
48214
+ const kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
48215
+ const kSocketUsed = Symbol("kSocketUsed");
48067
48216
  let extractBody;
48068
48217
  function lazyllhttp() {
48069
48218
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
48070
48219
  let mod;
48071
48220
  let useWasmSIMD = process.arch !== "ppc64";
48072
- if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
48073
- else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = false;
48221
+ if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = false;
48222
+ else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = true;
48074
48223
  if (useWasmSIMD) try {
48075
48224
  mod = new WebAssembly.Module(require_llhttp_simd_wasm());
48076
48225
  } catch {}
@@ -48144,6 +48293,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48144
48293
  */
48145
48294
  this.socket = socket;
48146
48295
  this.timeout = null;
48296
+ this.timeoutWeakRef = new WeakRef(this);
48147
48297
  this.timeoutValue = null;
48148
48298
  this.timeoutType = null;
48149
48299
  this.statusCode = 0;
@@ -48167,9 +48317,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48167
48317
  timers.clearTimeout(this.timeout);
48168
48318
  this.timeout = null;
48169
48319
  }
48170
- if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this));
48320
+ if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef);
48171
48321
  else {
48172
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this));
48322
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
48173
48323
  this.timeout?.unref();
48174
48324
  }
48175
48325
  this.timeoutValue = delay;
@@ -48228,20 +48378,42 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48228
48378
  else if (ret === constants.ERROR.PAUSED) {
48229
48379
  this.paused = true;
48230
48380
  socket.unshift(data);
48231
- } else {
48232
- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
48233
- let message = "";
48234
- if (ptr) {
48235
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
48236
- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
48237
- }
48238
- throw new HTTPParserError(message, constants.ERROR[ret], data);
48239
- }
48381
+ } else throw this.createError(ret, data);
48240
48382
  }
48241
48383
  } catch (err) {
48242
48384
  util.destroy(socket, err);
48243
48385
  }
48244
48386
  }
48387
+ finish() {
48388
+ assert$23(currentParser === null);
48389
+ assert$23(this.ptr != null);
48390
+ assert$23(!this.paused);
48391
+ const { llhttp } = this;
48392
+ let ret;
48393
+ try {
48394
+ currentParser = this;
48395
+ ret = llhttp.llhttp_finish(this.ptr);
48396
+ } finally {
48397
+ currentParser = null;
48398
+ }
48399
+ if (ret === constants.ERROR.OK) return null;
48400
+ if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
48401
+ this.paused = true;
48402
+ return null;
48403
+ }
48404
+ return this.createError(ret, EMPTY_BUF);
48405
+ }
48406
+ createError(ret, data) {
48407
+ const { llhttp, contentLength, bytesRead } = this;
48408
+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) return new ResponseContentLengthMismatchError();
48409
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr);
48410
+ let message = "";
48411
+ if (ptr) {
48412
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
48413
+ message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
48414
+ }
48415
+ return new HTTPParserError(message, constants.ERROR[ret], data);
48416
+ }
48245
48417
  destroy() {
48246
48418
  assert$23(currentParser === null);
48247
48419
  assert$23(this.ptr != null);
@@ -48267,6 +48439,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48267
48439
  onMessageBegin() {
48268
48440
  const { socket, client } = this;
48269
48441
  if (socket.destroyed) return -1;
48442
+ if (client[kRunning] === 0) {
48443
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
48444
+ return -1;
48445
+ }
48270
48446
  const request = client[kQueue][client[kRunningIdx]];
48271
48447
  if (!request) return -1;
48272
48448
  request.onResponseStarted();
@@ -48353,6 +48529,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48353
48529
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
48354
48530
  const { client, socket, headers, statusText } = this;
48355
48531
  if (socket.destroyed) return -1;
48532
+ if (client[kRunning] === 0) {
48533
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
48534
+ return -1;
48535
+ }
48356
48536
  const request = client[kQueue][client[kRunningIdx]];
48357
48537
  if (!request) return -1;
48358
48538
  assert$23(!this.upgrade);
@@ -48453,6 +48633,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48453
48633
  }
48454
48634
  request.onComplete(headers);
48455
48635
  client[kQueue][client[kRunningIdx]++] = null;
48636
+ socket[kSocketUsed] = client[kPending] === 0;
48456
48637
  if (socket[kWriting]) {
48457
48638
  assert$23(client[kRunning] === 0);
48458
48639
  util.destroy(socket, new InformationalError("reset"));
@@ -48498,6 +48679,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48498
48679
  socket[kWriting] = false;
48499
48680
  socket[kReset] = false;
48500
48681
  socket[kBlocking] = false;
48682
+ socket[kIdleSocketValidation] = 0;
48683
+ socket[kIdleSocketValidationTimeout] = null;
48684
+ socket[kSocketUsed] = false;
48501
48685
  socket[kParser] = new Parser(client, socket, llhttpInstance);
48502
48686
  util.addListener(socket, "error", onHttpSocketError);
48503
48687
  util.addListener(socket, "readable", onHttpSocketReadable);
@@ -48525,7 +48709,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48525
48709
  return socket.destroyed;
48526
48710
  },
48527
48711
  busy(request) {
48528
- if (socket[kWriting] || socket[kReset] || socket[kBlocking]) return true;
48712
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) return true;
48529
48713
  if (request) {
48530
48714
  if (client[kRunning] > 0 && !request.idempotent) return true;
48531
48715
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) return true;
@@ -48539,7 +48723,11 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48539
48723
  assert$23(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
48540
48724
  const parser = this[kParser];
48541
48725
  if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
48542
- parser.onMessageComplete();
48726
+ const parserErr = parser.finish();
48727
+ if (parserErr) {
48728
+ this[kError] = parserErr;
48729
+ this[kClient][kOnError](parserErr);
48730
+ }
48543
48731
  return;
48544
48732
  }
48545
48733
  this[kError] = err;
@@ -48551,15 +48739,17 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48551
48739
  function onHttpSocketEnd() {
48552
48740
  const parser = this[kParser];
48553
48741
  if (parser.statusCode && !parser.shouldKeepAlive) {
48554
- parser.onMessageComplete();
48742
+ const parserErr = parser.finish();
48743
+ if (parserErr) util.destroy(this, parserErr);
48555
48744
  return;
48556
48745
  }
48557
48746
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
48558
48747
  }
48559
48748
  function onHttpSocketClose() {
48560
48749
  const parser = this[kParser];
48750
+ clearIdleSocketValidation(this);
48561
48751
  if (parser) {
48562
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) parser.onMessageComplete();
48752
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) this[kError] = parser.finish() || this[kError];
48563
48753
  this[kParser].destroy();
48564
48754
  this[kParser] = null;
48565
48755
  }
@@ -48587,6 +48777,22 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48587
48777
  function onSocketClose() {
48588
48778
  this[kClosed] = true;
48589
48779
  }
48780
+ function clearIdleSocketValidation(socket) {
48781
+ if (socket[kIdleSocketValidationTimeout]) {
48782
+ clearTimeout(socket[kIdleSocketValidationTimeout]);
48783
+ socket[kIdleSocketValidationTimeout] = null;
48784
+ }
48785
+ socket[kIdleSocketValidation] = 0;
48786
+ }
48787
+ function scheduleIdleSocketValidation(client, socket) {
48788
+ socket[kIdleSocketValidation] = 1;
48789
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
48790
+ socket[kIdleSocketValidationTimeout] = null;
48791
+ socket[kIdleSocketValidation] = 2;
48792
+ if (client[kSocket] === socket && !socket.destroyed) client[kResume]();
48793
+ }, 0);
48794
+ socket[kIdleSocketValidationTimeout].unref?.();
48795
+ }
48590
48796
  /**
48591
48797
  * @param {import('./client.js')} client
48592
48798
  */
@@ -48602,6 +48808,23 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48602
48808
  socket.ref();
48603
48809
  socket[kNoRef] = false;
48604
48810
  }
48811
+ if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
48812
+ if (socket[kIdleSocketValidation] === 0) {
48813
+ scheduleIdleSocketValidation(client, socket);
48814
+ socket[kParser].readMore();
48815
+ if (socket.destroyed) return;
48816
+ return;
48817
+ }
48818
+ if (socket[kIdleSocketValidation] === 1) {
48819
+ socket[kParser].readMore();
48820
+ if (socket.destroyed) return;
48821
+ return;
48822
+ }
48823
+ }
48824
+ if (client[kRunning] === 0) {
48825
+ socket[kParser].readMore();
48826
+ if (socket.destroyed) return;
48827
+ }
48605
48828
  if (client[kSize] === 0) {
48606
48829
  if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
48607
48830
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
@@ -48645,6 +48868,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48645
48868
  process.emitWarning(new RequestContentLengthMismatchError());
48646
48869
  }
48647
48870
  const socket = client[kSocket];
48871
+ clearIdleSocketValidation(socket);
48648
48872
  /**
48649
48873
  * @param {Error} [err]
48650
48874
  * @returns {void}
@@ -49509,7 +49733,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49509
49733
  //#region ../../node_modules/undici/lib/dispatcher/client.js
49510
49734
  var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49511
49735
  const assert$21 = require("node:assert");
49512
- const net$2 = require("node:net");
49736
+ const net$1 = require("node:net");
49513
49737
  const http$1 = require("node:http");
49514
49738
  const util = require_util$5();
49515
49739
  const { ClientStats } = require_stats();
@@ -49538,7 +49762,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49538
49762
  * @param {string|URL} url
49539
49763
  * @param {import('../../types/client.js').Client.Options} options
49540
49764
  */
49541
- constructor(url, { maxHeaderSize, headersTimeout, socketTimeout, requestTimeout, connectTimeout, bodyTimeout, idleTimeout, keepAlive, keepAliveTimeout, maxKeepAliveTimeout, keepAliveMaxTimeout, keepAliveTimeoutThreshold, socketPath, pipelining, tls, strictContentLength, maxCachedSessions, connect, maxRequestsPerClient, localAddress, maxResponseSize, autoSelectFamily, autoSelectFamilyAttemptTimeout, maxConcurrentStreams, allowH2, useH2c, initialWindowSize, connectionWindowSize, pingInterval } = {}) {
49765
+ constructor(url, { maxHeaderSize, headersTimeout, socketTimeout, requestTimeout, connectTimeout, bodyTimeout, idleTimeout, keepAlive, keepAliveTimeout, maxKeepAliveTimeout, keepAliveMaxTimeout, keepAliveTimeoutThreshold, socketPath, pipelining, tls, strictContentLength, maxCachedSessions, connect, maxRequestsPerClient, localAddress, maxResponseSize, autoSelectFamily, autoSelectFamilyAttemptTimeout, maxConcurrentStreams, allowH2, useH2c, initialWindowSize, connectionWindowSize, pingInterval, webSocket } = {}) {
49542
49766
  if (keepAlive !== void 0) throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
49543
49767
  if (socketTimeout !== void 0) throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
49544
49768
  if (requestTimeout !== void 0) throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
@@ -49556,7 +49780,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49556
49780
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
49557
49781
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
49558
49782
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
49559
- if (localAddress != null && (typeof localAddress !== "string" || net$2.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
49783
+ if (localAddress != null && (typeof localAddress !== "string" || net$1.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
49560
49784
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) throw new InvalidArgumentError("maxResponseSize must be a positive number");
49561
49785
  if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
49562
49786
  if (allowH2 != null && typeof allowH2 !== "boolean") throw new InvalidArgumentError("allowH2 must be a valid boolean value");
@@ -49565,7 +49789,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49565
49789
  if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
49566
49790
  if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
49567
49791
  if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
49568
- super();
49792
+ super({ webSocket });
49569
49793
  if (typeof connect !== "function") connect = buildConnector({
49570
49794
  ...tls,
49571
49795
  maxCachedSessions,
@@ -49579,11 +49803,12 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49579
49803
  } : void 0,
49580
49804
  ...connect
49581
49805
  });
49582
- else if (socketPath != null) {
49806
+ else {
49583
49807
  const customConnect = connect;
49584
49808
  connect = (opts, callback) => customConnect({
49585
49809
  ...opts,
49586
- socketPath
49810
+ ...socketPath != null ? { socketPath } : null,
49811
+ ...allowH2 != null ? { allowH2 } : null
49587
49812
  }, callback);
49588
49813
  }
49589
49814
  this[kUrl] = util.parseOrigin(url);
@@ -49706,7 +49931,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49706
49931
  const idx = hostname.indexOf("]");
49707
49932
  assert$21(idx !== -1);
49708
49933
  const ip = hostname.substring(1, idx);
49709
- assert$21(net$2.isIPv6(ip));
49934
+ assert$21(net$1.isIPv6(ip));
49710
49935
  hostname = ip;
49711
49936
  }
49712
49937
  client[kConnecting] = true;
@@ -50128,7 +50353,7 @@ var require_pool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50128
50353
  } : void 0,
50129
50354
  ...connect
50130
50355
  });
50131
- super();
50356
+ super(options);
50132
50357
  this[kConnections] = connections || null;
50133
50358
  this[kUrl] = util.parseOrigin(origin);
50134
50359
  this[kOptions] = {
@@ -50202,7 +50427,7 @@ var require_balanced_pool = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50202
50427
  var BalancedPool = class extends PoolBase {
50203
50428
  constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
50204
50429
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50205
- super();
50430
+ super(opts);
50206
50431
  this[kOptions] = { ...util.deepClone(opts) };
50207
50432
  this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
50208
50433
  this[kIndex] = -1;
@@ -50387,7 +50612,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50387
50612
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50388
50613
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
50389
50614
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
50390
- super();
50615
+ super(options);
50391
50616
  if (connect && typeof connect !== "function") connect = { ...connect };
50392
50617
  this[kOptions] = {
50393
50618
  ...util.deepClone(options),
@@ -50477,7 +50702,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50477
50702
  //#region ../../node_modules/undici/lib/core/socks5-utils.js
50478
50703
  var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50479
50704
  const { Buffer: Buffer$2 } = require("node:buffer");
50480
- const net$1 = require("node:net");
50705
+ const net = require("node:net");
50481
50706
  const { InvalidArgumentError } = require_errors$1();
50482
50707
  /**
50483
50708
  * Parse an address and determine its type
@@ -50485,14 +50710,14 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50485
50710
  * @returns {{type: number, buffer: Buffer}} Address type and buffer
50486
50711
  */
50487
50712
  function parseAddress(address) {
50488
- if (net$1.isIPv4(address)) {
50713
+ if (net.isIPv4(address)) {
50489
50714
  const parts = address.split(".").map(Number);
50490
50715
  return {
50491
50716
  type: 1,
50492
50717
  buffer: Buffer$2.from(parts)
50493
50718
  };
50494
50719
  }
50495
- if (net$1.isIPv6(address)) return {
50720
+ if (net.isIPv6(address)) return {
50496
50721
  type: 4,
50497
50722
  buffer: parseIPv6(address)
50498
50723
  };
@@ -50510,23 +50735,36 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50510
50735
  */
50511
50736
  function parseIPv6(address) {
50512
50737
  const buffer = Buffer$2.alloc(16);
50513
- const parts = address.split(":");
50514
- let partIndex = 0;
50515
- let bufferIndex = 0;
50516
- const doubleColonIndex = address.indexOf("::");
50738
+ let normalizedAddress = address;
50739
+ if (address.includes(".")) {
50740
+ const lastColonIndex = address.lastIndexOf(":");
50741
+ const ipv4Part = address.slice(lastColonIndex + 1);
50742
+ if (net.isIPv4(ipv4Part)) {
50743
+ const octets = ipv4Part.split(".").map(Number);
50744
+ const high = (octets[0] << 8 | octets[1]).toString(16);
50745
+ const low = (octets[2] << 8 | octets[3]).toString(16);
50746
+ normalizedAddress = `${address.slice(0, lastColonIndex)}:${high}:${low}`;
50747
+ }
50748
+ }
50749
+ const doubleColonIndex = normalizedAddress.indexOf("::");
50517
50750
  if (doubleColonIndex !== -1) {
50518
- const skipParts = 8 - parts.filter((p) => p.length > 0).length;
50519
- for (let i = 0; i < parts.length; i++) if (parts[i] === "" && i === doubleColonIndex / 3) bufferIndex += skipParts * 2;
50520
- else if (parts[i] !== "") {
50521
- const value = parseInt(parts[i], 16);
50522
- buffer.writeUInt16BE(value, bufferIndex);
50751
+ const before = normalizedAddress.slice(0, doubleColonIndex);
50752
+ const after = normalizedAddress.slice(doubleColonIndex + 2);
50753
+ const beforeParts = before === "" ? [] : before.split(":");
50754
+ const afterParts = after === "" ? [] : after.split(":");
50755
+ let bufferIndex = 0;
50756
+ for (const part of beforeParts) {
50757
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
50523
50758
  bufferIndex += 2;
50524
50759
  }
50525
- } else for (const part of parts) {
50526
- if (part === "") continue;
50527
- const value = parseInt(part, 16);
50528
- buffer.writeUInt16BE(value, partIndex * 2);
50529
- partIndex++;
50760
+ bufferIndex = 16 - afterParts.length * 2;
50761
+ for (const part of afterParts) {
50762
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
50763
+ bufferIndex += 2;
50764
+ }
50765
+ } else {
50766
+ const parts = normalizedAddress.split(":");
50767
+ for (let i = 0; i < parts.length; i++) buffer.writeUInt16BE(parseInt(parts[i], 16), i * 2);
50530
50768
  }
50531
50769
  return buffer;
50532
50770
  }
@@ -50631,6 +50869,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50631
50869
  const { debuglog: debuglog$1 } = require("node:util");
50632
50870
  const { parseAddress } = require_socks5_utils();
50633
50871
  const debug = debuglog$1("undici:socks5");
50872
+ const EMPTY_BUFFER = Buffer$1.alloc(0);
50634
50873
  const SOCKS_VERSION = 5;
50635
50874
  const AUTH_METHODS = {
50636
50875
  NO_AUTH: 0,
@@ -50663,6 +50902,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50663
50902
  INITIAL: "initial",
50664
50903
  HANDSHAKING: "handshaking",
50665
50904
  AUTHENTICATING: "authenticating",
50905
+ AUTHENTICATED: "authenticated",
50666
50906
  CONNECTING: "connecting",
50667
50907
  CONNECTED: "connected",
50668
50908
  ERROR: "error",
@@ -50679,13 +50919,16 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50679
50919
  this.socket = socket;
50680
50920
  this.options = options;
50681
50921
  this.state = STATES.INITIAL;
50682
- this.buffer = Buffer$1.alloc(0);
50922
+ this.buffer = EMPTY_BUFFER;
50923
+ this.onSocketData = this.onData.bind(this);
50924
+ this.onSocketError = this.onError.bind(this);
50925
+ this.onSocketClose = this.onClose.bind(this);
50683
50926
  this.authMethods = [];
50684
50927
  if (options.username && options.password) this.authMethods.push(AUTH_METHODS.USERNAME_PASSWORD);
50685
50928
  this.authMethods.push(AUTH_METHODS.NO_AUTH);
50686
- this.socket.on("data", this.onData.bind(this));
50687
- this.socket.on("error", this.onError.bind(this));
50688
- this.socket.on("close", this.onClose.bind(this));
50929
+ this.socket.on("data", this.onSocketData);
50930
+ this.socket.on("error", this.onSocketError);
50931
+ this.socket.on("close", this.onSocketClose);
50689
50932
  }
50690
50933
  /**
50691
50934
  * Handle incoming data from the socket
@@ -50732,6 +50975,10 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50732
50975
  destroy() {
50733
50976
  if (this.socket && !this.socket.destroyed) this.socket.destroy();
50734
50977
  }
50978
+ markAuthenticated() {
50979
+ this.state = STATES.AUTHENTICATED;
50980
+ this.emit("authenticated");
50981
+ }
50735
50982
  /**
50736
50983
  * Start the SOCKS5 handshake
50737
50984
  */
@@ -50758,7 +51005,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50758
51005
  if (method === AUTH_METHODS.NO_ACCEPTABLE) throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
50759
51006
  this.buffer = this.buffer.subarray(2);
50760
51007
  debug("server selected auth method", method);
50761
- if (method === AUTH_METHODS.NO_AUTH) this.emit("authenticated");
51008
+ if (method === AUTH_METHODS.NO_AUTH) this.markAuthenticated();
50762
51009
  else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
50763
51010
  this.state = STATES.AUTHENTICATING;
50764
51011
  this.sendAuthRequest();
@@ -50793,7 +51040,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50793
51040
  if (status !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
50794
51041
  this.buffer = this.buffer.subarray(2);
50795
51042
  debug("authentication successful");
50796
- this.emit("authenticated");
51043
+ this.markAuthenticated();
50797
51044
  }
50798
51045
  /**
50799
51046
  * Send CONNECT command
@@ -50801,7 +51048,8 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50801
51048
  * @param {number} port - Target port
50802
51049
  */
50803
51050
  connect(address, port) {
50804
- if (this.state === STATES.CONNECTED) throw new InvalidArgumentError("Already connected");
51051
+ if (this.state === STATES.CONNECTING || this.state === STATES.CONNECTED) throw new InvalidArgumentError("Connection already in progress");
51052
+ if (this.state !== STATES.AUTHENTICATED) throw new InvalidArgumentError("Client must be authenticated before CONNECT");
50805
51053
  debug("connecting to", address, port);
50806
51054
  this.state = STATES.CONNECTING;
50807
51055
  const request = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
@@ -50859,8 +51107,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50859
51107
  offset += 16;
50860
51108
  }
50861
51109
  const boundPort = this.buffer.readUInt16BE(offset);
50862
- this.buffer = this.buffer.subarray(responseLength);
51110
+ this.buffer = EMPTY_BUFFER;
50863
51111
  this.state = STATES.CONNECTED;
51112
+ this.socket.removeListener("data", this.onSocketData);
50864
51113
  debug("connected, bound address:", boundAddress, "port:", boundPort);
50865
51114
  this.emit("connected", {
50866
51115
  address: boundAddress,
@@ -50896,12 +51145,11 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50896
51145
  //#endregion
50897
51146
  //#region ../../node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
50898
51147
  var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50899
- const net = require("node:net");
50900
51148
  const { URL: URL$1 } = require("node:url");
50901
51149
  let tls;
50902
51150
  const DispatcherBase = require_dispatcher_base();
50903
51151
  const { InvalidArgumentError } = require_errors$1();
50904
- const { Socks5Client } = require_socks5_client();
51152
+ const { Socks5Client, STATES } = require_socks5_client();
50905
51153
  const { kDispatch, kClose, kDestroy } = require_symbols();
50906
51154
  const Pool = require_pool();
50907
51155
  const buildConnector = require_connect();
@@ -50910,8 +51158,10 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50910
51158
  const kProxyUrl = Symbol("proxy url");
50911
51159
  const kProxyHeaders = Symbol("proxy headers");
50912
51160
  const kProxyAuth = Symbol("proxy auth");
50913
- const kPool = Symbol("pool");
51161
+ const kProxyProtocol = Symbol("proxy protocol");
51162
+ const kPools = Symbol("pools");
50914
51163
  const kConnector = Symbol("connector");
51164
+ const kRequestTls = Symbol("request tls settings");
50915
51165
  let experimentalWarningEmitted = false;
50916
51166
  /**
50917
51167
  * SOCKS5 proxy agent for dispatching requests through a SOCKS5 proxy
@@ -50928,6 +51178,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50928
51178
  if (url.protocol !== "socks5:" && url.protocol !== "socks:") throw new InvalidArgumentError("Proxy URL must use socks5:// or socks:// protocol");
50929
51179
  this[kProxyUrl] = url;
50930
51180
  this[kProxyHeaders] = options.headers || {};
51181
+ this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
51182
+ this[kRequestTls] = options.requestTls;
50931
51183
  this[kProxyAuth] = {
50932
51184
  username: options.username || (url.username ? decodeURIComponent(url.username) : null),
50933
51185
  password: options.password || (url.password ? decodeURIComponent(url.password) : null)
@@ -50936,7 +51188,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50936
51188
  ...options.proxyTls,
50937
51189
  servername: options.proxyTls?.servername || url.hostname
50938
51190
  });
50939
- this[kPool] = null;
51191
+ this[kPools] = /* @__PURE__ */ new Map();
50940
51192
  }
50941
51193
  /**
50942
51194
  * Create a SOCKS5 connection to the proxy
@@ -50946,20 +51198,15 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50946
51198
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
50947
51199
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
50948
51200
  const socket = await new Promise((resolve, reject) => {
50949
- const onConnect = () => {
50950
- socket.removeListener("error", onError);
50951
- resolve(socket);
50952
- };
50953
- const onError = (err) => {
50954
- socket.removeListener("connect", onConnect);
50955
- reject(err);
50956
- };
50957
- const socket = net.connect({
51201
+ this[kConnector]({
51202
+ hostname: proxyHost,
50958
51203
  host: proxyHost,
50959
- port: proxyPort
51204
+ port: proxyPort,
51205
+ protocol: this[kProxyProtocol]
51206
+ }, (err, socket) => {
51207
+ if (err) reject(err);
51208
+ else resolve(socket);
50960
51209
  });
50961
- socket.once("connect", onConnect);
50962
- socket.once("error", onError);
50963
51210
  });
50964
51211
  const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
50965
51212
  socks5Client.on("error", (err) => {
@@ -50981,7 +51228,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50981
51228
  socks5Client.removeListener("authenticated", onAuthenticated);
50982
51229
  reject(err);
50983
51230
  };
50984
- if (socks5Client.state === "authenticated") {
51231
+ if (socks5Client.state === STATES.AUTHENTICATED) {
50985
51232
  clearTimeout(timeout);
50986
51233
  resolve();
50987
51234
  } else {
@@ -51013,53 +51260,69 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
51013
51260
  /**
51014
51261
  * Dispatch a request through the SOCKS5 proxy
51015
51262
  */
51016
- async [kDispatch](opts, handler) {
51263
+ [kDispatch](opts, handler) {
51017
51264
  const { origin } = opts;
51018
51265
  debug("dispatching request to", origin, "via SOCKS5");
51019
51266
  try {
51020
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) this[kPool] = new Pool(origin, {
51021
- pipelining: opts.pipelining,
51022
- connections: opts.connections,
51023
- connect: async (connectOpts, callback) => {
51024
- try {
51025
- const url = new URL$1(origin);
51026
- const targetHost = url.hostname;
51027
- const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
51028
- debug("establishing SOCKS5 connection to", targetHost, targetPort);
51029
- const socket = await this.createSocks5Connection(targetHost, targetPort);
51030
- let finalSocket = socket;
51031
- if (url.protocol === "https:") {
51032
- if (!tls) tls = require("node:tls");
51033
- debug("upgrading to TLS");
51034
- finalSocket = tls.connect({
51035
- socket,
51036
- servername: targetHost,
51037
- ...connectOpts.tls || {}
51038
- });
51039
- await new Promise((resolve, reject) => {
51040
- finalSocket.once("secureConnect", resolve);
51041
- finalSocket.once("error", reject);
51042
- });
51267
+ const originKey = String(origin);
51268
+ let pool = this[kPools].get(originKey);
51269
+ if (!pool || pool.destroyed || pool.closed) {
51270
+ pool = new Pool(origin, {
51271
+ pipelining: opts.pipelining,
51272
+ connections: opts.connections,
51273
+ connect: async (connectOpts, callback) => {
51274
+ try {
51275
+ const url = new URL$1(origin);
51276
+ const targetHost = url.hostname;
51277
+ const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
51278
+ debug("establishing SOCKS5 connection to", targetHost, targetPort);
51279
+ const socket = await this.createSocks5Connection(targetHost, targetPort);
51280
+ let finalSocket = socket;
51281
+ if (url.protocol === "https:") {
51282
+ if (!tls) tls = require("node:tls");
51283
+ debug("upgrading to TLS");
51284
+ finalSocket = tls.connect({
51285
+ ...this[kRequestTls],
51286
+ socket,
51287
+ servername: this[kRequestTls]?.servername || targetHost
51288
+ });
51289
+ await new Promise((resolve, reject) => {
51290
+ finalSocket.once("secureConnect", resolve);
51291
+ finalSocket.once("error", reject);
51292
+ });
51293
+ }
51294
+ callback(null, finalSocket);
51295
+ } catch (err) {
51296
+ debug("SOCKS5 connection error:", err);
51297
+ callback(err);
51043
51298
  }
51044
- callback(null, finalSocket);
51045
- } catch (err) {
51046
- debug("SOCKS5 connection error:", err);
51047
- callback(err);
51048
51299
  }
51049
- }
51050
- });
51051
- return this[kPool][kDispatch](opts, handler);
51300
+ });
51301
+ this[kPools].set(originKey, pool);
51302
+ }
51303
+ return pool[kDispatch](opts, handler);
51052
51304
  } catch (err) {
51053
51305
  debug("dispatch error:", err);
51054
- if (typeof handler.onError === "function") handler.onError(err);
51055
- else throw err;
51306
+ if (typeof handler.onResponseError === "function") {
51307
+ handler.onResponseError(null, err);
51308
+ return false;
51309
+ } else if (typeof handler.onError === "function") {
51310
+ handler.onError(err);
51311
+ return false;
51312
+ } else throw err;
51056
51313
  }
51057
51314
  }
51058
51315
  async [kClose]() {
51059
- if (this[kPool]) await this[kPool].close();
51316
+ const closePromises = [];
51317
+ for (const pool of this[kPools].values()) closePromises.push(pool.close());
51318
+ this[kPools].clear();
51319
+ await Promise.all(closePromises);
51060
51320
  }
51061
51321
  async [kDestroy](err) {
51062
- if (this[kPool]) await this[kPool].destroy(err);
51322
+ const destroyPromises = [];
51323
+ for (const pool of this[kPools].values()) destroyPromises.push(pool.destroy(err));
51324
+ this[kPools].clear();
51325
+ await Promise.all(destroyPromises);
51063
51326
  }
51064
51327
  };
51065
51328
  module.exports = Socks5ProxyAgent;
@@ -51163,7 +51426,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51163
51426
  factory: agentFactory,
51164
51427
  username: opts.username || username,
51165
51428
  password: opts.password || password,
51166
- proxyTls: opts.proxyTls
51429
+ proxyTls: opts.proxyTls,
51430
+ requestTls: opts.requestTls
51167
51431
  });
51168
51432
  if (!this[kTunnelProxy] && protocol === "http:" && this[kProxy].protocol === "http:") return new Http1ProxyWrapper(this[kProxy].uri, {
51169
51433
  headers: this[kProxyHeaders],
@@ -51671,7 +51935,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51671
51935
  constructor(origin, clientOpts) {
51672
51936
  if (typeof origin === "string") origin = new URL(origin);
51673
51937
  if (origin.protocol !== "http:") throw new InvalidArgumentError("h2c-client: Only h2c protocol is supported");
51674
- const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51938
+ const { maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51675
51939
  let defaultMaxConcurrentStreams = 100;
51676
51940
  let defaultPipelining = 100;
51677
51941
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) defaultMaxConcurrentStreams = maxConcurrentStreams;
@@ -52116,7 +52380,7 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
52116
52380
  const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
52117
52381
  try {
52118
52382
  if (typeof callback !== "function") throw new InvalidArgumentError("invalid callback");
52119
- if (highWaterMark && (typeof highWaterMark !== "number" || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
52383
+ if (highWaterMark != null && (!Number.isFinite(highWaterMark) || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
52120
52384
  if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
52121
52385
  if (method === "CONNECT") throw new InvalidArgumentError("invalid method");
52122
52386
  if (onInfo && typeof onInfo !== "function") throw new InvalidArgumentError("invalid onInfo callback");
@@ -53302,12 +53566,12 @@ var require_mock_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53302
53566
  var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53303
53567
  const { kMockCallHistoryAddLog } = require_mock_symbols();
53304
53568
  const { InvalidArgumentError } = require_errors$1();
53305
- function handleFilterCallsWithOptions(criteria, options, handler, store) {
53569
+ function handleFilterCallsWithOptions(criteria, options, handler, store, allLogs) {
53306
53570
  switch (options.operator) {
53307
53571
  case "OR":
53308
- store.push(...handler(criteria));
53572
+ store.push(...handler(criteria, allLogs));
53309
53573
  return store;
53310
- case "AND": return handler.call({ logs: store }, criteria);
53574
+ case "AND": return handler(criteria, store);
53311
53575
  default: throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
53312
53576
  }
53313
53577
  }
@@ -53323,11 +53587,11 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53323
53587
  return finalOptions;
53324
53588
  }
53325
53589
  function makeFilterCalls(parameterName) {
53326
- return (parameterValue) => {
53327
- if (typeof parameterValue === "string" || parameterValue == null) return this.logs.filter((log) => {
53590
+ return (parameterValue, logs) => {
53591
+ if (typeof parameterValue === "string" || parameterValue == null) return logs.filter((log) => {
53328
53592
  return log[parameterName] === parameterValue;
53329
53593
  });
53330
- if (parameterValue instanceof RegExp) return this.logs.filter((log) => {
53594
+ if (parameterValue instanceof RegExp) return logs.filter((log) => {
53331
53595
  return parameterValue.test(log[parameterName]);
53332
53596
  });
53333
53597
  throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
@@ -53415,15 +53679,15 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53415
53679
  operator: "OR",
53416
53680
  ...buildAndValidateFilterCallsOptions(options)
53417
53681
  };
53418
- let maybeDuplicatedLogsFiltered = [];
53419
- if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
53420
- if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
53421
- if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
53422
- if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
53423
- if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
53424
- if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
53425
- if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
53426
- if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered);
53682
+ let maybeDuplicatedLogsFiltered = finalOptions.operator === "AND" ? this.logs : [];
53683
+ if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered, this.logs);
53684
+ if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered, this.logs);
53685
+ if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered, this.logs);
53686
+ if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered, this.logs);
53687
+ if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered, this.logs);
53688
+ if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered, this.logs);
53689
+ if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered, this.logs);
53690
+ if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered, this.logs);
53427
53691
  return [...new Set(maybeDuplicatedLogsFiltered)];
53428
53692
  }
53429
53693
  throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
@@ -54472,7 +54736,8 @@ var require_snapshot_agent = /* @__PURE__ */ __commonJSMin(((exports, module) =>
54472
54736
  //#endregion
54473
54737
  //#region ../../node_modules/undici/lib/global.js
54474
54738
  var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54475
- const globalDispatcher = Symbol.for("undici.globalDispatcher.1");
54739
+ const globalDispatcher = Symbol.for("undici.globalDispatcher.2");
54740
+ const legacyGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");
54476
54741
  const { InvalidArgumentError } = require_errors$1();
54477
54742
  const Agent = require_agent();
54478
54743
  if (getGlobalDispatcher() === void 0) setGlobalDispatcher(new Agent());
@@ -54484,9 +54749,15 @@ var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54484
54749
  enumerable: false,
54485
54750
  configurable: false
54486
54751
  });
54752
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
54753
+ value: agent,
54754
+ writable: true,
54755
+ enumerable: false,
54756
+ configurable: false
54757
+ });
54487
54758
  }
54488
54759
  function getGlobalDispatcher() {
54489
- return globalThis[globalDispatcher];
54760
+ return globalThis[legacyGlobalDispatcher];
54490
54761
  }
54491
54762
  module.exports = {
54492
54763
  setGlobalDispatcher,
@@ -55185,7 +55456,7 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55185
55456
  function makeCacheKey(opts) {
55186
55457
  if (!opts.origin) throw new Error("opts.origin is undefined");
55187
55458
  let fullPath = opts.path || "/";
55188
- if (opts.query && !pathHasQueryOrFragment(opts.path)) fullPath = serializePathWithQuery(fullPath, opts.query);
55459
+ if (opts.query && !pathHasQueryOrFragment(fullPath)) fullPath = serializePathWithQuery(fullPath, opts.query);
55189
55460
  return {
55190
55461
  origin: opts.origin.toString(),
55191
55462
  method: opts.method,
@@ -55301,11 +55572,15 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55301
55572
  lastHeader = lastHeader.substring(0, lastHeader.length - 1);
55302
55573
  headers[headers.length - 1] = lastHeader;
55303
55574
  }
55575
+ for (let j = 0; j < headers.length; j++) headers[j] = headers[j].trim();
55304
55576
  if (key in output) output[key] = output[key].concat(headers);
55305
55577
  else output[key] = headers;
55306
55578
  }
55307
- } else if (key in output) output[key] = output[key].concat(value);
55308
- else output[key] = [value];
55579
+ } else {
55580
+ const fieldName = value.trim();
55581
+ if (key in output) output[key] = output[key].concat(fieldName);
55582
+ else output[key] = [fieldName];
55583
+ }
55309
55584
  break;
55310
55585
  }
55311
55586
  case "public":
@@ -55383,16 +55658,20 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55383
55658
  * @returns {string}
55384
55659
  */
55385
55660
  function makeDeduplicationKey(cacheKey, excludeHeaders) {
55386
- let key = `${cacheKey.origin}:${cacheKey.method}:${cacheKey.path}`;
55661
+ const headers = {};
55387
55662
  if (cacheKey.headers) {
55388
55663
  const sortedHeaders = Object.keys(cacheKey.headers).sort();
55389
55664
  for (const header of sortedHeaders) {
55390
55665
  if (excludeHeaders?.has(header.toLowerCase())) continue;
55391
- const value = cacheKey.headers[header];
55392
- key += `:${header}=${Array.isArray(value) ? value.join(",") : value}`;
55666
+ headers[header] = cacheKey.headers[header];
55393
55667
  }
55394
55668
  }
55395
- return key;
55669
+ return JSON.stringify([
55670
+ cacheKey.origin,
55671
+ cacheKey.method,
55672
+ cacheKey.path,
55673
+ headers
55674
+ ]);
55396
55675
  }
55397
55676
  module.exports = {
55398
55677
  makeCacheKey,
@@ -57331,7 +57610,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57331
57610
  SELECT
57332
57611
  id
57333
57612
  FROM cacheInterceptorV${VERSION}
57334
- ORDER BY cachedAt DESC
57613
+ ORDER BY cachedAt ASC
57335
57614
  LIMIT ?
57336
57615
  )
57337
57616
  `);
@@ -57372,8 +57651,8 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57372
57651
  const existingValue = this.#findValue(key, true);
57373
57652
  if (existingValue) this.#updateValueQuery.run(body, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.cachedAt, value.staleAt, existingValue.id);
57374
57653
  else {
57375
- this.#prune();
57376
57654
  this.#insertValueQuery.run(url, key.method, body, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.vary ? JSON.stringify(value.vary) : null, value.cachedAt, value.staleAt);
57655
+ this.#prune();
57377
57656
  }
57378
57657
  }
57379
57658
  /**
@@ -57456,7 +57735,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57456
57735
  if (values.length === 0) return;
57457
57736
  const now = Date.now();
57458
57737
  for (const value of values) {
57459
- if (now >= value.deleteAt && !canBeExpired) return;
57738
+ if (now >= value.deleteAt && !canBeExpired) continue;
57460
57739
  let matches = true;
57461
57740
  if (value.vary) {
57462
57741
  const vary = JSON.parse(value.vary);
@@ -57886,7 +58165,7 @@ var require_response = /* @__PURE__ */ __commonJSMin(((exports, module) => {
57886
58165
  const nodeUtil$1 = require("node:util");
57887
58166
  const { kEnumerableProperty } = util;
57888
58167
  const { isValidReasonPhrase, isCancelled, isAborted, isErrorLike, environmentSettingsObject: relevantRealm } = require_util$4();
57889
- const { redirectStatusSet, nullBodyStatus } = require_constants$4();
58168
+ const { redirectStatusSet, nullBodyStatus } = require_constants$3();
57890
58169
  const { webidl } = require_webidl();
57891
58170
  const { URLSerializer } = require_data_url();
57892
58171
  const { kConstruct } = require_symbols();
@@ -58230,7 +58509,7 @@ var require_request$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58230
58509
  const util = require_util$5();
58231
58510
  const nodeUtil = require("node:util");
58232
58511
  const { isValidHTTPToken, sameOrigin, environmentSettingsObject } = require_util$4();
58233
- const { forbiddenMethodsSet, corsSafeListedMethodsSet, referrerPolicy, requestRedirect, requestMode, requestCredentials, requestCache, requestDuplex } = require_constants$4();
58512
+ const { forbiddenMethodsSet, corsSafeListedMethodsSet, referrerPolicy, requestRedirect, requestMode, requestCredentials, requestCache, requestDuplex } = require_constants$3();
58234
58513
  const { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util;
58235
58514
  const { webidl } = require_webidl();
58236
58515
  const { URLSerializer } = require_data_url();
@@ -58987,7 +59266,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58987
59266
  const { makePolicyContainer, clonePolicyContainer, requestBadPort, TAOCheck, appendRequestOriginHeader, responseLocationURL, requestCurrentURL, setRequestReferrerPolicyOnRedirect, tryUpgradeRequestToAPotentiallyTrustworthyURL, createOpaqueTimingInfo, appendFetchMetadata, corsCheck, crossOriginResourcePolicyCheck, determineRequestsReferrer, coarsenedSharedCurrentTime, sameOrigin, isCancelled, isAborted, isErrorLike, fullyReadBody, readableStreamClose, urlIsLocal, urlIsHttpHttpsScheme, urlHasHttpsScheme, clampAndCoarsenConnectionTimingInfo, simpleRangeHeaderValue, buildContentRange, createInflate, extractMimeType, hasAuthenticationEntry, includesCredentials, isTraversableNavigable } = require_util$4();
58988
59267
  const assert$5 = require("node:assert");
58989
59268
  const { safelyExtractBody, extractBody } = require_body();
58990
- const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$4();
59269
+ const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$3();
58991
59270
  const EE = require("node:events");
58992
59271
  const { Readable, pipeline: pipeline$1, finished, isErrored, isReadable } = require("node:stream");
58993
59272
  const { addAbortListener, bufferToLowerCasedHeaderName } = require_util$5();
@@ -59286,7 +59565,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59286
59565
  cacheState = "";
59287
59566
  }
59288
59567
  let responseStatus = 0;
59289
- if (fetchParams.request.mode !== "navigator" || !response.hasCrossOriginRedirects) {
59568
+ if (fetchParams.request.mode !== "navigate" || !response.hasCrossOriginRedirects) {
59290
59569
  responseStatus = response.status;
59291
59570
  const mimeType = extractMimeType(response.headersList);
59292
59571
  if (mimeType !== "failure") bodyInfo.contentType = minimizeSupportedMimeType(mimeType);
@@ -59390,7 +59669,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59390
59669
  let contentLengthHeaderValue = null;
59391
59670
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) contentLengthHeaderValue = "0";
59392
59671
  if (contentLength != null) contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
59393
- if (contentLengthHeaderValue != null) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
59672
+ if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
59394
59673
  if (contentLength != null && httpRequest.keepalive) {}
59395
59674
  if (webidl.is.URL(httpRequest.referrer)) httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
59396
59675
  appendRequestOriginHeader(httpRequest);
@@ -60303,7 +60582,7 @@ var require_cachestorage = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60303
60582
  }));
60304
60583
  //#endregion
60305
60584
  //#region ../../node_modules/undici/lib/web/cookies/constants.js
60306
- var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60585
+ var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60307
60586
  module.exports = {
60308
60587
  maxAttributeValueSize: 1024,
60309
60588
  maxNameValuePairSize: 4096
@@ -60507,10 +60786,9 @@ var require_util$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60507
60786
  //#region ../../node_modules/undici/lib/web/cookies/parse.js
60508
60787
  var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60509
60788
  const { collectASequenceOfCodePointsFast } = require_infra();
60510
- const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$3();
60789
+ const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$2();
60511
60790
  const { isCTLExcludingHtab } = require_util$2();
60512
60791
  const assert$2 = require("node:assert");
60513
- const { unescape: qsUnescape } = require("node:querystring");
60514
60792
  /**
60515
60793
  * @description Parses the field-value attributes of a set-cookie header string.
60516
60794
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4
@@ -60539,7 +60817,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60539
60817
  if (name.length + value.length > maxNameValuePairSize) return null;
60540
60818
  return {
60541
60819
  name,
60542
- value: qsUnescape(value),
60820
+ value,
60543
60821
  ...parseUnparsedAttributes(unparsedAttributes)
60544
60822
  };
60545
60823
  }
@@ -60591,12 +60869,10 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60591
60869
  } else if (attributeNameLowercase === "secure") cookieAttributeList.secure = true;
60592
60870
  else if (attributeNameLowercase === "httponly") cookieAttributeList.httpOnly = true;
60593
60871
  else if (attributeNameLowercase === "samesite") {
60594
- let enforcement = "Default";
60595
60872
  const attributeValueLowercase = attributeValue.toLowerCase();
60596
- if (attributeValueLowercase.includes("none")) enforcement = "None";
60597
- if (attributeValueLowercase.includes("strict")) enforcement = "Strict";
60598
- if (attributeValueLowercase.includes("lax")) enforcement = "Lax";
60599
- cookieAttributeList.sameSite = enforcement;
60873
+ if (attributeValueLowercase === "none") cookieAttributeList.sameSite = "None";
60874
+ else if (attributeValueLowercase === "strict") cookieAttributeList.sameSite = "Strict";
60875
+ else if (attributeValueLowercase === "lax") cookieAttributeList.sameSite = "Lax";
60600
60876
  } else {
60601
60877
  cookieAttributeList.unparsed ??= [];
60602
60878
  cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
@@ -61034,7 +61310,7 @@ var require_events = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61034
61310
  }));
61035
61311
  //#endregion
61036
61312
  //#region ../../node_modules/undici/lib/web/websocket/constants.js
61037
- var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61313
+ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61038
61314
  module.exports = {
61039
61315
  uid: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
61040
61316
  sentCloseFrameState: {
@@ -61079,7 +61355,7 @@ var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61079
61355
  //#endregion
61080
61356
  //#region ../../node_modules/undici/lib/web/websocket/util.js
61081
61357
  var require_util$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61082
- const { states, opcodes } = require_constants$2();
61358
+ const { states, opcodes } = require_constants$1();
61083
61359
  const { isUtf8 } = require("node:buffer");
61084
61360
  const { removeHTTPWhitespace } = require_data_url();
61085
61361
  const { collectASequenceOfCodePointsFast } = require_infra();
@@ -61286,7 +61562,7 @@ var require_util$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61286
61562
  //#region ../../node_modules/undici/lib/web/websocket/frame.js
61287
61563
  var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61288
61564
  const { runtimeFeatures } = require_runtime_features();
61289
- const { maxUnsigned16Bit, opcodes } = require_constants$2();
61565
+ const { maxUnsigned16Bit, opcodes } = require_constants$1();
61290
61566
  const BUFFER_SIZE = 8 * 1024;
61291
61567
  let buffer = null;
61292
61568
  let bufIdx = BUFFER_SIZE;
@@ -61384,7 +61660,7 @@ var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61384
61660
  //#endregion
61385
61661
  //#region ../../node_modules/undici/lib/web/websocket/connection.js
61386
61662
  var require_connection = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61387
- const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$2();
61663
+ const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$1();
61388
61664
  const { parseExtensions, isClosed, isClosing, isEstablished, isConnecting, validateCloseCodeAndReason } = require_util$1();
61389
61665
  const { makeRequest } = require_request$1();
61390
61666
  const { fetching } = require_fetch();
@@ -61545,27 +61821,26 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61545
61821
  ]);
61546
61822
  const kBuffer = Symbol("kBuffer");
61547
61823
  const kLength = Symbol("kLength");
61548
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024;
61549
61824
  var PerMessageDeflate = class {
61550
61825
  /** @type {import('node:zlib').InflateRaw} */
61551
61826
  #inflate;
61552
61827
  #options = {};
61553
- /** @type {boolean} */
61554
- #aborted = false;
61555
- /** @type {Function|null} */
61556
- #currentCallback = null;
61828
+ #maxPayloadSize = 0;
61557
61829
  /**
61558
61830
  * @param {Map<string, string>} extensions
61559
61831
  */
61560
- constructor(extensions) {
61832
+ constructor(extensions, options) {
61561
61833
  this.#options.serverNoContextTakeover = extensions.has("server_no_context_takeover");
61562
61834
  this.#options.serverMaxWindowBits = extensions.get("server_max_window_bits");
61835
+ this.#maxPayloadSize = options.maxPayloadSize;
61563
61836
  }
61837
+ /**
61838
+ * Decompress a compressed payload.
61839
+ * @param {Buffer} chunk Compressed data
61840
+ * @param {boolean} fin Final fragment flag
61841
+ * @param {Function} callback Callback function
61842
+ */
61564
61843
  decompress(chunk, fin, callback) {
61565
- if (this.#aborted) {
61566
- callback(new MessageSizeExceededError());
61567
- return;
61568
- }
61569
61844
  if (!this.#inflate) {
61570
61845
  let windowBits = Z_DEFAULT_WINDOWBITS;
61571
61846
  if (this.#options.serverMaxWindowBits) {
@@ -61584,18 +61859,11 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61584
61859
  this.#inflate[kBuffer] = [];
61585
61860
  this.#inflate[kLength] = 0;
61586
61861
  this.#inflate.on("data", (data) => {
61587
- if (this.#aborted) return;
61588
61862
  this.#inflate[kLength] += data.length;
61589
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
61590
- this.#aborted = true;
61863
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
61864
+ callback(new MessageSizeExceededError());
61591
61865
  this.#inflate.removeAllListeners();
61592
- this.#inflate.destroy();
61593
61866
  this.#inflate = null;
61594
- if (this.#currentCallback) {
61595
- const cb = this.#currentCallback;
61596
- this.#currentCallback = null;
61597
- cb(new MessageSizeExceededError());
61598
- }
61599
61867
  return;
61600
61868
  }
61601
61869
  this.#inflate[kBuffer].push(data);
@@ -61605,15 +61873,13 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61605
61873
  callback(err);
61606
61874
  });
61607
61875
  }
61608
- this.#currentCallback = callback;
61609
61876
  this.#inflate.write(chunk);
61610
61877
  if (fin) this.#inflate.write(tail);
61611
61878
  this.#inflate.flush(() => {
61612
- if (this.#aborted || !this.#inflate) return;
61879
+ if (!this.#inflate) return;
61613
61880
  const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength]);
61614
61881
  this.#inflate[kBuffer].length = 0;
61615
61882
  this.#inflate[kLength] = 0;
61616
- this.#currentCallback = null;
61617
61883
  callback(null, full);
61618
61884
  });
61619
61885
  }
@@ -61625,7 +61891,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61625
61891
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61626
61892
  const { Writable } = require("node:stream");
61627
61893
  const assert = require("node:assert");
61628
- const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$2();
61894
+ const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$1();
61629
61895
  const { isValidStatusCode, isValidOpcode, websocketMessageReceived, utf8Decode, isControlFrame, isTextBinaryFrame, isContinuationFrame } = require_util$1();
61630
61896
  const { failWebsocketConnection } = require_connection();
61631
61897
  const { WebsocketFrameSend } = require_frame();
@@ -61643,15 +61909,22 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61643
61909
  #extensions;
61644
61910
  /** @type {import('./websocket').Handler} */
61645
61911
  #handler;
61912
+ /** @type {number} */
61913
+ #maxFragments;
61914
+ /** @type {number} */
61915
+ #maxPayloadSize;
61646
61916
  /**
61647
61917
  * @param {import('./websocket').Handler} handler
61648
61918
  * @param {Map<string, string>|null} extensions
61919
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
61649
61920
  */
61650
- constructor(handler, extensions) {
61921
+ constructor(handler, extensions, options = {}) {
61651
61922
  super();
61652
61923
  this.#handler = handler;
61653
61924
  this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
61654
- if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions));
61925
+ this.#maxFragments = options.maxFragments ?? 0;
61926
+ this.#maxPayloadSize = options.maxPayloadSize ?? 0;
61927
+ if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions, options));
61655
61928
  }
61656
61929
  /**
61657
61930
  * @param {Buffer} chunk
@@ -61663,6 +61936,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61663
61936
  this.#loop = true;
61664
61937
  this.run(callback);
61665
61938
  }
61939
+ #validatePayloadLength() {
61940
+ if (this.#maxPayloadSize > 0 && !isControlFrame(this.#info.opcode) && this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize) {
61941
+ failWebsocketConnection(this.#handler, 1009, "Payload size exceeds maximum allowed size");
61942
+ return false;
61943
+ }
61944
+ return true;
61945
+ }
61666
61946
  /**
61667
61947
  * Runs whenever a new chunk is received.
61668
61948
  * Callback is called whenever there are no more chunks buffering,
@@ -61719,6 +61999,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61719
61999
  if (payloadLength <= 125) {
61720
62000
  this.#info.payloadLength = payloadLength;
61721
62001
  this.#state = parserStates.READ_DATA;
62002
+ if (!this.#validatePayloadLength()) return;
61722
62003
  } else if (payloadLength === 126) this.#state = parserStates.PAYLOADLENGTH_16;
61723
62004
  else if (payloadLength === 127) this.#state = parserStates.PAYLOADLENGTH_64;
61724
62005
  if (isTextBinaryFrame(opcode)) {
@@ -61734,6 +62015,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61734
62015
  const buffer = this.consume(2);
61735
62016
  this.#info.payloadLength = buffer.readUInt16BE(0);
61736
62017
  this.#state = parserStates.READ_DATA;
62018
+ if (!this.#validatePayloadLength()) return;
61737
62019
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
61738
62020
  if (this.#byteOffset < 8) return callback();
61739
62021
  const buffer = this.consume(8);
@@ -61745,6 +62027,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61745
62027
  }
61746
62028
  this.#info.payloadLength = lower;
61747
62029
  this.#state = parserStates.READ_DATA;
62030
+ if (!this.#validatePayloadLength()) return;
61748
62031
  } else if (this.#state === parserStates.READ_DATA) {
61749
62032
  if (this.#byteOffset < this.#info.payloadLength) return callback();
61750
62033
  const body = this.consume(this.#info.payloadLength);
@@ -61752,7 +62035,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61752
62035
  this.#loop = this.parseControlFrame(body);
61753
62036
  this.#state = parserStates.INFO;
61754
62037
  } else if (!this.#info.compressed) {
61755
- this.writeFragments(body);
62038
+ if (!this.writeFragments(body)) return;
61756
62039
  if (!this.#info.fragmented && this.#info.fin) websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments());
61757
62040
  this.#state = parserStates.INFO;
61758
62041
  } else {
@@ -61762,7 +62045,11 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61762
62045
  failWebsocketConnection(this.#handler, code, error.message);
61763
62046
  return;
61764
62047
  }
61765
- this.writeFragments(data);
62048
+ if (!this.writeFragments(data)) return;
62049
+ if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
62050
+ failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message);
62051
+ return;
62052
+ }
61766
62053
  if (!this.#info.fin) {
61767
62054
  this.#state = parserStates.INFO;
61768
62055
  this.#loop = true;
@@ -61773,7 +62060,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61773
62060
  this.#loop = true;
61774
62061
  this.#state = parserStates.INFO;
61775
62062
  this.run(callback);
61776
- });
62063
+ }, this.#fragmentsBytes);
61777
62064
  this.#loop = false;
61778
62065
  break;
61779
62066
  }
@@ -61815,8 +62102,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61815
62102
  }
61816
62103
  }
61817
62104
  writeFragments(fragment) {
62105
+ if (this.#maxFragments > 0 && this.#fragments.length === this.#maxFragments) {
62106
+ failWebsocketConnection(this.#handler, 1008, "Too many message fragments");
62107
+ return false;
62108
+ }
61818
62109
  this.#fragmentsBytes += fragment.length;
61819
62110
  this.#fragments.push(fragment);
62111
+ return true;
61820
62112
  }
61821
62113
  consumeFragments() {
61822
62114
  const fragments = this.#fragments;
@@ -61912,7 +62204,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61912
62204
  //#region ../../node_modules/undici/lib/web/websocket/sender.js
61913
62205
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61914
62206
  const { WebsocketFrameSend } = require_frame();
61915
- const { opcodes, sendHints } = require_constants$2();
62207
+ const { opcodes, sendHints } = require_constants$1();
61916
62208
  const FixedQueue = require_fixed_queue();
61917
62209
  /**
61918
62210
  * @typedef {object} SendQueueNode
@@ -61998,7 +62290,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61998
62290
  const { webidl } = require_webidl();
61999
62291
  const { URLSerializer } = require_data_url();
62000
62292
  const { environmentSettingsObject } = require_util$4();
62001
- const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$2();
62293
+ const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$1();
62002
62294
  const { isConnecting, isEstablished, isClosing, isClosed, isValidSubprotocol, fireEvent, utf8Decode, toArrayBuffer, getURLRecord } = require_util$1();
62003
62295
  const { establishWebSocketConnection, closeWebSocketConnection, failWebsocketConnection } = require_connection();
62004
62296
  const { ByteParser } = require_receiver();
@@ -62237,7 +62529,13 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62237
62529
  */
62238
62530
  #onConnectionEstablished(response, parsedExtensions) {
62239
62531
  this.#handler.socket = response.socket;
62240
- const parser = new ByteParser(this.#handler, parsedExtensions);
62532
+ const webSocketOptions = this.#handler.controller.dispatcher?.webSocketOptions;
62533
+ const maxFragments = webSocketOptions?.maxFragments;
62534
+ const maxPayloadSize = webSocketOptions?.maxPayloadSize;
62535
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
62536
+ maxFragments,
62537
+ maxPayloadSize
62538
+ });
62241
62539
  parser.on("drain", () => this.#handler.onParserDrain());
62242
62540
  parser.on("error", (err) => this.#handler.onParserError(err));
62243
62541
  this.#parser = parser;
@@ -62475,7 +62773,7 @@ var require_websocketerror = /* @__PURE__ */ __commonJSMin(((exports, module) =>
62475
62773
  var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62476
62774
  const { createDeferredPromise } = require_promise();
62477
62775
  const { environmentSettingsObject } = require_util$4();
62478
- const { states, opcodes, sentCloseFrameState } = require_constants$2();
62776
+ const { states, opcodes, sentCloseFrameState } = require_constants$1();
62479
62777
  const { webidl } = require_webidl();
62480
62778
  const { getURLRecord, isValidSubprotocol, isEstablished, utf8Decode } = require_util$1();
62481
62779
  const { establishWebSocketConnection, failWebsocketConnection, closeWebSocketConnection } = require_connection();
@@ -62606,7 +62904,12 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62606
62904
  /** @type {import('../websocket').Handler['onConnectionEstablished']} */
62607
62905
  #onConnectionEstablished(response, parsedExtensions) {
62608
62906
  this.#handler.socket = response.socket;
62609
- const parser = new ByteParser(this.#handler, parsedExtensions);
62907
+ const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
62908
+ const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
62909
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
62910
+ maxFragments,
62911
+ maxPayloadSize
62912
+ });
62610
62913
  parser.on("drain", () => this.#handler.onParserDrain());
62611
62914
  parser.on("error", (err) => this.#handler.onParserError(err));
62612
62915
  this.#parser = parser;
@@ -62617,10 +62920,6 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62617
62920
  start: (controller) => {
62618
62921
  this.#readableStreamController = controller;
62619
62922
  },
62620
- pull(controller) {
62621
- let chunk;
62622
- while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) controller.enqueue(chunk);
62623
- },
62624
62923
  cancel: (reason) => this.#cancel(reason)
62625
62924
  });
62626
62925
  const writable = new WritableStream({
@@ -62644,7 +62943,7 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62644
62943
  if (type === opcodes.TEXT) try {
62645
62944
  chunk = utf8Decode(data);
62646
62945
  } catch {
62647
- failWebsocketConnection(this.#handler, "Received invalid UTF-8 in text frame.");
62946
+ failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame.");
62648
62947
  return;
62649
62948
  }
62650
62949
  else if (type === opcodes.BINARY) chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
@@ -73976,6 +74275,17 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
73976
74275
  var hasOwn = require_hasown();
73977
74276
  var populate = require_populate();
73978
74277
  /**
74278
+ * Escape CR, LF, and `"` in a multipart `name`/`filename` parameter, so a field
74279
+ * name or filename can not break out of its header line to inject headers or
74280
+ * smuggle additional parts. Matches the WHATWG HTML multipart/form-data encoding.
74281
+ *
74282
+ * @param {string} str - the parameter value to escape
74283
+ * @returns {string} the escaped value
74284
+ */
74285
+ function escapeHeaderParam(str) {
74286
+ return String(str).replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/"/g, "%22");
74287
+ }
74288
+ /**
73979
74289
  * Create readable "multipart/form-data" streams.
73980
74290
  * Can be used to submit forms
73981
74291
  * and file uploads to other web applications.
@@ -74045,7 +74355,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74045
74355
  var contentType = this._getContentType(value, options);
74046
74356
  var contents = "";
74047
74357
  var headers = {
74048
- "Content-Disposition": ["form-data", "name=\"" + field + "\""].concat(contentDisposition || []),
74358
+ "Content-Disposition": ["form-data", "name=\"" + escapeHeaderParam(field) + "\""].concat(contentDisposition || []),
74049
74359
  "Content-Type": [].concat(contentType || [])
74050
74360
  };
74051
74361
  if (typeof options.header === "object") populate(headers, options.header);
@@ -74063,7 +74373,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74063
74373
  if (typeof options.filepath === "string") filename = path$1.normalize(options.filepath).replace(/\\/g, "/");
74064
74374
  else if (options.filename || value && (value.name || value.path)) filename = path$1.basename(options.filename || value && (value.name || value.path));
74065
74375
  else if (value && value.readable && hasOwn(value, "httpVersion")) filename = path$1.basename(value.client._httpMessage.path || "");
74066
- if (filename) return "filename=\"" + filename + "\"";
74376
+ if (filename) return "filename=\"" + escapeHeaderParam(filename) + "\"";
74067
74377
  };
74068
74378
  FormData.prototype._getContentType = function(value, options) {
74069
74379
  var contentType = options.contentType;
@@ -74190,12 +74500,12 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74190
74500
  FormData.prototype.toString = function() {
74191
74501
  return "[object FormData]";
74192
74502
  };
74193
- setToStringTag(FormData, "FormData");
74503
+ setToStringTag(FormData.prototype, "FormData");
74194
74504
  module.exports = FormData;
74195
74505
  }));
74196
74506
  //#endregion
74197
74507
  //#region ../../node_modules/semver/internal/constants.js
74198
- var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74508
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74199
74509
  const SEMVER_SPEC_VERSION = "2.0.0";
74200
74510
  const MAX_LENGTH = 256;
74201
74511
  const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
@@ -74226,7 +74536,7 @@ var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74226
74536
  //#endregion
74227
74537
  //#region ../../node_modules/semver/internal/re.js
74228
74538
  var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74229
- const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants$1();
74539
+ const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
74230
74540
  const debug = require_debug();
74231
74541
  exports = module.exports = {};
74232
74542
  const re = exports.re = [];
@@ -74338,7 +74648,7 @@ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74338
74648
  //#region ../../node_modules/semver/classes/semver.js
74339
74649
  var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74340
74650
  const debug = require_debug();
74341
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants$1();
74651
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
74342
74652
  const { safeRe: re, t } = require_re();
74343
74653
  const parseOptions = require_parse_options();
74344
74654
  const { compareIdentifiers } = require_identifiers();
@@ -74919,7 +75229,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74919
75229
  const debug = require_debug();
74920
75230
  const SemVer = require_semver$1();
74921
75231
  const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
74922
- const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants$1();
75232
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
74923
75233
  const isNullSet = (c) => c.value === "<0.0.0-0";
74924
75234
  const isAny = (c) => c.value === "";
74925
75235
  const isSatisfiable = (comparators, options) => {
@@ -75479,7 +75789,7 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
75479
75789
  //#region ../../node_modules/semver/index.js
75480
75790
  var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
75481
75791
  const internalRe = require_re();
75482
- const constants = require_constants$1();
75792
+ const constants = require_constants();
75483
75793
  const SemVer = require_semver$1();
75484
75794
  const identifiers = require_identifiers();
75485
75795
  module.exports = {
@@ -76296,6 +76606,9 @@ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
76296
76606
  setJsonOutput(newJsonOutput) {
76297
76607
  this.jsonOutput = newJsonOutput;
76298
76608
  }
76609
+ isJsonOutput() {
76610
+ return this.jsonOutput;
76611
+ }
76299
76612
  error(s) {
76300
76613
  if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
76301
76614
  }
@@ -77800,13 +78113,61 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
77800
78113
  //#endregion
77801
78114
  //#region ../base/dist/index.js
77802
78115
  var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
78116
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
78117
+ if (k2 === void 0) k2 = k;
78118
+ var desc = Object.getOwnPropertyDescriptor(m, k);
78119
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
78120
+ enumerable: true,
78121
+ get: function() {
78122
+ return m[k];
78123
+ }
78124
+ };
78125
+ Object.defineProperty(o, k2, desc);
78126
+ }) : (function(o, m, k, k2) {
78127
+ if (k2 === void 0) k2 = k;
78128
+ o[k2] = m[k];
78129
+ }));
78130
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
78131
+ Object.defineProperty(o, "default", {
78132
+ enumerable: true,
78133
+ value: v
78134
+ });
78135
+ }) : function(o, v) {
78136
+ o["default"] = v;
78137
+ });
78138
+ var __importStar = exports && exports.__importStar || function(mod) {
78139
+ if (mod && mod.__esModule) return mod;
78140
+ var result = {};
78141
+ if (mod != null) {
78142
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
78143
+ }
78144
+ __setModuleDefault(result, mod);
78145
+ return result;
78146
+ };
77803
78147
  Object.defineProperty(exports, "__esModule", { value: true });
77804
78148
  exports.BaseCommand = void 0;
77805
78149
  const clipanion_1 = require_advanced();
78150
+ const t = __importStar(require_lib$2());
78151
+ const constants_1 = require_constants$10();
78152
+ const logger_1 = require_logger();
77806
78153
  /**
77807
78154
  * This command should be extended by **every** command in the monorepo.
77808
78155
  */
77809
- var BaseCommand = class extends clipanion_1.Command {};
78156
+ var BaseCommand = class extends clipanion_1.Command {
78157
+ constructor() {
78158
+ super(...arguments);
78159
+ this.logFormat = clipanion_1.Option.String("--log-format", "text", {
78160
+ env: constants_1.LOG_FORMAT_ENV_VAR,
78161
+ hidden: true,
78162
+ description: "Output format for logs: 'text' (default) or 'json' (one JSON object per line).",
78163
+ validator: t.isEnum(["text", "json"])
78164
+ });
78165
+ }
78166
+ get logger() {
78167
+ if (!this._logger) this._logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO, { jsonOutput: this.logFormat === "json" });
78168
+ return this._logger;
78169
+ }
78170
+ };
77810
78171
  exports.BaseCommand = BaseCommand;
77811
78172
  }));
77812
78173
  //#endregion
@@ -77917,69 +78278,6 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
77917
78278
  });
77918
78279
  }));
77919
78280
  //#endregion
77920
- //#region ../base/dist/constants.js
77921
- var require_constants = /* @__PURE__ */ __commonJSMin(((exports) => {
77922
- Object.defineProperty(exports, "__esModule", { value: true });
77923
- exports.METHOD_POST = exports.CONTENT_TYPE_VALUE_JSON = exports.CONTENT_TYPE_VALUE_PROTOBUF = exports.CONTENT_TYPE_HEADER = exports.FIPS_IGNORE_ERROR_ENV_VAR = exports.FIPS_ENV_VAR = exports.DATADOG_SITES = exports.DATADOG_SITE_US2_GOV = exports.DATADOG_SITE_GOV = exports.DATADOG_SITE_AP2 = exports.DATADOG_SITE_AP1 = exports.DATADOG_SITE_US5 = exports.DATADOG_SITE_US3 = exports.DATADOG_SITE_EU1 = exports.DATADOG_SITE_US1 = void 0;
77924
- exports.DATADOG_SITE_US1 = "datadoghq.com";
77925
- exports.DATADOG_SITE_EU1 = "datadoghq.eu";
77926
- exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
77927
- exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
77928
- exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
77929
- exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
77930
- exports.DATADOG_SITE_GOV = "ddog-gov.com";
77931
- exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
77932
- exports.DATADOG_SITES = [
77933
- exports.DATADOG_SITE_US1,
77934
- exports.DATADOG_SITE_EU1,
77935
- exports.DATADOG_SITE_US3,
77936
- exports.DATADOG_SITE_US5,
77937
- exports.DATADOG_SITE_AP1,
77938
- exports.DATADOG_SITE_AP2,
77939
- exports.DATADOG_SITE_GOV,
77940
- exports.DATADOG_SITE_US2_GOV
77941
- ];
77942
- exports.FIPS_ENV_VAR = "DATADOG_FIPS";
77943
- exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
77944
- exports.CONTENT_TYPE_HEADER = "Content-Type";
77945
- exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
77946
- exports.CONTENT_TYPE_VALUE_JSON = "application/json";
77947
- exports.METHOD_POST = "post";
77948
- }));
77949
- //#endregion
77950
- //#region ../base/dist/helpers/env.js
77951
- var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
77952
- Object.defineProperty(exports, "__esModule", { value: true });
77953
- exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
77954
- const toBoolean = (env) => {
77955
- if (env === void 0) return;
77956
- if (env.toLowerCase() === "true" || env === "1") return true;
77957
- if (env.toLowerCase() === "false" || env === "0") return false;
77958
- };
77959
- exports.toBoolean = toBoolean;
77960
- const toNumber = (env) => {
77961
- if (env === void 0 || env.trim() === "") return;
77962
- const number = Number(env);
77963
- if (isNaN(number)) return;
77964
- return number;
77965
- };
77966
- exports.toNumber = toNumber;
77967
- const toStringMap = (env) => {
77968
- if (env === void 0) return;
77969
- const cleanedEnv = env.replace(/'/g, "\"");
77970
- try {
77971
- const parsed = JSON.parse(cleanedEnv);
77972
- if (typeof parsed === "object" && parsed !== null) {
77973
- for (const key in parsed) if (typeof parsed[key] !== "string") return;
77974
- return parsed;
77975
- }
77976
- } catch (error) {
77977
- return;
77978
- }
77979
- };
77980
- exports.toStringMap = toStringMap;
77981
- }));
77982
- //#endregion
77983
78281
  //#region ../base/dist/helpers/fips.js
77984
78282
  var require_fips = /* @__PURE__ */ __commonJSMin(((exports) => {
77985
78283
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -78044,7 +78342,7 @@ var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
78044
78342
  var require_api = /* @__PURE__ */ __commonJSMin(((exports) => {
78045
78343
  Object.defineProperty(exports, "__esModule", { value: true });
78046
78344
  exports.getBaseIntakeUrl = exports.getApiUrl = exports.getIntakeUrl = exports.getDatadogSite = exports.getDatadogSiteFromEnv = void 0;
78047
- const constants_1 = require_constants();
78345
+ const constants_1 = require_constants$10();
78048
78346
  /**
78049
78347
  * Read the Datadog site from `DATADOG_SITE` / `DD_SITE` env vars.
78050
78348
  * Returns `undefined` when neither is set.
@@ -78085,6 +78383,8 @@ var require_api = /* @__PURE__ */ __commonJSMin(((exports) => {
78085
78383
  //#endregion
78086
78384
  //#region src/api.ts
78087
78385
  var import_source = /* @__PURE__ */ __toESM(require_source());
78386
+ var import_constants = require_constants$10();
78387
+ var import_env = require_env();
78088
78388
  var import_format_git_span_data = require_format_git_span_data();
78089
78389
  var import_user_provided_git = require_user_provided_git();
78090
78390
  var import_ci = require_ci();
@@ -78094,8 +78394,6 @@ var import_gitdb = require_gitdb();
78094
78394
  var import_logger = require_logger();
78095
78395
  var import_library = require_library();
78096
78396
  var import_upload = require_upload();
78097
- var import_constants = require_constants();
78098
- var import_env = require_env();
78099
78397
  var import_fips = require_fips();
78100
78398
  var import_id = /* @__PURE__ */ __toESM(require_id());
78101
78399
  var import_api = require_api();
@@ -78310,7 +78608,6 @@ var PluginCommand = class extends import_upload.TerraformUploadCommand {
78310
78608
  fips: (0, import_env.toBoolean)(process.env[import_constants.FIPS_ENV_VAR]) ?? false,
78311
78609
  fipsIgnoreError: (0, import_env.toBoolean)(process.env[import_constants.FIPS_IGNORE_ERROR_ENV_VAR]) ?? false
78312
78610
  };
78313
- this.logger = new import_logger.Logger((s) => this.context.stdout.write(s), import_logger.LogLevel.INFO);
78314
78611
  this.git = void 0;
78315
78612
  }
78316
78613
  async execute() {