EdgeDidResolver

@atiproto/edge-resolvers

Extends DidResolver from @atproto/identity using fetch-based sub-resolvers for both did:plc and did:web, making it compatible with Cloudflare Workers and any fetch-capable runtime.

Constructor

typescript
new EdgeDidResolver(opts?: DidResolverOpts)
OptionTypeDefaultDescription
plcUrlstring"https://plc.directory"Base URL for the PLC directory used to resolve did:plc identifiers.
timeoutnumber3000Milliseconds before a resolution request is aborted.

Methods

MethodReturnsDescription
resolve(did)Promise<DidDocument>Resolves a DID to its DID document. Dispatches to the PLC or Web sub-resolver based on the DID method.
resolveHandle(did)Promise<string | undefined>Extracts the handle from the alsoKnownAs field of the resolved DID document.
asOAuthResolver()OAuthResolverReturns an adapter compatible with the didResolver option of EdgeOAuthClient.

Example

typescript
import { EdgeDidResolver } from "@atiproto/edge-resolvers";
// Standalone resolution
const resolver = new EdgeDidResolver({ timeout: 5000 });
const doc = await resolver.resolve("did:plc:abc123");
// As an OAuth-compatible resolver
const oauthResolver = resolver.asOAuthResolver();