Handle resolution for Exosphere.ATProto.
Handles are DNS domain names that resolve to DIDs. Resolution can occur via:
- DNS TXT record at
_atproto.<handle> - HTTPS well-known endpoint at
https://<handle>/.well-known/atproto-did
Examples
# Resolve a handle to its DID
{:ok, did} = Exosphere.ATProto.Identity.Handle.resolve("alice.bsky.social")
# => {:ok, "did:plc:z72i7hdynmk6r22z27h6tvur"}
# Validate handle syntax
Exosphere.ATProto.Identity.Handle.valid?("alice.example.com")
# => true
Summary
Functions
Normalize a handle to lowercase.
Resolve a handle to its DID.
Resolve a handle via DNS TXT record.
Resolve a handle via HTTPS well-known endpoint.
Validate handle syntax.
Types
@type resolve_opts() :: [ timeout: pos_integer(), methods: [:dns | :https], http_client: module() ]
Functions
Normalize a handle to lowercase.
@spec resolve(String.t(), resolve_opts()) :: {:ok, String.t()} | {:error, term()}
Resolve a handle to its DID.
Tries DNS TXT record first, then falls back to HTTPS well-known endpoint.
Options
:timeout- Request timeout in milliseconds (default: 10_000):methods- Resolution methods to try (default:[:dns, :https]):http_client- HTTP client module implementingHTTP.Behaviour(default:Exosphere.ATProto.HTTP; useful for testing)
Resolve a handle via DNS TXT record.
Queries _atproto.<handle> for a TXT record containing the DID.
@spec resolve_https(String.t(), resolve_opts()) :: {:ok, String.t()} | {:error, term()}
Resolve a handle via HTTPS well-known endpoint.
Fetches https://<handle>/.well-known/atproto-did.
Validate handle syntax.
Handles must be valid domain names with:
- At least one dot
- Only allowed characters (letters, digits, hyphens, dots)
- No consecutive dots or leading/trailing dots
- Labels between 1-63 characters
- Total length under 253 characters
- A final segment (the TLD) that does not start with a digit