@datadog/datadog-ci-plugin-container-app 5.18.0 → 5.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -3153,7 +3153,7 @@ var require_dist$15 = /* @__PURE__ */ __commonJSMin(((exports) => {
3153
3153
  };
3154
3154
  Object.defineProperty(exports, "__esModule", { value: true });
3155
3155
  exports.Agent = void 0;
3156
- const net$11 = __importStar(require("net"));
3156
+ const net$10 = __importStar(require("net"));
3157
3157
  const http$6 = __importStar(require("http"));
3158
3158
  const https_1$2 = require("https");
3159
3159
  __exportStar(require_helpers$2(), exports);
@@ -3178,7 +3178,7 @@ var require_dist$15 = /* @__PURE__ */ __commonJSMin(((exports) => {
3178
3178
  incrementSockets(name) {
3179
3179
  if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
3180
3180
  if (!this.sockets[name]) this.sockets[name] = [];
3181
- const fakeSocket = new net$11.Socket({ writable: false });
3181
+ const fakeSocket = new net$10.Socket({ writable: false });
3182
3182
  this.sockets[name].push(fakeSocket);
3183
3183
  this.totalSocketCount++;
3184
3184
  return fakeSocket;
@@ -3363,7 +3363,7 @@ var require_dist$14 = /* @__PURE__ */ __commonJSMin(((exports) => {
3363
3363
  };
3364
3364
  Object.defineProperty(exports, "__esModule", { value: true });
3365
3365
  exports.HttpsProxyAgent = void 0;
3366
- const net$10 = __importStar(require("net"));
3366
+ const net$9 = __importStar(require("net"));
3367
3367
  const tls$3 = __importStar(require("tls"));
3368
3368
  const assert_1 = __importDefault(require("assert"));
3369
3369
  const debug_1 = __importDefault(require_src$2());
@@ -3372,7 +3372,7 @@ var require_dist$14 = /* @__PURE__ */ __commonJSMin(((exports) => {
3372
3372
  const parse_proxy_response_1 = require_parse_proxy_response();
3373
3373
  const debug = (0, debug_1.default)("https-proxy-agent");
3374
3374
  const setServernameFromNonIpHost = (options) => {
3375
- if (options.servername === void 0 && options.host && !net$10.isIP(options.host)) return {
3375
+ if (options.servername === void 0 && options.host && !net$9.isIP(options.host)) return {
3376
3376
  ...options,
3377
3377
  servername: options.host
3378
3378
  };
@@ -3419,10 +3419,10 @@ var require_dist$14 = /* @__PURE__ */ __commonJSMin(((exports) => {
3419
3419
  socket = tls$3.connect(setServernameFromNonIpHost(this.connectOpts));
3420
3420
  } else {
3421
3421
  debug("Creating `net.Socket`: %o", this.connectOpts);
3422
- socket = net$10.connect(this.connectOpts);
3422
+ socket = net$9.connect(this.connectOpts);
3423
3423
  }
3424
3424
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
3425
- const host = net$10.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
3425
+ const host = net$9.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
3426
3426
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
3427
3427
  if (proxy.username || proxy.password) {
3428
3428
  const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
@@ -3448,7 +3448,7 @@ var require_dist$14 = /* @__PURE__ */ __commonJSMin(((exports) => {
3448
3448
  return socket;
3449
3449
  }
3450
3450
  socket.destroy();
3451
- const fakeSocket = new net$10.Socket({ writable: false });
3451
+ const fakeSocket = new net$9.Socket({ writable: false });
3452
3452
  fakeSocket.readable = true;
3453
3453
  req.once("socket", (s) => {
3454
3454
  debug("Replaying proxy buffer for failed request");
@@ -3510,7 +3510,7 @@ var require_dist$13 = /* @__PURE__ */ __commonJSMin(((exports) => {
3510
3510
  };
3511
3511
  Object.defineProperty(exports, "__esModule", { value: true });
3512
3512
  exports.HttpProxyAgent = void 0;
3513
- const net$9 = __importStar(require("net"));
3513
+ const net$8 = __importStar(require("net"));
3514
3514
  const tls$2 = __importStar(require("tls"));
3515
3515
  const debug_1 = __importDefault(require_src$2());
3516
3516
  const events_1$3 = require("events");
@@ -3577,7 +3577,7 @@ var require_dist$13 = /* @__PURE__ */ __commonJSMin(((exports) => {
3577
3577
  socket = tls$2.connect(this.connectOpts);
3578
3578
  } else {
3579
3579
  debug("Creating `net.Socket`: %o", this.connectOpts);
3580
- socket = net$9.connect(this.connectOpts);
3580
+ socket = net$8.connect(this.connectOpts);
3581
3581
  }
3582
3582
  await (0, events_1$3.once)(socket, "connect");
3583
3583
  return socket;
@@ -53125,11 +53125,12 @@ var require_source$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53125
53125
  var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53126
53126
  module.exports = {
53127
53127
  "name": "@datadog/datadog-ci-base",
53128
- "version": "5.18.0",
53128
+ "version": "5.20.0",
53129
53129
  "description": "Base package for Datadog CI",
53130
53130
  "license": "Apache-2.0",
53131
53131
  "keywords": ["datadog", "datadog-ci"],
53132
53132
  "homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/base",
53133
+ "bugs": { "url": "https://github.com/DataDog/datadog-ci/issues" },
53133
53134
  "repository": {
53134
53135
  "type": "git",
53135
53136
  "url": "https://github.com/DataDog/datadog-ci.git",
@@ -53221,12 +53222,12 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53221
53222
  "debug": "^4.4.1",
53222
53223
  "deep-extend": "^0.6.0",
53223
53224
  "fast-xml-parser": "^5.7.2",
53224
- "form-data": "^4.0.4",
53225
+ "form-data": "^4.0.6",
53225
53226
  "glob": "^13.0.6",
53226
53227
  "inquirer": "^8.2.7",
53227
53228
  "is-docker": "^4.0.0",
53228
53229
  "jest-diff": "^30.2.0",
53229
- "js-yaml": "^4.1.1",
53230
+ "js-yaml": "^4.2.0",
53230
53231
  "jszip": "^3.10.1",
53231
53232
  "proxy-agent": "^6.4.0",
53232
53233
  "semver": "^7.6.3",
@@ -53234,7 +53235,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53234
53235
  "terminal-link": "^2.1.1",
53235
53236
  "tiny-async-pool": "^2.1.0",
53236
53237
  "typanion": "^3.14.0",
53237
- "undici": "^7.24.6",
53238
+ "undici": "^7.28.0",
53238
53239
  "upath": "^2.0.1"
53239
53240
  },
53240
53241
  "devDependencies": {
@@ -53249,6 +53250,71 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53249
53250
  };
53250
53251
  }));
53251
53252
  //#endregion
53253
+ //#region ../base/dist/constants.js
53254
+ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
53255
+ Object.defineProperty(exports, "__esModule", { value: true });
53256
+ 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;
53257
+ exports.DATADOG_SITE_US1 = "datadoghq.com";
53258
+ exports.DATADOG_SITE_EU1 = "datadoghq.eu";
53259
+ exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
53260
+ exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
53261
+ exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
53262
+ exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
53263
+ exports.DATADOG_SITE_GOV = "ddog-gov.com";
53264
+ exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
53265
+ exports.DATADOG_SITES = [
53266
+ exports.DATADOG_SITE_US1,
53267
+ exports.DATADOG_SITE_EU1,
53268
+ exports.DATADOG_SITE_US3,
53269
+ exports.DATADOG_SITE_US5,
53270
+ exports.DATADOG_SITE_AP1,
53271
+ exports.DATADOG_SITE_AP2,
53272
+ exports.DATADOG_SITE_GOV,
53273
+ exports.DATADOG_SITE_US2_GOV
53274
+ ];
53275
+ exports.FIPS_ENV_VAR = "DATADOG_FIPS";
53276
+ exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
53277
+ exports.LOG_FORMAT_ENV_VAR = "DD_LOG_FORMAT";
53278
+ exports.SKIP_VERSION_BANNER_ENV_VAR = "DD_CI_SKIP_VERSION_BANNER";
53279
+ exports.CONTENT_TYPE_HEADER = "Content-Type";
53280
+ exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
53281
+ exports.CONTENT_TYPE_VALUE_JSON = "application/json";
53282
+ exports.METHOD_POST = "post";
53283
+ }));
53284
+ //#endregion
53285
+ //#region ../base/dist/helpers/env.js
53286
+ var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
53287
+ Object.defineProperty(exports, "__esModule", { value: true });
53288
+ exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
53289
+ const toBoolean = (env) => {
53290
+ if (env === void 0) return;
53291
+ if (env.toLowerCase() === "true" || env === "1") return true;
53292
+ if (env.toLowerCase() === "false" || env === "0") return false;
53293
+ };
53294
+ exports.toBoolean = toBoolean;
53295
+ const toNumber = (env) => {
53296
+ if (env === void 0 || env.trim() === "") return;
53297
+ const number = Number(env);
53298
+ if (isNaN(number)) return;
53299
+ return number;
53300
+ };
53301
+ exports.toNumber = toNumber;
53302
+ const toStringMap = (env) => {
53303
+ if (env === void 0) return;
53304
+ const cleanedEnv = env.replace(/'/g, "\"");
53305
+ try {
53306
+ const parsed = JSON.parse(cleanedEnv);
53307
+ if (typeof parsed === "object" && parsed !== null) {
53308
+ for (const key in parsed) if (typeof parsed[key] !== "string") return;
53309
+ return parsed;
53310
+ }
53311
+ } catch (error) {
53312
+ return;
53313
+ }
53314
+ };
53315
+ exports.toStringMap = toStringMap;
53316
+ }));
53317
+ //#endregion
53252
53318
  //#region ../base/dist/version.js
53253
53319
  var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
53254
53320
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -53257,12 +53323,23 @@ var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
53257
53323
  Object.defineProperty(exports, "__esModule", { value: true });
53258
53324
  exports.printVersion = exports.cliVersion = void 0;
53259
53325
  const chalk_1 = __importDefault(require_source$1());
53260
- exports.cliVersion = require_package$1().version;
53326
+ const package_json_1 = require_package$1();
53327
+ const constants_1 = require_constants$9();
53328
+ const env_1 = require_env();
53329
+ exports.cliVersion = package_json_1.version;
53261
53330
  /**
53262
- * Prints version in all commands, except version commands.
53331
+ * Logs the version in all commands, except version commands. Routed through the
53332
+ * logger so it respects `--log-format` (a JSON line in JSON mode, dim text otherwise).
53333
+ *
53334
+ * Suppressed entirely when `DD_CI_SKIP_VERSION_BANNER` is `1`/`true`, for callers
53335
+ * that find the per-invocation banner too noisy.
53263
53336
  */
53264
- const printVersion = () => {
53265
- if (!(process.argv.at(-1) === "--version" || process.argv.at(-1) === "version")) process.stdout.write(chalk_1.default.dim(`datadog-ci v${exports.cliVersion}\n`));
53337
+ const printVersion = (logger) => {
53338
+ if ((0, env_1.toBoolean)(process.env[constants_1.SKIP_VERSION_BANNER_ENV_VAR])) return;
53339
+ const lastArg = process.argv.at(-1);
53340
+ if (lastArg === "--version" || lastArg === "version" || lastArg === "--help") return;
53341
+ const banner = `datadog-ci v${exports.cliVersion}`;
53342
+ logger.info(logger.isJsonOutput() ? banner : chalk_1.default.dim(banner));
53266
53343
  };
53267
53344
  exports.printVersion = printVersion;
53268
53345
  }));
@@ -54606,7 +54683,7 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
54606
54683
  }));
54607
54684
  //#endregion
54608
54685
  //#region ../base/dist/helpers/serverless/constants.js
54609
- var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
54686
+ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
54610
54687
  Object.defineProperty(exports, "__esModule", { value: true });
54611
54688
  exports.ENV_VAR_REGEX = exports.DEFAULT_HEALTH_CHECK_PORT = exports.DEFAULT_LOGS_PATH = exports.DEFAULT_VOLUME_PATH = exports.DEFAULT_VOLUME_NAME = exports.DEFAULT_SIDECAR_NAME = exports.SIDECAR_PORT = exports.SIDECAR_IMAGE = exports.SIDECAR_CONTAINER_NAME = exports.FLARE_PROJECT_FILES = exports.INSIGHTS_FILE_NAME = exports.ADDITIONAL_FILES_DIRECTORY = exports.PROJECT_FILES_DIRECTORY = exports.LOGS_DIRECTORY = exports.FLARE_OUTPUT_DIRECTORY = exports.EXTRA_TAGS_REG_EXP = exports.VERSION_ENV_VAR = exports.ENVIRONMENT_ENV_VAR = exports.SERVICE_ENV_VAR = exports.DD_SOURCE_ENV_VAR = exports.DD_TAGS_ENV_VAR = exports.DD_LLMOBS_AGENTLESS_ENABLED_ENV_VAR = exports.DD_LLMOBS_ML_APP_ENV_VAR = exports.DD_LLMOBS_ENABLED_ENV_VAR = exports.DD_TRACE_ENABLED_ENV_VAR = exports.DD_LOG_LEVEL_ENV_VAR = exports.HEALTH_PORT_ENV_VAR = exports.LOGS_PATH_ENV_VAR = exports.LOGS_INJECTION_ENV_VAR = exports.SITE_ENV_VAR = exports.CI_SITE_ENV_VAR = exports.CI_API_KEY_ENV_VAR = exports.API_KEY_ENV_VAR = void 0;
54612
54689
  exports.API_KEY_ENV_VAR = "DD_API_KEY";
@@ -54684,69 +54761,6 @@ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
54684
54761
  exports.ENV_VAR_REGEX = /^([\w.]+)=(.*)$/;
54685
54762
  }));
54686
54763
  //#endregion
54687
- //#region ../base/dist/constants.js
54688
- var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
54689
- Object.defineProperty(exports, "__esModule", { value: true });
54690
- 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;
54691
- exports.DATADOG_SITE_US1 = "datadoghq.com";
54692
- exports.DATADOG_SITE_EU1 = "datadoghq.eu";
54693
- exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
54694
- exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
54695
- exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
54696
- exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
54697
- exports.DATADOG_SITE_GOV = "ddog-gov.com";
54698
- exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
54699
- exports.DATADOG_SITES = [
54700
- exports.DATADOG_SITE_US1,
54701
- exports.DATADOG_SITE_EU1,
54702
- exports.DATADOG_SITE_US3,
54703
- exports.DATADOG_SITE_US5,
54704
- exports.DATADOG_SITE_AP1,
54705
- exports.DATADOG_SITE_AP2,
54706
- exports.DATADOG_SITE_GOV,
54707
- exports.DATADOG_SITE_US2_GOV
54708
- ];
54709
- exports.FIPS_ENV_VAR = "DATADOG_FIPS";
54710
- exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
54711
- exports.CONTENT_TYPE_HEADER = "Content-Type";
54712
- exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
54713
- exports.CONTENT_TYPE_VALUE_JSON = "application/json";
54714
- exports.METHOD_POST = "post";
54715
- }));
54716
- //#endregion
54717
- //#region ../base/dist/helpers/env.js
54718
- var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
54719
- Object.defineProperty(exports, "__esModule", { value: true });
54720
- exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
54721
- const toBoolean = (env) => {
54722
- if (env === void 0) return;
54723
- if (env.toLowerCase() === "true" || env === "1") return true;
54724
- if (env.toLowerCase() === "false" || env === "0") return false;
54725
- };
54726
- exports.toBoolean = toBoolean;
54727
- const toNumber = (env) => {
54728
- if (env === void 0 || env.trim() === "") return;
54729
- const number = Number(env);
54730
- if (isNaN(number)) return;
54731
- return number;
54732
- };
54733
- exports.toNumber = toNumber;
54734
- const toStringMap = (env) => {
54735
- if (env === void 0) return;
54736
- const cleanedEnv = env.replace(/'/g, "\"");
54737
- try {
54738
- const parsed = JSON.parse(cleanedEnv);
54739
- if (typeof parsed === "object" && parsed !== null) {
54740
- for (const key in parsed) if (typeof parsed[key] !== "string") return;
54741
- return parsed;
54742
- }
54743
- } catch (error) {
54744
- return;
54745
- }
54746
- };
54747
- exports.toStringMap = toStringMap;
54748
- }));
54749
- //#endregion
54750
54764
  //#region ../base/dist/helpers/fips.js
54751
54765
  var require_fips = /* @__PURE__ */ __commonJSMin(((exports) => {
54752
54766
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -60232,7 +60246,7 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
60232
60246
  const constants_1 = require_constants$7();
60233
60247
  const stream$2 = require("stream");
60234
60248
  const ip_address_1 = require_ip_address();
60235
- const net$8 = require("net");
60249
+ const net$7 = require("net");
60236
60250
  /**
60237
60251
  * Validates the provided SocksClientOptions
60238
60252
  * @param options { SocksClientOptions }
@@ -60310,10 +60324,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
60310
60324
  }
60311
60325
  exports.int32ToIpv4 = int32ToIpv4;
60312
60326
  function ipToBuffer(ip) {
60313
- if (net$8.isIPv4(ip)) {
60327
+ if (net$7.isIPv4(ip)) {
60314
60328
  const address = new ip_address_1.Address4(ip);
60315
60329
  return Buffer.from(address.toArray());
60316
- } else if (net$8.isIPv6(ip)) {
60330
+ } else if (net$7.isIPv6(ip)) {
60317
60331
  const address = new ip_address_1.Address6(ip);
60318
60332
  return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
60319
60333
  } else throw new Error("Invalid IP address format");
@@ -60392,7 +60406,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60392
60406
  Object.defineProperty(exports, "__esModule", { value: true });
60393
60407
  exports.SocksClientError = exports.SocksClient = void 0;
60394
60408
  const events_1$2 = require("events");
60395
- const net$7 = require("net");
60409
+ const net$6 = require("net");
60396
60410
  const smart_buffer_1 = require_smartbuffer();
60397
60411
  const constants_1 = require_constants$7();
60398
60412
  const helpers_1 = require_helpers();
@@ -60504,10 +60518,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60504
60518
  const buff = new smart_buffer_1.SmartBuffer();
60505
60519
  buff.writeUInt16BE(0);
60506
60520
  buff.writeUInt8(options.frameNumber || 0);
60507
- if (net$7.isIPv4(options.remoteHost.host)) {
60521
+ if (net$6.isIPv4(options.remoteHost.host)) {
60508
60522
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
60509
60523
  buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
60510
- } else if (net$7.isIPv6(options.remoteHost.host)) {
60524
+ } else if (net$6.isIPv6(options.remoteHost.host)) {
60511
60525
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
60512
60526
  buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
60513
60527
  } else {
@@ -60560,7 +60574,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60560
60574
  const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
60561
60575
  if (timer.unref && typeof timer.unref === "function") timer.unref();
60562
60576
  if (existingSocket) this.socket = existingSocket;
60563
- else this.socket = new net$7.Socket();
60577
+ else this.socket = new net$6.Socket();
60564
60578
  this.socket.once("close", this.onClose);
60565
60579
  this.socket.once("error", this.onError);
60566
60580
  this.socket.once("connect", this.onConnect);
@@ -60672,7 +60686,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60672
60686
  buff.writeUInt8(4);
60673
60687
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
60674
60688
  buff.writeUInt16BE(this.options.destination.port);
60675
- if (net$7.isIPv4(this.options.destination.host)) {
60689
+ if (net$6.isIPv4(this.options.destination.host)) {
60676
60690
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60677
60691
  buff.writeStringNT(userId);
60678
60692
  } else {
@@ -60831,10 +60845,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60831
60845
  buff.writeUInt8(5);
60832
60846
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
60833
60847
  buff.writeUInt8(0);
60834
- if (net$7.isIPv4(this.options.destination.host)) {
60848
+ if (net$6.isIPv4(this.options.destination.host)) {
60835
60849
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
60836
60850
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60837
- } else if (net$7.isIPv6(this.options.destination.host)) {
60851
+ } else if (net$6.isIPv6(this.options.destination.host)) {
60838
60852
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
60839
60853
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60840
60854
  } else {
@@ -61044,12 +61058,12 @@ var require_dist$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
61044
61058
  const agent_base_1 = require_dist$15();
61045
61059
  const debug_1 = __importDefault(require_src$2());
61046
61060
  const dns = __importStar(require("dns"));
61047
- const net$6 = __importStar(require("net"));
61061
+ const net$5 = __importStar(require("net"));
61048
61062
  const tls$1 = __importStar(require("tls"));
61049
61063
  const url_1$5 = require("url");
61050
61064
  const debug = (0, debug_1.default)("socks-proxy-agent");
61051
61065
  const setServernameFromNonIpHost = (options) => {
61052
- if (options.servername === void 0 && options.host && !net$6.isIP(options.host)) return {
61066
+ if (options.servername === void 0 && options.host && !net$5.isIP(options.host)) return {
61053
61067
  ...options,
61054
61068
  servername: options.host
61055
61069
  };
@@ -63309,6 +63323,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63309
63323
  function doNothing() {
63310
63324
  /** Do nothing */
63311
63325
  }
63326
+ const maxControlResponseLength = 2 ** 16;
63312
63327
  /**
63313
63328
  * FTPContext holds the control and data sockets of an FTP connection and provides a
63314
63329
  * simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -63435,6 +63450,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63435
63450
  * Send an FTP command without waiting for or handling the result.
63436
63451
  */
63437
63452
  send(command) {
63453
+ if (/[\r\n\0]/.test(command)) throw new Error(`Invalid command: Contains control characters. (${command})`);
63438
63454
  const message = command.startsWith("PASS") ? "> PASS ###" : `> ${command}`;
63439
63455
  this.log(message);
63440
63456
  this._socket.write(command + "\r\n", this.encoding);
@@ -63513,6 +63529,10 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63513
63529
  */
63514
63530
  _onControlSocketData(chunk) {
63515
63531
  this.log(`< ${chunk}`);
63532
+ if (this._partialResponse.length + chunk.length > maxControlResponseLength) {
63533
+ this.closeWithError(/* @__PURE__ */ new Error("FTP control response exceeded maximum allowed size"));
63534
+ return;
63535
+ }
63516
63536
  const completeResponse = this._partialResponse + chunk;
63517
63537
  const parsed = (0, parseControlResponse_1.parseControlResponse)(completeResponse);
63518
63538
  this._partialResponse = parsed.rest;
@@ -63596,6 +63616,61 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63596
63616
  exports.FTPContext = FTPContext;
63597
63617
  }));
63598
63618
  //#endregion
63619
+ //#region ../../node_modules/basic-ftp/dist/netUtils.js
63620
+ var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
63621
+ Object.defineProperty(exports, "__esModule", { value: true });
63622
+ exports.describeTLS = describeTLS;
63623
+ exports.describeAddress = describeAddress;
63624
+ exports.upgradeSocket = upgradeSocket;
63625
+ exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
63626
+ const tls_1$2 = require("tls");
63627
+ /**
63628
+ * Returns a string describing the encryption on a given socket instance.
63629
+ */
63630
+ function describeTLS(socket) {
63631
+ if (socket instanceof tls_1$2.TLSSocket) {
63632
+ const protocol = socket.getProtocol();
63633
+ return protocol ? protocol : "Server socket or disconnected client socket";
63634
+ }
63635
+ return "No encryption";
63636
+ }
63637
+ /**
63638
+ * Returns a string describing the remote address of a socket.
63639
+ */
63640
+ function describeAddress(socket) {
63641
+ if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
63642
+ return `${socket.remoteAddress}:${socket.remotePort}`;
63643
+ }
63644
+ /**
63645
+ * Upgrade a socket connection with TLS.
63646
+ */
63647
+ function upgradeSocket(socket, options) {
63648
+ return new Promise((resolve, reject) => {
63649
+ const tlsOptions = Object.assign({}, options, { socket });
63650
+ const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
63651
+ if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
63652
+ else {
63653
+ tlsSocket.removeAllListeners("error");
63654
+ resolve(tlsSocket);
63655
+ }
63656
+ }).once("error", (error) => {
63657
+ reject(error);
63658
+ });
63659
+ });
63660
+ }
63661
+ /**
63662
+ * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
63663
+ * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
63664
+ *
63665
+ * @param ip The IP as a string, e.g. "192.168.0.1"
63666
+ */
63667
+ function ipIsPrivateV4Address(ip = "") {
63668
+ if (ip.startsWith("::ffff:")) ip = ip.substr(7);
63669
+ const octets = ip.split(".").map((o) => parseInt(o, 10));
63670
+ return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
63671
+ }
63672
+ }));
63673
+ //#endregion
63599
63674
  //#region ../../node_modules/basic-ftp/dist/FileInfo.js
63600
63675
  var require_FileInfo = /* @__PURE__ */ __commonJSMin(((exports) => {
63601
63676
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -64131,78 +64206,32 @@ var require_StringWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
64131
64206
  exports.StringWriter = void 0;
64132
64207
  const stream_1$3 = require("stream");
64133
64208
  var StringWriter = class extends stream_1$3.Writable {
64134
- constructor() {
64135
- super(...arguments);
64136
- this.buf = Buffer.alloc(0);
64209
+ constructor(maxByteLength = 1 * 1024 * 1024) {
64210
+ super();
64211
+ this.maxByteLength = maxByteLength;
64212
+ this.byteLength = 0;
64213
+ this.bufs = [];
64137
64214
  }
64138
64215
  _write(chunk, _, callback) {
64139
- if (chunk instanceof Buffer) {
64140
- this.buf = Buffer.concat([this.buf, chunk]);
64141
- callback(null);
64142
- } else callback(/* @__PURE__ */ new Error("StringWriter expects chunks of type 'Buffer'."));
64216
+ if (!(chunk instanceof Buffer)) {
64217
+ callback(/* @__PURE__ */ new Error("StringWriter: expects chunks of type 'Buffer'."));
64218
+ return;
64219
+ }
64220
+ if (this.byteLength + chunk.byteLength > this.maxByteLength) {
64221
+ callback(/* @__PURE__ */ new Error(`StringWriter: Maximum bytes exceeded, maxByteLength=${this.maxByteLength}.`));
64222
+ return;
64223
+ }
64224
+ this.byteLength += chunk.byteLength;
64225
+ this.bufs.push(chunk);
64226
+ callback(null);
64143
64227
  }
64144
64228
  getText(encoding) {
64145
- return this.buf.toString(encoding);
64229
+ return Buffer.concat(this.bufs).toString(encoding);
64146
64230
  }
64147
64231
  };
64148
64232
  exports.StringWriter = StringWriter;
64149
64233
  }));
64150
64234
  //#endregion
64151
- //#region ../../node_modules/basic-ftp/dist/netUtils.js
64152
- var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
64153
- Object.defineProperty(exports, "__esModule", { value: true });
64154
- exports.describeTLS = describeTLS;
64155
- exports.describeAddress = describeAddress;
64156
- exports.upgradeSocket = upgradeSocket;
64157
- exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
64158
- const tls_1$2 = require("tls");
64159
- /**
64160
- * Returns a string describing the encryption on a given socket instance.
64161
- */
64162
- function describeTLS(socket) {
64163
- if (socket instanceof tls_1$2.TLSSocket) {
64164
- const protocol = socket.getProtocol();
64165
- return protocol ? protocol : "Server socket or disconnected client socket";
64166
- }
64167
- return "No encryption";
64168
- }
64169
- /**
64170
- * Returns a string describing the remote address of a socket.
64171
- */
64172
- function describeAddress(socket) {
64173
- if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
64174
- return `${socket.remoteAddress}:${socket.remotePort}`;
64175
- }
64176
- /**
64177
- * Upgrade a socket connection with TLS.
64178
- */
64179
- function upgradeSocket(socket, options) {
64180
- return new Promise((resolve, reject) => {
64181
- const tlsOptions = Object.assign({}, options, { socket });
64182
- const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
64183
- if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
64184
- else {
64185
- tlsSocket.removeAllListeners("error");
64186
- resolve(tlsSocket);
64187
- }
64188
- }).once("error", (error) => {
64189
- reject(error);
64190
- });
64191
- });
64192
- }
64193
- /**
64194
- * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
64195
- * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
64196
- *
64197
- * @param ip The IP as a string, e.g. "192.168.0.1"
64198
- */
64199
- function ipIsPrivateV4Address(ip = "") {
64200
- if (ip.startsWith("::ffff:")) ip = ip.substr(7);
64201
- const octets = ip.split(".").map((o) => parseInt(o, 10));
64202
- return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
64203
- }
64204
- }));
64205
- //#endregion
64206
64235
  //#region ../../node_modules/basic-ftp/dist/transfer.js
64207
64236
  var require_transfer = /* @__PURE__ */ __commonJSMin(((exports) => {
64208
64237
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -64448,20 +64477,23 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64448
64477
  const tls_1 = require("tls");
64449
64478
  const util_1$3 = require("util");
64450
64479
  const FtpContext_1 = require_FtpContext();
64480
+ const netUtils_1 = require_netUtils();
64481
+ const parseControlResponse_1 = require_parseControlResponse();
64451
64482
  const parseList_1 = require_parseList();
64483
+ const parseListMLSD_1 = require_parseListMLSD();
64452
64484
  const ProgressTracker_1 = require_ProgressTracker();
64453
64485
  const StringWriter_1 = require_StringWriter();
64454
- const parseListMLSD_1 = require_parseListMLSD();
64455
- const netUtils_1 = require_netUtils();
64456
64486
  const transfer_1 = require_transfer();
64457
- const parseControlResponse_1 = require_parseControlResponse();
64458
64487
  const fsReadDir = (0, util_1$3.promisify)(fs_1$6.readdir);
64459
64488
  const fsMkDir = (0, util_1$3.promisify)(fs_1$6.mkdir);
64460
64489
  const fsStat = (0, util_1$3.promisify)(fs_1$6.stat);
64461
64490
  const fsOpen = (0, util_1$3.promisify)(fs_1$6.open);
64462
64491
  const fsClose = (0, util_1$3.promisify)(fs_1$6.close);
64463
64492
  const fsUnlink = (0, util_1$3.promisify)(fs_1$6.unlink);
64464
- const defaultClientOptions = { allowSeparateTransferHost: true };
64493
+ const defaultClientOptions = {
64494
+ allowSeparateTransferHost: true,
64495
+ maxListingBytes: 40 * 1024 * 1024
64496
+ };
64465
64497
  const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
64466
64498
  const LIST_COMMANDS_MLSD = () => [
64467
64499
  "MLSD",
@@ -64477,10 +64509,15 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64477
64509
  *
64478
64510
  * @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
64479
64511
  */
64480
- constructor(timeout = 3e4, options = defaultClientOptions) {
64512
+ constructor(timeout = 3e4, userOptions = defaultClientOptions) {
64481
64513
  this.availableListCommands = LIST_COMMANDS_DEFAULT();
64514
+ const options = {
64515
+ ...defaultClientOptions,
64516
+ ...userOptions
64517
+ };
64482
64518
  this.ftp = new FtpContext_1.FTPContext(timeout);
64483
64519
  this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, options.allowSeparateTransferHost ? transfer_1.enterPassiveModeIPv4 : transfer_1.enterPassiveModeIPv4_forceControlHostIP]);
64520
+ this.options = options;
64484
64521
  this.parseList = parseList_1.parseList;
64485
64522
  this._progressTracker = new ProgressTracker_1.ProgressTracker();
64486
64523
  }
@@ -64880,7 +64917,7 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64880
64917
  * @protected
64881
64918
  */
64882
64919
  async _requestListWithCommand(command) {
64883
- const buffer = new StringWriter_1.StringWriter();
64920
+ const buffer = new StringWriter_1.StringWriter(this.options.maxListingBytes);
64884
64921
  await (0, transfer_1.downloadTo)(buffer, {
64885
64922
  ftp: this.ftp,
64886
64923
  tracker: this._progressTracker,
@@ -81642,7 +81679,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81642
81679
  };
81643
81680
  Object.defineProperty(exports, "__esModule", { value: true });
81644
81681
  exports.PacProxyAgent = void 0;
81645
- const net$5 = __importStar(require("net"));
81682
+ const net$4 = __importStar(require("net"));
81646
81683
  const tls = __importStar(require("tls"));
81647
81684
  const crypto$5 = __importStar(require("crypto"));
81648
81685
  const events_1 = require("events");
@@ -81654,7 +81691,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81654
81691
  const quickjs_emscripten_1 = require_dist$7();
81655
81692
  const debug = (0, debug_1.default)("pac-proxy-agent");
81656
81693
  const setServernameFromNonIpHost = (options) => {
81657
- if (options.servername === void 0 && options.host && !net$5.isIP(options.host)) return {
81694
+ if (options.servername === void 0 && options.host && !net$4.isIP(options.host)) return {
81658
81695
  ...options,
81659
81696
  servername: options.host
81660
81697
  };
@@ -81744,7 +81781,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81744
81781
  const isWebSocket = req.getHeader("upgrade") === "websocket";
81745
81782
  const resolver = await this.getResolver();
81746
81783
  const protocol = secureEndpoint ? "https:" : "http:";
81747
- const host = opts.host && net$5.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
81784
+ const host = opts.host && net$4.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
81748
81785
  const defaultPort = secureEndpoint ? 443 : 80;
81749
81786
  const url = Object.assign(new url_1$3.URL(req.path, `${protocol}//${host}`), defaultPort ? void 0 : { port: opts.port });
81750
81787
  debug("url: %s", url);
@@ -81758,7 +81795,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81758
81795
  const [type, target] = proxy.split(/\s+/);
81759
81796
  debug("Attempting to use proxy: %o", proxy);
81760
81797
  if (type === "DIRECT") if (secureEndpoint) socket = tls.connect(setServernameFromNonIpHost(opts));
81761
- else socket = net$5.connect(opts);
81798
+ else socket = net$4.connect(opts);
81762
81799
  else if (type === "SOCKS" || type === "SOCKS5") {
81763
81800
  const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require_dist$12()));
81764
81801
  agent = new SocksProxyAgent(`socks://${target}`, this.opts);
@@ -81786,7 +81823,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81786
81823
  }
81787
81824
  if (agent) {
81788
81825
  const s = await agent.connect(req, opts);
81789
- if (!(s instanceof net$5.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
81826
+ if (!(s instanceof net$4.Socket)) throw new Error("Expected a `net.Socket` to be returned from agent");
81790
81827
  req.emit("proxy", {
81791
81828
  proxy,
81792
81829
  socket: s
@@ -82968,7 +83005,7 @@ var require_util$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
82968
83005
  const { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
82969
83006
  const { IncomingMessage } = require("node:http");
82970
83007
  const stream$1 = require("node:stream");
82971
- const net$4 = require("node:net");
83008
+ const net$3 = require("node:net");
82972
83009
  const { stringify } = require("node:querystring");
82973
83010
  const { EventEmitter: EE$2 } = require("node:events");
82974
83011
  const timers = require_timers();
@@ -83129,7 +83166,7 @@ var require_util$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
83129
83166
  if (!host) return null;
83130
83167
  assert$32(typeof host === "string");
83131
83168
  const servername = getHostname(host);
83132
- if (net$4.isIP(servername)) return "";
83169
+ if (net$3.isIP(servername)) return "";
83133
83170
  return servername;
83134
83171
  }
83135
83172
  /**
@@ -84039,6 +84076,14 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84039
84076
  const { channels } = require_diagnostics();
84040
84077
  const { headerNameLowerCasedRecord } = require_constants$4();
84041
84078
  const invalidPathRegex = /[^\u0021-\u00ff]/;
84079
+ function isValidContentLengthHeaderValue(val) {
84080
+ if (typeof val !== "string" || val.length === 0) return false;
84081
+ for (let i = 0; i < val.length; i++) {
84082
+ const charCode = val.charCodeAt(i);
84083
+ if (charCode < 48 || charCode > 57) return false;
84084
+ }
84085
+ return true;
84086
+ }
84042
84087
  const kHandler = Symbol("handler");
84043
84088
  var Request = class {
84044
84089
  constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
@@ -84247,8 +84292,8 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84247
84292
  request.host = val;
84248
84293
  } else if (headerName === "content-length") {
84249
84294
  if (request.contentLength !== null) throw new InvalidArgumentError("duplicate content-length header");
84295
+ if (!isValidContentLengthHeaderValue(val)) throw new InvalidArgumentError("invalid content-length header");
84250
84296
  request.contentLength = parseInt(val, 10);
84251
- if (!Number.isFinite(request.contentLength)) throw new InvalidArgumentError("invalid content-length header");
84252
84297
  } else if (request.contentType === null && headerName === "content-type") {
84253
84298
  request.contentType = val;
84254
84299
  request.headers.push(key, val);
@@ -84373,6 +84418,8 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84373
84418
  #aborted = false;
84374
84419
  #abort;
84375
84420
  [kResume] = null;
84421
+ rawHeaders = null;
84422
+ rawTrailers = null;
84376
84423
  constructor(abort) {
84377
84424
  this.#abort = abort;
84378
84425
  }
@@ -84419,10 +84466,12 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84419
84466
  return this.#handler.onResponseStarted?.();
84420
84467
  }
84421
84468
  onUpgrade(statusCode, rawHeaders, socket) {
84469
+ this.#controller.rawHeaders = rawHeaders;
84422
84470
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
84423
84471
  }
84424
84472
  onHeaders(statusCode, rawHeaders, resume, statusMessage) {
84425
84473
  this.#controller[kResume] = resume;
84474
+ this.#controller.rawHeaders = rawHeaders;
84426
84475
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
84427
84476
  return !this.#controller.paused;
84428
84477
  }
@@ -84431,6 +84480,7 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84431
84480
  return !this.#controller.paused;
84432
84481
  }
84433
84482
  onComplete(rawTrailers) {
84483
+ this.#controller.rawTrailers = rawTrailers;
84434
84484
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
84435
84485
  }
84436
84486
  onError(err) {
@@ -84448,6 +84498,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84448
84498
  const { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
84449
84499
  const kOnDestroyed = Symbol("onDestroyed");
84450
84500
  const kOnClosed = Symbol("onClosed");
84501
+ const kWebSocketOptions = Symbol("webSocketOptions");
84451
84502
  var DispatcherBase = class extends Dispatcher {
84452
84503
  /** @type {boolean} */
84453
84504
  [kDestroyed] = false;
@@ -84457,6 +84508,22 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84457
84508
  [kClosed] = false;
84458
84509
  /** @type {Array<Function>|null} */
84459
84510
  [kOnClosed] = null;
84511
+ /**
84512
+ * @param {import('../../types/dispatcher').DispatcherOptions} [opts]
84513
+ */
84514
+ constructor(opts) {
84515
+ super();
84516
+ this[kWebSocketOptions] = opts?.webSocket ?? {};
84517
+ }
84518
+ /**
84519
+ * @returns {import('../../types/dispatcher').WebSocketOptions}
84520
+ */
84521
+ get webSocketOptions() {
84522
+ return {
84523
+ maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
84524
+ maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
84525
+ };
84526
+ }
84460
84527
  /** @returns {boolean} */
84461
84528
  get destroyed() {
84462
84529
  return this[kDestroyed];
@@ -84539,7 +84606,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84539
84606
  //#endregion
84540
84607
  //#region ../../node_modules/undici/lib/core/connect.js
84541
84608
  var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84542
- const net$3 = require("node:net");
84609
+ const net$2 = require("node:net");
84543
84610
  const assert$30 = require("node:assert");
84544
84611
  const util = require_util$6();
84545
84612
  const { InvalidArgumentError } = require_errors$1();
@@ -84560,6 +84627,15 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84560
84627
  }
84561
84628
  set(sessionKey, session) {
84562
84629
  if (this._maxCachedSessions === 0) return;
84630
+ if (this._sessionCache.has(sessionKey)) this._sessionCache.delete(sessionKey);
84631
+ else if (this._sessionCache.size >= this._maxCachedSessions) {
84632
+ for (const [key, ref] of this._sessionCache) if (ref.deref() === void 0) {
84633
+ this._sessionCache.delete(key);
84634
+ return;
84635
+ }
84636
+ const oldest = this._sessionCache.keys().next();
84637
+ if (!oldest.done) this._sessionCache.delete(oldest.value);
84638
+ }
84563
84639
  this._sessionCache.set(sessionKey, new WeakRef(session));
84564
84640
  this._sessionRegistry.register(session, sessionKey);
84565
84641
  }
@@ -84599,7 +84675,7 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84599
84675
  } else {
84600
84676
  assert$30(!httpSocket, "httpSocket can only be sent on TLS update");
84601
84677
  port = port || 80;
84602
- socket = net$3.connect({
84678
+ socket = net$2.connect({
84603
84679
  highWaterMark: 64 * 1024,
84604
84680
  ...options,
84605
84681
  localAddress,
@@ -86157,7 +86233,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86157
86233
  lowerBound = 0;
86158
86234
  upperBound = Math.pow(2, bitLength) - 1;
86159
86235
  } else {
86160
- lowerBound = Math.pow(-2, bitLength) - 1;
86236
+ lowerBound = -Math.pow(2, bitLength - 1);
86161
86237
  upperBound = Math.pow(2, bitLength - 1) - 1;
86162
86238
  }
86163
86239
  let x = Number(V);
@@ -86183,7 +86259,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86183
86259
  if (Number.isNaN(x) || x === 0 && Object.is(0, x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) return 0;
86184
86260
  x = webidl.util.IntegerPart(x);
86185
86261
  x = x % Math.pow(2, bitLength);
86186
- if (signedness === "signed" && x >= Math.pow(2, bitLength) - 1) return x - Math.pow(2, bitLength);
86262
+ if (signedness === "signed" && x >= Math.pow(2, bitLength - 1)) return x - Math.pow(2, bitLength);
86187
86263
  return x;
86188
86264
  };
86189
86265
  webidl.util.IntegerPart = function(n) {
@@ -87528,7 +87604,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87528
87604
  * Parses content-disposition attributes (e.g., name="value" or filename*=utf-8''encoded)
87529
87605
  * @param {Buffer} input
87530
87606
  * @param {{ position: number }} position
87531
- * @returns {{ name: string, value: string }}
87607
+ * @returns {{ name: string, value: string, extended: boolean } | null}
87532
87608
  */
87533
87609
  function parseContentDispositionAttribute(input, position) {
87534
87610
  if (input[position.position] === 59) position.position++;
@@ -87558,7 +87634,8 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87558
87634
  }
87559
87635
  return {
87560
87636
  name: attrNameStr,
87561
- value
87637
+ value,
87638
+ extended: isExtended
87562
87639
  };
87563
87640
  }
87564
87641
  /**
@@ -87588,17 +87665,24 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87588
87665
  position.position++;
87589
87666
  collectASequenceOfBytes((char) => char === 32 || char === 9, input, position);
87590
87667
  switch (bufferToLowerCasedHeaderName(headerName)) {
87591
- case "content-disposition":
87668
+ case "content-disposition": {
87592
87669
  name = filename = null;
87670
+ let filenameIsExtended = false;
87593
87671
  if (collectASequenceOfBytes((char) => isToken(char), input, position).toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
87594
- while (position.position < input.length && input[position.position] !== 13 && input[position.position + 1] !== 10) {
87672
+ while (position.position < input.length && (input[position.position] !== 13 || input[position.position + 1] !== 10)) {
87595
87673
  const attribute = parseContentDispositionAttribute(input, position);
87596
87674
  if (!attribute) break;
87597
87675
  if (attribute.name === "name") name = attribute.value;
87598
- else if (attribute.name === "filename") filename = attribute.value;
87676
+ else if (attribute.name === "filename") {
87677
+ if (attribute.extended) {
87678
+ filename = attribute.value;
87679
+ filenameIsExtended = true;
87680
+ } else if (!filenameIsExtended) filename = attribute.value;
87681
+ }
87599
87682
  }
87600
87683
  if (name === null) throw parsingError("name attribute is required in content-disposition header");
87601
87684
  break;
87685
+ }
87602
87686
  case "content-type": {
87603
87687
  let headerValue = collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
87604
87688
  headerValue = removeChars(headerValue, false, true, (char) => char === 9 || char === 32);
@@ -87613,7 +87697,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87613
87697
  }
87614
87698
  default: collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
87615
87699
  }
87616
- if (input[position.position] !== 13 && input[position.position + 1] !== 10) throw parsingError("expected CRLF");
87700
+ if (input[position.position] !== 13 || input[position.position + 1] !== 10) throw parsingError("expected CRLF");
87617
87701
  else position.position += 2;
87618
87702
  }
87619
87703
  }
@@ -87985,13 +88069,16 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87985
88069
  const EMPTY_BUF = Buffer.alloc(0);
87986
88070
  const FastBuffer = Buffer[Symbol.species];
87987
88071
  const removeAllListeners = util.removeAllListeners;
88072
+ const kIdleSocketValidation = Symbol("kIdleSocketValidation");
88073
+ const kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
88074
+ const kSocketUsed = Symbol("kSocketUsed");
87988
88075
  let extractBody;
87989
88076
  function lazyllhttp() {
87990
88077
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
87991
88078
  let mod;
87992
88079
  let useWasmSIMD = process.arch !== "ppc64";
87993
- if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
87994
- else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = false;
88080
+ if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = false;
88081
+ else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = true;
87995
88082
  if (useWasmSIMD) try {
87996
88083
  mod = new WebAssembly.Module(require_llhttp_simd_wasm());
87997
88084
  } catch {}
@@ -88065,6 +88152,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88065
88152
  */
88066
88153
  this.socket = socket;
88067
88154
  this.timeout = null;
88155
+ this.timeoutWeakRef = new WeakRef(this);
88068
88156
  this.timeoutValue = null;
88069
88157
  this.timeoutType = null;
88070
88158
  this.statusCode = 0;
@@ -88088,9 +88176,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88088
88176
  timers.clearTimeout(this.timeout);
88089
88177
  this.timeout = null;
88090
88178
  }
88091
- if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this));
88179
+ if (delay) if (type & USE_FAST_TIMER) this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef);
88092
88180
  else {
88093
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this));
88181
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
88094
88182
  this.timeout?.unref();
88095
88183
  }
88096
88184
  this.timeoutValue = delay;
@@ -88149,20 +88237,42 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88149
88237
  else if (ret === constants.ERROR.PAUSED) {
88150
88238
  this.paused = true;
88151
88239
  socket.unshift(data);
88152
- } else {
88153
- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
88154
- let message = "";
88155
- if (ptr) {
88156
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
88157
- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
88158
- }
88159
- throw new HTTPParserError(message, constants.ERROR[ret], data);
88160
- }
88240
+ } else throw this.createError(ret, data);
88161
88241
  }
88162
88242
  } catch (err) {
88163
88243
  util.destroy(socket, err);
88164
88244
  }
88165
88245
  }
88246
+ finish() {
88247
+ assert$23(currentParser === null);
88248
+ assert$23(this.ptr != null);
88249
+ assert$23(!this.paused);
88250
+ const { llhttp } = this;
88251
+ let ret;
88252
+ try {
88253
+ currentParser = this;
88254
+ ret = llhttp.llhttp_finish(this.ptr);
88255
+ } finally {
88256
+ currentParser = null;
88257
+ }
88258
+ if (ret === constants.ERROR.OK) return null;
88259
+ if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
88260
+ this.paused = true;
88261
+ return null;
88262
+ }
88263
+ return this.createError(ret, EMPTY_BUF);
88264
+ }
88265
+ createError(ret, data) {
88266
+ const { llhttp, contentLength, bytesRead } = this;
88267
+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) return new ResponseContentLengthMismatchError();
88268
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr);
88269
+ let message = "";
88270
+ if (ptr) {
88271
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
88272
+ message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
88273
+ }
88274
+ return new HTTPParserError(message, constants.ERROR[ret], data);
88275
+ }
88166
88276
  destroy() {
88167
88277
  assert$23(currentParser === null);
88168
88278
  assert$23(this.ptr != null);
@@ -88188,6 +88298,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88188
88298
  onMessageBegin() {
88189
88299
  const { socket, client } = this;
88190
88300
  if (socket.destroyed) return -1;
88301
+ if (client[kRunning] === 0) {
88302
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
88303
+ return -1;
88304
+ }
88191
88305
  const request = client[kQueue][client[kRunningIdx]];
88192
88306
  if (!request) return -1;
88193
88307
  request.onResponseStarted();
@@ -88274,6 +88388,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88274
88388
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
88275
88389
  const { client, socket, headers, statusText } = this;
88276
88390
  if (socket.destroyed) return -1;
88391
+ if (client[kRunning] === 0) {
88392
+ util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
88393
+ return -1;
88394
+ }
88277
88395
  const request = client[kQueue][client[kRunningIdx]];
88278
88396
  if (!request) return -1;
88279
88397
  assert$23(!this.upgrade);
@@ -88374,6 +88492,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88374
88492
  }
88375
88493
  request.onComplete(headers);
88376
88494
  client[kQueue][client[kRunningIdx]++] = null;
88495
+ socket[kSocketUsed] = client[kPending] === 0;
88377
88496
  if (socket[kWriting]) {
88378
88497
  assert$23(client[kRunning] === 0);
88379
88498
  util.destroy(socket, new InformationalError("reset"));
@@ -88419,6 +88538,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88419
88538
  socket[kWriting] = false;
88420
88539
  socket[kReset] = false;
88421
88540
  socket[kBlocking] = false;
88541
+ socket[kIdleSocketValidation] = 0;
88542
+ socket[kIdleSocketValidationTimeout] = null;
88543
+ socket[kSocketUsed] = false;
88422
88544
  socket[kParser] = new Parser(client, socket, llhttpInstance);
88423
88545
  util.addListener(socket, "error", onHttpSocketError);
88424
88546
  util.addListener(socket, "readable", onHttpSocketReadable);
@@ -88446,7 +88568,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88446
88568
  return socket.destroyed;
88447
88569
  },
88448
88570
  busy(request) {
88449
- if (socket[kWriting] || socket[kReset] || socket[kBlocking]) return true;
88571
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) return true;
88450
88572
  if (request) {
88451
88573
  if (client[kRunning] > 0 && !request.idempotent) return true;
88452
88574
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) return true;
@@ -88460,7 +88582,11 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88460
88582
  assert$23(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
88461
88583
  const parser = this[kParser];
88462
88584
  if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
88463
- parser.onMessageComplete();
88585
+ const parserErr = parser.finish();
88586
+ if (parserErr) {
88587
+ this[kError] = parserErr;
88588
+ this[kClient][kOnError](parserErr);
88589
+ }
88464
88590
  return;
88465
88591
  }
88466
88592
  this[kError] = err;
@@ -88472,15 +88598,17 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88472
88598
  function onHttpSocketEnd() {
88473
88599
  const parser = this[kParser];
88474
88600
  if (parser.statusCode && !parser.shouldKeepAlive) {
88475
- parser.onMessageComplete();
88601
+ const parserErr = parser.finish();
88602
+ if (parserErr) util.destroy(this, parserErr);
88476
88603
  return;
88477
88604
  }
88478
88605
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
88479
88606
  }
88480
88607
  function onHttpSocketClose() {
88481
88608
  const parser = this[kParser];
88609
+ clearIdleSocketValidation(this);
88482
88610
  if (parser) {
88483
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) parser.onMessageComplete();
88611
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) this[kError] = parser.finish() || this[kError];
88484
88612
  this[kParser].destroy();
88485
88613
  this[kParser] = null;
88486
88614
  }
@@ -88508,6 +88636,22 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88508
88636
  function onSocketClose() {
88509
88637
  this[kClosed] = true;
88510
88638
  }
88639
+ function clearIdleSocketValidation(socket) {
88640
+ if (socket[kIdleSocketValidationTimeout]) {
88641
+ clearTimeout(socket[kIdleSocketValidationTimeout]);
88642
+ socket[kIdleSocketValidationTimeout] = null;
88643
+ }
88644
+ socket[kIdleSocketValidation] = 0;
88645
+ }
88646
+ function scheduleIdleSocketValidation(client, socket) {
88647
+ socket[kIdleSocketValidation] = 1;
88648
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
88649
+ socket[kIdleSocketValidationTimeout] = null;
88650
+ socket[kIdleSocketValidation] = 2;
88651
+ if (client[kSocket] === socket && !socket.destroyed) client[kResume]();
88652
+ }, 0);
88653
+ socket[kIdleSocketValidationTimeout].unref?.();
88654
+ }
88511
88655
  /**
88512
88656
  * @param {import('./client.js')} client
88513
88657
  */
@@ -88523,6 +88667,23 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88523
88667
  socket.ref();
88524
88668
  socket[kNoRef] = false;
88525
88669
  }
88670
+ if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
88671
+ if (socket[kIdleSocketValidation] === 0) {
88672
+ scheduleIdleSocketValidation(client, socket);
88673
+ socket[kParser].readMore();
88674
+ if (socket.destroyed) return;
88675
+ return;
88676
+ }
88677
+ if (socket[kIdleSocketValidation] === 1) {
88678
+ socket[kParser].readMore();
88679
+ if (socket.destroyed) return;
88680
+ return;
88681
+ }
88682
+ }
88683
+ if (client[kRunning] === 0) {
88684
+ socket[kParser].readMore();
88685
+ if (socket.destroyed) return;
88686
+ }
88526
88687
  if (client[kSize] === 0) {
88527
88688
  if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
88528
88689
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
@@ -88566,6 +88727,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88566
88727
  process.emitWarning(new RequestContentLengthMismatchError());
88567
88728
  }
88568
88729
  const socket = client[kSocket];
88730
+ clearIdleSocketValidation(socket);
88569
88731
  /**
88570
88732
  * @param {Error} [err]
88571
88733
  * @returns {void}
@@ -89430,7 +89592,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89430
89592
  //#region ../../node_modules/undici/lib/dispatcher/client.js
89431
89593
  var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89432
89594
  const assert$21 = require("node:assert");
89433
- const net$2 = require("node:net");
89595
+ const net$1 = require("node:net");
89434
89596
  const http$2 = require("node:http");
89435
89597
  const util = require_util$6();
89436
89598
  const { ClientStats } = require_stats();
@@ -89459,7 +89621,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89459
89621
  * @param {string|URL} url
89460
89622
  * @param {import('../../types/client.js').Client.Options} options
89461
89623
  */
89462
- 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 } = {}) {
89624
+ 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 } = {}) {
89463
89625
  if (keepAlive !== void 0) throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
89464
89626
  if (socketTimeout !== void 0) throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
89465
89627
  if (requestTimeout !== void 0) throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
@@ -89477,7 +89639,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89477
89639
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
89478
89640
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
89479
89641
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
89480
- if (localAddress != null && (typeof localAddress !== "string" || net$2.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
89642
+ if (localAddress != null && (typeof localAddress !== "string" || net$1.isIP(localAddress) === 0)) throw new InvalidArgumentError("localAddress must be valid string IP address");
89481
89643
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) throw new InvalidArgumentError("maxResponseSize must be a positive number");
89482
89644
  if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
89483
89645
  if (allowH2 != null && typeof allowH2 !== "boolean") throw new InvalidArgumentError("allowH2 must be a valid boolean value");
@@ -89486,7 +89648,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89486
89648
  if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
89487
89649
  if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
89488
89650
  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");
89489
- super();
89651
+ super({ webSocket });
89490
89652
  if (typeof connect !== "function") connect = buildConnector({
89491
89653
  ...tls,
89492
89654
  maxCachedSessions,
@@ -89500,11 +89662,12 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89500
89662
  } : void 0,
89501
89663
  ...connect
89502
89664
  });
89503
- else if (socketPath != null) {
89665
+ else {
89504
89666
  const customConnect = connect;
89505
89667
  connect = (opts, callback) => customConnect({
89506
89668
  ...opts,
89507
- socketPath
89669
+ ...socketPath != null ? { socketPath } : null,
89670
+ ...allowH2 != null ? { allowH2 } : null
89508
89671
  }, callback);
89509
89672
  }
89510
89673
  this[kUrl] = util.parseOrigin(url);
@@ -89627,7 +89790,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89627
89790
  const idx = hostname.indexOf("]");
89628
89791
  assert$21(idx !== -1);
89629
89792
  const ip = hostname.substring(1, idx);
89630
- assert$21(net$2.isIPv6(ip));
89793
+ assert$21(net$1.isIPv6(ip));
89631
89794
  hostname = ip;
89632
89795
  }
89633
89796
  client[kConnecting] = true;
@@ -90049,7 +90212,7 @@ var require_pool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90049
90212
  } : void 0,
90050
90213
  ...connect
90051
90214
  });
90052
- super();
90215
+ super(options);
90053
90216
  this[kConnections] = connections || null;
90054
90217
  this[kUrl] = util.parseOrigin(origin);
90055
90218
  this[kOptions] = {
@@ -90123,7 +90286,7 @@ var require_balanced_pool = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90123
90286
  var BalancedPool = class extends PoolBase {
90124
90287
  constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
90125
90288
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
90126
- super();
90289
+ super(opts);
90127
90290
  this[kOptions] = { ...util.deepClone(opts) };
90128
90291
  this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
90129
90292
  this[kIndex] = -1;
@@ -90308,7 +90471,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90308
90471
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
90309
90472
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
90310
90473
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
90311
- super();
90474
+ super(options);
90312
90475
  if (connect && typeof connect !== "function") connect = { ...connect };
90313
90476
  this[kOptions] = {
90314
90477
  ...util.deepClone(options),
@@ -90398,7 +90561,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90398
90561
  //#region ../../node_modules/undici/lib/core/socks5-utils.js
90399
90562
  var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90400
90563
  const { Buffer: Buffer$2 } = require("node:buffer");
90401
- const net$1 = require("node:net");
90564
+ const net = require("node:net");
90402
90565
  const { InvalidArgumentError } = require_errors$1();
90403
90566
  /**
90404
90567
  * Parse an address and determine its type
@@ -90406,14 +90569,14 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90406
90569
  * @returns {{type: number, buffer: Buffer}} Address type and buffer
90407
90570
  */
90408
90571
  function parseAddress(address) {
90409
- if (net$1.isIPv4(address)) {
90572
+ if (net.isIPv4(address)) {
90410
90573
  const parts = address.split(".").map(Number);
90411
90574
  return {
90412
90575
  type: 1,
90413
90576
  buffer: Buffer$2.from(parts)
90414
90577
  };
90415
90578
  }
90416
- if (net$1.isIPv6(address)) return {
90579
+ if (net.isIPv6(address)) return {
90417
90580
  type: 4,
90418
90581
  buffer: parseIPv6(address)
90419
90582
  };
@@ -90431,23 +90594,36 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90431
90594
  */
90432
90595
  function parseIPv6(address) {
90433
90596
  const buffer = Buffer$2.alloc(16);
90434
- const parts = address.split(":");
90435
- let partIndex = 0;
90436
- let bufferIndex = 0;
90437
- const doubleColonIndex = address.indexOf("::");
90597
+ let normalizedAddress = address;
90598
+ if (address.includes(".")) {
90599
+ const lastColonIndex = address.lastIndexOf(":");
90600
+ const ipv4Part = address.slice(lastColonIndex + 1);
90601
+ if (net.isIPv4(ipv4Part)) {
90602
+ const octets = ipv4Part.split(".").map(Number);
90603
+ const high = (octets[0] << 8 | octets[1]).toString(16);
90604
+ const low = (octets[2] << 8 | octets[3]).toString(16);
90605
+ normalizedAddress = `${address.slice(0, lastColonIndex)}:${high}:${low}`;
90606
+ }
90607
+ }
90608
+ const doubleColonIndex = normalizedAddress.indexOf("::");
90438
90609
  if (doubleColonIndex !== -1) {
90439
- const skipParts = 8 - parts.filter((p) => p.length > 0).length;
90440
- for (let i = 0; i < parts.length; i++) if (parts[i] === "" && i === doubleColonIndex / 3) bufferIndex += skipParts * 2;
90441
- else if (parts[i] !== "") {
90442
- const value = parseInt(parts[i], 16);
90443
- buffer.writeUInt16BE(value, bufferIndex);
90610
+ const before = normalizedAddress.slice(0, doubleColonIndex);
90611
+ const after = normalizedAddress.slice(doubleColonIndex + 2);
90612
+ const beforeParts = before === "" ? [] : before.split(":");
90613
+ const afterParts = after === "" ? [] : after.split(":");
90614
+ let bufferIndex = 0;
90615
+ for (const part of beforeParts) {
90616
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
90617
+ bufferIndex += 2;
90618
+ }
90619
+ bufferIndex = 16 - afterParts.length * 2;
90620
+ for (const part of afterParts) {
90621
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
90444
90622
  bufferIndex += 2;
90445
90623
  }
90446
- } else for (const part of parts) {
90447
- if (part === "") continue;
90448
- const value = parseInt(part, 16);
90449
- buffer.writeUInt16BE(value, partIndex * 2);
90450
- partIndex++;
90624
+ } else {
90625
+ const parts = normalizedAddress.split(":");
90626
+ for (let i = 0; i < parts.length; i++) buffer.writeUInt16BE(parseInt(parts[i], 16), i * 2);
90451
90627
  }
90452
90628
  return buffer;
90453
90629
  }
@@ -90552,6 +90728,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90552
90728
  const { debuglog: debuglog$1 } = require("node:util");
90553
90729
  const { parseAddress } = require_socks5_utils();
90554
90730
  const debug = debuglog$1("undici:socks5");
90731
+ const EMPTY_BUFFER = Buffer$1.alloc(0);
90555
90732
  const SOCKS_VERSION = 5;
90556
90733
  const AUTH_METHODS = {
90557
90734
  NO_AUTH: 0,
@@ -90584,6 +90761,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90584
90761
  INITIAL: "initial",
90585
90762
  HANDSHAKING: "handshaking",
90586
90763
  AUTHENTICATING: "authenticating",
90764
+ AUTHENTICATED: "authenticated",
90587
90765
  CONNECTING: "connecting",
90588
90766
  CONNECTED: "connected",
90589
90767
  ERROR: "error",
@@ -90600,13 +90778,16 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90600
90778
  this.socket = socket;
90601
90779
  this.options = options;
90602
90780
  this.state = STATES.INITIAL;
90603
- this.buffer = Buffer$1.alloc(0);
90781
+ this.buffer = EMPTY_BUFFER;
90782
+ this.onSocketData = this.onData.bind(this);
90783
+ this.onSocketError = this.onError.bind(this);
90784
+ this.onSocketClose = this.onClose.bind(this);
90604
90785
  this.authMethods = [];
90605
90786
  if (options.username && options.password) this.authMethods.push(AUTH_METHODS.USERNAME_PASSWORD);
90606
90787
  this.authMethods.push(AUTH_METHODS.NO_AUTH);
90607
- this.socket.on("data", this.onData.bind(this));
90608
- this.socket.on("error", this.onError.bind(this));
90609
- this.socket.on("close", this.onClose.bind(this));
90788
+ this.socket.on("data", this.onSocketData);
90789
+ this.socket.on("error", this.onSocketError);
90790
+ this.socket.on("close", this.onSocketClose);
90610
90791
  }
90611
90792
  /**
90612
90793
  * Handle incoming data from the socket
@@ -90653,6 +90834,10 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90653
90834
  destroy() {
90654
90835
  if (this.socket && !this.socket.destroyed) this.socket.destroy();
90655
90836
  }
90837
+ markAuthenticated() {
90838
+ this.state = STATES.AUTHENTICATED;
90839
+ this.emit("authenticated");
90840
+ }
90656
90841
  /**
90657
90842
  * Start the SOCKS5 handshake
90658
90843
  */
@@ -90679,7 +90864,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90679
90864
  if (method === AUTH_METHODS.NO_ACCEPTABLE) throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
90680
90865
  this.buffer = this.buffer.subarray(2);
90681
90866
  debug("server selected auth method", method);
90682
- if (method === AUTH_METHODS.NO_AUTH) this.emit("authenticated");
90867
+ if (method === AUTH_METHODS.NO_AUTH) this.markAuthenticated();
90683
90868
  else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
90684
90869
  this.state = STATES.AUTHENTICATING;
90685
90870
  this.sendAuthRequest();
@@ -90714,7 +90899,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90714
90899
  if (status !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
90715
90900
  this.buffer = this.buffer.subarray(2);
90716
90901
  debug("authentication successful");
90717
- this.emit("authenticated");
90902
+ this.markAuthenticated();
90718
90903
  }
90719
90904
  /**
90720
90905
  * Send CONNECT command
@@ -90722,7 +90907,8 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90722
90907
  * @param {number} port - Target port
90723
90908
  */
90724
90909
  connect(address, port) {
90725
- if (this.state === STATES.CONNECTED) throw new InvalidArgumentError("Already connected");
90910
+ if (this.state === STATES.CONNECTING || this.state === STATES.CONNECTED) throw new InvalidArgumentError("Connection already in progress");
90911
+ if (this.state !== STATES.AUTHENTICATED) throw new InvalidArgumentError("Client must be authenticated before CONNECT");
90726
90912
  debug("connecting to", address, port);
90727
90913
  this.state = STATES.CONNECTING;
90728
90914
  const request = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
@@ -90780,8 +90966,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90780
90966
  offset += 16;
90781
90967
  }
90782
90968
  const boundPort = this.buffer.readUInt16BE(offset);
90783
- this.buffer = this.buffer.subarray(responseLength);
90969
+ this.buffer = EMPTY_BUFFER;
90784
90970
  this.state = STATES.CONNECTED;
90971
+ this.socket.removeListener("data", this.onSocketData);
90785
90972
  debug("connected, bound address:", boundAddress, "port:", boundPort);
90786
90973
  this.emit("connected", {
90787
90974
  address: boundAddress,
@@ -90817,12 +91004,11 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90817
91004
  //#endregion
90818
91005
  //#region ../../node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
90819
91006
  var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90820
- const net = require("node:net");
90821
91007
  const { URL: URL$1 } = require("node:url");
90822
91008
  let tls;
90823
91009
  const DispatcherBase = require_dispatcher_base();
90824
91010
  const { InvalidArgumentError } = require_errors$1();
90825
- const { Socks5Client } = require_socks5_client();
91011
+ const { Socks5Client, STATES } = require_socks5_client();
90826
91012
  const { kDispatch, kClose, kDestroy } = require_symbols();
90827
91013
  const Pool = require_pool();
90828
91014
  const buildConnector = require_connect();
@@ -90831,8 +91017,10 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90831
91017
  const kProxyUrl = Symbol("proxy url");
90832
91018
  const kProxyHeaders = Symbol("proxy headers");
90833
91019
  const kProxyAuth = Symbol("proxy auth");
90834
- const kPool = Symbol("pool");
91020
+ const kProxyProtocol = Symbol("proxy protocol");
91021
+ const kPools = Symbol("pools");
90835
91022
  const kConnector = Symbol("connector");
91023
+ const kRequestTls = Symbol("request tls settings");
90836
91024
  let experimentalWarningEmitted = false;
90837
91025
  /**
90838
91026
  * SOCKS5 proxy agent for dispatching requests through a SOCKS5 proxy
@@ -90849,6 +91037,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90849
91037
  if (url.protocol !== "socks5:" && url.protocol !== "socks:") throw new InvalidArgumentError("Proxy URL must use socks5:// or socks:// protocol");
90850
91038
  this[kProxyUrl] = url;
90851
91039
  this[kProxyHeaders] = options.headers || {};
91040
+ this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
91041
+ this[kRequestTls] = options.requestTls;
90852
91042
  this[kProxyAuth] = {
90853
91043
  username: options.username || (url.username ? decodeURIComponent(url.username) : null),
90854
91044
  password: options.password || (url.password ? decodeURIComponent(url.password) : null)
@@ -90857,7 +91047,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90857
91047
  ...options.proxyTls,
90858
91048
  servername: options.proxyTls?.servername || url.hostname
90859
91049
  });
90860
- this[kPool] = null;
91050
+ this[kPools] = /* @__PURE__ */ new Map();
90861
91051
  }
90862
91052
  /**
90863
91053
  * Create a SOCKS5 connection to the proxy
@@ -90867,20 +91057,15 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90867
91057
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
90868
91058
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
90869
91059
  const socket = await new Promise((resolve, reject) => {
90870
- const onConnect = () => {
90871
- socket.removeListener("error", onError);
90872
- resolve(socket);
90873
- };
90874
- const onError = (err) => {
90875
- socket.removeListener("connect", onConnect);
90876
- reject(err);
90877
- };
90878
- const socket = net.connect({
91060
+ this[kConnector]({
91061
+ hostname: proxyHost,
90879
91062
  host: proxyHost,
90880
- port: proxyPort
91063
+ port: proxyPort,
91064
+ protocol: this[kProxyProtocol]
91065
+ }, (err, socket) => {
91066
+ if (err) reject(err);
91067
+ else resolve(socket);
90881
91068
  });
90882
- socket.once("connect", onConnect);
90883
- socket.once("error", onError);
90884
91069
  });
90885
91070
  const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
90886
91071
  socks5Client.on("error", (err) => {
@@ -90902,7 +91087,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90902
91087
  socks5Client.removeListener("authenticated", onAuthenticated);
90903
91088
  reject(err);
90904
91089
  };
90905
- if (socks5Client.state === "authenticated") {
91090
+ if (socks5Client.state === STATES.AUTHENTICATED) {
90906
91091
  clearTimeout(timeout);
90907
91092
  resolve();
90908
91093
  } else {
@@ -90934,53 +91119,69 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90934
91119
  /**
90935
91120
  * Dispatch a request through the SOCKS5 proxy
90936
91121
  */
90937
- async [kDispatch](opts, handler) {
91122
+ [kDispatch](opts, handler) {
90938
91123
  const { origin } = opts;
90939
91124
  debug("dispatching request to", origin, "via SOCKS5");
90940
91125
  try {
90941
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) this[kPool] = new Pool(origin, {
90942
- pipelining: opts.pipelining,
90943
- connections: opts.connections,
90944
- connect: async (connectOpts, callback) => {
90945
- try {
90946
- const url = new URL$1(origin);
90947
- const targetHost = url.hostname;
90948
- const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
90949
- debug("establishing SOCKS5 connection to", targetHost, targetPort);
90950
- const socket = await this.createSocks5Connection(targetHost, targetPort);
90951
- let finalSocket = socket;
90952
- if (url.protocol === "https:") {
90953
- if (!tls) tls = require("node:tls");
90954
- debug("upgrading to TLS");
90955
- finalSocket = tls.connect({
90956
- socket,
90957
- servername: targetHost,
90958
- ...connectOpts.tls || {}
90959
- });
90960
- await new Promise((resolve, reject) => {
90961
- finalSocket.once("secureConnect", resolve);
90962
- finalSocket.once("error", reject);
90963
- });
91126
+ const originKey = String(origin);
91127
+ let pool = this[kPools].get(originKey);
91128
+ if (!pool || pool.destroyed || pool.closed) {
91129
+ pool = new Pool(origin, {
91130
+ pipelining: opts.pipelining,
91131
+ connections: opts.connections,
91132
+ connect: async (connectOpts, callback) => {
91133
+ try {
91134
+ const url = new URL$1(origin);
91135
+ const targetHost = url.hostname;
91136
+ const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
91137
+ debug("establishing SOCKS5 connection to", targetHost, targetPort);
91138
+ const socket = await this.createSocks5Connection(targetHost, targetPort);
91139
+ let finalSocket = socket;
91140
+ if (url.protocol === "https:") {
91141
+ if (!tls) tls = require("node:tls");
91142
+ debug("upgrading to TLS");
91143
+ finalSocket = tls.connect({
91144
+ ...this[kRequestTls],
91145
+ socket,
91146
+ servername: this[kRequestTls]?.servername || targetHost
91147
+ });
91148
+ await new Promise((resolve, reject) => {
91149
+ finalSocket.once("secureConnect", resolve);
91150
+ finalSocket.once("error", reject);
91151
+ });
91152
+ }
91153
+ callback(null, finalSocket);
91154
+ } catch (err) {
91155
+ debug("SOCKS5 connection error:", err);
91156
+ callback(err);
90964
91157
  }
90965
- callback(null, finalSocket);
90966
- } catch (err) {
90967
- debug("SOCKS5 connection error:", err);
90968
- callback(err);
90969
91158
  }
90970
- }
90971
- });
90972
- return this[kPool][kDispatch](opts, handler);
91159
+ });
91160
+ this[kPools].set(originKey, pool);
91161
+ }
91162
+ return pool[kDispatch](opts, handler);
90973
91163
  } catch (err) {
90974
91164
  debug("dispatch error:", err);
90975
- if (typeof handler.onError === "function") handler.onError(err);
90976
- else throw err;
91165
+ if (typeof handler.onResponseError === "function") {
91166
+ handler.onResponseError(null, err);
91167
+ return false;
91168
+ } else if (typeof handler.onError === "function") {
91169
+ handler.onError(err);
91170
+ return false;
91171
+ } else throw err;
90977
91172
  }
90978
91173
  }
90979
91174
  async [kClose]() {
90980
- if (this[kPool]) await this[kPool].close();
91175
+ const closePromises = [];
91176
+ for (const pool of this[kPools].values()) closePromises.push(pool.close());
91177
+ this[kPools].clear();
91178
+ await Promise.all(closePromises);
90981
91179
  }
90982
91180
  async [kDestroy](err) {
90983
- if (this[kPool]) await this[kPool].destroy(err);
91181
+ const destroyPromises = [];
91182
+ for (const pool of this[kPools].values()) destroyPromises.push(pool.destroy(err));
91183
+ this[kPools].clear();
91184
+ await Promise.all(destroyPromises);
90984
91185
  }
90985
91186
  };
90986
91187
  module.exports = Socks5ProxyAgent;
@@ -91084,7 +91285,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
91084
91285
  factory: agentFactory,
91085
91286
  username: opts.username || username,
91086
91287
  password: opts.password || password,
91087
- proxyTls: opts.proxyTls
91288
+ proxyTls: opts.proxyTls,
91289
+ requestTls: opts.requestTls
91088
91290
  });
91089
91291
  if (!this[kTunnelProxy] && protocol === "http:" && this[kProxy].protocol === "http:") return new Http1ProxyWrapper(this[kProxy].uri, {
91090
91292
  headers: this[kProxyHeaders],
@@ -91592,7 +91794,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
91592
91794
  constructor(origin, clientOpts) {
91593
91795
  if (typeof origin === "string") origin = new URL(origin);
91594
91796
  if (origin.protocol !== "http:") throw new InvalidArgumentError("h2c-client: Only h2c protocol is supported");
91595
- const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
91797
+ const { maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
91596
91798
  let defaultMaxConcurrentStreams = 100;
91597
91799
  let defaultPipelining = 100;
91598
91800
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) defaultMaxConcurrentStreams = maxConcurrentStreams;
@@ -92037,7 +92239,7 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92037
92239
  const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
92038
92240
  try {
92039
92241
  if (typeof callback !== "function") throw new InvalidArgumentError("invalid callback");
92040
- if (highWaterMark && (typeof highWaterMark !== "number" || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
92242
+ if (highWaterMark != null && (!Number.isFinite(highWaterMark) || highWaterMark < 0)) throw new InvalidArgumentError("invalid highWaterMark");
92041
92243
  if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
92042
92244
  if (method === "CONNECT") throw new InvalidArgumentError("invalid method");
92043
92245
  if (onInfo && typeof onInfo !== "function") throw new InvalidArgumentError("invalid onInfo callback");
@@ -93223,12 +93425,12 @@ var require_mock_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
93223
93425
  var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module) => {
93224
93426
  const { kMockCallHistoryAddLog } = require_mock_symbols();
93225
93427
  const { InvalidArgumentError } = require_errors$1();
93226
- function handleFilterCallsWithOptions(criteria, options, handler, store) {
93428
+ function handleFilterCallsWithOptions(criteria, options, handler, store, allLogs) {
93227
93429
  switch (options.operator) {
93228
93430
  case "OR":
93229
- store.push(...handler(criteria));
93431
+ store.push(...handler(criteria, allLogs));
93230
93432
  return store;
93231
- case "AND": return handler.call({ logs: store }, criteria);
93433
+ case "AND": return handler(criteria, store);
93232
93434
  default: throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
93233
93435
  }
93234
93436
  }
@@ -93244,11 +93446,11 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
93244
93446
  return finalOptions;
93245
93447
  }
93246
93448
  function makeFilterCalls(parameterName) {
93247
- return (parameterValue) => {
93248
- if (typeof parameterValue === "string" || parameterValue == null) return this.logs.filter((log) => {
93449
+ return (parameterValue, logs) => {
93450
+ if (typeof parameterValue === "string" || parameterValue == null) return logs.filter((log) => {
93249
93451
  return log[parameterName] === parameterValue;
93250
93452
  });
93251
- if (parameterValue instanceof RegExp) return this.logs.filter((log) => {
93453
+ if (parameterValue instanceof RegExp) return logs.filter((log) => {
93252
93454
  return parameterValue.test(log[parameterName]);
93253
93455
  });
93254
93456
  throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
@@ -93336,15 +93538,15 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
93336
93538
  operator: "OR",
93337
93539
  ...buildAndValidateFilterCallsOptions(options)
93338
93540
  };
93339
- let maybeDuplicatedLogsFiltered = [];
93340
- if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
93341
- if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
93342
- if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
93343
- if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
93344
- if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
93345
- if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
93346
- if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
93347
- if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered);
93541
+ let maybeDuplicatedLogsFiltered = finalOptions.operator === "AND" ? this.logs : [];
93542
+ if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered, this.logs);
93543
+ if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered, this.logs);
93544
+ if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered, this.logs);
93545
+ if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered, this.logs);
93546
+ if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered, this.logs);
93547
+ if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered, this.logs);
93548
+ if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered, this.logs);
93549
+ if ("method" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered, this.logs);
93348
93550
  return [...new Set(maybeDuplicatedLogsFiltered)];
93349
93551
  }
93350
93552
  throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
@@ -94393,7 +94595,8 @@ var require_snapshot_agent = /* @__PURE__ */ __commonJSMin(((exports, module) =>
94393
94595
  //#endregion
94394
94596
  //#region ../../node_modules/undici/lib/global.js
94395
94597
  var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
94396
- const globalDispatcher = Symbol.for("undici.globalDispatcher.1");
94598
+ const globalDispatcher = Symbol.for("undici.globalDispatcher.2");
94599
+ const legacyGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");
94397
94600
  const { InvalidArgumentError } = require_errors$1();
94398
94601
  const Agent = require_agent();
94399
94602
  if (getGlobalDispatcher() === void 0) setGlobalDispatcher(new Agent());
@@ -94405,9 +94608,15 @@ var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
94405
94608
  enumerable: false,
94406
94609
  configurable: false
94407
94610
  });
94611
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
94612
+ value: agent,
94613
+ writable: true,
94614
+ enumerable: false,
94615
+ configurable: false
94616
+ });
94408
94617
  }
94409
94618
  function getGlobalDispatcher() {
94410
- return globalThis[globalDispatcher];
94619
+ return globalThis[legacyGlobalDispatcher];
94411
94620
  }
94412
94621
  module.exports = {
94413
94622
  setGlobalDispatcher,
@@ -95106,7 +95315,7 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95106
95315
  function makeCacheKey(opts) {
95107
95316
  if (!opts.origin) throw new Error("opts.origin is undefined");
95108
95317
  let fullPath = opts.path || "/";
95109
- if (opts.query && !pathHasQueryOrFragment(opts.path)) fullPath = serializePathWithQuery(fullPath, opts.query);
95318
+ if (opts.query && !pathHasQueryOrFragment(fullPath)) fullPath = serializePathWithQuery(fullPath, opts.query);
95110
95319
  return {
95111
95320
  origin: opts.origin.toString(),
95112
95321
  method: opts.method,
@@ -95222,11 +95431,15 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95222
95431
  lastHeader = lastHeader.substring(0, lastHeader.length - 1);
95223
95432
  headers[headers.length - 1] = lastHeader;
95224
95433
  }
95434
+ for (let j = 0; j < headers.length; j++) headers[j] = headers[j].trim();
95225
95435
  if (key in output) output[key] = output[key].concat(headers);
95226
95436
  else output[key] = headers;
95227
95437
  }
95228
- } else if (key in output) output[key] = output[key].concat(value);
95229
- else output[key] = [value];
95438
+ } else {
95439
+ const fieldName = value.trim();
95440
+ if (key in output) output[key] = output[key].concat(fieldName);
95441
+ else output[key] = [fieldName];
95442
+ }
95230
95443
  break;
95231
95444
  }
95232
95445
  case "public":
@@ -95304,16 +95517,20 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95304
95517
  * @returns {string}
95305
95518
  */
95306
95519
  function makeDeduplicationKey(cacheKey, excludeHeaders) {
95307
- let key = `${cacheKey.origin}:${cacheKey.method}:${cacheKey.path}`;
95520
+ const headers = {};
95308
95521
  if (cacheKey.headers) {
95309
95522
  const sortedHeaders = Object.keys(cacheKey.headers).sort();
95310
95523
  for (const header of sortedHeaders) {
95311
95524
  if (excludeHeaders?.has(header.toLowerCase())) continue;
95312
- const value = cacheKey.headers[header];
95313
- key += `:${header}=${Array.isArray(value) ? value.join(",") : value}`;
95525
+ headers[header] = cacheKey.headers[header];
95314
95526
  }
95315
95527
  }
95316
- return key;
95528
+ return JSON.stringify([
95529
+ cacheKey.origin,
95530
+ cacheKey.method,
95531
+ cacheKey.path,
95532
+ headers
95533
+ ]);
95317
95534
  }
95318
95535
  module.exports = {
95319
95536
  makeCacheKey,
@@ -97252,7 +97469,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97252
97469
  SELECT
97253
97470
  id
97254
97471
  FROM cacheInterceptorV${VERSION}
97255
- ORDER BY cachedAt DESC
97472
+ ORDER BY cachedAt ASC
97256
97473
  LIMIT ?
97257
97474
  )
97258
97475
  `);
@@ -97293,8 +97510,8 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97293
97510
  const existingValue = this.#findValue(key, true);
97294
97511
  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);
97295
97512
  else {
97296
- this.#prune();
97297
97513
  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);
97514
+ this.#prune();
97298
97515
  }
97299
97516
  }
97300
97517
  /**
@@ -97377,7 +97594,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97377
97594
  if (values.length === 0) return;
97378
97595
  const now = Date.now();
97379
97596
  for (const value of values) {
97380
- if (now >= value.deleteAt && !canBeExpired) return;
97597
+ if (now >= value.deleteAt && !canBeExpired) continue;
97381
97598
  let matches = true;
97382
97599
  if (value.vary) {
97383
97600
  const vary = JSON.parse(value.vary);
@@ -99207,7 +99424,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99207
99424
  cacheState = "";
99208
99425
  }
99209
99426
  let responseStatus = 0;
99210
- if (fetchParams.request.mode !== "navigator" || !response.hasCrossOriginRedirects) {
99427
+ if (fetchParams.request.mode !== "navigate" || !response.hasCrossOriginRedirects) {
99211
99428
  responseStatus = response.status;
99212
99429
  const mimeType = extractMimeType(response.headersList);
99213
99430
  if (mimeType !== "failure") bodyInfo.contentType = minimizeSupportedMimeType(mimeType);
@@ -99311,7 +99528,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99311
99528
  let contentLengthHeaderValue = null;
99312
99529
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) contentLengthHeaderValue = "0";
99313
99530
  if (contentLength != null) contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
99314
- if (contentLengthHeaderValue != null) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
99531
+ if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
99315
99532
  if (contentLength != null && httpRequest.keepalive) {}
99316
99533
  if (webidl.is.URL(httpRequest.referrer)) httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
99317
99534
  appendRequestOriginHeader(httpRequest);
@@ -100431,7 +100648,6 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100431
100648
  const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$1();
100432
100649
  const { isCTLExcludingHtab } = require_util$3();
100433
100650
  const assert$2 = require("node:assert");
100434
- const { unescape: qsUnescape } = require("node:querystring");
100435
100651
  /**
100436
100652
  * @description Parses the field-value attributes of a set-cookie header string.
100437
100653
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4
@@ -100460,7 +100676,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100460
100676
  if (name.length + value.length > maxNameValuePairSize) return null;
100461
100677
  return {
100462
100678
  name,
100463
- value: qsUnescape(value),
100679
+ value,
100464
100680
  ...parseUnparsedAttributes(unparsedAttributes)
100465
100681
  };
100466
100682
  }
@@ -100512,12 +100728,10 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100512
100728
  } else if (attributeNameLowercase === "secure") cookieAttributeList.secure = true;
100513
100729
  else if (attributeNameLowercase === "httponly") cookieAttributeList.httpOnly = true;
100514
100730
  else if (attributeNameLowercase === "samesite") {
100515
- let enforcement = "Default";
100516
100731
  const attributeValueLowercase = attributeValue.toLowerCase();
100517
- if (attributeValueLowercase.includes("none")) enforcement = "None";
100518
- if (attributeValueLowercase.includes("strict")) enforcement = "Strict";
100519
- if (attributeValueLowercase.includes("lax")) enforcement = "Lax";
100520
- cookieAttributeList.sameSite = enforcement;
100732
+ if (attributeValueLowercase === "none") cookieAttributeList.sameSite = "None";
100733
+ else if (attributeValueLowercase === "strict") cookieAttributeList.sameSite = "Strict";
100734
+ else if (attributeValueLowercase === "lax") cookieAttributeList.sameSite = "Lax";
100521
100735
  } else {
100522
100736
  cookieAttributeList.unparsed ??= [];
100523
100737
  cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
@@ -101466,27 +101680,26 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101466
101680
  ]);
101467
101681
  const kBuffer = Symbol("kBuffer");
101468
101682
  const kLength = Symbol("kLength");
101469
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024;
101470
101683
  var PerMessageDeflate = class {
101471
101684
  /** @type {import('node:zlib').InflateRaw} */
101472
101685
  #inflate;
101473
101686
  #options = {};
101474
- /** @type {boolean} */
101475
- #aborted = false;
101476
- /** @type {Function|null} */
101477
- #currentCallback = null;
101687
+ #maxPayloadSize = 0;
101478
101688
  /**
101479
101689
  * @param {Map<string, string>} extensions
101480
101690
  */
101481
- constructor(extensions) {
101691
+ constructor(extensions, options) {
101482
101692
  this.#options.serverNoContextTakeover = extensions.has("server_no_context_takeover");
101483
101693
  this.#options.serverMaxWindowBits = extensions.get("server_max_window_bits");
101694
+ this.#maxPayloadSize = options.maxPayloadSize;
101484
101695
  }
101696
+ /**
101697
+ * Decompress a compressed payload.
101698
+ * @param {Buffer} chunk Compressed data
101699
+ * @param {boolean} fin Final fragment flag
101700
+ * @param {Function} callback Callback function
101701
+ */
101485
101702
  decompress(chunk, fin, callback) {
101486
- if (this.#aborted) {
101487
- callback(new MessageSizeExceededError());
101488
- return;
101489
- }
101490
101703
  if (!this.#inflate) {
101491
101704
  let windowBits = Z_DEFAULT_WINDOWBITS;
101492
101705
  if (this.#options.serverMaxWindowBits) {
@@ -101505,18 +101718,11 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101505
101718
  this.#inflate[kBuffer] = [];
101506
101719
  this.#inflate[kLength] = 0;
101507
101720
  this.#inflate.on("data", (data) => {
101508
- if (this.#aborted) return;
101509
101721
  this.#inflate[kLength] += data.length;
101510
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
101511
- this.#aborted = true;
101722
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
101723
+ callback(new MessageSizeExceededError());
101512
101724
  this.#inflate.removeAllListeners();
101513
- this.#inflate.destroy();
101514
101725
  this.#inflate = null;
101515
- if (this.#currentCallback) {
101516
- const cb = this.#currentCallback;
101517
- this.#currentCallback = null;
101518
- cb(new MessageSizeExceededError());
101519
- }
101520
101726
  return;
101521
101727
  }
101522
101728
  this.#inflate[kBuffer].push(data);
@@ -101526,15 +101732,13 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101526
101732
  callback(err);
101527
101733
  });
101528
101734
  }
101529
- this.#currentCallback = callback;
101530
101735
  this.#inflate.write(chunk);
101531
101736
  if (fin) this.#inflate.write(tail);
101532
101737
  this.#inflate.flush(() => {
101533
- if (this.#aborted || !this.#inflate) return;
101738
+ if (!this.#inflate) return;
101534
101739
  const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength]);
101535
101740
  this.#inflate[kBuffer].length = 0;
101536
101741
  this.#inflate[kLength] = 0;
101537
- this.#currentCallback = null;
101538
101742
  callback(null, full);
101539
101743
  });
101540
101744
  }
@@ -101564,15 +101768,22 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101564
101768
  #extensions;
101565
101769
  /** @type {import('./websocket').Handler} */
101566
101770
  #handler;
101771
+ /** @type {number} */
101772
+ #maxFragments;
101773
+ /** @type {number} */
101774
+ #maxPayloadSize;
101567
101775
  /**
101568
101776
  * @param {import('./websocket').Handler} handler
101569
101777
  * @param {Map<string, string>|null} extensions
101778
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
101570
101779
  */
101571
- constructor(handler, extensions) {
101780
+ constructor(handler, extensions, options = {}) {
101572
101781
  super();
101573
101782
  this.#handler = handler;
101574
101783
  this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
101575
- if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions));
101784
+ this.#maxFragments = options.maxFragments ?? 0;
101785
+ this.#maxPayloadSize = options.maxPayloadSize ?? 0;
101786
+ if (this.#extensions.has("permessage-deflate")) this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions, options));
101576
101787
  }
101577
101788
  /**
101578
101789
  * @param {Buffer} chunk
@@ -101584,6 +101795,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101584
101795
  this.#loop = true;
101585
101796
  this.run(callback);
101586
101797
  }
101798
+ #validatePayloadLength() {
101799
+ if (this.#maxPayloadSize > 0 && !isControlFrame(this.#info.opcode) && this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize) {
101800
+ failWebsocketConnection(this.#handler, 1009, "Payload size exceeds maximum allowed size");
101801
+ return false;
101802
+ }
101803
+ return true;
101804
+ }
101587
101805
  /**
101588
101806
  * Runs whenever a new chunk is received.
101589
101807
  * Callback is called whenever there are no more chunks buffering,
@@ -101640,6 +101858,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101640
101858
  if (payloadLength <= 125) {
101641
101859
  this.#info.payloadLength = payloadLength;
101642
101860
  this.#state = parserStates.READ_DATA;
101861
+ if (!this.#validatePayloadLength()) return;
101643
101862
  } else if (payloadLength === 126) this.#state = parserStates.PAYLOADLENGTH_16;
101644
101863
  else if (payloadLength === 127) this.#state = parserStates.PAYLOADLENGTH_64;
101645
101864
  if (isTextBinaryFrame(opcode)) {
@@ -101655,6 +101874,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101655
101874
  const buffer = this.consume(2);
101656
101875
  this.#info.payloadLength = buffer.readUInt16BE(0);
101657
101876
  this.#state = parserStates.READ_DATA;
101877
+ if (!this.#validatePayloadLength()) return;
101658
101878
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
101659
101879
  if (this.#byteOffset < 8) return callback();
101660
101880
  const buffer = this.consume(8);
@@ -101666,6 +101886,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101666
101886
  }
101667
101887
  this.#info.payloadLength = lower;
101668
101888
  this.#state = parserStates.READ_DATA;
101889
+ if (!this.#validatePayloadLength()) return;
101669
101890
  } else if (this.#state === parserStates.READ_DATA) {
101670
101891
  if (this.#byteOffset < this.#info.payloadLength) return callback();
101671
101892
  const body = this.consume(this.#info.payloadLength);
@@ -101673,7 +101894,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101673
101894
  this.#loop = this.parseControlFrame(body);
101674
101895
  this.#state = parserStates.INFO;
101675
101896
  } else if (!this.#info.compressed) {
101676
- this.writeFragments(body);
101897
+ if (!this.writeFragments(body)) return;
101677
101898
  if (!this.#info.fragmented && this.#info.fin) websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments());
101678
101899
  this.#state = parserStates.INFO;
101679
101900
  } else {
@@ -101683,7 +101904,11 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101683
101904
  failWebsocketConnection(this.#handler, code, error.message);
101684
101905
  return;
101685
101906
  }
101686
- this.writeFragments(data);
101907
+ if (!this.writeFragments(data)) return;
101908
+ if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
101909
+ failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message);
101910
+ return;
101911
+ }
101687
101912
  if (!this.#info.fin) {
101688
101913
  this.#state = parserStates.INFO;
101689
101914
  this.#loop = true;
@@ -101694,7 +101919,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101694
101919
  this.#loop = true;
101695
101920
  this.#state = parserStates.INFO;
101696
101921
  this.run(callback);
101697
- });
101922
+ }, this.#fragmentsBytes);
101698
101923
  this.#loop = false;
101699
101924
  break;
101700
101925
  }
@@ -101736,8 +101961,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101736
101961
  }
101737
101962
  }
101738
101963
  writeFragments(fragment) {
101964
+ if (this.#maxFragments > 0 && this.#fragments.length === this.#maxFragments) {
101965
+ failWebsocketConnection(this.#handler, 1008, "Too many message fragments");
101966
+ return false;
101967
+ }
101739
101968
  this.#fragmentsBytes += fragment.length;
101740
101969
  this.#fragments.push(fragment);
101970
+ return true;
101741
101971
  }
101742
101972
  consumeFragments() {
101743
101973
  const fragments = this.#fragments;
@@ -102158,7 +102388,13 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
102158
102388
  */
102159
102389
  #onConnectionEstablished(response, parsedExtensions) {
102160
102390
  this.#handler.socket = response.socket;
102161
- const parser = new ByteParser(this.#handler, parsedExtensions);
102391
+ const webSocketOptions = this.#handler.controller.dispatcher?.webSocketOptions;
102392
+ const maxFragments = webSocketOptions?.maxFragments;
102393
+ const maxPayloadSize = webSocketOptions?.maxPayloadSize;
102394
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
102395
+ maxFragments,
102396
+ maxPayloadSize
102397
+ });
102162
102398
  parser.on("drain", () => this.#handler.onParserDrain());
102163
102399
  parser.on("error", (err) => this.#handler.onParserError(err));
102164
102400
  this.#parser = parser;
@@ -102527,7 +102763,12 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102527
102763
  /** @type {import('../websocket').Handler['onConnectionEstablished']} */
102528
102764
  #onConnectionEstablished(response, parsedExtensions) {
102529
102765
  this.#handler.socket = response.socket;
102530
- const parser = new ByteParser(this.#handler, parsedExtensions);
102766
+ const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
102767
+ const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
102768
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
102769
+ maxFragments,
102770
+ maxPayloadSize
102771
+ });
102531
102772
  parser.on("drain", () => this.#handler.onParserDrain());
102532
102773
  parser.on("error", (err) => this.#handler.onParserError(err));
102533
102774
  this.#parser = parser;
@@ -102538,10 +102779,6 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102538
102779
  start: (controller) => {
102539
102780
  this.#readableStreamController = controller;
102540
102781
  },
102541
- pull(controller) {
102542
- let chunk;
102543
- while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) controller.enqueue(chunk);
102544
- },
102545
102782
  cancel: (reason) => this.#cancel(reason)
102546
102783
  });
102547
102784
  const writable = new WritableStream({
@@ -102565,7 +102802,7 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102565
102802
  if (type === opcodes.TEXT) try {
102566
102803
  chunk = utf8Decode(data);
102567
102804
  } catch {
102568
- failWebsocketConnection(this.#handler, "Received invalid UTF-8 in text frame.");
102805
+ failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame.");
102569
102806
  return;
102570
102807
  }
102571
102808
  else if (type === opcodes.BINARY) chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
@@ -103804,15 +104041,135 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
103804
104041
  exports.isFile = isFile;
103805
104042
  }));
103806
104043
  //#endregion
104044
+ //#region ../base/dist/helpers/logger.js
104045
+ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
104046
+ var __importDefault = exports && exports.__importDefault || function(mod) {
104047
+ return mod && mod.__esModule ? mod : { "default": mod };
104048
+ };
104049
+ Object.defineProperty(exports, "__esModule", { value: true });
104050
+ exports.Logger = exports.LogLevel = void 0;
104051
+ const chalk_1 = __importDefault(require_source$1());
104052
+ var LogLevel;
104053
+ (function(LogLevel) {
104054
+ LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
104055
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
104056
+ LogLevel[LogLevel["WARN"] = 3] = "WARN";
104057
+ LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
104058
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
104059
+ const LEVEL_NAMES = {
104060
+ [LogLevel.DEBUG]: "debug",
104061
+ [LogLevel.INFO]: "info",
104062
+ [LogLevel.WARN]: "warn",
104063
+ [LogLevel.ERROR]: "error"
104064
+ };
104065
+ var Logger = class {
104066
+ constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
104067
+ var _a, _b;
104068
+ const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
104069
+ this.rawWriteMessage = writeMessage;
104070
+ this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
104071
+ this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
104072
+ this.loglevel = loglevel;
104073
+ }
104074
+ setLogLevel(newLogLevel) {
104075
+ this.loglevel = newLogLevel;
104076
+ }
104077
+ setShouldIncludeTime(newShouldIncludeTimestamp) {
104078
+ this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
104079
+ }
104080
+ setJsonOutput(newJsonOutput) {
104081
+ this.jsonOutput = newJsonOutput;
104082
+ }
104083
+ isJsonOutput() {
104084
+ return this.jsonOutput;
104085
+ }
104086
+ error(s) {
104087
+ if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
104088
+ }
104089
+ warn(s) {
104090
+ if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
104091
+ }
104092
+ info(s) {
104093
+ if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
104094
+ }
104095
+ debug(s) {
104096
+ if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
104097
+ }
104098
+ emit(level, message, colorize) {
104099
+ if (this.jsonOutput) {
104100
+ const payload = {
104101
+ level: LEVEL_NAMES[level],
104102
+ message
104103
+ };
104104
+ if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
104105
+ this.rawWriteMessage(JSON.stringify(payload) + "\n");
104106
+ return;
104107
+ }
104108
+ const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
104109
+ const body = colorize ? colorize(message) : message;
104110
+ this.rawWriteMessage(prefix + body + "\n");
104111
+ }
104112
+ };
104113
+ exports.Logger = Logger;
104114
+ }));
104115
+ //#endregion
103807
104116
  //#region ../base/dist/index.js
103808
104117
  var require_dist$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
104118
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
104119
+ if (k2 === void 0) k2 = k;
104120
+ var desc = Object.getOwnPropertyDescriptor(m, k);
104121
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
104122
+ enumerable: true,
104123
+ get: function() {
104124
+ return m[k];
104125
+ }
104126
+ };
104127
+ Object.defineProperty(o, k2, desc);
104128
+ }) : (function(o, m, k, k2) {
104129
+ if (k2 === void 0) k2 = k;
104130
+ o[k2] = m[k];
104131
+ }));
104132
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
104133
+ Object.defineProperty(o, "default", {
104134
+ enumerable: true,
104135
+ value: v
104136
+ });
104137
+ }) : function(o, v) {
104138
+ o["default"] = v;
104139
+ });
104140
+ var __importStar = exports && exports.__importStar || function(mod) {
104141
+ if (mod && mod.__esModule) return mod;
104142
+ var result = {};
104143
+ if (mod != null) {
104144
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
104145
+ }
104146
+ __setModuleDefault(result, mod);
104147
+ return result;
104148
+ };
103809
104149
  Object.defineProperty(exports, "__esModule", { value: true });
103810
104150
  exports.BaseCommand = void 0;
103811
104151
  const clipanion_1 = require_advanced();
104152
+ const t = __importStar(require_lib$3());
104153
+ const constants_1 = require_constants$9();
104154
+ const logger_1 = require_logger();
103812
104155
  /**
103813
104156
  * This command should be extended by **every** command in the monorepo.
103814
104157
  */
103815
- var BaseCommand = class extends clipanion_1.Command {};
104158
+ var BaseCommand = class extends clipanion_1.Command {
104159
+ constructor() {
104160
+ super(...arguments);
104161
+ this.logFormat = clipanion_1.Option.String("--log-format", "text", {
104162
+ env: constants_1.LOG_FORMAT_ENV_VAR,
104163
+ hidden: true,
104164
+ description: "Output format for logs: 'text' (default) or 'json' (one JSON object per line).",
104165
+ validator: t.isEnum(["text", "json"])
104166
+ });
104167
+ }
104168
+ get logger() {
104169
+ if (!this._logger) this._logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO, { jsonOutput: this.logFormat === "json" });
104170
+ return this._logger;
104171
+ }
104172
+ };
103816
104173
  exports.BaseCommand = BaseCommand;
103817
104174
  }));
103818
104175
  //#endregion
@@ -103848,12 +104205,12 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
103848
104205
  Object.defineProperty(exports, "__esModule", { value: true });
103849
104206
  exports.ContainerAppCommand = void 0;
103850
104207
  const clipanion_1 = require_advanced();
103851
- const constants_1 = require_constants$8();
104208
+ const constants_1 = require_constants$9();
103852
104209
  const env_1 = require_env();
103853
104210
  const fips_1 = require_fips();
103854
104211
  const renderer_1 = require_renderer$1();
103855
104212
  const azure_1 = require_azure();
103856
- const constants_2 = require_constants$9();
104213
+ const constants_2 = require_constants$8();
103857
104214
  const utils_1 = require_utils();
103858
104215
  const __1 = require_dist$4();
103859
104216
  var ContainerAppCommand = class extends __1.BaseCommand {
@@ -103966,7 +104323,7 @@ var require_instrument = /* @__PURE__ */ __commonJSMin(((exports) => {
103966
104323
  const clipanion_1 = require_advanced();
103967
104324
  const typanion_1 = require_lib$3();
103968
104325
  const plugin_1 = require_plugin();
103969
- const constants_1 = require_constants$9();
104326
+ const constants_1 = require_constants$8();
103970
104327
  const common_1 = require_common$1();
103971
104328
  exports.DEFAULT_SIDECAR_CPU = .5;
103972
104329
  exports.DEFAULT_SIDECAR_MEMORY = 1;
@@ -104028,7 +104385,7 @@ var require_instrument = /* @__PURE__ */ __commonJSMin(((exports) => {
104028
104385
  var require_api$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
104029
104386
  Object.defineProperty(exports, "__esModule", { value: true });
104030
104387
  exports.getBaseIntakeUrl = exports.getApiUrl = exports.getIntakeUrl = exports.getDatadogSite = exports.getDatadogSiteFromEnv = void 0;
104031
- const constants_1 = require_constants$8();
104388
+ const constants_1 = require_constants$9();
104032
104389
  /**
104033
104390
  * Read the Datadog site from `DATADOG_SITE` / `DD_SITE` env vars.
104034
104391
  * Returns `undefined` when neither is set.
@@ -107095,9 +107452,9 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
107095
107452
  const node_util_1 = require("node:util");
107096
107453
  const chalk_1 = __importDefault(require_source$1());
107097
107454
  const jest_diff_1 = require_build();
107098
- const constants_1 = require_constants$8();
107455
+ const constants_1 = require_constants$9();
107099
107456
  const api_1 = require_api$2();
107100
- const constants_2 = require_constants$9();
107457
+ const constants_2 = require_constants$8();
107101
107458
  /**
107102
107459
  * Parses environment variables from array format (KEY=VALUE) to object format.
107103
107460
  * @param envVars - Array of environment variables in KEY=VALUE format
@@ -107239,30 +107596,36 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
107239
107596
  * Given the configuration, an app template, the base sidecar configuration, and base shared volume,
107240
107597
  */
107241
107598
  const createInstrumentedTemplate = (template, baseSidecar, sharedVolumeOptions, envVarsByName) => {
107242
- var _a;
107599
+ var _a, _b, _c;
107243
107600
  const sharedVolumeMount = {
107244
107601
  [sharedVolumeOptions.volumeMountNameKey]: sharedVolumeOptions.name,
107245
107602
  mountPath: sharedVolumeOptions.mountPath
107246
107603
  };
107247
107604
  const containers = template.containers || [];
107248
- const hasSidecarContainer = containers.some((c) => c.name === baseSidecar.name);
107249
- const newSidecarContainer = Object.assign(Object.assign({}, baseSidecar), {
107250
- env: Object.values(Object.assign(Object.assign(Object.assign({}, DEFAULT_ENV_VARS_BY_NAME), (0, exports.byName)((_a = baseSidecar.env) !== null && _a !== void 0 ? _a : [])), envVarsByName)),
107251
- volumeMounts: [sharedVolumeMount]
107605
+ const existingSidecarContainer = containers.find((c) => c.name === baseSidecar.name);
107606
+ const ensureSharedVolumeMount = (volumeMounts) => {
107607
+ const existingVolumeMounts = volumeMounts || [];
107608
+ const hasSharedVolumeMount = existingVolumeMounts.some((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name);
107609
+ const updatedVolumeMounts = existingVolumeMounts.map((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name ? sharedVolumeMount : mount);
107610
+ if (!hasSharedVolumeMount) updatedVolumeMounts.push(sharedVolumeMount);
107611
+ return updatedVolumeMounts;
107612
+ };
107613
+ const existingSidecarResources = existingSidecarContainer && "resources" in existingSidecarContainer ? existingSidecarContainer.resources : void 0;
107614
+ const baseSidecarResources = baseSidecar && "resources" in baseSidecar ? baseSidecar.resources : void 0;
107615
+ const newSidecarContainer = Object.assign(Object.assign(Object.assign({}, existingSidecarContainer), baseSidecar), {
107616
+ resources: existingSidecarResources || baseSidecarResources ? Object.assign(Object.assign({}, existingSidecarResources !== null && existingSidecarResources !== void 0 ? existingSidecarResources : {}), baseSidecarResources !== null && baseSidecarResources !== void 0 ? baseSidecarResources : {}) : void 0,
107617
+ env: Object.values(Object.assign(Object.assign(Object.assign(Object.assign({}, DEFAULT_ENV_VARS_BY_NAME), (0, exports.byName)((_a = existingSidecarContainer === null || existingSidecarContainer === void 0 ? void 0 : existingSidecarContainer.env) !== null && _a !== void 0 ? _a : [])), (0, exports.byName)((_b = baseSidecar.env) !== null && _b !== void 0 ? _b : [])), envVarsByName)),
107618
+ volumeMounts: ensureSharedVolumeMount((_c = existingSidecarContainer === null || existingSidecarContainer === void 0 ? void 0 : existingSidecarContainer.volumeMounts) !== null && _c !== void 0 ? _c : baseSidecar.volumeMounts)
107252
107619
  });
107253
107620
  const updatedContainers = containers.map((container) => {
107254
107621
  var _a;
107255
107622
  if (container.name === baseSidecar.name) return newSidecarContainer;
107256
- const existingVolumeMounts = container.volumeMounts || [];
107257
- const hasSharedVolumeMount = existingVolumeMounts.some((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name);
107258
- const updatedVolumeMounts = existingVolumeMounts.map((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name ? sharedVolumeMount : mount);
107259
- if (!hasSharedVolumeMount) updatedVolumeMounts.push(sharedVolumeMount);
107260
107623
  return Object.assign(Object.assign({}, container), {
107261
- volumeMounts: updatedVolumeMounts,
107624
+ volumeMounts: ensureSharedVolumeMount(container.volumeMounts),
107262
107625
  env: Object.values(Object.assign(Object.assign(Object.assign({}, DEFAULT_ENV_VARS_BY_NAME), (0, exports.byName)((_a = container.env) !== null && _a !== void 0 ? _a : [])), envVarsByName))
107263
107626
  });
107264
107627
  });
107265
- if (!hasSidecarContainer) updatedContainers.push(newSidecarContainer);
107628
+ if (!existingSidecarContainer) updatedContainers.push(newSidecarContainer);
107266
107629
  const volumes = template.volumes || [];
107267
107630
  const sharedVolume = Object.assign(Object.assign({}, sharedVolumeOptions.mountOptions), { name: sharedVolumeOptions.name });
107268
107631
  const hasSharedVolume = volumes.some((volume) => volume.name === sharedVolumeOptions.name);
@@ -116842,51 +117205,6 @@ var require_formatting = /* @__PURE__ */ __commonJSMin(((exports) => {
116842
117205
  };
116843
117206
  }));
116844
117207
  //#endregion
116845
- //#region ../base/dist/helpers/logger.js
116846
- var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
116847
- var __importDefault = exports && exports.__importDefault || function(mod) {
116848
- return mod && mod.__esModule ? mod : { "default": mod };
116849
- };
116850
- Object.defineProperty(exports, "__esModule", { value: true });
116851
- exports.Logger = exports.LogLevel = void 0;
116852
- const chalk_1 = __importDefault(require_source$1());
116853
- var LogLevel;
116854
- (function(LogLevel) {
116855
- LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
116856
- LogLevel[LogLevel["INFO"] = 2] = "INFO";
116857
- LogLevel[LogLevel["WARN"] = 3] = "WARN";
116858
- LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
116859
- })(LogLevel || (exports.LogLevel = LogLevel = {}));
116860
- var Logger = class {
116861
- constructor(writeMessage, loglevel, shouldIncludeTimestamp) {
116862
- this.shouldIncludeTimestamp = shouldIncludeTimestamp !== null && shouldIncludeTimestamp !== void 0 ? shouldIncludeTimestamp : false;
116863
- this.writeMessage = (s) => {
116864
- return writeMessage(this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ${s}` : s);
116865
- };
116866
- this.loglevel = loglevel;
116867
- }
116868
- setLogLevel(newLogLevel) {
116869
- this.loglevel = newLogLevel;
116870
- }
116871
- setShouldIncludeTime(newShouldIncludeTimestamp) {
116872
- this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
116873
- }
116874
- error(s) {
116875
- if (this.loglevel <= LogLevel.ERROR) this.writeMessage(chalk_1.default.red(s) + "\n");
116876
- }
116877
- warn(s) {
116878
- if (this.loglevel <= LogLevel.WARN) this.writeMessage(chalk_1.default.yellow(s) + "\n");
116879
- }
116880
- info(s) {
116881
- if (this.loglevel <= LogLevel.INFO) this.writeMessage(s + "\n");
116882
- }
116883
- debug(s) {
116884
- if (this.loglevel <= LogLevel.DEBUG) this.writeMessage(s + "\n");
116885
- }
116886
- };
116887
- exports.Logger = Logger;
116888
- }));
116889
- //#endregion
116890
117208
  //#region ../../node_modules/datadog-metrics/node_modules/ms/index.js
116891
117209
  var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
116892
117210
  /**
@@ -143567,6 +143885,17 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143567
143885
  var hasOwn = require_hasown();
143568
143886
  var populate = require_populate();
143569
143887
  /**
143888
+ * Escape CR, LF, and `"` in a multipart `name`/`filename` parameter, so a field
143889
+ * name or filename can not break out of its header line to inject headers or
143890
+ * smuggle additional parts. Matches the WHATWG HTML multipart/form-data encoding.
143891
+ *
143892
+ * @param {string} str - the parameter value to escape
143893
+ * @returns {string} the escaped value
143894
+ */
143895
+ function escapeHeaderParam(str) {
143896
+ return String(str).replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/"/g, "%22");
143897
+ }
143898
+ /**
143570
143899
  * Create readable "multipart/form-data" streams.
143571
143900
  * Can be used to submit forms
143572
143901
  * and file uploads to other web applications.
@@ -143636,7 +143965,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143636
143965
  var contentType = this._getContentType(value, options);
143637
143966
  var contents = "";
143638
143967
  var headers = {
143639
- "Content-Disposition": ["form-data", "name=\"" + field + "\""].concat(contentDisposition || []),
143968
+ "Content-Disposition": ["form-data", "name=\"" + escapeHeaderParam(field) + "\""].concat(contentDisposition || []),
143640
143969
  "Content-Type": [].concat(contentType || [])
143641
143970
  };
143642
143971
  if (typeof options.header === "object") populate(headers, options.header);
@@ -143654,7 +143983,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143654
143983
  if (typeof options.filepath === "string") filename = path$1.normalize(options.filepath).replace(/\\/g, "/");
143655
143984
  else if (options.filename || value && (value.name || value.path)) filename = path$1.basename(options.filename || value && (value.name || value.path));
143656
143985
  else if (value && value.readable && hasOwn(value, "httpVersion")) filename = path$1.basename(value.client._httpMessage.path || "");
143657
- if (filename) return "filename=\"" + filename + "\"";
143986
+ if (filename) return "filename=\"" + escapeHeaderParam(filename) + "\"";
143658
143987
  };
143659
143988
  FormData.prototype._getContentType = function(value, options) {
143660
143989
  var contentType = options.contentType;
@@ -143781,7 +144110,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143781
144110
  FormData.prototype.toString = function() {
143782
144111
  return "[object FormData]";
143783
144112
  };
143784
- setToStringTag(FormData, "FormData");
144113
+ setToStringTag(FormData.prototype, "FormData");
143785
144114
  module.exports = FormData;
143786
144115
  }));
143787
144116
  //#endregion
@@ -144617,7 +144946,7 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
144617
144946
  exports.GitMetadataUploadCommand = void 0;
144618
144947
  const chalk_1 = __importDefault(require_source$1());
144619
144948
  const clipanion_1 = require_advanced();
144620
- const constants_1 = require_constants$8();
144949
+ const constants_1 = require_constants$9();
144621
144950
  const apikey_1 = require_apikey();
144622
144951
  const env_1 = require_env();
144623
144952
  const errors_1 = require_errors();
@@ -144652,17 +144981,12 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
144652
144981
  fips: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
144653
144982
  fipsIgnoreError: (_c = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _c !== void 0 ? _c : false
144654
144983
  };
144655
- this.logger = new logger_1.Logger((s) => {
144656
- this.context.stdout.write(s);
144657
- }, logger_1.LogLevel.INFO);
144658
144984
  }
144659
144985
  execute() {
144660
144986
  return __awaiter(this, void 0, void 0, function* () {
144661
144987
  const initialTime = Date.now();
144662
144988
  (0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
144663
- if (this.verbose) this.logger = new logger_1.Logger((s) => {
144664
- this.context.stdout.write(s);
144665
- }, logger_1.LogLevel.DEBUG);
144989
+ if (this.verbose) this.logger.setLogLevel(logger_1.LogLevel.DEBUG);
144666
144990
  if (this.dryRun) this.logger.warn((0, renderer_1.renderDryRunWarning)());
144667
144991
  if (this.directory) process.chdir(this.directory);
144668
144992
  if (!this.config.apiKey) {
@@ -144873,7 +145197,7 @@ var require_source_code_integration = /* @__PURE__ */ __commonJSMin(((exports) =
144873
145197
  //#endregion
144874
145198
  //#region src/common.ts
144875
145199
  var import_source = /* @__PURE__ */ __toESM(require_source$1());
144876
- var import_constants = require_constants$9();
145200
+ var import_constants = require_constants$8();
144877
145201
  var import_renderer = require_renderer$1();
144878
145202
  var import_azure = require_azure();
144879
145203
  var import_utils = require_utils();
@@ -144903,6 +145227,10 @@ const getEnvVarsByName = (config, subscriptionId, resourceGroup) => {
144903
145227
  name: "DD_SERVERLESS_LOG_PATH",
144904
145228
  value: config.logsPath
144905
145229
  };
145230
+ envVars.DD_APM_ENABLED = {
145231
+ name: "DD_APM_ENABLED",
145232
+ value: "true"
145233
+ };
144906
145234
  return envVars;
144907
145235
  };
144908
145236
  //#endregion
@@ -145065,7 +145393,7 @@ var import_uninstrument = (/* @__PURE__ */ __commonJSMin(((exports) => {
145065
145393
  exports.ContainerAppUninstrumentCommand = void 0;
145066
145394
  const clipanion_1 = require_advanced();
145067
145395
  const plugin_1 = require_plugin();
145068
- const constants_1 = require_constants$9();
145396
+ const constants_1 = require_constants$8();
145069
145397
  const common_1 = require_common$1();
145070
145398
  var ContainerAppUninstrumentCommand = class extends common_1.ContainerAppCommand {
145071
145399
  constructor() {