diff --git a/packages/degenerator/package.json b/packages/degenerator/package.json index be000afb..536b0947 100644 --- a/packages/degenerator/package.json +++ b/packages/degenerator/package.json @@ -19,7 +19,7 @@ "url": "git://github.com/TooTallNate/node-degenerator.git" }, "engines": { - "node": ">= 6" + "node": ">= 14" }, "license": "MIT", "dependencies": { diff --git a/packages/https-proxy-agent/src/index.ts b/packages/https-proxy-agent/src/index.ts index 3259cf4b..94e86c66 100644 --- a/packages/https-proxy-agent/src/index.ts +++ b/packages/https-proxy-agent/src/index.ts @@ -39,7 +39,7 @@ export class HttpsProxyAgent extends Agent { super(); this.proxy = typeof proxy === 'string' ? new URL(proxy) : proxy; this.proxyHeaders = opts?.headers ?? {}; - debug('creating new HttpsProxyAgent instance: %o', opts); + debug('creating new HttpsProxyAgent instance: %o', this.proxy.href); const host = this.proxy.hostname || this.proxy.host; const port = this.proxy.port @@ -52,12 +52,6 @@ export class HttpsProxyAgent extends Agent { host, port, }; - - // ALPN is supported by Node.js >= v5. - // attempt to negotiate http/1.1 for proxy servers that support http/2 - if (this.secureProxy && !('ALPNProtocols' in this.connectOpts)) { - this.connectOpts.ALPNProtocols = ['http 1.1']; - } } /** diff --git a/packages/https-proxy-agent/test/test.js b/packages/https-proxy-agent/test/test.js index ee5a8386..5649024d 100644 --- a/packages/https-proxy-agent/test/test.js +++ b/packages/https-proxy-agent/test/test.js @@ -169,7 +169,7 @@ describe('HttpsProxyAgent', () => { }); req.once('error', done); }); - it.only('should work over an HTTPS proxy', (done) => { + it('should work over an HTTPS proxy', (done) => { server.once('request', (req, res) => { res.end(JSON.stringify(req.headers)); }); @@ -328,26 +328,26 @@ describe('HttpsProxyAgent', () => { }); let proxy = `https://localhost:${sslProxyPort}`; - proxy = url.parse(proxy); - proxy.rejectUnauthorized = false; - let agent = new HttpsProxyAgent(proxy); - - let opts = url.parse(`https://localhost:${sslServerPort}`); - opts.agent = agent; - opts.rejectUnauthorized = false; - - https.get(opts, (res) => { - let data = ''; - res.setEncoding('utf8'); - res.on('data', (b) => { - data += b; - }); - res.on('end', () => { - data = JSON.parse(data); - assert.equal(`localhost:${sslServerPort}`, data.host); - done(); - }); + let agent = new HttpsProxyAgent(proxy, { + rejectUnauthorized: false, }); + + https.get( + `https://localhost:${sslServerPort}`, + { agent, rejectUnauthorized: false }, + (res) => { + let data = ''; + res.setEncoding('utf8'); + res.on('data', (b) => { + data += b; + }); + res.on('end', () => { + data = JSON.parse(data); + assert.equal(`localhost:${sslServerPort}`, data.host); + done(); + }); + } + ); }); it('should not send a port number for the default port', (done) => { diff --git a/packages/pac-proxy-agent/package.json b/packages/pac-proxy-agent/package.json index 54e9d21e..fd8ef6d2 100644 --- a/packages/pac-proxy-agent/package.json +++ b/packages/pac-proxy-agent/package.json @@ -45,7 +45,7 @@ }, "devDependencies": { "@types/debug": "^4.1.7", - "@types/node": "^12.20.55", + "@types/node": "^14.18.43", "mocha": "^6.2.3", "proxy": "^1.0.2", "socksv5": "0.0.6", diff --git a/packages/pac-proxy-agent/src/index.ts b/packages/pac-proxy-agent/src/index.ts index 6f124cec..134f4c25 100644 --- a/packages/pac-proxy-agent/src/index.ts +++ b/packages/pac-proxy-agent/src/index.ts @@ -45,19 +45,22 @@ export const protocols = Object.keys(gProtocols); * - "pac+https", "https" - refers to an HTTPS endpoint */ export class PacProxyAgent extends Agent { - uri: string; + uri: URL; opts: PacProxyAgentOptions; cache?: Readable; resolver?: FindProxyForURL; resolverHash: string; resolverPromise?: Promise; - constructor(uri: string, opts?: PacProxyAgentOptions) { + constructor(uri: string | URL, opts?: PacProxyAgentOptions) { super(); - debug('Creating PacProxyAgent with URI %o and options %o', uri, opts); // Strip the "pac+" prefix - this.uri = uri.replace(/^pac\+/i, ''); + const uriStr = typeof uri === 'string' ? uri : uri.href; + this.uri = new URL(uriStr.replace(/^pac\+/i, '')); + + debug('Creating PacProxyAgent with URI %o', this.uri.href); + this.opts = { port: 0, ...opts }; this.cache = undefined; this.resolver = undefined; @@ -66,7 +69,7 @@ export class PacProxyAgent extends Agent { // For `PacResolver` if (!this.opts.filename) { - this.opts.filename = uri; + this.opts.filename = this.uri.href; } } diff --git a/packages/pac-proxy-agent/test/test.js b/packages/pac-proxy-agent/test/test.js index dea7c10d..0902f865 100644 --- a/packages/pac-proxy-agent/test/test.js +++ b/packages/pac-proxy-agent/test/test.js @@ -149,25 +149,19 @@ describe('PacProxyAgent', function () { describe('constructor', function () { it('should throw an Error if no "proxy" argument is given', function () { - assert.throws(function () { + assert.throws(() => { new PacProxyAgent(); }); }); it('should accept a "string" proxy argument', function () { let agent = new PacProxyAgent('pac+ftp://example.com/proxy.pac'); - assert.equal('ftp://example.com/proxy.pac', agent.uri); + assert.equal('ftp://example.com/proxy.pac', agent.uri.href); }); it('should accept a `URL` instance proxy argument', function () { let agent = new PacProxyAgent( new URL('pac+ftp://example.com/proxy.pac') ); - assert.equal('ftp://example.com/proxy.pac', agent.uri); - }); - it('should accept a `uri` on the options object', function () { - let agent = new PacProxyAgent({ - uri: 'pac+ftp://example.com/proxy.pac', - }); - assert.equal('ftp://example.com/proxy.pac', agent.uri); + assert.equal('ftp://example.com/proxy.pac', agent.uri.href); }); }); @@ -213,9 +207,7 @@ describe('PacProxyAgent', function () { let uri = `data:,${encodeURIComponent( FindProxyForURL.toString().replace('PORT', proxyHttpsPort) )}`; - let proxy = url.parse(uri); - proxy.rejectUnauthorized = false; - let agent = new PacProxyAgent(proxy); + let agent = new PacProxyAgent(uri, { rejectUnauthorized: false }); let opts = url.parse(`http://localhost:${httpPort}/test`); opts.agent = agent; diff --git a/packages/pac-resolver/package.json b/packages/pac-resolver/package.json index 5b80ce5b..db2574d5 100644 --- a/packages/pac-resolver/package.json +++ b/packages/pac-resolver/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@types/ip": "^1.1.0", "@types/netmask": "^1.0.30", - "@types/node": "^17.0.19", + "@types/node": "^14.18.43", "mocha": "^9.2.1", "tsconfig": "workspace:*", "typescript": "^5.0.4" @@ -31,7 +31,7 @@ "url": "git://github.com/TooTallNate/node-pac-resolver.git" }, "engines": { - "node": ">= 8" + "node": ">= 14" }, "keywords": [ "pac", diff --git a/packages/socks-proxy-agent/package.json b/packages/socks-proxy-agent/package.json index 38eaf251..d5f4c326 100644 --- a/packages/socks-proxy-agent/package.json +++ b/packages/socks-proxy-agent/package.json @@ -112,12 +112,12 @@ "socks": "^2.7.1" }, "devDependencies": { - "@types/debug": "latest", - "@types/node": "latest", - "cacheable-lookup": "latest", - "dns2": "latest", + "@types/debug": "^4.1.7", + "@types/node": "^14.18.43", + "cacheable-lookup": "^6.1.0", + "dns2": "^2.1.0", "mocha": "^9.2.2", - "raw-body": "latest", + "raw-body": "^2.5.2", "socksv5": "github:TooTallNate/socksv5#fix/dstSock-close-event", "tsconfig": "workspace:*", "typescript": "^5.0.4" diff --git a/packages/socks-proxy-agent/test/test.js b/packages/socks-proxy-agent/test/test.js index 1bef3c7a..69743d90 100644 --- a/packages/socks-proxy-agent/test/test.js +++ b/packages/socks-proxy-agent/test/test.js @@ -24,7 +24,7 @@ describe('SocksProxyAgent', function () { before(function (done) { // setup SOCKS proxy server - socksServer = socks.createServer(function (info, accept, deny) { + socksServer = socks.createServer(function (_info, accept) { accept(); }); socksServer.listen(0, '127.0.0.1', function () { @@ -118,7 +118,7 @@ describe('SocksProxyAgent', function () { headers: { foo: 'bar' }, }; - const req = http.get(opts, function () {}); + const req = http.get(opts); req.once('error', (err) => { assert.equal(err.message, 'socket hang up'); @@ -245,7 +245,7 @@ describe('SocksProxyAgent', function () { ); opts.agent = agent; - opts.lookup = (hostname, opts, callback) => { + opts.lookup = (hostname, _opts, callback) => { if (hostname === 'non-existent-domain.test') callback(null, '127.0.0.1'); else callback(new Error('Bad domain')); @@ -253,10 +253,7 @@ describe('SocksProxyAgent', function () { let req = http.get(opts, function (res) { assert.equal(404, res.statusCode); - getRawBody(res, 'utf8', function (err, buf) { - if (err) return done(err); - done(); - }); + done(); }); req.once('error', done); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 189bc505..729d5812 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -275,8 +275,8 @@ importers: specifier: ^4.1.7 version: 4.1.7 '@types/node': - specifier: ^12.20.55 - version: 12.20.55 + specifier: ^14.18.43 + version: 14.18.43 mocha: specifier: ^6.2.3 version: 6.2.3 @@ -312,8 +312,8 @@ importers: specifier: ^1.0.30 version: 1.0.30 '@types/node': - specifier: ^17.0.19 - version: 17.0.19 + specifier: ^14.18.43 + version: 14.18.43 mocha: specifier: ^9.2.1 version: 9.2.1 @@ -337,22 +337,22 @@ importers: version: 2.7.1 devDependencies: '@types/debug': - specifier: latest + specifier: ^4.1.7 version: 4.1.7 '@types/node': - specifier: latest - version: 18.16.1 + specifier: ^14.18.43 + version: 14.18.43 cacheable-lookup: - specifier: latest - version: 7.0.0 + specifier: ^6.1.0 + version: 6.1.0 dns2: - specifier: latest + specifier: ^2.1.0 version: 2.1.0 mocha: specifier: ^9.2.2 version: 9.2.2 raw-body: - specifier: latest + specifier: ^2.5.2 version: 2.5.2 socksv5: specifier: github:TooTallNate/socksv5#fix/dstSock-close-event @@ -783,7 +783,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 jest-message-util: 29.5.0 jest-util: 29.5.0 @@ -804,14 +804,14 @@ packages: '@jest/test-result': 29.5.0 '@jest/transform': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.5.0 - jest-config: 29.5.0(@types/node@18.16.1) + jest-config: 29.5.0(@types/node@14.18.43) jest-haste-map: 29.5.0 jest-message-util: 29.5.0 jest-regex-util: 29.4.3 @@ -838,7 +838,7 @@ packages: dependencies: '@jest/fake-timers': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 jest-mock: 29.5.0 dev: true @@ -865,7 +865,7 @@ packages: dependencies: '@jest/types': 29.5.0 '@sinonjs/fake-timers': 10.0.2 - '@types/node': 18.16.1 + '@types/node': 14.18.43 jest-message-util: 29.5.0 jest-mock: 29.5.0 jest-util: 29.5.0 @@ -898,7 +898,7 @@ packages: '@jest/transform': 29.5.0 '@jest/types': 29.5.0 '@jridgewell/trace-mapping': 0.3.18 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -986,7 +986,7 @@ packages: '@jest/schemas': 29.4.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.16.1 + '@types/node': 14.18.43 '@types/yargs': 17.0.24 chalk: 4.1.2 dev: true @@ -1142,13 +1142,13 @@ packages: /@types/graceful-fs@4.1.6: resolution: {integrity: sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==} dependencies: - '@types/node': 18.16.1 + '@types/node': 14.18.43 dev: true /@types/ip@1.1.0: resolution: {integrity: sha512-dwNe8gOoF70VdL6WJBwVHtQmAX4RMd62M+mAB9HQFjG1/qiCLM/meRy95Pd14FYBbEDwCq7jgJs89cHpLBu4HQ==} dependencies: - '@types/node': 18.16.1 + '@types/node': 14.18.43 dev: true /@types/istanbul-lib-coverage@2.0.4: @@ -1201,14 +1201,6 @@ packages: resolution: {integrity: sha512-n3eFEaoem0WNwLux+k272P0+aq++5o05bA9CfiwKPdYPB5ZambWKdWoeHy7/OJiizMhzg27NLaZ6uzjLTzXceQ==} dev: true - /@types/node@17.0.19: - resolution: {integrity: sha512-PfeQhvcMR4cPFVuYfBN4ifG7p9c+Dlh3yUZR6k+5yQK7wX3gDgVxBly4/WkBRs9x4dmcy1TVl08SY67wwtEvmA==} - dev: true - - /@types/node@18.16.1: - resolution: {integrity: sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA==} - dev: true - /@types/prettier@2.7.2: resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} dev: true @@ -1732,9 +1724,9 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - /cacheable-lookup@7.0.0: - resolution: {integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==} - engines: {node: '>=14.16'} + /cacheable-lookup@6.1.0: + resolution: {integrity: sha512-KJ/Dmo1lDDhmW2XDPMo+9oiy/CeqosPguPCrgcVzKyZrL6pM1gU2GmPY/xo6OQPTUaA/c0kwHuywB4E6nmT9ww==} + engines: {node: '>=10.6.0'} dev: true /call-bind@1.0.2: @@ -3082,7 +3074,7 @@ packages: '@jest/expect': 29.5.0 '@jest/test-result': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -3169,45 +3161,6 @@ packages: - supports-color dev: true - /jest-config@29.5.0(@types/node@18.16.1): - resolution: {integrity: sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true - dependencies: - '@babel/core': 7.21.4 - '@jest/test-sequencer': 29.5.0 - '@jest/types': 29.5.0 - '@types/node': 18.16.1 - babel-jest: 29.5.0(@babel/core@7.21.4) - chalk: 4.1.2 - ci-info: 3.8.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.5.0 - jest-environment-node: 29.5.0 - jest-get-type: 29.4.3 - jest-regex-util: 29.4.3 - jest-resolve: 29.5.0 - jest-runner: 29.5.0 - jest-util: 29.5.0 - jest-validate: 29.5.0 - micromatch: 4.0.5 - parse-json: 5.2.0 - pretty-format: 29.5.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - supports-color - dev: true - /jest-diff@27.5.1: resolution: {integrity: sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} @@ -3253,7 +3206,7 @@ packages: '@jest/environment': 29.5.0 '@jest/fake-timers': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 jest-mock: 29.5.0 jest-util: 29.5.0 dev: true @@ -3274,7 +3227,7 @@ packages: dependencies: '@jest/types': 29.5.0 '@types/graceful-fs': 4.1.6 - '@types/node': 18.16.1 + '@types/node': 14.18.43 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -3325,7 +3278,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 jest-util: 29.5.0 dev: true @@ -3380,7 +3333,7 @@ packages: '@jest/test-result': 29.5.0 '@jest/transform': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -3411,7 +3364,7 @@ packages: '@jest/test-result': 29.5.0 '@jest/transform': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 cjs-module-lexer: 1.2.2 collect-v8-coverage: 1.0.1 @@ -3466,7 +3419,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -3491,7 +3444,7 @@ packages: dependencies: '@jest/test-result': 29.5.0 '@jest/types': 29.5.0 - '@types/node': 18.16.1 + '@types/node': 14.18.43 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -3503,7 +3456,7 @@ packages: resolution: {integrity: sha512-NcrQnevGoSp4b5kg+akIpthoAFHxPBcb5P6mYPY0fUNT+sSvmtu6jlkEle3anczUKIKEbMxFimk9oTP/tpIPgA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 18.16.1 + '@types/node': 14.18.43 jest-util: 29.5.0 merge-stream: 2.0.0 supports-color: 8.1.1