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

jsonwebtoken

Package Overview
Dependencies
Maintainers
7
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 5.5.2 to 5.5.3

test/issue_147.tests.js

20

index.js

@@ -41,5 +41,15 @@ var jws = require('jws');

var payload_options = [
'expiresIn',
'notBefore',
'expiresInMinutes',
'expiresInSeconds',
'audience',
'issuer',
'subject',
'jwtid'
];
JWT.sign = function(payload, secretOrPrivateKey, options, callback) {
options = options || {};
payload = typeof payload === 'object' ? xtend(payload) : payload;
var header = {};

@@ -49,4 +59,12 @@

header.typ = 'JWT';
payload = xtend(payload);
} else {
var invalid_option = payload_options.filter(function (key) {
return typeof options[key] !== 'undefined';
})[0];
console.warn('invalid "' + invalid_option + '" option for ' + (typeof payload) + ' payload');
}
header.alg = options.algorithm || 'HS256';

@@ -53,0 +71,0 @@

2

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

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

@@ -13,2 +13,9 @@ var jwt = require('../index');

//v6 version will throw in this case:
it.skip('should throw with expiresIn', function () {
expect(function () {
jwt.sign('hello', '123', { expiresIn: '12h' });
}).to.throw(/invalid expiresIn option for string payload/);
});
it('should fail to validate audience when the payload is string', function () {

@@ -15,0 +22,0 @@ var token = jwt.sign('hello', '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