DID (Decentralized Identifier) resolution for Exosphere.ATProto.
Exosphere.ATProto supports two DID methods:
did:plc- Bluesky's novel DID method with key rotation and recoverydid:web- W3C standard based on HTTPS/DNS
Examples
# Resolve a did:plc
{:ok, doc} = Exosphere.ATProto.Identity.DID.resolve("did:plc:z72i7hdynmk6r22z27h6tvur")
# Resolve a did:web
{:ok, doc} = Exosphere.ATProto.Identity.DID.resolve("did:web:example.com")
# Extract PDS endpoint from DID document
{:ok, pds_url} = Exosphere.ATProto.Identity.DID.get_pds_endpoint(doc)
# Extract signing key
{:ok, public_key, curve} = Exosphere.ATProto.Identity.DID.get_signing_key(doc)
Summary
Functions
Extract the handle (alsoKnownAs) from a DID Document.
Extract the PDS (Personal Data Server) endpoint from a DID Document.
Extract the Exosphere.ATProto signing key from a DID Document.
Parse the DID method from a DID string.
Resolve a DID to its DID Document.
Validate DID syntax according to Exosphere.ATProto rules.
Types
@type did() :: String.t()
@type resolve_opts() :: [timeout: pos_integer(), http_client: module()]
Functions
@spec get_handle(Exosphere.ATProto.Identity.Document.t()) :: {:ok, String.t()} | {:error, :not_found}
Extract the handle (alsoKnownAs) from a DID Document.
Returns the first at:// URI from the alsoKnownAs array.
Examples
iex> Exosphere.ATProto.Identity.DID.get_handle(doc)
{:ok, "alice.example.com"}
@spec get_pds_endpoint(Exosphere.ATProto.Identity.Document.t()) :: {:ok, String.t()} | {:error, :not_found}
Extract the PDS (Personal Data Server) endpoint from a DID Document.
Looks for a service with id #atproto_pds and type AtprotoPersonalDataServer.
Examples
iex> Exosphere.ATProto.Identity.DID.get_pds_endpoint(doc)
{:ok, "https://pds.example.com"}
@spec get_signing_key(Exosphere.ATProto.Identity.Document.t()) :: {:ok, binary(), atom()} | {:error, :not_found}
Extract the Exosphere.ATProto signing key from a DID Document.
Looks for a verification method with id #atproto and extracts the public key.
Examples
iex> Exosphere.ATProto.Identity.DID.get_signing_key(doc)
{:ok, <<public_key_bytes>>, :secp256k1}
Parse the DID method from a DID string.
Examples
iex> Exosphere.ATProto.Identity.DID.method("did:plc:abc123")
{:ok, :plc}
iex> Exosphere.ATProto.Identity.DID.method("did:web:example.com")
{:ok, :web}
@spec resolve(did(), resolve_opts()) :: {:ok, Exosphere.ATProto.Identity.Document.t()} | {:error, term()}
Resolve a DID to its DID Document.
Supports did:plc and did:web methods.
Options
:timeout- HTTP request timeout in milliseconds (default: 10_000):http_client- HTTP client module implementingHTTP.Behaviour(default:Exosphere.ATProto.HTTP; useful for testing)
Examples
iex> Exosphere.ATProto.Identity.DID.resolve("did:plc:z72i7hdynmk6r22z27h6tvur")
{:ok, %Document{...}}
iex> Exosphere.ATProto.Identity.DID.resolve("did:web:example.com")
{:ok, %Document{...}}
iex> Exosphere.ATProto.Identity.DID.resolve("did:unsupported:xyz")
{:error, :unsupported_did_method}
Validate DID syntax according to Exosphere.ATProto rules.
Examples
iex> Exosphere.ATProto.Identity.DID.valid?("did:plc:z72i7hdynmk6r22z27h6tvur")
true
iex> Exosphere.ATProto.Identity.DID.valid?("not-a-did")
false