atproto_core/oauth/effect

A sans-IO effect kernel: an Effect(a) is a pure description of the HTTP + DPoP steps a flow needs, interpreted by a per-target runner. Keys never appear here; DpopProof asks the runner for a proof. Fetch carries string bodies (OAuth endpoints), FetchBits binary (the resource path).

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 get_checked(
  url: String,
) -> Effect(Result(response.Response(String), xrpc.XrpcError))

GET url and status-check the response: the shared shape of the metadata and resolver lookups.

pub fn map(effect: Effect(a), f: fn(a) -> b) -> Effect(b)
pub fn map_error(
  effect: Effect(Result(a, e1)),
  f: fn(e1) -> e2,
) -> Effect(Result(a, e2))
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).

pub fn try(
  effect: Effect(Result(a, e)),
  f: fn(a) -> Effect(Result(b, e)),
) -> Effect(Result(b, e))

Short-circuiting bind over Effect(Result(_, e)): use ok <- effect.try(eff) stops at the first Error.

Search Document