ProtoRune.Atproto.Identity.Behaviour behaviour (proto_rune v0.5.2)

Copy Markdown

Defines the behaviour for AT Protocol identity management operations.

This behaviour specifies the contract for handling:

  • Handle resolution
  • DID resolution
  • Identity validation
  • Signature verification

Summary

Callbacks

Forces a refresh of cached DID document.

Forces a refresh of cached handle resolution data.

Resolves a DID to its full DID document.

Resolves a handle to its corresponding DID.

Runtime check for valid DID format, syntactically.

Runtime check for valid handle format, syntactically.

Validates the full identity chain from handle to DID document, ensuring bidirectional verification.

Verifies a signature against a DID's public key.

Types

did()

@type did() :: String.t()

did_document()

@type did_document() :: %{
  id: did(),
  handle: handle() | nil,
  service_endpoint: String.t(),
  verification_method: [map()],
  also_known_as: [String.t()]
}

error_reason()

@type error_reason() ::
  :not_found
  | :network_error
  | :invalid_format
  | :unsupported_did_method
  | :invalid_signature
  | :rate_limited
  | {:http_error, pos_integer()}

handle()

@type handle() :: String.t()

message()

@type message() :: binary()

signature()

@type signature() :: binary()

Callbacks

refresh_did(did)

@callback refresh_did(did()) :: :ok

Forces a refresh of cached DID document.

refresh_handle(handle)

@callback refresh_handle(handle()) :: :ok

Forces a refresh of cached handle resolution data.

resolve_did(did)

@callback resolve_did(did()) :: {:ok, did_document()} | {:error, error_reason()}

Resolves a DID to its full DID document.

resolve_handle(handle)

@callback resolve_handle(handle()) :: {:ok, did()} | {:error, error_reason()}

Resolves a handle to its corresponding DID.

valid_did?(term)

@callback valid_did?(term()) :: boolean()

Runtime check for valid DID format, syntactically.

valid_handle?(term)

@callback valid_handle?(term()) :: boolean()

Runtime check for valid handle format, syntactically.

validate_identity(handle)

@callback validate_identity(handle()) :: {:ok, did_document()} | {:error, error_reason()}

Validates the full identity chain from handle to DID document, ensuring bidirectional verification.

verify_signature(did, message, signature)

@callback verify_signature(did(), message(), signature()) ::
  :ok | {:error, error_reason()}

Verifies a signature against a DID's public key.