mirror of
https://github.com/hanzoai/node-jsonwebtoken.git
synced 2026-09-24 17:00:48 +00:00
do not stringify the payload when signing async - closes #224
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user