JwtLite
Lightweight JWT decoder for Elixir. Decode and inspect JWTs without signature verification. Zero dependencies.
Installation
def deps do
[{:jwt_lite, "~> 0.1"}]
end
Usage
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0IiwibmFtZSI6IkFsaWNlIiwiZXhwIjo5OTk5OTk5OTk5fQ.sig"
{:ok, %{header: header, payload: payload}} = JwtLite.decode(token)
# => %{"alg" => "HS256", "typ" => "JWT"}
JwtLite.expired?(token) # => false
JwtLite.ttl(token) # => seconds until expiry
API
JwtLite.decode/2— decode to{:ok, %{header, payload, signature}}JwtLite.decode!/2— same but raises on errorJwtLite.expired?/1— returnstrueif exp claim is in the pastJwtLite.ttl/1— seconds remaining until expiry
Tip Jar
If this saves you time, tips are welcome:
ETH / Polygon / Base: 0x7463903430D5294DcfBa09Abb9B8B30A42BdFe36
License
MIT