# `PhoenixWebTransport.Token`
[🔗](https://github.com/knevan/phoenix-wtransport/blob/main/lib/phoenix_wtransport/token.ex#L1)

Signs and verifies short-lived `Phoenix.Token` credentials for bridging
HTTP session state into cookie-less WebTransport connections.

Because browsers send WebTransport `CONNECT` requests with
`credentials: "omit"`, Plug session cookies are not attached to the HTTP/3
handshake. Applications mint a signed token on the normal HTTPS/HTTP endpoint
(see `PhoenixWebTransport.Plug`) and verify it in `socket.connect/1` or a
LiveView `on_mount` hook.

# `default_max_age`

```elixir
@spec default_max_age() :: pos_integer()
```

Default token lifetime in seconds.

# `sign`

```elixir
@spec sign(module() | Plug.Conn.t() | binary(), term(), keyword()) :: String.t()
```

Signs `claims` using `Phoenix.Token.sign/4`.

`context` may be a `Phoenix.Endpoint`, a `Plug.Conn`, or a `secret_key_base`
binary. Options: `:salt` (default `"phoenix_wtransport_connect"`), `:max_age`.

# `verify`

```elixir
@spec verify(module() | Plug.Conn.t() | binary(), String.t() | nil, keyword()) ::
  {:ok, term()} | {:error, :missing | :invalid | :expired}
```

Verifies a token minted by `sign/3`.

Options: `:salt` (default `"phoenix_wtransport_connect"`), `:max_age`
(default `60` seconds).

---

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