@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.
Files changed (124) hide show
  1. package/dependencies/src/axios-0.33.0/index.d.ts +345 -0
  2. package/dependencies/src/axios-0.33.0/lib/adapters/http.js +771 -0
  3. package/dependencies/src/axios-0.33.0/lib/adapters/xhr.js +305 -0
  4. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/axios.js +22 -7
  5. package/dependencies/src/axios-0.33.0/lib/cancel/CancelToken.js +118 -0
  6. package/dependencies/src/axios-0.33.0/lib/cancel/CanceledError.js +24 -0
  7. package/dependencies/src/axios-0.33.0/lib/core/Axios.js +178 -0
  8. package/dependencies/src/axios-0.33.0/lib/core/AxiosError.js +173 -0
  9. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/InterceptorManager.js +13 -2
  10. package/dependencies/src/axios-0.33.0/lib/core/buildFullPath.js +23 -0
  11. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/dispatchRequest.js +34 -16
  12. package/dependencies/src/axios-0.33.0/lib/core/mergeConfig.js +117 -0
  13. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/settle.js +4 -4
  14. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/transformData.js +5 -2
  15. package/dependencies/src/axios-0.33.0/lib/defaults/index.js +181 -0
  16. package/dependencies/src/axios-0.33.0/lib/defaults/transitional.js +7 -0
  17. package/dependencies/src/axios-0.33.0/lib/env/classes/FormData.js +2 -0
  18. package/dependencies/src/axios-0.33.0/lib/env/data.js +3 -0
  19. package/dependencies/src/axios-0.33.0/lib/helpers/AxiosURLSearchParams.js +50 -0
  20. package/dependencies/src/axios-0.33.0/lib/helpers/bind.js +7 -0
  21. package/dependencies/src/axios-0.33.0/lib/helpers/buildURL.js +63 -0
  22. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/combineURLs.js +1 -1
  23. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/cookies.js +15 -2
  24. package/dependencies/src/axios-0.33.0/lib/helpers/defaultRedactKeys.js +3 -0
  25. package/dependencies/src/axios-0.33.0/lib/helpers/estimateDataURLDecodedBytes.js +79 -0
  26. package/dependencies/src/axios-0.33.0/lib/helpers/formDataToJSON.js +91 -0
  27. package/dependencies/src/axios-0.33.0/lib/helpers/fromDataURI.js +51 -0
  28. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isAbsoluteURL.js +1 -1
  29. package/dependencies/src/axios-0.33.0/lib/helpers/isAxiosError.js +13 -0
  30. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isURLSameOrigin.js +12 -12
  31. package/dependencies/src/axios-0.33.0/lib/helpers/null.js +2 -0
  32. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/parseHeaders.js +2 -2
  33. package/dependencies/src/axios-0.33.0/lib/helpers/parseProtocol.js +6 -0
  34. package/dependencies/src/axios-0.33.0/lib/helpers/sanitizeHeaderValue.js +22 -0
  35. package/dependencies/src/axios-0.33.0/lib/helpers/shouldBypassProxy.js +187 -0
  36. package/dependencies/src/axios-0.33.0/lib/helpers/toFormData.js +212 -0
  37. package/dependencies/src/axios-0.33.0/lib/helpers/toURLEncodedForm.js +18 -0
  38. package/dependencies/src/axios-0.33.0/lib/helpers/validator.js +86 -0
  39. package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/FormData.js +3 -0
  40. package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/URLSearchParams.js +5 -0
  41. package/dependencies/src/axios-0.33.0/lib/platform/browser/index.js +11 -0
  42. package/dependencies/src/axios-0.33.0/lib/platform/index.js +3 -0
  43. package/dependencies/src/axios-0.33.0/lib/platform/node/classes/FormData.js +3 -0
  44. package/dependencies/src/axios-0.33.0/lib/platform/node/classes/URLSearchParams.js +5 -0
  45. package/dependencies/src/axios-0.33.0/lib/platform/node/index.js +11 -0
  46. package/dependencies/src/axios-0.33.0/lib/utils.js +565 -0
  47. package/dependencies/src/axios-0.33.0/package.json +100 -0
  48. package/dependencies/src/{bn.js-4.11.8 → bn.js-4.11.9}/lib/bn.js +7 -1
  49. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/base.js +36 -31
  50. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/edwards.js +13 -10
  51. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/mont.js +1 -1
  52. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/short.js +48 -47
  53. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curves.js +21 -21
  54. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/ec/index.js +53 -16
  55. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/key.js +8 -5
  56. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/signature.js +11 -1
  57. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/index.js +5 -2
  58. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/signature.js +3 -2
  59. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/precomputed/secp256k1.js +197 -197
  60. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/utils.js +12 -9
  61. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/package.json +20 -22
  62. package/dependencies/src/ethereumjs-util-5.2.0/index.js +1 -1
  63. package/dependencies/src/follow-redirects-1.16.0/debug.js +15 -0
  64. package/dependencies/src/follow-redirects-1.16.0/index.js +709 -0
  65. package/dependencies/src/follow-redirects-1.16.0/package.json +58 -0
  66. package/dependencies/src/proxy-from-env-1.1.0/index.js +108 -0
  67. package/dependencies/src/proxy-from-env-1.1.0/package.json +34 -0
  68. package/dependencies/src/secp256k1-3.7.1/lib/elliptic/index.js +2 -2
  69. package/dependencies/src/secp256k1-4.0.2/lib/elliptic.js +1 -1
  70. package/dependencies/src/tiny-secp256k1-1.1.3/js.js +2 -2
  71. package/errors/index.d.ts +2 -2
  72. package/errors/index.js.map +1 -1
  73. package/package.json +2 -2
  74. package/utils/remote-data/HttpRemoteData.js +3 -8
  75. package/utils/remote-data/HttpRemoteData.js.map +1 -1
  76. package/utils/remote-data/IpfsRemoteData.js +13 -7
  77. package/utils/remote-data/IpfsRemoteData.js.map +1 -1
  78. package/utils/remote-data/Sha256RemoteData.js +5 -6
  79. package/utils/remote-data/Sha256RemoteData.js.map +1 -1
  80. package/utils/remote-data/remoteDataRequest.d.ts +16 -0
  81. package/utils/remote-data/remoteDataRequest.js +240 -0
  82. package/utils/remote-data/remoteDataRequest.js.map +1 -0
  83. package/dependencies/src/axios-0.19.0/index.d.ts +0 -152
  84. package/dependencies/src/axios-0.19.0/lib/adapters/http.js +0 -275
  85. package/dependencies/src/axios-0.19.0/lib/adapters/xhr.js +0 -174
  86. package/dependencies/src/axios-0.19.0/lib/cancel/Cancel.js +0 -19
  87. package/dependencies/src/axios-0.19.0/lib/cancel/CancelToken.js +0 -57
  88. package/dependencies/src/axios-0.19.0/lib/core/Axios.js +0 -86
  89. package/dependencies/src/axios-0.19.0/lib/core/createError.js +0 -18
  90. package/dependencies/src/axios-0.19.0/lib/core/enhanceError.js +0 -42
  91. package/dependencies/src/axios-0.19.0/lib/core/mergeConfig.js +0 -51
  92. package/dependencies/src/axios-0.19.0/lib/defaults.js +0 -98
  93. package/dependencies/src/axios-0.19.0/lib/helpers/bind.js +0 -11
  94. package/dependencies/src/axios-0.19.0/lib/helpers/buildURL.js +0 -71
  95. package/dependencies/src/axios-0.19.0/lib/utils.js +0 -334
  96. package/dependencies/src/axios-0.19.0/package.json +0 -85
  97. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/base.js +0 -374
  98. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/mont.js +0 -178
  99. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curves.js +0 -206
  100. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/key.js +0 -118
  101. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/signature.js +0 -134
  102. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/index.js +0 -118
  103. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/signature.js +0 -65
  104. package/dependencies/src/elliptic-6.5.1/lib/elliptic/utils.js +0 -120
  105. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/edwards.js +0 -432
  106. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/index.js +0 -8
  107. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/short.js +0 -937
  108. package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/index.js +0 -241
  109. package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/key.js +0 -95
  110. package/dependencies/src/elliptic-6.5.3/lib/elliptic/precomputed/secp256k1.js +0 -780
  111. package/dependencies/src/elliptic-6.5.3/lib/elliptic.js +0 -13
  112. package/dependencies/src/elliptic-6.5.3/package.json +0 -55
  113. package/dependencies/src/follow-redirects-1.5.10/index.js +0 -322
  114. package/dependencies/src/is-buffer-2.0.3/index.js +0 -11
  115. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/index.js +0 -0
  116. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/cancel/isCancel.js +0 -0
  117. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/deprecatedMethod.js +0 -0
  118. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/normalizeHeaderName.js +0 -0
  119. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/spread.js +0 -0
  120. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/index.js +0 -0
  121. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/eddsa/key.js +0 -0
  122. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic.js +0 -0
  123. /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/http.js +0 -0
  124. /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/https.js +0 -0
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var toFormData = require('./toFormData');
4
+
5
+ function encode(str) {
6
+ // Do not map `%00` back to a raw null byte: that reversed
7
+ // the safe percent-encoding from encodeURIComponent and enabled null byte injection.
8
+ var charMap = {
9
+ '!': '%21',
10
+ "'": '%27',
11
+ '(': '%28',
12
+ ')': '%29',
13
+ '~': '%7E',
14
+ '%20': '+'
15
+ };
16
+ return encodeURIComponent(str).replace(
17
+ /[!'\(\)~]|%20/g,
18
+ function replacer(match) {
19
+ return charMap[match];
20
+ }
21
+ );
22
+ }
23
+
24
+ function AxiosURLSearchParams(params, options) {
25
+ this._pairs = [];
26
+
27
+ params && toFormData(params, this, options);
28
+ }
29
+
30
+ var prototype = AxiosURLSearchParams.prototype;
31
+
32
+ prototype.append = function append(name, value) {
33
+ this._pairs.push([name, value]);
34
+ };
35
+
36
+ prototype.toString = function toString(encoder) {
37
+ var _encode = encoder
38
+ ? function(value) {
39
+ return encoder.call(this, value, encode);
40
+ }
41
+ : encode;
42
+
43
+ return this._pairs
44
+ .map(function each(pair) {
45
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
46
+ }, '')
47
+ .join('&');
48
+ };
49
+
50
+ module.exports = AxiosURLSearchParams;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports = function bind(fn, thisArg) {
4
+ return function wrap() {
5
+ return fn.apply(thisArg, arguments);
6
+ };
7
+ };
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+ var AxiosURLSearchParams = require('../helpers/AxiosURLSearchParams');
5
+
6
+ function encode(val) {
7
+ return encodeURIComponent(val).
8
+ replace(/%3A/gi, ':').
9
+ replace(/%24/g, '$').
10
+ replace(/%2C/gi, ',').
11
+ replace(/%20/g, '+').
12
+ replace(/%5B/gi, '[').
13
+ replace(/%5D/gi, ']');
14
+ }
15
+
16
+ /**
17
+ * Build a URL by appending params to the end
18
+ *
19
+ * @param {string} url The base of the url (e.g., http://www.google.com)
20
+ * @param {object} [params] The params to be appended
21
+ * @param {?object} options
22
+ * @returns {string} The formatted url
23
+ */
24
+ module.exports = function buildURL(url, params, options) {
25
+ /*eslint no-param-reassign:0*/
26
+ if (!params) {
27
+ return url;
28
+ }
29
+
30
+ var hashmarkIndex = url.indexOf('#');
31
+
32
+ if (hashmarkIndex !== -1) {
33
+ url = url.slice(0, hashmarkIndex);
34
+ }
35
+
36
+ var _encode = encode;
37
+ var serializeFn;
38
+
39
+ if (options) {
40
+ if (utils.isFunction(options)) {
41
+ serializeFn = options;
42
+ } else {
43
+ _encode = utils.hasOwnProperty(options, 'encode') && options.encode || encode;
44
+ serializeFn = utils.hasOwnProperty(options, 'serialize') ? options.serialize : undefined;
45
+ }
46
+ }
47
+
48
+ var serializedParams;
49
+
50
+ if (serializeFn) {
51
+ serializedParams = serializeFn(params, options);
52
+ } else {
53
+ serializedParams = utils.isURLSearchParams(params) ?
54
+ params.toString() :
55
+ new AxiosURLSearchParams(params, options).toString(_encode);
56
+ }
57
+
58
+ if (serializedParams) {
59
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
60
+ }
61
+
62
+ return url;
63
+ };
@@ -9,6 +9,6 @@
9
9
  */
10
10
  module.exports = function combineURLs(baseURL, relativeURL) {
11
11
  return relativeURL
12
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
12
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
13
13
  : baseURL;
14
14
  };
@@ -32,8 +32,21 @@ module.exports = (
32
32
  },
33
33
 
34
34
  read: function read(name) {
35
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36
- return (match ? decodeURIComponent(match[3]) : null);
35
+ var nameEQ = name + '=';
36
+ var cookies = document.cookie.split(';');
37
+ var cookie;
38
+
39
+ for (var i = 0; i < cookies.length; i++) {
40
+ cookie = cookies[i];
41
+ while (cookie.charAt(0) === ' ') {
42
+ cookie = cookie.substring(1);
43
+ }
44
+ if (cookie.indexOf(nameEQ) === 0) {
45
+ return decodeURIComponent(cookie.substring(nameEQ.length));
46
+ }
47
+ }
48
+
49
+ return null;
37
50
  },
38
51
 
39
52
  remove: function remove(name) {
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = ['authorization', 'proxy-authorization', 'cookie', 'set-cookie', 'x-api-key', 'password'];
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
5
+ * - For base64: compute exact decoded size using length and padding;
6
+ * handle %XX at the character-count level (no string allocation).
7
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
8
+ *
9
+ * @param {string} url
10
+ * @returns {number}
11
+ */
12
+ function estimateDataURLDecodedBytes(url) {
13
+ if (!url || typeof url !== 'string') return 0;
14
+ if (!url.startsWith('data:')) return 0;
15
+
16
+ var comma = url.indexOf(',');
17
+ if (comma < 0) return 0;
18
+
19
+ var meta = url.slice(5, comma);
20
+ var body = url.slice(comma + 1);
21
+ var isBase64 = /;base64/i.test(meta);
22
+
23
+ if (isBase64) {
24
+ var effectiveLen = body.length;
25
+ var len = body.length; // cache length
26
+
27
+ for (var i = 0; i < len; i++) {
28
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
29
+ var a = body.charCodeAt(i + 1);
30
+ var b = body.charCodeAt(i + 2);
31
+ var isHex =
32
+ ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
33
+ ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
34
+
35
+ if (isHex) {
36
+ effectiveLen -= 2;
37
+ i += 2;
38
+ }
39
+ }
40
+ }
41
+
42
+ var pad = 0;
43
+ var idx = len - 1;
44
+
45
+ // eslint-disable-next-line no-inner-declarations
46
+ function tailIsPct3D(j) {
47
+ return j >= 2 &&
48
+ body.charCodeAt(j - 2) === 37 && // '%'
49
+ body.charCodeAt(j - 1) === 51 && // '3'
50
+ (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
51
+ }
52
+
53
+ if (idx >= 0) {
54
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
55
+ pad++;
56
+ idx--;
57
+ } else if (tailIsPct3D(idx)) {
58
+ pad++;
59
+ idx -= 3;
60
+ }
61
+ }
62
+
63
+ if (pad === 1 && idx >= 0) {
64
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
65
+ pad++;
66
+ } else if (tailIsPct3D(idx)) {
67
+ pad++;
68
+ }
69
+ }
70
+
71
+ var groups = Math.floor(effectiveLen / 4);
72
+ var bytes = groups * 3 - (pad || 0);
73
+ return bytes > 0 ? bytes : 0;
74
+ }
75
+
76
+ return Buffer.byteLength(body, 'utf8');
77
+ }
78
+
79
+ module.exports = estimateDataURLDecodedBytes;
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+ var AxiosError = require('../core/AxiosError');
5
+
6
+ var MAX_FORM_DATA_TO_JSON_DEPTH = 100;
7
+
8
+ function assertPathDepth(path) {
9
+ var depth = path.length - 1;
10
+
11
+ if (depth > MAX_FORM_DATA_TO_JSON_DEPTH) {
12
+ throw new AxiosError(
13
+ 'Maximum object depth of ' + MAX_FORM_DATA_TO_JSON_DEPTH + ' exceeded (got ' + depth + ' levels)',
14
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
15
+ );
16
+ }
17
+ }
18
+
19
+ function parsePropPath(name) {
20
+ // foo[x][y][z]
21
+ // foo.x.y.z
22
+ // foo-x-y-z
23
+ // foo x y z
24
+ return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function(match) {
25
+ return match[0] === '[]' ? '' : match[1] || match[0];
26
+ });
27
+ }
28
+
29
+ function arrayToObject(arr) {
30
+ var obj = {};
31
+ var keys = Object.keys(arr);
32
+ var i;
33
+ var len = keys.length;
34
+ var key;
35
+ for (i = 0; i < len; i++) {
36
+ key = keys[i];
37
+ obj[key] = arr[key];
38
+ }
39
+ return obj;
40
+ }
41
+
42
+ function formDataToJSON(formData) {
43
+ function buildPath(path, value, target, index) {
44
+ var name = path[index++];
45
+
46
+ if (name === '__proto__') return true;
47
+
48
+ var isNumericKey = Number.isFinite(+name);
49
+ var isLast = index >= path.length;
50
+ name = !name && utils.isArray(target) ? target.length : name;
51
+
52
+ if (isLast) {
53
+ if (utils.hasOwnProperty(target, name)) {
54
+ target[name] = [target[name], value];
55
+ } else {
56
+ target[name] = value;
57
+ }
58
+
59
+ return !isNumericKey;
60
+ }
61
+
62
+ if (!target[name] || !utils.isObject(target[name])) {
63
+ target[name] = [];
64
+ }
65
+
66
+ var result = buildPath(path, value, target[name], index);
67
+
68
+ if (result && utils.isArray(target[name])) {
69
+ target[name] = arrayToObject(target[name]);
70
+ }
71
+
72
+ return !isNumericKey;
73
+ }
74
+
75
+ if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
76
+ var obj = {};
77
+
78
+ utils.forEachEntry(formData, function(name, value) {
79
+ var path = parsePropPath(name);
80
+
81
+ assertPathDepth(path);
82
+ buildPath(path, value, obj, 0);
83
+ });
84
+
85
+ return obj;
86
+ }
87
+
88
+ return null;
89
+ }
90
+
91
+ module.exports = formDataToJSON;
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var AxiosError = require('../core/AxiosError');
4
+ var parseProtocol = require('./parseProtocol');
5
+ var platform = require('../platform');
6
+
7
+ var DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
8
+
9
+ /**
10
+ * Parse data uri to a Buffer or Blob
11
+ * @param {String} uri
12
+ * @param {?Boolean} asBlob
13
+ * @param {?Object} options
14
+ * @param {?Function} options.Blob
15
+ * @returns {Buffer|Blob}
16
+ */
17
+ module.exports = function fromDataURI(uri, asBlob, options) {
18
+ var _Blob = options && options.Blob || platform.classes.Blob;
19
+ var protocol = parseProtocol(uri);
20
+
21
+ if (asBlob === undefined && _Blob) {
22
+ asBlob = true;
23
+ }
24
+
25
+ if (protocol === 'data') {
26
+ uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
27
+
28
+ var match = DATA_URL_PATTERN.exec(uri);
29
+
30
+ if (!match) {
31
+ throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
32
+ }
33
+
34
+ var mime = match[1];
35
+ var isBase64 = match[2];
36
+ var body = match[3];
37
+ var buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
38
+
39
+ if (asBlob) {
40
+ if (!_Blob) {
41
+ throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
42
+ }
43
+
44
+ return new _Blob([buffer], {type: mime});
45
+ }
46
+
47
+ return buffer;
48
+ }
49
+
50
+ throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
51
+ };
@@ -10,5 +10,5 @@ module.exports = function isAbsoluteURL(url) {
10
10
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
11
11
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
12
12
  // by any combination of letters, digits, plus, period, or hyphen.
13
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
13
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
14
14
  };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./../utils');
4
+
5
+ /**
6
+ * Determines whether the payload is an error thrown by Axios
7
+ *
8
+ * @param {*} payload The value to test
9
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
10
+ */
11
+ module.exports = function isAxiosError(payload) {
12
+ return utils.isObject(payload) && (payload.isAxiosError === true);
13
+ };
@@ -13,16 +13,16 @@ module.exports = (
13
13
  var originURL;
14
14
 
15
15
  /**
16
- * Parse a URL to discover it's components
17
- *
18
- * @param {String} url The URL to be parsed
19
- * @returns {Object}
20
- */
16
+ * Parse a URL to discover it's components
17
+ *
18
+ * @param {String} url The URL to be parsed
19
+ * @returns {Object}
20
+ */
21
21
  function resolveURL(url) {
22
22
  var href = url;
23
23
 
24
24
  if (msie) {
25
- // IE needs attribute set twice to normalize properties
25
+ // IE needs attribute set twice to normalize properties
26
26
  urlParsingNode.setAttribute('href', href);
27
27
  href = urlParsingNode.href;
28
28
  }
@@ -47,11 +47,11 @@ module.exports = (
47
47
  originURL = resolveURL(window.location.href);
48
48
 
49
49
  /**
50
- * Determine if a URL shares the same origin as the current location
51
- *
52
- * @param {String} requestURL The URL to test
53
- * @returns {boolean} True if URL shares the same origin, otherwise false
54
- */
50
+ * Determine if a URL shares the same origin as the current location
51
+ *
52
+ * @param {String} requestURL The URL to test
53
+ * @returns {boolean} True if URL shares the same origin, otherwise false
54
+ */
55
55
  return function isURLSameOrigin(requestURL) {
56
56
  var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57
57
  return (parsed.protocol === originURL.protocol &&
@@ -59,7 +59,7 @@ module.exports = (
59
59
  };
60
60
  })() :
61
61
 
62
- // Non standard browser envs (web workers, react-native) lack needed support.
62
+ // Non standard browser envs (web workers, react-native) lack needed support.
63
63
  (function nonStandardBrowserEnv() {
64
64
  return function isURLSameOrigin() {
65
65
  return true;
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line strict
2
+ module.exports = null;
@@ -34,8 +34,8 @@ module.exports = function parseHeaders(headers) {
34
34
 
35
35
  utils.forEach(headers.split('\n'), function parser(line) {
36
36
  i = line.indexOf(':');
37
- key = utils.trim(line.substr(0, i)).toLowerCase();
38
- val = utils.trim(line.substr(i + 1));
37
+ key = utils.trim(line.slice(0, i)).toLowerCase();
38
+ val = utils.trim(line.slice(i + 1));
39
39
 
40
40
  if (key) {
41
41
  if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ module.exports = function parseProtocol(url) {
4
+ var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
5
+ return match && match[1] || '';
6
+ };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+
5
+ var INVALID_HEADER_VALUE_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
6
+ var BOUNDARY_WHITESPACE_RE = /^[\x09\x20]+|[\x09\x20]+$/g;
7
+
8
+ function sanitizeHeaderValue(value) {
9
+ if (value === false || value == null) {
10
+ return value;
11
+ }
12
+
13
+ if (utils.isArray(value)) {
14
+ return value.map(sanitizeHeaderValue);
15
+ }
16
+
17
+ return String(value)
18
+ .replace(INVALID_HEADER_VALUE_RE, '')
19
+ .replace(BOUNDARY_WHITESPACE_RE, '');
20
+ }
21
+
22
+ module.exports = sanitizeHeaderValue;
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+
3
+ var URL = require('url').URL;
4
+
5
+ var DEFAULT_PORTS = {
6
+ http: 80,
7
+ https: 443,
8
+ ws: 80,
9
+ wss: 443,
10
+ ftp: 21
11
+ };
12
+
13
+ function parseNoProxyEntry(entry) {
14
+ var entryHost = entry;
15
+ var entryPort = 0;
16
+
17
+ if (entryHost.charAt(0) === '[') {
18
+ var bracketIndex = entryHost.indexOf(']');
19
+
20
+ if (bracketIndex !== -1) {
21
+ var host = entryHost.slice(1, bracketIndex);
22
+ var rest = entryHost.slice(bracketIndex + 1);
23
+
24
+ if (rest.charAt(0) === ':' && /^\d+$/.test(rest.slice(1))) {
25
+ entryPort = parseInt(rest.slice(1), 10);
26
+ }
27
+
28
+ return [host, entryPort];
29
+ }
30
+ }
31
+
32
+ var firstColon = entryHost.indexOf(':');
33
+ var lastColon = entryHost.lastIndexOf(':');
34
+
35
+ if (firstColon !== -1 && firstColon === lastColon && /^\d+$/.test(entryHost.slice(lastColon + 1))) {
36
+ entryPort = parseInt(entryHost.slice(lastColon + 1), 10);
37
+ entryHost = entryHost.slice(0, lastColon);
38
+ }
39
+
40
+ return [entryHost, entryPort];
41
+ }
42
+
43
+ function parseIPv4Octets(hostname) {
44
+ var octets = hostname.split('.');
45
+
46
+ if (octets.length !== 4) {
47
+ return null;
48
+ }
49
+
50
+ for (var i = 0; i < octets.length; i++) {
51
+ if (!/^\d+$/.test(octets[i]) || Number(octets[i]) > 255) {
52
+ return null;
53
+ }
54
+ }
55
+
56
+ return octets;
57
+ }
58
+
59
+ // Recognises the canonical IPv4-mapped IPv6 forms the Node URL parser produces:
60
+ // ::ffff:127.0.0.1 (dotted-quad tail)
61
+ // ::ffff:7f00:1 (compressed two-group hex tail)
62
+ // Fully-expanded forms like 0:0:0:0:0:ffff:7f00:1 or single-group tails like
63
+ // ::ffff:1 are not normalised here. URL inputs are canonicalised by the parser
64
+ // before reaching this helper, but hand-crafted no_proxy entries in those
65
+ // shapes will not match an IPv4 listing.
66
+ function normalizeIPv4MappedIPv6(hostname) {
67
+ // Match against the lowercased form so a hand-crafted no_proxy entry like
68
+ // `[::FFFF:7F00:1]` still resolves to its IPv4 alias. Callers that route via
69
+ // URL parsing already lowercase, but the helper stays robust on its own.
70
+ var lower = hostname.toLowerCase();
71
+ var dottedMatch = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(lower);
72
+
73
+ if (dottedMatch) {
74
+ var octets = parseIPv4Octets(dottedMatch[1]);
75
+ return octets ? octets.join('.') : hostname;
76
+ }
77
+
78
+ var hexMatch = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(lower);
79
+
80
+ if (hexMatch) {
81
+ var high = parseInt(hexMatch[1], 16);
82
+ var low = parseInt(hexMatch[2], 16);
83
+
84
+ return [
85
+ (high >> 8) & 0xff,
86
+ high & 0xff,
87
+ (low >> 8) & 0xff,
88
+ low & 0xff
89
+ ].join('.');
90
+ }
91
+
92
+ return hostname;
93
+ }
94
+
95
+ function normalizeNoProxyHost(hostname) {
96
+ if (!hostname) {
97
+ return hostname;
98
+ }
99
+
100
+ if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
101
+ hostname = hostname.slice(1, -1);
102
+ }
103
+
104
+ hostname = hostname.replace(/\.+$/, '');
105
+
106
+ return normalizeIPv4MappedIPv6(hostname);
107
+ }
108
+
109
+ function isLoopbackIPv4(hostname) {
110
+ var octets = hostname.split('.');
111
+
112
+ if (octets.length !== 4) {
113
+ return false;
114
+ }
115
+
116
+ if (octets[0] !== '127') {
117
+ return false;
118
+ }
119
+
120
+ return octets.every(function testOctet(octet) {
121
+ return /^\d+$/.test(octet) && Number(octet) >= 0 && Number(octet) <= 255;
122
+ });
123
+ }
124
+
125
+ function isLoopbackHost(hostname) {
126
+ return hostname === 'localhost' || hostname === '::1' || hostname === '0.0.0.0' || isLoopbackIPv4(hostname);
127
+ }
128
+
129
+ module.exports = function shouldBypassProxy(location) {
130
+ var parsed;
131
+
132
+ try {
133
+ parsed = new URL(location);
134
+ } catch (err) {
135
+ return false;
136
+ }
137
+
138
+ var noProxy = (process.env.no_proxy || process.env.NO_PROXY || '').toLowerCase();
139
+
140
+ if (!noProxy) {
141
+ return false;
142
+ }
143
+
144
+ if (noProxy === '*') {
145
+ return true;
146
+ }
147
+
148
+ var protocol = parsed.protocol.split(':', 1)[0];
149
+ var port = parsed.port !== '' ? parseInt(parsed.port, 10) : (DEFAULT_PORTS[protocol] || 0);
150
+ var hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
151
+
152
+ return noProxy.split(/[\s,]+/).some(function testNoProxyEntry(entry) {
153
+ if (!entry) {
154
+ return false;
155
+ }
156
+
157
+ var entryParts = parseNoProxyEntry(entry);
158
+ var entryHost = normalizeNoProxyHost(entryParts[0]);
159
+ var entryPort = entryParts[1];
160
+
161
+ if (entryHost === '*') {
162
+ return true;
163
+ }
164
+
165
+ if (!entryHost) {
166
+ return false;
167
+ }
168
+
169
+ if (entryPort && entryPort !== port) {
170
+ return false;
171
+ }
172
+
173
+ if (isLoopbackHost(hostname) && isLoopbackHost(entryHost)) {
174
+ return true;
175
+ }
176
+
177
+ if (entryHost.charAt(0) === '*') {
178
+ entryHost = entryHost.slice(1);
179
+ }
180
+
181
+ if (entryHost.charAt(0) === '.') {
182
+ return hostname.slice(-entryHost.length) === entryHost;
183
+ }
184
+
185
+ return hostname === entryHost;
186
+ });
187
+ };