Module

Jwt

A JSON Web Token (JWT) (RFC 7519) is a string that consists of three (URL-safe) Base64-encoded strings separated by dots.

<header>.<payload>.<signature>

The payload is basically an encoded JSON object which can be retrieved via the decode function in this module.

For further information see: https://en.wikipedia.org/wiki/JSON_Web_Token https://tools.ietf.org/html/rfc7519

#JwtError

data JwtError a

A JwtError a can be a

  • MalformedToken when the token is not of the form <header>.<payload>.<signature>
  • Base64DecodeError when the payload is not a valid Base64 string
  • JsonDecodeError a when the user-provided decoder function fails
  • JsonParseError when the decoded Base64 string cannot be parsed as JSON

Constructors

#decode

decode :: forall a. String -> Either (JwtError a) Json

Decode a token into a Json value.

#decodeWith

decodeWith :: forall a b. (Json -> Either b a) -> String -> Either (JwtError b) a

Decode a token to a PureScript value via a user-provided function. This is for convenience as it saves a little bit of error type juggling.

Modules