Rerouted (archive, verified). The original repository is gone. This copy comes from an archive (Software Heritage). The Lamdera package server serves a copy recovered from swh:1:rev:6e42bbcb75707ce44273d810b1c9b2ec2eb20c4c (Software Heritage, origin https://github.com/georgesboris/elm-jwt).
What we checked: Software Heritage archived tag 1.0.0 of github.com/georgesboris/elm-jwt at commit 6e42bbcb7570; its commit 6e42bbcb7570 is from 2023-08-16 18:53 UTC, before the version was published (2023-08-16 18:54 UTC); elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, made from Software Heritage's copy of the files Elm uses, so its SHA-1 is not the published one.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/georgesboris/elm-jwt/zipball/1.0.0/
JSON Web Token encoder and decoder.
Create and sign a token.
import Json.Decode
import Json.Encode
import TestHelpers
exposing
( aValidToken
, correctSecret
, encodePayload
, payload
, payloadDecoder
, wrongSecret
)
encode hmacSha256 encodePayload correctSecret payload
--> aValidToken
encode hmacSha512 Json.Encode.string "other secret" "some payload"
|> (decode Json.Decode.string "other secret")
--> Ok "some payload"
encode hmacSha224 Json.Encode.int "123" 456
|> (decode Json.Decode.int "abc")
--> Err <| InvalidSecret 456Create and sign a token, optionally passing extra values to be included in your JWT header.
import Json.Decode
import Json.Encode
import TestHelpers
exposing
( aValidTokenWithCustomHeaders
, correctSecret
, encodePayload
, payload
, payloadDecoder
, wrongSecret
)
encodeWithHeaders hmacSha256 (\payload -> [ ( "kid", Json.Encode.int payload.iat) ]) encodePayload correctSecret payload
--> aValidTokenWithCustomHeadersHMAC SHA224 digest algorithm.
HMAC SHA256 digest algorithm.
HMAC SHA384 digest algorithm.
HMAC SHA512 digest algorithm.
Types of errors which can occur during decoding of a token.
Type of algoirthm to use for the digest
String used to sign or verify a token.
A JSON web token.
Algorithm decoder.
Verify a token given a secret or public key.
If all goes well, you'll get a result back with the payload.
If something goes wrong, you get an error:
Some errors will include the payload. However, whenever there is an error the payload should not be trusted.