Socket
Book a DemoInstallSign in
Socket

resolve-lexicon

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-lexicon

ATProto Lexicon network resolver

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

resolve-lexicon

ATProto Lexicon network resolver. Resolves NSID (Namespaced Identifiers) to their corresponding Lexicon JSON schemas over the network.

Installation

npm install resolve-lexicon

Usage

import { resolveLexicon } from 'resolve-lexicon';

const json = await resolveLexicon('com.atproto.repo.getRecord');
console.log(json);

How it Works

The resolution process follows the Lexicon Publication and Distribution spec:

  • Parse NSID - Extract authority domain and name from the NSID

    • Example: com.atproto.repo.getRecord → authority: repo.atproto.com, name: getRecord
  • DNS Lookup - Query DNS TXT record for _lexicon.<authority>

    • Uses DNS-over-HTTPS (Cloudflare DNS API) for browser compatibility
    • Extracts DID from TXT record (format: did=did:plc:...)
  • DID Resolution - Resolve DID to PDS (Personal Data Server) endpoint

    • Supports did:plc via plc.directory
    • Supports did:web
  • Fetch Lexicon - Retrieve the lexicon record from PDS

    • Uses com.atproto.repo.getRecord XRPC endpoint
    • Collection: com.atproto.lexicon.schema
    • Record key: the NSID

API

resolveLexicon(nsid: string): Promise<LexiconDocument>

Resolves an NSID to its Lexicon schema.

Parameters:

  • nsid - Namespaced identifier (e.g., "com.atproto.repo.getRecord")

Returns:

  • Promise that resolves to a LexiconDocument

Types

interface LexiconDocument {
  lexicon: number
  id: string
  [key: string]: unknown
}

class LexiconResolverError extends Error {
  code: string
}

License

MIT

Keywords

atproto

FAQs

Package last updated on 07 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts