atproto_core/did
DIDs and native DID document resolution as Effects, with no
third-party resolver in the path: did:plc documents come from the PLC
directory, did:web documents from https://<host>/.well-known/did.json.
This is what the OAuth flow trusts for “which PDS, and therefore which
authorization server, speaks for this account”; a resolver such as
Slingshot (atproto_core/identity) only ever supplies a hint that this
module re-verifies.
Handle resolution (DNS TXT _atproto / /.well-known/atproto-did) is not
implemented here. A handle is accepted only when the DID document it led
to lists it in alsoKnownAs; the account identity is always the DID.
Types
Did
opaqueA syntactically valid did:plc or did:web DID. Other methods are not
supported by atproto and are rejected on parse.
pub opaque type Did
The parts of a DID document the OAuth flow relies on: the DID it is for
(checked against the document id), the #atproto_pds service origin, and
the handles the document claims (alsoKnownAs entries, at:// stripped).
pub type DidDocument {
DidDocument(
did: Did,
pds: remote.Origin,
handles: List(String),
)
}
Constructors
-
DidDocument(did: Did, pds: remote.Origin, handles: List(String))
pub type DidError {
InvalidDid(value: String)
UnsupportedMethod(value: String)
DocumentFetchFailed(did: String, error: effect.FetchError)
DocumentIdMismatch(did: String, claimed: String)
NoPdsService(did: String)
InvalidPdsEndpoint(did: String, error: remote.UrlError)
InvalidPlcDirectory(error: remote.UrlError)
}
Constructors
-
InvalidDid(value: String) -
UnsupportedMethod(value: String) -
DocumentFetchFailed(did: String, error: effect.FetchError) -
DocumentIdMismatch(did: String, claimed: String) -
NoPdsService(did: String) -
InvalidPdsEndpoint(did: String, error: remote.UrlError) -
InvalidPlcDirectory(error: remote.UrlError)
Values
pub fn did_error_to_string(error: DidError) -> String
pub fn document_url(
did: Did,
plc_directory plc_directory: remote.Origin,
) -> remote.Url
Where the DID document lives: the PLC directory for did:plc, the host’s
/.well-known/did.json for did:web.
pub const plc_directory: String
pub fn resolve(
did: Did,
) -> effect.Effect(Result(DidDocument, DidError))
Fetch and verify did’s document from the default PLC directory (or the
did:web host).
pub fn resolve_via(
did: Did,
plc_directory: remote.Origin,
) -> effect.Effect(Result(DidDocument, DidError))
resolve against an alternative PLC directory (a mirror, or a test host).