Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: auth0/node-jsonwebtoken
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.0.2
Choose a base ref
...
head repository: auth0/node-jsonwebtoken
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.3
Choose a head ref
  • 6 commits
  • 3 files changed
  • 4 contributors

Commits on Jun 17, 2015

  1. Copy the full SHA
    59c110a View commit details

Commits on Jun 18, 2015

  1. Merge pull request #98 from adam-back/patch-1

    Fix typo, line 139 README, complete option for .decode.
    dschenkelman committed Jun 18, 2015
    Copy the full SHA
    33b326f View commit details

Commits on Jul 9, 2015

  1. Fix this referring to the global object instead of module.exports

    … in `verify()`
    Chance Dickson committed Jul 9, 2015
    Copy the full SHA
    93f5543 View commit details

Commits on Jul 15, 2015

  1. Copy the full SHA
    9039cf0 View commit details
  2. minor

    jfromaniello committed Jul 15, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    61ff117 View commit details
  3. 5.0.3

    jfromaniello committed Jul 15, 2015
    Copy the full SHA
    815a1a1 View commit details
Showing with 12 additions and 9 deletions.
  1. +1 −1 README.md
  2. +10 −7 index.js
  3. +1 −1 package.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ jwt.verify(token, cert, { algorithms: ['RS256'] }, function (err, payload) {
`options`:

* `json`: force JSON.parse on the payload even if the header doesn't contain `"typ":"JWT"`.
* `complete`: return an object with the decode payload and header.
* `complete`: return an object with the decoded payload and header.

Example

17 changes: 10 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
var jws = require('jws');

var JsonWebTokenError = module.exports.JsonWebTokenError = require('./lib/JsonWebTokenError');
var TokenExpiredError = module.exports.TokenExpiredError = require('./lib/TokenExpiredError');
var JWT = module.exports;

module.exports.decode = function (jwt, options) {
var JsonWebTokenError = JWT.JsonWebTokenError = require('./lib/JsonWebTokenError');
var TokenExpiredError = JWT.TokenExpiredError = require('./lib/TokenExpiredError');


JWT.decode = function (jwt, options) {
options = options || {};
var decoded = jws.decode(jwt, options);
if (!decoded) { return null; }
@@ -18,7 +21,7 @@ module.exports.decode = function (jwt, options) {
}
} catch (e) { }
}

//return header if `complete` option is enabled. header includes claims
//such as `kid` and `alg` used to select the key within a JWKS needed to
//verify the signature
@@ -32,7 +35,7 @@ module.exports.decode = function (jwt, options) {
return payload;
};

module.exports.sign = function(payload, secretOrPrivateKey, options) {
JWT.sign = function(payload, secretOrPrivateKey, options) {
options = options || {};

var header = ((typeof options.headers === 'object') && options.headers) || {};
@@ -81,7 +84,7 @@ module.exports.sign = function(payload, secretOrPrivateKey, options) {
return signed;
};

module.exports.verify = function(jwtString, secretOrPublicKey, options, callback) {
JWT.verify = function(jwtString, secretOrPublicKey, options, callback) {
if ((typeof options === 'function') && !callback) {
callback = options;
options = {};
@@ -160,7 +163,7 @@ module.exports.verify = function(jwtString, secretOrPublicKey, options, callback
var payload;

try {
payload = this.decode(jwtString);
payload = JWT.decode(jwtString);
} catch(err) {
return done(err);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonwebtoken",
"version": "5.0.2",
"version": "5.0.3",
"description": "JSON Web Token implementation (symmetric and asymmetric)",
"main": "index.js",
"scripts": {