-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add complete option in jwt.verify #522
Conversation
The change is good to me, however, what is the use case for this change? |
Thanks @ziluvatar for the response. My motivation to include this feature was that inside Line 55 in 5498bdc
My use case requires to verify the token and also returns the full JWT (header, payload, signature) after verifying it. For now, I do 2 calls: one to |
That's how you want to get it done, I'm asking what the use case is for the need of returning the full JWT, what do you need to do with the header or the signature? I want to understand the root reason better. |
@ziluvatar there may be any number of additional properties in the JWS protected header a developer may want to access. Exposing this option would save extra processing of something which was already parsed once. |
I can see:
@javespi Currently that use case can be achieve by passing the Anyway, if you remove that comment I'll merge the PR. |
Thanks @ziluvatar and @panva for your feedback. I've already removed that comment. |
test/verify.tests.js
Outdated
@@ -69,6 +69,30 @@ describe('verify', function() { | |||
}); | |||
}); | |||
|
|||
describe('option: complete', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't realize about this before, can you follow similar approach as this option?
https://github.com/auth0/node-jsonwebtoken/blob/master/test/option-nonce.test.js
That is: option-complete.test.js
, using testUtils.asyncCheck
(to report errors correctly) and testUtils.verifyJWTHelper
(to verify sync and async).
We are refactoring the tests moving towards that model so each option and claim has its own tests using common tooling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved here 4d8f50a
Apart from that, I added another unit test for complete: false
option.
Co-Authored-By: javespi <[email protected]>
Thanks @javespi ! 🎉 Released on v8.5.0 |
@ziluvatar thanks to you! Great project! |
Same behaviour as in
decode
method. Just return an object with the header, payload and signature whencomplete: true
option is passed.Added also a test to cover this use case.