carpe / elm-data / ElmData.Jwt

Jwt module is a collection of helpers used to derive sessions from JWTs.


type alias JwtClaims =
{ issuer : String
, expiration : Basics.Int
, permissions : List String 
}

Basic Jwt Claims. In the future this should be configurable.

checkToken : String -> (Result ElmData.Session.SessionFailure ElmData.Session.SessionData -> msg) -> Platform.Cmd.Cmd msg

Checks a token for Expiry. Returns expiry or any errors that occurred in decoding.

scheduleExpiration : ElmData.Session.SessionData -> Basics.Int -> msg -> Platform.Cmd.Cmd msg

Schedule a message to be sent any number of milliseconds BEFORE the JWT expires. You can use this to remind users that they may need to re-login soon, or to simply expire the session.