@zowe/db2-for-zowe-cli 6.1.17 → 6.1.19

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 (282) hide show
  1. package/README.md +12 -10
  2. package/lib/Db2PluginLifeCycle.d.ts +11 -9
  3. package/lib/Db2PluginLifeCycle.js +18 -13
  4. package/lib/Db2PluginLifeCycle.js.map +1 -1
  5. package/node_modules/adm-zip/adm-zip.js +32 -6
  6. package/node_modules/adm-zip/headers/entryHeader.js +13 -1
  7. package/node_modules/adm-zip/methods/inflater.js +33 -3
  8. package/node_modules/adm-zip/package.json +2 -2
  9. package/node_modules/adm-zip/util/errors.js +3 -0
  10. package/node_modules/adm-zip/util/utils.js +102 -14
  11. package/node_modules/adm-zip/zipEntry.js +43 -18
  12. package/node_modules/adm-zip/zipFile.js +10 -0
  13. package/node_modules/axios/CHANGELOG.md +62 -0
  14. package/node_modules/axios/README.md +236 -73
  15. package/node_modules/axios/dist/axios.js +1308 -357
  16. package/node_modules/axios/dist/axios.min.js +3 -3
  17. package/node_modules/axios/dist/axios.min.js.map +1 -1
  18. package/node_modules/axios/dist/browser/axios.cjs +1443 -403
  19. package/node_modules/axios/dist/esm/axios.js +1443 -403
  20. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  21. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  22. package/node_modules/axios/dist/node/axios.cjs +1483 -348
  23. package/node_modules/axios/index.d.cts +24 -1
  24. package/node_modules/axios/index.d.ts +22 -1
  25. package/node_modules/axios/lib/adapters/fetch.js +136 -30
  26. package/node_modules/axios/lib/adapters/http.js +277 -74
  27. package/node_modules/axios/lib/adapters/xhr.js +172 -16
  28. package/node_modules/axios/lib/core/Axios.js +87 -27
  29. package/node_modules/axios/lib/core/AxiosError.js +59 -0
  30. package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
  31. package/node_modules/axios/lib/core/InterceptorManager.js +118 -8
  32. package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
  33. package/node_modules/axios/lib/core/buildFullPath.js +1 -13
  34. package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
  35. package/node_modules/axios/lib/core/dispatchRequest.js +28 -2
  36. package/node_modules/axios/lib/core/mergeConfig.js +183 -120
  37. package/node_modules/axios/lib/core/methodList.js +17 -0
  38. package/node_modules/axios/lib/defaults/index.js +2 -1
  39. package/node_modules/axios/lib/defaults/transitional.js +1 -0
  40. package/node_modules/axios/lib/env/data.js +1 -1
  41. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
  42. package/node_modules/axios/lib/helpers/Http2Sessions.js +4 -1
  43. package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
  44. package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
  45. package/node_modules/axios/lib/helpers/cookies.js +30 -6
  46. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
  47. package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
  48. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
  49. package/node_modules/axios/lib/helpers/fromDataURI.js +11 -4
  50. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
  51. package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  52. package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
  53. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  54. package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
  55. package/node_modules/axios/lib/helpers/resolveConfig.js +20 -5
  56. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +197 -6
  57. package/node_modules/axios/lib/helpers/throttle.js +3 -2
  58. package/node_modules/axios/lib/helpers/toFormData.js +14 -21
  59. package/node_modules/axios/lib/utils.js +192 -20
  60. package/node_modules/axios/package.json +1 -2
  61. package/node_modules/follow-redirects/README.md +27 -1
  62. package/node_modules/follow-redirects/index.js +11 -6
  63. package/node_modules/follow-redirects/package.json +1 -1
  64. package/node_modules/fs-extra/README.md +0 -1
  65. package/node_modules/fs-extra/lib/empty/index.js +4 -2
  66. package/node_modules/fs-extra/lib/util/stat.js +12 -2
  67. package/node_modules/fs-extra/package.json +1 -1
  68. package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
  69. package/node_modules/ibm_db/LICENSE +23 -23
  70. package/node_modules/ibm_db/README.md +735 -735
  71. package/node_modules/ibm_db/binding.gyp +99 -98
  72. package/node_modules/ibm_db/installer/driverInstall.js +984 -958
  73. package/node_modules/ibm_db/installer/ifx.sh +38 -38
  74. package/node_modules/ibm_db/installer/setenv.sh +23 -23
  75. package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
  76. package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
  77. package/node_modules/ibm_db/lib/climacros.js +431 -431
  78. package/node_modules/ibm_db/lib/odbc.js +4293 -3487
  79. package/node_modules/ibm_db/lib/simple-queue.js +41 -41
  80. package/node_modules/ibm_db/package.json +70 -70
  81. package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
  82. package/node_modules/ibm_db/src/odbc.h +477 -473
  83. package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
  84. package/node_modules/ibm_db/src/odbc_connection.h +228 -215
  85. package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
  86. package/node_modules/ibm_db/src/odbc_result.h +152 -152
  87. package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
  88. package/node_modules/ibm_db/src/odbc_statement.h +257 -135
  89. package/node_modules/ibm_db/src/strptime.c +389 -389
  90. package/node_modules/ibm_db/src/strptime.h +46 -46
  91. package/node_modules/ibm_db/test/README +23 -23
  92. package/node_modules/ibm_db/test/bench-insert.js +62 -62
  93. package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
  94. package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
  95. package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
  96. package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
  97. package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
  98. package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
  99. package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
  100. package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
  101. package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
  102. package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
  103. package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
  104. package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
  105. package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
  106. package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
  107. package/node_modules/ibm_db/test/bench-query.js +40 -40
  108. package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
  109. package/node_modules/ibm_db/test/bench-querySync.js +29 -29
  110. package/node_modules/ibm_db/test/common.d.ts +10 -10
  111. package/node_modules/ibm_db/test/common.js +127 -127
  112. package/node_modules/ibm_db/test/config.json +7 -7
  113. package/node_modules/ibm_db/test/config.zos.json +4 -4
  114. package/node_modules/ibm_db/test/data/sample1.txt +9 -9
  115. package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
  116. package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
  117. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
  118. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
  119. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
  120. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
  121. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
  122. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
  123. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
  124. package/node_modules/ibm_db/test/odbc-bench.c +123 -123
  125. package/node_modules/ibm_db/test/perfTest.js +53 -53
  126. package/node_modules/ibm_db/test/quick-example.sh +30 -30
  127. package/node_modules/ibm_db/test/quick-example.ts +80 -80
  128. package/node_modules/ibm_db/test/run-bench.js +96 -96
  129. package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
  130. package/node_modules/ibm_db/test/run-tests.js +132 -138
  131. package/node_modules/ibm_db/test/sql-cli.js +28 -28
  132. package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
  133. package/node_modules/ibm_db/test/test-array-insert.js +178 -178
  134. package/node_modules/ibm_db/test/test-async-await.js +105 -105
  135. package/node_modules/ibm_db/test/test-attributes.js +34 -34
  136. package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
  137. package/node_modules/ibm_db/test/test-basic-test.js +138 -138
  138. package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
  139. package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
  140. package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
  141. package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
  142. package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
  143. package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
  144. package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
  145. package/node_modules/ibm_db/test/test-call-async.js +64 -64
  146. package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
  147. package/node_modules/ibm_db/test/test-cancel.js +703 -0
  148. package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
  149. package/node_modules/ibm_db/test/test-connection.js +306 -0
  150. package/node_modules/ibm_db/test/test-date.js +32 -32
  151. package/node_modules/ibm_db/test/test-dbclob.js +93 -93
  152. package/node_modules/ibm_db/test/test-decimals.js +135 -135
  153. package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
  154. package/node_modules/ibm_db/test/test-executeFile.js +167 -167
  155. package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
  156. package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
  157. package/node_modules/ibm_db/test/test-fetchN.js +130 -130
  158. package/node_modules/ibm_db/test/test-getinfo.js +197 -197
  159. package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
  160. package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
  161. package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
  162. package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
  163. package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
  164. package/node_modules/ibm_db/test/test-issue-54.js +39 -39
  165. package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
  166. package/node_modules/ibm_db/test/test-issue211.js +80 -80
  167. package/node_modules/ibm_db/test/test-issue253.js +39 -39
  168. package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
  169. package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
  170. package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
  171. package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
  172. package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
  173. package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
  174. package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
  175. package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
  176. package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
  177. package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
  178. package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
  179. package/node_modules/ibm_db/test/test-procedures.js +243 -0
  180. package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
  181. package/node_modules/ibm_db/test/test-query-operations.js +405 -0
  182. package/node_modules/ibm_db/test/test-quick-example.js +25 -25
  183. package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
  184. package/node_modules/ibm_db/test/test-sp-array.js +54 -54
  185. package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
  186. package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
  187. package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
  188. package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
  189. package/node_modules/ibm_db/test/test-transactions.js +261 -0
  190. package/node_modules/ibm_db/test/test-typescript.js +48 -48
  191. package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
  192. package/node_modules/ibm_db/test/testWebApp.js +56 -56
  193. package/node_modules/ibm_db/test/trace +51 -51
  194. package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
  195. package/node_modules/ibm_db/test/webapp.html +17 -17
  196. package/node_modules/ibm_db/test/webapp.js +79 -79
  197. package/node_modules/ibm_db/typescript/README.md +28 -28
  198. package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
  199. package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
  200. package/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +21 -0
  201. package/node_modules/string_decoder/node_modules/safe-buffer/README.md +584 -0
  202. package/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +187 -0
  203. package/node_modules/string_decoder/node_modules/safe-buffer/index.js +62 -0
  204. package/node_modules/string_decoder/node_modules/safe-buffer/package.json +37 -0
  205. package/node_modules/which-typed-array/CHANGELOG.md +14 -0
  206. package/node_modules/which-typed-array/README.md +0 -2
  207. package/node_modules/which-typed-array/index.d.ts +288 -11
  208. package/node_modules/which-typed-array/index.js +6 -7
  209. package/node_modules/which-typed-array/package.json +12 -11
  210. package/package.json +10 -11
  211. package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
  212. package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
  213. package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
  214. package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
  215. package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
  216. package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
  217. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
  218. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
  219. package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
  220. package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
  221. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
  222. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
  223. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
  224. package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
  225. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
  226. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
  227. package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
  228. package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
  229. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
  230. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
  231. package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
  232. package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
  233. package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
  234. package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
  235. package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
  236. package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
  237. package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
  238. package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
  239. package/node_modules/ibm_db/test/test-closed.js +0 -14
  240. package/node_modules/ibm_db/test/test-connection-object.js +0 -16
  241. package/node_modules/ibm_db/test/test-describe-column.js +0 -92
  242. package/node_modules/ibm_db/test/test-describe-database.js +0 -18
  243. package/node_modules/ibm_db/test/test-describe-table.js +0 -31
  244. package/node_modules/ibm_db/test/test-domains-open.js +0 -19
  245. package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
  246. package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
  247. package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
  248. package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
  249. package/node_modules/ibm_db/test/test-open-close.js +0 -29
  250. package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
  251. package/node_modules/ibm_db/test/test-openSync.js +0 -31
  252. package/node_modules/ibm_db/test/test-pool-close.js +0 -120
  253. package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
  254. package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
  255. package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
  256. package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
  257. package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
  258. package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
  259. package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
  260. package/node_modules/ibm_db/test/test-query-insert.js +0 -38
  261. package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
  262. package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
  263. package/node_modules/ibm_db/test/test-query-select.js +0 -64
  264. package/node_modules/ibm_db/test/test-queryResult.js +0 -35
  265. package/node_modules/ibm_db/test/test-queryStream.js +0 -43
  266. package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
  267. package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
  268. package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
  269. package/node_modules/ibm_db/test/test-statement-close.js +0 -118
  270. package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
  271. package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
  272. package/node_modules/which-typed-array/eslint.config.mjs +0 -12
  273. package/node_modules/which-typed-array/test/index.js +0 -105
  274. /package/node_modules/{tar-fs/node_modules/chownr → chownr}/LICENSE +0 -0
  275. /package/node_modules/{tar-fs/node_modules/chownr → chownr}/README.md +0 -0
  276. /package/node_modules/{tar-fs/node_modules/chownr → chownr}/chownr.js +0 -0
  277. /package/node_modules/{tar-fs/node_modules/chownr → chownr}/package.json +0 -0
  278. /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/.travis.yml +0 -0
  279. /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/LICENSE +0 -0
  280. /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/README.md +0 -0
  281. /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/lib/string_decoder.js +0 -0
  282. /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/package.json +0 -0
@@ -1,4 +1,4 @@
1
- /*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.21.0 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  /**
3
3
  * Create a bound version of a function with a specified `this` context
4
4
  *
@@ -25,12 +25,65 @@ const hasOwnProperty = (
25
25
  hasOwnProperty.call(obj, prop)
26
26
  )(Object.prototype);
27
27
 
28
+ const isUnsafeObjectKey = (prop) =>
29
+ typeof prop === 'string' &&
30
+ (prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
31
+
32
+ /**
33
+ * Determine whether an inherited object must be treated as a shared-prototype
34
+ * boundary. Cross-realm Object.prototype objects cannot be distinguished
35
+ * reliably from application-created null-prototype objects because their
36
+ * properties are mutable, so all inherited terminal prototypes are excluded
37
+ * as a fail-closed boundary. A null-prototype source still keeps its own
38
+ * properties, as produced by mergeConfig and other safe materialization paths.
39
+ *
40
+ * @param {*} obj The object to inspect
41
+ * @param {*} prototype The object's prototype
42
+ * @param {boolean} source Whether obj is the original traversal source
43
+ *
44
+ * @returns {boolean} True when obj is a safe prototype traversal boundary
45
+ */
46
+ const isPrototypeBoundary = (obj, prototype, source) =>
47
+ obj === Object.prototype || (!source && prototype === null);
48
+
49
+ /**
50
+ * Determine whether an object can retain its identity through code paths that
51
+ * add, replace, and remove config properties without bypassing unsafe-key
52
+ * filtering. Immutable objects, unsafe-key-bearing objects, and objects with
53
+ * accessor or restricted data properties must be materialized instead.
54
+ *
55
+ * @param {*} obj The object to inspect
56
+ *
57
+ * @returns {boolean} True when every own property is safe and fully mutable
58
+ */
59
+ const isSafeAndFullyMutable = (obj) => {
60
+ if (!Object.isExtensible(obj)) {
61
+ return false;
62
+ }
63
+
64
+ const props = Object.getOwnPropertyNames(obj);
65
+
66
+ if (Object.getOwnPropertySymbols) {
67
+ props.push(...Object.getOwnPropertySymbols(obj));
68
+ }
69
+
70
+ return props.every((prop) => {
71
+ if (isUnsafeObjectKey(prop)) {
72
+ return false;
73
+ }
74
+
75
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
76
+
77
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
78
+ });
79
+ };
80
+
28
81
  /**
29
- * Walk the prototype chain (excluding the shared Object.prototype) looking for
30
- * an own `prop`. This distinguishes genuine own/inherited members — including
31
- * class accessors and template prototypes — from members injected via
32
- * Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
33
- * live on Object.prototype itself and are therefore never matched.
82
+ * Walk the prototype chain (excluding the source realm's Object.prototype)
83
+ * looking for an own `prop`. This distinguishes genuine own/inherited members
84
+ * — including class accessors and template prototypes — from members injected
85
+ * via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
86
+ * which live on Object.prototype itself and are therefore never matched.
34
87
  *
35
88
  * @param {*} thing The value whose chain to inspect
36
89
  * @param {string|symbol} prop The property key to look for
@@ -41,16 +94,22 @@ const hasOwnInPrototypeChain = (thing, prop) => {
41
94
  let obj = thing;
42
95
  const seen = [];
43
96
 
44
- while (obj != null && obj !== Object.prototype) {
97
+ while (obj != null) {
45
98
  if (seen.indexOf(obj) !== -1) {
46
99
  return false;
47
100
  }
48
101
  seen.push(obj);
49
102
 
103
+ const prototype = getPrototypeOf(obj);
104
+
105
+ if (isPrototypeBoundary(obj, prototype, obj === thing)) {
106
+ return false;
107
+ }
108
+
50
109
  if (hasOwnProperty(obj, prop)) {
51
110
  return true;
52
111
  }
53
- obj = getPrototypeOf(obj);
112
+ obj = prototype;
54
113
  }
55
114
  return false;
56
115
  };
@@ -69,6 +128,69 @@ const hasOwnInPrototypeChain = (thing, prop) => {
69
128
  const getSafeProp = (obj, prop) =>
70
129
  obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
71
130
 
131
+ /**
132
+ * Flatten an object and its application-defined prototype chain into a
133
+ * null-prototype object. Members inherited only from the source realm's
134
+ * Object.prototype are deliberately excluded, while class/template members
135
+ * below that boundary are preserved.
136
+ *
137
+ * @param {*} thing The value to flatten
138
+ *
139
+ * @returns {*} A null-prototype copy, or the original value when it is already
140
+ * structurally safe or is not an object
141
+ */
142
+ const toSafeFlatObject = (thing) => {
143
+ if (thing == null || (typeof thing !== 'object' && typeof thing !== 'function')) {
144
+ return thing;
145
+ }
146
+
147
+ const sourcePrototype = getPrototypeOf(thing);
148
+
149
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
150
+ return thing;
151
+ }
152
+
153
+ const result = Object.create(null);
154
+ const merged = Object.create(null);
155
+ const seen = [];
156
+ let current = thing;
157
+
158
+ while (current != null) {
159
+ if (seen.indexOf(current) !== -1) {
160
+ break;
161
+ }
162
+
163
+ seen.push(current);
164
+
165
+ const prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
166
+
167
+ if (isPrototypeBoundary(current, prototype, current === thing)) {
168
+ break;
169
+ }
170
+
171
+ const props = Object.getOwnPropertyNames(current);
172
+
173
+ if (Object.getOwnPropertySymbols) {
174
+ props.push(...Object.getOwnPropertySymbols(current));
175
+ }
176
+
177
+ for (const prop of props) {
178
+ if (isUnsafeObjectKey(prop)) {
179
+ continue;
180
+ }
181
+
182
+ if (!hasOwnProperty(merged, prop)) {
183
+ result[prop] = thing[prop];
184
+ merged[prop] = true;
185
+ }
186
+ }
187
+
188
+ current = prototype;
189
+ }
190
+
191
+ return result;
192
+ };
193
+
72
194
  const kindOf = ((cache) => (thing) => {
73
195
  const str = toString.call(thing);
74
196
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -200,14 +322,18 @@ const isPlainObject = (val) => {
200
322
 
201
323
  const prototype = getPrototypeOf(val);
202
324
  return (
203
- (prototype === null ||
204
- prototype === Object.prototype ||
205
- getPrototypeOf(prototype) === null) &&
206
- // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
207
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
208
- // than a plain object, while ignoring keys injected onto Object.prototype.
209
- !hasOwnInPrototypeChain(val, toStringTag) &&
210
- !hasOwnInPrototypeChain(val, iterator)
325
+ (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
326
+ // Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
327
+ // value is tagged/iterable, ignoring members reachable only through shared
328
+ // or terminal prototype boundaries. This is exactly what
329
+ // hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
330
+ // above (null, Object.prototype, or a terminal null-prototype template) is
331
+ // a boundary, so the walk never inspects anything but `val`'s own members,
332
+ // and stops before even those when `val` is itself the boundary
333
+ // Object.prototype. Checking that inline avoids allocating the walker's
334
+ // `seen` list twice per call on the mergeConfig / merge hot path.
335
+ (isPrototypeBoundary(val, prototype, true) ||
336
+ (!hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator)))
211
337
  );
212
338
  };
213
339
 
@@ -471,15 +597,30 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
471
597
  function merge(...objs) {
472
598
  const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
473
599
  const result = {};
600
+ // Caseless lookup only applies to string keys — symbol keys are
601
+ // identity-matched. Every string key that reaches `result` passes through
602
+ // this index first, so it can never hold two case variants of one key and a
603
+ // lowercase -> key map is exactly what findKey(result, key) would rescan
604
+ // Object.keys(result) for on each assignment.
605
+ const lowerCaseKeys = caseless ? Object.create(null) : null;
474
606
  const assignValue = (val, key) => {
475
607
  // Skip dangerous property names to prevent prototype pollution
476
608
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
477
609
  return;
478
610
  }
479
611
 
480
- // findKey lowercases the key, so caseless lookup only applies to strings —
481
- // symbol keys are identity-matched.
482
- const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
612
+ let targetKey = key;
613
+ if (lowerCaseKeys && typeof key === 'string') {
614
+ const lowerKey = key.toLowerCase();
615
+ const knownKey = lowerCaseKeys[lowerKey];
616
+ // A key recorded but absent from `result` was skipped by skipUndefined;
617
+ // the later spelling wins then, as it does for findKey.
618
+ if (knownKey !== undefined && hasOwnProperty(result, knownKey)) {
619
+ targetKey = knownKey;
620
+ } else {
621
+ lowerCaseKeys[lowerKey] = key;
622
+ }
623
+ }
483
624
  // Read via own-prop only — a bare `result[targetKey]` walks the prototype
484
625
  // chain, so a polluted Object.prototype value could surface here and get
485
626
  // copied into the merged result.
@@ -503,7 +644,7 @@ function merge(...objs) {
503
644
 
504
645
  forEach(source, assignValue);
505
646
 
506
- if (typeof source !== 'object' || isArray(source)) {
647
+ if (typeof source !== 'object' || isArray(source) || !Object.getOwnPropertySymbols) {
507
648
  continue;
508
649
  }
509
650
 
@@ -662,7 +803,37 @@ const toArray = (thing) => {
662
803
  if (!thing) return null;
663
804
  if (isArray(thing)) return thing;
664
805
  let i = thing.length;
665
- if (!isNumber(i)) return null;
806
+ if (!Number.isSafeInteger(i) || i < 0 || i > 0xffffffff) return null;
807
+
808
+ // Bound the copy by actual indexed properties, including hidden and inherited
809
+ // members of array-like collections, rather than by the declared length alone.
810
+ const indexes = new Set();
811
+ const seen = new Set();
812
+ let source = thing;
813
+
814
+ while (source != null && indexes.size < i) {
815
+ if (seen.has(source)) return null;
816
+ seen.add(source);
817
+
818
+ const prototype = getPrototypeOf(source);
819
+ if (isPrototypeBoundary(source, prototype, source === thing)) break;
820
+
821
+ Object.getOwnPropertyNames(source).forEach((key) => {
822
+ const index = +key;
823
+ if (
824
+ Number.isInteger(index) &&
825
+ index >= 0 &&
826
+ index < i &&
827
+ String(index) === key &&
828
+ hasOwnProperty(source, key)
829
+ ) {
830
+ indexes.add(index);
831
+ }
832
+ });
833
+ source = prototype;
834
+ }
835
+
836
+ if (indexes.size !== i) return null;
666
837
  const arr = new Array(i);
667
838
  while (i-- > 0) {
668
839
  arr[i] = thing[i];
@@ -1019,6 +1190,7 @@ var utils$1 = {
1019
1190
  hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
1020
1191
  hasOwnInPrototypeChain,
1021
1192
  getSafeProp,
1193
+ toSafeFlatObject,
1022
1194
  reduceDescriptors,
1023
1195
  freezeMethods,
1024
1196
  toObjectSet,
@@ -1075,7 +1247,8 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
1075
1247
  * @returns {Object} Headers parsed into an object
1076
1248
  */
1077
1249
  var parseHeaders = (rawHeaders) => {
1078
- const parsed = {};
1250
+ // Header names are data, including __proto__; avoid inherited setters.
1251
+ const parsed = Object.create(null);
1079
1252
  let key;
1080
1253
  let val;
1081
1254
  let i;
@@ -1163,7 +1336,7 @@ function toByteStringHeaderObject(headers) {
1163
1336
  return byteStringHeaders;
1164
1337
  }
1165
1338
 
1166
- const $internals = Symbol('internals');
1339
+ const $internals$1 = Symbol('internals');
1167
1340
 
1168
1341
  function normalizeHeader(header) {
1169
1342
  return header && String(header).trim().toLowerCase();
@@ -1309,9 +1482,22 @@ function parseParameters(value) {
1309
1482
 
1310
1483
  const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1311
1484
 
1485
+ // `__proto__` is a valid field name, and the one name the uppercase mapping at
1486
+ // the bottom of this file cannot reach: it is inherited from Object.prototype
1487
+ // instead of being declared on AxiosHeaders.prototype, so `self.__proto__ = v`
1488
+ // runs the inherited setter. That silently discards the header, and an array
1489
+ // value replaces the instance prototype, taking every method with it.
1490
+ // Store it under the same kind of case variant that mapping uses for `set` and
1491
+ // `constructor`. Header lookup is caseless, so it reads back under either
1492
+ // spelling, and no own `__proto__` slot is ever created for a later
1493
+ // `Object.assign` to copy onto a plain object through the same setter.
1494
+ const PROTO_HEADER_SLOT = '__Proto__';
1495
+
1496
+ const headerSlot = (name) => (name === '__proto__' ? PROTO_HEADER_SLOT : name);
1497
+
1312
1498
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1313
1499
  if (utils$1.isFunction(filter)) {
1314
- return filter.call(this, value, header);
1500
+ return filter.call(context, value, header);
1315
1501
  }
1316
1502
 
1317
1503
  if (isHeaderNameFilter) {
@@ -1377,7 +1563,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
1377
1563
  _rewrite === true ||
1378
1564
  (_rewrite === undefined && self[key] !== false)
1379
1565
  ) {
1380
- self[key || _header] = normalizeValue(_value);
1566
+ self[headerSlot(key || _header)] = normalizeValue(_value);
1381
1567
  }
1382
1568
  }
1383
1569
 
@@ -1506,7 +1692,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
1506
1692
 
1507
1693
  normalize(format) {
1508
1694
  const self = this;
1509
- const headers = {};
1695
+ const headers = Object.create(null);
1510
1696
 
1511
1697
  utils$1.forEach(this, (value, header) => {
1512
1698
  const key = utils$1.findKey(headers, header);
@@ -1517,7 +1703,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
1517
1703
  return;
1518
1704
  }
1519
1705
 
1520
- const normalized = format ? formatHeader(header) : String(header).trim();
1706
+ const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
1521
1707
 
1522
1708
  if (normalized !== header) {
1523
1709
  delete self[header];
@@ -1584,8 +1770,8 @@ let AxiosHeaders$1 = class AxiosHeaders {
1584
1770
 
1585
1771
  static accessor(header) {
1586
1772
  const internals =
1587
- (this[$internals] =
1588
- this[$internals] =
1773
+ (this[$internals$1] =
1774
+ this[$internals$1] =
1589
1775
  {
1590
1776
  accessors: {},
1591
1777
  });
@@ -1722,6 +1908,61 @@ function aggregateErrorMessage(error) {
1722
1908
  return message || error.name || 'AggregateError';
1723
1909
  }
1724
1910
 
1911
+ // Shared with `Axios.prototype.request`, which splices the reconstructed
1912
+ // caller frames in ahead of this marker.
1913
+ const CAUSED_BY_SEPARATOR = '\nCaused by: ';
1914
+ const $causeStack = Symbol('causeStack');
1915
+
1916
+ // Match the section we appended, not marker-like text in an error message or
1917
+ // a replacement stack supplied by the caller. Do not re-read the cause's stack.
1918
+ function getCauseStackIndex(error, stack) {
1919
+ const causeStack = utils$1.hasOwnProp(error, $causeStack) && error[$causeStack];
1920
+
1921
+ return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
1922
+ }
1923
+
1924
+ /**
1925
+ * Append the stack of a wrapped error to `target.stack`.
1926
+ *
1927
+ * `cause` already exposes the original error for tooling that walks the standard
1928
+ * cause chain, but many error reporters read `stack` and nothing else. Inlining
1929
+ * the wrapped stack there means those reporters surface the underlying failure
1930
+ * instead of the axios frames that normalized it (see #6670).
1931
+ *
1932
+ * Every read is defensive: a custom `Error.prepareStackTrace` hook, a runtime
1933
+ * without stack support, or a replaced `stack` property can leave the value
1934
+ * missing, non-string, or read-only, and normalizing an error must not throw
1935
+ * because of that.
1936
+ *
1937
+ * @param {Error} target The AxiosError being built.
1938
+ * @param {Error} source The error being wrapped.
1939
+ *
1940
+ * @returns {void}
1941
+ */
1942
+ function appendCauseStack(target, source) {
1943
+ try {
1944
+ const sourceStack = source && source.stack;
1945
+
1946
+ if (typeof sourceStack !== 'string' || !sourceStack) {
1947
+ return;
1948
+ }
1949
+
1950
+ const targetStack = target.stack;
1951
+
1952
+ if (typeof targetStack !== 'string' || !targetStack) {
1953
+ return;
1954
+ }
1955
+
1956
+ // Each call to `from()` creates a fresh target. Re-wrapping includes the
1957
+ // previous stack verbatim, adding one cause section per wrap.
1958
+ const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
1959
+ target.stack = targetStack + causeStack;
1960
+ Object.defineProperty(target, $causeStack, { __proto__: null, value: causeStack });
1961
+ } catch (e) {
1962
+ // Ignore failures from custom stack hooks or un-writable stack properties.
1963
+ }
1964
+ }
1965
+
1725
1966
  let AxiosError$1 = class AxiosError extends Error {
1726
1967
  static from(error, code, config, request, response, customProps) {
1727
1968
  // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
@@ -1748,6 +1989,10 @@ let AxiosError$1 = class AxiosError extends Error {
1748
1989
  });
1749
1990
  axiosError.name = error.name;
1750
1991
 
1992
+ // Inline the wrapped stack for reporters that read only `stack`; the `cause`
1993
+ // property above already covers cause-aware tooling.
1994
+ appendCauseStack(axiosError, error);
1995
+
1751
1996
  // Preserve status from the original error if not already set from response
1752
1997
  if (error.status != null && axiosError.status == null) {
1753
1998
  axiosError.status = error.status;
@@ -1939,28 +2184,18 @@ function toFormData$1(obj, formData, options) {
1939
2184
  // eslint-disable-next-line no-param-reassign
1940
2185
  formData = formData || new (FormData)();
1941
2186
 
1942
- // eslint-disable-next-line no-param-reassign
1943
- options = utils$1.toFlatObject(
1944
- options,
1945
- {
1946
- metaTokens: true,
1947
- dots: false,
1948
- indexes: false,
1949
- },
1950
- false,
1951
- function defined(option, source) {
1952
- // eslint-disable-next-line no-eq-null,eqeqeq
1953
- return !utils$1.isUndefined(source[option]);
1954
- }
1955
- );
2187
+ const option = (name, fallback) => {
2188
+ const value = utils$1.getSafeProp(options, name);
2189
+ return utils$1.isUndefined(value) ? fallback : value;
2190
+ };
1956
2191
 
1957
- const metaTokens = options.metaTokens;
2192
+ const metaTokens = option('metaTokens', true);
1958
2193
  // eslint-disable-next-line no-use-before-define
1959
- const visitor = options.visitor || defaultVisitor;
1960
- const dots = options.dots;
1961
- const indexes = options.indexes;
1962
- const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1963
- const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
2194
+ const visitor = option('visitor') || defaultVisitor;
2195
+ const dots = option('dots', false);
2196
+ const indexes = option('indexes', false);
2197
+ const _Blob = option('Blob') || (typeof Blob !== 'undefined' && Blob);
2198
+ const maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
1964
2199
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1965
2200
  const stack = [];
1966
2201
 
@@ -1987,7 +2222,10 @@ function toFormData$1(obj, formData, options) {
1987
2222
  if (useBlob && typeof _Blob === 'function') {
1988
2223
  return new _Blob([value]);
1989
2224
  }
1990
- throw new AxiosError$1('Blob is not supported. Use a Buffer instead.', AxiosError$1.ERR_NOT_SUPPORT);
2225
+ throw new AxiosError$1(
2226
+ 'Blob is not supported. Use a Buffer instead.',
2227
+ AxiosError$1.ERR_NOT_SUPPORT
2228
+ );
1991
2229
  }
1992
2230
 
1993
2231
  return value;
@@ -2239,9 +2477,67 @@ function buildURL(url, params, options) {
2239
2477
  return url;
2240
2478
  }
2241
2479
 
2480
+ const $internals = Symbol('internals');
2481
+
2482
+ // `handlers` is public and may be replaced with a nullish value by user code;
2483
+ // `clear()` has always tolerated that. Treat it as an empty stack rather than
2484
+ // dereferencing it.
2485
+ function countHandlers(handlers) {
2486
+ return handlers ? handlers.length : 0;
2487
+ }
2488
+
2489
+ function trimHandlers(handlers) {
2490
+ if (!handlers) {
2491
+ return;
2492
+ }
2493
+
2494
+ while (handlers.length && handlers[handlers.length - 1] === null) {
2495
+ handlers.pop();
2496
+ }
2497
+ }
2498
+
2499
+ // Preserve the array-key coercion used before IDs were stored in a Map, without
2500
+ // treating null, empty strings, or noncanonical numeric strings as ID zero.
2501
+ function normalizeHandlerId(id) {
2502
+ if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
2503
+ return Number(id);
2504
+ }
2505
+
2506
+ return id;
2507
+ }
2508
+
2509
+ function syncHandlerEntries(manager, internals) {
2510
+ const handlers = manager.handlers;
2511
+ const length = countHandlers(handlers);
2512
+
2513
+ if (handlers !== internals.handlersRef) {
2514
+ internals.handlersRef = handlers;
2515
+ internals.handlerEntries.clear();
2516
+ } else if (length !== internals.handlersLength) {
2517
+ if (!length) {
2518
+ internals.handlerEntries.clear();
2519
+ } else {
2520
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
2521
+ if (handlers[entry.index] !== entry.handler) {
2522
+ internals.handlerEntries.delete(id);
2523
+ }
2524
+ });
2525
+ }
2526
+ }
2527
+
2528
+ internals.handlersLength = length;
2529
+ }
2530
+
2242
2531
  class InterceptorManager {
2243
2532
  constructor() {
2244
2533
  this.handlers = [];
2534
+ this[$internals] = {
2535
+ handlersRef: this.handlers,
2536
+ handlersLength: this.handlers.length,
2537
+ handlerEntries: new Map(),
2538
+ iterationDepth: 0,
2539
+ nextId: 0,
2540
+ };
2245
2541
  }
2246
2542
 
2247
2543
  /**
@@ -2254,13 +2550,30 @@ class InterceptorManager {
2254
2550
  * @return {Number} An ID used to remove interceptor later
2255
2551
  */
2256
2552
  use(fulfilled, rejected, options) {
2257
- this.handlers.push({
2553
+ const handler = {
2258
2554
  fulfilled,
2259
2555
  rejected,
2260
2556
  synchronous: options ? options.synchronous : false,
2261
2557
  runWhen: options ? options.runWhen : null,
2558
+ };
2559
+ const internals = this[$internals];
2560
+
2561
+ if (this.handlers == null) {
2562
+ this.handlers = [];
2563
+ }
2564
+
2565
+ syncHandlerEntries(this, internals);
2566
+
2567
+ const id = internals.nextId++;
2568
+
2569
+ this.handlers.push(handler);
2570
+ internals.handlerEntries.set(id, {
2571
+ handler,
2572
+ index: this.handlers.length - 1,
2262
2573
  });
2263
- return this.handlers.length - 1;
2574
+ internals.handlersLength = this.handlers.length;
2575
+
2576
+ return id;
2264
2577
  }
2265
2578
 
2266
2579
  /**
@@ -2271,8 +2584,28 @@ class InterceptorManager {
2271
2584
  * @returns {void}
2272
2585
  */
2273
2586
  eject(id) {
2274
- if (this.handlers[id]) {
2275
- this.handlers[id] = null;
2587
+ const internals = this[$internals];
2588
+
2589
+ syncHandlerEntries(this, internals);
2590
+
2591
+ const handlerId = normalizeHandlerId(id);
2592
+ const entry = internals.handlerEntries.get(handlerId);
2593
+
2594
+ if (entry) {
2595
+ internals.handlerEntries.delete(handlerId);
2596
+
2597
+ // Ignore IDs invalidated by clear or direct replacement of handlers.
2598
+ if (this.handlers[entry.index] !== entry.handler) {
2599
+ return;
2600
+ }
2601
+
2602
+ this.handlers[entry.index] = null;
2603
+
2604
+ // Do not reuse an index while forEach is walking its length snapshot.
2605
+ if (!internals.iterationDepth) {
2606
+ trimHandlers(this.handlers);
2607
+ internals.handlersLength = this.handlers.length;
2608
+ }
2276
2609
  }
2277
2610
  }
2278
2611
 
@@ -2284,6 +2617,7 @@ class InterceptorManager {
2284
2617
  clear() {
2285
2618
  if (this.handlers) {
2286
2619
  this.handlers = [];
2620
+ syncHandlerEntries(this, this[$internals]);
2287
2621
  }
2288
2622
  }
2289
2623
 
@@ -2298,11 +2632,25 @@ class InterceptorManager {
2298
2632
  * @returns {void}
2299
2633
  */
2300
2634
  forEach(fn) {
2301
- utils$1.forEach(this.handlers, function forEachHandler(h) {
2302
- if (h !== null) {
2303
- fn(h);
2635
+ const internals = this[$internals];
2636
+
2637
+ syncHandlerEntries(this, internals);
2638
+
2639
+ internals.iterationDepth++;
2640
+
2641
+ try {
2642
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2643
+ if (h !== null) {
2644
+ fn(h);
2645
+ }
2646
+ });
2647
+ } finally {
2648
+ if (!--internals.iterationDepth) {
2649
+ syncHandlerEntries(this, internals);
2650
+ trimHandlers(this.handlers);
2651
+ internals.handlersLength = countHandlers(this.handlers);
2304
2652
  }
2305
- });
2653
+ }
2306
2654
  }
2307
2655
  }
2308
2656
 
@@ -2313,6 +2661,7 @@ var transitionalDefaults = {
2313
2661
  legacyInterceptorReqResOrdering: true,
2314
2662
  advertiseZstdAcceptEncoding: false,
2315
2663
  validateStatusUndefinedResolves: true,
2664
+ encodeBasicAuthUsername: false,
2316
2665
  };
2317
2666
 
2318
2667
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -2465,6 +2814,29 @@ function arrayToObject(arr) {
2465
2814
  return obj;
2466
2815
  }
2467
2816
 
2817
+ function normalizeArray(value) {
2818
+ if (!utils$1.isArray(value)) return value;
2819
+
2820
+ const keys = Object.keys(value);
2821
+ return keys.length !== value.length || keys.some((key, index) => key !== String(index))
2822
+ ? arrayToObject(value)
2823
+ : value;
2824
+ }
2825
+
2826
+ function normalizeArrays(obj) {
2827
+ const pending = [obj];
2828
+ while (pending.length) {
2829
+ const target = pending.pop();
2830
+ Object.keys(target).forEach((key) => {
2831
+ const value = (target[key] = normalizeArray(target[key]));
2832
+ if (utils$1.isArray(value) || utils$1.isPlainObject(value)) {
2833
+ pending.push(value);
2834
+ }
2835
+ });
2836
+ }
2837
+ return obj;
2838
+ }
2839
+
2468
2840
  /**
2469
2841
  * It takes a FormData object and returns a JavaScript object
2470
2842
  *
@@ -2486,6 +2858,7 @@ function formDataToJSON(formData) {
2486
2858
 
2487
2859
  if (isLast) {
2488
2860
  if (utils$1.hasOwnProp(target, name)) {
2861
+ target[name] = normalizeArray(target[name]);
2489
2862
  target[name] = utils$1.isArray(target[name])
2490
2863
  ? target[name].concat(value)
2491
2864
  : [target[name], value];
@@ -2516,12 +2889,26 @@ function formDataToJSON(formData) {
2516
2889
  buildPath(parsePropPath(name), value, obj, 0);
2517
2890
  });
2518
2891
 
2519
- return obj;
2892
+ return normalizeArrays(obj);
2520
2893
  }
2521
2894
 
2522
2895
  return null;
2523
2896
  }
2524
2897
 
2898
+ const methodList = Object.freeze([
2899
+ 'get',
2900
+ 'delete',
2901
+ 'head',
2902
+ 'options',
2903
+ 'post',
2904
+ 'put',
2905
+ 'patch',
2906
+ 'purge',
2907
+ 'link',
2908
+ 'unlink',
2909
+ 'query',
2910
+ ]);
2911
+
2525
2912
  const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
2526
2913
 
2527
2914
  /**
@@ -2684,7 +3071,7 @@ const defaults = {
2684
3071
  },
2685
3072
  };
2686
3073
 
2687
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
3074
+ utils$1.forEach(methodList, (method) => {
2688
3075
  defaults.headers[method] = {};
2689
3076
  });
2690
3077
 
@@ -2756,68 +3143,177 @@ function settle(resolve, reject, response) {
2756
3143
  }
2757
3144
  }
2758
3145
 
2759
- function parseProtocol(url) {
2760
- const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
2761
- return (match && match[1]) || '';
2762
- }
3146
+ const urlParserControlCharacters = /[\t\n\r]/g;
2763
3147
 
2764
3148
  /**
2765
- * Calculate data maxRate
2766
- * @param {Number} [samplesCount= 10]
2767
- * @param {Number} [min= 1000]
2768
- * @returns {Function}
3149
+ * Match WHATWG URL preprocessing before checking a URL's protocol.
3150
+ *
3151
+ * @param {string} url
3152
+ *
3153
+ * @returns {string}
2769
3154
  */
2770
- function speedometer(samplesCount, min) {
2771
- samplesCount = samplesCount || 10;
2772
- const bytes = new Array(samplesCount);
2773
- const timestamps = new Array(samplesCount);
2774
- let head = 0;
2775
- let tail = 0;
2776
- let firstSampleTS;
2777
-
2778
- min = min !== undefined ? min : 1000;
2779
-
2780
- return function push(chunkLength) {
2781
- const now = Date.now();
2782
-
2783
- const startedAt = timestamps[tail];
3155
+ function normalizeURLForProtocolCheck(url) {
3156
+ if (typeof url !== 'string') {
3157
+ return url;
3158
+ }
2784
3159
 
2785
- if (!firstSampleTS) {
2786
- firstSampleTS = now;
2787
- }
3160
+ let start = 0;
2788
3161
 
2789
- bytes[head] = chunkLength;
2790
- timestamps[head] = now;
3162
+ while (start < url.length && url.charCodeAt(start) <= 0x20) {
3163
+ start++;
3164
+ }
2791
3165
 
2792
- let i = tail;
2793
- let bytesCount = 0;
3166
+ return url.slice(start).replace(urlParserControlCharacters, '');
3167
+ }
2794
3168
 
2795
- while (i !== head) {
2796
- bytesCount += bytes[i++];
2797
- i = i % samplesCount;
2798
- }
3169
+ function parseProtocol(url) {
3170
+ const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
3171
+ return (match && match[1].toLowerCase()) || '';
3172
+ }
2799
3173
 
2800
- head = (head + 1) % samplesCount;
3174
+ const decodeCookieValue = (value) => {
3175
+ try {
3176
+ return decodeURIComponent(value);
3177
+ } catch (e) {
3178
+ return value;
3179
+ }
3180
+ };
2801
3181
 
2802
- if (head === tail) {
2803
- tail = (tail + 1) % samplesCount;
2804
- }
3182
+ var cookies = platform.hasStandardBrowserEnv
3183
+ ? // Standard browser envs support document.cookie
3184
+ {
3185
+ write(name, value, expires, path, domain, secure, sameSite) {
3186
+ if (typeof document === 'undefined') return;
2805
3187
 
2806
- if (now - firstSampleTS < min) {
2807
- return;
2808
- }
3188
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2809
3189
 
2810
- const passed = startedAt && now - startedAt;
3190
+ if (utils$1.isNumber(expires)) {
3191
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
3192
+ }
3193
+ if (utils$1.isString(path)) {
3194
+ cookie.push(`path=${path}`);
3195
+ }
3196
+ if (utils$1.isString(domain)) {
3197
+ cookie.push(`domain=${domain}`);
3198
+ }
3199
+ if (secure === true) {
3200
+ cookie.push('secure');
3201
+ }
3202
+ if (utils$1.isString(sameSite)) {
3203
+ cookie.push(`SameSite=${sameSite}`);
3204
+ }
2811
3205
 
2812
- return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
2813
- };
2814
- }
3206
+ document.cookie = cookie.join('; ');
3207
+ },
2815
3208
 
2816
- /**
2817
- * Throttle decorator
3209
+ read(name) {
3210
+ if (typeof document === 'undefined') return null;
3211
+ const cookieString = document.cookie;
3212
+ if (!cookieString) return null;
3213
+ // Match name=value by splitting on the semicolon separator instead of building a
3214
+ // RegExp from `name` — interpolating an unescaped string into a RegExp would let
3215
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
3216
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
3217
+ // "; ", so ignore optional whitespace before each cookie name.
3218
+ const cookies = cookieString.split(';');
3219
+ for (let i = 0; i < cookies.length; i++) {
3220
+ const cookie = cookies[i].replace(/^\s+/, '');
3221
+ const eq = cookie.indexOf('=');
3222
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
3223
+ return decodeCookieValue(cookie.slice(eq + 1));
3224
+ }
3225
+ }
3226
+ return null;
3227
+ },
3228
+
3229
+ async readAsync(name) {
3230
+ try {
3231
+ const store = typeof window !== 'undefined' && window.cookieStore;
3232
+ if (store && utils$1.isFunction(store.get)) {
3233
+ const cookie = await store.get(name);
3234
+ // Both APIs expose stored bytes; preserve Axios's existing URI decoding.
3235
+ return cookie ? decodeCookieValue(cookie.value) : null;
3236
+ }
3237
+ } catch (e) {
3238
+ // Restricted or unavailable storage retains the synchronous fallback.
3239
+ }
3240
+
3241
+ return this.read(name);
3242
+ },
3243
+
3244
+ remove(name) {
3245
+ this.write(name, '', Date.now() - 86400000, '/');
3246
+ },
3247
+ }
3248
+ : // Non-standard browser env (web workers, react-native) lack needed support.
3249
+ {
3250
+ write() {},
3251
+ read() {
3252
+ return null;
3253
+ },
3254
+ async readAsync() {
3255
+ return null;
3256
+ },
3257
+ remove() {},
3258
+ };
3259
+
3260
+ /**
3261
+ * Calculate data maxRate
3262
+ * @param {Number} [samplesCount= 10]
3263
+ * @param {Number} [min= 1000]
3264
+ * @returns {Function}
3265
+ */
3266
+ function speedometer(samplesCount, min) {
3267
+ samplesCount = samplesCount || 10;
3268
+ const bytes = new Array(samplesCount);
3269
+ const timestamps = new Array(samplesCount);
3270
+ let head = 0;
3271
+ let tail = 0;
3272
+ let firstSampleTS;
3273
+
3274
+ min = min !== undefined ? min : 1000;
3275
+
3276
+ return function push(chunkLength) {
3277
+ const now = Date.now();
3278
+
3279
+ const startedAt = timestamps[tail];
3280
+
3281
+ if (!firstSampleTS) {
3282
+ firstSampleTS = now;
3283
+ }
3284
+
3285
+ bytes[head] = chunkLength;
3286
+ timestamps[head] = now;
3287
+
3288
+ let i = tail;
3289
+ let bytesCount = 0;
3290
+
3291
+ while (i !== head) {
3292
+ bytesCount += bytes[i++];
3293
+ i = i % samplesCount;
3294
+ }
3295
+
3296
+ head = (head + 1) % samplesCount;
3297
+
3298
+ if (head === tail) {
3299
+ tail = (tail + 1) % samplesCount;
3300
+ }
3301
+
3302
+ if (now - firstSampleTS < min) {
3303
+ return;
3304
+ }
3305
+
3306
+ const passed = startedAt && now - startedAt;
3307
+
3308
+ return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
3309
+ };
3310
+ }
3311
+
3312
+ /**
3313
+ * Throttle decorator
2818
3314
  * @param {Function} fn
2819
3315
  * @param {Number} freq
2820
- * @return {Function}
3316
+ * @return {Array<Function>}
2821
3317
  */
2822
3318
  function throttle(fn, freq) {
2823
3319
  let timestamp = 0;
@@ -2852,8 +3348,9 @@ function throttle(fn, freq) {
2852
3348
  };
2853
3349
 
2854
3350
  const flush = () => lastArgs && invoke(lastArgs);
3351
+ const flushWith = (...args) => invoke(args);
2855
3352
 
2856
- return [throttled, flush];
3353
+ return [throttled, flush, flushWith];
2857
3354
  }
2858
3355
 
2859
3356
  const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
@@ -2861,7 +3358,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2861
3358
  const _speedometer = speedometer(50, 250);
2862
3359
 
2863
3360
  return throttle((e) => {
2864
- if (!e || typeof e.loaded !== 'number') {
3361
+ if (!e || !utils$1.isNumber(e.loaded)) {
2865
3362
  return;
2866
3363
  }
2867
3364
  const rawLoaded = e.loaded;
@@ -2908,82 +3405,15 @@ const asyncDecorator =
2908
3405
  scheduler(() => fn(...args));
2909
3406
 
2910
3407
  var isURLSameOrigin = platform.hasStandardBrowserEnv
2911
- ? ((origin, isMSIE) => (url) => {
2912
- url = new URL(url, platform.origin);
3408
+ ? ((origin) => (url) => {
3409
+ url = new URL(url, document.baseURI || platform.origin);
2913
3410
 
2914
3411
  return (
2915
- origin.protocol === url.protocol &&
2916
- origin.host === url.host &&
2917
- (isMSIE || origin.port === url.port)
3412
+ origin.protocol === url.protocol && origin.host === url.host && origin.port === url.port
2918
3413
  );
2919
- })(
2920
- new URL(platform.origin),
2921
- platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2922
- )
3414
+ })(new URL(platform.origin))
2923
3415
  : () => true;
2924
3416
 
2925
- var cookies = platform.hasStandardBrowserEnv
2926
- ? // Standard browser envs support document.cookie
2927
- {
2928
- write(name, value, expires, path, domain, secure, sameSite) {
2929
- if (typeof document === 'undefined') return;
2930
-
2931
- const cookie = [`${name}=${encodeURIComponent(value)}`];
2932
-
2933
- if (utils$1.isNumber(expires)) {
2934
- cookie.push(`expires=${new Date(expires).toUTCString()}`);
2935
- }
2936
- if (utils$1.isString(path)) {
2937
- cookie.push(`path=${path}`);
2938
- }
2939
- if (utils$1.isString(domain)) {
2940
- cookie.push(`domain=${domain}`);
2941
- }
2942
- if (secure === true) {
2943
- cookie.push('secure');
2944
- }
2945
- if (utils$1.isString(sameSite)) {
2946
- cookie.push(`SameSite=${sameSite}`);
2947
- }
2948
-
2949
- document.cookie = cookie.join('; ');
2950
- },
2951
-
2952
- read(name) {
2953
- if (typeof document === 'undefined') return null;
2954
- // Match name=value by splitting on the semicolon separator instead of building a
2955
- // RegExp from `name` — interpolating an unescaped string into a RegExp would let
2956
- // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
2957
- // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
2958
- // "; ", so ignore optional whitespace before each cookie name.
2959
- const cookies = document.cookie.split(';');
2960
- for (let i = 0; i < cookies.length; i++) {
2961
- const cookie = cookies[i].replace(/^\s+/, '');
2962
- const eq = cookie.indexOf('=');
2963
- if (eq !== -1 && cookie.slice(0, eq) === name) {
2964
- try {
2965
- return decodeURIComponent(cookie.slice(eq + 1));
2966
- } catch (e) {
2967
- return cookie.slice(eq + 1);
2968
- }
2969
- }
2970
- }
2971
- return null;
2972
- },
2973
-
2974
- remove(name) {
2975
- this.write(name, '', Date.now() - 86400000, '/');
2976
- },
2977
- }
2978
- : // Non-standard browser env (web workers, react-native) lack needed support.
2979
- {
2980
- write() {},
2981
- read() {
2982
- return null;
2983
- },
2984
- remove() {},
2985
- };
2986
-
2987
3417
  /**
2988
3418
  * Determines whether the specified URL is absolute
2989
3419
  *
@@ -3025,19 +3455,6 @@ function combineURLs(baseURL, relativeURL) {
3025
3455
  }
3026
3456
 
3027
3457
  const malformedHttpProtocol = /^https?:(?!\/\/)/i;
3028
- const httpProtocolControlCharacters = /[\t\n\r]/g;
3029
-
3030
- function stripLeadingC0ControlOrSpace(url) {
3031
- let i = 0;
3032
- while (i < url.length && url.charCodeAt(i) <= 0x20) {
3033
- i++;
3034
- }
3035
- return url.slice(i);
3036
- }
3037
-
3038
- function normalizeURLForProtocolCheck(url) {
3039
- return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
3040
- }
3041
3458
 
3042
3459
  // Redact the parts of a URL that can carry secrets before it is embedded in an
3043
3460
  // error message. AxiosError.toJSON() serializes `message` verbatim and errors
@@ -3107,19 +3524,234 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
3107
3524
  return requestedURL;
3108
3525
  }
3109
3526
 
3527
+ function assertParamsAcyclic(params) {
3528
+ const pending = [{ value: params }];
3529
+ const active = new WeakSet();
3530
+ const visited = new WeakSet();
3531
+
3532
+ while (pending.length) {
3533
+ const { value, done } = pending.pop();
3534
+ if (!utils$1.isPlainObject(value) && !utils$1.isArray(value)) continue;
3535
+ if (done) {
3536
+ active.delete(value);
3537
+ continue;
3538
+ }
3539
+ if (active.has(value)) {
3540
+ throw new AxiosError$1(
3541
+ 'Circular reference detected in params',
3542
+ AxiosError$1.ERR_BAD_OPTION_VALUE
3543
+ );
3544
+ }
3545
+ if (visited.has(value)) continue;
3546
+ visited.add(value);
3547
+ active.add(value);
3548
+ pending.push({ value, done: true });
3549
+
3550
+ const keys = Object.keys(value);
3551
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
3552
+ Object.getOwnPropertySymbols(value).forEach((key) => {
3553
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
3554
+ if (descriptor && descriptor.enumerable) keys.push(key);
3555
+ });
3556
+ }
3557
+ // Shallow array elements retain fields filtered during plain-object merges.
3558
+ // Inspect reserved data properties without evaluating their accessors.
3559
+ keys.forEach((key) => {
3560
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
3561
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
3562
+ if (descriptor && utils$1.hasOwnProp(descriptor, 'value')) {
3563
+ pending.push({ value: descriptor.value });
3564
+ }
3565
+ } else {
3566
+ pending.push({ value: value[key] });
3567
+ }
3568
+ });
3569
+ }
3570
+ }
3571
+
3110
3572
  const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
3111
3573
 
3112
3574
  const ownEnumerableKeys = (thing) => {
3113
3575
  if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
3114
3576
  return Object.keys(thing).concat(
3115
- Object.getOwnPropertySymbols(thing).filter(
3116
- (symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
3117
- )
3577
+ Object.getOwnPropertySymbols(thing).filter((symbol) => {
3578
+ const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
3579
+ return descriptor && descriptor.enumerable;
3580
+ })
3118
3581
  );
3119
3582
  }
3120
3583
  return Object.keys(thing);
3121
3584
  };
3122
3585
 
3586
+ // Copy params without recursive merges so the serializer remains responsible
3587
+ // for its depth policy. Only visit defaults that contribute to the result.
3588
+ function mergeParams(a, b) {
3589
+ const pending = [];
3590
+ const copies = new WeakMap();
3591
+ const empty = {};
3592
+
3593
+ function copy(target, source) {
3594
+ if (!utils$1.isPlainObject(source)) {
3595
+ return utils$1.isArray(source) ? source.slice() : source;
3596
+ }
3597
+
3598
+ const base = utils$1.isPlainObject(target) ? target : empty;
3599
+ let bases = copies.get(source);
3600
+ if (!bases) {
3601
+ bases = new WeakMap();
3602
+ copies.set(source, bases);
3603
+ }
3604
+ if (bases.has(base)) return bases.get(base);
3605
+
3606
+ const result = {};
3607
+ bases.set(base, result);
3608
+ pending.push({ base, source, result });
3609
+ return result;
3610
+ }
3611
+
3612
+ const result = utils$1.isUndefined(b) ? copy(undefined, a) : copy(a, b);
3613
+ while (pending.length) {
3614
+ const { base, source, result: target } = pending.pop();
3615
+ const baseKeys = new Set(ownEnumerableKeys(base));
3616
+ const sourceKeys = new Set(ownEnumerableKeys(source));
3617
+ const keys = new Set([...baseKeys, ...sourceKeys]);
3618
+
3619
+ keys.forEach((key) => {
3620
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
3621
+ const hasSource = sourceKeys.has(key);
3622
+ const value = hasSource ? source[key] : undefined;
3623
+ const previous =
3624
+ (!hasSource || utils$1.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
3625
+ target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
3626
+ });
3627
+ }
3628
+
3629
+ assertParamsAcyclic(result);
3630
+ return result;
3631
+ }
3632
+
3633
+ function getMergedValue(target, source, prop, caseless) {
3634
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3635
+ return utils$1.merge.call({ caseless }, target, source);
3636
+ } else if (utils$1.isPlainObject(source)) {
3637
+ return utils$1.merge({}, source);
3638
+ } else if (utils$1.isArray(source)) {
3639
+ return source.slice();
3640
+ }
3641
+ return source;
3642
+ }
3643
+
3644
+ function mergeDeepProperties(a, b, prop, caseless) {
3645
+ if (!utils$1.isUndefined(b)) {
3646
+ return getMergedValue(a, b, prop, caseless);
3647
+ } else if (!utils$1.isUndefined(a)) {
3648
+ return getMergedValue(undefined, a, prop, caseless);
3649
+ }
3650
+ }
3651
+
3652
+ // eslint-disable-next-line consistent-return
3653
+ function valueFromConfig2(a, b) {
3654
+ if (!utils$1.isUndefined(b)) {
3655
+ return getMergedValue(undefined, b);
3656
+ }
3657
+ }
3658
+
3659
+ // eslint-disable-next-line consistent-return
3660
+ function defaultToConfig2(a, b) {
3661
+ if (!utils$1.isUndefined(b)) {
3662
+ return getMergedValue(undefined, b);
3663
+ } else if (!utils$1.isUndefined(a)) {
3664
+ return getMergedValue(undefined, a);
3665
+ }
3666
+ }
3667
+
3668
+ function getMergedTransitionalOption(config1, config2, prop) {
3669
+ const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
3670
+ ? config2.transitional
3671
+ : undefined;
3672
+
3673
+ if (!utils$1.isUndefined(transitional2)) {
3674
+ if (utils$1.isPlainObject(transitional2)) {
3675
+ if (utils$1.hasOwnProp(transitional2, prop)) {
3676
+ return transitional2[prop];
3677
+ }
3678
+ } else {
3679
+ return undefined;
3680
+ }
3681
+ }
3682
+
3683
+ const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
3684
+ ? config1.transitional
3685
+ : undefined;
3686
+
3687
+ if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
3688
+ return transitional1[prop];
3689
+ }
3690
+
3691
+ return undefined;
3692
+ }
3693
+
3694
+ // eslint-disable-next-line consistent-return
3695
+ function mergeDirectKeys(a, b, prop, config1, config2) {
3696
+ if (utils$1.hasOwnProp(config2, prop)) {
3697
+ return getMergedValue(a, b);
3698
+ } else if (utils$1.hasOwnProp(config1, prop)) {
3699
+ return getMergedValue(undefined, a);
3700
+ }
3701
+ }
3702
+
3703
+ function mergeHeaders(a, b, prop) {
3704
+ return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
3705
+ }
3706
+
3707
+ // Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
3708
+ // this data descriptor into an accessor descriptor on the way in.
3709
+ // defineProperty only reads it, so one shared instance serves every call.
3710
+ const hasOwnPropertyDescriptor = Object.freeze({
3711
+ __proto__: null,
3712
+ value: Object.prototype.hasOwnProperty,
3713
+ enumerable: false,
3714
+ writable: true,
3715
+ configurable: true,
3716
+ });
3717
+
3718
+ // The strategy table and the strategies above are stateless, so they are
3719
+ // built once at module load instead of on every call: mergeConfig runs at
3720
+ // most twice per request (once from a method alias, once from `_request`).
3721
+ const mergeMap = {
3722
+ url: valueFromConfig2,
3723
+ method: valueFromConfig2,
3724
+ data: valueFromConfig2,
3725
+ baseURL: defaultToConfig2,
3726
+ transformRequest: defaultToConfig2,
3727
+ transformResponse: defaultToConfig2,
3728
+ params: mergeParams,
3729
+ paramsSerializer: defaultToConfig2,
3730
+ timeout: defaultToConfig2,
3731
+ timeoutErrorMessage: defaultToConfig2,
3732
+ withCredentials: defaultToConfig2,
3733
+ withXSRFToken: defaultToConfig2,
3734
+ adapter: defaultToConfig2,
3735
+ responseType: defaultToConfig2,
3736
+ xsrfCookieName: defaultToConfig2,
3737
+ xsrfHeaderName: defaultToConfig2,
3738
+ onUploadProgress: defaultToConfig2,
3739
+ onDownloadProgress: defaultToConfig2,
3740
+ decompress: defaultToConfig2,
3741
+ maxContentLength: defaultToConfig2,
3742
+ maxBodyLength: defaultToConfig2,
3743
+ beforeRedirect: defaultToConfig2,
3744
+ transport: defaultToConfig2,
3745
+ httpAgent: defaultToConfig2,
3746
+ httpsAgent: defaultToConfig2,
3747
+ cancelToken: defaultToConfig2,
3748
+ socketPath: defaultToConfig2,
3749
+ allowedSocketPaths: defaultToConfig2,
3750
+ responseEncoding: defaultToConfig2,
3751
+ validateStatus: mergeDirectKeys,
3752
+ headers: mergeHeaders,
3753
+ };
3754
+
3123
3755
  /**
3124
3756
  * Config-specific merge-function which creates a new config-object
3125
3757
  * by merging two configuration objects together.
@@ -3139,133 +3771,25 @@ function mergeConfig$1(config1, config2) {
3139
3771
  // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
3140
3772
  // ergonomics for user code that relies on it.
3141
3773
  const config = Object.create(null);
3142
- Object.defineProperty(config, 'hasOwnProperty', {
3143
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
3144
- // this data descriptor into an accessor descriptor on the way in.
3145
- __proto__: null,
3146
- value: Object.prototype.hasOwnProperty,
3147
- enumerable: false,
3148
- writable: true,
3149
- configurable: true,
3150
- });
3151
-
3152
- function getMergedValue(target, source, prop, caseless) {
3153
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3154
- return utils$1.merge.call({ caseless }, target, source);
3155
- } else if (utils$1.isPlainObject(source)) {
3156
- return utils$1.merge({}, source);
3157
- } else if (utils$1.isArray(source)) {
3158
- return source.slice();
3159
- }
3160
- return source;
3161
- }
3162
-
3163
- function mergeDeepProperties(a, b, prop, caseless) {
3164
- if (!utils$1.isUndefined(b)) {
3165
- return getMergedValue(a, b, prop, caseless);
3166
- } else if (!utils$1.isUndefined(a)) {
3167
- return getMergedValue(undefined, a, prop, caseless);
3168
- }
3169
- }
3170
-
3171
- // eslint-disable-next-line consistent-return
3172
- function valueFromConfig2(a, b) {
3173
- if (!utils$1.isUndefined(b)) {
3174
- return getMergedValue(undefined, b);
3175
- }
3176
- }
3177
-
3178
- // eslint-disable-next-line consistent-return
3179
- function defaultToConfig2(a, b) {
3180
- if (!utils$1.isUndefined(b)) {
3181
- return getMergedValue(undefined, b);
3182
- } else if (!utils$1.isUndefined(a)) {
3183
- return getMergedValue(undefined, a);
3184
- }
3185
- }
3186
-
3187
- function getMergedTransitionalOption(prop) {
3188
- const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
3189
- ? config2.transitional
3190
- : undefined;
3191
-
3192
- if (!utils$1.isUndefined(transitional2)) {
3193
- if (utils$1.isPlainObject(transitional2)) {
3194
- if (utils$1.hasOwnProp(transitional2, prop)) {
3195
- return transitional2[prop];
3196
- }
3197
- } else {
3198
- return undefined;
3199
- }
3200
- }
3774
+ Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
3201
3775
 
3202
- const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
3203
- ? config1.transitional
3204
- : undefined;
3205
-
3206
- if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
3207
- return transitional1[prop];
3208
- }
3209
-
3210
- return undefined;
3211
- }
3212
-
3213
- // eslint-disable-next-line consistent-return
3214
- function mergeDirectKeys(a, b, prop) {
3215
- if (utils$1.hasOwnProp(config2, prop)) {
3216
- return getMergedValue(a, b);
3217
- } else if (utils$1.hasOwnProp(config1, prop)) {
3218
- return getMergedValue(undefined, a);
3219
- }
3220
- }
3221
-
3222
- const mergeMap = {
3223
- url: valueFromConfig2,
3224
- method: valueFromConfig2,
3225
- data: valueFromConfig2,
3226
- baseURL: defaultToConfig2,
3227
- transformRequest: defaultToConfig2,
3228
- transformResponse: defaultToConfig2,
3229
- paramsSerializer: defaultToConfig2,
3230
- timeout: defaultToConfig2,
3231
- timeoutMessage: defaultToConfig2,
3232
- withCredentials: defaultToConfig2,
3233
- withXSRFToken: defaultToConfig2,
3234
- adapter: defaultToConfig2,
3235
- responseType: defaultToConfig2,
3236
- xsrfCookieName: defaultToConfig2,
3237
- xsrfHeaderName: defaultToConfig2,
3238
- onUploadProgress: defaultToConfig2,
3239
- onDownloadProgress: defaultToConfig2,
3240
- decompress: defaultToConfig2,
3241
- maxContentLength: defaultToConfig2,
3242
- maxBodyLength: defaultToConfig2,
3243
- beforeRedirect: defaultToConfig2,
3244
- transport: defaultToConfig2,
3245
- httpAgent: defaultToConfig2,
3246
- httpsAgent: defaultToConfig2,
3247
- cancelToken: defaultToConfig2,
3248
- socketPath: defaultToConfig2,
3249
- allowedSocketPaths: defaultToConfig2,
3250
- responseEncoding: defaultToConfig2,
3251
- validateStatus: mergeDirectKeys,
3252
- headers: (a, b, prop) =>
3253
- mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
3254
- };
3776
+ const keys = ownEnumerableKeys({ ...config1, ...config2 });
3255
3777
 
3256
- utils$1.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
3257
- if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3778
+ for (let i = 0, len = keys.length; i < len; i++) {
3779
+ const prop = keys[i];
3780
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
3258
3781
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3259
3782
  const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
3260
3783
  const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
3261
- const configValue = merge(a, b, prop);
3784
+ const configValue =
3785
+ merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
3262
3786
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3263
- });
3787
+ }
3264
3788
 
3265
3789
  if (
3266
3790
  utils$1.hasOwnProp(config2, 'validateStatus') &&
3267
3791
  utils$1.isUndefined(config2.validateStatus) &&
3268
- getMergedTransitionalOption('validateStatusUndefinedResolves') === false
3792
+ getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false
3269
3793
  ) {
3270
3794
  if (utils$1.hasOwnProp(config1, 'validateStatus')) {
3271
3795
  config.validateStatus = getMergedValue(undefined, config1.validateStatus);
@@ -3316,7 +3840,9 @@ const encodeUTF8$1 = (str) =>
3316
3840
  String.fromCharCode(parseInt(hex, 16))
3317
3841
  );
3318
3842
 
3319
- function resolveConfig(config) {
3843
+ const readCookie = (name) => cookies.read(name);
3844
+
3845
+ function resolveConfig(config, readXsrfCookie = readCookie) {
3320
3846
  const newConfig = mergeConfig$1({}, config);
3321
3847
 
3322
3848
  // Read only own properties to prevent prototype pollution gadgets
@@ -3345,11 +3871,22 @@ function resolveConfig(config) {
3345
3871
  if (auth) {
3346
3872
  const username = utils$1.getSafeProp(auth, 'username') || '';
3347
3873
  const password = utils$1.getSafeProp(auth, 'password') || '';
3874
+ const transitional = own('transitional');
3875
+ const encodeUsername =
3876
+ transitional &&
3877
+ utils$1.hasOwnProp(transitional, 'encodeBasicAuthUsername') &&
3878
+ transitional.encodeBasicAuthUsername === true;
3348
3879
 
3349
3880
  try {
3350
3881
  headers.set(
3351
3882
  'Authorization',
3352
- 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
3883
+ // Preserve legacy username bytes unless the caller opts in to UTF-8.
3884
+ 'Basic ' +
3885
+ btoa(
3886
+ (encodeUsername ? encodeUTF8$1(username) : username) +
3887
+ ':' +
3888
+ (password ? encodeUTF8$1(password) : '')
3889
+ )
3353
3890
  );
3354
3891
  } catch (e) {
3355
3892
  throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_OPTION_VALUE, config);
@@ -3357,15 +3894,17 @@ function resolveConfig(config) {
3357
3894
  }
3358
3895
 
3359
3896
  if (utils$1.isFormData(data)) {
3897
+ const getHeaders = utils$1.getSafeProp(data, 'getHeaders');
3898
+
3360
3899
  if (
3361
3900
  platform.hasStandardBrowserEnv ||
3362
3901
  platform.hasStandardBrowserWebWorkerEnv ||
3363
3902
  utils$1.isReactNative(data)
3364
3903
  ) {
3365
3904
  headers.setContentType(undefined); // browser/web worker/RN handles it
3366
- } else if (utils$1.isFunction(data.getHeaders)) {
3905
+ } else if (utils$1.isFunction(getHeaders)) {
3367
3906
  // Node.js FormData (like form-data package)
3368
- setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
3907
+ setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
3369
3908
  }
3370
3909
  }
3371
3910
 
@@ -3385,7 +3924,7 @@ function resolveConfig(config) {
3385
3924
  withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
3386
3925
 
3387
3926
  if (shouldSendXSRF) {
3388
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3927
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
3389
3928
 
3390
3929
  if (xsrfValue) {
3391
3930
  headers.set(xsrfHeaderName, xsrfValue);
@@ -3401,17 +3940,60 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3401
3940
  var xhrAdapter = isXHRAdapterSupported &&
3402
3941
  function (config) {
3403
3942
  return new Promise(function dispatchXhrRequest(resolve, reject) {
3404
- const _config = resolveConfig(config);
3943
+ let useAsyncXsrf;
3944
+ try {
3945
+ const store =
3946
+ platform.hasStandardBrowserEnv && typeof window !== 'undefined' && window.cookieStore;
3947
+ useAsyncXsrf = store && utils$1.isFunction(store.get);
3948
+ } catch (e) {
3949
+ // A restricted Cookie Store getter must retain the synchronous fallback.
3950
+ }
3951
+ let xsrfCookieName;
3952
+ const _config = resolveConfig(
3953
+ config,
3954
+ useAsyncXsrf
3955
+ ? (name) => {
3956
+ xsrfCookieName = name;
3957
+ return null;
3958
+ }
3959
+ : undefined
3960
+ );
3405
3961
  let requestData = _config.data;
3406
3962
  const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3407
3963
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
3408
3964
  let onCanceled;
3965
+ let timeoutId;
3409
3966
  let uploadThrottled, downloadThrottled;
3410
- let flushUpload, flushDownload;
3967
+ let flushUpload, flushDownload, flushDownloadWithEvent;
3411
3968
 
3412
3969
  function done() {
3413
- flushUpload && flushUpload(); // flush events
3414
- flushDownload && flushDownload(); // flush events
3970
+ clearTimeout(timeoutId);
3971
+ // A final progress callback must not prevent the remaining cleanup.
3972
+ // Report errors asynchronously, as onloadend and the throttle timer do.
3973
+ try {
3974
+ flushUpload && flushUpload(); // flush events
3975
+ } catch (err) {
3976
+ setTimeout(() => {
3977
+ throw err;
3978
+ });
3979
+ }
3980
+ try {
3981
+ flushDownload && flushDownload(); // flush events
3982
+ } catch (err) {
3983
+ setTimeout(() => {
3984
+ throw err;
3985
+ });
3986
+ }
3987
+
3988
+ // A flush can synchronously cancel the request and reenter done().
3989
+ // In that case the inner call has already detached these listeners.
3990
+ if (request) {
3991
+ downloadThrottled && request.removeEventListener('progress', downloadThrottled);
3992
+ if (request.upload) {
3993
+ uploadThrottled && request.upload.removeEventListener('progress', uploadThrottled);
3994
+ flushUpload && request.upload.removeEventListener('loadend', flushUpload);
3995
+ }
3996
+ }
3415
3997
 
3416
3998
  _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3417
3999
 
@@ -3425,10 +4007,55 @@ var xhrAdapter = isXHRAdapterSupported &&
3425
4007
  // Set the request timeout in MS
3426
4008
  request.timeout = _config.timeout;
3427
4009
 
3428
- function onloadend() {
4010
+ function onloadend(event) {
4011
+ if (!request) {
4012
+ return;
4013
+ }
4014
+
4015
+ // Status 0 means no response was received, which onerror and onabort normally
4016
+ // reject before this runs. Firefox 152 fires only readystatechange and loadend for
4017
+ // navigation-canceled requests (https://bugzilla.mozilla.org/show_bug.cgi?id=1505389),
4018
+ // leaving settle() to resolve them as an empty success. ECONNABORTED is the error
4019
+ // onabort raised on Firefox 151. Reads over file:, which some environments report as
4020
+ // status 0 on success, are excluded by the request URL's scheme after browser-style
4021
+ // preprocessing, by the page origin's scheme for relative URLs (which inherit it), or
4022
+ // by responseURL where implemented.
4023
+ if (
4024
+ request.status === 0 &&
4025
+ (parseProtocol(normalizeURLForProtocolCheck(_config.url)) ||
4026
+ parseProtocol(platform.origin)) !== 'file' &&
4027
+ !(request.responseURL && request.responseURL.startsWith('file:'))
4028
+ ) {
4029
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
4030
+ done();
4031
+
4032
+ // Clean up request
4033
+ request = null;
4034
+ return;
4035
+ }
4036
+
4037
+ // When loadend is still dispatching, flushing with it gives progress
4038
+ // listeners a final delivery whose event has a live target. The legacy
4039
+ // ready-state fallback has no event, so replay its pending progress.
4040
+ // A throwing listener must not block settlement; rethrow asynchronously,
4041
+ // matching how listener errors surface on the throttle timer path.
4042
+ try {
4043
+ if (event) {
4044
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
4045
+ } else {
4046
+ flushDownload && flushDownload();
4047
+ }
4048
+ } catch (err) {
4049
+ setTimeout(() => {
4050
+ throw err;
4051
+ });
4052
+ }
4053
+
4054
+ // A final progress callback can cancel the request synchronously.
3429
4055
  if (!request) {
3430
4056
  return;
3431
4057
  }
4058
+
3432
4059
  // Prepare the response
3433
4060
  const responseHeaders = AxiosHeaders$1.from(
3434
4061
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
@@ -3517,6 +4144,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3517
4144
 
3518
4145
  // Handle timeout
3519
4146
  request.ontimeout = function handleTimeout() {
4147
+ if (!request) return;
3520
4148
  let timeoutErrorMessage = _config.timeout
3521
4149
  ? 'timeout of ' + _config.timeout + 'ms exceeded'
3522
4150
  : 'timeout exceeded';
@@ -3541,13 +4169,6 @@ var xhrAdapter = isXHRAdapterSupported &&
3541
4169
  // Remove Content-Type if data is undefined
3542
4170
  requestData === undefined && requestHeaders.setContentType(null);
3543
4171
 
3544
- // Add headers to the request
3545
- if ('setRequestHeader' in request) {
3546
- utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
3547
- request.setRequestHeader(key, val);
3548
- });
3549
- }
3550
-
3551
4172
  // Add withCredentials to request if needed
3552
4173
  if (!utils$1.isUndefined(_config.withCredentials)) {
3553
4174
  request.withCredentials = !!_config.withCredentials;
@@ -3560,7 +4181,10 @@ var xhrAdapter = isXHRAdapterSupported &&
3560
4181
 
3561
4182
  // Handle progress if needed
3562
4183
  if (onDownloadProgress) {
3563
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
4184
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
4185
+ onDownloadProgress,
4186
+ true
4187
+ );
3564
4188
  request.addEventListener('progress', downloadThrottled);
3565
4189
  }
3566
4190
 
@@ -3581,12 +4205,14 @@ var xhrAdapter = isXHRAdapterSupported &&
3581
4205
  return;
3582
4206
  }
3583
4207
  reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
3584
- request.abort();
4208
+ const xhr = request;
3585
4209
  done();
3586
4210
  request = null;
4211
+ xhr.abort();
3587
4212
  };
3588
4213
 
3589
4214
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
4215
+ if (!request) return;
3590
4216
  if (_config.signal) {
3591
4217
  _config.signal.aborted
3592
4218
  ? onCanceled()
@@ -3594,6 +4220,8 @@ var xhrAdapter = isXHRAdapterSupported &&
3594
4220
  }
3595
4221
  }
3596
4222
 
4223
+ if (!request) return;
4224
+
3597
4225
  const protocol = parseProtocol(_config.url);
3598
4226
 
3599
4227
  if (protocol && !platform.protocols.includes(protocol)) {
@@ -3608,8 +4236,73 @@ var xhrAdapter = isXHRAdapterSupported &&
3608
4236
  return;
3609
4237
  }
3610
4238
 
3611
- // Send the request
3612
- request.send(requestData || null);
4239
+ const sendRequest = () => {
4240
+ if (!request) return;
4241
+ // Apply headers after an asynchronous XSRF read so existing headers are
4242
+ // replaced through AxiosHeaders rather than appended by the native XHR.
4243
+ if ('setRequestHeader' in request) {
4244
+ utils$1.forEach(
4245
+ toByteStringHeaderObject(requestHeaders),
4246
+ function setRequestHeader(val, key) {
4247
+ request.setRequestHeader(key, val);
4248
+ }
4249
+ );
4250
+ }
4251
+ request.send(requestData || null);
4252
+ };
4253
+
4254
+ if (xsrfCookieName) {
4255
+ // Native XHR timeout starts at send(). Cover cookie preparation and the
4256
+ // subsequent request with the same budget and existing timeout handler.
4257
+ const now =
4258
+ typeof performance !== 'undefined' && utils$1.isFunction(performance.now)
4259
+ ? () => performance.now()
4260
+ : Date.now;
4261
+ const deadline = request.timeout > 0 ? now() + Number(request.timeout) : undefined;
4262
+ const abortOnTimeout = () => {
4263
+ if (!request) return;
4264
+ const xhr = request;
4265
+ xhr.ontimeout();
4266
+ xhr.abort();
4267
+ };
4268
+ if (deadline !== undefined) {
4269
+ const scheduleTimeout = () => {
4270
+ const remaining = deadline - now();
4271
+ if (remaining > 0) {
4272
+ // Browser timers overflow above the signed 32-bit delay limit.
4273
+ timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 0x7fffffff));
4274
+ } else {
4275
+ abortOnTimeout();
4276
+ }
4277
+ };
4278
+ scheduleTimeout();
4279
+ }
4280
+
4281
+ cookies
4282
+ .readAsync(xsrfCookieName)
4283
+ .then((value) => {
4284
+ if (!request) return;
4285
+ // Promise callbacks may run before an overdue timer after a busy task.
4286
+ if (deadline !== undefined && now() >= deadline) {
4287
+ abortOnTimeout();
4288
+ return;
4289
+ }
4290
+ if (value) {
4291
+ const headerName =
4292
+ utils$1.hasOwnProp(_config, 'xsrfHeaderName') && _config.xsrfHeaderName;
4293
+ requestHeaders.set(headerName, value);
4294
+ }
4295
+ sendRequest();
4296
+ })
4297
+ .catch((error) => {
4298
+ if (!request) return;
4299
+ reject(AxiosError$1.from(error, null, config, request));
4300
+ done();
4301
+ request = null;
4302
+ });
4303
+ } else {
4304
+ sendRequest();
4305
+ }
3613
4306
  });
3614
4307
  };
3615
4308
 
@@ -3645,12 +4338,15 @@ const composeSignals = (signals, timeout) => {
3645
4338
  }, timeout);
3646
4339
 
3647
4340
  const unsubscribe = () => {
3648
- if (!signals) { return; }
4341
+ if (!signals) {
4342
+ return;
4343
+ }
3649
4344
  timer && clearTimeout(timer);
3650
4345
  timer = null;
3651
4346
  signals.forEach((signal) => {
3652
- signal.unsubscribe
3653
- ? signal.unsubscribe(onabort)
4347
+ const unsubscribeSignal = utils$1.getSafeProp(signal, 'unsubscribe');
4348
+ utils$1.isFunction(unsubscribeSignal)
4349
+ ? unsubscribeSignal.call(signal, onabort)
3654
4350
  : signal.removeEventListener('abort', onabort);
3655
4351
  });
3656
4352
  signals = null;
@@ -3766,11 +4462,156 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3766
4462
  );
3767
4463
  };
3768
4464
 
4465
+ const CRLF = '\r\n';
4466
+ const normalizeLines = (value) => String(value).replace(/\r\n|\r|\n/g, CRLF);
4467
+ const escapeName = (value) =>
4468
+ String(value).replace(/[\r\n"]/g, (char) =>
4469
+ char === '\r' ? '%0D' : char === '\n' ? '%0A' : '%22'
4470
+ );
4471
+
4472
+ // Count UTF-8 bytes without allocating an encoded copy of a field. FormData
4473
+ // string values normalize line endings; Blob/File contents remain unchanged.
4474
+ const stringBytes = (value, normalize) => {
4475
+ let length = 0;
4476
+ for (let i = 0; i < value.length; i++) {
4477
+ const code = value.charCodeAt(i);
4478
+ if (normalize && (code === 13 || code === 10)) {
4479
+ if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
4480
+ length += 2;
4481
+ } else if (code < 0x80) {
4482
+ length++;
4483
+ } else if (code < 0x800) {
4484
+ length += 2;
4485
+ } else if (
4486
+ code >= 0xd800 &&
4487
+ code <= 0xdbff &&
4488
+ value.charCodeAt(i + 1) >= 0xdc00 &&
4489
+ value.charCodeAt(i + 1) <= 0xdfff
4490
+ ) {
4491
+ length += 4;
4492
+ i++;
4493
+ } else {
4494
+ length += 3;
4495
+ }
4496
+ }
4497
+ return length;
4498
+ };
4499
+
4500
+ // Describe serialization failures independently of any request library.
4501
+ class FormDataError extends TypeError {
4502
+ constructor(message, reason) {
4503
+ super(message);
4504
+ this.name = 'FormDataError';
4505
+ this.reason = reason;
4506
+ }
4507
+ }
4508
+
4509
+ // The caller supplies the boundary, Blob implementation, and limit error.
4510
+ function formDataToBlob(form, Blob, limit, limitError, boundary) {
4511
+ if (!utils$1.isFunction(Blob)) {
4512
+ throw new FormDataError('Blob is not supported', 'blob');
4513
+ }
4514
+
4515
+ if (
4516
+ !utils$1.isString(boundary) ||
4517
+ !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) ||
4518
+ / $/.test(boundary)
4519
+ ) {
4520
+ throw new FormDataError('Invalid multipart boundary', 'boundary');
4521
+ }
4522
+ const footer = '--' + boundary + '--' + CRLF;
4523
+ let length = footer.length;
4524
+ const parts = [];
4525
+ const checkLength = (extra) => {
4526
+ if (length + extra > limit) throw limitError();
4527
+ };
4528
+ checkLength(0);
4529
+
4530
+ for (const [name, value] of form) {
4531
+ const isString = utils$1.isString(value);
4532
+ const valueLength = isString ? stringBytes(value, true) : value.size;
4533
+ if (!Number.isFinite(valueLength) || valueLength < 0) {
4534
+ throw new FormDataError('Unsupported FormData part size', 'part');
4535
+ }
4536
+ // Reject large values and names before building normalized header strings.
4537
+ checkLength(
4538
+ valueLength +
4539
+ stringBytes(name, true) +
4540
+ (!isString && value.name ? stringBytes(value.name, false) : 0) +
4541
+ (!isString && value.type ? stringBytes(value.type, false) : 0)
4542
+ );
4543
+
4544
+ let header =
4545
+ '--' +
4546
+ boundary +
4547
+ CRLF +
4548
+ 'Content-Disposition: form-data; name="' +
4549
+ escapeName(normalizeLines(name)) +
4550
+ '"';
4551
+ if (!isString) {
4552
+ header +=
4553
+ '; filename="' +
4554
+ escapeName(utils$1.isString(value.name) ? value.name : 'blob') +
4555
+ '"' +
4556
+ CRLF +
4557
+ 'Content-Type: ' +
4558
+ String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
4559
+ }
4560
+ header += CRLF + CRLF;
4561
+ const partLength = stringBytes(header, false) + valueLength + CRLF.length;
4562
+ checkLength(partLength);
4563
+ length += partLength;
4564
+ parts.push({ header, value, isString });
4565
+ }
4566
+
4567
+ // Native Blob composition retains existing Blob/File data. No file is read
4568
+ // and no complete multipart ArrayBuffer is created to determine its length.
4569
+ const blobParts = [];
4570
+ for (const part of parts) {
4571
+ blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF);
4572
+ }
4573
+ blobParts.push(footer);
4574
+ return new Blob(blobParts, { type: 'multipart/form-data; boundary=' + boundary });
4575
+ }
4576
+
4577
+ function createMultipartBody(form, Blob, limit, limitError, boundary) {
4578
+ // Report missing Blob support before trying to select a random source.
4579
+ if (!utils$1.isFunction(Blob)) {
4580
+ throw new AxiosError$1('Blob is not supported', AxiosError$1.ERR_NOT_SUPPORT);
4581
+ }
4582
+
4583
+ if (boundary === undefined) {
4584
+ if (utils$1.isFunction(platform.generateString)) {
4585
+ boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
4586
+ } else {
4587
+ const crypto = utils$1.global.crypto;
4588
+ if (!crypto || !utils$1.isFunction(crypto.getRandomValues)) {
4589
+ throw new AxiosError$1('Random byte generation is not supported', AxiosError$1.ERR_NOT_SUPPORT);
4590
+ }
4591
+ const random = new Uint8Array(18);
4592
+ crypto.getRandomValues(random);
4593
+ boundary =
4594
+ 'axios-' + Array.from(random, (value) => ('0' + value.toString(16)).slice(-2)).join('');
4595
+ }
4596
+ }
4597
+
4598
+ try {
4599
+ return formDataToBlob(form, Blob, limit, limitError, boundary);
4600
+ } catch (error) {
4601
+ if (error instanceof FormDataError) {
4602
+ const code =
4603
+ error.reason === 'boundary' ? AxiosError$1.ERR_BAD_OPTION_VALUE : AxiosError$1.ERR_BAD_REQUEST;
4604
+ throw new AxiosError$1(error.message, code);
4605
+ }
4606
+ throw error;
4607
+ }
4608
+ }
4609
+
3769
4610
  /**
3770
4611
  * Estimate data: URL byte lengths *without* allocating large buffers.
3771
4612
  * - Fetch percent-decodes a base64 body before decoding it.
3772
4613
  * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
3773
- * raw body, including ignored characters and content after padding.
4614
+ * percent-decoded body, including ignored characters and content after padding.
3774
4615
  * - Non-base64 data is percent-decoded and then encoded as UTF-8.
3775
4616
  */
3776
4617
  const isHexDigit = (charCode) =>
@@ -3863,16 +4704,16 @@ const estimatePercentDecodedBase64Bytes = (body) => {
3863
4704
  return base64Bytes(significant);
3864
4705
  };
3865
4706
 
3866
- const estimateDataURLBytes = (url, estimateBase64) => {
4707
+ const estimateDataURLBytes = (url, estimateBase64, base64Pattern) => {
3867
4708
  if (!url || typeof url !== 'string') return 0;
3868
- if (!url.startsWith('data:')) return 0;
4709
+ if (!/^data:/i.test(url)) return 0;
3869
4710
 
3870
4711
  const comma = url.indexOf(',');
3871
4712
  if (comma < 0) return 0;
3872
4713
 
3873
4714
  const meta = url.slice(5, comma);
3874
4715
  const body = url.slice(comma + 1);
3875
- const isBase64 = /;base64/i.test(meta);
4716
+ const isBase64 = base64Pattern.test(meta);
3876
4717
 
3877
4718
  if (isBase64) {
3878
4719
  return estimateBase64(body);
@@ -3919,14 +4760,27 @@ function estimateDataURLDecodedBytes(url) {
3919
4760
 
3920
4761
  return estimateDataURLBytes(
3921
4762
  fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
3922
- estimatePercentDecodedBase64Bytes
4763
+ estimatePercentDecodedBase64Bytes,
4764
+ /; *base64[\t\n\f\r ]*$/i
3923
4765
  );
3924
4766
  }
3925
4767
 
3926
- const VERSION$1 = "1.19.0";
4768
+ const VERSION$1 = "1.21.0";
3927
4769
 
3928
4770
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
3929
4771
 
4772
+ const DEFAULT_REQUEST_OPTIONS = {
4773
+ cache: 'default',
4774
+ redirect: 'follow',
4775
+ referrer: 'about:client',
4776
+ referrerPolicy: '',
4777
+ mode: 'cors',
4778
+ integrity: '',
4779
+ keepalive: false,
4780
+ priority: 'auto',
4781
+ window: null,
4782
+ };
4783
+
3930
4784
  const { isFunction } = utils$1;
3931
4785
 
3932
4786
  /**
@@ -3977,9 +4831,7 @@ const maybeWithAuthCredentials = (url) => {
3977
4831
 
3978
4832
  const factory = (env) => {
3979
4833
  const globalObject =
3980
- utils$1.global !== undefined && utils$1.global !== null
3981
- ? utils$1.global
3982
- : globalThis;
4834
+ utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
3983
4835
  const { ReadableStream, TextEncoder } = globalObject;
3984
4836
 
3985
4837
  env = utils$1.merge.call(
@@ -3989,11 +4841,13 @@ const factory = (env) => {
3989
4841
  {
3990
4842
  Request: globalObject.Request,
3991
4843
  Response: globalObject.Response,
4844
+ Blob: globalObject.Blob,
3992
4845
  },
3993
4846
  env
3994
4847
  );
3995
4848
 
3996
- const { fetch: envFetch, Request, Response } = env;
4849
+ const envFetch = utils$1.hasOwnProp(env, 'fetch') ? env.fetch : undefined;
4850
+ const { Request, Response, Blob } = env;
3997
4851
  const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3998
4852
  const isRequestSupported = isFunction(Request);
3999
4853
  const isResponseSupported = isFunction(Response);
@@ -4042,6 +4896,20 @@ const factory = (env) => {
4042
4896
  isReadableStreamSupported &&
4043
4897
  test(() => utils$1.isReadableStream(new Response('').body));
4044
4898
 
4899
+ // Some runtimes reject every explicit cache mode. Use own defaults for both
4900
+ // probes so unrelated polluted options cannot affect cache-mode detection.
4901
+ const requestDefaults = Object.assign(Object.create(null), DEFAULT_REQUEST_OPTIONS);
4902
+
4903
+ if (isRequestSupported && !test(() => new Request(platform.origin, requestDefaults))) {
4904
+ delete requestDefaults.cache;
4905
+
4906
+ // Only omit cache when that makes Request construction succeed. Otherwise
4907
+ // retain the explicit default that protects supporting runtimes from pollution.
4908
+ if (!test(() => new Request(platform.origin, requestDefaults))) {
4909
+ requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
4910
+ }
4911
+ }
4912
+
4045
4913
  const resolvers = {
4046
4914
  stream: supportsResponseStream && ((res) => res.body),
4047
4915
  };
@@ -4075,14 +4943,6 @@ const factory = (env) => {
4075
4943
  return body.size;
4076
4944
  }
4077
4945
 
4078
- if (utils$1.isSpecCompliantForm(body)) {
4079
- const _request = new Request(platform.origin, {
4080
- method: 'POST',
4081
- body,
4082
- });
4083
- return (await _request.arrayBuffer()).byteLength;
4084
- }
4085
-
4086
4946
  if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
4087
4947
  return body.byteLength;
4088
4948
  }
@@ -4118,6 +4978,7 @@ const factory = (env) => {
4118
4978
  fetchOptions,
4119
4979
  maxContentLength,
4120
4980
  maxBodyLength,
4981
+ maxRedirects,
4121
4982
  } = resolveConfig(config);
4122
4983
 
4123
4984
  const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
@@ -4144,11 +5005,12 @@ const factory = (env) => {
4144
5005
 
4145
5006
  let requestContentLength;
4146
5007
 
4147
- // AxiosError we raise while the request body is being streamed. Captured
5008
+ // AxiosErrors we raise while request or response bodies are being streamed. Captured
4148
5009
  // by identity so the catch block can surface it directly, regardless of
4149
5010
  // how the runtime wraps the resulting fetch rejection (undici exposes it
4150
5011
  // as `err.cause`; some browsers drop the original error entirely).
4151
5012
  let pendingBodyError = null;
5013
+ let pendingResponseError = null;
4152
5014
 
4153
5015
  const maxBodyLengthError = () =>
4154
5016
  new AxiosError$1(
@@ -4168,19 +5030,20 @@ const factory = (env) => {
4168
5030
  const password = utils$1.getSafeProp(configAuth, 'password') || '';
4169
5031
  auth = {
4170
5032
  username,
4171
- password
5033
+ password,
4172
5034
  };
4173
5035
  }
4174
5036
 
5037
+ let parsedURL;
4175
5038
  if (maybeWithAuthCredentials(url)) {
4176
- const parsedURL = new URL(url, platform.origin);
5039
+ parsedURL = new URL(url, platform.origin);
4177
5040
 
4178
5041
  if (!auth && (parsedURL.username || parsedURL.password)) {
4179
5042
  const urlUsername = decodeURIComponentSafe(parsedURL.username);
4180
5043
  const urlPassword = decodeURIComponentSafe(parsedURL.password);
4181
5044
  auth = {
4182
5045
  username: urlUsername,
4183
- password: urlPassword
5046
+ password: urlPassword,
4184
5047
  };
4185
5048
  }
4186
5049
 
@@ -4202,8 +5065,8 @@ const factory = (env) => {
4202
5065
  // Enforce maxContentLength for data: URLs up-front so we never materialize
4203
5066
  // an oversized payload. The HTTP adapter applies the same check (see http.js
4204
5067
  // "if (protocol === 'data:')" branch).
4205
- if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
4206
- const estimated = estimateDataURLDecodedBytes(url);
5068
+ if (hasMaxContentLength && parsedURL && parsedURL.protocol === 'data:') {
5069
+ const estimated = estimateDataURLDecodedBytes(parsedURL.href);
4207
5070
  if (estimated > maxContentLength) {
4208
5071
  throw new AxiosError$1(
4209
5072
  'maxContentLength size of ' + maxContentLength + ' exceeded',
@@ -4214,6 +5077,38 @@ const factory = (env) => {
4214
5077
  }
4215
5078
  }
4216
5079
 
5080
+ const formContentType =
5081
+ utils$1.isSpecCompliantForm(data) && AxiosHeaders$1.from(own('headers')).getContentType();
5082
+ let formBoundary;
5083
+ if (
5084
+ utils$1.isString(formContentType) &&
5085
+ /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())
5086
+ ) {
5087
+ const parameters = AxiosHeaders$1.parseParameters(formContentType);
5088
+ if (utils$1.hasOwnProp(parameters, 'boundary')) formBoundary = parameters.boundary;
5089
+ }
5090
+
5091
+ if (
5092
+ utils$1.isSpecCompliantForm(data) &&
5093
+ method !== 'get' &&
5094
+ method !== 'head' &&
5095
+ (hasMaxBodyLength ||
5096
+ (onUploadProgress && supportsRequestStream) ||
5097
+ formBoundary !== undefined)
5098
+ ) {
5099
+ data = createMultipartBody(
5100
+ data,
5101
+ Blob,
5102
+ hasMaxBodyLength ? maxBodyLength : Infinity,
5103
+ maxBodyLengthError,
5104
+ formBoundary
5105
+ );
5106
+ // Blob.type lowercases its value, including a case-sensitive boundary.
5107
+ // Retain the caller's header when an explicit boundary was serialized.
5108
+ headers.setContentType(formBoundary === undefined ? data.type : formContentType);
5109
+ requestContentLength = data.size;
5110
+ }
5111
+
4217
5112
  // Enforce maxBodyLength against known-size bodies before dispatch using
4218
5113
  // the body's *actual* size — never a caller-declared Content-Length,
4219
5114
  // which could under-report to slip an oversized body past the check.
@@ -4254,7 +5149,9 @@ const factory = (env) => {
4254
5149
  (onUploadProgress || mustEnforceStreamBody)
4255
5150
  ) {
4256
5151
  requestContentLength =
4257
- requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
5152
+ requestContentLength == null
5153
+ ? await resolveBodyLength(headers, data)
5154
+ : requestContentLength;
4258
5155
 
4259
5156
  // A declared length of 0 is only trusted to skip the wrap when we are
4260
5157
  // not enforcing a stream limit (which must not rely on that header).
@@ -4267,7 +5164,10 @@ const factory = (env) => {
4267
5164
 
4268
5165
  let contentTypeHeader;
4269
5166
 
4270
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
5167
+ if (
5168
+ utils$1.isFormData(data) &&
5169
+ (contentTypeHeader = _request.headers.get('content-type'))
5170
+ ) {
4271
5171
  headers.setContentType(contentTypeHeader);
4272
5172
  }
4273
5173
 
@@ -4330,20 +5230,57 @@ const factory = (env) => {
4330
5230
  // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
4331
5231
  headers.set('User-Agent', 'axios/' + VERSION$1, false);
4332
5232
 
4333
- const resolvedOptions = {
4334
- ...fetchOptions,
5233
+ const safeFetchOptions =
5234
+ fetchOptions == null ? fetchOptions : Object.assign(Object.create(null), fetchOptions);
5235
+
5236
+ if (safeFetchOptions) {
5237
+ // These options are owned by Axios and are already reflected in the
5238
+ // resolved Request passed to fetch.
5239
+ delete safeFetchOptions.body;
5240
+ delete safeFetchOptions.headers;
5241
+ delete safeFetchOptions.method;
5242
+ delete safeFetchOptions.signal;
5243
+ delete safeFetchOptions.duplex;
5244
+ delete safeFetchOptions.credentials;
5245
+ }
5246
+
5247
+ const resolvedOptions = Object.assign(Object.create(null), safeFetchOptions, {
4335
5248
  signal: composedSignal,
4336
5249
  method: method.toUpperCase(),
4337
5250
  headers: toByteStringHeaderObject(headers.normalize()),
4338
5251
  body: data,
4339
5252
  duplex: 'half',
4340
5253
  credentials: isCredentialsSupported ? withCredentials : undefined,
4341
- };
5254
+ });
5255
+
5256
+ if (isRequestSupported) {
5257
+ utils$1.forEach(requestDefaults, (value, key) => {
5258
+ if (resolvedOptions[key] === undefined) {
5259
+ resolvedOptions[key] = value;
5260
+ }
5261
+ });
5262
+
5263
+ if (resolvedOptions.signal === undefined) {
5264
+ resolvedOptions.signal = null;
5265
+ }
5266
+
5267
+ if (resolvedOptions.body === undefined) {
5268
+ resolvedOptions.body = null;
5269
+ }
5270
+ }
5271
+
5272
+ if (maxRedirects === 0) {
5273
+ resolvedOptions.redirect = 'manual';
5274
+
5275
+ if (safeFetchOptions) {
5276
+ safeFetchOptions.redirect = 'manual';
5277
+ }
5278
+ }
4342
5279
 
4343
5280
  request = isRequestSupported && new Request(url, resolvedOptions);
4344
5281
 
4345
5282
  let response = await (isRequestSupported
4346
- ? _fetch(request, fetchOptions)
5283
+ ? _fetch(request, safeFetchOptions)
4347
5284
  : _fetch(url, resolvedOptions));
4348
5285
 
4349
5286
  const responseHeaders = AxiosHeaders$1.from(response.headers);
@@ -4391,12 +5328,12 @@ const factory = (env) => {
4391
5328
  if (hasMaxContentLength) {
4392
5329
  bytesRead = loadedBytes;
4393
5330
  if (bytesRead > maxContentLength) {
4394
- throw new AxiosError$1(
5331
+ throw (pendingResponseError = new AxiosError$1(
4395
5332
  'maxContentLength size of ' + maxContentLength + ' exceeded',
4396
5333
  AxiosError$1.ERR_BAD_RESPONSE,
4397
5334
  config,
4398
5335
  request
4399
- );
5336
+ ));
4400
5337
  }
4401
5338
  }
4402
5339
  onProgress && onProgress(loadedBytes);
@@ -4482,7 +5419,7 @@ const factory = (env) => {
4482
5419
  }
4483
5420
 
4484
5421
  // Surface a maxBodyLength violation we raised while the request body was
4485
- // being streamed. Matching by identity (rather than reading
5422
+ // being streamed. Keeping the original error (rather than reading
4486
5423
  // `err.cause.isAxiosError`) keeps the error deterministic across runtimes
4487
5424
  // and avoids both prototype-pollution reads and mis-attributing a foreign
4488
5425
  // AxiosError that merely happened to land in `err.cause`.
@@ -4491,6 +5428,10 @@ const factory = (env) => {
4491
5428
  throw pendingBodyError;
4492
5429
  }
4493
5430
 
5431
+ if (pendingResponseError) {
5432
+ throw pendingResponseError;
5433
+ }
5434
+
4494
5435
  // Re-throw AxiosErrors we raised synchronously (data: URL / content-length
4495
5436
  // pre-checks, response size enforcement) without re-wrapping them.
4496
5437
  if (err instanceof AxiosError$1) {
@@ -4526,9 +5467,15 @@ const factory = (env) => {
4526
5467
  const seedCache = new Map();
4527
5468
 
4528
5469
  const getFetch = (config) => {
4529
- let env = (config && config.env) || {};
4530
- const { fetch, Request, Response } = env;
4531
- const seeds = [Request, Response, fetch];
5470
+ const env = Object.create(null);
5471
+ const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
5472
+ ['fetch', 'Request', 'Response', 'Blob'].forEach((key) => {
5473
+ if (configuredEnv && utils$1.hasOwnProp(configuredEnv, key)) {
5474
+ env[key] = configuredEnv[key];
5475
+ }
5476
+ });
5477
+ const { fetch, Request, Response, Blob } = env;
5478
+ const seeds = [Request, Response, fetch, Blob];
4532
5479
 
4533
5480
  let len = seeds.length,
4534
5481
  i = len,
@@ -4694,6 +5641,21 @@ function throwIfCancellationRequested(config) {
4694
5641
  }
4695
5642
  }
4696
5643
 
5644
+ /**
5645
+ * Milliseconds elapsed since `start`, floored at zero.
5646
+ *
5647
+ * Wall-clock, to match the rest of the codebase (speedometer, throttle,
5648
+ * AxiosTransformStream). A backwards clock adjustment mid-request would
5649
+ * otherwise produce a negative duration, so the result is clamped.
5650
+ *
5651
+ * @param {number} start Timestamp from `Date.now()`
5652
+ *
5653
+ * @returns {number} Non-negative elapsed milliseconds
5654
+ */
5655
+ function elapsedSince(start) {
5656
+ return Math.max(0, Date.now() - start);
5657
+ }
5658
+
4697
5659
  /**
4698
5660
  * Dispatch a request to the server using the configured adapter.
4699
5661
  *
@@ -4701,10 +5663,15 @@ function throwIfCancellationRequested(config) {
4701
5663
  *
4702
5664
  * @returns {Promise} The Promise to be fulfilled
4703
5665
  */
4704
- function dispatchRequest(config) {
5666
+ function dispatchRequest(_config) {
5667
+ // Interceptors may replace the merged config with an ordinary object. Flatten
5668
+ // it at the dispatch boundary so shared prototype members cannot become
5669
+ // request behavior, while preserving intentional template/class members.
5670
+ const config = utils$1.toSafeFlatObject(_config);
5671
+
4705
5672
  throwIfCancellationRequested(config);
4706
5673
 
4707
- config.headers = AxiosHeaders$1.from(config.headers);
5674
+ config.headers = AxiosHeaders$1.from(utils$1.getSafeProp(config, 'headers'));
4708
5675
 
4709
5676
  // Transform request data
4710
5677
  config.data = transformData.call(config, config.transformRequest);
@@ -4715,10 +5682,14 @@ function dispatchRequest(config) {
4715
5682
 
4716
5683
  const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
4717
5684
 
5685
+ const start = Date.now();
5686
+
4718
5687
  return adapter(config).then(
4719
5688
  function onAdapterResolution(response) {
4720
5689
  throwIfCancellationRequested(config);
4721
5690
 
5691
+ response.duration = elapsedSince(start);
5692
+
4722
5693
  // Expose the current response on config so that transformResponse can
4723
5694
  // attach it to any AxiosError it throws (e.g. on JSON parse failure).
4724
5695
  // We clean it up afterwards to avoid polluting the config object.
@@ -4739,6 +5710,7 @@ function dispatchRequest(config) {
4739
5710
 
4740
5711
  // Transform response data
4741
5712
  if (reason && reason.response) {
5713
+ reason.response.duration = elapsedSince(start);
4742
5714
  config.response = reason.response;
4743
5715
  try {
4744
5716
  reason.response.data = transformData.call(
@@ -4868,6 +5840,37 @@ var validator = {
4868
5840
 
4869
5841
  const validators = validator.validators;
4870
5842
 
5843
+ // Recognize header maps without consuming objects intended as literal values.
5844
+ // AxiosHeaders from other builds share a brand and header-container interface,
5845
+ // but not constructor identity. A tag and toJSON alone can describe a literal.
5846
+ const isHeadersBucket = (value) => {
5847
+ if (value == null || utils$1.isPlainObject(value) || value instanceof AxiosHeaders$1) {
5848
+ return true;
5849
+ }
5850
+
5851
+ try {
5852
+ return (
5853
+ utils$1.isObject(value) &&
5854
+ utils$1.getSafeProp(value, Symbol.toStringTag) === 'AxiosHeaders' &&
5855
+ [
5856
+ 'toJSON',
5857
+ 'set',
5858
+ 'get',
5859
+ 'has',
5860
+ 'delete',
5861
+ 'clear',
5862
+ 'normalize',
5863
+ 'concat',
5864
+ 'toString',
5865
+ Symbol.iterator,
5866
+ ].every((method) => utils$1.isFunction(utils$1.getSafeProp(value, method)))
5867
+ );
5868
+ } catch (e) {
5869
+ // A failed optional brand probe must not prevent literal header serialization.
5870
+ return false;
5871
+ }
5872
+ };
5873
+
4871
5874
  /**
4872
5875
  * Create a new instance of Axios
4873
5876
  *
@@ -4897,37 +5900,47 @@ let Axios$1 = class Axios {
4897
5900
  return await this._request(configOrUrl, config);
4898
5901
  } catch (err) {
4899
5902
  if (err instanceof Error) {
4900
- let dummy = {};
5903
+ try {
5904
+ let dummy = {};
4901
5905
 
4902
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
5906
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
4903
5907
 
4904
- // slice off the Error: ... line
4905
- const stack = (() => {
4906
- if (!dummy.stack) {
4907
- return '';
4908
- }
5908
+ const dummyStack = dummy.stack;
5909
+ let stack = '';
4909
5910
 
4910
- const firstNewlineIndex = dummy.stack.indexOf('\n');
5911
+ // slice off the Error: ... line
5912
+ if (typeof dummyStack === 'string') {
5913
+ const firstNewlineIndex = dummyStack.indexOf('\n');
5914
+
5915
+ stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
5916
+ }
4911
5917
 
4912
- return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
4913
- })();
4914
- try {
4915
5918
  if (!err.stack) {
4916
5919
  err.stack = stack;
4917
- // match without the 2 top stack lines
4918
5920
  } else if (stack) {
5921
+ // Match a common suffix after the 2 top frames when available,
5922
+ // otherwise compare the full reconstructed stack.
4919
5923
  const firstNewlineIndex = stack.indexOf('\n');
4920
5924
  const secondNewlineIndex =
4921
5925
  firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
4922
- const stackWithoutTwoTopLines =
4923
- secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
4924
-
4925
- if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
4926
- err.stack += '\n' + stack;
5926
+ const duplicateCheckSuffix =
5927
+ secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
5928
+
5929
+ // `AxiosError.from()` may have already inlined the wrapped error's
5930
+ // stack under a `Caused by:` marker. Keep the reconstructed caller
5931
+ // frames ahead of that marker so stack-only reporters do not read
5932
+ // them as part of the low-level cause.
5933
+ const currentStack = String(err.stack);
5934
+ const causeIndex = getCauseStackIndex(err, currentStack);
5935
+ const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
5936
+ const causeSection = causeIndex === -1 ? '' : currentStack.slice(causeIndex);
5937
+
5938
+ if (!stackHead.endsWith(duplicateCheckSuffix)) {
5939
+ err.stack = stackHead + '\n' + stack + causeSection;
4927
5940
  }
4928
5941
  }
4929
5942
  } catch (e) {
4930
- // ignore the case where "stack" is an un-writable property
5943
+ // Ignore failures from custom stack hooks or un-writable stack properties.
4931
5944
  }
4932
5945
  }
4933
5946
 
@@ -4959,6 +5972,7 @@ let Axios$1 = class Axios {
4959
5972
  legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
4960
5973
  advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
4961
5974
  validateStatusUndefinedResolves: validators.transitional(validators.boolean),
5975
+ encodeBasicAuthUsername: validators.transitional(validators.boolean),
4962
5976
  },
4963
5977
  false
4964
5978
  );
@@ -4982,7 +5996,10 @@ let Axios$1 = class Axios {
4982
5996
  }
4983
5997
 
4984
5998
  // Set config.allowAbsoluteUrls
4985
- if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
5999
+ if (config.allowAbsoluteUrls !== undefined) ; else if (
6000
+ utils$1.hasOwnProp(this.defaults, 'allowAbsoluteUrls') &&
6001
+ this.defaults.allowAbsoluteUrls !== undefined
6002
+ ) {
4986
6003
  config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
4987
6004
  } else {
4988
6005
  config.allowAbsoluteUrls = true;
@@ -4998,14 +6015,27 @@ let Axios$1 = class Axios {
4998
6015
  );
4999
6016
 
5000
6017
  // Set config.method
5001
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
5002
-
5003
- // Flatten headers
5004
- let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
6018
+ config.method = (
6019
+ utils$1.getSafeProp(config, 'method') ||
6020
+ utils$1.getSafeProp(this.defaults, 'method') ||
6021
+ 'get'
6022
+ ).toLowerCase();
6023
+
6024
+ // Flatten header defaults without consuming literal method-named headers.
6025
+ const commonHeaders = utils$1.getSafeProp(headers, 'common');
6026
+ const methodHeaders = utils$1.getSafeProp(headers, config.method);
6027
+ const contextHeaders =
6028
+ headers &&
6029
+ utils$1.merge(
6030
+ isHeadersBucket(commonHeaders) ? commonHeaders : undefined,
6031
+ isHeadersBucket(methodHeaders) ? methodHeaders : undefined
6032
+ );
5005
6033
 
5006
6034
  headers &&
5007
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
5008
- delete headers[method];
6035
+ utils$1.forEach(methodList.concat('common'), (method) => {
6036
+ if (isHeadersBucket(utils$1.getSafeProp(headers, method))) {
6037
+ delete headers[method];
6038
+ }
5009
6039
  });
5010
6040
 
5011
6041
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
@@ -5114,7 +6144,7 @@ let Axios$1 = class Axios {
5114
6144
  // Provide aliases for supported request methods
5115
6145
  utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
5116
6146
  /*eslint func-names:0*/
5117
- Axios$1.prototype[method] = function (url, config) {
6147
+ Axios$1.prototype[method] = async function (url, config) {
5118
6148
  return this.request(
5119
6149
  mergeConfig$1(config || {}, {
5120
6150
  method,
@@ -5127,7 +6157,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
5127
6157
 
5128
6158
  utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
5129
6159
  function generateHTTPMethod(isForm) {
5130
- return function httpMethod(url, data, config) {
6160
+ return async function httpMethod(url, data, config) {
5131
6161
  return this.request(
5132
6162
  mergeConfig$1(config || {}, {
5133
6163
  method,
@@ -5357,14 +6387,22 @@ const HttpStatusCode$1 = {
5357
6387
  Gone: 410,
5358
6388
  LengthRequired: 411,
5359
6389
  PreconditionFailed: 412,
6390
+ /**
6391
+ * @deprecated Use `ContentTooLarge` instead.
6392
+ */
5360
6393
  PayloadTooLarge: 413,
6394
+ ContentTooLarge: 413,
5361
6395
  UriTooLong: 414,
5362
6396
  UnsupportedMediaType: 415,
5363
6397
  RangeNotSatisfiable: 416,
5364
6398
  ExpectationFailed: 417,
5365
6399
  ImATeapot: 418,
5366
6400
  MisdirectedRequest: 421,
6401
+ /**
6402
+ * @deprecated Use `UnprocessableContent` instead.
6403
+ */
5367
6404
  UnprocessableEntity: 422,
6405
+ UnprocessableContent: 422,
5368
6406
  Locked: 423,
5369
6407
  FailedDependency: 424,
5370
6408
  TooEarly: 425,
@@ -5394,7 +6432,9 @@ const HttpStatusCode$1 = {
5394
6432
  };
5395
6433
 
5396
6434
  Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
5397
- HttpStatusCode$1[value] = key;
6435
+ if (HttpStatusCode$1[value] === undefined) {
6436
+ HttpStatusCode$1[value] = key;
6437
+ }
5398
6438
  });
5399
6439
 
5400
6440
  /**