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