appium-mac2-driver 4.3.5 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/WebDriverAgentMac/IntegrationTests/AMSessionTests.m +14 -0
  3. package/WebDriverAgentMac/WebDriverAgentLib/Commands/FBSessionCommands.m +17 -5
  4. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBSession.m +5 -1
  5. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBXPath.m +48 -2
  6. package/WebDriverAgentMac/WebDriverAgentMac.xcodeproj/project.pbxproj +4 -0
  7. package/build/lib/driver.d.ts +3 -0
  8. package/build/lib/driver.d.ts.map +1 -1
  9. package/build/lib/driver.js +52 -32
  10. package/build/lib/driver.js.map +1 -1
  11. package/build/lib/session-claim-handler.d.ts +41 -0
  12. package/build/lib/session-claim-handler.d.ts.map +1 -0
  13. package/build/lib/session-claim-handler.js +236 -0
  14. package/build/lib/session-claim-handler.js.map +1 -0
  15. package/build/lib/wda-mac.d.ts +6 -2
  16. package/build/lib/wda-mac.d.ts.map +1 -1
  17. package/build/lib/wda-mac.js +43 -14
  18. package/build/lib/wda-mac.js.map +1 -1
  19. package/lib/driver.ts +55 -31
  20. package/lib/session-claim-handler.ts +306 -0
  21. package/lib/wda-mac.ts +45 -15
  22. package/node_modules/@appium/logger/CHANGELOG.md +8 -0
  23. package/node_modules/@appium/logger/package.json +3 -3
  24. package/node_modules/@appium/strongbox/build/lib/index.d.ts.map +1 -1
  25. package/node_modules/@appium/strongbox/build/lib/index.js +6 -1
  26. package/node_modules/@appium/strongbox/build/lib/index.js.map +1 -1
  27. package/node_modules/@appium/strongbox/lib/index.ts +6 -1
  28. package/node_modules/@appium/strongbox/package.json +2 -2
  29. package/node_modules/@appium/support/build/lib/fs.d.ts.map +1 -1
  30. package/node_modules/@appium/support/build/lib/fs.js +7 -0
  31. package/node_modules/@appium/support/build/lib/fs.js.map +1 -1
  32. package/node_modules/@appium/support/build/lib/index.d.ts.map +1 -1
  33. package/node_modules/@appium/support/build/lib/net.d.ts.map +1 -1
  34. package/node_modules/@appium/support/build/lib/net.js +6 -2
  35. package/node_modules/@appium/support/build/lib/net.js.map +1 -1
  36. package/node_modules/@appium/support/build/lib/util.d.ts.map +1 -1
  37. package/node_modules/@appium/support/build/lib/util.js +10 -4
  38. package/node_modules/@appium/support/build/lib/util.js.map +1 -1
  39. package/node_modules/@appium/support/build/lib/zip.d.ts.map +1 -1
  40. package/node_modules/@appium/support/build/lib/zip.js +2 -7
  41. package/node_modules/@appium/support/build/lib/zip.js.map +1 -1
  42. package/node_modules/@appium/support/lib/fs.ts +8 -1
  43. package/node_modules/@appium/support/lib/net.ts +7 -2
  44. package/node_modules/@appium/support/lib/util.ts +9 -3
  45. package/node_modules/@appium/support/lib/zip.ts +3 -9
  46. package/node_modules/@appium/support/package.json +9 -9
  47. package/node_modules/@appium/types/package.json +4 -4
  48. package/node_modules/@img/sharp-darwin-arm64/index.cjs +1 -1
  49. package/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64-0.35.5.node +0 -0
  50. package/node_modules/@img/sharp-darwin-arm64/package.json +2 -2
  51. package/node_modules/@img/sharp-libvips-darwin-arm64/README.md +1 -1
  52. package/node_modules/@img/sharp-libvips-darwin-arm64/lib/glib-2.0/include/glibconfig.h +2 -2
  53. package/node_modules/@img/sharp-libvips-darwin-arm64/lib/{libvips-cpp.8.18.6.dylib → libvips-cpp.8.18.7.dylib} +0 -0
  54. package/node_modules/@img/sharp-libvips-darwin-arm64/package.json +2 -2
  55. package/node_modules/@img/sharp-libvips-darwin-arm64/versions.json +11 -11
  56. package/node_modules/appium-xcode/CHANGELOG.md +35 -0
  57. package/node_modules/appium-xcode/README.md +1 -1
  58. package/node_modules/appium-xcode/package.json +14 -18
  59. package/node_modules/async-lock/AUTHORS +21 -0
  60. package/node_modules/async-lock/History.md +132 -0
  61. package/node_modules/async-lock/LICENSE +22 -0
  62. package/node_modules/async-lock/README.md +177 -0
  63. package/node_modules/async-lock/index.js +2 -0
  64. package/node_modules/async-lock/lib/index.js +312 -0
  65. package/node_modules/async-lock/package.json +48 -0
  66. package/node_modules/b4a/browser.js +5 -0
  67. package/node_modules/b4a/index.d.ts +144 -0
  68. package/node_modules/b4a/index.js +5 -0
  69. package/node_modules/b4a/package.json +4 -1
  70. package/node_modules/b4a/runtime.d.ts +14 -0
  71. package/node_modules/bare-fs/binding.c +52 -23
  72. package/node_modules/bare-fs/index.d.ts +12 -10
  73. package/node_modules/bare-fs/index.js +43 -10
  74. package/node_modules/bare-fs/package.json +2 -1
  75. package/node_modules/bare-fs/prebuilds/android-arm/bare-fs.bare +0 -0
  76. package/node_modules/bare-fs/prebuilds/android-arm64/bare-fs.bare +0 -0
  77. package/node_modules/bare-fs/prebuilds/android-ia32/bare-fs.bare +0 -0
  78. package/node_modules/bare-fs/prebuilds/android-x64/bare-fs.bare +0 -0
  79. package/node_modules/bare-fs/prebuilds/darwin-arm64/bare-fs.bare +0 -0
  80. package/node_modules/bare-fs/prebuilds/darwin-x64/bare-fs.bare +0 -0
  81. package/node_modules/bare-fs/prebuilds/ios-arm64/bare-fs.bare +0 -0
  82. package/node_modules/bare-fs/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
  83. package/node_modules/bare-fs/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
  84. package/node_modules/bare-fs/prebuilds/linux-arm64/bare-fs.bare +0 -0
  85. package/node_modules/bare-fs/prebuilds/linux-x64/bare-fs.bare +0 -0
  86. package/node_modules/bare-fs/prebuilds/win32-arm64/bare-fs.bare +0 -0
  87. package/node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare +0 -0
  88. package/node_modules/bplist-creator/README.md +26 -6
  89. package/node_modules/bplist-creator/dist/index.cjs +508 -0
  90. package/node_modules/bplist-creator/dist/index.cjs.map +7 -0
  91. package/node_modules/bplist-creator/dist/index.d.cts +12 -0
  92. package/node_modules/bplist-creator/dist/index.d.ts +12 -0
  93. package/node_modules/bplist-creator/dist/index.mjs +472 -0
  94. package/node_modules/bplist-creator/dist/index.mjs.map +7 -0
  95. package/node_modules/bplist-creator/package.json +43 -9
  96. package/node_modules/bplist-parser/README.md +37 -3
  97. package/node_modules/bplist-parser/dist/index.cjs +385 -0
  98. package/node_modules/bplist-parser/dist/index.cjs.map +7 -0
  99. package/node_modules/bplist-parser/dist/index.d.cts +13 -0
  100. package/node_modules/bplist-parser/dist/index.d.ts +13 -0
  101. package/node_modules/bplist-parser/{bplistParser.js → dist/index.mjs} +141 -171
  102. package/node_modules/bplist-parser/dist/index.mjs.map +7 -0
  103. package/node_modules/bplist-parser/package.json +39 -12
  104. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +4 -0
  105. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -1
  106. package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
  107. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
  108. package/node_modules/brace-expansion/dist/esm/index.d.ts +4 -0
  109. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -1
  110. package/node_modules/brace-expansion/dist/esm/index.js +68 -24
  111. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
  112. package/node_modules/brace-expansion/package.json +2 -1
  113. package/node_modules/follow-redirects/index.js +10 -1
  114. package/node_modules/follow-redirects/package.json +1 -1
  115. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  116. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.js.map +1 -0
  117. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.d.ts +5 -0
  118. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.js +7 -0
  119. package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts +1400 -0
  120. package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts.map +1 -0
  121. package/node_modules/lru-cache/dist/commonjs/react-native/index.js +1733 -0
  122. package/node_modules/lru-cache/dist/commonjs/react-native/index.js.map +1 -0
  123. package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts +12 -0
  124. package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts.map +1 -0
  125. package/node_modules/lru-cache/dist/commonjs/react-native/perf.js +10 -0
  126. package/node_modules/lru-cache/dist/commonjs/react-native/perf.js.map +1 -0
  127. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  128. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.js.map +1 -0
  129. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.d.ts +5 -0
  130. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.js +4 -0
  131. package/node_modules/lru-cache/dist/esm/react-native/index.d.ts +1400 -0
  132. package/node_modules/lru-cache/dist/esm/react-native/index.d.ts.map +1 -0
  133. package/node_modules/lru-cache/dist/esm/react-native/index.js +1729 -0
  134. package/node_modules/lru-cache/dist/esm/react-native/index.js.map +1 -0
  135. package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts +12 -0
  136. package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts.map +1 -0
  137. package/node_modules/lru-cache/dist/esm/react-native/perf.js +7 -0
  138. package/node_modules/lru-cache/dist/esm/react-native/perf.js.map +1 -0
  139. package/node_modules/lru-cache/package.json +27 -1
  140. package/node_modules/p-limit/index.d.ts +2 -0
  141. package/node_modules/p-limit/index.js +17 -1
  142. package/node_modules/p-limit/package.json +1 -1
  143. package/node_modules/p-limit/readme.md +2 -0
  144. package/node_modules/readable-stream/lib/internal/shims/process.js +19 -0
  145. package/node_modules/readable-stream/lib/internal/streams/destroy.js +1 -1
  146. package/node_modules/readable-stream/lib/internal/streams/duplexify.js +1 -1
  147. package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -1
  148. package/node_modules/readable-stream/lib/internal/streams/from.js +1 -1
  149. package/node_modules/readable-stream/lib/internal/streams/legacy.js +6 -1
  150. package/node_modules/readable-stream/lib/internal/streams/pipeline.js +1 -1
  151. package/node_modules/readable-stream/lib/internal/streams/readable.js +1 -1
  152. package/node_modules/readable-stream/lib/internal/streams/writable.js +1 -1
  153. package/node_modules/readable-stream/package.json +3 -2
  154. package/node_modules/sharp/dist/index.d.cts +2 -2
  155. package/node_modules/sharp/dist/index.d.mts +3 -3
  156. package/node_modules/sharp/dist/is.cjs +8 -2
  157. package/node_modules/sharp/dist/is.mjs +8 -2
  158. package/node_modules/sharp/dist/operation.cjs +2 -2
  159. package/node_modules/sharp/dist/operation.mjs +2 -2
  160. package/node_modules/sharp/dist/output.cjs +1 -0
  161. package/node_modules/sharp/dist/output.mjs +1 -0
  162. package/node_modules/sharp/dist/resize.cjs +14 -14
  163. package/node_modules/sharp/dist/resize.mjs +14 -14
  164. package/node_modules/sharp/dist/sharp.cjs +3 -3
  165. package/node_modules/sharp/dist/sharp.mjs +3 -3
  166. package/node_modules/sharp/lib/index.d.ts +2 -2
  167. package/node_modules/sharp/package.json +35 -35
  168. package/node_modules/sharp/src/binding.gyp +1 -1
  169. package/node_modules/sharp/src/common.cc +4 -4
  170. package/node_modules/sharp/src/common.h +2 -2
  171. package/node_modules/sharp/src/pipeline.cc +31 -6
  172. package/node_modules/sharp/src/utilities.cc +1 -1
  173. package/node_modules/spdx-license-ids/index.json +13 -0
  174. package/node_modules/spdx-license-ids/package.json +1 -1
  175. package/node_modules/stream-buffers/.codeclimate.yml +12 -0
  176. package/node_modules/stream-buffers/.eslintignore +1 -0
  177. package/node_modules/stream-buffers/.eslintrc +25 -0
  178. package/node_modules/stream-buffers/.github/workflows/codeql-analysis.yml +71 -0
  179. package/node_modules/stream-buffers/.github/workflows/node.js.yml +31 -0
  180. package/node_modules/stream-buffers/.mailmap +1 -0
  181. package/node_modules/stream-buffers/.nvmrc +1 -0
  182. package/node_modules/stream-buffers/README.md +65 -65
  183. package/node_modules/stream-buffers/lib/constants.js +8 -6
  184. package/node_modules/stream-buffers/lib/readable_streambuffer.js +114 -136
  185. package/node_modules/stream-buffers/lib/streambuffer.js +5 -3
  186. package/node_modules/stream-buffers/lib/writable_streambuffer.js +72 -97
  187. package/node_modules/stream-buffers/package.json +7 -5
  188. package/node_modules/tar-stream/package.json +7 -7
  189. package/node_modules/type-fest/index.d.ts +7 -7
  190. package/node_modules/type-fest/package.json +2 -1
  191. package/node_modules/type-fest/readme.md +7 -16
  192. package/node_modules/type-fest/source/all-extend.d.ts +9 -7
  193. package/node_modules/type-fest/source/array-reverse.d.ts +13 -12
  194. package/node_modules/type-fest/source/array-tail.d.ts +3 -3
  195. package/node_modules/type-fest/source/delimiter-case.d.ts +1 -1
  196. package/node_modules/type-fest/source/get.d.ts +1 -1
  197. package/node_modules/type-fest/source/int-closed-range.d.ts +4 -1
  198. package/node_modules/type-fest/source/int-range.d.ts +56 -9
  199. package/node_modules/type-fest/source/internal/array.d.ts +14 -13
  200. package/node_modules/type-fest/source/internal/numeric.d.ts +0 -38
  201. package/node_modules/type-fest/source/internal/object.d.ts +30 -1
  202. package/node_modules/type-fest/source/is-boolean-literal.d.ts +39 -0
  203. package/node_modules/type-fest/source/is-literal.d.ts +43 -269
  204. package/node_modules/type-fest/source/is-numeric-literal.d.ts +50 -0
  205. package/node_modules/type-fest/source/is-string-literal.d.ts +72 -0
  206. package/node_modules/type-fest/source/is-symbol-literal.d.ts +39 -0
  207. package/node_modules/type-fest/source/is-tuple.d.ts +3 -3
  208. package/node_modules/type-fest/source/jsonify.d.ts +1 -5
  209. package/node_modules/type-fest/source/merge-deep.d.ts +3 -3
  210. package/node_modules/type-fest/source/remove-prefix.d.ts +1 -1
  211. package/node_modules/type-fest/source/remove-suffix.d.ts +1 -1
  212. package/node_modules/type-fest/source/rename-keys.d.ts +163 -0
  213. package/node_modules/type-fest/source/set-required.d.ts +10 -9
  214. package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +6 -4
  215. package/node_modules/type-fest/source/some-extend.d.ts +9 -7
  216. package/node_modules/type-fest/source/split-on-rest-element.d.ts +14 -13
  217. package/node_modules/type-fest/source/split.d.ts +22 -11
  218. package/node_modules/type-fest/source/string-repeat.d.ts +1 -1
  219. package/node_modules/type-fest/source/string-to-array.d.ts +1 -1
  220. package/node_modules/type-fest/source/tsconfig-json.d.ts +1 -1
  221. package/node_modules/type-fest/source/typed-array.d.ts +6 -0
  222. package/node_modules/type-fest/source/union-max.d.ts +56 -0
  223. package/node_modules/type-fest/source/writable.d.ts +2 -2
  224. package/package.json +5 -3
  225. package/node_modules/@appium/support/node_modules/asyncbox/LICENSE +0 -203
  226. package/node_modules/@appium/support/node_modules/asyncbox/README.md +0 -215
  227. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts +0 -103
  228. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts.map +0 -1
  229. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncbox.js +0 -301
  230. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncbox.js.map +0 -1
  231. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.d.ts +0 -84
  232. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.d.ts.map +0 -1
  233. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.js +0 -3
  234. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.js.map +0 -1
  235. package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/package.json +0 -3
  236. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts +0 -103
  237. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts.map +0 -1
  238. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncbox.js +0 -288
  239. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncbox.js.map +0 -1
  240. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.d.ts +0 -84
  241. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.d.ts.map +0 -1
  242. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.js +0 -2
  243. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.js.map +0 -1
  244. package/node_modules/@appium/support/node_modules/asyncbox/build/esm/package.json +0 -3
  245. package/node_modules/@appium/support/node_modules/asyncbox/lib/asyncbox.ts +0 -365
  246. package/node_modules/@appium/support/node_modules/asyncbox/lib/types.ts +0 -88
  247. package/node_modules/@appium/support/node_modules/asyncbox/package.json +0 -74
  248. package/node_modules/@appium/support/node_modules/axios/CHANGELOG.md +0 -1872
  249. package/node_modules/@appium/support/node_modules/axios/LICENSE +0 -7
  250. package/node_modules/@appium/support/node_modules/axios/MIGRATION_GUIDE.md +0 -877
  251. package/node_modules/@appium/support/node_modules/axios/README.md +0 -2623
  252. package/node_modules/@appium/support/node_modules/axios/dist/axios.js +0 -5509
  253. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js +0 -5
  254. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js.map +0 -1
  255. package/node_modules/@appium/support/node_modules/axios/dist/browser/axios.cjs +0 -5469
  256. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.js +0 -5490
  257. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js +0 -3
  258. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js.map +0 -1
  259. package/node_modules/@appium/support/node_modules/axios/dist/node/axios.cjs +0 -6356
  260. package/node_modules/@appium/support/node_modules/axios/index.d.cts +0 -762
  261. package/node_modules/@appium/support/node_modules/axios/index.d.ts +0 -783
  262. package/node_modules/@appium/support/node_modules/axios/index.js +0 -45
  263. package/node_modules/@appium/support/node_modules/axios/lib/adapters/README.md +0 -36
  264. package/node_modules/@appium/support/node_modules/axios/lib/adapters/adapters.js +0 -132
  265. package/node_modules/@appium/support/node_modules/axios/lib/adapters/fetch.js +0 -643
  266. package/node_modules/@appium/support/node_modules/axios/lib/adapters/http.js +0 -1406
  267. package/node_modules/@appium/support/node_modules/axios/lib/adapters/xhr.js +0 -228
  268. package/node_modules/@appium/support/node_modules/axios/lib/axios.js +0 -89
  269. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CancelToken.js +0 -135
  270. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CanceledError.js +0 -22
  271. package/node_modules/@appium/support/node_modules/axios/lib/cancel/isCancel.js +0 -5
  272. package/node_modules/@appium/support/node_modules/axios/lib/core/Axios.js +0 -301
  273. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosError.js +0 -219
  274. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosHeaders.js +0 -474
  275. package/node_modules/@appium/support/node_modules/axios/lib/core/InterceptorManager.js +0 -72
  276. package/node_modules/@appium/support/node_modules/axios/lib/core/README.md +0 -8
  277. package/node_modules/@appium/support/node_modules/axios/lib/core/buildFullPath.js +0 -88
  278. package/node_modules/@appium/support/node_modules/axios/lib/core/dispatchRequest.js +0 -89
  279. package/node_modules/@appium/support/node_modules/axios/lib/core/mergeConfig.js +0 -174
  280. package/node_modules/@appium/support/node_modules/axios/lib/core/setFormDataHeaders.js +0 -27
  281. package/node_modules/@appium/support/node_modules/axios/lib/core/settle.js +0 -27
  282. package/node_modules/@appium/support/node_modules/axios/lib/core/transformData.js +0 -28
  283. package/node_modules/@appium/support/node_modules/axios/lib/defaults/index.js +0 -177
  284. package/node_modules/@appium/support/node_modules/axios/lib/defaults/transitional.js +0 -10
  285. package/node_modules/@appium/support/node_modules/axios/lib/env/README.md +0 -3
  286. package/node_modules/@appium/support/node_modules/axios/lib/env/classes/FormData.js +0 -2
  287. package/node_modules/@appium/support/node_modules/axios/lib/env/data.js +0 -1
  288. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -156
  289. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -59
  290. package/node_modules/@appium/support/node_modules/axios/lib/helpers/Http2Sessions.js +0 -119
  291. package/node_modules/@appium/support/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -78
  292. package/node_modules/@appium/support/node_modules/axios/lib/helpers/README.md +0 -7
  293. package/node_modules/@appium/support/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -29
  294. package/node_modules/@appium/support/node_modules/axios/lib/helpers/bind.js +0 -14
  295. package/node_modules/@appium/support/node_modules/axios/lib/helpers/buildURL.js +0 -69
  296. package/node_modules/@appium/support/node_modules/axios/lib/helpers/callbackify.js +0 -18
  297. package/node_modules/@appium/support/node_modules/axios/lib/helpers/combineURLs.js +0 -23
  298. package/node_modules/@appium/support/node_modules/axios/lib/helpers/composeSignals.js +0 -68
  299. package/node_modules/@appium/support/node_modules/axios/lib/helpers/cookies.js +0 -64
  300. package/node_modules/@appium/support/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -31
  301. package/node_modules/@appium/support/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +0 -166
  302. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToJSON.js +0 -125
  303. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToStream.js +0 -119
  304. package/node_modules/@appium/support/node_modules/axios/lib/helpers/fromDataURI.js +0 -68
  305. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -19
  306. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  307. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
  308. package/node_modules/@appium/support/node_modules/axios/lib/helpers/null.js +0 -2
  309. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseHeaders.js +0 -71
  310. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  311. package/node_modules/@appium/support/node_modules/axios/lib/helpers/progressEventReducer.js +0 -54
  312. package/node_modules/@appium/support/node_modules/axios/lib/helpers/readBlob.js +0 -15
  313. package/node_modules/@appium/support/node_modules/axios/lib/helpers/resolveConfig.js +0 -105
  314. package/node_modules/@appium/support/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +0 -60
  315. package/node_modules/@appium/support/node_modules/axios/lib/helpers/shouldBypassProxy.js +0 -329
  316. package/node_modules/@appium/support/node_modules/axios/lib/helpers/speedometer.js +0 -55
  317. package/node_modules/@appium/support/node_modules/axios/lib/helpers/spread.js +0 -28
  318. package/node_modules/@appium/support/node_modules/axios/lib/helpers/throttle.js +0 -44
  319. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toFormData.js +0 -286
  320. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
  321. package/node_modules/@appium/support/node_modules/axios/lib/helpers/trackStream.js +0 -89
  322. package/node_modules/@appium/support/node_modules/axios/lib/helpers/validator.js +0 -112
  323. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  324. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  325. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
  326. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/index.js +0 -13
  327. package/node_modules/@appium/support/node_modules/axios/lib/platform/common/utils.js +0 -52
  328. package/node_modules/@appium/support/node_modules/axios/lib/platform/index.js +0 -7
  329. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/Buffer.js +0 -11
  330. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
  331. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
  332. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/index.js +0 -37
  333. package/node_modules/@appium/support/node_modules/axios/lib/utils.js +0 -1029
  334. package/node_modules/@appium/support/node_modules/axios/package.json +0 -203
  335. package/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64-0.35.4.node +0 -0
  336. package/node_modules/big-integer/BigInteger.d.ts +0 -2393
  337. package/node_modules/big-integer/BigInteger.js +0 -1453
  338. package/node_modules/big-integer/BigInteger.min.js +0 -1
  339. package/node_modules/big-integer/LICENSE +0 -24
  340. package/node_modules/big-integer/README.md +0 -589
  341. package/node_modules/big-integer/bower.json +0 -29
  342. package/node_modules/big-integer/package.json +0 -48
  343. package/node_modules/big-integer/tsconfig.json +0 -24
  344. package/node_modules/bplist-creator/bplistCreator.d.ts +0 -8
  345. package/node_modules/bplist-creator/bplistCreator.js +0 -460
  346. package/node_modules/bplist-creator/test/airplay.bplist +0 -0
  347. package/node_modules/bplist-creator/test/binaryData.bplist +0 -0
  348. package/node_modules/bplist-creator/test/creatorTest.js +0 -211
  349. package/node_modules/bplist-creator/test/iTunes-small.bplist +0 -0
  350. package/node_modules/bplist-creator/test/integers.bplist +0 -0
  351. package/node_modules/bplist-creator/test/sample1.bplist +0 -0
  352. package/node_modules/bplist-creator/test/sample2.bplist +0 -0
  353. package/node_modules/bplist-creator/test/uid.bplist +0 -0
  354. package/node_modules/bplist-creator/test/utf16.bplist +0 -0
  355. package/node_modules/bplist-parser/.editorconfig +0 -12
  356. package/node_modules/bplist-parser/.eslintignore +0 -1
  357. package/node_modules/bplist-parser/.eslintrc.js +0 -296
  358. package/node_modules/bplist-parser/bplistParser.d.ts +0 -8
  359. package/node_modules/stream-buffers/.travis.yml +0 -28
  360. package/node_modules/stream-buffers/coverage/coverage.json +0 -1
  361. package/node_modules/stream-buffers/coverage/lcov-report/base.css +0 -182
  362. package/node_modules/stream-buffers/coverage/lcov-report/index.html +0 -73
  363. package/node_modules/stream-buffers/coverage/lcov-report/lib/constants.js.html +0 -63
  364. package/node_modules/stream-buffers/coverage/lcov-report/lib/index.html +0 -112
  365. package/node_modules/stream-buffers/coverage/lcov-report/lib/readable_streambuffer.js.html +0 -453
  366. package/node_modules/stream-buffers/coverage/lcov-report/lib/streambuffer.js.html +0 -54
  367. package/node_modules/stream-buffers/coverage/lcov-report/lib/writable_streambuffer.js.html +0 -336
  368. package/node_modules/stream-buffers/coverage/lcov-report/prettify.css +0 -1
  369. package/node_modules/stream-buffers/coverage/lcov-report/prettify.js +0 -1
  370. package/node_modules/stream-buffers/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  371. package/node_modules/stream-buffers/coverage/lcov-report/sorter.js +0 -156
  372. package/node_modules/stream-buffers/coverage/lcov.info +0 -305
@@ -1,1406 +0,0 @@
1
- import utils from '../utils.js';
2
- import settle from '../core/settle.js';
3
- import buildFullPath from '../core/buildFullPath.js';
4
- import buildURL from '../helpers/buildURL.js';
5
- import { getProxyForUrl } from 'proxy-from-env';
6
- import HttpsProxyAgent from 'https-proxy-agent';
7
- import http from 'http';
8
- import https from 'https';
9
- import http2 from 'http2';
10
- import util from 'util';
11
- import { resolve as resolvePath } from 'path';
12
- import followRedirects from 'follow-redirects';
13
- import zlib from 'zlib';
14
- import { VERSION } from '../env/data.js';
15
- import transitionalDefaults from '../defaults/transitional.js';
16
- import AxiosError from '../core/AxiosError.js';
17
- import CanceledError from '../cancel/CanceledError.js';
18
- import platform from '../platform/index.js';
19
- import fromDataURI from '../helpers/fromDataURI.js';
20
- import stream from 'stream';
21
- import AxiosHeaders from '../core/AxiosHeaders.js';
22
- import setFormDataHeaders from '../core/setFormDataHeaders.js';
23
- import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
24
- import { EventEmitter } from 'events';
25
- import formDataToStream from '../helpers/formDataToStream.js';
26
- import readBlob from '../helpers/readBlob.js';
27
- import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js';
28
- import Http2Sessions from '../helpers/Http2Sessions.js';
29
- import callbackify from '../helpers/callbackify.js';
30
- import shouldBypassProxy from '../helpers/shouldBypassProxy.js';
31
- import { toByteStringHeaderObject } from '../helpers/sanitizeHeaderValue.js';
32
- import {
33
- progressEventReducer,
34
- progressEventDecorator,
35
- asyncDecorator,
36
- } from '../helpers/progressEventReducer.js';
37
- import { estimateDataURLBufferAllocation } from '../helpers/estimateDataURLDecodedBytes.js';
38
-
39
- const zlibOptions = {
40
- flush: zlib.constants.Z_SYNC_FLUSH,
41
- finishFlush: zlib.constants.Z_SYNC_FLUSH,
42
- };
43
-
44
- const brotliOptions = {
45
- flush: zlib.constants.BROTLI_OPERATION_FLUSH,
46
- finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH,
47
- };
48
-
49
- const zstdOptions = {
50
- flush: zlib.constants.ZSTD_e_flush,
51
- finishFlush: zlib.constants.ZSTD_e_flush,
52
- };
53
-
54
- const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
55
- const isZstdSupported = utils.isFunction(zlib.createZstdDecompress);
56
- const ACCEPT_ENCODING = 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : '');
57
- const ACCEPT_ENCODING_WITH_ZSTD = ACCEPT_ENCODING + (isZstdSupported ? ', zstd' : '');
58
- const scheduleProgress =
59
- typeof process !== 'undefined' && process.nextTick ? process.nextTick.bind(process) : utils.asap;
60
-
61
- const { http: httpFollow, https: httpsFollow } = followRedirects;
62
-
63
- const isHttps = /https:?/;
64
-
65
- // Symbols used to bind a single 'error' listener to a pooled socket and track
66
- // the request currently owning that socket across keep-alive reuse (issue #10780).
67
- const kAxiosSocketListener = Symbol('axios.http.socketListener');
68
- const kAxiosCurrentReq = Symbol('axios.http.currentReq');
69
-
70
- // Tags HttpsProxyAgent instances installed by setProxy() so the redirect path
71
- // can strip them without clobbering a user-supplied agent that happens to be
72
- // an HttpsProxyAgent.
73
- const kAxiosInstalledTunnel = Symbol('axios.http.installedTunnel');
74
-
75
- // Cache of CONNECT-tunneling agents keyed by proxy config so repeat requests
76
- // through the same proxy reuse a single agent (and its socket pool). The
77
- // keyspace is bounded by the set of distinct proxy configs the process uses,
78
- // so unbounded growth is not a concern in practice.
79
- const tunnelingAgentCache = new Map();
80
- const tunnelingAgentCacheUser = new WeakMap();
81
- // Minimum minor versions where Node's HTTP Agent supports native proxyEnv
82
- // handling. Checking the selected agent below also covers startup modes such
83
- // as NODE_OPTIONS=--use-env-proxy and --no-use-env-proxy precedence.
84
- const NODE_NATIVE_ENV_PROXY_SUPPORT = {
85
- 22: 21,
86
- 24: 5,
87
- };
88
-
89
- function isNodeNativeEnvProxySupported(nodeVersion = process.versions && process.versions.node) {
90
- if (!nodeVersion) {
91
- return false;
92
- }
93
-
94
- const [major, minor] = nodeVersion.split('.').map((part) => Number(part));
95
-
96
- if (!Number.isInteger(major) || !Number.isInteger(minor)) {
97
- return false;
98
- }
99
-
100
- if (major > 24) {
101
- return true;
102
- }
103
-
104
- return (
105
- NODE_NATIVE_ENV_PROXY_SUPPORT[major] != null && minor >= NODE_NATIVE_ENV_PROXY_SUPPORT[major]
106
- );
107
- }
108
-
109
- function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.versions.node) {
110
- if (!isNodeNativeEnvProxySupported(nodeVersion)) {
111
- return false;
112
- }
113
-
114
- const agentOptions = agent && agent.options;
115
-
116
- return Boolean(
117
- agentOptions &&
118
- utils.hasOwnProp(agentOptions, 'proxyEnv') &&
119
- agentOptions.proxyEnv != null
120
- );
121
- }
122
-
123
- function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
124
- return isHttps.test(options.protocol)
125
- ? (configHttpsAgent || https.globalAgent)
126
- : (configHttpAgent || http.globalAgent);
127
- }
128
-
129
- function getTunnelingAgent(agentOptions, userHttpsAgent) {
130
- const key =
131
- agentOptions.protocol +
132
- '//' +
133
- agentOptions.hostname +
134
- ':' +
135
- (agentOptions.port || '') +
136
- '#' +
137
- (agentOptions.auth || '');
138
- const cache = userHttpsAgent
139
- ? (tunnelingAgentCacheUser.get(userHttpsAgent) ||
140
- tunnelingAgentCacheUser.set(userHttpsAgent, new Map()).get(userHttpsAgent))
141
- : tunnelingAgentCache;
142
- let agent = cache.get(key);
143
- if (agent) return agent;
144
- // Forward the user's TLS options (custom CA, rejectUnauthorized, client cert,
145
- // etc.) into the tunneling agent so they apply to the origin TLS upgrade
146
- // performed after CONNECT. Our proxy fields take precedence on conflict.
147
- const merged = userHttpsAgent && userHttpsAgent.options
148
- ? { ...userHttpsAgent.options, ...agentOptions }
149
- : agentOptions;
150
- agent = new HttpsProxyAgent(merged);
151
- if (userHttpsAgent && userHttpsAgent.options) {
152
- const originTLSOptions = { ...userHttpsAgent.options };
153
- const callback = agent.callback;
154
- agent.callback = function axiosTunnelingAgentCallback(req, opts) {
155
- // HttpsProxyAgent v5 reads callback opts for the post-CONNECT origin TLS upgrade.
156
- return callback.call(this, req, { ...originTLSOptions, ...opts });
157
- };
158
- }
159
- agent[kAxiosInstalledTunnel] = true;
160
- cache.set(key, agent);
161
- return agent;
162
- }
163
-
164
- const supportedProtocols = platform.protocols.map((protocol) => {
165
- return protocol + ':';
166
- });
167
-
168
- // Node's WHATWG URL parser returns `username` and `password` percent-encoded.
169
- // Decode before composing the `auth` option so credentials such as
170
- // `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
171
- // original value for malformed input so a bad encoding never throws.
172
- const decodeURIComponentSafe = (value) => {
173
- if (!utils.isString(value)) {
174
- return value;
175
- }
176
-
177
- try {
178
- return decodeURIComponent(value);
179
- } catch (error) {
180
- return value;
181
- }
182
- };
183
-
184
- const flushOnFinish = (stream, [throttled, flush]) => {
185
- stream.on('end', flush).on('error', flush);
186
-
187
- return throttled;
188
- };
189
-
190
- const http2Sessions = new Http2Sessions();
191
-
192
- /**
193
- * If the proxy, auth, sensitive header, or config beforeRedirects functions are defined,
194
- * call them with the options object.
195
- *
196
- * @param {Object<string, any>} options - The options object that was passed to the request.
197
- *
198
- * @returns {Object<string, any>}
199
- */
200
- function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
201
- if (options.beforeRedirects.proxy) {
202
- options.beforeRedirects.proxy(options);
203
- }
204
- if (options.beforeRedirects.auth) {
205
- options.beforeRedirects.auth(options);
206
- }
207
- if (options.beforeRedirects.sensitiveHeaders) {
208
- options.beforeRedirects.sensitiveHeaders(options, requestDetails);
209
- }
210
- if (options.beforeRedirects.config) {
211
- options.beforeRedirects.config(options, responseDetails, requestDetails);
212
- }
213
- }
214
-
215
- function stripMatchingHeaders(headers, sensitiveSet) {
216
- if (!headers) {
217
- return;
218
- }
219
-
220
- Object.keys(headers).forEach((header) => {
221
- if (sensitiveSet.has(header.toLowerCase())) {
222
- delete headers[header];
223
- }
224
- });
225
- }
226
-
227
- function isSameOriginRedirect(redirectOptions, requestDetails) {
228
- if (!requestDetails) {
229
- return false;
230
- }
231
-
232
- try {
233
- return new URL(requestDetails.url).origin === new URL(redirectOptions.href).origin;
234
- } catch (e) {
235
- // If origin comparison fails, treat the redirect as unsafe.
236
- return false;
237
- }
238
- }
239
-
240
- /**
241
- * If the proxy or config afterRedirects functions are defined, call them with the options
242
- *
243
- * @param {http.ClientRequestArgs} options
244
- * @param {AxiosProxyConfig} configProxy configuration from Axios options object
245
- * @param {string} location
246
- *
247
- * @returns {http.ClientRequestArgs}
248
- */
249
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
250
- let proxy = configProxy;
251
- const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
252
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
253
- const proxyUrl = getProxyForUrl(location);
254
- if (proxyUrl) {
255
- if (!shouldBypassProxy(location)) {
256
- proxy = new URL(proxyUrl);
257
- }
258
- }
259
- }
260
- // On redirect re-invocation, strip any stale Proxy-Authorization header carried
261
- // over from the prior request (e.g. new target no longer uses a proxy, or uses
262
- // a different proxy). Skip on the initial request so user-supplied headers are
263
- // preserved. Header names are case-insensitive, so remove every case variant.
264
- if (isRedirect && options.headers) {
265
- for (const name of Object.keys(options.headers)) {
266
- if (name.toLowerCase() === 'proxy-authorization') {
267
- delete options.headers[name];
268
- }
269
- }
270
- }
271
- // Strip any tunneling agent we installed for the previous hop so a redirect
272
- // that drops the proxy or crosses an HTTPS↔HTTP boundary doesn't reuse a
273
- // stale one. Match on our Symbol marker so a user-supplied HttpsProxyAgent
274
- // (which won't carry the marker) is left alone.
275
- if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
276
- options.agent = undefined;
277
- }
278
- if (proxy) {
279
- // Read proxy fields without traversing the prototype chain. URL instances expose
280
- // username/password/hostname/host/port/protocol via getters on URL.prototype (so
281
- // direct reads are shielded), but plain object proxies — and the `auth` field
282
- // (which URL does not expose) — must be guarded so a polluted Object.prototype
283
- // (e.g. Object.prototype.auth = { username, password }) cannot inject
284
- // attacker-controlled credentials into the Proxy-Authorization header or
285
- // redirect proxying to an attacker-controlled host.
286
- const isProxyURL = proxy instanceof URL;
287
- const readProxyField = (key) =>
288
- isProxyURL || utils.hasOwnProp(proxy, key) ? proxy[key] : undefined;
289
-
290
- const proxyUsername = readProxyField('username');
291
- const proxyPassword = readProxyField('password');
292
- let proxyAuth = utils.hasOwnProp(proxy, 'auth') ? proxy.auth : undefined;
293
-
294
- // Basic proxy authorization
295
- if (proxyUsername) {
296
- proxyAuth = (proxyUsername || '') + ':' + (proxyPassword || '');
297
- }
298
-
299
- if (proxyAuth) {
300
- // Support proxy auth object form. Read sub-fields via own-prop checks so a
301
- // plain object inheriting from polluted Object.prototype cannot leak creds.
302
- const authIsObject = typeof proxyAuth === 'object';
303
- const authUsername =
304
- authIsObject && utils.hasOwnProp(proxyAuth, 'username') ? proxyAuth.username : undefined;
305
- const authPassword =
306
- authIsObject && utils.hasOwnProp(proxyAuth, 'password') ? proxyAuth.password : undefined;
307
- const validProxyAuth = Boolean(authUsername || authPassword);
308
-
309
- if (validProxyAuth) {
310
- proxyAuth = (authUsername || '') + ':' + (authPassword || '');
311
- } else if (authIsObject) {
312
- throw new AxiosError('Invalid proxy authorization', AxiosError.ERR_BAD_OPTION, { proxy });
313
- }
314
- }
315
-
316
- const targetIsHttps = isHttps.test(options.protocol);
317
-
318
- if (targetIsHttps) {
319
- // CONNECT-tunneling path for HTTPS targets. Preserves end-to-end TLS to
320
- // the origin so the proxy cannot inspect the URL, headers, or body — the
321
- // behavior already promised by THREATMODEL.md (T-R9). HttpsProxyAgent
322
- // sends Proxy-Authorization on the CONNECT request only, never on the
323
- // wrapped TLS request, which is why we don't stamp it onto
324
- // options.headers here. If the user already supplied an HttpsProxyAgent,
325
- // they own tunneling end-to-end and we leave them alone; otherwise we
326
- // install our own tunneling agent and forward their TLS options (if any)
327
- // so a custom httpsAgent for cert pinning / rejectUnauthorized still
328
- // applies to the origin TLS upgrade.
329
- if (!(configHttpsAgent instanceof HttpsProxyAgent)) {
330
- const proxyHost = readProxyField('hostname') || readProxyField('host');
331
- const proxyPort = readProxyField('port');
332
- const rawProxyProtocol = readProxyField('protocol');
333
- const normalizedProtocol = rawProxyProtocol
334
- ? rawProxyProtocol.includes(':')
335
- ? rawProxyProtocol
336
- : `${rawProxyProtocol}:`
337
- : 'http:';
338
- // Bracket IPv6 literals for URL parsing; URL.hostname strips the
339
- // brackets again on read so the agent receives the raw form.
340
- const proxyHostForURL =
341
- proxyHost && proxyHost.includes(':') && !proxyHost.startsWith('[')
342
- ? `[${proxyHost}]`
343
- : proxyHost;
344
- const proxyURL = new URL(
345
- `${normalizedProtocol}//${proxyHostForURL}${proxyPort ? ':' + proxyPort : ''}`
346
- );
347
- const agentOptions = {
348
- protocol: proxyURL.protocol,
349
- hostname: proxyURL.hostname.replace(/^\[|\]$/g, ''),
350
- port: proxyURL.port,
351
- auth: proxyAuth && typeof proxyAuth === 'string' ? proxyAuth : undefined,
352
- };
353
- if (proxyURL.protocol === 'https:') {
354
- agentOptions.ALPNProtocols = ['http/1.1'];
355
- }
356
- const tunnelingAgent = getTunnelingAgent(agentOptions, configHttpsAgent);
357
- // Set both: `options.agent` is consumed by the native https.request path
358
- // (maxRedirects === 0); `options.agents.https` is consumed by
359
- // follow-redirects, which ignores `options.agent` when `options.agents`
360
- // is present.
361
- options.agent = tunnelingAgent;
362
- if (options.agents) {
363
- options.agents.https = tunnelingAgent;
364
- }
365
- }
366
- } else {
367
- // Forward-proxy mode for plaintext HTTP targets. The request line carries
368
- // the absolute URL and the proxy sees everything — acceptable for plain
369
- // HTTP since the wire was already plaintext.
370
- if (proxyAuth) {
371
- const base64 = Buffer.from(proxyAuth, 'utf8').toString('base64');
372
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
373
- }
374
-
375
- // Preserve a user-supplied Host header (case-insensitive) so callers can override
376
- // the value forwarded to the proxy; otherwise default to the request URL's host.
377
- let hasUserHostHeader = false;
378
- for (const name of Object.keys(options.headers)) {
379
- if (name.toLowerCase() === 'host') {
380
- hasUserHostHeader = true;
381
- break;
382
- }
383
- }
384
- if (!hasUserHostHeader) {
385
- options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
386
- }
387
- const proxyHost = readProxyField('hostname') || readProxyField('host');
388
- options.hostname = proxyHost;
389
- // Replace 'host' since options is not a URL object
390
- options.host = proxyHost;
391
- options.port = readProxyField('port');
392
- options.path = location;
393
- const proxyProtocol = readProxyField('protocol');
394
- if (proxyProtocol) {
395
- options.protocol = proxyProtocol.includes(':') ? proxyProtocol : `${proxyProtocol}:`;
396
- }
397
- }
398
- }
399
-
400
- options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
401
- // Configure proxy for redirected request, passing the original config proxy to apply
402
- // the exact same logic as if the redirected request was performed by axios directly.
403
- setProxy(
404
- redirectOptions,
405
- configProxy,
406
- redirectOptions.href,
407
- true,
408
- configHttpsAgent,
409
- configHttpAgent
410
- );
411
- };
412
- }
413
-
414
- const isHttpAdapterSupported =
415
- typeof process !== 'undefined' && utils.kindOf(process) === 'process';
416
-
417
- // temporary hotfix
418
-
419
- const wrapAsync = (asyncExecutor) => {
420
- return new Promise((resolve, reject) => {
421
- let onDone;
422
- let isDone;
423
-
424
- const done = (value, isRejected) => {
425
- if (isDone) return;
426
- isDone = true;
427
- onDone && onDone(value, isRejected);
428
- };
429
-
430
- const _resolve = (value) => {
431
- done(value);
432
- resolve(value);
433
- };
434
-
435
- const _reject = (reason) => {
436
- done(reason, true);
437
- reject(reason);
438
- };
439
-
440
- asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
441
- });
442
- };
443
-
444
- const resolveFamily = ({ address, family }) => {
445
- if (!utils.isString(address)) {
446
- throw TypeError('address must be a string');
447
- }
448
- return {
449
- address,
450
- family: family || (address.indexOf('.') < 0 ? 6 : 4),
451
- };
452
- };
453
-
454
- const buildAddressEntry = (address, family) =>
455
- resolveFamily(utils.isObject(address) ? address : { address, family });
456
-
457
- const http2Transport = {
458
- request(options, cb) {
459
- const authority =
460
- options.protocol +
461
- '//' +
462
- options.hostname +
463
- ':' +
464
- (options.port || (options.protocol === 'https:' ? 443 : 80));
465
-
466
- const { http2Options, headers } = options;
467
-
468
- const session = http2Sessions.getSession(authority, http2Options);
469
-
470
- const { HTTP2_HEADER_SCHEME, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } =
471
- http2.constants;
472
-
473
- const http2Headers = {
474
- [HTTP2_HEADER_SCHEME]: options.protocol.replace(':', ''),
475
- [HTTP2_HEADER_METHOD]: options.method,
476
- [HTTP2_HEADER_PATH]: options.path,
477
- };
478
-
479
- utils.forEach(headers, (header, name) => {
480
- name.charAt(0) !== ':' && (http2Headers[name] = header);
481
- });
482
-
483
- const req = session.request(http2Headers);
484
-
485
- req.once('response', (responseHeaders) => {
486
- const response = req; //duplex
487
-
488
- responseHeaders = Object.assign({}, responseHeaders);
489
-
490
- const status = responseHeaders[HTTP2_HEADER_STATUS];
491
-
492
- delete responseHeaders[HTTP2_HEADER_STATUS];
493
-
494
- response.headers = responseHeaders;
495
-
496
- response.statusCode = +status;
497
-
498
- cb(response);
499
- });
500
-
501
- return req;
502
- },
503
- };
504
-
505
- /*eslint consistent-return:0*/
506
- export default isHttpAdapterSupported &&
507
- function httpAdapter(config) {
508
- return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
509
- // Read config pollution-safely: own properties and members inherited from
510
- // a non-Object.prototype source (e.g. an Object.create(defaults) template)
511
- // are honored, but values injected onto a polluted Object.prototype are
512
- // ignored. All behavior-affecting reads in this adapter go through own()
513
- // so the protection boundary stays consistent.
514
- const own = (key) => utils.getSafeProp(config, key);
515
- const transitional = own('transitional') || transitionalDefaults;
516
- let data = own('data');
517
- let lookup = own('lookup');
518
- let family = own('family');
519
- let httpVersion = own('httpVersion');
520
- if (httpVersion === undefined) httpVersion = 1;
521
- let http2Options = own('http2Options');
522
- const httpAgent = own('httpAgent');
523
- const httpsAgent = own('httpsAgent');
524
- const configProxy = own('proxy');
525
- const responseType = own('responseType');
526
- const responseEncoding = own('responseEncoding');
527
- const socketPath = own('socketPath');
528
- const method = own('method').toUpperCase();
529
- const maxRedirects = own('maxRedirects');
530
- const maxBodyLength = own('maxBodyLength');
531
- const maxContentLength = own('maxContentLength');
532
- const decompress = own('decompress');
533
- let isDone;
534
- let rejected = false;
535
- let req;
536
- let connectPhaseTimer;
537
-
538
- httpVersion = +httpVersion;
539
-
540
- if (Number.isNaN(httpVersion)) {
541
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
542
- }
543
-
544
- if (httpVersion !== 1 && httpVersion !== 2) {
545
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
546
- }
547
-
548
- const isHttp2 = httpVersion === 2;
549
-
550
- if (lookup) {
551
- const _lookup = callbackify(lookup, (value) => (utils.isArray(value) ? value : [value]));
552
- // hotfix to support opt.all option which is required for node 20.x
553
- lookup = (hostname, opt, cb) => {
554
- _lookup(hostname, opt, (err, arg0, arg1) => {
555
- if (err) {
556
- return cb(err);
557
- }
558
-
559
- const addresses = utils.isArray(arg0)
560
- ? arg0.map((addr) => buildAddressEntry(addr))
561
- : [buildAddressEntry(arg0, arg1)];
562
-
563
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
564
- });
565
- };
566
- }
567
-
568
- const abortEmitter = new EventEmitter();
569
-
570
- function abort(reason) {
571
- try {
572
- abortEmitter.emit(
573
- 'abort',
574
- !reason || reason.type ? new CanceledError(null, config, req) : reason
575
- );
576
- } catch (err) {
577
- // ignore emit errors
578
- }
579
- }
580
-
581
- function clearConnectPhaseTimer() {
582
- if (connectPhaseTimer) {
583
- clearTimeout(connectPhaseTimer);
584
- connectPhaseTimer = null;
585
- }
586
- }
587
-
588
- function createTimeoutError() {
589
- const configTimeout = own('timeout');
590
- let timeoutErrorMessage = configTimeout
591
- ? 'timeout of ' + configTimeout + 'ms exceeded'
592
- : 'timeout exceeded';
593
- const configTimeoutErrorMessage = own('timeoutErrorMessage');
594
- if (configTimeoutErrorMessage) {
595
- timeoutErrorMessage = configTimeoutErrorMessage;
596
- }
597
- return new AxiosError(
598
- timeoutErrorMessage,
599
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
600
- config,
601
- req
602
- );
603
- }
604
-
605
- abortEmitter.once('abort', reject);
606
-
607
- const onFinished = () => {
608
- clearConnectPhaseTimer();
609
-
610
- if (config.cancelToken) {
611
- config.cancelToken.unsubscribe(abort);
612
- }
613
-
614
- if (config.signal) {
615
- config.signal.removeEventListener('abort', abort);
616
- }
617
-
618
- abortEmitter.removeAllListeners();
619
- };
620
-
621
- if (config.cancelToken || config.signal) {
622
- config.cancelToken && config.cancelToken.subscribe(abort);
623
- if (config.signal) {
624
- config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
625
- }
626
- }
627
-
628
- onDone((response, isRejected) => {
629
- isDone = true;
630
- clearConnectPhaseTimer();
631
-
632
- if (isRejected) {
633
- rejected = true;
634
- onFinished();
635
- return;
636
- }
637
-
638
- const { data } = response;
639
-
640
- if (data instanceof stream.Readable || data instanceof stream.Duplex) {
641
- const offListeners = stream.finished(data, () => {
642
- offListeners();
643
- onFinished();
644
- });
645
- } else {
646
- onFinished();
647
- }
648
- });
649
-
650
- // Parse url
651
- const fullPath = buildFullPath(own('baseURL'), own('url'), own('allowAbsoluteUrls'), config);
652
- // Unix-socket requests (own socketPath) commonly pass a path-only url
653
- // like '/foo'; supply a synthetic base so new URL() can still parse it.
654
- // Use the own-property value (not config.socketPath) so a polluted
655
- // prototype cannot influence URL base selection.
656
- const urlBase = socketPath
657
- ? 'http://localhost'
658
- : (platform.hasBrowserEnv ? platform.origin : undefined);
659
- const parsed = new URL(fullPath, urlBase);
660
- const protocol = parsed.protocol || supportedProtocols[0];
661
-
662
- if (protocol === 'data:') {
663
- // Apply the same semantics as HTTP: only enforce if a finite, non-negative cap is set.
664
- if (maxContentLength > -1) {
665
- // Use the exact string passed to fromDataURI (the configured url); fall back to fullPath if needed.
666
- const dataUrl = String(own('url') || fullPath || '');
667
- const estimated = estimateDataURLBufferAllocation(dataUrl);
668
-
669
- if (estimated > maxContentLength) {
670
- return reject(
671
- new AxiosError(
672
- 'maxContentLength size of ' + maxContentLength + ' exceeded',
673
- AxiosError.ERR_BAD_RESPONSE,
674
- config
675
- )
676
- );
677
- }
678
- }
679
-
680
- let convertedData;
681
-
682
- if (method !== 'GET') {
683
- return settle(resolve, reject, {
684
- status: 405,
685
- statusText: 'method not allowed',
686
- headers: {},
687
- config,
688
- });
689
- }
690
-
691
- try {
692
- convertedData = fromDataURI(own('url'), responseType === 'blob', {
693
- Blob: config.env && config.env.Blob,
694
- });
695
- } catch (err) {
696
- throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
697
- }
698
-
699
- if (responseType === 'text') {
700
- convertedData = convertedData.toString(responseEncoding);
701
-
702
- if (!responseEncoding || responseEncoding === 'utf8') {
703
- convertedData = utils.stripBOM(convertedData);
704
- }
705
- } else if (responseType === 'stream') {
706
- convertedData = stream.Readable.from(convertedData);
707
- }
708
-
709
- return settle(resolve, reject, {
710
- data: convertedData,
711
- status: 200,
712
- statusText: 'OK',
713
- headers: new AxiosHeaders(),
714
- config,
715
- });
716
- }
717
-
718
- if (supportedProtocols.indexOf(protocol) === -1) {
719
- return reject(
720
- new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_BAD_REQUEST, config)
721
- );
722
- }
723
-
724
- const headers = AxiosHeaders.from(config.headers).normalize();
725
-
726
- // Set User-Agent (required by some servers)
727
- // See https://github.com/axios/axios/issues/69
728
- // User-Agent is specified; handle case where no UA header is desired
729
- // Only set header if it hasn't been set in config
730
- headers.set('User-Agent', 'axios/' + VERSION, false);
731
-
732
- const { onUploadProgress, onDownloadProgress } = config;
733
- const maxRate = config.maxRate;
734
- let maxUploadRate = undefined;
735
- let maxDownloadRate = undefined;
736
-
737
- // support for spec compliant FormData objects
738
- if (utils.isSpecCompliantForm(data)) {
739
- const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
740
-
741
- data = formDataToStream(
742
- data,
743
- (formHeaders) => {
744
- headers.set(formHeaders);
745
- },
746
- {
747
- tag: `axios-${VERSION}-boundary`,
748
- boundary: (userBoundary && userBoundary[1]) || undefined,
749
- }
750
- );
751
- // support for https://www.npmjs.com/package/form-data api
752
- } else if (
753
- utils.isFormData(data) &&
754
- utils.isFunction(data.getHeaders) &&
755
- data.getHeaders !== Object.prototype.getHeaders
756
- ) {
757
- setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
758
-
759
- if (!headers.hasContentLength()) {
760
- try {
761
- const knownLength = await util.promisify(data.getLength).call(data);
762
- Number.isFinite(knownLength) &&
763
- knownLength >= 0 &&
764
- headers.setContentLength(knownLength);
765
- /*eslint no-empty:0*/
766
- } catch (e) {}
767
- }
768
- } else if (utils.isBlob(data) || utils.isFile(data)) {
769
- data.size && headers.setContentType(data.type || 'application/octet-stream');
770
- headers.setContentLength(data.size || 0);
771
- data = stream.Readable.from(readBlob(data));
772
- } else if (data && !utils.isStream(data)) {
773
- if (Buffer.isBuffer(data)) {
774
- // Nothing to do...
775
- } else if (utils.isArrayBuffer(data)) {
776
- data = Buffer.from(new Uint8Array(data));
777
- } else if (utils.isString(data)) {
778
- data = Buffer.from(data, 'utf-8');
779
- } else {
780
- return reject(
781
- new AxiosError(
782
- 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
783
- AxiosError.ERR_BAD_REQUEST,
784
- config
785
- )
786
- );
787
- }
788
-
789
- // Add Content-Length header if data exists
790
- headers.setContentLength(data.length, false);
791
-
792
- if (maxBodyLength > -1 && data.length > maxBodyLength) {
793
- return reject(
794
- new AxiosError(
795
- 'Request body larger than maxBodyLength limit',
796
- AxiosError.ERR_BAD_REQUEST,
797
- config
798
- )
799
- );
800
- }
801
- }
802
-
803
- const contentLength = utils.toFiniteNumber(headers.getContentLength());
804
-
805
- if (utils.isArray(maxRate)) {
806
- maxUploadRate = maxRate[0];
807
- maxDownloadRate = maxRate[1];
808
- } else {
809
- maxUploadRate = maxDownloadRate = maxRate;
810
- }
811
-
812
- if (data && (onUploadProgress || maxUploadRate)) {
813
- if (!utils.isStream(data)) {
814
- data = stream.Readable.from(data, { objectMode: false });
815
- }
816
-
817
- data = stream.pipeline(
818
- [
819
- data,
820
- new AxiosTransformStream({
821
- maxRate: utils.toFiniteNumber(maxUploadRate),
822
- }),
823
- ],
824
- utils.noop
825
- );
826
-
827
- onUploadProgress &&
828
- data.on(
829
- 'progress',
830
- flushOnFinish(
831
- data,
832
- progressEventDecorator(
833
- contentLength,
834
- progressEventReducer(asyncDecorator(onUploadProgress, scheduleProgress), false, 3)
835
- )
836
- )
837
- );
838
- }
839
-
840
- // HTTP basic authentication
841
- let auth = undefined;
842
- const configAuth = own('auth');
843
- if (configAuth) {
844
- const username = utils.getSafeProp(configAuth, 'username') || '';
845
- const password = utils.getSafeProp(configAuth, 'password') || '';
846
- auth = username + ':' + password;
847
- }
848
-
849
- if (!auth && (parsed.username || parsed.password)) {
850
- const urlUsername = decodeURIComponentSafe(parsed.username);
851
- const urlPassword = decodeURIComponentSafe(parsed.password);
852
- auth = urlUsername + ':' + urlPassword;
853
- }
854
-
855
- auth && headers.delete('authorization');
856
-
857
- let path;
858
-
859
- try {
860
- path = buildURL(
861
- parsed.pathname + parsed.search,
862
- own('params'),
863
- own('paramsSerializer')
864
- ).replace(/^\?/, '');
865
- } catch (err) {
866
- return reject(
867
- AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config, null, null, {
868
- url: own('url'),
869
- exists: true
870
- })
871
- );
872
- }
873
-
874
- headers.set(
875
- 'Accept-Encoding',
876
- utils.hasOwnProp(transitional, 'advertiseZstdAcceptEncoding') &&
877
- transitional.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
878
- false
879
- );
880
-
881
- // Null-prototype to block prototype pollution gadgets on properties read
882
- // directly by Node's http.request (e.g. insecureHTTPParser, lookup).
883
- const options = Object.assign(Object.create(null), {
884
- path,
885
- method: method,
886
- headers: toByteStringHeaderObject(headers),
887
- agents: { http: httpAgent, https: httpsAgent },
888
- auth,
889
- protocol,
890
- family,
891
- beforeRedirect: dispatchBeforeRedirect,
892
- beforeRedirects: Object.create(null),
893
- http2Options,
894
- });
895
-
896
- // cacheable-lookup integration hotfix
897
- !utils.isUndefined(lookup) && (options.lookup = lookup);
898
-
899
- if (socketPath) {
900
- if (typeof socketPath !== 'string') {
901
- return reject(
902
- new AxiosError('socketPath must be a string', AxiosError.ERR_BAD_OPTION_VALUE, config)
903
- );
904
- }
905
-
906
- const allowedSocketPaths = own('allowedSocketPaths');
907
- if (allowedSocketPaths != null) {
908
- const allowed = Array.isArray(allowedSocketPaths)
909
- ? allowedSocketPaths
910
- : [allowedSocketPaths];
911
-
912
- const resolvedSocket = resolvePath(socketPath);
913
- const isAllowed = allowed.some(
914
- (entry) => typeof entry === 'string' && resolvePath(entry) === resolvedSocket
915
- );
916
-
917
- if (!isAllowed) {
918
- return reject(
919
- new AxiosError(
920
- `socketPath "${socketPath}" is not permitted by allowedSocketPaths`,
921
- AxiosError.ERR_BAD_OPTION_VALUE,
922
- config
923
- )
924
- );
925
- }
926
- }
927
-
928
- options.socketPath = socketPath;
929
- } else {
930
- options.hostname = parsed.hostname.startsWith('[')
931
- ? parsed.hostname.slice(1, -1)
932
- : parsed.hostname;
933
- options.port = parsed.port;
934
- setProxy(
935
- options,
936
- configProxy,
937
- protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path,
938
- false,
939
- httpsAgent,
940
- httpAgent
941
- );
942
- }
943
- let transport;
944
- let isNativeTransport = false;
945
- // True only for the follow-redirects transport, which applies
946
- // options.maxBodyLength itself. Every other transport (http2, native
947
- // http/https, a user-supplied custom transport) needs the explicit
948
- // byte-counting pipeline below to enforce maxBodyLength on streamed uploads.
949
- let transportEnforcesMaxBodyLength = false;
950
- const isHttpsRequest = isHttps.test(options.protocol);
951
- // Don't clobber a CONNECT-tunneling agent installed by setProxy() for an
952
- // HTTPS target.
953
- if (options.agent == null) {
954
- options.agent = isHttpsRequest ? httpsAgent : httpAgent;
955
- }
956
-
957
- if (isHttp2) {
958
- transport = http2Transport;
959
- } else {
960
- const configTransport = own('transport');
961
- if (configTransport) {
962
- transport = configTransport;
963
- } else if (maxRedirects === 0) {
964
- transport = isHttpsRequest ? https : http;
965
- isNativeTransport = true;
966
- } else {
967
- transportEnforcesMaxBodyLength = true;
968
- options.sensitiveHeaders = [];
969
- if (maxRedirects) {
970
- options.maxRedirects = maxRedirects;
971
- }
972
- const configBeforeRedirect = own('beforeRedirect');
973
- if (configBeforeRedirect) {
974
- options.beforeRedirects.config = configBeforeRedirect;
975
- }
976
- if (auth) {
977
- // Restore HTTP Basic credentials on same-origin redirects only.
978
- // follow-redirects >= 1.15.8 strips Authorization on every redirect (see #6929);
979
- // cross-origin stripping is the documented mitigation for T-R2 in THREATMODEL.md
980
- // and is preserved by deliberately not restoring on origin change.
981
- const requestOrigin = parsed.origin;
982
- const authToRestore = auth;
983
- options.beforeRedirects.auth = function beforeRedirectAuth(redirectOptions) {
984
- try {
985
- if (new URL(redirectOptions.href).origin === requestOrigin) {
986
- redirectOptions.auth = authToRestore;
987
- }
988
- } catch (e) {
989
- // ignore malformed URL: leaving auth stripped is fail-safe
990
- }
991
- };
992
- }
993
- const sensitiveHeaders = own('sensitiveHeaders');
994
- if (sensitiveHeaders != null) {
995
- if (!utils.isArray(sensitiveHeaders)) {
996
- return reject(
997
- new AxiosError(
998
- 'sensitiveHeaders must be an array of strings',
999
- AxiosError.ERR_BAD_OPTION_VALUE,
1000
- config
1001
- )
1002
- );
1003
- }
1004
-
1005
- const sensitiveSet = new Set();
1006
- for (const header of sensitiveHeaders) {
1007
- if (!utils.isString(header)) {
1008
- return reject(
1009
- new AxiosError(
1010
- 'sensitiveHeaders must be an array of strings',
1011
- AxiosError.ERR_BAD_OPTION_VALUE,
1012
- config
1013
- )
1014
- );
1015
- }
1016
-
1017
- sensitiveSet.add(header.toLowerCase());
1018
- }
1019
-
1020
- if (sensitiveSet.size) {
1021
- options.sensitiveHeaders = Array.from(sensitiveSet);
1022
- options.beforeRedirects.sensitiveHeaders = function beforeRedirectSensitiveHeaders(
1023
- redirectOptions,
1024
- requestDetails
1025
- ) {
1026
- if (!isSameOriginRedirect(redirectOptions, requestDetails)) {
1027
- stripMatchingHeaders(redirectOptions.headers, sensitiveSet);
1028
- }
1029
- };
1030
- }
1031
- }
1032
- transport = isHttpsRequest ? httpsFollow : httpFollow;
1033
- }
1034
- }
1035
-
1036
- // Set an explicit maxBodyLength option for transports that inspect it.
1037
- // When maxBodyLength is -1 (default/unlimited), use Infinity so
1038
- // follow-redirects does not fall back to its own 10MB default.
1039
- if (maxBodyLength > -1) {
1040
- options.maxBodyLength = maxBodyLength;
1041
- } else {
1042
- options.maxBodyLength = Infinity;
1043
- }
1044
-
1045
- // Always set an explicit own value so a polluted
1046
- // Object.prototype.insecureHTTPParser cannot enable the lenient parser
1047
- // through Node's internal options copy
1048
- options.insecureHTTPParser = Boolean(own('insecureHTTPParser'));
1049
-
1050
- // Create the request
1051
- req = transport.request(options, function handleResponse(res) {
1052
- clearConnectPhaseTimer();
1053
-
1054
- if (req.destroyed) return;
1055
-
1056
- const streams = [res];
1057
-
1058
- const responseLength = utils.toFiniteNumber(res.headers['content-length']);
1059
-
1060
- if (onDownloadProgress || maxDownloadRate) {
1061
- const transformStream = new AxiosTransformStream({
1062
- maxRate: utils.toFiniteNumber(maxDownloadRate),
1063
- });
1064
-
1065
- onDownloadProgress &&
1066
- transformStream.on(
1067
- 'progress',
1068
- flushOnFinish(
1069
- transformStream,
1070
- progressEventDecorator(
1071
- responseLength,
1072
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
1073
- )
1074
- )
1075
- );
1076
-
1077
- streams.push(transformStream);
1078
- }
1079
-
1080
- // decompress the response body transparently if required
1081
- let responseStream = res;
1082
-
1083
- // return the last request in case of redirects
1084
- const lastRequest = res.req || req;
1085
-
1086
- // if decompress disabled we should not decompress
1087
- if (decompress !== false && res.headers['content-encoding']) {
1088
- // if no content, but headers still say that it is encoded,
1089
- // remove the header not confuse downstream operations
1090
- if (method === 'HEAD' || res.statusCode === 204) {
1091
- delete res.headers['content-encoding'];
1092
- }
1093
-
1094
- switch ((res.headers['content-encoding'] || '').toLowerCase()) {
1095
- /*eslint default-case:0*/
1096
- case 'gzip':
1097
- case 'x-gzip':
1098
- case 'compress':
1099
- case 'x-compress':
1100
- // add the unzipper to the body stream processing pipeline
1101
- streams.push(zlib.createUnzip(zlibOptions));
1102
-
1103
- // remove the content-encoding in order to not confuse downstream operations
1104
- delete res.headers['content-encoding'];
1105
- break;
1106
- case 'deflate':
1107
- streams.push(new ZlibHeaderTransformStream());
1108
-
1109
- // add the unzipper to the body stream processing pipeline
1110
- streams.push(zlib.createUnzip(zlibOptions));
1111
-
1112
- // remove the content-encoding in order to not confuse downstream operations
1113
- delete res.headers['content-encoding'];
1114
- break;
1115
- case 'br':
1116
- if (isBrotliSupported) {
1117
- streams.push(zlib.createBrotliDecompress(brotliOptions));
1118
- delete res.headers['content-encoding'];
1119
- }
1120
- break;
1121
- case 'zstd':
1122
- if (isZstdSupported) {
1123
- streams.push(zlib.createZstdDecompress(zstdOptions));
1124
- delete res.headers['content-encoding'];
1125
- }
1126
- break;
1127
- }
1128
- }
1129
-
1130
- responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0];
1131
-
1132
- const response = {
1133
- status: res.statusCode,
1134
- statusText: res.statusMessage,
1135
- headers: new AxiosHeaders(res.headers),
1136
- config,
1137
- request: lastRequest,
1138
- };
1139
-
1140
- if (responseType === 'stream') {
1141
- // Enforce maxContentLength on streamed responses; previously this
1142
- // was applied only to buffered responses.
1143
- if (maxContentLength > -1) {
1144
- const limit = maxContentLength;
1145
- const source = responseStream;
1146
- async function* enforceMaxContentLength() {
1147
- let totalResponseBytes = 0;
1148
- for await (const chunk of source) {
1149
- totalResponseBytes += chunk.length;
1150
- if (totalResponseBytes > limit) {
1151
- throw new AxiosError(
1152
- 'maxContentLength size of ' + limit + ' exceeded',
1153
- AxiosError.ERR_BAD_RESPONSE,
1154
- config,
1155
- lastRequest
1156
- );
1157
- }
1158
- yield chunk;
1159
- }
1160
- }
1161
- responseStream = stream.Readable.from(enforceMaxContentLength(), {
1162
- objectMode: false,
1163
- });
1164
- }
1165
- response.data = responseStream;
1166
- settle(resolve, reject, response);
1167
- } else {
1168
- const responseBuffer = [];
1169
- let totalResponseBytes = 0;
1170
-
1171
- responseStream.on('data', function handleStreamData(chunk) {
1172
- responseBuffer.push(chunk);
1173
- totalResponseBytes += chunk.length;
1174
-
1175
- // make sure the content length is not over the maxContentLength if specified
1176
- if (maxContentLength > -1 && totalResponseBytes > maxContentLength) {
1177
- // stream.destroy() emit aborted event before calling reject() on Node.js v16
1178
- rejected = true;
1179
- responseStream.destroy();
1180
- abort(
1181
- new AxiosError(
1182
- 'maxContentLength size of ' + maxContentLength + ' exceeded',
1183
- AxiosError.ERR_BAD_RESPONSE,
1184
- config,
1185
- lastRequest
1186
- )
1187
- );
1188
- }
1189
- });
1190
-
1191
- responseStream.on('aborted', function handlerStreamAborted() {
1192
- if (rejected) {
1193
- return;
1194
- }
1195
-
1196
- const err = new AxiosError(
1197
- 'stream has been aborted',
1198
- AxiosError.ERR_BAD_RESPONSE,
1199
- config,
1200
- lastRequest,
1201
- response
1202
- );
1203
- responseStream.destroy(err);
1204
- reject(err);
1205
- });
1206
-
1207
- responseStream.on('error', function handleStreamError(err) {
1208
- if (rejected) return;
1209
- reject(AxiosError.from(err, null, config, lastRequest, response));
1210
- });
1211
-
1212
- responseStream.on('end', function handleStreamEnd() {
1213
- try {
1214
- let responseData =
1215
- responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
1216
- if (responseType !== 'arraybuffer') {
1217
- responseData = responseData.toString(responseEncoding);
1218
- if (!responseEncoding || responseEncoding === 'utf8') {
1219
- responseData = utils.stripBOM(responseData);
1220
- }
1221
- }
1222
- response.data = responseData;
1223
- } catch (err) {
1224
- return reject(AxiosError.from(err, null, config, response.request, response));
1225
- }
1226
- settle(resolve, reject, response);
1227
- });
1228
- }
1229
-
1230
- abortEmitter.once('abort', (err) => {
1231
- if (!responseStream.destroyed) {
1232
- responseStream.emit('error', err);
1233
- responseStream.destroy();
1234
- }
1235
- });
1236
- });
1237
-
1238
- abortEmitter.once('abort', (err) => {
1239
- if (req.close) {
1240
- req.close();
1241
- } else {
1242
- req.destroy(err);
1243
- }
1244
- });
1245
-
1246
- // Handle errors
1247
- req.on('error', function handleRequestError(err) {
1248
- reject(AxiosError.from(err, null, config, req));
1249
- });
1250
-
1251
- // set tcp keep alive to prevent drop connection by peer
1252
- // Track every socket bound to this outer RedirectableRequest so a single
1253
- // 'close' listener can release ownership on all of them. follow-redirects
1254
- // re-emits the 'socket' event for each hop's native request onto the same
1255
- // outer request, so attaching per-request listeners inside this handler
1256
- // would accumulate across hops and trigger MaxListenersExceededWarning at
1257
- // >= 11 redirects. Clearing only the last-bound socket would leave stale
1258
- // kAxiosCurrentReq refs on earlier hop sockets returned to the keep-alive
1259
- // pool, causing an idle-pool 'error' to be attributed to a closed req.
1260
- const boundSockets = new Set();
1261
-
1262
- req.on('socket', function handleRequestSocket(socket) {
1263
- // default interval of sending ack packet is 1 minute
1264
- // proxy agents (e.g. agent-base) may return a generic Duplex stream
1265
- // that doesn't have setKeepAlive, so guard before calling
1266
- if (typeof socket.setKeepAlive === 'function') {
1267
- socket.setKeepAlive(true, 1000 * 60);
1268
- }
1269
-
1270
- // Install a single 'error' listener per socket (not per request) to avoid
1271
- // accumulating listeners on pooled keep-alive sockets that get reassigned
1272
- // to new requests before the previous request's 'close' fires (issue #10780).
1273
- // The listener is bound to the socket's currently-active request via a
1274
- // symbol, which is swapped as the socket is reassigned.
1275
- if (!socket[kAxiosSocketListener]) {
1276
- socket.on('error', function handleSocketError(err) {
1277
- const current = socket[kAxiosCurrentReq];
1278
- if (current && !current.destroyed) {
1279
- current.destroy(err);
1280
- }
1281
- });
1282
- socket[kAxiosSocketListener] = true;
1283
- }
1284
-
1285
- socket[kAxiosCurrentReq] = req;
1286
- boundSockets.add(socket);
1287
- });
1288
-
1289
- req.once('close', function clearCurrentReq() {
1290
- clearConnectPhaseTimer();
1291
-
1292
- for (const socket of boundSockets) {
1293
- if (socket[kAxiosCurrentReq] === req) {
1294
- socket[kAxiosCurrentReq] = null;
1295
- }
1296
- }
1297
- boundSockets.clear();
1298
- });
1299
-
1300
- // Handle request timeout
1301
- if (own('timeout')) {
1302
- // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
1303
- const timeout = parseInt(own('timeout'), 10);
1304
-
1305
- if (Number.isNaN(timeout)) {
1306
- abort(
1307
- new AxiosError(
1308
- 'error trying to parse `config.timeout` to int',
1309
- AxiosError.ERR_BAD_OPTION_VALUE,
1310
- config,
1311
- req
1312
- )
1313
- );
1314
-
1315
- return;
1316
- }
1317
-
1318
- const handleTimeout = function handleTimeout() {
1319
- if (isDone) return;
1320
- abort(createTimeoutError());
1321
- };
1322
-
1323
- if (isNativeTransport && timeout > 0) {
1324
- // Native ClientRequest#setTimeout starts from the socket lifecycle and
1325
- // may not fire while TCP connect is still pending. Mirror the
1326
- // follow-redirects wall-clock timer for the maxRedirects === 0 path.
1327
- connectPhaseTimer = setTimeout(handleTimeout, timeout);
1328
- }
1329
-
1330
- // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
1331
- // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
1332
- // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
1333
- // And then these socket which be hang up will devouring CPU little by little.
1334
- // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
1335
- req.setTimeout(timeout, handleTimeout);
1336
- } else {
1337
- // explicitly reset the socket timeout value for a possible `keep-alive` request
1338
- req.setTimeout(0);
1339
- }
1340
-
1341
- // Send the request
1342
- if (utils.isStream(data)) {
1343
- let ended = false;
1344
- let errored = false;
1345
-
1346
- data.on('end', () => {
1347
- ended = true;
1348
- });
1349
-
1350
- data.once('error', (err) => {
1351
- errored = true;
1352
- req.destroy(err);
1353
- });
1354
-
1355
- data.on('close', () => {
1356
- if (!ended && !errored) {
1357
- abort(new CanceledError('Request stream has been aborted', config, req));
1358
- }
1359
- });
1360
-
1361
- // Enforce maxBodyLength for streamed uploads on every transport that
1362
- // does not apply options.maxBodyLength itself (native http/https, http2,
1363
- // and user-supplied custom transports). The follow-redirects transport
1364
- // enforces it on the redirected HTTP/1 path.
1365
- let uploadStream = data;
1366
- if (maxBodyLength > -1 && !transportEnforcesMaxBodyLength) {
1367
- const limit = maxBodyLength;
1368
- let bytesSent = 0;
1369
- uploadStream = stream.pipeline(
1370
- [
1371
- data,
1372
- new stream.Transform({
1373
- transform(chunk, _enc, cb) {
1374
- bytesSent += chunk.length;
1375
- if (bytesSent > limit) {
1376
- return cb(
1377
- new AxiosError(
1378
- 'Request body larger than maxBodyLength limit',
1379
- AxiosError.ERR_BAD_REQUEST,
1380
- config,
1381
- req
1382
- )
1383
- );
1384
- }
1385
- cb(null, chunk);
1386
- },
1387
- }),
1388
- ],
1389
- utils.noop
1390
- );
1391
- uploadStream.on('error', (err) => {
1392
- if (!req.destroyed) req.destroy(err);
1393
- });
1394
- }
1395
-
1396
- uploadStream.pipe(req);
1397
- } else {
1398
- data && req.write(data);
1399
- req.end();
1400
- }
1401
- });
1402
- };
1403
-
1404
- export const __setProxy = setProxy;
1405
- export const __isNodeEnvProxyEnabled = isNodeEnvProxyEnabled;
1406
- export const __isSameOriginRedirect = isSameOriginRedirect;