do not stringify the payload when signing async - closes #224

This commit is contained in:
José F. Romaniello
2016-07-12 10:06:23 -03:00
parent 7a180a6684
commit 084f537d3d
2 changed files with 11 additions and 3 deletions
+2 -3
View File
@@ -127,10 +127,9 @@ module.exports = function (payload, secretOrPrivateKey, options, callback) {
jws.createSign({
header: header,
privateKey: secretOrPrivateKey,
payload: JSON.stringify(payload),
payload: payload,
encoding: encoding
})
.once('error', callback)
}).once('error', callback)
.once('done', function (signature) {
callback(null, signature);
});
+9
View File
@@ -1,5 +1,6 @@
var jwt = require('../index');
var expect = require('chai').expect;
var jws = require('jws');
describe('signing a token asynchronously', function() {
@@ -40,5 +41,13 @@ describe('signing a token asynchronously', function() {
done();
});
});
it('should not stringify the payload', function (done) {
jwt.sign('string', 'secret', {}, function (err, token) {
if (err) { return done(err); }
expect(jws.decode(token).payload).to.equal('string');
done();
});
});
});
});