atproto_core/oauth/effect

A sans-IO effect kernel for the OAuth orchestration. An Effect(a) is a pure description of the HTTP + DPoP steps a flow needs; a per-target runner interprets it (sync xrpc.Client + gose.Key on erlang, async Promise Client + WebCrypto CryptoKey in the browser). Keys never appear here: DpopProof asks the runner for a proof and each runner closes over its own platform key. Bodies come in two shapes: Fetch for the string-shaped OAuth endpoints, FetchBits for the binary resource path (blobs).

Types

pub type Effect(a) {
  Fetch(
    request: request.Request(String),
    next: fn(
      Result(response.Response(String), xrpc.TransportError),
    ) -> Effect(a),
  )
  FetchBits(
    request: request.Request(BitArray),
    next: fn(
      Result(response.Response(BitArray), xrpc.TransportError),
    ) -> Effect(a),
  )
  DpopProof(
    method: String,
    url: String,
    nonce: option.Option(String),
    ath: option.Option(String),
    next: fn(Result(String, String)) -> Effect(a),
  )
  Done(a)
}

Constructors

Values

pub fn done(value: a) -> Effect(a)
pub fn fetch(
  request: request.Request(String),
) -> Effect(
  Result(response.Response(String), xrpc.TransportError),
)

A string-bodied HTTP request, yielding the response (or a transport error).

pub fn fetch_bits(
  request: request.Request(BitArray),
) -> Effect(
  Result(response.Response(BitArray), xrpc.TransportError),
)

A binary HTTP request (the resource path, for blobs), yielding the response.

pub fn map(effect: Effect(a), f: fn(a) -> b) -> Effect(b)
pub fn proof(
  method method: String,
  url url: String,
  nonce nonce: option.Option(String),
  ath ath: option.Option(String),
) -> Effect(Result(String, String))

Ask the runner for a DPoP proof bound to this method+URL (and optional nonce and access-token hash). The runner signs it with its platform key.

pub fn then(
  effect: Effect(a),
  f: fn(a) -> Effect(b),
) -> Effect(b)

Monadic bind, use-syntax friendly: use x <- effect.then(some_effect).

Search Document