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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -5761,7 +5761,7 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
5761
5761
  var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5762
5762
  module.exports = {
5763
5763
  "name": "@datadog/datadog-ci-base",
5764
- "version": "5.19.0",
5764
+ "version": "5.20.1",
5765
5765
  "description": "Base package for Datadog CI",
5766
5766
  "license": "Apache-2.0",
5767
5767
  "keywords": ["datadog", "datadog-ci"],
@@ -5858,12 +5858,12 @@ var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5858
5858
  "debug": "^4.4.1",
5859
5859
  "deep-extend": "^0.6.0",
5860
5860
  "fast-xml-parser": "^5.7.2",
5861
- "form-data": "^4.0.4",
5861
+ "form-data": "^4.0.6",
5862
5862
  "glob": "^13.0.6",
5863
5863
  "inquirer": "^8.2.7",
5864
5864
  "is-docker": "^4.0.0",
5865
5865
  "jest-diff": "^30.2.0",
5866
- "js-yaml": "^4.1.1",
5866
+ "js-yaml": "^4.2.0",
5867
5867
  "jszip": "^3.10.1",
5868
5868
  "proxy-agent": "^6.4.0",
5869
5869
  "semver": "^7.6.3",
@@ -5871,7 +5871,7 @@ var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5871
5871
  "terminal-link": "^2.1.1",
5872
5872
  "tiny-async-pool": "^2.1.0",
5873
5873
  "typanion": "^3.14.0",
5874
- "undici": "^7.24.6",
5874
+ "undici": "^7.28.0",
5875
5875
  "upath": "^2.0.1"
5876
5876
  },
5877
5877
  "devDependencies": {
@@ -5886,6 +5886,71 @@ var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5886
5886
  };
5887
5887
  }));
5888
5888
  //#endregion
5889
+ //#region ../base/dist/constants.js
5890
+ var require_constants$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
5891
+ Object.defineProperty(exports, "__esModule", { value: true });
5892
+ 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;
5893
+ exports.DATADOG_SITE_US1 = "datadoghq.com";
5894
+ exports.DATADOG_SITE_EU1 = "datadoghq.eu";
5895
+ exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
5896
+ exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
5897
+ exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
5898
+ exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
5899
+ exports.DATADOG_SITE_GOV = "ddog-gov.com";
5900
+ exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
5901
+ exports.DATADOG_SITES = [
5902
+ exports.DATADOG_SITE_US1,
5903
+ exports.DATADOG_SITE_EU1,
5904
+ exports.DATADOG_SITE_US3,
5905
+ exports.DATADOG_SITE_US5,
5906
+ exports.DATADOG_SITE_AP1,
5907
+ exports.DATADOG_SITE_AP2,
5908
+ exports.DATADOG_SITE_GOV,
5909
+ exports.DATADOG_SITE_US2_GOV
5910
+ ];
5911
+ exports.FIPS_ENV_VAR = "DATADOG_FIPS";
5912
+ exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
5913
+ exports.LOG_FORMAT_ENV_VAR = "DD_LOG_FORMAT";
5914
+ exports.SKIP_VERSION_BANNER_ENV_VAR = "DD_CI_SKIP_VERSION_BANNER";
5915
+ exports.CONTENT_TYPE_HEADER = "Content-Type";
5916
+ exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
5917
+ exports.CONTENT_TYPE_VALUE_JSON = "application/json";
5918
+ exports.METHOD_POST = "post";
5919
+ }));
5920
+ //#endregion
5921
+ //#region ../base/dist/helpers/env.js
5922
+ var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
5923
+ Object.defineProperty(exports, "__esModule", { value: true });
5924
+ exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
5925
+ const toBoolean = (env) => {
5926
+ if (env === void 0) return;
5927
+ if (env.toLowerCase() === "true" || env === "1") return true;
5928
+ if (env.toLowerCase() === "false" || env === "0") return false;
5929
+ };
5930
+ exports.toBoolean = toBoolean;
5931
+ const toNumber = (env) => {
5932
+ if (env === void 0 || env.trim() === "") return;
5933
+ const number = Number(env);
5934
+ if (isNaN(number)) return;
5935
+ return number;
5936
+ };
5937
+ exports.toNumber = toNumber;
5938
+ const toStringMap = (env) => {
5939
+ if (env === void 0) return;
5940
+ const cleanedEnv = env.replace(/'/g, "\"");
5941
+ try {
5942
+ const parsed = JSON.parse(cleanedEnv);
5943
+ if (typeof parsed === "object" && parsed !== null) {
5944
+ for (const key in parsed) if (typeof parsed[key] !== "string") return;
5945
+ return parsed;
5946
+ }
5947
+ } catch (error) {
5948
+ return;
5949
+ }
5950
+ };
5951
+ exports.toStringMap = toStringMap;
5952
+ }));
5953
+ //#endregion
5889
5954
  //#region ../base/dist/version.js
5890
5955
  var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
5891
5956
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -5894,12 +5959,23 @@ var require_version$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
5894
5959
  Object.defineProperty(exports, "__esModule", { value: true });
5895
5960
  exports.printVersion = exports.cliVersion = void 0;
5896
5961
  const chalk_1 = __importDefault(require_source$3());
5897
- exports.cliVersion = require_package$2().version;
5962
+ const package_json_1 = require_package$2();
5963
+ const constants_1 = require_constants$12();
5964
+ const env_1 = require_env();
5965
+ exports.cliVersion = package_json_1.version;
5898
5966
  /**
5899
- * Prints version in all commands, except version commands.
5967
+ * Logs the version in all commands, except version commands. Routed through the
5968
+ * logger so it respects `--log-format` (a JSON line in JSON mode, dim text otherwise).
5969
+ *
5970
+ * Suppressed entirely when `DD_CI_SKIP_VERSION_BANNER` is `1`/`true`, for callers
5971
+ * that find the per-invocation banner too noisy.
5900
5972
  */
5901
- const printVersion = () => {
5902
- if (!(process.argv.at(-1) === "--version" || process.argv.at(-1) === "version")) process.stdout.write(chalk_1.default.dim(`datadog-ci v${exports.cliVersion}\n`));
5973
+ const printVersion = (logger) => {
5974
+ if ((0, env_1.toBoolean)(process.env[constants_1.SKIP_VERSION_BANNER_ENV_VAR])) return;
5975
+ const lastArg = process.argv.at(-1);
5976
+ if (lastArg === "--version" || lastArg === "version" || lastArg === "--help") return;
5977
+ const banner = `datadog-ci v${exports.cliVersion}`;
5978
+ logger.info(logger.isJsonOutput() ? banner : chalk_1.default.dim(banner));
5903
5979
  };
5904
5980
  exports.printVersion = printVersion;
5905
5981
  }));
@@ -11068,7 +11144,7 @@ var require_cjs$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11068
11144
  }));
11069
11145
  //#endregion
11070
11146
  //#region ../../node_modules/clipanion/lib/constants.js
11071
- var require_constants$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
11147
+ var require_constants$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
11072
11148
  Object.defineProperty(exports, "__esModule", { value: true });
11073
11149
  const NODE_INITIAL = 0;
11074
11150
  const NODE_SUCCESS = 1;
@@ -11097,7 +11173,7 @@ var require_constants$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
11097
11173
  //#region ../../node_modules/clipanion/lib/errors.js
11098
11174
  var require_errors$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
11099
11175
  Object.defineProperty(exports, "__esModule", { value: true });
11100
- var constants = require_constants$12();
11176
+ var constants = require_constants$11();
11101
11177
  /**
11102
11178
  * A generic usage error with the name `UsageError`.
11103
11179
  *
@@ -12385,7 +12461,7 @@ var require_Command = /* @__PURE__ */ __commonJSMin(((exports) => {
12385
12461
  //#region ../../node_modules/clipanion/lib/core.js
12386
12462
  var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
12387
12463
  Object.defineProperty(exports, "__esModule", { value: true });
12388
- var constants = require_constants$12();
12464
+ var constants = require_constants$11();
12389
12465
  var errors = require_errors$5();
12390
12466
  function debug(str) {
12391
12467
  if (constants.DEBUG) console.log(str);
@@ -13282,7 +13358,7 @@ var require_HelpCommand = /* @__PURE__ */ __commonJSMin(((exports) => {
13282
13358
  //#region ../../node_modules/clipanion/lib/advanced/Cli.js
13283
13359
  var require_Cli = /* @__PURE__ */ __commonJSMin(((exports) => {
13284
13360
  Object.defineProperty(exports, "__esModule", { value: true });
13285
- var constants = require_constants$12();
13361
+ var constants = require_constants$11();
13286
13362
  var core = require_core$1();
13287
13363
  var format = require_format();
13288
13364
  var platform = require_node$4();
@@ -14969,7 +15045,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14969
15045
  };
14970
15046
  Object.defineProperty(exports, "__esModule", { value: true });
14971
15047
  exports.Agent = void 0;
14972
- const net$13 = __importStar(require("net"));
15048
+ const net$12 = __importStar(require("net"));
14973
15049
  const http$6 = __importStar(require("http"));
14974
15050
  const https_1$2 = require("https");
14975
15051
  __exportStar(require_helpers$2(), exports);
@@ -14994,7 +15070,7 @@ var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
14994
15070
  incrementSockets(name) {
14995
15071
  if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
14996
15072
  if (!this.sockets[name]) this.sockets[name] = [];
14997
- const fakeSocket = new net$13.Socket({ writable: false });
15073
+ const fakeSocket = new net$12.Socket({ writable: false });
14998
15074
  this.sockets[name].push(fakeSocket);
14999
15075
  this.totalSocketCount++;
15000
15076
  return fakeSocket;
@@ -15163,7 +15239,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15163
15239
  };
15164
15240
  Object.defineProperty(exports, "__esModule", { value: true });
15165
15241
  exports.HttpProxyAgent = void 0;
15166
- const net$12 = __importStar(require("net"));
15242
+ const net$11 = __importStar(require("net"));
15167
15243
  const tls$4 = __importStar(require("tls"));
15168
15244
  const debug_1 = __importDefault(require_src$2());
15169
15245
  const events_1$3 = require("events");
@@ -15230,7 +15306,7 @@ var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
15230
15306
  socket = tls$4.connect(this.connectOpts);
15231
15307
  } else {
15232
15308
  debug("Creating `net.Socket`: %o", this.connectOpts);
15233
- socket = net$12.connect(this.connectOpts);
15309
+ socket = net$11.connect(this.connectOpts);
15234
15310
  }
15235
15311
  await (0, events_1$3.once)(socket, "connect");
15236
15312
  return socket;
@@ -15369,7 +15445,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15369
15445
  };
15370
15446
  Object.defineProperty(exports, "__esModule", { value: true });
15371
15447
  exports.HttpsProxyAgent = void 0;
15372
- const net$11 = __importStar(require("net"));
15448
+ const net$10 = __importStar(require("net"));
15373
15449
  const tls$3 = __importStar(require("tls"));
15374
15450
  const assert_1 = __importDefault(require("assert"));
15375
15451
  const debug_1 = __importDefault(require_src$2());
@@ -15378,7 +15454,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15378
15454
  const parse_proxy_response_1 = require_parse_proxy_response();
15379
15455
  const debug = (0, debug_1.default)("https-proxy-agent");
15380
15456
  const setServernameFromNonIpHost = (options) => {
15381
- if (options.servername === void 0 && options.host && !net$11.isIP(options.host)) return {
15457
+ if (options.servername === void 0 && options.host && !net$10.isIP(options.host)) return {
15382
15458
  ...options,
15383
15459
  servername: options.host
15384
15460
  };
@@ -15425,10 +15501,10 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15425
15501
  socket = tls$3.connect(setServernameFromNonIpHost(this.connectOpts));
15426
15502
  } else {
15427
15503
  debug("Creating `net.Socket`: %o", this.connectOpts);
15428
- socket = net$11.connect(this.connectOpts);
15504
+ socket = net$10.connect(this.connectOpts);
15429
15505
  }
15430
15506
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
15431
- const host = net$11.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15507
+ const host = net$10.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
15432
15508
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
15433
15509
  if (proxy.username || proxy.password) {
15434
15510
  const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
@@ -15454,7 +15530,7 @@ var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
15454
15530
  return socket;
15455
15531
  }
15456
15532
  socket.destroy();
15457
- const fakeSocket = new net$11.Socket({ writable: false });
15533
+ const fakeSocket = new net$10.Socket({ writable: false });
15458
15534
  fakeSocket.readable = true;
15459
15535
  req.once("socket", (s) => {
15460
15536
  debug("Replaying proxy buffer for failed request");
@@ -16663,7 +16739,7 @@ var require_smartbuffer = /* @__PURE__ */ __commonJSMin(((exports) => {
16663
16739
  }));
16664
16740
  //#endregion
16665
16741
  //#region ../../node_modules/socks/build/common/constants.js
16666
- var require_constants$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
16742
+ var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
16667
16743
  Object.defineProperty(exports, "__esModule", { value: true });
16668
16744
  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;
16669
16745
  exports.DEFAULT_TIMEOUT = 3e4;
@@ -16811,7 +16887,7 @@ var require_common$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
16811
16887
  }));
16812
16888
  //#endregion
16813
16889
  //#region ../../node_modules/ip-address/dist/v4/constants.js
16814
- var require_constants$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
16890
+ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
16815
16891
  Object.defineProperty(exports, "__esModule", { value: true });
16816
16892
  exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = void 0;
16817
16893
  exports.BITS = 32;
@@ -18448,7 +18524,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18448
18524
  Object.defineProperty(exports, "__esModule", { value: true });
18449
18525
  exports.Address4 = void 0;
18450
18526
  const common = __importStar(require_common$2());
18451
- const constants = __importStar(require_constants$10());
18527
+ const constants = __importStar(require_constants$9());
18452
18528
  const address_error_1 = require_address_error();
18453
18529
  const jsbn_1 = require_jsbn$1();
18454
18530
  const sprintf_js_1 = require_sprintf();
@@ -18724,7 +18800,7 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18724
18800
  }));
18725
18801
  //#endregion
18726
18802
  //#region ../../node_modules/ip-address/dist/v6/constants.js
18727
- var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
18803
+ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
18728
18804
  Object.defineProperty(exports, "__esModule", { value: true });
18729
18805
  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;
18730
18806
  exports.BITS = 128;
@@ -18878,7 +18954,7 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18878
18954
  };
18879
18955
  Object.defineProperty(exports, "__esModule", { value: true });
18880
18956
  exports.possibleElisions = exports.simpleRegularExpression = exports.ADDRESS_BOUNDARY = exports.padGroup = exports.groupPossibilities = void 0;
18881
- const v6 = __importStar(require_constants$9());
18957
+ const v6 = __importStar(require_constants$8());
18882
18958
  const sprintf_js_1 = require_sprintf();
18883
18959
  function groupPossibilities(possibilities) {
18884
18960
  return (0, sprintf_js_1.sprintf)("(%s)", possibilities.join("|"));
@@ -18958,8 +19034,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18958
19034
  Object.defineProperty(exports, "__esModule", { value: true });
18959
19035
  exports.Address6 = void 0;
18960
19036
  const common = __importStar(require_common$2());
18961
- const constants4 = __importStar(require_constants$10());
18962
- const constants6 = __importStar(require_constants$9());
19037
+ const constants4 = __importStar(require_constants$9());
19038
+ const constants6 = __importStar(require_constants$8());
18963
19039
  const helpers = __importStar(require_helpers$1());
18964
19040
  const ipv4_1 = require_ipv4();
18965
19041
  const regular_expressions_1 = require_regular_expressions();
@@ -19777,10 +19853,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19777
19853
  Object.defineProperty(exports, "__esModule", { value: true });
19778
19854
  exports.ipToBuffer = exports.int32ToIpv4 = exports.ipv4ToInt32 = exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = void 0;
19779
19855
  const util_1 = require_util$11();
19780
- const constants_1 = require_constants$11();
19856
+ const constants_1 = require_constants$10();
19781
19857
  const stream$3 = require("stream");
19782
19858
  const ip_address_1 = require_ip_address();
19783
- const net$10 = require("net");
19859
+ const net$9 = require("net");
19784
19860
  /**
19785
19861
  * Validates the provided SocksClientOptions
19786
19862
  * @param options { SocksClientOptions }
@@ -19858,10 +19934,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19858
19934
  }
19859
19935
  exports.int32ToIpv4 = int32ToIpv4;
19860
19936
  function ipToBuffer(ip) {
19861
- if (net$10.isIPv4(ip)) {
19937
+ if (net$9.isIPv4(ip)) {
19862
19938
  const address = new ip_address_1.Address4(ip);
19863
19939
  return Buffer.from(address.toArray());
19864
- } else if (net$10.isIPv6(ip)) {
19940
+ } else if (net$9.isIPv6(ip)) {
19865
19941
  const address = new ip_address_1.Address6(ip);
19866
19942
  return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
19867
19943
  } else throw new Error("Invalid IP address format");
@@ -19940,9 +20016,9 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
19940
20016
  Object.defineProperty(exports, "__esModule", { value: true });
19941
20017
  exports.SocksClientError = exports.SocksClient = void 0;
19942
20018
  const events_1$2 = require("events");
19943
- const net$9 = require("net");
20019
+ const net$8 = require("net");
19944
20020
  const smart_buffer_1 = require_smartbuffer();
19945
- const constants_1 = require_constants$11();
20021
+ const constants_1 = require_constants$10();
19946
20022
  const helpers_1 = require_helpers();
19947
20023
  const receivebuffer_1 = require_receivebuffer();
19948
20024
  const util_1 = require_util$11();
@@ -20052,10 +20128,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20052
20128
  const buff = new smart_buffer_1.SmartBuffer();
20053
20129
  buff.writeUInt16BE(0);
20054
20130
  buff.writeUInt8(options.frameNumber || 0);
20055
- if (net$9.isIPv4(options.remoteHost.host)) {
20131
+ if (net$8.isIPv4(options.remoteHost.host)) {
20056
20132
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20057
20133
  buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
20058
- } else if (net$9.isIPv6(options.remoteHost.host)) {
20134
+ } else if (net$8.isIPv6(options.remoteHost.host)) {
20059
20135
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20060
20136
  buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
20061
20137
  } else {
@@ -20108,7 +20184,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20108
20184
  const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
20109
20185
  if (timer.unref && typeof timer.unref === "function") timer.unref();
20110
20186
  if (existingSocket) this.socket = existingSocket;
20111
- else this.socket = new net$9.Socket();
20187
+ else this.socket = new net$8.Socket();
20112
20188
  this.socket.once("close", this.onClose);
20113
20189
  this.socket.once("error", this.onError);
20114
20190
  this.socket.once("connect", this.onConnect);
@@ -20220,7 +20296,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20220
20296
  buff.writeUInt8(4);
20221
20297
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20222
20298
  buff.writeUInt16BE(this.options.destination.port);
20223
- if (net$9.isIPv4(this.options.destination.host)) {
20299
+ if (net$8.isIPv4(this.options.destination.host)) {
20224
20300
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20225
20301
  buff.writeStringNT(userId);
20226
20302
  } else {
@@ -20379,10 +20455,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
20379
20455
  buff.writeUInt8(5);
20380
20456
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
20381
20457
  buff.writeUInt8(0);
20382
- if (net$9.isIPv4(this.options.destination.host)) {
20458
+ if (net$8.isIPv4(this.options.destination.host)) {
20383
20459
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
20384
20460
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20385
- } else if (net$9.isIPv6(this.options.destination.host)) {
20461
+ } else if (net$8.isIPv6(this.options.destination.host)) {
20386
20462
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
20387
20463
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
20388
20464
  } else {
@@ -20592,12 +20668,12 @@ var require_dist$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
20592
20668
  const agent_base_1 = require_dist$11();
20593
20669
  const debug_1 = __importDefault(require_src$2());
20594
20670
  const dns = __importStar(require("dns"));
20595
- const net$8 = __importStar(require("net"));
20671
+ const net$7 = __importStar(require("net"));
20596
20672
  const tls$2 = __importStar(require("tls"));
20597
20673
  const url_1$4 = require("url");
20598
20674
  const debug = (0, debug_1.default)("socks-proxy-agent");
20599
20675
  const setServernameFromNonIpHost = (options) => {
20600
- if (options.servername === void 0 && options.host && !net$8.isIP(options.host)) return {
20676
+ if (options.servername === void 0 && options.host && !net$7.isIP(options.host)) return {
20601
20677
  ...options,
20602
20678
  servername: options.host
20603
20679
  };
@@ -22857,6 +22933,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22857
22933
  function doNothing() {
22858
22934
  /** Do nothing */
22859
22935
  }
22936
+ const maxControlResponseLength = 2 ** 16;
22860
22937
  /**
22861
22938
  * FTPContext holds the control and data sockets of an FTP connection and provides a
22862
22939
  * simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -22983,6 +23060,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
22983
23060
  * Send an FTP command without waiting for or handling the result.
22984
23061
  */
22985
23062
  send(command) {
23063
+ if (/[\r\n\0]/.test(command)) throw new Error(`Invalid command: Contains control characters. (${command})`);
22986
23064
  const message = command.startsWith("PASS") ? "> PASS ###" : `> ${command}`;
22987
23065
  this.log(message);
22988
23066
  this._socket.write(command + "\r\n", this.encoding);
@@ -23061,6 +23139,10 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23061
23139
  */
23062
23140
  _onControlSocketData(chunk) {
23063
23141
  this.log(`< ${chunk}`);
23142
+ if (this._partialResponse.length + chunk.length > maxControlResponseLength) {
23143
+ this.closeWithError(/* @__PURE__ */ new Error("FTP control response exceeded maximum allowed size"));
23144
+ return;
23145
+ }
23064
23146
  const completeResponse = this._partialResponse + chunk;
23065
23147
  const parsed = (0, parseControlResponse_1.parseControlResponse)(completeResponse);
23066
23148
  this._partialResponse = parsed.rest;
@@ -23144,6 +23226,61 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
23144
23226
  exports.FTPContext = FTPContext;
23145
23227
  }));
23146
23228
  //#endregion
23229
+ //#region ../../node_modules/basic-ftp/dist/netUtils.js
23230
+ var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
23231
+ Object.defineProperty(exports, "__esModule", { value: true });
23232
+ exports.describeTLS = describeTLS;
23233
+ exports.describeAddress = describeAddress;
23234
+ exports.upgradeSocket = upgradeSocket;
23235
+ exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
23236
+ const tls_1$2 = require("tls");
23237
+ /**
23238
+ * Returns a string describing the encryption on a given socket instance.
23239
+ */
23240
+ function describeTLS(socket) {
23241
+ if (socket instanceof tls_1$2.TLSSocket) {
23242
+ const protocol = socket.getProtocol();
23243
+ return protocol ? protocol : "Server socket or disconnected client socket";
23244
+ }
23245
+ return "No encryption";
23246
+ }
23247
+ /**
23248
+ * Returns a string describing the remote address of a socket.
23249
+ */
23250
+ function describeAddress(socket) {
23251
+ if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
23252
+ return `${socket.remoteAddress}:${socket.remotePort}`;
23253
+ }
23254
+ /**
23255
+ * Upgrade a socket connection with TLS.
23256
+ */
23257
+ function upgradeSocket(socket, options) {
23258
+ return new Promise((resolve, reject) => {
23259
+ const tlsOptions = Object.assign({}, options, { socket });
23260
+ const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
23261
+ if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
23262
+ else {
23263
+ tlsSocket.removeAllListeners("error");
23264
+ resolve(tlsSocket);
23265
+ }
23266
+ }).once("error", (error) => {
23267
+ reject(error);
23268
+ });
23269
+ });
23270
+ }
23271
+ /**
23272
+ * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
23273
+ * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
23274
+ *
23275
+ * @param ip The IP as a string, e.g. "192.168.0.1"
23276
+ */
23277
+ function ipIsPrivateV4Address(ip = "") {
23278
+ if (ip.startsWith("::ffff:")) ip = ip.substr(7);
23279
+ const octets = ip.split(".").map((o) => parseInt(o, 10));
23280
+ return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
23281
+ }
23282
+ }));
23283
+ //#endregion
23147
23284
  //#region ../../node_modules/basic-ftp/dist/FileInfo.js
23148
23285
  var require_FileInfo = /* @__PURE__ */ __commonJSMin(((exports) => {
23149
23286
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23679,78 +23816,32 @@ var require_StringWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
23679
23816
  exports.StringWriter = void 0;
23680
23817
  const stream_1$5 = require("stream");
23681
23818
  var StringWriter = class extends stream_1$5.Writable {
23682
- constructor() {
23683
- super(...arguments);
23684
- this.buf = Buffer.alloc(0);
23819
+ constructor(maxByteLength = 1 * 1024 * 1024) {
23820
+ super();
23821
+ this.maxByteLength = maxByteLength;
23822
+ this.byteLength = 0;
23823
+ this.bufs = [];
23685
23824
  }
23686
23825
  _write(chunk, _, callback) {
23687
- if (chunk instanceof Buffer) {
23688
- this.buf = Buffer.concat([this.buf, chunk]);
23689
- callback(null);
23690
- } else callback(/* @__PURE__ */ new Error("StringWriter expects chunks of type 'Buffer'."));
23826
+ if (!(chunk instanceof Buffer)) {
23827
+ callback(/* @__PURE__ */ new Error("StringWriter: expects chunks of type 'Buffer'."));
23828
+ return;
23829
+ }
23830
+ if (this.byteLength + chunk.byteLength > this.maxByteLength) {
23831
+ callback(/* @__PURE__ */ new Error(`StringWriter: Maximum bytes exceeded, maxByteLength=${this.maxByteLength}.`));
23832
+ return;
23833
+ }
23834
+ this.byteLength += chunk.byteLength;
23835
+ this.bufs.push(chunk);
23836
+ callback(null);
23691
23837
  }
23692
23838
  getText(encoding) {
23693
- return this.buf.toString(encoding);
23839
+ return Buffer.concat(this.bufs).toString(encoding);
23694
23840
  }
23695
23841
  };
23696
23842
  exports.StringWriter = StringWriter;
23697
23843
  }));
23698
23844
  //#endregion
23699
- //#region ../../node_modules/basic-ftp/dist/netUtils.js
23700
- var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
23701
- Object.defineProperty(exports, "__esModule", { value: true });
23702
- exports.describeTLS = describeTLS;
23703
- exports.describeAddress = describeAddress;
23704
- exports.upgradeSocket = upgradeSocket;
23705
- exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
23706
- const tls_1$2 = require("tls");
23707
- /**
23708
- * Returns a string describing the encryption on a given socket instance.
23709
- */
23710
- function describeTLS(socket) {
23711
- if (socket instanceof tls_1$2.TLSSocket) {
23712
- const protocol = socket.getProtocol();
23713
- return protocol ? protocol : "Server socket or disconnected client socket";
23714
- }
23715
- return "No encryption";
23716
- }
23717
- /**
23718
- * Returns a string describing the remote address of a socket.
23719
- */
23720
- function describeAddress(socket) {
23721
- if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
23722
- return `${socket.remoteAddress}:${socket.remotePort}`;
23723
- }
23724
- /**
23725
- * Upgrade a socket connection with TLS.
23726
- */
23727
- function upgradeSocket(socket, options) {
23728
- return new Promise((resolve, reject) => {
23729
- const tlsOptions = Object.assign({}, options, { socket });
23730
- const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
23731
- if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
23732
- else {
23733
- tlsSocket.removeAllListeners("error");
23734
- resolve(tlsSocket);
23735
- }
23736
- }).once("error", (error) => {
23737
- reject(error);
23738
- });
23739
- });
23740
- }
23741
- /**
23742
- * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
23743
- * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
23744
- *
23745
- * @param ip The IP as a string, e.g. "192.168.0.1"
23746
- */
23747
- function ipIsPrivateV4Address(ip = "") {
23748
- if (ip.startsWith("::ffff:")) ip = ip.substr(7);
23749
- const octets = ip.split(".").map((o) => parseInt(o, 10));
23750
- return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
23751
- }
23752
- }));
23753
- //#endregion
23754
23845
  //#region ../../node_modules/basic-ftp/dist/transfer.js
23755
23846
  var require_transfer = /* @__PURE__ */ __commonJSMin(((exports) => {
23756
23847
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -23996,20 +24087,23 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
23996
24087
  const tls_1 = require("tls");
23997
24088
  const util_1$3 = require("util");
23998
24089
  const FtpContext_1 = require_FtpContext();
24090
+ const netUtils_1 = require_netUtils();
24091
+ const parseControlResponse_1 = require_parseControlResponse();
23999
24092
  const parseList_1 = require_parseList();
24093
+ const parseListMLSD_1 = require_parseListMLSD();
24000
24094
  const ProgressTracker_1 = require_ProgressTracker();
24001
24095
  const StringWriter_1 = require_StringWriter();
24002
- const parseListMLSD_1 = require_parseListMLSD();
24003
- const netUtils_1 = require_netUtils();
24004
24096
  const transfer_1 = require_transfer();
24005
- const parseControlResponse_1 = require_parseControlResponse();
24006
24097
  const fsReadDir = (0, util_1$3.promisify)(fs_1$5.readdir);
24007
24098
  const fsMkDir = (0, util_1$3.promisify)(fs_1$5.mkdir);
24008
24099
  const fsStat = (0, util_1$3.promisify)(fs_1$5.stat);
24009
24100
  const fsOpen = (0, util_1$3.promisify)(fs_1$5.open);
24010
24101
  const fsClose = (0, util_1$3.promisify)(fs_1$5.close);
24011
24102
  const fsUnlink = (0, util_1$3.promisify)(fs_1$5.unlink);
24012
- const defaultClientOptions = { allowSeparateTransferHost: true };
24103
+ const defaultClientOptions = {
24104
+ allowSeparateTransferHost: true,
24105
+ maxListingBytes: 40 * 1024 * 1024
24106
+ };
24013
24107
  const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
24014
24108
  const LIST_COMMANDS_MLSD = () => [
24015
24109
  "MLSD",
@@ -24025,10 +24119,15 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24025
24119
  *
24026
24120
  * @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
24027
24121
  */
24028
- constructor(timeout = 3e4, options = defaultClientOptions) {
24122
+ constructor(timeout = 3e4, userOptions = defaultClientOptions) {
24029
24123
  this.availableListCommands = LIST_COMMANDS_DEFAULT();
24124
+ const options = {
24125
+ ...defaultClientOptions,
24126
+ ...userOptions
24127
+ };
24030
24128
  this.ftp = new FtpContext_1.FTPContext(timeout);
24031
24129
  this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, options.allowSeparateTransferHost ? transfer_1.enterPassiveModeIPv4 : transfer_1.enterPassiveModeIPv4_forceControlHostIP]);
24130
+ this.options = options;
24032
24131
  this.parseList = parseList_1.parseList;
24033
24132
  this._progressTracker = new ProgressTracker_1.ProgressTracker();
24034
24133
  }
@@ -24428,7 +24527,7 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
24428
24527
  * @protected
24429
24528
  */
24430
24529
  async _requestListWithCommand(command) {
24431
- const buffer = new StringWriter_1.StringWriter();
24530
+ const buffer = new StringWriter_1.StringWriter(this.options.maxListingBytes);
24432
24531
  await (0, transfer_1.downloadTo)(buffer, {
24433
24532
  ftp: this.ftp,
24434
24533
  tracker: this._progressTracker,
@@ -41731,7 +41830,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41731
41830
  };
41732
41831
  Object.defineProperty(exports, "__esModule", { value: true });
41733
41832
  exports.PacProxyAgent = void 0;
41734
- const net$7 = __importStar(require("net"));
41833
+ const net$6 = __importStar(require("net"));
41735
41834
  const tls$1 = __importStar(require("tls"));
41736
41835
  const crypto$14 = __importStar(require("crypto"));
41737
41836
  const events_1 = require("events");
@@ -41743,7 +41842,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41743
41842
  const quickjs_emscripten_1 = require_dist$3();
41744
41843
  const debug = (0, debug_1.default)("pac-proxy-agent");
41745
41844
  const setServernameFromNonIpHost = (options) => {
41746
- if (options.servername === void 0 && options.host && !net$7.isIP(options.host)) return {
41845
+ if (options.servername === void 0 && options.host && !net$6.isIP(options.host)) return {
41747
41846
  ...options,
41748
41847
  servername: options.host
41749
41848
  };
@@ -41833,7 +41932,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41833
41932
  const isWebSocket = req.getHeader("upgrade") === "websocket";
41834
41933
  const resolver = await this.getResolver();
41835
41934
  const protocol = secureEndpoint ? "https:" : "http:";
41836
- const host = opts.host && net$7.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
41935
+ const host = opts.host && net$6.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
41837
41936
  const defaultPort = secureEndpoint ? 443 : 80;
41838
41937
  const url = Object.assign(new url_1$2.URL(req.path, `${protocol}//${host}`), defaultPort ? void 0 : { port: opts.port });
41839
41938
  debug("url: %s", url);
@@ -41847,7 +41946,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41847
41946
  const [type, target] = proxy.split(/\s+/);
41848
41947
  debug("Attempting to use proxy: %o", proxy);
41849
41948
  if (type === "DIRECT") if (secureEndpoint) socket = tls$1.connect(setServernameFromNonIpHost(opts));
41850
- else socket = net$7.connect(opts);
41949
+ else socket = net$6.connect(opts);
41851
41950
  else if (type === "SOCKS" || type === "SOCKS5") {
41852
41951
  const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require_dist$8()));
41853
41952
  agent = new SocksProxyAgent(`socks://${target}`, this.opts);
@@ -41875,7 +41974,7 @@ var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
41875
41974
  }
41876
41975
  if (agent) {
41877
41976
  const s = await agent.connect(req, opts);
41878
- if (!(s instanceof net$7.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
41977
+ if (!(s instanceof net$6.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
41879
41978
  req.emit("proxy", {
41880
41979
  proxy,
41881
41980
  socket: s
@@ -42803,7 +42902,7 @@ var require_errors$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42803
42902
  }));
42804
42903
  //#endregion
42805
42904
  //#region ../../node_modules/undici/lib/core/constants.js
42806
- var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42905
+ var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42807
42906
  /**
42808
42907
  * @see https://developer.mozilla.org/docs/Web/HTTP/Headers
42809
42908
  */
@@ -42935,7 +43034,7 @@ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42935
43034
  //#endregion
42936
43035
  //#region ../../node_modules/undici/lib/core/tree.js
42937
43036
  var require_tree = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42938
- const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$8();
43037
+ const { wellknownHeaderNames, headerNameLowerCasedRecord } = require_constants$7();
42939
43038
  var TstNode = class TstNode {
42940
43039
  /** @type {any} */
42941
43040
  value = null;
@@ -43057,12 +43156,12 @@ var require_util$8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43057
43156
  const { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
43058
43157
  const { IncomingMessage } = require("node:http");
43059
43158
  const stream$2 = require("node:stream");
43060
- const net$6 = require("node:net");
43159
+ const net$5 = require("node:net");
43061
43160
  const { stringify: stringify$1 } = require("node:querystring");
43062
43161
  const { EventEmitter: EE$3 } = require("node:events");
43063
43162
  const timers = require_timers();
43064
43163
  const { InvalidArgumentError, ConnectTimeoutError } = require_errors$3();
43065
- const { headerNameLowerCasedRecord } = require_constants$8();
43164
+ const { headerNameLowerCasedRecord } = require_constants$7();
43066
43165
  const { tree } = require_tree();
43067
43166
  const [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
43068
43167
  var BodyAsyncIterable = class {
@@ -43218,7 +43317,7 @@ var require_util$8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43218
43317
  if (!host) return null;
43219
43318
  assert$38(typeof host === "string");
43220
43319
  const servername = getHostname(host);
43221
- if (net$6.isIP(servername)) return "";
43320
+ if (net$5.isIP(servername)) return "";
43222
43321
  return servername;
43223
43322
  }
43224
43323
  /**
@@ -44126,8 +44225,16 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44126
44225
  const assert$37 = require("node:assert");
44127
44226
  const { isValidHTTPToken, isValidHeaderValue, isStream, destroy, isBuffer, isFormDataLike, isIterable, hasSafeIterator, isBlobLike, serializePathWithQuery, assertRequestHandler, getServerName, normalizedMethodRecords, getProtocolFromUrlString } = require_util$8();
44128
44227
  const { channels } = require_diagnostics();
44129
- const { headerNameLowerCasedRecord } = require_constants$8();
44228
+ const { headerNameLowerCasedRecord } = require_constants$7();
44130
44229
  const invalidPathRegex = /[^\u0021-\u00ff]/;
44230
+ function isValidContentLengthHeaderValue(val) {
44231
+ if (typeof val !== "string" || val.length === 0) return false;
44232
+ for (let i = 0; i < val.length; i++) {
44233
+ const charCode = val.charCodeAt(i);
44234
+ if (charCode < 48 || charCode > 57) return false;
44235
+ }
44236
+ return true;
44237
+ }
44131
44238
  const kHandler = Symbol("handler");
44132
44239
  var Request = class {
44133
44240
  constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
@@ -44336,8 +44443,8 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44336
44443
  request.host = val;
44337
44444
  } else if (headerName === "content-length") {
44338
44445
  if (request.contentLength !== null) throw new InvalidArgumentError("duplicate content-length header");
44446
+ if (!isValidContentLengthHeaderValue(val)) throw new InvalidArgumentError("invalid content-length header");
44339
44447
  request.contentLength = parseInt(val, 10);
44340
- if (!Number.isFinite(request.contentLength)) throw new InvalidArgumentError("invalid content-length header");
44341
44448
  } else if (request.contentType === null && headerName === "content-type") {
44342
44449
  request.contentType = val;
44343
44450
  request.headers.push(key, val);
@@ -44462,6 +44569,8 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44462
44569
  #aborted = false;
44463
44570
  #abort;
44464
44571
  [kResume] = null;
44572
+ rawHeaders = null;
44573
+ rawTrailers = null;
44465
44574
  constructor(abort) {
44466
44575
  this.#abort = abort;
44467
44576
  }
@@ -44508,10 +44617,12 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44508
44617
  return this.#handler.onResponseStarted?.();
44509
44618
  }
44510
44619
  onUpgrade(statusCode, rawHeaders, socket) {
44620
+ this.#controller.rawHeaders = rawHeaders;
44511
44621
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
44512
44622
  }
44513
44623
  onHeaders(statusCode, rawHeaders, resume, statusMessage) {
44514
44624
  this.#controller[kResume] = resume;
44625
+ this.#controller.rawHeaders = rawHeaders;
44515
44626
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
44516
44627
  return !this.#controller.paused;
44517
44628
  }
@@ -44520,6 +44631,7 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
44520
44631
  return !this.#controller.paused;
44521
44632
  }
44522
44633
  onComplete(rawTrailers) {
44634
+ this.#controller.rawTrailers = rawTrailers;
44523
44635
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
44524
44636
  }
44525
44637
  onError(err) {
@@ -44537,6 +44649,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44537
44649
  const { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
44538
44650
  const kOnDestroyed = Symbol("onDestroyed");
44539
44651
  const kOnClosed = Symbol("onClosed");
44652
+ const kWebSocketOptions = Symbol("webSocketOptions");
44540
44653
  var DispatcherBase = class extends Dispatcher {
44541
44654
  /** @type {boolean} */
44542
44655
  [kDestroyed] = false;
@@ -44546,6 +44659,22 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44546
44659
  [kClosed] = false;
44547
44660
  /** @type {Array<Function>|null} */
44548
44661
  [kOnClosed] = null;
44662
+ /**
44663
+ * @param {import('../../types/dispatcher').DispatcherOptions} [opts]
44664
+ */
44665
+ constructor(opts) {
44666
+ super();
44667
+ this[kWebSocketOptions] = opts?.webSocket ?? {};
44668
+ }
44669
+ /**
44670
+ * @returns {import('../../types/dispatcher').WebSocketOptions}
44671
+ */
44672
+ get webSocketOptions() {
44673
+ return {
44674
+ maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
44675
+ maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
44676
+ };
44677
+ }
44549
44678
  /** @returns {boolean} */
44550
44679
  get destroyed() {
44551
44680
  return this[kDestroyed];
@@ -44628,7 +44757,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
44628
44757
  //#endregion
44629
44758
  //#region ../../node_modules/undici/lib/core/connect.js
44630
44759
  var require_connect$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44631
- const net$5 = require("node:net");
44760
+ const net$4 = require("node:net");
44632
44761
  const assert$36 = require("node:assert");
44633
44762
  const util = require_util$8();
44634
44763
  const { InvalidArgumentError } = require_errors$3();
@@ -44649,6 +44778,15 @@ var require_connect$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44649
44778
  }
44650
44779
  set(sessionKey, session) {
44651
44780
  if (this._maxCachedSessions === 0) return;
44781
+ if (this._sessionCache.has(sessionKey)) this._sessionCache.delete(sessionKey);
44782
+ else if (this._sessionCache.size >= this._maxCachedSessions) {
44783
+ for (const [key, ref] of this._sessionCache) if (ref.deref() === void 0) {
44784
+ this._sessionCache.delete(key);
44785
+ return;
44786
+ }
44787
+ const oldest = this._sessionCache.keys().next();
44788
+ if (!oldest.done) this._sessionCache.delete(oldest.value);
44789
+ }
44652
44790
  this._sessionCache.set(sessionKey, new WeakRef(session));
44653
44791
  this._sessionRegistry.register(session, sessionKey);
44654
44792
  }
@@ -44688,7 +44826,7 @@ var require_connect$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44688
44826
  } else {
44689
44827
  assert$36(!httpSocket, "httpSocket can only be sent on TLS update");
44690
44828
  port = port || 80;
44691
- socket = net$5.connect({
44829
+ socket = net$4.connect({
44692
44830
  highWaterMark: 64 * 1024,
44693
44831
  ...options,
44694
44832
  localAddress,
@@ -44741,7 +44879,7 @@ var require_utils$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
44741
44879
  }));
44742
44880
  //#endregion
44743
44881
  //#region ../../node_modules/undici/lib/llhttp/constants.js
44744
- var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
44882
+ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
44745
44883
  Object.defineProperty(exports, "__esModule", { value: true });
44746
44884
  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;
44747
44885
  const utils_1 = require_utils$6();
@@ -45347,7 +45485,7 @@ var require_llhttp_simd_wasm = /* @__PURE__ */ __commonJSMin(((exports, module)
45347
45485
  }));
45348
45486
  //#endregion
45349
45487
  //#region ../../node_modules/undici/lib/web/fetch/constants.js
45350
- var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45488
+ var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45351
45489
  const corsSafeListedMethods = [
45352
45490
  "GET",
45353
45491
  "HEAD",
@@ -46246,7 +46384,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46246
46384
  lowerBound = 0;
46247
46385
  upperBound = Math.pow(2, bitLength) - 1;
46248
46386
  } else {
46249
- lowerBound = Math.pow(-2, bitLength) - 1;
46387
+ lowerBound = -Math.pow(2, bitLength - 1);
46250
46388
  upperBound = Math.pow(2, bitLength - 1) - 1;
46251
46389
  }
46252
46390
  let x = Number(V);
@@ -46272,7 +46410,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46272
46410
  if (Number.isNaN(x) || x === 0 && Object.is(0, x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) return 0;
46273
46411
  x = webidl.util.IntegerPart(x);
46274
46412
  x = x % Math.pow(2, bitLength);
46275
- if (signedness === "signed" && x >= Math.pow(2, bitLength) - 1) return x - Math.pow(2, bitLength);
46413
+ if (signedness === "signed" && x >= Math.pow(2, bitLength - 1)) return x - Math.pow(2, bitLength);
46276
46414
  return x;
46277
46415
  };
46278
46416
  webidl.util.IntegerPart = function(n) {
@@ -46607,7 +46745,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46607
46745
  var require_util$7 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
46608
46746
  const { Transform: Transform$2 } = require("node:stream");
46609
46747
  const zlib$2 = require("node:zlib");
46610
- const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$6();
46748
+ const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants$5();
46611
46749
  const { getGlobalOrigin } = require_global$1();
46612
46750
  const { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
46613
46751
  const { performance: performance$1 } = require("node:perf_hooks");
@@ -47617,7 +47755,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47617
47755
  * Parses content-disposition attributes (e.g., name="value" or filename*=utf-8''encoded)
47618
47756
  * @param {Buffer} input
47619
47757
  * @param {{ position: number }} position
47620
- * @returns {{ name: string, value: string }}
47758
+ * @returns {{ name: string, value: string, extended: boolean } | null}
47621
47759
  */
47622
47760
  function parseContentDispositionAttribute(input, position) {
47623
47761
  if (input[position.position] === 59) position.position++;
@@ -47647,7 +47785,8 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47647
47785
  }
47648
47786
  return {
47649
47787
  name: attrNameStr,
47650
- value
47788
+ value,
47789
+ extended: isExtended
47651
47790
  };
47652
47791
  }
47653
47792
  /**
@@ -47677,17 +47816,24 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47677
47816
  position.position++;
47678
47817
  collectASequenceOfBytes((char) => char === 32 || char === 9, input, position);
47679
47818
  switch (bufferToLowerCasedHeaderName(headerName)) {
47680
- case "content-disposition":
47819
+ case "content-disposition": {
47681
47820
  name = filename = null;
47821
+ let filenameIsExtended = false;
47682
47822
  if (collectASequenceOfBytes((char) => isToken(char), input, position).toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
47683
- while (position.position < input.length && input[position.position] !== 13 && input[position.position + 1] !== 10) {
47823
+ while (position.position < input.length && (input[position.position] !== 13 || input[position.position + 1] !== 10)) {
47684
47824
  const attribute = parseContentDispositionAttribute(input, position);
47685
47825
  if (!attribute) break;
47686
47826
  if (attribute.name === "name") name = attribute.value;
47687
- else if (attribute.name === "filename") filename = attribute.value;
47827
+ else if (attribute.name === "filename") {
47828
+ if (attribute.extended) {
47829
+ filename = attribute.value;
47830
+ filenameIsExtended = true;
47831
+ } else if (!filenameIsExtended) filename = attribute.value;
47832
+ }
47688
47833
  }
47689
47834
  if (name === null) throw parsingError("name attribute is required in content-disposition header");
47690
47835
  break;
47836
+ }
47691
47837
  case "content-type": {
47692
47838
  let headerValue = collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47693
47839
  headerValue = removeChars(headerValue, false, true, (char) => char === 9 || char === 32);
@@ -47702,7 +47848,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
47702
47848
  }
47703
47849
  default: collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
47704
47850
  }
47705
- if (input[position.position] !== 13 && input[position.position + 1] !== 10) throw parsingError("expected CRLF");
47851
+ if (input[position.position] !== 13 || input[position.position + 1] !== 10) throw parsingError("expected CRLF");
47706
47852
  else position.position += 2;
47707
47853
  }
47708
47854
  }
@@ -48070,17 +48216,20 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48070
48216
  const timers = require_timers();
48071
48217
  const { RequestContentLengthMismatchError, ResponseContentLengthMismatchError, RequestAbortedError, HeadersTimeoutError, HeadersOverflowError, SocketError, InformationalError, BodyTimeoutError, HTTPParserError, ResponseExceededMaxSizeError } = require_errors$3();
48072
48218
  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();
48073
- const constants = require_constants$7();
48219
+ const constants = require_constants$6();
48074
48220
  const EMPTY_BUF = Buffer.alloc(0);
48075
48221
  const FastBuffer = Buffer[Symbol.species];
48076
48222
  const removeAllListeners = util.removeAllListeners;
48223
+ const kIdleSocketValidation = Symbol("kIdleSocketValidation");
48224
+ const kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
48225
+ const kSocketUsed = Symbol("kSocketUsed");
48077
48226
  let extractBody;
48078
48227
  function lazyllhttp() {
48079
48228
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
48080
48229
  let mod;
48081
48230
  let useWasmSIMD = process.arch !== "ppc64";
48082
- if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
48083
- else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = false;
48231
+ if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = false;
48232
+ else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = true;
48084
48233
  if (useWasmSIMD) try {
48085
48234
  mod = new WebAssembly.Module(require_llhttp_simd_wasm());
48086
48235
  } catch {}
@@ -48154,6 +48303,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48154
48303
  */
48155
48304
  this.socket = socket;
48156
48305
  this.timeout = null;
48306
+ this.timeoutWeakRef = new WeakRef(this);
48157
48307
  this.timeoutValue = null;
48158
48308
  this.timeoutType = null;
48159
48309
  this.statusCode = 0;
@@ -48177,9 +48327,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48177
48327
  timers.clearTimeout(this.timeout);
48178
48328
  this.timeout = null;
48179
48329
  }
48180
- if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this));
48330
+ if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef);
48181
48331
  else {
48182
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this));
48332
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
48183
48333
  this.timeout?.unref();
48184
48334
  }
48185
48335
  this.timeoutValue = delay;
@@ -48238,20 +48388,42 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48238
48388
  else if (ret === constants.ERROR.PAUSED) {
48239
48389
  this.paused = true;
48240
48390
  socket.unshift(data);
48241
- } else {
48242
- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
48243
- let message = "";
48244
- if (ptr) {
48245
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
48246
- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
48247
- }
48248
- throw new HTTPParserError(message, constants.ERROR[ret], data);
48249
- }
48391
+ } else throw this.createError(ret, data);
48250
48392
  }
48251
48393
  } catch (err) {
48252
48394
  util.destroy(socket, err);
48253
48395
  }
48254
48396
  }
48397
+ finish() {
48398
+ assert$29(currentParser === null);
48399
+ assert$29(this.ptr != null);
48400
+ assert$29(!this.paused);
48401
+ const { llhttp } = this;
48402
+ let ret;
48403
+ try {
48404
+ currentParser = this;
48405
+ ret = llhttp.llhttp_finish(this.ptr);
48406
+ } finally {
48407
+ currentParser = null;
48408
+ }
48409
+ if (ret === constants.ERROR.OK) return null;
48410
+ if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
48411
+ this.paused = true;
48412
+ return null;
48413
+ }
48414
+ return this.createError(ret, EMPTY_BUF);
48415
+ }
48416
+ createError(ret, data) {
48417
+ const { llhttp, contentLength, bytesRead } = this;
48418
+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) return new ResponseContentLengthMismatchError();
48419
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr);
48420
+ let message = "";
48421
+ if (ptr) {
48422
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
48423
+ message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
48424
+ }
48425
+ return new HTTPParserError(message, constants.ERROR[ret], data);
48426
+ }
48255
48427
  destroy() {
48256
48428
  assert$29(currentParser === null);
48257
48429
  assert$29(this.ptr != null);
@@ -48277,6 +48449,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48277
48449
  onMessageBegin() {
48278
48450
  const { socket, client } = this;
48279
48451
  if (socket.destroyed) return -1;
48452
+ if (client[kRunning] === 0) {
48453
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
48454
+ return -1;
48455
+ }
48280
48456
  const request = client[kQueue][client[kRunningIdx]];
48281
48457
  if (!request) return -1;
48282
48458
  request.onResponseStarted();
@@ -48363,6 +48539,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48363
48539
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
48364
48540
  const { client, socket, headers, statusText } = this;
48365
48541
  if (socket.destroyed) return -1;
48542
+ if (client[kRunning] === 0) {
48543
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
48544
+ return -1;
48545
+ }
48366
48546
  const request = client[kQueue][client[kRunningIdx]];
48367
48547
  if (!request) return -1;
48368
48548
  assert$29(!this.upgrade);
@@ -48463,6 +48643,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48463
48643
  }
48464
48644
  request.onComplete(headers);
48465
48645
  client[kQueue][client[kRunningIdx]++] = null;
48646
+ socket[kSocketUsed] = client[kPending] === 0;
48466
48647
  if (socket[kWriting]) {
48467
48648
  assert$29(client[kRunning] === 0);
48468
48649
  util.destroy(socket, new InformationalError("reset"));
@@ -48508,6 +48689,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48508
48689
  socket[kWriting] = false;
48509
48690
  socket[kReset] = false;
48510
48691
  socket[kBlocking] = false;
48692
+ socket[kIdleSocketValidation] = 0;
48693
+ socket[kIdleSocketValidationTimeout] = null;
48694
+ socket[kSocketUsed] = false;
48511
48695
  socket[kParser] = new Parser(client, socket, llhttpInstance);
48512
48696
  util.addListener(socket, "error", onHttpSocketError);
48513
48697
  util.addListener(socket, "readable", onHttpSocketReadable);
@@ -48535,7 +48719,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48535
48719
  return socket.destroyed;
48536
48720
  },
48537
48721
  busy(request) {
48538
- if (socket[kWriting] || socket[kReset] || socket[kBlocking]) return true;
48722
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) return true;
48539
48723
  if (request) {
48540
48724
  if (client[kRunning] > 0 && !request.idempotent) return true;
48541
48725
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) return true;
@@ -48549,7 +48733,11 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48549
48733
  assert$29(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
48550
48734
  const parser = this[kParser];
48551
48735
  if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
48552
- parser.onMessageComplete();
48736
+ const parserErr = parser.finish();
48737
+ if (parserErr) {
48738
+ this[kError] = parserErr;
48739
+ this[kClient][kOnError](parserErr);
48740
+ }
48553
48741
  return;
48554
48742
  }
48555
48743
  this[kError] = err;
@@ -48561,15 +48749,17 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48561
48749
  function onHttpSocketEnd() {
48562
48750
  const parser = this[kParser];
48563
48751
  if (parser.statusCode && !parser.shouldKeepAlive) {
48564
- parser.onMessageComplete();
48752
+ const parserErr = parser.finish();
48753
+ if (parserErr) util.destroy(this, parserErr);
48565
48754
  return;
48566
48755
  }
48567
48756
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
48568
48757
  }
48569
48758
  function onHttpSocketClose() {
48570
48759
  const parser = this[kParser];
48760
+ clearIdleSocketValidation(this);
48571
48761
  if (parser) {
48572
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) parser.onMessageComplete();
48762
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) this[kError] = parser.finish() || this[kError];
48573
48763
  this[kParser].destroy();
48574
48764
  this[kParser] = null;
48575
48765
  }
@@ -48597,6 +48787,22 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48597
48787
  function onSocketClose() {
48598
48788
  this[kClosed] = true;
48599
48789
  }
48790
+ function clearIdleSocketValidation(socket) {
48791
+ if (socket[kIdleSocketValidationTimeout]) {
48792
+ clearTimeout(socket[kIdleSocketValidationTimeout]);
48793
+ socket[kIdleSocketValidationTimeout] = null;
48794
+ }
48795
+ socket[kIdleSocketValidation] = 0;
48796
+ }
48797
+ function scheduleIdleSocketValidation(client, socket) {
48798
+ socket[kIdleSocketValidation] = 1;
48799
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
48800
+ socket[kIdleSocketValidationTimeout] = null;
48801
+ socket[kIdleSocketValidation] = 2;
48802
+ if (client[kSocket] === socket && !socket.destroyed) client[kResume]();
48803
+ }, 0);
48804
+ socket[kIdleSocketValidationTimeout].unref?.();
48805
+ }
48600
48806
  /**
48601
48807
  * @param {import('./client.js')} client
48602
48808
  */
@@ -48612,6 +48818,23 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48612
48818
  socket.ref();
48613
48819
  socket[kNoRef] = false;
48614
48820
  }
48821
+ if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
48822
+ if (socket[kIdleSocketValidation] === 0) {
48823
+ scheduleIdleSocketValidation(client, socket);
48824
+ socket[kParser].readMore();
48825
+ if (socket.destroyed) return;
48826
+ return;
48827
+ }
48828
+ if (socket[kIdleSocketValidation] === 1) {
48829
+ socket[kParser].readMore();
48830
+ if (socket.destroyed) return;
48831
+ return;
48832
+ }
48833
+ }
48834
+ if (client[kRunning] === 0) {
48835
+ socket[kParser].readMore();
48836
+ if (socket.destroyed) return;
48837
+ }
48615
48838
  if (client[kSize] === 0) {
48616
48839
  if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
48617
48840
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
@@ -48655,6 +48878,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
48655
48878
  process.emitWarning(new RequestContentLengthMismatchError());
48656
48879
  }
48657
48880
  const socket = client[kSocket];
48881
+ clearIdleSocketValidation(socket);
48658
48882
  /**
48659
48883
  * @param {Error} [err]
48660
48884
  * @returns {void}
@@ -49519,7 +49743,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49519
49743
  //#region ../../node_modules/undici/lib/dispatcher/client.js
49520
49744
  var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49521
49745
  const assert$27 = require("node:assert");
49522
- const net$4 = require("node:net");
49746
+ const net$3 = require("node:net");
49523
49747
  const http$4 = require("node:http");
49524
49748
  const util = require_util$8();
49525
49749
  const { ClientStats } = require_stats();
@@ -49548,7 +49772,7 @@ var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49548
49772
  * @param {string|URL} url
49549
49773
  * @param {import('../../types/client.js').Client.Options} options
49550
49774
  */
49551
- 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 } = {}) {
49775
+ 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 } = {}) {
49552
49776
  if (keepAlive !== void 0) throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
49553
49777
  if (socketTimeout !== void 0) throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
49554
49778
  if (requestTimeout !== void 0) throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
@@ -49566,7 +49790,7 @@ var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49566
49790
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
49567
49791
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
49568
49792
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
49569
- if (localAddress != null && (typeof localAddress !== "string" || net$4.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
49793
+ if (localAddress != null && (typeof localAddress !== "string" || net$3.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
49570
49794
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) throw new InvalidArgumentError("maxResponseSize must be a positive number");
49571
49795
  if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
49572
49796
  if (allowH2 != null && typeof allowH2 !== "boolean") throw new InvalidArgumentError("allowH2 must be a valid boolean value");
@@ -49575,7 +49799,7 @@ var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49575
49799
  if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
49576
49800
  if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
49577
49801
  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");
49578
- super();
49802
+ super({ webSocket });
49579
49803
  if (typeof connect !== "function") connect = buildConnector({
49580
49804
  ...tls,
49581
49805
  maxCachedSessions,
@@ -49589,11 +49813,12 @@ var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49589
49813
  } : void 0,
49590
49814
  ...connect
49591
49815
  });
49592
- else if (socketPath != null) {
49816
+ else {
49593
49817
  const customConnect = connect;
49594
49818
  connect = (opts, callback) => customConnect({
49595
49819
  ...opts,
49596
- socketPath
49820
+ ...socketPath != null ? { socketPath } : null,
49821
+ ...allowH2 != null ? { allowH2 } : null
49597
49822
  }, callback);
49598
49823
  }
49599
49824
  this[kUrl] = util.parseOrigin(url);
@@ -49716,7 +49941,7 @@ var require_client$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49716
49941
  const idx = hostname.indexOf("]");
49717
49942
  assert$27(idx !== -1);
49718
49943
  const ip = hostname.substring(1, idx);
49719
- assert$27(net$4.isIPv6(ip));
49944
+ assert$27(net$3.isIPv6(ip));
49720
49945
  hostname = ip;
49721
49946
  }
49722
49947
  client[kConnecting] = true;
@@ -50138,7 +50363,7 @@ var require_pool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50138
50363
  } : void 0,
50139
50364
  ...connect
50140
50365
  });
50141
- super();
50366
+ super(options);
50142
50367
  this[kConnections] = connections || null;
50143
50368
  this[kUrl] = util.parseOrigin(origin);
50144
50369
  this[kOptions] = {
@@ -50212,7 +50437,7 @@ var require_balanced_pool = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50212
50437
  var BalancedPool = class extends PoolBase {
50213
50438
  constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
50214
50439
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50215
- super();
50440
+ super(opts);
50216
50441
  this[kOptions] = { ...util.deepClone(opts) };
50217
50442
  this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
50218
50443
  this[kIndex] = -1;
@@ -50397,7 +50622,7 @@ var require_agent$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50397
50622
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
50398
50623
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
50399
50624
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
50400
- super();
50625
+ super(options);
50401
50626
  if (connect && typeof connect !== "function") connect = { ...connect };
50402
50627
  this[kOptions] = {
50403
50628
  ...util.deepClone(options),
@@ -50487,7 +50712,7 @@ var require_agent$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50487
50712
  //#region ../../node_modules/undici/lib/core/socks5-utils.js
50488
50713
  var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50489
50714
  const { Buffer: Buffer$6 } = require("node:buffer");
50490
- const net$3 = require("node:net");
50715
+ const net$2 = require("node:net");
50491
50716
  const { InvalidArgumentError } = require_errors$3();
50492
50717
  /**
50493
50718
  * Parse an address and determine its type
@@ -50495,14 +50720,14 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50495
50720
  * @returns {{type: number, buffer: Buffer}} Address type and buffer
50496
50721
  */
50497
50722
  function parseAddress(address) {
50498
- if (net$3.isIPv4(address)) {
50723
+ if (net$2.isIPv4(address)) {
50499
50724
  const parts = address.split(".").map(Number);
50500
50725
  return {
50501
50726
  type: 1,
50502
50727
  buffer: Buffer$6.from(parts)
50503
50728
  };
50504
50729
  }
50505
- if (net$3.isIPv6(address)) return {
50730
+ if (net$2.isIPv6(address)) return {
50506
50731
  type: 4,
50507
50732
  buffer: parseIPv6(address)
50508
50733
  };
@@ -50520,23 +50745,36 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50520
50745
  */
50521
50746
  function parseIPv6(address) {
50522
50747
  const buffer = Buffer$6.alloc(16);
50523
- const parts = address.split(":");
50524
- let partIndex = 0;
50525
- let bufferIndex = 0;
50526
- const doubleColonIndex = address.indexOf("::");
50748
+ let normalizedAddress = address;
50749
+ if (address.includes(".")) {
50750
+ const lastColonIndex = address.lastIndexOf(":");
50751
+ const ipv4Part = address.slice(lastColonIndex + 1);
50752
+ if (net$2.isIPv4(ipv4Part)) {
50753
+ const octets = ipv4Part.split(".").map(Number);
50754
+ const high = (octets[0] << 8 | octets[1]).toString(16);
50755
+ const low = (octets[2] << 8 | octets[3]).toString(16);
50756
+ normalizedAddress = `${address.slice(0, lastColonIndex)}:${high}:${low}`;
50757
+ }
50758
+ }
50759
+ const doubleColonIndex = normalizedAddress.indexOf("::");
50527
50760
  if (doubleColonIndex !== -1) {
50528
- const skipParts = 8 - parts.filter((p) => p.length > 0).length;
50529
- for (let i = 0; i < parts.length; i++) if (parts[i] === "" && i === doubleColonIndex / 3) bufferIndex += skipParts * 2;
50530
- else if (parts[i] !== "") {
50531
- const value = parseInt(parts[i], 16);
50532
- buffer.writeUInt16BE(value, bufferIndex);
50761
+ const before = normalizedAddress.slice(0, doubleColonIndex);
50762
+ const after = normalizedAddress.slice(doubleColonIndex + 2);
50763
+ const beforeParts = before === "" ? [] : before.split(":");
50764
+ const afterParts = after === "" ? [] : after.split(":");
50765
+ let bufferIndex = 0;
50766
+ for (const part of beforeParts) {
50767
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
50768
+ bufferIndex += 2;
50769
+ }
50770
+ bufferIndex = 16 - afterParts.length * 2;
50771
+ for (const part of afterParts) {
50772
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
50533
50773
  bufferIndex += 2;
50534
50774
  }
50535
- } else for (const part of parts) {
50536
- if (part === "") continue;
50537
- const value = parseInt(part, 16);
50538
- buffer.writeUInt16BE(value, partIndex * 2);
50539
- partIndex++;
50775
+ } else {
50776
+ const parts = normalizedAddress.split(":");
50777
+ for (let i = 0; i < parts.length; i++) buffer.writeUInt16BE(parseInt(parts[i], 16), i * 2);
50540
50778
  }
50541
50779
  return buffer;
50542
50780
  }
@@ -50641,6 +50879,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50641
50879
  const { debuglog: debuglog$1 } = require("node:util");
50642
50880
  const { parseAddress } = require_socks5_utils();
50643
50881
  const debug = debuglog$1("undici:socks5");
50882
+ const EMPTY_BUFFER = Buffer$5.alloc(0);
50644
50883
  const SOCKS_VERSION = 5;
50645
50884
  const AUTH_METHODS = {
50646
50885
  NO_AUTH: 0,
@@ -50673,6 +50912,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50673
50912
  INITIAL: "initial",
50674
50913
  HANDSHAKING: "handshaking",
50675
50914
  AUTHENTICATING: "authenticating",
50915
+ AUTHENTICATED: "authenticated",
50676
50916
  CONNECTING: "connecting",
50677
50917
  CONNECTED: "connected",
50678
50918
  ERROR: "error",
@@ -50689,13 +50929,16 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50689
50929
  this.socket = socket;
50690
50930
  this.options = options;
50691
50931
  this.state = STATES.INITIAL;
50692
- this.buffer = Buffer$5.alloc(0);
50932
+ this.buffer = EMPTY_BUFFER;
50933
+ this.onSocketData = this.onData.bind(this);
50934
+ this.onSocketError = this.onError.bind(this);
50935
+ this.onSocketClose = this.onClose.bind(this);
50693
50936
  this.authMethods = [];
50694
50937
  if (options.username && options.password) this.authMethods.push(AUTH_METHODS.USERNAME_PASSWORD);
50695
50938
  this.authMethods.push(AUTH_METHODS.NO_AUTH);
50696
- this.socket.on("data", this.onData.bind(this));
50697
- this.socket.on("error", this.onError.bind(this));
50698
- this.socket.on("close", this.onClose.bind(this));
50939
+ this.socket.on("data", this.onSocketData);
50940
+ this.socket.on("error", this.onSocketError);
50941
+ this.socket.on("close", this.onSocketClose);
50699
50942
  }
50700
50943
  /**
50701
50944
  * Handle incoming data from the socket
@@ -50742,6 +50985,10 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50742
50985
  destroy() {
50743
50986
  if (this.socket && !this.socket.destroyed) this.socket.destroy();
50744
50987
  }
50988
+ markAuthenticated() {
50989
+ this.state = STATES.AUTHENTICATED;
50990
+ this.emit("authenticated");
50991
+ }
50745
50992
  /**
50746
50993
  * Start the SOCKS5 handshake
50747
50994
  */
@@ -50768,7 +51015,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50768
51015
  if (method === AUTH_METHODS.NO_ACCEPTABLE) throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
50769
51016
  this.buffer = this.buffer.subarray(2);
50770
51017
  debug("server selected auth method", method);
50771
- if (method === AUTH_METHODS.NO_AUTH) this.emit("authenticated");
51018
+ if (method === AUTH_METHODS.NO_AUTH) this.markAuthenticated();
50772
51019
  else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
50773
51020
  this.state = STATES.AUTHENTICATING;
50774
51021
  this.sendAuthRequest();
@@ -50803,7 +51050,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50803
51050
  if (status !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
50804
51051
  this.buffer = this.buffer.subarray(2);
50805
51052
  debug("authentication successful");
50806
- this.emit("authenticated");
51053
+ this.markAuthenticated();
50807
51054
  }
50808
51055
  /**
50809
51056
  * Send CONNECT command
@@ -50811,7 +51058,8 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50811
51058
  * @param {number} port - Target port
50812
51059
  */
50813
51060
  connect(address, port) {
50814
- if (this.state === STATES.CONNECTED) throw new InvalidArgumentError("Already connected");
51061
+ if (this.state === STATES.CONNECTING || this.state === STATES.CONNECTED) throw new InvalidArgumentError("Connection already in progress");
51062
+ if (this.state !== STATES.AUTHENTICATED) throw new InvalidArgumentError("Client must be authenticated before CONNECT");
50815
51063
  debug("connecting to", address, port);
50816
51064
  this.state = STATES.CONNECTING;
50817
51065
  const request = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
@@ -50869,8 +51117,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50869
51117
  offset += 16;
50870
51118
  }
50871
51119
  const boundPort = this.buffer.readUInt16BE(offset);
50872
- this.buffer = this.buffer.subarray(responseLength);
51120
+ this.buffer = EMPTY_BUFFER;
50873
51121
  this.state = STATES.CONNECTED;
51122
+ this.socket.removeListener("data", this.onSocketData);
50874
51123
  debug("connected, bound address:", boundAddress, "port:", boundPort);
50875
51124
  this.emit("connected", {
50876
51125
  address: boundAddress,
@@ -50906,12 +51155,11 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
50906
51155
  //#endregion
50907
51156
  //#region ../../node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
50908
51157
  var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50909
- const net$2 = require("node:net");
50910
51158
  const { URL: URL$2 } = require("node:url");
50911
51159
  let tls;
50912
51160
  const DispatcherBase = require_dispatcher_base();
50913
51161
  const { InvalidArgumentError } = require_errors$3();
50914
- const { Socks5Client } = require_socks5_client();
51162
+ const { Socks5Client, STATES } = require_socks5_client();
50915
51163
  const { kDispatch, kClose, kDestroy } = require_symbols();
50916
51164
  const Pool = require_pool();
50917
51165
  const buildConnector = require_connect$1();
@@ -50920,8 +51168,10 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50920
51168
  const kProxyUrl = Symbol("proxy url");
50921
51169
  const kProxyHeaders = Symbol("proxy headers");
50922
51170
  const kProxyAuth = Symbol("proxy auth");
50923
- const kPool = Symbol("pool");
51171
+ const kProxyProtocol = Symbol("proxy protocol");
51172
+ const kPools = Symbol("pools");
50924
51173
  const kConnector = Symbol("connector");
51174
+ const kRequestTls = Symbol("request tls settings");
50925
51175
  let experimentalWarningEmitted = false;
50926
51176
  /**
50927
51177
  * SOCKS5 proxy agent for dispatching requests through a SOCKS5 proxy
@@ -50938,6 +51188,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50938
51188
  if (url.protocol !== "socks5:" && url.protocol !== "socks:") throw new InvalidArgumentError("Proxy URL must use socks5:// or socks:// protocol");
50939
51189
  this[kProxyUrl] = url;
50940
51190
  this[kProxyHeaders] = options.headers || {};
51191
+ this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
51192
+ this[kRequestTls] = options.requestTls;
50941
51193
  this[kProxyAuth] = {
50942
51194
  username: options.username || (url.username ? decodeURIComponent(url.username) : null),
50943
51195
  password: options.password || (url.password ? decodeURIComponent(url.password) : null)
@@ -50946,7 +51198,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50946
51198
  ...options.proxyTls,
50947
51199
  servername: options.proxyTls?.servername || url.hostname
50948
51200
  });
50949
- this[kPool] = null;
51201
+ this[kPools] = /* @__PURE__ */ new Map();
50950
51202
  }
50951
51203
  /**
50952
51204
  * Create a SOCKS5 connection to the proxy
@@ -50956,20 +51208,15 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50956
51208
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
50957
51209
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
50958
51210
  const socket = await new Promise((resolve, reject) => {
50959
- const onConnect = () => {
50960
- socket.removeListener("error", onError);
50961
- resolve(socket);
50962
- };
50963
- const onError = (err) => {
50964
- socket.removeListener("connect", onConnect);
50965
- reject(err);
50966
- };
50967
- const socket = net$2.connect({
51211
+ this[kConnector]({
51212
+ hostname: proxyHost,
50968
51213
  host: proxyHost,
50969
- port: proxyPort
51214
+ port: proxyPort,
51215
+ protocol: this[kProxyProtocol]
51216
+ }, (err, socket) => {
51217
+ if (err) reject(err);
51218
+ else resolve(socket);
50970
51219
  });
50971
- socket.once("connect", onConnect);
50972
- socket.once("error", onError);
50973
51220
  });
50974
51221
  const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
50975
51222
  socks5Client.on("error", (err) => {
@@ -50991,7 +51238,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
50991
51238
  socks5Client.removeListener("authenticated", onAuthenticated);
50992
51239
  reject(err);
50993
51240
  };
50994
- if (socks5Client.state === "authenticated") {
51241
+ if (socks5Client.state === STATES.AUTHENTICATED) {
50995
51242
  clearTimeout(timeout);
50996
51243
  resolve();
50997
51244
  } else {
@@ -51023,53 +51270,69 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
51023
51270
  /**
51024
51271
  * Dispatch a request through the SOCKS5 proxy
51025
51272
  */
51026
- async [kDispatch](opts, handler) {
51273
+ [kDispatch](opts, handler) {
51027
51274
  const { origin } = opts;
51028
51275
  debug("dispatching request to", origin, "via SOCKS5");
51029
51276
  try {
51030
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) this[kPool] = new Pool(origin, {
51031
- pipelining: opts.pipelining,
51032
- connections: opts.connections,
51033
- connect: async (connectOpts, callback) => {
51034
- try {
51035
- const url = new URL$2(origin);
51036
- const targetHost = url.hostname;
51037
- const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
51038
- debug("establishing SOCKS5 connection to", targetHost, targetPort);
51039
- const socket = await this.createSocks5Connection(targetHost, targetPort);
51040
- let finalSocket = socket;
51041
- if (url.protocol === "https:") {
51042
- if (!tls) tls = require("node:tls");
51043
- debug("upgrading to TLS");
51044
- finalSocket = tls.connect({
51045
- socket,
51046
- servername: targetHost,
51047
- ...connectOpts.tls || {}
51048
- });
51049
- await new Promise((resolve, reject) => {
51050
- finalSocket.once("secureConnect", resolve);
51051
- finalSocket.once("error", reject);
51052
- });
51277
+ const originKey = String(origin);
51278
+ let pool = this[kPools].get(originKey);
51279
+ if (!pool || pool.destroyed || pool.closed) {
51280
+ pool = new Pool(origin, {
51281
+ pipelining: opts.pipelining,
51282
+ connections: opts.connections,
51283
+ connect: async (connectOpts, callback) => {
51284
+ try {
51285
+ const url = new URL$2(origin);
51286
+ const targetHost = url.hostname;
51287
+ const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
51288
+ debug("establishing SOCKS5 connection to", targetHost, targetPort);
51289
+ const socket = await this.createSocks5Connection(targetHost, targetPort);
51290
+ let finalSocket = socket;
51291
+ if (url.protocol === "https:") {
51292
+ if (!tls) tls = require("node:tls");
51293
+ debug("upgrading to TLS");
51294
+ finalSocket = tls.connect({
51295
+ ...this[kRequestTls],
51296
+ socket,
51297
+ servername: this[kRequestTls]?.servername || targetHost
51298
+ });
51299
+ await new Promise((resolve, reject) => {
51300
+ finalSocket.once("secureConnect", resolve);
51301
+ finalSocket.once("error", reject);
51302
+ });
51303
+ }
51304
+ callback(null, finalSocket);
51305
+ } catch (err) {
51306
+ debug("SOCKS5 connection error:", err);
51307
+ callback(err);
51053
51308
  }
51054
- callback(null, finalSocket);
51055
- } catch (err) {
51056
- debug("SOCKS5 connection error:", err);
51057
- callback(err);
51058
51309
  }
51059
- }
51060
- });
51061
- return this[kPool][kDispatch](opts, handler);
51310
+ });
51311
+ this[kPools].set(originKey, pool);
51312
+ }
51313
+ return pool[kDispatch](opts, handler);
51062
51314
  } catch (err) {
51063
51315
  debug("dispatch error:", err);
51064
- if (typeof handler.onError === "function") handler.onError(err);
51065
- else throw err;
51316
+ if (typeof handler.onResponseError === "function") {
51317
+ handler.onResponseError(null, err);
51318
+ return false;
51319
+ } else if (typeof handler.onError === "function") {
51320
+ handler.onError(err);
51321
+ return false;
51322
+ } else throw err;
51066
51323
  }
51067
51324
  }
51068
51325
  async [kClose]() {
51069
- if (this[kPool]) await this[kPool].close();
51326
+ const closePromises = [];
51327
+ for (const pool of this[kPools].values()) closePromises.push(pool.close());
51328
+ this[kPools].clear();
51329
+ await Promise.all(closePromises);
51070
51330
  }
51071
51331
  async [kDestroy](err) {
51072
- if (this[kPool]) await this[kPool].destroy(err);
51332
+ const destroyPromises = [];
51333
+ for (const pool of this[kPools].values()) destroyPromises.push(pool.destroy(err));
51334
+ this[kPools].clear();
51335
+ await Promise.all(destroyPromises);
51073
51336
  }
51074
51337
  };
51075
51338
  module.exports = Socks5ProxyAgent;
@@ -51173,7 +51436,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51173
51436
  factory: agentFactory,
51174
51437
  username: opts.username || username,
51175
51438
  password: opts.password || password,
51176
- proxyTls: opts.proxyTls
51439
+ proxyTls: opts.proxyTls,
51440
+ requestTls: opts.requestTls
51177
51441
  });
51178
51442
  if (!this[kTunnelProxy] && protocol === "http:" && this[kProxy].protocol === "http:") return new Http1ProxyWrapper(this[kProxy].uri, {
51179
51443
  headers: this[kProxyHeaders],
@@ -51681,7 +51945,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
51681
51945
  constructor(origin, clientOpts) {
51682
51946
  if (typeof origin === "string") origin = new URL(origin);
51683
51947
  if (origin.protocol !== "http:") throw new InvalidArgumentError("h2c-client: Only h2c protocol is supported");
51684
- const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51948
+ const { maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
51685
51949
  let defaultMaxConcurrentStreams = 100;
51686
51950
  let defaultPipelining = 100;
51687
51951
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) defaultMaxConcurrentStreams = maxConcurrentStreams;
@@ -52126,7 +52390,7 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
52126
52390
  const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
52127
52391
  try {
52128
52392
  if (typeof callback !== "function") throw new InvalidArgumentError("invalid callback");
52129
- if (highWaterMark && (typeof highWaterMark !== "number" || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
52393
+ if (highWaterMark != null && (!Number.isFinite(highWaterMark) || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
52130
52394
  if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
52131
52395
  if (method === "CONNECT") throw new InvalidArgumentError("invalid method");
52132
52396
  if (onInfo && typeof onInfo !== "function") throw new InvalidArgumentError("invalid onInfo callback");
@@ -53312,12 +53576,12 @@ var require_mock_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53312
53576
  var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53313
53577
  const { kMockCallHistoryAddLog } = require_mock_symbols();
53314
53578
  const { InvalidArgumentError } = require_errors$3();
53315
- function handleFilterCallsWithOptions(criteria, options, handler, store) {
53579
+ function handleFilterCallsWithOptions(criteria, options, handler, store, allLogs) {
53316
53580
  switch (options.operator) {
53317
53581
  case "OR":
53318
- store.push(...handler(criteria));
53582
+ store.push(...handler(criteria, allLogs));
53319
53583
  return store;
53320
- case "AND": return handler.call({ logs: store }, criteria);
53584
+ case "AND": return handler(criteria, store);
53321
53585
  default: throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
53322
53586
  }
53323
53587
  }
@@ -53333,11 +53597,11 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53333
53597
  return finalOptions;
53334
53598
  }
53335
53599
  function makeFilterCalls(parameterName) {
53336
- return (parameterValue) => {
53337
- if (typeof parameterValue === "string" || parameterValue == null) return this.logs.filter((log) => {
53600
+ return (parameterValue, logs) => {
53601
+ if (typeof parameterValue === "string" || parameterValue == null) return logs.filter((log) => {
53338
53602
  return log[parameterName] === parameterValue;
53339
53603
  });
53340
- if (parameterValue instanceof RegExp) return this.logs.filter((log) => {
53604
+ if (parameterValue instanceof RegExp) return logs.filter((log) => {
53341
53605
  return parameterValue.test(log[parameterName]);
53342
53606
  });
53343
53607
  throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
@@ -53425,15 +53689,15 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
53425
53689
  operator: "OR",
53426
53690
  ...buildAndValidateFilterCallsOptions(options)
53427
53691
  };
53428
- let maybeDuplicatedLogsFiltered = [];
53429
- if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
53430
- if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
53431
- if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
53432
- if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
53433
- if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
53434
- if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
53435
- if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
53436
- if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered);
53692
+ let maybeDuplicatedLogsFiltered = finalOptions.operator === "AND" ? this.logs : [];
53693
+ if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered, this.logs);
53694
+ if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered, this.logs);
53695
+ if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered, this.logs);
53696
+ if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered, this.logs);
53697
+ if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered, this.logs);
53698
+ if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered, this.logs);
53699
+ if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered, this.logs);
53700
+ if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered, this.logs);
53437
53701
  return [...new Set(maybeDuplicatedLogsFiltered)];
53438
53702
  }
53439
53703
  throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
@@ -54482,7 +54746,8 @@ var require_snapshot_agent = /* @__PURE__ */ __commonJSMin(((exports, module) =>
54482
54746
  //#endregion
54483
54747
  //#region ../../node_modules/undici/lib/global.js
54484
54748
  var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54485
- const globalDispatcher = Symbol.for("undici.globalDispatcher.1");
54749
+ const globalDispatcher = Symbol.for("undici.globalDispatcher.2");
54750
+ const legacyGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");
54486
54751
  const { InvalidArgumentError } = require_errors$3();
54487
54752
  const Agent = require_agent$1();
54488
54753
  if (getGlobalDispatcher() === void 0) setGlobalDispatcher(new Agent());
@@ -54494,9 +54759,15 @@ var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
54494
54759
  enumerable: false,
54495
54760
  configurable: false
54496
54761
  });
54762
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
54763
+ value: agent,
54764
+ writable: true,
54765
+ enumerable: false,
54766
+ configurable: false
54767
+ });
54497
54768
  }
54498
54769
  function getGlobalDispatcher() {
54499
- return globalThis[globalDispatcher];
54770
+ return globalThis[legacyGlobalDispatcher];
54500
54771
  }
54501
54772
  module.exports = {
54502
54773
  setGlobalDispatcher,
@@ -55195,7 +55466,7 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55195
55466
  function makeCacheKey(opts) {
55196
55467
  if (!opts.origin) throw new Error("opts.origin is undefined");
55197
55468
  let fullPath = opts.path || "/";
55198
- if (opts.query && !pathHasQueryOrFragment(opts.path)) fullPath = serializePathWithQuery(fullPath, opts.query);
55469
+ if (opts.query && !pathHasQueryOrFragment(fullPath)) fullPath = serializePathWithQuery(fullPath, opts.query);
55199
55470
  return {
55200
55471
  origin: opts.origin.toString(),
55201
55472
  method: opts.method,
@@ -55311,11 +55582,15 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55311
55582
  lastHeader = lastHeader.substring(0, lastHeader.length - 1);
55312
55583
  headers[headers.length - 1] = lastHeader;
55313
55584
  }
55585
+ for (let j = 0; j < headers.length; j++) headers[j] = headers[j].trim();
55314
55586
  if (key in output) output[key] = output[key].concat(headers);
55315
55587
  else output[key] = headers;
55316
55588
  }
55317
- } else if (key in output) output[key] = output[key].concat(value);
55318
- else output[key] = [value];
55589
+ } else {
55590
+ const fieldName = value.trim();
55591
+ if (key in output) output[key] = output[key].concat(fieldName);
55592
+ else output[key] = [fieldName];
55593
+ }
55319
55594
  break;
55320
55595
  }
55321
55596
  case "public":
@@ -55393,16 +55668,20 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
55393
55668
  * @returns {string}
55394
55669
  */
55395
55670
  function makeDeduplicationKey(cacheKey, excludeHeaders) {
55396
- let key = `${cacheKey.origin}:${cacheKey.method}:${cacheKey.path}`;
55671
+ const headers = {};
55397
55672
  if (cacheKey.headers) {
55398
55673
  const sortedHeaders = Object.keys(cacheKey.headers).sort();
55399
55674
  for (const header of sortedHeaders) {
55400
55675
  if (excludeHeaders?.has(header.toLowerCase())) continue;
55401
- const value = cacheKey.headers[header];
55402
- key += `:${header}=${Array.isArray(value) ? value.join(",") : value}`;
55676
+ headers[header] = cacheKey.headers[header];
55403
55677
  }
55404
55678
  }
55405
- return key;
55679
+ return JSON.stringify([
55680
+ cacheKey.origin,
55681
+ cacheKey.method,
55682
+ cacheKey.path,
55683
+ headers
55684
+ ]);
55406
55685
  }
55407
55686
  module.exports = {
55408
55687
  makeCacheKey,
@@ -57341,7 +57620,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57341
57620
  SELECT
57342
57621
  id
57343
57622
  FROM cacheInterceptorV${VERSION}
57344
- ORDER BY cachedAt DESC
57623
+ ORDER BY cachedAt ASC
57345
57624
  LIMIT ?
57346
57625
  )
57347
57626
  `);
@@ -57382,8 +57661,8 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57382
57661
  const existingValue = this.#findValue(key, true);
57383
57662
  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);
57384
57663
  else {
57385
- this.#prune();
57386
57664
  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);
57665
+ this.#prune();
57387
57666
  }
57388
57667
  }
57389
57668
  /**
@@ -57466,7 +57745,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
57466
57745
  if (values.length === 0) return;
57467
57746
  const now = Date.now();
57468
57747
  for (const value of values) {
57469
- if (now >= value.deleteAt && !canBeExpired) return;
57748
+ if (now >= value.deleteAt && !canBeExpired) continue;
57470
57749
  let matches = true;
57471
57750
  if (value.vary) {
57472
57751
  const vary = JSON.parse(value.vary);
@@ -57896,7 +58175,7 @@ var require_response = /* @__PURE__ */ __commonJSMin(((exports, module) => {
57896
58175
  const nodeUtil$1 = require("node:util");
57897
58176
  const { kEnumerableProperty } = util;
57898
58177
  const { isValidReasonPhrase, isCancelled, isAborted, isErrorLike, environmentSettingsObject: relevantRealm } = require_util$7();
57899
- const { redirectStatusSet, nullBodyStatus } = require_constants$6();
58178
+ const { redirectStatusSet, nullBodyStatus } = require_constants$5();
57900
58179
  const { webidl } = require_webidl();
57901
58180
  const { URLSerializer } = require_data_url();
57902
58181
  const { kConstruct } = require_symbols();
@@ -58240,7 +58519,7 @@ var require_request$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58240
58519
  const util = require_util$8();
58241
58520
  const nodeUtil = require("node:util");
58242
58521
  const { isValidHTTPToken, sameOrigin, environmentSettingsObject } = require_util$7();
58243
- const { forbiddenMethodsSet, corsSafeListedMethodsSet, referrerPolicy, requestRedirect, requestMode, requestCredentials, requestCache, requestDuplex } = require_constants$6();
58522
+ const { forbiddenMethodsSet, corsSafeListedMethodsSet, referrerPolicy, requestRedirect, requestMode, requestCredentials, requestCache, requestDuplex } = require_constants$5();
58244
58523
  const { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util;
58245
58524
  const { webidl } = require_webidl();
58246
58525
  const { URLSerializer } = require_data_url();
@@ -58997,7 +59276,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
58997
59276
  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$7();
58998
59277
  const assert$11 = require("node:assert");
58999
59278
  const { safelyExtractBody, extractBody } = require_body();
59000
- const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$6();
59279
+ const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$5();
59001
59280
  const EE$1 = require("node:events");
59002
59281
  const { Readable: Readable$1, pipeline: pipeline$2, finished, isErrored, isReadable } = require("node:stream");
59003
59282
  const { addAbortListener, bufferToLowerCasedHeaderName } = require_util$8();
@@ -59296,7 +59575,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59296
59575
  cacheState = "";
59297
59576
  }
59298
59577
  let responseStatus = 0;
59299
- if (fetchParams.request.mode !== "navigator" || !response.hasCrossOriginRedirects) {
59578
+ if (fetchParams.request.mode !== "navigate" || !response.hasCrossOriginRedirects) {
59300
59579
  responseStatus = response.status;
59301
59580
  const mimeType = extractMimeType(response.headersList);
59302
59581
  if (mimeType !== "failure") bodyInfo.contentType = minimizeSupportedMimeType(mimeType);
@@ -59400,7 +59679,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59400
59679
  let contentLengthHeaderValue = null;
59401
59680
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) contentLengthHeaderValue = "0";
59402
59681
  if (contentLength != null) contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
59403
- if (contentLengthHeaderValue != null) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
59682
+ if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
59404
59683
  if (contentLength != null && httpRequest.keepalive) {}
59405
59684
  if (webidl.is.URL(httpRequest.referrer)) httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
59406
59685
  appendRequestOriginHeader(httpRequest);
@@ -60313,7 +60592,7 @@ var require_cachestorage = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60313
60592
  }));
60314
60593
  //#endregion
60315
60594
  //#region ../../node_modules/undici/lib/web/cookies/constants.js
60316
- var require_constants$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60595
+ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60317
60596
  module.exports = {
60318
60597
  maxAttributeValueSize: 1024,
60319
60598
  maxNameValuePairSize: 4096
@@ -60517,10 +60796,9 @@ var require_util$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60517
60796
  //#region ../../node_modules/undici/lib/web/cookies/parse.js
60518
60797
  var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60519
60798
  const { collectASequenceOfCodePointsFast } = require_infra();
60520
- const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$5();
60799
+ const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$4();
60521
60800
  const { isCTLExcludingHtab } = require_util$5();
60522
60801
  const assert$8 = require("node:assert");
60523
- const { unescape: qsUnescape } = require("node:querystring");
60524
60802
  /**
60525
60803
  * @description Parses the field-value attributes of a set-cookie header string.
60526
60804
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4
@@ -60549,7 +60827,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60549
60827
  if (name.length + value.length > maxNameValuePairSize) return null;
60550
60828
  return {
60551
60829
  name,
60552
- value: qsUnescape(value),
60830
+ value,
60553
60831
  ...parseUnparsedAttributes(unparsedAttributes)
60554
60832
  };
60555
60833
  }
@@ -60601,12 +60879,10 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
60601
60879
  } else if (attributeNameLowercase === "secure") cookieAttributeList.secure = true;
60602
60880
  else if (attributeNameLowercase === "httponly") cookieAttributeList.httpOnly = true;
60603
60881
  else if (attributeNameLowercase === "samesite") {
60604
- let enforcement = "Default";
60605
60882
  const attributeValueLowercase = attributeValue.toLowerCase();
60606
- if (attributeValueLowercase.includes("none")) enforcement = "None";
60607
- if (attributeValueLowercase.includes("strict")) enforcement = "Strict";
60608
- if (attributeValueLowercase.includes("lax")) enforcement = "Lax";
60609
- cookieAttributeList.sameSite = enforcement;
60883
+ if (attributeValueLowercase === "none") cookieAttributeList.sameSite = "None";
60884
+ else if (attributeValueLowercase === "strict") cookieAttributeList.sameSite = "Strict";
60885
+ else if (attributeValueLowercase === "lax") cookieAttributeList.sameSite = "Lax";
60610
60886
  } else {
60611
60887
  cookieAttributeList.unparsed ??= [];
60612
60888
  cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
@@ -61044,7 +61320,7 @@ var require_events$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61044
61320
  }));
61045
61321
  //#endregion
61046
61322
  //#region ../../node_modules/undici/lib/web/websocket/constants.js
61047
- var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61323
+ var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61048
61324
  module.exports = {
61049
61325
  uid: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
61050
61326
  sentCloseFrameState: {
@@ -61089,7 +61365,7 @@ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61089
61365
  //#endregion
61090
61366
  //#region ../../node_modules/undici/lib/web/websocket/util.js
61091
61367
  var require_util$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61092
- const { states, opcodes } = require_constants$4();
61368
+ const { states, opcodes } = require_constants$3();
61093
61369
  const { isUtf8 } = require("node:buffer");
61094
61370
  const { removeHTTPWhitespace } = require_data_url();
61095
61371
  const { collectASequenceOfCodePointsFast } = require_infra();
@@ -61296,7 +61572,7 @@ var require_util$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61296
61572
  //#region ../../node_modules/undici/lib/web/websocket/frame.js
61297
61573
  var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61298
61574
  const { runtimeFeatures } = require_runtime_features();
61299
- const { maxUnsigned16Bit, opcodes } = require_constants$4();
61575
+ const { maxUnsigned16Bit, opcodes } = require_constants$3();
61300
61576
  const BUFFER_SIZE = 8 * 1024;
61301
61577
  let buffer = null;
61302
61578
  let bufIdx = BUFFER_SIZE;
@@ -61394,7 +61670,7 @@ var require_frame = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61394
61670
  //#endregion
61395
61671
  //#region ../../node_modules/undici/lib/web/websocket/connection.js
61396
61672
  var require_connection = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61397
- const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$4();
61673
+ const { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants$3();
61398
61674
  const { parseExtensions, isClosed, isClosing, isEstablished, isConnecting, validateCloseCodeAndReason } = require_util$4();
61399
61675
  const { makeRequest } = require_request$1();
61400
61676
  const { fetching } = require_fetch();
@@ -61555,27 +61831,26 @@ var require_permessage_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports, modu
61555
61831
  ]);
61556
61832
  const kBuffer = Symbol("kBuffer");
61557
61833
  const kLength = Symbol("kLength");
61558
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024;
61559
61834
  var PerMessageDeflate = class {
61560
61835
  /** @type {import('node:zlib').InflateRaw} */
61561
61836
  #inflate;
61562
61837
  #options = {};
61563
- /** @type {boolean} */
61564
- #aborted = false;
61565
- /** @type {Function|null} */
61566
- #currentCallback = null;
61838
+ #maxPayloadSize = 0;
61567
61839
  /**
61568
61840
  * @param {Map<string, string>} extensions
61569
61841
  */
61570
- constructor(extensions) {
61842
+ constructor(extensions, options) {
61571
61843
  this.#options.serverNoContextTakeover = extensions.has("server_no_context_takeover");
61572
61844
  this.#options.serverMaxWindowBits = extensions.get("server_max_window_bits");
61845
+ this.#maxPayloadSize = options.maxPayloadSize;
61573
61846
  }
61847
+ /**
61848
+ * Decompress a compressed payload.
61849
+ * @param {Buffer} chunk Compressed data
61850
+ * @param {boolean} fin Final fragment flag
61851
+ * @param {Function} callback Callback function
61852
+ */
61574
61853
  decompress(chunk, fin, callback) {
61575
- if (this.#aborted) {
61576
- callback(new MessageSizeExceededError());
61577
- return;
61578
- }
61579
61854
  if (!this.#inflate) {
61580
61855
  let windowBits = Z_DEFAULT_WINDOWBITS$1;
61581
61856
  if (this.#options.serverMaxWindowBits) {
@@ -61594,18 +61869,11 @@ var require_permessage_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports, modu
61594
61869
  this.#inflate[kBuffer] = [];
61595
61870
  this.#inflate[kLength] = 0;
61596
61871
  this.#inflate.on("data", (data) => {
61597
- if (this.#aborted) return;
61598
61872
  this.#inflate[kLength] += data.length;
61599
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
61600
- this.#aborted = true;
61873
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
61874
+ callback(new MessageSizeExceededError());
61601
61875
  this.#inflate.removeAllListeners();
61602
- this.#inflate.destroy();
61603
61876
  this.#inflate = null;
61604
- if (this.#currentCallback) {
61605
- const cb = this.#currentCallback;
61606
- this.#currentCallback = null;
61607
- cb(new MessageSizeExceededError());
61608
- }
61609
61877
  return;
61610
61878
  }
61611
61879
  this.#inflate[kBuffer].push(data);
@@ -61615,15 +61883,13 @@ var require_permessage_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports, modu
61615
61883
  callback(err);
61616
61884
  });
61617
61885
  }
61618
- this.#currentCallback = callback;
61619
61886
  this.#inflate.write(chunk);
61620
61887
  if (fin) this.#inflate.write(tail);
61621
61888
  this.#inflate.flush(() => {
61622
- if (this.#aborted || !this.#inflate) return;
61889
+ if (!this.#inflate) return;
61623
61890
  const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength]);
61624
61891
  this.#inflate[kBuffer].length = 0;
61625
61892
  this.#inflate[kLength] = 0;
61626
- this.#currentCallback = null;
61627
61893
  callback(null, full);
61628
61894
  });
61629
61895
  }
@@ -61635,7 +61901,7 @@ var require_permessage_deflate$1 = /* @__PURE__ */ __commonJSMin(((exports, modu
61635
61901
  var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61636
61902
  const { Writable: Writable$1 } = require("node:stream");
61637
61903
  const assert$6 = require("node:assert");
61638
- const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$4();
61904
+ const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants$3();
61639
61905
  const { isValidStatusCode, isValidOpcode, websocketMessageReceived, utf8Decode, isControlFrame, isTextBinaryFrame, isContinuationFrame } = require_util$4();
61640
61906
  const { failWebsocketConnection } = require_connection();
61641
61907
  const { WebsocketFrameSend } = require_frame();
@@ -61653,15 +61919,22 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61653
61919
  #extensions;
61654
61920
  /** @type {import('./websocket').Handler} */
61655
61921
  #handler;
61922
+ /** @type {number} */
61923
+ #maxFragments;
61924
+ /** @type {number} */
61925
+ #maxPayloadSize;
61656
61926
  /**
61657
61927
  * @param {import('./websocket').Handler} handler
61658
61928
  * @param {Map<string, string>|null} extensions
61929
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
61659
61930
  */
61660
- constructor(handler, extensions) {
61931
+ constructor(handler, extensions, options = {}) {
61661
61932
  super();
61662
61933
  this.#handler = handler;
61663
61934
  this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
61664
- if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions));
61935
+ this.#maxFragments = options.maxFragments ?? 0;
61936
+ this.#maxPayloadSize = options.maxPayloadSize ?? 0;
61937
+ if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions, options));
61665
61938
  }
61666
61939
  /**
61667
61940
  * @param {Buffer} chunk
@@ -61673,6 +61946,13 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61673
61946
  this.#loop = true;
61674
61947
  this.run(callback);
61675
61948
  }
61949
+ #validatePayloadLength() {
61950
+ if (this.#maxPayloadSize > 0 && !isControlFrame(this.#info.opcode) && this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize) {
61951
+ failWebsocketConnection(this.#handler, 1009, "Payload size exceeds maximum allowed size");
61952
+ return false;
61953
+ }
61954
+ return true;
61955
+ }
61676
61956
  /**
61677
61957
  * Runs whenever a new chunk is received.
61678
61958
  * Callback is called whenever there are no more chunks buffering,
@@ -61729,6 +62009,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61729
62009
  if (payloadLength <= 125) {
61730
62010
  this.#info.payloadLength = payloadLength;
61731
62011
  this.#state = parserStates.READ_DATA;
62012
+ if (!this.#validatePayloadLength()) return;
61732
62013
  } else if (payloadLength === 126) this.#state = parserStates.PAYLOADLENGTH_16;
61733
62014
  else if (payloadLength === 127) this.#state = parserStates.PAYLOADLENGTH_64;
61734
62015
  if (isTextBinaryFrame(opcode)) {
@@ -61744,6 +62025,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61744
62025
  const buffer = this.consume(2);
61745
62026
  this.#info.payloadLength = buffer.readUInt16BE(0);
61746
62027
  this.#state = parserStates.READ_DATA;
62028
+ if (!this.#validatePayloadLength()) return;
61747
62029
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
61748
62030
  if (this.#byteOffset < 8) return callback();
61749
62031
  const buffer = this.consume(8);
@@ -61755,6 +62037,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61755
62037
  }
61756
62038
  this.#info.payloadLength = lower;
61757
62039
  this.#state = parserStates.READ_DATA;
62040
+ if (!this.#validatePayloadLength()) return;
61758
62041
  } else if (this.#state === parserStates.READ_DATA) {
61759
62042
  if (this.#byteOffset < this.#info.payloadLength) return callback();
61760
62043
  const body = this.consume(this.#info.payloadLength);
@@ -61762,7 +62045,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61762
62045
  this.#loop = this.parseControlFrame(body);
61763
62046
  this.#state = parserStates.INFO;
61764
62047
  } else if (!this.#info.compressed) {
61765
- this.writeFragments(body);
62048
+ if (!this.writeFragments(body)) return;
61766
62049
  if (!this.#info.fragmented && this.#info.fin) websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments());
61767
62050
  this.#state = parserStates.INFO;
61768
62051
  } else {
@@ -61772,7 +62055,11 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61772
62055
  failWebsocketConnection(this.#handler, code, error.message);
61773
62056
  return;
61774
62057
  }
61775
- this.writeFragments(data);
62058
+ if (!this.writeFragments(data)) return;
62059
+ if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
62060
+ failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message);
62061
+ return;
62062
+ }
61776
62063
  if (!this.#info.fin) {
61777
62064
  this.#state = parserStates.INFO;
61778
62065
  this.#loop = true;
@@ -61783,7 +62070,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61783
62070
  this.#loop = true;
61784
62071
  this.#state = parserStates.INFO;
61785
62072
  this.run(callback);
61786
- });
62073
+ }, this.#fragmentsBytes);
61787
62074
  this.#loop = false;
61788
62075
  break;
61789
62076
  }
@@ -61825,8 +62112,13 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61825
62112
  }
61826
62113
  }
61827
62114
  writeFragments(fragment) {
62115
+ if (this.#maxFragments > 0 && this.#fragments.length === this.#maxFragments) {
62116
+ failWebsocketConnection(this.#handler, 1008, "Too many message fragments");
62117
+ return false;
62118
+ }
61828
62119
  this.#fragmentsBytes += fragment.length;
61829
62120
  this.#fragments.push(fragment);
62121
+ return true;
61830
62122
  }
61831
62123
  consumeFragments() {
61832
62124
  const fragments = this.#fragments;
@@ -61922,7 +62214,7 @@ var require_receiver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61922
62214
  //#region ../../node_modules/undici/lib/web/websocket/sender.js
61923
62215
  var require_sender$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61924
62216
  const { WebsocketFrameSend } = require_frame();
61925
- const { opcodes, sendHints } = require_constants$4();
62217
+ const { opcodes, sendHints } = require_constants$3();
61926
62218
  const FixedQueue = require_fixed_queue();
61927
62219
  /**
61928
62220
  * @typedef {object} SendQueueNode
@@ -62008,7 +62300,7 @@ var require_websocket$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62008
62300
  const { webidl } = require_webidl();
62009
62301
  const { URLSerializer } = require_data_url();
62010
62302
  const { environmentSettingsObject } = require_util$7();
62011
- const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$4();
62303
+ const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants$3();
62012
62304
  const { isConnecting, isEstablished, isClosing, isClosed, isValidSubprotocol, fireEvent, utf8Decode, toArrayBuffer, getURLRecord } = require_util$4();
62013
62305
  const { establishWebSocketConnection, closeWebSocketConnection, failWebsocketConnection } = require_connection();
62014
62306
  const { ByteParser } = require_receiver$1();
@@ -62247,7 +62539,13 @@ var require_websocket$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62247
62539
  */
62248
62540
  #onConnectionEstablished(response, parsedExtensions) {
62249
62541
  this.#handler.socket = response.socket;
62250
- const parser = new ByteParser(this.#handler, parsedExtensions);
62542
+ const webSocketOptions = this.#handler.controller.dispatcher?.webSocketOptions;
62543
+ const maxFragments = webSocketOptions?.maxFragments;
62544
+ const maxPayloadSize = webSocketOptions?.maxPayloadSize;
62545
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
62546
+ maxFragments,
62547
+ maxPayloadSize
62548
+ });
62251
62549
  parser.on("drain", () => this.#handler.onParserDrain());
62252
62550
  parser.on("error", (err) => this.#handler.onParserError(err));
62253
62551
  this.#parser = parser;
@@ -62485,7 +62783,7 @@ var require_websocketerror = /* @__PURE__ */ __commonJSMin(((exports, module) =>
62485
62783
  var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62486
62784
  const { createDeferredPromise } = require_promise();
62487
62785
  const { environmentSettingsObject } = require_util$7();
62488
- const { states, opcodes, sentCloseFrameState } = require_constants$4();
62786
+ const { states, opcodes, sentCloseFrameState } = require_constants$3();
62489
62787
  const { webidl } = require_webidl();
62490
62788
  const { getURLRecord, isValidSubprotocol, isEstablished, utf8Decode } = require_util$4();
62491
62789
  const { establishWebSocketConnection, failWebsocketConnection, closeWebSocketConnection } = require_connection();
@@ -62616,7 +62914,12 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62616
62914
  /** @type {import('../websocket').Handler['onConnectionEstablished']} */
62617
62915
  #onConnectionEstablished(response, parsedExtensions) {
62618
62916
  this.#handler.socket = response.socket;
62619
- const parser = new ByteParser(this.#handler, parsedExtensions);
62917
+ const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
62918
+ const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
62919
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
62920
+ maxFragments,
62921
+ maxPayloadSize
62922
+ });
62620
62923
  parser.on("drain", () => this.#handler.onParserDrain());
62621
62924
  parser.on("error", (err) => this.#handler.onParserError(err));
62622
62925
  this.#parser = parser;
@@ -62627,10 +62930,6 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62627
62930
  start: (controller) => {
62628
62931
  this.#readableStreamController = controller;
62629
62932
  },
62630
- pull(controller) {
62631
- let chunk;
62632
- while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) controller.enqueue(chunk);
62633
- },
62634
62933
  cancel: (reason) => this.#cancel(reason)
62635
62934
  });
62636
62935
  const writable = new WritableStream({
@@ -62654,7 +62953,7 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
62654
62953
  if (type === opcodes.TEXT) try {
62655
62954
  chunk = utf8Decode(data);
62656
62955
  } catch {
62657
- failWebsocketConnection(this.#handler, "Received invalid UTF-8 in text frame.");
62956
+ failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame.");
62658
62957
  return;
62659
62958
  }
62660
62959
  else if (type === opcodes.BINARY) chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
@@ -71192,74 +71491,11 @@ var AppUploadReporter = class {
71192
71491
  }
71193
71492
  };
71194
71493
  //#endregion
71195
- //#region ../base/dist/helpers/env.js
71196
- var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
71197
- Object.defineProperty(exports, "__esModule", { value: true });
71198
- exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
71199
- const toBoolean = (env) => {
71200
- if (env === void 0) return;
71201
- if (env.toLowerCase() === "true" || env === "1") return true;
71202
- if (env.toLowerCase() === "false" || env === "0") return false;
71203
- };
71204
- exports.toBoolean = toBoolean;
71205
- const toNumber = (env) => {
71206
- if (env === void 0 || env.trim() === "") return;
71207
- const number = Number(env);
71208
- if (isNaN(number)) return;
71209
- return number;
71210
- };
71211
- exports.toNumber = toNumber;
71212
- const toStringMap = (env) => {
71213
- if (env === void 0) return;
71214
- const cleanedEnv = env.replace(/'/g, "\"");
71215
- try {
71216
- const parsed = JSON.parse(cleanedEnv);
71217
- if (typeof parsed === "object" && parsed !== null) {
71218
- for (const key in parsed) if (typeof parsed[key] !== "string") return;
71219
- return parsed;
71220
- }
71221
- } catch (error) {
71222
- return;
71223
- }
71224
- };
71225
- exports.toStringMap = toStringMap;
71226
- }));
71227
- //#endregion
71228
- //#region ../base/dist/constants.js
71229
- var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
71230
- Object.defineProperty(exports, "__esModule", { value: true });
71231
- 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;
71232
- exports.DATADOG_SITE_US1 = "datadoghq.com";
71233
- exports.DATADOG_SITE_EU1 = "datadoghq.eu";
71234
- exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
71235
- exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
71236
- exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
71237
- exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
71238
- exports.DATADOG_SITE_GOV = "ddog-gov.com";
71239
- exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
71240
- exports.DATADOG_SITES = [
71241
- exports.DATADOG_SITE_US1,
71242
- exports.DATADOG_SITE_EU1,
71243
- exports.DATADOG_SITE_US3,
71244
- exports.DATADOG_SITE_US5,
71245
- exports.DATADOG_SITE_AP1,
71246
- exports.DATADOG_SITE_AP2,
71247
- exports.DATADOG_SITE_GOV,
71248
- exports.DATADOG_SITE_US2_GOV
71249
- ];
71250
- exports.FIPS_ENV_VAR = "DATADOG_FIPS";
71251
- exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
71252
- exports.CONTENT_TYPE_HEADER = "Content-Type";
71253
- exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
71254
- exports.CONTENT_TYPE_VALUE_JSON = "application/json";
71255
- exports.METHOD_POST = "post";
71256
- }));
71257
- //#endregion
71258
71494
  //#region ../base/dist/helpers/api.js
71259
71495
  var require_api = /* @__PURE__ */ __commonJSMin(((exports) => {
71260
71496
  Object.defineProperty(exports, "__esModule", { value: true });
71261
71497
  exports.getBaseIntakeUrl = exports.getApiUrl = exports.getIntakeUrl = exports.getDatadogSite = exports.getDatadogSiteFromEnv = void 0;
71262
- const constants_1 = require_constants$3();
71498
+ const constants_1 = require_constants$12();
71263
71499
  /**
71264
71500
  * Read the Datadog site from `DATADOG_SITE` / `DD_SITE` env vars.
71265
71501
  * Returns `undefined` when neither is set.
@@ -133903,13 +134139,19 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
133903
134139
  * @param {Boolean} [isServer=false] Specifies whether to operate in client or
133904
134140
  * server mode
133905
134141
  * @param {Number} [maxPayload=0] The maximum allowed message length
134142
+ * @param {Number} [maxBufferedChunks=0] The maximum number of
134143
+ * buffered data chunks
134144
+ * @param {Number} [maxFragments=0] The maximum number of message
134145
+ * fragments
133906
134146
  */
133907
- constructor(binaryType, extensions, isServer, maxPayload) {
134147
+ constructor(binaryType, extensions, isServer, maxPayload, maxBufferedChunks, maxFragments) {
133908
134148
  super();
133909
134149
  this._binaryType = binaryType || BINARY_TYPES[0];
133910
134150
  this[kWebSocket] = void 0;
133911
134151
  this._extensions = extensions || {};
133912
134152
  this._isServer = !!isServer;
134153
+ this._maxBufferedChunks = maxBufferedChunks | 0;
134154
+ this._maxFragments = maxFragments | 0;
133913
134155
  this._maxPayload = maxPayload | 0;
133914
134156
  this._bufferedBytes = 0;
133915
134157
  this._buffers = [];
@@ -133936,6 +134178,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
133936
134178
  */
133937
134179
  _write(chunk, encoding, cb) {
133938
134180
  if (this._opcode === 8 && this._state == GET_INFO) return cb();
134181
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) return cb(error(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
133939
134182
  this._bufferedBytes += chunk.length;
133940
134183
  this._buffers.push(chunk);
133941
134184
  this.startLoop(cb);
@@ -134161,6 +134404,10 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
134161
134404
  return;
134162
134405
  }
134163
134406
  if (data.length) {
134407
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
134408
+ this._loop = false;
134409
+ return error(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
134410
+ }
134164
134411
  this._messageLength = this._totalPayloadLength;
134165
134412
  this._fragments.push(data);
134166
134413
  }
@@ -134179,6 +134426,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
134179
134426
  if (buf.length) {
134180
134427
  this._messageLength += buf.length;
134181
134428
  if (this._messageLength > this._maxPayload && this._maxPayload > 0) return cb(error(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
134429
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) return cb(error(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
134182
134430
  this._fragments.push(buf);
134183
134431
  }
134184
134432
  const er = this.dataMessage();
@@ -135159,10 +135407,14 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
135159
135407
  * server and client
135160
135408
  * @param {Buffer} head The first packet of the upgraded stream
135161
135409
  * @param {Number} [maxPayload=0] The maximum allowed message size
135410
+ * @param {Number} [maxBufferedChunks=0] The maximum number of
135411
+ * buffered data chunks
135412
+ * @param {Number} [maxFragments=0] The maximum number of message
135413
+ * fragments
135162
135414
  * @private
135163
135415
  */
135164
- setSocket(socket, head, maxPayload) {
135165
- const receiver = new Receiver(this.binaryType, this._extensions, this._isServer, maxPayload);
135416
+ setSocket(socket, head, maxPayload, maxBufferedChunks, maxFragments) {
135417
+ const receiver = new Receiver(this.binaryType, this._extensions, this._isServer, maxPayload, maxBufferedChunks, maxFragments);
135166
135418
  this._sender = new Sender(socket, this._extensions);
135167
135419
  this._receiver = receiver;
135168
135420
  this._socket = socket;
@@ -135445,6 +135697,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
135445
135697
  * `Sec-WebSocket-Version` header
135446
135698
  * @param {String} [options.origin] Value of the `Origin` or
135447
135699
  * `Sec-WebSocket-Origin` header
135700
+ * @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
135701
+ * buffered data chunks
135702
+ * @param {Number} [options.maxFragments=131072] The maximum number of message
135703
+ * fragments
135448
135704
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
135449
135705
  * size
135450
135706
  * @param {Boolean} [options.followRedirects=false] Whether or not to follow
@@ -135456,6 +135712,8 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
135456
135712
  function initAsClient(websocket, address, protocols, options) {
135457
135713
  const opts = {
135458
135714
  protocolVersion: protocolVersions[1],
135715
+ maxBufferedChunks: 1024 * 1024,
135716
+ maxFragments: 128 * 1024,
135459
135717
  maxPayload: 100 * 1024 * 1024,
135460
135718
  perMessageDeflate: true,
135461
135719
  followRedirects: false,
@@ -135623,7 +135881,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
135623
135881
  websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
135624
135882
  }
135625
135883
  }
135626
- websocket.setSocket(socket, head, opts.maxPayload);
135884
+ websocket.setSocket(socket, head, opts.maxPayload, opts.maxBufferedChunks, opts.maxFragments);
135627
135885
  });
135628
135886
  }
135629
135887
  /**
@@ -136011,6 +136269,10 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
136011
136269
  * track clients
136012
136270
  * @param {Function} [options.handleProtocols] A hook to handle protocols
136013
136271
  * @param {String} [options.host] The hostname where to bind the server
136272
+ * @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
136273
+ * buffered data chunks
136274
+ * @param {Number} [options.maxFragments=131072] The maximum number of message
136275
+ * fragments
136014
136276
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
136015
136277
  * size
136016
136278
  * @param {Boolean} [options.noServer=false] Enable no server mode
@@ -136026,6 +136288,8 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
136026
136288
  constructor(options, callback) {
136027
136289
  super();
136028
136290
  options = {
136291
+ maxBufferedChunks: 1024 * 1024,
136292
+ maxFragments: 128 * 1024,
136029
136293
  maxPayload: 100 * 1024 * 1024,
136030
136294
  perMessageDeflate: false,
136031
136295
  handleProtocols: null,
@@ -136209,7 +136473,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
136209
136473
  this.emit("headers", headers, req);
136210
136474
  socket.write(headers.concat("\r\n").join("\r\n"));
136211
136475
  socket.removeListener("error", socketOnError);
136212
- ws.setSocket(socket, head, this.options.maxPayload);
136476
+ ws.setSocket(socket, head, this.options.maxPayload, this.options.maxBufferedChunks, this.options.maxFragments);
136213
136477
  if (this.clients) {
136214
136478
  this.clients.add(ws);
136215
136479
  ws.on("close", () => this.clients.delete(ws));
@@ -138816,15 +139080,135 @@ var require_terminal_link = /* @__PURE__ */ __commonJSMin(((exports) => {
138816
139080
  exports.makeTerminalLink = makeTerminalLink;
138817
139081
  }));
138818
139082
  //#endregion
139083
+ //#region ../base/dist/helpers/logger.js
139084
+ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
139085
+ var __importDefault = exports && exports.__importDefault || function(mod) {
139086
+ return mod && mod.__esModule ? mod : { "default": mod };
139087
+ };
139088
+ Object.defineProperty(exports, "__esModule", { value: true });
139089
+ exports.Logger = exports.LogLevel = void 0;
139090
+ const chalk_1 = __importDefault(require_source$3());
139091
+ var LogLevel;
139092
+ (function(LogLevel) {
139093
+ LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
139094
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
139095
+ LogLevel[LogLevel["WARN"] = 3] = "WARN";
139096
+ LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
139097
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
139098
+ const LEVEL_NAMES = {
139099
+ [LogLevel.DEBUG]: "debug",
139100
+ [LogLevel.INFO]: "info",
139101
+ [LogLevel.WARN]: "warn",
139102
+ [LogLevel.ERROR]: "error"
139103
+ };
139104
+ var Logger = class {
139105
+ constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
139106
+ var _a, _b;
139107
+ const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
139108
+ this.rawWriteMessage = writeMessage;
139109
+ this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
139110
+ this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
139111
+ this.loglevel = loglevel;
139112
+ }
139113
+ setLogLevel(newLogLevel) {
139114
+ this.loglevel = newLogLevel;
139115
+ }
139116
+ setShouldIncludeTime(newShouldIncludeTimestamp) {
139117
+ this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
139118
+ }
139119
+ setJsonOutput(newJsonOutput) {
139120
+ this.jsonOutput = newJsonOutput;
139121
+ }
139122
+ isJsonOutput() {
139123
+ return this.jsonOutput;
139124
+ }
139125
+ error(s) {
139126
+ if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
139127
+ }
139128
+ warn(s) {
139129
+ if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
139130
+ }
139131
+ info(s) {
139132
+ if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
139133
+ }
139134
+ debug(s) {
139135
+ if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
139136
+ }
139137
+ emit(level, message, colorize) {
139138
+ if (this.jsonOutput) {
139139
+ const payload = {
139140
+ level: LEVEL_NAMES[level],
139141
+ message
139142
+ };
139143
+ if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
139144
+ this.rawWriteMessage(JSON.stringify(payload) + "\n");
139145
+ return;
139146
+ }
139147
+ const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
139148
+ const body = colorize ? colorize(message) : message;
139149
+ this.rawWriteMessage(prefix + body + "\n");
139150
+ }
139151
+ };
139152
+ exports.Logger = Logger;
139153
+ }));
139154
+ //#endregion
138819
139155
  //#region ../base/dist/index.js
138820
139156
  var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
139157
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
139158
+ if (k2 === void 0) k2 = k;
139159
+ var desc = Object.getOwnPropertyDescriptor(m, k);
139160
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
139161
+ enumerable: true,
139162
+ get: function() {
139163
+ return m[k];
139164
+ }
139165
+ };
139166
+ Object.defineProperty(o, k2, desc);
139167
+ }) : (function(o, m, k, k2) {
139168
+ if (k2 === void 0) k2 = k;
139169
+ o[k2] = m[k];
139170
+ }));
139171
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
139172
+ Object.defineProperty(o, "default", {
139173
+ enumerable: true,
139174
+ value: v
139175
+ });
139176
+ }) : function(o, v) {
139177
+ o["default"] = v;
139178
+ });
139179
+ var __importStar = exports && exports.__importStar || function(mod) {
139180
+ if (mod && mod.__esModule) return mod;
139181
+ var result = {};
139182
+ if (mod != null) {
139183
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
139184
+ }
139185
+ __setModuleDefault(result, mod);
139186
+ return result;
139187
+ };
138821
139188
  Object.defineProperty(exports, "__esModule", { value: true });
138822
139189
  exports.BaseCommand = void 0;
138823
139190
  const clipanion_1 = require_advanced();
139191
+ const t = __importStar(require_lib$8());
139192
+ const constants_1 = require_constants$12();
139193
+ const logger_1 = require_logger();
138824
139194
  /**
138825
139195
  * This command should be extended by **every** command in the monorepo.
138826
139196
  */
138827
- var BaseCommand = class extends clipanion_1.Command {};
139197
+ var BaseCommand = class extends clipanion_1.Command {
139198
+ constructor() {
139199
+ super(...arguments);
139200
+ this.logFormat = clipanion_1.Option.String("--log-format", "text", {
139201
+ env: constants_1.LOG_FORMAT_ENV_VAR,
139202
+ hidden: true,
139203
+ description: "Output format for logs: 'text' (default) or 'json' (one JSON object per line).",
139204
+ validator: t.isEnum(["text", "json"])
139205
+ });
139206
+ }
139207
+ get logger() {
139208
+ if (!this._logger) this._logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO, { jsonOutput: this.logFormat === "json" });
139209
+ return this._logger;
139210
+ }
139211
+ };
138828
139212
  exports.BaseCommand = BaseCommand;
138829
139213
  }));
138830
139214
  //#endregion
@@ -138919,7 +139303,7 @@ var require_fips = /* @__PURE__ */ __commonJSMin(((exports) => {
138919
139303
  }));
138920
139304
  //#endregion
138921
139305
  //#region ../../node_modules/get-value/dist/index.mjs
138922
- var import_constants = require_constants$3();
139306
+ var import_constants = require_constants$12();
138923
139307
  var import_api = require_api();
138924
139308
  var import_deploy_tests = require_deploy_tests();
138925
139309
  var import_fips = require_fips();
@@ -139473,7 +139857,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
139473
139857
  exports.isInteger = exports.checkAPIKeyOverride = exports.isValidDatadogSite = exports.checkFile = void 0;
139474
139858
  const fs_1 = __importDefault(require("fs"));
139475
139859
  const t = __importStar(require_lib$8());
139476
- const constants_1 = require_constants$3();
139860
+ const constants_1 = require_constants$12();
139477
139861
  const checkFile = (path) => {
139478
139862
  try {
139479
139863
  if (fs_1.default.statSync(path).size === 0) return {
@@ -140037,8 +140421,8 @@ var PluginCommand$1 = class extends import_run_tests.SyntheticsRunTestsCommand {
140037
140421
  }
140038
140422
  };
140039
140423
  //#endregion
140040
- //#region ../base/dist/commands/synthetics/upload-application.js
140041
- var require_upload_application = /* @__PURE__ */ __commonJSMin(((exports) => {
140424
+ //#region src/commands/upload-application.ts
140425
+ var import_upload_application = (/* @__PURE__ */ __commonJSMin(((exports) => {
140042
140426
  var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
140043
140427
  function adopt(value) {
140044
140428
  return value instanceof P ? value : new P(function(resolve) {
@@ -140107,80 +140491,7 @@ var require_upload_application = /* @__PURE__ */ __commonJSMin(((exports) => {
140107
140491
  `,
140108
140492
  examples: [["Upload version `example 1.0` and mark it as latest", "datadog-ci synthetics upload-application --mobileApplicationId '123-123-123' --mobileApplicationVersionFilePath example/test.apk --versionName 'example 1.0' --latest"]]
140109
140493
  });
140110
- }));
140111
- //#endregion
140112
- //#region ../base/dist/helpers/logger.js
140113
- var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
140114
- var __importDefault = exports && exports.__importDefault || function(mod) {
140115
- return mod && mod.__esModule ? mod : { "default": mod };
140116
- };
140117
- Object.defineProperty(exports, "__esModule", { value: true });
140118
- exports.Logger = exports.LogLevel = void 0;
140119
- const chalk_1 = __importDefault(require_source$3());
140120
- var LogLevel;
140121
- (function(LogLevel) {
140122
- LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
140123
- LogLevel[LogLevel["INFO"] = 2] = "INFO";
140124
- LogLevel[LogLevel["WARN"] = 3] = "WARN";
140125
- LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
140126
- })(LogLevel || (exports.LogLevel = LogLevel = {}));
140127
- const LEVEL_NAMES = {
140128
- [LogLevel.DEBUG]: "debug",
140129
- [LogLevel.INFO]: "info",
140130
- [LogLevel.WARN]: "warn",
140131
- [LogLevel.ERROR]: "error"
140132
- };
140133
- var Logger = class {
140134
- constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
140135
- var _a, _b;
140136
- const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
140137
- this.rawWriteMessage = writeMessage;
140138
- this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
140139
- this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
140140
- this.loglevel = loglevel;
140141
- }
140142
- setLogLevel(newLogLevel) {
140143
- this.loglevel = newLogLevel;
140144
- }
140145
- setShouldIncludeTime(newShouldIncludeTimestamp) {
140146
- this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
140147
- }
140148
- setJsonOutput(newJsonOutput) {
140149
- this.jsonOutput = newJsonOutput;
140150
- }
140151
- error(s) {
140152
- if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
140153
- }
140154
- warn(s) {
140155
- if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
140156
- }
140157
- info(s) {
140158
- if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
140159
- }
140160
- debug(s) {
140161
- if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
140162
- }
140163
- emit(level, message, colorize) {
140164
- if (this.jsonOutput) {
140165
- const payload = {
140166
- level: LEVEL_NAMES[level],
140167
- message
140168
- };
140169
- if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
140170
- this.rawWriteMessage(JSON.stringify(payload) + "\n");
140171
- return;
140172
- }
140173
- const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
140174
- const body = colorize ? colorize(message) : message;
140175
- this.rawWriteMessage(prefix + body + "\n");
140176
- }
140177
- };
140178
- exports.Logger = Logger;
140179
- }));
140180
- //#endregion
140181
- //#region src/commands/upload-application.ts
140182
- var import_upload_application = require_upload_application();
140183
- var import_logger = require_logger();
140494
+ })))();
140184
140495
  var PluginCommand = class PluginCommand extends import_upload_application.SyntheticsUploadApplicationCommand {
140185
140496
  constructor(..._args) {
140186
140497
  super(..._args);
@@ -140189,9 +140500,6 @@ var PluginCommand = class PluginCommand extends import_upload_application.Synthe
140189
140500
  fips: (0, import_env.toBoolean)(process.env[import_constants.FIPS_ENV_VAR]) ?? false,
140190
140501
  fipsIgnoreError: (0, import_env.toBoolean)(process.env[import_constants.FIPS_IGNORE_ERROR_ENV_VAR]) ?? false
140191
140502
  };
140192
- this.logger = new import_logger.Logger((s) => {
140193
- this.context.stdout.write(s);
140194
- }, import_logger.LogLevel.INFO);
140195
140503
  }
140196
140504
  static getDefaultConfig() {
140197
140505
  return {