Exosphere.ATProto.Identity.Document (Exosphere v0.3.0)

Copy Markdown View Source

DID Document structure and parsing for Exosphere.ATProto.

A DID Document contains:

  • The DID itself
  • Verification methods (signing keys)
  • Service endpoints (PDS location)
  • Also known as (handles)

Summary

Functions

Get the handle from a DID Document.

Get the PDS endpoint from a DID Document.

Get the signing key from a DID Document.

Parse a raw DID Document map into a structured Document.

Types

service()

@type service() :: %{id: String.t(), type: String.t(), service_endpoint: String.t()}

t()

@type t() :: %Exosphere.ATProto.Identity.Document{
  also_known_as: [String.t()] | nil,
  id: String.t(),
  service: [service()] | nil,
  verification_method: [verification_method()] | nil
}

verification_method()

@type verification_method() :: %{
  id: String.t(),
  type: String.t(),
  controller: String.t(),
  public_key_multibase: String.t()
}

Functions

get_handle(arg1)

@spec get_handle(t()) :: {:ok, String.t()} | {:error, :not_found}

Get the handle from a DID Document.

Returns the first at:// URI from alsoKnownAs, extracting just the handle.

get_pds_endpoint(arg1)

@spec get_pds_endpoint(t()) :: {:ok, String.t()} | {:error, :not_found}

Get the PDS endpoint from a DID Document.

Looks for a service with id ending in #atproto_pds and type AtprotoPersonalDataServer.

get_signing_key(arg1)

@spec get_signing_key(t()) :: {:ok, binary(), atom()} | {:error, :not_found}

Get the signing key from a DID Document.

Looks for a verification method with id ending in #atproto. Returns the public key bytes and curve type.

parse(raw)

@spec parse(map()) :: {:ok, t()} | {:error, term()}

Parse a raw DID Document map into a structured Document.

Examples

iex> Exosphere.ATProto.Identity.Document.parse(%{"id" => "did:plc:abc", ...})
{:ok, %Document{...}}