Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 825 Bytes

README.md

File metadata and controls

20 lines (14 loc) · 825 Bytes

elm-jsonwebtoken

elm-package CircleCI

JSON Web Token encoder and decoder.

import JsonWebToken as JWT exposing (hmacSha256)

JWT.encode hmacSha256 Json.Encode.string "secret" "some payload"
    |> JWT.decode Json.Decode.string "secret"
--> Ok "some payload"

JWT.encode hmacSha256 Json.Encode.int "secret" 123
    |> JWT.decode Json.Decode.int "wrong secret"
--> Err <| InvalidSecret 123

Currently supports HMAC digests using SHA224, SHA256, SHA384, and SHA512. If any other alg is used, then decode will fail with DecodeHeaderFailed String.