1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Cryptographic signature operations and utilities for AT Protocol records.
//!
//! This library provides comprehensive functionality for working with AT Protocol records,
//! including cryptographic signature creation and verification, AT-URI parsing, and
//! datetime serialization utilities. Built on IPLD DAG-CBOR for deterministic encoding
//! with support for P-256, P-384, and K-256 elliptic curve cryptography.
//!
//! ## Main Features
//!
//! - **Signature Operations**: Create and verify cryptographic signatures following the
//! community.lexicon.attestation.signature specification
//! - **AT-URI Support**: Parse and validate AT Protocol URIs for record identification
//! - **DateTime Utilities**: RFC 3339 datetime serialization with millisecond precision
//! - **Type-Safe Errors**: Structured error types following project conventions
//!
//! ## Example Usage
//!
//! ```ignore
//! use atproto_record::signature;
//! use atproto_identity::key::identify_key;
//! use serde_json::json;
//!
//! // Sign a record
//! let key_data = identify_key("did:key:...")?;
//! let record = json!({"$type": "app.bsky.feed.post", "text": "Hello!"});
//! let sig_obj = json!({"issuer": "did:plc:..."});
//!
//! let signed = signature::create(&key_data, &record, "did:plc:repo",
//! "app.bsky.feed.post", sig_obj).await?;
//!
//! // Verify a signature
//! signature::verify("did:plc:issuer", &key_data, signed,
//! "did:plc:repo", "app.bsky.feed.post").await?;
//! ```
/// Structured error types for record operations.
///
/// Comprehensive error handling for signature verification, AT-URI parsing,
/// and CLI operations. All errors follow the project's standardized format:
/// `error-atproto-record-{domain}-{number} {message}: {details}`
/// Core signature creation and verification.
///
/// Provides functions for creating and verifying cryptographic signatures on
/// AT Protocol records using IPLD DAG-CBOR serialization. Supports the
/// community.lexicon.attestation.signature specification with proper $sig
/// object handling and multiple signature support.
/// AT-URI parsing and validation.
///
/// Parse and validate AT Protocol URIs (at://authority/collection/record_key)
/// for identifying records within repositories. Supports both did:plc and
/// did:web authority types with comprehensive validation.
/// DateTime serialization utilities.
///
/// RFC 3339 datetime serialization modules for consistent timestamp handling
/// across AT Protocol records. Includes support for both required and optional
/// datetime fields with millisecond precision.
/// Byte array serialization utilities.
///
/// Provides specialized serialization and deserialization for byte arrays
/// in AT Protocol records, handling base64 encoding with the `$bytes` field format.
/// AT Protocol lexicon type definitions.
///
/// Contains structured type definitions for various AT Protocol lexicons including
/// badges, calendar events, RSVPs, locations, and attestations. These types follow
/// the AT Protocol lexicon specifications for data interchange.
/// Generic wrapper for handling lexicon types with `$type` fields.
///
/// Provides a flexible way to handle the `$type` discriminator field that appears
/// in many AT Protocol lexicon structures. The wrapper can automatically add type
/// fields during serialization and validate them during deserialization.