appium-mac2-driver 4.4.0 → 4.5.1

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 (350) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/WebDriverAgentMac/IntegrationTests/AMWindowTests.m +427 -0
  3. package/WebDriverAgentMac/WebDriverAgentLib/Commands/AMWindowCommands.m +63 -0
  4. package/WebDriverAgentMac/WebDriverAgentLib/Commands/FBDebugCommands.m +2 -0
  5. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBCommandStatus.h +3 -0
  6. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBCommandStatus.m +13 -0
  7. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMScreenUtils.h +4 -0
  8. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMScreenUtils.m +23 -0
  9. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSnapshotUtils.h +18 -0
  10. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSnapshotUtils.m +43 -28
  11. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMWindowUtils.h +111 -0
  12. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMWindowUtils.m +780 -0
  13. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMXCTAccessibility.h +61 -0
  14. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMXCTAccessibility.m +108 -0
  15. package/WebDriverAgentMac/WebDriverAgentMac.xcodeproj/project.pbxproj +20 -0
  16. package/build/lib/commands/native-record-screen.d.ts +2 -0
  17. package/build/lib/commands/native-record-screen.d.ts.map +1 -1
  18. package/build/lib/commands/native-record-screen.js.map +1 -1
  19. package/build/lib/commands/windows.d.ts +22 -0
  20. package/build/lib/commands/windows.d.ts.map +1 -0
  21. package/build/lib/commands/windows.js +32 -0
  22. package/build/lib/commands/windows.js.map +1 -0
  23. package/build/lib/driver.d.ts +12 -0
  24. package/build/lib/driver.d.ts.map +1 -1
  25. package/build/lib/driver.js +3 -0
  26. package/build/lib/driver.js.map +1 -1
  27. package/build/lib/execute-method-map.d.ts +9 -0
  28. package/build/lib/execute-method-map.d.ts.map +1 -1
  29. package/build/lib/execute-method-map.js +9 -0
  30. package/build/lib/execute-method-map.js.map +1 -1
  31. package/build/lib/session-claim-handler.d.ts.map +1 -1
  32. package/build/lib/session-claim-handler.js +1 -2
  33. package/build/lib/session-claim-handler.js.map +1 -1
  34. package/build/lib/types.d.ts +26 -0
  35. package/build/lib/types.d.ts.map +1 -1
  36. package/build/lib/wda-mac.d.ts +0 -1
  37. package/build/lib/wda-mac.d.ts.map +1 -1
  38. package/build/lib/wda-mac.js +1 -1
  39. package/lib/commands/native-record-screen.ts +2 -0
  40. package/lib/commands/windows.ts +44 -0
  41. package/lib/driver.ts +4 -0
  42. package/lib/execute-method-map.ts +9 -0
  43. package/lib/session-claim-handler.ts +1 -2
  44. package/lib/types.ts +28 -0
  45. package/lib/wda-mac.ts +1 -2
  46. package/node_modules/@appium/support/build/lib/npm.d.ts.map +1 -1
  47. package/node_modules/@appium/support/build/lib/npm.js +2 -1
  48. package/node_modules/@appium/support/build/lib/npm.js.map +1 -1
  49. package/node_modules/@appium/support/build/lib/util.d.ts.map +1 -1
  50. package/node_modules/@appium/support/build/lib/util.js +13 -1
  51. package/node_modules/@appium/support/build/lib/util.js.map +1 -1
  52. package/node_modules/@appium/support/build/lib/zip.d.ts +2 -1
  53. package/node_modules/@appium/support/build/lib/zip.d.ts.map +1 -1
  54. package/node_modules/@appium/support/build/lib/zip.js +193 -64
  55. package/node_modules/@appium/support/build/lib/zip.js.map +1 -1
  56. package/node_modules/@appium/support/lib/npm.ts +2 -1
  57. package/node_modules/@appium/support/lib/util.ts +13 -1
  58. package/node_modules/@appium/support/lib/zip.ts +231 -71
  59. package/node_modules/@appium/support/node_modules/axios/CHANGELOG.md +1934 -0
  60. package/node_modules/@appium/support/node_modules/axios/LICENSE +7 -0
  61. package/node_modules/@appium/support/node_modules/axios/MIGRATION_GUIDE.md +877 -0
  62. package/node_modules/@appium/support/node_modules/axios/README.md +2851 -0
  63. package/node_modules/@appium/support/node_modules/axios/dist/axios.js +5807 -0
  64. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js +5 -0
  65. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js.map +1 -0
  66. package/node_modules/@appium/support/node_modules/axios/dist/browser/axios.cjs +5829 -0
  67. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.js +5850 -0
  68. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js +3 -0
  69. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js.map +1 -0
  70. package/node_modules/@appium/support/node_modules/axios/dist/node/axios.cjs +6808 -0
  71. package/node_modules/@appium/support/node_modules/axios/index.d.cts +766 -0
  72. package/node_modules/@appium/support/node_modules/axios/index.d.ts +787 -0
  73. package/node_modules/@appium/support/node_modules/axios/index.js +45 -0
  74. package/node_modules/@appium/support/node_modules/axios/lib/adapters/README.md +36 -0
  75. package/node_modules/@appium/support/node_modules/axios/lib/adapters/adapters.js +132 -0
  76. package/node_modules/@appium/support/node_modules/axios/lib/adapters/fetch.js +696 -0
  77. package/node_modules/@appium/support/node_modules/axios/lib/adapters/http.js +1490 -0
  78. package/node_modules/@appium/support/node_modules/axios/lib/adapters/xhr.js +277 -0
  79. package/node_modules/@appium/support/node_modules/axios/lib/axios.js +89 -0
  80. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CancelToken.js +135 -0
  81. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CanceledError.js +22 -0
  82. package/node_modules/@appium/support/node_modules/axios/lib/cancel/isCancel.js +5 -0
  83. package/node_modules/@appium/support/node_modules/axios/lib/core/Axios.js +306 -0
  84. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosError.js +219 -0
  85. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosHeaders.js +474 -0
  86. package/node_modules/@appium/support/node_modules/axios/lib/core/InterceptorManager.js +171 -0
  87. package/node_modules/@appium/support/node_modules/axios/lib/core/README.md +8 -0
  88. package/node_modules/@appium/support/node_modules/axios/lib/core/buildFullPath.js +76 -0
  89. package/node_modules/@appium/support/node_modules/axios/lib/core/dispatchRequest.js +95 -0
  90. package/node_modules/@appium/support/node_modules/axios/lib/core/mergeConfig.js +174 -0
  91. package/node_modules/@appium/support/node_modules/axios/lib/core/methodList.js +17 -0
  92. package/node_modules/@appium/support/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
  93. package/node_modules/@appium/support/node_modules/axios/lib/core/settle.js +27 -0
  94. package/node_modules/@appium/support/node_modules/axios/lib/core/transformData.js +28 -0
  95. package/node_modules/@appium/support/node_modules/axios/lib/defaults/index.js +178 -0
  96. package/node_modules/@appium/support/node_modules/axios/lib/defaults/transitional.js +10 -0
  97. package/node_modules/@appium/support/node_modules/axios/lib/env/README.md +3 -0
  98. package/node_modules/@appium/support/node_modules/axios/lib/env/classes/FormData.js +2 -0
  99. package/node_modules/@appium/support/node_modules/axios/lib/env/data.js +1 -0
  100. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosTransformStream.js +156 -0
  101. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
  102. package/node_modules/@appium/support/node_modules/axios/lib/helpers/Http2Sessions.js +121 -0
  103. package/node_modules/@appium/support/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
  104. package/node_modules/@appium/support/node_modules/axios/lib/helpers/README.md +7 -0
  105. package/node_modules/@appium/support/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
  106. package/node_modules/@appium/support/node_modules/axios/lib/helpers/bind.js +14 -0
  107. package/node_modules/@appium/support/node_modules/axios/lib/helpers/buildURL.js +69 -0
  108. package/node_modules/@appium/support/node_modules/axios/lib/helpers/callbackify.js +18 -0
  109. package/node_modules/@appium/support/node_modules/axios/lib/helpers/combineURLs.js +23 -0
  110. package/node_modules/@appium/support/node_modules/axios/lib/helpers/composeSignals.js +68 -0
  111. package/node_modules/@appium/support/node_modules/axios/lib/helpers/cookies.js +64 -0
  112. package/node_modules/@appium/support/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
  113. package/node_modules/@appium/support/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +166 -0
  114. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToJSON.js +125 -0
  115. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
  116. package/node_modules/@appium/support/node_modules/axios/lib/helpers/fromDataURI.js +69 -0
  117. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
  118. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
  119. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isURLSameOrigin.js +16 -0
  120. package/node_modules/@appium/support/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  121. package/node_modules/@appium/support/node_modules/axios/lib/helpers/null.js +2 -0
  122. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseHeaders.js +71 -0
  123. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
  124. package/node_modules/@appium/support/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
  125. package/node_modules/@appium/support/node_modules/axios/lib/helpers/readBlob.js +15 -0
  126. package/node_modules/@appium/support/node_modules/axios/lib/helpers/resolveConfig.js +107 -0
  127. package/node_modules/@appium/support/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  128. package/node_modules/@appium/support/node_modules/axios/lib/helpers/shouldBypassProxy.js +505 -0
  129. package/node_modules/@appium/support/node_modules/axios/lib/helpers/speedometer.js +55 -0
  130. package/node_modules/@appium/support/node_modules/axios/lib/helpers/spread.js +28 -0
  131. package/node_modules/@appium/support/node_modules/axios/lib/helpers/throttle.js +45 -0
  132. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toFormData.js +279 -0
  133. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
  134. package/node_modules/@appium/support/node_modules/axios/lib/helpers/trackStream.js +89 -0
  135. package/node_modules/@appium/support/node_modules/axios/lib/helpers/validator.js +112 -0
  136. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
  137. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
  138. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
  139. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/index.js +13 -0
  140. package/node_modules/@appium/support/node_modules/axios/lib/platform/common/utils.js +52 -0
  141. package/node_modules/@appium/support/node_modules/axios/lib/platform/index.js +7 -0
  142. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
  143. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
  144. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
  145. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/index.js +37 -0
  146. package/node_modules/@appium/support/node_modules/axios/lib/utils.js +1150 -0
  147. package/node_modules/@appium/support/node_modules/axios/package.json +203 -0
  148. package/node_modules/@appium/support/package.json +6 -6
  149. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts +6 -4
  150. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts.map +1 -1
  151. package/node_modules/@appium/types/lib/commands/basedriver.ts +4 -4
  152. package/node_modules/@appium/types/package.json +2 -2
  153. package/node_modules/appium-xcode/CHANGELOG.md +7 -0
  154. package/node_modules/appium-xcode/package.json +4 -4
  155. package/node_modules/asyncbox/README.md +43 -0
  156. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts +9 -0
  157. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts.map +1 -0
  158. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js +35 -0
  159. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js.map +1 -0
  160. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts +9 -0
  161. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts.map +1 -0
  162. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js +23 -0
  163. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js.map +1 -0
  164. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts +9 -0
  165. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -0
  166. package/node_modules/asyncbox/build/cjs/lib/errors.js +20 -0
  167. package/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -0
  168. package/node_modules/asyncbox/build/cjs/lib/index.d.ts +12 -0
  169. package/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -0
  170. package/node_modules/asyncbox/build/cjs/lib/index.js +24 -0
  171. package/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -0
  172. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts +3 -0
  173. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts.map +1 -0
  174. package/node_modules/asyncbox/build/cjs/lib/limit-function.js +15 -0
  175. package/node_modules/asyncbox/build/cjs/lib/limit-function.js.map +1 -0
  176. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts +74 -0
  177. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -0
  178. package/node_modules/asyncbox/build/cjs/lib/lock.js +295 -0
  179. package/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -0
  180. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts +15 -0
  181. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts.map +1 -0
  182. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js +36 -0
  183. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js.map +1 -0
  184. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts +17 -0
  185. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts.map +1 -0
  186. package/node_modules/asyncbox/build/cjs/lib/retry.js +57 -0
  187. package/node_modules/asyncbox/build/cjs/lib/retry.js.map +1 -0
  188. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts +20 -0
  189. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts.map +1 -0
  190. package/node_modules/asyncbox/build/cjs/lib/sleep.js +61 -0
  191. package/node_modules/asyncbox/build/cjs/lib/sleep.js.map +1 -0
  192. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +18 -0
  193. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -0
  194. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +51 -0
  195. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -0
  196. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts +16 -0
  197. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts.map +1 -0
  198. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js +45 -0
  199. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js.map +1 -0
  200. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts +9 -0
  201. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts.map +1 -0
  202. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js +32 -0
  203. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js.map +1 -0
  204. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts +9 -0
  205. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts.map +1 -0
  206. package/node_modules/asyncbox/build/esm/lib/asyncmap.js +20 -0
  207. package/node_modules/asyncbox/build/esm/lib/asyncmap.js.map +1 -0
  208. package/node_modules/asyncbox/build/esm/lib/errors.d.ts +9 -0
  209. package/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -0
  210. package/node_modules/asyncbox/build/esm/lib/errors.js +15 -0
  211. package/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -0
  212. package/node_modules/asyncbox/build/esm/lib/index.d.ts +12 -0
  213. package/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -0
  214. package/node_modules/asyncbox/build/esm/lib/index.js +10 -0
  215. package/node_modules/asyncbox/build/esm/lib/index.js.map +1 -0
  216. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts +3 -0
  217. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts.map +1 -0
  218. package/node_modules/asyncbox/build/esm/lib/limit-function.js +12 -0
  219. package/node_modules/asyncbox/build/esm/lib/limit-function.js.map +1 -0
  220. package/node_modules/asyncbox/build/esm/lib/lock.d.ts +74 -0
  221. package/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -0
  222. package/node_modules/asyncbox/build/esm/lib/lock.js +291 -0
  223. package/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -0
  224. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts +15 -0
  225. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts.map +1 -0
  226. package/node_modules/asyncbox/build/esm/lib/long-sleep.js +33 -0
  227. package/node_modules/asyncbox/build/esm/lib/long-sleep.js.map +1 -0
  228. package/node_modules/asyncbox/build/esm/lib/retry.d.ts +17 -0
  229. package/node_modules/asyncbox/build/esm/lib/retry.d.ts.map +1 -0
  230. package/node_modules/asyncbox/build/esm/lib/retry.js +53 -0
  231. package/node_modules/asyncbox/build/esm/lib/retry.js.map +1 -0
  232. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts +20 -0
  233. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts.map +1 -0
  234. package/node_modules/asyncbox/build/esm/lib/sleep.js +58 -0
  235. package/node_modules/asyncbox/build/esm/lib/sleep.js.map +1 -0
  236. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +18 -0
  237. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -0
  238. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +48 -0
  239. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -0
  240. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts +16 -0
  241. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map +1 -0
  242. package/node_modules/asyncbox/build/esm/lib/with-timeout.js +42 -0
  243. package/node_modules/asyncbox/build/esm/lib/with-timeout.js.map +1 -0
  244. package/node_modules/asyncbox/lib/asyncfilter.ts +38 -0
  245. package/node_modules/asyncbox/lib/asyncmap.ts +29 -0
  246. package/node_modules/asyncbox/lib/errors.ts +15 -0
  247. package/node_modules/asyncbox/lib/index.ts +21 -0
  248. package/node_modules/asyncbox/lib/limit-function.ts +18 -0
  249. package/node_modules/asyncbox/lib/lock.ts +360 -0
  250. package/node_modules/asyncbox/lib/long-sleep.ts +38 -0
  251. package/node_modules/asyncbox/lib/retry.ts +61 -0
  252. package/node_modules/asyncbox/lib/sleep.ts +79 -0
  253. package/node_modules/asyncbox/lib/wait-for-condition.ts +52 -0
  254. package/node_modules/asyncbox/lib/with-timeout.ts +43 -0
  255. package/node_modules/asyncbox/package.json +8 -8
  256. package/node_modules/axios/README.md +41 -106
  257. package/node_modules/axios/dist/axios.js +931 -278
  258. package/node_modules/axios/dist/axios.min.js +2 -2
  259. package/node_modules/axios/dist/axios.min.js.map +1 -1
  260. package/node_modules/axios/dist/browser/axios.cjs +948 -268
  261. package/node_modules/axios/dist/esm/axios.js +948 -268
  262. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  263. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  264. package/node_modules/axios/dist/node/axios.cjs +925 -242
  265. package/node_modules/axios/index.d.cts +20 -1
  266. package/node_modules/axios/index.d.ts +18 -1
  267. package/node_modules/axios/lib/adapters/fetch.js +73 -20
  268. package/node_modules/axios/lib/adapters/http.js +145 -26
  269. package/node_modules/axios/lib/adapters/xhr.js +120 -13
  270. package/node_modules/axios/lib/core/Axios.js +67 -12
  271. package/node_modules/axios/lib/core/AxiosError.js +59 -0
  272. package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
  273. package/node_modules/axios/lib/core/InterceptorManager.js +13 -2
  274. package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
  275. package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
  276. package/node_modules/axios/lib/core/dispatchRequest.js +20 -0
  277. package/node_modules/axios/lib/core/mergeConfig.js +183 -120
  278. package/node_modules/axios/lib/defaults/transitional.js +1 -0
  279. package/node_modules/axios/lib/env/data.js +1 -1
  280. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
  281. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -1
  282. package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
  283. package/node_modules/axios/lib/helpers/cookies.js +30 -6
  284. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
  285. package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
  286. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
  287. package/node_modules/axios/lib/helpers/fromDataURI.js +8 -2
  288. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
  289. package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
  290. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  291. package/node_modules/axios/lib/helpers/resolveConfig.js +16 -3
  292. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +16 -1
  293. package/node_modules/axios/lib/utils.js +61 -10
  294. package/node_modules/axios/package.json +1 -2
  295. package/node_modules/bare-url/README.md +4 -0
  296. package/node_modules/bare-url/index.d.ts +3 -0
  297. package/node_modules/bare-url/index.js +42 -18
  298. package/node_modules/bare-url/lib/errors.js +4 -0
  299. package/node_modules/bare-url/package.json +1 -1
  300. package/node_modules/bare-url/prebuilds/android-arm/bare-url.bare +0 -0
  301. package/node_modules/bare-url/prebuilds/android-arm64/bare-url.bare +0 -0
  302. package/node_modules/bare-url/prebuilds/android-ia32/bare-url.bare +0 -0
  303. package/node_modules/bare-url/prebuilds/android-x64/bare-url.bare +0 -0
  304. package/node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare +0 -0
  305. package/node_modules/bare-url/prebuilds/darwin-x64/bare-url.bare +0 -0
  306. package/node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare +0 -0
  307. package/node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
  308. package/node_modules/bare-url/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
  309. package/node_modules/bare-url/prebuilds/linux-arm64/bare-url.bare +0 -0
  310. package/node_modules/bare-url/prebuilds/linux-x64/bare-url.bare +0 -0
  311. package/node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare +0 -0
  312. package/node_modules/bare-url/prebuilds/win32-x64/bare-url.bare +0 -0
  313. package/node_modules/follow-redirects/README.md +27 -1
  314. package/node_modules/follow-redirects/index.js +1 -5
  315. package/node_modules/follow-redirects/package.json +1 -1
  316. package/node_modules/shell-quote/README.md +37 -4
  317. package/node_modules/shell-quote/package.json +10 -6
  318. package/node_modules/shell-quote/parse.d.ts +1 -1
  319. package/node_modules/shell-quote/parse.js +63 -11
  320. package/node_modules/shell-quote/quote.d.ts +2 -1
  321. package/node_modules/shell-quote/quote.js +23 -3
  322. package/node_modules/uuid/package.json +17 -17
  323. package/package.json +6 -7
  324. package/scripts/setup-accessibility.mjs +175 -0
  325. package/node_modules/async-lock/AUTHORS +0 -21
  326. package/node_modules/async-lock/History.md +0 -132
  327. package/node_modules/async-lock/LICENSE +0 -22
  328. package/node_modules/async-lock/README.md +0 -177
  329. package/node_modules/async-lock/index.js +0 -2
  330. package/node_modules/async-lock/lib/index.js +0 -312
  331. package/node_modules/async-lock/package.json +0 -48
  332. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts +0 -103
  333. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts.map +0 -1
  334. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js +0 -311
  335. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js.map +0 -1
  336. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts +0 -103
  337. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts.map +0 -1
  338. package/node_modules/asyncbox/build/esm/lib/asyncbox.js +0 -298
  339. package/node_modules/asyncbox/build/esm/lib/asyncbox.js.map +0 -1
  340. package/node_modules/asyncbox/lib/asyncbox.ts +0 -382
  341. package/node_modules/shell-quote/.nycrc +0 -14
  342. package/node_modules/shell-quote/eslint.config.mjs +0 -29
  343. package/node_modules/shell-quote/security.md +0 -11
  344. package/node_modules/shell-quote/test/comment.js +0 -16
  345. package/node_modules/shell-quote/test/env.js +0 -52
  346. package/node_modules/shell-quote/test/env_fn.js +0 -21
  347. package/node_modules/shell-quote/test/op.js +0 -102
  348. package/node_modules/shell-quote/test/parse.js +0 -149
  349. package/node_modules/shell-quote/test/quote.js +0 -145
  350. package/node_modules/shell-quote/test/set.js +0 -31
@@ -1,4 +1,4 @@
1
- /*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.21.0 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  var FormData$1 = require('form-data');
@@ -306,11 +306,17 @@ const isPlainObject = val => {
306
306
  return false;
307
307
  }
308
308
  const prototype = getPrototypeOf(val);
309
- return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
310
- // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
311
- // evidence the value is tagged/iterable, while ignoring members reachable
312
- // only through shared or terminal prototype boundaries.
313
- !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
309
+ return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) && (
310
+ // Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
311
+ // value is tagged/iterable, ignoring members reachable only through shared
312
+ // or terminal prototype boundaries. This is exactly what
313
+ // hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
314
+ // above (null, Object.prototype, or a terminal null-prototype template) is
315
+ // a boundary, so the walk never inspects anything but `val`'s own members,
316
+ // and stops before even those when `val` is itself the boundary
317
+ // Object.prototype. Checking that inline avoids allocating the walker's
318
+ // `seen` list twice per call on the mergeConfig / merge hot path.
319
+ isPrototypeBoundary(val, prototype, true) || !hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator));
314
320
  };
315
321
 
316
322
  /**
@@ -561,15 +567,29 @@ function merge(...objs) {
561
567
  skipUndefined
562
568
  } = isContextDefined(this) && this || {};
563
569
  const result = {};
570
+ // Caseless lookup only applies to string keys — symbol keys are
571
+ // identity-matched. Every string key that reaches `result` passes through
572
+ // this index first, so it can never hold two case variants of one key and a
573
+ // lowercase -> key map is exactly what findKey(result, key) would rescan
574
+ // Object.keys(result) for on each assignment.
575
+ const lowerCaseKeys = caseless ? Object.create(null) : null;
564
576
  const assignValue = (val, key) => {
565
577
  // Skip dangerous property names to prevent prototype pollution
566
578
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
567
579
  return;
568
580
  }
569
-
570
- // findKey lowercases the key, so caseless lookup only applies to strings —
571
- // symbol keys are identity-matched.
572
- const targetKey = caseless && typeof key === 'string' && findKey(result, key) || key;
581
+ let targetKey = key;
582
+ if (lowerCaseKeys && typeof key === 'string') {
583
+ const lowerKey = key.toLowerCase();
584
+ const knownKey = lowerCaseKeys[lowerKey];
585
+ // A key recorded but absent from `result` was skipped by skipUndefined;
586
+ // the later spelling wins then, as it does for findKey.
587
+ if (knownKey !== undefined && hasOwnProperty(result, knownKey)) {
588
+ targetKey = knownKey;
589
+ } else {
590
+ lowerCaseKeys[lowerKey] = key;
591
+ }
592
+ }
573
593
  // Read via own-prop only — a bare `result[targetKey]` walks the prototype
574
594
  // chain, so a polluted Object.prototype value could surface here and get
575
595
  // copied into the merged result.
@@ -590,7 +610,7 @@ function merge(...objs) {
590
610
  continue;
591
611
  }
592
612
  forEach(source, assignValue);
593
- if (typeof source !== 'object' || isArray(source)) {
613
+ if (typeof source !== 'object' || isArray(source) || !Object.getOwnPropertySymbols) {
594
614
  continue;
595
615
  }
596
616
  const symbols = Object.getOwnPropertySymbols(source);
@@ -745,7 +765,27 @@ const toArray = thing => {
745
765
  if (!thing) return null;
746
766
  if (isArray(thing)) return thing;
747
767
  let i = thing.length;
748
- if (!isNumber(i)) return null;
768
+ if (!Number.isSafeInteger(i) || i < 0 || i > 0xffffffff) return null;
769
+
770
+ // Bound the copy by actual indexed properties, including hidden and inherited
771
+ // members of array-like collections, rather than by the declared length alone.
772
+ const indexes = new Set();
773
+ const seen = new Set();
774
+ let source = thing;
775
+ while (source != null && indexes.size < i) {
776
+ if (seen.has(source)) return null;
777
+ seen.add(source);
778
+ const prototype = getPrototypeOf(source);
779
+ if (isPrototypeBoundary(source, prototype, source === thing)) break;
780
+ Object.getOwnPropertyNames(source).forEach(key => {
781
+ const index = +key;
782
+ if (Number.isInteger(index) && index >= 0 && index < i && String(index) === key && hasOwnProperty(source, key)) {
783
+ indexes.add(index);
784
+ }
785
+ });
786
+ source = prototype;
787
+ }
788
+ if (indexes.size !== i) return null;
749
789
  const arr = new Array(i);
750
790
  while (i-- > 0) {
751
791
  arr[i] = thing[i];
@@ -1096,7 +1136,8 @@ const ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-
1096
1136
  * @returns {Object} Headers parsed into an object
1097
1137
  */
1098
1138
  var parseHeaders = rawHeaders => {
1099
- const parsed = {};
1139
+ // Header names are data, including __proto__; avoid inherited setters.
1140
+ const parsed = Object.create(null);
1100
1141
  let key;
1101
1142
  let val;
1102
1143
  let i;
@@ -1266,9 +1307,21 @@ function parseParameters(value) {
1266
1307
  return parameters;
1267
1308
  }
1268
1309
  const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1310
+
1311
+ // `__proto__` is a valid field name, and the one name the uppercase mapping at
1312
+ // the bottom of this file cannot reach: it is inherited from Object.prototype
1313
+ // instead of being declared on AxiosHeaders.prototype, so `self.__proto__ = v`
1314
+ // runs the inherited setter. That silently discards the header, and an array
1315
+ // value replaces the instance prototype, taking every method with it.
1316
+ // Store it under the same kind of case variant that mapping uses for `set` and
1317
+ // `constructor`. Header lookup is caseless, so it reads back under either
1318
+ // spelling, and no own `__proto__` slot is ever created for a later
1319
+ // `Object.assign` to copy onto a plain object through the same setter.
1320
+ const PROTO_HEADER_SLOT = '__Proto__';
1321
+ const headerSlot = name => name === '__proto__' ? PROTO_HEADER_SLOT : name;
1269
1322
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1270
1323
  if (utils$1.isFunction(filter)) {
1271
- return filter.call(this, value, header);
1324
+ return filter.call(context, value, header);
1272
1325
  }
1273
1326
  if (isHeaderNameFilter) {
1274
1327
  value = header;
@@ -1313,7 +1366,7 @@ class AxiosHeaders {
1313
1366
  }
1314
1367
  const key = utils$1.findKey(self, lHeader);
1315
1368
  if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1316
- self[key || _header] = normalizeValue(_value);
1369
+ self[headerSlot(key || _header)] = normalizeValue(_value);
1317
1370
  }
1318
1371
  }
1319
1372
  const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
@@ -1408,7 +1461,7 @@ class AxiosHeaders {
1408
1461
  }
1409
1462
  normalize(format) {
1410
1463
  const self = this;
1411
- const headers = {};
1464
+ const headers = Object.create(null);
1412
1465
  utils$1.forEach(this, (value, header) => {
1413
1466
  const key = utils$1.findKey(headers, header);
1414
1467
  if (key) {
@@ -1416,7 +1469,7 @@ class AxiosHeaders {
1416
1469
  delete self[header];
1417
1470
  return;
1418
1471
  }
1419
- const normalized = format ? formatHeader(header) : String(header).trim();
1472
+ const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
1420
1473
  if (normalized !== header) {
1421
1474
  delete self[header];
1422
1475
  }
@@ -1565,6 +1618,60 @@ function aggregateErrorMessage(error) {
1565
1618
  }).filter(Boolean).join('; ');
1566
1619
  return message || error.name || 'AggregateError';
1567
1620
  }
1621
+
1622
+ // Shared with `Axios.prototype.request`, which splices the reconstructed
1623
+ // caller frames in ahead of this marker.
1624
+ const CAUSED_BY_SEPARATOR = '\nCaused by: ';
1625
+ const $causeStack = Symbol('causeStack');
1626
+
1627
+ // Match the section we appended, not marker-like text in an error message or
1628
+ // a replacement stack supplied by the caller. Do not re-read the cause's stack.
1629
+ function getCauseStackIndex(error, stack) {
1630
+ const causeStack = utils$1.hasOwnProp(error, $causeStack) && error[$causeStack];
1631
+ return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
1632
+ }
1633
+
1634
+ /**
1635
+ * Append the stack of a wrapped error to `target.stack`.
1636
+ *
1637
+ * `cause` already exposes the original error for tooling that walks the standard
1638
+ * cause chain, but many error reporters read `stack` and nothing else. Inlining
1639
+ * the wrapped stack there means those reporters surface the underlying failure
1640
+ * instead of the axios frames that normalized it (see #6670).
1641
+ *
1642
+ * Every read is defensive: a custom `Error.prepareStackTrace` hook, a runtime
1643
+ * without stack support, or a replaced `stack` property can leave the value
1644
+ * missing, non-string, or read-only, and normalizing an error must not throw
1645
+ * because of that.
1646
+ *
1647
+ * @param {Error} target The AxiosError being built.
1648
+ * @param {Error} source The error being wrapped.
1649
+ *
1650
+ * @returns {void}
1651
+ */
1652
+ function appendCauseStack(target, source) {
1653
+ try {
1654
+ const sourceStack = source && source.stack;
1655
+ if (typeof sourceStack !== 'string' || !sourceStack) {
1656
+ return;
1657
+ }
1658
+ const targetStack = target.stack;
1659
+ if (typeof targetStack !== 'string' || !targetStack) {
1660
+ return;
1661
+ }
1662
+
1663
+ // Each call to `from()` creates a fresh target. Re-wrapping includes the
1664
+ // previous stack verbatim, adding one cause section per wrap.
1665
+ const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
1666
+ target.stack = targetStack + causeStack;
1667
+ Object.defineProperty(target, $causeStack, {
1668
+ __proto__: null,
1669
+ value: causeStack
1670
+ });
1671
+ } catch (e) {
1672
+ // Ignore failures from custom stack hooks or un-writable stack properties.
1673
+ }
1674
+ }
1568
1675
  class AxiosError extends Error {
1569
1676
  static from(error, code, config, request, response, customProps) {
1570
1677
  // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
@@ -1590,6 +1697,10 @@ class AxiosError extends Error {
1590
1697
  });
1591
1698
  axiosError.name = error.name;
1592
1699
 
1700
+ // Inline the wrapped stack for reporters that read only `stack`; the `cause`
1701
+ // property above already covers cause-aware tooling.
1702
+ appendCauseStack(axiosError, error);
1703
+
1593
1704
  // Preserve status from the original error if not already set from response
1594
1705
  if (error.status != null && axiosError.status == null) {
1595
1706
  axiosError.status = error.status;
@@ -2014,6 +2125,15 @@ function trimHandlers(handlers) {
2014
2125
  handlers.pop();
2015
2126
  }
2016
2127
  }
2128
+
2129
+ // Preserve the array-key coercion used before IDs were stored in a Map, without
2130
+ // treating null, empty strings, or noncanonical numeric strings as ID zero.
2131
+ function normalizeHandlerId(id) {
2132
+ if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
2133
+ return Number(id);
2134
+ }
2135
+ return id;
2136
+ }
2017
2137
  function syncHandlerEntries(manager, internals) {
2018
2138
  const handlers = manager.handlers;
2019
2139
  const length = countHandlers(handlers);
@@ -2086,9 +2206,10 @@ class InterceptorManager {
2086
2206
  eject(id) {
2087
2207
  const internals = this[$internals];
2088
2208
  syncHandlerEntries(this, internals);
2089
- const entry = internals.handlerEntries.get(id);
2209
+ const handlerId = normalizeHandlerId(id);
2210
+ const entry = internals.handlerEntries.get(handlerId);
2090
2211
  if (entry) {
2091
- internals.handlerEntries.delete(id);
2212
+ internals.handlerEntries.delete(handlerId);
2092
2213
 
2093
2214
  // Ignore IDs invalidated by clear or direct replacement of handlers.
2094
2215
  if (this.handlers[entry.index] !== entry.handler) {
@@ -2152,7 +2273,8 @@ var transitionalDefaults = {
2152
2273
  clarifyTimeoutError: false,
2153
2274
  legacyInterceptorReqResOrdering: true,
2154
2275
  advertiseZstdAcceptEncoding: false,
2155
- validateStatusUndefinedResolves: true
2276
+ validateStatusUndefinedResolves: true,
2277
+ encodeBasicAuthUsername: false
2156
2278
  };
2157
2279
 
2158
2280
  var URLSearchParams = url.URLSearchParams;
@@ -2307,6 +2429,24 @@ function arrayToObject(arr) {
2307
2429
  }
2308
2430
  return obj;
2309
2431
  }
2432
+ function normalizeArray(value) {
2433
+ if (!utils$1.isArray(value)) return value;
2434
+ const keys = Object.keys(value);
2435
+ return keys.length !== value.length || keys.some((key, index) => key !== String(index)) ? arrayToObject(value) : value;
2436
+ }
2437
+ function normalizeArrays(obj) {
2438
+ const pending = [obj];
2439
+ while (pending.length) {
2440
+ const target = pending.pop();
2441
+ Object.keys(target).forEach(key => {
2442
+ const value = target[key] = normalizeArray(target[key]);
2443
+ if (utils$1.isArray(value) || utils$1.isPlainObject(value)) {
2444
+ pending.push(value);
2445
+ }
2446
+ });
2447
+ }
2448
+ return obj;
2449
+ }
2310
2450
 
2311
2451
  /**
2312
2452
  * It takes a FormData object and returns a JavaScript object
@@ -2325,6 +2465,7 @@ function formDataToJSON(formData) {
2325
2465
  name = !name && utils$1.isArray(target) ? target.length : name;
2326
2466
  if (isLast) {
2327
2467
  if (utils$1.hasOwnProp(target, name)) {
2468
+ target[name] = normalizeArray(target[name]);
2328
2469
  target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
2329
2470
  } else {
2330
2471
  target[name] = value;
@@ -2345,7 +2486,7 @@ function formDataToJSON(formData) {
2345
2486
  utils$1.forEachEntry(formData, (name, value) => {
2346
2487
  buildPath(parsePropPath(name), value, obj, 0);
2347
2488
  });
2348
- return obj;
2489
+ return normalizeArrays(obj);
2349
2490
  }
2350
2491
  return null;
2351
2492
  }
@@ -2740,16 +2881,19 @@ function getEnv(key) {
2740
2881
  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
2741
2882
  }
2742
2883
 
2743
- const VERSION = "1.20.0";
2884
+ const VERSION = "1.21.0";
2744
2885
 
2745
2886
  function parseProtocol(url) {
2746
2887
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
2747
- return match && match[1] || '';
2888
+ return match && match[1].toLowerCase() || '';
2748
2889
  }
2749
2890
 
2750
2891
  // RFC 2397: data:[<mediatype>][;base64],<data>
2751
2892
  // mediatype = type/subtype followed by optional ;name=value parameters
2752
- const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
2893
+ // The `i` flag makes the `;base64` token case-insensitive, matching the WHATWG
2894
+ // URL/Fetch data URL processor (and therefore the fetch adapter and browsers).
2895
+ // The remaining character classes do not depend on letter case.
2896
+ const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/i;
2753
2897
 
2754
2898
  /**
2755
2899
  * Parse data uri to a Buffer or Blob
@@ -2786,7 +2930,7 @@ function fromDataURI(uri, asBlob, options) {
2786
2930
  } else if (params) {
2787
2931
  mime = 'text/plain' + params;
2788
2932
  }
2789
- const buffer = encoding === 'base64' ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body), encoding);
2933
+ const buffer = encoding === 'base64' ? Buffer.from(body.replace(/%([\da-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))), 'base64') : Buffer.from(decodeURIComponent(body), encoding);
2790
2934
  if (asBlob) {
2791
2935
  if (!_Blob) {
2792
2936
  throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
@@ -2875,7 +3019,10 @@ class AxiosTransformStream extends stream.Transform {
2875
3019
  const timeWindow = internals.timeWindow;
2876
3020
  const divider = 1000 / timeWindow;
2877
3021
  const bytesThreshold = maxRate / divider;
2878
- const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
3022
+ let minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
3023
+ if (maxRate) {
3024
+ minChunkSize = Math.min(bytesThreshold, minChunkSize);
3025
+ }
2879
3026
  const pushChunk = (_chunk, _callback) => {
2880
3027
  const bytes = Buffer.byteLength(_chunk);
2881
3028
  internals.bytesSeen += bytes;
@@ -2891,6 +3038,9 @@ class AxiosTransformStream extends stream.Transform {
2891
3038
  }
2892
3039
  };
2893
3040
  const transformChunk = (_chunk, _callback) => {
3041
+ if (this.destroyed) {
3042
+ return _callback();
3043
+ }
2894
3044
  const chunkSize = Buffer.byteLength(_chunk);
2895
3045
  let chunkRemainder = null;
2896
3046
  let maxChunkSize = readableHighWaterMark;
@@ -2914,7 +3064,9 @@ class AxiosTransformStream extends stream.Transform {
2914
3064
  }, timeWindow - passed);
2915
3065
  }
2916
3066
  if (bytesLeft < maxChunkSize) {
2917
- maxChunkSize = bytesLeft;
3067
+ // A buffer boundary must consume at least one byte. Carry any
3068
+ // fractional allowance forward in the next accounting window.
3069
+ maxChunkSize = Math.max(1, Math.floor(bytesLeft));
2918
3070
  }
2919
3071
  }
2920
3072
  if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
@@ -2955,8 +3107,8 @@ const readBlob = async function* (blob) {
2955
3107
 
2956
3108
  const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
2957
3109
  const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
2958
- const CRLF = '\r\n';
2959
- const CRLF_BYTES = textEncoder.encode(CRLF);
3110
+ const CRLF$1 = '\r\n';
3111
+ const CRLF_BYTES = textEncoder.encode(CRLF$1);
2960
3112
  const CRLF_BYTES_COUNT = 2;
2961
3113
  class FormDataPart {
2962
3114
  constructor(name, value) {
@@ -2964,14 +3116,14 @@ class FormDataPart {
2964
3116
  escapeName
2965
3117
  } = this.constructor;
2966
3118
  const isStringValue = utils$1.isString(value);
2967
- let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''}${CRLF}`;
3119
+ let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''}${CRLF$1}`;
2968
3120
  if (isStringValue) {
2969
- value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
3121
+ value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF$1));
2970
3122
  } else {
2971
3123
  const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
2972
- headers += `Content-Type: ${safeType}${CRLF}`;
3124
+ headers += `Content-Type: ${safeType}${CRLF$1}`;
2973
3125
  }
2974
- this.headers = textEncoder.encode(headers + CRLF);
3126
+ this.headers = textEncoder.encode(headers + CRLF$1);
2975
3127
  this.contentLength = isStringValue ? value.byteLength : value.size;
2976
3128
  this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
2977
3129
  this.name = name;
@@ -3009,8 +3161,8 @@ const formDataToStream = (form, headersHandler, options) => {
3009
3161
  if (boundary.length < 1 || boundary.length > 70) {
3010
3162
  throw new Error('boundary must be 1-70 characters long');
3011
3163
  }
3012
- const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
3013
- const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
3164
+ const boundaryBytes = textEncoder.encode('--' + boundary + CRLF$1);
3165
+ const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF$1);
3014
3166
  let contentLength = footerBytes.byteLength;
3015
3167
  const parts = Array.from(form.entries()).map(([name, value]) => {
3016
3168
  const part = new FormDataPart(name, value);
@@ -3118,7 +3270,7 @@ class Http2Sessions {
3118
3270
  timer = null;
3119
3271
  }
3120
3272
  stream.once('close', () => {
3121
- if (! --streamsCount) {
3273
+ if (! --streamsCount && !removed) {
3122
3274
  timer = setTimeout(() => {
3123
3275
  timer = null;
3124
3276
  removeSession();
@@ -3130,6 +3282,7 @@ class Http2Sessions {
3130
3282
  }
3131
3283
  session.once('close', removeSession);
3132
3284
  session.once('error', removeSession);
3285
+ session.once('goaway', removeSession);
3133
3286
  let entry = [session, options];
3134
3287
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
3135
3288
  return session;
@@ -3408,7 +3561,20 @@ const normalizeNoProxyHost = hostname => {
3408
3561
  if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
3409
3562
  hostname = hostname.slice(1, -1);
3410
3563
  }
3411
- const trimmed = trimTrailingDots(hostname);
3564
+ let trimmed = trimTrailingDots(hostname);
3565
+ if (trimmed.indexOf(':') !== -1) {
3566
+ try {
3567
+ trimmed = new URL('http://[' + trimmed + ']/').hostname.slice(1, -1);
3568
+ } catch (_err) {
3569
+ return trimmed;
3570
+ }
3571
+ } else if (/[\u0080-\uffff]/.test(trimmed)) {
3572
+ const prefix = /^[*.]+/.exec(trimmed);
3573
+ const start = prefix ? prefix[0] : '';
3574
+ const ascii = url.domainToASCII(trimmed.slice(start.length));
3575
+ if (!ascii) return '';
3576
+ trimmed = start + trimTrailingDots(ascii);
3577
+ }
3412
3578
 
3413
3579
  // IPv4 shorthand/octal/hex → dotted-decimal; helper is a no-op for inputs
3414
3580
  // containing ':' (IPv6 and IPv4-mapped IPv6) so we fall through to unmap.
@@ -3671,7 +3837,7 @@ const asyncDecorator = (fn, scheduler = utils$1.asap) => (...args) => scheduler(
3671
3837
  * Estimate data: URL byte lengths *without* allocating large buffers.
3672
3838
  * - Fetch percent-decodes a base64 body before decoding it.
3673
3839
  * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
3674
- * raw body, including ignored characters and content after padding.
3840
+ * percent-decoded body, including ignored characters and content after padding.
3675
3841
  * - Non-base64 data is percent-decoded and then encoded as UTF-8.
3676
3842
  */
3677
3843
  const isHexDigit = charCode => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
@@ -3711,6 +3877,27 @@ const estimateBase64BufferAllocation = body => {
3711
3877
  }
3712
3878
  return Math.floor((len - padding) * 3 / 4);
3713
3879
  };
3880
+ const estimatePercentDecodedBase64BufferAllocation = body => {
3881
+ // Ordinary Base64 needs only its length and trailing padding.
3882
+ if (body.indexOf('%') === -1) {
3883
+ return estimateBase64BufferAllocation(body);
3884
+ }
3885
+ let length = 0;
3886
+ let previous = 0;
3887
+ let last = 0;
3888
+ for (let i = 0, len = body.length; i < len; i++) {
3889
+ let code = body.charCodeAt(i);
3890
+ if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
3891
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
3892
+ i += 2;
3893
+ }
3894
+ length++;
3895
+ previous = last;
3896
+ last = code;
3897
+ }
3898
+ const padding = last === 61 ? previous === 61 ? 2 : 1 : 0;
3899
+ return Math.floor((length - padding) * 3 / 4);
3900
+ };
3714
3901
  const estimatePercentDecodedBase64Bytes = body => {
3715
3902
  const len = body.length;
3716
3903
  let significant = 0;
@@ -3743,14 +3930,14 @@ const estimatePercentDecodedBase64Bytes = body => {
3743
3930
  }
3744
3931
  return base64Bytes(significant);
3745
3932
  };
3746
- const estimateDataURLBytes = (url, estimateBase64) => {
3933
+ const estimateDataURLBytes = (url, estimateBase64, base64Pattern) => {
3747
3934
  if (!url || typeof url !== 'string') return 0;
3748
- if (!url.startsWith('data:')) return 0;
3935
+ if (!/^data:/i.test(url)) return 0;
3749
3936
  const comma = url.indexOf(',');
3750
3937
  if (comma < 0) return 0;
3751
3938
  const meta = url.slice(5, comma);
3752
3939
  const body = url.slice(comma + 1);
3753
- const isBase64 = /;base64/i.test(meta);
3940
+ const isBase64 = base64Pattern.test(meta);
3754
3941
  if (isBase64) {
3755
3942
  return estimateBase64(body);
3756
3943
  }
@@ -3793,17 +3980,18 @@ const estimateDataURLBytes = (url, estimateBase64) => {
3793
3980
  function estimateDataURLDecodedBytes(url) {
3794
3981
  // Fetch removes URL fragments before processing a data: URL.
3795
3982
  const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
3796
- return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes);
3983
+ return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes, /; *base64[\t\n\f\r ]*$/i);
3797
3984
  }
3798
3985
 
3799
3986
  /**
3800
- * Estimate the Buffer backing allocation used by Node's raw base64 decoder.
3987
+ * Estimate the Buffer backing allocation used after Node's percent-decoding step.
3801
3988
  *
3802
3989
  * @param {string} url
3803
3990
  * @returns {number}
3804
3991
  */
3805
3992
  function estimateDataURLBufferAllocation(url) {
3806
- return estimateDataURLBytes(url, estimateBase64BufferAllocation);
3993
+ // Match fromDataURI's case-insensitive protocol and encoding suffix.
3994
+ return estimateDataURLBytes(url, estimatePercentDecodedBase64BufferAllocation, /;base64$/i);
3807
3995
  }
3808
3996
 
3809
3997
  const zlibOptions = {
@@ -3854,6 +4042,9 @@ const kAxiosInstalledTunnel = Symbol('axios.http.installedTunnel');
3854
4042
  // so unbounded growth is not a concern in practice.
3855
4043
  const tunnelingAgentCache = new Map();
3856
4044
  const tunnelingAgentCacheUser = new WeakMap();
4045
+ const directAgents = new WeakMap();
4046
+ const directAgentHooks = ['createConnection', 'getName'];
4047
+ const nativeAgentPoolHooks = ['addRequest', 'createSocket', 'removeSocket', 'keepSocketAlive', 'reuseSocket', '_getSession', '_cacheSession', '_evictSession'];
3857
4048
  // Minimum minor versions where Node's HTTP Agent supports native proxyEnv
3858
4049
  // handling. Checking the selected agent below also covers startup modes such
3859
4050
  // as NODE_OPTIONS=--use-env-proxy and --no-use-env-proxy precedence.
@@ -3884,32 +4075,88 @@ function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.
3884
4075
  function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
3885
4076
  return isHttps.test(options.protocol) ? configHttpsAgent || https.globalAgent : configHttpAgent || http.globalAgent;
3886
4077
  }
4078
+ function getDirectAgent(configuredAgent, transport) {
4079
+ if (!process.allowedNodeEnvironmentFlags || !process.allowedNodeEnvironmentFlags.has('--use-env-proxy')) {
4080
+ return configuredAgent;
4081
+ }
4082
+ const agent = configuredAgent || transport.globalAgent;
4083
+ const options = agent && agent.options;
4084
+ if (!(agent instanceof transport.Agent) || agent.protocol !== transport.globalAgent.protocol || !options || !utils$1.hasOwnProp(options, 'proxyEnv') || typeof options.proxyEnv !== 'object' || options.proxyEnv === null) {
4085
+ return configuredAgent;
4086
+ }
4087
+
4088
+ // These hooks own pool queues or TLS session state. Neither binding them to
4089
+ // the source agent nor copying them without subclass state preserves their
4090
+ // behavior on a separate direct pool.
4091
+ for (const hook of nativeAgentPoolHooks) {
4092
+ if (utils$1.isFunction(transport.Agent.prototype[hook]) && agent[hook] !== transport.Agent.prototype[hook]) {
4093
+ throw new AxiosError('proxy: false cannot adapt an agent overriding ' + hook + '; use an agent constructed without proxyEnv', AxiosError.ERR_BAD_OPTION_VALUE);
4094
+ }
4095
+ }
4096
+
4097
+ // Node snapshots proxyEnv when constructing the agent. Keep this check
4098
+ // conservative even when the caller later removes protocol-specific entries.
4099
+ let direct = directAgents.get(agent);
4100
+ if (!direct) {
4101
+ direct = new transport.Agent({
4102
+ ...options,
4103
+ proxyEnv: undefined
4104
+ });
4105
+
4106
+ // Agent.destroy() does not emit an event. Keep the associated pool under
4107
+ // the configured agent's lifetime, including agents reused after destroy().
4108
+ const destroy = agent.destroy;
4109
+ agent.destroy = function destroyWithDirectAgent() {
4110
+ try {
4111
+ return destroy.apply(this, arguments);
4112
+ } finally {
4113
+ direct.destroy();
4114
+ }
4115
+ };
4116
+ directAgents.set(agent, direct);
4117
+ }
4118
+
4119
+ // Connections and pool keys do not own the direct pool's queues. Preserve
4120
+ // their configured receiver and refresh hooks that change between requests.
4121
+ for (const hook of directAgentHooks) {
4122
+ direct[hook] = agent[hook] === transport.Agent.prototype[hook] ? transport.Agent.prototype[hook] : bind(agent[hook], agent);
4123
+ }
4124
+ return direct;
4125
+ }
4126
+ function setDirectAgent(options, configHttpAgent, configHttpsAgent) {
4127
+ const secure = isHttps.test(options.protocol);
4128
+ const agent = getDirectAgent(secure ? configHttpsAgent : configHttpAgent, secure ? https : http);
4129
+ options.agent = agent;
4130
+ if (options.agents) {
4131
+ options.agents[secure ? 'https' : 'http'] = agent;
4132
+ }
4133
+ }
3887
4134
  function getTunnelingAgent(agentOptions, userHttpsAgent) {
3888
4135
  const key = agentOptions.protocol + '//' + agentOptions.hostname + ':' + (agentOptions.port || '') + '#' + (agentOptions.auth || '');
3889
4136
  const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, new Map()).get(userHttpsAgent) : tunnelingAgentCache;
3890
4137
  let agent = cache.get(key);
3891
4138
  if (agent) return agent;
3892
- // Forward the user's TLS options (custom CA, rejectUnauthorized, client cert,
3893
- // etc.) into the tunneling agent so they apply to the origin TLS upgrade
3894
- // performed after CONNECT. Our proxy fields take precedence on conflict.
4139
+ // Preserve per-request TLS options for the proxy connection, with our proxy
4140
+ // fields taking precedence. Global-agent options belong only to the origin
4141
+ // TLS upgrade in the callback below.
3895
4142
  const merged = userHttpsAgent && userHttpsAgent.options ? {
3896
4143
  ...userHttpsAgent.options,
3897
4144
  ...agentOptions
3898
4145
  } : agentOptions;
3899
4146
  agent = new HttpsProxyAgent(merged);
3900
- if (userHttpsAgent && userHttpsAgent.options) {
3901
- const originTLSOptions = {
3902
- ...userHttpsAgent.options
3903
- };
3904
- const callback = agent.callback;
3905
- agent.callback = function axiosTunnelingAgentCallback(req, opts) {
3906
- // HttpsProxyAgent v5 reads callback opts for the post-CONNECT origin TLS upgrade.
3907
- return callback.call(this, req, {
3908
- ...originTLSOptions,
3909
- ...opts
3910
- });
3911
- };
3912
- }
4147
+ const callback = agent.callback;
4148
+ agent.callback = function axiosTunnelingAgentCallback(req, opts) {
4149
+ // Without a proxy the origin TLS connection would be made by https.globalAgent,
4150
+ // so its options have to reach the tunneled origin too. Resolved per request
4151
+ // because the tunneling agent outlives any one of them.
4152
+ const originTLSAgent = userHttpsAgent || https.globalAgent;
4153
+ const originTLSOptions = originTLSAgent && originTLSAgent.options;
4154
+ // HttpsProxyAgent v5 reads callback opts for the post-CONNECT origin TLS upgrade.
4155
+ return callback.call(this, req, {
4156
+ ...originTLSOptions,
4157
+ ...opts
4158
+ });
4159
+ };
3913
4160
  agent[kAxiosInstalledTunnel] = true;
3914
4161
  cache.set(key, agent);
3915
4162
  return agent;
@@ -3947,6 +4194,10 @@ const http2Sessions = new Http2Sessions();
3947
4194
  * @returns {Object<string, any>}
3948
4195
  */
3949
4196
  function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
4197
+ if (!isSameOriginRedirect(options, requestDetails)) {
4198
+ stripMatchingHeaders(options.headers, new Set(['authorization', 'cookie']));
4199
+ delete options.auth;
4200
+ }
3950
4201
  if (options.beforeRedirects.proxy) {
3951
4202
  options.beforeRedirects.proxy(options);
3952
4203
  }
@@ -3956,6 +4207,9 @@ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
3956
4207
  if (options.beforeRedirects.sensitiveHeaders) {
3957
4208
  options.beforeRedirects.sensitiveHeaders(options, requestDetails);
3958
4209
  }
4210
+ if (options.beforeRedirects.direct) {
4211
+ options.beforeRedirects.direct(options);
4212
+ }
3959
4213
  if (options.beforeRedirects.config) {
3960
4214
  options.beforeRedirects.config(options, responseDetails, requestDetails);
3961
4215
  }
@@ -4021,6 +4275,9 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
4021
4275
  if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
4022
4276
  options.agent = undefined;
4023
4277
  }
4278
+ if (isRedirect && options.agents && options.agents.https && options.agents.https[kAxiosInstalledTunnel]) {
4279
+ options.agents.https = configHttpsAgent;
4280
+ }
4024
4281
  if (proxy) {
4025
4282
  // Read proxy fields without traversing the prototype chain. URL instances expose
4026
4283
  // username/password/hostname/host/port/protocol via getters on URL.prototype (so
@@ -4254,9 +4511,9 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4254
4511
  if (httpVersion === undefined) httpVersion = 1;
4255
4512
  const rawHttpVersion = httpVersion;
4256
4513
  let http2Options = own('http2Options');
4514
+ const configProxy = own('proxy');
4257
4515
  const httpAgent = own('httpAgent');
4258
4516
  const httpsAgent = own('httpsAgent');
4259
- const configProxy = own('proxy');
4260
4517
  const responseType = own('responseType');
4261
4518
  const responseEncoding = own('responseEncoding');
4262
4519
  const socketPath = own('socketPath');
@@ -4380,6 +4637,11 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4380
4637
  } catch (err) {
4381
4638
  throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
4382
4639
  }
4640
+
4641
+ // Check bytes before converting the result to text or a stream.
4642
+ if (maxContentLength > -1 && (responseType === 'blob' ? convertedData.size : convertedData.length) > maxContentLength) {
4643
+ return reject(new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config));
4644
+ }
4383
4645
  if (responseType === 'text') {
4384
4646
  convertedData = convertedData.toString(responseEncoding);
4385
4647
  if (!responseEncoding || responseEncoding === 'utf8') {
@@ -4548,15 +4810,15 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4548
4810
  }
4549
4811
  let transport;
4550
4812
  let isNativeTransport = false;
4551
- // True only for the follow-redirects transport, which applies
4552
- // options.maxBodyLength itself. Every other transport (http2, native
4553
- // http/https, a user-supplied custom transport) needs the explicit
4554
- // byte-counting pipeline below to enforce maxBodyLength on streamed uploads.
4555
- let transportEnforcesMaxBodyLength = false;
4556
4813
  const isHttpsRequest = isHttps.test(options.protocol);
4557
4814
  // Don't clobber a CONNECT-tunneling agent installed by setProxy() for an
4558
4815
  // HTTPS target.
4559
- if (options.agent == null) {
4816
+ if (!isHttp2 && configProxy === false) {
4817
+ setDirectAgent(options, httpAgent, httpsAgent);
4818
+ options.beforeRedirects.direct = redirectOptions => {
4819
+ setDirectAgent(redirectOptions, httpAgent, httpsAgent);
4820
+ };
4821
+ } else if (options.agent == null) {
4560
4822
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
4561
4823
  }
4562
4824
  if (isHttp2) {
@@ -4572,7 +4834,6 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4572
4834
  transport = isHttpsRequest ? https : http;
4573
4835
  isNativeTransport = true;
4574
4836
  } else {
4575
- transportEnforcesMaxBodyLength = true;
4576
4837
  options.sensitiveHeaders = [];
4577
4838
  if (maxRedirects) {
4578
4839
  options.maxRedirects = maxRedirects;
@@ -4876,12 +5137,10 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4876
5137
  }
4877
5138
  });
4878
5139
 
4879
- // Enforce maxBodyLength for streamed uploads on every transport that
4880
- // does not apply options.maxBodyLength itself (native http/https, http2,
4881
- // and user-supplied custom transports). The follow-redirects transport
4882
- // enforces it on the redirected HTTP/1 path.
5140
+ // Transform decodes string chunks to Buffers before counting, so every
5141
+ // transport receives at most maxBodyLength encoded bytes.
4883
5142
  let uploadStream = data;
4884
- if (maxBodyLength > -1 && !transportEnforcesMaxBodyLength) {
5143
+ if (maxBodyLength > -1) {
4885
5144
  const limit = maxBodyLength;
4886
5145
  let bytesSent = 0;
4887
5146
  uploadStream = stream.pipeline([data, new stream.Transform({
@@ -4905,11 +5164,13 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
4905
5164
  });
4906
5165
  };
4907
5166
 
4908
- var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => url => {
4909
- url = new URL(url, platform.origin);
4910
- return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
4911
- })(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : () => true;
4912
-
5167
+ const decodeCookieValue = value => {
5168
+ try {
5169
+ return decodeURIComponent(value);
5170
+ } catch (e) {
5171
+ return value;
5172
+ }
5173
+ };
4913
5174
  var cookies = platform.hasStandardBrowserEnv ?
4914
5175
  // Standard browser envs support document.cookie
4915
5176
  {
@@ -4935,25 +5196,36 @@ var cookies = platform.hasStandardBrowserEnv ?
4935
5196
  },
4936
5197
  read(name) {
4937
5198
  if (typeof document === 'undefined') return null;
5199
+ const cookieString = document.cookie;
5200
+ if (!cookieString) return null;
4938
5201
  // Match name=value by splitting on the semicolon separator instead of building a
4939
5202
  // RegExp from `name` — interpolating an unescaped string into a RegExp would let
4940
5203
  // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
4941
5204
  // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
4942
5205
  // "; ", so ignore optional whitespace before each cookie name.
4943
- const cookies = document.cookie.split(';');
5206
+ const cookies = cookieString.split(';');
4944
5207
  for (let i = 0; i < cookies.length; i++) {
4945
5208
  const cookie = cookies[i].replace(/^\s+/, '');
4946
5209
  const eq = cookie.indexOf('=');
4947
5210
  if (eq !== -1 && cookie.slice(0, eq) === name) {
4948
- try {
4949
- return decodeURIComponent(cookie.slice(eq + 1));
4950
- } catch (e) {
4951
- return cookie.slice(eq + 1);
4952
- }
5211
+ return decodeCookieValue(cookie.slice(eq + 1));
4953
5212
  }
4954
5213
  }
4955
5214
  return null;
4956
5215
  },
5216
+ async readAsync(name) {
5217
+ try {
5218
+ const store = typeof window !== 'undefined' && window.cookieStore;
5219
+ if (store && utils$1.isFunction(store.get)) {
5220
+ const cookie = await store.get(name);
5221
+ // Both APIs expose stored bytes; preserve Axios's existing URI decoding.
5222
+ return cookie ? decodeCookieValue(cookie.value) : null;
5223
+ }
5224
+ } catch (e) {
5225
+ // Restricted or unavailable storage retains the synchronous fallback.
5226
+ }
5227
+ return this.read(name);
5228
+ },
4957
5229
  remove(name) {
4958
5230
  this.write(name, '', Date.now() - 86400000, '/');
4959
5231
  }
@@ -4964,19 +5236,242 @@ var cookies = platform.hasStandardBrowserEnv ?
4964
5236
  read() {
4965
5237
  return null;
4966
5238
  },
5239
+ async readAsync() {
5240
+ return null;
5241
+ },
4967
5242
  remove() {}
4968
5243
  };
4969
5244
 
5245
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? (origin => url => {
5246
+ url = new URL(url, document.baseURI || platform.origin);
5247
+ return origin.protocol === url.protocol && origin.host === url.host && origin.port === url.port;
5248
+ })(new URL(platform.origin)) : () => true;
5249
+
5250
+ function assertParamsAcyclic(params) {
5251
+ const pending = [{
5252
+ value: params
5253
+ }];
5254
+ const active = new WeakSet();
5255
+ const visited = new WeakSet();
5256
+ while (pending.length) {
5257
+ const {
5258
+ value,
5259
+ done
5260
+ } = pending.pop();
5261
+ if (!utils$1.isPlainObject(value) && !utils$1.isArray(value)) continue;
5262
+ if (done) {
5263
+ active.delete(value);
5264
+ continue;
5265
+ }
5266
+ if (active.has(value)) {
5267
+ throw new AxiosError('Circular reference detected in params', AxiosError.ERR_BAD_OPTION_VALUE);
5268
+ }
5269
+ if (visited.has(value)) continue;
5270
+ visited.add(value);
5271
+ active.add(value);
5272
+ pending.push({
5273
+ value,
5274
+ done: true
5275
+ });
5276
+ const keys = Object.keys(value);
5277
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
5278
+ Object.getOwnPropertySymbols(value).forEach(key => {
5279
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
5280
+ if (descriptor && descriptor.enumerable) keys.push(key);
5281
+ });
5282
+ }
5283
+ // Shallow array elements retain fields filtered during plain-object merges.
5284
+ // Inspect reserved data properties without evaluating their accessors.
5285
+ keys.forEach(key => {
5286
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
5287
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
5288
+ if (descriptor && utils$1.hasOwnProp(descriptor, 'value')) {
5289
+ pending.push({
5290
+ value: descriptor.value
5291
+ });
5292
+ }
5293
+ } else {
5294
+ pending.push({
5295
+ value: value[key]
5296
+ });
5297
+ }
5298
+ });
5299
+ }
5300
+ }
5301
+
4970
5302
  const headersToObject = thing => thing instanceof AxiosHeaders ? {
4971
5303
  ...thing
4972
5304
  } : thing;
4973
5305
  const ownEnumerableKeys = thing => {
4974
5306
  if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
4975
- return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(symbol => Object.getOwnPropertyDescriptor(thing, symbol).enumerable));
5307
+ return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(symbol => {
5308
+ const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
5309
+ return descriptor && descriptor.enumerable;
5310
+ }));
4976
5311
  }
4977
5312
  return Object.keys(thing);
4978
5313
  };
4979
5314
 
5315
+ // Copy params without recursive merges so the serializer remains responsible
5316
+ // for its depth policy. Only visit defaults that contribute to the result.
5317
+ function mergeParams(a, b) {
5318
+ const pending = [];
5319
+ const copies = new WeakMap();
5320
+ const empty = {};
5321
+ function copy(target, source) {
5322
+ if (!utils$1.isPlainObject(source)) {
5323
+ return utils$1.isArray(source) ? source.slice() : source;
5324
+ }
5325
+ const base = utils$1.isPlainObject(target) ? target : empty;
5326
+ let bases = copies.get(source);
5327
+ if (!bases) {
5328
+ bases = new WeakMap();
5329
+ copies.set(source, bases);
5330
+ }
5331
+ if (bases.has(base)) return bases.get(base);
5332
+ const result = {};
5333
+ bases.set(base, result);
5334
+ pending.push({
5335
+ base,
5336
+ source,
5337
+ result
5338
+ });
5339
+ return result;
5340
+ }
5341
+ const result = utils$1.isUndefined(b) ? copy(undefined, a) : copy(a, b);
5342
+ while (pending.length) {
5343
+ const {
5344
+ base,
5345
+ source,
5346
+ result: target
5347
+ } = pending.pop();
5348
+ const baseKeys = new Set(ownEnumerableKeys(base));
5349
+ const sourceKeys = new Set(ownEnumerableKeys(source));
5350
+ const keys = new Set([...baseKeys, ...sourceKeys]);
5351
+ keys.forEach(key => {
5352
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
5353
+ const hasSource = sourceKeys.has(key);
5354
+ const value = hasSource ? source[key] : undefined;
5355
+ const previous = (!hasSource || utils$1.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
5356
+ target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
5357
+ });
5358
+ }
5359
+ assertParamsAcyclic(result);
5360
+ return result;
5361
+ }
5362
+ function getMergedValue(target, source, prop, caseless) {
5363
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
5364
+ return utils$1.merge.call({
5365
+ caseless
5366
+ }, target, source);
5367
+ } else if (utils$1.isPlainObject(source)) {
5368
+ return utils$1.merge({}, source);
5369
+ } else if (utils$1.isArray(source)) {
5370
+ return source.slice();
5371
+ }
5372
+ return source;
5373
+ }
5374
+ function mergeDeepProperties(a, b, prop, caseless) {
5375
+ if (!utils$1.isUndefined(b)) {
5376
+ return getMergedValue(a, b, prop, caseless);
5377
+ } else if (!utils$1.isUndefined(a)) {
5378
+ return getMergedValue(undefined, a, prop, caseless);
5379
+ }
5380
+ }
5381
+
5382
+ // eslint-disable-next-line consistent-return
5383
+ function valueFromConfig2(a, b) {
5384
+ if (!utils$1.isUndefined(b)) {
5385
+ return getMergedValue(undefined, b);
5386
+ }
5387
+ }
5388
+
5389
+ // eslint-disable-next-line consistent-return
5390
+ function defaultToConfig2(a, b) {
5391
+ if (!utils$1.isUndefined(b)) {
5392
+ return getMergedValue(undefined, b);
5393
+ } else if (!utils$1.isUndefined(a)) {
5394
+ return getMergedValue(undefined, a);
5395
+ }
5396
+ }
5397
+ function getMergedTransitionalOption(config1, config2, prop) {
5398
+ const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
5399
+ if (!utils$1.isUndefined(transitional2)) {
5400
+ if (utils$1.isPlainObject(transitional2)) {
5401
+ if (utils$1.hasOwnProp(transitional2, prop)) {
5402
+ return transitional2[prop];
5403
+ }
5404
+ } else {
5405
+ return undefined;
5406
+ }
5407
+ }
5408
+ const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
5409
+ if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
5410
+ return transitional1[prop];
5411
+ }
5412
+ return undefined;
5413
+ }
5414
+
5415
+ // eslint-disable-next-line consistent-return
5416
+ function mergeDirectKeys(a, b, prop, config1, config2) {
5417
+ if (utils$1.hasOwnProp(config2, prop)) {
5418
+ return getMergedValue(a, b);
5419
+ } else if (utils$1.hasOwnProp(config1, prop)) {
5420
+ return getMergedValue(undefined, a);
5421
+ }
5422
+ }
5423
+ function mergeHeaders(a, b, prop) {
5424
+ return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
5425
+ }
5426
+
5427
+ // Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
5428
+ // this data descriptor into an accessor descriptor on the way in.
5429
+ // defineProperty only reads it, so one shared instance serves every call.
5430
+ const hasOwnPropertyDescriptor = Object.freeze({
5431
+ __proto__: null,
5432
+ value: Object.prototype.hasOwnProperty,
5433
+ enumerable: false,
5434
+ writable: true,
5435
+ configurable: true
5436
+ });
5437
+
5438
+ // The strategy table and the strategies above are stateless, so they are
5439
+ // built once at module load instead of on every call: mergeConfig runs at
5440
+ // most twice per request (once from a method alias, once from `_request`).
5441
+ const mergeMap = {
5442
+ url: valueFromConfig2,
5443
+ method: valueFromConfig2,
5444
+ data: valueFromConfig2,
5445
+ baseURL: defaultToConfig2,
5446
+ transformRequest: defaultToConfig2,
5447
+ transformResponse: defaultToConfig2,
5448
+ params: mergeParams,
5449
+ paramsSerializer: defaultToConfig2,
5450
+ timeout: defaultToConfig2,
5451
+ timeoutErrorMessage: defaultToConfig2,
5452
+ withCredentials: defaultToConfig2,
5453
+ withXSRFToken: defaultToConfig2,
5454
+ adapter: defaultToConfig2,
5455
+ responseType: defaultToConfig2,
5456
+ xsrfCookieName: defaultToConfig2,
5457
+ xsrfHeaderName: defaultToConfig2,
5458
+ onUploadProgress: defaultToConfig2,
5459
+ onDownloadProgress: defaultToConfig2,
5460
+ decompress: defaultToConfig2,
5461
+ maxContentLength: defaultToConfig2,
5462
+ maxBodyLength: defaultToConfig2,
5463
+ beforeRedirect: defaultToConfig2,
5464
+ transport: defaultToConfig2,
5465
+ httpAgent: defaultToConfig2,
5466
+ httpsAgent: defaultToConfig2,
5467
+ cancelToken: defaultToConfig2,
5468
+ socketPath: defaultToConfig2,
5469
+ allowedSocketPaths: defaultToConfig2,
5470
+ responseEncoding: defaultToConfig2,
5471
+ validateStatus: mergeDirectKeys,
5472
+ headers: mergeHeaders
5473
+ };
5474
+
4980
5475
  /**
4981
5476
  * Config-specific merge-function which creates a new config-object
4982
5477
  * by merging two configuration objects together.
@@ -4996,120 +5491,21 @@ function mergeConfig(config1, config2) {
4996
5491
  // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
4997
5492
  // ergonomics for user code that relies on it.
4998
5493
  const config = Object.create(null);
4999
- Object.defineProperty(config, 'hasOwnProperty', {
5000
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
5001
- // this data descriptor into an accessor descriptor on the way in.
5002
- __proto__: null,
5003
- value: Object.prototype.hasOwnProperty,
5004
- enumerable: false,
5005
- writable: true,
5006
- configurable: true
5007
- });
5008
- function getMergedValue(target, source, prop, caseless) {
5009
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
5010
- return utils$1.merge.call({
5011
- caseless
5012
- }, target, source);
5013
- } else if (utils$1.isPlainObject(source)) {
5014
- return utils$1.merge({}, source);
5015
- } else if (utils$1.isArray(source)) {
5016
- return source.slice();
5017
- }
5018
- return source;
5019
- }
5020
- function mergeDeepProperties(a, b, prop, caseless) {
5021
- if (!utils$1.isUndefined(b)) {
5022
- return getMergedValue(a, b, prop, caseless);
5023
- } else if (!utils$1.isUndefined(a)) {
5024
- return getMergedValue(undefined, a, prop, caseless);
5025
- }
5026
- }
5027
-
5028
- // eslint-disable-next-line consistent-return
5029
- function valueFromConfig2(a, b) {
5030
- if (!utils$1.isUndefined(b)) {
5031
- return getMergedValue(undefined, b);
5032
- }
5033
- }
5034
-
5035
- // eslint-disable-next-line consistent-return
5036
- function defaultToConfig2(a, b) {
5037
- if (!utils$1.isUndefined(b)) {
5038
- return getMergedValue(undefined, b);
5039
- } else if (!utils$1.isUndefined(a)) {
5040
- return getMergedValue(undefined, a);
5041
- }
5042
- }
5043
- function getMergedTransitionalOption(prop) {
5044
- const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
5045
- if (!utils$1.isUndefined(transitional2)) {
5046
- if (utils$1.isPlainObject(transitional2)) {
5047
- if (utils$1.hasOwnProp(transitional2, prop)) {
5048
- return transitional2[prop];
5049
- }
5050
- } else {
5051
- return undefined;
5052
- }
5053
- }
5054
- const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
5055
- if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
5056
- return transitional1[prop];
5057
- }
5058
- return undefined;
5059
- }
5060
-
5061
- // eslint-disable-next-line consistent-return
5062
- function mergeDirectKeys(a, b, prop) {
5063
- if (utils$1.hasOwnProp(config2, prop)) {
5064
- return getMergedValue(a, b);
5065
- } else if (utils$1.hasOwnProp(config1, prop)) {
5066
- return getMergedValue(undefined, a);
5067
- }
5068
- }
5069
- const mergeMap = {
5070
- url: valueFromConfig2,
5071
- method: valueFromConfig2,
5072
- data: valueFromConfig2,
5073
- baseURL: defaultToConfig2,
5074
- transformRequest: defaultToConfig2,
5075
- transformResponse: defaultToConfig2,
5076
- paramsSerializer: defaultToConfig2,
5077
- timeout: defaultToConfig2,
5078
- timeoutErrorMessage: defaultToConfig2,
5079
- withCredentials: defaultToConfig2,
5080
- withXSRFToken: defaultToConfig2,
5081
- adapter: defaultToConfig2,
5082
- responseType: defaultToConfig2,
5083
- xsrfCookieName: defaultToConfig2,
5084
- xsrfHeaderName: defaultToConfig2,
5085
- onUploadProgress: defaultToConfig2,
5086
- onDownloadProgress: defaultToConfig2,
5087
- decompress: defaultToConfig2,
5088
- maxContentLength: defaultToConfig2,
5089
- maxBodyLength: defaultToConfig2,
5090
- beforeRedirect: defaultToConfig2,
5091
- transport: defaultToConfig2,
5092
- httpAgent: defaultToConfig2,
5093
- httpsAgent: defaultToConfig2,
5094
- cancelToken: defaultToConfig2,
5095
- socketPath: defaultToConfig2,
5096
- allowedSocketPaths: defaultToConfig2,
5097
- responseEncoding: defaultToConfig2,
5098
- validateStatus: mergeDirectKeys,
5099
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
5100
- };
5101
- utils$1.forEach(ownEnumerableKeys({
5494
+ Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
5495
+ const keys = ownEnumerableKeys({
5102
5496
  ...config1,
5103
5497
  ...config2
5104
- }), function computeConfigValue(prop) {
5105
- if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
5498
+ });
5499
+ for (let i = 0, len = keys.length; i < len; i++) {
5500
+ const prop = keys[i];
5501
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
5106
5502
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
5107
5503
  const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
5108
5504
  const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
5109
- const configValue = merge(a, b, prop);
5505
+ const configValue = merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
5110
5506
  utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
5111
- });
5112
- if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption('validateStatusUndefinedResolves') === false) {
5507
+ }
5508
+ if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false) {
5113
5509
  if (utils$1.hasOwnProp(config1, 'validateStatus')) {
5114
5510
  config.validateStatus = getMergedValue(undefined, config1.validateStatus);
5115
5511
  } else {
@@ -5128,7 +5524,8 @@ function mergeConfig(config1, config2) {
5128
5524
  * @returns {string} UTF-8 bytes as a Latin-1 string
5129
5525
  */
5130
5526
  const encodeUTF8$1 = str => encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
5131
- function resolveConfig(config) {
5527
+ const readCookie = name => cookies.read(name);
5528
+ function resolveConfig(config, readXsrfCookie = readCookie) {
5132
5529
  const newConfig = mergeConfig({}, config);
5133
5530
 
5134
5531
  // Read only own properties to prevent prototype pollution gadgets
@@ -5150,8 +5547,12 @@ function resolveConfig(config) {
5150
5547
  if (auth) {
5151
5548
  const username = utils$1.getSafeProp(auth, 'username') || '';
5152
5549
  const password = utils$1.getSafeProp(auth, 'password') || '';
5550
+ const transitional = own('transitional');
5551
+ const encodeUsername = transitional && utils$1.hasOwnProp(transitional, 'encodeBasicAuthUsername') && transitional.encodeBasicAuthUsername === true;
5153
5552
  try {
5154
- headers.set('Authorization', 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : '')));
5553
+ headers.set('Authorization',
5554
+ // Preserve legacy username bytes unless the caller opts in to UTF-8.
5555
+ 'Basic ' + btoa((encodeUsername ? encodeUTF8$1(username) : username) + ':' + (password ? encodeUTF8$1(password) : '')));
5155
5556
  } catch (e) {
5156
5557
  throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
5157
5558
  }
@@ -5180,7 +5581,7 @@ function resolveConfig(config) {
5180
5581
  // the XSRF token cross-origin.
5181
5582
  const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
5182
5583
  if (shouldSendXSRF) {
5183
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
5584
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
5184
5585
  if (xsrfValue) {
5185
5586
  headers.set(xsrfHeaderName, xsrfValue);
5186
5587
  }
@@ -5192,7 +5593,18 @@ function resolveConfig(config) {
5192
5593
  const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
5193
5594
  var xhrAdapter = isXHRAdapterSupported && function (config) {
5194
5595
  return new Promise(function dispatchXhrRequest(resolve, reject) {
5195
- const _config = resolveConfig(config);
5596
+ let useAsyncXsrf;
5597
+ try {
5598
+ const store = platform.hasStandardBrowserEnv && typeof window !== 'undefined' && window.cookieStore;
5599
+ useAsyncXsrf = store && utils$1.isFunction(store.get);
5600
+ } catch (e) {
5601
+ // A restricted Cookie Store getter must retain the synchronous fallback.
5602
+ }
5603
+ let xsrfCookieName;
5604
+ const _config = resolveConfig(config, useAsyncXsrf ? name => {
5605
+ xsrfCookieName = name;
5606
+ return null;
5607
+ } : undefined);
5196
5608
  let requestData = _config.data;
5197
5609
  const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
5198
5610
  let {
@@ -5201,12 +5613,37 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
5201
5613
  onDownloadProgress
5202
5614
  } = _config;
5203
5615
  let onCanceled;
5616
+ let timeoutId;
5204
5617
  let uploadThrottled, downloadThrottled;
5205
5618
  let flushUpload, flushDownload, flushDownloadWithEvent;
5206
5619
  function done() {
5207
- flushUpload && flushUpload(); // flush events
5208
- flushDownload && flushDownload(); // flush events
5620
+ clearTimeout(timeoutId);
5621
+ // A final progress callback must not prevent the remaining cleanup.
5622
+ // Report errors asynchronously, as onloadend and the throttle timer do.
5623
+ try {
5624
+ flushUpload && flushUpload(); // flush events
5625
+ } catch (err) {
5626
+ setTimeout(() => {
5627
+ throw err;
5628
+ });
5629
+ }
5630
+ try {
5631
+ flushDownload && flushDownload(); // flush events
5632
+ } catch (err) {
5633
+ setTimeout(() => {
5634
+ throw err;
5635
+ });
5636
+ }
5209
5637
 
5638
+ // A flush can synchronously cancel the request and reenter done().
5639
+ // In that case the inner call has already detached these listeners.
5640
+ if (request) {
5641
+ downloadThrottled && request.removeEventListener('progress', downloadThrottled);
5642
+ if (request.upload) {
5643
+ uploadThrottled && request.upload.removeEventListener('progress', uploadThrottled);
5644
+ flushUpload && request.upload.removeEventListener('loadend', flushUpload);
5645
+ }
5646
+ }
5210
5647
  _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
5211
5648
  _config.signal && _config.signal.removeEventListener('abort', onCanceled);
5212
5649
  }
@@ -5332,6 +5769,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
5332
5769
 
5333
5770
  // Handle timeout
5334
5771
  request.ontimeout = function handleTimeout() {
5772
+ if (!request) return;
5335
5773
  let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
5336
5774
  const transitional = _config.transitional || transitionalDefaults;
5337
5775
  if (_config.timeoutErrorMessage) {
@@ -5347,13 +5785,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
5347
5785
  // Remove Content-Type if data is undefined
5348
5786
  requestData === undefined && requestHeaders.setContentType(null);
5349
5787
 
5350
- // Add headers to the request
5351
- if ('setRequestHeader' in request) {
5352
- utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
5353
- request.setRequestHeader(key, val);
5354
- });
5355
- }
5356
-
5357
5788
  // Add withCredentials to request if needed
5358
5789
  if (!utils$1.isUndefined(_config.withCredentials)) {
5359
5790
  request.withCredentials = !!_config.withCredentials;
@@ -5384,24 +5815,79 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
5384
5815
  return;
5385
5816
  }
5386
5817
  reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
5387
- request.abort();
5818
+ const xhr = request;
5388
5819
  done();
5389
5820
  request = null;
5821
+ xhr.abort();
5390
5822
  };
5391
5823
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
5824
+ if (!request) return;
5392
5825
  if (_config.signal) {
5393
5826
  _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
5394
5827
  }
5395
5828
  }
5829
+ if (!request) return;
5396
5830
  const protocol = parseProtocol(_config.url);
5397
5831
  if (protocol && !platform.protocols.includes(protocol)) {
5398
5832
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
5399
5833
  done();
5400
5834
  return;
5401
5835
  }
5402
-
5403
- // Send the request
5404
- request.send(requestData || null);
5836
+ const sendRequest = () => {
5837
+ if (!request) return;
5838
+ // Apply headers after an asynchronous XSRF read so existing headers are
5839
+ // replaced through AxiosHeaders rather than appended by the native XHR.
5840
+ if ('setRequestHeader' in request) {
5841
+ utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
5842
+ request.setRequestHeader(key, val);
5843
+ });
5844
+ }
5845
+ request.send(requestData || null);
5846
+ };
5847
+ if (xsrfCookieName) {
5848
+ // Native XHR timeout starts at send(). Cover cookie preparation and the
5849
+ // subsequent request with the same budget and existing timeout handler.
5850
+ const now = typeof performance !== 'undefined' && utils$1.isFunction(performance.now) ? () => performance.now() : Date.now;
5851
+ const deadline = request.timeout > 0 ? now() + Number(request.timeout) : undefined;
5852
+ const abortOnTimeout = () => {
5853
+ if (!request) return;
5854
+ const xhr = request;
5855
+ xhr.ontimeout();
5856
+ xhr.abort();
5857
+ };
5858
+ if (deadline !== undefined) {
5859
+ const scheduleTimeout = () => {
5860
+ const remaining = deadline - now();
5861
+ if (remaining > 0) {
5862
+ // Browser timers overflow above the signed 32-bit delay limit.
5863
+ timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 0x7fffffff));
5864
+ } else {
5865
+ abortOnTimeout();
5866
+ }
5867
+ };
5868
+ scheduleTimeout();
5869
+ }
5870
+ cookies.readAsync(xsrfCookieName).then(value => {
5871
+ if (!request) return;
5872
+ // Promise callbacks may run before an overdue timer after a busy task.
5873
+ if (deadline !== undefined && now() >= deadline) {
5874
+ abortOnTimeout();
5875
+ return;
5876
+ }
5877
+ if (value) {
5878
+ const headerName = utils$1.hasOwnProp(_config, 'xsrfHeaderName') && _config.xsrfHeaderName;
5879
+ requestHeaders.set(headerName, value);
5880
+ }
5881
+ sendRequest();
5882
+ }).catch(error => {
5883
+ if (!request) return;
5884
+ reject(AxiosError.from(error, null, config, request));
5885
+ done();
5886
+ request = null;
5887
+ });
5888
+ } else {
5889
+ sendRequest();
5890
+ }
5405
5891
  });
5406
5892
  };
5407
5893
 
@@ -5431,7 +5917,8 @@ const composeSignals = (signals, timeout) => {
5431
5917
  timer && clearTimeout(timer);
5432
5918
  timer = null;
5433
5919
  signals.forEach(signal => {
5434
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
5920
+ const unsubscribeSignal = utils$1.getSafeProp(signal, 'unsubscribe');
5921
+ utils$1.isFunction(unsubscribeSignal) ? unsubscribeSignal.call(signal, onabort) : signal.removeEventListener('abort', onabort);
5435
5922
  });
5436
5923
  signals = null;
5437
5924
  };
@@ -5536,6 +6023,121 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
5536
6023
  });
5537
6024
  };
5538
6025
 
6026
+ const CRLF = '\r\n';
6027
+ const normalizeLines = value => String(value).replace(/\r\n|\r|\n/g, CRLF);
6028
+ const escapeName = value => String(value).replace(/[\r\n"]/g, char => char === '\r' ? '%0D' : char === '\n' ? '%0A' : '%22');
6029
+
6030
+ // Count UTF-8 bytes without allocating an encoded copy of a field. FormData
6031
+ // string values normalize line endings; Blob/File contents remain unchanged.
6032
+ const stringBytes = (value, normalize) => {
6033
+ let length = 0;
6034
+ for (let i = 0; i < value.length; i++) {
6035
+ const code = value.charCodeAt(i);
6036
+ if (normalize && (code === 13 || code === 10)) {
6037
+ if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
6038
+ length += 2;
6039
+ } else if (code < 0x80) {
6040
+ length++;
6041
+ } else if (code < 0x800) {
6042
+ length += 2;
6043
+ } else if (code >= 0xd800 && code <= 0xdbff && value.charCodeAt(i + 1) >= 0xdc00 && value.charCodeAt(i + 1) <= 0xdfff) {
6044
+ length += 4;
6045
+ i++;
6046
+ } else {
6047
+ length += 3;
6048
+ }
6049
+ }
6050
+ return length;
6051
+ };
6052
+
6053
+ // Describe serialization failures independently of any request library.
6054
+ class FormDataError extends TypeError {
6055
+ constructor(message, reason) {
6056
+ super(message);
6057
+ this.name = 'FormDataError';
6058
+ this.reason = reason;
6059
+ }
6060
+ }
6061
+
6062
+ // The caller supplies the boundary, Blob implementation, and limit error.
6063
+ function formDataToBlob(form, Blob, limit, limitError, boundary) {
6064
+ if (!utils$1.isFunction(Blob)) {
6065
+ throw new FormDataError('Blob is not supported', 'blob');
6066
+ }
6067
+ if (!utils$1.isString(boundary) || !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) || / $/.test(boundary)) {
6068
+ throw new FormDataError('Invalid multipart boundary', 'boundary');
6069
+ }
6070
+ const footer = '--' + boundary + '--' + CRLF;
6071
+ let length = footer.length;
6072
+ const parts = [];
6073
+ const checkLength = extra => {
6074
+ if (length + extra > limit) throw limitError();
6075
+ };
6076
+ checkLength(0);
6077
+ for (const [name, value] of form) {
6078
+ const isString = utils$1.isString(value);
6079
+ const valueLength = isString ? stringBytes(value, true) : value.size;
6080
+ if (!Number.isFinite(valueLength) || valueLength < 0) {
6081
+ throw new FormDataError('Unsupported FormData part size', 'part');
6082
+ }
6083
+ // Reject large values and names before building normalized header strings.
6084
+ checkLength(valueLength + stringBytes(name, true) + (!isString && value.name ? stringBytes(value.name, false) : 0) + (!isString && value.type ? stringBytes(value.type, false) : 0));
6085
+ let header = '--' + boundary + CRLF + 'Content-Disposition: form-data; name="' + escapeName(normalizeLines(name)) + '"';
6086
+ if (!isString) {
6087
+ header += '; filename="' + escapeName(utils$1.isString(value.name) ? value.name : 'blob') + '"' + CRLF + 'Content-Type: ' + String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
6088
+ }
6089
+ header += CRLF + CRLF;
6090
+ const partLength = stringBytes(header, false) + valueLength + CRLF.length;
6091
+ checkLength(partLength);
6092
+ length += partLength;
6093
+ parts.push({
6094
+ header,
6095
+ value,
6096
+ isString
6097
+ });
6098
+ }
6099
+
6100
+ // Native Blob composition retains existing Blob/File data. No file is read
6101
+ // and no complete multipart ArrayBuffer is created to determine its length.
6102
+ const blobParts = [];
6103
+ for (const part of parts) {
6104
+ blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF);
6105
+ }
6106
+ blobParts.push(footer);
6107
+ return new Blob(blobParts, {
6108
+ type: 'multipart/form-data; boundary=' + boundary
6109
+ });
6110
+ }
6111
+
6112
+ function createMultipartBody(form, Blob, limit, limitError, boundary) {
6113
+ // Report missing Blob support before trying to select a random source.
6114
+ if (!utils$1.isFunction(Blob)) {
6115
+ throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
6116
+ }
6117
+ if (boundary === undefined) {
6118
+ if (utils$1.isFunction(platform.generateString)) {
6119
+ boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
6120
+ } else {
6121
+ const crypto = utils$1.global.crypto;
6122
+ if (!crypto || !utils$1.isFunction(crypto.getRandomValues)) {
6123
+ throw new AxiosError('Random byte generation is not supported', AxiosError.ERR_NOT_SUPPORT);
6124
+ }
6125
+ const random = new Uint8Array(18);
6126
+ crypto.getRandomValues(random);
6127
+ boundary = 'axios-' + Array.from(random, value => ('0' + value.toString(16)).slice(-2)).join('');
6128
+ }
6129
+ }
6130
+ try {
6131
+ return formDataToBlob(form, Blob, limit, limitError, boundary);
6132
+ } catch (error) {
6133
+ if (error instanceof FormDataError) {
6134
+ const code = error.reason === 'boundary' ? AxiosError.ERR_BAD_OPTION_VALUE : AxiosError.ERR_BAD_REQUEST;
6135
+ throw new AxiosError(error.message, code);
6136
+ }
6137
+ throw error;
6138
+ }
6139
+ }
6140
+
5539
6141
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
5540
6142
  const DEFAULT_REQUEST_OPTIONS = {
5541
6143
  cache: 'default',
@@ -5601,12 +6203,14 @@ const factory = env => {
5601
6203
  skipUndefined: true
5602
6204
  }, {
5603
6205
  Request: globalObject.Request,
5604
- Response: globalObject.Response
6206
+ Response: globalObject.Response,
6207
+ Blob: globalObject.Blob
5605
6208
  }, env);
6209
+ const envFetch = utils$1.hasOwnProp(env, 'fetch') ? env.fetch : undefined;
5606
6210
  const {
5607
- fetch: envFetch,
5608
6211
  Request,
5609
- Response
6212
+ Response,
6213
+ Blob
5610
6214
  } = env;
5611
6215
  const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
5612
6216
  const isRequestSupported = isFunction(Request);
@@ -5633,6 +6237,19 @@ const factory = env => {
5633
6237
  return duplexAccessed && !hasContentType;
5634
6238
  });
5635
6239
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response('').body));
6240
+
6241
+ // Some runtimes reject every explicit cache mode. Use own defaults for both
6242
+ // probes so unrelated polluted options cannot affect cache-mode detection.
6243
+ const requestDefaults = Object.assign(Object.create(null), DEFAULT_REQUEST_OPTIONS);
6244
+ if (isRequestSupported && !test(() => new Request(platform.origin, requestDefaults))) {
6245
+ delete requestDefaults.cache;
6246
+
6247
+ // Only omit cache when that makes Request construction succeed. Otherwise
6248
+ // retain the explicit default that protects supporting runtimes from pollution.
6249
+ if (!test(() => new Request(platform.origin, requestDefaults))) {
6250
+ requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
6251
+ }
6252
+ }
5636
6253
  const resolvers = {
5637
6254
  stream: supportsResponseStream && (res => res.body)
5638
6255
  };
@@ -5654,13 +6271,6 @@ const factory = env => {
5654
6271
  if (utils$1.isBlob(body)) {
5655
6272
  return body.size;
5656
6273
  }
5657
- if (utils$1.isSpecCompliantForm(body)) {
5658
- const _request = new Request(platform.origin, {
5659
- method: 'POST',
5660
- body
5661
- });
5662
- return (await _request.arrayBuffer()).byteLength;
5663
- }
5664
6274
  if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
5665
6275
  return body.byteLength;
5666
6276
  }
@@ -5705,11 +6315,12 @@ const factory = env => {
5705
6315
  });
5706
6316
  let requestContentLength;
5707
6317
 
5708
- // AxiosError we raise while the request body is being streamed. Captured
6318
+ // AxiosErrors we raise while request or response bodies are being streamed. Captured
5709
6319
  // by identity so the catch block can surface it directly, regardless of
5710
6320
  // how the runtime wraps the resulting fetch rejection (undici exposes it
5711
6321
  // as `err.cause`; some browsers drop the original error entirely).
5712
6322
  let pendingBodyError = null;
6323
+ let pendingResponseError = null;
5713
6324
  const maxBodyLengthError = () => new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
5714
6325
  try {
5715
6326
  // HTTP basic authentication
@@ -5723,8 +6334,9 @@ const factory = env => {
5723
6334
  password
5724
6335
  };
5725
6336
  }
6337
+ let parsedURL;
5726
6338
  if (maybeWithAuthCredentials(url)) {
5727
- const parsedURL = new URL(url, platform.origin);
6339
+ parsedURL = new URL(url, platform.origin);
5728
6340
  if (!auth && (parsedURL.username || parsedURL.password)) {
5729
6341
  const urlUsername = decodeURIComponentSafe(parsedURL.username);
5730
6342
  const urlPassword = decodeURIComponentSafe(parsedURL.password);
@@ -5747,12 +6359,25 @@ const factory = env => {
5747
6359
  // Enforce maxContentLength for data: URLs up-front so we never materialize
5748
6360
  // an oversized payload. The HTTP adapter applies the same check (see http.js
5749
6361
  // "if (protocol === 'data:')" branch).
5750
- if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
5751
- const estimated = estimateDataURLDecodedBytes(url);
6362
+ if (hasMaxContentLength && parsedURL && parsedURL.protocol === 'data:') {
6363
+ const estimated = estimateDataURLDecodedBytes(parsedURL.href);
5752
6364
  if (estimated > maxContentLength) {
5753
6365
  throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
5754
6366
  }
5755
6367
  }
6368
+ const formContentType = utils$1.isSpecCompliantForm(data) && AxiosHeaders.from(own('headers')).getContentType();
6369
+ let formBoundary;
6370
+ if (utils$1.isString(formContentType) && /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())) {
6371
+ const parameters = AxiosHeaders.parseParameters(formContentType);
6372
+ if (utils$1.hasOwnProp(parameters, 'boundary')) formBoundary = parameters.boundary;
6373
+ }
6374
+ if (utils$1.isSpecCompliantForm(data) && method !== 'get' && method !== 'head' && (hasMaxBodyLength || onUploadProgress && supportsRequestStream || formBoundary !== undefined)) {
6375
+ data = createMultipartBody(data, Blob, hasMaxBodyLength ? maxBodyLength : Infinity, maxBodyLengthError, formBoundary);
6376
+ // Blob.type lowercases its value, including a case-sensitive boundary.
6377
+ // Retain the caller's header when an explicit boundary was serialized.
6378
+ headers.setContentType(formBoundary === undefined ? data.type : formContentType);
6379
+ requestContentLength = data.size;
6380
+ }
5756
6381
 
5757
6382
  // Enforce maxBodyLength against known-size bodies before dispatch using
5758
6383
  // the body's *actual* size — never a caller-declared Content-Length,
@@ -5842,7 +6467,7 @@ const factory = env => {
5842
6467
  credentials: isCredentialsSupported ? withCredentials : undefined
5843
6468
  });
5844
6469
  if (isRequestSupported) {
5845
- utils$1.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
6470
+ utils$1.forEach(requestDefaults, (value, key) => {
5846
6471
  if (resolvedOptions[key] === undefined) {
5847
6472
  resolvedOptions[key] = value;
5848
6473
  }
@@ -5885,7 +6510,7 @@ const factory = env => {
5885
6510
  if (hasMaxContentLength) {
5886
6511
  bytesRead = loadedBytes;
5887
6512
  if (bytesRead > maxContentLength) {
5888
- throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
6513
+ throw pendingResponseError = new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
5889
6514
  }
5890
6515
  }
5891
6516
  onProgress && onProgress(loadedBytes);
@@ -5952,7 +6577,7 @@ const factory = env => {
5952
6577
  }
5953
6578
 
5954
6579
  // Surface a maxBodyLength violation we raised while the request body was
5955
- // being streamed. Matching by identity (rather than reading
6580
+ // being streamed. Keeping the original error (rather than reading
5956
6581
  // `err.cause.isAxiosError`) keeps the error deterministic across runtimes
5957
6582
  // and avoids both prototype-pollution reads and mis-attributing a foreign
5958
6583
  // AxiosError that merely happened to land in `err.cause`.
@@ -5960,6 +6585,9 @@ const factory = env => {
5960
6585
  request && !pendingBodyError.request && (pendingBodyError.request = request);
5961
6586
  throw pendingBodyError;
5962
6587
  }
6588
+ if (pendingResponseError) {
6589
+ throw pendingResponseError;
6590
+ }
5963
6591
 
5964
6592
  // Re-throw AxiosErrors we raised synchronously (data: URL / content-length
5965
6593
  // pre-checks, response size enforcement) without re-wrapping them.
@@ -5986,13 +6614,20 @@ const factory = env => {
5986
6614
  };
5987
6615
  const seedCache = new Map();
5988
6616
  const getFetch = config => {
5989
- let env = config && config.env || {};
6617
+ const env = Object.create(null);
6618
+ const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
6619
+ ['fetch', 'Request', 'Response', 'Blob'].forEach(key => {
6620
+ if (configuredEnv && utils$1.hasOwnProp(configuredEnv, key)) {
6621
+ env[key] = configuredEnv[key];
6622
+ }
6623
+ });
5990
6624
  const {
5991
6625
  fetch,
5992
6626
  Request,
5993
- Response
6627
+ Response,
6628
+ Blob
5994
6629
  } = env;
5995
- const seeds = [Request, Response, fetch];
6630
+ const seeds = [Request, Response, fetch, Blob];
5996
6631
  let len = seeds.length,
5997
6632
  i = len,
5998
6633
  seed,
@@ -6134,6 +6769,21 @@ function throwIfCancellationRequested(config) {
6134
6769
  }
6135
6770
  }
6136
6771
 
6772
+ /**
6773
+ * Milliseconds elapsed since `start`, floored at zero.
6774
+ *
6775
+ * Wall-clock, to match the rest of the codebase (speedometer, throttle,
6776
+ * AxiosTransformStream). A backwards clock adjustment mid-request would
6777
+ * otherwise produce a negative duration, so the result is clamped.
6778
+ *
6779
+ * @param {number} start Timestamp from `Date.now()`
6780
+ *
6781
+ * @returns {number} Non-negative elapsed milliseconds
6782
+ */
6783
+ function elapsedSince(start) {
6784
+ return Math.max(0, Date.now() - start);
6785
+ }
6786
+
6137
6787
  /**
6138
6788
  * Dispatch a request to the server using the configured adapter.
6139
6789
  *
@@ -6155,8 +6805,10 @@ function dispatchRequest(_config) {
6155
6805
  config.headers.setContentType('application/x-www-form-urlencoded', false);
6156
6806
  }
6157
6807
  const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
6808
+ const start = Date.now();
6158
6809
  return adapter(config).then(function onAdapterResolution(response) {
6159
6810
  throwIfCancellationRequested(config);
6811
+ response.duration = elapsedSince(start);
6160
6812
 
6161
6813
  // Expose the current response on config so that transformResponse can
6162
6814
  // attach it to any AxiosError it throws (e.g. on JSON parse failure).
@@ -6175,6 +6827,7 @@ function dispatchRequest(_config) {
6175
6827
 
6176
6828
  // Transform response data
6177
6829
  if (reason && reason.response) {
6830
+ reason.response.duration = elapsedSince(start);
6178
6831
  config.response = reason.response;
6179
6832
  try {
6180
6833
  reason.response.data = transformData.call(config, config.transformResponse, reason.response);
@@ -6274,6 +6927,21 @@ var validator = {
6274
6927
 
6275
6928
  const validators = validator.validators;
6276
6929
 
6930
+ // Recognize header maps without consuming objects intended as literal values.
6931
+ // AxiosHeaders from other builds share a brand and header-container interface,
6932
+ // but not constructor identity. A tag and toJSON alone can describe a literal.
6933
+ const isHeadersBucket = value => {
6934
+ if (value == null || utils$1.isPlainObject(value) || value instanceof AxiosHeaders) {
6935
+ return true;
6936
+ }
6937
+ try {
6938
+ return utils$1.isObject(value) && utils$1.getSafeProp(value, Symbol.toStringTag) === 'AxiosHeaders' && ['toJSON', 'set', 'get', 'has', 'delete', 'clear', 'normalize', 'concat', 'toString', Symbol.iterator].every(method => utils$1.isFunction(utils$1.getSafeProp(value, method)));
6939
+ } catch (e) {
6940
+ // A failed optional brand probe must not prevent literal header serialization.
6941
+ return false;
6942
+ }
6943
+ };
6944
+
6277
6945
  /**
6278
6946
  * Create a new instance of Axios
6279
6947
  *
@@ -6316,13 +6984,23 @@ class Axios {
6316
6984
  }
6317
6985
  if (!err.stack) {
6318
6986
  err.stack = stack;
6319
- // match without the 2 top stack lines
6320
6987
  } else if (stack) {
6988
+ // Match a common suffix after the 2 top frames when available,
6989
+ // otherwise compare the full reconstructed stack.
6321
6990
  const firstNewlineIndex = stack.indexOf('\n');
6322
6991
  const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
6323
- const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
6324
- if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
6325
- err.stack += '\n' + stack;
6992
+ const duplicateCheckSuffix = secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
6993
+
6994
+ // `AxiosError.from()` may have already inlined the wrapped error's
6995
+ // stack under a `Caused by:` marker. Keep the reconstructed caller
6996
+ // frames ahead of that marker so stack-only reporters do not read
6997
+ // them as part of the low-level cause.
6998
+ const currentStack = String(err.stack);
6999
+ const causeIndex = getCauseStackIndex(err, currentStack);
7000
+ const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
7001
+ const causeSection = causeIndex === -1 ? '' : currentStack.slice(causeIndex);
7002
+ if (!stackHead.endsWith(duplicateCheckSuffix)) {
7003
+ err.stack = stackHead + '\n' + stack + causeSection;
6326
7004
  }
6327
7005
  }
6328
7006
  } catch (e) {
@@ -6354,7 +7032,8 @@ class Axios {
6354
7032
  clarifyTimeoutError: validators.transitional(validators.boolean),
6355
7033
  legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
6356
7034
  advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
6357
- validateStatusUndefinedResolves: validators.transitional(validators.boolean)
7035
+ validateStatusUndefinedResolves: validators.transitional(validators.boolean),
7036
+ encodeBasicAuthUsername: validators.transitional(validators.boolean)
6358
7037
  }, false);
6359
7038
  }
6360
7039
  if (paramsSerializer != null) {
@@ -6371,7 +7050,7 @@ class Axios {
6371
7050
  }
6372
7051
 
6373
7052
  // Set config.allowAbsoluteUrls
6374
- if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
7053
+ if (config.allowAbsoluteUrls !== undefined) ; else if (utils$1.hasOwnProp(this.defaults, 'allowAbsoluteUrls') && this.defaults.allowAbsoluteUrls !== undefined) {
6375
7054
  config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
6376
7055
  } else {
6377
7056
  config.allowAbsoluteUrls = true;
@@ -6384,10 +7063,14 @@ class Axios {
6384
7063
  // Set config.method
6385
7064
  config.method = (utils$1.getSafeProp(config, 'method') || utils$1.getSafeProp(this.defaults, 'method') || 'get').toLowerCase();
6386
7065
 
6387
- // Flatten headers
6388
- let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
7066
+ // Flatten header defaults without consuming literal method-named headers.
7067
+ const commonHeaders = utils$1.getSafeProp(headers, 'common');
7068
+ const methodHeaders = utils$1.getSafeProp(headers, config.method);
7069
+ const contextHeaders = headers && utils$1.merge(isHeadersBucket(commonHeaders) ? commonHeaders : undefined, isHeadersBucket(methodHeaders) ? methodHeaders : undefined);
6389
7070
  headers && utils$1.forEach(methodList.concat('common'), method => {
6390
- delete headers[method];
7071
+ if (isHeadersBucket(utils$1.getSafeProp(headers, method))) {
7072
+ delete headers[method];
7073
+ }
6391
7074
  });
6392
7075
  config.headers = AxiosHeaders.concat(contextHeaders, headers);
6393
7076
 
@@ -6472,7 +7155,7 @@ class Axios {
6472
7155
  // Provide aliases for supported request methods
6473
7156
  utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
6474
7157
  /*eslint func-names:0*/
6475
- Axios.prototype[method] = function (url, config) {
7158
+ Axios.prototype[method] = async function (url, config) {
6476
7159
  return this.request(mergeConfig(config || {}, {
6477
7160
  method,
6478
7161
  url,
@@ -6482,7 +7165,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
6482
7165
  });
6483
7166
  utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
6484
7167
  function generateHTTPMethod(isForm) {
6485
- return function httpMethod(url, data, config) {
7168
+ return async function httpMethod(url, data, config) {
6486
7169
  return this.request(mergeConfig(config || {}, {
6487
7170
  method,
6488
7171
  headers: isForm ? {