DiscoveryChain
Implements the AT Protocol discovery chain:
Handle → DID: HTTP fallback via
/.well-known/atproto-didon the handle's domain. (DNS_atproto.<handle>TXT is preferred but requires a DNS library; HTTP fallback covers all cases.)DID → PDS: Fetch the DID document from
plc.directory(fordid:plc) or the DID method's resolution endpoint, extract the#atproto_pdsservice endpoint.PDS → Auth Server: Fetch
/.well-known/oauth-protected-resource→authorization_servers[0], then/.well-known/oauth-authorization-server→ extract all OAuth endpoint URLs.Bidirectional handle verification: verify the DID document's
alsoKnownAsfield claims the original handle.
For signup flows where no handle/DID is known up front, use resolveKnownAuthServer to short-circuit the chain and fetch only the auth-server metadata; identity is hydrated post-token-exchange via hydrateIdentityFromDid.
Constructors
Functions
Resolves a handle or DID all the way to a fully-populated AuthServerMetadata ready for the OAuth flow.
Short-circuits the discovery chain for flows where the auth server is already known (e.g. signup, where the user has no handle/DID yet). Fetches only the auth-server metadata; AuthServerMetadata.did, AuthServerMetadata.handle, and AuthServerMetadata.pdsUrl are left null — populate them post-token-exchange via hydrateIdentityFromDid.