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

Extracts `connect_info` and `auth_token` credentials for `Phoenix.Socket.Transport`
with full parity for non-cookie HTTP/3 WebTransport `CONNECT` upgrades.

Supported `:connect_info` keys:
  * `:peer_data` - `%{address: ip, port: port, ssl_cert: ...}`
  * `:uri` - `%URI{scheme: "https", ...}` built from path, query, and `:authority`
  * `:user_agent` - value of `"user-agent"` header
  * `:x_headers` - all request headers starting with `"x-"` (lowercased names)
  * `:trace_context_headers` - `"traceparent"` / `"tracestate"` headers
  * `:auth_token` - decoded token from `wt-protocol` / `sec-websocket-protocol`
    header or a pre-join `:auth` frame (`base64url.bearer.phx.<token>`)
  * `{:session, _}` - always `%{}` on WebTransport (`credentials: "omit"` omits
    cookies, and `Phoenix.LiveView.Channel` rejects `%{session: nil}` as stale;
    use `PhoenixWebTransport.Token` + `PhoenixWebTransport.Plug` for session claims)
  * `{key, val}` - arbitrary custom key/value pairs passed through unchanged

# `headers`

```elixir
@type headers() :: [{binary(), binary()}]
```

# `build`

```elixir
@spec build(map(), keyword(), binary() | nil) :: map()
```

Builds the `connect_info` map for `socket.connect/1` based on configured keys.

# `decode_auth_token`

```elixir
@spec decode_auth_token(binary(), keyword()) :: {:ok, binary()} | :error
```

Decodes an `auth_token` credential from either a `"base64url.bearer.phx.<b64>"`
string (as emitted by `phoenix.js`) or a raw token binary when explicitly
sent in a pre-join `:auth` frame.

# `extract_header_auth_token`

```elixir
@spec extract_header_auth_token(headers()) :: {:ok, binary()} | :none | :error
```

Extracts an optional Phoenix `auth_token` from `CONNECT` subprotocol headers
(`"wt-protocol"` or `"sec-websocket-protocol"`).

# `header_value`

```elixir
@spec header_value(headers(), binary()) :: binary() | nil
```

Finds the first header value matching lowercase `name`.

---

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