Atex.IdentityResolver.DIDDocument (atex v0.3.0)

View Source

Struct and schema for describing and validating a DID document.

Summary

Types

service()

@type service() :: %{
  id: String.t(),
  type: String.t() | [String.t()],
  service_endpoint:
    String.t()
    | %{required(String.t()) => String.t()}
    | [String.t() | %{required(String.t()) => String.t()}]
}

t()

@type t() :: %Atex.IdentityResolver.DIDDocument{
  "@context": [String.t()],
  also_known_as: [String.t()] | nil,
  authentication: [String.t() | verification_method()] | nil,
  controller: (String.t() | [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(),
  optional(:public_key_multibase) => String.t(),
  optional(:public_key_jwk) => map()
}

Functions

from_json(map)

@spec from_json(map()) :: {:ok, t()} | {:error, Peri.Error.t()}

get_atproto_handle(doc)

@spec get_atproto_handle(t()) :: String.t() | nil

Get the associated ATProto handle in the DID document.

ATProto dictates that only the first valid handle is to be used, so this follows that rule.

Note

While DID documents are fairly authoritative, you need to make sure to validate the handle bidirectionally. See Atex.IdentityResolver.Handle.resolve/2.

get_schema(atom)

new(params)

schema(data)

schema!(data)

service(data)

service!(data)

validate_for_atproto(doc, did)

@spec validate_for_atproto(t(), String.t()) :: any()

verification_method(data)

verification_method!(data)