Current section
Files
Jump to
Current section
Files
README.md
# JwtLite
Lightweight JWT decoder for Elixir. Decode and inspect JWTs without signature verification. Zero dependencies.
## Installation
```elixir
def deps do
[{:jwt_lite, "~> 0.1"}]
end
```
## Usage
```elixir
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 error
- `JwtLite.expired?/1` — returns `true` if exp claim is in the past
- `JwtLite.ttl/1` — seconds remaining until expiry
## Tip Jar
If this saves you time, tips are welcome:
ETH / Polygon / Base: `0x7463903430D5294DcfBa09Abb9B8B30A42BdFe36`
## License
MIT