Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'header' of null #4

Closed
thgh opened this issue Mar 27, 2020 · 1 comment
Closed

Cannot read property 'header' of null #4

thgh opened this issue Mar 27, 2020 · 1 comment

Comments

@thgh
Copy link

thgh commented Mar 27, 2020

Invalid tokens might be null:
https://github.com/auth0/node-jsonwebtoken/blob/5f10bf9957a2541828501cfecab0310908b2f62f/decode.js#L6

That is why this code throws Cannot read property 'header' of null

decoded = jwt.decode(token, { complete: true, json: true });
kid = decoded.header.kid;

Instead, it would make sense to throw an 'invalid token' error like here:
https://github.com/auth0/node-jsonwebtoken/blob/5f10bf9957a2541828501cfecab0310908b2f62f/verify.js#L75

@justinlettau
Copy link
Owner

Pushed; Will be updated in next release 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants