Socket
Socket
Sign inDemoInstall

express-jwt

Package Overview
Dependencies
Maintainers
55
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 7.0.0 to 7.1.0

2

package.json
{
"name": "express-jwt",
"version": "7.0.0",
"version": "7.1.0",
"description": "JWT authentication middleware.",

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

@@ -9,3 +9,3 @@ import * as jwt from 'jsonwebtoken';

type TokenGetter = (req: express.Request) => string | undefined;
type TokenGetter = (req: express.Request) => string | Promise<string> | undefined;

@@ -52,3 +52,3 @@ type Params = {

if (options.getToken && typeof options.getToken === 'function') {
token = options.getToken(req);
token = await options.getToken(req);
} else if (req.headers && req.headers.authorization) {

@@ -55,0 +55,0 @@ const parts = req.headers.authorization.split(' ');

@@ -325,2 +325,26 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

it('should work with an async getToken function', function (done) {
const req = {} as ExpressJwtRequest;
const res = {} as express.Response;
const secret = 'shhhhhh';
const token = jwt.sign({ foo: 'bar' }, secret);
req.headers = {};
req.query = {};
req.query.token = token;
function getTokenFromQuery(req) {
return Promise.resolve(req.query.token);
}
expressjwt({
secret: secret,
algorithms: ['HS256'],
getToken: getTokenFromQuery
})(req, res, function () {
assert.equal(req.auth.foo, 'bar');
done();
});
});
it('should work with a secretCallback function that accepts header argument', function (done) {

@@ -327,0 +351,0 @@ const req = {} as ExpressJwtRequest;

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