malinoff / elm-jwt / JWT

JWT


type JWT
    = JWS JWS

A JSON Web Token.

Can be either a JWS (signed) or a JWE (encrypted). The latter is not yet implemented.


type DecodeError
    = TokenTypeUnknown
    | JWSError JWS.DecodeError

A structured error describing exactly how the decoder failed.

fromString : String -> Result DecodeError JWT

Decode a JWT from string.

fromString "eyJhbGciOi..." == Ok ...
fromString "" == Err ...
fromString "definitelyNotAJWT" == Err ...

Verification


type VerificationError
    = JWSVerificationError JWS.VerificationError

A structured error describing all verification errors.

isValid : ClaimSet.VerifyOptions -> String -> Time.Posix -> JWT -> Result VerificationError Basics.Bool

Check if the token is valid.

validate : ClaimSet.VerifyOptions -> String -> JWT -> Task Basics.Never (Result VerificationError Basics.Bool)

A task to check if the token is valid.