mirror of
https://github.com/hanzoai/node-jsonwebtoken.git
synced 2026-09-24 17:00:48 +00:00
Notable changes: 1. `expiresInMinutes` and `expiresInSeconds` are deprecated and no longer supported. 2. `notBeforeInMinutes` and `notBeforeInSeconds` are deprecated and no longer supported. 3. options are properly validated. 4. `options.expiresIn`, `options.notBefore`, `options.audience`, `options.issuer`, `options.subject` and `options.jwtid` are mutually exclusive with `payload.exp`, `payload.nbf`, `payload.aud`, `payload.iss`, `payload.sub` and `payload.jti` respectively. 5. `options.algorithm` is properly validated. 6. `options.headers` is renamed to `options.header`.
19 lines
577 B
JavaScript
19 lines
577 B
JavaScript
var jwt = require('../index');
|
|
var expect = require('chai').expect;
|
|
|
|
describe('set header', function() {
|
|
|
|
it('should add the header', function () {
|
|
var token = jwt.sign({foo: 123}, '123', { header: { foo: 'bar' } });
|
|
var decoded = jwt.decode(token, {complete: true});
|
|
expect(decoded.header.foo).to.equal('bar');
|
|
});
|
|
|
|
it('should allow overriding header', function () {
|
|
var token = jwt.sign({foo: 123}, '123', { header: { alg: 'HS512' } });
|
|
var decoded = jwt.decode(token, {complete: true});
|
|
expect(decoded.header.alg).to.equal('HS512');
|
|
});
|
|
|
|
});
|