Socket
Socket
Sign inDemoInstall

express-jwt

Package Overview
Dependencies
Maintainers
5
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-jwt - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

11

lib/index.js

@@ -85,10 +85,15 @@ var jwt = require('jsonwebtoken');

var payload = jwt.decode(token);
var dtoken = jwt.decode(token, { complete: true }) || {};
async.parallel([
function(callback){
secretCallback(req, payload, callback);
var arity = secretCallback.length;
if (arity == 4) {
secretCallback(req, dtoken.header, dtoken.payload, callback);
} else { // arity == 3
secretCallback(req, dtoken.payload, callback);
}
},
function(callback){
isRevokedCallback(req, payload, callback);
isRevokedCallback(req, dtoken.payload, callback);
}

@@ -95,0 +100,0 @@ ], function(err, results){

{
"name": "express-jwt",
"version": "3.0.0",
"version": "3.0.1",
"description": "JWT authentication middleware.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -246,2 +246,18 @@ var jwt = require('jsonwebtoken');

});
it('should work with a secretCallback function that accepts header argument', function() {
var secret = 'shhhhhh';
var secretCallback = function(req, headers, payload, cb) {
assert.equal(headers.alg, 'HS256');
assert.equal(payload.foo, 'bar');
process.nextTick(function(){ return cb(null, secret) });
}
var token = jwt.sign({foo: 'bar'}, secret);
req.headers = {};
req.headers.authorization = 'Bearer ' + token;
expressjwt({secret: secretCallback})(req, res, function() {
assert.equal('bar', req.user.foo);
});
});
});
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