Overview
The@atproto/identity package provides TypeScript utilities for resolving and managing decentralized identities in the AT Protocol. It supports DID resolution (did:plc and did:web) and handle resolution via DNS and HTTP methods.
Installation
Core Concepts
The identity package handles two main types of identifiers:- DIDs (Decentralized Identifiers): Persistent, cryptographically-verifiable identifiers
- Handles: Human-readable domain names that resolve to DIDs
Main Exports
Classes
IdResolver
The main class that combines both DID and handle resolution.IdentityResolverOpts
Configuration options for the resolver
handle: HandleResolver- Handle resolver instancedid: DidResolver- DID resolver instance
DidResolver
Resolves DIDs to their DID documents. Supportsdid:plc and did:web methods.
DidResolverOpts
Configuration options
Promise<DidDocument>
Promise<AtprotoData>
did: string- The DIDsigningKey: string- The signing key in did:key formathandle: string- The associated handlepds: string- The PDS endpoint URL
HandleResolver
Resolves handles to DIDs using DNS TXT records and HTTP well-known endpoints.HandleResolverOpts
Configuration options
Promise<string | undefined>
string
required
The handle to resolve (e.g., ‘alice.bsky.social’)
Promise<string | undefined>
_atproto.{handle}Promise<string | undefined>
https://{handle}/.well-known/atproto-didUtility Functions
DID Document Parsing
Extract AT Protocol-specific data from DID documents.Partial<AtprotoData>
AtprotoData
string | undefined
string | undefined
string | undefined
Types
AtprotoData
DidDocument
W3C DID Document structure. Re-exported from@atproto/common-web.
DidCache
Interface for implementing custom DID document caching.Errors
The package exports several error classes:- DidNotFoundError - DID could not be resolved
- PoorlyFormattedDidError - DID syntax is invalid
- UnsupportedDidMethodError - DID method is not supported (only did:plc and did:web are supported)
- PoorlyFormattedDidDocumentError - DID document structure is invalid
- UnsupportedDidWebPathError - did:web path is not supported
Complete Example
Related Packages
- @atproto/crypto - Cryptographic utilities for key verification
- @atproto/syntax - Validation for DIDs, handles, and other identifiers
- @atproto/common-web - Common web utilities including DID document types