Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
jfromaniello committed Jul 15, 2015
1 parent 9039cf0 commit 61ff117
Showing 1 changed file with 10 additions and 7 deletions.
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; }
Expand All @@ -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
Expand All @@ -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) || {};
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -160,7 +163,7 @@ module.exports.verify = function(jwtString, secretOrPublicKey, options, callback
var payload;

try {
payload = module.exports.decode(jwtString);
payload = JWT.decode(jwtString);
} catch(err) {
return done(err);
}
Expand Down

0 comments on commit 61ff117

Please sign in to comment.