Exosphere.ATProto repository operations for writing records to a user's PDS.
This module handles authenticated writes to the user's Exosphere.ATProto repository using OAuth tokens and DPoP proofs.
Summary
Functions
Create a new record in the user's repository.
Delete a record from the user's repository.
Get a record from any repository (public, no auth needed).
Put (create or update) a record in the user's repository.
Fetch a repository from a PDS as a CAR archive and fully verify it.
Functions
Create a new record in the user's repository.
Uses com.atproto.repo.createRecord for records with auto-generated keys.
Parameters
session- OAuth session with access_token and dpop_private_keypds_url- URL of the user's PDSdid- The user's DIDcollection- The collection NSIDrecord- The record data to write
Returns
{:ok, %{uri: uri, cid: cid}}on success{:error, reason}on failure
Delete a record from the user's repository.
Parameters
session- OAuth sessionpds_url- URL of the user's PDSdid- The user's DIDcollection- The collection NSIDrkey- The record key to delete
Get a record from any repository (public, no auth needed).
Put (create or update) a record in the user's repository.
Uses com.atproto.repo.putRecord for records with known keys (like profile with "self").
Parameters
session- OAuth session with access_token and dpop_private_keypds_url- URL of the user's PDSdid- The user's DIDcollection- The collection NSID (e.g., "app.bsky.actor.profile")rkey- The record key (e.g., "self")record- The record data to write
Returns
{:ok, %{uri: uri, cid: cid}}on success{:error, reason}on failure
@spec verify_checkout(String.t(), Exosphere.ATProto.Identity.DID.did(), keyword()) :: {:ok, %{ did: Exosphere.ATProto.Identity.DID.did(), rev: String.t() | nil, commit: Exosphere.ATProto.CID.t(), records: map() }} | {:error, term()}
Fetch a repository from a PDS as a CAR archive and fully verify it.
Downloads com.atproto.sync.getRepo, reads the record set out of the
returned MST, checks it against the commit's signed root
(Repo.Commit.verify_checkout/2), resolves the repo's DID document, and
verifies the commit signature (Repo.Commit.verify/3).
This is the trustless read path: rather than trusting the PDS's getRecord
responses, the whole repository is checked against the key the account
advertises in its DID document.
Parameters
pds_url- Base URL of the PDS (e.g."https://bsky.social")did- The repository's DIDopts- Options::verify_signature- Whenfalse, skip DID resolution and signature verification (default:true):http- HTTP client module implementingHTTP.Behaviour(default:HTTP; useful for testing):did_document- A pre-resolved%Identity.Document{}to verify against, skipping DID resolution (useful for testing)
Returns
{:ok, %{did: did, rev: rev, commit: %CID{}, records: %{path => %CID{}}}}{:error, reason}— network errors, malformed CAR, MST/root mismatches, or signature failures