-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: enable detached payloads for JWS #126
feat: enable detached payloads for JWS #126
Conversation
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.
It looks great but it needs some new tests.
decodeJWS
works as expected with a JWS input and fails as expected with garbage inputcreateJWS
works with both JSON payload andstring
payload (not sure if the method should fail when given an array as payload)
Thanks @mirceanis I'll add the tests!
I don't see why it should as that would be valid JSON. |
I can't find a concrete reference about the JSON payload of JWT but since the RFC talks about claims in the payload that can only happen if the payload is an object, not an array. With this changeset, I suppose that typescript would complain if you tried to call the method with an array, or number instead of an object(because of |
In that case it seems like the check should be in the |
That also seems out of scope for this PR? |
Pushed an update with tests. |
Yes, I was only pointing it out because of that new corner case inconsistency. |
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.
Looks great!
# [4.5.0](4.4.2...4.5.0) (2020-08-19) ### Features * enable arbitrary payloads for JWS ([#126](#126)) ([5573e63](5573e63))
🎉 This PR is included in version 4.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks 🙏 |
This PR enables a caller of
createJWS
to pass anbase64url
encoded payload directly. This is useful when you need to sign something that isn't a JSON object.