mirror of
https://github.com/hanzoai/node-jsonwebtoken.git
synced 2026-09-24 17:00:48 +00:00
temporarly fix an issue of double callback in JWS
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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()],
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user