hn.today

ATProto in Practice #1: Identity

mackuba.eu4 points0 comments
Screenshot of ATProto in Practice #1: Identity

This explains how AT Protocol identities work and gives concrete, Ruby-centered recipes for converting between human handles (domain-looking strings like @example.com) and immutable DIDs (did:plc:...), plus how to validate those mappings. Every account has a DID and usually one mutable handle listed in the DID document’s alsoKnownAs array; implementations must filter invalid entries and confirm assignments in both directions. Two verification methods resolve a handle to a DID: a DNS TXT record at _atproto.domain with "did=..." and an HTTP .well-known/atproto-did file containing the DID. Examples show using Resolv::DNS and URI.open in Ruby, and advice is to check both methods (or run them in parallel), prefer DNS when they conflict, reject reserved TLDs, and treat unverified handles as non-owned. The post highlights edge cases like multiple/invalid handles and what an “invalid handle” means in UI/API terms.

Resolving a DID requires different handling by DID method: did:plc documents are fetched from plc.directory (with an immutable audit log of past handle assignments), while did:web documents live at the domain’s .well-known/did.json and bind permanently to that domain. Code examples demonstrate fetching and parsing JSON DID documents and extracting PDS host and verified handle. For bulk needs, plc.directory offers an /export JSON-lines API to iterate operations (useful for caches or stats), with a note that large-scale exports include significant spam.

Read on mackuba.eu0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Web

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.