ATProto Lexicon network resolver. Resolves NSID (Namespaced Identifiers) to their corresponding Lexicon JSON schemas over the network.
npm install resolve-lexicon
import { resolveLexicon } from 'resolve-lexicon';
const json = await resolveLexicon('com.atproto.repo.getRecord');
console.log(json);
The resolution process follows the Lexicon Publication and Distribution spec:
Parse NSID - Extract authority domain and name from the NSID
com.atproto.repo.getRecord → authority: repo.atproto.com, name: getRecordDNS Lookup - Query DNS TXT record for _lexicon.<authority>
did=did:plc:...)DID Resolution - Resolve DID to PDS (Personal Data Server) endpoint
did:plc via plc.directorydid:webFetch Lexicon - Retrieve the lexicon record from PDS
com.atproto.repo.getRecord XRPC endpointcom.atproto.lexicon.schemaresolveLexicon(nsid: string): Promise<LexiconDocument>Resolves an NSID to its Lexicon schema.
Parameters:
nsid - Namespaced identifier (e.g., "com.atproto.repo.getRecord")Returns:
LexiconDocumentinterface LexiconDocument {
lexicon: number
id: string
[key: string]: unknown
}
class LexiconResolverError extends Error {
code: string
}
MIT