Skip to content

Commit

Permalink
temporarly fix an issue of double callback in JWS
Browse files Browse the repository at this point in the history
  • Loading branch information
jfromaniello committed Jul 14, 2016
1 parent bece881 commit 758ca5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"url": "https://github.com/auth0/node-jsonwebtoken/issues"
},
"dependencies": {
"cb": "~0.1.0",
"joi": "~6.10.1",
"jws": "^3.0.0",
"ms": "^0.7.1",
Expand Down
3 changes: 3 additions & 0 deletions sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var Joi = require('joi');
var timespan = require('./lib/timespan');
var xtend = require('xtend');
var jws = require('jws');
var cb = require('cb');

var sign_options_schema = Joi.object().keys({
expiresIn: [Joi.number().integer(), Joi.string()],
Expand Down Expand Up @@ -124,6 +125,8 @@ module.exports = function (payload, secretOrPrivateKey, options, callback) {
var encoding = options.encoding || 'utf8';

if (typeof callback === 'function') {
callback = callback && cb(callback).once();

jws.createSign({
header: header,
privateKey: secretOrPrivateKey,
Expand Down
4 changes: 2 additions & 2 deletions test/async_sign.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('signing a token asynchronously', function() {

it('should work', function (done) {
jwt.sign({abc: 1}, "secret", {}, function (err, res) {
expect(err).to.not.exist();
done();
expect(err).to.be.null();
done();
});
});

Expand Down

0 comments on commit 758ca5e

Please sign in to comment.