@airgap/coinlib-core 0.13.46 → 0.13.47
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/dependencies/src/axios-0.33.0/index.d.ts +345 -0
- package/dependencies/src/axios-0.33.0/lib/adapters/http.js +771 -0
- package/dependencies/src/axios-0.33.0/lib/adapters/xhr.js +305 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/axios.js +22 -7
- package/dependencies/src/axios-0.33.0/lib/cancel/CancelToken.js +118 -0
- package/dependencies/src/axios-0.33.0/lib/cancel/CanceledError.js +24 -0
- package/dependencies/src/axios-0.33.0/lib/core/Axios.js +178 -0
- package/dependencies/src/axios-0.33.0/lib/core/AxiosError.js +173 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/InterceptorManager.js +13 -2
- package/dependencies/src/axios-0.33.0/lib/core/buildFullPath.js +23 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/dispatchRequest.js +34 -16
- package/dependencies/src/axios-0.33.0/lib/core/mergeConfig.js +117 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/settle.js +4 -4
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/transformData.js +5 -2
- package/dependencies/src/axios-0.33.0/lib/defaults/index.js +181 -0
- package/dependencies/src/axios-0.33.0/lib/defaults/transitional.js +7 -0
- package/dependencies/src/axios-0.33.0/lib/env/classes/FormData.js +2 -0
- package/dependencies/src/axios-0.33.0/lib/env/data.js +3 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/AxiosURLSearchParams.js +50 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/bind.js +7 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/buildURL.js +63 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/combineURLs.js +1 -1
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/cookies.js +15 -2
- package/dependencies/src/axios-0.33.0/lib/helpers/defaultRedactKeys.js +3 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/estimateDataURLDecodedBytes.js +79 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/formDataToJSON.js +91 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/fromDataURI.js +51 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isAbsoluteURL.js +1 -1
- package/dependencies/src/axios-0.33.0/lib/helpers/isAxiosError.js +13 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isURLSameOrigin.js +12 -12
- package/dependencies/src/axios-0.33.0/lib/helpers/null.js +2 -0
- package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/parseHeaders.js +2 -2
- package/dependencies/src/axios-0.33.0/lib/helpers/parseProtocol.js +6 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/sanitizeHeaderValue.js +22 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/shouldBypassProxy.js +187 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/toFormData.js +212 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/toURLEncodedForm.js +18 -0
- package/dependencies/src/axios-0.33.0/lib/helpers/validator.js +86 -0
- package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/FormData.js +3 -0
- package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/dependencies/src/axios-0.33.0/lib/platform/browser/index.js +11 -0
- package/dependencies/src/axios-0.33.0/lib/platform/index.js +3 -0
- package/dependencies/src/axios-0.33.0/lib/platform/node/classes/FormData.js +3 -0
- package/dependencies/src/axios-0.33.0/lib/platform/node/classes/URLSearchParams.js +5 -0
- package/dependencies/src/axios-0.33.0/lib/platform/node/index.js +11 -0
- package/dependencies/src/axios-0.33.0/lib/utils.js +565 -0
- package/dependencies/src/axios-0.33.0/package.json +100 -0
- package/dependencies/src/{bn.js-4.11.8 → bn.js-4.11.9}/lib/bn.js +7 -1
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/base.js +36 -31
- package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/edwards.js +13 -10
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/mont.js +1 -1
- package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/short.js +48 -47
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curves.js +21 -21
- package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/ec/index.js +53 -16
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/key.js +8 -5
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/signature.js +11 -1
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/index.js +5 -2
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/signature.js +3 -2
- package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/precomputed/secp256k1.js +197 -197
- package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/utils.js +12 -9
- package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/package.json +20 -22
- package/dependencies/src/ethereumjs-util-5.2.0/index.js +1 -1
- package/dependencies/src/follow-redirects-1.16.0/debug.js +15 -0
- package/dependencies/src/follow-redirects-1.16.0/index.js +709 -0
- package/dependencies/src/follow-redirects-1.16.0/package.json +58 -0
- package/dependencies/src/proxy-from-env-1.1.0/index.js +108 -0
- package/dependencies/src/proxy-from-env-1.1.0/package.json +34 -0
- package/dependencies/src/secp256k1-3.7.1/lib/elliptic/index.js +2 -2
- package/dependencies/src/secp256k1-4.0.2/lib/elliptic.js +1 -1
- package/dependencies/src/tiny-secp256k1-1.1.3/js.js +2 -2
- package/errors/index.d.ts +2 -2
- package/errors/index.js.map +1 -1
- package/package.json +2 -2
- package/utils/remote-data/HttpRemoteData.js +3 -8
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +13 -7
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.js +5 -6
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/remote-data/remoteDataRequest.d.ts +16 -0
- package/utils/remote-data/remoteDataRequest.js +240 -0
- package/utils/remote-data/remoteDataRequest.js.map +1 -0
- package/dependencies/src/axios-0.19.0/index.d.ts +0 -152
- package/dependencies/src/axios-0.19.0/lib/adapters/http.js +0 -275
- package/dependencies/src/axios-0.19.0/lib/adapters/xhr.js +0 -174
- package/dependencies/src/axios-0.19.0/lib/cancel/Cancel.js +0 -19
- package/dependencies/src/axios-0.19.0/lib/cancel/CancelToken.js +0 -57
- package/dependencies/src/axios-0.19.0/lib/core/Axios.js +0 -86
- package/dependencies/src/axios-0.19.0/lib/core/createError.js +0 -18
- package/dependencies/src/axios-0.19.0/lib/core/enhanceError.js +0 -42
- package/dependencies/src/axios-0.19.0/lib/core/mergeConfig.js +0 -51
- package/dependencies/src/axios-0.19.0/lib/defaults.js +0 -98
- package/dependencies/src/axios-0.19.0/lib/helpers/bind.js +0 -11
- package/dependencies/src/axios-0.19.0/lib/helpers/buildURL.js +0 -71
- package/dependencies/src/axios-0.19.0/lib/utils.js +0 -334
- package/dependencies/src/axios-0.19.0/package.json +0 -85
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/base.js +0 -374
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/mont.js +0 -178
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/curves.js +0 -206
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/key.js +0 -118
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/signature.js +0 -134
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/index.js +0 -118
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/signature.js +0 -65
- package/dependencies/src/elliptic-6.5.1/lib/elliptic/utils.js +0 -120
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/edwards.js +0 -432
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/index.js +0 -8
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/short.js +0 -937
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/index.js +0 -241
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/key.js +0 -95
- package/dependencies/src/elliptic-6.5.3/lib/elliptic/precomputed/secp256k1.js +0 -780
- package/dependencies/src/elliptic-6.5.3/lib/elliptic.js +0 -13
- package/dependencies/src/elliptic-6.5.3/package.json +0 -55
- package/dependencies/src/follow-redirects-1.5.10/index.js +0 -322
- package/dependencies/src/is-buffer-2.0.3/index.js +0 -11
- /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/index.js +0 -0
- /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/cancel/isCancel.js +0 -0
- /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/deprecatedMethod.js +0 -0
- /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/normalizeHeaderName.js +0 -0
- /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/spread.js +0 -0
- /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/index.js +0 -0
- /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/eddsa/key.js +0 -0
- /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic.js +0 -0
- /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/http.js +0 -0
- /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/https.js +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
var AxiosError = require('../core/AxiosError');
|
|
5
|
+
var envFormData = require('../env/classes/FormData');
|
|
6
|
+
|
|
7
|
+
function isVisitable(thing) {
|
|
8
|
+
return utils.isPlainObject(thing) || utils.isArray(thing);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function removeBrackets(key) {
|
|
12
|
+
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function renderKey(path, key, dots) {
|
|
16
|
+
if (!path) return key;
|
|
17
|
+
return path.concat(key).map(function each(token, i) {
|
|
18
|
+
// eslint-disable-next-line no-param-reassign
|
|
19
|
+
token = removeBrackets(token);
|
|
20
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
21
|
+
}).join(dots ? '.' : '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isFlatArray(arr) {
|
|
25
|
+
return utils.isArray(arr) && !arr.some(isVisitable);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
29
|
+
return /^is[A-Z]/.test(prop);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function isSpecCompliant(thing) {
|
|
33
|
+
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Convert a data object to FormData
|
|
38
|
+
* @param {Object} obj
|
|
39
|
+
* @param {?Object} [formData]
|
|
40
|
+
* @param {?Object} [options]
|
|
41
|
+
* @param {Function} [options.visitor]
|
|
42
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
43
|
+
* @param {Boolean} [options.dots = false]
|
|
44
|
+
* @param {?Boolean} [options.indexes = false]
|
|
45
|
+
* @returns {Object}
|
|
46
|
+
**/
|
|
47
|
+
|
|
48
|
+
function toFormData(obj, formData, options) {
|
|
49
|
+
if (!utils.isObject(obj)) {
|
|
50
|
+
throw new TypeError('target must be an object');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line no-param-reassign
|
|
54
|
+
formData = formData || new (envFormData || FormData)();
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
options = utils.toFlatObject(options, {
|
|
58
|
+
metaTokens: true,
|
|
59
|
+
dots: false,
|
|
60
|
+
indexes: false
|
|
61
|
+
}, false, function defined(option, source) {
|
|
62
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
63
|
+
return !utils.isUndefined(source[option]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
var metaTokens = options.metaTokens;
|
|
67
|
+
// eslint-disable-next-line no-use-before-define
|
|
68
|
+
var visitor = options.visitor || defaultVisitor;
|
|
69
|
+
var dots = options.dots;
|
|
70
|
+
var indexes = options.indexes;
|
|
71
|
+
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
72
|
+
var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
73
|
+
var useBlob = _Blob && isSpecCompliant(formData);
|
|
74
|
+
|
|
75
|
+
if (!utils.isFunction(visitor)) {
|
|
76
|
+
throw new TypeError('visitor must be a function');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function convertValue(value) {
|
|
80
|
+
if (value === null) return '';
|
|
81
|
+
|
|
82
|
+
if (utils.isDate(value)) {
|
|
83
|
+
return value.toISOString();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!useBlob && utils.isBlob(value)) {
|
|
87
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
|
91
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var stack = [];
|
|
98
|
+
|
|
99
|
+
function assertValueDepth(value, depth) {
|
|
100
|
+
if (depth > maxDepth) {
|
|
101
|
+
throw new AxiosError(
|
|
102
|
+
'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
|
|
103
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!utils.isObject(value) || stack.indexOf(value) !== -1) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
stack.push(value);
|
|
112
|
+
|
|
113
|
+
utils.forEach(value, function each(el) {
|
|
114
|
+
assertValueDepth(el, depth + 1);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
stack.pop();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @param {*} value
|
|
123
|
+
* @param {String|Number} key
|
|
124
|
+
* @param {Array<String|Number>} path
|
|
125
|
+
* @this {FormData}
|
|
126
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
127
|
+
*/
|
|
128
|
+
function defaultVisitor(value, key, path) {
|
|
129
|
+
var arr = value;
|
|
130
|
+
|
|
131
|
+
if (value && !path && typeof value === 'object') {
|
|
132
|
+
if (utils.endsWith(key, '{}')) {
|
|
133
|
+
// eslint-disable-next-line no-param-reassign
|
|
134
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
135
|
+
assertValueDepth(value, 1);
|
|
136
|
+
// eslint-disable-next-line no-param-reassign
|
|
137
|
+
value = JSON.stringify(value);
|
|
138
|
+
} else if (
|
|
139
|
+
(utils.isArray(value) && isFlatArray(value)) ||
|
|
140
|
+
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
|
141
|
+
)) {
|
|
142
|
+
// eslint-disable-next-line no-param-reassign
|
|
143
|
+
key = removeBrackets(key);
|
|
144
|
+
|
|
145
|
+
arr.forEach(function each(el, index) {
|
|
146
|
+
!(utils.isUndefined(el) || el === null) && formData.append(
|
|
147
|
+
// eslint-disable-next-line no-nested-ternary
|
|
148
|
+
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
149
|
+
convertValue(el)
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (isVisitable(value)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
161
|
+
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var exposedHelpers = Object.assign(predicates, {
|
|
166
|
+
defaultVisitor: defaultVisitor,
|
|
167
|
+
convertValue: convertValue,
|
|
168
|
+
isVisitable: isVisitable
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
function build(value, path, depth) {
|
|
172
|
+
if (utils.isUndefined(value)) return;
|
|
173
|
+
|
|
174
|
+
// eslint-disable-next-line no-param-reassign
|
|
175
|
+
depth = depth || 0;
|
|
176
|
+
|
|
177
|
+
if (depth > maxDepth) {
|
|
178
|
+
throw new AxiosError(
|
|
179
|
+
'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
|
|
180
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (stack.indexOf(value) !== -1) {
|
|
185
|
+
throw Error('Circular reference detected in ' + path.join('.'));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
stack.push(value);
|
|
189
|
+
|
|
190
|
+
utils.forEach(value, function each(el, key) {
|
|
191
|
+
var result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
192
|
+
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (result === true) {
|
|
196
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
stack.pop();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!utils.isObject(obj)) {
|
|
204
|
+
throw new TypeError('data must be an object');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
build(obj, null, 0);
|
|
208
|
+
|
|
209
|
+
return formData;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
module.exports = toFormData;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
var toFormData = require('./toFormData');
|
|
5
|
+
var platform = require('../platform/');
|
|
6
|
+
|
|
7
|
+
module.exports = function toURLEncodedForm(data, options) {
|
|
8
|
+
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
9
|
+
visitor: function(value, key, path, helpers) {
|
|
10
|
+
if (platform.isNode && utils.isBuffer(value)) {
|
|
11
|
+
this.append(key, value.toString('base64'));
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
}, options));
|
|
18
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var VERSION = require('../env/data').version;
|
|
4
|
+
var AxiosError = require('../core/AxiosError');
|
|
5
|
+
|
|
6
|
+
var validators = {};
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line func-names
|
|
9
|
+
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
|
|
10
|
+
validators[type] = function validator(thing) {
|
|
11
|
+
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var deprecatedWarnings = {};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transitional option validator
|
|
19
|
+
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
20
|
+
* @param {string?} version - deprecated version / removed since version
|
|
21
|
+
* @param {string?} message - some message with additional info
|
|
22
|
+
* @returns {function}
|
|
23
|
+
*/
|
|
24
|
+
validators.transitional = function transitional(validator, version, message) {
|
|
25
|
+
function formatMessage(opt, desc) {
|
|
26
|
+
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line func-names
|
|
30
|
+
return function(value, opt, opts) {
|
|
31
|
+
if (validator === false) {
|
|
32
|
+
throw new AxiosError(
|
|
33
|
+
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
34
|
+
AxiosError.ERR_DEPRECATED
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (version && !deprecatedWarnings[opt]) {
|
|
39
|
+
deprecatedWarnings[opt] = true;
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.warn(
|
|
42
|
+
formatMessage(
|
|
43
|
+
opt,
|
|
44
|
+
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return validator ? validator(value, opt, opts) : true;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Assert object's properties type
|
|
55
|
+
* @param {object} options
|
|
56
|
+
* @param {object} schema
|
|
57
|
+
* @param {boolean?} allowUnknown
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
61
|
+
if (typeof options !== 'object') {
|
|
62
|
+
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
63
|
+
}
|
|
64
|
+
var keys = Object.keys(options);
|
|
65
|
+
var i = keys.length;
|
|
66
|
+
while (i-- > 0) {
|
|
67
|
+
var opt = keys[i];
|
|
68
|
+
var validator = schema[opt];
|
|
69
|
+
if (validator) {
|
|
70
|
+
var value = options[opt];
|
|
71
|
+
var result = value === undefined || validator(value, opt, options);
|
|
72
|
+
if (result !== true) {
|
|
73
|
+
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (allowUnknown !== true) {
|
|
78
|
+
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
assertOptions: assertOptions,
|
|
85
|
+
validators: validators
|
|
86
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
isNode: true,
|
|
5
|
+
classes: {
|
|
6
|
+
URLSearchParams: require('./classes/URLSearchParams'),
|
|
7
|
+
FormData: require('./classes/FormData'),
|
|
8
|
+
Blob: typeof Blob !== 'undefined' && Blob || null
|
|
9
|
+
},
|
|
10
|
+
protocols: [ 'http', 'https', 'file', 'data' ]
|
|
11
|
+
};
|