Socket
Socket
Sign inDemoInstall

jsonwebtoken

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonwebtoken - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

test/verify.tests.js

16

index.js

@@ -8,3 +8,15 @@ var jws = require('jws');

var decoded = jws.decode(jwt, options);
return decoded && decoded.payload;
var payload = decoded && decoded.payload;
//try parse the payload
if(typeof payload === 'string') {
try {
var obj = JSON.parse(payload);
if(typeof obj === 'object') {
return obj;
}
} catch (e) { }
}
return payload;
};

@@ -113,3 +125,3 @@

try {
payload = this.decode(jwtString);
payload = this.decode(jwtString);
} catch(err) {

@@ -116,0 +128,0 @@ return done(err);

2

package.json
{
"name": "jsonwebtoken",
"version": "4.0.0",
"version": "4.1.0",
"description": "JSON Web Token implementation (symmetric and asymmetric)",

@@ -5,0 +5,0 @@ "main": "index.js",

var jwt = require('../index');
var expect = require('chai').expect;
var JsonWebTokenError = require('../lib/JsonWebTokenError');

@@ -12,2 +13,9 @@ describe('non_object_values values', function() {

it('should fail to validate audience when the payload is string', function () {
var token = jwt.sign('hello', '123');
expect(function () {
jwt.verify(token, '123', { audience: 'foo' });
}).to.throw(JsonWebTokenError);
});
it('should work with number', function () {

@@ -14,0 +22,0 @@ var token = jwt.sign(123, '123');

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