diff --git a/.eslintrc b/.eslintrc index e6c504453..455c4543a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,9 @@ { "checkLoops": false } - ] + ], + "n/no-unsupported-features/node-builtins": ["error", { + "allowExperimental": true + }] } -} \ No newline at end of file +} diff --git a/lib/install.js b/lib/install.js index 617dd8663..381477d8a 100644 --- a/lib/install.js +++ b/lib/install.js @@ -7,12 +7,12 @@ exports.usage = 'Attempts to install pre-built binary for module'; const fs = require('fs'); const path = require('path'); const log = require('npmlog'); +const { ProxyAgent } = require('undici'); const existsAsync = fs.exists || path.exists; const versioning = require('./util/versioning.js'); const napi = require('./util/napi.js'); const makeDir = require('make-dir'); // for fetching binaries -const fetch = require('node-fetch'); const tar = require('tar'); let npgVersion = 'unknown'; @@ -56,12 +56,11 @@ function place_binary(uri, targetDir, opts, callback) { process.env.npm_config_proxy; let agent; if (proxyUrl) { - const ProxyAgent = require('https-proxy-agent'); agent = new ProxyAgent(proxyUrl); log.http('download', 'proxy agent configured using: "%s"', proxyUrl); } - fetch(sanitized, { agent }) + fetch(sanitized, { dispatcher: agent }) .then((res) => { if (!res.ok) { throw new Error(`response status ${res.status} ${res.statusText} on ${sanitized}`); diff --git a/package-lock.json b/package-lock.json index 2e7456a76..94381e2a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,13 +10,12 @@ "license": "BSD-3-Clause", "dependencies": { "detect-libc": "^2.0.0", - "https-proxy-agent": "^5.0.0", "make-dir": "^3.1.0", - "node-fetch": "^2.6.7", "nopt": "^7.2.1", "npmlog": "^7.0.1", - "semver": "^7.3.5", - "tar": "^7.4.0" + "semver": "^7.5.3", + "tar": "^7.4.0", + "undici": "^6.19.2" }, "bin": { "node-pre-gyp": "bin/node-pre-gyp" @@ -29,7 +28,7 @@ "eslint": "^8.57.0", "eslint-plugin-n": "^17.9.0", "mock-aws-s3": "^4.0.2", - "nock": "^12.0.3", + "nock": "^14.0.0-beta.8", "node-addon-api": "^4.3.0", "nyc": "^15.1.0", "tape": "^5.5.2", @@ -962,6 +961,24 @@ "eslint-plugin-unused-imports": "^3.1.0" } }, + "node_modules/@mswjs/interceptors": { + "version": "0.33.1", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.33.1.tgz", + "integrity": "sha512-H6FIM3VMoLfZjKGt3kl3OaB6H7IkttDMSA0REmloCLnVBkIKHe4q7OAEHDZ8DNxOx1TCVguFO8a0BFn0eDzzlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/logger": "^0.3.0", + "@open-draft/until": "^2.0.0", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "strict-event-emitter": "^0.5.1" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1000,6 +1017,31 @@ "node": ">= 8" } }, + "node_modules/@open-draft/deferred-promise": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", + "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@open-draft/logger": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", + "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + } + }, + "node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", + "dev": true, + "license": "MIT" + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1256,6 +1298,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, "license": "MIT", "dependencies": { "debug": "4" @@ -1895,6 +1938,7 @@ "version": "4.3.5", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dev": true, "license": "MIT", "dependencies": { "ms": "2.1.2" @@ -3367,6 +3411,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "6", @@ -3697,6 +3742,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-node-process": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", + "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", + "dev": true, + "license": "MIT" + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -4221,13 +4273,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", @@ -4417,6 +4462,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true, "license": "MIT" }, "node_modules/natural-compare": { @@ -4427,19 +4473,18 @@ "license": "MIT" }, "node_modules/nock": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/nock/-/nock-12.0.3.tgz", - "integrity": "sha512-QNb/j8kbFnKCiyqi9C5DD0jH/FubFGj5rt9NQFONXwQm3IPB0CULECg/eS3AU1KgZb/6SwUa4/DTRKhVxkGABw==", + "version": "14.0.0-beta.8", + "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.0-beta.8.tgz", + "integrity": "sha512-fKPzXHZozO7649AMCJttOZvYh8tO00e0jU3LYRYlxZb2rmB6e5+hmh57Vtazsd+42L/idm7q8qA09mRDCKzwiA==", "dev": true, "license": "MIT", "dependencies": { - "debug": "^4.1.0", + "@mswjs/interceptors": "^0.33.1", "json-stringify-safe": "^5.0.1", - "lodash": "^4.17.13", "propagate": "^2.0.0" }, "engines": { - "node": ">= 10.13" + "node": ">= 18" } }, "node_modules/node-addon-api": { @@ -4453,6 +4498,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -4739,6 +4785,13 @@ "node": ">= 0.8.0" } }, + "node_modules/outvariant": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", + "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", + "dev": true, + "license": "MIT" + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -5573,6 +5626,13 @@ "stubs": "^3.0.0" } }, + "node_modules/strict-event-emitter": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", + "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", + "dev": true, + "license": "MIT" + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -5956,6 +6016,7 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, "license": "MIT" }, "node_modules/ts-api-utils": { @@ -6123,6 +6184,15 @@ "dev": true, "license": "MIT" }, + "node_modules/undici": { + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.2.tgz", + "integrity": "sha512-JfjKqIauur3Q6biAtHJ564e3bWa8VvT+7cSiOJHFbX4Erv6CLGDpg8z+Fmg/1OI/47RA+GI2QZaF48SSaLvyBA==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -6237,12 +6307,14 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, "license": "MIT", "dependencies": { "tr46": "~0.0.3", diff --git a/package.json b/package.json index 6d5d1a987..13217a439 100644 --- a/package.json +++ b/package.json @@ -24,13 +24,12 @@ }, "dependencies": { "detect-libc": "^2.0.0", - "https-proxy-agent": "^5.0.0", "make-dir": "^3.1.0", - "node-fetch": "^2.6.7", "nopt": "^7.2.1", "npmlog": "^7.0.1", "semver": "^7.5.3", - "tar": "^7.4.0" + "tar": "^7.4.0", + "undici": "^6.19.2" }, "devDependencies": { "@mapbox/cloudfriend": "^5.1.0", @@ -40,7 +39,7 @@ "eslint": "^8.57.0", "eslint-plugin-n": "^17.9.0", "mock-aws-s3": "^4.0.2", - "nock": "^12.0.3", + "nock": "^14.0.0-beta.8", "node-addon-api": "^4.3.0", "nyc": "^15.1.0", "tape": "^5.5.2", diff --git a/test/proxy-bcrypt.test.js b/test/proxy-bcrypt.test.js index b13818ed0..91acda8e1 100644 --- a/test/proxy-bcrypt.test.js +++ b/test/proxy-bcrypt.test.js @@ -6,7 +6,7 @@ const { createUnzip } = require('zlib'); const os = require('os'); const tar = require('tar-fs'); -const Agent = require('https-proxy-agent'); +const { ProxyAgent } = require('undici'); const fetch = require('node-fetch'); const { rimraf } = require('rimraf'); @@ -44,7 +44,7 @@ test('setup proxy server', (t) => { proxy.startServer({ port: proxyPort }); process.env.https_proxy = process.env.http_proxy = proxyServer; - options.agent = new Agent(proxyServer); + options.dispatcher = new ProxyAgent(proxyServer); // make sure the download directory deleted then create an empty one rimraf(downloadDir).then(() => {