@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
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var elliptic = exports;
4
-
5
- elliptic.version = require('../package.json').version;
6
- elliptic.utils = require('./elliptic/utils');
7
- elliptic.rand = require('../../brorand-1.1.0/index');
8
- elliptic.curve = require('./elliptic/curve');
9
- elliptic.curves = require('./elliptic/curves');
10
-
11
- // Protocols
12
- elliptic.ec = require('./elliptic/ec');
13
- elliptic.eddsa = require('./elliptic/eddsa');
@@ -1,55 +0,0 @@
1
- {
2
- "name": "elliptic",
3
- "version": "6.5.3",
4
- "description": "EC cryptography",
5
- "main": "lib/elliptic.js",
6
- "scripts": {
7
- "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
8
- "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
9
- "lint": "npm run jscs && npm run jshint",
10
- "unit": "istanbul test _mocha --reporter=spec test/index.js",
11
- "test": "npm run lint && npm run unit",
12
- "version": "grunt dist && git add dist/"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git@github.com:indutny/elliptic"
17
- },
18
- "keywords": [
19
- "EC",
20
- "Elliptic",
21
- "curve",
22
- "Cryptography"
23
- ],
24
- "author": "Fedor Indutny <fedor@indutny.com>",
25
- "license": "MIT",
26
- "bugs": {
27
- "url": "https://github.com/indutny/elliptic/issues"
28
- },
29
- "homepage": "https://github.com/indutny/elliptic",
30
- "devDependencies": {
31
- "brfs": "^1.4.3",
32
- "coveralls": "^3.0.8",
33
- "grunt": "^1.0.4",
34
- "grunt-browserify": "^5.0.0",
35
- "grunt-cli": "^1.2.0",
36
- "grunt-contrib-connect": "^1.0.0",
37
- "grunt-contrib-copy": "^1.0.0",
38
- "grunt-contrib-uglify": "^1.0.1",
39
- "grunt-mocha-istanbul": "^3.0.1",
40
- "grunt-saucelabs": "^9.0.1",
41
- "istanbul": "^0.4.2",
42
- "jscs": "^3.0.7",
43
- "jshint": "^2.10.3",
44
- "mocha": "^6.2.2"
45
- },
46
- "dependencies": {
47
- "bn.js": "^4.4.0",
48
- "brorand": "^1.0.1",
49
- "hash.js": "^1.0.0",
50
- "hmac-drbg": "^1.0.0",
51
- "inherits": "^2.0.1",
52
- "minimalistic-assert": "^1.0.0",
53
- "minimalistic-crypto-utils": "^1.0.0"
54
- }
55
- }
@@ -1,322 +0,0 @@
1
- var url = require("url");
2
- var http = require("http");
3
- var https = require("https");
4
- var assert = require("assert");
5
- var Writable = require("stream").Writable;
6
- var debug = require("../debug-3.1.0/src/browser")("follow-redirects");
7
-
8
- // RFC7231§4.2.1: Of the request methods defined by this specification,
9
- // the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
10
- var SAFE_METHODS = { GET: true, HEAD: true, OPTIONS: true, TRACE: true };
11
-
12
- // Create handlers that pass events from native requests
13
- var eventHandlers = Object.create(null);
14
- ["abort", "aborted", "error", "socket", "timeout"].forEach(function (event) {
15
- eventHandlers[event] = function (arg) {
16
- this._redirectable.emit(event, arg);
17
- };
18
- });
19
-
20
- // An HTTP(S) request that can be redirected
21
- function RedirectableRequest(options, responseCallback) {
22
- // Initialize the request
23
- Writable.call(this);
24
- options.headers = options.headers || {};
25
- this._options = options;
26
- this._redirectCount = 0;
27
- this._redirects = [];
28
- this._requestBodyLength = 0;
29
- this._requestBodyBuffers = [];
30
-
31
- // Since http.request treats host as an alias of hostname,
32
- // but the url module interprets host as hostname plus port,
33
- // eliminate the host property to avoid confusion.
34
- if (options.host) {
35
- // Use hostname if set, because it has precedence
36
- if (!options.hostname) {
37
- options.hostname = options.host;
38
- }
39
- delete options.host;
40
- }
41
-
42
- // Attach a callback if passed
43
- if (responseCallback) {
44
- this.on("response", responseCallback);
45
- }
46
-
47
- // React to responses of native requests
48
- var self = this;
49
- this._onNativeResponse = function (response) {
50
- self._processResponse(response);
51
- };
52
-
53
- // Complete the URL object when necessary
54
- if (!options.pathname && options.path) {
55
- var searchPos = options.path.indexOf("?");
56
- if (searchPos < 0) {
57
- options.pathname = options.path;
58
- }
59
- else {
60
- options.pathname = options.path.substring(0, searchPos);
61
- options.search = options.path.substring(searchPos);
62
- }
63
- }
64
-
65
- // Perform the first request
66
- this._performRequest();
67
- }
68
- RedirectableRequest.prototype = Object.create(Writable.prototype);
69
-
70
- // Writes buffered data to the current native request
71
- RedirectableRequest.prototype.write = function (data, encoding, callback) {
72
- // Validate input and shift parameters if necessary
73
- if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
74
- throw new Error("data should be a string, Buffer or Uint8Array");
75
- }
76
- if (typeof encoding === "function") {
77
- callback = encoding;
78
- encoding = null;
79
- }
80
-
81
- // Ignore empty buffers, since writing them doesn't invoke the callback
82
- // https://github.com/nodejs/node/issues/22066
83
- if (data.length === 0) {
84
- if (callback) {
85
- callback();
86
- }
87
- return;
88
- }
89
- // Only write when we don't exceed the maximum body length
90
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
91
- this._requestBodyLength += data.length;
92
- this._requestBodyBuffers.push({ data: data, encoding: encoding });
93
- this._currentRequest.write(data, encoding, callback);
94
- }
95
- // Error when we exceed the maximum body length
96
- else {
97
- this.emit("error", new Error("Request body larger than maxBodyLength limit"));
98
- this.abort();
99
- }
100
- };
101
-
102
- // Ends the current native request
103
- RedirectableRequest.prototype.end = function (data, encoding, callback) {
104
- // Shift parameters if necessary
105
- if (typeof data === "function") {
106
- callback = data;
107
- data = encoding = null;
108
- }
109
- else if (typeof encoding === "function") {
110
- callback = encoding;
111
- encoding = null;
112
- }
113
-
114
- // Write data and end
115
- var currentRequest = this._currentRequest;
116
- this.write(data || "", encoding, function () {
117
- currentRequest.end(null, null, callback);
118
- });
119
- };
120
-
121
- // Sets a header value on the current native request
122
- RedirectableRequest.prototype.setHeader = function (name, value) {
123
- this._options.headers[name] = value;
124
- this._currentRequest.setHeader(name, value);
125
- };
126
-
127
- // Clears a header value on the current native request
128
- RedirectableRequest.prototype.removeHeader = function (name) {
129
- delete this._options.headers[name];
130
- this._currentRequest.removeHeader(name);
131
- };
132
-
133
- // Proxy all other public ClientRequest methods
134
- [
135
- "abort", "flushHeaders", "getHeader",
136
- "setNoDelay", "setSocketKeepAlive", "setTimeout",
137
- ].forEach(function (method) {
138
- RedirectableRequest.prototype[method] = function (a, b) {
139
- return this._currentRequest[method](a, b);
140
- };
141
- });
142
-
143
- // Proxy all public ClientRequest properties
144
- ["aborted", "connection", "socket"].forEach(function (property) {
145
- Object.defineProperty(RedirectableRequest.prototype, property, {
146
- get: function () { return this._currentRequest[property]; },
147
- });
148
- });
149
-
150
- // Executes the next native request (initial or redirect)
151
- RedirectableRequest.prototype._performRequest = function () {
152
- // Load the native protocol
153
- var protocol = this._options.protocol;
154
- var nativeProtocol = this._options.nativeProtocols[protocol];
155
- if (!nativeProtocol) {
156
- this.emit("error", new Error("Unsupported protocol " + protocol));
157
- return;
158
- }
159
-
160
- // If specified, use the agent corresponding to the protocol
161
- // (HTTP and HTTPS use different types of agents)
162
- if (this._options.agents) {
163
- var scheme = protocol.substr(0, protocol.length - 1);
164
- this._options.agent = this._options.agents[scheme];
165
- }
166
-
167
- // Create the native request
168
- var request = this._currentRequest =
169
- nativeProtocol.request(this._options, this._onNativeResponse);
170
- this._currentUrl = url.format(this._options);
171
-
172
- // Set up event handlers
173
- request._redirectable = this;
174
- for (var event in eventHandlers) {
175
- /* istanbul ignore else */
176
- if (event) {
177
- request.on(event, eventHandlers[event]);
178
- }
179
- }
180
-
181
- // End a redirected request
182
- // (The first request must be ended explicitly with RedirectableRequest#end)
183
- if (this._isRedirect) {
184
- // Write the request entity and end.
185
- var i = 0;
186
- var buffers = this._requestBodyBuffers;
187
- (function writeNext() {
188
- if (i < buffers.length) {
189
- var buffer = buffers[i++];
190
- request.write(buffer.data, buffer.encoding, writeNext);
191
- }
192
- else {
193
- request.end();
194
- }
195
- }());
196
- }
197
- };
198
-
199
- // Processes a response from the current native request
200
- RedirectableRequest.prototype._processResponse = function (response) {
201
- // Store the redirected response
202
- if (this._options.trackRedirects) {
203
- this._redirects.push({
204
- url: this._currentUrl,
205
- headers: response.headers,
206
- statusCode: response.statusCode,
207
- });
208
- }
209
-
210
- // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
211
- // that further action needs to be taken by the user agent in order to
212
- // fulfill the request. If a Location header field is provided,
213
- // the user agent MAY automatically redirect its request to the URI
214
- // referenced by the Location field value,
215
- // even if the specific status code is not understood.
216
- var location = response.headers.location;
217
- if (location && this._options.followRedirects !== false &&
218
- response.statusCode >= 300 && response.statusCode < 400) {
219
- // RFC7231§6.4: A client SHOULD detect and intervene
220
- // in cyclical redirections (i.e., "infinite" redirection loops).
221
- if (++this._redirectCount > this._options.maxRedirects) {
222
- this.emit("error", new Error("Max redirects exceeded."));
223
- return;
224
- }
225
-
226
- // RFC7231§6.4: Automatic redirection needs to done with
227
- // care for methods not known to be safe […],
228
- // since the user might not wish to redirect an unsafe request.
229
- // RFC7231§6.4.7: The 307 (Temporary Redirect) status code indicates
230
- // that the target resource resides temporarily under a different URI
231
- // and the user agent MUST NOT change the request method
232
- // if it performs an automatic redirection to that URI.
233
- var header;
234
- var headers = this._options.headers;
235
- if (response.statusCode !== 307 && !(this._options.method in SAFE_METHODS)) {
236
- this._options.method = "GET";
237
- // Drop a possible entity and headers related to it
238
- this._requestBodyBuffers = [];
239
- for (header in headers) {
240
- if (/^content-/i.test(header)) {
241
- delete headers[header];
242
- }
243
- }
244
- }
245
-
246
- // Drop the Host header, as the redirect might lead to a different host
247
- if (!this._isRedirect) {
248
- for (header in headers) {
249
- if (/^host$/i.test(header)) {
250
- delete headers[header];
251
- }
252
- }
253
- }
254
-
255
- // Perform the redirected request
256
- var redirectUrl = url.resolve(this._currentUrl, location);
257
- debug("redirecting to", redirectUrl);
258
- Object.assign(this._options, url.parse(redirectUrl));
259
- this._isRedirect = true;
260
- this._performRequest();
261
-
262
- // Discard the remainder of the response to avoid waiting for data
263
- response.destroy();
264
- }
265
- else {
266
- // The response is not a redirect; return it as-is
267
- response.responseUrl = this._currentUrl;
268
- response.redirects = this._redirects;
269
- this.emit("response", response);
270
-
271
- // Clean up
272
- this._requestBodyBuffers = [];
273
- }
274
- };
275
-
276
- // Wraps the key/value object of protocols with redirect functionality
277
- function wrap(protocols) {
278
- // Default settings
279
- var exports = {
280
- maxRedirects: 21,
281
- maxBodyLength: 10 * 1024 * 1024,
282
- };
283
-
284
- // Wrap each protocol
285
- var nativeProtocols = {};
286
- Object.keys(protocols).forEach(function (scheme) {
287
- var protocol = scheme + ":";
288
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
289
- var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
290
-
291
- // Executes a request, following redirects
292
- wrappedProtocol.request = function (options, callback) {
293
- if (typeof options === "string") {
294
- options = url.parse(options);
295
- options.maxRedirects = exports.maxRedirects;
296
- }
297
- else {
298
- options = Object.assign({
299
- protocol: protocol,
300
- maxRedirects: exports.maxRedirects,
301
- maxBodyLength: exports.maxBodyLength,
302
- }, options);
303
- }
304
- options.nativeProtocols = nativeProtocols;
305
- assert.equal(options.protocol, protocol, "protocol mismatch");
306
- debug("options", options);
307
- return new RedirectableRequest(options, callback);
308
- };
309
-
310
- // Executes a GET request, following redirects
311
- wrappedProtocol.get = function (options, callback) {
312
- var request = wrappedProtocol.request(options, callback);
313
- request.end();
314
- return request;
315
- };
316
- });
317
- return exports;
318
- }
319
-
320
- // Exports
321
- module.exports = wrap({ http: http, https: https });
322
- module.exports.wrap = wrap;
@@ -1,11 +0,0 @@
1
- /*!
2
- * Determine if an object is a Buffer
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */
7
-
8
- module.exports = function isBuffer (obj) {
9
- return obj != null && obj.constructor != null &&
10
- typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
11
- }