[{"name":"Jwt","comment":" Helper functions for working with Jwt tokens and authenticated CRUD APIs.\n\nThis package provides functions for reading tokens, and for using them to make\nauthenticated Http requests.\n\n\n# Token reading\n\n@docs decodeToken, tokenDecoder, isExpired, checkTokenExpiry\n\n\n# Authenticated Http requests\n\n@docs createRequest, createRequestObject, send, sendCheckExpired, get, post, put, delete\n\n\n# Error handlers\n\n@docs JwtError, promote401, handleError\n\n","unions":[{"name":"JwtError","comment":" The following errors are modeled\n\n  - 401 (Unauthorized), due either to token expiry or e.g. inadequate permissions\n  - token (non-)expiry information\n  - issues with processing (e.g. base 64 decoding) the token\n  - problems decoding the json data within the content of the token\n  - Any Http.Error, other than a 401\n\n","args":[],"cases":[["Unauthorized",[]],["TokenExpired",[]],["TokenNotExpired",[]],["TokenProcessingError",["String.String"]],["TokenDecodeError",["Json.Decode.Error"]],["HttpError",["Http.Error"]]]}],"aliases":[],"values":[{"name":"checkTokenExpiry","comment":" Checks a token for Expiry. Returns expiry or any errors that occurred in decoding.\n","type":"String.String -> Task.Task Basics.Never Jwt.JwtError"},{"name":"createRequest","comment":" createRequest creates a Http.Request with the token added to the headers, and\nsets the `withCredentials` field to True.\n","type":"String.String -> String.String -> String.String -> Http.Body -> Json.Decode.Decoder a -> Http.Request a"},{"name":"createRequestObject","comment":" createRequestObject creates the data structure expected by Http.Request.\nIt is broken out here so that users can change the expect part in the event that\none of their REST apis does not return Json.\n\nIn my experience, the Authorization header is NOT case sensitive. Do raise an issue if you experience otherwise.\n\nSee [MDN](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) for more on withCredentials. The default is False.\n\n","type":"String.String -> String.String -> String.String -> Http.Body -> Json.Decode.Decoder a -> { method : String.String, headers : List.List Http.Header, url : String.String, body : Http.Body, expect : Http.Expect a, timeout : Maybe.Maybe Basics.Float, withCredentials : Basics.Bool }"},{"name":"decodeToken","comment":" decodeToken parses the token, checking that it meets the Jwt standards.\n\n    decodeToken dec token\n\nIn the event of success, `decodeToken` returns an Elm record structure using the JSON Decoder.\n\n","type":"Json.Decode.Decoder a -> String.String -> Result.Result Jwt.JwtError a"},{"name":"delete","comment":" returns a `DELETE` Http.Request with the token attached to the headers.\n","type":"String.String -> String.String -> Json.Decode.Decoder a -> Http.Request a"},{"name":"get","comment":" `get` is a replacement for `Http.get` that returns a Http.Request with the token\nattached to the headers.\n\n    getData : String -> Cmd Msg\n    getData token =\n        Jwt.get token \"/api/data\" dataDecoder\n            |> Jwt.send DataResult\n\n","type":"String.String -> String.String -> Json.Decode.Decoder a -> Http.Request a"},{"name":"handleError","comment":" Takes an Http.Error. If it is a 401, check the token for expiry.\n","type":"String.String -> Http.Error -> Task.Task Basics.Never Jwt.JwtError"},{"name":"isExpired","comment":" Checks whether a token has expired, and returns True or False, or\nany error that occurred while decoding the token.\n","type":"Time.Posix -> String.String -> Result.Result Jwt.JwtError Basics.Bool"},{"name":"post","comment":" post is a replacement for `Http.post` that returns a Http.Request with the token\nattached to the headers.\n\n** Note that is important to use jsonBody to ensure that the 'application/json' is added to the headers **\n\n    postContent : Token -> Decoder a -> E.Value -> String -> Request a\n    postContent token dec value url =\n        Jwt.post token url (Http.jsonBody value) (phoenixDecoder dec)\n            |> Jwt.send ContentResult\n\n","type":"String.String -> String.String -> Http.Body -> Json.Decode.Decoder a -> Http.Request a"},{"name":"promote401","comment":" Examines a 401 Unauthorized reponse, and converts the error to TokenExpired\nwhen that is the case.\n\n    getAuth : String -> String -> Decoder a -> Task Never (Result JwtError a)\n    getAuth token url dec =\n        createRequest \"GET\" token url Http.emptyBody dec\n            |> toTask\n            |> Task.map Result.Ok\n            |> Task.onError (promote401 token)\n\n","type":"Http.Error -> Jwt.JwtError"},{"name":"put","comment":" Create a PUT request with a token attached to the Authorization header\n","type":"String.String -> String.String -> Http.Body -> Json.Decode.Decoder a -> Http.Request a"},{"name":"send","comment":" `send` replaces `Http.send`. On receipt of a 401 error, it returns a Jwt.Unauthorized.\n","type":"(Result.Result Jwt.JwtError a -> msg) -> Http.Request a -> Platform.Cmd.Cmd msg"},{"name":"sendCheckExpired","comment":" `sendCheckExpired` is similar to `send` but, on receiving a 401, it carries out a further check to\ndetermine whether the token has expired.\n","type":"String.String -> (Result.Result Jwt.JwtError a -> msg) -> Http.Request a -> Platform.Cmd.Cmd msg"},{"name":"tokenDecoder","comment":" All the token parsing goodness in the form of a Json Decoder\n\n    -- decode token from Firebase\n    let firebaseToken =\n            decodeString (tokenDecoder Jwt.Decoders.firebase) tokenString\n\n","type":"Json.Decode.Decoder a -> Json.Decode.Decoder a"}],"binops":[]},{"name":"Jwt.Decoders","comment":" Helper functions for working with Jwt tokens and authenticated CRUD APIs.\n\nThis package provides functions for reading tokens, and for using them to make\nauthenticated Http requests.\n\n\n# Decoders for popular Jwt tokens\n\n@docs JwtToken, firebase, phoenixGuardian\n\n","unions":[],"aliases":[{"name":"JwtToken","comment":" Generic constructor for commonly found fields in a Jwt token\n","args":[],"type":"{ iat : Basics.Int, exp : Basics.Int, userId : Maybe.Maybe String.String, email : Maybe.Maybe String.String }"}],"values":[{"name":"firebase","comment":" Decoder for Firebase Jwt\n","type":"Json.Decode.Decoder Jwt.Decoders.JwtToken"},{"name":"phoenixGuardian","comment":" Decoder for Guardian\n<https://github.com/ueberauth/guardian>\n","type":"Json.Decode.Decoder Jwt.Decoders.JwtToken"}],"binops":[]}]