possum/did

DID (Decentralized ID)

DIDs, or Decentralized IDentifiers, are universally-unique identifiers which represent data repos. They are permanent and non-human-readable. DIDs are a W3C specification. The AT Protocol currently supports did:web and did:plc, two different DID methods.

DIDs resolve to documents which contain metadata about a repo, including the address of the repo’s PDS, the repo’s handles, and the public signing keys.

Types

AT Protocol uses Decentralized Identifiers (DIDs) as persistent account identifiers. An example DID is did:plc:ewvi7nxzyoun6zhxrhs64oiz.

Documentation: DID

pub opaque type Did
pub type DidError {
  InvalidRegexPattern(pattern: String)
  InvalidFormat(value: String)
  InvalidDidMethod(value: String)
}

Constructors

  • InvalidRegexPattern(pattern: String)
  • InvalidFormat(value: String)
  • InvalidDidMethod(value: String)

The core DID standard and describes a framework for compliant identifier systems (“DID methods”), of which several exist. To ensure broad interoperation across the ecosystem, atproto only supports a small number of “blessed” DID methods.

Documentation: Blessed DID Methods

pub type Method {
  Plc
  Web
}

Constructors

  • Plc

    Self-authenticating DID method developed specifically for use with atproto. See the DID PLC website for more details.

  • Web

    W3C community draft based on HTTPS (and DNS). The identifier section is a hostname. This method is supported in atproto to provide an independent alternative to did:plc.

    The special localhost hostname is allowed, but only in testing and development environments. Port numbers (with separating colon hex-encoded) are only allowed for localhost, and only in testing and development.

    Documentation: did:web

Values

pub fn decoder() -> decode.Decoder(Did)
pub fn indentifer(self: Did) -> String

Return the DID identifier.

This function does not convert the value into a valid DID format, for that use to_string.

Examples

import possum/did

let identifier =
  Did(Plc, "k5vecqzf4d5mdvkcu3mx6l5g")
  |> did.identifier

assert identifier == "k5vecqzf4d5mdvkcu3mx6l5g"
pub fn method(self: Did) -> Method

Return the DID method

Examples

let method =
  Did(Plc, "k5vecqzf4d5mdvkcu3mx6l5g")
  |> possum.method

assert method == did.Plc
pub fn parse(content: String) -> Result(Did, DidError)

Parse a string into a valid Did type If the value is not a valid string then an error is returned.

Examples

import possum/did

let string = "did:plc:k5vecqzf4d5mdvkcu3mx6l5g"
let assert Ok(did) = did.parse(string)
pub const pattern: String
pub fn to_string(self: Did) -> String

Convert a DID to a string.

Examples

import possum/did

let string =
  Did(Plc, "k5vecqzf4d5mdvkcu3mx6l5g")
  |> did.to_string

assert string == "did:plc:k5vecqzf4d5mdvkcu3mx6l5g"
Search Document