Add complete option in jwt.verify#522
Add complete option in jwt.verify#522ziluvatar merged 5 commits intoauth0:masterfrom javespi:addCompleteOptionInVerify
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
| }); | ||
| }); | ||
|
|
||
| describe('option: complete', function() { |
There was a problem hiding this comment.
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.
Moved here 4d8f50a
Apart from that, I added another unit test for complete: false option.
Co-Authored-By: javespi <javespalf@gmail.com>
|
Thanks @javespi ! 🎉 Released on v8.5.0 |
|
@ziluvatar thanks to you! Great project! |
Same behaviour as in
decodemethod. Just return an object with the header, payload and signature whencomplete: trueoption is passed.Added also a test to cover this use case.