@datadog/datadog-ci-plugin-container-app 5.19.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,7 +53125,7 @@ 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.19.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"],
@@ -53222,12 +53222,12 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53222
53222
  "debug": "^4.4.1",
53223
53223
  "deep-extend": "^0.6.0",
53224
53224
  "fast-xml-parser": "^5.7.2",
53225
- "form-data": "^4.0.4",
53225
+ "form-data": "^4.0.6",
53226
53226
  "glob": "^13.0.6",
53227
53227
  "inquirer": "^8.2.7",
53228
53228
  "is-docker": "^4.0.0",
53229
53229
  "jest-diff": "^30.2.0",
53230
- "js-yaml": "^4.1.1",
53230
+ "js-yaml": "^4.2.0",
53231
53231
  "jszip": "^3.10.1",
53232
53232
  "proxy-agent": "^6.4.0",
53233
53233
  "semver": "^7.6.3",
@@ -53235,7 +53235,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53235
53235
  "terminal-link": "^2.1.1",
53236
53236
  "tiny-async-pool": "^2.1.0",
53237
53237
  "typanion": "^3.14.0",
53238
- "undici": "^7.24.6",
53238
+ "undici": "^7.28.0",
53239
53239
  "upath": "^2.0.1"
53240
53240
  },
53241
53241
  "devDependencies": {
@@ -53250,6 +53250,71 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
53250
53250
  };
53251
53251
  }));
53252
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
53253
53318
  //#region ../base/dist/version.js
53254
53319
  var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
53255
53320
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -53258,12 +53323,23 @@ var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
53258
53323
  Object.defineProperty(exports, "__esModule", { value: true });
53259
53324
  exports.printVersion = exports.cliVersion = void 0;
53260
53325
  const chalk_1 = __importDefault(require_source$1());
53261
- 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;
53262
53330
  /**
53263
- * 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.
53264
53336
  */
53265
- const printVersion = () => {
53266
- 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));
53267
53343
  };
53268
53344
  exports.printVersion = printVersion;
53269
53345
  }));
@@ -54607,7 +54683,7 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
54607
54683
  }));
54608
54684
  //#endregion
54609
54685
  //#region ../base/dist/helpers/serverless/constants.js
54610
- var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
54686
+ var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
54611
54687
  Object.defineProperty(exports, "__esModule", { value: true });
54612
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;
54613
54689
  exports.API_KEY_ENV_VAR = "DD_API_KEY";
@@ -54685,69 +54761,6 @@ var require_constants$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
54685
54761
  exports.ENV_VAR_REGEX = /^([\w.]+)=(.*)$/;
54686
54762
  }));
54687
54763
  //#endregion
54688
- //#region ../base/dist/constants.js
54689
- var require_constants$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
54690
- Object.defineProperty(exports, "__esModule", { value: true });
54691
- 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;
54692
- exports.DATADOG_SITE_US1 = "datadoghq.com";
54693
- exports.DATADOG_SITE_EU1 = "datadoghq.eu";
54694
- exports.DATADOG_SITE_US3 = "us3.datadoghq.com";
54695
- exports.DATADOG_SITE_US5 = "us5.datadoghq.com";
54696
- exports.DATADOG_SITE_AP1 = "ap1.datadoghq.com";
54697
- exports.DATADOG_SITE_AP2 = "ap2.datadoghq.com";
54698
- exports.DATADOG_SITE_GOV = "ddog-gov.com";
54699
- exports.DATADOG_SITE_US2_GOV = "us2.ddog-gov.com";
54700
- exports.DATADOG_SITES = [
54701
- exports.DATADOG_SITE_US1,
54702
- exports.DATADOG_SITE_EU1,
54703
- exports.DATADOG_SITE_US3,
54704
- exports.DATADOG_SITE_US5,
54705
- exports.DATADOG_SITE_AP1,
54706
- exports.DATADOG_SITE_AP2,
54707
- exports.DATADOG_SITE_GOV,
54708
- exports.DATADOG_SITE_US2_GOV
54709
- ];
54710
- exports.FIPS_ENV_VAR = "DATADOG_FIPS";
54711
- exports.FIPS_IGNORE_ERROR_ENV_VAR = "DATADOG_FIPS_IGNORE_ERROR";
54712
- exports.CONTENT_TYPE_HEADER = "Content-Type";
54713
- exports.CONTENT_TYPE_VALUE_PROTOBUF = "application/x-protobuf";
54714
- exports.CONTENT_TYPE_VALUE_JSON = "application/json";
54715
- exports.METHOD_POST = "post";
54716
- }));
54717
- //#endregion
54718
- //#region ../base/dist/helpers/env.js
54719
- var require_env = /* @__PURE__ */ __commonJSMin(((exports) => {
54720
- Object.defineProperty(exports, "__esModule", { value: true });
54721
- exports.toStringMap = exports.toNumber = exports.toBoolean = void 0;
54722
- const toBoolean = (env) => {
54723
- if (env === void 0) return;
54724
- if (env.toLowerCase() === "true" || env === "1") return true;
54725
- if (env.toLowerCase() === "false" || env === "0") return false;
54726
- };
54727
- exports.toBoolean = toBoolean;
54728
- const toNumber = (env) => {
54729
- if (env === void 0 || env.trim() === "") return;
54730
- const number = Number(env);
54731
- if (isNaN(number)) return;
54732
- return number;
54733
- };
54734
- exports.toNumber = toNumber;
54735
- const toStringMap = (env) => {
54736
- if (env === void 0) return;
54737
- const cleanedEnv = env.replace(/'/g, "\"");
54738
- try {
54739
- const parsed = JSON.parse(cleanedEnv);
54740
- if (typeof parsed === "object" && parsed !== null) {
54741
- for (const key in parsed) if (typeof parsed[key] !== "string") return;
54742
- return parsed;
54743
- }
54744
- } catch (error) {
54745
- return;
54746
- }
54747
- };
54748
- exports.toStringMap = toStringMap;
54749
- }));
54750
- //#endregion
54751
54764
  //#region ../base/dist/helpers/fips.js
54752
54765
  var require_fips = /* @__PURE__ */ __commonJSMin(((exports) => {
54753
54766
  var __importDefault = exports && exports.__importDefault || function(mod) {
@@ -60233,7 +60246,7 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
60233
60246
  const constants_1 = require_constants$7();
60234
60247
  const stream$2 = require("stream");
60235
60248
  const ip_address_1 = require_ip_address();
60236
- const net$8 = require("net");
60249
+ const net$7 = require("net");
60237
60250
  /**
60238
60251
  * Validates the provided SocksClientOptions
60239
60252
  * @param options { SocksClientOptions }
@@ -60311,10 +60324,10 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
60311
60324
  }
60312
60325
  exports.int32ToIpv4 = int32ToIpv4;
60313
60326
  function ipToBuffer(ip) {
60314
- if (net$8.isIPv4(ip)) {
60327
+ if (net$7.isIPv4(ip)) {
60315
60328
  const address = new ip_address_1.Address4(ip);
60316
60329
  return Buffer.from(address.toArray());
60317
- } else if (net$8.isIPv6(ip)) {
60330
+ } else if (net$7.isIPv6(ip)) {
60318
60331
  const address = new ip_address_1.Address6(ip);
60319
60332
  return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
60320
60333
  } else throw new Error("Invalid IP address format");
@@ -60393,7 +60406,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60393
60406
  Object.defineProperty(exports, "__esModule", { value: true });
60394
60407
  exports.SocksClientError = exports.SocksClient = void 0;
60395
60408
  const events_1$2 = require("events");
60396
- const net$7 = require("net");
60409
+ const net$6 = require("net");
60397
60410
  const smart_buffer_1 = require_smartbuffer();
60398
60411
  const constants_1 = require_constants$7();
60399
60412
  const helpers_1 = require_helpers();
@@ -60505,10 +60518,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60505
60518
  const buff = new smart_buffer_1.SmartBuffer();
60506
60519
  buff.writeUInt16BE(0);
60507
60520
  buff.writeUInt8(options.frameNumber || 0);
60508
- if (net$7.isIPv4(options.remoteHost.host)) {
60521
+ if (net$6.isIPv4(options.remoteHost.host)) {
60509
60522
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
60510
60523
  buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
60511
- } else if (net$7.isIPv6(options.remoteHost.host)) {
60524
+ } else if (net$6.isIPv6(options.remoteHost.host)) {
60512
60525
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
60513
60526
  buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
60514
60527
  } else {
@@ -60561,7 +60574,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60561
60574
  const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
60562
60575
  if (timer.unref && typeof timer.unref === "function") timer.unref();
60563
60576
  if (existingSocket) this.socket = existingSocket;
60564
- else this.socket = new net$7.Socket();
60577
+ else this.socket = new net$6.Socket();
60565
60578
  this.socket.once("close", this.onClose);
60566
60579
  this.socket.once("error", this.onError);
60567
60580
  this.socket.once("connect", this.onConnect);
@@ -60673,7 +60686,7 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60673
60686
  buff.writeUInt8(4);
60674
60687
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
60675
60688
  buff.writeUInt16BE(this.options.destination.port);
60676
- if (net$7.isIPv4(this.options.destination.host)) {
60689
+ if (net$6.isIPv4(this.options.destination.host)) {
60677
60690
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60678
60691
  buff.writeStringNT(userId);
60679
60692
  } else {
@@ -60832,10 +60845,10 @@ var require_socksclient = /* @__PURE__ */ __commonJSMin(((exports) => {
60832
60845
  buff.writeUInt8(5);
60833
60846
  buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
60834
60847
  buff.writeUInt8(0);
60835
- if (net$7.isIPv4(this.options.destination.host)) {
60848
+ if (net$6.isIPv4(this.options.destination.host)) {
60836
60849
  buff.writeUInt8(constants_1.Socks5HostType.IPv4);
60837
60850
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60838
- } else if (net$7.isIPv6(this.options.destination.host)) {
60851
+ } else if (net$6.isIPv6(this.options.destination.host)) {
60839
60852
  buff.writeUInt8(constants_1.Socks5HostType.IPv6);
60840
60853
  buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
60841
60854
  } else {
@@ -61045,12 +61058,12 @@ var require_dist$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
61045
61058
  const agent_base_1 = require_dist$15();
61046
61059
  const debug_1 = __importDefault(require_src$2());
61047
61060
  const dns = __importStar(require("dns"));
61048
- const net$6 = __importStar(require("net"));
61061
+ const net$5 = __importStar(require("net"));
61049
61062
  const tls$1 = __importStar(require("tls"));
61050
61063
  const url_1$5 = require("url");
61051
61064
  const debug = (0, debug_1.default)("socks-proxy-agent");
61052
61065
  const setServernameFromNonIpHost = (options) => {
61053
- 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 {
61054
61067
  ...options,
61055
61068
  servername: options.host
61056
61069
  };
@@ -63310,6 +63323,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63310
63323
  function doNothing() {
63311
63324
  /** Do nothing */
63312
63325
  }
63326
+ const maxControlResponseLength = 2 ** 16;
63313
63327
  /**
63314
63328
  * FTPContext holds the control and data sockets of an FTP connection and provides a
63315
63329
  * simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -63436,6 +63450,7 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63436
63450
  * Send an FTP command without waiting for or handling the result.
63437
63451
  */
63438
63452
  send(command) {
63453
+ if (/[\r\n\0]/.test(command)) throw new Error(`Invalid command: Contains control characters. (${command})`);
63439
63454
  const message = command.startsWith("PASS") ? "> PASS ###" : `> ${command}`;
63440
63455
  this.log(message);
63441
63456
  this._socket.write(command + "\r\n", this.encoding);
@@ -63514,6 +63529,10 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63514
63529
  */
63515
63530
  _onControlSocketData(chunk) {
63516
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
+ }
63517
63536
  const completeResponse = this._partialResponse + chunk;
63518
63537
  const parsed = (0, parseControlResponse_1.parseControlResponse)(completeResponse);
63519
63538
  this._partialResponse = parsed.rest;
@@ -63597,6 +63616,61 @@ var require_FtpContext = /* @__PURE__ */ __commonJSMin(((exports) => {
63597
63616
  exports.FTPContext = FTPContext;
63598
63617
  }));
63599
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
63600
63674
  //#region ../../node_modules/basic-ftp/dist/FileInfo.js
63601
63675
  var require_FileInfo = /* @__PURE__ */ __commonJSMin(((exports) => {
63602
63676
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -64132,78 +64206,32 @@ var require_StringWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
64132
64206
  exports.StringWriter = void 0;
64133
64207
  const stream_1$3 = require("stream");
64134
64208
  var StringWriter = class extends stream_1$3.Writable {
64135
- constructor() {
64136
- super(...arguments);
64137
- this.buf = Buffer.alloc(0);
64209
+ constructor(maxByteLength = 1 * 1024 * 1024) {
64210
+ super();
64211
+ this.maxByteLength = maxByteLength;
64212
+ this.byteLength = 0;
64213
+ this.bufs = [];
64138
64214
  }
64139
64215
  _write(chunk, _, callback) {
64140
- if (chunk instanceof Buffer) {
64141
- this.buf = Buffer.concat([this.buf, chunk]);
64142
- callback(null);
64143
- } 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);
64144
64227
  }
64145
64228
  getText(encoding) {
64146
- return this.buf.toString(encoding);
64229
+ return Buffer.concat(this.bufs).toString(encoding);
64147
64230
  }
64148
64231
  };
64149
64232
  exports.StringWriter = StringWriter;
64150
64233
  }));
64151
64234
  //#endregion
64152
- //#region ../../node_modules/basic-ftp/dist/netUtils.js
64153
- var require_netUtils = /* @__PURE__ */ __commonJSMin(((exports) => {
64154
- Object.defineProperty(exports, "__esModule", { value: true });
64155
- exports.describeTLS = describeTLS;
64156
- exports.describeAddress = describeAddress;
64157
- exports.upgradeSocket = upgradeSocket;
64158
- exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
64159
- const tls_1$2 = require("tls");
64160
- /**
64161
- * Returns a string describing the encryption on a given socket instance.
64162
- */
64163
- function describeTLS(socket) {
64164
- if (socket instanceof tls_1$2.TLSSocket) {
64165
- const protocol = socket.getProtocol();
64166
- return protocol ? protocol : "Server socket or disconnected client socket";
64167
- }
64168
- return "No encryption";
64169
- }
64170
- /**
64171
- * Returns a string describing the remote address of a socket.
64172
- */
64173
- function describeAddress(socket) {
64174
- if (socket.remoteFamily === "IPv6") return `[${socket.remoteAddress}]:${socket.remotePort}`;
64175
- return `${socket.remoteAddress}:${socket.remotePort}`;
64176
- }
64177
- /**
64178
- * Upgrade a socket connection with TLS.
64179
- */
64180
- function upgradeSocket(socket, options) {
64181
- return new Promise((resolve, reject) => {
64182
- const tlsOptions = Object.assign({}, options, { socket });
64183
- const tlsSocket = (0, tls_1$2.connect)(tlsOptions, () => {
64184
- if (tlsOptions.rejectUnauthorized !== false && !tlsSocket.authorized) reject(tlsSocket.authorizationError);
64185
- else {
64186
- tlsSocket.removeAllListeners("error");
64187
- resolve(tlsSocket);
64188
- }
64189
- }).once("error", (error) => {
64190
- reject(error);
64191
- });
64192
- });
64193
- }
64194
- /**
64195
- * Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
64196
- * This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
64197
- *
64198
- * @param ip The IP as a string, e.g. "192.168.0.1"
64199
- */
64200
- function ipIsPrivateV4Address(ip = "") {
64201
- if (ip.startsWith("::ffff:")) ip = ip.substr(7);
64202
- const octets = ip.split(".").map((o) => parseInt(o, 10));
64203
- return octets[0] === 10 || octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31 || octets[0] === 192 && octets[1] === 168 || ip === "127.0.0.1";
64204
- }
64205
- }));
64206
- //#endregion
64207
64235
  //#region ../../node_modules/basic-ftp/dist/transfer.js
64208
64236
  var require_transfer = /* @__PURE__ */ __commonJSMin(((exports) => {
64209
64237
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -64449,20 +64477,23 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64449
64477
  const tls_1 = require("tls");
64450
64478
  const util_1$3 = require("util");
64451
64479
  const FtpContext_1 = require_FtpContext();
64480
+ const netUtils_1 = require_netUtils();
64481
+ const parseControlResponse_1 = require_parseControlResponse();
64452
64482
  const parseList_1 = require_parseList();
64483
+ const parseListMLSD_1 = require_parseListMLSD();
64453
64484
  const ProgressTracker_1 = require_ProgressTracker();
64454
64485
  const StringWriter_1 = require_StringWriter();
64455
- const parseListMLSD_1 = require_parseListMLSD();
64456
- const netUtils_1 = require_netUtils();
64457
64486
  const transfer_1 = require_transfer();
64458
- const parseControlResponse_1 = require_parseControlResponse();
64459
64487
  const fsReadDir = (0, util_1$3.promisify)(fs_1$6.readdir);
64460
64488
  const fsMkDir = (0, util_1$3.promisify)(fs_1$6.mkdir);
64461
64489
  const fsStat = (0, util_1$3.promisify)(fs_1$6.stat);
64462
64490
  const fsOpen = (0, util_1$3.promisify)(fs_1$6.open);
64463
64491
  const fsClose = (0, util_1$3.promisify)(fs_1$6.close);
64464
64492
  const fsUnlink = (0, util_1$3.promisify)(fs_1$6.unlink);
64465
- const defaultClientOptions = { allowSeparateTransferHost: true };
64493
+ const defaultClientOptions = {
64494
+ allowSeparateTransferHost: true,
64495
+ maxListingBytes: 40 * 1024 * 1024
64496
+ };
64466
64497
  const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
64467
64498
  const LIST_COMMANDS_MLSD = () => [
64468
64499
  "MLSD",
@@ -64478,10 +64509,15 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64478
64509
  *
64479
64510
  * @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
64480
64511
  */
64481
- constructor(timeout = 3e4, options = defaultClientOptions) {
64512
+ constructor(timeout = 3e4, userOptions = defaultClientOptions) {
64482
64513
  this.availableListCommands = LIST_COMMANDS_DEFAULT();
64514
+ const options = {
64515
+ ...defaultClientOptions,
64516
+ ...userOptions
64517
+ };
64483
64518
  this.ftp = new FtpContext_1.FTPContext(timeout);
64484
64519
  this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, options.allowSeparateTransferHost ? transfer_1.enterPassiveModeIPv4 : transfer_1.enterPassiveModeIPv4_forceControlHostIP]);
64520
+ this.options = options;
64485
64521
  this.parseList = parseList_1.parseList;
64486
64522
  this._progressTracker = new ProgressTracker_1.ProgressTracker();
64487
64523
  }
@@ -64881,7 +64917,7 @@ var require_Client = /* @__PURE__ */ __commonJSMin(((exports) => {
64881
64917
  * @protected
64882
64918
  */
64883
64919
  async _requestListWithCommand(command) {
64884
- const buffer = new StringWriter_1.StringWriter();
64920
+ const buffer = new StringWriter_1.StringWriter(this.options.maxListingBytes);
64885
64921
  await (0, transfer_1.downloadTo)(buffer, {
64886
64922
  ftp: this.ftp,
64887
64923
  tracker: this._progressTracker,
@@ -81643,7 +81679,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81643
81679
  };
81644
81680
  Object.defineProperty(exports, "__esModule", { value: true });
81645
81681
  exports.PacProxyAgent = void 0;
81646
- const net$5 = __importStar(require("net"));
81682
+ const net$4 = __importStar(require("net"));
81647
81683
  const tls = __importStar(require("tls"));
81648
81684
  const crypto$5 = __importStar(require("crypto"));
81649
81685
  const events_1 = require("events");
@@ -81655,7 +81691,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81655
81691
  const quickjs_emscripten_1 = require_dist$7();
81656
81692
  const debug = (0, debug_1.default)("pac-proxy-agent");
81657
81693
  const setServernameFromNonIpHost = (options) => {
81658
- 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 {
81659
81695
  ...options,
81660
81696
  servername: options.host
81661
81697
  };
@@ -81745,7 +81781,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81745
81781
  const isWebSocket = req.getHeader("upgrade") === "websocket";
81746
81782
  const resolver = await this.getResolver();
81747
81783
  const protocol = secureEndpoint ? "https:" : "http:";
81748
- 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;
81749
81785
  const defaultPort = secureEndpoint ? 443 : 80;
81750
81786
  const url = Object.assign(new url_1$3.URL(req.path, `${protocol}//${host}`), defaultPort ? void 0 : { port: opts.port });
81751
81787
  debug("url: %s", url);
@@ -81759,7 +81795,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81759
81795
  const [type, target] = proxy.split(/\s+/);
81760
81796
  debug("Attempting to use proxy: %o", proxy);
81761
81797
  if (type === "DIRECT") if (secureEndpoint) socket = tls.connect(setServernameFromNonIpHost(opts));
81762
- else socket = net$5.connect(opts);
81798
+ else socket = net$4.connect(opts);
81763
81799
  else if (type === "SOCKS" || type === "SOCKS5") {
81764
81800
  const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require_dist$12()));
81765
81801
  agent = new SocksProxyAgent(`socks://${target}`, this.opts);
@@ -81787,7 +81823,7 @@ var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
81787
81823
  }
81788
81824
  if (agent) {
81789
81825
  const s = await agent.connect(req, opts);
81790
- 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");
81791
81827
  req.emit("proxy", {
81792
81828
  proxy,
81793
81829
  socket: s
@@ -82969,7 +83005,7 @@ var require_util$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
82969
83005
  const { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
82970
83006
  const { IncomingMessage } = require("node:http");
82971
83007
  const stream$1 = require("node:stream");
82972
- const net$4 = require("node:net");
83008
+ const net$3 = require("node:net");
82973
83009
  const { stringify } = require("node:querystring");
82974
83010
  const { EventEmitter: EE$2 } = require("node:events");
82975
83011
  const timers = require_timers();
@@ -83130,7 +83166,7 @@ var require_util$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
83130
83166
  if (!host) return null;
83131
83167
  assert$32(typeof host === "string");
83132
83168
  const servername = getHostname(host);
83133
- if (net$4.isIP(servername)) return "";
83169
+ if (net$3.isIP(servername)) return "";
83134
83170
  return servername;
83135
83171
  }
83136
83172
  /**
@@ -84040,6 +84076,14 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84040
84076
  const { channels } = require_diagnostics();
84041
84077
  const { headerNameLowerCasedRecord } = require_constants$4();
84042
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
+ }
84043
84087
  const kHandler = Symbol("handler");
84044
84088
  var Request = class {
84045
84089
  constructor(origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
@@ -84248,8 +84292,8 @@ var require_request$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84248
84292
  request.host = val;
84249
84293
  } else if (headerName === "content-length") {
84250
84294
  if (request.contentLength !== null) throw new InvalidArgumentError("duplicate content-length header");
84295
+ if (!isValidContentLengthHeaderValue(val)) throw new InvalidArgumentError("invalid content-length header");
84251
84296
  request.contentLength = parseInt(val, 10);
84252
- if (!Number.isFinite(request.contentLength)) throw new InvalidArgumentError("invalid content-length header");
84253
84297
  } else if (request.contentType === null && headerName === "content-type") {
84254
84298
  request.contentType = val;
84255
84299
  request.headers.push(key, val);
@@ -84374,6 +84418,8 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84374
84418
  #aborted = false;
84375
84419
  #abort;
84376
84420
  [kResume] = null;
84421
+ rawHeaders = null;
84422
+ rawTrailers = null;
84377
84423
  constructor(abort) {
84378
84424
  this.#abort = abort;
84379
84425
  }
@@ -84420,10 +84466,12 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84420
84466
  return this.#handler.onResponseStarted?.();
84421
84467
  }
84422
84468
  onUpgrade(statusCode, rawHeaders, socket) {
84469
+ this.#controller.rawHeaders = rawHeaders;
84423
84470
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
84424
84471
  }
84425
84472
  onHeaders(statusCode, rawHeaders, resume, statusMessage) {
84426
84473
  this.#controller[kResume] = resume;
84474
+ this.#controller.rawHeaders = rawHeaders;
84427
84475
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
84428
84476
  return !this.#controller.paused;
84429
84477
  }
@@ -84432,6 +84480,7 @@ var require_unwrap_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
84432
84480
  return !this.#controller.paused;
84433
84481
  }
84434
84482
  onComplete(rawTrailers) {
84483
+ this.#controller.rawTrailers = rawTrailers;
84435
84484
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
84436
84485
  }
84437
84486
  onError(err) {
@@ -84449,6 +84498,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84449
84498
  const { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
84450
84499
  const kOnDestroyed = Symbol("onDestroyed");
84451
84500
  const kOnClosed = Symbol("onClosed");
84501
+ const kWebSocketOptions = Symbol("webSocketOptions");
84452
84502
  var DispatcherBase = class extends Dispatcher {
84453
84503
  /** @type {boolean} */
84454
84504
  [kDestroyed] = false;
@@ -84458,6 +84508,22 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84458
84508
  [kClosed] = false;
84459
84509
  /** @type {Array<Function>|null} */
84460
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
+ }
84461
84527
  /** @returns {boolean} */
84462
84528
  get destroyed() {
84463
84529
  return this[kDestroyed];
@@ -84540,7 +84606,7 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
84540
84606
  //#endregion
84541
84607
  //#region ../../node_modules/undici/lib/core/connect.js
84542
84608
  var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84543
- const net$3 = require("node:net");
84609
+ const net$2 = require("node:net");
84544
84610
  const assert$30 = require("node:assert");
84545
84611
  const util = require_util$6();
84546
84612
  const { InvalidArgumentError } = require_errors$1();
@@ -84561,6 +84627,15 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84561
84627
  }
84562
84628
  set(sessionKey, session) {
84563
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
+ }
84564
84639
  this._sessionCache.set(sessionKey, new WeakRef(session));
84565
84640
  this._sessionRegistry.register(session, sessionKey);
84566
84641
  }
@@ -84600,7 +84675,7 @@ var require_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84600
84675
  } else {
84601
84676
  assert$30(!httpSocket, "httpSocket can only be sent on TLS update");
84602
84677
  port = port || 80;
84603
- socket = net$3.connect({
84678
+ socket = net$2.connect({
84604
84679
  highWaterMark: 64 * 1024,
84605
84680
  ...options,
84606
84681
  localAddress,
@@ -86158,7 +86233,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86158
86233
  lowerBound = 0;
86159
86234
  upperBound = Math.pow(2, bitLength) - 1;
86160
86235
  } else {
86161
- lowerBound = Math.pow(-2, bitLength) - 1;
86236
+ lowerBound = -Math.pow(2, bitLength - 1);
86162
86237
  upperBound = Math.pow(2, bitLength - 1) - 1;
86163
86238
  }
86164
86239
  let x = Number(V);
@@ -86184,7 +86259,7 @@ var require_webidl = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86184
86259
  if (Number.isNaN(x) || x === 0 && Object.is(0, x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) return 0;
86185
86260
  x = webidl.util.IntegerPart(x);
86186
86261
  x = x % Math.pow(2, bitLength);
86187
- 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);
86188
86263
  return x;
86189
86264
  };
86190
86265
  webidl.util.IntegerPart = function(n) {
@@ -87529,7 +87604,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87529
87604
  * Parses content-disposition attributes (e.g., name="value" or filename*=utf-8''encoded)
87530
87605
  * @param {Buffer} input
87531
87606
  * @param {{ position: number }} position
87532
- * @returns {{ name: string, value: string }}
87607
+ * @returns {{ name: string, value: string, extended: boolean } | null}
87533
87608
  */
87534
87609
  function parseContentDispositionAttribute(input, position) {
87535
87610
  if (input[position.position] === 59) position.position++;
@@ -87559,7 +87634,8 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87559
87634
  }
87560
87635
  return {
87561
87636
  name: attrNameStr,
87562
- value
87637
+ value,
87638
+ extended: isExtended
87563
87639
  };
87564
87640
  }
87565
87641
  /**
@@ -87589,17 +87665,24 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87589
87665
  position.position++;
87590
87666
  collectASequenceOfBytes((char) => char === 32 || char === 9, input, position);
87591
87667
  switch (bufferToLowerCasedHeaderName(headerName)) {
87592
- case "content-disposition":
87668
+ case "content-disposition": {
87593
87669
  name = filename = null;
87670
+ let filenameIsExtended = false;
87594
87671
  if (collectASequenceOfBytes((char) => isToken(char), input, position).toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
87595
- 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)) {
87596
87673
  const attribute = parseContentDispositionAttribute(input, position);
87597
87674
  if (!attribute) break;
87598
87675
  if (attribute.name === "name") name = attribute.value;
87599
- 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
+ }
87600
87682
  }
87601
87683
  if (name === null) throw parsingError("name attribute is required in content-disposition header");
87602
87684
  break;
87685
+ }
87603
87686
  case "content-type": {
87604
87687
  let headerValue = collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
87605
87688
  headerValue = removeChars(headerValue, false, true, (char) => char === 9 || char === 32);
@@ -87614,7 +87697,7 @@ var require_formdata_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =
87614
87697
  }
87615
87698
  default: collectASequenceOfBytes((char) => char !== 10 && char !== 13, input, position);
87616
87699
  }
87617
- 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");
87618
87701
  else position.position += 2;
87619
87702
  }
87620
87703
  }
@@ -87986,13 +88069,16 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87986
88069
  const EMPTY_BUF = Buffer.alloc(0);
87987
88070
  const FastBuffer = Buffer[Symbol.species];
87988
88071
  const removeAllListeners = util.removeAllListeners;
88072
+ const kIdleSocketValidation = Symbol("kIdleSocketValidation");
88073
+ const kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
88074
+ const kSocketUsed = Symbol("kSocketUsed");
87989
88075
  let extractBody;
87990
88076
  function lazyllhttp() {
87991
88077
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
87992
88078
  let mod;
87993
88079
  let useWasmSIMD = process.arch !== "ppc64";
87994
- if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
87995
- 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;
87996
88082
  if (useWasmSIMD) try {
87997
88083
  mod = new WebAssembly.Module(require_llhttp_simd_wasm());
87998
88084
  } catch {}
@@ -88066,6 +88152,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88066
88152
  */
88067
88153
  this.socket = socket;
88068
88154
  this.timeout = null;
88155
+ this.timeoutWeakRef = new WeakRef(this);
88069
88156
  this.timeoutValue = null;
88070
88157
  this.timeoutType = null;
88071
88158
  this.statusCode = 0;
@@ -88089,9 +88176,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88089
88176
  timers.clearTimeout(this.timeout);
88090
88177
  this.timeout = null;
88091
88178
  }
88092
- 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);
88093
88180
  else {
88094
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this));
88181
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
88095
88182
  this.timeout?.unref();
88096
88183
  }
88097
88184
  this.timeoutValue = delay;
@@ -88150,20 +88237,42 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88150
88237
  else if (ret === constants.ERROR.PAUSED) {
88151
88238
  this.paused = true;
88152
88239
  socket.unshift(data);
88153
- } else {
88154
- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
88155
- let message = "";
88156
- if (ptr) {
88157
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
88158
- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
88159
- }
88160
- throw new HTTPParserError(message, constants.ERROR[ret], data);
88161
- }
88240
+ } else throw this.createError(ret, data);
88162
88241
  }
88163
88242
  } catch (err) {
88164
88243
  util.destroy(socket, err);
88165
88244
  }
88166
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
+ }
88167
88276
  destroy() {
88168
88277
  assert$23(currentParser === null);
88169
88278
  assert$23(this.ptr != null);
@@ -88189,6 +88298,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88189
88298
  onMessageBegin() {
88190
88299
  const { socket, client } = this;
88191
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
+ }
88192
88305
  const request = client[kQueue][client[kRunningIdx]];
88193
88306
  if (!request) return -1;
88194
88307
  request.onResponseStarted();
@@ -88275,6 +88388,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88275
88388
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
88276
88389
  const { client, socket, headers, statusText } = this;
88277
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
+ }
88278
88395
  const request = client[kQueue][client[kRunningIdx]];
88279
88396
  if (!request) return -1;
88280
88397
  assert$23(!this.upgrade);
@@ -88375,6 +88492,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88375
88492
  }
88376
88493
  request.onComplete(headers);
88377
88494
  client[kQueue][client[kRunningIdx]++] = null;
88495
+ socket[kSocketUsed] = client[kPending] === 0;
88378
88496
  if (socket[kWriting]) {
88379
88497
  assert$23(client[kRunning] === 0);
88380
88498
  util.destroy(socket, new InformationalError("reset"));
@@ -88420,6 +88538,9 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88420
88538
  socket[kWriting] = false;
88421
88539
  socket[kReset] = false;
88422
88540
  socket[kBlocking] = false;
88541
+ socket[kIdleSocketValidation] = 0;
88542
+ socket[kIdleSocketValidationTimeout] = null;
88543
+ socket[kSocketUsed] = false;
88423
88544
  socket[kParser] = new Parser(client, socket, llhttpInstance);
88424
88545
  util.addListener(socket, "error", onHttpSocketError);
88425
88546
  util.addListener(socket, "readable", onHttpSocketReadable);
@@ -88447,7 +88568,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88447
88568
  return socket.destroyed;
88448
88569
  },
88449
88570
  busy(request) {
88450
- if (socket[kWriting] || socket[kReset] || socket[kBlocking]) return true;
88571
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) return true;
88451
88572
  if (request) {
88452
88573
  if (client[kRunning] > 0 && !request.idempotent) return true;
88453
88574
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) return true;
@@ -88461,7 +88582,11 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88461
88582
  assert$23(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
88462
88583
  const parser = this[kParser];
88463
88584
  if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
88464
- parser.onMessageComplete();
88585
+ const parserErr = parser.finish();
88586
+ if (parserErr) {
88587
+ this[kError] = parserErr;
88588
+ this[kClient][kOnError](parserErr);
88589
+ }
88465
88590
  return;
88466
88591
  }
88467
88592
  this[kError] = err;
@@ -88473,15 +88598,17 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88473
88598
  function onHttpSocketEnd() {
88474
88599
  const parser = this[kParser];
88475
88600
  if (parser.statusCode && !parser.shouldKeepAlive) {
88476
- parser.onMessageComplete();
88601
+ const parserErr = parser.finish();
88602
+ if (parserErr) util.destroy(this, parserErr);
88477
88603
  return;
88478
88604
  }
88479
88605
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
88480
88606
  }
88481
88607
  function onHttpSocketClose() {
88482
88608
  const parser = this[kParser];
88609
+ clearIdleSocketValidation(this);
88483
88610
  if (parser) {
88484
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) parser.onMessageComplete();
88611
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) this[kError] = parser.finish() || this[kError];
88485
88612
  this[kParser].destroy();
88486
88613
  this[kParser] = null;
88487
88614
  }
@@ -88509,6 +88636,22 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88509
88636
  function onSocketClose() {
88510
88637
  this[kClosed] = true;
88511
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
+ }
88512
88655
  /**
88513
88656
  * @param {import('./client.js')} client
88514
88657
  */
@@ -88524,6 +88667,23 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88524
88667
  socket.ref();
88525
88668
  socket[kNoRef] = false;
88526
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
+ }
88527
88687
  if (client[kSize] === 0) {
88528
88688
  if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
88529
88689
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
@@ -88567,6 +88727,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
88567
88727
  process.emitWarning(new RequestContentLengthMismatchError());
88568
88728
  }
88569
88729
  const socket = client[kSocket];
88730
+ clearIdleSocketValidation(socket);
88570
88731
  /**
88571
88732
  * @param {Error} [err]
88572
88733
  * @returns {void}
@@ -89431,7 +89592,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89431
89592
  //#region ../../node_modules/undici/lib/dispatcher/client.js
89432
89593
  var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89433
89594
  const assert$21 = require("node:assert");
89434
- const net$2 = require("node:net");
89595
+ const net$1 = require("node:net");
89435
89596
  const http$2 = require("node:http");
89436
89597
  const util = require_util$6();
89437
89598
  const { ClientStats } = require_stats();
@@ -89460,7 +89621,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89460
89621
  * @param {string|URL} url
89461
89622
  * @param {import('../../types/client.js').Client.Options} options
89462
89623
  */
89463
- 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 } = {}) {
89464
89625
  if (keepAlive !== void 0) throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
89465
89626
  if (socketTimeout !== void 0) throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
89466
89627
  if (requestTimeout !== void 0) throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
@@ -89478,7 +89639,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89478
89639
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
89479
89640
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
89480
89641
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
89481
- 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");
89482
89643
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) throw new InvalidArgumentError("maxResponseSize must be a positive number");
89483
89644
  if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
89484
89645
  if (allowH2 != null && typeof allowH2 !== "boolean") throw new InvalidArgumentError("allowH2 must be a valid boolean value");
@@ -89487,7 +89648,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89487
89648
  if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
89488
89649
  if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
89489
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");
89490
- super();
89651
+ super({ webSocket });
89491
89652
  if (typeof connect !== "function") connect = buildConnector({
89492
89653
  ...tls,
89493
89654
  maxCachedSessions,
@@ -89501,11 +89662,12 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89501
89662
  } : void 0,
89502
89663
  ...connect
89503
89664
  });
89504
- else if (socketPath != null) {
89665
+ else {
89505
89666
  const customConnect = connect;
89506
89667
  connect = (opts, callback) => customConnect({
89507
89668
  ...opts,
89508
- socketPath
89669
+ ...socketPath != null ? { socketPath } : null,
89670
+ ...allowH2 != null ? { allowH2 } : null
89509
89671
  }, callback);
89510
89672
  }
89511
89673
  this[kUrl] = util.parseOrigin(url);
@@ -89628,7 +89790,7 @@ var require_client$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
89628
89790
  const idx = hostname.indexOf("]");
89629
89791
  assert$21(idx !== -1);
89630
89792
  const ip = hostname.substring(1, idx);
89631
- assert$21(net$2.isIPv6(ip));
89793
+ assert$21(net$1.isIPv6(ip));
89632
89794
  hostname = ip;
89633
89795
  }
89634
89796
  client[kConnecting] = true;
@@ -90050,7 +90212,7 @@ var require_pool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90050
90212
  } : void 0,
90051
90213
  ...connect
90052
90214
  });
90053
- super();
90215
+ super(options);
90054
90216
  this[kConnections] = connections || null;
90055
90217
  this[kUrl] = util.parseOrigin(origin);
90056
90218
  this[kOptions] = {
@@ -90124,7 +90286,7 @@ var require_balanced_pool = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90124
90286
  var BalancedPool = class extends PoolBase {
90125
90287
  constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
90126
90288
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
90127
- super();
90289
+ super(opts);
90128
90290
  this[kOptions] = { ...util.deepClone(opts) };
90129
90291
  this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
90130
90292
  this[kIndex] = -1;
@@ -90309,7 +90471,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90309
90471
  if (typeof factory !== "function") throw new InvalidArgumentError("factory must be a function.");
90310
90472
  if (connect != null && typeof connect !== "function" && typeof connect !== "object") throw new InvalidArgumentError("connect must be a function or an object");
90311
90473
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
90312
- super();
90474
+ super(options);
90313
90475
  if (connect && typeof connect !== "function") connect = { ...connect };
90314
90476
  this[kOptions] = {
90315
90477
  ...util.deepClone(options),
@@ -90399,7 +90561,7 @@ var require_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90399
90561
  //#region ../../node_modules/undici/lib/core/socks5-utils.js
90400
90562
  var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90401
90563
  const { Buffer: Buffer$2 } = require("node:buffer");
90402
- const net$1 = require("node:net");
90564
+ const net = require("node:net");
90403
90565
  const { InvalidArgumentError } = require_errors$1();
90404
90566
  /**
90405
90567
  * Parse an address and determine its type
@@ -90407,14 +90569,14 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90407
90569
  * @returns {{type: number, buffer: Buffer}} Address type and buffer
90408
90570
  */
90409
90571
  function parseAddress(address) {
90410
- if (net$1.isIPv4(address)) {
90572
+ if (net.isIPv4(address)) {
90411
90573
  const parts = address.split(".").map(Number);
90412
90574
  return {
90413
90575
  type: 1,
90414
90576
  buffer: Buffer$2.from(parts)
90415
90577
  };
90416
90578
  }
90417
- if (net$1.isIPv6(address)) return {
90579
+ if (net.isIPv6(address)) return {
90418
90580
  type: 4,
90419
90581
  buffer: parseIPv6(address)
90420
90582
  };
@@ -90432,23 +90594,36 @@ var require_socks5_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90432
90594
  */
90433
90595
  function parseIPv6(address) {
90434
90596
  const buffer = Buffer$2.alloc(16);
90435
- const parts = address.split(":");
90436
- let partIndex = 0;
90437
- let bufferIndex = 0;
90438
- 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("::");
90439
90609
  if (doubleColonIndex !== -1) {
90440
- const skipParts = 8 - parts.filter((p) => p.length > 0).length;
90441
- for (let i = 0; i < parts.length; i++) if (parts[i] === "" && i === doubleColonIndex / 3) bufferIndex += skipParts * 2;
90442
- else if (parts[i] !== "") {
90443
- const value = parseInt(parts[i], 16);
90444
- 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);
90445
90617
  bufferIndex += 2;
90446
90618
  }
90447
- } else for (const part of parts) {
90448
- if (part === "") continue;
90449
- const value = parseInt(part, 16);
90450
- buffer.writeUInt16BE(value, partIndex * 2);
90451
- partIndex++;
90619
+ bufferIndex = 16 - afterParts.length * 2;
90620
+ for (const part of afterParts) {
90621
+ buffer.writeUInt16BE(parseInt(part, 16), bufferIndex);
90622
+ bufferIndex += 2;
90623
+ }
90624
+ } else {
90625
+ const parts = normalizedAddress.split(":");
90626
+ for (let i = 0; i < parts.length; i++) buffer.writeUInt16BE(parseInt(parts[i], 16), i * 2);
90452
90627
  }
90453
90628
  return buffer;
90454
90629
  }
@@ -90553,6 +90728,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90553
90728
  const { debuglog: debuglog$1 } = require("node:util");
90554
90729
  const { parseAddress } = require_socks5_utils();
90555
90730
  const debug = debuglog$1("undici:socks5");
90731
+ const EMPTY_BUFFER = Buffer$1.alloc(0);
90556
90732
  const SOCKS_VERSION = 5;
90557
90733
  const AUTH_METHODS = {
90558
90734
  NO_AUTH: 0,
@@ -90585,6 +90761,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90585
90761
  INITIAL: "initial",
90586
90762
  HANDSHAKING: "handshaking",
90587
90763
  AUTHENTICATING: "authenticating",
90764
+ AUTHENTICATED: "authenticated",
90588
90765
  CONNECTING: "connecting",
90589
90766
  CONNECTED: "connected",
90590
90767
  ERROR: "error",
@@ -90601,13 +90778,16 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90601
90778
  this.socket = socket;
90602
90779
  this.options = options;
90603
90780
  this.state = STATES.INITIAL;
90604
- 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);
90605
90785
  this.authMethods = [];
90606
90786
  if (options.username && options.password) this.authMethods.push(AUTH_METHODS.USERNAME_PASSWORD);
90607
90787
  this.authMethods.push(AUTH_METHODS.NO_AUTH);
90608
- this.socket.on("data", this.onData.bind(this));
90609
- this.socket.on("error", this.onError.bind(this));
90610
- 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);
90611
90791
  }
90612
90792
  /**
90613
90793
  * Handle incoming data from the socket
@@ -90654,6 +90834,10 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90654
90834
  destroy() {
90655
90835
  if (this.socket && !this.socket.destroyed) this.socket.destroy();
90656
90836
  }
90837
+ markAuthenticated() {
90838
+ this.state = STATES.AUTHENTICATED;
90839
+ this.emit("authenticated");
90840
+ }
90657
90841
  /**
90658
90842
  * Start the SOCKS5 handshake
90659
90843
  */
@@ -90680,7 +90864,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90680
90864
  if (method === AUTH_METHODS.NO_ACCEPTABLE) throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
90681
90865
  this.buffer = this.buffer.subarray(2);
90682
90866
  debug("server selected auth method", method);
90683
- if (method === AUTH_METHODS.NO_AUTH) this.emit("authenticated");
90867
+ if (method === AUTH_METHODS.NO_AUTH) this.markAuthenticated();
90684
90868
  else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
90685
90869
  this.state = STATES.AUTHENTICATING;
90686
90870
  this.sendAuthRequest();
@@ -90715,7 +90899,7 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90715
90899
  if (status !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
90716
90900
  this.buffer = this.buffer.subarray(2);
90717
90901
  debug("authentication successful");
90718
- this.emit("authenticated");
90902
+ this.markAuthenticated();
90719
90903
  }
90720
90904
  /**
90721
90905
  * Send CONNECT command
@@ -90723,7 +90907,8 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90723
90907
  * @param {number} port - Target port
90724
90908
  */
90725
90909
  connect(address, port) {
90726
- 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");
90727
90912
  debug("connecting to", address, port);
90728
90913
  this.state = STATES.CONNECTING;
90729
90914
  const request = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
@@ -90781,8 +90966,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90781
90966
  offset += 16;
90782
90967
  }
90783
90968
  const boundPort = this.buffer.readUInt16BE(offset);
90784
- this.buffer = this.buffer.subarray(responseLength);
90969
+ this.buffer = EMPTY_BUFFER;
90785
90970
  this.state = STATES.CONNECTED;
90971
+ this.socket.removeListener("data", this.onSocketData);
90786
90972
  debug("connected, bound address:", boundAddress, "port:", boundPort);
90787
90973
  this.emit("connected", {
90788
90974
  address: boundAddress,
@@ -90818,12 +91004,11 @@ var require_socks5_client = /* @__PURE__ */ __commonJSMin(((exports, module) =>
90818
91004
  //#endregion
90819
91005
  //#region ../../node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
90820
91006
  var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
90821
- const net = require("node:net");
90822
91007
  const { URL: URL$1 } = require("node:url");
90823
91008
  let tls;
90824
91009
  const DispatcherBase = require_dispatcher_base();
90825
91010
  const { InvalidArgumentError } = require_errors$1();
90826
- const { Socks5Client } = require_socks5_client();
91011
+ const { Socks5Client, STATES } = require_socks5_client();
90827
91012
  const { kDispatch, kClose, kDestroy } = require_symbols();
90828
91013
  const Pool = require_pool();
90829
91014
  const buildConnector = require_connect();
@@ -90832,8 +91017,10 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90832
91017
  const kProxyUrl = Symbol("proxy url");
90833
91018
  const kProxyHeaders = Symbol("proxy headers");
90834
91019
  const kProxyAuth = Symbol("proxy auth");
90835
- const kPool = Symbol("pool");
91020
+ const kProxyProtocol = Symbol("proxy protocol");
91021
+ const kPools = Symbol("pools");
90836
91022
  const kConnector = Symbol("connector");
91023
+ const kRequestTls = Symbol("request tls settings");
90837
91024
  let experimentalWarningEmitted = false;
90838
91025
  /**
90839
91026
  * SOCKS5 proxy agent for dispatching requests through a SOCKS5 proxy
@@ -90850,6 +91037,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90850
91037
  if (url.protocol !== "socks5:" && url.protocol !== "socks:") throw new InvalidArgumentError("Proxy URL must use socks5:// or socks:// protocol");
90851
91038
  this[kProxyUrl] = url;
90852
91039
  this[kProxyHeaders] = options.headers || {};
91040
+ this[kProxyProtocol] = options.proxyTls ? "https:" : "http:";
91041
+ this[kRequestTls] = options.requestTls;
90853
91042
  this[kProxyAuth] = {
90854
91043
  username: options.username || (url.username ? decodeURIComponent(url.username) : null),
90855
91044
  password: options.password || (url.password ? decodeURIComponent(url.password) : null)
@@ -90858,7 +91047,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90858
91047
  ...options.proxyTls,
90859
91048
  servername: options.proxyTls?.servername || url.hostname
90860
91049
  });
90861
- this[kPool] = null;
91050
+ this[kPools] = /* @__PURE__ */ new Map();
90862
91051
  }
90863
91052
  /**
90864
91053
  * Create a SOCKS5 connection to the proxy
@@ -90868,20 +91057,15 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90868
91057
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
90869
91058
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
90870
91059
  const socket = await new Promise((resolve, reject) => {
90871
- const onConnect = () => {
90872
- socket.removeListener("error", onError);
90873
- resolve(socket);
90874
- };
90875
- const onError = (err) => {
90876
- socket.removeListener("connect", onConnect);
90877
- reject(err);
90878
- };
90879
- const socket = net.connect({
91060
+ this[kConnector]({
91061
+ hostname: proxyHost,
90880
91062
  host: proxyHost,
90881
- port: proxyPort
91063
+ port: proxyPort,
91064
+ protocol: this[kProxyProtocol]
91065
+ }, (err, socket) => {
91066
+ if (err) reject(err);
91067
+ else resolve(socket);
90882
91068
  });
90883
- socket.once("connect", onConnect);
90884
- socket.once("error", onError);
90885
91069
  });
90886
91070
  const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
90887
91071
  socks5Client.on("error", (err) => {
@@ -90903,7 +91087,7 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90903
91087
  socks5Client.removeListener("authenticated", onAuthenticated);
90904
91088
  reject(err);
90905
91089
  };
90906
- if (socks5Client.state === "authenticated") {
91090
+ if (socks5Client.state === STATES.AUTHENTICATED) {
90907
91091
  clearTimeout(timeout);
90908
91092
  resolve();
90909
91093
  } else {
@@ -90935,53 +91119,69 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module
90935
91119
  /**
90936
91120
  * Dispatch a request through the SOCKS5 proxy
90937
91121
  */
90938
- async [kDispatch](opts, handler) {
91122
+ [kDispatch](opts, handler) {
90939
91123
  const { origin } = opts;
90940
91124
  debug("dispatching request to", origin, "via SOCKS5");
90941
91125
  try {
90942
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) this[kPool] = new Pool(origin, {
90943
- pipelining: opts.pipelining,
90944
- connections: opts.connections,
90945
- connect: async (connectOpts, callback) => {
90946
- try {
90947
- const url = new URL$1(origin);
90948
- const targetHost = url.hostname;
90949
- const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
90950
- debug("establishing SOCKS5 connection to", targetHost, targetPort);
90951
- const socket = await this.createSocks5Connection(targetHost, targetPort);
90952
- let finalSocket = socket;
90953
- if (url.protocol === "https:") {
90954
- if (!tls) tls = require("node:tls");
90955
- debug("upgrading to TLS");
90956
- finalSocket = tls.connect({
90957
- socket,
90958
- servername: targetHost,
90959
- ...connectOpts.tls || {}
90960
- });
90961
- await new Promise((resolve, reject) => {
90962
- finalSocket.once("secureConnect", resolve);
90963
- finalSocket.once("error", reject);
90964
- });
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);
90965
91157
  }
90966
- callback(null, finalSocket);
90967
- } catch (err) {
90968
- debug("SOCKS5 connection error:", err);
90969
- callback(err);
90970
91158
  }
90971
- }
90972
- });
90973
- return this[kPool][kDispatch](opts, handler);
91159
+ });
91160
+ this[kPools].set(originKey, pool);
91161
+ }
91162
+ return pool[kDispatch](opts, handler);
90974
91163
  } catch (err) {
90975
91164
  debug("dispatch error:", err);
90976
- if (typeof handler.onError === "function") handler.onError(err);
90977
- 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;
90978
91172
  }
90979
91173
  }
90980
91174
  async [kClose]() {
90981
- 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);
90982
91179
  }
90983
91180
  async [kDestroy](err) {
90984
- 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);
90985
91185
  }
90986
91186
  };
90987
91187
  module.exports = Socks5ProxyAgent;
@@ -91085,7 +91285,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
91085
91285
  factory: agentFactory,
91086
91286
  username: opts.username || username,
91087
91287
  password: opts.password || password,
91088
- proxyTls: opts.proxyTls
91288
+ proxyTls: opts.proxyTls,
91289
+ requestTls: opts.requestTls
91089
91290
  });
91090
91291
  if (!this[kTunnelProxy] && protocol === "http:" && this[kProxy].protocol === "http:") return new Http1ProxyWrapper(this[kProxy].uri, {
91091
91292
  headers: this[kProxyHeaders],
@@ -91593,7 +91794,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
91593
91794
  constructor(origin, clientOpts) {
91594
91795
  if (typeof origin === "string") origin = new URL(origin);
91595
91796
  if (origin.protocol !== "http:") throw new InvalidArgumentError("h2c-client: Only h2c protocol is supported");
91596
- const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
91797
+ const { maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
91597
91798
  let defaultMaxConcurrentStreams = 100;
91598
91799
  let defaultPipelining = 100;
91599
91800
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) defaultMaxConcurrentStreams = maxConcurrentStreams;
@@ -92038,7 +92239,7 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92038
92239
  const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
92039
92240
  try {
92040
92241
  if (typeof callback !== "function") throw new InvalidArgumentError("invalid callback");
92041
- 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");
92042
92243
  if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
92043
92244
  if (method === "CONNECT") throw new InvalidArgumentError("invalid method");
92044
92245
  if (onInfo && typeof onInfo !== "function") throw new InvalidArgumentError("invalid onInfo callback");
@@ -93224,12 +93425,12 @@ var require_mock_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
93224
93425
  var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module) => {
93225
93426
  const { kMockCallHistoryAddLog } = require_mock_symbols();
93226
93427
  const { InvalidArgumentError } = require_errors$1();
93227
- function handleFilterCallsWithOptions(criteria, options, handler, store) {
93428
+ function handleFilterCallsWithOptions(criteria, options, handler, store, allLogs) {
93228
93429
  switch (options.operator) {
93229
93430
  case "OR":
93230
- store.push(...handler(criteria));
93431
+ store.push(...handler(criteria, allLogs));
93231
93432
  return store;
93232
- case "AND": return handler.call({ logs: store }, criteria);
93433
+ case "AND": return handler(criteria, store);
93233
93434
  default: throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
93234
93435
  }
93235
93436
  }
@@ -93245,11 +93446,11 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
93245
93446
  return finalOptions;
93246
93447
  }
93247
93448
  function makeFilterCalls(parameterName) {
93248
- return (parameterValue) => {
93249
- 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) => {
93250
93451
  return log[parameterName] === parameterValue;
93251
93452
  });
93252
- if (parameterValue instanceof RegExp) return this.logs.filter((log) => {
93453
+ if (parameterValue instanceof RegExp) return logs.filter((log) => {
93253
93454
  return parameterValue.test(log[parameterName]);
93254
93455
  });
93255
93456
  throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
@@ -93337,15 +93538,15 @@ var require_mock_call_history = /* @__PURE__ */ __commonJSMin(((exports, module)
93337
93538
  operator: "OR",
93338
93539
  ...buildAndValidateFilterCallsOptions(options)
93339
93540
  };
93340
- let maybeDuplicatedLogsFiltered = [];
93341
- if ("protocol" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
93342
- if ("host" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
93343
- if ("port" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
93344
- if ("origin" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
93345
- if ("path" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
93346
- if ("hash" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
93347
- if ("fullUrl" in criteria) maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
93348
- 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);
93349
93550
  return [...new Set(maybeDuplicatedLogsFiltered)];
93350
93551
  }
93351
93552
  throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
@@ -94394,7 +94595,8 @@ var require_snapshot_agent = /* @__PURE__ */ __commonJSMin(((exports, module) =>
94394
94595
  //#endregion
94395
94596
  //#region ../../node_modules/undici/lib/global.js
94396
94597
  var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
94397
- const globalDispatcher = Symbol.for("undici.globalDispatcher.1");
94598
+ const globalDispatcher = Symbol.for("undici.globalDispatcher.2");
94599
+ const legacyGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");
94398
94600
  const { InvalidArgumentError } = require_errors$1();
94399
94601
  const Agent = require_agent();
94400
94602
  if (getGlobalDispatcher() === void 0) setGlobalDispatcher(new Agent());
@@ -94406,9 +94608,15 @@ var require_global = /* @__PURE__ */ __commonJSMin(((exports, module) => {
94406
94608
  enumerable: false,
94407
94609
  configurable: false
94408
94610
  });
94611
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
94612
+ value: agent,
94613
+ writable: true,
94614
+ enumerable: false,
94615
+ configurable: false
94616
+ });
94409
94617
  }
94410
94618
  function getGlobalDispatcher() {
94411
- return globalThis[globalDispatcher];
94619
+ return globalThis[legacyGlobalDispatcher];
94412
94620
  }
94413
94621
  module.exports = {
94414
94622
  setGlobalDispatcher,
@@ -95107,7 +95315,7 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95107
95315
  function makeCacheKey(opts) {
95108
95316
  if (!opts.origin) throw new Error("opts.origin is undefined");
95109
95317
  let fullPath = opts.path || "/";
95110
- if (opts.query && !pathHasQueryOrFragment(opts.path)) fullPath = serializePathWithQuery(fullPath, opts.query);
95318
+ if (opts.query && !pathHasQueryOrFragment(fullPath)) fullPath = serializePathWithQuery(fullPath, opts.query);
95111
95319
  return {
95112
95320
  origin: opts.origin.toString(),
95113
95321
  method: opts.method,
@@ -95223,11 +95431,15 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95223
95431
  lastHeader = lastHeader.substring(0, lastHeader.length - 1);
95224
95432
  headers[headers.length - 1] = lastHeader;
95225
95433
  }
95434
+ for (let j = 0; j < headers.length; j++) headers[j] = headers[j].trim();
95226
95435
  if (key in output) output[key] = output[key].concat(headers);
95227
95436
  else output[key] = headers;
95228
95437
  }
95229
- } else if (key in output) output[key] = output[key].concat(value);
95230
- 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
+ }
95231
95443
  break;
95232
95444
  }
95233
95445
  case "public":
@@ -95305,16 +95517,20 @@ var require_cache$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95305
95517
  * @returns {string}
95306
95518
  */
95307
95519
  function makeDeduplicationKey(cacheKey, excludeHeaders) {
95308
- let key = `${cacheKey.origin}:${cacheKey.method}:${cacheKey.path}`;
95520
+ const headers = {};
95309
95521
  if (cacheKey.headers) {
95310
95522
  const sortedHeaders = Object.keys(cacheKey.headers).sort();
95311
95523
  for (const header of sortedHeaders) {
95312
95524
  if (excludeHeaders?.has(header.toLowerCase())) continue;
95313
- const value = cacheKey.headers[header];
95314
- key += `:${header}=${Array.isArray(value) ? value.join(",") : value}`;
95525
+ headers[header] = cacheKey.headers[header];
95315
95526
  }
95316
95527
  }
95317
- return key;
95528
+ return JSON.stringify([
95529
+ cacheKey.origin,
95530
+ cacheKey.method,
95531
+ cacheKey.path,
95532
+ headers
95533
+ ]);
95318
95534
  }
95319
95535
  module.exports = {
95320
95536
  makeCacheKey,
@@ -97253,7 +97469,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97253
97469
  SELECT
97254
97470
  id
97255
97471
  FROM cacheInterceptorV${VERSION}
97256
- ORDER BY cachedAt DESC
97472
+ ORDER BY cachedAt ASC
97257
97473
  LIMIT ?
97258
97474
  )
97259
97475
  `);
@@ -97294,8 +97510,8 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97294
97510
  const existingValue = this.#findValue(key, true);
97295
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);
97296
97512
  else {
97297
- this.#prune();
97298
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();
97299
97515
  }
97300
97516
  }
97301
97517
  /**
@@ -97378,7 +97594,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJSMin(((exports, module
97378
97594
  if (values.length === 0) return;
97379
97595
  const now = Date.now();
97380
97596
  for (const value of values) {
97381
- if (now >= value.deleteAt && !canBeExpired) return;
97597
+ if (now >= value.deleteAt && !canBeExpired) continue;
97382
97598
  let matches = true;
97383
97599
  if (value.vary) {
97384
97600
  const vary = JSON.parse(value.vary);
@@ -99208,7 +99424,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99208
99424
  cacheState = "";
99209
99425
  }
99210
99426
  let responseStatus = 0;
99211
- if (fetchParams.request.mode !== "navigator" || !response.hasCrossOriginRedirects) {
99427
+ if (fetchParams.request.mode !== "navigate" || !response.hasCrossOriginRedirects) {
99212
99428
  responseStatus = response.status;
99213
99429
  const mimeType = extractMimeType(response.headersList);
99214
99430
  if (mimeType !== "failure") bodyInfo.contentType = minimizeSupportedMimeType(mimeType);
@@ -99312,7 +99528,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99312
99528
  let contentLengthHeaderValue = null;
99313
99529
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) contentLengthHeaderValue = "0";
99314
99530
  if (contentLength != null) contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
99315
- 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);
99316
99532
  if (contentLength != null && httpRequest.keepalive) {}
99317
99533
  if (webidl.is.URL(httpRequest.referrer)) httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
99318
99534
  appendRequestOriginHeader(httpRequest);
@@ -100432,7 +100648,6 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100432
100648
  const { maxNameValuePairSize, maxAttributeValueSize } = require_constants$1();
100433
100649
  const { isCTLExcludingHtab } = require_util$3();
100434
100650
  const assert$2 = require("node:assert");
100435
- const { unescape: qsUnescape } = require("node:querystring");
100436
100651
  /**
100437
100652
  * @description Parses the field-value attributes of a set-cookie header string.
100438
100653
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4
@@ -100461,7 +100676,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100461
100676
  if (name.length + value.length > maxNameValuePairSize) return null;
100462
100677
  return {
100463
100678
  name,
100464
- value: qsUnescape(value),
100679
+ value,
100465
100680
  ...parseUnparsedAttributes(unparsedAttributes)
100466
100681
  };
100467
100682
  }
@@ -100513,12 +100728,10 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100513
100728
  } else if (attributeNameLowercase === "secure") cookieAttributeList.secure = true;
100514
100729
  else if (attributeNameLowercase === "httponly") cookieAttributeList.httpOnly = true;
100515
100730
  else if (attributeNameLowercase === "samesite") {
100516
- let enforcement = "Default";
100517
100731
  const attributeValueLowercase = attributeValue.toLowerCase();
100518
- if (attributeValueLowercase.includes("none")) enforcement = "None";
100519
- if (attributeValueLowercase.includes("strict")) enforcement = "Strict";
100520
- if (attributeValueLowercase.includes("lax")) enforcement = "Lax";
100521
- 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";
100522
100735
  } else {
100523
100736
  cookieAttributeList.unparsed ??= [];
100524
100737
  cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
@@ -101467,27 +101680,26 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101467
101680
  ]);
101468
101681
  const kBuffer = Symbol("kBuffer");
101469
101682
  const kLength = Symbol("kLength");
101470
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024;
101471
101683
  var PerMessageDeflate = class {
101472
101684
  /** @type {import('node:zlib').InflateRaw} */
101473
101685
  #inflate;
101474
101686
  #options = {};
101475
- /** @type {boolean} */
101476
- #aborted = false;
101477
- /** @type {Function|null} */
101478
- #currentCallback = null;
101687
+ #maxPayloadSize = 0;
101479
101688
  /**
101480
101689
  * @param {Map<string, string>} extensions
101481
101690
  */
101482
- constructor(extensions) {
101691
+ constructor(extensions, options) {
101483
101692
  this.#options.serverNoContextTakeover = extensions.has("server_no_context_takeover");
101484
101693
  this.#options.serverMaxWindowBits = extensions.get("server_max_window_bits");
101694
+ this.#maxPayloadSize = options.maxPayloadSize;
101485
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
+ */
101486
101702
  decompress(chunk, fin, callback) {
101487
- if (this.#aborted) {
101488
- callback(new MessageSizeExceededError());
101489
- return;
101490
- }
101491
101703
  if (!this.#inflate) {
101492
101704
  let windowBits = Z_DEFAULT_WINDOWBITS;
101493
101705
  if (this.#options.serverMaxWindowBits) {
@@ -101506,18 +101718,11 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101506
101718
  this.#inflate[kBuffer] = [];
101507
101719
  this.#inflate[kLength] = 0;
101508
101720
  this.#inflate.on("data", (data) => {
101509
- if (this.#aborted) return;
101510
101721
  this.#inflate[kLength] += data.length;
101511
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
101512
- this.#aborted = true;
101722
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
101723
+ callback(new MessageSizeExceededError());
101513
101724
  this.#inflate.removeAllListeners();
101514
- this.#inflate.destroy();
101515
101725
  this.#inflate = null;
101516
- if (this.#currentCallback) {
101517
- const cb = this.#currentCallback;
101518
- this.#currentCallback = null;
101519
- cb(new MessageSizeExceededError());
101520
- }
101521
101726
  return;
101522
101727
  }
101523
101728
  this.#inflate[kBuffer].push(data);
@@ -101527,15 +101732,13 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
101527
101732
  callback(err);
101528
101733
  });
101529
101734
  }
101530
- this.#currentCallback = callback;
101531
101735
  this.#inflate.write(chunk);
101532
101736
  if (fin) this.#inflate.write(tail);
101533
101737
  this.#inflate.flush(() => {
101534
- if (this.#aborted || !this.#inflate) return;
101738
+ if (!this.#inflate) return;
101535
101739
  const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength]);
101536
101740
  this.#inflate[kBuffer].length = 0;
101537
101741
  this.#inflate[kLength] = 0;
101538
- this.#currentCallback = null;
101539
101742
  callback(null, full);
101540
101743
  });
101541
101744
  }
@@ -101565,15 +101768,22 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101565
101768
  #extensions;
101566
101769
  /** @type {import('./websocket').Handler} */
101567
101770
  #handler;
101771
+ /** @type {number} */
101772
+ #maxFragments;
101773
+ /** @type {number} */
101774
+ #maxPayloadSize;
101568
101775
  /**
101569
101776
  * @param {import('./websocket').Handler} handler
101570
101777
  * @param {Map<string, string>|null} extensions
101778
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
101571
101779
  */
101572
- constructor(handler, extensions) {
101780
+ constructor(handler, extensions, options = {}) {
101573
101781
  super();
101574
101782
  this.#handler = handler;
101575
101783
  this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
101576
- 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));
101577
101787
  }
101578
101788
  /**
101579
101789
  * @param {Buffer} chunk
@@ -101585,6 +101795,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101585
101795
  this.#loop = true;
101586
101796
  this.run(callback);
101587
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
+ }
101588
101805
  /**
101589
101806
  * Runs whenever a new chunk is received.
101590
101807
  * Callback is called whenever there are no more chunks buffering,
@@ -101641,6 +101858,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101641
101858
  if (payloadLength <= 125) {
101642
101859
  this.#info.payloadLength = payloadLength;
101643
101860
  this.#state = parserStates.READ_DATA;
101861
+ if (!this.#validatePayloadLength()) return;
101644
101862
  } else if (payloadLength === 126) this.#state = parserStates.PAYLOADLENGTH_16;
101645
101863
  else if (payloadLength === 127) this.#state = parserStates.PAYLOADLENGTH_64;
101646
101864
  if (isTextBinaryFrame(opcode)) {
@@ -101656,6 +101874,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101656
101874
  const buffer = this.consume(2);
101657
101875
  this.#info.payloadLength = buffer.readUInt16BE(0);
101658
101876
  this.#state = parserStates.READ_DATA;
101877
+ if (!this.#validatePayloadLength()) return;
101659
101878
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
101660
101879
  if (this.#byteOffset < 8) return callback();
101661
101880
  const buffer = this.consume(8);
@@ -101667,6 +101886,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101667
101886
  }
101668
101887
  this.#info.payloadLength = lower;
101669
101888
  this.#state = parserStates.READ_DATA;
101889
+ if (!this.#validatePayloadLength()) return;
101670
101890
  } else if (this.#state === parserStates.READ_DATA) {
101671
101891
  if (this.#byteOffset < this.#info.payloadLength) return callback();
101672
101892
  const body = this.consume(this.#info.payloadLength);
@@ -101674,7 +101894,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101674
101894
  this.#loop = this.parseControlFrame(body);
101675
101895
  this.#state = parserStates.INFO;
101676
101896
  } else if (!this.#info.compressed) {
101677
- this.writeFragments(body);
101897
+ if (!this.writeFragments(body)) return;
101678
101898
  if (!this.#info.fragmented && this.#info.fin) websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments());
101679
101899
  this.#state = parserStates.INFO;
101680
101900
  } else {
@@ -101684,7 +101904,11 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101684
101904
  failWebsocketConnection(this.#handler, code, error.message);
101685
101905
  return;
101686
101906
  }
101687
- 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
+ }
101688
101912
  if (!this.#info.fin) {
101689
101913
  this.#state = parserStates.INFO;
101690
101914
  this.#loop = true;
@@ -101695,7 +101919,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101695
101919
  this.#loop = true;
101696
101920
  this.#state = parserStates.INFO;
101697
101921
  this.run(callback);
101698
- });
101922
+ }, this.#fragmentsBytes);
101699
101923
  this.#loop = false;
101700
101924
  break;
101701
101925
  }
@@ -101737,8 +101961,13 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101737
101961
  }
101738
101962
  }
101739
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
+ }
101740
101968
  this.#fragmentsBytes += fragment.length;
101741
101969
  this.#fragments.push(fragment);
101970
+ return true;
101742
101971
  }
101743
101972
  consumeFragments() {
101744
101973
  const fragments = this.#fragments;
@@ -102159,7 +102388,13 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
102159
102388
  */
102160
102389
  #onConnectionEstablished(response, parsedExtensions) {
102161
102390
  this.#handler.socket = response.socket;
102162
- 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
+ });
102163
102398
  parser.on("drain", () => this.#handler.onParserDrain());
102164
102399
  parser.on("error", (err) => this.#handler.onParserError(err));
102165
102400
  this.#parser = parser;
@@ -102528,7 +102763,12 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102528
102763
  /** @type {import('../websocket').Handler['onConnectionEstablished']} */
102529
102764
  #onConnectionEstablished(response, parsedExtensions) {
102530
102765
  this.#handler.socket = response.socket;
102531
- 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
+ });
102532
102772
  parser.on("drain", () => this.#handler.onParserDrain());
102533
102773
  parser.on("error", (err) => this.#handler.onParserError(err));
102534
102774
  this.#parser = parser;
@@ -102539,10 +102779,6 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102539
102779
  start: (controller) => {
102540
102780
  this.#readableStreamController = controller;
102541
102781
  },
102542
- pull(controller) {
102543
- let chunk;
102544
- while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) controller.enqueue(chunk);
102545
- },
102546
102782
  cancel: (reason) => this.#cancel(reason)
102547
102783
  });
102548
102784
  const writable = new WritableStream({
@@ -102566,7 +102802,7 @@ var require_websocketstream = /* @__PURE__ */ __commonJSMin(((exports, module) =
102566
102802
  if (type === opcodes.TEXT) try {
102567
102803
  chunk = utf8Decode(data);
102568
102804
  } catch {
102569
- failWebsocketConnection(this.#handler, "Received invalid UTF-8 in text frame.");
102805
+ failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame.");
102570
102806
  return;
102571
102807
  }
102572
102808
  else if (type === opcodes.BINARY) chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
@@ -103805,15 +104041,135 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
103805
104041
  exports.isFile = isFile;
103806
104042
  }));
103807
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
103808
104116
  //#region ../base/dist/index.js
103809
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
+ };
103810
104149
  Object.defineProperty(exports, "__esModule", { value: true });
103811
104150
  exports.BaseCommand = void 0;
103812
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();
103813
104155
  /**
103814
104156
  * This command should be extended by **every** command in the monorepo.
103815
104157
  */
103816
- 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
+ };
103817
104173
  exports.BaseCommand = BaseCommand;
103818
104174
  }));
103819
104175
  //#endregion
@@ -103849,12 +104205,12 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
103849
104205
  Object.defineProperty(exports, "__esModule", { value: true });
103850
104206
  exports.ContainerAppCommand = void 0;
103851
104207
  const clipanion_1 = require_advanced();
103852
- const constants_1 = require_constants$8();
104208
+ const constants_1 = require_constants$9();
103853
104209
  const env_1 = require_env();
103854
104210
  const fips_1 = require_fips();
103855
104211
  const renderer_1 = require_renderer$1();
103856
104212
  const azure_1 = require_azure();
103857
- const constants_2 = require_constants$9();
104213
+ const constants_2 = require_constants$8();
103858
104214
  const utils_1 = require_utils();
103859
104215
  const __1 = require_dist$4();
103860
104216
  var ContainerAppCommand = class extends __1.BaseCommand {
@@ -103967,7 +104323,7 @@ var require_instrument = /* @__PURE__ */ __commonJSMin(((exports) => {
103967
104323
  const clipanion_1 = require_advanced();
103968
104324
  const typanion_1 = require_lib$3();
103969
104325
  const plugin_1 = require_plugin();
103970
- const constants_1 = require_constants$9();
104326
+ const constants_1 = require_constants$8();
103971
104327
  const common_1 = require_common$1();
103972
104328
  exports.DEFAULT_SIDECAR_CPU = .5;
103973
104329
  exports.DEFAULT_SIDECAR_MEMORY = 1;
@@ -104029,7 +104385,7 @@ var require_instrument = /* @__PURE__ */ __commonJSMin(((exports) => {
104029
104385
  var require_api$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
104030
104386
  Object.defineProperty(exports, "__esModule", { value: true });
104031
104387
  exports.getBaseIntakeUrl = exports.getApiUrl = exports.getIntakeUrl = exports.getDatadogSite = exports.getDatadogSiteFromEnv = void 0;
104032
- const constants_1 = require_constants$8();
104388
+ const constants_1 = require_constants$9();
104033
104389
  /**
104034
104390
  * Read the Datadog site from `DATADOG_SITE` / `DD_SITE` env vars.
104035
104391
  * Returns `undefined` when neither is set.
@@ -107096,9 +107452,9 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
107096
107452
  const node_util_1 = require("node:util");
107097
107453
  const chalk_1 = __importDefault(require_source$1());
107098
107454
  const jest_diff_1 = require_build();
107099
- const constants_1 = require_constants$8();
107455
+ const constants_1 = require_constants$9();
107100
107456
  const api_1 = require_api$2();
107101
- const constants_2 = require_constants$9();
107457
+ const constants_2 = require_constants$8();
107102
107458
  /**
107103
107459
  * Parses environment variables from array format (KEY=VALUE) to object format.
107104
107460
  * @param envVars - Array of environment variables in KEY=VALUE format
@@ -107240,30 +107596,36 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
107240
107596
  * Given the configuration, an app template, the base sidecar configuration, and base shared volume,
107241
107597
  */
107242
107598
  const createInstrumentedTemplate = (template, baseSidecar, sharedVolumeOptions, envVarsByName) => {
107243
- var _a;
107599
+ var _a, _b, _c;
107244
107600
  const sharedVolumeMount = {
107245
107601
  [sharedVolumeOptions.volumeMountNameKey]: sharedVolumeOptions.name,
107246
107602
  mountPath: sharedVolumeOptions.mountPath
107247
107603
  };
107248
107604
  const containers = template.containers || [];
107249
- const hasSidecarContainer = containers.some((c) => c.name === baseSidecar.name);
107250
- const newSidecarContainer = Object.assign(Object.assign({}, baseSidecar), {
107251
- 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)),
107252
- 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)
107253
107619
  });
107254
107620
  const updatedContainers = containers.map((container) => {
107255
107621
  var _a;
107256
107622
  if (container.name === baseSidecar.name) return newSidecarContainer;
107257
- const existingVolumeMounts = container.volumeMounts || [];
107258
- const hasSharedVolumeMount = existingVolumeMounts.some((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name);
107259
- const updatedVolumeMounts = existingVolumeMounts.map((mount) => mount[sharedVolumeOptions.volumeMountNameKey] === sharedVolumeOptions.name ? sharedVolumeMount : mount);
107260
- if (!hasSharedVolumeMount) updatedVolumeMounts.push(sharedVolumeMount);
107261
107623
  return Object.assign(Object.assign({}, container), {
107262
- volumeMounts: updatedVolumeMounts,
107624
+ volumeMounts: ensureSharedVolumeMount(container.volumeMounts),
107263
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))
107264
107626
  });
107265
107627
  });
107266
- if (!hasSidecarContainer) updatedContainers.push(newSidecarContainer);
107628
+ if (!existingSidecarContainer) updatedContainers.push(newSidecarContainer);
107267
107629
  const volumes = template.volumes || [];
107268
107630
  const sharedVolume = Object.assign(Object.assign({}, sharedVolumeOptions.mountOptions), { name: sharedVolumeOptions.name });
107269
107631
  const hasSharedVolume = volumes.some((volume) => volume.name === sharedVolumeOptions.name);
@@ -116843,75 +117205,6 @@ var require_formatting = /* @__PURE__ */ __commonJSMin(((exports) => {
116843
117205
  };
116844
117206
  }));
116845
117207
  //#endregion
116846
- //#region ../base/dist/helpers/logger.js
116847
- var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
116848
- var __importDefault = exports && exports.__importDefault || function(mod) {
116849
- return mod && mod.__esModule ? mod : { "default": mod };
116850
- };
116851
- Object.defineProperty(exports, "__esModule", { value: true });
116852
- exports.Logger = exports.LogLevel = void 0;
116853
- const chalk_1 = __importDefault(require_source$1());
116854
- var LogLevel;
116855
- (function(LogLevel) {
116856
- LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
116857
- LogLevel[LogLevel["INFO"] = 2] = "INFO";
116858
- LogLevel[LogLevel["WARN"] = 3] = "WARN";
116859
- LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
116860
- })(LogLevel || (exports.LogLevel = LogLevel = {}));
116861
- const LEVEL_NAMES = {
116862
- [LogLevel.DEBUG]: "debug",
116863
- [LogLevel.INFO]: "info",
116864
- [LogLevel.WARN]: "warn",
116865
- [LogLevel.ERROR]: "error"
116866
- };
116867
- var Logger = class {
116868
- constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
116869
- var _a, _b;
116870
- const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
116871
- this.rawWriteMessage = writeMessage;
116872
- this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
116873
- this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
116874
- this.loglevel = loglevel;
116875
- }
116876
- setLogLevel(newLogLevel) {
116877
- this.loglevel = newLogLevel;
116878
- }
116879
- setShouldIncludeTime(newShouldIncludeTimestamp) {
116880
- this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
116881
- }
116882
- setJsonOutput(newJsonOutput) {
116883
- this.jsonOutput = newJsonOutput;
116884
- }
116885
- error(s) {
116886
- if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
116887
- }
116888
- warn(s) {
116889
- if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
116890
- }
116891
- info(s) {
116892
- if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
116893
- }
116894
- debug(s) {
116895
- if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
116896
- }
116897
- emit(level, message, colorize) {
116898
- if (this.jsonOutput) {
116899
- const payload = {
116900
- level: LEVEL_NAMES[level],
116901
- message
116902
- };
116903
- if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
116904
- this.rawWriteMessage(JSON.stringify(payload) + "\n");
116905
- return;
116906
- }
116907
- const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
116908
- const body = colorize ? colorize(message) : message;
116909
- this.rawWriteMessage(prefix + body + "\n");
116910
- }
116911
- };
116912
- exports.Logger = Logger;
116913
- }));
116914
- //#endregion
116915
117208
  //#region ../../node_modules/datadog-metrics/node_modules/ms/index.js
116916
117209
  var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
116917
117210
  /**
@@ -143592,6 +143885,17 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143592
143885
  var hasOwn = require_hasown();
143593
143886
  var populate = require_populate();
143594
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
+ /**
143595
143899
  * Create readable "multipart/form-data" streams.
143596
143900
  * Can be used to submit forms
143597
143901
  * and file uploads to other web applications.
@@ -143661,7 +143965,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143661
143965
  var contentType = this._getContentType(value, options);
143662
143966
  var contents = "";
143663
143967
  var headers = {
143664
- "Content-Disposition": ["form-data", "name=\"" + field + "\""].concat(contentDisposition || []),
143968
+ "Content-Disposition": ["form-data", "name=\"" + escapeHeaderParam(field) + "\""].concat(contentDisposition || []),
143665
143969
  "Content-Type": [].concat(contentType || [])
143666
143970
  };
143667
143971
  if (typeof options.header === "object") populate(headers, options.header);
@@ -143679,7 +143983,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143679
143983
  if (typeof options.filepath === "string") filename = path$1.normalize(options.filepath).replace(/\\/g, "/");
143680
143984
  else if (options.filename || value && (value.name || value.path)) filename = path$1.basename(options.filename || value && (value.name || value.path));
143681
143985
  else if (value && value.readable && hasOwn(value, "httpVersion")) filename = path$1.basename(value.client._httpMessage.path || "");
143682
- if (filename) return "filename=\"" + filename + "\"";
143986
+ if (filename) return "filename=\"" + escapeHeaderParam(filename) + "\"";
143683
143987
  };
143684
143988
  FormData.prototype._getContentType = function(value, options) {
143685
143989
  var contentType = options.contentType;
@@ -143806,7 +144110,7 @@ var require_form_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
143806
144110
  FormData.prototype.toString = function() {
143807
144111
  return "[object FormData]";
143808
144112
  };
143809
- setToStringTag(FormData, "FormData");
144113
+ setToStringTag(FormData.prototype, "FormData");
143810
144114
  module.exports = FormData;
143811
144115
  }));
143812
144116
  //#endregion
@@ -144642,7 +144946,7 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
144642
144946
  exports.GitMetadataUploadCommand = void 0;
144643
144947
  const chalk_1 = __importDefault(require_source$1());
144644
144948
  const clipanion_1 = require_advanced();
144645
- const constants_1 = require_constants$8();
144949
+ const constants_1 = require_constants$9();
144646
144950
  const apikey_1 = require_apikey();
144647
144951
  const env_1 = require_env();
144648
144952
  const errors_1 = require_errors();
@@ -144677,17 +144981,12 @@ var require_upload = /* @__PURE__ */ __commonJSMin(((exports) => {
144677
144981
  fips: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
144678
144982
  fipsIgnoreError: (_c = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _c !== void 0 ? _c : false
144679
144983
  };
144680
- this.logger = new logger_1.Logger((s) => {
144681
- this.context.stdout.write(s);
144682
- }, logger_1.LogLevel.INFO);
144683
144984
  }
144684
144985
  execute() {
144685
144986
  return __awaiter(this, void 0, void 0, function* () {
144686
144987
  const initialTime = Date.now();
144687
144988
  (0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
144688
- if (this.verbose) this.logger = new logger_1.Logger((s) => {
144689
- this.context.stdout.write(s);
144690
- }, logger_1.LogLevel.DEBUG);
144989
+ if (this.verbose) this.logger.setLogLevel(logger_1.LogLevel.DEBUG);
144691
144990
  if (this.dryRun) this.logger.warn((0, renderer_1.renderDryRunWarning)());
144692
144991
  if (this.directory) process.chdir(this.directory);
144693
144992
  if (!this.config.apiKey) {
@@ -144898,7 +145197,7 @@ var require_source_code_integration = /* @__PURE__ */ __commonJSMin(((exports) =
144898
145197
  //#endregion
144899
145198
  //#region src/common.ts
144900
145199
  var import_source = /* @__PURE__ */ __toESM(require_source$1());
144901
- var import_constants = require_constants$9();
145200
+ var import_constants = require_constants$8();
144902
145201
  var import_renderer = require_renderer$1();
144903
145202
  var import_azure = require_azure();
144904
145203
  var import_utils = require_utils();
@@ -144928,6 +145227,10 @@ const getEnvVarsByName = (config, subscriptionId, resourceGroup) => {
144928
145227
  name: "DD_SERVERLESS_LOG_PATH",
144929
145228
  value: config.logsPath
144930
145229
  };
145230
+ envVars.DD_APM_ENABLED = {
145231
+ name: "DD_APM_ENABLED",
145232
+ value: "true"
145233
+ };
144931
145234
  return envVars;
144932
145235
  };
144933
145236
  //#endregion
@@ -145090,7 +145393,7 @@ var import_uninstrument = (/* @__PURE__ */ __commonJSMin(((exports) => {
145090
145393
  exports.ContainerAppUninstrumentCommand = void 0;
145091
145394
  const clipanion_1 = require_advanced();
145092
145395
  const plugin_1 = require_plugin();
145093
- const constants_1 = require_constants$9();
145396
+ const constants_1 = require_constants$8();
145094
145397
  const common_1 = require_common$1();
145095
145398
  var ContainerAppUninstrumentCommand = class extends common_1.ContainerAppCommand {
145096
145399
  constructor() {