auth0 / node-jws

JSON Web Signatures
http://self-issued.info/docs/draft-ietf-jose-json-web-signature.html
MIT License
709 stars 108 forks source link

Fix: Catch errors from JSON.parse #107

Open glensc opened 1 year ago

glensc commented 1 year ago

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Keep the contract that the decode returns null on errors

➜ node
Welcome to Node.js v16.19.0.
Fix: Catch errors from JSON.parse
Type ".help" for more information.
> JSON.parse("xx")
Uncaught SyntaxError: Unexpected token x in JSON at position 0
>

Checklist

glensc commented 1 year ago

Includes https://github.com/auth0/node-jws/pull/108, depends which one gets merged first.