garyf / json_web_token_ex

An Elixir implementation of the JSON Web Token (JWT) Standard, RFC 7519
MIT License
143 stars 50 forks source link

Non-banged `verify/2` throws exceptions #25

Open nihalgonsalves opened 6 years ago

nihalgonsalves commented 6 years ago
iex(1)> JsonWebToken.verify("foobar", %{key: "barbaz"})    
** (RuntimeError) Failed to decode header from JSON
    (json_web_token) lib/json_web_token/jws.ex:95: JsonWebToken.Jws.header_map/1
    (json_web_token) lib/json_web_token/jws.ex:82: JsonWebToken.Jws.validate_alg_matched/2
    (json_web_token) lib/json_web_token/jws.ex:77: JsonWebToken.Jws.verify/3
    (json_web_token) lib/json_web_token/jwt.ex:89: JsonWebToken.Jwt.verify/2

I would expect that it should return {:error, "invalid"} or something similar, as it isn't the banged verify!/2 version of the function.