Pixir.Auth.CallbackServer (pixir v0.1.0)

Copy Markdown View Source

Short-lived localhost HTTP server for the Codex browser OAuth callback (ADR 0002).

Binds 127.0.0.1:1455 by default, accepts a single /auth/callback request, validates the OAuth state, and returns the authorization code. The registered redirect URI uses localhost (Pi/Codex convention) even though the listener binds to loopback.

Summary

Functions

Close the listen socket.

Start listening for one browser callback. Accepts :host, :port (testing).

Registered OAuth redirect URI for the browser flow.

Accept one callback connection and return the authorization code.

Types

listen_socket()

@type listen_socket() :: port()

Functions

close(socket)

@spec close(listen_socket()) :: :ok

Close the listen socket.

listen(opts \\ [])

@spec listen(keyword()) :: {:ok, listen_socket()} | {:error, map()}

Start listening for one browser callback. Accepts :host, :port (testing).

redirect_uri()

@spec redirect_uri() :: String.t()

Registered OAuth redirect URI for the browser flow.

wait_for_callback(socket, opts)

@spec wait_for_callback(
  listen_socket(),
  keyword()
) :: {:ok, String.t()} | {:error, map()}

Accept one callback connection and return the authorization code.

Options: :state (required), :timeout_ms (default 15 min).