@yanglaofish/fishtools 0.5.2 → 0.5.3

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 (826) hide show
  1. package/README.md +23 -11
  2. package/manual/README.md +23 -11
  3. package/manual/docs/deployment.md +3 -3
  4. package/manual/docs/examples/action-plugin/package.json +1 -1
  5. package/manual/docs/plugin-development.md +15 -4
  6. package/manual/docs/releases.md +24 -0
  7. package/manual/docs/superpowers/plans/2026-10-13-command-shortcuts.md +3 -2
  8. package/manual/docs/superpowers/plans/2026-10-13-global-plugins.md +56 -0
  9. package/manual/docs/superpowers/plans/2026-10-13-tui-readable-sessions.md +21 -0
  10. package/manual/docs/superpowers/reviews/2026-10-13-0.5.3-review.md +28 -0
  11. package/manual/docs/superpowers/reviews/2026-10-13-command-shortcuts-review.md +7 -0
  12. package/manual/docs/superpowers/reviews/2026-10-13-tui-sessions-review.md +55 -0
  13. package/manual/docs/superpowers/specs/2026-10-13-issue-4-workflow-menu.md +23 -0
  14. package/manual/docs/superpowers/specs/2026-10-13-issue-5-results-and-history.md +20 -0
  15. package/manual/docs/terminal-commands.md +8 -0
  16. package/manual/docs/verification.md +30 -0
  17. package/manual/packages/core/README.md +2 -0
  18. package/manual/packages/core/package.json +1 -1
  19. package/manual/packages/core/src/application.js +100 -51
  20. package/manual/packages/core/src/development-watch-worker.js +10 -1
  21. package/manual/packages/core/src/development.js +1 -1
  22. package/manual/packages/core/src/plugin-catalog.js +42 -0
  23. package/manual/packages/core/src/version.js +1 -1
  24. package/manual/packages/fst-cli/README.md +4 -0
  25. package/manual/packages/fst-cli/bin/fst.js +7 -6
  26. package/manual/packages/fst-cli/package.json +1 -1
  27. package/manual/packages/fst-cli/src/development.js +6 -1
  28. package/manual/packages/fst-cli/src/terminal/command-menu.js +8 -3
  29. package/manual/packages/fst-cli/src/terminal/navigation.js +2 -0
  30. package/manual/packages/fst-cli/src/terminal/presentation.js +4 -3
  31. package/manual/packages/fst-cli/src/terminal/run-feed.js +69 -13
  32. package/manual/packages/fst-cli/src/terminal/run-presentation.js +55 -12
  33. package/manual/packages/fst-cli/src/terminal/run-viewer.js +26 -10
  34. package/manual/packages/fst-cli/src/terminal/session-history.js +82 -0
  35. package/manual/packages/fst-cli/src/terminal/session.js +119 -40
  36. package/manual/packages/fst-cli/src/terminal/view.js +31 -8
  37. package/manual/packages/fst-cli/src/terminal/workflow-menu.js +14 -9
  38. package/manual/packages/fst-devtools/package.json +2 -2
  39. package/manual/packages/fst-devtools/src/plugin-tools.js +1 -1
  40. package/manual/packages/fst-logs/README.md +23 -2
  41. package/manual/packages/fst-logs/package.json +2 -1
  42. package/manual/packages/fst-logs/src/file-identity.js +23 -0
  43. package/manual/packages/fst-logs/src/markdown-log.js +4 -3
  44. package/manual/packages/fst-logs/src/run-logs.js +3 -2
  45. package/manual/packages/fst-logs/src/session-history.js +180 -0
  46. package/manual/packages/fst-platform/README.md +4 -0
  47. package/manual/packages/fst-platform/package.json +3 -3
  48. package/manual/packages/fst-platform/src/process.js +4 -1
  49. package/manual/packages/fst-platform/src/shell.js +46 -1
  50. package/manual/packages/fst-plugin/package.json +1 -1
  51. package/manual/packages/fst-plugin/src/host.js +31 -23
  52. package/manual/packages/fst-workflow/package.json +1 -1
  53. package/manual/packages/fst-workflow/src/engine.js +1 -1
  54. package/manual/packages/fst-workspace/README.md +2 -0
  55. package/manual/packages/fst-workspace/package.json +2 -1
  56. package/manual/packages/fst-workspace/src/plugin-registry.js +58 -0
  57. package/manual/packages/fst-workspace/src/plugins.js +7 -4
  58. package/manual/packages/fst-workspace/src/workflows.js +5 -3
  59. package/manual/packages/pack/package.json +3 -3
  60. package/manual/packages/pack/runtime-cache.js +26 -0
  61. package/manual/packages/pack/runtime.js +6 -10
  62. package/manual/plugins/commands/package.json +1 -1
  63. package/node_modules/@mytools/commands/package.json +1 -1
  64. package/node_modules/@mytools/core/README.md +2 -0
  65. package/node_modules/@mytools/core/package.json +1 -1
  66. package/node_modules/@mytools/core/src/application.js +100 -51
  67. package/node_modules/@mytools/core/src/development-watch-worker.js +10 -1
  68. package/node_modules/@mytools/core/src/development.js +1 -1
  69. package/node_modules/@mytools/core/src/plugin-catalog.js +42 -0
  70. package/node_modules/@mytools/core/src/version.js +1 -1
  71. package/node_modules/@mytools/fst-cli/README.md +4 -0
  72. package/node_modules/@mytools/fst-cli/bin/fst.js +7 -6
  73. package/node_modules/@mytools/fst-cli/package.json +1 -1
  74. package/node_modules/@mytools/fst-cli/src/development.js +6 -1
  75. package/node_modules/@mytools/fst-cli/src/terminal/command-menu.js +8 -3
  76. package/node_modules/@mytools/fst-cli/src/terminal/navigation.js +2 -0
  77. package/node_modules/@mytools/fst-cli/src/terminal/presentation.js +4 -3
  78. package/node_modules/@mytools/fst-cli/src/terminal/run-feed.js +69 -13
  79. package/node_modules/@mytools/fst-cli/src/terminal/run-presentation.js +55 -12
  80. package/node_modules/@mytools/fst-cli/src/terminal/run-viewer.js +26 -10
  81. package/node_modules/@mytools/fst-cli/src/terminal/session-history.js +82 -0
  82. package/node_modules/@mytools/fst-cli/src/terminal/session.js +119 -40
  83. package/node_modules/@mytools/fst-cli/src/terminal/view.js +31 -8
  84. package/node_modules/@mytools/fst-cli/src/terminal/workflow-menu.js +14 -9
  85. package/node_modules/@mytools/fst-devtools/package.json +2 -2
  86. package/node_modules/@mytools/fst-devtools/src/plugin-tools.js +1 -1
  87. package/node_modules/@mytools/fst-logs/README.md +23 -2
  88. package/node_modules/@mytools/fst-logs/package.json +2 -1
  89. package/node_modules/@mytools/fst-logs/src/file-identity.js +23 -0
  90. package/node_modules/@mytools/fst-logs/src/markdown-log.js +4 -3
  91. package/node_modules/@mytools/fst-logs/src/run-logs.js +3 -2
  92. package/node_modules/@mytools/fst-logs/src/session-history.js +180 -0
  93. package/node_modules/@mytools/fst-platform/README.md +4 -0
  94. package/node_modules/@mytools/fst-platform/node_modules/undici/LICENSE +21 -0
  95. package/node_modules/{undici/docs/docs/index.md → @mytools/fst-platform/node_modules/undici/README.md} +85 -137
  96. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Agent.md +84 -0
  97. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
  98. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
  99. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
  100. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Client.md +288 -0
  101. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
  102. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Connector.md +115 -0
  103. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ContentType.md +57 -0
  104. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Cookies.md +128 -0
  105. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Debug.md +62 -0
  106. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +317 -0
  107. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Dispatcher.md +1393 -0
  108. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
  109. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Errors.md +49 -0
  110. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/EventSource.md +45 -0
  111. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Fetch.md +60 -0
  112. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
  113. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
  114. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
  115. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
  116. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
  117. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockClient.md +81 -0
  118. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
  119. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockPool.md +555 -0
  120. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Pool.md +84 -0
  121. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
  122. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
  123. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
  124. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
  125. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
  126. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
  127. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
  128. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
  129. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Util.md +25 -0
  130. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
  131. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
  132. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
  133. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/docs/docs/best-practices/crawling.md +1 -3
  134. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
  135. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
  136. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/docs/docs/best-practices/undici-vs-builtin-fetch.md +8 -10
  137. package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
  138. package/node_modules/@mytools/fst-platform/node_modules/undici/index-fetch.js +65 -0
  139. package/node_modules/@mytools/fst-platform/node_modules/undici/index.d.ts +3 -0
  140. package/node_modules/@mytools/fst-platform/node_modules/undici/index.js +234 -0
  141. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/abort-signal.js +59 -0
  142. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-connect.js +110 -0
  143. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-pipeline.js +252 -0
  144. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-request.js +214 -0
  145. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-stream.js +209 -0
  146. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-upgrade.js +111 -0
  147. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/index.js +7 -0
  148. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/readable.js +580 -0
  149. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/cache/memory-cache-store.js +3 -3
  150. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/cache/sqlite-cache-store.js +1 -3
  151. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/connect.js +153 -0
  152. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/constants.js +143 -0
  153. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/diagnostics.js +227 -0
  154. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/errors.js +477 -0
  155. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/request.js +485 -0
  156. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/symbols.js +75 -0
  157. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/tree.js +160 -0
  158. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/util.js +992 -0
  159. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/agent.js +158 -0
  160. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
  161. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client-h1.js +1746 -0
  162. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client-h2.js +1060 -0
  163. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client.js +668 -0
  164. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
  165. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
  166. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
  167. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  168. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/h2c-client.js +4 -4
  169. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
  170. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/pool.js +118 -0
  171. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
  172. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
  173. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/round-robin-pool.js +10 -32
  174. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/socks5-proxy-agent.js +63 -153
  175. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/global.js +59 -0
  176. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/cache-handler.js +7 -49
  177. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/cache-revalidation-handler.js +0 -10
  178. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/decorator-handler.js +67 -0
  179. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/deduplication-handler.js +10 -29
  180. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/redirect-handler.js +238 -0
  181. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/retry-handler.js +504 -0
  182. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
  183. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/wrap-handler.js +105 -0
  184. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/cache.js +26 -79
  185. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/decompress.js +3 -13
  186. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/deduplicate.js +4 -5
  187. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/dns.js +571 -0
  188. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/dump.js +99 -0
  189. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/redirect.js +21 -0
  190. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/response-error.js +95 -0
  191. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/retry.js +19 -0
  192. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  193. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/constants.js +531 -0
  194. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  195. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  196. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/utils.js +12 -0
  197. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-agent.js +232 -0
  198. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/mock-call-history.js +1 -1
  199. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-client.js +68 -0
  200. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-errors.js +29 -0
  201. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
  202. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-pool.js +68 -0
  203. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  204. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-utils.js +486 -0
  205. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  206. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-agent.js +7 -25
  207. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-recorder.js +3 -38
  208. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/cache.js +10 -92
  209. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/util/promise.js +28 -0
  210. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/runtime-features.js +34 -3
  211. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/util/timers.js +425 -0
  212. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/cache.js +864 -0
  213. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
  214. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/util.js +45 -0
  215. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/constants.js +12 -0
  216. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/index.js +199 -0
  217. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/parse.js +314 -0
  218. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/util.js +352 -0
  219. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
  220. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
  221. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/util.js +29 -0
  222. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  223. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/body.js +509 -0
  224. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/constants.js +131 -0
  225. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  226. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
  227. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/formdata.js +259 -0
  228. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/global.js +40 -0
  229. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/headers.js +719 -0
  230. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/index.js +2413 -0
  231. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/request.js +1115 -0
  232. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/response.js +641 -0
  233. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/util.js +1522 -0
  234. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/infra/index.js +1 -16
  235. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/webidl/index.js +21 -7
  236. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/connection.js +339 -0
  237. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/constants.js +126 -0
  238. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/events.js +331 -0
  239. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/frame.js +133 -0
  240. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
  241. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/receiver.js +507 -0
  242. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/sender.js +109 -0
  243. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/websocket/stream/websocketerror.js +10 -13
  244. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/websocket/stream/websocketstream.js +14 -29
  245. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/util.js +347 -0
  246. package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/websocket.js +758 -0
  247. package/node_modules/@mytools/fst-platform/node_modules/undici/package.json +152 -0
  248. package/node_modules/@mytools/fst-platform/node_modules/undici/scripts/strip-comments.js +10 -0
  249. package/node_modules/@mytools/fst-platform/node_modules/undici/types/README.md +6 -0
  250. package/node_modules/@mytools/fst-platform/node_modules/undici/types/agent.d.ts +32 -0
  251. package/node_modules/@mytools/fst-platform/node_modules/undici/types/api.d.ts +43 -0
  252. package/node_modules/@mytools/fst-platform/node_modules/undici/types/balanced-pool.d.ts +30 -0
  253. package/node_modules/@mytools/fst-platform/node_modules/undici/types/cache.d.ts +36 -0
  254. package/node_modules/@mytools/fst-platform/node_modules/undici/types/client.d.ts +139 -0
  255. package/node_modules/@mytools/fst-platform/node_modules/undici/types/connector.d.ts +36 -0
  256. package/node_modules/@mytools/fst-platform/node_modules/undici/types/content-type.d.ts +21 -0
  257. package/node_modules/@mytools/fst-platform/node_modules/undici/types/cookies.d.ts +30 -0
  258. package/node_modules/@mytools/fst-platform/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
  259. package/node_modules/@mytools/fst-platform/node_modules/undici/types/dispatcher.d.ts +275 -0
  260. package/node_modules/@mytools/fst-platform/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  261. package/node_modules/@mytools/fst-platform/node_modules/undici/types/errors.d.ts +177 -0
  262. package/node_modules/@mytools/fst-platform/node_modules/undici/types/eventsource.d.ts +66 -0
  263. package/node_modules/@mytools/fst-platform/node_modules/undici/types/fetch.d.ts +231 -0
  264. package/node_modules/@mytools/fst-platform/node_modules/undici/types/formdata.d.ts +114 -0
  265. package/node_modules/@mytools/fst-platform/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  266. package/node_modules/@mytools/fst-platform/node_modules/undici/types/global-origin.d.ts +7 -0
  267. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/h2c-client.d.ts +6 -6
  268. package/node_modules/@mytools/fst-platform/node_modules/undici/types/handlers.d.ts +14 -0
  269. package/node_modules/@mytools/fst-platform/node_modules/undici/types/header.d.ts +160 -0
  270. package/node_modules/@mytools/fst-platform/node_modules/undici/types/index.d.ts +91 -0
  271. package/node_modules/@mytools/fst-platform/node_modules/undici/types/interceptors.d.ts +82 -0
  272. package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-agent.d.ts +68 -0
  273. package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-client.d.ts +27 -0
  274. package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-errors.d.ts +12 -0
  275. package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-interceptor.d.ts +94 -0
  276. package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-pool.d.ts +27 -0
  277. package/node_modules/@mytools/fst-platform/node_modules/undici/types/patch.d.ts +29 -0
  278. package/node_modules/@mytools/fst-platform/node_modules/undici/types/pool-stats.d.ts +19 -0
  279. package/node_modules/@mytools/fst-platform/node_modules/undici/types/pool.d.ts +41 -0
  280. package/node_modules/@mytools/fst-platform/node_modules/undici/types/proxy-agent.d.ts +29 -0
  281. package/node_modules/@mytools/fst-platform/node_modules/undici/types/readable.d.ts +68 -0
  282. package/node_modules/@mytools/fst-platform/node_modules/undici/types/retry-agent.d.ts +8 -0
  283. package/node_modules/@mytools/fst-platform/node_modules/undici/types/retry-handler.d.ts +125 -0
  284. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/round-robin-pool.d.ts +2 -0
  285. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/snapshot-agent.d.ts +0 -4
  286. package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/socks5-proxy-agent.d.ts +2 -4
  287. package/node_modules/@mytools/fst-platform/node_modules/undici/types/util.d.ts +18 -0
  288. package/node_modules/@mytools/fst-platform/node_modules/undici/types/webidl.d.ts +347 -0
  289. package/node_modules/@mytools/fst-platform/node_modules/undici/types/websocket.d.ts +188 -0
  290. package/node_modules/@mytools/fst-platform/package.json +3 -3
  291. package/node_modules/@mytools/fst-platform/src/process.js +4 -1
  292. package/node_modules/@mytools/fst-platform/src/shell.js +46 -1
  293. package/node_modules/@mytools/fst-plugin/package.json +1 -1
  294. package/node_modules/@mytools/fst-plugin/src/host.js +31 -23
  295. package/node_modules/@mytools/fst-workflow/package.json +1 -1
  296. package/node_modules/@mytools/fst-workflow/src/engine.js +1 -1
  297. package/node_modules/@mytools/fst-workspace/README.md +2 -0
  298. package/node_modules/@mytools/fst-workspace/package.json +2 -1
  299. package/node_modules/@mytools/fst-workspace/src/plugin-registry.js +58 -0
  300. package/node_modules/@mytools/fst-workspace/src/plugins.js +7 -4
  301. package/node_modules/@mytools/fst-workspace/src/workflows.js +5 -3
  302. package/node_modules/@mytools/pack/package.json +3 -3
  303. package/node_modules/@mytools/pack/runtime-cache.js +26 -0
  304. package/node_modules/@mytools/pack/runtime.js +6 -10
  305. package/node_modules/@mytools/web/public/THIRD_PARTY_NOTICES.txt +953 -963
  306. package/node_modules/@npmcli/agent/lib/agents.js +0 -10
  307. package/node_modules/@npmcli/agent/package.json +12 -11
  308. package/node_modules/@npmcli/arborist/README.md +2 -2
  309. package/node_modules/@npmcli/arborist/bin/index.js +2 -1
  310. package/node_modules/@npmcli/arborist/bin/shrinkwrap.js +7 -0
  311. package/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +25 -159
  312. package/node_modules/@npmcli/arborist/lib/arborist/isolated-reifier.js +49 -11
  313. package/node_modules/@npmcli/arborist/lib/arborist/load-actual.js +0 -67
  314. package/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +37 -5
  315. package/node_modules/@npmcli/arborist/lib/arborist/rebuild.js +8 -15
  316. package/node_modules/@npmcli/arborist/lib/arborist/reify.js +42 -59
  317. package/node_modules/@npmcli/arborist/lib/consistent-resolve.js +1 -1
  318. package/node_modules/@npmcli/arborist/lib/diff.js +22 -17
  319. package/node_modules/@npmcli/arborist/lib/edge.js +2 -22
  320. package/node_modules/@npmcli/arborist/lib/index.js +0 -2
  321. package/node_modules/@npmcli/arborist/lib/isolated-classes.js +1 -4
  322. package/node_modules/@npmcli/arborist/lib/node.js +9 -13
  323. package/node_modules/@npmcli/arborist/lib/place-dep.js +0 -6
  324. package/node_modules/@npmcli/arborist/lib/printable.js +5 -0
  325. package/node_modules/@npmcli/arborist/lib/shrinkwrap.js +32 -55
  326. package/node_modules/@npmcli/arborist/package.json +26 -32
  327. package/node_modules/@npmcli/fs/lib/move-file.js +5 -5
  328. package/node_modules/@npmcli/fs/package.json +5 -5
  329. package/node_modules/@npmcli/git/package.json +12 -13
  330. package/node_modules/@npmcli/installed-package-contents/package.json +7 -7
  331. package/node_modules/@npmcli/map-workspaces/package.json +7 -7
  332. package/node_modules/@npmcli/metavuln-calculator/package.json +16 -10
  333. package/node_modules/@npmcli/name-from-folder/package.json +16 -13
  334. package/node_modules/@npmcli/node-gyp/package.json +5 -5
  335. package/node_modules/@npmcli/package-json/lib/index.js +1 -2
  336. package/node_modules/@npmcli/package-json/lib/normalize.js +22 -23
  337. package/node_modules/@npmcli/package-json/package.json +10 -11
  338. package/node_modules/@npmcli/promise-spawn/README.md +2 -1
  339. package/node_modules/@npmcli/promise-spawn/package.json +5 -5
  340. package/node_modules/@npmcli/redact/package.json +4 -4
  341. package/node_modules/@npmcli/run-script/lib/is-server-package.js +11 -0
  342. package/node_modules/@npmcli/run-script/lib/make-spawn-args.js +6 -5
  343. package/node_modules/@npmcli/run-script/lib/run-script-pkg.js +13 -4
  344. package/node_modules/@npmcli/run-script/lib/run-script.js +2 -1
  345. package/node_modules/@npmcli/run-script/package.json +11 -12
  346. package/node_modules/@sigstore/bundle/README.md +1 -1
  347. package/node_modules/@sigstore/bundle/dist/error.js +0 -1
  348. package/node_modules/@sigstore/bundle/package.json +2 -2
  349. package/node_modules/@sigstore/core/README.md +1 -1
  350. package/node_modules/@sigstore/core/dist/asn1/length.js +1 -12
  351. package/node_modules/@sigstore/core/dist/asn1/obj.js +7 -25
  352. package/node_modules/@sigstore/core/dist/asn1/parse.js +5 -24
  353. package/node_modules/@sigstore/core/package.json +2 -2
  354. package/node_modules/@sigstore/sign/README.md +1 -1
  355. package/node_modules/@sigstore/sign/dist/signer/fulcio/ephemeral.js +1 -1
  356. package/node_modules/@sigstore/sign/package.json +9 -9
  357. package/node_modules/@sigstore/tuf/README.md +1 -1
  358. package/node_modules/@sigstore/tuf/package.json +4 -4
  359. package/node_modules/@sigstore/tuf/seeds.json +1 -1
  360. package/node_modules/@sigstore/verify/README.md +1 -1
  361. package/node_modules/@sigstore/verify/dist/bundle/dsse.d.ts +0 -1
  362. package/node_modules/@sigstore/verify/dist/bundle/dsse.js +0 -6
  363. package/node_modules/@sigstore/verify/dist/bundle/message.d.ts +0 -1
  364. package/node_modules/@sigstore/verify/dist/bundle/message.js +0 -5
  365. package/node_modules/@sigstore/verify/dist/policy.d.ts +1 -1
  366. package/node_modules/@sigstore/verify/dist/policy.js +2 -0
  367. package/node_modules/@sigstore/verify/dist/shared.types.d.ts +1 -6
  368. package/node_modules/@sigstore/verify/dist/tlog/checkpoint.js +3 -17
  369. package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.js +4 -4
  370. package/node_modules/@sigstore/verify/dist/tlog/index.js +1 -13
  371. package/node_modules/@sigstore/verify/dist/tlog/merkle.js +1 -12
  372. package/node_modules/@sigstore/verify/dist/verifier.js +5 -13
  373. package/node_modules/@sigstore/verify/package.json +5 -5
  374. package/node_modules/@tufjs/models/package.json +3 -3
  375. package/node_modules/abbrev/package.json +8 -9
  376. package/node_modules/agent-base/dist/helpers.d.ts +5 -0
  377. package/node_modules/agent-base/dist/helpers.d.ts.map +1 -1
  378. package/node_modules/agent-base/dist/helpers.js +34 -5
  379. package/node_modules/agent-base/dist/helpers.js.map +1 -1
  380. package/node_modules/agent-base/dist/index.d.ts +5 -1
  381. package/node_modules/agent-base/dist/index.d.ts.map +1 -1
  382. package/node_modules/agent-base/dist/index.js +40 -8
  383. package/node_modules/agent-base/dist/index.js.map +1 -1
  384. package/node_modules/agent-base/package.json +12 -12
  385. package/node_modules/bin-links/README.md +4 -5
  386. package/node_modules/bin-links/lib/fix-bin.js +1 -3
  387. package/node_modules/bin-links/lib/index.js +16 -8
  388. package/node_modules/bin-links/lib/link-mans.js +53 -0
  389. package/node_modules/bin-links/package.json +12 -11
  390. package/node_modules/cacache/lib/content/write.js +0 -2
  391. package/node_modules/cacache/lib/entry-index.js +0 -3
  392. package/node_modules/cacache/lib/rm.js +0 -1
  393. package/node_modules/cacache/lib/util/tmp.js +1 -5
  394. package/node_modules/cacache/lib/verify.js +2 -2
  395. package/node_modules/cacache/package.json +7 -7
  396. package/node_modules/cmd-shim/lib/index.js +32 -67
  397. package/node_modules/cmd-shim/package.json +5 -5
  398. package/node_modules/hosted-git-info/README.md +1 -1
  399. package/node_modules/hosted-git-info/lib/parse-url.js +3 -1
  400. package/node_modules/hosted-git-info/package.json +4 -4
  401. package/node_modules/http-proxy-agent/dist/index.d.ts +5 -8
  402. package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -1
  403. package/node_modules/http-proxy-agent/dist/index.js +42 -26
  404. package/node_modules/http-proxy-agent/dist/index.js.map +1 -1
  405. package/node_modules/http-proxy-agent/package.json +14 -15
  406. package/node_modules/https-proxy-agent/dist/index.d.ts +5 -9
  407. package/node_modules/https-proxy-agent/dist/index.d.ts.map +1 -1
  408. package/node_modules/https-proxy-agent/dist/index.js +44 -98
  409. package/node_modules/https-proxy-agent/dist/index.js.map +1 -1
  410. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +3 -0
  411. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts.map +1 -1
  412. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +10 -3
  413. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -1
  414. package/node_modules/https-proxy-agent/package.json +15 -16
  415. package/node_modules/ignore-walk/package.json +4 -4
  416. package/node_modules/ini/package.json +5 -5
  417. package/node_modules/ip-address/README.md +70 -70
  418. package/node_modules/ip-address/dist/ipv6.js +7 -4
  419. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  420. package/node_modules/ip-address/dist/v6/constants.d.ts +3 -0
  421. package/node_modules/ip-address/dist/v6/constants.js +3 -0
  422. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  423. package/node_modules/ip-address/package.json +2 -1
  424. package/node_modules/json-parse-even-better-errors/lib/index.js +1 -3
  425. package/node_modules/json-parse-even-better-errors/package.json +17 -13
  426. package/node_modules/make-fetch-happen/package.json +11 -11
  427. package/node_modules/minipass-fetch/package.json +4 -4
  428. package/node_modules/node-gyp/.release-please-manifest.json +1 -1
  429. package/node_modules/node-gyp/CHANGELOG.md +0 -102
  430. package/node_modules/node-gyp/README.md +2 -3
  431. package/node_modules/node-gyp/eslint.config.js +1 -4
  432. package/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
  433. package/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +19 -14
  434. package/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +2 -7
  435. package/node_modules/node-gyp/gyp/pyproject.toml +1 -1
  436. package/node_modules/node-gyp/lib/build.js +6 -18
  437. package/node_modules/node-gyp/lib/create-config-gypi.js +0 -5
  438. package/node_modules/node-gyp/lib/node-gyp.js +2 -9
  439. package/node_modules/node-gyp/lib/rebuild.js +3 -3
  440. package/node_modules/node-gyp/package.json +9 -11
  441. package/node_modules/nopt/README.md +4 -2
  442. package/node_modules/nopt/lib/debug.js +5 -0
  443. package/node_modules/nopt/lib/nopt-lib.js +43 -7
  444. package/node_modules/nopt/lib/nopt.js +4 -2
  445. package/node_modules/nopt/lib/type-defs.js +13 -8
  446. package/node_modules/nopt/package.json +17 -15
  447. package/node_modules/npm-bundled/package.json +6 -6
  448. package/node_modules/npm-install-checks/package.json +5 -5
  449. package/node_modules/npm-normalize-package-bin/package.json +16 -13
  450. package/node_modules/npm-package-arg/package.json +7 -7
  451. package/node_modules/npm-packlist/README.md +30 -45
  452. package/node_modules/npm-packlist/lib/index.js +47 -115
  453. package/node_modules/npm-packlist/package.json +8 -10
  454. package/node_modules/npm-pick-manifest/package.json +19 -15
  455. package/node_modules/npm-registry-fetch/lib/errors.js +3 -8
  456. package/node_modules/npm-registry-fetch/package.json +12 -12
  457. package/node_modules/pacote/lib/dir.js +5 -60
  458. package/node_modules/pacote/lib/fetcher.js +0 -4
  459. package/node_modules/pacote/lib/git.js +3 -11
  460. package/node_modules/pacote/lib/util/add-git-sha.js +1 -1
  461. package/node_modules/pacote/package.json +18 -19
  462. package/node_modules/parse-conflict-json/package.json +6 -6
  463. package/node_modules/proc-log/package.json +4 -4
  464. package/node_modules/read-cmd-shim/lib/index.js +1 -1
  465. package/node_modules/read-cmd-shim/package.json +18 -14
  466. package/node_modules/sigstore/README.md +1 -1
  467. package/node_modules/sigstore/package.json +10 -10
  468. package/node_modules/socks-proxy-agent/dist/index.d.ts +3 -1
  469. package/node_modules/socks-proxy-agent/dist/index.d.ts.map +1 -1
  470. package/node_modules/socks-proxy-agent/dist/index.js +43 -17
  471. package/node_modules/socks-proxy-agent/dist/index.js.map +1 -1
  472. package/node_modules/socks-proxy-agent/package.json +15 -15
  473. package/node_modules/ssri/package.json +4 -4
  474. package/node_modules/tuf-js/dist/config.d.ts +2 -2
  475. package/node_modules/tuf-js/dist/fetcher.d.ts +4 -4
  476. package/node_modules/tuf-js/dist/fetcher.js +16 -55
  477. package/node_modules/tuf-js/dist/updater.js +2 -2
  478. package/node_modules/tuf-js/package.json +8 -8
  479. package/node_modules/undici/README.md +72 -405
  480. package/node_modules/undici/docs/docs/api/Agent.md +41 -252
  481. package/node_modules/undici/docs/docs/api/BalancedPool.md +48 -246
  482. package/node_modules/undici/docs/docs/api/CacheStorage.md +13 -171
  483. package/node_modules/undici/docs/docs/api/Client.md +139 -395
  484. package/node_modules/undici/docs/docs/api/Connector.md +35 -118
  485. package/node_modules/undici/docs/docs/api/ContentType.md +25 -65
  486. package/node_modules/undici/docs/docs/api/Cookies.md +47 -125
  487. package/node_modules/undici/docs/docs/api/Debug.md +31 -47
  488. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +97 -409
  489. package/node_modules/undici/docs/docs/api/DispatchInterceptor.md +60 -0
  490. package/node_modules/undici/docs/docs/api/Dispatcher.md +1011 -500
  491. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +96 -105
  492. package/node_modules/undici/docs/docs/api/Errors.md +28 -528
  493. package/node_modules/undici/docs/docs/api/EventSource.md +13 -326
  494. package/node_modules/undici/docs/docs/api/Fetch.md +24 -693
  495. package/node_modules/undici/docs/docs/api/MockAgent.md +264 -346
  496. package/node_modules/undici/docs/docs/api/MockClient.md +31 -153
  497. package/node_modules/undici/docs/docs/api/MockErrors.md +5 -56
  498. package/node_modules/undici/docs/docs/api/MockPool.md +253 -324
  499. package/node_modules/undici/docs/docs/api/Pool.md +41 -235
  500. package/node_modules/undici/docs/docs/api/PoolStats.md +13 -119
  501. package/node_modules/undici/docs/docs/api/ProxyAgent.md +81 -198
  502. package/node_modules/undici/docs/docs/api/RedirectHandler.md +58 -238
  503. package/node_modules/undici/docs/docs/api/RetryAgent.md +28 -119
  504. package/node_modules/undici/docs/docs/api/RetryHandler.md +78 -161
  505. package/node_modules/undici/docs/docs/api/Util.md +11 -68
  506. package/node_modules/undici/docs/docs/api/WebSocket.md +24 -509
  507. package/node_modules/undici/docs/docs/api/api-lifecycle.md +33 -101
  508. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -2
  509. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +2 -58
  510. package/node_modules/undici/docs/docs/best-practices/proxy.md +1 -3
  511. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -45
  512. package/node_modules/undici/index-fetch.js +4 -34
  513. package/node_modules/undici/index.d.ts +1 -1
  514. package/node_modules/undici/index.js +20 -87
  515. package/node_modules/undici/lib/api/abort-signal.js +0 -2
  516. package/node_modules/undici/lib/api/api-connect.js +11 -15
  517. package/node_modules/undici/lib/api/api-pipeline.js +19 -33
  518. package/node_modules/undici/lib/api/api-request.js +59 -89
  519. package/node_modules/undici/lib/api/api-stream.js +64 -114
  520. package/node_modules/undici/lib/api/api-upgrade.js +13 -26
  521. package/node_modules/undici/lib/api/readable.js +87 -317
  522. package/node_modules/undici/lib/api/util.js +93 -0
  523. package/node_modules/undici/lib/core/connect.js +125 -77
  524. package/node_modules/undici/lib/core/constants.js +9 -11
  525. package/node_modules/undici/lib/core/diagnostics.js +129 -154
  526. package/node_modules/undici/lib/core/errors.js +50 -122
  527. package/node_modules/undici/lib/core/request.js +87 -172
  528. package/node_modules/undici/lib/core/symbols.js +2 -14
  529. package/node_modules/undici/lib/core/tree.js +2 -10
  530. package/node_modules/undici/lib/core/util.js +190 -481
  531. package/node_modules/undici/lib/dispatcher/agent.js +35 -83
  532. package/node_modules/undici/lib/dispatcher/balanced-pool.js +38 -46
  533. package/node_modules/undici/lib/dispatcher/client-h1.js +199 -492
  534. package/node_modules/undici/lib/dispatcher/client-h2.js +380 -1409
  535. package/node_modules/undici/lib/dispatcher/client.js +130 -253
  536. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +52 -50
  537. package/node_modules/undici/lib/dispatcher/dispatcher.js +24 -17
  538. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +45 -75
  539. package/node_modules/undici/lib/dispatcher/fixed-queue.js +50 -68
  540. package/node_modules/undici/lib/dispatcher/pool-base.js +54 -153
  541. package/node_modules/undici/lib/dispatcher/pool-stats.js +34 -0
  542. package/node_modules/undici/lib/dispatcher/pool.js +16 -135
  543. package/node_modules/undici/lib/dispatcher/proxy-agent.js +41 -175
  544. package/node_modules/undici/lib/dispatcher/retry-agent.js +0 -3
  545. package/node_modules/undici/lib/global.js +9 -59
  546. package/node_modules/undici/lib/handler/decorator-handler.js +15 -43
  547. package/node_modules/undici/lib/handler/redirect-handler.js +116 -127
  548. package/node_modules/undici/lib/handler/retry-handler.js +182 -398
  549. package/node_modules/undici/lib/interceptor/dns.js +47 -254
  550. package/node_modules/undici/lib/interceptor/dump.js +56 -32
  551. package/node_modules/undici/lib/interceptor/redirect-interceptor.js +21 -0
  552. package/node_modules/undici/lib/interceptor/redirect.js +14 -11
  553. package/node_modules/undici/lib/interceptor/response-error.js +22 -31
  554. package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  555. package/node_modules/undici/lib/llhttp/constants.js +193 -446
  556. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -11
  557. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -11
  558. package/node_modules/undici/lib/llhttp/utils.js +12 -9
  559. package/node_modules/undici/lib/mock/mock-agent.js +22 -106
  560. package/node_modules/undici/lib/mock/mock-client.js +4 -13
  561. package/node_modules/undici/lib/mock/mock-errors.js +2 -3
  562. package/node_modules/undici/lib/mock/mock-interceptor.js +13 -33
  563. package/node_modules/undici/lib/mock/mock-pool.js +4 -13
  564. package/node_modules/undici/lib/mock/mock-symbols.js +1 -10
  565. package/node_modules/undici/lib/mock/mock-utils.js +51 -404
  566. package/node_modules/undici/lib/mock/pluralizer.js +29 -0
  567. package/node_modules/undici/lib/util/timers.js +9 -11
  568. package/node_modules/undici/lib/web/cache/cache.js +51 -63
  569. package/node_modules/undici/lib/web/cache/cachestorage.js +7 -13
  570. package/node_modules/undici/lib/web/cache/symbols.js +5 -0
  571. package/node_modules/undici/lib/web/cookies/index.js +18 -45
  572. package/node_modules/undici/lib/web/cookies/parse.js +149 -157
  573. package/node_modules/undici/lib/web/cookies/util.js +2 -4
  574. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +9 -37
  575. package/node_modules/undici/lib/web/eventsource/eventsource.js +64 -108
  576. package/node_modules/undici/lib/web/eventsource/util.js +5 -28
  577. package/node_modules/undici/lib/web/fetch/body.js +148 -173
  578. package/node_modules/undici/lib/web/fetch/constants.js +6 -13
  579. package/node_modules/undici/lib/web/fetch/data-url.js +167 -19
  580. package/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +46 -0
  581. package/node_modules/undici/lib/web/fetch/file.js +126 -0
  582. package/node_modules/undici/lib/web/fetch/formdata-parser.js +117 -229
  583. package/node_modules/undici/lib/web/fetch/formdata.js +65 -85
  584. package/node_modules/undici/lib/web/fetch/headers.js +108 -143
  585. package/node_modules/undici/lib/web/fetch/index.js +446 -627
  586. package/node_modules/undici/lib/web/fetch/request.js +115 -217
  587. package/node_modules/undici/lib/web/fetch/response.js +82 -110
  588. package/node_modules/undici/lib/web/fetch/symbols.js +9 -0
  589. package/node_modules/undici/lib/web/fetch/util.js +393 -291
  590. package/node_modules/undici/lib/web/fetch/webidl.js +695 -0
  591. package/node_modules/undici/lib/web/fileapi/encoding.js +290 -0
  592. package/node_modules/undici/lib/web/fileapi/filereader.js +344 -0
  593. package/node_modules/undici/lib/web/fileapi/progressevent.js +78 -0
  594. package/node_modules/undici/lib/web/fileapi/symbols.js +10 -0
  595. package/node_modules/undici/lib/web/fileapi/util.js +391 -0
  596. package/node_modules/undici/lib/web/websocket/connection.js +160 -139
  597. package/node_modules/undici/lib/web/websocket/constants.js +10 -70
  598. package/node_modules/undici/lib/web/websocket/events.js +30 -49
  599. package/node_modules/undici/lib/web/websocket/frame.js +20 -51
  600. package/node_modules/undici/lib/web/websocket/receiver.js +87 -83
  601. package/node_modules/undici/lib/web/websocket/sender.js +13 -18
  602. package/node_modules/undici/lib/web/websocket/symbols.js +12 -0
  603. package/node_modules/undici/lib/web/websocket/util.js +90 -115
  604. package/node_modules/undici/lib/web/websocket/websocket.js +171 -359
  605. package/node_modules/undici/package.json +57 -49
  606. package/node_modules/undici/scripts/strip-comments.js +1 -3
  607. package/node_modules/undici/types/agent.d.ts +13 -12
  608. package/node_modules/undici/types/api.d.ts +26 -26
  609. package/node_modules/undici/types/balanced-pool.d.ts +12 -13
  610. package/node_modules/undici/types/client.d.ts +39 -98
  611. package/node_modules/undici/types/connector.d.ts +2 -5
  612. package/node_modules/undici/types/cookies.d.ts +1 -3
  613. package/node_modules/undici/types/diagnostics-channel.d.ts +11 -20
  614. package/node_modules/undici/types/dispatcher.d.ts +139 -136
  615. package/node_modules/undici/types/env-http-proxy-agent.d.ts +3 -4
  616. package/node_modules/undici/types/errors.d.ts +54 -86
  617. package/node_modules/undici/types/eventsource.d.ts +4 -9
  618. package/node_modules/undici/types/fetch.d.ts +25 -51
  619. package/node_modules/undici/types/file.d.ts +39 -0
  620. package/node_modules/undici/types/filereader.d.ts +54 -0
  621. package/node_modules/undici/types/formdata.d.ts +7 -7
  622. package/node_modules/undici/types/global-dispatcher.d.ts +4 -4
  623. package/node_modules/undici/types/global-origin.d.ts +5 -5
  624. package/node_modules/undici/types/handlers.d.ts +9 -10
  625. package/node_modules/undici/types/header.d.ts +1 -162
  626. package/node_modules/undici/types/index.d.ts +47 -69
  627. package/node_modules/undici/types/interceptors.d.ts +12 -62
  628. package/node_modules/undici/types/mock-agent.d.ts +27 -46
  629. package/node_modules/undici/types/mock-client.d.ts +4 -6
  630. package/node_modules/undici/types/mock-errors.d.ts +3 -3
  631. package/node_modules/undici/types/mock-interceptor.d.ts +21 -26
  632. package/node_modules/undici/types/mock-pool.d.ts +4 -6
  633. package/node_modules/undici/types/patch.d.ts +4 -0
  634. package/node_modules/undici/types/pool-stats.d.ts +8 -8
  635. package/node_modules/undici/types/pool.d.ts +14 -14
  636. package/node_modules/undici/types/proxy-agent.d.ts +6 -13
  637. package/node_modules/undici/types/readable.d.ts +16 -19
  638. package/node_modules/undici/types/retry-agent.d.ts +1 -1
  639. package/node_modules/undici/types/retry-handler.d.ts +9 -18
  640. package/node_modules/undici/types/util.d.ts +3 -3
  641. package/node_modules/undici/types/webidl.d.ts +32 -156
  642. package/node_modules/undici/types/websocket.d.ts +10 -48
  643. package/node_modules/validate-npm-package-name/package.json +4 -4
  644. package/node_modules/which/package.json +4 -4
  645. package/node_modules/write-file-atomic/package.json +4 -4
  646. package/package.json +56 -60
  647. package/node_modules/@npmcli/arborist/lib/npm-extension.js +0 -237
  648. package/node_modules/@npmcli/arborist/lib/package-extensions.js +0 -236
  649. package/node_modules/@npmcli/arborist/lib/patch.js +0 -111
  650. package/node_modules/@npmcli/arborist/lib/patched-dependencies.js +0 -168
  651. package/node_modules/cacache/lib/util/cache-dir.js +0 -29
  652. package/node_modules/diff/CONTRIBUTING.md +0 -28
  653. package/node_modules/diff/LICENSE +0 -29
  654. package/node_modules/diff/README.md +0 -388
  655. package/node_modules/diff/dist/diff.js +0 -1782
  656. package/node_modules/diff/dist/diff.min.js +0 -1
  657. package/node_modules/diff/eslint.config.mjs +0 -182
  658. package/node_modules/diff/libcjs/convert/dmp.d.ts +0 -8
  659. package/node_modules/diff/libcjs/convert/dmp.d.ts.map +0 -1
  660. package/node_modules/diff/libcjs/convert/dmp.js +0 -24
  661. package/node_modules/diff/libcjs/convert/xml.d.ts +0 -6
  662. package/node_modules/diff/libcjs/convert/xml.d.ts.map +0 -1
  663. package/node_modules/diff/libcjs/convert/xml.js +0 -34
  664. package/node_modules/diff/libcjs/diff/array.d.ts +0 -19
  665. package/node_modules/diff/libcjs/diff/array.d.ts.map +0 -1
  666. package/node_modules/diff/libcjs/diff/array.js +0 -40
  667. package/node_modules/diff/libcjs/diff/base.d.ts +0 -20
  668. package/node_modules/diff/libcjs/diff/base.d.ts.map +0 -1
  669. package/node_modules/diff/libcjs/diff/base.js +0 -265
  670. package/node_modules/diff/libcjs/diff/character.d.ts +0 -19
  671. package/node_modules/diff/libcjs/diff/character.d.ts.map +0 -1
  672. package/node_modules/diff/libcjs/diff/character.js +0 -31
  673. package/node_modules/diff/libcjs/diff/css.d.ts +0 -18
  674. package/node_modules/diff/libcjs/diff/css.d.ts.map +0 -1
  675. package/node_modules/diff/libcjs/diff/css.js +0 -34
  676. package/node_modules/diff/libcjs/diff/json.d.ts +0 -24
  677. package/node_modules/diff/libcjs/diff/json.d.ts.map +0 -1
  678. package/node_modules/diff/libcjs/diff/json.js +0 -105
  679. package/node_modules/diff/libcjs/diff/line.d.ts +0 -24
  680. package/node_modules/diff/libcjs/diff/line.d.ts.map +0 -1
  681. package/node_modules/diff/libcjs/diff/line.js +0 -89
  682. package/node_modules/diff/libcjs/diff/sentence.d.ts +0 -21
  683. package/node_modules/diff/libcjs/diff/sentence.d.ts.map +0 -1
  684. package/node_modules/diff/libcjs/diff/sentence.js +0 -67
  685. package/node_modules/diff/libcjs/diff/word.d.ts +0 -35
  686. package/node_modules/diff/libcjs/diff/word.d.ts.map +0 -1
  687. package/node_modules/diff/libcjs/diff/word.js +0 -312
  688. package/node_modules/diff/libcjs/index.d.ts +0 -20
  689. package/node_modules/diff/libcjs/index.d.ts.map +0 -1
  690. package/node_modules/diff/libcjs/index.js +0 -64
  691. package/node_modules/diff/libcjs/package.json +0 -1
  692. package/node_modules/diff/libcjs/patch/apply.d.ts +0 -62
  693. package/node_modules/diff/libcjs/patch/apply.d.ts.map +0 -1
  694. package/node_modules/diff/libcjs/patch/apply.js +0 -267
  695. package/node_modules/diff/libcjs/patch/create.d.ts +0 -122
  696. package/node_modules/diff/libcjs/patch/create.d.ts.map +0 -1
  697. package/node_modules/diff/libcjs/patch/create.js +0 -251
  698. package/node_modules/diff/libcjs/patch/line-endings.d.ts +0 -17
  699. package/node_modules/diff/libcjs/patch/line-endings.d.ts.map +0 -1
  700. package/node_modules/diff/libcjs/patch/line-endings.js +0 -61
  701. package/node_modules/diff/libcjs/patch/parse.d.ts +0 -8
  702. package/node_modules/diff/libcjs/patch/parse.d.ts.map +0 -1
  703. package/node_modules/diff/libcjs/patch/parse.js +0 -150
  704. package/node_modules/diff/libcjs/patch/reverse.d.ts +0 -9
  705. package/node_modules/diff/libcjs/patch/reverse.d.ts.map +0 -1
  706. package/node_modules/diff/libcjs/patch/reverse.js +0 -37
  707. package/node_modules/diff/libcjs/types.d.ts +0 -213
  708. package/node_modules/diff/libcjs/types.d.ts.map +0 -1
  709. package/node_modules/diff/libcjs/types.js +0 -2
  710. package/node_modules/diff/libcjs/util/array.d.ts +0 -3
  711. package/node_modules/diff/libcjs/util/array.d.ts.map +0 -1
  712. package/node_modules/diff/libcjs/util/array.js +0 -21
  713. package/node_modules/diff/libcjs/util/distance-iterator.d.ts +0 -2
  714. package/node_modules/diff/libcjs/util/distance-iterator.d.ts.map +0 -1
  715. package/node_modules/diff/libcjs/util/distance-iterator.js +0 -40
  716. package/node_modules/diff/libcjs/util/params.d.ts +0 -4
  717. package/node_modules/diff/libcjs/util/params.d.ts.map +0 -1
  718. package/node_modules/diff/libcjs/util/params.js +0 -17
  719. package/node_modules/diff/libcjs/util/string.d.ts +0 -30
  720. package/node_modules/diff/libcjs/util/string.d.ts.map +0 -1
  721. package/node_modules/diff/libcjs/util/string.js +0 -200
  722. package/node_modules/diff/libesm/convert/dmp.d.ts +0 -8
  723. package/node_modules/diff/libesm/convert/dmp.d.ts.map +0 -1
  724. package/node_modules/diff/libesm/convert/dmp.js +0 -21
  725. package/node_modules/diff/libesm/convert/xml.d.ts +0 -6
  726. package/node_modules/diff/libesm/convert/xml.d.ts.map +0 -1
  727. package/node_modules/diff/libesm/convert/xml.js +0 -31
  728. package/node_modules/diff/libesm/diff/array.d.ts +0 -19
  729. package/node_modules/diff/libesm/diff/array.d.ts.map +0 -1
  730. package/node_modules/diff/libesm/diff/array.js +0 -16
  731. package/node_modules/diff/libesm/diff/base.d.ts +0 -20
  732. package/node_modules/diff/libesm/diff/base.d.ts.map +0 -1
  733. package/node_modules/diff/libesm/diff/base.js +0 -253
  734. package/node_modules/diff/libesm/diff/character.d.ts +0 -19
  735. package/node_modules/diff/libesm/diff/character.d.ts.map +0 -1
  736. package/node_modules/diff/libesm/diff/character.js +0 -7
  737. package/node_modules/diff/libesm/diff/css.d.ts +0 -18
  738. package/node_modules/diff/libesm/diff/css.d.ts.map +0 -1
  739. package/node_modules/diff/libesm/diff/css.js +0 -10
  740. package/node_modules/diff/libesm/diff/json.d.ts +0 -24
  741. package/node_modules/diff/libesm/diff/json.d.ts.map +0 -1
  742. package/node_modules/diff/libesm/diff/json.js +0 -78
  743. package/node_modules/diff/libesm/diff/line.d.ts +0 -24
  744. package/node_modules/diff/libesm/diff/line.d.ts.map +0 -1
  745. package/node_modules/diff/libesm/diff/line.js +0 -65
  746. package/node_modules/diff/libesm/diff/sentence.d.ts +0 -21
  747. package/node_modules/diff/libesm/diff/sentence.d.ts.map +0 -1
  748. package/node_modules/diff/libesm/diff/sentence.js +0 -43
  749. package/node_modules/diff/libesm/diff/word.d.ts +0 -35
  750. package/node_modules/diff/libesm/diff/word.d.ts.map +0 -1
  751. package/node_modules/diff/libesm/diff/word.js +0 -281
  752. package/node_modules/diff/libesm/index.d.ts +0 -20
  753. package/node_modules/diff/libesm/index.d.ts.map +0 -1
  754. package/node_modules/diff/libesm/index.js +0 -30
  755. package/node_modules/diff/libesm/package.json +0 -1
  756. package/node_modules/diff/libesm/patch/apply.d.ts +0 -62
  757. package/node_modules/diff/libesm/patch/apply.d.ts.map +0 -1
  758. package/node_modules/diff/libesm/patch/apply.js +0 -257
  759. package/node_modules/diff/libesm/patch/create.d.ts +0 -122
  760. package/node_modules/diff/libesm/patch/create.d.ts.map +0 -1
  761. package/node_modules/diff/libesm/patch/create.js +0 -228
  762. package/node_modules/diff/libesm/patch/line-endings.d.ts +0 -17
  763. package/node_modules/diff/libesm/patch/line-endings.d.ts.map +0 -1
  764. package/node_modules/diff/libesm/patch/line-endings.js +0 -44
  765. package/node_modules/diff/libesm/patch/parse.d.ts +0 -8
  766. package/node_modules/diff/libesm/patch/parse.d.ts.map +0 -1
  767. package/node_modules/diff/libesm/patch/parse.js +0 -147
  768. package/node_modules/diff/libesm/patch/reverse.d.ts +0 -9
  769. package/node_modules/diff/libesm/patch/reverse.d.ts.map +0 -1
  770. package/node_modules/diff/libesm/patch/reverse.js +0 -23
  771. package/node_modules/diff/libesm/types.d.ts +0 -213
  772. package/node_modules/diff/libesm/types.d.ts.map +0 -1
  773. package/node_modules/diff/libesm/types.js +0 -1
  774. package/node_modules/diff/libesm/util/array.d.ts +0 -3
  775. package/node_modules/diff/libesm/util/array.d.ts.map +0 -1
  776. package/node_modules/diff/libesm/util/array.js +0 -17
  777. package/node_modules/diff/libesm/util/distance-iterator.d.ts +0 -2
  778. package/node_modules/diff/libesm/util/distance-iterator.d.ts.map +0 -1
  779. package/node_modules/diff/libesm/util/distance-iterator.js +0 -37
  780. package/node_modules/diff/libesm/util/params.d.ts +0 -4
  781. package/node_modules/diff/libesm/util/params.d.ts.map +0 -1
  782. package/node_modules/diff/libesm/util/params.js +0 -14
  783. package/node_modules/diff/libesm/util/string.d.ts +0 -30
  784. package/node_modules/diff/libesm/util/string.d.ts.map +0 -1
  785. package/node_modules/diff/libesm/util/string.js +0 -184
  786. package/node_modules/diff/package.json +0 -130
  787. package/node_modules/diff/release-notes.md +0 -432
  788. package/node_modules/node-gyp/commitlint.config.mjs +0 -3
  789. package/node_modules/node-gyp/gyp/commitlint.config.js +0 -6
  790. package/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake_test.py +0 -105
  791. package/node_modules/node-gyp/zizmor.yml +0 -5
  792. package/node_modules/proxy-agent-negotiate/dist/index.d.ts +0 -14
  793. package/node_modules/proxy-agent-negotiate/dist/index.d.ts.map +0 -1
  794. package/node_modules/proxy-agent-negotiate/dist/index.js +0 -35
  795. package/node_modules/proxy-agent-negotiate/dist/index.js.map +0 -1
  796. package/node_modules/proxy-agent-negotiate/package.json +0 -47
  797. package/node_modules/undici/docs/docs/api/CacheStore.md +0 -360
  798. package/node_modules/undici/docs/docs/api/ClientStats.md +0 -93
  799. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +0 -121
  800. package/node_modules/undici/docs/docs/api/H2CClient.md +0 -385
  801. package/node_modules/undici/docs/docs/api/Interceptors.md +0 -419
  802. package/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -371
  803. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -206
  804. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +0 -239
  805. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +0 -361
  806. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +0 -256
  807. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +0 -233
  808. package/node_modules/undici/docs/docs/getting-started.md +0 -281
  809. package/node_modules/undici/docs/docs/site.json +0 -125
  810. package/node_modules/undici/docs/docs/type-map.json +0 -79
  811. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +0 -110
  812. package/node_modules/undici/types/dispatcher1-wrapper.d.ts +0 -7
  813. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/core/socks5-client.js +0 -0
  814. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/core/socks5-utils.js +0 -0
  815. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/encoding/index.js +0 -0
  816. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/llhttp/constants.d.ts +0 -0
  817. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/llhttp/utils.d.ts +0 -0
  818. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-utils.js +0 -0
  819. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/date.js +0 -0
  820. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/stats.js +0 -0
  821. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/subresource-integrity/Readme.md +0 -0
  822. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/subresource-integrity/subresource-integrity.js +0 -0
  823. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/cache-interceptor.d.ts +0 -0
  824. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/client-stats.d.ts +0 -0
  825. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/mock-call-history.d.ts +0 -0
  826. /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/utility.d.ts +0 -0
@@ -7,13 +7,13 @@ const {
7
7
  makeAppropriateNetworkError,
8
8
  filterResponse,
9
9
  makeResponse,
10
- fromInnerResponse,
11
- getResponseState
10
+ fromInnerResponse
12
11
  } = require('./response')
13
12
  const { HeadersList } = require('./headers')
14
- const { Request, cloneRequest, getRequestDispatcher, getRequestState, removeRequestAbortListener } = require('./request')
13
+ const { Request, cloneRequest } = require('./request')
15
14
  const zlib = require('node:zlib')
16
15
  const {
16
+ bytesMatch,
17
17
  makePolicyContainer,
18
18
  clonePolicyContainer,
19
19
  requestBadPort,
@@ -29,12 +29,15 @@ const {
29
29
  crossOriginResourcePolicyCheck,
30
30
  determineRequestsReferrer,
31
31
  coarsenedSharedCurrentTime,
32
+ createDeferredPromise,
33
+ isBlobLike,
32
34
  sameOrigin,
33
35
  isCancelled,
34
36
  isAborted,
35
37
  isErrorLike,
36
38
  fullyReadBody,
37
39
  readableStreamClose,
40
+ isomorphicEncode,
38
41
  urlIsLocal,
39
42
  urlIsHttpHttpsScheme,
40
43
  urlHasHttpsScheme,
@@ -42,11 +45,9 @@ const {
42
45
  simpleRangeHeaderValue,
43
46
  buildContentRange,
44
47
  createInflate,
45
- extractMimeType,
46
- hasAuthenticationEntry,
47
- includesCredentials,
48
- isTraversableNavigable
48
+ extractMimeType
49
49
  } = require('./util')
50
+ const { kState, kDispatcher } = require('./symbols')
50
51
  const assert = require('node:assert')
51
52
  const { safelyExtractBody, extractBody } = require('./body')
52
53
  const {
@@ -57,16 +58,12 @@ const {
57
58
  subresourceSet
58
59
  } = require('./constants')
59
60
  const EE = require('node:events')
60
- const { Readable, pipeline, finished, isErrored, isReadable } = require('node:stream')
61
- const { addAbortListener, bufferToLowerCasedHeaderName } = require('../../core/util')
62
- const { SocketError } = require('../../core/errors')
61
+ const { Readable, pipeline, finished } = require('node:stream')
62
+ const { addAbortListener, isErrored, isReadable, bufferToLowerCasedHeaderName } = require('../../core/util')
63
63
  const { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require('./data-url')
64
64
  const { getGlobalDispatcher } = require('../../global')
65
- const { webidl } = require('../webidl')
65
+ const { webidl } = require('./webidl')
66
66
  const { STATUS_CODES } = require('node:http')
67
- const { bytesMatch } = require('../subresource-integrity/subresource-integrity')
68
- const { isomorphicEncode } = require('../infra')
69
-
70
67
  const GET_OR_HEAD = ['GET', 'HEAD']
71
68
 
72
69
  const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esbuildDetection !== 'undefined'
@@ -76,35 +73,6 @@ const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esb
76
73
  /** @type {import('buffer').resolveObjectURL} */
77
74
  let resolveObjectURL
78
75
 
79
- function appendHeadersListFromResponseHeaders (headersList, headers, rawHeaders) {
80
- if (Array.isArray(rawHeaders)) {
81
- for (let i = 0; i < rawHeaders.length; i += 2) {
82
- const nameStr = bufferToLowerCasedHeaderName(rawHeaders[i])
83
- const value = rawHeaders[i + 1]
84
-
85
- if (Array.isArray(value) && !Buffer.isBuffer(value)) {
86
- for (const val of value) {
87
- headersList.append(nameStr, val.toString('latin1'), true)
88
- }
89
- } else {
90
- headersList.append(nameStr, value.toString('latin1'), true)
91
- }
92
- }
93
-
94
- return
95
- }
96
-
97
- for (const [name, value] of Object.entries(headers ?? {})) {
98
- if (Array.isArray(value)) {
99
- for (const entry of value) {
100
- headersList.append(name, `${entry}`, true)
101
- }
102
- } else {
103
- headersList.append(name, `${value}`, true)
104
- }
105
- }
106
- }
107
-
108
76
  class Fetch extends EE {
109
77
  constructor (dispatcher) {
110
78
  super()
@@ -161,7 +129,7 @@ function fetch (input, init = undefined) {
161
129
  webidl.argumentLengthCheck(arguments, 1, 'globalThis.fetch')
162
130
 
163
131
  // 1. Let p be a new promise.
164
- let p = Promise.withResolvers()
132
+ let p = createDeferredPromise()
165
133
 
166
134
  // 2. Let requestObject be the result of invoking the initial value of
167
135
  // Request as constructor with input and init as arguments. If this throws
@@ -176,13 +144,13 @@ function fetch (input, init = undefined) {
176
144
  }
177
145
 
178
146
  // 3. Let request be requestObject’s request.
179
- const request = getRequestState(requestObject)
147
+ const request = requestObject[kState]
180
148
 
181
149
  // 4. If requestObject’s signal’s aborted flag is set, then:
182
150
  if (requestObject.signal.aborted) {
183
151
  // 1. Abort the fetch() call with p, request, null, and
184
152
  // requestObject’s signal’s abort reason.
185
- abortFetch(p, request, null, requestObject.signal.reason, null)
153
+ abortFetch(p, request, null, requestObject.signal.reason)
186
154
 
187
155
  // 2. Return p.
188
156
  return p.promise
@@ -209,7 +177,7 @@ function fetch (input, init = undefined) {
209
177
  let controller = null
210
178
 
211
179
  // 11. Add the following abort steps to requestObject’s signal:
212
- const removeAbortListener = addAbortListener(
180
+ addAbortListener(
213
181
  requestObject.signal,
214
182
  () => {
215
183
  // 1. Set locallyAborted to true.
@@ -225,19 +193,10 @@ function fetch (input, init = undefined) {
225
193
 
226
194
  // 4. Abort the fetch() call with p, request, responseObject,
227
195
  // and requestObject’s signal’s abort reason.
228
- abortFetch(p, request, realResponse, requestObject.signal.reason, controller.controller)
196
+ abortFetch(p, request, realResponse, requestObject.signal.reason)
229
197
  }
230
198
  )
231
199
 
232
- // Remove the `abort` listeners registered above and in the Request
233
- // constructor once the fetch has settled. Without this, reusing a single
234
- // signal across many requests leaks listeners and Node.js emits a
235
- // MaxListenersExceededWarning. See https://github.com/nodejs/undici/issues/5285
236
- const cleanupAbortListeners = () => {
237
- removeAbortListener()
238
- removeRequestAbortListener(requestObject)
239
- }
240
-
241
200
  // 12. Let handleFetchDone given response response be to finalize and
242
201
  // report timing with response, globalObject, and "fetch".
243
202
  // see function handleFetchDone
@@ -261,8 +220,7 @@ function fetch (input, init = undefined) {
261
220
  // 2. Abort the fetch() call with p, request, responseObject, and
262
221
  // deserializedError.
263
222
 
264
- abortFetch(p, request, responseObject, controller.serializedAbortReason, controller.controller)
265
- cleanupAbortListeners()
223
+ abortFetch(p, request, responseObject, controller.serializedAbortReason)
266
224
  return
267
225
  }
268
226
 
@@ -270,7 +228,6 @@ function fetch (input, init = undefined) {
270
228
  // and terminate these substeps.
271
229
  if (response.type === 'error') {
272
230
  p.reject(new TypeError('fetch failed', { cause: response.error }))
273
- cleanupAbortListeners()
274
231
  return
275
232
  }
276
233
 
@@ -285,15 +242,9 @@ function fetch (input, init = undefined) {
285
242
 
286
243
  controller = fetching({
287
244
  request,
288
- processResponseEndOfBody: (response) => {
289
- handleFetchDone(response)
290
- cleanupAbortListeners()
291
- },
245
+ processResponseEndOfBody: handleFetchDone,
292
246
  processResponse,
293
- dispatcher: getRequestDispatcher(requestObject), // undici
294
- // Keep requestObject alive to prevent its AbortController from being GC'd
295
- // See https://github.com/nodejs/undici/issues/4627
296
- requestObject
247
+ dispatcher: requestObject[kDispatcher] // undici
297
248
  })
298
249
 
299
250
  // 14. Return p.
@@ -359,9 +310,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
359
310
  originalURL.href,
360
311
  initiatorType,
361
312
  globalThis,
362
- cacheState,
363
- '', // bodyType
364
- response.status
313
+ cacheState
365
314
  )
366
315
  }
367
316
 
@@ -369,7 +318,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
369
318
  const markResourceTiming = performance.markResourceTiming
370
319
 
371
320
  // https://fetch.spec.whatwg.org/#abort-fetch
372
- function abortFetch (p, request, responseObject, error, controller /* undici-specific */) {
321
+ function abortFetch (p, request, responseObject, error) {
373
322
  // 1. Reject promise with error.
374
323
  if (p) {
375
324
  // We might have already resolved the promise at this stage
@@ -378,7 +327,7 @@ function abortFetch (p, request, responseObject, error, controller /* undici-spe
378
327
 
379
328
  // 2. If request’s body is not null and is readable, then cancel request’s
380
329
  // body with error.
381
- if (request.body?.stream != null && isReadable(request.body.stream)) {
330
+ if (request.body != null && isReadable(request.body?.stream)) {
382
331
  request.body.stream.cancel(error).catch((err) => {
383
332
  if (err.code === 'ERR_INVALID_STATE') {
384
333
  // Node bug?
@@ -394,12 +343,18 @@ function abortFetch (p, request, responseObject, error, controller /* undici-spe
394
343
  }
395
344
 
396
345
  // 4. Let response be responseObject’s response.
397
- const response = getResponseState(responseObject)
346
+ const response = responseObject[kState]
398
347
 
399
348
  // 5. If response’s body is not null and is readable, then error response’s
400
349
  // body with error.
401
- if (response.body?.stream != null && isReadable(response.body.stream)) {
402
- controller.error(error)
350
+ if (response.body != null && isReadable(response.body?.stream)) {
351
+ response.body.stream.cancel(error).catch((err) => {
352
+ if (err.code === 'ERR_INVALID_STATE') {
353
+ // Node bug?
354
+ return
355
+ }
356
+ throw err
357
+ })
403
358
  }
404
359
  }
405
360
 
@@ -412,8 +367,7 @@ function fetching ({
412
367
  processResponseEndOfBody,
413
368
  processResponseConsumeBody,
414
369
  useParallelQueue = false,
415
- dispatcher = getGlobalDispatcher(), // undici
416
- requestObject = null // Keep alive to prevent AbortController GC, see #4627
370
+ dispatcher = getGlobalDispatcher() // undici
417
371
  }) {
418
372
  // Ensure that the dispatcher is set accordingly
419
373
  assert(dispatcher)
@@ -467,9 +421,7 @@ function fetching ({
467
421
  processResponseConsumeBody,
468
422
  processResponseEndOfBody,
469
423
  taskDestination,
470
- crossOriginIsolatedCapability,
471
- // Keep requestObject alive to prevent its AbortController from being GC'd
472
- requestObject
424
+ crossOriginIsolatedCapability
473
425
  }
474
426
 
475
427
  // 7. If request’s body is a byte sequence, then set request’s body to
@@ -554,71 +506,75 @@ function fetching ({
554
506
  }
555
507
 
556
508
  // 16. Run main fetch given fetchParams.
557
- mainFetch(fetchParams, false)
509
+ mainFetch(fetchParams)
510
+ .catch(err => {
511
+ fetchParams.controller.terminate(err)
512
+ })
558
513
 
559
514
  // 17. Return fetchParam's controller
560
515
  return fetchParams.controller
561
516
  }
562
517
 
563
518
  // https://fetch.spec.whatwg.org/#concept-main-fetch
564
- async function mainFetch (fetchParams, recursive) {
565
- try {
566
- // 1. Let request be fetchParams’s request.
567
- const request = fetchParams.request
519
+ async function mainFetch (fetchParams, recursive = false) {
520
+ // 1. Let request be fetchParams’s request.
521
+ const request = fetchParams.request
568
522
 
569
- // 2. Let response be null.
570
- let response = null
523
+ // 2. Let response be null.
524
+ let response = null
571
525
 
572
- // 3. If request’s local-URLs-only flag is set and request’s current URL is
573
- // not local, then set response to a network error.
574
- if (request.localURLsOnly && !urlIsLocal(requestCurrentURL(request))) {
575
- response = makeNetworkError('local URLs only')
576
- }
526
+ // 3. If request’s local-URLs-only flag is set and request’s current URL is
527
+ // not local, then set response to a network error.
528
+ if (request.localURLsOnly && !urlIsLocal(requestCurrentURL(request))) {
529
+ response = makeNetworkError('local URLs only')
530
+ }
577
531
 
578
- // 4. Run report Content Security Policy violations for request.
579
- // TODO
532
+ // 4. Run report Content Security Policy violations for request.
533
+ // TODO
580
534
 
581
- // 5. Upgrade request to a potentially trustworthy URL, if appropriate.
582
- tryUpgradeRequestToAPotentiallyTrustworthyURL(request)
535
+ // 5. Upgrade request to a potentially trustworthy URL, if appropriate.
536
+ tryUpgradeRequestToAPotentiallyTrustworthyURL(request)
583
537
 
584
- // 6. If should request be blocked due to a bad port, should fetching request
585
- // be blocked as mixed content, or should request be blocked by Content
586
- // Security Policy returns blocked, then set response to a network error.
587
- if (requestBadPort(request) === 'blocked') {
588
- response = makeNetworkError('bad port')
589
- }
590
- // TODO: should fetching request be blocked as mixed content?
591
- // TODO: should request be blocked by Content Security Policy?
538
+ // 6. If should request be blocked due to a bad port, should fetching request
539
+ // be blocked as mixed content, or should request be blocked by Content
540
+ // Security Policy returns blocked, then set response to a network error.
541
+ if (requestBadPort(request) === 'blocked') {
542
+ response = makeNetworkError('bad port')
543
+ }
544
+ // TODO: should fetching request be blocked as mixed content?
545
+ // TODO: should request be blocked by Content Security Policy?
592
546
 
593
- // 7. If request’s referrer policy is the empty string, then set request’s
594
- // referrer policy to request’s policy container’s referrer policy.
595
- if (request.referrerPolicy === '') {
596
- request.referrerPolicy = request.policyContainer.referrerPolicy
597
- }
547
+ // 7. If request’s referrer policy is the empty string, then set request’s
548
+ // referrer policy to request’s policy container’s referrer policy.
549
+ if (request.referrerPolicy === '') {
550
+ request.referrerPolicy = request.policyContainer.referrerPolicy
551
+ }
598
552
 
599
- // 8. If request’s referrer is not "no-referrer", then set request’s
600
- // referrer to the result of invoking determine request’s referrer.
601
- if (request.referrer !== 'no-referrer') {
602
- request.referrer = determineRequestsReferrer(request)
603
- }
553
+ // 8. If request’s referrer is not "no-referrer", then set request’s
554
+ // referrer to the result of invoking determine request’s referrer.
555
+ if (request.referrer !== 'no-referrer') {
556
+ request.referrer = determineRequestsReferrer(request)
557
+ }
604
558
 
605
- // 9. Set request’s current URL’s scheme to "https" if all of the following
606
- // conditions are true:
607
- // - request’s current URL’s scheme is "http"
608
- // - request’s current URL’s host is a domain
609
- // - Matching request’s current URL’s host per Known HSTS Host Domain Name
610
- // Matching results in either a superdomain match with an asserted
611
- // includeSubDomains directive or a congruent match (with or without an
612
- // asserted includeSubDomains directive). [HSTS]
613
- // TODO
559
+ // 9. Set request’s current URL’s scheme to "https" if all of the following
560
+ // conditions are true:
561
+ // - request’s current URL’s scheme is "http"
562
+ // - request’s current URL’s host is a domain
563
+ // - Matching request’s current URL’s host per Known HSTS Host Domain Name
564
+ // Matching results in either a superdomain match with an asserted
565
+ // includeSubDomains directive or a congruent match (with or without an
566
+ // asserted includeSubDomains directive). [HSTS]
567
+ // TODO
614
568
 
615
- // 10. If recursive is false, then run the remaining steps in parallel.
616
- // TODO
569
+ // 10. If recursive is false, then run the remaining steps in parallel.
570
+ // TODO
617
571
 
618
- // 11. If response is null, then set response to the result of running
619
- // the steps corresponding to the first matching statement:
620
- if (response === null) {
572
+ // 11. If response is null, then set response to the result of running
573
+ // the steps corresponding to the first matching statement:
574
+ if (response === null) {
575
+ response = await (async () => {
621
576
  const currentURL = requestCurrentURL(request)
577
+
622
578
  if (
623
579
  // - request’s current URL’s origin is same origin with request’s origin,
624
580
  // and request’s response tainting is "basic"
@@ -632,188 +588,192 @@ async function mainFetch (fetchParams, recursive) {
632
588
  request.responseTainting = 'basic'
633
589
 
634
590
  // 2. Return the result of running scheme fetch given fetchParams.
635
- response = await schemeFetch(fetchParams)
591
+ return await schemeFetch(fetchParams)
592
+ }
636
593
 
637
594
  // request’s mode is "same-origin"
638
- } else if (request.mode === 'same-origin') {
595
+ if (request.mode === 'same-origin') {
639
596
  // 1. Return a network error.
640
- response = makeNetworkError('request mode cannot be "same-origin"')
597
+ return makeNetworkError('request mode cannot be "same-origin"')
598
+ }
641
599
 
642
600
  // request’s mode is "no-cors"
643
- } else if (request.mode === 'no-cors') {
601
+ if (request.mode === 'no-cors') {
644
602
  // 1. If request’s redirect mode is not "follow", then return a network
645
603
  // error.
646
604
  if (request.redirect !== 'follow') {
647
- response = makeNetworkError(
605
+ return makeNetworkError(
648
606
  'redirect mode cannot be "follow" for "no-cors" request'
649
607
  )
650
- } else {
651
- // 2. Set request’s response tainting to "opaque".
652
- request.responseTainting = 'opaque'
653
-
654
- // 3. Return the result of running scheme fetch given fetchParams.
655
- response = await schemeFetch(fetchParams)
656
608
  }
609
+
610
+ // 2. Set request’s response tainting to "opaque".
611
+ request.responseTainting = 'opaque'
612
+
613
+ // 3. Return the result of running scheme fetch given fetchParams.
614
+ return await schemeFetch(fetchParams)
615
+ }
616
+
657
617
  // request’s current URL’s scheme is not an HTTP(S) scheme
658
- } else if (!urlIsHttpHttpsScheme(requestCurrentURL(request))) {
618
+ if (!urlIsHttpHttpsScheme(requestCurrentURL(request))) {
659
619
  // Return a network error.
660
- response = makeNetworkError('URL scheme must be a HTTP(S) scheme')
661
-
662
- // - request’s use-CORS-preflight flag is set
663
- // - request’s unsafe-request flag is set and either request’s method is
664
- // not a CORS-safelisted method or CORS-unsafe request-header names with
665
- // request’s header list is not empty
666
- // 1. Set request’s response tainting to "cors".
667
- // 2. Let corsWithPreflightResponse be the result of running HTTP fetch
668
- // given fetchParams and true.
669
- // 3. If corsWithPreflightResponse is a network error, then clear cache
670
- // entries using request.
671
- // 4. Return corsWithPreflightResponse.
672
- // TODO
620
+ return makeNetworkError('URL scheme must be a HTTP(S) scheme')
621
+ }
622
+
623
+ // - request’s use-CORS-preflight flag is set
624
+ // - request’s unsafe-request flag is set and either request’s method is
625
+ // not a CORS-safelisted method or CORS-unsafe request-header names with
626
+ // request’s header list is not empty
627
+ // 1. Set request’s response tainting to "cors".
628
+ // 2. Let corsWithPreflightResponse be the result of running HTTP fetch
629
+ // given fetchParams and true.
630
+ // 3. If corsWithPreflightResponse is a network error, then clear cache
631
+ // entries using request.
632
+ // 4. Return corsWithPreflightResponse.
633
+ // TODO
673
634
 
674
635
  // Otherwise
675
- } else {
676
- // 1. Set request’s response tainting to "cors".
677
- request.responseTainting = 'cors'
636
+ // 1. Set request’s response tainting to "cors".
637
+ request.responseTainting = 'cors'
678
638
 
679
- // 2. Return the result of running HTTP fetch given fetchParams.
680
- response = await httpFetch(fetchParams)
681
- }
639
+ // 2. Return the result of running HTTP fetch given fetchParams.
640
+ return await httpFetch(fetchParams)
641
+ })()
642
+ }
643
+
644
+ // 12. If recursive is true, then return response.
645
+ if (recursive) {
646
+ return response
647
+ }
648
+
649
+ // 13. If response is not a network error and response is not a filtered
650
+ // response, then:
651
+ if (response.status !== 0 && !response.internalResponse) {
652
+ // If request’s response tainting is "cors", then:
653
+ if (request.responseTainting === 'cors') {
654
+ // 1. Let headerNames be the result of extracting header list values
655
+ // given `Access-Control-Expose-Headers` and response’s header list.
656
+ // TODO
657
+ // 2. If request’s credentials mode is not "include" and headerNames
658
+ // contains `*`, then set response’s CORS-exposed header-name list to
659
+ // all unique header names in response’s header list.
660
+ // TODO
661
+ // 3. Otherwise, if headerNames is not null or failure, then set
662
+ // response’s CORS-exposed header-name list to headerNames.
663
+ // TODO
682
664
  }
683
665
 
684
- // 12. If recursive is true, then return response.
685
- if (recursive) {
686
- return response
666
+ // Set response to the following filtered response with response as its
667
+ // internal response, depending on request’s response tainting:
668
+ if (request.responseTainting === 'basic') {
669
+ response = filterResponse(response, 'basic')
670
+ } else if (request.responseTainting === 'cors') {
671
+ response = filterResponse(response, 'cors')
672
+ } else if (request.responseTainting === 'opaque') {
673
+ response = filterResponse(response, 'opaque')
674
+ } else {
675
+ assert(false)
687
676
  }
677
+ }
688
678
 
689
- // 13. If response is not a network error and response is not a filtered
690
- // response, then:
691
- if (response.status !== 0 && !response.internalResponse) {
692
- // If request’s response tainting is "cors", then:
693
- if (request.responseTainting === 'cors') {
694
- // 1. Let headerNames be the result of extracting header list values
695
- // given `Access-Control-Expose-Headers` and response’s header list.
696
- // TODO
697
- // 2. If request’s credentials mode is not "include" and headerNames
698
- // contains `*`, then set response’s CORS-exposed header-name list to
699
- // all unique header names in response’s header list.
700
- // TODO
701
- // 3. Otherwise, if headerNames is not null or failure, then set
702
- // response’s CORS-exposed header-name list to headerNames.
703
- // TODO
704
- }
679
+ // 14. Let internalResponse be response, if response is a network error,
680
+ // and response’s internal response otherwise.
681
+ let internalResponse =
682
+ response.status === 0 ? response : response.internalResponse
705
683
 
706
- // Set response to the following filtered response with response as its
707
- // internal response, depending on request’s response tainting:
708
- if (request.responseTainting === 'basic') {
709
- response = filterResponse(response, 'basic')
710
- } else if (request.responseTainting === 'cors') {
711
- response = filterResponse(response, 'cors')
712
- } else if (request.responseTainting === 'opaque') {
713
- response = filterResponse(response, 'opaque')
714
- } else {
715
- assert(false)
716
- }
717
- }
684
+ // 15. If internalResponse’s URL list is empty, then set it to a clone of
685
+ // request’s URL list.
686
+ if (internalResponse.urlList.length === 0) {
687
+ internalResponse.urlList.push(...request.urlList)
688
+ }
718
689
 
719
- // 14. Let internalResponse be response, if response is a network error,
720
- // and response’s internal response otherwise.
721
- let internalResponse =
722
- response.status === 0 ? response : response.internalResponse
690
+ // 16. If request’s timing allow failed flag is unset, then set
691
+ // internalResponse’s timing allow passed flag.
692
+ if (!request.timingAllowFailed) {
693
+ response.timingAllowPassed = true
694
+ }
723
695
 
724
- // 15. If internalResponse’s URL list is empty, then set it to a clone of
725
- // request’s URL list.
726
- if (internalResponse.urlList.length === 0) {
727
- internalResponse.urlList.push(...request.urlList)
728
- }
696
+ // 17. If response is not a network error and any of the following returns
697
+ // blocked
698
+ // - should internalResponse to request be blocked as mixed content
699
+ // - should internalResponse to request be blocked by Content Security Policy
700
+ // - should internalResponse to request be blocked due to its MIME type
701
+ // - should internalResponse to request be blocked due to nosniff
702
+ // TODO
729
703
 
730
- // 16. If request’s timing allow failed flag is unset, then set
731
- // internalResponse’s timing allow passed flag.
732
- if (!request.timingAllowFailed) {
733
- response.timingAllowPassed = true
734
- }
704
+ // 18. If response’s type is "opaque", internalResponse’s status is 206,
705
+ // internalResponse’s range-requested flag is set, and request’s header
706
+ // list does not contain `Range`, then set response and internalResponse
707
+ // to a network error.
708
+ if (
709
+ response.type === 'opaque' &&
710
+ internalResponse.status === 206 &&
711
+ internalResponse.rangeRequested &&
712
+ !request.headers.contains('range', true)
713
+ ) {
714
+ response = internalResponse = makeNetworkError()
715
+ }
735
716
 
736
- // 17. If response is not a network error and any of the following returns
737
- // blocked
738
- // - should internalResponse to request be blocked as mixed content
739
- // - should internalResponse to request be blocked by Content Security Policy
740
- // - should internalResponse to request be blocked due to its MIME type
741
- // - should internalResponse to request be blocked due to nosniff
742
- // TODO
717
+ // 19. If response is not a network error and either request’s method is
718
+ // `HEAD` or `CONNECT`, or internalResponse’s status is a null body status,
719
+ // set internalResponse’s body to null and disregard any enqueuing toward
720
+ // it (if any).
721
+ if (
722
+ response.status !== 0 &&
723
+ (request.method === 'HEAD' ||
724
+ request.method === 'CONNECT' ||
725
+ nullBodyStatus.includes(internalResponse.status))
726
+ ) {
727
+ internalResponse.body = null
728
+ fetchParams.controller.dump = true
729
+ }
743
730
 
744
- // 18. If response’s type is "opaque", internalResponse’s status is 206,
745
- // internalResponse’s range-requested flag is set, and request’s header
746
- // list does not contain `Range`, then set response and internalResponse
747
- // to a network error.
748
- if (
749
- response.type === 'opaque' &&
750
- internalResponse.status === 206 &&
751
- internalResponse.rangeRequested &&
752
- !request.headers.contains('range', true)
753
- ) {
754
- response = internalResponse = makeNetworkError()
755
- }
731
+ // 20. If request’s integrity metadata is not the empty string, then:
732
+ if (request.integrity) {
733
+ // 1. Let processBodyError be this step: run fetch finale given fetchParams
734
+ // and a network error.
735
+ const processBodyError = (reason) =>
736
+ fetchFinale(fetchParams, makeNetworkError(reason))
756
737
 
757
- // 19. If response is not a network error and either request’s method is
758
- // `HEAD` or `CONNECT`, or internalResponse’s status is a null body status,
759
- // set internalResponse’s body to null and disregard any enqueuing toward
760
- // it (if any).
761
- if (
762
- response.status !== 0 &&
763
- (request.method === 'HEAD' ||
764
- request.method === 'CONNECT' ||
765
- nullBodyStatus.includes(internalResponse.status))
766
- ) {
767
- internalResponse.body = null
768
- fetchParams.controller.dump = true
738
+ // 2. If request’s response tainting is "opaque", or response’s body is null,
739
+ // then run processBodyError and abort these steps.
740
+ if (request.responseTainting === 'opaque' || response.body == null) {
741
+ processBodyError(response.error)
742
+ return
769
743
  }
770
744
 
771
- // 20. If request’s integrity metadata is not the empty string, then:
772
- if (request.integrity) {
773
- // 1. Let processBodyError be this step: run fetch finale given fetchParams
774
- // and a network error.
775
- const processBodyError = (reason) =>
776
- fetchFinale(fetchParams, makeNetworkError(reason))
777
-
778
- // 2. If request’s response tainting is "opaque", or response’s body is null,
779
- // then run processBodyError and abort these steps.
780
- if (request.responseTainting === 'opaque' || response.body == null) {
781
- processBodyError(response.error)
745
+ // 3. Let processBody given bytes be these steps:
746
+ const processBody = (bytes) => {
747
+ // 1. If bytes do not match request’s integrity metadata,
748
+ // then run processBodyError and abort these steps. [SRI]
749
+ if (!bytesMatch(bytes, request.integrity)) {
750
+ processBodyError('integrity mismatch')
782
751
  return
783
752
  }
784
753
 
785
- // 3. Let processBody given bytes be these steps:
786
- const processBody = (bytes) => {
787
- // 1. If bytes do not match request’s integrity metadata,
788
- // then run processBodyError and abort these steps. [SRI]
789
- if (!bytesMatch(bytes, request.integrity)) {
790
- processBodyError('integrity mismatch')
791
- return
792
- }
793
-
794
- // 2. Set response’s body to bytes as a body.
795
- response.body = safelyExtractBody(bytes)[0]
796
-
797
- // 3. Run fetch finale given fetchParams and response.
798
- fetchFinale(fetchParams, response)
799
- }
754
+ // 2. Set response’s body to bytes as a body.
755
+ response.body = safelyExtractBody(bytes)[0]
800
756
 
801
- // 4. Fully read response’s body given processBody and processBodyError.
802
- fullyReadBody(response.body, processBody, processBodyError)
803
- } else {
804
- // 21. Otherwise, run fetch finale given fetchParams and response.
757
+ // 3. Run fetch finale given fetchParams and response.
805
758
  fetchFinale(fetchParams, response)
806
759
  }
807
- } catch (err) {
808
- fetchParams.controller.terminate(err)
760
+
761
+ // 4. Fully read response’s body given processBody and processBodyError.
762
+ await fullyReadBody(response.body, processBody, processBodyError)
763
+ } else {
764
+ // 21. Otherwise, run fetch finale given fetchParams and response.
765
+ fetchFinale(fetchParams, response)
809
766
  }
810
767
  }
811
768
 
812
769
  // https://fetch.spec.whatwg.org/#concept-scheme-fetch
813
770
  // given a fetch params fetchParams
814
771
  function schemeFetch (fetchParams) {
772
+ // Note: since the connection is destroyed on redirect, which sets fetchParams to a
773
+ // cancelled state, we do not want this condition to trigger *unless* there have been
774
+ // no redirects. See https://github.com/nodejs/undici/issues/1776
815
775
  // 1. If fetchParams is canceled, then return the appropriate network error for fetchParams.
816
- if (isCancelled(fetchParams)) {
776
+ if (isCancelled(fetchParams) && fetchParams.request.redirectCount === 0) {
817
777
  return Promise.resolve(makeAppropriateNetworkError(fetchParams))
818
778
  }
819
779
 
@@ -850,7 +810,7 @@ function schemeFetch (fetchParams) {
850
810
 
851
811
  // 2. If request’s method is not `GET`, blobURLEntry is null, or blobURLEntry’s
852
812
  // object is not a Blob object, then return a network error.
853
- if (request.method !== 'GET' || !webidl.is.Blob(blob)) {
813
+ if (request.method !== 'GET' || !isBlobLike(blob)) {
854
814
  return Promise.resolve(makeNetworkError('invalid method'))
855
815
  }
856
816
 
@@ -928,7 +888,7 @@ function schemeFetch (fetchParams) {
928
888
 
929
889
  // 8. Let slicedBlob be the result of invoking slice blob given blob, rangeStart,
930
890
  // rangeEnd + 1, and type.
931
- const slicedBlob = blob.slice(rangeStart, rangeEnd + 1, type)
891
+ const slicedBlob = blob.slice(rangeStart, rangeEnd, type)
932
892
 
933
893
  // 9. Let slicedBodyWithType be the result of safely extracting slicedBlob.
934
894
  // Note: same reason as mentioned above as to why we use extractBody
@@ -1027,21 +987,21 @@ function fetchFinale (fetchParams, response) {
1027
987
  // `Server-Timing` from response’s internal response’s header list.
1028
988
  // TODO
1029
989
 
1030
- // 3. If fetchParams’s request’s destination is "document", then set fetchParams’s controller’s
1031
- // full timing info to fetchParams’s timing info.
1032
- if (fetchParams.request.destination === 'document') {
1033
- fetchParams.controller.fullTimingInfo = timingInfo
1034
- }
1035
-
1036
- // 4. Let processResponseEndOfBody be the following steps:
990
+ // 3. Let processResponseEndOfBody be the following steps:
1037
991
  const processResponseEndOfBody = () => {
1038
992
  // 1. Let unsafeEndTime be the unsafe shared current time.
1039
993
  const unsafeEndTime = Date.now() // ?
1040
994
 
1041
- // 2. Set fetchParams’s controller’s report timing steps to the following steps given a global object global:
995
+ // 2. If fetchParams’s request’s destination is "document", then set fetchParams’s controller’s
996
+ // full timing info to fetchParams’s timing info.
997
+ if (fetchParams.request.destination === 'document') {
998
+ fetchParams.controller.fullTimingInfo = timingInfo
999
+ }
1000
+
1001
+ // 3. Set fetchParams’s controller’s report timing steps to the following steps given a global object global:
1042
1002
  fetchParams.controller.reportTimingSteps = () => {
1043
1003
  // 1. If fetchParams’s request’s URL’s scheme is not an HTTP(S) scheme, then return.
1044
- if (!urlIsHttpHttpsScheme(fetchParams.request.url)) {
1004
+ if (fetchParams.request.url.protocol !== 'https:') {
1045
1005
  return
1046
1006
  }
1047
1007
 
@@ -1066,7 +1026,7 @@ function fetchFinale (fetchParams, response) {
1066
1026
  let responseStatus = 0
1067
1027
 
1068
1028
  // 7. If fetchParams’s request’s mode is not "navigate" or response’s has-cross-origin-redirects is false:
1069
- if (fetchParams.request.mode !== 'navigate' || !response.hasCrossOriginRedirects) {
1029
+ if (fetchParams.request.mode !== 'navigator' || !response.hasCrossOriginRedirects) {
1070
1030
  // 1. Set responseStatus to response’s status.
1071
1031
  responseStatus = response.status
1072
1032
 
@@ -1083,11 +1043,12 @@ function fetchFinale (fetchParams, response) {
1083
1043
  // fetchParams’s request’s URL, fetchParams’s request’s initiator type, global, cacheState, bodyInfo,
1084
1044
  // and responseStatus.
1085
1045
  if (fetchParams.request.initiatorType != null) {
1046
+ // TODO: update markresourcetiming
1086
1047
  markResourceTiming(timingInfo, fetchParams.request.url.href, fetchParams.request.initiatorType, globalThis, cacheState, bodyInfo, responseStatus)
1087
1048
  }
1088
1049
  }
1089
1050
 
1090
- // 3. Let processResponseEndOfBodyTask be the following steps:
1051
+ // 4. Let processResponseEndOfBodyTask be the following steps:
1091
1052
  const processResponseEndOfBodyTask = () => {
1092
1053
  // 1. Set fetchParams’s request’s done flag.
1093
1054
  fetchParams.request.done = true
@@ -1106,11 +1067,11 @@ function fetchFinale (fetchParams, response) {
1106
1067
  }
1107
1068
  }
1108
1069
 
1109
- // 4. Queue a fetch task to run processResponseEndOfBodyTask with fetchParams’s task destination
1070
+ // 5. Queue a fetch task to run processResponseEndOfBodyTask with fetchParams’s task destination
1110
1071
  queueMicrotask(() => processResponseEndOfBodyTask())
1111
1072
  }
1112
1073
 
1113
- // 5. If fetchParams’s process response is non-null, then queue a fetch task to run fetchParams’s
1074
+ // 4. If fetchParams’s process response is non-null, then queue a fetch task to run fetchParams’s
1114
1075
  // process response given response, with fetchParams’s task destination.
1115
1076
  if (fetchParams.processResponse != null) {
1116
1077
  queueMicrotask(() => {
@@ -1119,14 +1080,11 @@ function fetchFinale (fetchParams, response) {
1119
1080
  })
1120
1081
  }
1121
1082
 
1122
- // 6. Let internalResponse be response, if response is a network error; otherwise response’s internal response.
1083
+ // 5. Let internalResponse be response, if response is a network error; otherwise response’s internal response.
1123
1084
  const internalResponse = response.type === 'error' ? response : (response.internalResponse ?? response)
1124
1085
 
1125
- // 7. If response is a network error, then run the WebDriver BiDi fetch error steps with request.
1126
- // Otherwise, run the WebDriver BiDi response completed steps with request and response.
1127
-
1128
- // 8. If internalResponse’s body is null, then run processResponseEndOfBody.
1129
- // 9. Otherwise:
1086
+ // 6. If internalResponse’s body is null, then run processResponseEndOfBody.
1087
+ // 7. Otherwise:
1130
1088
  if (internalResponse.body == null) {
1131
1089
  processResponseEndOfBody()
1132
1090
  } else {
@@ -1144,27 +1102,6 @@ function fetchFinale (fetchParams, response) {
1144
1102
  processResponseEndOfBody()
1145
1103
  })
1146
1104
  }
1147
-
1148
- // 10. If fetchParams’s process response consume body is non-null, then:
1149
- if (fetchParams.processResponseConsumeBody != null) {
1150
- // 1. Let processBody given nullOrBytes be this step: run fetchParams’s
1151
- // process response consume body given response and nullOrBytes.
1152
- const processBody = (nullOrBytes) => fetchParams.processResponseConsumeBody(response, nullOrBytes)
1153
-
1154
- // 2. Let processBodyError be this step: run fetchParams’s process
1155
- // response consume body given response and failure.
1156
- const processBodyError = () => fetchParams.processResponseConsumeBody(response, 'failure')
1157
-
1158
- // 3. If internalResponse’s body is null, then queue a fetch task to run
1159
- // processBody given null, with fetchParams’s task destination.
1160
- if (internalResponse.body == null) {
1161
- queueMicrotask(() => processBody(null))
1162
- } else {
1163
- // 4. Otherwise, fully read internalResponse’s body given processBody,
1164
- // processBodyError, and fetchParams’s task destination.
1165
- fullyReadBody(internalResponse.body, processBody, processBodyError)
1166
- }
1167
- }
1168
1105
  }
1169
1106
 
1170
1107
  // https://fetch.spec.whatwg.org/#http-fetch
@@ -1240,7 +1177,7 @@ async function httpFetch (fetchParams) {
1240
1177
  // encouraged to, transmit an RST_STREAM frame.
1241
1178
  // See, https://github.com/whatwg/fetch/issues/1288
1242
1179
  if (request.redirect !== 'manual') {
1243
- fetchParams.controller.connection.destroy()
1180
+ fetchParams.controller.connection.destroy(undefined, false)
1244
1181
  }
1245
1182
 
1246
1183
  // 2. Switch on request’s redirect mode:
@@ -1381,8 +1318,8 @@ function httpRedirectFetch (fetchParams, response) {
1381
1318
  request.headersList.delete('host', true)
1382
1319
  }
1383
1320
 
1384
- // 14. If request's body is non-null, then set request's body to the first return
1385
- // value of safely extracting request's body's source.
1321
+ // 14. If request’s body is non-null, then set request’s body to the first return
1322
+ // value of safely extracting request’s body’s source.
1386
1323
  if (request.body != null) {
1387
1324
  assert(request.body.source != null)
1388
1325
  request.body = safelyExtractBody(request.body.source)[0]
@@ -1453,16 +1390,7 @@ async function httpNetworkOrCacheFetch (
1453
1390
  // Otherwise:
1454
1391
 
1455
1392
  // 1. Set httpRequest to a clone of request.
1456
- // Implementations are encouraged to avoid teeing request’s body’s stream
1457
- // when request’s body’s source is null as only a single body is needed in
1458
- // that case. E.g., when request’s body’s source is null, redirects and
1459
- // authentication will end up failing the fetch.
1460
- if (request.body?.source != null) {
1461
- httpRequest = cloneRequest(request)
1462
- } else {
1463
- httpRequest = cloneRequest({ ...request, body: null })
1464
- httpRequest.body = request.body
1465
- }
1393
+ httpRequest = cloneRequest(request)
1466
1394
 
1467
1395
  // 2. Set httpFetchParams to a copy of fetchParams.
1468
1396
  httpFetchParams = { ...fetchParams }
@@ -1502,10 +1430,7 @@ async function httpNetworkOrCacheFetch (
1502
1430
  // 8. If contentLengthHeaderValue is non-null, then append
1503
1431
  // `Content-Length`/contentLengthHeaderValue to httpRequest’s header
1504
1432
  // list.
1505
- if (
1506
- contentLengthHeaderValue != null &&
1507
- !httpRequest.headersList.contains('content-length', true)
1508
- ) {
1433
+ if (contentLengthHeaderValue != null) {
1509
1434
  httpRequest.headersList.append('content-length', contentLengthHeaderValue, true)
1510
1435
  }
1511
1436
 
@@ -1521,7 +1446,7 @@ async function httpNetworkOrCacheFetch (
1521
1446
  // 11. If httpRequest’s referrer is a URL, then append
1522
1447
  // `Referer`/httpRequest’s referrer, serialized and isomorphic encoded,
1523
1448
  // to httpRequest’s header list.
1524
- if (webidl.is.URL(httpRequest.referrer)) {
1449
+ if (httpRequest.referrer instanceof URL) {
1525
1450
  httpRequest.headersList.append('referer', isomorphicEncode(httpRequest.referrer.href), true)
1526
1451
  }
1527
1452
 
@@ -1535,7 +1460,7 @@ async function httpNetworkOrCacheFetch (
1535
1460
  // user agents should append `User-Agent`/default `User-Agent` value to
1536
1461
  // httpRequest’s header list.
1537
1462
  if (!httpRequest.headersList.contains('user-agent', true)) {
1538
- httpRequest.headersList.append('user-agent', defaultUserAgent, true)
1463
+ httpRequest.headersList.append('user-agent', defaultUserAgent)
1539
1464
  }
1540
1465
 
1541
1466
  // 15. If httpRequest’s cache mode is "default" and httpRequest’s header
@@ -1591,7 +1516,7 @@ async function httpNetworkOrCacheFetch (
1591
1516
  // TODO: https://github.com/whatwg/fetch/issues/1285#issuecomment-896560129
1592
1517
  if (!httpRequest.headersList.contains('accept-encoding', true)) {
1593
1518
  if (urlHasHttpsScheme(requestCurrentURL(httpRequest))) {
1594
- httpRequest.headersList.append('accept-encoding', 'br, gzip, deflate, zstd', true)
1519
+ httpRequest.headersList.append('accept-encoding', 'br, gzip, deflate', true)
1595
1520
  } else {
1596
1521
  httpRequest.headersList.append('accept-encoding', 'gzip, deflate', true)
1597
1522
  }
@@ -1599,39 +1524,13 @@ async function httpNetworkOrCacheFetch (
1599
1524
 
1600
1525
  httpRequest.headersList.delete('host', true)
1601
1526
 
1602
- // 21. If includeCredentials is true, then:
1527
+ // 20. If includeCredentials is true, then:
1603
1528
  if (includeCredentials) {
1604
1529
  // 1. If the user agent is not configured to block cookies for httpRequest
1605
1530
  // (see section 7 of [COOKIES]), then:
1606
1531
  // TODO: credentials
1607
-
1608
1532
  // 2. If httpRequest’s header list does not contain `Authorization`, then:
1609
- if (!httpRequest.headersList.contains('authorization', true)) {
1610
- // 1. Let authorizationValue be null.
1611
- let authorizationValue = null
1612
-
1613
- // 2. If there’s an authentication entry for httpRequest and either
1614
- // httpRequest’s use-URL-credentials flag is unset or httpRequest’s
1615
- // current URL does not include credentials, then set
1616
- // authorizationValue to authentication entry.
1617
- if (hasAuthenticationEntry(httpRequest) && (
1618
- httpRequest.useURLCredentials === undefined || !includesCredentials(requestCurrentURL(httpRequest))
1619
- )) {
1620
- // TODO
1621
- } else if (includesCredentials(requestCurrentURL(httpRequest)) && isAuthenticationFetch) {
1622
- // 3. Otherwise, if httpRequest’s current URL does include credentials
1623
- // and isAuthenticationFetch is true, set authorizationValue to
1624
- // httpRequest’s current URL, converted to an `Authorization` value
1625
- const { username, password } = requestCurrentURL(httpRequest)
1626
- authorizationValue = `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`
1627
- }
1628
-
1629
- // 4. If authorizationValue is non-null, then append (`Authorization`,
1630
- // authorizationValue) to httpRequest’s header list.
1631
- if (authorizationValue !== null) {
1632
- httpRequest.headersList.append('Authorization', authorizationValue, false)
1633
- }
1634
- }
1533
+ // TODO: credentials
1635
1534
  }
1636
1535
 
1637
1536
  // 21. If there’s a proxy-authentication entry, use it as appropriate.
@@ -1713,66 +1612,10 @@ async function httpNetworkOrCacheFetch (
1713
1612
  // 13. Set response’s request-includes-credentials to includeCredentials.
1714
1613
  response.requestIncludesCredentials = includeCredentials
1715
1614
 
1716
- // 14. If response’s status is 401, httpRequest’s response tainting is not "cors",
1717
- // includeCredentials is true, and request’s traversable for user prompts is
1718
- // a traversable navigable:
1719
- //
1720
- // In Node.js there is no traversable navigable to prompt the user, but we
1721
- // still need to handle URL-embedded credentials so authentication retries
1722
- // for WebSocket handshakes continue to work.
1723
- if (response.status === 401 && httpRequest.responseTainting !== 'cors' && includeCredentials && (
1724
- request.useURLCredentials !== undefined ||
1725
- isTraversableNavigable(request.traversableForUserPrompts)
1726
- )) {
1727
- // 2. If request’s body is non-null, then:
1728
- if (request.body != null) {
1729
- // 1. If request’s body’s source is null, then return a network error.
1730
- if (request.body.source == null) {
1731
- // Note: In Node.js, this code path should not be reached because
1732
- // isTraversableNavigable() returns false for non-navigable contexts.
1733
- // However, we handle it gracefully by returning the response instead of
1734
- // a network error, as we won't actually retry the request.
1735
- // This aligns with the Fetch spec discussion in whatwg/fetch#1132,
1736
- // which allows implementations flexibility when credentials can't be obtained.
1737
- return response
1738
- }
1739
-
1740
- // 2. Set request’s body to the body of the result of safely extracting
1741
- // request’s body’s source.
1742
- request.body = safelyExtractBody(request.body.source)[0]
1743
- }
1744
-
1745
- // 3. If request’s use-URL-credentials flag is unset or isAuthenticationFetch is
1746
- // true, then:
1747
- if (request.useURLCredentials === undefined || isAuthenticationFetch) {
1748
- // 1. If fetchParams is canceled, then return the appropriate network error
1749
- // for fetchParams.
1750
- if (isCancelled(fetchParams)) {
1751
- return makeAppropriateNetworkError(fetchParams)
1752
- }
1753
-
1754
- // 2. Let username and password be the result of prompting the end user for a
1755
- // username and password, respectively, in request’s traversable for user prompts.
1756
- // TODO
1757
-
1758
- // 3. Set the username given request’s current URL and username.
1759
- // requestCurrentURL(request).username = TODO
1760
-
1761
- // 4. Set the password given request’s current URL and password.
1762
- // requestCurrentURL(request).password = TODO
1763
-
1764
- // In browsers, the user will be prompted to enter a username/password before the request
1765
- // is re-sent. To prevent an infinite 401 loop, return the response for now.
1766
- // https://github.com/nodejs/undici/pull/4756
1767
- return response
1768
- }
1769
-
1770
- // 4. Set response to the result of running HTTP-network-or-cache fetch given
1771
- // fetchParams and true.
1772
- fetchParams.controller.connection.destroy()
1773
-
1774
- response = await httpNetworkOrCacheFetch(fetchParams, true)
1775
- }
1615
+ // 14. If response’s status is 401, httpRequest’s response tainting is not
1616
+ // "cors", includeCredentials is true, and request’s window is an environment
1617
+ // settings object, then:
1618
+ // TODO
1776
1619
 
1777
1620
  // 15. If response’s status is 407, then:
1778
1621
  if (response.status === 407) {
@@ -1849,10 +1692,12 @@ async function httpNetworkFetch (
1849
1692
  fetchParams.controller.connection = {
1850
1693
  abort: null,
1851
1694
  destroyed: false,
1852
- destroy (err) {
1695
+ destroy (err, abort = true) {
1853
1696
  if (!this.destroyed) {
1854
1697
  this.destroyed = true
1855
- this.abort?.(err ?? new DOMException('The operation was aborted.', 'AbortError'))
1698
+ if (abort) {
1699
+ this.abort?.(err ?? new DOMException('The operation was aborted.', 'AbortError'))
1700
+ }
1856
1701
  }
1857
1702
  }
1858
1703
  }
@@ -2043,8 +1888,8 @@ async function httpNetworkFetch (
2043
1888
 
2044
1889
  // 11. Let pullAlgorithm be an action that resumes the ongoing fetch
2045
1890
  // if it is suspended.
2046
- const pullAlgorithm = () => {
2047
- return fetchParams.controller.resume()
1891
+ const pullAlgorithm = async () => {
1892
+ await fetchParams.controller.resume()
2048
1893
  }
2049
1894
 
2050
1895
  // 12. Let cancelAlgorithm be an algorithm that aborts fetchParams’s
@@ -2070,11 +1915,15 @@ async function httpNetworkFetch (
2070
1915
  // cancelAlgorithm set to cancelAlgorithm.
2071
1916
  const stream = new ReadableStream(
2072
1917
  {
2073
- start (controller) {
1918
+ async start (controller) {
2074
1919
  fetchParams.controller.controller = controller
2075
1920
  },
2076
- pull: pullAlgorithm,
2077
- cancel: cancelAlgorithm,
1921
+ async pull (controller) {
1922
+ await pullAlgorithm(controller)
1923
+ },
1924
+ async cancel (reason) {
1925
+ await cancelAlgorithm(reason)
1926
+ },
2078
1927
  type: 'bytes'
2079
1928
  }
2080
1929
  )
@@ -2101,10 +1950,8 @@ async function httpNetworkFetch (
2101
1950
  // 19. Run these steps in parallel:
2102
1951
 
2103
1952
  // 1. Run these steps, but abort when fetchParams is canceled:
2104
- if (!fetchParams.controller.resume) {
2105
- fetchParams.controller.on('terminated', onAborted)
2106
- }
2107
-
1953
+ fetchParams.controller.onAborted = onAborted
1954
+ fetchParams.controller.on('terminated', onAborted)
2108
1955
  fetchParams.controller.resume = async () => {
2109
1956
  // 1. While true
2110
1957
  while (true) {
@@ -2212,236 +2059,208 @@ async function httpNetworkFetch (
2212
2059
 
2213
2060
  function dispatch ({ body }) {
2214
2061
  const url = requestCurrentURL(request)
2215
- /** @type {import('../../..').Agent} */
2062
+ /** @type {import('../..').Agent} */
2216
2063
  const agent = fetchParams.controller.dispatcher
2217
2064
 
2218
- const path = url.pathname + url.search
2219
- const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === '?'
2220
-
2221
- return dispatchWithProtocolPreference(body)
2222
-
2223
- function dispatchWithProtocolPreference (body, allowH2) {
2224
- return new Promise((resolve, reject) => agent.dispatch(
2225
- {
2226
- path: hasTrailingQuestionMark ? `${path}?` : path,
2227
- origin: url.origin,
2228
- method: request.method,
2229
- body: agent.isMockActive ? request.body && (request.body.source || request.body.stream) : body,
2230
- // Preserve the serialized fetch body for MockAgent net-connect fallthroughs.
2231
- __mockAgentBodyForDispatch: body,
2232
- headers: request.headersList.entries,
2233
- maxRedirections: 0,
2234
- upgrade: request.mode === 'websocket' ? 'websocket' : undefined,
2235
- ...(allowH2 === false ? { allowH2 } : null)
2065
+ return new Promise((resolve, reject) => agent.dispatch(
2066
+ {
2067
+ path: url.pathname + url.search,
2068
+ origin: url.origin,
2069
+ method: request.method,
2070
+ body: agent.isMockActive ? request.body && (request.body.source || request.body.stream) : body,
2071
+ headers: request.headersList.entries,
2072
+ maxRedirections: 0,
2073
+ upgrade: request.mode === 'websocket' ? 'websocket' : undefined
2074
+ },
2075
+ {
2076
+ body: null,
2077
+ abort: null,
2078
+
2079
+ onConnect (abort) {
2080
+ // TODO (fix): Do we need connection here?
2081
+ const { connection } = fetchParams.controller
2082
+
2083
+ // Set timingInfo’s final connection timing info to the result of calling clamp and coarsen
2084
+ // connection timing info with connection’s timing info, timingInfo’s post-redirect start
2085
+ // time, and fetchParams’s cross-origin isolated capability.
2086
+ // TODO: implement connection timing
2087
+ timingInfo.finalConnectionTimingInfo = clampAndCoarsenConnectionTimingInfo(undefined, timingInfo.postRedirectStartTime, fetchParams.crossOriginIsolatedCapability)
2088
+
2089
+ if (connection.destroyed) {
2090
+ abort(new DOMException('The operation was aborted.', 'AbortError'))
2091
+ } else {
2092
+ fetchParams.controller.on('terminated', abort)
2093
+ this.abort = connection.abort = abort
2094
+ }
2095
+
2096
+ // Set timingInfo’s final network-request start time to the coarsened shared current time given
2097
+ // fetchParams’s cross-origin isolated capability.
2098
+ timingInfo.finalNetworkRequestStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
2236
2099
  },
2237
- {
2238
- body: null,
2239
- abort: null,
2240
-
2241
- onRequestStart (controller) {
2242
- // TODO (fix): Do we need connection here?
2243
- const { connection } = fetchParams.controller
2244
-
2245
- // Set timingInfo’s final connection timing info to the result of calling clamp and coarsen
2246
- // connection timing info with connection’s timing info, timingInfo’s post-redirect start
2247
- // time, and fetchParams’s cross-origin isolated capability.
2248
- // TODO: implement connection timing
2249
- timingInfo.finalConnectionTimingInfo = clampAndCoarsenConnectionTimingInfo(undefined, timingInfo.postRedirectStartTime, fetchParams.crossOriginIsolatedCapability)
2250
-
2251
- const abort = (reason) => controller.abort(reason)
2252
-
2253
- if (connection.destroyed) {
2254
- abort(new DOMException('The operation was aborted.', 'AbortError'))
2255
- } else {
2256
- fetchParams.controller.on('terminated', abort)
2257
- this.abort = connection.abort = abort
2258
- }
2259
2100
 
2260
- // Set timingInfo’s final network-request start time to the coarsened shared current time given
2261
- // fetchParams’s cross-origin isolated capability.
2262
- timingInfo.finalNetworkRequestStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
2263
- },
2264
-
2265
- onResponseStarted () {
2266
- // Set timingInfo’s final network-response start time to the coarsened shared current
2267
- // time given fetchParams’s cross-origin isolated capability, immediately after the
2268
- // user agent’s HTTP parser receives the first byte of the response (e.g., frame header
2269
- // bytes for HTTP/2 or response status line for HTTP/1.x).
2270
- timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
2271
- },
2272
-
2273
- onResponseStart (controller, status, headers, statusText) {
2274
- if (status < 200) {
2275
- return
2276
- }
2101
+ onResponseStarted () {
2102
+ // Set timingInfo’s final network-response start time to the coarsened shared current
2103
+ // time given fetchParams’s cross-origin isolated capability, immediately after the
2104
+ // user agent’s HTTP parser receives the first byte of the response (e.g., frame header
2105
+ // bytes for HTTP/2 or response status line for HTTP/1.x).
2106
+ timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
2107
+ },
2277
2108
 
2278
- const rawHeaders = controller?.rawHeaders ?? []
2279
- const headersList = new HeadersList()
2280
- appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders)
2281
- const location = headersList.get('location', true)
2109
+ onHeaders (status, rawHeaders, resume, statusText) {
2110
+ if (status < 200) {
2111
+ return
2112
+ }
2282
2113
 
2283
- this.body = new Readable({ read: () => controller.resume() })
2114
+ let location = ''
2284
2115
 
2285
- const willFollow = location && request.redirect === 'follow' &&
2286
- redirectStatusSet.has(status)
2116
+ const headersList = new HeadersList()
2287
2117
 
2288
- const decoders = []
2118
+ for (let i = 0; i < rawHeaders.length; i += 2) {
2119
+ headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString('latin1'), true)
2120
+ }
2121
+ location = headersList.get('location', true)
2289
2122
 
2290
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
2291
- if (request.method !== 'HEAD' && request.method !== 'CONNECT' && !nullBodyStatus.includes(status) && !willFollow) {
2292
- // https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.1
2293
- const contentEncoding = headersList.get('content-encoding', true)
2294
- // "All content-coding values are case-insensitive..."
2295
- /** @type {string[]} */
2296
- const codings = contentEncoding ? contentEncoding.toLowerCase().split(',') : []
2123
+ this.body = new Readable({ read: resume })
2297
2124
 
2298
- // Limit the number of content-encodings to prevent resource exhaustion.
2299
- // CVE fix similar to urllib3 (GHSA-gm62-xv2j-4w53) and curl (CVE-2022-32206).
2300
- const maxContentEncodings = 5
2301
- if (codings.length > maxContentEncodings) {
2302
- reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`))
2303
- return
2304
- }
2125
+ const decoders = []
2305
2126
 
2306
- for (let i = codings.length - 1; i >= 0; --i) {
2307
- const coding = codings[i].trim()
2308
- // https://www.rfc-editor.org/rfc/rfc9112.html#section-7.2
2309
- if (coding === 'x-gzip' || coding === 'gzip') {
2310
- decoders.push(zlib.createGunzip({
2311
- // Be less strict when decoding compressed responses, since sometimes
2312
- // servers send slightly invalid responses that are still accepted
2313
- // by common browsers.
2314
- // Always using Z_SYNC_FLUSH is what cURL does.
2315
- flush: zlib.constants.Z_SYNC_FLUSH,
2316
- finishFlush: zlib.constants.Z_SYNC_FLUSH
2317
- }))
2318
- } else if (coding === 'deflate') {
2319
- decoders.push(createInflate({
2320
- flush: zlib.constants.Z_SYNC_FLUSH,
2321
- finishFlush: zlib.constants.Z_SYNC_FLUSH
2322
- }))
2323
- } else if (coding === 'br') {
2324
- decoders.push(zlib.createBrotliDecompress({
2325
- flush: zlib.constants.BROTLI_OPERATION_FLUSH,
2326
- finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
2327
- }))
2328
- } else if (coding === 'zstd') {
2329
- decoders.push(zlib.createZstdDecompress({
2330
- flush: zlib.constants.ZSTD_e_continue,
2331
- finishFlush: zlib.constants.ZSTD_e_end
2332
- }))
2333
- } else {
2334
- decoders.length = 0
2335
- break
2336
- }
2337
- }
2127
+ const willFollow = location && request.redirect === 'follow' &&
2128
+ redirectStatusSet.has(status)
2129
+
2130
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
2131
+ if (request.method !== 'HEAD' && request.method !== 'CONNECT' && !nullBodyStatus.includes(status) && !willFollow) {
2132
+ // https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.1
2133
+ const contentEncoding = headersList.get('content-encoding', true)
2134
+ // "All content-coding values are case-insensitive..."
2135
+ /** @type {string[]} */
2136
+ const codings = contentEncoding ? contentEncoding.toLowerCase().split(',') : []
2137
+
2138
+ // Limit the number of content-encodings to prevent resource exhaustion.
2139
+ // CVE fix similar to urllib3 (GHSA-gm62-xv2j-4w53) and curl (CVE-2022-32206).
2140
+ const maxContentEncodings = 5
2141
+ if (codings.length > maxContentEncodings) {
2142
+ reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`))
2143
+ return true
2338
2144
  }
2339
2145
 
2340
- const onError = (err) => this.onResponseError(controller, err)
2341
-
2342
- resolve({
2343
- status,
2344
- statusText,
2345
- headersList,
2346
- body: decoders.length
2347
- ? pipeline(this.body, ...decoders, (err) => {
2348
- if (err) {
2349
- this.onResponseError(controller, err)
2350
- }
2351
- }).on('error', onError)
2352
- : this.body.on('error', onError)
2353
- })
2354
- },
2355
-
2356
- onResponseData (controller, chunk) {
2357
- if (fetchParams.controller.dump) {
2358
- return
2146
+ for (let i = codings.length - 1; i >= 0; --i) {
2147
+ const coding = codings[i].trim()
2148
+ // https://www.rfc-editor.org/rfc/rfc9112.html#section-7.2
2149
+ if (coding === 'x-gzip' || coding === 'gzip') {
2150
+ decoders.push(zlib.createGunzip({
2151
+ // Be less strict when decoding compressed responses, since sometimes
2152
+ // servers send slightly invalid responses that are still accepted
2153
+ // by common browsers.
2154
+ // Always using Z_SYNC_FLUSH is what cURL does.
2155
+ flush: zlib.constants.Z_SYNC_FLUSH,
2156
+ finishFlush: zlib.constants.Z_SYNC_FLUSH
2157
+ }))
2158
+ } else if (coding === 'deflate') {
2159
+ decoders.push(createInflate({
2160
+ flush: zlib.constants.Z_SYNC_FLUSH,
2161
+ finishFlush: zlib.constants.Z_SYNC_FLUSH
2162
+ }))
2163
+ } else if (coding === 'br') {
2164
+ decoders.push(zlib.createBrotliDecompress({
2165
+ flush: zlib.constants.BROTLI_OPERATION_FLUSH,
2166
+ finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
2167
+ }))
2168
+ } else {
2169
+ decoders.length = 0
2170
+ break
2171
+ }
2359
2172
  }
2173
+ }
2360
2174
 
2361
- // 1. If one or more bytes have been transmitted from response’s
2362
- // message body, then:
2175
+ const onError = this.onError.bind(this)
2363
2176
 
2364
- // 1. Let bytes be the transmitted bytes.
2365
- const bytes = chunk
2177
+ resolve({
2178
+ status,
2179
+ statusText,
2180
+ headersList,
2181
+ body: decoders.length
2182
+ ? pipeline(this.body, ...decoders, (err) => {
2183
+ if (err) {
2184
+ this.onError(err)
2185
+ }
2186
+ }).on('error', onError)
2187
+ : this.body.on('error', onError)
2188
+ })
2366
2189
 
2367
- // 2. Let codings be the result of extracting header list values
2368
- // given `Content-Encoding` and response’s header list.
2369
- // See pullAlgorithm.
2190
+ return true
2191
+ },
2370
2192
 
2371
- // 3. Increase timingInfo’s encoded body size by bytes’s length.
2372
- timingInfo.encodedBodySize += bytes.byteLength
2193
+ onData (chunk) {
2194
+ if (fetchParams.controller.dump) {
2195
+ return
2196
+ }
2373
2197
 
2374
- // 4. See pullAlgorithm...
2198
+ // 1. If one or more bytes have been transmitted from response’s
2199
+ // message body, then:
2375
2200
 
2376
- if (this.body.push(bytes) === false) {
2377
- controller.pause()
2378
- }
2379
- },
2201
+ // 1. Let bytes be the transmitted bytes.
2202
+ const bytes = chunk
2380
2203
 
2381
- onResponseEnd () {
2382
- if (this.abort) {
2383
- fetchParams.controller.off('terminated', this.abort)
2384
- }
2204
+ // 2. Let codings be the result of extracting header list values
2205
+ // given `Content-Encoding` and response’s header list.
2206
+ // See pullAlgorithm.
2385
2207
 
2386
- fetchParams.controller.ended = true
2208
+ // 3. Increase timingInfo’s encoded body size by bytes’s length.
2209
+ timingInfo.encodedBodySize += bytes.byteLength
2387
2210
 
2388
- this.body?.push(null)
2389
- },
2211
+ // 4. See pullAlgorithm...
2390
2212
 
2391
- onResponseError (controller, error) {
2392
- if (this.abort) {
2393
- fetchParams.controller.off('terminated', this.abort)
2394
- }
2213
+ return this.body.push(bytes)
2214
+ },
2395
2215
 
2396
- if (
2397
- request.mode === 'websocket' &&
2398
- allowH2 !== false &&
2399
- error?.code === 'UND_ERR_INFO' &&
2400
- error?.message === 'HTTP/2: Extended CONNECT protocol not supported by server'
2401
- ) {
2402
- // The origin negotiated H2, but RFC 8441 websocket support is unavailable.
2403
- // Retry the opening handshake on a fresh HTTP/1.1-only connection instead.
2404
- resolve(dispatchWithProtocolPreference(body, false))
2405
- return
2406
- }
2216
+ onComplete () {
2217
+ if (this.abort) {
2218
+ fetchParams.controller.off('terminated', this.abort)
2219
+ }
2407
2220
 
2408
- this.body?.destroy(error)
2221
+ if (fetchParams.controller.onAborted) {
2222
+ fetchParams.controller.off('terminated', fetchParams.controller.onAborted)
2223
+ }
2409
2224
 
2410
- if (!controller?.aborted) {
2411
- fetchParams.controller.terminate(error)
2412
- }
2225
+ fetchParams.controller.ended = true
2413
2226
 
2414
- reject(error)
2415
- },
2416
-
2417
- onRequestUpgrade (controller, status, headers, socket) {
2418
- // We need to support 200 for websocket over h2 as per RFC-8441
2419
- // Absence of session means H1
2420
- if ((socket.session != null && status !== 200) || (socket.session == null && status !== 101)) {
2421
- if (socket.session != null) {
2422
- // The server refused the extended CONNECT, and nothing further
2423
- // will settle this request. Fail the opening handshake here.
2424
- controller.abort(new SocketError('bad upgrade', null))
2425
- }
2426
- return false
2427
- }
2227
+ this.body.push(null)
2228
+ },
2428
2229
 
2429
- const rawHeaders = controller?.rawHeaders ?? []
2430
- const headersList = new HeadersList()
2431
- appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders)
2230
+ onError (error) {
2231
+ if (this.abort) {
2232
+ fetchParams.controller.off('terminated', this.abort)
2233
+ }
2432
2234
 
2433
- resolve({
2434
- status,
2435
- statusText: STATUS_CODES[status],
2436
- headersList,
2437
- socket
2438
- })
2235
+ this.body?.destroy(error)
2439
2236
 
2440
- return true
2237
+ fetchParams.controller.terminate(error)
2238
+
2239
+ reject(error)
2240
+ },
2241
+
2242
+ onUpgrade (status, rawHeaders, socket) {
2243
+ if (status !== 101) {
2244
+ return
2245
+ }
2246
+
2247
+ const headersList = new HeadersList()
2248
+
2249
+ for (let i = 0; i < rawHeaders.length; i += 2) {
2250
+ headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString('latin1'), true)
2441
2251
  }
2252
+
2253
+ resolve({
2254
+ status,
2255
+ statusText: STATUS_CODES[status],
2256
+ headersList,
2257
+ socket
2258
+ })
2259
+
2260
+ return true
2442
2261
  }
2443
- ))
2444
- }
2262
+ }
2263
+ ))
2445
2264
  }
2446
2265
  }
2447
2266