# `Dialup.Auth.SessionToken`
[🔗](https://github.com/SouichiroTsujimoto/Dialup/blob/main/lib/auth/session_token.ex#L1)

Opaque session token generation and hashing.

Raw tokens are sent to clients (cookie). Only SHA-256 hashes are stored in the
database, following the `phx_gen_auth` model.

# `generate`

```elixir
@spec generate() :: binary()
```

Generates a URL-safe opaque session token.

# `hash`

```elixir
@spec hash(binary()) :: binary()
```

Hashes a raw token for database storage.

# `ttl`

```elixir
@spec ttl(atom()) :: non_neg_integer()
```

Returns the TTL in seconds for a token context.

# `valid?`

```elixir
@spec valid?(binary(), binary()) :: boolean()
```

Constant-time comparison of a raw token against a stored hash.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
