Update dependencies
This commit is contained in:
parent
efe3c87c15
commit
64b899a72a
1218 changed files with 79658 additions and 39990 deletions
43
node_modules/node-fetch/README.md
generated
vendored
43
node_modules/node-fetch/README.md
generated
vendored
|
@ -188,6 +188,49 @@ fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
|
|||
});
|
||||
```
|
||||
|
||||
In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch
|
||||
errors -- the longer a response runs, the more likely it is to encounter an error.
|
||||
|
||||
```js
|
||||
const fetch = require('node-fetch');
|
||||
const response = await fetch('https://httpbin.org/stream/3');
|
||||
try {
|
||||
for await (const chunk of response.body) {
|
||||
console.dir(JSON.parse(chunk.toString()));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
```
|
||||
|
||||
In Node.js 12 you can also use async iterators to read `body`; however, async iterators with streams
|
||||
did not mature until Node.js 14, so you need to do some extra work to ensure you handle errors
|
||||
directly from the stream and wait on it response to fully close.
|
||||
|
||||
```js
|
||||
const fetch = require('node-fetch');
|
||||
const read = async body => {
|
||||
let error;
|
||||
body.on('error', err => {
|
||||
error = err;
|
||||
});
|
||||
for await (const chunk of body) {
|
||||
console.dir(JSON.parse(chunk.toString()));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
body.on('close', () => {
|
||||
error ? reject(error) : resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
try {
|
||||
const response = await fetch('https://httpbin.org/stream/3');
|
||||
await read(response.body);
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
```
|
||||
|
||||
#### Buffer
|
||||
If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API)
|
||||
|
||||
|
|
14
node_modules/node-fetch/browser.js
generated
vendored
14
node_modules/node-fetch/browser.js
generated
vendored
|
@ -11,15 +11,15 @@ var getGlobal = function () {
|
|||
throw new Error('unable to locate global object');
|
||||
}
|
||||
|
||||
var global = getGlobal();
|
||||
var globalObject = getGlobal();
|
||||
|
||||
module.exports = exports = global.fetch;
|
||||
module.exports = exports = globalObject.fetch;
|
||||
|
||||
// Needed for TypeScript and Webpack.
|
||||
if (global.fetch) {
|
||||
exports.default = global.fetch.bind(global);
|
||||
if (globalObject.fetch) {
|
||||
exports.default = globalObject.fetch.bind(globalObject);
|
||||
}
|
||||
|
||||
exports.Headers = global.Headers;
|
||||
exports.Request = global.Request;
|
||||
exports.Response = global.Response;
|
||||
exports.Headers = globalObject.Headers;
|
||||
exports.Request = globalObject.Request;
|
||||
exports.Response = globalObject.Response;
|
||||
|
|
94
node_modules/node-fetch/lib/index.es.js
generated
vendored
94
node_modules/node-fetch/lib/index.es.js
generated
vendored
|
@ -1413,6 +1413,20 @@ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original)
|
|||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* isSameProtocol reports whether the two provided URLs use the same protocol.
|
||||
*
|
||||
* Both domains must already be in canonical form.
|
||||
* @param {string|URL} original
|
||||
* @param {string|URL} destination
|
||||
*/
|
||||
const isSameProtocol = function isSameProtocol(destination, original) {
|
||||
const orig = new URL$1(original).protocol;
|
||||
const dest = new URL$1(destination).protocol;
|
||||
|
||||
return orig === dest;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*
|
||||
|
@ -1444,7 +1458,7 @@ function fetch(url, opts) {
|
|||
let error = new AbortError('The user aborted a request.');
|
||||
reject(error);
|
||||
if (request.body && request.body instanceof Stream.Readable) {
|
||||
request.body.destroy(error);
|
||||
destroyStream(request.body, error);
|
||||
}
|
||||
if (!response || !response.body) return;
|
||||
response.body.emit('error', error);
|
||||
|
@ -1485,9 +1499,43 @@ function fetch(url, opts) {
|
|||
|
||||
req.on('error', function (err) {
|
||||
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
|
||||
finalize();
|
||||
});
|
||||
|
||||
fixResponseChunkedTransferBadEnding(req, function (err) {
|
||||
if (signal && signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
});
|
||||
|
||||
/* c8 ignore next 18 */
|
||||
if (parseInt(process.version.substring(1)) < 14) {
|
||||
// Before Node.js 14, pipeline() does not fully support async iterators and does not always
|
||||
// properly handle when the socket close/end events are out of order.
|
||||
req.on('socket', function (s) {
|
||||
s.addListener('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = s.listenerCount('data') > 0;
|
||||
|
||||
// if end happened before close but the socket didn't emit an error, do it now
|
||||
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
response.body.emit('error', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
req.on('response', function (res) {
|
||||
clearTimeout(reqTimeout);
|
||||
|
||||
|
@ -1559,7 +1607,7 @@ function fetch(url, opts) {
|
|||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
|
@ -1652,6 +1700,13 @@ function fetch(url, opts) {
|
|||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
});
|
||||
raw.on('end', function () {
|
||||
// some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted.
|
||||
if (!response) {
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1671,6 +1726,41 @@ function fetch(url, opts) {
|
|||
writeToStream(req, request);
|
||||
});
|
||||
}
|
||||
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
||||
let socket;
|
||||
|
||||
request.on('socket', function (s) {
|
||||
socket = s;
|
||||
});
|
||||
|
||||
request.on('response', function (response) {
|
||||
const headers = response.headers;
|
||||
|
||||
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
|
||||
response.once('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = socket.listenerCount('data') > 0;
|
||||
|
||||
if (hasDataListener && !hadError) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
errorCallback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function destroyStream(stream, err) {
|
||||
if (stream.destroy) {
|
||||
stream.destroy(err);
|
||||
} else {
|
||||
// node < 8
|
||||
stream.emit('error', err);
|
||||
stream.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect code matching
|
||||
*
|
||||
|
|
94
node_modules/node-fetch/lib/index.js
generated
vendored
94
node_modules/node-fetch/lib/index.js
generated
vendored
|
@ -1417,6 +1417,20 @@ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original)
|
|||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* isSameProtocol reports whether the two provided URLs use the same protocol.
|
||||
*
|
||||
* Both domains must already be in canonical form.
|
||||
* @param {string|URL} original
|
||||
* @param {string|URL} destination
|
||||
*/
|
||||
const isSameProtocol = function isSameProtocol(destination, original) {
|
||||
const orig = new URL$1(original).protocol;
|
||||
const dest = new URL$1(destination).protocol;
|
||||
|
||||
return orig === dest;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*
|
||||
|
@ -1448,7 +1462,7 @@ function fetch(url, opts) {
|
|||
let error = new AbortError('The user aborted a request.');
|
||||
reject(error);
|
||||
if (request.body && request.body instanceof Stream.Readable) {
|
||||
request.body.destroy(error);
|
||||
destroyStream(request.body, error);
|
||||
}
|
||||
if (!response || !response.body) return;
|
||||
response.body.emit('error', error);
|
||||
|
@ -1489,9 +1503,43 @@ function fetch(url, opts) {
|
|||
|
||||
req.on('error', function (err) {
|
||||
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
|
||||
finalize();
|
||||
});
|
||||
|
||||
fixResponseChunkedTransferBadEnding(req, function (err) {
|
||||
if (signal && signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
});
|
||||
|
||||
/* c8 ignore next 18 */
|
||||
if (parseInt(process.version.substring(1)) < 14) {
|
||||
// Before Node.js 14, pipeline() does not fully support async iterators and does not always
|
||||
// properly handle when the socket close/end events are out of order.
|
||||
req.on('socket', function (s) {
|
||||
s.addListener('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = s.listenerCount('data') > 0;
|
||||
|
||||
// if end happened before close but the socket didn't emit an error, do it now
|
||||
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
response.body.emit('error', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
req.on('response', function (res) {
|
||||
clearTimeout(reqTimeout);
|
||||
|
||||
|
@ -1563,7 +1611,7 @@ function fetch(url, opts) {
|
|||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
|
@ -1656,6 +1704,13 @@ function fetch(url, opts) {
|
|||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
});
|
||||
raw.on('end', function () {
|
||||
// some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted.
|
||||
if (!response) {
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1675,6 +1730,41 @@ function fetch(url, opts) {
|
|||
writeToStream(req, request);
|
||||
});
|
||||
}
|
||||
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
||||
let socket;
|
||||
|
||||
request.on('socket', function (s) {
|
||||
socket = s;
|
||||
});
|
||||
|
||||
request.on('response', function (response) {
|
||||
const headers = response.headers;
|
||||
|
||||
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
|
||||
response.once('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = socket.listenerCount('data') > 0;
|
||||
|
||||
if (hasDataListener && !hadError) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
errorCallback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function destroyStream(stream, err) {
|
||||
if (stream.destroy) {
|
||||
stream.destroy(err);
|
||||
} else {
|
||||
// node < 8
|
||||
stream.emit('error', err);
|
||||
stream.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect code matching
|
||||
*
|
||||
|
|
94
node_modules/node-fetch/lib/index.mjs
generated
vendored
94
node_modules/node-fetch/lib/index.mjs
generated
vendored
|
@ -1411,6 +1411,20 @@ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original)
|
|||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* isSameProtocol reports whether the two provided URLs use the same protocol.
|
||||
*
|
||||
* Both domains must already be in canonical form.
|
||||
* @param {string|URL} original
|
||||
* @param {string|URL} destination
|
||||
*/
|
||||
const isSameProtocol = function isSameProtocol(destination, original) {
|
||||
const orig = new URL$1(original).protocol;
|
||||
const dest = new URL$1(destination).protocol;
|
||||
|
||||
return orig === dest;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*
|
||||
|
@ -1442,7 +1456,7 @@ function fetch(url, opts) {
|
|||
let error = new AbortError('The user aborted a request.');
|
||||
reject(error);
|
||||
if (request.body && request.body instanceof Stream.Readable) {
|
||||
request.body.destroy(error);
|
||||
destroyStream(request.body, error);
|
||||
}
|
||||
if (!response || !response.body) return;
|
||||
response.body.emit('error', error);
|
||||
|
@ -1483,9 +1497,43 @@ function fetch(url, opts) {
|
|||
|
||||
req.on('error', function (err) {
|
||||
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
|
||||
finalize();
|
||||
});
|
||||
|
||||
fixResponseChunkedTransferBadEnding(req, function (err) {
|
||||
if (signal && signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (response && response.body) {
|
||||
destroyStream(response.body, err);
|
||||
}
|
||||
});
|
||||
|
||||
/* c8 ignore next 18 */
|
||||
if (parseInt(process.version.substring(1)) < 14) {
|
||||
// Before Node.js 14, pipeline() does not fully support async iterators and does not always
|
||||
// properly handle when the socket close/end events are out of order.
|
||||
req.on('socket', function (s) {
|
||||
s.addListener('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = s.listenerCount('data') > 0;
|
||||
|
||||
// if end happened before close but the socket didn't emit an error, do it now
|
||||
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
response.body.emit('error', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
req.on('response', function (res) {
|
||||
clearTimeout(reqTimeout);
|
||||
|
||||
|
@ -1557,7 +1605,7 @@ function fetch(url, opts) {
|
|||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
|
@ -1650,6 +1698,13 @@ function fetch(url, opts) {
|
|||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
});
|
||||
raw.on('end', function () {
|
||||
// some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted.
|
||||
if (!response) {
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1669,6 +1724,41 @@ function fetch(url, opts) {
|
|||
writeToStream(req, request);
|
||||
});
|
||||
}
|
||||
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
||||
let socket;
|
||||
|
||||
request.on('socket', function (s) {
|
||||
socket = s;
|
||||
});
|
||||
|
||||
request.on('response', function (response) {
|
||||
const headers = response.headers;
|
||||
|
||||
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
|
||||
response.once('close', function (hadError) {
|
||||
// if a data listener is still present we didn't end cleanly
|
||||
const hasDataListener = socket.listenerCount('data') > 0;
|
||||
|
||||
if (hasDataListener && !hadError) {
|
||||
const err = new Error('Premature close');
|
||||
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
|
||||
errorCallback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function destroyStream(stream, err) {
|
||||
if (stream.destroy) {
|
||||
stream.destroy(err);
|
||||
} else {
|
||||
// node < 8
|
||||
stream.emit('error', err);
|
||||
stream.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect code matching
|
||||
*
|
||||
|
|
19
node_modules/node-fetch/package.json
generated
vendored
19
node_modules/node-fetch/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "node-fetch",
|
||||
"version": "2.6.7",
|
||||
"version": "2.6.9",
|
||||
"description": "A light-weight module that brings window.fetch to node.js",
|
||||
"main": "lib/index.js",
|
||||
"browser": "./browser.js",
|
||||
|
@ -39,7 +39,7 @@
|
|||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
|
@ -53,7 +53,9 @@
|
|||
"abortcontroller-polyfill": "^1.3.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-plugin-istanbul": "^4.1.6",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-plugin-transform-async-generator-functions": "^6.24.1",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"babel-preset-env": "1.4.0",
|
||||
"babel-register": "^6.16.3",
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
|
@ -72,5 +74,16 @@
|
|||
"rollup-plugin-babel": "^3.0.7",
|
||||
"string-to-arraybuffer": "^1.0.2",
|
||||
"teeny-request": "3.7.0"
|
||||
},
|
||||
"release": {
|
||||
"branches": [
|
||||
"+([0-9]).x",
|
||||
"main",
|
||||
"next",
|
||||
{
|
||||
"name": "beta",
|
||||
"prerelease": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue