atproto-identity
A Rust library for AT Protocol identity resolution and management.
Overview
atproto-identity provides comprehensive support for resolving and managing identities in the AT Protocol ecosystem. This library handles multiple DID (Decentralized Identifier) methods including did:plc and did:web, as well as AT Protocol handle resolution via both DNS and HTTP methods.
This project was extracted from the open-sourced Smokesignal project and is designed to be a standalone, reusable library for AT Protocol identity operations.
Features
- Handle Resolution: Resolve AT Protocol handles to DIDs using DNS TXT records and HTTP well-known endpoints
- DID Document Retrieval: Fetch and parse DID documents for
did:plcanddid:webidentifiers - Multiple Resolution Methods: Supports both DNS and HTTP-based handle resolution with conflict detection
- Configurable DNS: Custom DNS nameserver support with fallback to system defaults
- Cryptographic Key Operations: Support for P-256 and K-256 key identification, signature validation, and signing
- Structured Logging: Built-in tracing support for debugging and monitoring
- Type Safety: Comprehensive error handling with structured error types
Supported DID Methods
- did-method-plc: Public Ledger of Credentials DIDs via PLC directory
- did-method-web: Web-based DIDs following the did:web specification with URL conversion utilities
- ATProtocol Handle Resolution: AT Protocol handles (e.g.,
ngerakines.me) can be resolved to DIDs
Installation
Add this to your Cargo.toml:
[]
= "0.2.0"
Usage
Basic Handle Resolution
use ;
async
DID Document Retrieval
use ;
async
Web DID URL Conversion
The web module provides utilities for converting DID identifiers to their HTTPS document URLs:
use web;
Cryptographic Key Operations
The key module provides utilities for working with cryptographic keys:
use ;
Configuration
The library supports various configuration options through environment variables:
# Custom PLC directory hostname
# Custom DNS nameservers (semicolon-separated)
;
# Custom CA certificate bundles (semicolon-separated paths)
;
# Custom User-Agent string
Command Line Tool
The library includes a command-line tool for testing and resolution:
# Install the binary
# Resolve a handle to DID
# Get full DID document
Architecture
The library is organized into several modules:
- resolve: Core resolution logic for handles and DIDs
- plc: PLC directory client for
did:plcresolution - web: Web DID client for
did:webresolution and URL conversion - model: Data structures for DID documents and AT Protocol entities
- validation: Input validation for handles and DIDs
- config: Configuration management and environment variable handling
- errors: Structured error types following project conventions
- key: Cryptographic key operations including signature validation and key identification for P-256 and K-256 curves
Error Handling
All errors follow a structured format:
error-atproto-identity-<domain>-<number> <message>: <details>
Examples:
error-atproto-identity-resolve-1 Multiple DIDs resolved for methoderror-atproto-identity-plc-1 HTTP request failed: https://plc.directory/did:plc:example Not Founderror-did-web-1 Invalid DID format: missing 'did:web:' prefix
Contributing
Contributions are welcome! Please ensure that:
- All tests pass:
cargo test - Code is properly formatted:
cargo fmt - No linting issues:
cargo clippy - New functionality includes appropriate tests
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
This library was extracted from the Smokesignal project, an open-source event and RSVP management and discovery application.