https-proxy-agent
Advanced tools
+8
-0
| 1.0.0 / 2015-07-10 | ||
| ================== | ||
| * upgrade to "agent-base" v2 API | ||
| * test: test case is fixed | ||
| * use %o debug() formatter | ||
| * README: use SVG for Travis-CI badge | ||
| 0.3.6 / 2015-07-06 | ||
@@ -3,0 +11,0 @@ ================== |
+7
-30
@@ -31,3 +31,3 @@ | ||
| if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!'); | ||
| debug('creating new HttpsProxyAgent instance: %j', opts); | ||
| debug('creating new HttpsProxyAgent instance: %o', opts); | ||
| Agent.call(this, connect); | ||
@@ -40,5 +40,2 @@ | ||
| // if `true`, then connect to the destination endpoint over TLS, defaults to `true` | ||
| this.secureEndpoint = opts.secureEndpoint !== false; | ||
| // prefer `hostname` over `host`, and set the `port` if needed | ||
@@ -61,9 +58,2 @@ proxy.host = proxy.hostname || proxy.host; | ||
| /** | ||
| * Default options for the "connect" opts object. | ||
| */ | ||
| var defaults = { port: 80 }; | ||
| var secureDefaults = { port: 443 }; | ||
| /** | ||
| * Called when the node-core HTTP client library is creating a new HTTP request. | ||
@@ -74,11 +64,9 @@ * | ||
| function connect (req, _opts, fn) { | ||
| function connect (req, opts, fn) { | ||
| var proxy = this.proxy; | ||
| var secureProxy = this.secureProxy; | ||
| var secureEndpoint = this.secureEndpoint; | ||
| // create a socket connection to the proxy server | ||
| var socket; | ||
| if (secureProxy) { | ||
| if (this.secureProxy) { | ||
| socket = tls.connect(proxy); | ||
@@ -89,11 +77,2 @@ } else { | ||
| // these `opts` are the connect options to connect to the destination endpoint | ||
| // XXX: we mix in the proxy options so that TLS options like | ||
| // `rejectUnauthorized` get passed to the destination endpoint as well | ||
| var proxyOpts = extend({}, proxy); | ||
| delete proxyOpts.host; | ||
| delete proxyOpts.hostname; | ||
| delete proxyOpts.port; | ||
| var opts = extend({}, proxyOpts, secureEndpoint ? secureDefaults : defaults, _opts); | ||
| // we need to buffer any HTTP traffic that happens with the proxy before we get | ||
@@ -121,3 +100,3 @@ // the CONNECT response, so that if the response is anything other than an "200" | ||
| function onclose (err) { | ||
| debug('onclose had error', err); | ||
| debug('onclose had error %o', err); | ||
| } | ||
@@ -153,5 +132,3 @@ | ||
| var statusCode = +firstLine.split(' ')[1]; | ||
| debug('got proxy server response: "%s"', firstLine); | ||
| //console.log('statusCode: %d', statusCode); | ||
| //console.log(b.length, b, b.toString()); | ||
| debug('got proxy server response: %o', firstLine); | ||
@@ -165,6 +142,6 @@ if (200 == statusCode) { | ||
| if (secureEndpoint) { | ||
| if (opts.secureEndpoint) { | ||
| // since the proxy is connecting to an SSL server, we have | ||
| // to upgrade this socket connection to an SSL connection | ||
| debug('upgrading proxy-connected socket to TLS connection: "%s"', opts.host); | ||
| debug('upgrading proxy-connected socket to TLS connection: %o', opts.host); | ||
| opts.socket = socket; | ||
@@ -171,0 +148,0 @@ opts.servername = opts.host; |
+2
-2
| { | ||
| "name": "https-proxy-agent", | ||
| "version": "0.3.6", | ||
| "version": "1.0.0", | ||
| "description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS", | ||
@@ -25,3 +25,3 @@ "main": "https-proxy-agent.js", | ||
| "dependencies": { | ||
| "agent-base": "~1.0.1", | ||
| "agent-base": "2", | ||
| "debug": "2", | ||
@@ -28,0 +28,0 @@ "extend": "3" |
+1
-1
| https-proxy-agent | ||
| ================ | ||
| ### An HTTP(s) proxy `http.Agent` implementation for HTTPS | ||
| [](https://travis-ci.org/TooTallNate/node-https-proxy-agent) | ||
| [](https://travis-ci.org/TooTallNate/node-https-proxy-agent) | ||
@@ -6,0 +6,0 @@ This module provides an `http.Agent` implementation that connects to a specified |
+52
-29
@@ -112,20 +112,2 @@ | ||
| }); | ||
| describe('secureEndpoint', function () { | ||
| it('should default to `true`', function () { | ||
| var agent = new HttpsProxyAgent('http://127.0.0.1:' + proxyPort); | ||
| assert.equal(true, agent.secureEndpoint); | ||
| }); | ||
| it('should be `false` when passed in as an option', function () { | ||
| var opts = url.parse('http://127.0.0.1:' + proxyPort); | ||
| opts.secureEndpoint = false; | ||
| var agent = new HttpsProxyAgent(opts); | ||
| assert.equal(false, agent.secureEndpoint); | ||
| }); | ||
| it('should be `true` when passed in as an option', function () { | ||
| var opts = url.parse('http://127.0.0.1:' + proxyPort); | ||
| opts.secureEndpoint = true; | ||
| var agent = new HttpsProxyAgent(opts); | ||
| assert.equal(true, agent.secureEndpoint); | ||
| }); | ||
| }); | ||
| describe('secureProxy', function () { | ||
@@ -157,2 +139,54 @@ it('should default to `false`', function () { | ||
| it('should work over an HTTP proxy', function (done) { | ||
| server.once('request', function (req, res) { | ||
| res.end(JSON.stringify(req.headers)); | ||
| }); | ||
| var proxy = process.env.HTTP_PROXY || process.env.http_proxy || 'http://127.0.0.1:' + proxyPort; | ||
| var agent = new HttpsProxyAgent(proxy); | ||
| var opts = url.parse('http://127.0.0.1:' + serverPort); | ||
| opts.agent = agent; | ||
| var req = http.get(opts, function (res) { | ||
| var data = ''; | ||
| res.setEncoding('utf8'); | ||
| res.on('data', function (b) { | ||
| data += b; | ||
| }); | ||
| res.on('end', function () { | ||
| data = JSON.parse(data); | ||
| assert.equal('127.0.0.1:' + serverPort, data.host); | ||
| done(); | ||
| }); | ||
| }); | ||
| req.once('error', done); | ||
| }); | ||
| it('should work over an HTTPS proxy', function (done) { | ||
| server.once('request', function (req, res) { | ||
| res.end(JSON.stringify(req.headers)); | ||
| }); | ||
| var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort; | ||
| proxy = url.parse(proxy); | ||
| proxy.rejectUnauthorized = false; | ||
| var agent = new HttpsProxyAgent(proxy); | ||
| var opts = url.parse('http://127.0.0.1:' + serverPort); | ||
| opts.agent = agent; | ||
| http.get(opts, function (res) { | ||
| var data = ''; | ||
| res.setEncoding('utf8'); | ||
| res.on('data', function (b) { | ||
| data += b; | ||
| }); | ||
| res.on('end', function () { | ||
| data = JSON.parse(data); | ||
| console.log(data); | ||
| assert.equal('127.0.0.1:' + serverPort, data.host); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| it('should receive the 407 authorization code on the `http.ClientResponse`', function (done) { | ||
@@ -199,3 +233,2 @@ // set a proxy authentication function for this test | ||
| it('should work over an HTTP proxy', function (done) { | ||
| // set HTTP "request" event handler for this test | ||
| sslServer.once('request', function (req, res) { | ||
@@ -206,9 +239,2 @@ res.end(JSON.stringify(req.headers)); | ||
| var proxy = process.env.HTTP_PROXY || process.env.http_proxy || 'http://127.0.0.1:' + proxyPort; | ||
| proxy = url.parse(proxy); | ||
| // `rejectUnauthorized` shoudn't *technically* be necessary here, | ||
| // but up until node v0.11.6, the `http.Agent` class didn't have | ||
| // access to the *entire* request "options" object. Thus, | ||
| // `https-proxy-agent` will *also* merge in options you pass here | ||
| // to the destination endpoints… | ||
| proxy.rejectUnauthorized = false; | ||
| var agent = new HttpsProxyAgent(proxy); | ||
@@ -239,3 +265,2 @@ | ||
| it('should work over an HTTPS proxy', function (done) { | ||
| // set HTTP "request" event handler for this test | ||
| sslServer.once('request', function (req, res) { | ||
@@ -247,4 +272,2 @@ res.end(JSON.stringify(req.headers)); | ||
| proxy = url.parse(proxy); | ||
| // `rejectUnauthorized` is actually necessary this time since the HTTPS | ||
| // proxy server itself is using a self-signed SSL certificate… | ||
| proxy.rejectUnauthorized = false; | ||
@@ -251,0 +274,0 @@ var agent = new HttpsProxyAgent(proxy); |
Network access
Supply chain riskThis module accesses the network.
Found 4 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 4 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-50%24550
-1.96%419
-0.48%12
50%+ Added
+ Added
- Removed
Updated