Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-request

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-request - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

25

dist/main.js

@@ -13,5 +13,9 @@ "use strict";

request.debug = false;
Arequest = function (defaultOptions) {
var arequest = undefined;
Arequest.validateOptions(defaultOptions);
arequest = function callee$1$0(url, options) {

@@ -24,6 +28,6 @@ return _regeneratorRuntime.async(function callee$1$0$(context$2$0) {

options = _.assign({ url: url }, options, defaultOptions);
options = Arequest.mapOptions(options);
options = _.assign({ url: url }, options);
request(options, function (error, response) {

@@ -54,2 +58,6 @@ if (error) {

if (options.cookieJar === true) {
options.cookieJar = request.jar();
}
return Arequest(options);

@@ -61,2 +69,5 @@ };

/**
*
*/
Arequest.validateOptions = function (options) {

@@ -69,3 +80,3 @@ var unknownOption = undefined;

unknownOption = _.first(_.difference(_.keys(options), ["method", "data", "headers", "proxy"]));
unknownOption = _.first(_.difference(_.keys(options), ["method", "data", "headers", "proxy", "cookieJar", "cookieJar2"]));

@@ -95,2 +106,8 @@ if (unknownOption) {

if (options.cookieJar) {
options.jar = options.cookieJar;
delete options.cookieJar;
}
return options;

@@ -100,2 +117,2 @@ };

module.exports = Arequest({});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm1haW4uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsWUFBWSxDQUFDOzs7Ozs7OztBQUViLElBQUksUUFBUSxZQUFBO0lBQ1IsT0FBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUM7SUFDNUIsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQzs7QUFFMUIsUUFBUSxHQUFHLFVBQUMsY0FBYyxFQUFLO0FBQzNCLFFBQUksUUFBUS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cmVzcG9uc2Uuc3RhdHVzQ29kZSxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzcG9uc2UuaGVhZGVycyxcbiAgICAgICAgICAgICAgICAgICAgYm9keTogcmVzcG9uc2UuYm9keVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH07XG5cbiAgICBhcmVxdWVzdC5kZWZhdWx0cyA9IChvcHRpb25zKSA9PiB7XG4gICAgICAgIGlmICghb3B0aW9ucykge1xuICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRPcHRpb25zO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG9wdGlvbnMuY29va2llSmFyID09PSB0cnVlKSB7XG4gICAgICAgICAgICBvcHRpb25zLmNvb2tpZUphciA9IHJlcXVlc3QuamFyKCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gQXJlcXVlc3Qob3B0aW9ucyk7XG4gICAgfTtcblxuICAgIHJldHVybiBhcmVxdWVzdDtcbn07XG5cbi8qKlxuICpcbiAqL1xuQXJlcXVlc3QudmFsaWRhdGVPcHRpb25zID0gKG9wdGlvbnMpID0+IHtcbiAgICBsZXQgdW5rbm93bk9wdGlvbjtcblxuICAgIGlmICghb3B0aW9ucykge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgdW5rbm93bk9wdGlvbiA9IF8uZmlyc3QoXy5kaWZmZXJlbmNlKF8ua2V5cyhvcHRpb25zKSwgWydtZXRob2QnLCAnZGF0YScsICdoZWFkZXJzJywgJ3Byb3h5JywgJ2Nvb2tpZUphcicsICdjb29raWVKYXIyJ10pKTtcblxuICAgIGlmICh1bmtub3duT3B0aW9uKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcignVW5rbm93biBvcHRpb24gKFwiJyArIHVua25vd25PcHRpb24gKyAnXCIpLicpO1xuICAgIH1cblxuICAgIGlmIChvcHRpb25zLm1ldGhvZCAmJiBfLmluZGV4T2YoWydHRVQnLCAnUE9TVCcsICdQVVQnLCAnSEVBRCcsICdERUxFVEUnXSwgb3B0aW9ucy5tZXRob2QpID09PSAtMSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1Vua25vd24gb3B0aW9uLm1ldGhvZCB2YWx1ZSAoXCInICsgb3B0aW9ucy5tZXRob2QgKyAnXCIpLicpO1xuICAgIH1cbn07XG5cbi8qKlxuICogTWFwIG9wdGlvbnMgdG8gbWVldCB0aGUgcmVxdWVzdCBpbnRlcmZhY2UuXG4gKi9cbkFyZXF1ZXN0Lm1hcE9wdGlvbnMgPSAob3B0aW9ucykgPT4ge1xuICAgIGlmICghb3B0aW9ucykge1xuICAgICAgICByZXR1cm4gb3B0aW9ucztcbiAgICB9XG5cbiAgICBpZiAob3B0aW9ucy5kYXRhKSB7XG4gICAgICAgIG9wdGlvbnMuZm9ybSA9IG9wdGlvbnMuZGF0YTtcblxuICAgICAgICBkZWxldGUgb3B0aW9ucy5kYXRhO1xuICAgIH1cblxuICAgIGlmIChvcHRpb25zLmNvb2tpZUphcikge1xuICAgICAgICBvcHRpb25zLmphciA9IG9wdGlvbnMuY29va2llSmFyO1xuXG4gICAgICAgIGRlbGV0ZSBvcHRpb25zLmNvb2tpZUphcjtcbiAgICB9XG5cbiAgICByZXR1cm4gb3B0aW9ucztcbn07XG5cbm1vZHVsZS5leHBvcnRzID0gQXJlcXVlc3Qoe30pO1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

5

package.json
{
"name": "async-request",
"description": "async-request is a wrapper for request that uses ES7 async functions.",
"version": "1.1.0",
"version": "1.2.0",
"main": "src/main.js",

@@ -37,4 +37,5 @@ "author": {

"lodash": "^3.5.0",
"request": "^2.53.0"
"request": "^2.53.0",
"tough-cookie": "^0.12.1"
}
}

@@ -32,3 +32,8 @@ # async-request

},
proxy: 'http://127.0.0.1:8000'
proxy: 'http://127.0.0.1:8000',
// To create a new cookie jar.
cookieJar: true,
// To use a custom/existing cookie jar.
// https://www.npmjs.com/package/tough-cookie
cookieJar: new tough.CookieJar()
});

@@ -35,0 +40,0 @@ } catch (e) {

@@ -7,5 +7,9 @@ 'use strict';

request.debug = false;
Arequest = (defaultOptions) => {
let arequest;
Arequest.validateOptions(defaultOptions);
arequest = async (url, options) => {

@@ -15,6 +19,6 @@ return new Promise((resolve) => {

options = _.assign({url: url}, options, defaultOptions);
options = Arequest.mapOptions(options);
options = _.assign({url: url}, options);
request(options, (error, response) => {

@@ -39,2 +43,6 @@ if (error) {

if (options.cookieJar === true) {
options.cookieJar = request.jar();
}
return Arequest(options);

@@ -46,2 +54,5 @@ };

/**
*
*/
Arequest.validateOptions = (options) => {

@@ -54,3 +65,3 @@ let unknownOption;

unknownOption = _.first(_.difference(_.keys(options), ['method', 'data', 'headers', 'proxy']));
unknownOption = _.first(_.difference(_.keys(options), ['method', 'data', 'headers', 'proxy', 'cookieJar', 'cookieJar2']));

@@ -80,2 +91,8 @@ if (unknownOption) {

if (options.cookieJar) {
options.jar = options.cookieJar;
delete options.cookieJar;
}
return options;

@@ -82,0 +99,0 @@ };

'use strict';
let chai,
expect,
nock,
request;
let chai = require('chai'),
expect = chai.expect,
nock = require('nock');
chai = require('chai');
expect = chai.expect;
nock = require('nock');
request = require('../src/main.js');
describe('request', () => {
let request;
describe('request', () => {
beforeEach(() => {
request = require('../src/main.js');
nock.cleanAll();
nock.disableNetConnect();

@@ -133,2 +132,25 @@ });

describe('request(url, {cookieJar})', () => {
it('establishes a cookieJar', async () => {
nock('http://gajus.com')
.get('/set-cookie')
.reply(200, '', {
'set-cookie': 'foo=bar'
});
nock('http://gajus.com')
.matchHeader('cookie', 'foo=bar')
.get('/use-cookie')
.reply(200);
request = request.defaults({
cookieJar: true,
//proxy: 'http://127.0.0.1:8080/'
});
await request('http://gajus.com/set-cookie');
await request('http://gajus.com/use-cookie');
});
});
describe('request(url, {proxy})', () => {

@@ -135,0 +157,0 @@ // nock does not allow testing proxy.

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