Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-03-24 23:24:36 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-03-28 23:18:26 +0300
commitfeb4446d50a7b6a61e44a92b78e1e1af2d89a725 (patch)
treeff0202b7a2feb83d2c29a00cdae104471d84c7ca /node_modules
parent716a07fde7905bb69e4c6f1991bb7289589a6669 (diff)
deps: make-fetch-happen@10.1.0
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/make-fetch-happen/lib/agent.js5
-rw-r--r--node_modules/make-fetch-happen/lib/cache/index.js4
-rw-r--r--node_modules/make-fetch-happen/lib/dns.js49
-rw-r--r--node_modules/make-fetch-happen/lib/options.js4
-rw-r--r--node_modules/make-fetch-happen/package.json32
5 files changed, 78 insertions, 16 deletions
diff --git a/node_modules/make-fetch-happen/lib/agent.js b/node_modules/make-fetch-happen/lib/agent.js
index d28a31bfb..f64644ff6 100644
--- a/node_modules/make-fetch-happen/lib/agent.js
+++ b/node_modules/make-fetch-happen/lib/agent.js
@@ -2,6 +2,7 @@
const LRU = require('lru-cache')
const url = require('url')
const isLambda = require('is-lambda')
+const dns = require('./dns.js')
const AGENT_CACHE = new LRU({ max: 50 })
const HttpAgent = require('agentkeepalive')
@@ -77,11 +78,13 @@ function getAgent (uri, opts) {
rejectUnauthorized: opts.rejectUnauthorized,
timeout: agentTimeout,
freeSocketTimeout: 15000,
+ lookup: dns.getLookup(opts.dns),
}) : new HttpAgent({
maxSockets: agentMaxSockets,
localAddress: opts.localAddress,
timeout: agentTimeout,
freeSocketTimeout: 15000,
+ lookup: dns.getLookup(opts.dns),
})
AGENT_CACHE.set(key, agent)
return agent
@@ -171,6 +174,8 @@ const HttpsProxyAgent = require('https-proxy-agent')
const SocksProxyAgent = require('socks-proxy-agent')
module.exports.getProxy = getProxy
function getProxy (proxyUrl, opts, isHttps) {
+ // our current proxy agents do not support an overridden dns lookup method, so will not
+ // benefit from the dns cache
const popts = {
host: proxyUrl.hostname,
port: proxyUrl.port,
diff --git a/node_modules/make-fetch-happen/lib/cache/index.js b/node_modules/make-fetch-happen/lib/cache/index.js
index 17a642559..0de49d23f 100644
--- a/node_modules/make-fetch-happen/lib/cache/index.js
+++ b/node_modules/make-fetch-happen/lib/cache/index.js
@@ -14,8 +14,8 @@ const cacheFetch = async (request, options) => {
// otherwise, we make a request, store it and return it
const response = await remote(request, options)
- const entry = new CacheEntry({ request, response, options })
- return entry.store('miss')
+ const newEntry = new CacheEntry({ request, response, options })
+ return newEntry.store('miss')
}
// we have a cached response that satisfies this request, however if the cache
diff --git a/node_modules/make-fetch-happen/lib/dns.js b/node_modules/make-fetch-happen/lib/dns.js
new file mode 100644
index 000000000..f817c59f7
--- /dev/null
+++ b/node_modules/make-fetch-happen/lib/dns.js
@@ -0,0 +1,49 @@
+const LRUCache = require('lru-cache')
+const dns = require('dns')
+
+const defaultOptions = exports.defaultOptions = {
+ family: undefined,
+ hints: dns.ADDRCONFIG,
+ all: false,
+ verbatim: true,
+}
+
+const lookupCache = exports.lookupCache = new LRUCache({ max: 50 })
+
+// this is a factory so that each request can have its own opts (i.e. ttl)
+// while still sharing the cache across all requests
+exports.getLookup = (dnsOptions) => {
+ return (hostname, options, callback) => {
+ if (typeof options === 'function') {
+ callback = options
+ options = null
+ } else if (typeof options === 'number') {
+ options = { family: options }
+ }
+
+ options = { ...defaultOptions, ...options }
+
+ const key = JSON.stringify({
+ hostname,
+ family: options.family,
+ hints: options.hints,
+ all: options.all,
+ verbatim: options.verbatim,
+ })
+
+ if (lookupCache.has(key)) {
+ const [address, family] = lookupCache.get(key)
+ process.nextTick(callback, null, address, family)
+ return
+ }
+
+ dnsOptions.lookup(hostname, options, (err, address, family) => {
+ if (err) {
+ return callback(err)
+ }
+
+ lookupCache.set(key, [address, family], { ttl: dnsOptions.ttl })
+ return callback(null, address, family)
+ })
+ }
+}
diff --git a/node_modules/make-fetch-happen/lib/options.js b/node_modules/make-fetch-happen/lib/options.js
index a0c8664ad..daa9ecd9d 100644
--- a/node_modules/make-fetch-happen/lib/options.js
+++ b/node_modules/make-fetch-happen/lib/options.js
@@ -1,3 +1,5 @@
+const dns = require('dns')
+
const conditionalHeaders = [
'if-modified-since',
'if-none-match',
@@ -26,6 +28,8 @@ const configureOptions = (opts) => {
options.retry = { retries: 0, ...options.retry }
}
+ options.dns = { ttl: 5 * 60 * 1000, lookup: dns.lookup, ...options.dns }
+
options.cache = options.cache || 'default'
if (options.cache === 'default') {
const hasConditionalHeader = Object.keys(options.headers || {}).some((name) => {
diff --git a/node_modules/make-fetch-happen/package.json b/node_modules/make-fetch-happen/package.json
index e52131b8a..e4afddba5 100644
--- a/node_modules/make-fetch-happen/package.json
+++ b/node_modules/make-fetch-happen/package.json
@@ -1,11 +1,11 @@
{
"name": "make-fetch-happen",
- "version": "10.0.6",
+ "version": "10.1.0",
"description": "Opinionated, caching, retrying fetch client",
"main": "lib/index.js",
"files": [
- "bin",
- "lib"
+ "bin/",
+ "lib/"
],
"scripts": {
"preversion": "npm test",
@@ -14,13 +14,16 @@
"test": "tap",
"posttest": "npm run lint",
"eslint": "eslint",
- "lint": "eslint '**/*.js'",
+ "lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
- "postlint": "npm-template-check",
+ "postlint": "template-oss-check",
"snap": "tap",
- "template-copy": "npm-template-copy --force"
+ "template-oss-apply": "template-oss-apply --force"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/npm/make-fetch-happen.git"
},
- "repository": "https://github.com/npm/make-fetch-happen",
"keywords": [
"http",
"request",
@@ -34,12 +37,12 @@
"license": "ISC",
"dependencies": {
"agentkeepalive": "^4.2.1",
- "cacache": "^16.0.0",
+ "cacache": "^16.0.2",
"http-cache-semantics": "^4.1.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"is-lambda": "^1.0.1",
- "lru-cache": "^7.5.1",
+ "lru-cache": "^7.7.1",
"minipass": "^3.1.6",
"minipass-collect": "^1.0.2",
"minipass-fetch": "^2.0.3",
@@ -51,17 +54,17 @@
"ssri": "^8.0.1"
},
"devDependencies": {
- "@npmcli/template-oss": "^2.9.2",
- "eslint": "^8.11.0",
+ "@npmcli/eslint-config": "^3.0.1",
+ "@npmcli/template-oss": "3.1.2",
"mkdirp": "^1.0.4",
"nock": "^13.2.4",
"rimraf": "^3.0.2",
"safe-buffer": "^5.2.1",
"standard-version": "^9.3.2",
- "tap": "^15.1.6"
+ "tap": "^16.0.0"
},
"engines": {
- "node": "^12.13.0 || ^14.15.0 || >=16"
+ "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"tap": {
"color": 1,
@@ -69,6 +72,7 @@
"check-coverage": true
},
"templateOSS": {
- "version": "2.9.2"
+ "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
+ "version": "3.1.2"
}
}