@datadog/datadog-ci-plugin-terraform 5.18.0 → 5.20.0

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,11 +10914,12 @@ 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.18.0",
10917
+ "version": "5.20.0",
10918
10918
  "description": "Base package for Datadog CI",
10919
10919
  "license": "Apache-2.0",
10920
10920
  "keywords": ["datadog", "datadog-ci"],
10921
10921
  "homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/base",
10922
+ "bugs": { "url": "https://github.com/DataDog/datadog-ci/issues" },
10922
10923
  "repository": {
10923
10924
  "type": "git",
10924
10925
  "url": "https://github.com/DataDog/datadog-ci.git",
@@ -11010,12 +11011,12 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11010
11011
  "debug": "^4.4.1",
11011
11012
  "deep-extend": "^0.6.0",
11012
11013
  "fast-xml-parser": "^5.7.2",
11013
- "form-data": "^4.0.4",
11014
+ "form-data": "^4.0.6",
11014
11015
  "glob": "^13.0.6",
11015
11016
  "inquirer": "^8.2.7",
11016
11017
  "is-docker": "^4.0.0",
11017
11018
  "jest-diff": "^30.2.0",
11018
- "js-yaml": "^4.1.1",
11019
+ "js-yaml": "^4.2.0",
11019
11020
  "jszip": "^3.10.1",
11020
11021
  "proxy-agent": "^6.4.0",
11021
11022
  "semver": "^7.6.3",
@@ -11023,7 +11024,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11023
11024
  "terminal-link": "^2.1.1",
11024
11025
  "tiny-async-pool": "^2.1.0",
11025
11026
  "typanion": "^3.14.0",
11026
- "undici": "^7.24.6",
11027
+ "undici": "^7.28.0",
11027
11028
  "upath": "^2.0.1"
11028
11029
  },
11029
11030
  "devDependencies": {
@@ -11038,6 +11039,71 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11038
11039
  };
11039
11040
  }));
11040
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
11041
11107
  //#region ../base/dist/version.js
11042
11108
  var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
11043
11109
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -11046,18 +11112,29 @@ var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
11046
11112
  Object.defineProperty(exports, "__esModule", { value: true });
11047
11113
  exports.printVersion = exports.cliVersion = void 0;
11048
11114
  const chalk_1 = __importDefault(require_source());
11049
- 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;
11050
11119
  /**
11051
- * 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.
11052
11125
  */
11053
- const printVersion = () => {
11054
- 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));
11055
11132
  };
11056
11133
  exports.printVersion = printVersion;
11057
11134
  }));
11058
11135
  //#endregion
11059
11136
  //#region ../../node_modules/clipanion/lib/constants.js
11060
- var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
11137
+ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
11061
11138
  Object.defineProperty(exports, "__esModule", { value: true });
11062
11139
  const NODE_INITIAL = 0;
11063
11140
  const NODE_SUCCESS = 1;
@@ -11086,7 +11163,7 @@ var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
11086
11163
  //#region ../../node_modules/clipanion/lib/errors.js
11087
11164
  var require_errors$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
11088
11165
  Object.defineProperty(exports, "__esModule", { value: true });
11089
- var constants = require_constants$10();
11166
+ var constants = require_constants$9();
11090
11167
  /**
11091
11168
  * A generic usage error with the name `UsageError`.
11092
11169
  *
@@ -12374,7 +12451,7 @@ var require_Command = /* @__PURE__ */ __commonJSMin(((exports) => {
12374
12451
  //#region ../../node_modules/clipanion/lib/core.js
12375
12452
  var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
12376
12453
  Object.defineProperty(exports, "__esModule", { value: true });
12377
- var constants = require_constants$10();
12454
+ var constants = require_constants$9();
12378
12455
  var errors = require_errors$3();
12379
12456
  function debug(str) {
12380
12457
  if (constants.DEBUG) console.log(str);
@@ -13271,7 +13348,7 @@ var require_HelpCommand = /* @__PURE__ */ __commonJSMin(((exports) => {
13271
13348
  //#region ../../node_modules/clipanion/lib/advanced/Cli.js
13272
13349
  var require_Cli = /* @__PURE__ */ __commonJSMin(((exports) => {
13273
13350
  Object.defineProperty(exports, "__esModule", { value: true });
13274
- var constants = require_constants$10();
13351
+ var constants = require_constants$9();
13275
13352
  var core = require_core$1();
13276
13353
  var format = require_format();
13277
13354
  var platform = require_node$1();
@@ -14958,7 +15035,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14958
15035
  };
14959
15036
  Object.defineProperty(exports, "__esModule", { value: true });
14960
15037
  exports.Agent = void 0;
14961
- const net$11 = __importStar(require("net"));
15038
+ const net$10 = __importStar(require("net"));
14962
15039
  const http$3 = __importStar(require("http"));
14963
15040
  const https_1$2 = require("https");
14964
15041
  __exportStar(require_helpers$2(), exports);
@@ -14983,7 +15060,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14983
15060
  incrementSockets(name) {
14984
15061
  if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
14985
15062
  if (!this.sockets[name]) this.sockets[name] = [];
14986
- const fakeSocket = new net$11.Socket({ writable: false });
15063
+ const fakeSocket = new net$10.Socket({ writable: false });
14987
15064
  this.sockets[name].push(fakeSocket);
14988
15065
  this.totalSocketCount++;
14989
15066
  return fakeSocket;
@@ -15152,7 +15229,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15152
15229
  };
15153
15230
  Object.defineProperty(exports, "__esModule", { value: true });
15154
15231
  exports.HttpProxyAgent = void 0;
15155
- const net$10 = __importStar(require("net"));
15232
+ const net$9 = __importStar(require("net"));
15156
15233
  const tls$3 = __importStar(require("tls"));
15157
15234
  const debug_1 = __importDefault(require_src$1());
15158
15235
  const events_1$3 = require("events");
@@ -15219,7 +15296,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15219
15296
  socket = tls$3.connect(this.connectOpts);
15220
15297
  } else {
15221
15298
  debug("Creating `net.Socket`: %o", this.connectOpts);
15222
- socket = net$10.connect(this.connectOpts);
15299
+ socket = net$9.connect(this.connectOpts);
15223
15300
  }
15224
15301
  await (0, events_1$3.once)(socket, "connect");
15225
15302
  return socket;
@@ -15358,7 +15435,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15358
15435
  };
15359
15436
  Object.defineProperty(exports, "__esModule", { value: true });
15360
15437
  exports.HttpsProxyAgent = void 0;
15361
- const net$9 = __importStar(require("net"));
15438
+ const net$8 = __importStar(require("net"));
15362
15439
  const tls$2 = __importStar(require("tls"));
15363
15440
  const assert_1 = __importDefault(require("assert"));
15364
15441
  const debug_1 = __importDefault(require_src$1());
@@ -15367,7 +15444,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15367
15444
  const parse_proxy_response_1 = require_parse_proxy_response();
15368
15445
  const debug = (0, debug_1.default)("https-proxy-agent");
15369
15446
  const setServernameFromNonIpHost = (options) => {
15370
- 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 {
15371
15448
  ...options,
15372
15449
  servername: options.host
15373
15450
  };
@@ -15414,10 +15491,10 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15414
15491
  socket = tls$2.connect(setServernameFromNonIpHost(this.connectOpts));
15415
15492
  } else {
15416
15493
  debug("Creating `net.Socket`: %o", this.connectOpts);
15417
- socket = net$9.connect(this.connectOpts);
15494
+ socket = net$8.connect(this.connectOpts);
15418
15495
  }
15419
15496
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
15420
- const host = net$9.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15497
+ const host = net$8.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15421
15498
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
15422
15499
  if (proxy.username || proxy.password) {
15423
15500
  const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
@@ -15443,7 +15520,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15443
15520
  return socket;
15444
15521
  }
15445
15522
  socket.destroy();
15446
- const fakeSocket = new net$9.Socket({ writable: false });
15523
+ const fakeSocket = new net$8.Socket({ writable: false });
15447
15524
  fakeSocket.readable = true;
15448
15525
  req.once("socket", (s) => {
15449
15526
  debug("Replaying proxy buffer for failed request");
@@ -16652,7 +16729,7 @@ var require_smartbuffer = /* @__PURE__ */ __commonJSMin(((exports) => {
16652
16729
  }));
16653
16730
  //#endregion
16654
16731
  //#region ../../node_modules/socks/build/common/constants.js
16655
- var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
16732
+ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
16656
16733
  Object.defineProperty(exports, "__esModule", { value: true });
16657
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;
16658
16735
  exports.DEFAULT_TIMEOUT = 3e4;
@@ -16800,7 +16877,7 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
16800
16877
  }));
16801
16878
  //#endregion
16802
16879
  //#region ../../node_modules/ip-address/dist/v4/constants.js
16803
- var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
16880
+ var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
16804
16881
  Object.defineProperty(exports, "__esModule", { value: true });
16805
16882
  exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = void 0;
16806
16883
  exports.BITS = 32;
@@ -18437,7 +18514,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18437
18514
  Object.defineProperty(exports, "__esModule", { value: true });
18438
18515
  exports.Address4 = void 0;
18439
18516
  const common = __importStar(require_common$1());
18440
- const constants = __importStar(require_constants$8());
18517
+ const constants = __importStar(require_constants$7());
18441
18518
  const address_error_1 = require_address_error();
18442
18519
  const jsbn_1 = require_jsbn();
18443
18520
  const sprintf_js_1 = require_sprintf();
@@ -18713,7 +18790,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18713
18790
  }));
18714
18791
  //#endregion
18715
18792
  //#region ../../node_modules/ip-address/dist/v6/constants.js
18716
- var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
18793
+ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18717
18794
  Object.defineProperty(exports, "__esModule", { value: true });
18718
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;
18719
18796
  exports.BITS = 128;
@@ -18867,7 +18944,7 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18867
18944
  };
18868
18945
  Object.defineProperty(exports, "__esModule", { value: true });
18869
18946
  exports.possibleElisions = exports.simpleRegularExpression = exports.ADDRESS_BOUNDARY = exports.padGroup = exports.groupPossibilities = void 0;
18870
- const v6 = __importStar(require_constants$7());
18947
+ const v6 = __importStar(require_constants$6());
18871
18948
  const sprintf_js_1 = require_sprintf();
18872
18949
  function groupPossibilities(possibilities) {
18873
18950
  return (0, sprintf_js_1.sprintf)("(%s)", possibilities.join("|"));
@@ -18947,8 +19024,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18947
19024
  Object.defineProperty(exports, "__esModule", { value: true });
18948
19025
  exports.Address6 = void 0;
18949
19026
  const common = __importStar(require_common$1());
18950
- const constants4 = __importStar(require_constants$8());
18951
- const constants6 = __importStar(require_constants$7());
19027
+ const constants4 = __importStar(require_constants$7());
19028
+ const constants6 = __importStar(require_constants$6());
18952
19029
  const helpers = __importStar(require_helpers$1());
18953
19030
  const ipv4_1 = require_ipv4();
18954
19031
  const regular_expressions_1 = require_regular_expressions();
@@ -19766,10 +19843,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19766
19843
  Object.defineProperty(exports, "__esModule", { value: true });
19767
19844
  exports.ipToBuffer = exports.int32ToIpv4 = exports.ipv4ToInt32 = exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = void 0;
19768
19845
  const util_1 = require_util$8();
19769
- const constants_1 = require_constants$9();
19846
+ const constants_1 = require_constants$8();
19770
19847
  const stream$1 = require("stream");
19771
19848
  const ip_address_1 = require_ip_address();
19772
- const net$8 = require("net");
19849
+ const net$7 = require("net");
19773
19850
  /**
19774
19851
  * Validates the provided SocksClientOptions
19775
19852
  * @param options { SocksClientOptions }
@@ -19847,10 +19924,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19847
19924
  }
19848
19925
  exports.int32ToIpv4 = int32ToIpv4;
19849
19926
  function ipToBuffer(ip) {
19850
- if (net$8.isIPv4(ip)) {
19927
+ if (net$7.isIPv4(ip)) {
19851
19928
  const address = new ip_address_1.Address4(ip);
19852
19929
  return Buffer.from(address.toArray());
19853
- } else if (net$8.isIPv6(ip)) {
19930
+ } else if (net$7.isIPv6(ip)) {
19854
19931
  const address = new ip_address_1.Address6(ip);
19855
19932
  return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
19856
19933
  } else throw new Error("Invalid IP address format");
@@ -19929,9 +20006,9 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
19929
20006
  Object.defineProperty(exports, "__esModule", { value: true });
19930
20007
  exports.SocksClientError = exports.SocksClient = void 0;
19931
20008
  const events_1$2 = require("events");
19932
- const net$7 = require("net");
20009
+ const net$6 = require("net");
19933
20010
  const smart_buffer_1 = require_smartbuffer();
19934
- const constants_1 = require_constants$9();
20011
+ const constants_1 = require_constants$8();
19935
20012
  const helpers_1 = require_helpers();
19936
20013
  const receivebuffer_1 = require_receivebuffer();
19937
20014
  const util_1 = require_util$8();
@@ -20041,10 +20118,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20041
20118
  const buff = new smart_buffer_1.SmartBuffer();
20042
20119
  buff.writeUInt16BE(0);
20043
20120
  buff.writeUInt8(options.frameNumber || 0);
20044
- if (net$7.isIPv4(options.remoteHost.host)) {
20121
+ if (net$6.isIPv4(options.remoteHost.host)) {
20045
20122
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20046
20123
  buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
20047
- } else if (net$7.isIPv6(options.remoteHost.host)) {
20124
+ } else if (net$6.isIPv6(options.remoteHost.host)) {
20048
20125
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20049
20126
  buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
20050
20127
  } else {
@@ -20097,7 +20174,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20097
20174
  const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
20098
20175
  if (timer.unref && typeof timer.unref === "function") timer.unref();
20099
20176
  if (existingSocket) this.socket = existingSocket;
20100
- else this.socket = new net$7.Socket();
20177
+ else this.socket = new net$6.Socket();
20101
20178
  this.socket.once("close", this.onClose);
20102
20179
  this.socket.once("error", this.onError);
20103
20180
  this.socket.once("connect", this.onConnect);
@@ -20209,7 +20286,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20209
20286
  buff.writeUInt8(4);
20210
20287
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20211
20288
  buff.writeUInt16BE(this.options.destination.port);
20212
- if (net$7.isIPv4(this.options.destination.host)) {
20289
+ if (net$6.isIPv4(this.options.destination.host)) {
20213
20290
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20214
20291
  buff.writeStringNT(userId);
20215
20292
  } else {
@@ -20368,10 +20445,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20368
20445
  buff.writeUInt8(5);
20369
20446
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20370
20447
  buff.writeUInt8(0);
20371
- if (net$7.isIPv4(this.options.destination.host)) {
20448
+ if (net$6.isIPv4(this.options.destination.host)) {
20372
20449
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20373
20450
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20374
- } else if (net$7.isIPv6(this.options.destination.host)) {
20451
+ } else if (net$6.isIPv6(this.options.destination.host)) {
20375
20452
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20376
20453
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20377
20454
  } else {
@@ -20581,12 +20658,12 @@ var require_dist$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
20581
20658
  const agent_base_1 = require_dist$11();
20582
20659
  const debug_1 = __importDefault(require_src$1());
20583
20660
  const dns = __importStar(require("dns"));
20584
- const net$6 = __importStar(require("net"));
20661
+ const net$5 = __importStar(require("net"));
20585
20662
  const tls$1 = __importStar(require("tls"));
20586
20663
  const url_1$5 = require("url");
20587
20664
  const debug = (0, debug_1.default)("socks-proxy-agent");
20588
20665
  const setServernameFromNonIpHost = (options) => {
20589
- 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 {
20590
20667
  ...options,
20591
20668
  servername: options.host
20592
20669
  };
@@ -22846,6 +22923,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22846
22923
  function doNothing() {
22847
22924
  /** Do nothing */
22848
22925
  }
22926
+ const maxControlResponseLength = 2 ** 16;
22849
22927
  /**
22850
22928
  * FTPContext holds the control and data sockets of an FTP connection and provides a
22851
22929
  * simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -22972,6 +23050,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22972
23050
  * Send an FTP command without waiting for or handling the result.
22973
23051
  */
22974
23052
  send(command) {
23053
+ if (/[\r\n\0]/.test(command)) throw new Error(`Invalid command: Contains control characters. (${command})`);
22975
23054
  const message = command.startsWith("PASS") ? "> PASS ###" : `> ${command}`;
22976
23055
  this.log(message);
22977
23056
  this._socket.write(command + "\r\n", this.encoding);
@@ -23050,6 +23129,10 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23050
23129
  */
23051
23130
  _onControlSocketData(chunk) {
23052
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
+ }
23053
23136
  const completeResponse = this._partialResponse + chunk;
23054
23137
  const parsed = (0, parseControlResponse_1.parseControlResponse)(completeResponse);
23055
23138
  this._partialResponse = parsed.rest;
@@ -23133,6 +23216,61 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23133
23216
  exports.FTPContext = FTPContext;
23134
23217
  }));
23135
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
23136
23274
  //#region ../../node_modules/basic-ftp/dist/FileInfo.js
23137
23275
  var require_FileInfo = /* @__PURE__ */ __commonJSMin(((exports) => {
23138
23276
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23668,78 +23806,32 @@ var require_StringWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
23668
23806
  exports.StringWriter = void 0;
23669
23807
  const stream_1$3 = require("stream");
23670
23808
  var StringWriter = class extends stream_1$3.Writable {
23671
- constructor() {
23672
- super(...arguments);
23673
- this.buf = Buffer.alloc(0);
23809
+ constructor(maxByteLength = 1 * 1024 * 1024) {
23810
+ super();
23811
+ this.maxByteLength = maxByteLength;
23812
+ this.byteLength = 0;
23813
+ this.bufs = [];
23674
23814
  }
23675
23815
  _write(chunk, _, callback) {
23676
- if (chunk instanceof Buffer) {
23677
- this.buf = Buffer.concat([this.buf, chunk]);
23678
- callback(null);
23679
- } 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);
23680
23827
  }
23681
23828
  getText(encoding) {
23682
- return this.buf.toString(encoding);
23829
+ return Buffer.concat(this.bufs).toString(encoding);
23683
23830
  }
23684
23831
  };
23685
23832
  exports.StringWriter = StringWriter;
23686
23833
  }));
23687
23834
  //#endregion
23688
- //#region ../../node_modules/basic-ftp/dist/netUtils.js
23689
- var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
23690
- Object.defineProperty(exports, "__esModule", { value: true });
23691
- exports.describeTLS = describeTLS;
23692
- exports.describeAddress = describeAddress;
23693
- exports.upgradeSocket = upgradeSocket;
23694
- exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
23695
- const tls_1$2 = require("tls");
23696
- /**
23697
- * Returns a string describing the encryption on a given socket instance.
23698
- */
23699
- function describeTLS(socket) {
23700
- if (socket instanceof tls_1$2.TLSSocket) {
23701
- const protocol = socket.getProtocol();
23702
- return protocol ? protocol : "Server socket or disconnected client socket";
23703
- }
23704
- return "No encryption";
23705
- }
23706
- /**
23707
- * Returns a string describing the remote address of a socket.
23708
- */
23709
- function describeAddress(socket) {
23710
- if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
23711
- return `${socket.remoteAddress}:${socket.remotePort}`;
23712
- }
23713
- /**
23714
- * Upgrade a socket connection with TLS.
23715
- */
23716
- function upgradeSocket(socket, options) {
23717
- return new Promise((resolve, reject) => {
23718
- const tlsOptions = Object.assign({}, options, { socket });
23719
- const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
23720
- if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
23721
- else {
23722
- tlsSocket.removeAllListeners("error");
23723
- resolve(tlsSocket);
23724
- }
23725
- }).once("error", (error) => {
23726
- reject(error);
23727
- });
23728
- });
23729
- }
23730
- /**
23731
- * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
23732
- * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
23733
- *
23734
- * @param ip The IP as a string, e.g. "192.168.0.1"
23735
- */
23736
- function ipIsPrivateV4Address(ip = "") {
23737
- if (ip.startsWith("::ffff:")) ip = ip.substr(7);
23738
- const octets = ip.split(".").map((o) => parseInt(o, 10));
23739
- return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
23740
- }
23741
- }));
23742
- //#endregion
23743
23835
  //#region ../../node_modules/basic-ftp/dist/transfer.js
23744
23836
  var require_transfer = /* @__PURE__ */ __commonJSMin(((exports) => {
23745
23837
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23985,20 +24077,23 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
23985
24077
  const tls_1 = require("tls");
23986
24078
  const util_1$3 = require("util");
23987
24079
  const FtpContext_1 = require_FtpContext();
24080
+ const netUtils_1 = require_netUtils();
24081
+ const parseControlResponse_1 = require_parseControlResponse();
23988
24082
  const parseList_1 = require_parseList();
24083
+ const parseListMLSD_1 = require_parseListMLSD();
23989
24084
  const ProgressTracker_1 = require_ProgressTracker();
23990
24085
  const StringWriter_1 = require_StringWriter();
23991
- const parseListMLSD_1 = require_parseListMLSD();
23992
- const netUtils_1 = require_netUtils();
23993
24086
  const transfer_1 = require_transfer();
23994
- const parseControlResponse_1 = require_parseControlResponse();
23995
24087
  const fsReadDir = (0, util_1$3.promisify)(fs_1$5.readdir);
23996
24088
  const fsMkDir = (0, util_1$3.promisify)(fs_1$5.mkdir);
23997
24089
  const fsStat = (0, util_1$3.promisify)(fs_1$5.stat);
23998
24090
  const fsOpen = (0, util_1$3.promisify)(fs_1$5.open);
23999
24091
  const fsClose = (0, util_1$3.promisify)(fs_1$5.close);
24000
24092
  const fsUnlink = (0, util_1$3.promisify)(fs_1$5.unlink);
24001
- const defaultClientOptions = { allowSeparateTransferHost: true };
24093
+ const defaultClientOptions = {
24094
+ allowSeparateTransferHost: true,
24095
+ maxListingBytes: 40 * 1024 * 1024
24096
+ };
24002
24097
  const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
24003
24098
  const LIST_COMMANDS_MLSD = () => [
24004
24099
  "MLSD",
@@ -24014,10 +24109,15 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24014
24109
  *
24015
24110
  * @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
24016
24111
  */
24017
- constructor(timeout = 3e4, options = defaultClientOptions) {
24112
+ constructor(timeout = 3e4, userOptions = defaultClientOptions) {
24018
24113
  this.availableListCommands = LIST_COMMANDS_DEFAULT();
24114
+ const options = {
24115
+ ...defaultClientOptions,
24116
+ ...userOptions
24117
+ };
24019
24118
  this.ftp = new FtpContext_1.FTPContext(timeout);
24020
24119
  this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, options.allowSeparateTransferHost ? transfer_1.enterPassiveModeIPv4 : transfer_1.enterPassiveModeIPv4_forceControlHostIP]);
24120
+ this.options = options;
24021
24121
  this.parseList = parseList_1.parseList;
24022
24122
  this._progressTracker = new ProgressTracker_1.ProgressTracker();
24023
24123
  }
@@ -24417,7 +24517,7 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24417
24517
  * @protected
24418
24518
  */
24419
24519
  async _requestListWithCommand(command) {
24420
- const buffer = new StringWriter_1.StringWriter();
24520
+ const buffer = new StringWriter_1.StringWriter(this.options.maxListingBytes);
24421
24521
  await (0, transfer_1.downloadTo)(buffer, {
24422
24522
  ftp: this.ftp,
24423
24523
  tracker: this._progressTracker,
@@ -41720,7 +41820,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41720
41820
  };
41721
41821
  Object.defineProperty(exports, "__esModule", { value: true });
41722
41822
  exports.PacProxyAgent = void 0;
41723
- const net$5 = __importStar(require("net"));
41823
+ const net$4 = __importStar(require("net"));
41724
41824
  const tls = __importStar(require("tls"));
41725
41825
  const crypto$4 = __importStar(require("crypto"));
41726
41826
  const events_1 = require("events");
@@ -41732,7 +41832,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41732
41832
  const quickjs_emscripten_1 = require_dist$3();
41733
41833
  const debug = (0, debug_1.default)("pac-proxy-agent");
41734
41834
  const setServernameFromNonIpHost = (options) => {
41735
- 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 {
41736
41836
  ...options,
41737
41837
  servername: options.host
41738
41838
  };
@@ -41822,7 +41922,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41822
41922
  const isWebSocket = req.getHeader("upgrade") === "websocket";
41823
41923
  const resolver = await this.getResolver();
41824
41924
  const protocol = secureEndpoint ? "https:" : "http:";
41825
- 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;
41826
41926
  const defaultPort = secureEndpoint ? 443 : 80;
41827
41927
  const url = Object.assign(new url_1$3.URL(req.path, `${protocol}//${host}`), defaultPort ? void 0 : { port: opts.port });
41828
41928
  debug("url: %s", url);
@@ -41836,7 +41936,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41836
41936
  const [type, target] = proxy.split(/\s+/);
41837
41937
  debug("Attempting to use proxy: %o", proxy);
41838
41938
  if (type === "DIRECT") if (secureEndpoint) socket = tls.connect(setServernameFromNonIpHost(opts));
41839
- else socket = net$5.connect(opts);
41939
+ else socket = net$4.connect(opts);
41840
41940
  else if (type === "SOCKS" || type === "SOCKS5") {
41841
41941
  const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require_dist$8()));
41842
41942
  agent = new SocksProxyAgent(`socks://${target}`, this.opts);
@@ -41864,7 +41964,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41864
41964
  }
41865
41965
  if (agent) {
41866
41966
  const s = await agent.connect(req, opts);
41867
- 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");
41868
41968
  req.emit("proxy", {
41869
41969
  proxy,
41870
41970
  socket: s
@@ -42792,7 +42892,7 @@ var require_errors$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42792
42892
  }));
42793
42893
  //#endregion
42794
42894
  //#region ../../node_modules/undici/lib/core/constants.js
42795
- var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42895
+ var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42796
42896
  /**
42797
42897
  * @see https://developer.mozilla.org/docs/Web/HTTP/Headers
42798
42898
  */
@@ -42924,7 +43024,7 @@ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42924
43024
  //#endregion
42925
43025
  //#region ../../node_modules/undici/lib/core/tree.js
42926
43026
  var require_tree = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42927
- const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$6();
43027
+ const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$5();
42928
43028
  var TstNode = class TstNode {
42929
43029
  /** @type {any} */
42930
43030
  value = null;
@@ -43046,12 +43146,12 @@ var require_util$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43046
43146
  const { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
43047
43147
  const { IncomingMessage } = require("node:http");
43048
43148
  const stream = require("node:stream");
43049
- const net$4 = require("node:net");
43149
+ const net$3 = require("node:net");
43050
43150
  const { stringify } = require("node:querystring");
43051
43151
  const { EventEmitter: EE$2 } = require("node:events");
43052
43152
  const timers = require_timers();
43053
43153
  const { InvalidArgumentError, ConnectTimeoutError } = require_errors$1();
43054
- const { headerNameLowerCasedRecord } = require_constants$6();
43154
+ const { headerNameLowerCasedRecord } = require_constants$5();
43055
43155
  const { tree } = require_tree();
43056
43156
  const [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
43057
43157
  var BodyAsyncIterable = class {
@@ -43207,7 +43307,7 @@ var require_util$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43207
43307
  if (!host) return null;
43208
43308
  assert$32(typeof host === "string");
43209
43309
  const servername = getHostname(host);
43210
- if (net$4.isIP(servername)) return "";
43310
+ if (net$3.isIP(servername)) return "";
43211
43311
  return servername;
43212
43312
  }
43213
43313
  /**
@@ -44115,8 +44215,16 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44115
44215
  const assert$31 = require("node:assert");
44116
44216
  const { isValidHTTPToken, isValidHeaderValue, isStream, destroy, isBuffer, isFormDataLike, isIterable, hasSafeIterator, isBlobLike, serializePathWithQuery, assertRequestHandler, getServerName, normalizedMethodRecords, getProtocolFromUrlString } = require_util$5();
44117
44217
  const { channels } = require_diagnostics();
44118
- const { headerNameLowerCasedRecord } = require_constants$6();
44218
+ const { headerNameLowerCasedRecord } = require_constants$5();
44119
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
+ }
44120
44228
  const kHandler = Symbol("handler");
44121
44229
  var Request = class {
44122
44230
  constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
@@ -44325,8 +44433,8 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44325
44433
  request.host = val;
44326
44434
  } else if (headerName === "content-length") {
44327
44435
  if (request.contentLength !== null) throw new InvalidArgumentError("duplicate content-length header");
44436
+ if (!isValidContentLengthHeaderValue(val)) throw new InvalidArgumentError("invalid content-length header");
44328
44437
  request.contentLength = parseInt(val, 10);
44329
- if (!Number.isFinite(request.contentLength)) throw new InvalidArgumentError("invalid content-length header");
44330
44438
  } else if (request.contentType === null && headerName === "content-type") {
44331
44439
  request.contentType = val;
44332
44440
  request.headers.push(key, val);
@@ -44451,6 +44559,8 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44451
44559
  #aborted = false;
44452
44560
  #abort;
44453
44561
  [kResume] = null;
44562
+ rawHeaders = null;
44563
+ rawTrailers = null;
44454
44564
  constructor(abort) {
44455
44565
  this.#abort = abort;
44456
44566
  }
@@ -44497,10 +44607,12 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44497
44607
  return this.#handler.onResponseStarted?.();
44498
44608
  }
44499
44609
  onUpgrade(statusCode, rawHeaders, socket) {
44610
+ this.#controller.rawHeaders = rawHeaders;
44500
44611
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
44501
44612
  }
44502
44613
  onHeaders(statusCode, rawHeaders, resume, statusMessage) {
44503
44614
  this.#controller[kResume] = resume;
44615
+ this.#controller.rawHeaders = rawHeaders;
44504
44616
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
44505
44617
  return !this.#controller.paused;
44506
44618
  }
@@ -44509,6 +44621,7 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44509
44621
  return !this.#controller.paused;
44510
44622
  }
44511
44623
  onComplete(rawTrailers) {
44624
+ this.#controller.rawTrailers = rawTrailers;
44512
44625
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
44513
44626
  }
44514
44627
  onError(err) {
@@ -44526,6 +44639,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44526
44639
  const { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
44527
44640
  const kOnDestroyed = Symbol("onDestroyed");
44528
44641
  const kOnClosed = Symbol("onClosed");
44642
+ const kWebSocketOptions = Symbol("webSocketOptions");
44529
44643
  var DispatcherBase = class extends Dispatcher {
44530
44644
  /** @type {boolean} */
44531
44645
  [kDestroyed] = false;
@@ -44535,6 +44649,22 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44535
44649
  [kClosed] = false;
44536
44650
  /** @type {Array<Function>|null} */
44537
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
+ }
44538
44668
  /** @returns {boolean} */
44539
44669
  get destroyed() {
44540
44670
  return this[kDestroyed];
@@ -44617,7 +44747,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44617
44747
  //#endregion
44618
44748
  //#region ../../node_modules/undici/lib/core/connect.js
44619
44749
  var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44620
- const net$3 = require("node:net");
44750
+ const net$2 = require("node:net");
44621
44751
  const assert$30 = require("node:assert");
44622
44752
  const util = require_util$5();
44623
44753
  const { InvalidArgumentError } = require_errors$1();
@@ -44638,6 +44768,15 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44638
44768
  }
44639
44769
  set(sessionKey, session) {
44640
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
+ }
44641
44780
  this._sessionCache.set(sessionKey, new WeakRef(session));
44642
44781
  this._sessionRegistry.register(session, sessionKey);
44643
44782
  }
@@ -44677,7 +44816,7 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44677
44816
  } else {
44678
44817
  assert$30(!httpSocket, "httpSocket can only be sent on TLS update");
44679
44818
  port = port || 80;
44680
- socket = net$3.connect({
44819
+ socket = net$2.connect({
44681
44820
  highWaterMark: 64 * 1024,
44682
44821
  ...options,
44683
44822
  localAddress,
@@ -44730,7 +44869,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
44730
44869
  }));
44731
44870
  //#endregion
44732
44871
  //#region ../../node_modules/undici/lib/llhttp/constants.js
44733
- var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
44872
+ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
44734
44873
  Object.defineProperty(exports, "__esModule", { value: true });
44735
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;
44736
44875
  const utils_1 = require_utils$1();
@@ -45336,7 +45475,7 @@ var require_llhttp_simd_wasm = /* @__PURE__ */ __commonJSMin(((exports, module)
45336
45475
  }));
45337
45476
  //#endregion
45338
45477
  //#region ../../node_modules/undici/lib/web/fetch/constants.js
45339
- var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45478
+ var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45340
45479
  const corsSafeListedMethods = [
45341
45480
  "GET",
45342
45481
  "HEAD",
@@ -46235,7 +46374,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46235
46374
  lowerBound = 0;
46236
46375
  upperBound = Math.pow(2, bitLength) - 1;
46237
46376
  } else {
46238
- lowerBound = Math.pow(-2, bitLength) - 1;
46377
+ lowerBound = -Math.pow(2, bitLength - 1);
46239
46378
  upperBound = Math.pow(2, bitLength - 1) - 1;
46240
46379
  }
46241
46380
  let x = Number(V);
@@ -46261,7 +46400,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46261
46400
  if (Number.isNaN(x) || x === 0 && Object.is(0, x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) return 0;
46262
46401
  x = webidl.util.IntegerPart(x);
46263
46402
  x = x % Math.pow(2, bitLength);
46264
- 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);
46265
46404
  return x;
46266
46405
  };
46267
46406
  webidl.util.IntegerPart = function(n) {
@@ -46596,7 +46735,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46596
46735
  var require_util$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46597
46736
  const { Transform: Transform$2 } = require("node:stream");
46598
46737
  const zlib$2 = require("node:zlib");
46599
- const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$4();
46738
+ const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$3();
46600
46739
  const { getGlobalOrigin } = require_global$1();
46601
46740
  const { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
46602
46741
  const { performance: performance$1 } = require("node:perf_hooks");
@@ -47606,7 +47745,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47606
47745
  * Parses content-disposition attributes (e.g., name="value" or filename*=utf-8''encoded)
47607
47746
  * @param {Buffer} input
47608
47747
  * @param {{ position: number }} position
47609
- * @returns {{ name: string, value: string }}
47748
+ * @returns {{ name: string, value: string, extended: boolean } | null}
47610
47749
  */
47611
47750
  function parseContentDispositionAttribute(input, position) {
47612
47751
  if (input[position.position] === 59) position.position++;
@@ -47636,7 +47775,8 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47636
47775
  }
47637
47776
  return {
47638
47777
  name: attrNameStr,
47639
- value
47778
+ value,
47779
+ extended: isExtended
47640
47780
  };
47641
47781
  }
47642
47782
  /**
@@ -47666,17 +47806,24 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47666
47806
  position.position++;
47667
47807
  collectASequenceOfBytes((char) => char === 32 || char === 9, input, position);
47668
47808
  switch (bufferToLowerCasedHeaderName(headerName)) {
47669
- case "content-disposition":
47809
+ case "content-disposition": {
47670
47810
  name = filename = null;
47811
+ let filenameIsExtended = false;
47671
47812
  if (collectASequenceOfBytes((char) => isToken(char), input, position).toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
47672
- 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)) {
47673
47814
  const attribute = parseContentDispositionAttribute(input, position);
47674
47815
  if (!attribute) break;
47675
47816
  if (attribute.name === "name") name = attribute.value;
47676
- 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
+ }
47677
47823
  }
47678
47824
  if (name === null) throw parsingError("name attribute is required in content-disposition header");
47679
47825
  break;
47826
+ }
47680
47827
  case "content-type": {
47681
47828
  let headerValue = collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47682
47829
  headerValue = removeChars(headerValue, false, true, (char) => char === 9 || char === 32);
@@ -47691,7 +47838,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47691
47838
  }
47692
47839
  default: collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47693
47840
  }
47694
- 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");
47695
47842
  else position.position += 2;
47696
47843
  }
47697
47844
  }
@@ -48059,17 +48206,20 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48059
48206
  const timers = require_timers();
48060
48207
  const { RequestContentLengthMismatchError, ResponseContentLengthMismatchError, RequestAbortedError, HeadersTimeoutError, HeadersOverflowError, SocketError, InformationalError, BodyTimeoutError, HTTPParserError, ResponseExceededMaxSizeError } = require_errors$1();
48061
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();
48062
- const constants = require_constants$5();
48209
+ const constants = require_constants$4();
48063
48210
  const EMPTY_BUF = Buffer.alloc(0);
48064
48211
  const FastBuffer = Buffer[Symbol.species];
48065
48212
  const removeAllListeners = util.removeAllListeners;
48213
+ const kIdleSocketValidation = Symbol("kIdleSocketValidation");
48214
+ const kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
48215
+ const kSocketUsed = Symbol("kSocketUsed");
48066
48216
  let extractBody;
48067
48217
  function lazyllhttp() {
48068
48218
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
48069
48219
  let mod;
48070
48220
  let useWasmSIMD = process.arch !== "ppc64";
48071
- if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
48072
- 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;
48073
48223
  if (useWasmSIMD) try {
48074
48224
  mod = new WebAssembly.Module(require_llhttp_simd_wasm());
48075
48225
  } catch {}
@@ -48143,6 +48293,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48143
48293
  */
48144
48294
  this.socket = socket;
48145
48295
  this.timeout = null;
48296
+ this.timeoutWeakRef = new WeakRef(this);
48146
48297
  this.timeoutValue = null;
48147
48298
  this.timeoutType = null;
48148
48299
  this.statusCode = 0;
@@ -48166,9 +48317,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48166
48317
  timers.clearTimeout(this.timeout);
48167
48318
  this.timeout = null;
48168
48319
  }
48169
- 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);
48170
48321
  else {
48171
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this));
48322
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
48172
48323
  this.timeout?.unref();
48173
48324
  }
48174
48325
  this.timeoutValue = delay;
@@ -48227,20 +48378,42 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48227
48378
  else if (ret === constants.ERROR.PAUSED) {
48228
48379
  this.paused = true;
48229
48380
  socket.unshift(data);
48230
- } else {
48231
- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
48232
- let message = "";
48233
- if (ptr) {
48234
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
48235
- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
48236
- }
48237
- throw new HTTPParserError(message, constants.ERROR[ret], data);
48238
- }
48381
+ } else throw this.createError(ret, data);
48239
48382
  }
48240
48383
  } catch (err) {
48241
48384
  util.destroy(socket, err);
48242
48385
  }
48243
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
+ }
48244
48417
  destroy() {
48245
48418
  assert$23(currentParser === null);
48246
48419
  assert$23(this.ptr != null);
@@ -48266,6 +48439,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48266
48439
  onMessageBegin() {
48267
48440
  const { socket, client } = this;
48268
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
+ }
48269
48446
  const request = client[kQueue][client[kRunningIdx]];
48270
48447
  if (!request) return -1;
48271
48448
  request.onResponseStarted();
@@ -48352,6 +48529,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48352
48529
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
48353
48530
  const { client, socket, headers, statusText } = this;
48354
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
+ }
48355
48536
  const request = client[kQueue][client[kRunningIdx]];
48356
48537
  if (!request) return -1;
48357
48538
  assert$23(!this.upgrade);
@@ -48452,6 +48633,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48452
48633
  }
48453
48634
  request.onComplete(headers);
48454
48635
  client[kQueue][client[kRunningIdx]++] = null;
48636
+ socket[kSocketUsed] = client[kPending] === 0;
48455
48637
  if (socket[kWriting]) {
48456
48638
  assert$23(client[kRunning] === 0);
48457
48639
  util.destroy(socket, new InformationalError("reset"));
@@ -48497,6 +48679,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48497
48679
  socket[kWriting] = false;
48498
48680
  socket[kReset] = false;
48499
48681
  socket[kBlocking] = false;
48682
+ socket[kIdleSocketValidation] = 0;
48683
+ socket[kIdleSocketValidationTimeout] = null;
48684
+ socket[kSocketUsed] = false;
48500
48685
  socket[kParser] = new Parser(client, socket, llhttpInstance);
48501
48686
  util.addListener(socket, "error", onHttpSocketError);
48502
48687
  util.addListener(socket, "readable", onHttpSocketReadable);
@@ -48524,7 +48709,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48524
48709
  return socket.destroyed;
48525
48710
  },
48526
48711
  busy(request) {
48527
- if (socket[kWriting] || socket[kReset] || socket[kBlocking]) return true;
48712
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) return true;
48528
48713
  if (request) {
48529
48714
  if (client[kRunning] > 0 && !request.idempotent) return true;
48530
48715
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) return true;
@@ -48538,7 +48723,11 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48538
48723
  assert$23(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
48539
48724
  const parser = this[kParser];
48540
48725
  if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
48541
- parser.onMessageComplete();
48726
+ const parserErr = parser.finish();
48727
+ if (parserErr) {
48728
+ this[kError] = parserErr;
48729
+ this[kClient][kOnError](parserErr);
48730
+ }
48542
48731
  return;
48543
48732
  }
48544
48733
  this[kError] = err;
@@ -48550,15 +48739,17 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48550
48739
  function onHttpSocketEnd() {
48551
48740
  const parser = this[kParser];
48552
48741
  if (parser.statusCode && !parser.shouldKeepAlive) {
48553
- parser.onMessageComplete();
48742
+ const parserErr = parser.finish();
48743
+ if (parserErr) util.destroy(this, parserErr);
48554
48744
  return;
48555
48745
  }
48556
48746
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
48557
48747
  }
48558
48748
  function onHttpSocketClose() {
48559
48749
  const parser = this[kParser];
48750
+ clearIdleSocketValidation(this);
48560
48751
  if (parser) {
48561
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) parser.onMessageComplete();
48752
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) this[kError] = parser.finish() || this[kError];
48562
48753
  this[kParser].destroy();
48563
48754
  this[kParser] = null;
48564
48755
  }
@@ -48586,6 +48777,22 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48586
48777
  function onSocketClose() {
48587
48778
  this[kClosed] = true;
48588
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
+ }
48589
48796
  /**
48590
48797
  * @param {import('./client.js')} client
48591
48798
  */
@@ -48601,6 +48808,23 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48601
48808
  socket.ref();
48602
48809
  socket[kNoRef] = false;
48603
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
+ }
48604
48828
  if (client[kSize] === 0) {
48605
48829
  if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
48606
48830
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
@@ -48644,6 +48868,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48644
48868
  process.emitWarning(new RequestContentLengthMismatchError());
48645
48869
  }
48646
48870
  const socket = client[kSocket];
48871
+ clearIdleSocketValidation(socket);
48647
48872
  /**
48648
48873
  * @param {Error} [err]
48649
48874
  * @returns {void}
@@ -49508,7 +49733,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49508
49733
  //#region ../../node_modules/undici/lib/dispatcher/client.js
49509
49734
  var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49510
49735
  const assert$21 = require("node:assert");
49511
- const net$2 = require("node:net");
49736
+ const net$1 = require("node:net");
49512
49737
  const http$1 = require("node:http");
49513
49738
  const util = require_util$5();
49514
49739
  const { ClientStats } = require_stats();
@@ -49537,7 +49762,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49537
49762
  * @param {string|URL} url
49538
49763
  * @param {import('../../types/client.js').Client.Options} options
49539
49764
  */
49540
- 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 } = {}) {
49541
49766
  if (keepAlive !== void 0) throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
49542
49767
  if (socketTimeout !== void 0) throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
49543
49768
  if (requestTimeout !== void 0) throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
@@ -49555,7 +49780,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49555
49780
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
49556
49781
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
49557
49782
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
49558
- 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");
49559
49784
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) throw new InvalidArgumentError("maxResponseSize must be a positive number");
49560
49785
  if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
49561
49786
  if (allowH2 != null && typeof allowH2 !== "boolean") throw new InvalidArgumentError("allowH2 must be a valid boolean value");
@@ -49564,7 +49789,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49564
49789
  if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
49565
49790
  if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
49566
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");
49567
- super();
49792
+ super({ webSocket });
49568
49793
  if (typeof connect !== "function") connect = buildConnector({
49569
49794
  ...tls,
49570
49795
  maxCachedSessions,
@@ -49578,11 +49803,12 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49578
49803
  } : void 0,
49579
49804
  ...connect
49580
49805
  });
49581
- else if (socketPath != null) {
49806
+ else {
49582
49807
  const customConnect = connect;
49583
49808
  connect = (opts, callback) => customConnect({
49584
49809
  ...opts,
49585
- socketPath
49810
+ ...socketPath != null ? { socketPath } : null,
49811
+ ...allowH2 != null ? { allowH2 } : null
49586
49812
  }, callback);
49587
49813
  }
49588
49814
  this[kUrl] = util.parseOrigin(url);
@@ -49705,7 +49931,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49705
49931
  const idx = hostname.indexOf("]");
49706
49932
  assert$21(idx !== -1);
49707
49933
  const ip = hostname.substring(1, idx);
49708
- assert$21(net$2.isIPv6(ip));
49934
+ assert$21(net$1.isIPv6(ip));
49709
49935
  hostname = ip;
49710
49936
  }
49711
49937
  client[kConnecting] = true;
@@ -50127,7 +50353,7 @@ var require_pool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50127
50353
  } : void 0,
50128
50354
  ...connect
50129
50355
  });
50130
- super();
50356
+ super(options);
50131
50357
  this[kConnections] = connections || null;
50132
50358
  this[kUrl] = util.parseOrigin(origin);
50133
50359
  this[kOptions] = {
@@ -50201,7 +50427,7 @@ var require_balanced_pool = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50201
50427
  var BalancedPool = class extends PoolBase {
50202
50428
  constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
50203
50429
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50204
- super();
50430
+ super(opts);
50205
50431
  this[kOptions] = { ...util.deepClone(opts) };
50206
50432
  this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
50207
50433
  this[kIndex] = -1;
@@ -50386,7 +50612,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50386
50612
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50387
50613
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
50388
50614
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
50389
- super();
50615
+ super(options);
50390
50616
  if (connect && typeof connect !== "function") connect = { ...connect };
50391
50617
  this[kOptions] = {
50392
50618
  ...util.deepClone(options),
@@ -50476,7 +50702,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50476
50702
  //#region ../../node_modules/undici/lib/core/socks5-utils.js
50477
50703
  var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50478
50704
  const { Buffer: Buffer$2 } = require("node:buffer");
50479
- const net$1 = require("node:net");
50705
+ const net = require("node:net");
50480
50706
  const { InvalidArgumentError } = require_errors$1();
50481
50707
  /**
50482
50708
  * Parse an address and determine its type
@@ -50484,14 +50710,14 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50484
50710
  * @returns {{type: number, buffer: Buffer}} Address type and buffer
50485
50711
  */
50486
50712
  function parseAddress(address) {
50487
- if (net$1.isIPv4(address)) {
50713
+ if (net.isIPv4(address)) {
50488
50714
  const parts = address.split(".").map(Number);
50489
50715
  return {
50490
50716
  type: 1,
50491
50717
  buffer: Buffer$2.from(parts)
50492
50718
  };
50493
50719
  }
50494
- if (net$1.isIPv6(address)) return {
50720
+ if (net.isIPv6(address)) return {
50495
50721
  type: 4,
50496
50722
  buffer: parseIPv6(address)
50497
50723
  };
@@ -50509,23 +50735,36 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50509
50735
  */
50510
50736
  function parseIPv6(address) {
50511
50737
  const buffer = Buffer$2.alloc(16);
50512
- const parts = address.split(":");
50513
- let partIndex = 0;
50514
- let bufferIndex = 0;
50515
- 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("::");
50516
50750
  if (doubleColonIndex !== -1) {
50517
- const skipParts = 8 - parts.filter((p) => p.length > 0).length;
50518
- for (let i = 0; i < parts.length; i++) if (parts[i] === "" && i === doubleColonIndex / 3) bufferIndex += skipParts * 2;
50519
- else if (parts[i] !== "") {
50520
- const value = parseInt(parts[i], 16);
50521
- 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);
50522
50758
  bufferIndex += 2;
50523
50759
  }
50524
- } else for (const part of parts) {
50525
- if (part === "") continue;
50526
- const value = parseInt(part, 16);
50527
- buffer.writeUInt16BE(value, partIndex * 2);
50528
- 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);
50529
50768
  }
50530
50769
  return buffer;
50531
50770
  }
@@ -50630,6 +50869,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50630
50869
  const { debuglog: debuglog$1 } = require("node:util");
50631
50870
  const { parseAddress } = require_socks5_utils();
50632
50871
  const debug = debuglog$1("undici:socks5");
50872
+ const EMPTY_BUFFER = Buffer$1.alloc(0);
50633
50873
  const SOCKS_VERSION = 5;
50634
50874
  const AUTH_METHODS = {
50635
50875
  NO_AUTH: 0,
@@ -50662,6 +50902,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50662
50902
  INITIAL: "initial",
50663
50903
  HANDSHAKING: "handshaking",
50664
50904
  AUTHENTICATING: "authenticating",
50905
+ AUTHENTICATED: "authenticated",
50665
50906
  CONNECTING: "connecting",
50666
50907
  CONNECTED: "connected",
50667
50908
  ERROR: "error",
@@ -50678,13 +50919,16 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50678
50919
  this.socket = socket;
50679
50920
  this.options = options;
50680
50921
  this.state = STATES.INITIAL;
50681
- 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);
50682
50926
  this.authMethods = [];
50683
50927
  if (options.username && options.password) this.authMethods.push(AUTH_METHODS.USERNAME_PASSWORD);
50684
50928
  this.authMethods.push(AUTH_METHODS.NO_AUTH);
50685
- this.socket.on("data", this.onData.bind(this));
50686
- this.socket.on("error", this.onError.bind(this));
50687
- 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);
50688
50932
  }
50689
50933
  /**
50690
50934
  * Handle incoming data from the socket
@@ -50731,6 +50975,10 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50731
50975
  destroy() {
50732
50976
  if (this.socket && !this.socket.destroyed) this.socket.destroy();
50733
50977
  }
50978
+ markAuthenticated() {
50979
+ this.state = STATES.AUTHENTICATED;
50980
+ this.emit("authenticated");
50981
+ }
50734
50982
  /**
50735
50983
  * Start the SOCKS5 handshake
50736
50984
  */
@@ -50757,7 +51005,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50757
51005
  if (method === AUTH_METHODS.NO_ACCEPTABLE) throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
50758
51006
  this.buffer = this.buffer.subarray(2);
50759
51007
  debug("server selected auth method", method);
50760
- if (method === AUTH_METHODS.NO_AUTH) this.emit("authenticated");
51008
+ if (method === AUTH_METHODS.NO_AUTH) this.markAuthenticated();
50761
51009
  else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
50762
51010
  this.state = STATES.AUTHENTICATING;
50763
51011
  this.sendAuthRequest();
@@ -50792,7 +51040,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50792
51040
  if (status !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
50793
51041
  this.buffer = this.buffer.subarray(2);
50794
51042
  debug("authentication successful");
50795
- this.emit("authenticated");
51043
+ this.markAuthenticated();
50796
51044
  }
50797
51045
  /**
50798
51046
  * Send CONNECT command
@@ -50800,7 +51048,8 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50800
51048
  * @param {number} port - Target port
50801
51049
  */
50802
51050
  connect(address, port) {
50803
- 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");
50804
51053
  debug("connecting to", address, port);
50805
51054
  this.state = STATES.CONNECTING;
50806
51055
  const request = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
@@ -50858,8 +51107,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50858
51107
  offset += 16;
50859
51108
  }
50860
51109
  const boundPort = this.buffer.readUInt16BE(offset);
50861
- this.buffer = this.buffer.subarray(responseLength);
51110
+ this.buffer = EMPTY_BUFFER;
50862
51111
  this.state = STATES.CONNECTED;
51112
+ this.socket.removeListener("data", this.onSocketData);
50863
51113
  debug("connected, bound address:", boundAddress, "port:", boundPort);
50864
51114
  this.emit("connected", {
50865
51115
  address: boundAddress,
@@ -50895,12 +51145,11 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50895
51145
  //#endregion
50896
51146
  //#region ../../node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
50897
51147
  var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50898
- const net = require("node:net");
50899
51148
  const { URL: URL$1 } = require("node:url");
50900
51149
  let tls;
50901
51150
  const DispatcherBase = require_dispatcher_base();
50902
51151
  const { InvalidArgumentError } = require_errors$1();
50903
- const { Socks5Client } = require_socks5_client();
51152
+ const { Socks5Client, STATES } = require_socks5_client();
50904
51153
  const { kDispatch, kClose, kDestroy } = require_symbols();
50905
51154
  const Pool = require_pool();
50906
51155
  const buildConnector = require_connect();
@@ -50909,8 +51158,10 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50909
51158
  const kProxyUrl = Symbol("proxy url");
50910
51159
  const kProxyHeaders = Symbol("proxy headers");
50911
51160
  const kProxyAuth = Symbol("proxy auth");
50912
- const kPool = Symbol("pool");
51161
+ const kProxyProtocol = Symbol("proxy protocol");
51162
+ const kPools = Symbol("pools");
50913
51163
  const kConnector = Symbol("connector");
51164
+ const kRequestTls = Symbol("request tls settings");
50914
51165
  let experimentalWarningEmitted = false;
50915
51166
  /**
50916
51167
  * SOCKS5 proxy agent for dispatching requests through a SOCKS5 proxy
@@ -50927,6 +51178,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50927
51178
  if (url.protocol !== "socks5:" && url.protocol !== "socks:") throw new InvalidArgumentError("Proxy URL must use socks5:// or socks:// protocol");
50928
51179
  this[kProxyUrl] = url;
50929
51180
  this[kProxyHeaders] = options.headers || {};
51181
+ this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
51182
+ this[kRequestTls] = options.requestTls;
50930
51183
  this[kProxyAuth] = {
50931
51184
  username: options.username || (url.username ? decodeURIComponent(url.username) : null),
50932
51185
  password: options.password || (url.password ? decodeURIComponent(url.password) : null)
@@ -50935,7 +51188,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50935
51188
  ...options.proxyTls,
50936
51189
  servername: options.proxyTls?.servername || url.hostname
50937
51190
  });
50938
- this[kPool] = null;
51191
+ this[kPools] = /* @__PURE__ */ new Map();
50939
51192
  }
50940
51193
  /**
50941
51194
  * Create a SOCKS5 connection to the proxy
@@ -50945,20 +51198,15 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50945
51198
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
50946
51199
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
50947
51200
  const socket = await new Promise((resolve, reject) => {
50948
- const onConnect = () => {
50949
- socket.removeListener("error", onError);
50950
- resolve(socket);
50951
- };
50952
- const onError = (err) => {
50953
- socket.removeListener("connect", onConnect);
50954
- reject(err);
50955
- };
50956
- const socket = net.connect({
51201
+ this[kConnector]({
51202
+ hostname: proxyHost,
50957
51203
  host: proxyHost,
50958
- port: proxyPort
51204
+ port: proxyPort,
51205
+ protocol: this[kProxyProtocol]
51206
+ }, (err, socket) => {
51207
+ if (err) reject(err);
51208
+ else resolve(socket);
50959
51209
  });
50960
- socket.once("connect", onConnect);
50961
- socket.once("error", onError);
50962
51210
  });
50963
51211
  const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
50964
51212
  socks5Client.on("error", (err) => {
@@ -50980,7 +51228,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50980
51228
  socks5Client.removeListener("authenticated", onAuthenticated);
50981
51229
  reject(err);
50982
51230
  };
50983
- if (socks5Client.state === "authenticated") {
51231
+ if (socks5Client.state === STATES.AUTHENTICATED) {
50984
51232
  clearTimeout(timeout);
50985
51233
  resolve();
50986
51234
  } else {
@@ -51012,53 +51260,69 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
51012
51260
  /**
51013
51261
  * Dispatch a request through the SOCKS5 proxy
51014
51262
  */
51015
- async [kDispatch](opts, handler) {
51263
+ [kDispatch](opts, handler) {
51016
51264
  const { origin } = opts;
51017
51265
  debug("dispatching request to", origin, "via SOCKS5");
51018
51266
  try {
51019
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) this[kPool] = new Pool(origin, {
51020
- pipelining: opts.pipelining,
51021
- connections: opts.connections,
51022
- connect: async (connectOpts, callback) => {
51023
- try {
51024
- const url = new URL$1(origin);
51025
- const targetHost = url.hostname;
51026
- const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
51027
- debug("establishing SOCKS5 connection to", targetHost, targetPort);
51028
- const socket = await this.createSocks5Connection(targetHost, targetPort);
51029
- let finalSocket = socket;
51030
- if (url.protocol === "https:") {
51031
- if (!tls) tls = require("node:tls");
51032
- debug("upgrading to TLS");
51033
- finalSocket = tls.connect({
51034
- socket,
51035
- servername: targetHost,
51036
- ...connectOpts.tls || {}
51037
- });
51038
- await new Promise((resolve, reject) => {
51039
- finalSocket.once("secureConnect", resolve);
51040
- finalSocket.once("error", reject);
51041
- });
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);
51042
51298
  }
51043
- callback(null, finalSocket);
51044
- } catch (err) {
51045
- debug("SOCKS5 connection error:", err);
51046
- callback(err);
51047
51299
  }
51048
- }
51049
- });
51050
- return this[kPool][kDispatch](opts, handler);
51300
+ });
51301
+ this[kPools].set(originKey, pool);
51302
+ }
51303
+ return pool[kDispatch](opts, handler);
51051
51304
  } catch (err) {
51052
51305
  debug("dispatch error:", err);
51053
- if (typeof handler.onError === "function") handler.onError(err);
51054
- 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;
51055
51313
  }
51056
51314
  }
51057
51315
  async [kClose]() {
51058
- 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);
51059
51320
  }
51060
51321
  async [kDestroy](err) {
51061
- 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);
51062
51326
  }
51063
51327
  };
51064
51328
  module.exports = Socks5ProxyAgent;
@@ -51162,7 +51426,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51162
51426
  factory: agentFactory,
51163
51427
  username: opts.username || username,
51164
51428
  password: opts.password || password,
51165
- proxyTls: opts.proxyTls
51429
+ proxyTls: opts.proxyTls,
51430
+ requestTls: opts.requestTls
51166
51431
  });
51167
51432
  if (!this[kTunnelProxy] && protocol === "http:" && this[kProxy].protocol === "http:") return new Http1ProxyWrapper(this[kProxy].uri, {
51168
51433
  headers: this[kProxyHeaders],
@@ -51670,7 +51935,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51670
51935
  constructor(origin, clientOpts) {
51671
51936
  if (typeof origin === "string") origin = new URL(origin);
51672
51937
  if (origin.protocol !== "http:") throw new InvalidArgumentError("h2c-client: Only h2c protocol is supported");
51673
- const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51938
+ const { maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51674
51939
  let defaultMaxConcurrentStreams = 100;
51675
51940
  let defaultPipelining = 100;
51676
51941
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) defaultMaxConcurrentStreams = maxConcurrentStreams;
@@ -52115,7 +52380,7 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
52115
52380
  const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
52116
52381
  try {
52117
52382
  if (typeof callback !== "function") throw new InvalidArgumentError("invalid callback");
52118
- 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");
52119
52384
  if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
52120
52385
  if (method === "CONNECT") throw new InvalidArgumentError("invalid method");
52121
52386
  if (onInfo && typeof onInfo !== "function") throw new InvalidArgumentError("invalid onInfo callback");
@@ -53301,12 +53566,12 @@ var require_mock_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53301
53566
  var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53302
53567
  const { kMockCallHistoryAddLog } = require_mock_symbols();
53303
53568
  const { InvalidArgumentError } = require_errors$1();
53304
- function handleFilterCallsWithOptions(criteria, options, handler, store) {
53569
+ function handleFilterCallsWithOptions(criteria, options, handler, store, allLogs) {
53305
53570
  switch (options.operator) {
53306
53571
  case "OR":
53307
- store.push(...handler(criteria));
53572
+ store.push(...handler(criteria, allLogs));
53308
53573
  return store;
53309
- case "AND": return handler.call({ logs: store }, criteria);
53574
+ case "AND": return handler(criteria, store);
53310
53575
  default: throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
53311
53576
  }
53312
53577
  }
@@ -53322,11 +53587,11 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53322
53587
  return finalOptions;
53323
53588
  }
53324
53589
  function makeFilterCalls(parameterName) {
53325
- return (parameterValue) => {
53326
- 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) => {
53327
53592
  return log[parameterName] === parameterValue;
53328
53593
  });
53329
- if (parameterValue instanceof RegExp) return this.logs.filter((log) => {
53594
+ if (parameterValue instanceof RegExp) return logs.filter((log) => {
53330
53595
  return parameterValue.test(log[parameterName]);
53331
53596
  });
53332
53597
  throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
@@ -53414,15 +53679,15 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53414
53679
  operator: "OR",
53415
53680
  ...buildAndValidateFilterCallsOptions(options)
53416
53681
  };
53417
- let maybeDuplicatedLogsFiltered = [];
53418
- if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
53419
- if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
53420
- if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
53421
- if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
53422
- if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
53423
- if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
53424
- if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
53425
- 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);
53426
53691
  return [...new Set(maybeDuplicatedLogsFiltered)];
53427
53692
  }
53428
53693
  throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
@@ -54471,7 +54736,8 @@ var require_snapshot_agent = /* @__PURE__ */ __commonJSMin(((exports, module) =>
54471
54736
  //#endregion
54472
54737
  //#region ../../node_modules/undici/lib/global.js
54473
54738
  var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54474
- const globalDispatcher = Symbol.for("undici.globalDispatcher.1");
54739
+ const globalDispatcher = Symbol.for("undici.globalDispatcher.2");
54740
+ const legacyGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");
54475
54741
  const { InvalidArgumentError } = require_errors$1();
54476
54742
  const Agent = require_agent();
54477
54743
  if (getGlobalDispatcher() === void 0) setGlobalDispatcher(new Agent());
@@ -54483,9 +54749,15 @@ var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54483
54749
  enumerable: false,
54484
54750
  configurable: false
54485
54751
  });
54752
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
54753
+ value: agent,
54754
+ writable: true,
54755
+ enumerable: false,
54756
+ configurable: false
54757
+ });
54486
54758
  }
54487
54759
  function getGlobalDispatcher() {
54488
- return globalThis[globalDispatcher];
54760
+ return globalThis[legacyGlobalDispatcher];
54489
54761
  }
54490
54762
  module.exports = {
54491
54763
  setGlobalDispatcher,
@@ -55184,7 +55456,7 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55184
55456
  function makeCacheKey(opts) {
55185
55457
  if (!opts.origin) throw new Error("opts.origin is undefined");
55186
55458
  let fullPath = opts.path || "/";
55187
- if (opts.query && !pathHasQueryOrFragment(opts.path)) fullPath = serializePathWithQuery(fullPath, opts.query);
55459
+ if (opts.query && !pathHasQueryOrFragment(fullPath)) fullPath = serializePathWithQuery(fullPath, opts.query);
55188
55460
  return {
55189
55461
  origin: opts.origin.toString(),
55190
55462
  method: opts.method,
@@ -55300,11 +55572,15 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55300
55572
  lastHeader = lastHeader.substring(0, lastHeader.length - 1);
55301
55573
  headers[headers.length - 1] = lastHeader;
55302
55574
  }
55575
+ for (let j = 0; j < headers.length; j++) headers[j] = headers[j].trim();
55303
55576
  if (key in output) output[key] = output[key].concat(headers);
55304
55577
  else output[key] = headers;
55305
55578
  }
55306
- } else if (key in output) output[key] = output[key].concat(value);
55307
- 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
+ }
55308
55584
  break;
55309
55585
  }
55310
55586
  case "public":
@@ -55382,16 +55658,20 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55382
55658
  * @returns {string}
55383
55659
  */
55384
55660
  function makeDeduplicationKey(cacheKey, excludeHeaders) {
55385
- let key = `${cacheKey.origin}:${cacheKey.method}:${cacheKey.path}`;
55661
+ const headers = {};
55386
55662
  if (cacheKey.headers) {
55387
55663
  const sortedHeaders = Object.keys(cacheKey.headers).sort();
55388
55664
  for (const header of sortedHeaders) {
55389
55665
  if (excludeHeaders?.has(header.toLowerCase())) continue;
55390
- const value = cacheKey.headers[header];
55391
- key += `:${header}=${Array.isArray(value) ? value.join(",") : value}`;
55666
+ headers[header] = cacheKey.headers[header];
55392
55667
  }
55393
55668
  }
55394
- return key;
55669
+ return JSON.stringify([
55670
+ cacheKey.origin,
55671
+ cacheKey.method,
55672
+ cacheKey.path,
55673
+ headers
55674
+ ]);
55395
55675
  }
55396
55676
  module.exports = {
55397
55677
  makeCacheKey,
@@ -57330,7 +57610,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57330
57610
  SELECT
57331
57611
  id
57332
57612
  FROM cacheInterceptorV${VERSION}
57333
- ORDER BY cachedAt DESC
57613
+ ORDER BY cachedAt ASC
57334
57614
  LIMIT ?
57335
57615
  )
57336
57616
  `);
@@ -57371,8 +57651,8 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57371
57651
  const existingValue = this.#findValue(key, true);
57372
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);
57373
57653
  else {
57374
- this.#prune();
57375
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();
57376
57656
  }
57377
57657
  }
57378
57658
  /**
@@ -57455,7 +57735,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57455
57735
  if (values.length === 0) return;
57456
57736
  const now = Date.now();
57457
57737
  for (const value of values) {
57458
- if (now >= value.deleteAt && !canBeExpired) return;
57738
+ if (now >= value.deleteAt && !canBeExpired) continue;
57459
57739
  let matches = true;
57460
57740
  if (value.vary) {
57461
57741
  const vary = JSON.parse(value.vary);
@@ -57885,7 +58165,7 @@ var require_response = /* @__PURE__ */ __commonJSMin(((exports, module) => {
57885
58165
  const nodeUtil$1 = require("node:util");
57886
58166
  const { kEnumerableProperty } = util;
57887
58167
  const { isValidReasonPhrase, isCancelled, isAborted, isErrorLike, environmentSettingsObject: relevantRealm } = require_util$4();
57888
- const { redirectStatusSet, nullBodyStatus } = require_constants$4();
58168
+ const { redirectStatusSet, nullBodyStatus } = require_constants$3();
57889
58169
  const { webidl } = require_webidl();
57890
58170
  const { URLSerializer } = require_data_url();
57891
58171
  const { kConstruct } = require_symbols();
@@ -58229,7 +58509,7 @@ var require_request$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58229
58509
  const util = require_util$5();
58230
58510
  const nodeUtil = require("node:util");
58231
58511
  const { isValidHTTPToken, sameOrigin, environmentSettingsObject } = require_util$4();
58232
- 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();
58233
58513
  const { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util;
58234
58514
  const { webidl } = require_webidl();
58235
58515
  const { URLSerializer } = require_data_url();
@@ -58986,7 +59266,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58986
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();
58987
59267
  const assert$5 = require("node:assert");
58988
59268
  const { safelyExtractBody, extractBody } = require_body();
58989
- const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$4();
59269
+ const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$3();
58990
59270
  const EE = require("node:events");
58991
59271
  const { Readable, pipeline: pipeline$1, finished, isErrored, isReadable } = require("node:stream");
58992
59272
  const { addAbortListener, bufferToLowerCasedHeaderName } = require_util$5();
@@ -59285,7 +59565,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59285
59565
  cacheState = "";
59286
59566
  }
59287
59567
  let responseStatus = 0;
59288
- if (fetchParams.request.mode !== "navigator" || !response.hasCrossOriginRedirects) {
59568
+ if (fetchParams.request.mode !== "navigate" || !response.hasCrossOriginRedirects) {
59289
59569
  responseStatus = response.status;
59290
59570
  const mimeType = extractMimeType(response.headersList);
59291
59571
  if (mimeType !== "failure") bodyInfo.contentType = minimizeSupportedMimeType(mimeType);
@@ -59389,7 +59669,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59389
59669
  let contentLengthHeaderValue = null;
59390
59670
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) contentLengthHeaderValue = "0";
59391
59671
  if (contentLength != null) contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
59392
- 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);
59393
59673
  if (contentLength != null && httpRequest.keepalive) {}
59394
59674
  if (webidl.is.URL(httpRequest.referrer)) httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
59395
59675
  appendRequestOriginHeader(httpRequest);
@@ -60302,7 +60582,7 @@ var require_cachestorage = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60302
60582
  }));
60303
60583
  //#endregion
60304
60584
  //#region ../../node_modules/undici/lib/web/cookies/constants.js
60305
- var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60585
+ var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60306
60586
  module.exports = {
60307
60587
  maxAttributeValueSize: 1024,
60308
60588
  maxNameValuePairSize: 4096
@@ -60506,10 +60786,9 @@ var require_util$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60506
60786
  //#region ../../node_modules/undici/lib/web/cookies/parse.js
60507
60787
  var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60508
60788
  const { collectASequenceOfCodePointsFast } = require_infra();
60509
- const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$3();
60789
+ const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$2();
60510
60790
  const { isCTLExcludingHtab } = require_util$2();
60511
60791
  const assert$2 = require("node:assert");
60512
- const { unescape: qsUnescape } = require("node:querystring");
60513
60792
  /**
60514
60793
  * @description Parses the field-value attributes of a set-cookie header string.
60515
60794
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4
@@ -60538,7 +60817,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60538
60817
  if (name.length + value.length > maxNameValuePairSize) return null;
60539
60818
  return {
60540
60819
  name,
60541
- value: qsUnescape(value),
60820
+ value,
60542
60821
  ...parseUnparsedAttributes(unparsedAttributes)
60543
60822
  };
60544
60823
  }
@@ -60590,12 +60869,10 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60590
60869
  } else if (attributeNameLowercase === "secure") cookieAttributeList.secure = true;
60591
60870
  else if (attributeNameLowercase === "httponly") cookieAttributeList.httpOnly = true;
60592
60871
  else if (attributeNameLowercase === "samesite") {
60593
- let enforcement = "Default";
60594
60872
  const attributeValueLowercase = attributeValue.toLowerCase();
60595
- if (attributeValueLowercase.includes("none")) enforcement = "None";
60596
- if (attributeValueLowercase.includes("strict")) enforcement = "Strict";
60597
- if (attributeValueLowercase.includes("lax")) enforcement = "Lax";
60598
- 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";
60599
60876
  } else {
60600
60877
  cookieAttributeList.unparsed ??= [];
60601
60878
  cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
@@ -61033,7 +61310,7 @@ var require_events = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61033
61310
  }));
61034
61311
  //#endregion
61035
61312
  //#region ../../node_modules/undici/lib/web/websocket/constants.js
61036
- var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61313
+ var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61037
61314
  module.exports = {
61038
61315
  uid: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
61039
61316
  sentCloseFrameState: {
@@ -61078,7 +61355,7 @@ var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61078
61355
  //#endregion
61079
61356
  //#region ../../node_modules/undici/lib/web/websocket/util.js
61080
61357
  var require_util$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61081
- const { states, opcodes } = require_constants$2();
61358
+ const { states, opcodes } = require_constants$1();
61082
61359
  const { isUtf8 } = require("node:buffer");
61083
61360
  const { removeHTTPWhitespace } = require_data_url();
61084
61361
  const { collectASequenceOfCodePointsFast } = require_infra();
@@ -61285,7 +61562,7 @@ var require_util$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61285
61562
  //#region ../../node_modules/undici/lib/web/websocket/frame.js
61286
61563
  var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61287
61564
  const { runtimeFeatures } = require_runtime_features();
61288
- const { maxUnsigned16Bit, opcodes } = require_constants$2();
61565
+ const { maxUnsigned16Bit, opcodes } = require_constants$1();
61289
61566
  const BUFFER_SIZE = 8 * 1024;
61290
61567
  let buffer = null;
61291
61568
  let bufIdx = BUFFER_SIZE;
@@ -61383,7 +61660,7 @@ var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61383
61660
  //#endregion
61384
61661
  //#region ../../node_modules/undici/lib/web/websocket/connection.js
61385
61662
  var require_connection = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61386
- const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$2();
61663
+ const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$1();
61387
61664
  const { parseExtensions, isClosed, isClosing, isEstablished, isConnecting, validateCloseCodeAndReason } = require_util$1();
61388
61665
  const { makeRequest } = require_request$1();
61389
61666
  const { fetching } = require_fetch();
@@ -61544,27 +61821,26 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61544
61821
  ]);
61545
61822
  const kBuffer = Symbol("kBuffer");
61546
61823
  const kLength = Symbol("kLength");
61547
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024;
61548
61824
  var PerMessageDeflate = class {
61549
61825
  /** @type {import('node:zlib').InflateRaw} */
61550
61826
  #inflate;
61551
61827
  #options = {};
61552
- /** @type {boolean} */
61553
- #aborted = false;
61554
- /** @type {Function|null} */
61555
- #currentCallback = null;
61828
+ #maxPayloadSize = 0;
61556
61829
  /**
61557
61830
  * @param {Map<string, string>} extensions
61558
61831
  */
61559
- constructor(extensions) {
61832
+ constructor(extensions, options) {
61560
61833
  this.#options.serverNoContextTakeover = extensions.has("server_no_context_takeover");
61561
61834
  this.#options.serverMaxWindowBits = extensions.get("server_max_window_bits");
61835
+ this.#maxPayloadSize = options.maxPayloadSize;
61562
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
+ */
61563
61843
  decompress(chunk, fin, callback) {
61564
- if (this.#aborted) {
61565
- callback(new MessageSizeExceededError());
61566
- return;
61567
- }
61568
61844
  if (!this.#inflate) {
61569
61845
  let windowBits = Z_DEFAULT_WINDOWBITS;
61570
61846
  if (this.#options.serverMaxWindowBits) {
@@ -61583,18 +61859,11 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61583
61859
  this.#inflate[kBuffer] = [];
61584
61860
  this.#inflate[kLength] = 0;
61585
61861
  this.#inflate.on("data", (data) => {
61586
- if (this.#aborted) return;
61587
61862
  this.#inflate[kLength] += data.length;
61588
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
61589
- this.#aborted = true;
61863
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
61864
+ callback(new MessageSizeExceededError());
61590
61865
  this.#inflate.removeAllListeners();
61591
- this.#inflate.destroy();
61592
61866
  this.#inflate = null;
61593
- if (this.#currentCallback) {
61594
- const cb = this.#currentCallback;
61595
- this.#currentCallback = null;
61596
- cb(new MessageSizeExceededError());
61597
- }
61598
61867
  return;
61599
61868
  }
61600
61869
  this.#inflate[kBuffer].push(data);
@@ -61604,15 +61873,13 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61604
61873
  callback(err);
61605
61874
  });
61606
61875
  }
61607
- this.#currentCallback = callback;
61608
61876
  this.#inflate.write(chunk);
61609
61877
  if (fin) this.#inflate.write(tail);
61610
61878
  this.#inflate.flush(() => {
61611
- if (this.#aborted || !this.#inflate) return;
61879
+ if (!this.#inflate) return;
61612
61880
  const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength]);
61613
61881
  this.#inflate[kBuffer].length = 0;
61614
61882
  this.#inflate[kLength] = 0;
61615
- this.#currentCallback = null;
61616
61883
  callback(null, full);
61617
61884
  });
61618
61885
  }
@@ -61624,7 +61891,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
61624
61891
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61625
61892
  const { Writable } = require("node:stream");
61626
61893
  const assert = require("node:assert");
61627
- const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$2();
61894
+ const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$1();
61628
61895
  const { isValidStatusCode, isValidOpcode, websocketMessageReceived, utf8Decode, isControlFrame, isTextBinaryFrame, isContinuationFrame } = require_util$1();
61629
61896
  const { failWebsocketConnection } = require_connection();
61630
61897
  const { WebsocketFrameSend } = require_frame();
@@ -61642,15 +61909,22 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61642
61909
  #extensions;
61643
61910
  /** @type {import('./websocket').Handler} */
61644
61911
  #handler;
61912
+ /** @type {number} */
61913
+ #maxFragments;
61914
+ /** @type {number} */
61915
+ #maxPayloadSize;
61645
61916
  /**
61646
61917
  * @param {import('./websocket').Handler} handler
61647
61918
  * @param {Map<string, string>|null} extensions
61919
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
61648
61920
  */
61649
- constructor(handler, extensions) {
61921
+ constructor(handler, extensions, options = {}) {
61650
61922
  super();
61651
61923
  this.#handler = handler;
61652
61924
  this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
61653
- 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));
61654
61928
  }
61655
61929
  /**
61656
61930
  * @param {Buffer} chunk
@@ -61662,6 +61936,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61662
61936
  this.#loop = true;
61663
61937
  this.run(callback);
61664
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
+ }
61665
61946
  /**
61666
61947
  * Runs whenever a new chunk is received.
61667
61948
  * Callback is called whenever there are no more chunks buffering,
@@ -61718,6 +61999,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61718
61999
  if (payloadLength <= 125) {
61719
62000
  this.#info.payloadLength = payloadLength;
61720
62001
  this.#state = parserStates.READ_DATA;
62002
+ if (!this.#validatePayloadLength()) return;
61721
62003
  } else if (payloadLength === 126) this.#state = parserStates.PAYLOADLENGTH_16;
61722
62004
  else if (payloadLength === 127) this.#state = parserStates.PAYLOADLENGTH_64;
61723
62005
  if (isTextBinaryFrame(opcode)) {
@@ -61733,6 +62015,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61733
62015
  const buffer = this.consume(2);
61734
62016
  this.#info.payloadLength = buffer.readUInt16BE(0);
61735
62017
  this.#state = parserStates.READ_DATA;
62018
+ if (!this.#validatePayloadLength()) return;
61736
62019
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
61737
62020
  if (this.#byteOffset < 8) return callback();
61738
62021
  const buffer = this.consume(8);
@@ -61744,6 +62027,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61744
62027
  }
61745
62028
  this.#info.payloadLength = lower;
61746
62029
  this.#state = parserStates.READ_DATA;
62030
+ if (!this.#validatePayloadLength()) return;
61747
62031
  } else if (this.#state === parserStates.READ_DATA) {
61748
62032
  if (this.#byteOffset < this.#info.payloadLength) return callback();
61749
62033
  const body = this.consume(this.#info.payloadLength);
@@ -61751,7 +62035,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61751
62035
  this.#loop = this.parseControlFrame(body);
61752
62036
  this.#state = parserStates.INFO;
61753
62037
  } else if (!this.#info.compressed) {
61754
- this.writeFragments(body);
62038
+ if (!this.writeFragments(body)) return;
61755
62039
  if (!this.#info.fragmented && this.#info.fin) websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments());
61756
62040
  this.#state = parserStates.INFO;
61757
62041
  } else {
@@ -61761,7 +62045,11 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61761
62045
  failWebsocketConnection(this.#handler, code, error.message);
61762
62046
  return;
61763
62047
  }
61764
- 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
+ }
61765
62053
  if (!this.#info.fin) {
61766
62054
  this.#state = parserStates.INFO;
61767
62055
  this.#loop = true;
@@ -61772,7 +62060,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61772
62060
  this.#loop = true;
61773
62061
  this.#state = parserStates.INFO;
61774
62062
  this.run(callback);
61775
- });
62063
+ }, this.#fragmentsBytes);
61776
62064
  this.#loop = false;
61777
62065
  break;
61778
62066
  }
@@ -61814,8 +62102,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61814
62102
  }
61815
62103
  }
61816
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
+ }
61817
62109
  this.#fragmentsBytes += fragment.length;
61818
62110
  this.#fragments.push(fragment);
62111
+ return true;
61819
62112
  }
61820
62113
  consumeFragments() {
61821
62114
  const fragments = this.#fragments;
@@ -61911,7 +62204,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61911
62204
  //#region ../../node_modules/undici/lib/web/websocket/sender.js
61912
62205
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61913
62206
  const { WebsocketFrameSend } = require_frame();
61914
- const { opcodes, sendHints } = require_constants$2();
62207
+ const { opcodes, sendHints } = require_constants$1();
61915
62208
  const FixedQueue = require_fixed_queue();
61916
62209
  /**
61917
62210
  * @typedef {object} SendQueueNode
@@ -61997,7 +62290,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61997
62290
  const { webidl } = require_webidl();
61998
62291
  const { URLSerializer } = require_data_url();
61999
62292
  const { environmentSettingsObject } = require_util$4();
62000
- const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$2();
62293
+ const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$1();
62001
62294
  const { isConnecting, isEstablished, isClosing, isClosed, isValidSubprotocol, fireEvent, utf8Decode, toArrayBuffer, getURLRecord } = require_util$1();
62002
62295
  const { establishWebSocketConnection, closeWebSocketConnection, failWebsocketConnection } = require_connection();
62003
62296
  const { ByteParser } = require_receiver();
@@ -62236,7 +62529,13 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62236
62529
  */
62237
62530
  #onConnectionEstablished(response, parsedExtensions) {
62238
62531
  this.#handler.socket = response.socket;
62239
- 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
+ });
62240
62539
  parser.on("drain", () => this.#handler.onParserDrain());
62241
62540
  parser.on("error", (err) => this.#handler.onParserError(err));
62242
62541
  this.#parser = parser;
@@ -62474,7 +62773,7 @@ var require_websocketerror = /* @__PURE__ */ __commonJSMin(((exports, module) =>
62474
62773
  var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62475
62774
  const { createDeferredPromise } = require_promise();
62476
62775
  const { environmentSettingsObject } = require_util$4();
62477
- const { states, opcodes, sentCloseFrameState } = require_constants$2();
62776
+ const { states, opcodes, sentCloseFrameState } = require_constants$1();
62478
62777
  const { webidl } = require_webidl();
62479
62778
  const { getURLRecord, isValidSubprotocol, isEstablished, utf8Decode } = require_util$1();
62480
62779
  const { establishWebSocketConnection, failWebsocketConnection, closeWebSocketConnection } = require_connection();
@@ -62605,7 +62904,12 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62605
62904
  /** @type {import('../websocket').Handler['onConnectionEstablished']} */
62606
62905
  #onConnectionEstablished(response, parsedExtensions) {
62607
62906
  this.#handler.socket = response.socket;
62608
- 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
+ });
62609
62913
  parser.on("drain", () => this.#handler.onParserDrain());
62610
62914
  parser.on("error", (err) => this.#handler.onParserError(err));
62611
62915
  this.#parser = parser;
@@ -62616,10 +62920,6 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62616
62920
  start: (controller) => {
62617
62921
  this.#readableStreamController = controller;
62618
62922
  },
62619
- pull(controller) {
62620
- let chunk;
62621
- while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) controller.enqueue(chunk);
62622
- },
62623
62923
  cancel: (reason) => this.#cancel(reason)
62624
62924
  });
62625
62925
  const writable = new WritableStream({
@@ -62643,7 +62943,7 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62643
62943
  if (type === opcodes.TEXT) try {
62644
62944
  chunk = utf8Decode(data);
62645
62945
  } catch {
62646
- failWebsocketConnection(this.#handler, "Received invalid UTF-8 in text frame.");
62946
+ failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame.");
62647
62947
  return;
62648
62948
  }
62649
62949
  else if (type === opcodes.BINARY) chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
@@ -73975,6 +74275,17 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
73975
74275
  var hasOwn = require_hasown();
73976
74276
  var populate = require_populate();
73977
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
+ /**
73978
74289
  * Create readable "multipart/form-data" streams.
73979
74290
  * Can be used to submit forms
73980
74291
  * and file uploads to other web applications.
@@ -74044,7 +74355,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74044
74355
  var contentType = this._getContentType(value, options);
74045
74356
  var contents = "";
74046
74357
  var headers = {
74047
- "Content-Disposition": ["form-data", "name=\"" + field + "\""].concat(contentDisposition || []),
74358
+ "Content-Disposition": ["form-data", "name=\"" + escapeHeaderParam(field) + "\""].concat(contentDisposition || []),
74048
74359
  "Content-Type": [].concat(contentType || [])
74049
74360
  };
74050
74361
  if (typeof options.header === "object") populate(headers, options.header);
@@ -74062,7 +74373,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74062
74373
  if (typeof options.filepath === "string") filename = path$1.normalize(options.filepath).replace(/\\/g, "/");
74063
74374
  else if (options.filename || value && (value.name || value.path)) filename = path$1.basename(options.filename || value && (value.name || value.path));
74064
74375
  else if (value && value.readable && hasOwn(value, "httpVersion")) filename = path$1.basename(value.client._httpMessage.path || "");
74065
- if (filename) return "filename=\"" + filename + "\"";
74376
+ if (filename) return "filename=\"" + escapeHeaderParam(filename) + "\"";
74066
74377
  };
74067
74378
  FormData.prototype._getContentType = function(value, options) {
74068
74379
  var contentType = options.contentType;
@@ -74189,12 +74500,12 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74189
74500
  FormData.prototype.toString = function() {
74190
74501
  return "[object FormData]";
74191
74502
  };
74192
- setToStringTag(FormData, "FormData");
74503
+ setToStringTag(FormData.prototype, "FormData");
74193
74504
  module.exports = FormData;
74194
74505
  }));
74195
74506
  //#endregion
74196
74507
  //#region ../../node_modules/semver/internal/constants.js
74197
- var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74508
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74198
74509
  const SEMVER_SPEC_VERSION = "2.0.0";
74199
74510
  const MAX_LENGTH = 256;
74200
74511
  const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
@@ -74225,7 +74536,7 @@ var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74225
74536
  //#endregion
74226
74537
  //#region ../../node_modules/semver/internal/re.js
74227
74538
  var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74228
- 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();
74229
74540
  const debug = require_debug();
74230
74541
  exports = module.exports = {};
74231
74542
  const re = exports.re = [];
@@ -74337,7 +74648,7 @@ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74337
74648
  //#region ../../node_modules/semver/classes/semver.js
74338
74649
  var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74339
74650
  const debug = require_debug();
74340
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants$1();
74651
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
74341
74652
  const { safeRe: re, t } = require_re();
74342
74653
  const parseOptions = require_parse_options();
74343
74654
  const { compareIdentifiers } = require_identifiers();
@@ -74918,7 +75229,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74918
75229
  const debug = require_debug();
74919
75230
  const SemVer = require_semver$1();
74920
75231
  const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
74921
- const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants$1();
75232
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
74922
75233
  const isNullSet = (c) => c.value === "<0.0.0-0";
74923
75234
  const isAny = (c) => c.value === "";
74924
75235
  const isSatisfiable = (comparators, options) => {
@@ -75478,7 +75789,7 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
75478
75789
  //#region ../../node_modules/semver/index.js
75479
75790
  var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
75480
75791
  const internalRe = require_re();
75481
- const constants = require_constants$1();
75792
+ const constants = require_constants();
75482
75793
  const SemVer = require_semver$1();
75483
75794
  const identifiers = require_identifiers();
75484
75795
  module.exports = {
@@ -76271,12 +76582,19 @@ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
76271
76582
  LogLevel[LogLevel["WARN"] = 3] = "WARN";
76272
76583
  LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
76273
76584
  })(LogLevel || (exports.LogLevel = LogLevel = {}));
76585
+ const LEVEL_NAMES = {
76586
+ [LogLevel.DEBUG]: "debug",
76587
+ [LogLevel.INFO]: "info",
76588
+ [LogLevel.WARN]: "warn",
76589
+ [LogLevel.ERROR]: "error"
76590
+ };
76274
76591
  var Logger = class {
76275
- constructor(writeMessage, loglevel, shouldIncludeTimestamp) {
76276
- this.shouldIncludeTimestamp = shouldIncludeTimestamp !== null && shouldIncludeTimestamp !== void 0 ? shouldIncludeTimestamp : false;
76277
- this.writeMessage = (s) => {
76278
- return writeMessage(this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ${s}` : s);
76279
- };
76592
+ constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
76593
+ var _a, _b;
76594
+ const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
76595
+ this.rawWriteMessage = writeMessage;
76596
+ this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
76597
+ this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
76280
76598
  this.loglevel = loglevel;
76281
76599
  }
76282
76600
  setLogLevel(newLogLevel) {
@@ -76285,17 +76603,37 @@ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
76285
76603
  setShouldIncludeTime(newShouldIncludeTimestamp) {
76286
76604
  this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
76287
76605
  }
76606
+ setJsonOutput(newJsonOutput) {
76607
+ this.jsonOutput = newJsonOutput;
76608
+ }
76609
+ isJsonOutput() {
76610
+ return this.jsonOutput;
76611
+ }
76288
76612
  error(s) {
76289
- if (this.loglevel <= LogLevel.ERROR) this.writeMessage(chalk_1.default.red(s) + "\n");
76613
+ if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
76290
76614
  }
76291
76615
  warn(s) {
76292
- if (this.loglevel <= LogLevel.WARN) this.writeMessage(chalk_1.default.yellow(s) + "\n");
76616
+ if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
76293
76617
  }
76294
76618
  info(s) {
76295
- if (this.loglevel <= LogLevel.INFO) this.writeMessage(s + "\n");
76619
+ if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
76296
76620
  }
76297
76621
  debug(s) {
76298
- if (this.loglevel <= LogLevel.DEBUG) this.writeMessage(s + "\n");
76622
+ if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
76623
+ }
76624
+ emit(level, message, colorize) {
76625
+ if (this.jsonOutput) {
76626
+ const payload = {
76627
+ level: LEVEL_NAMES[level],
76628
+ message
76629
+ };
76630
+ if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
76631
+ this.rawWriteMessage(JSON.stringify(payload) + "\n");
76632
+ return;
76633
+ }
76634
+ const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
76635
+ const body = colorize ? colorize(message) : message;
76636
+ this.rawWriteMessage(prefix + body + "\n");
76299
76637
  }
76300
76638
  };
76301
76639
  exports.Logger = Logger;
@@ -77775,13 +78113,61 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
77775
78113
  //#endregion
77776
78114
  //#region ../base/dist/index.js
77777
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
+ };
77778
78147
  Object.defineProperty(exports, "__esModule", { value: true });
77779
78148
  exports.BaseCommand = void 0;
77780
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();
77781
78153
  /**
77782
78154
  * This command should be extended by **every** command in the monorepo.
77783
78155
  */
77784
- 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
+ };
77785
78171
  exports.BaseCommand = BaseCommand;
77786
78172
  }));
77787
78173
  //#endregion
@@ -77892,69 +78278,6 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
77892
78278
  });
77893
78279
  }));
77894
78280
  //#endregion
77895
- //#region ../base/dist/constants.js
77896
- var require_constants = /* @__PURE__ */ __commonJSMin(((exports) => {
77897
- Object.defineProperty(exports, "__esModule", { value: true });
77898
- 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;
77899
- exports.DATADOG_SITE_US1 = "datadoghq.com";
77900
- exports.DATADOG_SITE_EU1 = "datadoghq.eu";
77901
- exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
77902
- exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
77903
- exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
77904
- exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
77905
- exports.DATADOG_SITE_GOV = "ddog-gov.com";
77906
- exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
77907
- exports.DATADOG_SITES = [
77908
- exports.DATADOG_SITE_US1,
77909
- exports.DATADOG_SITE_EU1,
77910
- exports.DATADOG_SITE_US3,
77911
- exports.DATADOG_SITE_US5,
77912
- exports.DATADOG_SITE_AP1,
77913
- exports.DATADOG_SITE_AP2,
77914
- exports.DATADOG_SITE_GOV,
77915
- exports.DATADOG_SITE_US2_GOV
77916
- ];
77917
- exports.FIPS_ENV_VAR = "DATADOG_FIPS";
77918
- exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
77919
- exports.CONTENT_TYPE_HEADER = "Content-Type";
77920
- exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
77921
- exports.CONTENT_TYPE_VALUE_JSON = "application/json";
77922
- exports.METHOD_POST = "post";
77923
- }));
77924
- //#endregion
77925
- //#region ../base/dist/helpers/env.js
77926
- var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
77927
- Object.defineProperty(exports, "__esModule", { value: true });
77928
- exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
77929
- const toBoolean = (env) => {
77930
- if (env === void 0) return;
77931
- if (env.toLowerCase() === "true" || env === "1") return true;
77932
- if (env.toLowerCase() === "false" || env === "0") return false;
77933
- };
77934
- exports.toBoolean = toBoolean;
77935
- const toNumber = (env) => {
77936
- if (env === void 0 || env.trim() === "") return;
77937
- const number = Number(env);
77938
- if (isNaN(number)) return;
77939
- return number;
77940
- };
77941
- exports.toNumber = toNumber;
77942
- const toStringMap = (env) => {
77943
- if (env === void 0) return;
77944
- const cleanedEnv = env.replace(/'/g, "\"");
77945
- try {
77946
- const parsed = JSON.parse(cleanedEnv);
77947
- if (typeof parsed === "object" && parsed !== null) {
77948
- for (const key in parsed) if (typeof parsed[key] !== "string") return;
77949
- return parsed;
77950
- }
77951
- } catch (error) {
77952
- return;
77953
- }
77954
- };
77955
- exports.toStringMap = toStringMap;
77956
- }));
77957
- //#endregion
77958
78281
  //#region ../base/dist/helpers/fips.js
77959
78282
  var require_fips = /* @__PURE__ */ __commonJSMin(((exports) => {
77960
78283
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -78019,7 +78342,7 @@ var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
78019
78342
  var require_api = /* @__PURE__ */ __commonJSMin(((exports) => {
78020
78343
  Object.defineProperty(exports, "__esModule", { value: true });
78021
78344
  exports.getBaseIntakeUrl = exports.getApiUrl = exports.getIntakeUrl = exports.getDatadogSite = exports.getDatadogSiteFromEnv = void 0;
78022
- const constants_1 = require_constants();
78345
+ const constants_1 = require_constants$10();
78023
78346
  /**
78024
78347
  * Read the Datadog site from `DATADOG_SITE` / `DD_SITE` env vars.
78025
78348
  * Returns `undefined` when neither is set.
@@ -78060,6 +78383,8 @@ var require_api = /* @__PURE__ */ __commonJSMin(((exports) => {
78060
78383
  //#endregion
78061
78384
  //#region src/api.ts
78062
78385
  var import_source = /* @__PURE__ */ __toESM(require_source());
78386
+ var import_constants = require_constants$10();
78387
+ var import_env = require_env();
78063
78388
  var import_format_git_span_data = require_format_git_span_data();
78064
78389
  var import_user_provided_git = require_user_provided_git();
78065
78390
  var import_ci = require_ci();
@@ -78069,8 +78394,6 @@ var import_gitdb = require_gitdb();
78069
78394
  var import_logger = require_logger();
78070
78395
  var import_library = require_library();
78071
78396
  var import_upload = require_upload();
78072
- var import_constants = require_constants();
78073
- var import_env = require_env();
78074
78397
  var import_fips = require_fips();
78075
78398
  var import_id = /* @__PURE__ */ __toESM(require_id());
78076
78399
  var import_api = require_api();
@@ -78285,7 +78608,6 @@ var PluginCommand = class extends import_upload.TerraformUploadCommand {
78285
78608
  fips: (0, import_env.toBoolean)(process.env[import_constants.FIPS_ENV_VAR]) ?? false,
78286
78609
  fipsIgnoreError: (0, import_env.toBoolean)(process.env[import_constants.FIPS_IGNORE_ERROR_ENV_VAR]) ?? false
78287
78610
  };
78288
- this.logger = new import_logger.Logger((s) => this.context.stdout.write(s), import_logger.LogLevel.INFO);
78289
78611
  this.git = void 0;
78290
78612
  }
78291
78613
  async execute() {