Socket
Socket
Sign inDemoInstall

caw

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caw - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

31

index.js
'use strict';
var url = require('url');
var getProxy = require('get-proxy');
var objectAssign = require('object-assign');
var tunnelAgent = require('tunnel-agent');
var isObj = require('is-obj');
const url = require('url');
const getProxy = require('get-proxy');
const tunnelAgent = require('tunnel-agent');
module.exports = function (proxy, opts) {
opts = objectAssign({}, opts);
module.exports = (proxy, opts) => {
proxy = proxy || getProxy();
opts = Object.assign({}, opts);
if (isObj(proxy)) {
if (typeof proxy === 'object') {
opts = proxy;
proxy = getProxy();
} else if (proxy === undefined) {
proxy = getProxy();
}
if (!proxy) {
return undefined;
return null;
}

@@ -24,13 +21,13 @@

var uriProtocol = opts.protocol === 'https' ? 'https' : 'http';
var proxyProtocol = proxy.protocol === 'https:' ? 'Https' : 'Http';
var port = proxy.port || (proxyProtocol === 'Https' ? 443 : 80);
var method = [uriProtocol, proxyProtocol].join('Over');
const uriProtocol = opts.protocol === 'https' ? 'https' : 'http';
const proxyProtocol = proxy.protocol === 'https:' ? 'Https' : 'Http';
const port = proxy.port || (proxyProtocol === 'Https' ? 443 : 80);
const method = `${uriProtocol}Over${proxyProtocol}`;
delete opts.protocol;
return tunnelAgent[method](objectAssign({
return tunnelAgent[method](Object.assign({
proxy: {
port,
host: proxy.hostname,
port: port,
proxyAuth: proxy.auth

@@ -37,0 +34,0 @@ }

{
"name": "caw",
"version": "1.2.0",
"version": "2.0.0",
"description": "Construct HTTP/HTTPS agents for tunneling proxies",

@@ -13,6 +13,6 @@ "license": "MIT",

"scripts": {
"test": "xo && tap test/test.js -t2"
"test": "xo && ava"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -30,12 +30,19 @@ "files": [

"get-proxy": "^1.0.1",
"is-obj": "^1.0.0",
"object-assign": "^3.0.0",
"tunnel-agent": "^0.4.0"
},
"devDependencies": {
"proxyquire": "^1.6.0",
"sinon": "^1.15.4",
"tap": "^1.3.1",
"ava": "*",
"get-port": "^2.1.0",
"got": "^6.3.0",
"pify": "^2.3.0",
"proxyquire": "^1.7.9",
"sinon": "^1.17.4",
"xo": "*"
},
"xo": {
"esnext": true,
"rules": {
"ava/no-skip-test": 0
}
}
}

@@ -16,8 +16,8 @@ # caw [![Build Status](https://travis-ci.org/kevva/caw.svg?branch=master)](https://travis-ci.org/kevva/caw)

```js
var caw = require('caw');
var got = require('got');
const caw = require('caw');
const got = require('got');
got('todomvc.com', {
agent: caw()
}, function () {});
}, () => {});
```

@@ -28,3 +28,3 @@

### caw(proxy, options)
### caw([proxy], [options])

@@ -35,8 +35,6 @@ #### proxy

Proxy URL.
Proxy URL. If not set, it'll try getting it using [`get-proxy`](https://github.com/kevva/get-proxy).
#### options
Type: `object`
Besides the options below, you can pass in options allowed in [tunnel-agent](https://github.com/koichik/node-tunnel).

@@ -46,3 +44,3 @@

Type: `string`
Type: `string`<br>
Default: `http`

@@ -49,0 +47,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc