95 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
Nathan RajlichandGitHub 36931677b8 docs: update references vercel/ms references (#770) 2021-03-31 11:00:10 +02:00
Andy EdwardsandGitHub 6b42e17f41 docs: document "invalid token" error
closes #768
2021-02-18 17:47:53 +01:00
Mikael ViitaniemiandGitHub ac696711f2 docs: fix spelling in README.md: Peak -> Peek (#754) 2020-11-09 11:36:47 +01:00
Filip SkokanandMarcos Castany c009297558 docs: make decode impossible to discover before verify
see #741
2020-09-10 08:33:02 -03:00
hiramatsutakuandGitHub 4dd584a05c docs: add jwtid to options of jwt.verify (#704) 2020-03-24 10:32:23 -04:00
Cristofer GonzalesandEduardo Diaz fda2dc7a0e Adds not to README on decoded payload validation (#646)
Adds a note to the README that suggest that decoded payload should not be trusted and should be treated as user inputs.
2019-11-29 11:55:04 +01:00
Ibrahim P.GandFilip Skokan 9ac3316319 docs: fix tiny style change in readme (#622) 2019-10-21 13:25:55 +02:00
Eduardo DiazandGitHub 96f8fa8e04 README: fix markdown for algorithms table 2019-02-20 15:07:21 +01:00
Filip SkokanandEduardo Diaz 11a0453c51 feat: add PS JWA support for applicable node versions (#573) 2019-02-20 13:42:37 +01:00
Javier EspinosaandEduardo Diaz 1e880c8c19 Add complete option in jwt.verify (#522)
* Add complete option in verify

* Remove comment

* Update README.md

Co-Authored-By: javespi <[email protected]>

* Move tests in a specific file
2019-02-20 13:32:23 +01:00
Mike MacCanaandEduardo Diaz 0d33928084 Fix 'cert' token which isn't a cert (#554)
Certs have pubkeys. We sign things with private keys.
2019-02-13 16:49:01 +01:00
kazuki229andEduardo Diaz c7e16cb5d5 Add verify option for nonce validation (#540)
* Add verify option for nonce validation

* Update README.md

Co-Authored-By: kazuki229 <[email protected]>

* Refactor option-nonce test

* Add nonce option validation
2018-11-14 11:02:59 +01:00
RobertandEduardo Diaz 81ed983edd Edited the README.md to make certain parts of the document for the api easier to read, emphasizing the examples. (#548) 2018-11-02 11:25:04 +01:00
Yash GaurkarandEduardo Diaz 06eb4becd7 Update README.md (#538) 2018-11-01 11:41:54 +01:00
Brian PloetzandEduardo Diaz 7cc9e94671 Document NotBeforeError (#529) 2018-10-10 15:41:57 -03:00
KundanandEduardo Diaz 2ecda9cfe0 Update README.md (#527) 2018-10-10 15:33:53 -03: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 DiazandJason Strutz 76378b6edc add some clarifications (#473) 2018-05-23 09:27:06 -07:00
Josh UngerandEduardo Diaz e96b826066 Update README.md (#461) 2018-04-26 12:27:49 +02:00
David BeiteyandEduardo Diaz cc7c41b109 Clarify that buffer/string payloads must be JSON (#442)
It does kinda go without saying that JWTs (_JSON_ Web Tokens) need to contain JSON but it's worth mentioning that signing doesn't check your payload.  In some unit tests I was writing where the payload was a dummy (non-JSON parsable) string, JWTs were being signed okay but they're not valid according to the spec.
2018-03-02 14:08:24 +01:00
Jonathan Gros-DuboisandEduardo Diaz cab1c43ee4 Add a new mutatePayload option (#446)
This option allows you to keep a reference to the raw token payload after claims have been applied to it but before it has been encoded.
2018-03-02 13:48:25 +01:00
Harkirat SinghandEduardo Diaz bab4a35287 Minor typo (#424) 2017-11-17 17:20:04 +01:00
TheBusCantSwimandEduardo Diaz 5193ee5616 Enhance audience check to verify against regular expressions (#398)
* Enhance audience check to verify against regular expressions

* Enhance audience check to verify against regular expressions

* Adapted README to have a showcase of the new RegExp-check for the audience validation
2017-10-09 19:29:15 +02:00
Jeff AlderandEduardo Diaz a5e0c09c2d #385: Tweak README (#408)
* #385: Tweak README

* #385 Further wording tweaks for consistency.
2017-10-09 13:57:02 +02:00
oughterandEduardo Diaz 04a88aba0d Fix typo in 'options.header' reference; Update Buffer() example to use recommended method (#380) 2017-09-15 11:31:21 +02:00
Eduardo Diaz 8d37ed85a3 docs: readme, migration notes 2017-09-06 16:49:06 +02:00
Fredrik LiljegrenandGitHub 3f2bff62d4 Merge pull request #349 from ziluvatar/fix-max-age-number-and-seconds
maxAge: Fix logic with number + use seconds instead of ms
2017-09-06 16:43:23 +02:00
Eduardo Diaz 18137809c9 docs: about refreshing tokens 2017-07-14 13:21:57 +02:00
Eduardo Diaz 5c47d0deee docs: verifying with base64 encoded secrets 2017-06-24 11:44:14 +02:00
rjruizesandEduardo Diaz c797714223 document keyid as option (#361) 2017-06-14 13:27:47 +02:00
Eduardo DiazandGitHub 61c9aa7408 readme: Using private key with passpharase (#353) 2017-05-23 11:35:20 +02:00
Eduardo Diaz 543bf7f71d maxAge: Fix logic with number + use seconds instead of ms 2017-05-13 17:29:19 +02:00
Eduardo Diaz 7a2e46a815 Add docs about numeric date fields 2017-03-21 17:23:24 +01:00
Eduardo Diaz 87d9e777ed Make Options object optional for callback-ish sign 2017-03-08 14:09:04 +01:00
Eduardo DiazandGitHub 70cab0e2c0 Add more information to maxAge option in README 2017-02-13 13:50:55 +01:00
Michael BorstandEduardo Diaz 912e40685f Allow user to specify now. (#274) 2017-02-10 19:27:44 +01:00
Eddy VerbruggenandEduardo Diaz a7d15fe138 Fixed a simple typo (#287)
* Fixed a simple typo

The example didn't work because of a missing comma.

* Fixed a simple typo

The example didn't work because of a missing comma.
2017-02-03 22:39:08 +01:00
Greg WaldenandEduardo Diaz 57c25955ff rauchg/ms.js changed to zeit/ms (#303)
* rauchg/ms.js changed to zeit/ms

* Update README.md
2017-02-03 19:38:42 +01:00
José F. RomanielloandGitHub 4910de5238 Merge pull request #243 from rmharrison/patch-1
Minor README.md edit: Added `iss` on L41
2016-12-06 09:42:02 -03:00
silvermanj7andGitHub ccc7610187 Restructured a sentence
It's a little easier to read this way.
2016-10-28 08:19:53 -04:00
José F. Romaniello 771e0b5f9b improve the documentation for expiration 2016-10-07 12:18:49 -03:00
Ryan M HarrisonandGitHub c5f7991ce7 Minor README.md edit: Added iss on L41 2016-08-25 00:31:16 -04:00
José F. RomanielloandGitHub 164fdc1eaa Merge pull request #202 from a0viedo/patch-1
add dependencies badge on readme
2016-07-12 09:34:20 -03:00
José F. RomanielloandGitHub 0cb870285e Merge pull request #215 from ConnorMcF/patch-1
Fixed broken link
2016-07-12 09:33:29 -03:00
José F. Romaniello f7d89ff39b fix doc issue - closes #213 2016-06-14 14:43:39 -03:00
Connor McFarlaneandGitHub 4e69b312fb Fixed broken link
Link was going relative to the repo instead of to the external domain.
2016-06-12 14:49:34 +01:00
Alejandro Oviedo 659b39950a add dependencies badge on readme
change build badge to link to master branch and changed it to svg (nicer on retina)
2016-05-17 11:18:32 -03:00
José F. Romaniello 65ddea934f Merge branch 'origin/clock_skew_tolerance' of https://github.com/jacopofar/node-jsonwebtoken into jacopofar-origin/clock_skew_tolerance 2016-04-29 11:30:21 -03:00