key-resolver

Factory functions that return KeyResolver implementations for @atiproto/atproto-attestation. Each factory returns a function with the canonical KeyResolver signature, ready to drop into verify.

Installation

bash
npm install @atiproto/key-resolver

Pick a resolver

  • createDidKeyResolver: local-only parser for did:key: references. Same behavior as the verifier's built-in default, exposed as an explicit factory.
  • createFetchKeyResolver: fetches DID documents from the PLC directory or did:web hosts using fetch, then extracts the key from the named verification method. Pure network, no cache.
  • createCachedKeyResolver: same as createFetchKeyResolver with a SimpleStore cache in front of the DID document fetch. Defaults to in-memory. Pair with @atiproto/edge-resolver-cache for cross-request caching on Cloudflare Workers.

Quick start

typescript
import { verify } from "@atiproto/atproto-attestation";
import { createCachedKeyResolver } from "@atiproto/key-resolver";
import { createDidCache } from "@atiproto/edge-resolver-cache";
const keyResolver = createCachedKeyResolver({
plcUrl: "https://plc.directory",
cache: createDidCache(),
});
const result = await verify({
record,
repository: "did:plc:recipient",
fields: ["items", "currency", "status"],
keyResolver,
});

See also