130 Commits
Author SHA1 Message Date
925d95de54 Merge pull request from GHSA-8cf7-32gw-wr33
* Check if node version supports asymmetricKeyDetails

* Validate algorithms for ec key type

* Rename variable

* Rename function

* Add early return for symmetric keys

* Validate algorithm for RSA key type

* Validate algorithm for RSA-PSS key type

* Check key types for EdDSA algorithm

* Rename function

* Move validateKey function to module

* Convert arrow to function notation

* Validate key in verify function

* Simplify if

* Convert if to switch..case

* Guard against empty key in validation

* Remove empty line

* Add lib to check modulus length

* Add modulus length checks

* Validate mgf1HashAlgorithm and saltLength

* Check node version before using key details API

* Use built-in modulus length getter

* Fix Node version validations

* Remove duplicate validateKey

* Add periods to error messages

* Fix validation in verify function

* Make asymmetric key validation the latest validation step

* Change key curve validation

* Remove support for ES256K

* Fix old test that was using wrong key types to sign tokens

* Enable RSA-PSS for old Node versions

* Add specific RSA-PSS validations on Node 16 LTS+

* Improve error message

* Simplify key validation code

* Fix typo

* Improve error message

* Change var to const in test

* Change const to let to avoid reassigning problem

* Improve error message

* Test incorrect private key type

* Rename invalid to unsupported

* Test verifying of jwt token with unsupported key

* Test invalid private key type

* Change order of object parameters

* Move validation test to separate file

* Move all validation tests to separate file

* Add prime256v1 ec key

* Remove modulus length check

* WIP: Add EC key validation tests

* Fix node version checks

* Fix error message check on test

* Add successful tests for EC curve check

* Remove only from describe

* Remove `only`

* Remove duplicate block of code

* Move variable to a different scope and make it const

* Convert allowed curves to object for faster lookup

* Rename variable

* Change variable assignment order

* Remove unused object properties

* Test RSA-PSS happy path and wrong length

* Add missing tests

* Pass validation if no algorithm has been provided

* Test validation of invalid salt length

* Test error when signing token with invalid key

* Change var to const/let in verify tests

* Test verifying token with invalid key

* Improve test error messages

* Add parameter to skip private key validation

* Replace DSA key with a 4096 bit long key

* Test allowInvalidPrivateKeys in key signing

* Improve test message

* Rename variable

* Add key validation flag tests

* Fix variable name in Readme

* Change private to public dsa key in verify

* Rename flag

* Run EC validation tests conditionally

* Fix tests in old node versions

* Ignore block of code from test coverage

* Separate EC validations tests into two different ones

* Add comment

* Wrap switch in if instead of having an early return

* Remove unsupported algorithms from asymmetric key validation

* Rename option to allowInvalidAsymmetricKeyTypes and improve Readme

* 9.0.0

* adding migration notes to readme

* adding changelog for version 9.0.0

Co-authored-by: julienwoll <[email protected]>
2022-12-21 13:36:01 +01:00
david-renaud-oktaandGitHub 44ce6fd923 fix!: Prevent accidental use of insecure key sizes & misconfiguration of secrets (#852)
* fix!: Disable use of weak RSA key sizes for asymmetric algorithms

Added checks to prevent invalid secrets from being used with the HS*** algorithms when signing and verifying
Added checks to prevent the use of insecure asymmetric key sizes except when explicitly overriden via options
Prevented Buffers containing malicious objects from being used as key material.

BREAKING CHANGE: Requires node 12.x or later to allow use of `KeyObject`
2022-11-29 11:58:59 -05:00
Eduardo Diaz 71e7b43c7d 8.5.1 2019-03-18 12:25:21 +01:00
Filip SkokanandEduardo Diaz fbab0a0ee9 fix: ensure correct PS signing and verification (#585) 2019-03-18 12:17:04 +01:00
Eduardo Diaz de0f610512 8.5.0 2019-02-20 14:06:59 +01:00
Filip SkokanandEduardo Diaz 11a0453c51 feat: add PS JWA support for applicable node versions (#573) 2019-02-20 13:42:37 +01:00
Lio李欧andEduardo Diaz f1f30a38a3 Force use_strict during testing (#577)
* Force use_strict during testing

* Add string payload test cases to .iat tests
2019-02-20 13:22:27 +01:00
Eduardo DiazandFilip Skokan d00ab1d8e0 ci: remove nsp from tests (#569)
Fixes https://github.com/auth0/node-jsonwebtoken/issues/567
2019-01-23 11:16:28 +01:00
Eduardo Diaz c4b352c157 8.4.0 2018-11-14 11:29:21 +01:00
gkwangandEduardo Diaz 1ab3963eef devDeps: [email protected] (#539) 2018-11-02 12:00:08 +01:00
Aakash AgarwalandEduardo Diaz 5ba7118db1 Updating Node version in Engines spec in package.json (#528)
* Updating Node version in package.json

Updated Node version from 0.12 to 1.4 in package.json engines

* Updated node version

Updated Node version from 0.12 to 4 in package.json Engines Spec

Fixes Issue #509
2018-10-22 20:30:43 +02:00
Tim OramandEduardo Diaz 477e4f7426 Update dependencies used for running tests (#518)
Update chai and mocha to the latest versions and update nyc to the
latest version that supports Node 4.
2018-09-10 11:48:41 +02:00
Tim OramandEduardo Diaz 6b0b47fc01 Refactor tests related to notBefore and nbf (#497)
This change extracts all tests in the current files related to notBefore
and nbf into a single test file. It also adds several missing related
tests.
2018-06-27 16:52:32 +02:00
Jaco KosterandEduardo Diaz d0ab5c5298 Make code-coverage mandatory when running tests (#495)
* Made code-coverage mandatory when running the tests.

* Missed the trailing-comma...
2018-06-25 22:49:15 +02:00
Tim OramandEduardo Diaz c86e573d16 Complete ESLint conversion and cleanup (#490)
* Add extension to ESLint config file

The .eslintrc file without an extension was deprecated a few years ago,
so this change renames the file to add the required extension.

See: https://github.com/eslint/eslint/commit/c9a8883d450d63a8d044a9e66d275f5b1973a3ba

* Add ESLint to package.json

This change adds ESLint as a dev-dependency and adds a lint script that
will run ESLint.

* Complete switch from JSHint to ESLint

Convert all the JSHint rules to the ESLint equivalents where possible.
The no-undef rule in ESLint caught a few cases of undefined usages in
the tests, so they were also fixed.

* Add a .eslintignore file

The HTML coverage report is currently being linted, which causes a lot
if invalid linting errors. This change adds a ignore file to ensure these
files are properly skipped during linting.
2018-06-25 19:54:04 +02:00
Tim OramandEduardo Diaz cc61447047 Use lolex for faking date in tests (#491)
Sinon.JS provides a project called lolex to handle faking dates. This
change replaces the fakeDate utility with the equivalent Sinon.JS code.
2018-06-16 18:36:05 +02:00
Jaco KosterandEduardo Diaz 7e40174623 Added Istanbul to check test-coverage (#468)
* Added Istanbul to check test-coverage

* node_modules_bak is generated and automatically removed by cost-of-modules and isn't needed in the ignore.
2018-06-16 12:44:54 +02:00
Eduardo Diaz 38d982b3cc 8.3.0 2018-06-11 17:36:46 +02:00
Jaco KosterandEduardo Diaz 4d2a22c975 Secret callback revisited (#480)
* Introduction of the secret callback

Without the more contentious 'none'-changes

* Removed some spaces...

I should really add a editor.config and eslint to this project ;-)

* Removed xtend as a dependency, as the native Object.Assign can do this as well

* Removed xtend as a dependency, as the native Object.Assign can do this as well

* Resolve feedback from review

* Added extra test and fixed the associated bug

* The return of the header

* Forgot to change this one as well... Sorry bout that

* Updated the readme and made the if-statements consistent

* Space; The final frontier
2018-06-11 17:32:29 +02:00
Eduardo Diaz ca3cd60408 8.2.2 2018-05-30 17:03:24 +02:00
Eduardo DiazandLuciano Balmaceda 404b455fd5 deps: [email protected] (#477)
Update 'jws' dependency to latest to fix a security issue
2018-05-30 11:42:16 -03:00
Eduardo Diaz a05a4b3548 8.2.1 2018-04-05 13:38:11 +02:00
Eduardo Diaz 8bc7d5b5e7 8.2.0 2018-03-02 13:56:32 +01:00
Eduardo Diaz 09a2b8e855 8.1.1 2018-01-22 20:27:15 +01:00
Tim OramandEduardo Diaz a6422365ab Bump ms version to add support for negative numbers (#438) 2018-01-19 14:20:57 +01:00
Eduardo Diaz 1101e00f1e 8.1.0 2017-10-09 19:36:47 +02:00
Eduardo Diaz b3dc03e170 8.0.1 2017-09-12 12:55:34 +02:00
Tomas ChmelevskijandEduardo Diaz 8fe1f3f44f Remove lodash.isarray dependency (#394) 2017-09-12 12:52:22 +02:00
Eduardo Diaz 96188a9990 8.0.0 2017-09-06 17:45:05 +02:00
Jorrit SchippersandEduardo Diaz 80b0f8535f Reduce size of NPM package (#347) 2017-09-06 16:36:01 +02:00
Chris PriceandEduardo Diaz 75b897b11d Remove joi to shrink module size (#348)
* Add cost-of-modules report to npm test

Results before any changes

┌─────────────┬────────────┬───────┐
│ name        │ children   │ size  │
├─────────────┼────────────┼───────┤
│ joi         │ 4          │ 3.12M │ <--!!!
├─────────────┼────────────┼───────┤
│ jws         │ 5          │ 0.18M │
├─────────────┼────────────┼───────┤
│ lodash.once │ 0          │ 0.01M │
├─────────────┼────────────┼───────┤
│ ms          │ 0          │ 0.01M │
├─────────────┼────────────┼───────┤
│ xtend       │ 0          │ 0.00M │
├─────────────┼────────────┼───────┤
│ 5 modules   │ 9 children │ 3.32M │
└─────────────┴────────────┴───────┘

* Replace joi with bespoke validator based on lodash

Dramatically reduces the module size without breaking ES5 compatability -

┌──────────────────────┬────────────┬───────┐
│ name                 │ children   │ size  │
├──────────────────────┼────────────┼───────┤
│ jws                  │ 5          │ 0.18M │
├──────────────────────┼────────────┼───────┤
│ lodash.includes      │ 0          │ 0.02M │
├──────────────────────┼────────────┼───────┤
│ lodash.once          │ 0          │ 0.01M │
├──────────────────────┼────────────┼───────┤
│ lodash.isinteger     │ 0          │ 0.01M │
├──────────────────────┼────────────┼───────┤
│ ms                   │ 0          │ 0.01M │
├──────────────────────┼────────────┼───────┤
│ lodash.isplainobject │ 0          │ 0.01M │
├──────────────────────┼────────────┼───────┤
│ xtend                │ 0          │ 0.00M │
├──────────────────────┼────────────┼───────┤
│ lodash.isstring      │ 0          │ 0.00M │
├──────────────────────┼────────────┼───────┤
│ lodash.isboolean     │ 0          │ 0.00M │
├──────────────────────┼────────────┼───────┤
│ lodash.isnumber      │ 0          │ 0.00M │
├──────────────────────┼────────────┼───────┤
│ lodash.isarray       │ 0          │ 0.00M │
├──────────────────────┼────────────┼───────┤
│ 11 modules           │ 5 children │ 0.25M │
└──────────────────────┴────────────┴───────┘

* Enhance validator error messages and add tests
2017-09-06 16:24:55 +02:00
Eduardo Diaz 27771716b5 7.4.3 2017-08-17 16:18:23 +02:00
Eduardo Diaz ee20a9e200 7.4.2 2017-08-04 14:33:50 +02:00
Eduardo Diaz a3f364a4d2 7.4.1 2017-05-17 11:30:53 +02:00
Dominykas BlyžėandEduardo Diaz d194df0171 bump ms to v2 due a ReDoS vuln (#352)
[email protected] is vulnerable to a ReDoS attack: https://snyk.io/vuln/npm:ms:20170412

Looking at the code, the breaking change in [email protected] that the accepted string is now limited to 100 chars.
2017-05-17 11:29:48 +02:00
Eduardo Diaz 045390c28c 7.4.0 2017-04-24 19:15:10 +02:00
Eduardo Diaz aeaf2e8d2a 7.3.0 2017-02-13 19:39:18 +01:00
José F. Romaniello bf6bedc4ba 7.2.1 2016-12-07 11:02:36 -03:00
José F. Romaniello 790cc72894 add nsp check to find vulnerabilities on npm test 2016-12-07 11:02:32 -03:00
José F. Romaniello d0ea609426 revert to joi@^6 to keep ES5 compatibility 2016-12-07 10:59:23 -03:00
José F. Romaniello ded1a5140c 7.2.0 2016-12-06 09:39:52 -03:00
José F. Romaniello 1cf1b5d3aa Merge branch 'latest-joi' of https://github.com/dominykas/node-jsonwebtoken into dominykas-latest-joi 2016-12-06 09:32:49 -03:00
José F. Romaniello 4a4f74f201 7.1.10 2016-12-06 09:28:13 -03:00
Dominykas Blyžė 715e3d9280 upgrade joi 2016-11-28 15:41:22 +00:00
Matt O'Connell 07813dd719 Bump node-jws version number
Bump node-jws version number from 3.1.3 -> 3.1.4.
Version 3.1.3 has a dependency on base64url ~1.0.4 which is throwing the
NodeJS Buffer DeprecationWarning. version 3.1.4 pulls in base64url ^2.0.0
which address the issue.
2016-11-17 08:32:25 -05:00
José F. Romaniello cc0f4d67b6 7.1.9 2016-08-11 13:23:12 -03:00
José F. Romaniello 51c4fef050 7.1.8 2016-08-10 09:52:59 -03:00
José F. Romaniello de2099b570 7.1.7 2016-07-29 15:55:14 -03:00
Christian Holm 3ac95ad93e Use lodash.once instead of unlicensed/unmaintained cb 2016-07-21 08:48:32 +02:00
José F. Romaniello ae360b5679 7.1.6 2016-07-15 09:32:38 -03:00