# Module /jwt

JSON Web Token (JWT) HS256 signing and verification (sign-jwt, verify-jwt).

```tangu
(use /jwt)
```

## Functions & symbols

### sign-jwt

`(sign-jwt options) -> (Result String Error)`

Signs a JSON Web Token from an options Map containing `:claims` and signing key (`:secret` or `:private-key-pem`).

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `options` | `Map` | no | Options Map {:claims Map :secret String [:algorithm "HS256" :private-key-pem String]} |

```tangu
(let token (jwt/sign-jwt {:claims {:sub "user_42" :exp 1900000000} :secret env-secret}))
```

### verify-jwt

`(verify-jwt token options) -> (Result Map Error)`

Verifies the cryptographic signature and standard claims (`exp`, optional `issuer`, `audience`, `subject`) of a JWT, returning the decoded claims `Map`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `token` | `String` | no | Compact JWT string (`header.payload.signature`) |
| `options` | `Map` | no | Verification Map {:secret String [:algorithm "HS256" :public-key-pem String :issuer String :audience String :leeway-secs Int]} |

```tangu
(let claims (jwt/verify-jwt token {:secret env-secret}))
```
