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

supertest-session

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest-session - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

.jshintignore

55

index.js

@@ -1,3 +0,3 @@

var _ = require('lodash'),
cookie = require('cookie'),
var cookie = require('cookie'),
methods = require('methods'),
request = require('supertest');

@@ -16,7 +16,9 @@

function serializeCookie (c) {
return _.compact(Object.keys(c).map(function (k) {
if (reservedAvs.indexOf(k.toLowerCase()) === -1) {
return decodeURIComponent(cookie.serialize(k, c[k]));
return Object.keys(c).reduce(function (pairs, key) {
var isReserved = reservedAvs.indexOf(key.toLowerCase()) === -1;
if (isReserved) {
return pairs.concat(decodeURIComponent(cookie.serialize(key, c[key])));
}
}));
return pairs;
}, []);
}

@@ -31,3 +33,3 @@

if (config.envs && _.isObject(config.envs)) {
if (config.envs && (config.envs instanceof Object)) {
Object.keys(config.envs).forEach(function(e) {

@@ -54,3 +56,3 @@ process.env[e] = config.envs[e];

Session.prototype._destroy = function () {
Session.prototype.destroy = function () {
if (config.destroy) config.destroy.call(this);

@@ -61,15 +63,14 @@ this.cookies = null;

Session.prototype.request = function (meth, route) {
var req = request(this.app);
req = req[meth](route);
var req = request(this.app)[meth](route);
var sess = this;
var _end = req.end.bind(req);
this._before(req);
req.end = _.wrap(req.end.bind(req), function (end, callback) {
return end(_.wrap(callback, function (callback, err, res) {
if (err === null) {
this._after(req, res);
}
req.end = function (callback) {
return _end(function (err, res) {
if (err === null) sess._after(req, res);
return callback(err, res);
}.bind(this)));
}.bind(this));
});
};

@@ -79,12 +80,16 @@ return req;

Session.prototype.destroy = function () {
this._destroy();
};
['get', 'put', 'post', 'del', 'patch'].forEach(function (m) {
Session.prototype[m] = _.partial(Session.prototype.request, m);
methods.forEach(function (m) {
Session.prototype[m] = function () {
var args = [].slice.call(arguments);
return this.request.apply(this, [m].concat(args));
};
});
if (_.isObject(config.helpers)) {
_.extend(Session.prototype, config.helpers);
// Back-compatibility only; will be removed in future version bump.
Session.prototype.del = Session.prototype.delete;
if (config.helpers instanceof Object) {
Object.keys(config.helpers).forEach(function (key) {
Session.prototype[key] = config.helpers[key];
});
}

@@ -91,0 +96,0 @@

{
"name": "supertest-session",
"version": "0.0.6",
"version": "0.0.7",
"description": "Cookie-based session persistence for Supertest",
"main": "index.js",
"scripts": {
"test": "./node_modules/jasmine-node/bin/jasmine-node --forceexit test",
"lint": "./node_modules/jshint/bin/jshint .",
"test": "npm run lint && ./node_modules/jasmine-node/bin/jasmine-node test",
"cover": "./node_modules/istanbul/lib/cli.js cover ./node_modules/jasmine-node/bin/jasmine-node ./spec/ && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

@@ -32,6 +33,4 @@ },

"cookie": "^0.1.2",
"coveralls": "^2.11.2",
"jasmine-node": "^1.14.5",
"lodash": "~2.2.1",
"supertest": "^0.14.0"
"methods": "^1.1.0",
"supertest": "^0.15.0"
},

@@ -41,6 +40,9 @@ "devDependencies": {

"cookie-session": "^1.1.0",
"coveralls": "^2.11.2",
"express": "^4.9.5",
"istanbul": "^0.3.0",
"jasmine-node": "^1.14.5",
"jshint": "^2.5.10",
"through": "^2.3.6"
}
}

@@ -7,3 +7,2 @@ # Supertest sessions

Status](https://travis-ci.org/rjz/supertest-session.svg?branch=master)](https://travis-ci.org/rjz/supertest-session)
[![Coverage

@@ -10,0 +9,0 @@ Status](https://coveralls.io/repos/rjz/supertest-session/badge.png)](https://coveralls.io/r/rjz/supertest-session)

@@ -48,18 +48,10 @@ var tr = require('through'),

it('supports streaming', function (done) {
sess = new Session();
sess.get('/')
.pipe(tr(function (data) {
assert.equal(data.toString('utf8'), 'GET,,1');
}, done));
});
describe('method sugar', function () {
var methods = {
'del' : 'DELETE',
'get' : 'GET',
'post' : 'POST',
'put' : 'PUT',
'patch' : 'PATCH'
};
'del' : 'DELETE',
'get' : 'GET',
'post' : 'POST',
'put' : 'PUT',
'patch' : 'PATCH'
};

@@ -66,0 +58,0 @@ Object.keys(methods).forEach(function (key) {

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