auth0 / node-jws

JSON Web Signatures
http://self-issued.info/docs/draft-ietf-jose-json-web-signature.html
MIT License
709 stars 108 forks source link

UTF8 encoding problem #17

Closed MilosStanic closed 9 years ago

MilosStanic commented 9 years ago

Your library is used by node-jsonwebtoken, and when it signs the token using your library it seems that it breaks the payload if there is an UTF8 character in the payload. When I retrieve the token and decode it, and when I parse with JSON.parse() I get 'Unexpected token' error if the payload contained UTF8 chars. In my case it was char 'ć' . Can you verify?

frantello commented 9 years ago

Take a look

MilosStanic commented 9 years ago

thanks, I think I solved my problem. Not very happily, but solved it :)

brianloveswords commented 9 years ago

Hey @MilosStanic, I just published v2.0.0 of jws which should fix your problem. I changed the default encoding from binary to utf8 and added an option to override the default.

MilosStanic commented 9 years ago

Hi @brianloveswords, thanks. I kinda solved my problem by escaping utf-8 chars before encoding them, and unescaping them after. But let's see how jws 2.0.0 works out when it gets adopted in the jsonwebtoken