Header menu logo FSharp.ATProto

Identity Module

AT Protocol identity resolution: DID documents, handle resolution, and bidirectional verification. Supports both did:plc (via PLC directory) and did:web (via .well-known) methods.

Types

Type Description

AtprotoIdentity

A resolved AT Protocol identity containing the DID and optional metadata extracted from the DID document.

Functions and values

Function or value Description

parseDidDocument doc

Full Usage: parseDidDocument doc

Parameters:
    doc : JsonElement - A JSON element representing the DID document.

Returns: Result<AtprotoIdentity, string> Ok with the parsed identity, or Error if the document is missing the required id field. Optional fields (handle, PDS endpoint, signing key) are None if absent from the document.

Parse a DID document JSON into an AtprotoIdentity. Extracts the DID, handle (from alsoKnownAs), PDS endpoint (from service), and signing key (from verificationMethod).

doc : JsonElement

A JSON element representing the DID document.

Returns: Result<AtprotoIdentity, string>

Ok with the parsed identity, or Error if the document is missing the required id field. Optional fields (handle, PDS endpoint, signing key) are None if absent from the document.

resolveDid agent did

Full Usage: resolveDid agent did

Parameters:
    agent : AtpAgent - An AtpAgent whose HttpClient is used for the HTTP request.
    did : Did - The DID to resolve. Must start with did:plc: (resolved via PLC directory) or did:web: (resolved via .well-known/did.json).

Returns: Task<Result<AtprotoIdentity, IdentityError>> Ok with the parsed identity on success, or Error with an IdentityError on HTTP failure or unsupported DID method.

Resolve a DID to an AtprotoIdentity by fetching its DID document.

agent : AtpAgent

An AtpAgent whose HttpClient is used for the HTTP request.

did : Did

The DID to resolve. Must start with did:plc: (resolved via PLC directory) or did:web: (resolved via .well-known/did.json).

Returns: Task<Result<AtprotoIdentity, IdentityError>>

Ok with the parsed identity on success, or Error with an IdentityError on HTTP failure or unsupported DID method.

resolveHandle agent handle

Full Usage: resolveHandle agent handle

Parameters:
    agent : AtpAgent - An authenticated AtpAgent.
    handle : Handle - The handle to resolve (e.g., my-handle.bsky.social).

Returns: Task<Result<Did, IdentityError>> Ok with the resolved Did on success, or Error with an IdentityError if the handle cannot be resolved.

Resolve a handle to its DID via com.atproto.identity.resolveHandle.

agent : AtpAgent

An authenticated AtpAgent.

handle : Handle

The handle to resolve (e.g., my-handle.bsky.social).

Returns: Task<Result<Did, IdentityError>>

Ok with the resolved Did on success, or Error with an IdentityError if the handle cannot be resolved.

resolveIdentity agent identifier

Full Usage: resolveIdentity agent identifier

Parameters:
    agent : AtpAgent - An authenticated AtpAgent.
    identifier : string - A DID (starting with did:) or a handle (e.g., my-handle.bsky.social).

Returns: Task<Result<AtprotoIdentity, IdentityError>> Ok with the resolved AtprotoIdentity. If bidirectional verification fails (the reverse lookup does not match), the Handle field is set to None but the identity is still returned. Returns Error on resolution failure.

Fully resolve an AT Protocol identity with bidirectional verification. Accepts either a DID or a handle and performs the forward + reverse resolution needed to confirm the handle-DID binding.

Bidirectional verification ensures that both directions of the DID-handle binding agree: the DID document must list the handle in alsoKnownAs, and resolving that handle must return the same DID. If either direction fails, the handle is cleared but the identity (DID, PDS endpoint, signing key) is still returned.

agent : AtpAgent

An authenticated AtpAgent.

identifier : string

A DID (starting with did:) or a handle (e.g., my-handle.bsky.social).

Returns: Task<Result<AtprotoIdentity, IdentityError>>

Ok with the resolved AtprotoIdentity. If bidirectional verification fails (the reverse lookup does not match), the Handle field is set to None but the identity is still returned. Returns Error on resolution failure.

Example

 let! identity = Identity.resolveIdentity agent "my-handle.bsky.social"
 match identity with
 | Ok id -> printfn "DID: %s, Handle verified: %b" (Did.value id.Did) id.Handle.IsSome
 | Error msg -> printfn "Resolution failed: %A" msg
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
val id: x: 'T -> 'T
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>

Type something to start searching.