Latch. DPoP
(latch v0.5.0)
Copy Markdown
DPoP (RFC 9449) proof JWTs for atproto OAuth, and server-issued nonce flow
shared by Latch.XRPC and Latch.Flow.
Summary
Functions
S256 hash of an access token for the ath claim (same as PKCE S256)
Generates a new ES256 (P-256) key pair as a plain RFC 7517 JWK map.
Extract dpop-nonce header from a map of headers.
Signs a DPoP proof JWT for an HTTP request.
RFC 7638 thumbprint of a plain JWK map.
Plumbing for the DPoP-nonce flow used in Latch.Flow and Latch.XRPC. This wraps
the logic for getting nonces, caching new ones, and retrying challenges like 4xx responses.
Types
@type send_error() :: Latch.Error.InvalidResponse.t() | Latch.Error.OAuth.t() | Latch.Error.Transport.t() | Latch.Error.XRPC.t()
@type send_result() :: {{:ok, map()} | :challenge | {:error, send_error()}, String.t() | nil}
Functions
S256 hash of an access token for the ath claim (same as PKCE S256)
@spec generate_key() :: map()
Generates a new ES256 (P-256) key pair as a plain RFC 7517 JWK map.
Extract dpop-nonce header from a map of headers.
Signs a DPoP proof JWT for an HTTP request.
Arguments
jwk— private plain JWK map for this OAuth sessionmethod— HTTP method (e.g."POST")url— request URL; query string is stripped forhtuper atproto
Options
:nonce— server DPoP nonce (omit when unknown):access_token— addsath(S256 hash) for PDS/resource requests:jti— overridejti(tests):iat— overrideiat(tests) Note: atproto currently says do not includeisson PDS-bound proofs.
RFC 7638 thumbprint of a plain JWK map.
@spec with_nonce(Latch.Config.t(), map(), String.t(), (String.t() | nil -> send_result())) :: {:ok, map()} | {:error, Latch.Error.MissingDPoPNonce.t() | send_error()}
Plumbing for the DPoP-nonce flow used in Latch.Flow and Latch.XRPC. This wraps
the logic for getting nonces, caching new ones, and retrying challenges like 4xx responses.