Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: auth0/node-jsonwebtoken
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.0
Choose a base ref
...
head repository: auth0/node-jsonwebtoken
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.1
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 27, 2016

  1. update changelog

    jfromaniello committed Apr 27, 2016
    Copy the full SHA
    5835f55 View commit details
  2. 1
    Copy the full SHA
    304f1b3 View commit details
  3. 6.0.1

    jfromaniello committed Apr 27, 2016
    Copy the full SHA
    2736ac2 View commit details
Showing with 36 additions and 3 deletions.
  1. +15 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +18 −0 sign.js
  4. +2 −2 test/non_object_values.tests.js
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,21 @@
All notable changes to this project will be documented in this file starting from version **v4.0.0**.
This project adheres to [Semantic Versioning](http://semver.org/).

## 6.0.0 - 2016-04-27

- Change .sign to standard async callback ([50873c7d45d2733244d5da8afef3d1872e657a60](https://github.com/auth0/node-jsonwebtoken/commit/50873c7d45d2733244d5da8afef3d1872e657a60))
- Improved the options for the `sign` method ([53c3987b3cc34e95eb396b26fc9b051276e2f6f9](https://github.com/auth0/node-jsonwebtoken/commit/53c3987b3cc34e95eb396b26fc9b051276e2f6f9))

- `expiresInMinutes` and `expiresInSeconds` are deprecated and no longer supported.
- `notBeforeInMinutes` and `notBeforeInSeconds` are deprecated and no longer supported.
- `options` are strongly validated.
- `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`
- `options.algorithm` is properly validated.
- `options.headers` is renamed to `options.header`.

- update CHANGELOG to reflect most of the changes. closes #136 ([b87a1a8d2e2533fbfab518765a54f00077918eb7](https://github.com/auth0/node-jsonwebtoken/commit/b87a1a8d2e2533fbfab518765a54f00077918eb7)), closes [#136](https://github.com/auth0/node-jsonwebtoken/issues/136)
- update readme ([53a88ecf4494e30e1d62a1cf3cc354650349f486](https://github.com/auth0/node-jsonwebtoken/commit/53a88ecf4494e30e1d62a1cf3cc354650349f486))

## 5.7.0 - 2016-02-16


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonwebtoken",
"version": "6.0.0",
"version": "6.0.1",
"description": "JSON Web Token implementation (symmetric and asymmetric)",
"main": "index.js",
"scripts": {
18 changes: 18 additions & 0 deletions sign.js
Original file line number Diff line number Diff line change
@@ -23,6 +23,16 @@ var options_to_payload = {
'jwtid': 'jti'
};

var options_for_objects = [
'expiresIn',
'notBefore',
'noTimestamp',
'audience',
'issuer',
'subject',
'jwtid',
];

module.exports = function(payload, secretOrPrivateKey, options, callback) {
options = options || {};

@@ -35,6 +45,14 @@ module.exports = function(payload, secretOrPrivateKey, options, callback) {
throw new Error('payload is required');
} else if (typeof payload === 'object') {
payload = xtend(payload);
} else if (typeof payload !== 'object') {
var invalid_options = options_for_objects.filter(function (opt) {
return typeof options[opt] !== 'undefined';
});

if (invalid_options.length > 0) {
throw new Error('invalid ' + invalid_options.join(',') + ' option for ' + (typeof payload ) + ' payload' );
}
}

if (typeof payload.exp !== 'undefined' && typeof options.expiresIn !== 'undefined') {
4 changes: 2 additions & 2 deletions test/non_object_values.tests.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ describe('non_object_values values', function() {
});

//v6 version will throw in this case:
it.skip('should throw with expiresIn', function () {
it('should throw with expiresIn', function () {
expect(function () {
jwt.sign('hello', '123', { expiresIn: '12h' });
}).to.throw(/invalid expiresIn option for string payload/);
@@ -30,4 +30,4 @@ describe('non_object_values values', function() {
expect(result).to.equal('123');
});

});
});