Clarify in README that buffer/string payloads must be JSON#442
Clarify in README that buffer/string payloads must be JSON#442ziluvatar merged 1 commit intoauth0:masterfrom
Conversation
It does kinda go without saying that JWTs (_JSON_ Web Tokens) need to contain JSON but it's worth mentioning that signing doesn't check your payload. In some unit tests I was writing where the payload was a dummy (non-JSON parsable) string, JWTs were being signed okay but they're not valid according to the spec.
|
I'd like to get more knowledge about it. When I run this: It works, what is the input you are using? |
|
Sure, no problem. For note, the spec states that the JWT payload ("JWT Claims Set") represents a JSON object at https://tools.ietf.org/html/rfc7519#section-4. A library like https://github.com/auth0/jwt-decode fails to decode your token there because it doesn't contain JSON: Node's traceback is a little hard to follow but the code throws the exception here, in the By comparison, With this specific PR, I was solving the issue in a simpler way -- documenting the current behaviour so a user knows this package isn't going to verify JSON. |
|
Thanks @davidjb, merged, I guess we would need to tackle that in some future major version release to align with the spec. |
|
Great, thanks @ziluvatar. Even a simple solution like throwing an exception on a failed |
It does kinda go without saying that JWTs (JSON Web Tokens) need to contain JSON but it's worth mentioning that signing doesn't check your payload. In some unit tests I was writing where the payload was a dummy (non-JSON parsable) string, JWTs were being signed okay but they're not valid according to the spec, which caused decoding of the JWTs to later fail.