@vm0/cli 9.274.15 → 9.275.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.
Files changed (145) hide show
  1. package/{agent-ODXX2P6E.js → agent-XK6H2544.js} +10 -10
  2. package/{banking-VS4X74FZ.js → banking-E5SI3MJU.js} +8 -8
  3. package/{browser-GJBNBJRP.js → browser-TH4Y55RS.js} +8 -8
  4. package/{chat-S3JIOOVJ.js → chat-3H5LWT6E.js} +11 -11
  5. package/{chunk-XXWDEMGD.js → chunk-2W73DZDW.js} +3 -3
  6. package/{chunk-KLI6K4VO.js → chunk-32FE3MDA.js} +2 -2
  7. package/{chunk-N6H3IGX4.js → chunk-45J5VDVQ.js} +2 -2
  8. package/{chunk-VATIZEFN.js → chunk-4QPJ5DOU.js} +3 -3
  9. package/{chunk-XEWEME7V.js → chunk-7R4SSWEY.js} +4 -4
  10. package/{chunk-NOQF5P7L.js → chunk-AEWU2YM3.js} +4 -4
  11. package/{chunk-IPJJ6SPP.js → chunk-ANOLYIPL.js} +2 -2
  12. package/{chunk-JKOHADWB.js → chunk-AUWSMG4F.js} +3 -3
  13. package/{chunk-JKOHADWB.js.map → chunk-AUWSMG4F.js.map} +1 -1
  14. package/{chunk-APSRFHWZ.js → chunk-BVCE3PAD.js} +2 -2
  15. package/{chunk-XYJDYAYC.js → chunk-DHQFVIPZ.js} +3 -3
  16. package/{chunk-YOEYKE3S.js → chunk-FLFZ47WJ.js} +2 -2
  17. package/{chunk-PIKDYOYV.js → chunk-GOQL4TY4.js} +3 -3
  18. package/{chunk-ESGNHS6C.js → chunk-IEU6XSW5.js} +3 -3
  19. package/{chunk-RIJV7M6E.js → chunk-J45P5ALH.js} +2 -2
  20. package/{chunk-FR224MDH.js → chunk-JAUTPXVK.js} +2 -2
  21. package/{chunk-3F4Y6RFF.js → chunk-LUNHJWDP.js} +7 -7
  22. package/{chunk-BEPCN5VV.js → chunk-LWHSFNRK.js} +3 -9
  23. package/chunk-LWHSFNRK.js.map +1 -0
  24. package/{chunk-GHTEDTGL.js → chunk-NKYACNWA.js} +2 -2
  25. package/{chunk-PC2HZDB4.js → chunk-O2L7CXVZ.js} +3 -60
  26. package/chunk-O2L7CXVZ.js.map +1 -0
  27. package/{chunk-5CA2JHZD.js → chunk-VNNPAHD3.js} +2 -2
  28. package/{chunk-6BMJ6UKM.js → chunk-YL5CDK4E.js} +2 -2
  29. package/{computer-use-CQNWSJPI.js → computer-use-PB4LNXCU.js} +7 -7
  30. package/{connector-TBDI6K3G.js → connector-KFLSG2WQ.js} +10 -10
  31. package/{credit-W2YK7WML.js → credit-R26H5QHN.js} +11 -11
  32. package/{developer-support-R75QA2AD.js → developer-support-Y7RNKJTH.js} +8 -8
  33. package/{doctor-3QHLHIXF.js → doctor-K6BOIL62.js} +11 -11
  34. package/{esm-SXSK2BEI.js → esm-GRI4FR5B.js} +30 -9
  35. package/esm-GRI4FR5B.js.map +1 -0
  36. package/{feishu-FQ5EZASI.js → feishu-LI3SINCU.js} +8 -8
  37. package/{finance-SDGIPPQG.js → finance-SJN3UHTH.js} +8 -8
  38. package/{generate-XTG7AUF6.js → generate-RXBVINXP.js} +13 -13
  39. package/{getMachineId-bsd-SEONPMIR.js → getMachineId-bsd-UR6WEJ6T.js} +4 -4
  40. package/{getMachineId-darwin-WCR6ZUPW.js → getMachineId-darwin-O3UESQMK.js} +4 -4
  41. package/{getMachineId-linux-JCQXUACW.js → getMachineId-linux-EGNGXDN3.js} +3 -3
  42. package/{getMachineId-unsupported-2SMDLJ6T.js → getMachineId-unsupported-EZ7SMARH.js} +3 -3
  43. package/{getMachineId-win-74VJCMCN.js → getMachineId-win-CM62ICHH.js} +4 -4
  44. package/{github-VHYMXRSL.js → github-S7ZPKL5Q.js} +8 -8
  45. package/{goal-2GFRBOON.js → goal-QY3JEJD5.js} +8 -8
  46. package/{host-GWAOWX2Y.js → host-GZH5RHJS.js} +8 -8
  47. package/{intro-COMCYJKY.js → intro-2UYXBOHI.js} +3 -3
  48. package/{logs-JFWVUVBV.js → logs-5GRE5WAY.js} +13 -13
  49. package/{mail-SFJOOF5T.js → mail-2PT5ZIWZ.js} +10 -10
  50. package/{maps-Z5ZA3KSP.js → maps-IN2UCVFP.js} +8 -8
  51. package/{model-B33B7KDW.js → model-PWEQPS6R.js} +9 -9
  52. package/{model-provider-775GSWU2.js → model-provider-LA4MKTUV.js} +9 -9
  53. package/{org-7SPC5LKV.js → org-KG4LKPZV.js} +9 -9
  54. package/package.json +1 -1
  55. package/{people-search-PWO6TS4T.js → people-search-UVOX2TZD.js} +8 -8
  56. package/{phone-CNXH64HR.js → phone-SOZRDNOK.js} +8 -8
  57. package/{preference-X7MDJHHN.js → preference-EDW74L7N.js} +9 -9
  58. package/{recognize-H6S4LJKB.js → recognize-5AK6UOZK.js} +8 -8
  59. package/{resource-3NH3TJ4Y.js → resource-UWBZNZ7Q.js} +9 -9
  60. package/{scrape-IHFIZT3M.js → scrape-6BVY7IQY.js} +8 -8
  61. package/{search-5PVCL3GS.js → search-HXLHHYC3.js} +13 -13
  62. package/{secret-FXKQ7C26.js → secret-SXRVG52Q.js} +9 -9
  63. package/{slack-N7Y47HF4.js → slack-CLP4POQB.js} +8 -8
  64. package/{teams-JAN67PG3.js → teams-TLRVUYTY.js} +8 -8
  65. package/{telegram-FZ7LNOUC.js → telegram-URIUGNGJ.js} +8 -8
  66. package/{undici-ETWE7SN4.js → undici-MBS5ACFE.js} +1823 -644
  67. package/undici-MBS5ACFE.js.map +1 -0
  68. package/{upgrade-MHC6IJKO.js → upgrade-X7DU6HLO.js} +8 -8
  69. package/{variable-RRV47SWO.js → variable-WUYEL65V.js} +9 -9
  70. package/{video-MSC5R23P.js → video-4CPNBFWY.js} +7 -7
  71. package/{weather-7VEGS6IZ.js → weather-S4L4XU2G.js} +8 -8
  72. package/{web-N42PHF2A.js → web-QMET3U3T.js} +8 -8
  73. package/{web-search-IW44QBUJ.js → web-search-BOENA4JA.js} +8 -8
  74. package/{whoami-XTQIEM6S.js → whoami-TKHAJZ5D.js} +9 -9
  75. package/{workflow-MMFEXZU3.js → workflow-FISYU5OY.js} +11 -11
  76. package/zero.js +50 -50
  77. package/zero.js.map +1 -1
  78. package/chunk-BEPCN5VV.js.map +0 -1
  79. package/chunk-PC2HZDB4.js.map +0 -1
  80. package/esm-SXSK2BEI.js.map +0 -1
  81. package/undici-ETWE7SN4.js.map +0 -1
  82. /package/{agent-ODXX2P6E.js.map → agent-XK6H2544.js.map} +0 -0
  83. /package/{banking-VS4X74FZ.js.map → banking-E5SI3MJU.js.map} +0 -0
  84. /package/{browser-GJBNBJRP.js.map → browser-TH4Y55RS.js.map} +0 -0
  85. /package/{chat-S3JIOOVJ.js.map → chat-3H5LWT6E.js.map} +0 -0
  86. /package/{chunk-XXWDEMGD.js.map → chunk-2W73DZDW.js.map} +0 -0
  87. /package/{chunk-KLI6K4VO.js.map → chunk-32FE3MDA.js.map} +0 -0
  88. /package/{chunk-N6H3IGX4.js.map → chunk-45J5VDVQ.js.map} +0 -0
  89. /package/{chunk-VATIZEFN.js.map → chunk-4QPJ5DOU.js.map} +0 -0
  90. /package/{chunk-XEWEME7V.js.map → chunk-7R4SSWEY.js.map} +0 -0
  91. /package/{chunk-NOQF5P7L.js.map → chunk-AEWU2YM3.js.map} +0 -0
  92. /package/{chunk-IPJJ6SPP.js.map → chunk-ANOLYIPL.js.map} +0 -0
  93. /package/{chunk-APSRFHWZ.js.map → chunk-BVCE3PAD.js.map} +0 -0
  94. /package/{chunk-XYJDYAYC.js.map → chunk-DHQFVIPZ.js.map} +0 -0
  95. /package/{chunk-YOEYKE3S.js.map → chunk-FLFZ47WJ.js.map} +0 -0
  96. /package/{chunk-PIKDYOYV.js.map → chunk-GOQL4TY4.js.map} +0 -0
  97. /package/{chunk-ESGNHS6C.js.map → chunk-IEU6XSW5.js.map} +0 -0
  98. /package/{chunk-RIJV7M6E.js.map → chunk-J45P5ALH.js.map} +0 -0
  99. /package/{chunk-FR224MDH.js.map → chunk-JAUTPXVK.js.map} +0 -0
  100. /package/{chunk-3F4Y6RFF.js.map → chunk-LUNHJWDP.js.map} +0 -0
  101. /package/{chunk-GHTEDTGL.js.map → chunk-NKYACNWA.js.map} +0 -0
  102. /package/{chunk-5CA2JHZD.js.map → chunk-VNNPAHD3.js.map} +0 -0
  103. /package/{chunk-6BMJ6UKM.js.map → chunk-YL5CDK4E.js.map} +0 -0
  104. /package/{computer-use-CQNWSJPI.js.map → computer-use-PB4LNXCU.js.map} +0 -0
  105. /package/{connector-TBDI6K3G.js.map → connector-KFLSG2WQ.js.map} +0 -0
  106. /package/{credit-W2YK7WML.js.map → credit-R26H5QHN.js.map} +0 -0
  107. /package/{developer-support-R75QA2AD.js.map → developer-support-Y7RNKJTH.js.map} +0 -0
  108. /package/{doctor-3QHLHIXF.js.map → doctor-K6BOIL62.js.map} +0 -0
  109. /package/{feishu-FQ5EZASI.js.map → feishu-LI3SINCU.js.map} +0 -0
  110. /package/{finance-SDGIPPQG.js.map → finance-SJN3UHTH.js.map} +0 -0
  111. /package/{generate-XTG7AUF6.js.map → generate-RXBVINXP.js.map} +0 -0
  112. /package/{getMachineId-bsd-SEONPMIR.js.map → getMachineId-bsd-UR6WEJ6T.js.map} +0 -0
  113. /package/{getMachineId-darwin-WCR6ZUPW.js.map → getMachineId-darwin-O3UESQMK.js.map} +0 -0
  114. /package/{getMachineId-linux-JCQXUACW.js.map → getMachineId-linux-EGNGXDN3.js.map} +0 -0
  115. /package/{getMachineId-unsupported-2SMDLJ6T.js.map → getMachineId-unsupported-EZ7SMARH.js.map} +0 -0
  116. /package/{getMachineId-win-74VJCMCN.js.map → getMachineId-win-CM62ICHH.js.map} +0 -0
  117. /package/{github-VHYMXRSL.js.map → github-S7ZPKL5Q.js.map} +0 -0
  118. /package/{goal-2GFRBOON.js.map → goal-QY3JEJD5.js.map} +0 -0
  119. /package/{host-GWAOWX2Y.js.map → host-GZH5RHJS.js.map} +0 -0
  120. /package/{intro-COMCYJKY.js.map → intro-2UYXBOHI.js.map} +0 -0
  121. /package/{logs-JFWVUVBV.js.map → logs-5GRE5WAY.js.map} +0 -0
  122. /package/{mail-SFJOOF5T.js.map → mail-2PT5ZIWZ.js.map} +0 -0
  123. /package/{maps-Z5ZA3KSP.js.map → maps-IN2UCVFP.js.map} +0 -0
  124. /package/{model-B33B7KDW.js.map → model-PWEQPS6R.js.map} +0 -0
  125. /package/{model-provider-775GSWU2.js.map → model-provider-LA4MKTUV.js.map} +0 -0
  126. /package/{org-7SPC5LKV.js.map → org-KG4LKPZV.js.map} +0 -0
  127. /package/{people-search-PWO6TS4T.js.map → people-search-UVOX2TZD.js.map} +0 -0
  128. /package/{phone-CNXH64HR.js.map → phone-SOZRDNOK.js.map} +0 -0
  129. /package/{preference-X7MDJHHN.js.map → preference-EDW74L7N.js.map} +0 -0
  130. /package/{recognize-H6S4LJKB.js.map → recognize-5AK6UOZK.js.map} +0 -0
  131. /package/{resource-3NH3TJ4Y.js.map → resource-UWBZNZ7Q.js.map} +0 -0
  132. /package/{scrape-IHFIZT3M.js.map → scrape-6BVY7IQY.js.map} +0 -0
  133. /package/{search-5PVCL3GS.js.map → search-HXLHHYC3.js.map} +0 -0
  134. /package/{secret-FXKQ7C26.js.map → secret-SXRVG52Q.js.map} +0 -0
  135. /package/{slack-N7Y47HF4.js.map → slack-CLP4POQB.js.map} +0 -0
  136. /package/{teams-JAN67PG3.js.map → teams-TLRVUYTY.js.map} +0 -0
  137. /package/{telegram-FZ7LNOUC.js.map → telegram-URIUGNGJ.js.map} +0 -0
  138. /package/{upgrade-MHC6IJKO.js.map → upgrade-X7DU6HLO.js.map} +0 -0
  139. /package/{variable-RRV47SWO.js.map → variable-WUYEL65V.js.map} +0 -0
  140. /package/{video-MSC5R23P.js.map → video-4CPNBFWY.js.map} +0 -0
  141. /package/{weather-7VEGS6IZ.js.map → weather-S4L4XU2G.js.map} +0 -0
  142. /package/{web-N42PHF2A.js.map → web-QMET3U3T.js.map} +0 -0
  143. /package/{web-search-IW44QBUJ.js.map → web-search-BOENA4JA.js.map} +0 -0
  144. /package/{whoami-XTQIEM6S.js.map → whoami-TKHAJZ5D.js.map} +0 -0
  145. /package/{workflow-MMFEXZU3.js.map → workflow-FISYU5OY.js.map} +0 -0
@@ -6,11 +6,11 @@ import {
6
6
  __filename,
7
7
  __require,
8
8
  init_esm_shims
9
- } from "./chunk-JKOHADWB.js";
9
+ } from "./chunk-AUWSMG4F.js";
10
10
 
11
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/symbols.js
11
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/symbols.js
12
12
  var require_symbols = __commonJS({
13
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/symbols.js"(exports, module) {
13
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/symbols.js"(exports, module) {
14
14
  "use strict";
15
15
  init_esm_shims();
16
16
  module.exports = {
@@ -69,6 +69,7 @@ var require_symbols = __commonJS({
69
69
  kCounter: /* @__PURE__ */ Symbol("socket request counter"),
70
70
  kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
71
71
  kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
72
+ kHTTP2Options: /* @__PURE__ */ Symbol("http2 options"),
72
73
  kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
73
74
  kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
74
75
  kConstruct: /* @__PURE__ */ Symbol("constructable"),
@@ -90,9 +91,9 @@ var require_symbols = __commonJS({
90
91
  }
91
92
  });
92
93
 
93
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/timers.js
94
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/timers.js
94
95
  var require_timers = __commonJS({
95
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/timers.js"(exports, module) {
96
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/timers.js"(exports, module) {
96
97
  "use strict";
97
98
  init_esm_shims();
98
99
  var fastNow = 0;
@@ -320,9 +321,9 @@ var require_timers = __commonJS({
320
321
  }
321
322
  });
322
323
 
323
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/errors.js
324
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/errors.js
324
325
  var require_errors = __commonJS({
325
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/errors.js"(exports, module) {
326
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/errors.js"(exports, module) {
326
327
  "use strict";
327
328
  init_esm_shims();
328
329
  var kUndiciError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR");
@@ -662,6 +663,22 @@ var require_errors = __commonJS({
662
663
  return true;
663
664
  }
664
665
  };
666
+ var kProxyConnectionError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_PRX_CONN");
667
+ var ProxyConnectionError = class extends UndiciError {
668
+ constructor(cause, message, options = {}) {
669
+ super(message, { cause, ...options });
670
+ this.name = "ProxyConnectionError";
671
+ this.message = message || "Proxy Connection failed";
672
+ this.code = "UND_ERR_PRX_CONN";
673
+ this.cause = cause;
674
+ }
675
+ static [Symbol.hasInstance](instance) {
676
+ return instance && instance[kProxyConnectionError] === true;
677
+ }
678
+ get [kProxyConnectionError]() {
679
+ return true;
680
+ }
681
+ };
665
682
  var kMaxOriginsReachedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_MAX_ORIGINS_REACHED");
666
683
  var MaxOriginsReachedError = class extends UndiciError {
667
684
  constructor(message) {
@@ -723,6 +740,7 @@ var require_errors = __commonJS({
723
740
  RequestRetryError,
724
741
  ResponseError,
725
742
  SecureProxyConnectionError,
743
+ ProxyConnectionError,
726
744
  MaxOriginsReachedError,
727
745
  Socks5ProxyError,
728
746
  MessageSizeExceededError
@@ -730,9 +748,9 @@ var require_errors = __commonJS({
730
748
  }
731
749
  });
732
750
 
733
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/constants.js
751
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/constants.js
734
752
  var require_constants = __commonJS({
735
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/constants.js"(exports, module) {
753
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/constants.js"(exports, module) {
736
754
  "use strict";
737
755
  init_esm_shims();
738
756
  var wellknownHeaderNames = (
@@ -849,9 +867,9 @@ var require_constants = __commonJS({
849
867
  }
850
868
  });
851
869
 
852
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/tree.js
870
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/tree.js
853
871
  var require_tree = __commonJS({
854
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/tree.js"(exports, module) {
872
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/tree.js"(exports, module) {
855
873
  "use strict";
856
874
  init_esm_shims();
857
875
  var {
@@ -992,9 +1010,9 @@ var require_tree = __commonJS({
992
1010
  }
993
1011
  });
994
1012
 
995
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/util.js
1013
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/util.js
996
1014
  var require_util = __commonJS({
997
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/util.js"(exports, module) {
1015
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/util.js"(exports, module) {
998
1016
  "use strict";
999
1017
  init_esm_shims();
1000
1018
  var assert = __require("assert");
@@ -1183,7 +1201,10 @@ var require_util = __commonJS({
1183
1201
  if (Object.getPrototypeOf(stream2).constructor === IncomingMessage) {
1184
1202
  stream2.socket = null;
1185
1203
  }
1186
- stream2.destroy(err);
1204
+ try {
1205
+ stream2.destroy(err);
1206
+ } catch {
1207
+ }
1187
1208
  } else if (err) {
1188
1209
  queueMicrotask(() => {
1189
1210
  stream2.emit("error", err);
@@ -1751,7 +1772,18 @@ var require_util = __commonJS({
1751
1772
  message += ` timeout: ${opts.timeout}ms)`;
1752
1773
  destroy(socket, new ConnectTimeoutError(message));
1753
1774
  }
1775
+ var lastUrlString = null;
1776
+ var lastProtocol = null;
1754
1777
  function getProtocolFromUrlString(urlString) {
1778
+ if (urlString === lastUrlString) {
1779
+ return lastProtocol;
1780
+ }
1781
+ const protocol = getProtocolFromUrlStringSlow(urlString);
1782
+ lastUrlString = urlString;
1783
+ lastProtocol = protocol;
1784
+ return protocol;
1785
+ }
1786
+ function getProtocolFromUrlStringSlow(urlString) {
1755
1787
  if (urlString[0] === "h" && urlString[1] === "t" && urlString[2] === "t" && urlString[3] === "p") {
1756
1788
  switch (urlString[4]) {
1757
1789
  case ":":
@@ -1780,7 +1812,9 @@ var require_util = __commonJS({
1780
1812
  post: "POST",
1781
1813
  POST: "POST",
1782
1814
  put: "PUT",
1783
- PUT: "PUT"
1815
+ PUT: "PUT",
1816
+ query: "QUERY",
1817
+ QUERY: "QUERY"
1784
1818
  };
1785
1819
  var normalizedMethodRecords = {
1786
1820
  ...normalizedMethodRecordsBase,
@@ -1838,9 +1872,9 @@ var require_util = __commonJS({
1838
1872
  }
1839
1873
  });
1840
1874
 
1841
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/stats.js
1875
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/stats.js
1842
1876
  var require_stats = __commonJS({
1843
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/stats.js"(exports, module) {
1877
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/stats.js"(exports, module) {
1844
1878
  "use strict";
1845
1879
  init_esm_shims();
1846
1880
  var {
@@ -1873,9 +1907,9 @@ var require_stats = __commonJS({
1873
1907
  }
1874
1908
  });
1875
1909
 
1876
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/diagnostics.js
1910
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/diagnostics.js
1877
1911
  var require_diagnostics = __commonJS({
1878
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/diagnostics.js"(exports, module) {
1912
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/diagnostics.js"(exports, module) {
1879
1913
  "use strict";
1880
1914
  init_esm_shims();
1881
1915
  var diagnosticsChannel = __require("diagnostics_channel");
@@ -2091,9 +2125,9 @@ var require_diagnostics = __commonJS({
2091
2125
  }
2092
2126
  });
2093
2127
 
2094
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/request.js
2128
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/request.js
2095
2129
  var require_request = __commonJS({
2096
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/request.js"(exports, module) {
2130
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/request.js"(exports, module) {
2097
2131
  "use strict";
2098
2132
  init_esm_shims();
2099
2133
  var {
@@ -2234,7 +2268,7 @@ var require_request = __commonJS({
2234
2268
  this.headersTimeout = headersTimeout;
2235
2269
  this.bodyTimeout = bodyTimeout;
2236
2270
  this.method = method;
2237
- this.typeOfService = typeOfService ?? 0;
2271
+ this.typeOfService = typeOfService;
2238
2272
  this.abort = null;
2239
2273
  if (body == null) {
2240
2274
  this.body = null;
@@ -2274,7 +2308,7 @@ var require_request = __commonJS({
2274
2308
  this.path = query ? serializePathWithQuery(path, query) : path;
2275
2309
  this.origin = origin;
2276
2310
  this.protocol = getProtocolFromUrlString(origin);
2277
- this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
2311
+ this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" || method === "QUERY" : idempotent;
2278
2312
  this.blocking = blocking ?? this.method !== "HEAD";
2279
2313
  this.reset = reset == null ? null : reset;
2280
2314
  this.host = null;
@@ -2468,7 +2502,11 @@ var require_request = __commonJS({
2468
2502
  } else if (typeof val[i] === "object") {
2469
2503
  throw new InvalidArgumentError(`invalid ${key} header`);
2470
2504
  } else {
2471
- arr.push(`${val[i]}`);
2505
+ const str = `${val[i]}`;
2506
+ if (!isValidHeaderValue(str)) {
2507
+ throw new InvalidArgumentError(`invalid ${key} header`);
2508
+ }
2509
+ arr.push(str);
2472
2510
  }
2473
2511
  }
2474
2512
  val = arr;
@@ -2480,6 +2518,9 @@ var require_request = __commonJS({
2480
2518
  val = "";
2481
2519
  } else {
2482
2520
  val = `${val}`;
2521
+ if (!isValidHeaderValue(val)) {
2522
+ throw new InvalidArgumentError(`invalid ${key} header`);
2523
+ }
2483
2524
  }
2484
2525
  if (headerName === "host") {
2485
2526
  if (request.host !== null) {
@@ -2526,9 +2567,9 @@ var require_request = __commonJS({
2526
2567
  }
2527
2568
  });
2528
2569
 
2529
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher.js
2570
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher.js
2530
2571
  var require_dispatcher = __commonJS({
2531
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher.js"(exports, module) {
2572
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher.js"(exports, module) {
2532
2573
  "use strict";
2533
2574
  init_esm_shims();
2534
2575
  var EventEmitter = __require("events");
@@ -2566,9 +2607,9 @@ var require_dispatcher = __commonJS({
2566
2607
  }
2567
2608
  });
2568
2609
 
2569
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher-base.js
2610
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher-base.js
2570
2611
  var require_dispatcher_base = __commonJS({
2571
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports, module) {
2612
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports, module) {
2572
2613
  "use strict";
2573
2614
  init_esm_shims();
2574
2615
  var Dispatcher = require_dispatcher();
@@ -2720,9 +2761,9 @@ var require_dispatcher_base = __commonJS({
2720
2761
  }
2721
2762
  });
2722
2763
 
2723
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/connect.js
2764
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/connect.js
2724
2765
  var require_connect = __commonJS({
2725
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/connect.js"(exports, module) {
2766
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/connect.js"(exports, module) {
2726
2767
  "use strict";
2727
2768
  init_esm_shims();
2728
2769
  var net = __require("net");
@@ -2808,14 +2849,26 @@ var require_connect = __commonJS({
2808
2849
  } else {
2809
2850
  assert(!httpSocket, "httpSocket can only be sent on TLS update");
2810
2851
  port = port || 80;
2811
- socket = net.connect({
2852
+ const connectOptions = {
2812
2853
  highWaterMark: 64 * 1024,
2813
2854
  // Same as nodejs fs streams.
2814
2855
  ...options,
2815
2856
  localAddress,
2816
2857
  port,
2817
2858
  host: hostname
2818
- });
2859
+ };
2860
+ const family = net.isIP(hostname);
2861
+ if (family !== 0 && servername && servername !== hostname) {
2862
+ connectOptions.host = servername;
2863
+ connectOptions.lookup = (_hostname, lookupOptions, cb) => {
2864
+ if (lookupOptions.all) {
2865
+ cb(null, [{ address: hostname, family }]);
2866
+ } else {
2867
+ cb(null, hostname, family);
2868
+ }
2869
+ };
2870
+ }
2871
+ socket = net.connect(connectOptions);
2819
2872
  if (useH2c === true) {
2820
2873
  socket.alpnProtocol = "h2";
2821
2874
  }
@@ -2862,9 +2915,9 @@ var require_connect = __commonJS({
2862
2915
  }
2863
2916
  });
2864
2917
 
2865
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/utils.js
2918
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/utils.js
2866
2919
  var require_utils = __commonJS({
2867
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/utils.js"(exports) {
2920
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/utils.js"(exports) {
2868
2921
  "use strict";
2869
2922
  init_esm_shims();
2870
2923
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -2879,9 +2932,9 @@ var require_utils = __commonJS({
2879
2932
  }
2880
2933
  });
2881
2934
 
2882
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/constants.js
2935
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/constants.js
2883
2936
  var require_constants2 = __commonJS({
2884
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/constants.js"(exports) {
2937
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/constants.js"(exports) {
2885
2938
  "use strict";
2886
2939
  init_esm_shims();
2887
2940
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -3503,9 +3556,9 @@ var require_constants2 = __commonJS({
3503
3556
  }
3504
3557
  });
3505
3558
 
3506
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/llhttp-wasm.js
3559
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/llhttp-wasm.js
3507
3560
  var require_llhttp_wasm = __commonJS({
3508
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/llhttp-wasm.js"(exports, module) {
3561
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/llhttp-wasm.js"(exports, module) {
3509
3562
  "use strict";
3510
3563
  init_esm_shims();
3511
3564
  var { Buffer: Buffer2 } = __require("buffer");
@@ -3519,9 +3572,9 @@ var require_llhttp_wasm = __commonJS({
3519
3572
  }
3520
3573
  });
3521
3574
 
3522
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js
3575
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js
3523
3576
  var require_llhttp_simd_wasm = __commonJS({
3524
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js"(exports, module) {
3577
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js"(exports, module) {
3525
3578
  "use strict";
3526
3579
  init_esm_shims();
3527
3580
  var { Buffer: Buffer2 } = __require("buffer");
@@ -3535,9 +3588,9 @@ var require_llhttp_simd_wasm = __commonJS({
3535
3588
  }
3536
3589
  });
3537
3590
 
3538
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/constants.js
3591
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/constants.js
3539
3592
  var require_constants3 = __commonJS({
3540
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/constants.js"(exports, module) {
3593
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/constants.js"(exports, module) {
3541
3594
  "use strict";
3542
3595
  init_esm_shims();
3543
3596
  var corsSafeListedMethods = (
@@ -3669,7 +3722,7 @@ var require_constants3 = __commonJS({
3669
3722
  );
3670
3723
  var safeMethods = (
3671
3724
  /** @type {const} */
3672
- ["GET", "HEAD", "OPTIONS", "TRACE"]
3725
+ ["GET", "HEAD", "OPTIONS", "TRACE", "QUERY"]
3673
3726
  );
3674
3727
  var safeMethodsSet = new Set(safeMethods);
3675
3728
  var requestMode = (
@@ -3760,9 +3813,9 @@ var require_constants3 = __commonJS({
3760
3813
  }
3761
3814
  });
3762
3815
 
3763
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/global.js
3816
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/global.js
3764
3817
  var require_global = __commonJS({
3765
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/global.js"(exports, module) {
3818
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/global.js"(exports, module) {
3766
3819
  "use strict";
3767
3820
  init_esm_shims();
3768
3821
  var globalOrigin = /* @__PURE__ */ Symbol.for("undici.globalOrigin.1");
@@ -3797,9 +3850,9 @@ var require_global = __commonJS({
3797
3850
  }
3798
3851
  });
3799
3852
 
3800
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/encoding/index.js
3853
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/encoding/index.js
3801
3854
  var require_encoding = __commonJS({
3802
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/encoding/index.js"(exports, module) {
3855
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/encoding/index.js"(exports, module) {
3803
3856
  "use strict";
3804
3857
  init_esm_shims();
3805
3858
  var textDecoder = new TextDecoder();
@@ -3819,9 +3872,9 @@ var require_encoding = __commonJS({
3819
3872
  }
3820
3873
  });
3821
3874
 
3822
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/infra/index.js
3875
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/infra/index.js
3823
3876
  var require_infra = __commonJS({
3824
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/infra/index.js"(exports, module) {
3877
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/infra/index.js"(exports, module) {
3825
3878
  "use strict";
3826
3879
  init_esm_shims();
3827
3880
  var assert = __require("assert");
@@ -3933,9 +3986,9 @@ var require_infra = __commonJS({
3933
3986
  }
3934
3987
  });
3935
3988
 
3936
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/data-url.js
3989
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/data-url.js
3937
3990
  var require_data_url = __commonJS({
3938
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/data-url.js"(exports, module) {
3991
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/data-url.js"(exports, module) {
3939
3992
  "use strict";
3940
3993
  init_esm_shims();
3941
3994
  var assert = __require("assert");
@@ -4213,9 +4266,9 @@ var require_data_url = __commonJS({
4213
4266
  }
4214
4267
  });
4215
4268
 
4216
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/webidl/index.js
4269
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/webidl/index.js
4217
4270
  var require_webidl = __commonJS({
4218
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/webidl/index.js"(exports, module) {
4271
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/webidl/index.js"(exports, module) {
4219
4272
  "use strict";
4220
4273
  init_esm_shims();
4221
4274
  var assert = __require("assert");
@@ -4815,9 +4868,9 @@ var require_webidl = __commonJS({
4815
4868
  }
4816
4869
  });
4817
4870
 
4818
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/util.js
4871
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/util.js
4819
4872
  var require_util2 = __commonJS({
4820
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/util.js"(exports, module) {
4873
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/util.js"(exports, module) {
4821
4874
  "use strict";
4822
4875
  init_esm_shims();
4823
4876
  var { Transform } = __require("stream");
@@ -5397,7 +5450,7 @@ var require_util2 = __commonJS({
5397
5450
  if (rangeEndValue === null && rangeStartValue === null) {
5398
5451
  return "failure";
5399
5452
  }
5400
- if (rangeStartValue > rangeEndValue) {
5453
+ if (rangeStartValue !== null && rangeEndValue !== null && rangeStartValue > rangeEndValue) {
5401
5454
  return "failure";
5402
5455
  }
5403
5456
  return { rangeStartValue, rangeEndValue };
@@ -5583,9 +5636,9 @@ var require_util2 = __commonJS({
5583
5636
  }
5584
5637
  });
5585
5638
 
5586
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/runtime-features.js
5639
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/runtime-features.js
5587
5640
  var require_runtime_features = __commonJS({
5588
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/runtime-features.js"(exports, module) {
5641
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/runtime-features.js"(exports, module) {
5589
5642
  "use strict";
5590
5643
  init_esm_shims();
5591
5644
  var lazyLoaders = {
@@ -5659,9 +5712,9 @@ var require_runtime_features = __commonJS({
5659
5712
  }
5660
5713
  });
5661
5714
 
5662
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/formdata.js
5715
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/formdata.js
5663
5716
  var require_formdata = __commonJS({
5664
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/formdata.js"(exports, module) {
5717
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/formdata.js"(exports, module) {
5665
5718
  "use strict";
5666
5719
  init_esm_shims();
5667
5720
  var { iteratorMixin } = require_util2();
@@ -5835,9 +5888,9 @@ var require_formdata = __commonJS({
5835
5888
  }
5836
5889
  });
5837
5890
 
5838
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/formdata-parser.js
5891
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/formdata-parser.js
5839
5892
  var require_formdata_parser = __commonJS({
5840
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/formdata-parser.js"(exports, module) {
5893
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/formdata-parser.js"(exports, module) {
5841
5894
  "use strict";
5842
5895
  init_esm_shims();
5843
5896
  var { bufferToLowerCasedHeaderName } = require_util();
@@ -6166,9 +6219,9 @@ var require_formdata_parser = __commonJS({
6166
6219
  }
6167
6220
  });
6168
6221
 
6169
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/body.js
6222
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/body.js
6170
6223
  var require_body = __commonJS({
6171
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/body.js"(exports, module) {
6224
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/body.js"(exports, module) {
6172
6225
  "use strict";
6173
6226
  init_esm_shims();
6174
6227
  var util = require_util();
@@ -6187,6 +6240,7 @@ var require_body = __commonJS({
6187
6240
  var { multipartFormDataParser } = require_formdata_parser();
6188
6241
  var { parseJSONFromBytes } = require_infra();
6189
6242
  var { utf8DecodeBytes } = require_encoding();
6243
+ var { ReadableStreamTee } = __require("stream/web");
6190
6244
  var textEncoder = new TextEncoder();
6191
6245
  function noop() {
6192
6246
  }
@@ -6329,7 +6383,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
6329
6383
  return extractBody(object, keepalive);
6330
6384
  }
6331
6385
  function cloneBody(body) {
6332
- const { 0: out1, 1: out2 } = body.stream.tee();
6386
+ const { 0: out1, 1: out2 } = ReadableStreamTee?.(body.stream, true) ?? body.stream.tee();
6333
6387
  body.stream = out1;
6334
6388
  return {
6335
6389
  stream: out2,
@@ -6470,9 +6524,9 @@ Content-Type: ${value.type || "application/octet-stream"}\r
6470
6524
  }
6471
6525
  });
6472
6526
 
6473
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client-h1.js
6527
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client-h1.js
6474
6528
  var require_client_h1 = __commonJS({
6475
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client-h1.js"(exports, module) {
6529
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client-h1.js"(exports, module) {
6476
6530
  "use strict";
6477
6531
  init_esm_shims();
6478
6532
  var assert = __require("assert");
@@ -6483,6 +6537,7 @@ var require_client_h1 = __commonJS({
6483
6537
  RequestContentLengthMismatchError,
6484
6538
  ResponseContentLengthMismatchError,
6485
6539
  RequestAbortedError,
6540
+ InvalidArgumentError,
6486
6541
  HeadersTimeoutError,
6487
6542
  HeadersOverflowError,
6488
6543
  SocketError,
@@ -6532,6 +6587,7 @@ var require_client_h1 = __commonJS({
6532
6587
  var kIdleSocketValidation = /* @__PURE__ */ Symbol("kIdleSocketValidation");
6533
6588
  var kIdleSocketValidationTimeout = /* @__PURE__ */ Symbol("kIdleSocketValidationTimeout");
6534
6589
  var kSocketUsed = /* @__PURE__ */ Symbol("kSocketUsed");
6590
+ var kTypeOfService = /* @__PURE__ */ Symbol("kTypeOfService");
6535
6591
  var extractBody;
6536
6592
  function lazyllhttp() {
6537
6593
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
@@ -6773,6 +6829,19 @@ var require_client_h1 = __commonJS({
6773
6829
  assert(currentParser === null);
6774
6830
  assert(this.ptr != null);
6775
6831
  const { llhttp } = this;
6832
+ if (this.paused) {
6833
+ let data;
6834
+ do {
6835
+ llhttp.llhttp_resume(this.ptr);
6836
+ this.paused = false;
6837
+ data = this.socket.read() || EMPTY_BUF;
6838
+ this.execute(data);
6839
+ } while (this.paused && data.length > 0);
6840
+ if (this.paused) {
6841
+ llhttp.llhttp_resume(this.ptr);
6842
+ this.paused = false;
6843
+ }
6844
+ }
6776
6845
  let ret;
6777
6846
  try {
6778
6847
  currentParser = this;
@@ -7322,6 +7391,24 @@ var require_client_h1 = __commonJS({
7322
7391
  function shouldSendContentLength(method) {
7323
7392
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
7324
7393
  }
7394
+ function setTypeOfService(socket, request) {
7395
+ if (typeof socket.setTypeOfService !== "function") {
7396
+ return;
7397
+ }
7398
+ const typeOfService = request.typeOfService;
7399
+ if (typeOfService === void 0) {
7400
+ return;
7401
+ }
7402
+ const currentTypeOfService = socket[kTypeOfService];
7403
+ if (currentTypeOfService === typeOfService) {
7404
+ return;
7405
+ }
7406
+ try {
7407
+ socket.setTypeOfService(typeOfService);
7408
+ socket[kTypeOfService] = typeOfService;
7409
+ } catch {
7410
+ }
7411
+ }
7325
7412
  function writeH1(client, request) {
7326
7413
  const { method, path, host, upgrade, blocking, reset } = request;
7327
7414
  let { body, headers, contentLength } = request;
@@ -7336,8 +7423,16 @@ var require_client_h1 = __commonJS({
7336
7423
  }
7337
7424
  body = bodyStream.stream;
7338
7425
  contentLength = bodyStream.length;
7339
- } else if (util.isBlobLike(body) && request.contentType == null && body.type) {
7340
- headers.push("content-type", body.type);
7426
+ } else if (util.isBlobLike(body) && request.contentType == null) {
7427
+ const contentType = body.type;
7428
+ if (contentType) {
7429
+ const contentTypeValue = `${contentType}`;
7430
+ if (!util.isValidHeaderValue(contentTypeValue)) {
7431
+ util.errorRequest(client, request, new InvalidArgumentError("invalid content-type header"));
7432
+ return false;
7433
+ }
7434
+ headers.push("content-type", contentTypeValue);
7435
+ }
7341
7436
  }
7342
7437
  if (body && typeof body.read === "function") {
7343
7438
  body.read(0);
@@ -7390,9 +7485,7 @@ var require_client_h1 = __commonJS({
7390
7485
  if (blocking) {
7391
7486
  socket[kBlocking] = true;
7392
7487
  }
7393
- if (socket.setTypeOfService) {
7394
- socket.setTypeOfService(request.typeOfService);
7395
- }
7488
+ setTypeOfService(socket, request);
7396
7489
  let header = `${method} ${path} HTTP/1.1\r
7397
7490
  `;
7398
7491
  if (typeof host === "string") {
@@ -7738,9 +7831,9 @@ ${len.toString(16)}\r
7738
7831
  }
7739
7832
  });
7740
7833
 
7741
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client-h2.js
7834
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client-h2.js
7742
7835
  var require_client_h2 = __commonJS({
7743
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client-h2.js"(exports, module) {
7836
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client-h2.js"(exports, module) {
7744
7837
  "use strict";
7745
7838
  init_esm_shims();
7746
7839
  var assert = __require("assert");
@@ -7769,10 +7862,7 @@ var require_client_h2 = __commonJS({
7769
7862
  kStrictContentLength,
7770
7863
  kOnError,
7771
7864
  kMaxConcurrentStreams,
7772
- kPingInterval,
7773
7865
  kHTTP2Session,
7774
- kHTTP2InitialWindowSize,
7775
- kHTTP2ConnectionWindowSize,
7776
7866
  kHostAuthority,
7777
7867
  kResume,
7778
7868
  kSize,
@@ -7784,7 +7874,8 @@ var require_client_h2 = __commonJS({
7784
7874
  kEnableConnectProtocol,
7785
7875
  kRemoteSettings,
7786
7876
  kHTTP2Stream,
7787
- kHTTP2SessionState
7877
+ kHTTP2SessionState,
7878
+ kHTTP2Options
7788
7879
  } = require_symbols();
7789
7880
  var { channels } = require_diagnostics();
7790
7881
  var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
@@ -7793,6 +7884,9 @@ var require_client_h2 = __commonJS({
7793
7884
  var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
7794
7885
  var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
7795
7886
  var kReceivedGoAway = /* @__PURE__ */ Symbol("received goaway");
7887
+ var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
7888
+ var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
7889
+ var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
7796
7890
  var extractBody;
7797
7891
  var http2;
7798
7892
  try {
@@ -7873,23 +7967,33 @@ var require_client_h2 = __commonJS({
7873
7967
  client[kQueue].splice(client[kPendingIdx] + 1, 0, request);
7874
7968
  }
7875
7969
  function completeRequest(client, request, resetPendingIdx = false) {
7876
- const index = client[kQueue].indexOf(request, client[kRunningIdx]);
7970
+ const queue = client[kQueue];
7971
+ const runningIdx = client[kRunningIdx];
7972
+ if (runningIdx < client[kPendingIdx] && queue[runningIdx] === request) {
7973
+ queue[runningIdx] = null;
7974
+ client[kRunningIdx] = runningIdx + 1;
7975
+ return;
7976
+ }
7977
+ const index = queue.indexOf(request, runningIdx);
7877
7978
  if (index === -1 || index >= client[kPendingIdx]) {
7878
7979
  return;
7879
7980
  }
7880
- client[kQueue].splice(index, 1);
7981
+ queue.splice(index, 1);
7881
7982
  client[kPendingIdx]--;
7882
7983
  if (resetPendingIdx && client[kPendingIdx] < client[kRunningIdx]) {
7883
7984
  client[kPendingIdx] = client[kRunningIdx];
7884
7985
  }
7885
7986
  }
7886
- function canRetryRequestAfterGoAway(request) {
7987
+ function canReplayRequest(request) {
7887
7988
  const { body } = request;
7888
7989
  return body == null || util.isBuffer(body) || util.isBlobLike(body);
7889
7990
  }
7890
- function closeRequestStream(request, code = NGHTTP2_REFUSED_STREAM) {
7891
- const stream = request[kRequestStream];
7892
- clearRequestStream(request);
7991
+ function registerGoAwayRefusal(request) {
7992
+ const attempts = (request[kGoAwayReplayAttempts] ?? 0) + 1;
7993
+ request[kGoAwayReplayAttempts] = attempts;
7994
+ return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS;
7995
+ }
7996
+ function closeStream(stream, code = NGHTTP2_REFUSED_STREAM) {
7893
7997
  if (stream != null && !stream.destroyed && !stream.closed) {
7894
7998
  try {
7895
7999
  stream.close(code);
@@ -7897,13 +8001,33 @@ var require_client_h2 = __commonJS({
7897
8001
  }
7898
8002
  }
7899
8003
  }
8004
+ function detachRequestStreamForClose(request) {
8005
+ const stream = request[kRequestStream];
8006
+ clearRequestStream(request);
8007
+ severRequestStream(stream);
8008
+ return stream;
8009
+ }
8010
+ function severRequestStream(stream) {
8011
+ if (stream == null || stream[kRequestStreamState] == null) {
8012
+ return;
8013
+ }
8014
+ stream[kRequestStreamState] = null;
8015
+ stream.off("close", completeRequestStream);
8016
+ stream.off("close", onUpgradeStreamClose);
8017
+ if (stream[kHTTP2Session] != null) {
8018
+ closeStreamSession(stream);
8019
+ }
8020
+ if (!stream.destroyed && !stream.closed) {
8021
+ stream.once("error", noop);
8022
+ }
8023
+ }
7900
8024
  function connectH2(client, socket) {
7901
8025
  client[kSocket] = socket;
7902
- const http2InitialWindowSize = client[kHTTP2InitialWindowSize];
7903
- const http2ConnectionWindowSize = client[kHTTP2ConnectionWindowSize];
8026
+ const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize;
8027
+ const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize;
7904
8028
  const session = http2.connect(client[kUrl], {
7905
8029
  createConnection: () => socket,
7906
- peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
8030
+ peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
7907
8031
  settings: {
7908
8032
  // TODO(metcoder95): add support for PUSH
7909
8033
  enablePush: false,
@@ -7916,8 +8040,16 @@ var require_client_h2 = __commonJS({
7916
8040
  session[kSocket] = socket;
7917
8041
  session[kHTTP2SessionState] = {
7918
8042
  idleTimeout: null,
8043
+ // Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
8044
+ // work that cannot start. See setNoStreamsTimeout.
8045
+ noStreamsTimeout: null,
8046
+ // Sockets start out ref'd. Session ref/unref proxies to the socket, so a
8047
+ // single cached flag lets us skip redundant uv ref/unref calls, provided
8048
+ // every ref/unref of the session or its socket goes through
8049
+ // refH2Session/unrefH2Session.
8050
+ refed: true,
7919
8051
  ping: {
7920
- interval: client[kPingInterval] === 0 ? null : setInterval(onHttp2SendPing, client[kPingInterval], session).unref()
8052
+ interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
7921
8053
  }
7922
8054
  };
7923
8055
  session[kReceivedGoAway] = false;
@@ -7928,11 +8060,10 @@ var require_client_h2 = __commonJS({
7928
8060
  }
7929
8061
  util.addListener(session, "error", onHttp2SessionError);
7930
8062
  util.addListener(session, "frameError", onHttp2FrameError);
7931
- util.addListener(session, "end", onHttp2SessionEnd);
7932
8063
  util.addListener(session, "goaway", onHttp2SessionGoAway);
7933
8064
  util.addListener(session, "close", onHttp2SessionClose);
7934
8065
  util.addListener(session, "remoteSettings", onHttp2RemoteSettings);
7935
- session.unref();
8066
+ unrefH2Session(session);
7936
8067
  client[kHTTP2Session] = session;
7937
8068
  socket[kHTTP2Session] = session;
7938
8069
  util.addListener(socket, "error", onHttp2SocketError);
@@ -7987,7 +8118,6 @@ var require_client_h2 = __commonJS({
7987
8118
  if (request != null) {
7988
8119
  if (client[kRunning] > 0) {
7989
8120
  if ((request.upgrade === "websocket" || request.method === "CONNECT") && session[kRemoteSettings] === false) return true;
7990
- if (util.bodyLength(request.body) !== 0 && (util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))) return true;
7991
8121
  } else {
7992
8122
  return (request.upgrade === "websocket" || request.method === "CONNECT") && session[kRemoteSettings] === false;
7993
8123
  }
@@ -7996,23 +8126,75 @@ var require_client_h2 = __commonJS({
7996
8126
  }
7997
8127
  };
7998
8128
  }
8129
+ function refH2Session(session) {
8130
+ const state = session[kHTTP2SessionState];
8131
+ if (state.refed === false) {
8132
+ state.refed = true;
8133
+ session.ref();
8134
+ }
8135
+ }
8136
+ function unrefH2Session(session) {
8137
+ const state = session[kHTTP2SessionState];
8138
+ if (state.refed === true) {
8139
+ state.refed = false;
8140
+ session.unref();
8141
+ }
8142
+ }
7999
8143
  function resumeH2(client) {
8000
8144
  const socket = client[kSocket];
8001
8145
  const session = client[kHTTP2Session];
8002
8146
  if (socket?.destroyed === false) {
8003
8147
  if (client[kSize] === 0 || client[kMaxConcurrentStreams] === 0) {
8004
- socket.unref();
8005
- session.unref();
8148
+ unrefH2Session(session);
8006
8149
  } else {
8007
- socket.ref();
8008
- session.ref();
8150
+ refH2Session(session);
8009
8151
  }
8010
8152
  if (client[kSize] === 0 && session[kOpenStreams] === 0) {
8011
8153
  setHttp2IdleTimeout(session);
8012
8154
  } else {
8013
8155
  clearHttp2IdleTimeout(session);
8014
8156
  }
8157
+ if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
8158
+ setNoStreamsTimeout(session);
8159
+ } else {
8160
+ clearNoStreamsTimeout(session);
8161
+ }
8162
+ }
8163
+ }
8164
+ function clearNoStreamsTimeout(session) {
8165
+ const state = session[kHTTP2SessionState];
8166
+ if (state?.noStreamsTimeout != null) {
8167
+ clearTimeout(state.noStreamsTimeout);
8168
+ state.noStreamsTimeout = null;
8169
+ }
8170
+ }
8171
+ function setNoStreamsTimeout(session) {
8172
+ const client = session[kClient];
8173
+ const state = session[kHTTP2SessionState];
8174
+ const timeout = client[kHeadersTimeout];
8175
+ if (!timeout || state.noStreamsTimeout != null) {
8176
+ return;
8177
+ }
8178
+ state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
8179
+ }
8180
+ function onNoStreamsTimeout(session) {
8181
+ const client = session[kClient];
8182
+ const state = session[kHTTP2SessionState];
8183
+ state.noStreamsTimeout = null;
8184
+ if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
8185
+ return;
8186
+ }
8187
+ const err = new HeadersTimeoutError(
8188
+ `HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
8189
+ );
8190
+ const requests = client[kQueue].splice(client[kPendingIdx]);
8191
+ for (let i = 0; i < requests.length; i++) {
8192
+ if (requests[i] != null) {
8193
+ util.errorRequest(client, requests[i], err);
8194
+ }
8015
8195
  }
8196
+ session[kError] = err;
8197
+ resetHttp2Session(session, err);
8016
8198
  }
8017
8199
  function clearHttp2IdleTimeout(session) {
8018
8200
  const state = session[kHTTP2SessionState];
@@ -8090,20 +8272,21 @@ var require_client_h2 = __commonJS({
8090
8272
  function onHttp2SessionError(err) {
8091
8273
  assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
8092
8274
  this[kSocket][kError] = err;
8275
+ if (this[kReceivedGoAway]) {
8276
+ return;
8277
+ }
8093
8278
  this[kClient][kOnError](err);
8094
8279
  }
8095
8280
  function onHttp2FrameError(type, code, id) {
8096
8281
  if (id === 0) {
8282
+ if (this[kReceivedGoAway]) {
8283
+ return;
8284
+ }
8097
8285
  const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
8098
8286
  this[kSocket][kError] = err;
8099
8287
  this[kClient][kOnError](err);
8100
8288
  }
8101
8289
  }
8102
- function onHttp2SessionEnd() {
8103
- const err = new SocketError("other side closed", util.getSocketInfo(this[kSocket]));
8104
- this.destroy(err);
8105
- util.destroy(this[kSocket], err);
8106
- }
8107
8290
  function onHttp2SessionGoAway(errorCode, lastStreamID) {
8108
8291
  if (this[kReceivedGoAway]) {
8109
8292
  return;
@@ -8114,17 +8297,21 @@ var require_client_h2 = __commonJS({
8114
8297
  const previousPendingIdx = client[kPendingIdx];
8115
8298
  const pendingIdx = getGoAwayPendingIdx(client, lastStreamID);
8116
8299
  const retriableRequests = [];
8300
+ const streamsToClose = [];
8117
8301
  for (let i = pendingIdx; i < previousPendingIdx; i++) {
8118
8302
  const request = client[kQueue][i];
8119
8303
  if (request != null) {
8120
- closeRequestStream(request);
8121
- if (canRetryRequestAfterGoAway(request)) {
8304
+ streamsToClose.push(detachRequestStreamForClose(request));
8305
+ if (canReplayRequest(request) && registerGoAwayRefusal(request)) {
8122
8306
  retriableRequests.push(request);
8123
8307
  } else {
8124
8308
  util.errorRequest(client, request, err);
8125
8309
  }
8126
8310
  }
8127
8311
  }
8312
+ for (let i = 0; i < streamsToClose.length; i++) {
8313
+ closeStream(streamsToClose[i]);
8314
+ }
8128
8315
  if (pendingIdx !== previousPendingIdx) {
8129
8316
  const remainingPendingRequests = client[kQueue].slice(previousPendingIdx);
8130
8317
  client[kQueue].length = pendingIdx;
@@ -8136,6 +8323,7 @@ var require_client_h2 = __commonJS({
8136
8323
  client[kHTTP2Session] = null;
8137
8324
  }
8138
8325
  clearHttp2IdleTimeout(this);
8326
+ clearNoStreamsTimeout(this);
8139
8327
  if (!this.closed && !this.destroyed) {
8140
8328
  this.close();
8141
8329
  }
@@ -8152,6 +8340,7 @@ var require_client_h2 = __commonJS({
8152
8340
  client[kHTTP2Session] = null;
8153
8341
  }
8154
8342
  clearHttp2IdleTimeout(this);
8343
+ clearNoStreamsTimeout(this);
8155
8344
  if (state.ping.interval != null) {
8156
8345
  clearInterval(state.ping.interval);
8157
8346
  state.ping.interval = null;
@@ -8190,7 +8379,10 @@ var require_client_h2 = __commonJS({
8190
8379
  function onHttp2SocketError(err) {
8191
8380
  assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
8192
8381
  this[kError] = err;
8193
- this[kClient][kOnError](err);
8382
+ if (this[kHTTP2Session]?.[kReceivedGoAway]) {
8383
+ return;
8384
+ }
8385
+ this[kHTTP2Session]?.[kClient]?.[kOnError](err);
8194
8386
  }
8195
8387
  function onHttp2SocketEnd() {
8196
8388
  util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
@@ -8205,7 +8397,7 @@ var require_client_h2 = __commonJS({
8205
8397
  stream[kHTTP2Session] = null;
8206
8398
  session[kOpenStreams] -= 1;
8207
8399
  if (session[kOpenStreams] === 0) {
8208
- session.unref();
8400
+ unrefH2Session(session);
8209
8401
  setHttp2IdleTimeout(session);
8210
8402
  }
8211
8403
  }
@@ -8216,17 +8408,22 @@ var require_client_h2 = __commonJS({
8216
8408
  failUpgradeStream(state, new InformationalError("HTTP/2: stream closed before response headers"));
8217
8409
  closeStreamSession(this);
8218
8410
  }
8219
- function onRequestStreamClose() {
8411
+ function completeRequestStream() {
8220
8412
  const state = this[kRequestStreamState];
8221
- if (state) {
8222
- releaseRequestStream(this);
8223
- if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
8224
- state.request.onResponseEnd(state.trailers || {});
8225
- state.finalizeRequest();
8226
- }
8413
+ if (state == null) {
8414
+ return;
8227
8415
  }
8228
- this.off("data", onData);
8229
- this.off("error", noop);
8416
+ releaseRequestStream(this);
8417
+ if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
8418
+ state.request.onResponseEnd(state.trailers || {});
8419
+ } else if (!state.request.aborted && !state.request.completed) {
8420
+ util.errorRequest(
8421
+ state.client,
8422
+ state.request,
8423
+ new InformationalError("HTTP/2: stream closed before the response was complete")
8424
+ );
8425
+ }
8426
+ finalizeRequest(state);
8230
8427
  closeStreamSession(this);
8231
8428
  this[kRequestStreamState] = null;
8232
8429
  }
@@ -8320,7 +8517,7 @@ var require_client_h2 = __commonJS({
8320
8517
  }
8321
8518
  removeUpgradeStreamListeners(stream);
8322
8519
  detachRequestFromStream(request);
8323
- state.finalizeRequest();
8520
+ finalizeRequest(state);
8324
8521
  }
8325
8522
  function setupUpgradeStream(stream, state) {
8326
8523
  const { request, headersTimeout, session } = state;
@@ -8338,28 +8535,63 @@ var require_client_h2 = __commonJS({
8338
8535
  ++session[kOpenStreams];
8339
8536
  stream.setTimeout(headersTimeout);
8340
8537
  }
8538
+ function finalizeRequest(state, resetPendingIdx = false) {
8539
+ if (state.requestFinalized) {
8540
+ return;
8541
+ }
8542
+ state.requestFinalized = true;
8543
+ completeRequest(state.client, state.request, resetPendingIdx);
8544
+ state.client[kResume]();
8545
+ }
8546
+ function openStream(client, request, session, abort, headers, options) {
8547
+ try {
8548
+ return session.request(headers, options);
8549
+ } catch (err) {
8550
+ if (err?.code === "ERR_HTTP2_INVALID_SESSION" || err?.code === "ERR_HTTP2_GOAWAY_SESSION") {
8551
+ const wrappedErr2 = new SocketError(err.message, util.getSocketInfo(session[kSocket]));
8552
+ wrappedErr2.cause = err;
8553
+ session[kError] = wrappedErr2;
8554
+ resetHttp2Session(session, wrappedErr2);
8555
+ requeueUnsentRequest(client, request);
8556
+ return null;
8557
+ }
8558
+ const wrappedErr = new InformationalError(err.message, { cause: err });
8559
+ session[kError] = wrappedErr;
8560
+ session[kSocket][kError] = wrappedErr;
8561
+ session.destroy(wrappedErr);
8562
+ util.destroy(session[kSocket], wrappedErr);
8563
+ abort(wrappedErr);
8564
+ return null;
8565
+ }
8566
+ }
8341
8567
  function writeH2(client, request) {
8342
8568
  const headersTimeout = request.headersTimeout ?? client[kHeadersTimeout];
8343
8569
  const bodyTimeout = request.bodyTimeout ?? client[kBodyTimeout];
8344
8570
  const session = client[kHTTP2Session];
8345
8571
  const { method, path, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
8346
- let { body } = request;
8347
8572
  if (upgrade != null && upgrade !== "websocket") {
8348
8573
  util.errorRequest(client, request, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
8349
8574
  return false;
8350
8575
  }
8351
8576
  const headers = buildRequestHeaders(reqHeaders);
8352
- let stream = null;
8353
8577
  headers[HTTP2_HEADER_AUTHORITY] = host || client[kHostAuthority];
8354
8578
  headers[HTTP2_HEADER_METHOD] = method;
8355
- let requestFinalized = false;
8356
- const finalizeRequest = (resetPendingIdx = false) => {
8357
- if (requestFinalized) {
8358
- return;
8359
- }
8360
- requestFinalized = true;
8361
- completeRequest(client, request, resetPendingIdx);
8362
- client[kResume]();
8579
+ const state = {
8580
+ abort: null,
8581
+ body: request.body,
8582
+ client,
8583
+ contentLength: null,
8584
+ expectsPayload: false,
8585
+ request,
8586
+ headersTimeout,
8587
+ bodyTimeout,
8588
+ requestFinalized: false,
8589
+ responseReceived: false,
8590
+ bodySent: false,
8591
+ pendingEnd: false,
8592
+ trailers: null,
8593
+ session,
8594
+ stream: null
8363
8595
  };
8364
8596
  const abort = (err, resetPendingIdx = false) => {
8365
8597
  if (request.aborted || request.completed) {
@@ -8367,35 +8599,20 @@ var require_client_h2 = __commonJS({
8367
8599
  }
8368
8600
  err = err || new RequestAbortedError();
8369
8601
  util.errorRequest(client, request, err);
8370
- if (stream != null) {
8602
+ if (state.stream != null) {
8371
8603
  clearRequestStream(request);
8372
- stream.close();
8604
+ const stream2 = state.stream;
8605
+ stream2.close();
8606
+ if (!stream2.destroyed) {
8607
+ util.destroy(stream2);
8608
+ }
8373
8609
  client[kOnError](err);
8374
- finalizeRequest(resetPendingIdx);
8375
- }
8376
- util.destroy(body, err);
8377
- };
8378
- const requestStream = (headers2, options) => {
8379
- try {
8380
- return session.request(headers2, options);
8381
- } catch (err) {
8382
- if (err?.code === "ERR_HTTP2_INVALID_SESSION") {
8383
- const wrappedErr2 = new SocketError(err.message, util.getSocketInfo(session[kSocket]));
8384
- wrappedErr2.cause = err;
8385
- session[kError] = wrappedErr2;
8386
- resetHttp2Session(session, wrappedErr2);
8387
- requeueUnsentRequest(client, request);
8388
- return null;
8389
- }
8390
- const wrappedErr = new InformationalError(err.message, { cause: err });
8391
- session[kError] = wrappedErr;
8392
- session[kSocket][kError] = wrappedErr;
8393
- session.destroy(wrappedErr);
8394
- util.destroy(session[kSocket], wrappedErr);
8395
- abort(wrappedErr);
8396
- return null;
8610
+ finalizeRequest(state, resetPendingIdx);
8397
8611
  }
8612
+ util.destroy(state.body, err);
8398
8613
  };
8614
+ state.abort = abort;
8615
+ let stream = null;
8399
8616
  try {
8400
8617
  request.onRequestStart(abort, null);
8401
8618
  } catch (err) {
@@ -8405,21 +8622,11 @@ var require_client_h2 = __commonJS({
8405
8622
  return false;
8406
8623
  }
8407
8624
  if (upgrade || method === "CONNECT") {
8408
- session.ref();
8409
- const upgradeState = {
8410
- abort,
8411
- finalizeRequest,
8412
- request,
8413
- headersTimeout,
8414
- bodyTimeout,
8415
- responseReceived: false,
8416
- session,
8417
- stream: null
8418
- };
8625
+ refH2Session(session);
8419
8626
  if (upgrade === "websocket") {
8420
8627
  if (session[kEnableConnectProtocol] === false) {
8421
8628
  util.errorRequest(client, request, new InformationalError("HTTP/2: Extended CONNECT protocol not supported by server"));
8422
- session.unref();
8629
+ unrefH2Session(session);
8423
8630
  return false;
8424
8631
  }
8425
8632
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
@@ -8430,25 +8637,26 @@ var require_client_h2 = __commonJS({
8430
8637
  } else {
8431
8638
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8432
8639
  }
8433
- stream = requestStream(headers, { endStream: false, signal });
8640
+ stream = openStream(client, request, session, abort, headers, { endStream: false, signal });
8434
8641
  if (stream == null) {
8435
- session.unref();
8642
+ unrefH2Session(session);
8436
8643
  return false;
8437
8644
  }
8438
- setupUpgradeStream(stream, upgradeState);
8645
+ setupUpgradeStream(stream, state);
8439
8646
  return true;
8440
8647
  }
8441
- stream = requestStream(headers, { endStream: false, signal });
8648
+ stream = openStream(client, request, session, abort, headers, { endStream: false, signal });
8442
8649
  if (stream == null) {
8443
- session.unref();
8650
+ unrefH2Session(session);
8444
8651
  return false;
8445
8652
  }
8446
- setupUpgradeStream(stream, upgradeState);
8653
+ setupUpgradeStream(stream, state);
8447
8654
  return true;
8448
8655
  }
8449
8656
  headers[HTTP2_HEADER_PATH] = path;
8450
8657
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8451
8658
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
8659
+ let body = state.body;
8452
8660
  if (body && typeof body.read === "function") {
8453
8661
  body.read(0);
8454
8662
  }
@@ -8477,7 +8685,7 @@ var require_client_h2 = __commonJS({
8477
8685
  assert(body || contentLength === 0, "no body must not have content length");
8478
8686
  headers[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength}`;
8479
8687
  }
8480
- session.ref();
8688
+ refH2Session(session);
8481
8689
  if (channels.sendHeaders.hasSubscribers) {
8482
8690
  let header = "";
8483
8691
  for (const key in headers) {
@@ -8487,24 +8695,13 @@ var require_client_h2 = __commonJS({
8487
8695
  channels.sendHeaders.publish({ request, headers: header, socket: session[kSocket] });
8488
8696
  }
8489
8697
  const shouldEndStream = body === null || contentLength === 0;
8490
- const state = {
8491
- abort,
8492
- body,
8493
- client,
8494
- contentLength,
8495
- expectsPayload,
8496
- finalizeRequest,
8497
- request,
8498
- headersTimeout,
8499
- bodyTimeout,
8500
- responseReceived: false,
8501
- session,
8502
- stream: null
8503
- };
8698
+ state.body = body;
8699
+ state.contentLength = contentLength;
8700
+ state.expectsPayload = expectsPayload;
8504
8701
  if (expectContinue) {
8505
8702
  headers[HTTP2_HEADER_EXPECT] = "100-continue";
8506
8703
  }
8507
- stream = requestStream(headers, { endStream: shouldEndStream, signal });
8704
+ stream = openStream(client, request, session, abort, headers, { endStream: shouldEndStream, signal });
8508
8705
  if (stream == null) {
8509
8706
  return false;
8510
8707
  }
@@ -8513,20 +8710,24 @@ var require_client_h2 = __commonJS({
8513
8710
  state.stream = stream;
8514
8711
  clearHttp2IdleTimeout(session);
8515
8712
  ++session[kOpenStreams];
8516
- stream.setTimeout(headersTimeout);
8713
+ if (headersTimeout) {
8714
+ stream.setTimeout(headersTimeout);
8715
+ }
8517
8716
  stream[kHTTP2Session] = session;
8518
- stream.once("close", onRequestStreamClose);
8717
+ stream.on("close", completeRequestStream);
8519
8718
  bindRequestToStream(request, stream, releaseRequestStream);
8520
8719
  if (expectContinue) {
8521
8720
  stream.once("continue", writeBodyH2);
8522
8721
  }
8523
- stream.once("response", onResponse);
8524
- stream.once("end", onEnd);
8525
- stream.once("error", onError);
8526
- stream.once("frameError", onFrameError);
8722
+ stream.on("response", onResponse);
8723
+ stream.on("end", onEnd);
8724
+ stream.on("error", onError);
8725
+ stream.on("frameError", onFrameError);
8527
8726
  stream.on("aborted", onAborted);
8528
- stream.on("timeout", onTimeout);
8529
- stream.once("trailers", onTrailers);
8727
+ if (headersTimeout || bodyTimeout) {
8728
+ stream.on("timeout", onTimeout);
8729
+ }
8730
+ stream.on("trailers", onTrailers);
8530
8731
  if (!expectContinue) {
8531
8732
  writeBodyH2.call(stream);
8532
8733
  }
@@ -8556,14 +8757,18 @@ var require_client_h2 = __commonJS({
8556
8757
  if (request[kRequestStream] === stream) {
8557
8758
  detachRequestFromStream(request);
8558
8759
  }
8559
- removeRequestStreamListeners(stream);
8560
8760
  if (!stream.destroyed && !stream.closed) {
8761
+ removeRequestStreamListeners(stream);
8561
8762
  stream.once("error", noop);
8562
8763
  }
8563
8764
  }
8564
8765
  function onData(chunk) {
8565
8766
  const stream = this;
8566
- const { request } = stream[kRequestStreamState];
8767
+ const state = stream[kRequestStreamState];
8768
+ if (state == null) {
8769
+ return;
8770
+ }
8771
+ const { request } = state;
8567
8772
  if (request.aborted || request.completed) {
8568
8773
  return;
8569
8774
  }
@@ -8574,14 +8779,23 @@ var require_client_h2 = __commonJS({
8574
8779
  function onResponse(headers) {
8575
8780
  const stream = this;
8576
8781
  const state = stream[kRequestStreamState];
8782
+ if (state == null) {
8783
+ return;
8784
+ }
8577
8785
  const { request } = state;
8578
8786
  stream.off("response", onResponse);
8787
+ if (state.body != null && !state.bodySent && !stream.writableEnded) {
8788
+ stream.removeListener("continue", writeBodyH2);
8789
+ stream.end();
8790
+ }
8579
8791
  const statusCode = headers[HTTP2_HEADER_STATUS];
8580
8792
  delete headers[HTTP2_HEADER_STATUS];
8581
8793
  request.onResponseStarted();
8582
8794
  state.responseReceived = true;
8583
- stream.setTimeout(state.bodyTimeout);
8584
- if (request.aborted) {
8795
+ if (state.headersTimeout || state.bodyTimeout) {
8796
+ stream.setTimeout(state.bodyTimeout);
8797
+ }
8798
+ if (request.aborted || request.completed) {
8585
8799
  releaseRequestStream(stream);
8586
8800
  return;
8587
8801
  }
@@ -8593,25 +8807,55 @@ var require_client_h2 = __commonJS({
8593
8807
  function onEnd() {
8594
8808
  const stream = this;
8595
8809
  const state = stream[kRequestStreamState];
8810
+ if (state == null) {
8811
+ return;
8812
+ }
8596
8813
  const { request } = state;
8597
8814
  stream.off("end", onEnd);
8598
8815
  if (state.responseReceived) {
8599
8816
  if (!request.aborted && !request.completed) {
8600
8817
  state.pendingEnd = true;
8818
+ completeRequestStream.call(stream);
8601
8819
  }
8602
8820
  } else {
8603
8821
  state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
8604
8822
  }
8605
8823
  }
8824
+ function retryRefusedStream(stream, state) {
8825
+ const { client, request } = state;
8826
+ if (state.responseReceived || request.aborted || request.completed || request[kRefusedStreamRetry] || !canReplayRequest(request)) {
8827
+ return false;
8828
+ }
8829
+ request[kRefusedStreamRetry] = true;
8830
+ detachRequestStreamForClose(request);
8831
+ state.stream = null;
8832
+ state.requestFinalized = true;
8833
+ completeRequest(client, request);
8834
+ client[kQueue].splice(client[kPendingIdx], 0, request);
8835
+ client[kResume]();
8836
+ return true;
8837
+ }
8606
8838
  function onError(err) {
8607
8839
  const stream = this;
8608
8840
  const state = stream[kRequestStreamState];
8841
+ if (state == null) {
8842
+ return;
8843
+ }
8609
8844
  stream.off("error", onError);
8845
+ if (typeof stream.rstCode === "number" && stream.rstCode !== NGHTTP2_NO_ERROR) {
8846
+ err.http2ErrorCode = stream.rstCode;
8847
+ }
8848
+ if (stream.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream, state)) {
8849
+ return;
8850
+ }
8610
8851
  state.abort(err);
8611
8852
  }
8612
8853
  function onFrameError(type, code) {
8613
8854
  const stream = this;
8614
8855
  const state = stream[kRequestStreamState];
8856
+ if (state == null) {
8857
+ return;
8858
+ }
8615
8859
  stream.off("frameError", onFrameError);
8616
8860
  state.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
8617
8861
  }
@@ -8621,6 +8865,9 @@ var require_client_h2 = __commonJS({
8621
8865
  function onTimeout() {
8622
8866
  const stream = this;
8623
8867
  const state = stream[kRequestStreamState];
8868
+ if (state == null) {
8869
+ return;
8870
+ }
8624
8871
  stream.off("timeout", onTimeout);
8625
8872
  const err = state.responseReceived ? new BodyTimeoutError(`HTTP/2: "stream timeout after ${state.bodyTimeout}"`) : new HeadersTimeoutError(`HTTP/2: "headers timeout after ${state.headersTimeout}"`);
8626
8873
  state.abort(err);
@@ -8628,6 +8875,9 @@ var require_client_h2 = __commonJS({
8628
8875
  function onTrailers(trailers) {
8629
8876
  const stream = this;
8630
8877
  const state = stream[kRequestStreamState];
8878
+ if (state == null) {
8879
+ return;
8880
+ }
8631
8881
  const { request } = state;
8632
8882
  stream.off("trailers", onTrailers);
8633
8883
  stream.off("data", onData);
@@ -8639,6 +8889,7 @@ var require_client_h2 = __commonJS({
8639
8889
  function writeBodyH2() {
8640
8890
  const stream = this;
8641
8891
  const state = stream[kRequestStreamState];
8892
+ state.bodySent = true;
8642
8893
  const { abort, body, client, contentLength, expectsPayload, request } = state;
8643
8894
  if (!body || contentLength === 0) {
8644
8895
  writeBuffer(
@@ -8821,9 +9072,9 @@ var require_client_h2 = __commonJS({
8821
9072
  }
8822
9073
  });
8823
9074
 
8824
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client.js
9075
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client.js
8825
9076
  var require_client = __commonJS({
8826
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/client.js"(exports, module) {
9077
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/client.js"(exports, module) {
8827
9078
  "use strict";
8828
9079
  init_esm_shims();
8829
9080
  var assert = __require("assert");
@@ -8879,10 +9130,8 @@ var require_client = __commonJS({
8879
9130
  kHTTPContext,
8880
9131
  kMaxConcurrentStreams,
8881
9132
  kHostAuthority,
8882
- kHTTP2InitialWindowSize,
8883
- kHTTP2ConnectionWindowSize,
8884
9133
  kResume,
8885
- kPingInterval
9134
+ kHTTP2Options
8886
9135
  } = require_symbols();
8887
9136
  var connectH1 = require_client_h1();
8888
9137
  var connectH2 = require_client_h2();
@@ -8895,6 +9144,14 @@ var require_client = __commonJS({
8895
9144
  function getPipelining(client) {
8896
9145
  return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1;
8897
9146
  }
9147
+ var h2NamespaceOptsWarning = false;
9148
+ function emitH2OptionsNamespaceWarning(optName) {
9149
+ if (h2NamespaceOptsWarning === true) return;
9150
+ process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
9151
+ code: "UNDICI-H2-OPTIONS"
9152
+ });
9153
+ h2NamespaceOptsWarning = true;
9154
+ }
8898
9155
  function getMaxConcurrent(client) {
8899
9156
  if (client[kHTTPContext]?.version === "h2") {
8900
9157
  return client[kMaxConcurrentStreams];
@@ -8938,7 +9195,8 @@ var require_client = __commonJS({
8938
9195
  initialWindowSize,
8939
9196
  connectionWindowSize,
8940
9197
  pingInterval,
8941
- webSocket
9198
+ webSocket,
9199
+ h2Options
8942
9200
  } = {}) {
8943
9201
  if (keepAlive !== void 0) {
8944
9202
  throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
@@ -9001,20 +9259,45 @@ var require_client = __commonJS({
9001
9259
  if (allowH2 != null && typeof allowH2 !== "boolean") {
9002
9260
  throw new InvalidArgumentError("allowH2 must be a valid boolean value");
9003
9261
  }
9004
- if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
9005
- throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
9006
- }
9007
- if (useH2c != null && typeof useH2c !== "boolean") {
9008
- throw new InvalidArgumentError("useH2c must be a valid boolean value");
9009
- }
9010
- if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
9011
- throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
9012
- }
9013
- if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
9014
- throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
9015
- }
9016
- if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
9017
- throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
9262
+ if (allowH2 !== false) {
9263
+ if (h2Options != null) {
9264
+ if (h2Options.useH2c != null && typeof h2Options.useH2c !== "boolean") {
9265
+ throw new InvalidArgumentError("h2Options.useH2c must be a valid boolean value");
9266
+ }
9267
+ if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
9268
+ throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
9269
+ }
9270
+ if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
9271
+ throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
9272
+ }
9273
+ if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
9274
+ throw new InvalidArgumentError("h2Options.connectionWindowSize must be a positive integer, greater than 0");
9275
+ }
9276
+ if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== "number" || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
9277
+ throw new InvalidArgumentError("h2Options.pingInterval must be a positive integer, greater or equal to 0");
9278
+ }
9279
+ } else {
9280
+ if (useH2c != null && typeof useH2c !== "boolean") {
9281
+ emitH2OptionsNamespaceWarning("useH2c");
9282
+ throw new InvalidArgumentError("useH2c must be a valid boolean value");
9283
+ }
9284
+ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
9285
+ emitH2OptionsNamespaceWarning("maxConcurrentStreams");
9286
+ throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
9287
+ }
9288
+ if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
9289
+ emitH2OptionsNamespaceWarning("initialWindowSize");
9290
+ throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
9291
+ }
9292
+ if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
9293
+ emitH2OptionsNamespaceWarning("connectionWindowSize");
9294
+ throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
9295
+ }
9296
+ if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
9297
+ emitH2OptionsNamespaceWarning("pingInterval");
9298
+ throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
9299
+ }
9300
+ }
9018
9301
  }
9019
9302
  super({ webSocket });
9020
9303
  if (typeof connect2 !== "function") {
@@ -9022,8 +9305,8 @@ var require_client = __commonJS({
9022
9305
  ...tls,
9023
9306
  maxCachedSessions,
9024
9307
  allowH2,
9025
- useH2c,
9026
9308
  socketPath,
9309
+ useH2c: h2Options?.useH2c ?? useH2c,
9027
9310
  timeout: connectTimeout,
9028
9311
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
9029
9312
  ...connect2
@@ -9058,10 +9341,21 @@ var require_client = __commonJS({
9058
9341
  this[kClosedResolve] = null;
9059
9342
  this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
9060
9343
  this[kHTTPContext] = null;
9061
- this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100;
9062
- this[kHTTP2InitialWindowSize] = initialWindowSize != null ? initialWindowSize : 262144;
9063
- this[kHTTP2ConnectionWindowSize] = connectionWindowSize != null ? connectionWindowSize : 524288;
9064
- this[kPingInterval] = pingInterval != null ? pingInterval : 6e4;
9344
+ this[kHTTP2Options] = {
9345
+ pingInterval: h2Options?.pingInterval ?? pingInterval ?? 6e4,
9346
+ connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
9347
+ maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100,
9348
+ // Max peerConcurrentStreams for a Node h2 server
9349
+ sessionOptions: {
9350
+ // HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
9351
+ // - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
9352
+ // Allows more data to be sent before requiring acknowledgment, improving throughput
9353
+ // especially on high-latency networks. This matches common production HTTP/2 servers.
9354
+ // - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
9355
+ // Provides better flow control for the entire connection across multiple streams.
9356
+ initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
9357
+ }
9358
+ };
9065
9359
  this[kQueue] = [];
9066
9360
  this[kRunningIdx] = 0;
9067
9361
  this[kPendingIdx] = 0;
@@ -9346,6 +9640,7 @@ var require_client = __commonJS({
9346
9640
  return;
9347
9641
  }
9348
9642
  if (!client[kHTTPContext]) {
9643
+ client[kServerName] = request.servername;
9349
9644
  connect(client);
9350
9645
  return;
9351
9646
  }
@@ -9366,9 +9661,9 @@ var require_client = __commonJS({
9366
9661
  }
9367
9662
  });
9368
9663
 
9369
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/fixed-queue.js
9664
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/fixed-queue.js
9370
9665
  var require_fixed_queue = __commonJS({
9371
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/fixed-queue.js"(exports, module) {
9666
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/fixed-queue.js"(exports, module) {
9372
9667
  "use strict";
9373
9668
  init_esm_shims();
9374
9669
  var kSize = 2048;
@@ -9438,9 +9733,9 @@ var require_fixed_queue = __commonJS({
9438
9733
  }
9439
9734
  });
9440
9735
 
9441
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/pool-base.js
9736
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/pool-base.js
9442
9737
  var require_pool_base = __commonJS({
9443
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/pool-base.js"(exports, module) {
9738
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/pool-base.js"(exports, module) {
9444
9739
  "use strict";
9445
9740
  init_esm_shims();
9446
9741
  var { PoolStats } = require_stats();
@@ -9626,9 +9921,9 @@ var require_pool_base = __commonJS({
9626
9921
  }
9627
9922
  });
9628
9923
 
9629
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/pool.js
9924
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/pool.js
9630
9925
  var require_pool = __commonJS({
9631
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/pool.js"(exports, module) {
9926
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/pool.js"(exports, module) {
9632
9927
  "use strict";
9633
9928
  init_esm_shims();
9634
9929
  var {
@@ -9751,9 +10046,9 @@ var require_pool = __commonJS({
9751
10046
  }
9752
10047
  });
9753
10048
 
9754
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/balanced-pool.js
10049
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/balanced-pool.js
9755
10050
  var require_balanced_pool = __commonJS({
9756
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/balanced-pool.js"(exports, module) {
10051
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/balanced-pool.js"(exports, module) {
9757
10052
  "use strict";
9758
10053
  init_esm_shims();
9759
10054
  var {
@@ -9897,9 +10192,9 @@ var require_balanced_pool = __commonJS({
9897
10192
  }
9898
10193
  });
9899
10194
 
9900
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/round-robin-pool.js
10195
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/round-robin-pool.js
9901
10196
  var require_round_robin_pool = __commonJS({
9902
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/round-robin-pool.js"(exports, module) {
10197
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/round-robin-pool.js"(exports, module) {
9903
10198
  "use strict";
9904
10199
  init_esm_shims();
9905
10200
  var {
@@ -10035,9 +10330,9 @@ var require_round_robin_pool = __commonJS({
10035
10330
  }
10036
10331
  });
10037
10332
 
10038
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/agent.js
10333
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/agent.js
10039
10334
  var require_agent = __commonJS({
10040
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/agent.js"(exports, module) {
10335
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/agent.js"(exports, module) {
10041
10336
  "use strict";
10042
10337
  init_esm_shims();
10043
10338
  var { InvalidArgumentError, MaxOriginsReachedError } = require_errors();
@@ -10122,14 +10417,14 @@ var require_agent = __commonJS({
10122
10417
  dispatcher.close();
10123
10418
  }
10124
10419
  let hasOrigin = false;
10125
- for (const client of this[kClients].values()) {
10126
- if (client[kUrl].origin === dispatcher[kUrl].origin) {
10420
+ for (const k of this[kClients].keys()) {
10421
+ if (k === origin || k === `${origin}#http1-only`) {
10127
10422
  hasOrigin = true;
10128
10423
  break;
10129
10424
  }
10130
10425
  }
10131
10426
  if (!hasOrigin) {
10132
- this[kOrigins].delete(dispatcher[kUrl].origin);
10427
+ this[kOrigins].delete(origin);
10133
10428
  }
10134
10429
  };
10135
10430
  dispatcher.on("drain", this[kOnDrain]).on("connect", this[kOnConnect]).on("disconnect", (origin2, targets, err) => {
@@ -10174,9 +10469,9 @@ var require_agent = __commonJS({
10174
10469
  }
10175
10470
  });
10176
10471
 
10177
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js
10472
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js
10178
10473
  var require_dispatcher1_wrapper = __commonJS({
10179
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js"(exports, module) {
10474
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js"(exports, module) {
10180
10475
  "use strict";
10181
10476
  init_esm_shims();
10182
10477
  var Dispatcher = require_dispatcher();
@@ -10260,9 +10555,9 @@ var require_dispatcher1_wrapper = __commonJS({
10260
10555
  }
10261
10556
  });
10262
10557
 
10263
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/socks5-utils.js
10558
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/socks5-utils.js
10264
10559
  var require_socks5_utils = __commonJS({
10265
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/socks5-utils.js"(exports, module) {
10560
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/socks5-utils.js"(exports, module) {
10266
10561
  "use strict";
10267
10562
  init_esm_shims();
10268
10563
  var { Buffer: Buffer2 } = __require("buffer");
@@ -10422,9 +10717,9 @@ var require_socks5_utils = __commonJS({
10422
10717
  }
10423
10718
  });
10424
10719
 
10425
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/socks5-client.js
10720
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/socks5-client.js
10426
10721
  var require_socks5_client = __commonJS({
10427
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/core/socks5-client.js"(exports, module) {
10722
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/core/socks5-client.js"(exports, module) {
10428
10723
  "use strict";
10429
10724
  init_esm_shims();
10430
10725
  var { EventEmitter } = __require("events");
@@ -10756,9 +11051,9 @@ var require_socks5_client = __commonJS({
10756
11051
  }
10757
11052
  });
10758
11053
 
10759
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
11054
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js
10760
11055
  var require_socks5_proxy_agent = __commonJS({
10761
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js"(exports, module) {
11056
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js"(exports, module) {
10762
11057
  "use strict";
10763
11058
  init_esm_shims();
10764
11059
  var { URL: URL2 } = __require("url");
@@ -10766,7 +11061,7 @@ var require_socks5_proxy_agent = __commonJS({
10766
11061
  var DispatcherBase = require_dispatcher_base();
10767
11062
  var { InvalidArgumentError } = require_errors();
10768
11063
  var { Socks5Client, STATES } = require_socks5_client();
10769
- var { kDispatch, kClose, kDestroy } = require_symbols();
11064
+ var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
10770
11065
  var Pool = require_pool();
10771
11066
  var buildConnector = require_connect();
10772
11067
  var { debuglog } = __require("util");
@@ -10924,6 +11219,17 @@ var require_socks5_proxy_agent = __commonJS({
10924
11219
  }
10925
11220
  });
10926
11221
  this[kPools].set(originKey, pool);
11222
+ const closePoolIfUnused = () => {
11223
+ if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
11224
+ return;
11225
+ }
11226
+ this[kPools].delete(originKey);
11227
+ if (!pool.destroyed) {
11228
+ pool.close();
11229
+ }
11230
+ };
11231
+ pool.on("disconnect", closePoolIfUnused);
11232
+ pool.on("connectionError", closePoolIfUnused);
10927
11233
  }
10928
11234
  return pool[kDispatch](opts, handler);
10929
11235
  } catch (err) {
@@ -10960,16 +11266,16 @@ var require_socks5_proxy_agent = __commonJS({
10960
11266
  }
10961
11267
  });
10962
11268
 
10963
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/proxy-agent.js
11269
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/proxy-agent.js
10964
11270
  var require_proxy_agent = __commonJS({
10965
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/proxy-agent.js"(exports, module) {
11271
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/proxy-agent.js"(exports, module) {
10966
11272
  "use strict";
10967
11273
  init_esm_shims();
10968
11274
  var { kProxy, kClose, kDestroy, kDispatch } = require_symbols();
10969
11275
  var Agent = require_agent();
10970
11276
  var Pool = require_pool();
10971
11277
  var DispatcherBase = require_dispatcher_base();
10972
- var { InvalidArgumentError, RequestAbortedError, SecureProxyConnectionError } = require_errors();
11278
+ var { InvalidArgumentError, RequestAbortedError, SecureProxyConnectionError, ProxyConnectionError } = require_errors();
10973
11279
  var buildConnector = require_connect();
10974
11280
  var Client = require_client();
10975
11281
  var { channels } = require_diagnostics();
@@ -10997,14 +11303,19 @@ var require_proxy_agent = __commonJS({
10997
11303
  }
10998
11304
  return new Pool(origin, opts);
10999
11305
  }
11306
+ function shouldProxyTunnel(requestProtocol, proxyTunnel) {
11307
+ return proxyTunnel === true || requestProtocol !== "http:";
11308
+ }
11000
11309
  var Http1ProxyWrapper = class extends DispatcherBase {
11001
11310
  #client;
11002
- constructor(proxyUrl, { headers = {}, connect, factory }) {
11311
+ #proxyServername;
11312
+ constructor(proxyUrl, { headers = {}, connect, factory, proxyServername }) {
11003
11313
  if (!proxyUrl) {
11004
11314
  throw new InvalidArgumentError("Proxy URL is mandatory");
11005
11315
  }
11006
11316
  super();
11007
11317
  this[kProxyHeaders] = headers;
11318
+ this.#proxyServername = proxyServername;
11008
11319
  if (factory) {
11009
11320
  this.#client = factory(proxyUrl, { connect });
11010
11321
  } else {
@@ -11033,6 +11344,9 @@ var require_proxy_agent = __commonJS({
11033
11344
  headers.host = host;
11034
11345
  }
11035
11346
  opts.headers = { ...this[kProxyHeaders], ...headers };
11347
+ if (this.#proxyServername != null) {
11348
+ opts.servername = this.#proxyServername;
11349
+ }
11036
11350
  return this.#client[kDispatch](opts, handler);
11037
11351
  }
11038
11352
  [kClose]() {
@@ -11051,7 +11365,7 @@ var require_proxy_agent = __commonJS({
11051
11365
  if (typeof clientFactory !== "function") {
11052
11366
  throw new InvalidArgumentError("Proxy opts.clientFactory must be a function.");
11053
11367
  }
11054
- const { proxyTunnel = true, connectTimeout } = opts;
11368
+ const { proxyTunnel, connectTimeout } = opts;
11055
11369
  super();
11056
11370
  const url = this.#getUrl(opts);
11057
11371
  const { href, origin, port, protocol, username, password, hostname: proxyHostname } = url;
@@ -11072,6 +11386,7 @@ var require_proxy_agent = __commonJS({
11072
11386
  this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:`).toString("base64")}`;
11073
11387
  }
11074
11388
  const connect = buildConnector({ timeout: connectTimeout, ...opts.proxyTls });
11389
+ const connectHTTP1 = buildConnector({ timeout: connectTimeout, ...opts.proxyTls, allowH2: false });
11075
11390
  this[kConnectEndpoint] = buildConnector({ timeout: connectTimeout, ...opts.requestTls });
11076
11391
  this[kConnectEndpointHTTP1] = buildConnector({ timeout: connectTimeout, ...opts.requestTls, allowH2: false });
11077
11392
  const agentFactory = opts.factory || defaultAgentFactory;
@@ -11088,11 +11403,19 @@ var require_proxy_agent = __commonJS({
11088
11403
  requestTls: opts.requestTls
11089
11404
  });
11090
11405
  }
11091
- if (!this[kTunnelProxy] && protocol2 === "http:" && this[kProxy].protocol === "http:") {
11406
+ if (!shouldProxyTunnel(protocol2, this[kTunnelProxy])) {
11407
+ const forwardConnect = this[kProxy].protocol === "https:" ? (opts2, cb) => connectHTTP1(opts2, (err, socket) => {
11408
+ if (err && err.code === "ERR_TLS_CERT_ALTNAME_INVALID") {
11409
+ cb(new SecureProxyConnectionError(err));
11410
+ } else {
11411
+ cb(err, socket);
11412
+ }
11413
+ }) : connectHTTP1;
11092
11414
  return new Http1ProxyWrapper(this[kProxy].uri, {
11093
11415
  headers: this[kProxyHeaders],
11094
- connect,
11095
- factory: agentFactory
11416
+ connect: forwardConnect,
11417
+ factory: agentFactory,
11418
+ proxyServername: this[kProxy].protocol === "https:" ? this[kProxyTls]?.servername || proxyHostname : void 0
11096
11419
  });
11097
11420
  }
11098
11421
  return agentFactory(origin2, options);
@@ -11154,6 +11477,8 @@ var require_proxy_agent = __commonJS({
11154
11477
  } catch (err) {
11155
11478
  if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") {
11156
11479
  callback(new SecureProxyConnectionError(err));
11480
+ } else if (err.code === "UND_ERR_SOCKET") {
11481
+ callback(new ProxyConnectionError(err));
11157
11482
  } else {
11158
11483
  callback(err);
11159
11484
  }
@@ -11234,9 +11559,9 @@ var require_proxy_agent = __commonJS({
11234
11559
  }
11235
11560
  });
11236
11561
 
11237
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js
11562
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js
11238
11563
  var require_env_http_proxy_agent = __commonJS({
11239
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js"(exports, module) {
11564
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js"(exports, module) {
11240
11565
  "use strict";
11241
11566
  init_esm_shims();
11242
11567
  var DispatcherBase = require_dispatcher_base();
@@ -11291,7 +11616,7 @@ var require_env_http_proxy_agent = __commonJS({
11291
11616
  }
11292
11617
  #getProxyAgentForUrl(url) {
11293
11618
  let { protocol, host: hostname, port } = url;
11294
- hostname = hostname.replace(/:\d*$/, "").toLowerCase();
11619
+ hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
11295
11620
  port = Number.parseInt(port, 10) || DEFAULT_PORTS[protocol] || 0;
11296
11621
  if (!this.#shouldProxy(hostname, port)) {
11297
11622
  return this[kNoProxyAgent];
@@ -11334,11 +11659,22 @@ var require_env_http_proxy_agent = __commonJS({
11334
11659
  if (!entry) {
11335
11660
  continue;
11336
11661
  }
11337
- const parsed = entry.match(/^(.+):(\d+)$/);
11662
+ let hostname, port;
11663
+ const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/);
11664
+ if (ipv6WithPort) {
11665
+ hostname = ipv6WithPort[1];
11666
+ port = Number.parseInt(ipv6WithPort[2], 10);
11667
+ } else {
11668
+ const unbracketed = entry.replace(/^\[(.+)\]$/, "$1");
11669
+ const colonCount = (unbracketed.match(/:/g) || []).length;
11670
+ const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
11671
+ hostname = parsed ? parsed[1] : unbracketed;
11672
+ port = parsed ? Number.parseInt(parsed[2], 10) : 0;
11673
+ }
11338
11674
  noProxyEntries.push({
11339
11675
  // strip leading dot or asterisk with dot
11340
- hostname: (parsed ? parsed[1] : entry).replace(/^\*?\./, "").toLowerCase(),
11341
- port: parsed ? Number.parseInt(parsed[2], 10) : 0
11676
+ hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
11677
+ port
11342
11678
  });
11343
11679
  }
11344
11680
  this.#noProxyValue = noProxyValue;
@@ -11358,9 +11694,9 @@ var require_env_http_proxy_agent = __commonJS({
11358
11694
  }
11359
11695
  });
11360
11696
 
11361
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/retry-handler.js
11697
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/retry-handler.js
11362
11698
  var require_retry_handler = __commonJS({
11363
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/retry-handler.js"(exports, module) {
11699
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/retry-handler.js"(exports, module) {
11364
11700
  "use strict";
11365
11701
  init_esm_shims();
11366
11702
  var assert = __require("assert");
@@ -11373,8 +11709,54 @@ var require_retry_handler = __commonJS({
11373
11709
  } = require_util();
11374
11710
  function calculateRetryAfterHeader(retryAfter) {
11375
11711
  const retryTime = new Date(retryAfter).getTime();
11376
- return isNaN(retryTime) ? 0 : retryTime - Date.now();
11712
+ return isNaN(retryTime) ? null : retryTime - Date.now();
11713
+ }
11714
+ function validatePartialResponseContentLength(headers, range, statusCode, retryCount) {
11715
+ const contentLength = headers["content-length"];
11716
+ if (contentLength == null) {
11717
+ return;
11718
+ }
11719
+ if (!Number.isFinite(range.start) || !Number.isFinite(range.end)) {
11720
+ return;
11721
+ }
11722
+ const length = Number(contentLength);
11723
+ const expectedLength = range.end - range.start + 1;
11724
+ if (!Number.isFinite(length) || length !== expectedLength) {
11725
+ throw new RequestRetryError("Content-Length mismatch", statusCode, {
11726
+ headers,
11727
+ data: { count: retryCount }
11728
+ });
11729
+ }
11377
11730
  }
11731
+ var RetryController = class {
11732
+ constructor() {
11733
+ this.target = null;
11734
+ }
11735
+ pause() {
11736
+ this.target?.pause();
11737
+ }
11738
+ resume() {
11739
+ this.target?.resume();
11740
+ }
11741
+ abort(reason) {
11742
+ this.target?.abort(reason);
11743
+ }
11744
+ get paused() {
11745
+ return this.target?.paused ?? false;
11746
+ }
11747
+ get aborted() {
11748
+ return this.target?.aborted ?? false;
11749
+ }
11750
+ get reason() {
11751
+ return this.target?.reason ?? null;
11752
+ }
11753
+ get rawHeaders() {
11754
+ return this.target?.rawHeaders ?? null;
11755
+ }
11756
+ get rawTrailers() {
11757
+ return this.target?.rawTrailers ?? null;
11758
+ }
11759
+ };
11378
11760
  var RetryHandler = class _RetryHandler {
11379
11761
  constructor(opts, { dispatch, handler }) {
11380
11762
  const { retryOptions, ...dispatchOpts } = opts;
@@ -11407,7 +11789,7 @@ var require_retry_handler = __commonJS({
11407
11789
  timeoutFactor: timeoutFactor ?? 2,
11408
11790
  maxRetries: maxRetries ?? 5,
11409
11791
  // What errors we should retry
11410
- methods: methods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"],
11792
+ methods: methods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE", "QUERY"],
11411
11793
  // Indicates which errors to retry
11412
11794
  statusCodes: statusCodes ?? [500, 502, 503, 504, 429],
11413
11795
  // List of errors to retry
@@ -11431,12 +11813,13 @@ var require_retry_handler = __commonJS({
11431
11813
  this.etag = null;
11432
11814
  this.statusCode = null;
11433
11815
  this.headers = null;
11816
+ this.controllerProxy = new RetryController();
11434
11817
  }
11435
11818
  onResponseStartWithRetry(controller, statusCode, headers, statusMessage, err) {
11436
11819
  if (this.retryOpts.throwOnError) {
11437
11820
  if (this.retryOpts.statusCodes.includes(statusCode) === false) {
11438
11821
  this.headersSent = true;
11439
- this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
11822
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
11440
11823
  } else {
11441
11824
  this.error = err;
11442
11825
  }
@@ -11444,13 +11827,13 @@ var require_retry_handler = __commonJS({
11444
11827
  }
11445
11828
  if (isDisturbed(this.opts.body)) {
11446
11829
  this.headersSent = true;
11447
- this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
11830
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
11448
11831
  return;
11449
11832
  }
11450
11833
  function shouldRetry(passedErr) {
11451
11834
  if (passedErr) {
11452
11835
  this.headersSent = true;
11453
- this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
11836
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
11454
11837
  controller.resume();
11455
11838
  return;
11456
11839
  }
@@ -11468,12 +11851,13 @@ var require_retry_handler = __commonJS({
11468
11851
  );
11469
11852
  }
11470
11853
  onRequestStart(controller, context) {
11854
+ this.controllerProxy.target = controller;
11471
11855
  if (!this.headersSent) {
11472
- this.handler.onRequestStart?.(controller, context);
11856
+ this.handler.onRequestStart?.(this.controllerProxy, context);
11473
11857
  }
11474
11858
  }
11475
- onRequestUpgrade(controller, statusCode, headers, socket) {
11476
- this.handler.onRequestUpgrade?.(controller, statusCode, headers, socket);
11859
+ onRequestUpgrade(_controller, statusCode, headers, socket) {
11860
+ this.handler.onRequestUpgrade?.(this.controllerProxy, statusCode, headers, socket);
11477
11861
  }
11478
11862
  static [kRetryHandlerDefaultRetry](err, { state, opts }, cb) {
11479
11863
  const { statusCode, code, headers } = err;
@@ -11509,10 +11893,14 @@ var require_retry_handler = __commonJS({
11509
11893
  retryAfterHeader = Number(retryAfterHeader);
11510
11894
  retryAfterHeader = Number.isNaN(retryAfterHeader) ? calculateRetryAfterHeader(headers["retry-after"]) : retryAfterHeader * 1e3;
11511
11895
  }
11512
- const retryTimeout = retryAfterHeader > 0 ? Math.min(retryAfterHeader, maxTimeout) : Math.min(minTimeout * timeoutFactor ** (counter - 1), maxTimeout);
11896
+ const retryTimeout = retryAfterHeader === 0 ? 0 : retryAfterHeader > 0 ? Math.min(retryAfterHeader, maxTimeout) : Math.min(minTimeout * timeoutFactor ** (counter - 1), maxTimeout);
11513
11897
  setTimeout(() => cb(null), retryTimeout);
11514
11898
  }
11515
11899
  onResponseStart(controller, statusCode, headers, statusMessage) {
11900
+ if (statusCode < 200) {
11901
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
11902
+ return;
11903
+ }
11516
11904
  this.error = null;
11517
11905
  this.retryCount += 1;
11518
11906
  this.statusCode = statusCode;
@@ -11547,6 +11935,7 @@ var require_retry_handler = __commonJS({
11547
11935
  data: { count: this.retryCount }
11548
11936
  });
11549
11937
  }
11938
+ validatePartialResponseContentLength(headers, contentRange, statusCode, this.retryCount);
11550
11939
  const { start, size, end = size ? size - 1 : null } = contentRange;
11551
11940
  assert(this.start === start, "content-range mismatch");
11552
11941
  assert(this.end == null || this.end === end, "content-range mismatch");
@@ -11555,16 +11944,17 @@ var require_retry_handler = __commonJS({
11555
11944
  if (this.end == null) {
11556
11945
  if (statusCode === 206) {
11557
11946
  const range = parseRangeHeader(headers["content-range"]);
11558
- if (range == null) {
11947
+ if (range == null || range.end == null) {
11559
11948
  this.headersSent = true;
11560
11949
  this.handler.onResponseStart?.(
11561
- controller,
11950
+ this.controllerProxy,
11562
11951
  statusCode,
11563
11952
  headers,
11564
11953
  statusMessage
11565
11954
  );
11566
11955
  return;
11567
11956
  }
11957
+ validatePartialResponseContentLength(headers, range, statusCode, this.retryCount);
11568
11958
  const { start, size, end = size ? size - 1 : null } = range;
11569
11959
  assert(
11570
11960
  start != null && Number.isFinite(start),
@@ -11574,7 +11964,7 @@ var require_retry_handler = __commonJS({
11574
11964
  this.start = start;
11575
11965
  this.end = end;
11576
11966
  }
11577
- if (this.end == null) {
11967
+ if (this.end == null && this.opts.method !== "HEAD") {
11578
11968
  const contentLength = headers["content-length"];
11579
11969
  this.end = contentLength != null ? Number(contentLength) - 1 : null;
11580
11970
  }
@@ -11590,7 +11980,7 @@ var require_retry_handler = __commonJS({
11590
11980
  }
11591
11981
  this.headersSent = true;
11592
11982
  this.handler.onResponseStart?.(
11593
- controller,
11983
+ this.controllerProxy,
11594
11984
  statusCode,
11595
11985
  headers,
11596
11986
  statusMessage
@@ -11602,14 +11992,14 @@ var require_retry_handler = __commonJS({
11602
11992
  });
11603
11993
  }
11604
11994
  }
11605
- onResponseData(controller, chunk) {
11995
+ onResponseData(_controller, chunk) {
11606
11996
  if (this.error) {
11607
11997
  return;
11608
11998
  }
11609
11999
  this.start += chunk.length;
11610
- this.handler.onResponseData?.(controller, chunk);
12000
+ this.handler.onResponseData?.(this.controllerProxy, chunk);
11611
12001
  }
11612
- onResponseEnd(controller, trailers) {
12002
+ onResponseEnd(_controller, trailers) {
11613
12003
  if (this.error && this.retryOpts.throwOnError) {
11614
12004
  throw this.error;
11615
12005
  }
@@ -11623,11 +12013,11 @@ var require_retry_handler = __commonJS({
11623
12013
  }
11624
12014
  }
11625
12015
  this.retryCount = 0;
11626
- return this.handler.onResponseEnd?.(controller, trailers);
12016
+ return this.handler.onResponseEnd?.(this.controllerProxy, trailers);
11627
12017
  }
11628
- this.retry(controller);
12018
+ this.retry();
11629
12019
  }
11630
- retry(controller) {
12020
+ retry() {
11631
12021
  if (this.start !== 0) {
11632
12022
  const headers = { range: `bytes=${this.start}-${this.end ?? ""}` };
11633
12023
  if (this.etag != null) {
@@ -11645,20 +12035,20 @@ var require_retry_handler = __commonJS({
11645
12035
  this.retryCountCheckpoint = this.retryCount;
11646
12036
  this.dispatch(this.opts, this);
11647
12037
  } catch (err) {
11648
- this.handler.onResponseError?.(controller, err);
12038
+ this.handler.onResponseError?.(this.controllerProxy, err);
11649
12039
  }
11650
12040
  }
11651
12041
  onResponseError(controller, err) {
11652
12042
  if (controller?.aborted || isDisturbed(this.opts.body)) {
11653
- this.handler.onResponseError?.(controller, err);
12043
+ this.handler.onResponseError?.(this.controllerProxy, err);
11654
12044
  return;
11655
12045
  }
11656
12046
  function shouldRetry(returnedErr) {
11657
12047
  if (!returnedErr) {
11658
- this.retry(controller);
12048
+ this.retry();
11659
12049
  return;
11660
12050
  }
11661
- this.handler?.onResponseError?.(controller, returnedErr);
12051
+ this.handler?.onResponseError?.(this.controllerProxy, returnedErr);
11662
12052
  }
11663
12053
  if (this.retryCount - this.retryCountCheckpoint > 0) {
11664
12054
  this.retryCount = this.retryCountCheckpoint + (this.retryCount - this.retryCountCheckpoint);
@@ -11679,9 +12069,9 @@ var require_retry_handler = __commonJS({
11679
12069
  }
11680
12070
  });
11681
12071
 
11682
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/retry-agent.js
12072
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/retry-agent.js
11683
12073
  var require_retry_agent = __commonJS({
11684
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/retry-agent.js"(exports, module) {
12074
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/retry-agent.js"(exports, module) {
11685
12075
  "use strict";
11686
12076
  init_esm_shims();
11687
12077
  var Dispatcher = require_dispatcher();
@@ -11715,9 +12105,9 @@ var require_retry_agent = __commonJS({
11715
12105
  }
11716
12106
  });
11717
12107
 
11718
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/h2c-client.js
12108
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/h2c-client.js
11719
12109
  var require_h2c_client = __commonJS({
11720
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/dispatcher/h2c-client.js"(exports, module) {
12110
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/dispatcher/h2c-client.js"(exports, module) {
11721
12111
  "use strict";
11722
12112
  init_esm_shims();
11723
12113
  var { InvalidArgumentError } = require_errors();
@@ -11759,9 +12149,9 @@ var require_h2c_client = __commonJS({
11759
12149
  }
11760
12150
  });
11761
12151
 
11762
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/readable.js
12152
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/readable.js
11763
12153
  var require_readable = __commonJS({
11764
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/readable.js"(exports, module) {
12154
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/readable.js"(exports, module) {
11765
12155
  "use strict";
11766
12156
  init_esm_shims();
11767
12157
  var assert = __require("assert");
@@ -12016,7 +12406,7 @@ var require_readable = __commonJS({
12016
12406
  */
12017
12407
  setEncoding(encoding) {
12018
12408
  if (Buffer.isEncoding(encoding)) {
12019
- this._readableState.encoding = encoding;
12409
+ super.setEncoding(encoding);
12020
12410
  }
12021
12411
  return this;
12022
12412
  }
@@ -12077,13 +12467,17 @@ var require_readable = __commonJS({
12077
12467
  consumePush(consume2, chunk);
12078
12468
  }
12079
12469
  }
12470
+ const decoder = state.decoder;
12471
+ if (decoder != null && decoder.lastNeed > 0) {
12472
+ consumePush(consume2, Buffer.from(decoder.lastChar.subarray(0, decoder.lastTotal - decoder.lastNeed)));
12473
+ }
12080
12474
  if (state.endEmitted) {
12081
- consumeEnd(this[kConsume], this._readableState.encoding);
12082
- } else {
12083
- consume2.stream.on("end", function() {
12084
- consumeEnd(this[kConsume], this._readableState.encoding);
12085
- });
12475
+ consumeEnd(consume2, state.encoding);
12476
+ return;
12086
12477
  }
12478
+ consume2.stream.on("end", function() {
12479
+ consumeEnd(this[kConsume], this._readableState.encoding);
12480
+ });
12087
12481
  consume2.stream.resume();
12088
12482
  while (consume2.stream.read() != null) {
12089
12483
  }
@@ -12137,6 +12531,12 @@ var require_readable = __commonJS({
12137
12531
  }
12138
12532
  }
12139
12533
  function consumePush(consume2, chunk) {
12534
+ if (consume2.body === null) {
12535
+ return;
12536
+ }
12537
+ if (typeof chunk === "string") {
12538
+ chunk = Buffer.from(chunk, consume2.stream._readableState.encoding);
12539
+ }
12140
12540
  consume2.length += chunk.length;
12141
12541
  consume2.body.push(chunk);
12142
12542
  }
@@ -12163,9 +12563,9 @@ var require_readable = __commonJS({
12163
12563
  }
12164
12564
  });
12165
12565
 
12166
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-request.js
12566
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-request.js
12167
12567
  var require_api_request = __commonJS({
12168
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-request.js"(exports, module) {
12568
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-request.js"(exports, module) {
12169
12569
  "use strict";
12170
12570
  init_esm_shims();
12171
12571
  var assert = __require("assert");
@@ -12224,7 +12624,9 @@ var require_api_request = __commonJS({
12224
12624
  this.removeAbortListener = util.addAbortListener(signal, () => {
12225
12625
  this.reason = signal.reason ?? new RequestAbortedError();
12226
12626
  if (this.res) {
12227
- util.destroy(this.res.on("error", noop), this.reason);
12627
+ const res = this.res;
12628
+ this.res = null;
12629
+ util.destroy(res.on("error", noop), this.reason);
12228
12630
  } else if (this.abort) {
12229
12631
  this.abort(this.reason);
12230
12632
  }
@@ -12363,9 +12765,9 @@ var require_api_request = __commonJS({
12363
12765
  }
12364
12766
  });
12365
12767
 
12366
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/abort-signal.js
12768
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/abort-signal.js
12367
12769
  var require_abort_signal = __commonJS({
12368
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/abort-signal.js"(exports, module) {
12770
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/abort-signal.js"(exports, module) {
12369
12771
  "use strict";
12370
12772
  init_esm_shims();
12371
12773
  var { addAbortListener } = require_util();
@@ -12416,9 +12818,9 @@ var require_abort_signal = __commonJS({
12416
12818
  }
12417
12819
  });
12418
12820
 
12419
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-stream.js
12821
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-stream.js
12420
12822
  var require_api_stream = __commonJS({
12421
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-stream.js"(exports, module) {
12823
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-stream.js"(exports, module) {
12422
12824
  "use strict";
12423
12825
  init_esm_shims();
12424
12826
  var assert = __require("assert");
@@ -12627,9 +13029,9 @@ var require_api_stream = __commonJS({
12627
13029
  }
12628
13030
  });
12629
13031
 
12630
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-pipeline.js
13032
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-pipeline.js
12631
13033
  var require_api_pipeline = __commonJS({
12632
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-pipeline.js"(exports, module) {
13034
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-pipeline.js"(exports, module) {
12633
13035
  "use strict";
12634
13036
  init_esm_shims();
12635
13037
  var {
@@ -12835,9 +13237,9 @@ var require_api_pipeline = __commonJS({
12835
13237
  }
12836
13238
  });
12837
13239
 
12838
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-upgrade.js
13240
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-upgrade.js
12839
13241
  var require_api_upgrade = __commonJS({
12840
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-upgrade.js"(exports, module) {
13242
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-upgrade.js"(exports, module) {
12841
13243
  "use strict";
12842
13244
  init_esm_shims();
12843
13245
  var { InvalidArgumentError, SocketError } = require_errors();
@@ -12936,9 +13338,9 @@ var require_api_upgrade = __commonJS({
12936
13338
  }
12937
13339
  });
12938
13340
 
12939
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-connect.js
13341
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-connect.js
12940
13342
  var require_api_connect = __commonJS({
12941
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/api-connect.js"(exports, module) {
13343
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/api-connect.js"(exports, module) {
12942
13344
  "use strict";
12943
13345
  init_esm_shims();
12944
13346
  var assert = __require("assert");
@@ -13029,9 +13431,9 @@ var require_api_connect = __commonJS({
13029
13431
  }
13030
13432
  });
13031
13433
 
13032
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/index.js
13434
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/index.js
13033
13435
  var require_api = __commonJS({
13034
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/api/index.js"(exports, module) {
13436
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/api/index.js"(exports, module) {
13035
13437
  "use strict";
13036
13438
  init_esm_shims();
13037
13439
  module.exports.request = require_api_request();
@@ -13042,9 +13444,9 @@ var require_api = __commonJS({
13042
13444
  }
13043
13445
  });
13044
13446
 
13045
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-errors.js
13447
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-errors.js
13046
13448
  var require_mock_errors = __commonJS({
13047
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-errors.js"(exports, module) {
13449
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-errors.js"(exports, module) {
13048
13450
  "use strict";
13049
13451
  init_esm_shims();
13050
13452
  var { UndiciError } = require_errors();
@@ -13069,9 +13471,9 @@ var require_mock_errors = __commonJS({
13069
13471
  }
13070
13472
  });
13071
13473
 
13072
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-symbols.js
13474
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-symbols.js
13073
13475
  var require_mock_symbols = __commonJS({
13074
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-symbols.js"(exports, module) {
13476
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-symbols.js"(exports, module) {
13075
13477
  "use strict";
13076
13478
  init_esm_shims();
13077
13479
  module.exports = {
@@ -13107,9 +13509,9 @@ var require_mock_symbols = __commonJS({
13107
13509
  }
13108
13510
  });
13109
13511
 
13110
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-utils.js
13512
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-utils.js
13111
13513
  var require_mock_utils = __commonJS({
13112
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-utils.js"(exports, module) {
13514
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-utils.js"(exports, module) {
13113
13515
  "use strict";
13114
13516
  init_esm_shims();
13115
13517
  var { MockNotMatchedError } = require_mock_errors();
@@ -13129,6 +13531,7 @@ var require_mock_utils = __commonJS({
13129
13531
  }
13130
13532
  } = __require("util");
13131
13533
  var { InvalidArgumentError } = require_errors();
13534
+ var requestAborted = /* @__PURE__ */ Symbol("request aborted");
13132
13535
  function matchValue(match, value) {
13133
13536
  if (typeof match === "string") {
13134
13537
  return match === value;
@@ -13241,6 +13644,8 @@ var require_mock_utils = __commonJS({
13241
13644
  return data;
13242
13645
  } else if (data instanceof ArrayBuffer) {
13243
13646
  return data;
13647
+ } else if (ArrayBuffer.isView(data)) {
13648
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
13244
13649
  } else if (typeof data === "object") {
13245
13650
  return JSON.stringify(data);
13246
13651
  } else if (data) {
@@ -13294,6 +13699,9 @@ var require_mock_utils = __commonJS({
13294
13699
  }
13295
13700
  }
13296
13701
  function removeTrailingSlash(path) {
13702
+ if (typeof path !== "string") {
13703
+ return path;
13704
+ }
13297
13705
  while (path.endsWith("/")) {
13298
13706
  path = path.slice(0, -1);
13299
13707
  }
@@ -13342,17 +13750,43 @@ var require_mock_utils = __commonJS({
13342
13750
  function mockDispatch(opts, handler) {
13343
13751
  const key = buildKey(opts);
13344
13752
  const mockDispatch2 = getMockDispatch(this[kDispatches], key);
13753
+ const mockDispatches = this[kDispatches];
13345
13754
  mockDispatch2.timesInvoked++;
13346
- if (mockDispatch2.data.callback) {
13347
- mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
13348
- }
13349
- const { data: { statusCode, data, headers, trailers, error }, delay, persist } = mockDispatch2;
13350
13755
  const { timesInvoked, times } = mockDispatch2;
13351
- mockDispatch2.consumed = !persist && timesInvoked >= times;
13756
+ mockDispatch2.consumed = !mockDispatch2.persist && timesInvoked >= times;
13352
13757
  mockDispatch2.pending = timesInvoked < times;
13353
- if (error !== null) {
13354
- deleteMockDispatch(this[kDispatches], key);
13355
- handler.onResponseError(null, error);
13758
+ const hasBodyHooks = typeof handler.onBodySent === "function" || typeof handler.onRequestSent === "function";
13759
+ if (mockDispatch2.data.callback && (!hasBodyHooks || opts.body == null)) {
13760
+ const { callback, ...responseDefaults } = mockDispatch2.data;
13761
+ const callbackResult = callback(opts);
13762
+ if (isPromise(callbackResult)) {
13763
+ callbackResult.then(
13764
+ (resolvedData) => {
13765
+ if (resolvedData == null || typeof resolvedData !== "object") {
13766
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
13767
+ return;
13768
+ }
13769
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
13770
+ dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
13771
+ },
13772
+ (error) => {
13773
+ handler.onResponseError(null, error);
13774
+ }
13775
+ );
13776
+ return true;
13777
+ }
13778
+ if (callbackResult == null || typeof callbackResult !== "object") {
13779
+ throw new InvalidArgumentError("reply options callback must return an object");
13780
+ }
13781
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
13782
+ }
13783
+ return dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
13784
+ }
13785
+ function dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler) {
13786
+ const { data: response, delay } = mockDispatch2;
13787
+ if (response.error !== null) {
13788
+ deleteMockDispatch(mockDispatches, key);
13789
+ handler.onResponseError(null, response.error);
13356
13790
  return true;
13357
13791
  }
13358
13792
  let aborted = false;
@@ -13379,39 +13813,172 @@ var require_mock_utils = __commonJS({
13379
13813
  handler.onResponseError?.(controller, reason);
13380
13814
  }
13381
13815
  };
13816
+ let replyOpts = opts;
13817
+ const dispatches = mockDispatches;
13382
13818
  handler.onRequestStart?.(controller, null);
13383
- if (typeof delay === "number" && delay > 0) {
13384
- timer = setTimeout(() => {
13385
- timer = null;
13386
- handleReply(this[kDispatches]);
13387
- }, delay);
13388
- } else {
13389
- handleReply(this[kDispatches]);
13819
+ if (aborted) {
13820
+ return true;
13821
+ }
13822
+ const requestBody = dispatchRequestBody(opts.body, handler, controller, () => aborted);
13823
+ if (isPromise(requestBody)) {
13824
+ requestBody.then((body) => {
13825
+ if (body === requestAborted) {
13826
+ return;
13827
+ }
13828
+ if (body !== opts.body) {
13829
+ replyOpts = { ...opts, body };
13830
+ }
13831
+ sendReply();
13832
+ }, (error) => controller.abort(error));
13833
+ return true;
13834
+ }
13835
+ if (requestBody === requestAborted) {
13836
+ return true;
13837
+ }
13838
+ if (requestBody !== opts.body) {
13839
+ replyOpts = { ...opts, body: requestBody };
13840
+ }
13841
+ sendReply();
13842
+ function sendReply() {
13843
+ if (response.callback) {
13844
+ const { callback, ...responseDefaults } = response;
13845
+ let callbackResult;
13846
+ try {
13847
+ callbackResult = callback(replyOpts);
13848
+ } catch (err) {
13849
+ deleteMockDispatch(mockDispatches, key);
13850
+ handler.onResponseError(null, err);
13851
+ return;
13852
+ }
13853
+ if (isPromise(callbackResult)) {
13854
+ callbackResult.then(
13855
+ (resolvedData) => {
13856
+ if (resolvedData == null || typeof resolvedData !== "object") {
13857
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
13858
+ return;
13859
+ }
13860
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
13861
+ handleReply(dispatches, mockDispatch2.data);
13862
+ },
13863
+ (err) => {
13864
+ handler.onResponseError(null, err);
13865
+ }
13866
+ );
13867
+ return;
13868
+ }
13869
+ if (callbackResult == null || typeof callbackResult !== "object") {
13870
+ throw new InvalidArgumentError("reply options callback must return an object");
13871
+ }
13872
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
13873
+ handleReply(dispatches, mockDispatch2.data);
13874
+ return;
13875
+ }
13876
+ if (typeof delay === "number" && delay > 0) {
13877
+ timer = setTimeout(() => {
13878
+ timer = null;
13879
+ handleReply(dispatches);
13880
+ }, delay);
13881
+ } else {
13882
+ handleReply(dispatches);
13883
+ }
13390
13884
  }
13391
- function handleReply(mockDispatches, _data = data) {
13885
+ function handleReply(mockDispatches2, _response = response) {
13392
13886
  if (aborted) {
13393
13887
  return;
13394
13888
  }
13889
+ const { statusCode, data, headers, trailers } = _response;
13395
13890
  const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
13396
- const body = typeof _data === "function" ? _data({ ...opts, headers: optsHeaders }) : _data;
13891
+ const body = typeof data === "function" ? data({ ...replyOpts, headers: optsHeaders }) : data;
13397
13892
  if (isPromise(body)) {
13398
- return body.then((newData) => handleReply(mockDispatches, newData));
13893
+ return body.then((newData) => handleReply(mockDispatches2, { ..._response, data: newData }));
13399
13894
  }
13400
13895
  if (aborted) {
13401
13896
  return;
13402
13897
  }
13403
13898
  const responseData = getResponseData(body);
13404
- const responseHeaders = generateKeyValues(headers);
13405
- const responseTrailers = generateKeyValues(trailers);
13899
+ const responseHeaders = generateKeyValues(headers ?? {});
13900
+ const responseTrailers = generateKeyValues(trailers ?? {});
13406
13901
  controller.rawHeaders = responseHeaders;
13407
13902
  controller.rawTrailers = responseTrailers;
13408
13903
  handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
13409
13904
  handler.onResponseData?.(controller, Buffer.from(responseData));
13410
13905
  handler.onResponseEnd?.(controller, parseHeaders(responseTrailers));
13411
- deleteMockDispatch(mockDispatches, key);
13906
+ deleteMockDispatch(mockDispatches2, key);
13412
13907
  }
13413
13908
  return true;
13414
13909
  }
13910
+ function dispatchRequestBody(body, handler, controller, isAborted) {
13911
+ if (typeof handler.onBodySent !== "function" && typeof handler.onRequestSent !== "function") {
13912
+ return body;
13913
+ }
13914
+ if (body == null) {
13915
+ return callOnRequestSent(handler, controller, isAborted) ? body : requestAborted;
13916
+ }
13917
+ if (body && typeof body[Symbol.asyncIterator] === "function") {
13918
+ return dispatchAsyncIterableBody(body, handler, controller, isAborted);
13919
+ }
13920
+ if (isIterableBody(body)) {
13921
+ const chunks = [];
13922
+ for (const chunk of body) {
13923
+ if (isAborted()) {
13924
+ return requestAborted;
13925
+ }
13926
+ chunks.push(chunk);
13927
+ if (!callOnBodySent(handler, controller, chunk) || isAborted()) {
13928
+ return requestAborted;
13929
+ }
13930
+ }
13931
+ return callOnRequestSent(handler, controller, isAborted) ? chunks : requestAborted;
13932
+ }
13933
+ if (isAborted()) {
13934
+ return requestAborted;
13935
+ }
13936
+ if (!callOnBodySent(handler, controller, body)) {
13937
+ return requestAborted;
13938
+ }
13939
+ return callOnRequestSent(handler, controller, isAborted) ? body : requestAborted;
13940
+ }
13941
+ async function dispatchAsyncIterableBody(body, handler, controller, isAborted) {
13942
+ const chunks = [];
13943
+ for await (const chunk of body) {
13944
+ if (isAborted()) {
13945
+ return requestAborted;
13946
+ }
13947
+ chunks.push(chunk);
13948
+ if (!callOnBodySent(handler, controller, chunk) || isAborted()) {
13949
+ return requestAborted;
13950
+ }
13951
+ }
13952
+ if (!callOnRequestSent(handler, controller, isAborted)) {
13953
+ return requestAborted;
13954
+ }
13955
+ return {
13956
+ async *[Symbol.asyncIterator]() {
13957
+ yield* chunks;
13958
+ }
13959
+ };
13960
+ }
13961
+ function callOnBodySent(handler, controller, chunk) {
13962
+ try {
13963
+ handler.onBodySent?.(chunk);
13964
+ return true;
13965
+ } catch (error) {
13966
+ controller.abort(error);
13967
+ return false;
13968
+ }
13969
+ }
13970
+ function callOnRequestSent(handler, controller, isAborted) {
13971
+ try {
13972
+ handler.onRequestSent?.();
13973
+ return !isAborted();
13974
+ } catch (error) {
13975
+ controller.abort(error);
13976
+ return false;
13977
+ }
13978
+ }
13979
+ function isIterableBody(body) {
13980
+ return typeof body !== "string" && !Buffer.isBuffer(body) && !ArrayBuffer.isView(body) && typeof body[Symbol.iterator] === "function";
13981
+ }
13415
13982
  function buildMockDispatch() {
13416
13983
  const agent = this[kMockAgent];
13417
13984
  const origin = this[kOrigin];
@@ -13496,9 +14063,9 @@ var require_mock_utils = __commonJS({
13496
14063
  }
13497
14064
  });
13498
14065
 
13499
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-interceptor.js
14066
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-interceptor.js
13500
14067
  var require_mock_interceptor = __commonJS({
13501
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-interceptor.js"(exports, module) {
14068
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-interceptor.js"(exports, module) {
13502
14069
  "use strict";
13503
14070
  init_esm_shims();
13504
14071
  var { getResponseData, buildKey, addMockDispatch } = require_mock_utils();
@@ -13513,6 +14080,11 @@ var require_mock_interceptor = __commonJS({
13513
14080
  } = require_mock_symbols();
13514
14081
  var { InvalidArgumentError } = require_errors();
13515
14082
  var { serializePathWithQuery } = require_util();
14083
+ var {
14084
+ types: {
14085
+ isPromise
14086
+ }
14087
+ } = __require("util");
13516
14088
  var MockScope = class {
13517
14089
  constructor(mockDispatch) {
13518
14090
  this[kMockDispatch] = mockDispatch;
@@ -13594,8 +14166,7 @@ var require_mock_interceptor = __commonJS({
13594
14166
  */
13595
14167
  reply(replyOptionsCallbackOrStatusCode) {
13596
14168
  if (typeof replyOptionsCallbackOrStatusCode === "function") {
13597
- const wrappedDefaultsCallback = (opts) => {
13598
- const resolvedData = replyOptionsCallbackOrStatusCode(opts);
14169
+ const resolveReplyCallbackData = (resolvedData) => {
13599
14170
  if (typeof resolvedData !== "object" || resolvedData === null) {
13600
14171
  throw new InvalidArgumentError("reply options callback must return an object");
13601
14172
  }
@@ -13605,6 +14176,13 @@ var require_mock_interceptor = __commonJS({
13605
14176
  ...this.createMockScopeDispatchData(replyParameters2)
13606
14177
  };
13607
14178
  };
14179
+ const wrappedDefaultsCallback = (opts) => {
14180
+ const resolvedData = replyOptionsCallbackOrStatusCode(opts);
14181
+ if (isPromise(resolvedData)) {
14182
+ return resolvedData.then(resolveReplyCallbackData);
14183
+ }
14184
+ return resolveReplyCallbackData(resolvedData);
14185
+ };
13608
14186
  const newMockDispatch2 = addMockDispatch(this[kDispatches], this[kDispatchKey], wrappedDefaultsCallback, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
13609
14187
  return new MockScope(newMockDispatch2);
13610
14188
  }
@@ -13661,9 +14239,9 @@ var require_mock_interceptor = __commonJS({
13661
14239
  }
13662
14240
  });
13663
14241
 
13664
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-client.js
14242
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-client.js
13665
14243
  var require_mock_client = __commonJS({
13666
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-client.js"(exports, module) {
14244
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-client.js"(exports, module) {
13667
14245
  "use strict";
13668
14246
  init_esm_shims();
13669
14247
  var { promisify } = __require("util");
@@ -13723,9 +14301,9 @@ var require_mock_client = __commonJS({
13723
14301
  }
13724
14302
  });
13725
14303
 
13726
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-call-history.js
14304
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-call-history.js
13727
14305
  var require_mock_call_history = __commonJS({
13728
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-call-history.js"(exports, module) {
14306
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-call-history.js"(exports, module) {
13729
14307
  "use strict";
13730
14308
  init_esm_shims();
13731
14309
  var { kMockCallHistoryAddLog } = require_mock_symbols();
@@ -13924,9 +14502,9 @@ var require_mock_call_history = __commonJS({
13924
14502
  }
13925
14503
  });
13926
14504
 
13927
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-pool.js
14505
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-pool.js
13928
14506
  var require_mock_pool = __commonJS({
13929
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-pool.js"(exports, module) {
14507
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-pool.js"(exports, module) {
13930
14508
  "use strict";
13931
14509
  init_esm_shims();
13932
14510
  var { promisify } = __require("util");
@@ -13986,9 +14564,9 @@ var require_mock_pool = __commonJS({
13986
14564
  }
13987
14565
  });
13988
14566
 
13989
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/pending-interceptors-formatter.js
14567
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/pending-interceptors-formatter.js
13990
14568
  var require_pending_interceptors_formatter = __commonJS({
13991
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/pending-interceptors-formatter.js"(exports, module) {
14569
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/pending-interceptors-formatter.js"(exports, module) {
13992
14570
  "use strict";
13993
14571
  init_esm_shims();
13994
14572
  var { Transform } = __require("stream");
@@ -14028,9 +14606,9 @@ var require_pending_interceptors_formatter = __commonJS({
14028
14606
  }
14029
14607
  });
14030
14608
 
14031
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-agent.js
14609
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-agent.js
14032
14610
  var require_mock_agent = __commonJS({
14033
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/mock-agent.js"(exports, module) {
14611
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/mock-agent.js"(exports, module) {
14034
14612
  "use strict";
14035
14613
  init_esm_shims();
14036
14614
  var { kClients } = require_symbols();
@@ -14213,9 +14791,9 @@ ${pendingInterceptorsFormatter.format(pending)}`.trim()
14213
14791
  }
14214
14792
  });
14215
14793
 
14216
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-utils.js
14794
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-utils.js
14217
14795
  var require_snapshot_utils = __commonJS({
14218
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-utils.js"(exports, module) {
14796
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-utils.js"(exports, module) {
14219
14797
  "use strict";
14220
14798
  init_esm_shims();
14221
14799
  var { InvalidArgumentError } = require_errors();
@@ -14300,9 +14878,9 @@ var require_snapshot_utils = __commonJS({
14300
14878
  }
14301
14879
  });
14302
14880
 
14303
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-recorder.js
14881
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js
14304
14882
  var require_snapshot_recorder = __commonJS({
14305
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
14883
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
14306
14884
  "use strict";
14307
14885
  init_esm_shims();
14308
14886
  var { writeFile, readFile, mkdir } = __require("fs/promises");
@@ -14692,9 +15270,9 @@ var require_snapshot_recorder = __commonJS({
14692
15270
  }
14693
15271
  });
14694
15272
 
14695
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-agent.js
15273
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-agent.js
14696
15274
  var require_snapshot_agent = __commonJS({
14697
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/mock/snapshot-agent.js"(exports, module) {
15275
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-agent.js"(exports, module) {
14698
15276
  "use strict";
14699
15277
  init_esm_shims();
14700
15278
  var Agent = require_agent();
@@ -14992,9 +15570,9 @@ var require_snapshot_agent = __commonJS({
14992
15570
  }
14993
15571
  });
14994
15572
 
14995
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/global.js
15573
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/global.js
14996
15574
  var require_global2 = __commonJS({
14997
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/global.js"(exports, module) {
15575
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/global.js"(exports, module) {
14998
15576
  "use strict";
14999
15577
  init_esm_shims();
15000
15578
  var globalDispatcher = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.2");
@@ -15002,6 +15580,7 @@ var require_global2 = __commonJS({
15002
15580
  var { InvalidArgumentError } = require_errors();
15003
15581
  var Agent = require_agent();
15004
15582
  var Dispatcher1Wrapper = require_dispatcher1_wrapper();
15583
+ var fallbackDispatcher;
15005
15584
  if (getGlobalDispatcher() === void 0) {
15006
15585
  setGlobalDispatcher(new Agent());
15007
15586
  }
@@ -15009,22 +15588,36 @@ var require_global2 = __commonJS({
15009
15588
  if (!agent || typeof agent.dispatch !== "function") {
15010
15589
  throw new InvalidArgumentError("Argument agent must implement Agent");
15011
15590
  }
15012
- Object.defineProperty(globalThis, globalDispatcher, {
15013
- value: agent,
15014
- writable: true,
15015
- enumerable: false,
15016
- configurable: false
15017
- });
15018
- const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent);
15019
- Object.defineProperty(globalThis, legacyGlobalDispatcher, {
15020
- value: legacyAgent,
15021
- writable: true,
15022
- enumerable: false,
15023
- configurable: false
15024
- });
15591
+ try {
15592
+ Object.defineProperty(globalThis, globalDispatcher, {
15593
+ value: agent,
15594
+ writable: true,
15595
+ enumerable: false,
15596
+ configurable: false
15597
+ });
15598
+ } catch (err) {
15599
+ if (err instanceof TypeError) {
15600
+ fallbackDispatcher = agent;
15601
+ return;
15602
+ }
15603
+ throw err;
15604
+ }
15605
+ try {
15606
+ const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent);
15607
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
15608
+ value: legacyAgent,
15609
+ writable: true,
15610
+ enumerable: false,
15611
+ configurable: false
15612
+ });
15613
+ } catch (err) {
15614
+ if (!(err instanceof TypeError)) {
15615
+ throw err;
15616
+ }
15617
+ }
15025
15618
  }
15026
15619
  function getGlobalDispatcher() {
15027
- return globalThis[globalDispatcher];
15620
+ return globalThis[globalDispatcher] ?? fallbackDispatcher;
15028
15621
  }
15029
15622
  var installedExports = (
15030
15623
  /** @type {const} */
@@ -15049,9 +15642,9 @@ var require_global2 = __commonJS({
15049
15642
  }
15050
15643
  });
15051
15644
 
15052
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/decorator-handler.js
15645
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/decorator-handler.js
15053
15646
  var require_decorator_handler = __commonJS({
15054
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/decorator-handler.js"(exports, module) {
15647
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/decorator-handler.js"(exports, module) {
15055
15648
  "use strict";
15056
15649
  init_esm_shims();
15057
15650
  var assert = __require("assert");
@@ -15105,9 +15698,9 @@ var require_decorator_handler = __commonJS({
15105
15698
  }
15106
15699
  });
15107
15700
 
15108
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/redirect-handler.js
15701
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/redirect-handler.js
15109
15702
  var require_redirect_handler = __commonJS({
15110
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/redirect-handler.js"(exports, module) {
15703
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/redirect-handler.js"(exports, module) {
15111
15704
  "use strict";
15112
15705
  init_esm_shims();
15113
15706
  var util = require_util();
@@ -15152,12 +15745,14 @@ var require_redirect_handler = __commonJS({
15152
15745
  if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
15153
15746
  throw new Error("max redirects");
15154
15747
  }
15748
+ let removeContentHeaders = statusCode === 303;
15155
15749
  if ((statusCode === 301 || statusCode === 302) && this.opts.method === "POST") {
15156
15750
  this.opts.method = "GET";
15157
15751
  if (util.isStream(this.opts.body)) {
15158
15752
  util.destroy(this.opts.body.on("error", noop));
15159
15753
  }
15160
15754
  this.opts.body = null;
15755
+ removeContentHeaders = true;
15161
15756
  }
15162
15757
  if (statusCode === 303 && this.opts.method !== "HEAD") {
15163
15758
  this.opts.method = "GET";
@@ -15182,7 +15777,7 @@ var require_redirect_handler = __commonJS({
15182
15777
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
15183
15778
  }
15184
15779
  }
15185
- this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin, this.stripHeadersOnRedirect, this.stripHeadersOnCrossOriginRedirect);
15780
+ this.opts.headers = cleanRequestHeaders(this.opts.headers, removeContentHeaders, this.opts.origin !== origin, this.stripHeadersOnRedirect, this.stripHeadersOnCrossOriginRedirect);
15186
15781
  this.opts.path = path;
15187
15782
  this.opts.origin = origin;
15188
15783
  this.opts.query = null;
@@ -15260,9 +15855,9 @@ var require_redirect_handler = __commonJS({
15260
15855
  }
15261
15856
  });
15262
15857
 
15263
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/redirect.js
15858
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/redirect.js
15264
15859
  var require_redirect = __commonJS({
15265
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/redirect.js"(exports, module) {
15860
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/redirect.js"(exports, module) {
15266
15861
  "use strict";
15267
15862
  init_esm_shims();
15268
15863
  var RedirectHandler = require_redirect_handler();
@@ -15283,9 +15878,9 @@ var require_redirect = __commonJS({
15283
15878
  }
15284
15879
  });
15285
15880
 
15286
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/response-error.js
15881
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/response-error.js
15287
15882
  var require_response_error = __commonJS({
15288
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/response-error.js"(exports, module) {
15883
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/response-error.js"(exports, module) {
15289
15884
  "use strict";
15290
15885
  init_esm_shims();
15291
15886
  var DecoratorHandler = require_decorator_handler();
@@ -15366,9 +15961,9 @@ var require_response_error = __commonJS({
15366
15961
  }
15367
15962
  });
15368
15963
 
15369
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/retry.js
15964
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/retry.js
15370
15965
  var require_retry = __commonJS({
15371
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/retry.js"(exports, module) {
15966
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/retry.js"(exports, module) {
15372
15967
  "use strict";
15373
15968
  init_esm_shims();
15374
15969
  var RetryHandler = require_retry_handler();
@@ -15391,9 +15986,9 @@ var require_retry = __commonJS({
15391
15986
  }
15392
15987
  });
15393
15988
 
15394
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/dump.js
15989
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/dump.js
15395
15990
  var require_dump = __commonJS({
15396
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/dump.js"(exports, module) {
15991
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/dump.js"(exports, module) {
15397
15992
  "use strict";
15398
15993
  init_esm_shims();
15399
15994
  var { InvalidArgumentError, RequestAbortedError } = require_errors();
@@ -15478,9 +16073,9 @@ var require_dump = __commonJS({
15478
16073
  }
15479
16074
  });
15480
16075
 
15481
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/dns.js
16076
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/dns.js
15482
16077
  var require_dns = __commonJS({
15483
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/dns.js"(exports, module) {
16078
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/dns.js"(exports, module) {
15484
16079
  "use strict";
15485
16080
  init_esm_shims();
15486
16081
  var { isIP } = __require("net");
@@ -15921,32 +16516,154 @@ var require_dns = __commonJS({
15921
16516
  }
15922
16517
  });
15923
16518
 
15924
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/cache.js
16519
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/cache.js
15925
16520
  var require_cache = __commonJS({
15926
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/cache.js"(exports, module) {
16521
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/cache.js"(exports, module) {
15927
16522
  "use strict";
15928
16523
  init_esm_shims();
15929
16524
  var {
15930
16525
  safeHTTPMethods,
15931
16526
  pathHasQueryOrFragment,
15932
- hasSafeIterator
16527
+ hasSafeIterator,
16528
+ isValidHTTPToken
15933
16529
  } = require_util();
15934
16530
  var { serializePathWithQuery } = require_util();
15935
- function makeCacheKey(opts) {
15936
- if (!opts.origin) {
15937
- throw new Error("opts.origin is undefined");
16531
+ var MAX_DELTA_SECONDS = 2147483647;
16532
+ var RESTRICTIVE_DIRECTIVE_NAMES = ["no-store", "private", "no-cache"];
16533
+ var kInvalidCacheControlDirectives = /* @__PURE__ */ Symbol("invalid cache-control directives");
16534
+ function trimOWS(value) {
16535
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
16536
+ }
16537
+ function arrayIncludes(array, value) {
16538
+ for (let i = 0; i < array.length; i++) {
16539
+ if (array[i] === value) {
16540
+ return true;
16541
+ }
16542
+ }
16543
+ return false;
16544
+ }
16545
+ function trimOWSStart(value) {
16546
+ return value.replace(/^[\t ]+/, "");
16547
+ }
16548
+ function trimOWSEnd(value) {
16549
+ return value.replace(/[\t ]+$/, "");
16550
+ }
16551
+ function findUnescapedQuote(value, start) {
16552
+ let escaped = false;
16553
+ for (let i = start; i < value.length; i++) {
16554
+ if (escaped) {
16555
+ escaped = false;
16556
+ } else if (value[i] === "\\") {
16557
+ escaped = true;
16558
+ } else if (value[i] === '"') {
16559
+ return i;
16560
+ }
16561
+ }
16562
+ return -1;
16563
+ }
16564
+ function splitCacheControlHeaderValue(value) {
16565
+ const directives = [];
16566
+ let start = 0;
16567
+ let quoteStart = -1;
16568
+ let inQuote = false;
16569
+ let escaped = false;
16570
+ for (let i = 0; i < value.length; i++) {
16571
+ if (inQuote) {
16572
+ if (escaped) {
16573
+ escaped = false;
16574
+ } else if (value[i] === "\\") {
16575
+ escaped = true;
16576
+ } else if (value[i] === '"') {
16577
+ inQuote = false;
16578
+ quoteStart = -1;
16579
+ }
16580
+ } else if (value[i] === '"') {
16581
+ inQuote = true;
16582
+ quoteStart = i;
16583
+ } else if (value[i] === ",") {
16584
+ directives.push({ value: value.substring(start, i), fromMalformedQuote: false });
16585
+ start = i + 1;
16586
+ }
16587
+ }
16588
+ if (!inQuote) {
16589
+ directives.push({ value: value.substring(start), fromMalformedQuote: false });
16590
+ return directives;
16591
+ }
16592
+ const tail = value.substring(start);
16593
+ const quoteOffset = quoteStart - start;
16594
+ let tailStart = 0;
16595
+ for (let i = 0; i < tail.length; i++) {
16596
+ if (tail[i] === ",") {
16597
+ directives.push({
16598
+ value: tail.substring(tailStart, i),
16599
+ fromMalformedQuote: tailStart > quoteOffset
16600
+ });
16601
+ tailStart = i + 1;
16602
+ }
16603
+ }
16604
+ directives.push({
16605
+ value: tail.substring(tailStart),
16606
+ fromMalformedQuote: tailStart > quoteOffset
16607
+ });
16608
+ return directives;
16609
+ }
16610
+ function markInvalidCacheControlDirective(directives, key) {
16611
+ let invalidDirectives = directives[kInvalidCacheControlDirectives];
16612
+ if (invalidDirectives === void 0) {
16613
+ invalidDirectives = /* @__PURE__ */ new Set();
16614
+ Object.defineProperty(directives, kInvalidCacheControlDirectives, {
16615
+ value: invalidDirectives
16616
+ });
15938
16617
  }
16618
+ invalidDirectives.add(key);
16619
+ }
16620
+ function hasInvalidCacheControlDirective(directives, key) {
16621
+ return directives[kInvalidCacheControlDirectives]?.has(key) === true;
16622
+ }
16623
+ function getMalformedRestrictiveDirectiveName(key) {
16624
+ for (const directiveName of RESTRICTIVE_DIRECTIVE_NAMES) {
16625
+ if (key.startsWith(directiveName) && key.length > directiveName.length && !isValidHTTPToken(key[directiveName.length])) {
16626
+ return directiveName;
16627
+ }
16628
+ }
16629
+ let tokenOnlyKey = "";
16630
+ let hasInvalidTokenChar = false;
16631
+ for (let i = 0; i < key.length; i++) {
16632
+ if (isValidHTTPToken(key[i])) {
16633
+ tokenOnlyKey += key[i];
16634
+ } else {
16635
+ hasInvalidTokenChar = true;
16636
+ }
16637
+ }
16638
+ if (hasInvalidTokenChar && arrayIncludes(RESTRICTIVE_DIRECTIVE_NAMES, tokenOnlyKey)) {
16639
+ return tokenOnlyKey;
16640
+ }
16641
+ }
16642
+ function makeCacheKey(opts) {
16643
+ const origin = opts.origin ? opts.origin.toString() : "";
15939
16644
  let fullPath = opts.path || "/";
15940
16645
  if (opts.query && !pathHasQueryOrFragment(fullPath)) {
15941
16646
  fullPath = serializePathWithQuery(fullPath, opts.query);
15942
16647
  }
15943
16648
  return {
15944
- origin: opts.origin.toString(),
16649
+ origin,
15945
16650
  method: opts.method,
15946
16651
  path: fullPath,
15947
16652
  headers: opts.headers
15948
16653
  };
15949
16654
  }
16655
+ function appendHeader(headers, key, val) {
16656
+ const headerName = key.toLowerCase();
16657
+ const current = headers[headerName];
16658
+ const values = Array.isArray(val) ? val : [val];
16659
+ if (current === void 0) {
16660
+ headers[headerName] = Array.isArray(val) ? val.slice() : val;
16661
+ } else if (Array.isArray(current)) {
16662
+ current.push(...values);
16663
+ } else {
16664
+ headers[headerName] = [current, ...values];
16665
+ }
16666
+ }
15950
16667
  function normalizeHeaders(opts) {
15951
16668
  let headers;
15952
16669
  if (opts.headers == null) {
@@ -15954,19 +16671,57 @@ var require_cache = __commonJS({
15954
16671
  } else if (typeof opts.headers === "object") {
15955
16672
  headers = {};
15956
16673
  if (hasSafeIterator(opts.headers)) {
15957
- for (const x of opts.headers) {
15958
- if (!Array.isArray(x)) {
15959
- throw new Error("opts.headers is not a valid header map");
16674
+ if (Array.isArray(opts.headers)) {
16675
+ const first = opts.headers[0];
16676
+ if (Array.isArray(first)) {
16677
+ for (const x of opts.headers) {
16678
+ if (!Array.isArray(x)) {
16679
+ throw new Error("opts.headers is not a valid header map");
16680
+ }
16681
+ const [key, val] = x;
16682
+ if (typeof key !== "string" || typeof val !== "string") {
16683
+ throw new Error("opts.headers is not a valid header map");
16684
+ }
16685
+ appendHeader(headers, key, val);
16686
+ }
16687
+ } else {
16688
+ const len = opts.headers.length;
16689
+ if (len % 2 !== 0) {
16690
+ throw new Error("opts.headers is not a valid header map");
16691
+ }
16692
+ for (let i = 0; i < len; i += 2) {
16693
+ const key = opts.headers[i];
16694
+ const val = opts.headers[i + 1];
16695
+ if (typeof key !== "string" || typeof val !== "string" && !Array.isArray(val)) {
16696
+ throw new Error("opts.headers is not a valid header map");
16697
+ }
16698
+ if (typeof val === "string") {
16699
+ appendHeader(headers, key, val);
16700
+ } else {
16701
+ const mapped = [];
16702
+ for (let j = 0; j < val.length; j++) {
16703
+ const v = val[j];
16704
+ mapped.push(typeof v === "string" ? v : v.toString("latin1"));
16705
+ }
16706
+ appendHeader(headers, key, mapped);
16707
+ }
16708
+ }
15960
16709
  }
15961
- const [key, val] = x;
15962
- if (typeof key !== "string" || typeof val !== "string") {
15963
- throw new Error("opts.headers is not a valid header map");
16710
+ } else {
16711
+ for (const x of opts.headers) {
16712
+ if (!Array.isArray(x)) {
16713
+ throw new Error("opts.headers is not a valid header map");
16714
+ }
16715
+ const [key, val] = x;
16716
+ if (typeof key !== "string" || typeof val !== "string") {
16717
+ throw new Error("opts.headers is not a valid header map");
16718
+ }
16719
+ appendHeader(headers, key, val);
15964
16720
  }
15965
- headers[key.toLowerCase()] = val;
15966
16721
  }
15967
16722
  } else {
15968
16723
  for (const key of Object.keys(opts.headers)) {
15969
- headers[key.toLowerCase()] = opts.headers[key];
16724
+ appendHeader(headers, key, opts.headers[key]);
15970
16725
  }
15971
16726
  }
15972
16727
  } else {
@@ -16011,25 +16766,32 @@ var require_cache = __commonJS({
16011
16766
  }
16012
16767
  function parseCacheControlHeader(header) {
16013
16768
  const output = {};
16014
- let directives;
16015
- if (Array.isArray(header)) {
16016
- directives = [];
16017
- for (const directive of header) {
16018
- directives.push(...directive.split(","));
16019
- }
16020
- } else {
16021
- directives = header.split(",");
16022
- }
16769
+ const invalidNumericDirectives = /* @__PURE__ */ new Set();
16770
+ const invalidNoArgumentDirectives = /* @__PURE__ */ new Set();
16771
+ const directives = splitCacheControlHeaderValue(Array.isArray(header) ? header.join(",") : header);
16023
16772
  for (let i = 0; i < directives.length; i++) {
16024
- const directive = directives[i].toLowerCase();
16773
+ const directiveRecord = directives[i];
16774
+ const directive = directiveRecord.value.toLowerCase();
16775
+ const fromMalformedQuote = directiveRecord.fromMalformedQuote;
16025
16776
  const keyValueDelimiter = directive.indexOf("=");
16026
16777
  let key;
16027
16778
  let value;
16779
+ let keyHasTrailingWhitespace = false;
16780
+ let valueHasLeadingWhitespace = false;
16028
16781
  if (keyValueDelimiter !== -1) {
16029
- key = directive.substring(0, keyValueDelimiter).trimStart();
16030
- value = directive.substring(keyValueDelimiter + 1);
16782
+ const rawKey = directive.substring(0, keyValueDelimiter);
16783
+ const rawValue = directive.substring(keyValueDelimiter + 1);
16784
+ keyHasTrailingWhitespace = trimOWSEnd(rawKey) !== rawKey;
16785
+ valueHasLeadingWhitespace = trimOWSStart(rawValue) !== rawValue;
16786
+ key = trimOWS(rawKey);
16787
+ value = trimOWSStart(rawValue);
16031
16788
  } else {
16032
- key = directive.trim();
16789
+ key = trimOWS(directive);
16790
+ }
16791
+ const malformedRestrictiveDirectiveName = getMalformedRestrictiveDirectiveName(key);
16792
+ if (malformedRestrictiveDirectiveName !== void 0) {
16793
+ output[malformedRestrictiveDirectiveName] = true;
16794
+ continue;
16033
16795
  }
16034
16796
  switch (key) {
16035
16797
  case "min-fresh":
@@ -16038,48 +16800,85 @@ var require_cache = __commonJS({
16038
16800
  case "s-maxage":
16039
16801
  case "stale-while-revalidate":
16040
16802
  case "stale-if-error": {
16041
- if (value === void 0 || value[0] === " ") {
16803
+ if (fromMalformedQuote || invalidNumericDirectives.has(key)) {
16804
+ continue;
16805
+ }
16806
+ if (value === void 0 || keyHasTrailingWhitespace || valueHasLeadingWhitespace) {
16807
+ delete output[key];
16808
+ invalidNumericDirectives.add(key);
16809
+ markInvalidCacheControlDirective(output, key);
16042
16810
  continue;
16043
16811
  }
16044
16812
  if (value.length >= 2 && value[0] === '"' && value[value.length - 1] === '"') {
16045
16813
  value = value.substring(1, value.length - 1);
16046
16814
  }
16047
- const parsedValue = parseInt(value, 10);
16048
- if (parsedValue !== parsedValue) {
16815
+ if (!/^[0-9]+$/.test(value)) {
16816
+ delete output[key];
16817
+ invalidNumericDirectives.add(key);
16818
+ markInvalidCacheControlDirective(output, key);
16049
16819
  continue;
16050
16820
  }
16051
- if (key === "max-age" && key in output && output[key] >= parsedValue) {
16052
- continue;
16821
+ const parsedValue = Math.min(parseInt(value, 10), MAX_DELTA_SECONDS);
16822
+ if (key === "min-fresh") {
16823
+ if (!(key in output) || output[key] < parsedValue) {
16824
+ output[key] = parsedValue;
16825
+ }
16826
+ } else if (!(key in output) || output[key] > parsedValue) {
16827
+ output[key] = parsedValue;
16053
16828
  }
16054
- output[key] = parsedValue;
16055
16829
  break;
16056
16830
  }
16057
16831
  case "private":
16058
16832
  case "no-cache": {
16833
+ if (fromMalformedQuote) {
16834
+ output[key] = true;
16835
+ break;
16836
+ }
16837
+ if (value !== void 0 && value.length === 0) {
16838
+ output[key] = true;
16839
+ break;
16840
+ }
16059
16841
  if (value) {
16060
16842
  if (value[0] === '"') {
16061
- const headers = [value.substring(1)];
16062
- let foundEndingQuote = value[value.length - 1] === '"';
16063
- if (!foundEndingQuote) {
16843
+ value = trimOWSEnd(value);
16844
+ let fieldList = "";
16845
+ let lastQuotedPart = i;
16846
+ let foundEndingQuote = false;
16847
+ const closingQuote = findUnescapedQuote(value, 1);
16848
+ if (closingQuote !== -1) {
16849
+ fieldList = value.substring(1, closingQuote);
16850
+ foundEndingQuote = true;
16851
+ } else {
16852
+ const fieldListParts = [value.substring(1)];
16064
16853
  for (let j = i + 1; j < directives.length; j++) {
16065
- const nextPart = directives[j];
16066
- const nextPartLength = nextPart.length;
16067
- headers.push(nextPart.trim());
16068
- if (nextPartLength !== 0 && nextPart[nextPartLength - 1] === '"') {
16854
+ const nextPart = trimOWS(directives[j].value);
16855
+ const closingQuote2 = findUnescapedQuote(nextPart, 0);
16856
+ lastQuotedPart = j;
16857
+ if (closingQuote2 !== -1) {
16858
+ fieldListParts.push(nextPart.substring(0, closingQuote2));
16069
16859
  foundEndingQuote = true;
16070
16860
  break;
16071
16861
  }
16862
+ fieldListParts.push(nextPart);
16072
16863
  }
16864
+ fieldList = fieldListParts.join(",");
16073
16865
  }
16074
- if (foundEndingQuote) {
16075
- let lastHeader = headers[headers.length - 1];
16076
- if (lastHeader[lastHeader.length - 1] === '"') {
16077
- lastHeader = lastHeader.substring(0, lastHeader.length - 1);
16078
- headers[headers.length - 1] = lastHeader;
16079
- }
16080
- for (let j = 0; j < headers.length; j++) {
16081
- headers[j] = headers[j].trim();
16866
+ if (!foundEndingQuote) {
16867
+ output[key] = true;
16868
+ break;
16869
+ }
16870
+ i = lastQuotedPart;
16871
+ const headers = fieldList.split(",");
16872
+ let validFieldNames = true;
16873
+ for (let j = 0; j < headers.length; j++) {
16874
+ headers[j] = trimOWS(headers[j]);
16875
+ if (!isValidHTTPToken(headers[j])) {
16876
+ validFieldNames = false;
16082
16877
  }
16878
+ }
16879
+ if (!validFieldNames) {
16880
+ output[key] = true;
16881
+ } else if (output[key] !== true) {
16083
16882
  if (key in output) {
16084
16883
  output[key] = output[key].concat(headers);
16085
16884
  } else {
@@ -16087,11 +16886,15 @@ var require_cache = __commonJS({
16087
16886
  }
16088
16887
  }
16089
16888
  } else {
16090
- const fieldName = value.trim();
16091
- if (key in output) {
16092
- output[key] = output[key].concat(fieldName);
16093
- } else {
16094
- output[key] = [fieldName];
16889
+ const fieldName = trimOWS(value);
16890
+ if (!isValidHTTPToken(fieldName)) {
16891
+ output[key] = true;
16892
+ } else if (output[key] !== true) {
16893
+ if (key in output) {
16894
+ output[key] = output[key].concat(fieldName);
16895
+ } else {
16896
+ output[key] = [fieldName];
16897
+ }
16095
16898
  }
16096
16899
  }
16097
16900
  break;
@@ -16099,39 +16902,76 @@ var require_cache = __commonJS({
16099
16902
  }
16100
16903
  // eslint-disable-next-line no-fallthrough
16101
16904
  case "public":
16102
- case "no-store":
16103
16905
  case "must-revalidate":
16104
16906
  case "proxy-revalidate":
16105
16907
  case "immutable":
16106
16908
  case "no-transform":
16107
16909
  case "must-understand":
16108
16910
  case "only-if-cached":
16109
- if (value) {
16911
+ if (fromMalformedQuote || invalidNoArgumentDirectives.has(key)) {
16912
+ continue;
16913
+ }
16914
+ if (value !== void 0) {
16915
+ delete output[key];
16916
+ invalidNoArgumentDirectives.add(key);
16110
16917
  continue;
16111
16918
  }
16112
16919
  output[key] = true;
16113
16920
  break;
16921
+ case "no-store":
16922
+ output[key] = true;
16923
+ break;
16114
16924
  default:
16115
16925
  continue;
16116
16926
  }
16117
16927
  }
16118
16928
  return output;
16119
16929
  }
16930
+ function splitVaryHeader(varyHeader) {
16931
+ const values = Array.isArray(varyHeader) ? varyHeader : [varyHeader];
16932
+ const output = [];
16933
+ for (let i = 0; i < values.length; i++) {
16934
+ const parts = values[i].split(",");
16935
+ for (let j = 0; j < parts.length; j++) {
16936
+ output.push(parts[j]);
16937
+ }
16938
+ }
16939
+ return output;
16940
+ }
16941
+ function hasVaryStar(varyHeader) {
16942
+ const values = splitVaryHeader(varyHeader);
16943
+ for (let i = 0; i < values.length; i++) {
16944
+ if (trimOWS(values[i]).indexOf("*") !== -1) {
16945
+ return true;
16946
+ }
16947
+ }
16948
+ return false;
16949
+ }
16120
16950
  function parseVaryHeader(varyHeader, headers) {
16121
- if (typeof varyHeader === "string" && varyHeader.includes("*")) {
16951
+ if (hasVaryStar(varyHeader)) {
16122
16952
  return headers;
16123
16953
  }
16124
16954
  const output = (
16125
16955
  /** @type {Record<string, string | string[] | null>} */
16126
16956
  {}
16127
16957
  );
16128
- const varyingHeaders = typeof varyHeader === "string" ? varyHeader.split(",") : varyHeader;
16958
+ const varyingHeaders = splitVaryHeader(varyHeader);
16129
16959
  for (const header of varyingHeaders) {
16130
- const trimmedHeader = header.trim().toLowerCase();
16131
- output[trimmedHeader] = headers[trimmedHeader] ?? null;
16960
+ const trimmedHeader = trimOWS(header).toLowerCase();
16961
+ if (trimmedHeader.length === 0) {
16962
+ continue;
16963
+ }
16964
+ if (!isValidHTTPToken(trimmedHeader)) {
16965
+ return void 0;
16966
+ }
16967
+ const headerValue = headers[trimmedHeader];
16968
+ output[trimmedHeader] = Array.isArray(headerValue) ? headerValue.slice() : headerValue ?? null;
16132
16969
  }
16133
16970
  return output;
16134
16971
  }
16972
+ function isInvalidOrWildcardVaryHeader(varyHeader) {
16973
+ return hasVaryStar(varyHeader) || parseVaryHeader(varyHeader, {}) === void 0;
16974
+ }
16135
16975
  function isEtagUsable(etag) {
16136
16976
  if (etag.length <= 2) {
16137
16977
  return false;
@@ -16162,7 +17002,7 @@ var require_cache = __commonJS({
16162
17002
  throw new TypeError(`${name} needs to have at least one method`);
16163
17003
  }
16164
17004
  for (const method of methods) {
16165
- if (!safeHTTPMethods.includes(method)) {
17005
+ if (!arrayIncludes(safeHTTPMethods, method)) {
16166
17006
  throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(", ")}, got ${method}`);
16167
17007
  }
16168
17008
  }
@@ -16186,7 +17026,10 @@ var require_cache = __commonJS({
16186
17026
  assertCacheKey,
16187
17027
  assertCacheValue,
16188
17028
  parseCacheControlHeader,
17029
+ hasInvalidCacheControlDirective,
16189
17030
  parseVaryHeader,
17031
+ hasVaryStar,
17032
+ isInvalidOrWildcardVaryHeader,
16190
17033
  isEtagUsable,
16191
17034
  assertCacheMethods,
16192
17035
  assertCacheStore,
@@ -16195,9 +17038,9 @@ var require_cache = __commonJS({
16195
17038
  }
16196
17039
  });
16197
17040
 
16198
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/date.js
17041
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/date.js
16199
17042
  var require_date = __commonJS({
16200
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/util/date.js"(exports, module) {
17043
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/util/date.js"(exports, module) {
16201
17044
  "use strict";
16202
17045
  init_esm_shims();
16203
17046
  function parseHttpDate(date) {
@@ -16210,6 +17053,13 @@ var require_date = __commonJS({
16210
17053
  return parseRfc850Date(date);
16211
17054
  }
16212
17055
  }
17056
+ function makeDate(year, monthIdx, day, hour, minute, second, weekday) {
17057
+ const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
17058
+ if (year >= 0 && year <= 99) {
17059
+ result.setUTCFullYear(year);
17060
+ }
17061
+ return result.getUTCFullYear() === year && result.getUTCMonth() === monthIdx && result.getUTCDate() === day && result.getUTCHours() === hour && result.getUTCMinutes() === minute && result.getUTCSeconds() === second && result.getUTCDay() === weekday ? result : void 0;
17062
+ }
16213
17063
  function parseImfDate(date) {
16214
17064
  if (date.length !== 29 || date[4] !== " " || date[7] !== " " || date[11] !== " " || date[16] !== " " || date[19] !== ":" || date[22] !== ":" || date[25] !== " " || date[26] !== "G" || date[27] !== "M" || date[28] !== "T") {
16215
17065
  return void 0;
@@ -16370,8 +17220,7 @@ var require_date = __commonJS({
16370
17220
  }
16371
17221
  second = (code1 - 48) * 10 + (code2 - 48);
16372
17222
  }
16373
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
16374
- return result.getUTCDay() === weekday ? result : void 0;
17223
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
16375
17224
  }
16376
17225
  function parseAscTimeDate(date) {
16377
17226
  if (date.length !== 24 || date[7] !== " " || date[10] !== " " || date[19] !== " ") {
@@ -16533,8 +17382,7 @@ var require_date = __commonJS({
16533
17382
  return void 0;
16534
17383
  }
16535
17384
  const year = (yearDigit1 - 48) * 1e3 + (yearDigit2 - 48) * 100 + (yearDigit3 - 48) * 10 + (yearDigit4 - 48);
16536
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
16537
- return result.getUTCDay() === weekday ? result : void 0;
17385
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
16538
17386
  }
16539
17387
  function parseRfc850Date(date) {
16540
17388
  let commaIndex = -1;
@@ -16683,8 +17531,7 @@ var require_date = __commonJS({
16683
17531
  }
16684
17532
  second = (code1 - 48) * 10 + (code2 - 48);
16685
17533
  }
16686
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
16687
- return result.getUTCDay() === weekday ? result : void 0;
17534
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
16688
17535
  }
16689
17536
  module.exports = {
16690
17537
  parseHttpDate
@@ -16692,15 +17539,18 @@ var require_date = __commonJS({
16692
17539
  }
16693
17540
  });
16694
17541
 
16695
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/cache-handler.js
17542
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/cache-handler.js
16696
17543
  var require_cache_handler = __commonJS({
16697
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/cache-handler.js"(exports, module) {
17544
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/cache-handler.js"(exports, module) {
16698
17545
  "use strict";
16699
17546
  init_esm_shims();
16700
17547
  var util = require_util();
16701
17548
  var {
16702
17549
  parseCacheControlHeader,
17550
+ hasInvalidCacheControlDirective,
16703
17551
  parseVaryHeader,
17552
+ hasVaryStar,
17553
+ isInvalidOrWildcardVaryHeader,
16704
17554
  isEtagUsable
16705
17555
  } = require_cache();
16706
17556
  var { parseHttpDate } = require_date();
@@ -16724,6 +17574,79 @@ var require_cache_handler = __commonJS({
16724
17574
  206
16725
17575
  ];
16726
17576
  var MAX_RESPONSE_AGE = 2147483647e3;
17577
+ var REVALIDATION_ONLY_RETENTION = 864e5;
17578
+ function trimOWS(value) {
17579
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
17580
+ }
17581
+ function arrayIncludes(array, value) {
17582
+ for (let i = 0; i < array.length; i++) {
17583
+ if (array[i] === value) {
17584
+ return true;
17585
+ }
17586
+ }
17587
+ return false;
17588
+ }
17589
+ function appendConnectionHeaderTokens(headersToRemove, connectionHeader) {
17590
+ const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
17591
+ for (let i = 0; i < values.length; i++) {
17592
+ const tokens = values[i].split(",");
17593
+ for (let j = 0; j < tokens.length; j++) {
17594
+ headersToRemove.push(trimOWS(tokens[j]).toLowerCase());
17595
+ }
17596
+ }
17597
+ }
17598
+ function getSameOriginPath(cacheKey, location) {
17599
+ if (typeof location !== "string") {
17600
+ return void 0;
17601
+ }
17602
+ let originUrl;
17603
+ let requestUrl;
17604
+ let locationUrl;
17605
+ try {
17606
+ originUrl = new URL(cacheKey.origin);
17607
+ requestUrl = new URL(cacheKey.path, originUrl);
17608
+ locationUrl = new URL(location, requestUrl);
17609
+ } catch {
17610
+ return void 0;
17611
+ }
17612
+ if (locationUrl.origin !== originUrl.origin) {
17613
+ return void 0;
17614
+ }
17615
+ return locationUrl.pathname + locationUrl.search;
17616
+ }
17617
+ function deleteCachedUri(store, cacheKey, path) {
17618
+ deleteCachedValue(store, {
17619
+ ...cacheKey,
17620
+ path
17621
+ });
17622
+ for (let i = 0; i < util.safeHTTPMethods.length; i++) {
17623
+ const method = util.safeHTTPMethods[i];
17624
+ if (method !== cacheKey.method) {
17625
+ deleteCachedValue(store, {
17626
+ ...cacheKey,
17627
+ method,
17628
+ path
17629
+ });
17630
+ }
17631
+ }
17632
+ }
17633
+ function deleteLocationTargets(store, cacheKey, headerValue) {
17634
+ if (headerValue === void 0) {
17635
+ return;
17636
+ }
17637
+ const values = Array.isArray(headerValue) ? headerValue : [headerValue];
17638
+ for (let i = 0; i < values.length; i++) {
17639
+ const path = getSameOriginPath(cacheKey, values[i]);
17640
+ if (path !== void 0) {
17641
+ deleteCachedUri(store, cacheKey, path);
17642
+ }
17643
+ }
17644
+ }
17645
+ function invalidateUnsafeRequest(store, cacheKey, resHeaders) {
17646
+ deleteCachedUri(store, cacheKey, cacheKey.path);
17647
+ deleteLocationTargets(store, cacheKey, resHeaders.location);
17648
+ deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
17649
+ }
16727
17650
  var CacheHandler = class {
16728
17651
  /**
16729
17652
  * @type {import('../../types/cache-interceptor.d.ts').default.CacheKey}
@@ -16783,35 +17706,51 @@ var require_cache_handler = __commonJS({
16783
17706
  statusMessage
16784
17707
  );
16785
17708
  const handler = this;
16786
- if (!util.safeHTTPMethods.includes(this.#cacheKey.method) && statusCode >= 200 && statusCode <= 399) {
16787
- try {
16788
- this.#store.delete(this.#cacheKey)?.catch?.(noop);
16789
- } catch {
16790
- }
17709
+ if (!arrayIncludes(util.safeHTTPMethods, this.#cacheKey.method) && statusCode >= 200 && statusCode <= 399) {
17710
+ invalidateUnsafeRequest(this.#store, this.#cacheKey, resHeaders);
16791
17711
  return downstreamOnHeaders();
16792
17712
  }
16793
17713
  const cacheControlHeader = resHeaders["cache-control"];
16794
- const heuristicallyCacheable = resHeaders["last-modified"] && HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode);
17714
+ const heuristicallyCacheable = resHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, statusCode);
16795
17715
  if (!cacheControlHeader && !resHeaders["expires"] && !heuristicallyCacheable && !this.#cacheByDefault) {
17716
+ if (statusCode === 304 && resHeaders.vary && isInvalidOrWildcardVaryHeader(resHeaders.vary)) {
17717
+ deleteCachedValue(this.#store, this.#cacheKey);
17718
+ }
16796
17719
  return downstreamOnHeaders();
16797
17720
  }
16798
17721
  const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
16799
17722
  if (!canCacheResponse(this.#cacheType, statusCode, resHeaders, cacheControlDirectives, this.#cacheKey.headers)) {
17723
+ if (statusCode === 304 && (cacheControlHeader || revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives))) {
17724
+ deleteCachedValue(this.#store, this.#cacheKey);
17725
+ }
16800
17726
  return downstreamOnHeaders();
16801
17727
  }
16802
17728
  const now = Date.now();
16803
- const resAge = resHeaders.age ? getAge(resHeaders.age) : void 0;
16804
- if (resAge && resAge >= MAX_RESPONSE_AGE) {
17729
+ const resAge = Object.hasOwn(resHeaders, "age") ? getAge(resHeaders.age) : void 0;
17730
+ if (resAge !== void 0 && resAge >= MAX_RESPONSE_AGE) {
17731
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
16805
17732
  return downstreamOnHeaders();
16806
17733
  }
16807
- const resDate = typeof resHeaders.date === "string" ? parseHttpDate(resHeaders.date) : void 0;
16808
- const staleAt = determineStaleAt(this.#cacheType, now, resAge, resHeaders, resDate, cacheControlDirectives) ?? this.#cacheByDefault;
16809
- if (staleAt === void 0 || resAge && resAge > staleAt) {
17734
+ const resDate = Object.hasOwn(resHeaders, "date") ? getDate(resHeaders.date) : void 0;
17735
+ if (resDate === null) {
17736
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
16810
17737
  return downstreamOnHeaders();
16811
17738
  }
16812
- const baseTime = resDate ? resDate.getTime() : now;
17739
+ const apparentAge = resDate ? Math.max(0, now - resDate.getTime()) : 0;
17740
+ const currentAge = Math.max(apparentAge, resAge ?? 0);
17741
+ const hasValidator = typeof resHeaders.etag === "string" && isEtagUsable(resHeaders.etag) || typeof resHeaders["last-modified"] === "string";
17742
+ const staleAt = determineStaleAt(this.#cacheType, now, resAge, resHeaders, resDate, cacheControlDirectives, hasValidator) ?? this.#cacheByDefault;
17743
+ const revalidationOnly = staleAt === 0 && hasValidator;
17744
+ if (staleAt === void 0 || currentAge >= staleAt && !revalidationOnly) {
17745
+ if (cacheControlHeader || staleAt !== void 0) {
17746
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
17747
+ }
17748
+ return downstreamOnHeaders();
17749
+ }
17750
+ const baseTime = now - currentAge;
16813
17751
  const absoluteStaleAt = staleAt + baseTime;
16814
- if (now >= absoluteStaleAt) {
17752
+ if (now >= absoluteStaleAt && !revalidationOnly) {
17753
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
16815
17754
  return downstreamOnHeaders();
16816
17755
  }
16817
17756
  let varyDirectives;
@@ -16821,8 +17760,8 @@ var require_cache_handler = __commonJS({
16821
17760
  return downstreamOnHeaders();
16822
17761
  }
16823
17762
  }
16824
- const cachedAt = resAge ? now - resAge : now;
16825
- const deleteAt = determineDeleteAt(baseTime, cachedAt, cacheControlDirectives, absoluteStaleAt);
17763
+ const cachedAt = baseTime;
17764
+ const deleteAt = determineDeleteAt(baseTime, now, cacheControlDirectives, absoluteStaleAt);
16826
17765
  const strippedHeaders = stripNecessaryHeaders(resHeaders, cacheControlDirectives);
16827
17766
  const value = {
16828
17767
  statusCode,
@@ -16842,6 +17781,7 @@ var require_cache_handler = __commonJS({
16842
17781
  value.statusCode = cachedValue.statusCode;
16843
17782
  value.statusMessage = cachedValue.statusMessage;
16844
17783
  value.etag = cachedValue.etag;
17784
+ value.vary = varyDirectives ?? cachedValue.vary;
16845
17785
  value.headers = { ...cachedValue.headers, ...strippedHeaders };
16846
17786
  downstreamOnHeaders();
16847
17787
  this.#writeStream = this.#store.createWriteStream(this.#cacheKey, value);
@@ -16932,11 +17872,25 @@ var require_cache_handler = __commonJS({
16932
17872
  this.#handler.onResponseError?.(controller, err);
16933
17873
  }
16934
17874
  };
17875
+ function deleteCachedValue(store, cacheKey) {
17876
+ try {
17877
+ store.delete(cacheKey)?.catch?.(noop);
17878
+ } catch {
17879
+ }
17880
+ }
17881
+ function deleteCachedValueIfNotModified(statusCode, store, cacheKey) {
17882
+ if (statusCode === 304) {
17883
+ deleteCachedValue(store, cacheKey);
17884
+ }
17885
+ }
17886
+ function revalidationResponseDisallowsCachedReuse(cacheType, resHeaders, cacheControlDirectives) {
17887
+ return cacheControlDirectives["no-store"] === true || cacheType === "shared" && cacheControlDirectives.private === true || (resHeaders.vary ? isInvalidOrWildcardVaryHeader(resHeaders.vary) : false);
17888
+ }
16935
17889
  function canCacheResponse(cacheType, statusCode, resHeaders, cacheControlDirectives, reqHeaders) {
16936
- if (statusCode < 200 || NOT_UNDERSTOOD_STATUS_CODES.includes(statusCode)) {
17890
+ if (statusCode < 200 || arrayIncludes(NOT_UNDERSTOOD_STATUS_CODES, statusCode)) {
16937
17891
  return false;
16938
17892
  }
16939
- if (!HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode) && !resHeaders["expires"] && !cacheControlDirectives.public && cacheControlDirectives["max-age"] === void 0 && // RFC 9111: a private response directive, if the cache is not shared
17893
+ if (!arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, statusCode) && !resHeaders["expires"] && !cacheControlDirectives.public && cacheControlDirectives["max-age"] === void 0 && // RFC 9111: a private response directive, if the cache is not shared
16940
17894
  !(cacheControlDirectives.private && cacheType === "private") && !(cacheControlDirectives["s-maxage"] !== void 0 && cacheType === "shared")) {
16941
17895
  return false;
16942
17896
  }
@@ -16946,60 +17900,104 @@ var require_cache_handler = __commonJS({
16946
17900
  if (cacheType === "shared" && cacheControlDirectives.private === true) {
16947
17901
  return false;
16948
17902
  }
16949
- if (resHeaders.vary?.includes("*")) {
17903
+ if (resHeaders.vary && hasVaryStar(resHeaders.vary)) {
16950
17904
  return false;
16951
17905
  }
16952
- if (reqHeaders?.authorization) {
17906
+ if (reqHeaders != null && Object.hasOwn(reqHeaders, "authorization")) {
16953
17907
  if (!cacheControlDirectives.public && !cacheControlDirectives["s-maxage"] && !cacheControlDirectives["must-revalidate"]) {
16954
17908
  return false;
16955
17909
  }
16956
17910
  if (typeof reqHeaders.authorization !== "string") {
16957
17911
  return false;
16958
17912
  }
16959
- if (Array.isArray(cacheControlDirectives["no-cache"]) && cacheControlDirectives["no-cache"].includes("authorization")) {
17913
+ if (Array.isArray(cacheControlDirectives["no-cache"]) && arrayIncludes(cacheControlDirectives["no-cache"], "authorization")) {
16960
17914
  return false;
16961
17915
  }
16962
- if (Array.isArray(cacheControlDirectives["private"]) && cacheControlDirectives["private"].includes("authorization")) {
17916
+ if (Array.isArray(cacheControlDirectives["private"]) && arrayIncludes(cacheControlDirectives["private"], "authorization")) {
16963
17917
  return false;
16964
17918
  }
16965
17919
  }
16966
17920
  return true;
16967
17921
  }
17922
+ function getDate(dateHeader) {
17923
+ let dateValue = dateHeader;
17924
+ if (Array.isArray(dateValue)) {
17925
+ if (dateValue.length !== 1) {
17926
+ return null;
17927
+ }
17928
+ dateValue = dateValue[0];
17929
+ }
17930
+ if (typeof dateValue !== "string") {
17931
+ return null;
17932
+ }
17933
+ return parseHttpDate(dateValue);
17934
+ }
16968
17935
  function getAge(ageHeader) {
16969
- const age = parseInt(Array.isArray(ageHeader) ? ageHeader[0] : ageHeader);
16970
- return isNaN(age) ? void 0 : age * 1e3;
17936
+ let ageValue = ageHeader;
17937
+ if (Array.isArray(ageValue)) {
17938
+ if (ageValue.length !== 1) {
17939
+ return MAX_RESPONSE_AGE;
17940
+ }
17941
+ ageValue = ageValue[0];
17942
+ }
17943
+ if (typeof ageValue !== "string" || !/^[\t ]*[0-9]+[\t ]*$/.test(ageValue)) {
17944
+ return MAX_RESPONSE_AGE;
17945
+ }
17946
+ const age = BigInt(ageValue.replace(/^[\t ]+|[\t ]+$/g, ""));
17947
+ if (age >= BigInt(MAX_RESPONSE_AGE / 1e3)) {
17948
+ return MAX_RESPONSE_AGE;
17949
+ }
17950
+ return Number(age) * 1e3;
16971
17951
  }
16972
- function determineStaleAt(cacheType, now, age, resHeaders, responseDate, cacheControlDirectives) {
17952
+ function determineStaleAt(cacheType, now, age, resHeaders, responseDate, cacheControlDirectives, hasValidator) {
16973
17953
  if (cacheType === "shared") {
17954
+ if (hasInvalidCacheControlDirective(cacheControlDirectives, "s-maxage")) {
17955
+ return 0;
17956
+ }
16974
17957
  const sMaxAge = cacheControlDirectives["s-maxage"];
16975
17958
  if (sMaxAge !== void 0) {
16976
- return sMaxAge > 0 ? sMaxAge * 1e3 : void 0;
17959
+ if (sMaxAge > 0) {
17960
+ return sMaxAge * 1e3;
17961
+ }
17962
+ return 0;
16977
17963
  }
16978
17964
  }
17965
+ if (hasInvalidCacheControlDirective(cacheControlDirectives, "max-age")) {
17966
+ return 0;
17967
+ }
16979
17968
  const maxAge = cacheControlDirectives["max-age"];
16980
17969
  if (maxAge !== void 0) {
16981
- return maxAge > 0 ? maxAge * 1e3 : void 0;
17970
+ if (maxAge > 0) {
17971
+ return maxAge * 1e3;
17972
+ }
17973
+ return 0;
16982
17974
  }
16983
- if (typeof resHeaders.expires === "string") {
17975
+ if (Object.hasOwn(resHeaders, "expires")) {
17976
+ if (typeof resHeaders.expires !== "string") {
17977
+ return 0;
17978
+ }
16984
17979
  const expiresDate = parseHttpDate(resHeaders.expires);
16985
- if (expiresDate) {
16986
- if (now >= expiresDate.getTime()) {
16987
- return void 0;
17980
+ if (!expiresDate) {
17981
+ return 0;
17982
+ }
17983
+ if (now >= expiresDate.getTime()) {
17984
+ return 0;
17985
+ }
17986
+ if (responseDate) {
17987
+ if (responseDate >= expiresDate) {
17988
+ return 0;
16988
17989
  }
16989
- if (responseDate) {
16990
- if (responseDate >= expiresDate) {
16991
- return void 0;
16992
- }
16993
- if (age !== void 0 && age > expiresDate - responseDate) {
16994
- return void 0;
16995
- }
17990
+ const freshnessLifetime = expiresDate.getTime() - responseDate.getTime();
17991
+ if (age !== void 0 && age >= freshnessLifetime) {
17992
+ return 0;
16996
17993
  }
16997
- return expiresDate.getTime() - now;
17994
+ return freshnessLifetime;
16998
17995
  }
17996
+ return expiresDate.getTime() - now;
16999
17997
  }
17000
17998
  if (typeof resHeaders["last-modified"] === "string") {
17001
- const lastModified = new Date(resHeaders["last-modified"]);
17002
- if (isValidDate(lastModified)) {
17999
+ const lastModified = parseHttpDate(resHeaders["last-modified"]);
18000
+ if (lastModified) {
17003
18001
  if (lastModified.getTime() >= now) {
17004
18002
  return void 0;
17005
18003
  }
@@ -17010,6 +18008,9 @@ var require_cache_handler = __commonJS({
17010
18008
  if (cacheControlDirectives.immutable) {
17011
18009
  return 31536e6;
17012
18010
  }
18011
+ if (cacheControlDirectives["no-cache"] === true && hasValidator) {
18012
+ return 0;
18013
+ }
17013
18014
  return void 0;
17014
18015
  }
17015
18016
  function determineDeleteAt(baseTime, cachedAt, cacheControlDirectives, staleAt) {
@@ -17027,6 +18028,9 @@ var require_cache_handler = __commonJS({
17027
18028
  }
17028
18029
  if (staleWhileRevalidate === -Infinity && staleIfError === -Infinity && immutable === -Infinity) {
17029
18030
  const freshnessLifetime = staleAt - baseTime;
18031
+ if (freshnessLifetime <= 0) {
18032
+ return cachedAt + REVALIDATION_ONLY_RETENTION;
18033
+ }
17030
18034
  const datePrecisionPadding = Math.min(Math.max(cachedAt - baseTime, 0), 1e3);
17031
18035
  return staleAt + freshnessLifetime + datePrecisionPadding;
17032
18036
  }
@@ -17046,11 +18050,7 @@ var require_cache_handler = __commonJS({
17046
18050
  "age"
17047
18051
  ];
17048
18052
  if (resHeaders["connection"]) {
17049
- if (Array.isArray(resHeaders["connection"])) {
17050
- headersToRemove.push(...resHeaders["connection"].map((header) => header.trim()));
17051
- } else {
17052
- headersToRemove.push(...resHeaders["connection"].split(",").map((header) => header.trim()));
17053
- }
18053
+ appendConnectionHeaderTokens(headersToRemove, resHeaders["connection"]);
17054
18054
  }
17055
18055
  if (Array.isArray(cacheControlDirectives["no-cache"])) {
17056
18056
  headersToRemove.push(...cacheControlDirectives["no-cache"]);
@@ -17060,23 +18060,20 @@ var require_cache_handler = __commonJS({
17060
18060
  }
17061
18061
  let strippedHeaders;
17062
18062
  for (const headerName of headersToRemove) {
17063
- if (resHeaders[headerName]) {
18063
+ if (Object.hasOwn(resHeaders, headerName)) {
17064
18064
  strippedHeaders ??= { ...resHeaders };
17065
18065
  delete strippedHeaders[headerName];
17066
18066
  }
17067
18067
  }
17068
18068
  return strippedHeaders ?? resHeaders;
17069
18069
  }
17070
- function isValidDate(date) {
17071
- return date instanceof Date && Number.isFinite(date.valueOf());
17072
- }
17073
18070
  module.exports = CacheHandler;
17074
18071
  }
17075
18072
  });
17076
18073
 
17077
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/cache/memory-cache-store.js
18074
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/cache/memory-cache-store.js
17078
18075
  var require_memory_cache_store = __commonJS({
17079
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/cache/memory-cache-store.js"(exports, module) {
18076
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/cache/memory-cache-store.js"(exports, module) {
17080
18077
  "use strict";
17081
18078
  init_esm_shims();
17082
18079
  var { Writable } = __require("stream");
@@ -17241,27 +18238,58 @@ var require_memory_cache_store = __commonJS({
17241
18238
  }
17242
18239
  };
17243
18240
  function findEntry(key, entries, now) {
17244
- return entries.find((entry) => entry.deleteAt > now && entry.method === key.method && (entry.vary == null || Object.keys(entry.vary).every((headerName) => {
17245
- if (entry.vary[headerName] === null) {
17246
- return key.headers[headerName] === void 0;
18241
+ for (let i = 0; i < entries.length; i++) {
18242
+ const entry = entries[i];
18243
+ if (entry.deleteAt > now && entry.method === key.method && varyMatches(key, entry)) {
18244
+ return entry;
18245
+ }
18246
+ }
18247
+ }
18248
+ function varyMatches(key, entry) {
18249
+ if (entry.vary == null) {
18250
+ return true;
18251
+ }
18252
+ for (const headerName in entry.vary) {
18253
+ if (Object.hasOwn(entry.vary, headerName) && !headerValueEquals(key.headers?.[headerName], entry.vary[headerName])) {
18254
+ return false;
18255
+ }
18256
+ }
18257
+ return true;
18258
+ }
18259
+ function headerValueEquals(lhs, rhs) {
18260
+ if (lhs == null && rhs == null) {
18261
+ return true;
18262
+ }
18263
+ if (lhs == null && rhs != null || lhs != null && rhs == null) {
18264
+ return false;
18265
+ }
18266
+ if (Array.isArray(lhs) && Array.isArray(rhs)) {
18267
+ if (lhs.length !== rhs.length) {
18268
+ return false;
18269
+ }
18270
+ for (let i = 0; i < lhs.length; i++) {
18271
+ if (lhs[i] !== rhs[i]) {
18272
+ return false;
18273
+ }
17247
18274
  }
17248
- return entry.vary[headerName] === key.headers[headerName];
17249
- })));
18275
+ return true;
18276
+ }
18277
+ return lhs === rhs;
17250
18278
  }
17251
18279
  module.exports = MemoryCacheStore;
17252
18280
  }
17253
18281
  });
17254
18282
 
17255
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/cache-revalidation-handler.js
18283
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/cache-revalidation-handler.js
17256
18284
  var require_cache_revalidation_handler = __commonJS({
17257
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/cache-revalidation-handler.js"(exports, module) {
18285
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/cache-revalidation-handler.js"(exports, module) {
17258
18286
  "use strict";
17259
18287
  init_esm_shims();
17260
18288
  var assert = __require("assert");
17261
18289
  var CacheRevalidationHandler = class {
17262
18290
  #successful = false;
17263
18291
  /**
17264
- * @type {((boolean, any) => void) | null}
18292
+ * @type {((success: boolean, context?: any, statusCode?: number, headers?: import('../../types/header.d.ts').IncomingHttpHeaders) => void) | null}
17265
18293
  */
17266
18294
  #callback;
17267
18295
  /**
@@ -17274,7 +18302,7 @@ var require_cache_revalidation_handler = __commonJS({
17274
18302
  */
17275
18303
  #allowErrorStatusCodes;
17276
18304
  /**
17277
- * @param {(boolean) => void} callback Function to call if the cached value is valid
18305
+ * @param {(success: boolean, context?: any, statusCode?: number, headers?: import('../../types/header.d.ts').IncomingHttpHeaders) => void} callback Function to call if the cached value is valid
17278
18306
  * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler
17279
18307
  * @param {boolean} allowErrorStatusCodes
17280
18308
  */
@@ -17296,7 +18324,7 @@ var require_cache_revalidation_handler = __commonJS({
17296
18324
  onResponseStart(controller, statusCode, headers, statusMessage) {
17297
18325
  assert(this.#callback != null);
17298
18326
  this.#successful = statusCode === 304 || this.#allowErrorStatusCodes && statusCode >= 500 && statusCode <= 504;
17299
- this.#callback(this.#successful, this.#context);
18327
+ this.#callback(this.#successful, this.#context, statusCode, headers);
17300
18328
  this.#callback = null;
17301
18329
  if (this.#successful) {
17302
18330
  return true;
@@ -17326,6 +18354,12 @@ var require_cache_revalidation_handler = __commonJS({
17326
18354
  return;
17327
18355
  }
17328
18356
  if (this.#callback) {
18357
+ if (this.#allowErrorStatusCodes) {
18358
+ this.#successful = true;
18359
+ this.#callback(true, this.#context);
18360
+ this.#callback = null;
18361
+ return;
18362
+ }
17329
18363
  this.#callback(false);
17330
18364
  this.#callback = null;
17331
18365
  }
@@ -17340,9 +18374,9 @@ var require_cache_revalidation_handler = __commonJS({
17340
18374
  }
17341
18375
  });
17342
18376
 
17343
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/cache.js
18377
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/cache.js
17344
18378
  var require_cache2 = __commonJS({
17345
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/cache.js"(exports, module) {
18379
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/cache.js"(exports, module) {
17346
18380
  "use strict";
17347
18381
  init_esm_shims();
17348
18382
  var assert = __require("assert");
@@ -17351,8 +18385,9 @@ var require_cache2 = __commonJS({
17351
18385
  var CacheHandler = require_cache_handler();
17352
18386
  var MemoryCacheStore = require_memory_cache_store();
17353
18387
  var CacheRevalidationHandler = require_cache_revalidation_handler();
17354
- var { assertCacheStore, assertCacheMethods, makeCacheKey, normalizeHeaders, parseCacheControlHeader } = require_cache();
18388
+ var { assertCacheStore, assertCacheMethods, makeCacheKey, normalizeHeaders, parseCacheControlHeader, isInvalidOrWildcardVaryHeader } = require_cache();
17355
18389
  var { AbortError } = require_errors();
18390
+ var { parseHttpDate } = require_date();
17356
18391
  function assertCacheOrigins(origins, name) {
17357
18392
  if (origins === void 0) return;
17358
18393
  if (!Array.isArray(origins)) {
@@ -17367,6 +18402,37 @@ var require_cache2 = __commonJS({
17367
18402
  }
17368
18403
  var nop = () => {
17369
18404
  };
18405
+ function trimOWS(value) {
18406
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
18407
+ }
18408
+ function arrayIncludes(array, value) {
18409
+ for (let i = 0; i < array.length; i++) {
18410
+ if (array[i] === value) {
18411
+ return true;
18412
+ }
18413
+ }
18414
+ return false;
18415
+ }
18416
+ function hasPragmaNoCache(headers) {
18417
+ const pragma = headers?.pragma;
18418
+ if (!pragma) {
18419
+ return false;
18420
+ }
18421
+ const values = Array.isArray(pragma) ? pragma : [pragma];
18422
+ for (let i = 0; i < values.length; i++) {
18423
+ const value = values[i];
18424
+ if (typeof value !== "string") {
18425
+ continue;
18426
+ }
18427
+ const directives = value.split(",");
18428
+ for (let j = 0; j < directives.length; j++) {
18429
+ if (trimOWS(directives[j]).toLowerCase() === "no-cache") {
18430
+ return true;
18431
+ }
18432
+ }
18433
+ }
18434
+ return false;
18435
+ }
17370
18436
  function needsRevalidation(result, cacheControlDirectives, { headers = {} }) {
17371
18437
  if (cacheControlDirectives?.["no-cache"]) {
17372
18438
  return true;
@@ -17379,10 +18445,58 @@ var require_cache2 = __commonJS({
17379
18445
  }
17380
18446
  return false;
17381
18447
  }
17382
- function isStale(result, cacheControlDirectives) {
18448
+ function staleResponseRequiresRevalidation(result, cacheType) {
18449
+ return result.cacheControlDirectives?.["must-revalidate"] === true || cacheType === "shared" && (result.cacheControlDirectives?.["proxy-revalidate"] === true || // https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2.10
18450
+ // s-maxage implies proxy-revalidate for shared caches.
18451
+ result.cacheControlDirectives?.["s-maxage"] !== void 0);
18452
+ }
18453
+ function revalidationResponseDisallowsCachedReuse(cacheType, headers) {
18454
+ if (headers.vary && isInvalidOrWildcardVaryHeader(headers.vary)) {
18455
+ return true;
18456
+ }
18457
+ const cacheControl = headers["cache-control"];
18458
+ if (!cacheControl) {
18459
+ return false;
18460
+ }
18461
+ const cacheControlDirectives = parseCacheControlHeader(cacheControl);
18462
+ return cacheControlDirectives["no-store"] === true || cacheType === "shared" && cacheControlDirectives.private === true;
18463
+ }
18464
+ function revalidationResponseUpdatesCacheControl(headers) {
18465
+ return headers["cache-control"] !== void 0;
18466
+ }
18467
+ function deleteCachedValue(store, cacheKey) {
18468
+ try {
18469
+ store.delete(cacheKey)?.catch?.(nop);
18470
+ } catch {
18471
+ }
18472
+ }
18473
+ function getUsableLastModified(headers) {
18474
+ const lastModified = headers?.["last-modified"];
18475
+ if (typeof lastModified === "string" && parseHttpDate(lastModified)) {
18476
+ return lastModified;
18477
+ }
18478
+ }
18479
+ function makeRevalidationHeaders(opts, result) {
18480
+ const headers = {
18481
+ ...opts.headers,
18482
+ "if-modified-since": getUsableLastModified(result.headers) ?? new Date(result.cachedAt).toUTCString()
18483
+ };
18484
+ if (result.etag) {
18485
+ headers["if-none-match"] = result.etag;
18486
+ }
18487
+ if (result.vary) {
18488
+ for (const key in result.vary) {
18489
+ if (result.vary[key] != null) {
18490
+ headers[key] = result.vary[key];
18491
+ }
18492
+ }
18493
+ }
18494
+ return headers;
18495
+ }
18496
+ function isStale(result, cacheControlDirectives, cacheType) {
17383
18497
  const now = Date.now();
17384
18498
  if (now > result.staleAt) {
17385
- if (cacheControlDirectives?.["max-stale"]) {
18499
+ if (!staleResponseRequiresRevalidation(result, cacheType) && cacheControlDirectives?.["max-stale"]) {
17386
18500
  const gracePeriod = result.staleAt + cacheControlDirectives["max-stale"] * 1e3;
17387
18501
  return now > gracePeriod;
17388
18502
  }
@@ -17395,9 +18509,9 @@ var require_cache2 = __commonJS({
17395
18509
  }
17396
18510
  return false;
17397
18511
  }
17398
- function withinStaleWhileRevalidateWindow(result) {
18512
+ function withinStaleWhileRevalidateWindow(result, cacheType) {
17399
18513
  const staleWhileRevalidate = result.cacheControlDirectives?.["stale-while-revalidate"];
17400
- if (!staleWhileRevalidate) {
18514
+ if (!staleWhileRevalidate || staleResponseRequiresRevalidation(result, cacheType)) {
17401
18515
  return false;
17402
18516
  }
17403
18517
  const now = Date.now();
@@ -17507,32 +18621,17 @@ var require_cache2 = __commonJS({
17507
18621
  return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17508
18622
  }
17509
18623
  const age = Math.round((now - result.cachedAt) / 1e3);
17510
- if (reqCacheControl?.["max-age"] && age >= reqCacheControl["max-age"]) {
17511
- return dispatch(opts, handler);
17512
- }
17513
- const stale = isStale(result, reqCacheControl);
17514
- const revalidate = needsRevalidation(result, reqCacheControl, opts);
18624
+ const requestMaxAgeExpired = reqCacheControl?.["max-age"] !== void 0 && age >= reqCacheControl["max-age"];
18625
+ const stale = requestMaxAgeExpired || isStale(result, reqCacheControl, globalOpts.type);
18626
+ const revalidate = requestMaxAgeExpired || needsRevalidation(result, reqCacheControl, opts);
17515
18627
  if (stale || revalidate) {
17516
18628
  if (util.isStream(opts.body) && util.bodyLength(opts.body) !== 0) {
17517
18629
  return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
17518
18630
  }
17519
- if (!revalidate && withinStaleWhileRevalidateWindow(result)) {
18631
+ if (!revalidate && withinStaleWhileRevalidateWindow(result, globalOpts.type)) {
17520
18632
  sendCachedValue(handler, opts, result, age, null, true);
17521
18633
  queueMicrotask(() => {
17522
- const headers2 = {
17523
- ...opts.headers,
17524
- "if-modified-since": new Date(result.cachedAt).toUTCString()
17525
- };
17526
- if (result.etag) {
17527
- headers2["if-none-match"] = result.etag;
17528
- }
17529
- if (result.vary) {
17530
- for (const key in result.vary) {
17531
- if (result.vary[key] != null) {
17532
- headers2[key] = result.vary[key];
17533
- }
17534
- }
17535
- }
18634
+ const headers2 = makeRevalidationHeaders(opts, result);
17536
18635
  dispatch(
17537
18636
  {
17538
18637
  ...opts,
@@ -17558,32 +18657,33 @@ var require_cache2 = __commonJS({
17558
18657
  return true;
17559
18658
  }
17560
18659
  let withinStaleIfErrorThreshold = false;
17561
- const staleIfErrorExpiry = result.cacheControlDirectives["stale-if-error"] ?? reqCacheControl?.["stale-if-error"];
17562
- if (staleIfErrorExpiry) {
17563
- withinStaleIfErrorThreshold = now < result.staleAt + staleIfErrorExpiry * 1e3;
17564
- }
17565
- const headers = {
17566
- ...opts.headers,
17567
- "if-modified-since": new Date(result.cachedAt).toUTCString()
17568
- };
17569
- if (result.etag) {
17570
- headers["if-none-match"] = result.etag;
17571
- }
17572
- if (result.vary) {
17573
- for (const key in result.vary) {
17574
- if (result.vary[key] != null) {
17575
- headers[key] = result.vary[key];
17576
- }
18660
+ if (!staleResponseRequiresRevalidation(result, globalOpts.type)) {
18661
+ const staleIfErrorExpiry = result.cacheControlDirectives["stale-if-error"] ?? reqCacheControl?.["stale-if-error"];
18662
+ if (staleIfErrorExpiry) {
18663
+ withinStaleIfErrorThreshold = now < result.staleAt + staleIfErrorExpiry * 1e3;
17577
18664
  }
17578
18665
  }
18666
+ const headers = makeRevalidationHeaders(opts, result);
17579
18667
  return dispatch(
17580
18668
  {
17581
18669
  ...opts,
17582
18670
  headers
17583
18671
  },
17584
18672
  new CacheRevalidationHandler(
17585
- (success, context) => {
18673
+ (success, context, statusCode, headers2) => {
17586
18674
  if (success) {
18675
+ if (statusCode === 304) {
18676
+ if (revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
18677
+ if (util.isStream(result.body)) {
18678
+ result.body.on("error", nop).destroy();
18679
+ }
18680
+ deleteCachedValue(globalOpts.store, cacheKey);
18681
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
18682
+ }
18683
+ if (revalidationResponseUpdatesCacheControl(headers2)) {
18684
+ deleteCachedValue(globalOpts.store, cacheKey);
18685
+ }
18686
+ }
17587
18687
  sendCachedValue(handler, opts, result, age, context, stale);
17588
18688
  } else if (util.isStream(result.body)) {
17589
18689
  result.body.on("error", nop).destroy();
@@ -17625,13 +18725,22 @@ var require_cache2 = __commonJS({
17625
18725
  cacheByDefault,
17626
18726
  type
17627
18727
  };
17628
- const safeMethodsToNotCache = util.safeHTTPMethods.filter((method) => methods.includes(method) === false);
18728
+ const safeMethodsToNotCache = [];
18729
+ for (let i = 0; i < util.safeHTTPMethods.length; i++) {
18730
+ const method = util.safeHTTPMethods[i];
18731
+ if (!arrayIncludes(methods, method)) {
18732
+ safeMethodsToNotCache.push(method);
18733
+ }
18734
+ }
17629
18735
  return (dispatch) => {
17630
18736
  return (opts2, handler) => {
17631
- if (!opts2.origin || safeMethodsToNotCache.includes(opts2.method)) {
18737
+ if (arrayIncludes(safeMethodsToNotCache, opts2.method)) {
17632
18738
  return dispatch(opts2, handler);
17633
18739
  }
17634
18740
  if (origins !== void 0) {
18741
+ if (!opts2.origin) {
18742
+ return dispatch(opts2, handler);
18743
+ }
17635
18744
  const requestOrigin = opts2.origin.toString().toLowerCase();
17636
18745
  let isAllowed = false;
17637
18746
  for (let i = 0; i < origins.length; i++) {
@@ -17654,7 +18763,7 @@ var require_cache2 = __commonJS({
17654
18763
  ...opts2,
17655
18764
  headers: normalizeHeaders(opts2)
17656
18765
  };
17657
- const reqCacheControl = opts2.headers?.["cache-control"] ? parseCacheControlHeader(opts2.headers["cache-control"]) : void 0;
18766
+ const reqCacheControl = opts2.headers?.["cache-control"] ? parseCacheControlHeader(opts2.headers["cache-control"]) : hasPragmaNoCache(opts2.headers) ? { "no-cache": true } : void 0;
17658
18767
  if (reqCacheControl?.["no-store"]) {
17659
18768
  return dispatch(opts2, handler);
17660
18769
  }
@@ -17687,9 +18796,9 @@ var require_cache2 = __commonJS({
17687
18796
  }
17688
18797
  });
17689
18798
 
17690
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/decompress.js
18799
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/decompress.js
17691
18800
  var require_decompress = __commonJS({
17692
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/decompress.js"(exports, module) {
18801
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/decompress.js"(exports, module) {
17693
18802
  "use strict";
17694
18803
  init_esm_shims();
17695
18804
  var { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = __require("zlib");
@@ -17715,6 +18824,8 @@ var require_decompress = __commonJS({
17715
18824
  var DecompressHandler = class extends DecoratorHandler {
17716
18825
  /** @type {Transform[]} */
17717
18826
  #decompressors = [];
18827
+ /** @type {Record<string, string | string[]> | undefined} */
18828
+ #trailers;
17718
18829
  /** @type {Readonly<number[]>} */
17719
18830
  #skipStatusCodes;
17720
18831
  /** @type {boolean} */
@@ -17790,7 +18901,7 @@ var require_decompress = __commonJS({
17790
18901
  const decompressor = this.#decompressors[0];
17791
18902
  this.#setupDecompressorEvents(decompressor, controller);
17792
18903
  decompressor.on("end", () => {
17793
- super.onResponseEnd(controller, {});
18904
+ super.onResponseEnd(controller, this.#trailers);
17794
18905
  });
17795
18906
  }
17796
18907
  /**
@@ -17806,7 +18917,7 @@ var require_decompress = __commonJS({
17806
18917
  super.onResponseError(controller, err);
17807
18918
  return;
17808
18919
  }
17809
- super.onResponseEnd(controller, {});
18920
+ super.onResponseEnd(controller, this.#trailers);
17810
18921
  });
17811
18922
  }
17812
18923
  /**
@@ -17884,6 +18995,7 @@ var require_decompress = __commonJS({
17884
18995
  */
17885
18996
  onResponseEnd(controller, trailers) {
17886
18997
  if (this.#decompressors.length > 0) {
18998
+ this.#trailers = trailers;
17887
18999
  this.#decompressors[0].end();
17888
19000
  this.#cleanupDecompressors();
17889
19001
  return;
@@ -17915,6 +19027,9 @@ var require_decompress = __commonJS({
17915
19027
  }
17916
19028
  return (dispatch) => {
17917
19029
  return (opts, handler) => {
19030
+ if (opts.method === "HEAD") {
19031
+ return dispatch(opts, handler);
19032
+ }
17918
19033
  const decompressHandler = new DecompressHandler(handler, options);
17919
19034
  return dispatch(opts, decompressHandler);
17920
19035
  };
@@ -17924,9 +19039,9 @@ var require_decompress = __commonJS({
17924
19039
  }
17925
19040
  });
17926
19041
 
17927
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/deduplication-handler.js
19042
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/deduplication-handler.js
17928
19043
  var require_deduplication_handler = __commonJS({
17929
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/handler/deduplication-handler.js"(exports, module) {
19044
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/handler/deduplication-handler.js"(exports, module) {
17930
19045
  "use strict";
17931
19046
  init_esm_shims();
17932
19047
  var { RequestAbortedError } = require_errors();
@@ -18284,9 +19399,9 @@ var require_deduplication_handler = __commonJS({
18284
19399
  }
18285
19400
  });
18286
19401
 
18287
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/deduplicate.js
19402
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/deduplicate.js
18288
19403
  var require_deduplicate = __commonJS({
18289
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/interceptor/deduplicate.js"(exports, module) {
19404
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/interceptor/deduplicate.js"(exports, module) {
18290
19405
  "use strict";
18291
19406
  init_esm_shims();
18292
19407
  var diagnosticsChannel = __require("diagnostics_channel");
@@ -18326,7 +19441,7 @@ var require_deduplicate = __commonJS({
18326
19441
  const pendingRequests = /* @__PURE__ */ new Map();
18327
19442
  return (dispatch) => {
18328
19443
  return (opts2, handler) => {
18329
- if (!opts2.origin || methods.includes(opts2.method) === false) {
19444
+ if (opts2.upgrade || methods.includes(opts2.method) === false) {
18330
19445
  return dispatch(opts2, handler);
18331
19446
  }
18332
19447
  opts2 = {
@@ -18370,9 +19485,9 @@ var require_deduplicate = __commonJS({
18370
19485
  }
18371
19486
  });
18372
19487
 
18373
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/cache/sqlite-cache-store.js
19488
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/cache/sqlite-cache-store.js
18374
19489
  var require_sqlite_cache_store = __commonJS({
18375
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/cache/sqlite-cache-store.js"(exports, module) {
19490
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/cache/sqlite-cache-store.js"(exports, module) {
18376
19491
  "use strict";
18377
19492
  init_esm_shims();
18378
19493
  var { Writable } = __require("stream");
@@ -18725,16 +19840,21 @@ var require_sqlite_cache_store = __commonJS({
18725
19840
  if (lhs.length !== rhs.length) {
18726
19841
  return false;
18727
19842
  }
18728
- return lhs.every((x, i) => x === rhs[i]);
19843
+ for (let i = 0; i < lhs.length; i++) {
19844
+ if (lhs[i] !== rhs[i]) {
19845
+ return false;
19846
+ }
19847
+ }
19848
+ return true;
18729
19849
  }
18730
19850
  return lhs === rhs;
18731
19851
  }
18732
19852
  }
18733
19853
  });
18734
19854
 
18735
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/headers.js
19855
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/headers.js
18736
19856
  var require_headers = __commonJS({
18737
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/headers.js"(exports, module) {
19857
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/headers.js"(exports, module) {
18738
19858
  "use strict";
18739
19859
  init_esm_shims();
18740
19860
  var { kConstruct } = require_symbols();
@@ -19194,9 +20314,9 @@ var require_headers = __commonJS({
19194
20314
  }
19195
20315
  });
19196
20316
 
19197
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/response.js
20317
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/response.js
19198
20318
  var require_response = __commonJS({
19199
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/response.js"(exports, module) {
20319
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/response.js"(exports, module) {
19200
20320
  "use strict";
19201
20321
  init_esm_shims();
19202
20322
  var { Headers, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = require_headers();
@@ -19233,9 +20353,7 @@ var require_response = __commonJS({
19233
20353
  // https://fetch.spec.whatwg.org/#dom-response-json
19234
20354
  static json(data, init = void 0) {
19235
20355
  webidl.argumentLengthCheck(arguments, 1, "Response.json");
19236
- if (init !== null) {
19237
- init = webidl.converters.ResponseInit(init);
19238
- }
20356
+ init = webidl.converters.ResponseInit(init);
19239
20357
  const bytes = textEncoder.encode(
19240
20358
  serializeJavascriptValueToJSONString(data)
19241
20359
  );
@@ -19617,9 +20735,9 @@ var require_response = __commonJS({
19617
20735
  }
19618
20736
  });
19619
20737
 
19620
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/request.js
20738
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/request.js
19621
20739
  var require_request2 = __commonJS({
19622
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/request.js"(exports, module) {
20740
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/request.js"(exports, module) {
19623
20741
  "use strict";
19624
20742
  init_esm_shims();
19625
20743
  var { extractBody, mixinBody, cloneBody, bodyUnusable } = require_body();
@@ -20396,9 +21514,9 @@ var require_request2 = __commonJS({
20396
21514
  }
20397
21515
  });
20398
21516
 
20399
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js
21517
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js
20400
21518
  var require_subresource_integrity = __commonJS({
20401
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js"(exports, module) {
21519
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js"(exports, module) {
20402
21520
  "use strict";
20403
21521
  init_esm_shims();
20404
21522
  var assert = __require("assert");
@@ -20536,9 +21654,9 @@ var require_subresource_integrity = __commonJS({
20536
21654
  }
20537
21655
  });
20538
21656
 
20539
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/index.js
21657
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/index.js
20540
21658
  var require_fetch = __commonJS({
20541
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/fetch/index.js"(exports, module) {
21659
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/fetch/index.js"(exports, module) {
20542
21660
  "use strict";
20543
21661
  init_esm_shims();
20544
21662
  var {
@@ -21223,7 +22341,12 @@ var require_fetch = __commonJS({
21223
22341
  httpFetchParams = fetchParams;
21224
22342
  httpRequest = request;
21225
22343
  } else {
21226
- httpRequest = cloneRequest(request);
22344
+ if (request.body?.source != null) {
22345
+ httpRequest = cloneRequest(request);
22346
+ } else {
22347
+ httpRequest = cloneRequest({ ...request, body: null });
22348
+ httpRequest.body = request.body;
22349
+ }
21227
22350
  httpFetchParams = { ...fetchParams };
21228
22351
  httpFetchParams.request = httpRequest;
21229
22352
  }
@@ -21268,7 +22391,7 @@ var require_fetch = __commonJS({
21268
22391
  }
21269
22392
  if (!httpRequest.headersList.contains("accept-encoding", true)) {
21270
22393
  if (urlHasHttpsScheme(requestCurrentURL(httpRequest))) {
21271
- httpRequest.headersList.append("accept-encoding", "br, gzip, deflate", true);
22394
+ httpRequest.headersList.append("accept-encoding", "br, gzip, deflate, zstd", true);
21272
22395
  } else {
21273
22396
  httpRequest.headersList.append("accept-encoding", "gzip, deflate", true);
21274
22397
  }
@@ -21680,9 +22803,9 @@ var require_fetch = __commonJS({
21680
22803
  }
21681
22804
  });
21682
22805
 
21683
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/util.js
22806
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/util.js
21684
22807
  var require_util3 = __commonJS({
21685
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/util.js"(exports, module) {
22808
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/util.js"(exports, module) {
21686
22809
  "use strict";
21687
22810
  init_esm_shims();
21688
22811
  var assert = __require("assert");
@@ -21711,9 +22834,9 @@ var require_util3 = __commonJS({
21711
22834
  }
21712
22835
  });
21713
22836
 
21714
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/cache.js
22837
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/cache.js
21715
22838
  var require_cache3 = __commonJS({
21716
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/cache.js"(exports, module) {
22839
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/cache.js"(exports, module) {
21717
22840
  "use strict";
21718
22841
  init_esm_shims();
21719
22842
  var assert = __require("assert");
@@ -22260,9 +23383,9 @@ var require_cache3 = __commonJS({
22260
23383
  }
22261
23384
  });
22262
23385
 
22263
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/cachestorage.js
23386
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/cachestorage.js
22264
23387
  var require_cachestorage = __commonJS({
22265
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cache/cachestorage.js"(exports, module) {
23388
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cache/cachestorage.js"(exports, module) {
22266
23389
  "use strict";
22267
23390
  init_esm_shims();
22268
23391
  var { Cache } = require_cache3();
@@ -22371,9 +23494,9 @@ var require_cachestorage = __commonJS({
22371
23494
  }
22372
23495
  });
22373
23496
 
22374
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/constants.js
23497
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/constants.js
22375
23498
  var require_constants4 = __commonJS({
22376
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/constants.js"(exports, module) {
23499
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/constants.js"(exports, module) {
22377
23500
  "use strict";
22378
23501
  init_esm_shims();
22379
23502
  var maxAttributeValueSize = 1024;
@@ -22385,9 +23508,9 @@ var require_constants4 = __commonJS({
22385
23508
  }
22386
23509
  });
22387
23510
 
22388
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/util.js
23511
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/util.js
22389
23512
  var require_util4 = __commonJS({
22390
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/util.js"(exports, module) {
23513
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/util.js"(exports, module) {
22391
23514
  "use strict";
22392
23515
  init_esm_shims();
22393
23516
  function isCTLExcludingHtab(value) {
@@ -22451,14 +23574,48 @@ var require_util4 = __commonJS({
22451
23574
  for (let i = 0; i < path.length; ++i) {
22452
23575
  const code = path.charCodeAt(i);
22453
23576
  if (code < 32 || // exclude CTLs (0-31)
22454
- code === 127 || // DEL
23577
+ code > 126 || // exclude non-ascii and DEL
22455
23578
  code === 59) {
22456
23579
  throw new Error("Invalid cookie path");
22457
23580
  }
22458
23581
  }
22459
23582
  }
23583
+ function isLetterOrDigit(code) {
23584
+ return code >= 48 && code <= 57 || // 0-9
23585
+ code >= 65 && code <= 90 || // A-Z
23586
+ code >= 97 && code <= 122;
23587
+ }
22460
23588
  function validateCookieDomain(domain) {
22461
- if (domain.startsWith("-") || domain.endsWith(".") || domain.endsWith("-")) {
23589
+ if (domain === " ") {
23590
+ return;
23591
+ }
23592
+ if (domain.length > 255) {
23593
+ throw new Error("Invalid cookie domain");
23594
+ }
23595
+ let labelLength = 0;
23596
+ for (let i = 0; i < domain.length; ++i) {
23597
+ const code = domain.charCodeAt(i);
23598
+ if (code === 46) {
23599
+ if (labelLength === 0) {
23600
+ throw new Error("Invalid cookie domain");
23601
+ }
23602
+ if (domain.charCodeAt(i - 1) === 45) {
23603
+ throw new Error("Invalid cookie domain");
23604
+ }
23605
+ labelLength = 0;
23606
+ continue;
23607
+ }
23608
+ if (labelLength === 0 && !isLetterOrDigit(code)) {
23609
+ throw new Error("Invalid cookie domain");
23610
+ }
23611
+ if (!isLetterOrDigit(code) && code !== 45) {
23612
+ throw new Error("Invalid cookie domain");
23613
+ }
23614
+ if (++labelLength > 63) {
23615
+ throw new Error("Invalid cookie domain");
23616
+ }
23617
+ }
23618
+ if (labelLength === 0 || domain.charCodeAt(domain.length - 1) === 45) {
22462
23619
  throw new Error("Invalid cookie domain");
22463
23620
  }
22464
23621
  }
@@ -22541,7 +23698,11 @@ var require_util4 = __commonJS({
22541
23698
  throw new Error("Invalid unparsed");
22542
23699
  }
22543
23700
  const [key, ...value] = part.split("=");
22544
- out.push(`${key.trim()}=${value.join("=")}`);
23701
+ const trimmedKey = key.trim();
23702
+ const joinedValue = value.join("=");
23703
+ validateCookieName(trimmedKey);
23704
+ validateCookieValue(joinedValue);
23705
+ out.push(`${trimmedKey}=${joinedValue}`);
22545
23706
  }
22546
23707
  return out.join("; ");
22547
23708
  }
@@ -22556,9 +23717,9 @@ var require_util4 = __commonJS({
22556
23717
  }
22557
23718
  });
22558
23719
 
22559
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/parse.js
23720
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/parse.js
22560
23721
  var require_parse = __commonJS({
22561
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/parse.js"(exports, module) {
23722
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/parse.js"(exports, module) {
22562
23723
  "use strict";
22563
23724
  init_esm_shims();
22564
23725
  var { collectASequenceOfCodePointsFast } = require_infra();
@@ -22641,7 +23802,9 @@ var require_parse = __commonJS({
22641
23802
  const attributeNameLowercase = attributeName.toLowerCase();
22642
23803
  if (attributeNameLowercase === "expires") {
22643
23804
  const expiryTime = new Date(attributeValue);
22644
- cookieAttributeList.expires = expiryTime;
23805
+ if (!Number.isNaN(expiryTime.getTime())) {
23806
+ cookieAttributeList.expires = expiryTime;
23807
+ }
22645
23808
  } else if (attributeNameLowercase === "max-age") {
22646
23809
  const charCode = attributeValue.charCodeAt(0);
22647
23810
  if ((charCode < 48 || charCode > 57) && attributeValue[0] !== "-") {
@@ -22693,9 +23856,9 @@ var require_parse = __commonJS({
22693
23856
  }
22694
23857
  });
22695
23858
 
22696
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/index.js
23859
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/index.js
22697
23860
  var require_cookies = __commonJS({
22698
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/cookies/index.js"(exports, module) {
23861
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/cookies/index.js"(exports, module) {
22699
23862
  "use strict";
22700
23863
  init_esm_shims();
22701
23864
  var { parseSetCookie } = require_parse();
@@ -22829,9 +23992,9 @@ var require_cookies = __commonJS({
22829
23992
  }
22830
23993
  });
22831
23994
 
22832
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/events.js
23995
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/events.js
22833
23996
  var require_events = __commonJS({
22834
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/events.js"(exports, module) {
23997
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/events.js"(exports, module) {
22835
23998
  "use strict";
22836
23999
  init_esm_shims();
22837
24000
  var { webidl } = require_webidl();
@@ -23098,9 +24261,9 @@ var require_events = __commonJS({
23098
24261
  }
23099
24262
  });
23100
24263
 
23101
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/constants.js
24264
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/constants.js
23102
24265
  var require_constants5 = __commonJS({
23103
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/constants.js"(exports, module) {
24266
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/constants.js"(exports, module) {
23104
24267
  "use strict";
23105
24268
  init_esm_shims();
23106
24269
  var uid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
@@ -23155,9 +24318,9 @@ var require_constants5 = __commonJS({
23155
24318
  }
23156
24319
  });
23157
24320
 
23158
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/util.js
24321
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/util.js
23159
24322
  var require_util5 = __commonJS({
23160
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/util.js"(exports, module) {
24323
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/util.js"(exports, module) {
23161
24324
  "use strict";
23162
24325
  init_esm_shims();
23163
24326
  var { states, opcodes } = require_constants5();
@@ -23333,9 +24496,9 @@ var require_util5 = __commonJS({
23333
24496
  }
23334
24497
  });
23335
24498
 
23336
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/frame.js
24499
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/frame.js
23337
24500
  var require_frame = __commonJS({
23338
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/frame.js"(exports, module) {
24501
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/frame.js"(exports, module) {
23339
24502
  "use strict";
23340
24503
  init_esm_shims();
23341
24504
  var { runtimeFeatures } = require_runtime_features();
@@ -23434,9 +24597,9 @@ var require_frame = __commonJS({
23434
24597
  }
23435
24598
  });
23436
24599
 
23437
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/connection.js
24600
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/connection.js
23438
24601
  var require_connection = __commonJS({
23439
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/connection.js"(exports, module) {
24602
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/connection.js"(exports, module) {
23440
24603
  "use strict";
23441
24604
  init_esm_shims();
23442
24605
  var { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants5();
@@ -23591,9 +24754,9 @@ var require_connection = __commonJS({
23591
24754
  }
23592
24755
  });
23593
24756
 
23594
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/permessage-deflate.js
24757
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/permessage-deflate.js
23595
24758
  var require_permessage_deflate = __commonJS({
23596
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/permessage-deflate.js"(exports, module) {
24759
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/permessage-deflate.js"(exports, module) {
23597
24760
  "use strict";
23598
24761
  init_esm_shims();
23599
24762
  var { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __require("zlib");
@@ -23673,9 +24836,9 @@ var require_permessage_deflate = __commonJS({
23673
24836
  }
23674
24837
  });
23675
24838
 
23676
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/receiver.js
24839
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/receiver.js
23677
24840
  var require_receiver = __commonJS({
23678
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/receiver.js"(exports, module) {
24841
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/receiver.js"(exports, module) {
23679
24842
  "use strict";
23680
24843
  init_esm_shims();
23681
24844
  var { Writable } = __require("stream");
@@ -24033,9 +25196,9 @@ var require_receiver = __commonJS({
24033
25196
  }
24034
25197
  });
24035
25198
 
24036
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/sender.js
25199
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/sender.js
24037
25200
  var require_sender = __commonJS({
24038
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/sender.js"(exports, module) {
25201
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/sender.js"(exports, module) {
24039
25202
  "use strict";
24040
25203
  init_esm_shims();
24041
25204
  var { WebsocketFrameSend } = require_frame();
@@ -24121,9 +25284,9 @@ var require_sender = __commonJS({
24121
25284
  }
24122
25285
  });
24123
25286
 
24124
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/websocket.js
25287
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/websocket.js
24125
25288
  var require_websocket = __commonJS({
24126
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/websocket.js"(exports, module) {
25289
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/websocket.js"(exports, module) {
24127
25290
  "use strict";
24128
25291
  init_esm_shims();
24129
25292
  var { isArrayBuffer } = __require("util/types");
@@ -24150,6 +25313,8 @@ var require_websocket = __commonJS({
24150
25313
  var { SendQueue } = require_sender();
24151
25314
  var { WebsocketFrameSend } = require_frame();
24152
25315
  var { channels } = require_diagnostics();
25316
+ var kRef = /* @__PURE__ */ Symbol.for("nodejs.ref");
25317
+ var kUnref = /* @__PURE__ */ Symbol.for("nodejs.unref");
24153
25318
  function getSocketAddress(socket) {
24154
25319
  if (typeof socket?.address === "function") {
24155
25320
  return socket.address();
@@ -24169,6 +25334,7 @@ var require_websocket = __commonJS({
24169
25334
  #bufferedAmount = 0;
24170
25335
  #protocol = "";
24171
25336
  #extensions = "";
25337
+ #refed = true;
24172
25338
  /** @type {SendQueue} */
24173
25339
  #sendQueue;
24174
25340
  /** @type {Handler} */
@@ -24251,6 +25417,16 @@ var require_websocket = __commonJS({
24251
25417
  this.#handler.readyState = _WebSocket.CONNECTING;
24252
25418
  this.#binaryType = "blob";
24253
25419
  }
25420
+ [kRef]() {
25421
+ webidl.brandCheck(this, _WebSocket);
25422
+ this.#refed = true;
25423
+ this.#handler.socket?.ref?.();
25424
+ }
25425
+ [kUnref]() {
25426
+ webidl.brandCheck(this, _WebSocket);
25427
+ this.#refed = false;
25428
+ this.#handler.socket?.unref?.();
25429
+ }
24254
25430
  /**
24255
25431
  * @see https://websockets.spec.whatwg.org/#dom-websocket-close
24256
25432
  * @param {number|undefined} code
@@ -24412,6 +25588,9 @@ var require_websocket = __commonJS({
24412
25588
  */
24413
25589
  #onConnectionEstablished(response, parsedExtensions) {
24414
25590
  this.#handler.socket = response.socket;
25591
+ if (!this.#refed) {
25592
+ this.#handler.socket.unref?.();
25593
+ }
24415
25594
  const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
24416
25595
  const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
24417
25596
  const parser = new ByteParser(this.#handler, parsedExtensions, {
@@ -24611,9 +25790,9 @@ var require_websocket = __commonJS({
24611
25790
  }
24612
25791
  });
24613
25792
 
24614
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/stream/websocketerror.js
25793
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/stream/websocketerror.js
24615
25794
  var require_websocketerror = __commonJS({
24616
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/stream/websocketerror.js"(exports, module) {
25795
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/stream/websocketerror.js"(exports, module) {
24617
25796
  "use strict";
24618
25797
  init_esm_shims();
24619
25798
  var { webidl } = require_webidl();
@@ -24692,9 +25871,9 @@ var require_websocketerror = __commonJS({
24692
25871
  }
24693
25872
  });
24694
25873
 
24695
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/stream/websocketstream.js
25874
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/stream/websocketstream.js
24696
25875
  var require_websocketstream = __commonJS({
24697
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/websocket/stream/websocketstream.js"(exports, module) {
25876
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/websocket/stream/websocketstream.js"(exports, module) {
24698
25877
  "use strict";
24699
25878
  init_esm_shims();
24700
25879
  var { addAbortListener } = __require("events");
@@ -25004,9 +26183,9 @@ var require_websocketstream = __commonJS({
25004
26183
  }
25005
26184
  });
25006
26185
 
25007
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/util.js
26186
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/util.js
25008
26187
  var require_util6 = __commonJS({
25009
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/util.js"(exports, module) {
26188
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/util.js"(exports, module) {
25010
26189
  "use strict";
25011
26190
  init_esm_shims();
25012
26191
  var { makeRequest } = require_request2();
@@ -25034,7 +26213,7 @@ var require_util6 = __commonJS({
25034
26213
  destination,
25035
26214
  mode,
25036
26215
  credentials: credentialsMode,
25037
- useCredentials: true
26216
+ useURLCredentials: true
25038
26217
  });
25039
26218
  }
25040
26219
  module.exports = {
@@ -25045,9 +26224,9 @@ var require_util6 = __commonJS({
25045
26224
  }
25046
26225
  });
25047
26226
 
25048
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/eventsource-stream.js
26227
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/eventsource-stream.js
25049
26228
  var require_eventsource_stream = __commonJS({
25050
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports, module) {
26229
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports, module) {
25051
26230
  "use strict";
25052
26231
  init_esm_shims();
25053
26232
  var { Transform } = __require("stream");
@@ -25387,9 +26566,9 @@ ${value}`;
25387
26566
  }
25388
26567
  });
25389
26568
 
25390
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/eventsource.js
26569
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/eventsource.js
25391
26570
  var require_eventsource = __commonJS({
25392
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/lib/web/eventsource/eventsource.js"(exports, module) {
26571
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/web/eventsource/eventsource.js"(exports, module) {
25393
26572
  "use strict";
25394
26573
  init_esm_shims();
25395
26574
  var { pipeline } = __require("stream");
@@ -25697,9 +26876,9 @@ var require_eventsource = __commonJS({
25697
26876
  }
25698
26877
  });
25699
26878
 
25700
- // ../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/index.js
26879
+ // ../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/index.js
25701
26880
  var require_undici = __commonJS({
25702
- "../../node_modules/.pnpm/undici@8.5.0/node_modules/undici/index.js"(exports, module) {
26881
+ "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/index.js"(exports, module) {
25703
26882
  init_esm_shims();
25704
26883
  var Client = require_client();
25705
26884
  var Dispatcher = require_dispatcher();
@@ -25902,4 +27081,4 @@ undici/lib/web/fetch/body.js:
25902
27081
  undici/lib/web/websocket/frame.js:
25903
27082
  (*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> *)
25904
27083
  */
25905
- //# sourceMappingURL=undici-ETWE7SN4.js.map
27084
+ //# sourceMappingURL=undici-MBS5ACFE.js.map