Expand description
atproto-proxy: an XRPC call this server does not serve, forwarded to
the service a DID document names.
The XRPC spec’s “Service Proxying”. The header names a DID and a service
id, as did:web:api.bsky.app#bsky_appview does. This server resolves the
DID, takes the service entry with that id, and forwards the method, the
query and the body there with a service-auth token signed as the calling
account: iss the account, aud the header’s DID and service id, lxm
the method. The answer streams back.
The call is authorized as crate::service_auth::authorize authorizes
one, before anything is resolved, so a caller with no credential makes
this server fetch nothing. Both fetches go through
didbot_http::pinned_client, and neither may reach this server itself.
Which headers cross in each direction are the reference PDS’s
(packages/pds/src/pipethrough.ts).
Each account’s calls are bounded by ProxyLimits: a call over its
rate, or past its own, its tree’s or the server’s share of calls in
flight, is refused 429 before anything is resolved. A call takes its
place once its body is read, so a slow upload holds none.
Re-exports§
pub use limits::ProxyLimits;pub use limits::ProxySettings;
Modules§
- limits 🔒
- What one account may spend of the proxy: a rate, a number of calls in flight, and a cache of where its targets live.
Structs§
- Target 🔒
- Where a call goes: the DID and the service id an
PROXY_HEADERnames.
Constants§
- BODY_
HEADERS 🔒 - The headers that describe a procedure’s body, carried with it.
- CONTENT_
HEADERS 🔒 - The headers that describe a successful answer’s body, carried with it.
- FORWARDED_
REQUEST_ 🔒HEADERS - Request headers a proxied call carries on, beside every
x-atproto-*header.Accept-Encodingis carried too, asidentitywhen absent. - FORWARDED_
RESPONSE_ 🔒HEADERS - Response headers carried back, on a failure as on a success.
- MAX_
PROXIED_ RESPONSE - The most of one proxied answer this server passes back, in bytes.
- PROXY_
HEADER - The request header naming the service a call is for.
- PROXY_
TIMEOUT - How long one proxied call may take, from connecting to the last byte of the answer.
Functions§
- admit 🔒
- Spends one of
did’s proxied calls, or answers the refusal. - answer 🔒
- A successful answer, streamed back under
MAX_PROXIED_RESPONSE. - app_
view 🔒 - Where an
app.bsky.*call atpathgoes when it names no service: the configuredProxySettings::app_view.Nonefor any other method. - fallback 🔒
- The router’s fallback: a path nothing serves, or an XRPC call this server does not serve.
- forward 🔒
- Forwards one XRPC call, or answers why it is not forwarded.
- forwarded_
request_ 🔒headers - The headers a call carries on to the service; see
FORWARDED_REQUEST_HEADERS. - proxy 🔒
- refuse_
this_ 🔒server - Refuses a URL on a name this deployment answers to: a call proxied there is a call this server makes of itself.
- resolve 🔒
- The service’s endpoint origin, and a client pinned to it. The origin is
the one
ProxyLimitskeeps for the target, or elseresolve_endpoint’s; neither it nor the document is on this server. - resolve_
endpoint 🔒 - The origin the target’s DID document names for its service id, fetched through a pinned client from a host that is not this server.
- status_
name 🔒 - The name XRPC gives a status, for a failure that names none: the
reference client’s
httpResponseCodeToName. - tree_of 🔒
- The account tree
didis in, named by its topmost account below this server’s own: the account the operator admitted, read up the parent chain. An account with no parent but this server is its own tree. - unreachable_
target 🔒 - The answer for a target this server will not, or cannot, reach.
- upstream_
error 🔒 - A failed answer, passed back as an XRPC error: the service’s own status,
errorandmessage, except that its 500 is this server’s 502.