@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
|
var FormData$1 = require('form-data');
|
|
@@ -45,13 +45,57 @@ const {
|
|
|
45
45
|
const hasOwnProperty = (({
|
|
46
46
|
hasOwnProperty
|
|
47
47
|
}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
|
48
|
+
const isUnsafeObjectKey = prop => typeof prop === 'string' && (prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* Determine whether an inherited object must be treated as a shared-prototype
|
|
52
|
+
* boundary. Cross-realm Object.prototype objects cannot be distinguished
|
|
53
|
+
* reliably from application-created null-prototype objects because their
|
|
54
|
+
* properties are mutable, so all inherited terminal prototypes are excluded
|
|
55
|
+
* as a fail-closed boundary. A null-prototype source still keeps its own
|
|
56
|
+
* properties, as produced by mergeConfig and other safe materialization paths.
|
|
57
|
+
*
|
|
58
|
+
* @param {*} obj The object to inspect
|
|
59
|
+
* @param {*} prototype The object's prototype
|
|
60
|
+
* @param {boolean} source Whether obj is the original traversal source
|
|
61
|
+
*
|
|
62
|
+
* @returns {boolean} True when obj is a safe prototype traversal boundary
|
|
63
|
+
*/
|
|
64
|
+
const isPrototypeBoundary = (obj, prototype, source) => obj === Object.prototype || !source && prototype === null;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Determine whether an object can retain its identity through code paths that
|
|
68
|
+
* add, replace, and remove config properties without bypassing unsafe-key
|
|
69
|
+
* filtering. Immutable objects, unsafe-key-bearing objects, and objects with
|
|
70
|
+
* accessor or restricted data properties must be materialized instead.
|
|
71
|
+
*
|
|
72
|
+
* @param {*} obj The object to inspect
|
|
73
|
+
*
|
|
74
|
+
* @returns {boolean} True when every own property is safe and fully mutable
|
|
75
|
+
*/
|
|
76
|
+
const isSafeAndFullyMutable = obj => {
|
|
77
|
+
if (!Object.isExtensible(obj)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
81
|
+
if (Object.getOwnPropertySymbols) {
|
|
82
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
83
|
+
}
|
|
84
|
+
return props.every(prop => {
|
|
85
|
+
if (isUnsafeObjectKey(prop)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
89
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Walk the prototype chain (excluding the source realm's Object.prototype)
|
|
95
|
+
* looking for an own `prop`. This distinguishes genuine own/inherited members
|
|
96
|
+
* — including class accessors and template prototypes — from members injected
|
|
97
|
+
* via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
98
|
+
* which live on Object.prototype itself and are therefore never matched.
|
|
55
99
|
*
|
|
56
100
|
* @param {*} thing The value whose chain to inspect
|
|
57
101
|
* @param {string|symbol} prop The property key to look for
|
|
@@ -61,15 +105,19 @@ const hasOwnProperty = (({
|
|
|
61
105
|
const hasOwnInPrototypeChain = (thing, prop) => {
|
|
62
106
|
let obj = thing;
|
|
63
107
|
const seen = [];
|
|
64
|
-
while (obj != null
|
|
108
|
+
while (obj != null) {
|
|
65
109
|
if (seen.indexOf(obj) !== -1) {
|
|
66
110
|
return false;
|
|
67
111
|
}
|
|
68
112
|
seen.push(obj);
|
|
113
|
+
const prototype = getPrototypeOf(obj);
|
|
114
|
+
if (isPrototypeBoundary(obj, prototype, obj === thing)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
69
117
|
if (hasOwnProperty(obj, prop)) {
|
|
70
118
|
return true;
|
|
71
119
|
}
|
|
72
|
-
obj =
|
|
120
|
+
obj = prototype;
|
|
73
121
|
}
|
|
74
122
|
return false;
|
|
75
123
|
};
|
|
@@ -86,6 +134,56 @@ const hasOwnInPrototypeChain = (thing, prop) => {
|
|
|
86
134
|
* @returns {*} The resolved value, or undefined when unsafe/absent
|
|
87
135
|
*/
|
|
88
136
|
const getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Flatten an object and its application-defined prototype chain into a
|
|
140
|
+
* null-prototype object. Members inherited only from the source realm's
|
|
141
|
+
* Object.prototype are deliberately excluded, while class/template members
|
|
142
|
+
* below that boundary are preserved.
|
|
143
|
+
*
|
|
144
|
+
* @param {*} thing The value to flatten
|
|
145
|
+
*
|
|
146
|
+
* @returns {*} A null-prototype copy, or the original value when it is already
|
|
147
|
+
* structurally safe or is not an object
|
|
148
|
+
*/
|
|
149
|
+
const toSafeFlatObject = thing => {
|
|
150
|
+
if (thing == null || typeof thing !== 'object' && typeof thing !== 'function') {
|
|
151
|
+
return thing;
|
|
152
|
+
}
|
|
153
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
154
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
155
|
+
return thing;
|
|
156
|
+
}
|
|
157
|
+
const result = Object.create(null);
|
|
158
|
+
const merged = Object.create(null);
|
|
159
|
+
const seen = [];
|
|
160
|
+
let current = thing;
|
|
161
|
+
while (current != null) {
|
|
162
|
+
if (seen.indexOf(current) !== -1) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
seen.push(current);
|
|
166
|
+
const prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
167
|
+
if (isPrototypeBoundary(current, prototype, current === thing)) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
const props = Object.getOwnPropertyNames(current);
|
|
171
|
+
if (Object.getOwnPropertySymbols) {
|
|
172
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
173
|
+
}
|
|
174
|
+
for (const prop of props) {
|
|
175
|
+
if (isUnsafeObjectKey(prop)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
179
|
+
result[prop] = thing[prop];
|
|
180
|
+
merged[prop] = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
current = prototype;
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
};
|
|
89
187
|
const kindOf = (cache => thing => {
|
|
90
188
|
const str = toString.call(thing);
|
|
91
189
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -208,11 +306,17 @@ const isPlainObject = val => {
|
|
|
208
306
|
return false;
|
|
209
307
|
}
|
|
210
308
|
const prototype = getPrototypeOf(val);
|
|
211
|
-
return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
|
|
212
|
-
// Treat
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
309
|
+
return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) && (
|
|
310
|
+
// Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
|
|
311
|
+
// value is tagged/iterable, ignoring members reachable only through shared
|
|
312
|
+
// or terminal prototype boundaries. This is exactly what
|
|
313
|
+
// hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
|
|
314
|
+
// above (null, Object.prototype, or a terminal null-prototype template) is
|
|
315
|
+
// a boundary, so the walk never inspects anything but `val`'s own members,
|
|
316
|
+
// and stops before even those when `val` is itself the boundary
|
|
317
|
+
// Object.prototype. Checking that inline avoids allocating the walker's
|
|
318
|
+
// `seen` list twice per call on the mergeConfig / merge hot path.
|
|
319
|
+
isPrototypeBoundary(val, prototype, true) || !hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator));
|
|
216
320
|
};
|
|
217
321
|
|
|
218
322
|
/**
|
|
@@ -463,15 +567,29 @@ function merge(...objs) {
|
|
|
463
567
|
skipUndefined
|
|
464
568
|
} = isContextDefined(this) && this || {};
|
|
465
569
|
const result = {};
|
|
570
|
+
// Caseless lookup only applies to string keys — symbol keys are
|
|
571
|
+
// identity-matched. Every string key that reaches `result` passes through
|
|
572
|
+
// this index first, so it can never hold two case variants of one key and a
|
|
573
|
+
// lowercase -> key map is exactly what findKey(result, key) would rescan
|
|
574
|
+
// Object.keys(result) for on each assignment.
|
|
575
|
+
const lowerCaseKeys = caseless ? Object.create(null) : null;
|
|
466
576
|
const assignValue = (val, key) => {
|
|
467
577
|
// Skip dangerous property names to prevent prototype pollution
|
|
468
578
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
469
579
|
return;
|
|
470
580
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
581
|
+
let targetKey = key;
|
|
582
|
+
if (lowerCaseKeys && typeof key === 'string') {
|
|
583
|
+
const lowerKey = key.toLowerCase();
|
|
584
|
+
const knownKey = lowerCaseKeys[lowerKey];
|
|
585
|
+
// A key recorded but absent from `result` was skipped by skipUndefined;
|
|
586
|
+
// the later spelling wins then, as it does for findKey.
|
|
587
|
+
if (knownKey !== undefined && hasOwnProperty(result, knownKey)) {
|
|
588
|
+
targetKey = knownKey;
|
|
589
|
+
} else {
|
|
590
|
+
lowerCaseKeys[lowerKey] = key;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
475
593
|
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
476
594
|
// chain, so a polluted Object.prototype value could surface here and get
|
|
477
595
|
// copied into the merged result.
|
|
@@ -492,7 +610,7 @@ function merge(...objs) {
|
|
|
492
610
|
continue;
|
|
493
611
|
}
|
|
494
612
|
forEach(source, assignValue);
|
|
495
|
-
if (typeof source !== 'object' || isArray(source)) {
|
|
613
|
+
if (typeof source !== 'object' || isArray(source) || !Object.getOwnPropertySymbols) {
|
|
496
614
|
continue;
|
|
497
615
|
}
|
|
498
616
|
const symbols = Object.getOwnPropertySymbols(source);
|
|
@@ -647,7 +765,27 @@ const toArray = thing => {
|
|
|
647
765
|
if (!thing) return null;
|
|
648
766
|
if (isArray(thing)) return thing;
|
|
649
767
|
let i = thing.length;
|
|
650
|
-
if (!
|
|
768
|
+
if (!Number.isSafeInteger(i) || i < 0 || i > 0xffffffff) return null;
|
|
769
|
+
|
|
770
|
+
// Bound the copy by actual indexed properties, including hidden and inherited
|
|
771
|
+
// members of array-like collections, rather than by the declared length alone.
|
|
772
|
+
const indexes = new Set();
|
|
773
|
+
const seen = new Set();
|
|
774
|
+
let source = thing;
|
|
775
|
+
while (source != null && indexes.size < i) {
|
|
776
|
+
if (seen.has(source)) return null;
|
|
777
|
+
seen.add(source);
|
|
778
|
+
const prototype = getPrototypeOf(source);
|
|
779
|
+
if (isPrototypeBoundary(source, prototype, source === thing)) break;
|
|
780
|
+
Object.getOwnPropertyNames(source).forEach(key => {
|
|
781
|
+
const index = +key;
|
|
782
|
+
if (Number.isInteger(index) && index >= 0 && index < i && String(index) === key && hasOwnProperty(source, key)) {
|
|
783
|
+
indexes.add(index);
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
source = prototype;
|
|
787
|
+
}
|
|
788
|
+
if (indexes.size !== i) return null;
|
|
651
789
|
const arr = new Array(i);
|
|
652
790
|
while (i-- > 0) {
|
|
653
791
|
arr[i] = thing[i];
|
|
@@ -959,6 +1097,7 @@ var utils$1 = {
|
|
|
959
1097
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
960
1098
|
hasOwnInPrototypeChain,
|
|
961
1099
|
getSafeProp,
|
|
1100
|
+
toSafeFlatObject,
|
|
962
1101
|
reduceDescriptors,
|
|
963
1102
|
freezeMethods,
|
|
964
1103
|
toObjectSet,
|
|
@@ -997,7 +1136,8 @@ const ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-
|
|
|
997
1136
|
* @returns {Object} Headers parsed into an object
|
|
998
1137
|
*/
|
|
999
1138
|
var parseHeaders = rawHeaders => {
|
|
1000
|
-
|
|
1139
|
+
// Header names are data, including __proto__; avoid inherited setters.
|
|
1140
|
+
const parsed = Object.create(null);
|
|
1001
1141
|
let key;
|
|
1002
1142
|
let val;
|
|
1003
1143
|
let i;
|
|
@@ -1063,7 +1203,7 @@ function toByteStringHeaderObject(headers) {
|
|
|
1063
1203
|
return byteStringHeaders;
|
|
1064
1204
|
}
|
|
1065
1205
|
|
|
1066
|
-
const $internals = Symbol('internals');
|
|
1206
|
+
const $internals$1 = Symbol('internals');
|
|
1067
1207
|
function normalizeHeader(header) {
|
|
1068
1208
|
return header && String(header).trim().toLowerCase();
|
|
1069
1209
|
}
|
|
@@ -1167,9 +1307,21 @@ function parseParameters(value) {
|
|
|
1167
1307
|
return parameters;
|
|
1168
1308
|
}
|
|
1169
1309
|
const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1310
|
+
|
|
1311
|
+
// `__proto__` is a valid field name, and the one name the uppercase mapping at
|
|
1312
|
+
// the bottom of this file cannot reach: it is inherited from Object.prototype
|
|
1313
|
+
// instead of being declared on AxiosHeaders.prototype, so `self.__proto__ = v`
|
|
1314
|
+
// runs the inherited setter. That silently discards the header, and an array
|
|
1315
|
+
// value replaces the instance prototype, taking every method with it.
|
|
1316
|
+
// Store it under the same kind of case variant that mapping uses for `set` and
|
|
1317
|
+
// `constructor`. Header lookup is caseless, so it reads back under either
|
|
1318
|
+
// spelling, and no own `__proto__` slot is ever created for a later
|
|
1319
|
+
// `Object.assign` to copy onto a plain object through the same setter.
|
|
1320
|
+
const PROTO_HEADER_SLOT = '__Proto__';
|
|
1321
|
+
const headerSlot = name => name === '__proto__' ? PROTO_HEADER_SLOT : name;
|
|
1170
1322
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1171
1323
|
if (utils$1.isFunction(filter)) {
|
|
1172
|
-
return filter.call(
|
|
1324
|
+
return filter.call(context, value, header);
|
|
1173
1325
|
}
|
|
1174
1326
|
if (isHeaderNameFilter) {
|
|
1175
1327
|
value = header;
|
|
@@ -1214,7 +1366,7 @@ class AxiosHeaders {
|
|
|
1214
1366
|
}
|
|
1215
1367
|
const key = utils$1.findKey(self, lHeader);
|
|
1216
1368
|
if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
|
|
1217
|
-
self[key || _header] = normalizeValue(_value);
|
|
1369
|
+
self[headerSlot(key || _header)] = normalizeValue(_value);
|
|
1218
1370
|
}
|
|
1219
1371
|
}
|
|
1220
1372
|
const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
@@ -1309,7 +1461,7 @@ class AxiosHeaders {
|
|
|
1309
1461
|
}
|
|
1310
1462
|
normalize(format) {
|
|
1311
1463
|
const self = this;
|
|
1312
|
-
const headers =
|
|
1464
|
+
const headers = Object.create(null);
|
|
1313
1465
|
utils$1.forEach(this, (value, header) => {
|
|
1314
1466
|
const key = utils$1.findKey(headers, header);
|
|
1315
1467
|
if (key) {
|
|
@@ -1317,7 +1469,7 @@ class AxiosHeaders {
|
|
|
1317
1469
|
delete self[header];
|
|
1318
1470
|
return;
|
|
1319
1471
|
}
|
|
1320
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1472
|
+
const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
|
|
1321
1473
|
if (normalized !== header) {
|
|
1322
1474
|
delete self[header];
|
|
1323
1475
|
}
|
|
@@ -1361,7 +1513,7 @@ class AxiosHeaders {
|
|
|
1361
1513
|
return computed;
|
|
1362
1514
|
}
|
|
1363
1515
|
static accessor(header) {
|
|
1364
|
-
const internals = this[$internals] = this[$internals] = {
|
|
1516
|
+
const internals = this[$internals$1] = this[$internals$1] = {
|
|
1365
1517
|
accessors: {}
|
|
1366
1518
|
};
|
|
1367
1519
|
const accessors = internals.accessors;
|
|
@@ -1466,6 +1618,60 @@ function aggregateErrorMessage(error) {
|
|
|
1466
1618
|
}).filter(Boolean).join('; ');
|
|
1467
1619
|
return message || error.name || 'AggregateError';
|
|
1468
1620
|
}
|
|
1621
|
+
|
|
1622
|
+
// Shared with `Axios.prototype.request`, which splices the reconstructed
|
|
1623
|
+
// caller frames in ahead of this marker.
|
|
1624
|
+
const CAUSED_BY_SEPARATOR = '\nCaused by: ';
|
|
1625
|
+
const $causeStack = Symbol('causeStack');
|
|
1626
|
+
|
|
1627
|
+
// Match the section we appended, not marker-like text in an error message or
|
|
1628
|
+
// a replacement stack supplied by the caller. Do not re-read the cause's stack.
|
|
1629
|
+
function getCauseStackIndex(error, stack) {
|
|
1630
|
+
const causeStack = utils$1.hasOwnProp(error, $causeStack) && error[$causeStack];
|
|
1631
|
+
return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* Append the stack of a wrapped error to `target.stack`.
|
|
1636
|
+
*
|
|
1637
|
+
* `cause` already exposes the original error for tooling that walks the standard
|
|
1638
|
+
* cause chain, but many error reporters read `stack` and nothing else. Inlining
|
|
1639
|
+
* the wrapped stack there means those reporters surface the underlying failure
|
|
1640
|
+
* instead of the axios frames that normalized it (see #6670).
|
|
1641
|
+
*
|
|
1642
|
+
* Every read is defensive: a custom `Error.prepareStackTrace` hook, a runtime
|
|
1643
|
+
* without stack support, or a replaced `stack` property can leave the value
|
|
1644
|
+
* missing, non-string, or read-only, and normalizing an error must not throw
|
|
1645
|
+
* because of that.
|
|
1646
|
+
*
|
|
1647
|
+
* @param {Error} target The AxiosError being built.
|
|
1648
|
+
* @param {Error} source The error being wrapped.
|
|
1649
|
+
*
|
|
1650
|
+
* @returns {void}
|
|
1651
|
+
*/
|
|
1652
|
+
function appendCauseStack(target, source) {
|
|
1653
|
+
try {
|
|
1654
|
+
const sourceStack = source && source.stack;
|
|
1655
|
+
if (typeof sourceStack !== 'string' || !sourceStack) {
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
const targetStack = target.stack;
|
|
1659
|
+
if (typeof targetStack !== 'string' || !targetStack) {
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// Each call to `from()` creates a fresh target. Re-wrapping includes the
|
|
1664
|
+
// previous stack verbatim, adding one cause section per wrap.
|
|
1665
|
+
const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
|
|
1666
|
+
target.stack = targetStack + causeStack;
|
|
1667
|
+
Object.defineProperty(target, $causeStack, {
|
|
1668
|
+
__proto__: null,
|
|
1669
|
+
value: causeStack
|
|
1670
|
+
});
|
|
1671
|
+
} catch (e) {
|
|
1672
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1469
1675
|
class AxiosError extends Error {
|
|
1470
1676
|
static from(error, code, config, request, response, customProps) {
|
|
1471
1677
|
// `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
|
|
@@ -1491,6 +1697,10 @@ class AxiosError extends Error {
|
|
|
1491
1697
|
});
|
|
1492
1698
|
axiosError.name = error.name;
|
|
1493
1699
|
|
|
1700
|
+
// Inline the wrapped stack for reporters that read only `stack`; the `cause`
|
|
1701
|
+
// property above already covers cause-aware tooling.
|
|
1702
|
+
appendCauseStack(axiosError, error);
|
|
1703
|
+
|
|
1494
1704
|
// Preserve status from the original error if not already set from response
|
|
1495
1705
|
if (error.status != null && axiosError.status == null) {
|
|
1496
1706
|
axiosError.status = error.status;
|
|
@@ -1676,23 +1886,17 @@ function toFormData(obj, formData, options) {
|
|
|
1676
1886
|
|
|
1677
1887
|
// eslint-disable-next-line no-param-reassign
|
|
1678
1888
|
formData = formData || new (FormData$1 || FormData)();
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
indexes: false
|
|
1685
|
-
}, false, function defined(option, source) {
|
|
1686
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1687
|
-
return !utils$1.isUndefined(source[option]);
|
|
1688
|
-
});
|
|
1689
|
-
const metaTokens = options.metaTokens;
|
|
1889
|
+
const option = (name, fallback) => {
|
|
1890
|
+
const value = utils$1.getSafeProp(options, name);
|
|
1891
|
+
return utils$1.isUndefined(value) ? fallback : value;
|
|
1892
|
+
};
|
|
1893
|
+
const metaTokens = option('metaTokens', true);
|
|
1690
1894
|
// eslint-disable-next-line no-use-before-define
|
|
1691
|
-
const visitor =
|
|
1692
|
-
const dots =
|
|
1693
|
-
const indexes =
|
|
1694
|
-
const _Blob =
|
|
1695
|
-
const maxDepth =
|
|
1895
|
+
const visitor = option('visitor') || defaultVisitor;
|
|
1896
|
+
const dots = option('dots', false);
|
|
1897
|
+
const indexes = option('indexes', false);
|
|
1898
|
+
const _Blob = option('Blob') || typeof Blob !== 'undefined' && Blob;
|
|
1899
|
+
const maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
1696
1900
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1697
1901
|
const stack = [];
|
|
1698
1902
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1905,9 +2109,60 @@ function buildURL(url, params, options) {
|
|
|
1905
2109
|
return url;
|
|
1906
2110
|
}
|
|
1907
2111
|
|
|
2112
|
+
const $internals = Symbol('internals');
|
|
2113
|
+
|
|
2114
|
+
// `handlers` is public and may be replaced with a nullish value by user code;
|
|
2115
|
+
// `clear()` has always tolerated that. Treat it as an empty stack rather than
|
|
2116
|
+
// dereferencing it.
|
|
2117
|
+
function countHandlers(handlers) {
|
|
2118
|
+
return handlers ? handlers.length : 0;
|
|
2119
|
+
}
|
|
2120
|
+
function trimHandlers(handlers) {
|
|
2121
|
+
if (!handlers) {
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
2125
|
+
handlers.pop();
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
// Preserve the array-key coercion used before IDs were stored in a Map, without
|
|
2130
|
+
// treating null, empty strings, or noncanonical numeric strings as ID zero.
|
|
2131
|
+
function normalizeHandlerId(id) {
|
|
2132
|
+
if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
|
|
2133
|
+
return Number(id);
|
|
2134
|
+
}
|
|
2135
|
+
return id;
|
|
2136
|
+
}
|
|
2137
|
+
function syncHandlerEntries(manager, internals) {
|
|
2138
|
+
const handlers = manager.handlers;
|
|
2139
|
+
const length = countHandlers(handlers);
|
|
2140
|
+
if (handlers !== internals.handlersRef) {
|
|
2141
|
+
internals.handlersRef = handlers;
|
|
2142
|
+
internals.handlerEntries.clear();
|
|
2143
|
+
} else if (length !== internals.handlersLength) {
|
|
2144
|
+
if (!length) {
|
|
2145
|
+
internals.handlerEntries.clear();
|
|
2146
|
+
} else {
|
|
2147
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
2148
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
2149
|
+
internals.handlerEntries.delete(id);
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
internals.handlersLength = length;
|
|
2155
|
+
}
|
|
1908
2156
|
class InterceptorManager {
|
|
1909
2157
|
constructor() {
|
|
1910
2158
|
this.handlers = [];
|
|
2159
|
+
this[$internals] = {
|
|
2160
|
+
handlersRef: this.handlers,
|
|
2161
|
+
handlersLength: this.handlers.length,
|
|
2162
|
+
handlerEntries: new Map(),
|
|
2163
|
+
iterationDepth: 0,
|
|
2164
|
+
nextId: 0
|
|
2165
|
+
};
|
|
1911
2166
|
}
|
|
1912
2167
|
|
|
1913
2168
|
/**
|
|
@@ -1920,13 +2175,25 @@ class InterceptorManager {
|
|
|
1920
2175
|
* @return {Number} An ID used to remove interceptor later
|
|
1921
2176
|
*/
|
|
1922
2177
|
use(fulfilled, rejected, options) {
|
|
1923
|
-
|
|
2178
|
+
const handler = {
|
|
1924
2179
|
fulfilled,
|
|
1925
2180
|
rejected,
|
|
1926
2181
|
synchronous: options ? options.synchronous : false,
|
|
1927
2182
|
runWhen: options ? options.runWhen : null
|
|
2183
|
+
};
|
|
2184
|
+
const internals = this[$internals];
|
|
2185
|
+
if (this.handlers == null) {
|
|
2186
|
+
this.handlers = [];
|
|
2187
|
+
}
|
|
2188
|
+
syncHandlerEntries(this, internals);
|
|
2189
|
+
const id = internals.nextId++;
|
|
2190
|
+
this.handlers.push(handler);
|
|
2191
|
+
internals.handlerEntries.set(id, {
|
|
2192
|
+
handler,
|
|
2193
|
+
index: this.handlers.length - 1
|
|
1928
2194
|
});
|
|
1929
|
-
|
|
2195
|
+
internals.handlersLength = this.handlers.length;
|
|
2196
|
+
return id;
|
|
1930
2197
|
}
|
|
1931
2198
|
|
|
1932
2199
|
/**
|
|
@@ -1937,8 +2204,24 @@ class InterceptorManager {
|
|
|
1937
2204
|
* @returns {void}
|
|
1938
2205
|
*/
|
|
1939
2206
|
eject(id) {
|
|
1940
|
-
|
|
1941
|
-
|
|
2207
|
+
const internals = this[$internals];
|
|
2208
|
+
syncHandlerEntries(this, internals);
|
|
2209
|
+
const handlerId = normalizeHandlerId(id);
|
|
2210
|
+
const entry = internals.handlerEntries.get(handlerId);
|
|
2211
|
+
if (entry) {
|
|
2212
|
+
internals.handlerEntries.delete(handlerId);
|
|
2213
|
+
|
|
2214
|
+
// Ignore IDs invalidated by clear or direct replacement of handlers.
|
|
2215
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
this.handlers[entry.index] = null;
|
|
2219
|
+
|
|
2220
|
+
// Do not reuse an index while forEach is walking its length snapshot.
|
|
2221
|
+
if (!internals.iterationDepth) {
|
|
2222
|
+
trimHandlers(this.handlers);
|
|
2223
|
+
internals.handlersLength = this.handlers.length;
|
|
2224
|
+
}
|
|
1942
2225
|
}
|
|
1943
2226
|
}
|
|
1944
2227
|
|
|
@@ -1950,6 +2233,7 @@ class InterceptorManager {
|
|
|
1950
2233
|
clear() {
|
|
1951
2234
|
if (this.handlers) {
|
|
1952
2235
|
this.handlers = [];
|
|
2236
|
+
syncHandlerEntries(this, this[$internals]);
|
|
1953
2237
|
}
|
|
1954
2238
|
}
|
|
1955
2239
|
|
|
@@ -1964,11 +2248,22 @@ class InterceptorManager {
|
|
|
1964
2248
|
* @returns {void}
|
|
1965
2249
|
*/
|
|
1966
2250
|
forEach(fn) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2251
|
+
const internals = this[$internals];
|
|
2252
|
+
syncHandlerEntries(this, internals);
|
|
2253
|
+
internals.iterationDepth++;
|
|
2254
|
+
try {
|
|
2255
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2256
|
+
if (h !== null) {
|
|
2257
|
+
fn(h);
|
|
2258
|
+
}
|
|
2259
|
+
});
|
|
2260
|
+
} finally {
|
|
2261
|
+
if (! --internals.iterationDepth) {
|
|
2262
|
+
syncHandlerEntries(this, internals);
|
|
2263
|
+
trimHandlers(this.handlers);
|
|
2264
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
1970
2265
|
}
|
|
1971
|
-
}
|
|
2266
|
+
}
|
|
1972
2267
|
}
|
|
1973
2268
|
}
|
|
1974
2269
|
|
|
@@ -1978,7 +2273,8 @@ var transitionalDefaults = {
|
|
|
1978
2273
|
clarifyTimeoutError: false,
|
|
1979
2274
|
legacyInterceptorReqResOrdering: true,
|
|
1980
2275
|
advertiseZstdAcceptEncoding: false,
|
|
1981
|
-
validateStatusUndefinedResolves: true
|
|
2276
|
+
validateStatusUndefinedResolves: true,
|
|
2277
|
+
encodeBasicAuthUsername: false
|
|
1982
2278
|
};
|
|
1983
2279
|
|
|
1984
2280
|
var URLSearchParams = url.URLSearchParams;
|
|
@@ -2133,6 +2429,24 @@ function arrayToObject(arr) {
|
|
|
2133
2429
|
}
|
|
2134
2430
|
return obj;
|
|
2135
2431
|
}
|
|
2432
|
+
function normalizeArray(value) {
|
|
2433
|
+
if (!utils$1.isArray(value)) return value;
|
|
2434
|
+
const keys = Object.keys(value);
|
|
2435
|
+
return keys.length !== value.length || keys.some((key, index) => key !== String(index)) ? arrayToObject(value) : value;
|
|
2436
|
+
}
|
|
2437
|
+
function normalizeArrays(obj) {
|
|
2438
|
+
const pending = [obj];
|
|
2439
|
+
while (pending.length) {
|
|
2440
|
+
const target = pending.pop();
|
|
2441
|
+
Object.keys(target).forEach(key => {
|
|
2442
|
+
const value = target[key] = normalizeArray(target[key]);
|
|
2443
|
+
if (utils$1.isArray(value) || utils$1.isPlainObject(value)) {
|
|
2444
|
+
pending.push(value);
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
}
|
|
2448
|
+
return obj;
|
|
2449
|
+
}
|
|
2136
2450
|
|
|
2137
2451
|
/**
|
|
2138
2452
|
* It takes a FormData object and returns a JavaScript object
|
|
@@ -2151,6 +2465,7 @@ function formDataToJSON(formData) {
|
|
|
2151
2465
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2152
2466
|
if (isLast) {
|
|
2153
2467
|
if (utils$1.hasOwnProp(target, name)) {
|
|
2468
|
+
target[name] = normalizeArray(target[name]);
|
|
2154
2469
|
target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
|
|
2155
2470
|
} else {
|
|
2156
2471
|
target[name] = value;
|
|
@@ -2171,11 +2486,13 @@ function formDataToJSON(formData) {
|
|
|
2171
2486
|
utils$1.forEachEntry(formData, (name, value) => {
|
|
2172
2487
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
2173
2488
|
});
|
|
2174
|
-
return obj;
|
|
2489
|
+
return normalizeArrays(obj);
|
|
2175
2490
|
}
|
|
2176
2491
|
return null;
|
|
2177
2492
|
}
|
|
2178
2493
|
|
|
2494
|
+
const methodList = Object.freeze(['get', 'delete', 'head', 'options', 'post', 'put', 'patch', 'purge', 'link', 'unlink', 'query']);
|
|
2495
|
+
|
|
2179
2496
|
const own = (obj, key) => obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
|
|
2180
2497
|
|
|
2181
2498
|
/**
|
|
@@ -2292,7 +2609,7 @@ const defaults = {
|
|
|
2292
2609
|
}
|
|
2293
2610
|
}
|
|
2294
2611
|
};
|
|
2295
|
-
utils$1.forEach(
|
|
2612
|
+
utils$1.forEach(methodList, method => {
|
|
2296
2613
|
defaults.headers[method] = {};
|
|
2297
2614
|
});
|
|
2298
2615
|
|
|
@@ -2391,19 +2708,28 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2391
2708
|
return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
|
|
2392
2709
|
}
|
|
2393
2710
|
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2711
|
+
const urlParserControlCharacters = /[\t\n\r]/g;
|
|
2712
|
+
|
|
2713
|
+
/**
|
|
2714
|
+
* Match WHATWG URL preprocessing before checking a URL's protocol.
|
|
2715
|
+
*
|
|
2716
|
+
* @param {string} url
|
|
2717
|
+
*
|
|
2718
|
+
* @returns {string}
|
|
2719
|
+
*/
|
|
2403
2720
|
function normalizeURLForProtocolCheck(url) {
|
|
2404
|
-
|
|
2721
|
+
if (typeof url !== 'string') {
|
|
2722
|
+
return url;
|
|
2723
|
+
}
|
|
2724
|
+
let start = 0;
|
|
2725
|
+
while (start < url.length && url.charCodeAt(start) <= 0x20) {
|
|
2726
|
+
start++;
|
|
2727
|
+
}
|
|
2728
|
+
return url.slice(start).replace(urlParserControlCharacters, '');
|
|
2405
2729
|
}
|
|
2406
2730
|
|
|
2731
|
+
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
2732
|
+
|
|
2407
2733
|
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
2408
2734
|
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
2409
2735
|
// are commonly logged, while the opt-in `config.redact` model only cleans
|
|
@@ -2555,16 +2881,19 @@ function getEnv(key) {
|
|
|
2555
2881
|
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
|
|
2556
2882
|
}
|
|
2557
2883
|
|
|
2558
|
-
const VERSION = "1.
|
|
2884
|
+
const VERSION = "1.21.0";
|
|
2559
2885
|
|
|
2560
2886
|
function parseProtocol(url) {
|
|
2561
2887
|
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2562
|
-
return match && match[1] || '';
|
|
2888
|
+
return match && match[1].toLowerCase() || '';
|
|
2563
2889
|
}
|
|
2564
2890
|
|
|
2565
2891
|
// RFC 2397: data:[<mediatype>][;base64],<data>
|
|
2566
2892
|
// mediatype = type/subtype followed by optional ;name=value parameters
|
|
2567
|
-
|
|
2893
|
+
// The `i` flag makes the `;base64` token case-insensitive, matching the WHATWG
|
|
2894
|
+
// URL/Fetch data URL processor (and therefore the fetch adapter and browsers).
|
|
2895
|
+
// The remaining character classes do not depend on letter case.
|
|
2896
|
+
const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/i;
|
|
2568
2897
|
|
|
2569
2898
|
/**
|
|
2570
2899
|
* Parse data uri to a Buffer or Blob
|
|
@@ -2601,7 +2930,7 @@ function fromDataURI(uri, asBlob, options) {
|
|
|
2601
2930
|
} else if (params) {
|
|
2602
2931
|
mime = 'text/plain' + params;
|
|
2603
2932
|
}
|
|
2604
|
-
const buffer = encoding === 'base64' ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body), encoding);
|
|
2933
|
+
const buffer = encoding === 'base64' ? Buffer.from(body.replace(/%([\da-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))), 'base64') : Buffer.from(decodeURIComponent(body), encoding);
|
|
2605
2934
|
if (asBlob) {
|
|
2606
2935
|
if (!_Blob) {
|
|
2607
2936
|
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
@@ -2690,7 +3019,10 @@ class AxiosTransformStream extends stream.Transform {
|
|
|
2690
3019
|
const timeWindow = internals.timeWindow;
|
|
2691
3020
|
const divider = 1000 / timeWindow;
|
|
2692
3021
|
const bytesThreshold = maxRate / divider;
|
|
2693
|
-
|
|
3022
|
+
let minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
|
|
3023
|
+
if (maxRate) {
|
|
3024
|
+
minChunkSize = Math.min(bytesThreshold, minChunkSize);
|
|
3025
|
+
}
|
|
2694
3026
|
const pushChunk = (_chunk, _callback) => {
|
|
2695
3027
|
const bytes = Buffer.byteLength(_chunk);
|
|
2696
3028
|
internals.bytesSeen += bytes;
|
|
@@ -2706,6 +3038,9 @@ class AxiosTransformStream extends stream.Transform {
|
|
|
2706
3038
|
}
|
|
2707
3039
|
};
|
|
2708
3040
|
const transformChunk = (_chunk, _callback) => {
|
|
3041
|
+
if (this.destroyed) {
|
|
3042
|
+
return _callback();
|
|
3043
|
+
}
|
|
2709
3044
|
const chunkSize = Buffer.byteLength(_chunk);
|
|
2710
3045
|
let chunkRemainder = null;
|
|
2711
3046
|
let maxChunkSize = readableHighWaterMark;
|
|
@@ -2729,7 +3064,9 @@ class AxiosTransformStream extends stream.Transform {
|
|
|
2729
3064
|
}, timeWindow - passed);
|
|
2730
3065
|
}
|
|
2731
3066
|
if (bytesLeft < maxChunkSize) {
|
|
2732
|
-
|
|
3067
|
+
// A buffer boundary must consume at least one byte. Carry any
|
|
3068
|
+
// fractional allowance forward in the next accounting window.
|
|
3069
|
+
maxChunkSize = Math.max(1, Math.floor(bytesLeft));
|
|
2733
3070
|
}
|
|
2734
3071
|
}
|
|
2735
3072
|
if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
|
|
@@ -2770,8 +3107,8 @@ const readBlob = async function* (blob) {
|
|
|
2770
3107
|
|
|
2771
3108
|
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
|
2772
3109
|
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
|
|
2773
|
-
const CRLF = '\r\n';
|
|
2774
|
-
const CRLF_BYTES = textEncoder.encode(CRLF);
|
|
3110
|
+
const CRLF$1 = '\r\n';
|
|
3111
|
+
const CRLF_BYTES = textEncoder.encode(CRLF$1);
|
|
2775
3112
|
const CRLF_BYTES_COUNT = 2;
|
|
2776
3113
|
class FormDataPart {
|
|
2777
3114
|
constructor(name, value) {
|
|
@@ -2779,14 +3116,14 @@ class FormDataPart {
|
|
|
2779
3116
|
escapeName
|
|
2780
3117
|
} = this.constructor;
|
|
2781
3118
|
const isStringValue = utils$1.isString(value);
|
|
2782
|
-
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''}${CRLF}`;
|
|
3119
|
+
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''}${CRLF$1}`;
|
|
2783
3120
|
if (isStringValue) {
|
|
2784
|
-
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
|
|
3121
|
+
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF$1));
|
|
2785
3122
|
} else {
|
|
2786
3123
|
const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
2787
|
-
headers += `Content-Type: ${safeType}${CRLF}`;
|
|
3124
|
+
headers += `Content-Type: ${safeType}${CRLF$1}`;
|
|
2788
3125
|
}
|
|
2789
|
-
this.headers = textEncoder.encode(headers + CRLF);
|
|
3126
|
+
this.headers = textEncoder.encode(headers + CRLF$1);
|
|
2790
3127
|
this.contentLength = isStringValue ? value.byteLength : value.size;
|
|
2791
3128
|
this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
|
|
2792
3129
|
this.name = name;
|
|
@@ -2824,8 +3161,8 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
2824
3161
|
if (boundary.length < 1 || boundary.length > 70) {
|
|
2825
3162
|
throw new Error('boundary must be 1-70 characters long');
|
|
2826
3163
|
}
|
|
2827
|
-
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
2828
|
-
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
3164
|
+
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF$1);
|
|
3165
|
+
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF$1);
|
|
2829
3166
|
let contentLength = footerBytes.byteLength;
|
|
2830
3167
|
const parts = Array.from(form.entries()).map(([name, value]) => {
|
|
2831
3168
|
const part = new FormDataPart(name, value);
|
|
@@ -2877,7 +3214,7 @@ class Http2Sessions {
|
|
|
2877
3214
|
this.sessions = Object.create(null);
|
|
2878
3215
|
}
|
|
2879
3216
|
getSession(authority, options) {
|
|
2880
|
-
options = Object.assign({
|
|
3217
|
+
options = Object.assign(Object.create(null), {
|
|
2881
3218
|
sessionTimeout: 1000
|
|
2882
3219
|
}, options);
|
|
2883
3220
|
let authoritySessions = this.sessions[authority];
|
|
@@ -2933,7 +3270,7 @@ class Http2Sessions {
|
|
|
2933
3270
|
timer = null;
|
|
2934
3271
|
}
|
|
2935
3272
|
stream.once('close', () => {
|
|
2936
|
-
if (! --streamsCount) {
|
|
3273
|
+
if (! --streamsCount && !removed) {
|
|
2937
3274
|
timer = setTimeout(() => {
|
|
2938
3275
|
timer = null;
|
|
2939
3276
|
removeSession();
|
|
@@ -2944,6 +3281,8 @@ class Http2Sessions {
|
|
|
2944
3281
|
};
|
|
2945
3282
|
}
|
|
2946
3283
|
session.once('close', removeSession);
|
|
3284
|
+
session.once('error', removeSession);
|
|
3285
|
+
session.once('goaway', removeSession);
|
|
2947
3286
|
let entry = [session, options];
|
|
2948
3287
|
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
|
2949
3288
|
return session;
|
|
@@ -2964,6 +3303,13 @@ const callbackify = (fn, reducer) => {
|
|
|
2964
3303
|
};
|
|
2965
3304
|
|
|
2966
3305
|
const LOOPBACK_HOSTNAMES = new Set(['localhost', '0.0.0.0']);
|
|
3306
|
+
const trimTrailingDots = value => {
|
|
3307
|
+
let end = value.length;
|
|
3308
|
+
while (end && value.charCodeAt(end - 1) === 46) {
|
|
3309
|
+
end--;
|
|
3310
|
+
}
|
|
3311
|
+
return end === value.length ? value : value.slice(0, end);
|
|
3312
|
+
};
|
|
2967
3313
|
const isIPv4Loopback = host => {
|
|
2968
3314
|
const parts = host.split('.');
|
|
2969
3315
|
if (parts.length !== 4) return false;
|
|
@@ -3019,7 +3365,7 @@ const normalizeIPAddress = host => {
|
|
|
3019
3365
|
if (h.charAt(0) === '[' && h.charAt(h.length - 1) === ']') {
|
|
3020
3366
|
h = h.slice(1, -1);
|
|
3021
3367
|
}
|
|
3022
|
-
h = h
|
|
3368
|
+
h = trimTrailingDots(h);
|
|
3023
3369
|
|
|
3024
3370
|
// Allowed characters for any IPv4 shape: digits, dot, 'x', 'X', hex digits.
|
|
3025
3371
|
if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
|
|
@@ -3174,6 +3520,40 @@ const unmapIPv4MappedIPv6 = host => {
|
|
|
3174
3520
|
}
|
|
3175
3521
|
return host;
|
|
3176
3522
|
};
|
|
3523
|
+
const IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
|
|
3524
|
+
const ipv4ToBytes = host => {
|
|
3525
|
+
const parts = host.split('.');
|
|
3526
|
+
return parts.length === 4 && parts.every(part => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
|
|
3527
|
+
};
|
|
3528
|
+
const IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
|
|
3529
|
+
const ipv6ToBytes = host => {
|
|
3530
|
+
const halves = host.split('::');
|
|
3531
|
+
if (halves.length > 2) {
|
|
3532
|
+
return null;
|
|
3533
|
+
}
|
|
3534
|
+
const groups = halves[0] ? halves[0].split(':') : [];
|
|
3535
|
+
if (halves.length === 2) {
|
|
3536
|
+
const rear = halves[1] ? halves[1].split(':') : [];
|
|
3537
|
+
const missing = 8 - groups.length - rear.length;
|
|
3538
|
+
if (missing < 1) {
|
|
3539
|
+
return null;
|
|
3540
|
+
}
|
|
3541
|
+
groups.push(...new Array(missing).fill('0'), ...rear);
|
|
3542
|
+
}
|
|
3543
|
+
if (groups.length !== 8 || groups.some(group => !IPV6_GROUP_RE.test(group))) {
|
|
3544
|
+
return null;
|
|
3545
|
+
}
|
|
3546
|
+
return groups.flatMap(group => {
|
|
3547
|
+
const value = Number.parseInt(group, 16);
|
|
3548
|
+
return [value >> 8 & 0xff, value & 0xff];
|
|
3549
|
+
});
|
|
3550
|
+
};
|
|
3551
|
+
const ipToBytes = host => {
|
|
3552
|
+
if (typeof host !== 'string' || !host) {
|
|
3553
|
+
return null;
|
|
3554
|
+
}
|
|
3555
|
+
return host.indexOf(':') !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
|
|
3556
|
+
};
|
|
3177
3557
|
const normalizeNoProxyHost = hostname => {
|
|
3178
3558
|
if (!hostname) {
|
|
3179
3559
|
return hostname;
|
|
@@ -3181,7 +3561,20 @@ const normalizeNoProxyHost = hostname => {
|
|
|
3181
3561
|
if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
|
|
3182
3562
|
hostname = hostname.slice(1, -1);
|
|
3183
3563
|
}
|
|
3184
|
-
|
|
3564
|
+
let trimmed = trimTrailingDots(hostname);
|
|
3565
|
+
if (trimmed.indexOf(':') !== -1) {
|
|
3566
|
+
try {
|
|
3567
|
+
trimmed = new URL('http://[' + trimmed + ']/').hostname.slice(1, -1);
|
|
3568
|
+
} catch (_err) {
|
|
3569
|
+
return trimmed;
|
|
3570
|
+
}
|
|
3571
|
+
} else if (/[\u0080-\uffff]/.test(trimmed)) {
|
|
3572
|
+
const prefix = /^[*.]+/.exec(trimmed);
|
|
3573
|
+
const start = prefix ? prefix[0] : '';
|
|
3574
|
+
const ascii = url.domainToASCII(trimmed.slice(start.length));
|
|
3575
|
+
if (!ascii) return '';
|
|
3576
|
+
trimmed = start + trimTrailingDots(ascii);
|
|
3577
|
+
}
|
|
3185
3578
|
|
|
3186
3579
|
// IPv4 shorthand/octal/hex → dotted-decimal; helper is a no-op for inputs
|
|
3187
3580
|
// containing ':' (IPv6 and IPv4-mapped IPv6) so we fall through to unmap.
|
|
@@ -3191,6 +3584,92 @@ const normalizeNoProxyHost = hostname => {
|
|
|
3191
3584
|
}
|
|
3192
3585
|
return unmapIPv4MappedIPv6(trimmed);
|
|
3193
3586
|
};
|
|
3587
|
+
const normalizeCidrBase = input => {
|
|
3588
|
+
let base = input;
|
|
3589
|
+
const startsBracket = base.charAt(0) === '[';
|
|
3590
|
+
const endsBracket = base.charAt(base.length - 1) === ']';
|
|
3591
|
+
const hasBracket = base.includes('[') || base.includes(']');
|
|
3592
|
+
if (startsBracket || endsBracket) {
|
|
3593
|
+
if (!startsBracket || !endsBracket) {
|
|
3594
|
+
return null;
|
|
3595
|
+
}
|
|
3596
|
+
base = base.slice(1, -1);
|
|
3597
|
+
if (base.indexOf(':') === -1 || base.includes('[') || base.includes(']')) {
|
|
3598
|
+
return null;
|
|
3599
|
+
}
|
|
3600
|
+
} else if (hasBracket) {
|
|
3601
|
+
return null;
|
|
3602
|
+
}
|
|
3603
|
+
if (!base || base.charAt(base.length - 1) === '.') {
|
|
3604
|
+
return null;
|
|
3605
|
+
}
|
|
3606
|
+
const wasIPv6 = base.indexOf(':') !== -1;
|
|
3607
|
+
if (wasIPv6) {
|
|
3608
|
+
try {
|
|
3609
|
+
base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
|
|
3610
|
+
} catch (_err) {
|
|
3611
|
+
return null;
|
|
3612
|
+
}
|
|
3613
|
+
} else {
|
|
3614
|
+
base = normalizeIPAddress(base);
|
|
3615
|
+
if (!ipv4ToBytes(base)) {
|
|
3616
|
+
return null;
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
return {
|
|
3620
|
+
normalized: unmapIPv4MappedIPv6(base),
|
|
3621
|
+
wasIPv6
|
|
3622
|
+
};
|
|
3623
|
+
};
|
|
3624
|
+
const CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
|
|
3625
|
+
const parseCidrEntry = entry => {
|
|
3626
|
+
if (entry.indexOf('/') === -1) {
|
|
3627
|
+
return undefined;
|
|
3628
|
+
}
|
|
3629
|
+
const match = CIDR_ENTRY_RE.exec(entry);
|
|
3630
|
+
if (!match) {
|
|
3631
|
+
return null;
|
|
3632
|
+
}
|
|
3633
|
+
let prefix = Number(match[2]);
|
|
3634
|
+
const parsedBase = normalizeCidrBase(match[1]);
|
|
3635
|
+
if (!parsedBase) {
|
|
3636
|
+
return null;
|
|
3637
|
+
}
|
|
3638
|
+
const {
|
|
3639
|
+
normalized,
|
|
3640
|
+
wasIPv6
|
|
3641
|
+
} = parsedBase;
|
|
3642
|
+
if (wasIPv6 && normalized.indexOf(':') === -1) {
|
|
3643
|
+
if (prefix < 96) {
|
|
3644
|
+
return null;
|
|
3645
|
+
}
|
|
3646
|
+
prefix -= 96;
|
|
3647
|
+
}
|
|
3648
|
+
const bytes = ipToBytes(normalized);
|
|
3649
|
+
if (!bytes || prefix > bytes.length * 8) {
|
|
3650
|
+
return null;
|
|
3651
|
+
}
|
|
3652
|
+
return {
|
|
3653
|
+
bytes,
|
|
3654
|
+
prefix
|
|
3655
|
+
};
|
|
3656
|
+
};
|
|
3657
|
+
const isInSubnet = (addressBytes, networkBytes, prefix) => {
|
|
3658
|
+
const fullBytes = prefix >> 3;
|
|
3659
|
+
for (let i = 0; i < fullBytes; i++) {
|
|
3660
|
+
if (addressBytes[i] !== networkBytes[i]) {
|
|
3661
|
+
return false;
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
const remainingBits = prefix & 7;
|
|
3665
|
+
if (remainingBits) {
|
|
3666
|
+
const mask = 0xff << 8 - remainingBits & 0xff;
|
|
3667
|
+
if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
|
|
3668
|
+
return false;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
return true;
|
|
3672
|
+
};
|
|
3194
3673
|
function shouldBypassProxy(location) {
|
|
3195
3674
|
let parsed;
|
|
3196
3675
|
try {
|
|
@@ -3207,6 +3686,7 @@ function shouldBypassProxy(location) {
|
|
|
3207
3686
|
}
|
|
3208
3687
|
const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS[parsed.protocol.split(':', 1)[0]] || 0;
|
|
3209
3688
|
const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
|
|
3689
|
+
const hostnameBytes = ipToBytes(hostname);
|
|
3210
3690
|
return noProxy.split(/[\s,]+/).some(entry => {
|
|
3211
3691
|
if (!entry) {
|
|
3212
3692
|
return false;
|
|
@@ -3214,6 +3694,10 @@ function shouldBypassProxy(location) {
|
|
|
3214
3694
|
if (entry === '*') {
|
|
3215
3695
|
return true;
|
|
3216
3696
|
}
|
|
3697
|
+
const cidr = parseCidrEntry(entry);
|
|
3698
|
+
if (cidr !== undefined) {
|
|
3699
|
+
return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
|
|
3700
|
+
}
|
|
3217
3701
|
let [entryHost, entryPort] = parseNoProxyEntry(entry);
|
|
3218
3702
|
entryHost = normalizeNoProxyHost(entryHost);
|
|
3219
3703
|
if (!entryHost) {
|
|
@@ -3276,7 +3760,7 @@ function speedometer(samplesCount, min) {
|
|
|
3276
3760
|
* Throttle decorator
|
|
3277
3761
|
* @param {Function} fn
|
|
3278
3762
|
* @param {Number} freq
|
|
3279
|
-
* @return {Function}
|
|
3763
|
+
* @return {Array<Function>}
|
|
3280
3764
|
*/
|
|
3281
3765
|
function throttle(fn, freq) {
|
|
3282
3766
|
let timestamp = 0;
|
|
@@ -3308,14 +3792,15 @@ function throttle(fn, freq) {
|
|
|
3308
3792
|
}
|
|
3309
3793
|
};
|
|
3310
3794
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
3311
|
-
|
|
3795
|
+
const flushWith = (...args) => invoke(args);
|
|
3796
|
+
return [throttled, flush, flushWith];
|
|
3312
3797
|
}
|
|
3313
3798
|
|
|
3314
3799
|
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
3315
3800
|
let bytesNotified = 0;
|
|
3316
3801
|
const _speedometer = speedometer(50, 250);
|
|
3317
3802
|
return throttle(e => {
|
|
3318
|
-
if (!e ||
|
|
3803
|
+
if (!e || !utils$1.isNumber(e.loaded)) {
|
|
3319
3804
|
return;
|
|
3320
3805
|
}
|
|
3321
3806
|
const rawLoaded = e.loaded;
|
|
@@ -3352,7 +3837,7 @@ const asyncDecorator = (fn, scheduler = utils$1.asap) => (...args) => scheduler(
|
|
|
3352
3837
|
* Estimate data: URL byte lengths *without* allocating large buffers.
|
|
3353
3838
|
* - Fetch percent-decodes a base64 body before decoding it.
|
|
3354
3839
|
* - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
|
|
3355
|
-
*
|
|
3840
|
+
* percent-decoded body, including ignored characters and content after padding.
|
|
3356
3841
|
* - Non-base64 data is percent-decoded and then encoded as UTF-8.
|
|
3357
3842
|
*/
|
|
3358
3843
|
const isHexDigit = charCode => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
|
|
@@ -3392,6 +3877,27 @@ const estimateBase64BufferAllocation = body => {
|
|
|
3392
3877
|
}
|
|
3393
3878
|
return Math.floor((len - padding) * 3 / 4);
|
|
3394
3879
|
};
|
|
3880
|
+
const estimatePercentDecodedBase64BufferAllocation = body => {
|
|
3881
|
+
// Ordinary Base64 needs only its length and trailing padding.
|
|
3882
|
+
if (body.indexOf('%') === -1) {
|
|
3883
|
+
return estimateBase64BufferAllocation(body);
|
|
3884
|
+
}
|
|
3885
|
+
let length = 0;
|
|
3886
|
+
let previous = 0;
|
|
3887
|
+
let last = 0;
|
|
3888
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
3889
|
+
let code = body.charCodeAt(i);
|
|
3890
|
+
if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
3891
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
3892
|
+
i += 2;
|
|
3893
|
+
}
|
|
3894
|
+
length++;
|
|
3895
|
+
previous = last;
|
|
3896
|
+
last = code;
|
|
3897
|
+
}
|
|
3898
|
+
const padding = last === 61 ? previous === 61 ? 2 : 1 : 0;
|
|
3899
|
+
return Math.floor((length - padding) * 3 / 4);
|
|
3900
|
+
};
|
|
3395
3901
|
const estimatePercentDecodedBase64Bytes = body => {
|
|
3396
3902
|
const len = body.length;
|
|
3397
3903
|
let significant = 0;
|
|
@@ -3424,14 +3930,14 @@ const estimatePercentDecodedBase64Bytes = body => {
|
|
|
3424
3930
|
}
|
|
3425
3931
|
return base64Bytes(significant);
|
|
3426
3932
|
};
|
|
3427
|
-
const estimateDataURLBytes = (url, estimateBase64) => {
|
|
3933
|
+
const estimateDataURLBytes = (url, estimateBase64, base64Pattern) => {
|
|
3428
3934
|
if (!url || typeof url !== 'string') return 0;
|
|
3429
|
-
if (
|
|
3935
|
+
if (!/^data:/i.test(url)) return 0;
|
|
3430
3936
|
const comma = url.indexOf(',');
|
|
3431
3937
|
if (comma < 0) return 0;
|
|
3432
3938
|
const meta = url.slice(5, comma);
|
|
3433
3939
|
const body = url.slice(comma + 1);
|
|
3434
|
-
const isBase64 =
|
|
3940
|
+
const isBase64 = base64Pattern.test(meta);
|
|
3435
3941
|
if (isBase64) {
|
|
3436
3942
|
return estimateBase64(body);
|
|
3437
3943
|
}
|
|
@@ -3474,17 +3980,18 @@ const estimateDataURLBytes = (url, estimateBase64) => {
|
|
|
3474
3980
|
function estimateDataURLDecodedBytes(url) {
|
|
3475
3981
|
// Fetch removes URL fragments before processing a data: URL.
|
|
3476
3982
|
const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
|
|
3477
|
-
return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes);
|
|
3983
|
+
return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes, /; *base64[\t\n\f\r ]*$/i);
|
|
3478
3984
|
}
|
|
3479
3985
|
|
|
3480
3986
|
/**
|
|
3481
|
-
* Estimate the Buffer backing allocation used
|
|
3987
|
+
* Estimate the Buffer backing allocation used after Node's percent-decoding step.
|
|
3482
3988
|
*
|
|
3483
3989
|
* @param {string} url
|
|
3484
3990
|
* @returns {number}
|
|
3485
3991
|
*/
|
|
3486
3992
|
function estimateDataURLBufferAllocation(url) {
|
|
3487
|
-
|
|
3993
|
+
// Match fromDataURI's case-insensitive protocol and encoding suffix.
|
|
3994
|
+
return estimateDataURLBytes(url, estimatePercentDecodedBase64BufferAllocation, /;base64$/i);
|
|
3488
3995
|
}
|
|
3489
3996
|
|
|
3490
3997
|
const zlibOptions = {
|
|
@@ -3515,6 +4022,15 @@ const isHttps = /https:?/;
|
|
|
3515
4022
|
const kAxiosSocketListener = Symbol('axios.http.socketListener');
|
|
3516
4023
|
const kAxiosCurrentReq = Symbol('axios.http.currentReq');
|
|
3517
4024
|
|
|
4025
|
+
// A shared listener avoids retaining an adapter context for the lifetime of a
|
|
4026
|
+
// pooled socket. EventEmitter invokes listeners with `this` set to the emitter.
|
|
4027
|
+
function handleSocketError(err) {
|
|
4028
|
+
const current = this[kAxiosCurrentReq];
|
|
4029
|
+
if (current && !current.destroyed) {
|
|
4030
|
+
current.destroy(err);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
|
|
3518
4034
|
// Tags HttpsProxyAgent instances installed by setProxy() so the redirect path
|
|
3519
4035
|
// can strip them without clobbering a user-supplied agent that happens to be
|
|
3520
4036
|
// an HttpsProxyAgent.
|
|
@@ -3526,6 +4042,9 @@ const kAxiosInstalledTunnel = Symbol('axios.http.installedTunnel');
|
|
|
3526
4042
|
// so unbounded growth is not a concern in practice.
|
|
3527
4043
|
const tunnelingAgentCache = new Map();
|
|
3528
4044
|
const tunnelingAgentCacheUser = new WeakMap();
|
|
4045
|
+
const directAgents = new WeakMap();
|
|
4046
|
+
const directAgentHooks = ['createConnection', 'getName'];
|
|
4047
|
+
const nativeAgentPoolHooks = ['addRequest', 'createSocket', 'removeSocket', 'keepSocketAlive', 'reuseSocket', '_getSession', '_cacheSession', '_evictSession'];
|
|
3529
4048
|
// Minimum minor versions where Node's HTTP Agent supports native proxyEnv
|
|
3530
4049
|
// handling. Checking the selected agent below also covers startup modes such
|
|
3531
4050
|
// as NODE_OPTIONS=--use-env-proxy and --no-use-env-proxy precedence.
|
|
@@ -3556,32 +4075,88 @@ function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.
|
|
|
3556
4075
|
function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
|
|
3557
4076
|
return isHttps.test(options.protocol) ? configHttpsAgent || https.globalAgent : configHttpAgent || http.globalAgent;
|
|
3558
4077
|
}
|
|
4078
|
+
function getDirectAgent(configuredAgent, transport) {
|
|
4079
|
+
if (!process.allowedNodeEnvironmentFlags || !process.allowedNodeEnvironmentFlags.has('--use-env-proxy')) {
|
|
4080
|
+
return configuredAgent;
|
|
4081
|
+
}
|
|
4082
|
+
const agent = configuredAgent || transport.globalAgent;
|
|
4083
|
+
const options = agent && agent.options;
|
|
4084
|
+
if (!(agent instanceof transport.Agent) || agent.protocol !== transport.globalAgent.protocol || !options || !utils$1.hasOwnProp(options, 'proxyEnv') || typeof options.proxyEnv !== 'object' || options.proxyEnv === null) {
|
|
4085
|
+
return configuredAgent;
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
// These hooks own pool queues or TLS session state. Neither binding them to
|
|
4089
|
+
// the source agent nor copying them without subclass state preserves their
|
|
4090
|
+
// behavior on a separate direct pool.
|
|
4091
|
+
for (const hook of nativeAgentPoolHooks) {
|
|
4092
|
+
if (utils$1.isFunction(transport.Agent.prototype[hook]) && agent[hook] !== transport.Agent.prototype[hook]) {
|
|
4093
|
+
throw new AxiosError('proxy: false cannot adapt an agent overriding ' + hook + '; use an agent constructed without proxyEnv', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
// Node snapshots proxyEnv when constructing the agent. Keep this check
|
|
4098
|
+
// conservative even when the caller later removes protocol-specific entries.
|
|
4099
|
+
let direct = directAgents.get(agent);
|
|
4100
|
+
if (!direct) {
|
|
4101
|
+
direct = new transport.Agent({
|
|
4102
|
+
...options,
|
|
4103
|
+
proxyEnv: undefined
|
|
4104
|
+
});
|
|
4105
|
+
|
|
4106
|
+
// Agent.destroy() does not emit an event. Keep the associated pool under
|
|
4107
|
+
// the configured agent's lifetime, including agents reused after destroy().
|
|
4108
|
+
const destroy = agent.destroy;
|
|
4109
|
+
agent.destroy = function destroyWithDirectAgent() {
|
|
4110
|
+
try {
|
|
4111
|
+
return destroy.apply(this, arguments);
|
|
4112
|
+
} finally {
|
|
4113
|
+
direct.destroy();
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
directAgents.set(agent, direct);
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
// Connections and pool keys do not own the direct pool's queues. Preserve
|
|
4120
|
+
// their configured receiver and refresh hooks that change between requests.
|
|
4121
|
+
for (const hook of directAgentHooks) {
|
|
4122
|
+
direct[hook] = agent[hook] === transport.Agent.prototype[hook] ? transport.Agent.prototype[hook] : bind(agent[hook], agent);
|
|
4123
|
+
}
|
|
4124
|
+
return direct;
|
|
4125
|
+
}
|
|
4126
|
+
function setDirectAgent(options, configHttpAgent, configHttpsAgent) {
|
|
4127
|
+
const secure = isHttps.test(options.protocol);
|
|
4128
|
+
const agent = getDirectAgent(secure ? configHttpsAgent : configHttpAgent, secure ? https : http);
|
|
4129
|
+
options.agent = agent;
|
|
4130
|
+
if (options.agents) {
|
|
4131
|
+
options.agents[secure ? 'https' : 'http'] = agent;
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
3559
4134
|
function getTunnelingAgent(agentOptions, userHttpsAgent) {
|
|
3560
4135
|
const key = agentOptions.protocol + '//' + agentOptions.hostname + ':' + (agentOptions.port || '') + '#' + (agentOptions.auth || '');
|
|
3561
4136
|
const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, new Map()).get(userHttpsAgent) : tunnelingAgentCache;
|
|
3562
4137
|
let agent = cache.get(key);
|
|
3563
4138
|
if (agent) return agent;
|
|
3564
|
-
//
|
|
3565
|
-
//
|
|
3566
|
-
//
|
|
4139
|
+
// Preserve per-request TLS options for the proxy connection, with our proxy
|
|
4140
|
+
// fields taking precedence. Global-agent options belong only to the origin
|
|
4141
|
+
// TLS upgrade in the callback below.
|
|
3567
4142
|
const merged = userHttpsAgent && userHttpsAgent.options ? {
|
|
3568
4143
|
...userHttpsAgent.options,
|
|
3569
4144
|
...agentOptions
|
|
3570
4145
|
} : agentOptions;
|
|
3571
4146
|
agent = new HttpsProxyAgent(merged);
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
};
|
|
3584
|
-
}
|
|
4147
|
+
const callback = agent.callback;
|
|
4148
|
+
agent.callback = function axiosTunnelingAgentCallback(req, opts) {
|
|
4149
|
+
// Without a proxy the origin TLS connection would be made by https.globalAgent,
|
|
4150
|
+
// so its options have to reach the tunneled origin too. Resolved per request
|
|
4151
|
+
// because the tunneling agent outlives any one of them.
|
|
4152
|
+
const originTLSAgent = userHttpsAgent || https.globalAgent;
|
|
4153
|
+
const originTLSOptions = originTLSAgent && originTLSAgent.options;
|
|
4154
|
+
// HttpsProxyAgent v5 reads callback opts for the post-CONNECT origin TLS upgrade.
|
|
4155
|
+
return callback.call(this, req, {
|
|
4156
|
+
...originTLSOptions,
|
|
4157
|
+
...opts
|
|
4158
|
+
});
|
|
4159
|
+
};
|
|
3585
4160
|
agent[kAxiosInstalledTunnel] = true;
|
|
3586
4161
|
cache.set(key, agent);
|
|
3587
4162
|
return agent;
|
|
@@ -3619,6 +4194,10 @@ const http2Sessions = new Http2Sessions();
|
|
|
3619
4194
|
* @returns {Object<string, any>}
|
|
3620
4195
|
*/
|
|
3621
4196
|
function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
|
|
4197
|
+
if (!isSameOriginRedirect(options, requestDetails)) {
|
|
4198
|
+
stripMatchingHeaders(options.headers, new Set(['authorization', 'cookie']));
|
|
4199
|
+
delete options.auth;
|
|
4200
|
+
}
|
|
3622
4201
|
if (options.beforeRedirects.proxy) {
|
|
3623
4202
|
options.beforeRedirects.proxy(options);
|
|
3624
4203
|
}
|
|
@@ -3628,6 +4207,9 @@ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
|
|
|
3628
4207
|
if (options.beforeRedirects.sensitiveHeaders) {
|
|
3629
4208
|
options.beforeRedirects.sensitiveHeaders(options, requestDetails);
|
|
3630
4209
|
}
|
|
4210
|
+
if (options.beforeRedirects.direct) {
|
|
4211
|
+
options.beforeRedirects.direct(options);
|
|
4212
|
+
}
|
|
3631
4213
|
if (options.beforeRedirects.config) {
|
|
3632
4214
|
options.beforeRedirects.config(options, responseDetails, requestDetails);
|
|
3633
4215
|
}
|
|
@@ -3660,13 +4242,14 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
|
|
|
3660
4242
|
* @param {http.ClientRequestArgs} options
|
|
3661
4243
|
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
|
|
3662
4244
|
* @param {string} location
|
|
4245
|
+
* @param {boolean} [allowEnvProxy=true] whether environment proxy configuration can be used
|
|
3663
4246
|
*
|
|
3664
|
-
* @returns {
|
|
4247
|
+
* @returns {boolean} whether a proxy applies to the selected transport
|
|
3665
4248
|
*/
|
|
3666
|
-
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
|
|
4249
|
+
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
|
|
3667
4250
|
let proxy = configProxy;
|
|
3668
4251
|
const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
|
|
3669
|
-
if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
4252
|
+
if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
3670
4253
|
const proxyUrl = getProxyForUrl(location);
|
|
3671
4254
|
if (proxyUrl) {
|
|
3672
4255
|
if (!shouldBypassProxy(location)) {
|
|
@@ -3692,6 +4275,9 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
|
|
|
3692
4275
|
if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
|
|
3693
4276
|
options.agent = undefined;
|
|
3694
4277
|
}
|
|
4278
|
+
if (isRedirect && options.agents && options.agents.https && options.agents.https[kAxiosInstalledTunnel]) {
|
|
4279
|
+
options.agents.https = configHttpsAgent;
|
|
4280
|
+
}
|
|
3695
4281
|
if (proxy) {
|
|
3696
4282
|
// Read proxy fields without traversing the prototype chain. URL instances expose
|
|
3697
4283
|
// username/password/hostname/host/port/protocol via getters on URL.prototype (so
|
|
@@ -3801,8 +4387,9 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
|
|
|
3801
4387
|
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
|
3802
4388
|
// Configure proxy for redirected request, passing the original config proxy to apply
|
|
3803
4389
|
// the exact same logic as if the redirected request was performed by axios directly.
|
|
3804
|
-
setProxy(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent);
|
|
4390
|
+
setProxy(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent, allowEnvProxy);
|
|
3805
4391
|
};
|
|
4392
|
+
return Boolean(proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent));
|
|
3806
4393
|
}
|
|
3807
4394
|
const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process';
|
|
3808
4395
|
|
|
@@ -3833,7 +4420,7 @@ const resolveFamily = ({
|
|
|
3833
4420
|
family
|
|
3834
4421
|
}) => {
|
|
3835
4422
|
if (!utils$1.isString(address)) {
|
|
3836
|
-
throw
|
|
4423
|
+
throw new AxiosError('address must be a string', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
3837
4424
|
}
|
|
3838
4425
|
return {
|
|
3839
4426
|
address,
|
|
@@ -3844,6 +4431,32 @@ const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(ad
|
|
|
3844
4431
|
address,
|
|
3845
4432
|
family
|
|
3846
4433
|
});
|
|
4434
|
+
const normalizedLookupCache = new WeakMap();
|
|
4435
|
+
const normalizeLookup = lookup => {
|
|
4436
|
+
let normalized = normalizedLookupCache.get(lookup);
|
|
4437
|
+
if (normalized) {
|
|
4438
|
+
return normalized;
|
|
4439
|
+
}
|
|
4440
|
+
const callbackLookup = callbackify(lookup, value => utils$1.isArray(value) ? value : [value]);
|
|
4441
|
+
|
|
4442
|
+
// Support opt.all, which is required by current Node.js releases.
|
|
4443
|
+
normalized = (hostname, opt, cb) => {
|
|
4444
|
+
callbackLookup(hostname, opt, (err, arg0, arg1) => {
|
|
4445
|
+
if (err) {
|
|
4446
|
+
return cb(err);
|
|
4447
|
+
}
|
|
4448
|
+
let addresses;
|
|
4449
|
+
try {
|
|
4450
|
+
addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
4451
|
+
} catch (error) {
|
|
4452
|
+
return cb(error);
|
|
4453
|
+
}
|
|
4454
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
4455
|
+
});
|
|
4456
|
+
};
|
|
4457
|
+
normalizedLookupCache.set(lookup, normalized);
|
|
4458
|
+
return normalized;
|
|
4459
|
+
};
|
|
3847
4460
|
const http2Transport = {
|
|
3848
4461
|
request(options, cb) {
|
|
3849
4462
|
const authority = options.protocol + '//' + options.hostname + ':' + (options.port || (options.protocol === 'https:' ? 443 : 80));
|
|
@@ -3896,10 +4509,11 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3896
4509
|
let family = own('family');
|
|
3897
4510
|
let httpVersion = own('httpVersion');
|
|
3898
4511
|
if (httpVersion === undefined) httpVersion = 1;
|
|
4512
|
+
const rawHttpVersion = httpVersion;
|
|
3899
4513
|
let http2Options = own('http2Options');
|
|
4514
|
+
const configProxy = own('proxy');
|
|
3900
4515
|
const httpAgent = own('httpAgent');
|
|
3901
4516
|
const httpsAgent = own('httpsAgent');
|
|
3902
|
-
const configProxy = own('proxy');
|
|
3903
4517
|
const responseType = own('responseType');
|
|
3904
4518
|
const responseEncoding = own('responseEncoding');
|
|
3905
4519
|
const socketPath = own('socketPath');
|
|
@@ -3912,26 +4526,20 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3912
4526
|
let rejected = false;
|
|
3913
4527
|
let req;
|
|
3914
4528
|
let connectPhaseTimer;
|
|
3915
|
-
|
|
4529
|
+
try {
|
|
4530
|
+
httpVersion = +httpVersion;
|
|
4531
|
+
} catch (err) {
|
|
4532
|
+
throw new AxiosError('Invalid protocol version: value is not a number', AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
4533
|
+
}
|
|
3916
4534
|
if (Number.isNaN(httpVersion)) {
|
|
3917
|
-
throw
|
|
4535
|
+
throw new AxiosError(`Invalid protocol version: '${rawHttpVersion}' is not a number`, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
3918
4536
|
}
|
|
3919
4537
|
if (httpVersion !== 1 && httpVersion !== 2) {
|
|
3920
|
-
throw
|
|
4538
|
+
throw new AxiosError(`Unsupported protocol version '${httpVersion}'`, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
3921
4539
|
}
|
|
3922
4540
|
const isHttp2 = httpVersion === 2;
|
|
3923
4541
|
if (lookup) {
|
|
3924
|
-
|
|
3925
|
-
// hotfix to support opt.all option which is required for node 20.x
|
|
3926
|
-
lookup = (hostname, opt, cb) => {
|
|
3927
|
-
_lookup(hostname, opt, (err, arg0, arg1) => {
|
|
3928
|
-
if (err) {
|
|
3929
|
-
return cb(err);
|
|
3930
|
-
}
|
|
3931
|
-
const addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
3932
|
-
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
3933
|
-
});
|
|
3934
|
-
};
|
|
4542
|
+
lookup = normalizeLookup(lookup);
|
|
3935
4543
|
}
|
|
3936
4544
|
const abortEmitter = new events.EventEmitter();
|
|
3937
4545
|
function abort(reason) {
|
|
@@ -4029,6 +4637,11 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4029
4637
|
} catch (err) {
|
|
4030
4638
|
throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
|
|
4031
4639
|
}
|
|
4640
|
+
|
|
4641
|
+
// Check bytes before converting the result to text or a stream.
|
|
4642
|
+
if (maxContentLength > -1 && (responseType === 'blob' ? convertedData.size : convertedData.length) > maxContentLength) {
|
|
4643
|
+
return reject(new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config));
|
|
4644
|
+
}
|
|
4032
4645
|
if (responseType === 'text') {
|
|
4033
4646
|
convertedData = convertedData.toString(responseEncoding);
|
|
4034
4647
|
if (!responseEncoding || responseEncoding === 'utf8') {
|
|
@@ -4144,6 +4757,11 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4144
4757
|
}));
|
|
4145
4758
|
}
|
|
4146
4759
|
headers.set('Accept-Encoding', utils$1.hasOwnProp(transitional, 'advertiseZstdAcceptEncoding') && transitional.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING, false);
|
|
4760
|
+
if (isHttp2 && lookup) {
|
|
4761
|
+
http2Options = Object.assign(Object.create(null), http2Options, {
|
|
4762
|
+
lookup
|
|
4763
|
+
});
|
|
4764
|
+
}
|
|
4147
4765
|
|
|
4148
4766
|
// Null-prototype to block prototype pollution gadgets on properties read
|
|
4149
4767
|
// directly by Node's http.request (e.g. insecureHTTPParser, lookup).
|
|
@@ -4160,11 +4778,13 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4160
4778
|
family,
|
|
4161
4779
|
beforeRedirect: dispatchBeforeRedirect,
|
|
4162
4780
|
beforeRedirects: Object.create(null),
|
|
4163
|
-
http2Options
|
|
4781
|
+
http2Options,
|
|
4782
|
+
createConnection: undefined
|
|
4164
4783
|
});
|
|
4165
4784
|
|
|
4166
4785
|
// cacheable-lookup integration hotfix
|
|
4167
4786
|
!utils$1.isUndefined(lookup) && (options.lookup = lookup);
|
|
4787
|
+
let proxyApplied = false;
|
|
4168
4788
|
if (socketPath) {
|
|
4169
4789
|
if (typeof socketPath !== 'string') {
|
|
4170
4790
|
return reject(new AxiosError('socketPath must be a string', AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
@@ -4182,22 +4802,29 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4182
4802
|
} else {
|
|
4183
4803
|
options.hostname = parsed.hostname.startsWith('[') ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
4184
4804
|
options.port = parsed.port;
|
|
4185
|
-
setProxy(options, configProxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path, false, httpsAgent, httpAgent
|
|
4805
|
+
proxyApplied = setProxy(options, configProxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path, false, httpsAgent, httpAgent,
|
|
4806
|
+
// The HTTP/2 transport connects independently of HTTP/1 agents, so it
|
|
4807
|
+
// cannot apply either axios-resolved or agent-local environment proxies.
|
|
4808
|
+
// Explicit proxy config is still processed and rejected below.
|
|
4809
|
+
!isHttp2);
|
|
4186
4810
|
}
|
|
4187
4811
|
let transport;
|
|
4188
4812
|
let isNativeTransport = false;
|
|
4189
|
-
// True only for the follow-redirects transport, which applies
|
|
4190
|
-
// options.maxBodyLength itself. Every other transport (http2, native
|
|
4191
|
-
// http/https, a user-supplied custom transport) needs the explicit
|
|
4192
|
-
// byte-counting pipeline below to enforce maxBodyLength on streamed uploads.
|
|
4193
|
-
let transportEnforcesMaxBodyLength = false;
|
|
4194
4813
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
4195
4814
|
// Don't clobber a CONNECT-tunneling agent installed by setProxy() for an
|
|
4196
4815
|
// HTTPS target.
|
|
4197
|
-
if (
|
|
4816
|
+
if (!isHttp2 && configProxy === false) {
|
|
4817
|
+
setDirectAgent(options, httpAgent, httpsAgent);
|
|
4818
|
+
options.beforeRedirects.direct = redirectOptions => {
|
|
4819
|
+
setDirectAgent(redirectOptions, httpAgent, httpsAgent);
|
|
4820
|
+
};
|
|
4821
|
+
} else if (options.agent == null) {
|
|
4198
4822
|
options.agent = isHttpsRequest ? httpsAgent : httpAgent;
|
|
4199
4823
|
}
|
|
4200
4824
|
if (isHttp2) {
|
|
4825
|
+
if (proxyApplied) {
|
|
4826
|
+
return reject(new AxiosError('HTTP/2 requests with a proxy are not supported', AxiosError.ERR_NOT_SUPPORT, config));
|
|
4827
|
+
}
|
|
4201
4828
|
transport = http2Transport;
|
|
4202
4829
|
} else {
|
|
4203
4830
|
const configTransport = own('transport');
|
|
@@ -4207,7 +4834,6 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4207
4834
|
transport = isHttpsRequest ? https : http;
|
|
4208
4835
|
isNativeTransport = true;
|
|
4209
4836
|
} else {
|
|
4210
|
-
transportEnforcesMaxBodyLength = true;
|
|
4211
4837
|
options.sensitiveHeaders = [];
|
|
4212
4838
|
if (maxRedirects) {
|
|
4213
4839
|
options.maxRedirects = maxRedirects;
|
|
@@ -4445,18 +5071,10 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4445
5071
|
socket.setKeepAlive(true, 1000 * 60);
|
|
4446
5072
|
}
|
|
4447
5073
|
|
|
4448
|
-
// Install
|
|
4449
|
-
//
|
|
4450
|
-
// to new requests before the previous request's 'close' fires (issue #10780).
|
|
4451
|
-
// The listener is bound to the socket's currently-active request via a
|
|
4452
|
-
// symbol, which is swapped as the socket is reassigned.
|
|
5074
|
+
// Install one shared 'error' listener per socket. The symbol follows the
|
|
5075
|
+
// currently-active request as pooled sockets are reassigned (issue #10780).
|
|
4453
5076
|
if (!socket[kAxiosSocketListener]) {
|
|
4454
|
-
socket.on('error',
|
|
4455
|
-
const current = socket[kAxiosCurrentReq];
|
|
4456
|
-
if (current && !current.destroyed) {
|
|
4457
|
-
current.destroy(err);
|
|
4458
|
-
}
|
|
4459
|
-
});
|
|
5077
|
+
socket.on('error', handleSocketError);
|
|
4460
5078
|
socket[kAxiosSocketListener] = true;
|
|
4461
5079
|
}
|
|
4462
5080
|
socket[kAxiosCurrentReq] = req;
|
|
@@ -4519,12 +5137,10 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4519
5137
|
}
|
|
4520
5138
|
});
|
|
4521
5139
|
|
|
4522
|
-
//
|
|
4523
|
-
//
|
|
4524
|
-
// and user-supplied custom transports). The follow-redirects transport
|
|
4525
|
-
// enforces it on the redirected HTTP/1 path.
|
|
5140
|
+
// Transform decodes string chunks to Buffers before counting, so every
|
|
5141
|
+
// transport receives at most maxBodyLength encoded bytes.
|
|
4526
5142
|
let uploadStream = data;
|
|
4527
|
-
if (maxBodyLength > -1
|
|
5143
|
+
if (maxBodyLength > -1) {
|
|
4528
5144
|
const limit = maxBodyLength;
|
|
4529
5145
|
let bytesSent = 0;
|
|
4530
5146
|
uploadStream = stream.pipeline([data, new stream.Transform({
|
|
@@ -4548,11 +5164,13 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
4548
5164
|
});
|
|
4549
5165
|
};
|
|
4550
5166
|
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
}
|
|
4555
|
-
|
|
5167
|
+
const decodeCookieValue = value => {
|
|
5168
|
+
try {
|
|
5169
|
+
return decodeURIComponent(value);
|
|
5170
|
+
} catch (e) {
|
|
5171
|
+
return value;
|
|
5172
|
+
}
|
|
5173
|
+
};
|
|
4556
5174
|
var cookies = platform.hasStandardBrowserEnv ?
|
|
4557
5175
|
// Standard browser envs support document.cookie
|
|
4558
5176
|
{
|
|
@@ -4578,25 +5196,36 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
4578
5196
|
},
|
|
4579
5197
|
read(name) {
|
|
4580
5198
|
if (typeof document === 'undefined') return null;
|
|
5199
|
+
const cookieString = document.cookie;
|
|
5200
|
+
if (!cookieString) return null;
|
|
4581
5201
|
// Match name=value by splitting on the semicolon separator instead of building a
|
|
4582
5202
|
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
4583
5203
|
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
4584
5204
|
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
4585
5205
|
// "; ", so ignore optional whitespace before each cookie name.
|
|
4586
|
-
const cookies =
|
|
5206
|
+
const cookies = cookieString.split(';');
|
|
4587
5207
|
for (let i = 0; i < cookies.length; i++) {
|
|
4588
5208
|
const cookie = cookies[i].replace(/^\s+/, '');
|
|
4589
5209
|
const eq = cookie.indexOf('=');
|
|
4590
5210
|
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
4591
|
-
|
|
4592
|
-
return decodeURIComponent(cookie.slice(eq + 1));
|
|
4593
|
-
} catch (e) {
|
|
4594
|
-
return cookie.slice(eq + 1);
|
|
4595
|
-
}
|
|
5211
|
+
return decodeCookieValue(cookie.slice(eq + 1));
|
|
4596
5212
|
}
|
|
4597
5213
|
}
|
|
4598
5214
|
return null;
|
|
4599
5215
|
},
|
|
5216
|
+
async readAsync(name) {
|
|
5217
|
+
try {
|
|
5218
|
+
const store = typeof window !== 'undefined' && window.cookieStore;
|
|
5219
|
+
if (store && utils$1.isFunction(store.get)) {
|
|
5220
|
+
const cookie = await store.get(name);
|
|
5221
|
+
// Both APIs expose stored bytes; preserve Axios's existing URI decoding.
|
|
5222
|
+
return cookie ? decodeCookieValue(cookie.value) : null;
|
|
5223
|
+
}
|
|
5224
|
+
} catch (e) {
|
|
5225
|
+
// Restricted or unavailable storage retains the synchronous fallback.
|
|
5226
|
+
}
|
|
5227
|
+
return this.read(name);
|
|
5228
|
+
},
|
|
4600
5229
|
remove(name) {
|
|
4601
5230
|
this.write(name, '', Date.now() - 86400000, '/');
|
|
4602
5231
|
}
|
|
@@ -4607,19 +5236,242 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
4607
5236
|
read() {
|
|
4608
5237
|
return null;
|
|
4609
5238
|
},
|
|
5239
|
+
async readAsync() {
|
|
5240
|
+
return null;
|
|
5241
|
+
},
|
|
4610
5242
|
remove() {}
|
|
4611
5243
|
};
|
|
4612
5244
|
|
|
5245
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv ? (origin => url => {
|
|
5246
|
+
url = new URL(url, document.baseURI || platform.origin);
|
|
5247
|
+
return origin.protocol === url.protocol && origin.host === url.host && origin.port === url.port;
|
|
5248
|
+
})(new URL(platform.origin)) : () => true;
|
|
5249
|
+
|
|
5250
|
+
function assertParamsAcyclic(params) {
|
|
5251
|
+
const pending = [{
|
|
5252
|
+
value: params
|
|
5253
|
+
}];
|
|
5254
|
+
const active = new WeakSet();
|
|
5255
|
+
const visited = new WeakSet();
|
|
5256
|
+
while (pending.length) {
|
|
5257
|
+
const {
|
|
5258
|
+
value,
|
|
5259
|
+
done
|
|
5260
|
+
} = pending.pop();
|
|
5261
|
+
if (!utils$1.isPlainObject(value) && !utils$1.isArray(value)) continue;
|
|
5262
|
+
if (done) {
|
|
5263
|
+
active.delete(value);
|
|
5264
|
+
continue;
|
|
5265
|
+
}
|
|
5266
|
+
if (active.has(value)) {
|
|
5267
|
+
throw new AxiosError('Circular reference detected in params', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
5268
|
+
}
|
|
5269
|
+
if (visited.has(value)) continue;
|
|
5270
|
+
visited.add(value);
|
|
5271
|
+
active.add(value);
|
|
5272
|
+
pending.push({
|
|
5273
|
+
value,
|
|
5274
|
+
done: true
|
|
5275
|
+
});
|
|
5276
|
+
const keys = Object.keys(value);
|
|
5277
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
5278
|
+
Object.getOwnPropertySymbols(value).forEach(key => {
|
|
5279
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
5280
|
+
if (descriptor && descriptor.enumerable) keys.push(key);
|
|
5281
|
+
});
|
|
5282
|
+
}
|
|
5283
|
+
// Shallow array elements retain fields filtered during plain-object merges.
|
|
5284
|
+
// Inspect reserved data properties without evaluating their accessors.
|
|
5285
|
+
keys.forEach(key => {
|
|
5286
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
5287
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
5288
|
+
if (descriptor && utils$1.hasOwnProp(descriptor, 'value')) {
|
|
5289
|
+
pending.push({
|
|
5290
|
+
value: descriptor.value
|
|
5291
|
+
});
|
|
5292
|
+
}
|
|
5293
|
+
} else {
|
|
5294
|
+
pending.push({
|
|
5295
|
+
value: value[key]
|
|
5296
|
+
});
|
|
5297
|
+
}
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
|
|
4613
5302
|
const headersToObject = thing => thing instanceof AxiosHeaders ? {
|
|
4614
5303
|
...thing
|
|
4615
5304
|
} : thing;
|
|
4616
5305
|
const ownEnumerableKeys = thing => {
|
|
4617
5306
|
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
4618
|
-
return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(symbol =>
|
|
5307
|
+
return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(symbol => {
|
|
5308
|
+
const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
|
|
5309
|
+
return descriptor && descriptor.enumerable;
|
|
5310
|
+
}));
|
|
4619
5311
|
}
|
|
4620
5312
|
return Object.keys(thing);
|
|
4621
5313
|
};
|
|
4622
5314
|
|
|
5315
|
+
// Copy params without recursive merges so the serializer remains responsible
|
|
5316
|
+
// for its depth policy. Only visit defaults that contribute to the result.
|
|
5317
|
+
function mergeParams(a, b) {
|
|
5318
|
+
const pending = [];
|
|
5319
|
+
const copies = new WeakMap();
|
|
5320
|
+
const empty = {};
|
|
5321
|
+
function copy(target, source) {
|
|
5322
|
+
if (!utils$1.isPlainObject(source)) {
|
|
5323
|
+
return utils$1.isArray(source) ? source.slice() : source;
|
|
5324
|
+
}
|
|
5325
|
+
const base = utils$1.isPlainObject(target) ? target : empty;
|
|
5326
|
+
let bases = copies.get(source);
|
|
5327
|
+
if (!bases) {
|
|
5328
|
+
bases = new WeakMap();
|
|
5329
|
+
copies.set(source, bases);
|
|
5330
|
+
}
|
|
5331
|
+
if (bases.has(base)) return bases.get(base);
|
|
5332
|
+
const result = {};
|
|
5333
|
+
bases.set(base, result);
|
|
5334
|
+
pending.push({
|
|
5335
|
+
base,
|
|
5336
|
+
source,
|
|
5337
|
+
result
|
|
5338
|
+
});
|
|
5339
|
+
return result;
|
|
5340
|
+
}
|
|
5341
|
+
const result = utils$1.isUndefined(b) ? copy(undefined, a) : copy(a, b);
|
|
5342
|
+
while (pending.length) {
|
|
5343
|
+
const {
|
|
5344
|
+
base,
|
|
5345
|
+
source,
|
|
5346
|
+
result: target
|
|
5347
|
+
} = pending.pop();
|
|
5348
|
+
const baseKeys = new Set(ownEnumerableKeys(base));
|
|
5349
|
+
const sourceKeys = new Set(ownEnumerableKeys(source));
|
|
5350
|
+
const keys = new Set([...baseKeys, ...sourceKeys]);
|
|
5351
|
+
keys.forEach(key => {
|
|
5352
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
|
|
5353
|
+
const hasSource = sourceKeys.has(key);
|
|
5354
|
+
const value = hasSource ? source[key] : undefined;
|
|
5355
|
+
const previous = (!hasSource || utils$1.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
|
|
5356
|
+
target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
|
|
5357
|
+
});
|
|
5358
|
+
}
|
|
5359
|
+
assertParamsAcyclic(result);
|
|
5360
|
+
return result;
|
|
5361
|
+
}
|
|
5362
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
5363
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
5364
|
+
return utils$1.merge.call({
|
|
5365
|
+
caseless
|
|
5366
|
+
}, target, source);
|
|
5367
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
5368
|
+
return utils$1.merge({}, source);
|
|
5369
|
+
} else if (utils$1.isArray(source)) {
|
|
5370
|
+
return source.slice();
|
|
5371
|
+
}
|
|
5372
|
+
return source;
|
|
5373
|
+
}
|
|
5374
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
5375
|
+
if (!utils$1.isUndefined(b)) {
|
|
5376
|
+
return getMergedValue(a, b, prop, caseless);
|
|
5377
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
5378
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
5379
|
+
}
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
// eslint-disable-next-line consistent-return
|
|
5383
|
+
function valueFromConfig2(a, b) {
|
|
5384
|
+
if (!utils$1.isUndefined(b)) {
|
|
5385
|
+
return getMergedValue(undefined, b);
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
|
|
5389
|
+
// eslint-disable-next-line consistent-return
|
|
5390
|
+
function defaultToConfig2(a, b) {
|
|
5391
|
+
if (!utils$1.isUndefined(b)) {
|
|
5392
|
+
return getMergedValue(undefined, b);
|
|
5393
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
5394
|
+
return getMergedValue(undefined, a);
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
function getMergedTransitionalOption(config1, config2, prop) {
|
|
5398
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
5399
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
5400
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
5401
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
5402
|
+
return transitional2[prop];
|
|
5403
|
+
}
|
|
5404
|
+
} else {
|
|
5405
|
+
return undefined;
|
|
5406
|
+
}
|
|
5407
|
+
}
|
|
5408
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
5409
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
5410
|
+
return transitional1[prop];
|
|
5411
|
+
}
|
|
5412
|
+
return undefined;
|
|
5413
|
+
}
|
|
5414
|
+
|
|
5415
|
+
// eslint-disable-next-line consistent-return
|
|
5416
|
+
function mergeDirectKeys(a, b, prop, config1, config2) {
|
|
5417
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
5418
|
+
return getMergedValue(a, b);
|
|
5419
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
5420
|
+
return getMergedValue(undefined, a);
|
|
5421
|
+
}
|
|
5422
|
+
}
|
|
5423
|
+
function mergeHeaders(a, b, prop) {
|
|
5424
|
+
return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
|
|
5425
|
+
}
|
|
5426
|
+
|
|
5427
|
+
// Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
|
|
5428
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
5429
|
+
// defineProperty only reads it, so one shared instance serves every call.
|
|
5430
|
+
const hasOwnPropertyDescriptor = Object.freeze({
|
|
5431
|
+
__proto__: null,
|
|
5432
|
+
value: Object.prototype.hasOwnProperty,
|
|
5433
|
+
enumerable: false,
|
|
5434
|
+
writable: true,
|
|
5435
|
+
configurable: true
|
|
5436
|
+
});
|
|
5437
|
+
|
|
5438
|
+
// The strategy table and the strategies above are stateless, so they are
|
|
5439
|
+
// built once at module load instead of on every call: mergeConfig runs at
|
|
5440
|
+
// most twice per request (once from a method alias, once from `_request`).
|
|
5441
|
+
const mergeMap = {
|
|
5442
|
+
url: valueFromConfig2,
|
|
5443
|
+
method: valueFromConfig2,
|
|
5444
|
+
data: valueFromConfig2,
|
|
5445
|
+
baseURL: defaultToConfig2,
|
|
5446
|
+
transformRequest: defaultToConfig2,
|
|
5447
|
+
transformResponse: defaultToConfig2,
|
|
5448
|
+
params: mergeParams,
|
|
5449
|
+
paramsSerializer: defaultToConfig2,
|
|
5450
|
+
timeout: defaultToConfig2,
|
|
5451
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
5452
|
+
withCredentials: defaultToConfig2,
|
|
5453
|
+
withXSRFToken: defaultToConfig2,
|
|
5454
|
+
adapter: defaultToConfig2,
|
|
5455
|
+
responseType: defaultToConfig2,
|
|
5456
|
+
xsrfCookieName: defaultToConfig2,
|
|
5457
|
+
xsrfHeaderName: defaultToConfig2,
|
|
5458
|
+
onUploadProgress: defaultToConfig2,
|
|
5459
|
+
onDownloadProgress: defaultToConfig2,
|
|
5460
|
+
decompress: defaultToConfig2,
|
|
5461
|
+
maxContentLength: defaultToConfig2,
|
|
5462
|
+
maxBodyLength: defaultToConfig2,
|
|
5463
|
+
beforeRedirect: defaultToConfig2,
|
|
5464
|
+
transport: defaultToConfig2,
|
|
5465
|
+
httpAgent: defaultToConfig2,
|
|
5466
|
+
httpsAgent: defaultToConfig2,
|
|
5467
|
+
cancelToken: defaultToConfig2,
|
|
5468
|
+
socketPath: defaultToConfig2,
|
|
5469
|
+
allowedSocketPaths: defaultToConfig2,
|
|
5470
|
+
responseEncoding: defaultToConfig2,
|
|
5471
|
+
validateStatus: mergeDirectKeys,
|
|
5472
|
+
headers: mergeHeaders
|
|
5473
|
+
};
|
|
5474
|
+
|
|
4623
5475
|
/**
|
|
4624
5476
|
* Config-specific merge-function which creates a new config-object
|
|
4625
5477
|
* by merging two configuration objects together.
|
|
@@ -4639,120 +5491,21 @@ function mergeConfig(config1, config2) {
|
|
|
4639
5491
|
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
4640
5492
|
// ergonomics for user code that relies on it.
|
|
4641
5493
|
const config = Object.create(null);
|
|
4642
|
-
Object.defineProperty(config, 'hasOwnProperty',
|
|
4643
|
-
|
|
4644
|
-
// this data descriptor into an accessor descriptor on the way in.
|
|
4645
|
-
__proto__: null,
|
|
4646
|
-
value: Object.prototype.hasOwnProperty,
|
|
4647
|
-
enumerable: false,
|
|
4648
|
-
writable: true,
|
|
4649
|
-
configurable: true
|
|
4650
|
-
});
|
|
4651
|
-
function getMergedValue(target, source, prop, caseless) {
|
|
4652
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
4653
|
-
return utils$1.merge.call({
|
|
4654
|
-
caseless
|
|
4655
|
-
}, target, source);
|
|
4656
|
-
} else if (utils$1.isPlainObject(source)) {
|
|
4657
|
-
return utils$1.merge({}, source);
|
|
4658
|
-
} else if (utils$1.isArray(source)) {
|
|
4659
|
-
return source.slice();
|
|
4660
|
-
}
|
|
4661
|
-
return source;
|
|
4662
|
-
}
|
|
4663
|
-
function mergeDeepProperties(a, b, prop, caseless) {
|
|
4664
|
-
if (!utils$1.isUndefined(b)) {
|
|
4665
|
-
return getMergedValue(a, b, prop, caseless);
|
|
4666
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
4667
|
-
return getMergedValue(undefined, a, prop, caseless);
|
|
4668
|
-
}
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
|
-
// eslint-disable-next-line consistent-return
|
|
4672
|
-
function valueFromConfig2(a, b) {
|
|
4673
|
-
if (!utils$1.isUndefined(b)) {
|
|
4674
|
-
return getMergedValue(undefined, b);
|
|
4675
|
-
}
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
// eslint-disable-next-line consistent-return
|
|
4679
|
-
function defaultToConfig2(a, b) {
|
|
4680
|
-
if (!utils$1.isUndefined(b)) {
|
|
4681
|
-
return getMergedValue(undefined, b);
|
|
4682
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
4683
|
-
return getMergedValue(undefined, a);
|
|
4684
|
-
}
|
|
4685
|
-
}
|
|
4686
|
-
function getMergedTransitionalOption(prop) {
|
|
4687
|
-
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
4688
|
-
if (!utils$1.isUndefined(transitional2)) {
|
|
4689
|
-
if (utils$1.isPlainObject(transitional2)) {
|
|
4690
|
-
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
4691
|
-
return transitional2[prop];
|
|
4692
|
-
}
|
|
4693
|
-
} else {
|
|
4694
|
-
return undefined;
|
|
4695
|
-
}
|
|
4696
|
-
}
|
|
4697
|
-
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
4698
|
-
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
4699
|
-
return transitional1[prop];
|
|
4700
|
-
}
|
|
4701
|
-
return undefined;
|
|
4702
|
-
}
|
|
4703
|
-
|
|
4704
|
-
// eslint-disable-next-line consistent-return
|
|
4705
|
-
function mergeDirectKeys(a, b, prop) {
|
|
4706
|
-
if (utils$1.hasOwnProp(config2, prop)) {
|
|
4707
|
-
return getMergedValue(a, b);
|
|
4708
|
-
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
4709
|
-
return getMergedValue(undefined, a);
|
|
4710
|
-
}
|
|
4711
|
-
}
|
|
4712
|
-
const mergeMap = {
|
|
4713
|
-
url: valueFromConfig2,
|
|
4714
|
-
method: valueFromConfig2,
|
|
4715
|
-
data: valueFromConfig2,
|
|
4716
|
-
baseURL: defaultToConfig2,
|
|
4717
|
-
transformRequest: defaultToConfig2,
|
|
4718
|
-
transformResponse: defaultToConfig2,
|
|
4719
|
-
paramsSerializer: defaultToConfig2,
|
|
4720
|
-
timeout: defaultToConfig2,
|
|
4721
|
-
timeoutMessage: defaultToConfig2,
|
|
4722
|
-
withCredentials: defaultToConfig2,
|
|
4723
|
-
withXSRFToken: defaultToConfig2,
|
|
4724
|
-
adapter: defaultToConfig2,
|
|
4725
|
-
responseType: defaultToConfig2,
|
|
4726
|
-
xsrfCookieName: defaultToConfig2,
|
|
4727
|
-
xsrfHeaderName: defaultToConfig2,
|
|
4728
|
-
onUploadProgress: defaultToConfig2,
|
|
4729
|
-
onDownloadProgress: defaultToConfig2,
|
|
4730
|
-
decompress: defaultToConfig2,
|
|
4731
|
-
maxContentLength: defaultToConfig2,
|
|
4732
|
-
maxBodyLength: defaultToConfig2,
|
|
4733
|
-
beforeRedirect: defaultToConfig2,
|
|
4734
|
-
transport: defaultToConfig2,
|
|
4735
|
-
httpAgent: defaultToConfig2,
|
|
4736
|
-
httpsAgent: defaultToConfig2,
|
|
4737
|
-
cancelToken: defaultToConfig2,
|
|
4738
|
-
socketPath: defaultToConfig2,
|
|
4739
|
-
allowedSocketPaths: defaultToConfig2,
|
|
4740
|
-
responseEncoding: defaultToConfig2,
|
|
4741
|
-
validateStatus: mergeDirectKeys,
|
|
4742
|
-
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
4743
|
-
};
|
|
4744
|
-
utils$1.forEach(ownEnumerableKeys({
|
|
5494
|
+
Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
|
|
5495
|
+
const keys = ownEnumerableKeys({
|
|
4745
5496
|
...config1,
|
|
4746
5497
|
...config2
|
|
4747
|
-
})
|
|
4748
|
-
|
|
5498
|
+
});
|
|
5499
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
5500
|
+
const prop = keys[i];
|
|
5501
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
|
|
4749
5502
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
4750
5503
|
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
4751
5504
|
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
4752
|
-
const configValue = merge(a, b, prop);
|
|
5505
|
+
const configValue = merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
|
|
4753
5506
|
utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
|
4754
|
-
}
|
|
4755
|
-
if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption('validateStatusUndefinedResolves') === false) {
|
|
5507
|
+
}
|
|
5508
|
+
if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false) {
|
|
4756
5509
|
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
4757
5510
|
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
4758
5511
|
} else {
|
|
@@ -4771,7 +5524,8 @@ function mergeConfig(config1, config2) {
|
|
|
4771
5524
|
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
4772
5525
|
*/
|
|
4773
5526
|
const encodeUTF8$1 = str => encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
4774
|
-
|
|
5527
|
+
const readCookie = name => cookies.read(name);
|
|
5528
|
+
function resolveConfig(config, readXsrfCookie = readCookie) {
|
|
4775
5529
|
const newConfig = mergeConfig({}, config);
|
|
4776
5530
|
|
|
4777
5531
|
// Read only own properties to prevent prototype pollution gadgets
|
|
@@ -4793,18 +5547,23 @@ function resolveConfig(config) {
|
|
|
4793
5547
|
if (auth) {
|
|
4794
5548
|
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
4795
5549
|
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
5550
|
+
const transitional = own('transitional');
|
|
5551
|
+
const encodeUsername = transitional && utils$1.hasOwnProp(transitional, 'encodeBasicAuthUsername') && transitional.encodeBasicAuthUsername === true;
|
|
4796
5552
|
try {
|
|
4797
|
-
headers.set('Authorization',
|
|
5553
|
+
headers.set('Authorization',
|
|
5554
|
+
// Preserve legacy username bytes unless the caller opts in to UTF-8.
|
|
5555
|
+
'Basic ' + btoa((encodeUsername ? encodeUTF8$1(username) : username) + ':' + (password ? encodeUTF8$1(password) : '')));
|
|
4798
5556
|
} catch (e) {
|
|
4799
5557
|
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
4800
5558
|
}
|
|
4801
5559
|
}
|
|
4802
5560
|
if (utils$1.isFormData(data)) {
|
|
5561
|
+
const getHeaders = utils$1.getSafeProp(data, 'getHeaders');
|
|
4803
5562
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
|
|
4804
5563
|
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
4805
|
-
} else if (utils$1.isFunction(
|
|
5564
|
+
} else if (utils$1.isFunction(getHeaders)) {
|
|
4806
5565
|
// Node.js FormData (like form-data package)
|
|
4807
|
-
setFormDataHeaders(headers,
|
|
5566
|
+
setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
|
|
4808
5567
|
}
|
|
4809
5568
|
}
|
|
4810
5569
|
|
|
@@ -4822,7 +5581,7 @@ function resolveConfig(config) {
|
|
|
4822
5581
|
// the XSRF token cross-origin.
|
|
4823
5582
|
const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
|
|
4824
5583
|
if (shouldSendXSRF) {
|
|
4825
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName &&
|
|
5584
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
|
|
4826
5585
|
if (xsrfValue) {
|
|
4827
5586
|
headers.set(xsrfHeaderName, xsrfValue);
|
|
4828
5587
|
}
|
|
@@ -4834,7 +5593,18 @@ function resolveConfig(config) {
|
|
|
4834
5593
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
4835
5594
|
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
4836
5595
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
4837
|
-
|
|
5596
|
+
let useAsyncXsrf;
|
|
5597
|
+
try {
|
|
5598
|
+
const store = platform.hasStandardBrowserEnv && typeof window !== 'undefined' && window.cookieStore;
|
|
5599
|
+
useAsyncXsrf = store && utils$1.isFunction(store.get);
|
|
5600
|
+
} catch (e) {
|
|
5601
|
+
// A restricted Cookie Store getter must retain the synchronous fallback.
|
|
5602
|
+
}
|
|
5603
|
+
let xsrfCookieName;
|
|
5604
|
+
const _config = resolveConfig(config, useAsyncXsrf ? name => {
|
|
5605
|
+
xsrfCookieName = name;
|
|
5606
|
+
return null;
|
|
5607
|
+
} : undefined);
|
|
4838
5608
|
let requestData = _config.data;
|
|
4839
5609
|
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
4840
5610
|
let {
|
|
@@ -4843,12 +5613,37 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4843
5613
|
onDownloadProgress
|
|
4844
5614
|
} = _config;
|
|
4845
5615
|
let onCanceled;
|
|
5616
|
+
let timeoutId;
|
|
4846
5617
|
let uploadThrottled, downloadThrottled;
|
|
4847
|
-
let flushUpload, flushDownload;
|
|
5618
|
+
let flushUpload, flushDownload, flushDownloadWithEvent;
|
|
4848
5619
|
function done() {
|
|
4849
|
-
|
|
4850
|
-
|
|
5620
|
+
clearTimeout(timeoutId);
|
|
5621
|
+
// A final progress callback must not prevent the remaining cleanup.
|
|
5622
|
+
// Report errors asynchronously, as onloadend and the throttle timer do.
|
|
5623
|
+
try {
|
|
5624
|
+
flushUpload && flushUpload(); // flush events
|
|
5625
|
+
} catch (err) {
|
|
5626
|
+
setTimeout(() => {
|
|
5627
|
+
throw err;
|
|
5628
|
+
});
|
|
5629
|
+
}
|
|
5630
|
+
try {
|
|
5631
|
+
flushDownload && flushDownload(); // flush events
|
|
5632
|
+
} catch (err) {
|
|
5633
|
+
setTimeout(() => {
|
|
5634
|
+
throw err;
|
|
5635
|
+
});
|
|
5636
|
+
}
|
|
4851
5637
|
|
|
5638
|
+
// A flush can synchronously cancel the request and reenter done().
|
|
5639
|
+
// In that case the inner call has already detached these listeners.
|
|
5640
|
+
if (request) {
|
|
5641
|
+
downloadThrottled && request.removeEventListener('progress', downloadThrottled);
|
|
5642
|
+
if (request.upload) {
|
|
5643
|
+
uploadThrottled && request.upload.removeEventListener('progress', uploadThrottled);
|
|
5644
|
+
flushUpload && request.upload.removeEventListener('loadend', flushUpload);
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
4852
5647
|
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
4853
5648
|
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
4854
5649
|
}
|
|
@@ -4857,10 +5652,50 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4857
5652
|
|
|
4858
5653
|
// Set the request timeout in MS
|
|
4859
5654
|
request.timeout = _config.timeout;
|
|
4860
|
-
function onloadend() {
|
|
5655
|
+
function onloadend(event) {
|
|
5656
|
+
if (!request) {
|
|
5657
|
+
return;
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5660
|
+
// Status 0 means no response was received, which onerror and onabort normally
|
|
5661
|
+
// reject before this runs. Firefox 152 fires only readystatechange and loadend for
|
|
5662
|
+
// navigation-canceled requests (https://bugzilla.mozilla.org/show_bug.cgi?id=1505389),
|
|
5663
|
+
// leaving settle() to resolve them as an empty success. ECONNABORTED is the error
|
|
5664
|
+
// onabort raised on Firefox 151. Reads over file:, which some environments report as
|
|
5665
|
+
// status 0 on success, are excluded by the request URL's scheme after browser-style
|
|
5666
|
+
// preprocessing, by the page origin's scheme for relative URLs (which inherit it), or
|
|
5667
|
+
// by responseURL where implemented.
|
|
5668
|
+
if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform.origin)) !== 'file' && !(request.responseURL && request.responseURL.startsWith('file:'))) {
|
|
5669
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
5670
|
+
done();
|
|
5671
|
+
|
|
5672
|
+
// Clean up request
|
|
5673
|
+
request = null;
|
|
5674
|
+
return;
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
// When loadend is still dispatching, flushing with it gives progress
|
|
5678
|
+
// listeners a final delivery whose event has a live target. The legacy
|
|
5679
|
+
// ready-state fallback has no event, so replay its pending progress.
|
|
5680
|
+
// A throwing listener must not block settlement; rethrow asynchronously,
|
|
5681
|
+
// matching how listener errors surface on the throttle timer path.
|
|
5682
|
+
try {
|
|
5683
|
+
if (event) {
|
|
5684
|
+
flushDownloadWithEvent && flushDownloadWithEvent(event);
|
|
5685
|
+
} else {
|
|
5686
|
+
flushDownload && flushDownload();
|
|
5687
|
+
}
|
|
5688
|
+
} catch (err) {
|
|
5689
|
+
setTimeout(() => {
|
|
5690
|
+
throw err;
|
|
5691
|
+
});
|
|
5692
|
+
}
|
|
5693
|
+
|
|
5694
|
+
// A final progress callback can cancel the request synchronously.
|
|
4861
5695
|
if (!request) {
|
|
4862
5696
|
return;
|
|
4863
5697
|
}
|
|
5698
|
+
|
|
4864
5699
|
// Prepare the response
|
|
4865
5700
|
const responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
|
4866
5701
|
const responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
|
|
@@ -4934,6 +5769,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4934
5769
|
|
|
4935
5770
|
// Handle timeout
|
|
4936
5771
|
request.ontimeout = function handleTimeout() {
|
|
5772
|
+
if (!request) return;
|
|
4937
5773
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
4938
5774
|
const transitional = _config.transitional || transitionalDefaults;
|
|
4939
5775
|
if (_config.timeoutErrorMessage) {
|
|
@@ -4949,13 +5785,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4949
5785
|
// Remove Content-Type if data is undefined
|
|
4950
5786
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
4951
5787
|
|
|
4952
|
-
// Add headers to the request
|
|
4953
|
-
if ('setRequestHeader' in request) {
|
|
4954
|
-
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
4955
|
-
request.setRequestHeader(key, val);
|
|
4956
|
-
});
|
|
4957
|
-
}
|
|
4958
|
-
|
|
4959
5788
|
// Add withCredentials to request if needed
|
|
4960
5789
|
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
4961
5790
|
request.withCredentials = !!_config.withCredentials;
|
|
@@ -4968,7 +5797,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4968
5797
|
|
|
4969
5798
|
// Handle progress if needed
|
|
4970
5799
|
if (onDownloadProgress) {
|
|
4971
|
-
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
5800
|
+
[downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(onDownloadProgress, true);
|
|
4972
5801
|
request.addEventListener('progress', downloadThrottled);
|
|
4973
5802
|
}
|
|
4974
5803
|
|
|
@@ -4986,24 +5815,79 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4986
5815
|
return;
|
|
4987
5816
|
}
|
|
4988
5817
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
4989
|
-
request
|
|
5818
|
+
const xhr = request;
|
|
4990
5819
|
done();
|
|
4991
5820
|
request = null;
|
|
5821
|
+
xhr.abort();
|
|
4992
5822
|
};
|
|
4993
5823
|
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
5824
|
+
if (!request) return;
|
|
4994
5825
|
if (_config.signal) {
|
|
4995
5826
|
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
4996
5827
|
}
|
|
4997
5828
|
}
|
|
5829
|
+
if (!request) return;
|
|
4998
5830
|
const protocol = parseProtocol(_config.url);
|
|
4999
5831
|
if (protocol && !platform.protocols.includes(protocol)) {
|
|
5000
5832
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
5001
5833
|
done();
|
|
5002
5834
|
return;
|
|
5003
5835
|
}
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5836
|
+
const sendRequest = () => {
|
|
5837
|
+
if (!request) return;
|
|
5838
|
+
// Apply headers after an asynchronous XSRF read so existing headers are
|
|
5839
|
+
// replaced through AxiosHeaders rather than appended by the native XHR.
|
|
5840
|
+
if ('setRequestHeader' in request) {
|
|
5841
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
5842
|
+
request.setRequestHeader(key, val);
|
|
5843
|
+
});
|
|
5844
|
+
}
|
|
5845
|
+
request.send(requestData || null);
|
|
5846
|
+
};
|
|
5847
|
+
if (xsrfCookieName) {
|
|
5848
|
+
// Native XHR timeout starts at send(). Cover cookie preparation and the
|
|
5849
|
+
// subsequent request with the same budget and existing timeout handler.
|
|
5850
|
+
const now = typeof performance !== 'undefined' && utils$1.isFunction(performance.now) ? () => performance.now() : Date.now;
|
|
5851
|
+
const deadline = request.timeout > 0 ? now() + Number(request.timeout) : undefined;
|
|
5852
|
+
const abortOnTimeout = () => {
|
|
5853
|
+
if (!request) return;
|
|
5854
|
+
const xhr = request;
|
|
5855
|
+
xhr.ontimeout();
|
|
5856
|
+
xhr.abort();
|
|
5857
|
+
};
|
|
5858
|
+
if (deadline !== undefined) {
|
|
5859
|
+
const scheduleTimeout = () => {
|
|
5860
|
+
const remaining = deadline - now();
|
|
5861
|
+
if (remaining > 0) {
|
|
5862
|
+
// Browser timers overflow above the signed 32-bit delay limit.
|
|
5863
|
+
timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 0x7fffffff));
|
|
5864
|
+
} else {
|
|
5865
|
+
abortOnTimeout();
|
|
5866
|
+
}
|
|
5867
|
+
};
|
|
5868
|
+
scheduleTimeout();
|
|
5869
|
+
}
|
|
5870
|
+
cookies.readAsync(xsrfCookieName).then(value => {
|
|
5871
|
+
if (!request) return;
|
|
5872
|
+
// Promise callbacks may run before an overdue timer after a busy task.
|
|
5873
|
+
if (deadline !== undefined && now() >= deadline) {
|
|
5874
|
+
abortOnTimeout();
|
|
5875
|
+
return;
|
|
5876
|
+
}
|
|
5877
|
+
if (value) {
|
|
5878
|
+
const headerName = utils$1.hasOwnProp(_config, 'xsrfHeaderName') && _config.xsrfHeaderName;
|
|
5879
|
+
requestHeaders.set(headerName, value);
|
|
5880
|
+
}
|
|
5881
|
+
sendRequest();
|
|
5882
|
+
}).catch(error => {
|
|
5883
|
+
if (!request) return;
|
|
5884
|
+
reject(AxiosError.from(error, null, config, request));
|
|
5885
|
+
done();
|
|
5886
|
+
request = null;
|
|
5887
|
+
});
|
|
5888
|
+
} else {
|
|
5889
|
+
sendRequest();
|
|
5890
|
+
}
|
|
5007
5891
|
});
|
|
5008
5892
|
};
|
|
5009
5893
|
|
|
@@ -5033,7 +5917,8 @@ const composeSignals = (signals, timeout) => {
|
|
|
5033
5917
|
timer && clearTimeout(timer);
|
|
5034
5918
|
timer = null;
|
|
5035
5919
|
signals.forEach(signal => {
|
|
5036
|
-
|
|
5920
|
+
const unsubscribeSignal = utils$1.getSafeProp(signal, 'unsubscribe');
|
|
5921
|
+
utils$1.isFunction(unsubscribeSignal) ? unsubscribeSignal.call(signal, onabort) : signal.removeEventListener('abort', onabort);
|
|
5037
5922
|
});
|
|
5038
5923
|
signals = null;
|
|
5039
5924
|
};
|
|
@@ -5138,7 +6023,133 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
5138
6023
|
});
|
|
5139
6024
|
};
|
|
5140
6025
|
|
|
6026
|
+
const CRLF = '\r\n';
|
|
6027
|
+
const normalizeLines = value => String(value).replace(/\r\n|\r|\n/g, CRLF);
|
|
6028
|
+
const escapeName = value => String(value).replace(/[\r\n"]/g, char => char === '\r' ? '%0D' : char === '\n' ? '%0A' : '%22');
|
|
6029
|
+
|
|
6030
|
+
// Count UTF-8 bytes without allocating an encoded copy of a field. FormData
|
|
6031
|
+
// string values normalize line endings; Blob/File contents remain unchanged.
|
|
6032
|
+
const stringBytes = (value, normalize) => {
|
|
6033
|
+
let length = 0;
|
|
6034
|
+
for (let i = 0; i < value.length; i++) {
|
|
6035
|
+
const code = value.charCodeAt(i);
|
|
6036
|
+
if (normalize && (code === 13 || code === 10)) {
|
|
6037
|
+
if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
|
|
6038
|
+
length += 2;
|
|
6039
|
+
} else if (code < 0x80) {
|
|
6040
|
+
length++;
|
|
6041
|
+
} else if (code < 0x800) {
|
|
6042
|
+
length += 2;
|
|
6043
|
+
} else if (code >= 0xd800 && code <= 0xdbff && value.charCodeAt(i + 1) >= 0xdc00 && value.charCodeAt(i + 1) <= 0xdfff) {
|
|
6044
|
+
length += 4;
|
|
6045
|
+
i++;
|
|
6046
|
+
} else {
|
|
6047
|
+
length += 3;
|
|
6048
|
+
}
|
|
6049
|
+
}
|
|
6050
|
+
return length;
|
|
6051
|
+
};
|
|
6052
|
+
|
|
6053
|
+
// Describe serialization failures independently of any request library.
|
|
6054
|
+
class FormDataError extends TypeError {
|
|
6055
|
+
constructor(message, reason) {
|
|
6056
|
+
super(message);
|
|
6057
|
+
this.name = 'FormDataError';
|
|
6058
|
+
this.reason = reason;
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
|
|
6062
|
+
// The caller supplies the boundary, Blob implementation, and limit error.
|
|
6063
|
+
function formDataToBlob(form, Blob, limit, limitError, boundary) {
|
|
6064
|
+
if (!utils$1.isFunction(Blob)) {
|
|
6065
|
+
throw new FormDataError('Blob is not supported', 'blob');
|
|
6066
|
+
}
|
|
6067
|
+
if (!utils$1.isString(boundary) || !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) || / $/.test(boundary)) {
|
|
6068
|
+
throw new FormDataError('Invalid multipart boundary', 'boundary');
|
|
6069
|
+
}
|
|
6070
|
+
const footer = '--' + boundary + '--' + CRLF;
|
|
6071
|
+
let length = footer.length;
|
|
6072
|
+
const parts = [];
|
|
6073
|
+
const checkLength = extra => {
|
|
6074
|
+
if (length + extra > limit) throw limitError();
|
|
6075
|
+
};
|
|
6076
|
+
checkLength(0);
|
|
6077
|
+
for (const [name, value] of form) {
|
|
6078
|
+
const isString = utils$1.isString(value);
|
|
6079
|
+
const valueLength = isString ? stringBytes(value, true) : value.size;
|
|
6080
|
+
if (!Number.isFinite(valueLength) || valueLength < 0) {
|
|
6081
|
+
throw new FormDataError('Unsupported FormData part size', 'part');
|
|
6082
|
+
}
|
|
6083
|
+
// Reject large values and names before building normalized header strings.
|
|
6084
|
+
checkLength(valueLength + stringBytes(name, true) + (!isString && value.name ? stringBytes(value.name, false) : 0) + (!isString && value.type ? stringBytes(value.type, false) : 0));
|
|
6085
|
+
let header = '--' + boundary + CRLF + 'Content-Disposition: form-data; name="' + escapeName(normalizeLines(name)) + '"';
|
|
6086
|
+
if (!isString) {
|
|
6087
|
+
header += '; filename="' + escapeName(utils$1.isString(value.name) ? value.name : 'blob') + '"' + CRLF + 'Content-Type: ' + String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
6088
|
+
}
|
|
6089
|
+
header += CRLF + CRLF;
|
|
6090
|
+
const partLength = stringBytes(header, false) + valueLength + CRLF.length;
|
|
6091
|
+
checkLength(partLength);
|
|
6092
|
+
length += partLength;
|
|
6093
|
+
parts.push({
|
|
6094
|
+
header,
|
|
6095
|
+
value,
|
|
6096
|
+
isString
|
|
6097
|
+
});
|
|
6098
|
+
}
|
|
6099
|
+
|
|
6100
|
+
// Native Blob composition retains existing Blob/File data. No file is read
|
|
6101
|
+
// and no complete multipart ArrayBuffer is created to determine its length.
|
|
6102
|
+
const blobParts = [];
|
|
6103
|
+
for (const part of parts) {
|
|
6104
|
+
blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF);
|
|
6105
|
+
}
|
|
6106
|
+
blobParts.push(footer);
|
|
6107
|
+
return new Blob(blobParts, {
|
|
6108
|
+
type: 'multipart/form-data; boundary=' + boundary
|
|
6109
|
+
});
|
|
6110
|
+
}
|
|
6111
|
+
|
|
6112
|
+
function createMultipartBody(form, Blob, limit, limitError, boundary) {
|
|
6113
|
+
// Report missing Blob support before trying to select a random source.
|
|
6114
|
+
if (!utils$1.isFunction(Blob)) {
|
|
6115
|
+
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
6116
|
+
}
|
|
6117
|
+
if (boundary === undefined) {
|
|
6118
|
+
if (utils$1.isFunction(platform.generateString)) {
|
|
6119
|
+
boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
|
|
6120
|
+
} else {
|
|
6121
|
+
const crypto = utils$1.global.crypto;
|
|
6122
|
+
if (!crypto || !utils$1.isFunction(crypto.getRandomValues)) {
|
|
6123
|
+
throw new AxiosError('Random byte generation is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
6124
|
+
}
|
|
6125
|
+
const random = new Uint8Array(18);
|
|
6126
|
+
crypto.getRandomValues(random);
|
|
6127
|
+
boundary = 'axios-' + Array.from(random, value => ('0' + value.toString(16)).slice(-2)).join('');
|
|
6128
|
+
}
|
|
6129
|
+
}
|
|
6130
|
+
try {
|
|
6131
|
+
return formDataToBlob(form, Blob, limit, limitError, boundary);
|
|
6132
|
+
} catch (error) {
|
|
6133
|
+
if (error instanceof FormDataError) {
|
|
6134
|
+
const code = error.reason === 'boundary' ? AxiosError.ERR_BAD_OPTION_VALUE : AxiosError.ERR_BAD_REQUEST;
|
|
6135
|
+
throw new AxiosError(error.message, code);
|
|
6136
|
+
}
|
|
6137
|
+
throw error;
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
|
|
5141
6141
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
6142
|
+
const DEFAULT_REQUEST_OPTIONS = {
|
|
6143
|
+
cache: 'default',
|
|
6144
|
+
redirect: 'follow',
|
|
6145
|
+
referrer: 'about:client',
|
|
6146
|
+
referrerPolicy: '',
|
|
6147
|
+
mode: 'cors',
|
|
6148
|
+
integrity: '',
|
|
6149
|
+
keepalive: false,
|
|
6150
|
+
priority: 'auto',
|
|
6151
|
+
window: null
|
|
6152
|
+
};
|
|
5142
6153
|
const {
|
|
5143
6154
|
isFunction
|
|
5144
6155
|
} = utils$1;
|
|
@@ -5192,12 +6203,14 @@ const factory = env => {
|
|
|
5192
6203
|
skipUndefined: true
|
|
5193
6204
|
}, {
|
|
5194
6205
|
Request: globalObject.Request,
|
|
5195
|
-
Response: globalObject.Response
|
|
6206
|
+
Response: globalObject.Response,
|
|
6207
|
+
Blob: globalObject.Blob
|
|
5196
6208
|
}, env);
|
|
6209
|
+
const envFetch = utils$1.hasOwnProp(env, 'fetch') ? env.fetch : undefined;
|
|
5197
6210
|
const {
|
|
5198
|
-
fetch: envFetch,
|
|
5199
6211
|
Request,
|
|
5200
|
-
Response
|
|
6212
|
+
Response,
|
|
6213
|
+
Blob
|
|
5201
6214
|
} = env;
|
|
5202
6215
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
5203
6216
|
const isRequestSupported = isFunction(Request);
|
|
@@ -5224,6 +6237,19 @@ const factory = env => {
|
|
|
5224
6237
|
return duplexAccessed && !hasContentType;
|
|
5225
6238
|
});
|
|
5226
6239
|
const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response('').body));
|
|
6240
|
+
|
|
6241
|
+
// Some runtimes reject every explicit cache mode. Use own defaults for both
|
|
6242
|
+
// probes so unrelated polluted options cannot affect cache-mode detection.
|
|
6243
|
+
const requestDefaults = Object.assign(Object.create(null), DEFAULT_REQUEST_OPTIONS);
|
|
6244
|
+
if (isRequestSupported && !test(() => new Request(platform.origin, requestDefaults))) {
|
|
6245
|
+
delete requestDefaults.cache;
|
|
6246
|
+
|
|
6247
|
+
// Only omit cache when that makes Request construction succeed. Otherwise
|
|
6248
|
+
// retain the explicit default that protects supporting runtimes from pollution.
|
|
6249
|
+
if (!test(() => new Request(platform.origin, requestDefaults))) {
|
|
6250
|
+
requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
5227
6253
|
const resolvers = {
|
|
5228
6254
|
stream: supportsResponseStream && (res => res.body)
|
|
5229
6255
|
};
|
|
@@ -5245,13 +6271,6 @@ const factory = env => {
|
|
|
5245
6271
|
if (utils$1.isBlob(body)) {
|
|
5246
6272
|
return body.size;
|
|
5247
6273
|
}
|
|
5248
|
-
if (utils$1.isSpecCompliantForm(body)) {
|
|
5249
|
-
const _request = new Request(platform.origin, {
|
|
5250
|
-
method: 'POST',
|
|
5251
|
-
body
|
|
5252
|
-
});
|
|
5253
|
-
return (await _request.arrayBuffer()).byteLength;
|
|
5254
|
-
}
|
|
5255
6274
|
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
5256
6275
|
return body.byteLength;
|
|
5257
6276
|
}
|
|
@@ -5281,7 +6300,8 @@ const factory = env => {
|
|
|
5281
6300
|
withCredentials = 'same-origin',
|
|
5282
6301
|
fetchOptions,
|
|
5283
6302
|
maxContentLength,
|
|
5284
|
-
maxBodyLength
|
|
6303
|
+
maxBodyLength,
|
|
6304
|
+
maxRedirects
|
|
5285
6305
|
} = resolveConfig(config);
|
|
5286
6306
|
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
5287
6307
|
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
@@ -5295,11 +6315,12 @@ const factory = env => {
|
|
|
5295
6315
|
});
|
|
5296
6316
|
let requestContentLength;
|
|
5297
6317
|
|
|
5298
|
-
//
|
|
6318
|
+
// AxiosErrors we raise while request or response bodies are being streamed. Captured
|
|
5299
6319
|
// by identity so the catch block can surface it directly, regardless of
|
|
5300
6320
|
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
5301
6321
|
// as `err.cause`; some browsers drop the original error entirely).
|
|
5302
6322
|
let pendingBodyError = null;
|
|
6323
|
+
let pendingResponseError = null;
|
|
5303
6324
|
const maxBodyLengthError = () => new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
|
|
5304
6325
|
try {
|
|
5305
6326
|
// HTTP basic authentication
|
|
@@ -5313,8 +6334,9 @@ const factory = env => {
|
|
|
5313
6334
|
password
|
|
5314
6335
|
};
|
|
5315
6336
|
}
|
|
6337
|
+
let parsedURL;
|
|
5316
6338
|
if (maybeWithAuthCredentials(url)) {
|
|
5317
|
-
|
|
6339
|
+
parsedURL = new URL(url, platform.origin);
|
|
5318
6340
|
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
5319
6341
|
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
5320
6342
|
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
@@ -5337,12 +6359,25 @@ const factory = env => {
|
|
|
5337
6359
|
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
5338
6360
|
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
5339
6361
|
// "if (protocol === 'data:')" branch).
|
|
5340
|
-
if (hasMaxContentLength &&
|
|
5341
|
-
const estimated = estimateDataURLDecodedBytes(
|
|
6362
|
+
if (hasMaxContentLength && parsedURL && parsedURL.protocol === 'data:') {
|
|
6363
|
+
const estimated = estimateDataURLDecodedBytes(parsedURL.href);
|
|
5342
6364
|
if (estimated > maxContentLength) {
|
|
5343
6365
|
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
5344
6366
|
}
|
|
5345
6367
|
}
|
|
6368
|
+
const formContentType = utils$1.isSpecCompliantForm(data) && AxiosHeaders.from(own('headers')).getContentType();
|
|
6369
|
+
let formBoundary;
|
|
6370
|
+
if (utils$1.isString(formContentType) && /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())) {
|
|
6371
|
+
const parameters = AxiosHeaders.parseParameters(formContentType);
|
|
6372
|
+
if (utils$1.hasOwnProp(parameters, 'boundary')) formBoundary = parameters.boundary;
|
|
6373
|
+
}
|
|
6374
|
+
if (utils$1.isSpecCompliantForm(data) && method !== 'get' && method !== 'head' && (hasMaxBodyLength || onUploadProgress && supportsRequestStream || formBoundary !== undefined)) {
|
|
6375
|
+
data = createMultipartBody(data, Blob, hasMaxBodyLength ? maxBodyLength : Infinity, maxBodyLengthError, formBoundary);
|
|
6376
|
+
// Blob.type lowercases its value, including a case-sensitive boundary.
|
|
6377
|
+
// Retain the caller's header when an explicit boundary was serialized.
|
|
6378
|
+
headers.setContentType(formBoundary === undefined ? data.type : formContentType);
|
|
6379
|
+
requestContentLength = data.size;
|
|
6380
|
+
}
|
|
5346
6381
|
|
|
5347
6382
|
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
5348
6383
|
// the body's *actual* size — never a caller-declared Content-Length,
|
|
@@ -5412,17 +6447,46 @@ const factory = env => {
|
|
|
5412
6447
|
|
|
5413
6448
|
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
5414
6449
|
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
5415
|
-
const
|
|
5416
|
-
|
|
6450
|
+
const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(Object.create(null), fetchOptions);
|
|
6451
|
+
if (safeFetchOptions) {
|
|
6452
|
+
// These options are owned by Axios and are already reflected in the
|
|
6453
|
+
// resolved Request passed to fetch.
|
|
6454
|
+
delete safeFetchOptions.body;
|
|
6455
|
+
delete safeFetchOptions.headers;
|
|
6456
|
+
delete safeFetchOptions.method;
|
|
6457
|
+
delete safeFetchOptions.signal;
|
|
6458
|
+
delete safeFetchOptions.duplex;
|
|
6459
|
+
delete safeFetchOptions.credentials;
|
|
6460
|
+
}
|
|
6461
|
+
const resolvedOptions = Object.assign(Object.create(null), safeFetchOptions, {
|
|
5417
6462
|
signal: composedSignal,
|
|
5418
6463
|
method: method.toUpperCase(),
|
|
5419
6464
|
headers: toByteStringHeaderObject(headers.normalize()),
|
|
5420
6465
|
body: data,
|
|
5421
6466
|
duplex: 'half',
|
|
5422
6467
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
5423
|
-
};
|
|
6468
|
+
});
|
|
6469
|
+
if (isRequestSupported) {
|
|
6470
|
+
utils$1.forEach(requestDefaults, (value, key) => {
|
|
6471
|
+
if (resolvedOptions[key] === undefined) {
|
|
6472
|
+
resolvedOptions[key] = value;
|
|
6473
|
+
}
|
|
6474
|
+
});
|
|
6475
|
+
if (resolvedOptions.signal === undefined) {
|
|
6476
|
+
resolvedOptions.signal = null;
|
|
6477
|
+
}
|
|
6478
|
+
if (resolvedOptions.body === undefined) {
|
|
6479
|
+
resolvedOptions.body = null;
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
6482
|
+
if (maxRedirects === 0) {
|
|
6483
|
+
resolvedOptions.redirect = 'manual';
|
|
6484
|
+
if (safeFetchOptions) {
|
|
6485
|
+
safeFetchOptions.redirect = 'manual';
|
|
6486
|
+
}
|
|
6487
|
+
}
|
|
5424
6488
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
5425
|
-
let response = await (isRequestSupported ? _fetch(request,
|
|
6489
|
+
let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url, resolvedOptions));
|
|
5426
6490
|
const responseHeaders = AxiosHeaders.from(response.headers);
|
|
5427
6491
|
|
|
5428
6492
|
// Cheap pre-check: if the server honestly declares a content-length that
|
|
@@ -5446,7 +6510,7 @@ const factory = env => {
|
|
|
5446
6510
|
if (hasMaxContentLength) {
|
|
5447
6511
|
bytesRead = loadedBytes;
|
|
5448
6512
|
if (bytesRead > maxContentLength) {
|
|
5449
|
-
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
6513
|
+
throw pendingResponseError = new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
5450
6514
|
}
|
|
5451
6515
|
}
|
|
5452
6516
|
onProgress && onProgress(loadedBytes);
|
|
@@ -5513,7 +6577,7 @@ const factory = env => {
|
|
|
5513
6577
|
}
|
|
5514
6578
|
|
|
5515
6579
|
// Surface a maxBodyLength violation we raised while the request body was
|
|
5516
|
-
// being streamed.
|
|
6580
|
+
// being streamed. Keeping the original error (rather than reading
|
|
5517
6581
|
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
5518
6582
|
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
5519
6583
|
// AxiosError that merely happened to land in `err.cause`.
|
|
@@ -5521,6 +6585,9 @@ const factory = env => {
|
|
|
5521
6585
|
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
5522
6586
|
throw pendingBodyError;
|
|
5523
6587
|
}
|
|
6588
|
+
if (pendingResponseError) {
|
|
6589
|
+
throw pendingResponseError;
|
|
6590
|
+
}
|
|
5524
6591
|
|
|
5525
6592
|
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
5526
6593
|
// pre-checks, response size enforcement) without re-wrapping them.
|
|
@@ -5547,13 +6614,20 @@ const factory = env => {
|
|
|
5547
6614
|
};
|
|
5548
6615
|
const seedCache = new Map();
|
|
5549
6616
|
const getFetch = config => {
|
|
5550
|
-
|
|
6617
|
+
const env = Object.create(null);
|
|
6618
|
+
const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
|
|
6619
|
+
['fetch', 'Request', 'Response', 'Blob'].forEach(key => {
|
|
6620
|
+
if (configuredEnv && utils$1.hasOwnProp(configuredEnv, key)) {
|
|
6621
|
+
env[key] = configuredEnv[key];
|
|
6622
|
+
}
|
|
6623
|
+
});
|
|
5551
6624
|
const {
|
|
5552
6625
|
fetch,
|
|
5553
6626
|
Request,
|
|
5554
|
-
Response
|
|
6627
|
+
Response,
|
|
6628
|
+
Blob
|
|
5555
6629
|
} = env;
|
|
5556
|
-
const seeds = [Request, Response, fetch];
|
|
6630
|
+
const seeds = [Request, Response, fetch, Blob];
|
|
5557
6631
|
let len = seeds.length,
|
|
5558
6632
|
i = len,
|
|
5559
6633
|
seed,
|
|
@@ -5695,6 +6769,21 @@ function throwIfCancellationRequested(config) {
|
|
|
5695
6769
|
}
|
|
5696
6770
|
}
|
|
5697
6771
|
|
|
6772
|
+
/**
|
|
6773
|
+
* Milliseconds elapsed since `start`, floored at zero.
|
|
6774
|
+
*
|
|
6775
|
+
* Wall-clock, to match the rest of the codebase (speedometer, throttle,
|
|
6776
|
+
* AxiosTransformStream). A backwards clock adjustment mid-request would
|
|
6777
|
+
* otherwise produce a negative duration, so the result is clamped.
|
|
6778
|
+
*
|
|
6779
|
+
* @param {number} start Timestamp from `Date.now()`
|
|
6780
|
+
*
|
|
6781
|
+
* @returns {number} Non-negative elapsed milliseconds
|
|
6782
|
+
*/
|
|
6783
|
+
function elapsedSince(start) {
|
|
6784
|
+
return Math.max(0, Date.now() - start);
|
|
6785
|
+
}
|
|
6786
|
+
|
|
5698
6787
|
/**
|
|
5699
6788
|
* Dispatch a request to the server using the configured adapter.
|
|
5700
6789
|
*
|
|
@@ -5702,9 +6791,13 @@ function throwIfCancellationRequested(config) {
|
|
|
5702
6791
|
*
|
|
5703
6792
|
* @returns {Promise} The Promise to be fulfilled
|
|
5704
6793
|
*/
|
|
5705
|
-
function dispatchRequest(
|
|
6794
|
+
function dispatchRequest(_config) {
|
|
6795
|
+
// Interceptors may replace the merged config with an ordinary object. Flatten
|
|
6796
|
+
// it at the dispatch boundary so shared prototype members cannot become
|
|
6797
|
+
// request behavior, while preserving intentional template/class members.
|
|
6798
|
+
const config = utils$1.toSafeFlatObject(_config);
|
|
5706
6799
|
throwIfCancellationRequested(config);
|
|
5707
|
-
config.headers = AxiosHeaders.from(config
|
|
6800
|
+
config.headers = AxiosHeaders.from(utils$1.getSafeProp(config, 'headers'));
|
|
5708
6801
|
|
|
5709
6802
|
// Transform request data
|
|
5710
6803
|
config.data = transformData.call(config, config.transformRequest);
|
|
@@ -5712,8 +6805,10 @@ function dispatchRequest(config) {
|
|
|
5712
6805
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
5713
6806
|
}
|
|
5714
6807
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
6808
|
+
const start = Date.now();
|
|
5715
6809
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
5716
6810
|
throwIfCancellationRequested(config);
|
|
6811
|
+
response.duration = elapsedSince(start);
|
|
5717
6812
|
|
|
5718
6813
|
// Expose the current response on config so that transformResponse can
|
|
5719
6814
|
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
@@ -5732,6 +6827,7 @@ function dispatchRequest(config) {
|
|
|
5732
6827
|
|
|
5733
6828
|
// Transform response data
|
|
5734
6829
|
if (reason && reason.response) {
|
|
6830
|
+
reason.response.duration = elapsedSince(start);
|
|
5735
6831
|
config.response = reason.response;
|
|
5736
6832
|
try {
|
|
5737
6833
|
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
|
@@ -5831,6 +6927,21 @@ var validator = {
|
|
|
5831
6927
|
|
|
5832
6928
|
const validators = validator.validators;
|
|
5833
6929
|
|
|
6930
|
+
// Recognize header maps without consuming objects intended as literal values.
|
|
6931
|
+
// AxiosHeaders from other builds share a brand and header-container interface,
|
|
6932
|
+
// but not constructor identity. A tag and toJSON alone can describe a literal.
|
|
6933
|
+
const isHeadersBucket = value => {
|
|
6934
|
+
if (value == null || utils$1.isPlainObject(value) || value instanceof AxiosHeaders) {
|
|
6935
|
+
return true;
|
|
6936
|
+
}
|
|
6937
|
+
try {
|
|
6938
|
+
return utils$1.isObject(value) && utils$1.getSafeProp(value, Symbol.toStringTag) === 'AxiosHeaders' && ['toJSON', 'set', 'get', 'has', 'delete', 'clear', 'normalize', 'concat', 'toString', Symbol.iterator].every(method => utils$1.isFunction(utils$1.getSafeProp(value, method)));
|
|
6939
|
+
} catch (e) {
|
|
6940
|
+
// A failed optional brand probe must not prevent literal header serialization.
|
|
6941
|
+
return false;
|
|
6942
|
+
}
|
|
6943
|
+
};
|
|
6944
|
+
|
|
5834
6945
|
/**
|
|
5835
6946
|
* Create a new instance of Axios
|
|
5836
6947
|
*
|
|
@@ -5860,31 +6971,40 @@ class Axios {
|
|
|
5860
6971
|
return await this._request(configOrUrl, config);
|
|
5861
6972
|
} catch (err) {
|
|
5862
6973
|
if (err instanceof Error) {
|
|
5863
|
-
let dummy = {};
|
|
5864
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
5865
|
-
|
|
5866
|
-
// slice off the Error: ... line
|
|
5867
|
-
const stack = (() => {
|
|
5868
|
-
if (!dummy.stack) {
|
|
5869
|
-
return '';
|
|
5870
|
-
}
|
|
5871
|
-
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
5872
|
-
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
5873
|
-
})();
|
|
5874
6974
|
try {
|
|
6975
|
+
let dummy = {};
|
|
6976
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
6977
|
+
const dummyStack = dummy.stack;
|
|
6978
|
+
let stack = '';
|
|
6979
|
+
|
|
6980
|
+
// slice off the Error: ... line
|
|
6981
|
+
if (typeof dummyStack === 'string') {
|
|
6982
|
+
const firstNewlineIndex = dummyStack.indexOf('\n');
|
|
6983
|
+
stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
|
|
6984
|
+
}
|
|
5875
6985
|
if (!err.stack) {
|
|
5876
6986
|
err.stack = stack;
|
|
5877
|
-
// match without the 2 top stack lines
|
|
5878
6987
|
} else if (stack) {
|
|
6988
|
+
// Match a common suffix after the 2 top frames when available,
|
|
6989
|
+
// otherwise compare the full reconstructed stack.
|
|
5879
6990
|
const firstNewlineIndex = stack.indexOf('\n');
|
|
5880
6991
|
const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
5881
|
-
const
|
|
5882
|
-
|
|
5883
|
-
|
|
6992
|
+
const duplicateCheckSuffix = secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
|
|
6993
|
+
|
|
6994
|
+
// `AxiosError.from()` may have already inlined the wrapped error's
|
|
6995
|
+
// stack under a `Caused by:` marker. Keep the reconstructed caller
|
|
6996
|
+
// frames ahead of that marker so stack-only reporters do not read
|
|
6997
|
+
// them as part of the low-level cause.
|
|
6998
|
+
const currentStack = String(err.stack);
|
|
6999
|
+
const causeIndex = getCauseStackIndex(err, currentStack);
|
|
7000
|
+
const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
|
|
7001
|
+
const causeSection = causeIndex === -1 ? '' : currentStack.slice(causeIndex);
|
|
7002
|
+
if (!stackHead.endsWith(duplicateCheckSuffix)) {
|
|
7003
|
+
err.stack = stackHead + '\n' + stack + causeSection;
|
|
5884
7004
|
}
|
|
5885
7005
|
}
|
|
5886
7006
|
} catch (e) {
|
|
5887
|
-
//
|
|
7007
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
5888
7008
|
}
|
|
5889
7009
|
}
|
|
5890
7010
|
throw err;
|
|
@@ -5912,7 +7032,8 @@ class Axios {
|
|
|
5912
7032
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
5913
7033
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
5914
7034
|
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
5915
|
-
validateStatusUndefinedResolves: validators.transitional(validators.boolean)
|
|
7035
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
7036
|
+
encodeBasicAuthUsername: validators.transitional(validators.boolean)
|
|
5916
7037
|
}, false);
|
|
5917
7038
|
}
|
|
5918
7039
|
if (paramsSerializer != null) {
|
|
@@ -5929,7 +7050,7 @@ class Axios {
|
|
|
5929
7050
|
}
|
|
5930
7051
|
|
|
5931
7052
|
// Set config.allowAbsoluteUrls
|
|
5932
|
-
if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
7053
|
+
if (config.allowAbsoluteUrls !== undefined) ; else if (utils$1.hasOwnProp(this.defaults, 'allowAbsoluteUrls') && this.defaults.allowAbsoluteUrls !== undefined) {
|
|
5933
7054
|
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
5934
7055
|
} else {
|
|
5935
7056
|
config.allowAbsoluteUrls = true;
|
|
@@ -5940,12 +7061,16 @@ class Axios {
|
|
|
5940
7061
|
}, true);
|
|
5941
7062
|
|
|
5942
7063
|
// Set config.method
|
|
5943
|
-
config.method = (config
|
|
5944
|
-
|
|
5945
|
-
// Flatten headers
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
7064
|
+
config.method = (utils$1.getSafeProp(config, 'method') || utils$1.getSafeProp(this.defaults, 'method') || 'get').toLowerCase();
|
|
7065
|
+
|
|
7066
|
+
// Flatten header defaults without consuming literal method-named headers.
|
|
7067
|
+
const commonHeaders = utils$1.getSafeProp(headers, 'common');
|
|
7068
|
+
const methodHeaders = utils$1.getSafeProp(headers, config.method);
|
|
7069
|
+
const contextHeaders = headers && utils$1.merge(isHeadersBucket(commonHeaders) ? commonHeaders : undefined, isHeadersBucket(methodHeaders) ? methodHeaders : undefined);
|
|
7070
|
+
headers && utils$1.forEach(methodList.concat('common'), method => {
|
|
7071
|
+
if (isHeadersBucket(utils$1.getSafeProp(headers, method))) {
|
|
7072
|
+
delete headers[method];
|
|
7073
|
+
}
|
|
5949
7074
|
});
|
|
5950
7075
|
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
5951
7076
|
|
|
@@ -6030,7 +7155,7 @@ class Axios {
|
|
|
6030
7155
|
// Provide aliases for supported request methods
|
|
6031
7156
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
6032
7157
|
/*eslint func-names:0*/
|
|
6033
|
-
Axios.prototype[method] = function (url, config) {
|
|
7158
|
+
Axios.prototype[method] = async function (url, config) {
|
|
6034
7159
|
return this.request(mergeConfig(config || {}, {
|
|
6035
7160
|
method,
|
|
6036
7161
|
url,
|
|
@@ -6040,7 +7165,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
6040
7165
|
});
|
|
6041
7166
|
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
6042
7167
|
function generateHTTPMethod(isForm) {
|
|
6043
|
-
return function httpMethod(url, data, config) {
|
|
7168
|
+
return async function httpMethod(url, data, config) {
|
|
6044
7169
|
return this.request(mergeConfig(config || {}, {
|
|
6045
7170
|
method,
|
|
6046
7171
|
headers: isForm ? {
|
|
@@ -6250,14 +7375,22 @@ const HttpStatusCode = {
|
|
|
6250
7375
|
Gone: 410,
|
|
6251
7376
|
LengthRequired: 411,
|
|
6252
7377
|
PreconditionFailed: 412,
|
|
7378
|
+
/**
|
|
7379
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
7380
|
+
*/
|
|
6253
7381
|
PayloadTooLarge: 413,
|
|
7382
|
+
ContentTooLarge: 413,
|
|
6254
7383
|
UriTooLong: 414,
|
|
6255
7384
|
UnsupportedMediaType: 415,
|
|
6256
7385
|
RangeNotSatisfiable: 416,
|
|
6257
7386
|
ExpectationFailed: 417,
|
|
6258
7387
|
ImATeapot: 418,
|
|
6259
7388
|
MisdirectedRequest: 421,
|
|
7389
|
+
/**
|
|
7390
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
7391
|
+
*/
|
|
6260
7392
|
UnprocessableEntity: 422,
|
|
7393
|
+
UnprocessableContent: 422,
|
|
6261
7394
|
Locked: 423,
|
|
6262
7395
|
FailedDependency: 424,
|
|
6263
7396
|
TooEarly: 425,
|
|
@@ -6286,7 +7419,9 @@ const HttpStatusCode = {
|
|
|
6286
7419
|
InvalidSslCertificate: 526
|
|
6287
7420
|
};
|
|
6288
7421
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
6289
|
-
HttpStatusCode[value]
|
|
7422
|
+
if (HttpStatusCode[value] === undefined) {
|
|
7423
|
+
HttpStatusCode[value] = key;
|
|
7424
|
+
}
|
|
6290
7425
|
});
|
|
6291
7426
|
|
|
6292
7427
|
/**
|