From d18c6bdf6b04131b0a2147b4eb1202d63a5c8aa6 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Wed, 7 Oct 2020 15:15:50 -0700 Subject: [PATCH] Update `agent-base` to v6 (#55) - small changes to adapt to new api - updated proxy dependencies that use agent-base@6 --- index.js | 8 +++++--- package.json | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 8d50c5b..96ed7e3 100644 --- a/index.js +++ b/index.js @@ -144,7 +144,7 @@ function mapOptsToProxy(opts) { function ProxyAgent (opts) { if (!(this instanceof ProxyAgent)) return new ProxyAgent(opts); debug('creating new ProxyAgent instance: %o', opts); - Agent.call(this, connect); + Agent.call(this); if (opts) { var proxy = mapOptsToProxy(opts); @@ -159,7 +159,7 @@ inherits(ProxyAgent, Agent); * */ -function connect (req, opts, fn) { +ProxyAgent.prototype.callback = function(req, opts, fn) { var proxyOpts = this.proxy; var proxyUri = this.proxyUri; var proxyFn = this.proxyFn; @@ -193,6 +193,8 @@ function connect (req, opts, fn) { agent.addRequest(req, opts); } else { // XXX: agent.callback() is an agent-base-ism - agent.callback(req, opts, fn); + agent.callback(req, opts) + .then(function(socket) { fn(null, socket); }) + .catch(function(error) { fn(error); }); } } diff --git a/package.json b/package.json index 8b3db98..ff67c83 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,14 @@ }, "homepage": "https://github.com/TooTallNate/node-proxy-agent", "dependencies": { - "agent-base": "^4.2.0", + "agent-base": "^6.0.0", "debug": "4", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^3.0.0", + "http-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", "lru-cache": "^5.1.1", - "pac-proxy-agent": "^3.0.1", + "pac-proxy-agent": "^4.1.0", "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^4.0.1" + "socks-proxy-agent": "^5.0.0" }, "devDependencies": { "@types/agent-base": "^4.2.0",