tiny REST API that resolves AT Protocol Lexicon schemas from NSIDs lex.desertthunder.dev
lexicon atproto rest jsx dns hono htmx
0

Configure Feed

Select the types of activity you want to include in your feed.

TypeScript 71.5%
CSS 17.1%
Hurl 11.2%
Other 0.3%
16 1 0

Clone this repository

https://git.vm.fail/desertthunder.dev/lexdns https://git.vm.fail/did:plc:wrpxsca56mhgyqk7fsimjsjt
ssh://git@knot1.tangled.sh:2222/desertthunder.dev/lexdns ssh://git@knot1.tangled.sh:2222/did:plc:wrpxsca56mhgyqk7fsimjsjt

For self-hosted knots, clone URLs may differ based on your setup.


README.md

lexdns#

lexdns is a tiny web app that resolves ATProto Lexicon schemas from NSIDs.

Usage#

# For metadata, including the ATURI:
curl https://lex.desertthunder.dev/api/resolve/app.bsky.feed.post

# For just the schema:
curl https://lex.desertthunder.dev/api/resolve/com.atproto.repo.getRecord | jq '.lexicon'

# Resolve an AT URI or HTTPS getRecord URL:
curl "https://lex.desertthunder.dev/api/uri/at%3A%2F%2Fdid%3Aplc%3Axg2vq45muivyy3xwatcehspu%2Fcom.atproto.lexicon.schema%2Forg.stormlightlabs.malfestio.card"
curl "https://lex.desertthunder.dev/api/uri?uri=https%3A%2F%2Fshaggymane.us-west.host.bsky.network%2Fxrpc%2Fcom.atproto.repo.getRecord%3Frepo%3Ddid%253Aplc%253Axg2vq45muivyy3xwatcehspu%26collection%3Dcom.atproto.lexicon.schema%26rkey%3Dorg.stormlightlabs.malfestio.card"

Endpoints#

GET /api/resolve/{nsid} resolves a direct Lexicon NSID.

GET /api/uri/{aturi} resolves an AT URI or HTTPS URL that points at a com.atproto.lexicon.schema record. URL-encode inputs that contain /, ?, or &. The same input can also be passed as GET /api/uri?uri=....

GET /openapi returns the generated OpenAPI document. The spec is generated from the Valibot schemas used to document the API routes.

How it Works#

  1. Validate the requested NSID.
  2. Convert its authority to a DNS name and query TXT over DNS over HTTPS.
  3. Read a did=... TXT value from _lexicon.<authority-domain>.
  4. Resolve that DID document and find its #atproto_pds service.
  5. Fetch the schema record from the publisher repo:
    • collection: com.atproto.lexicon.schema
    • record key: the full NSID

For example, app.bsky.feed.post resolves through _lexicon.feed.bsky.app, then fetches:

at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.feed.post

Development#

pnpm install
pnpm dev

By default, the local Worker runs at http://localhost:8787/.

Try a published lexicon:

curl http://127.0.0.1:8787/api/resolve/app.bsky.feed.post
curl http://127.0.0.1:8787/api/resolve/com.atproto.repo.getRecord