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

Origin validation for WebTransport `CONNECT` upgrades, matching
`Phoenix.Socket.Transport.check_origin/5` semantics.

Supports:
  * `false` - disables origin checking (useful for non-browser tests or CLI clients)
  * `true` - checks against `endpoint.config(:url)[:host]`
  * `list` of origin patterns (e.g. `["https://example.com", "//*.example.com:8443"]`)
  * `:conn` - compares origin scheme/host/port against the request `:authority`
  * `{module, function, args}` MFA tuple invoked as `apply(module, function, [origin_uri | args])`

When `opts[:check_origin]` is `nil` or omitted, defaults to
`endpoint.config(:check_origin)` if `endpoint` defines `config/1`, or `false`.

# `policy`

```elixir
@type policy() :: boolean() | [String.t()] | :conn | {module(), atom(), list()}
```

# `check`

```elixir
@spec check(binary() | nil, module(), keyword(), map()) ::
  :ok | {:error, 403, :origin_missing | {:origin_not_allowed, binary()}}
```

Validates an `Origin` header binary against the resolved policy.

Unlike HTTP/WebSocket where non-browser clients may omit `Origin`, WebTransport
rejects a missing `Origin` header with `{:error, 403, :origin_missing}` whenever
origin checking is enabled (`policy != false`).

# `resolve_policy`

```elixir
@spec resolve_policy(module(), keyword()) :: policy()
```

Resolves and validates the effective `:check_origin` policy.

---

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