aitp_core/lib.rs
1//! Core types and primitives for the Agent Identity & Trust Protocol (AITP).
2//!
3//! This crate is pure — no I/O, no crypto, no transport. It defines:
4//!
5//! - The [`Aid`] newtype: a validated AITP Agent Identifier.
6//! - The [`AitpEnvelope`] message wrapper.
7//! - JSON canonicalization per RFC 8785 ([`jcs`]).
8//! - Strict unpadded base64url codec ([`base64url`]).
9//! - The [`Timestamp`] newtype for Unix-second timestamps.
10//! - The [`ExtensionsMap`] type for forward-compatible extensions.
11//! - The [`AitpError`] and [`ErrorCode`] taxonomy from RFC-AITP-0001.
12//!
13//! Higher-level protocol crates (`aitp-manifest`, `aitp-tct`, `aitp-handshake`,
14//! `aitp-delegation`) build on these primitives.
15
16#![forbid(unsafe_code)]
17#![warn(missing_docs)]
18
19pub mod aid;
20pub mod base64url;
21pub mod envelope;
22pub mod error;
23pub mod extensions;
24pub mod jcs;
25pub mod raw_url;
26pub mod time;
27
28pub use aid::{Aid, AidAlgorithm, AidParseError};
29pub use envelope::{
30 envelope_signing_digest, envelope_signing_input, AitpEnvelope, MessageType, Sender,
31};
32pub use error::{AitpError, ErrorCode};
33pub use extensions::ExtensionsMap;
34pub use raw_url::RawUrl;
35pub use time::Timestamp;
36
37/// Protocol version this crate implements. Carried as the `version`
38/// field on JCS-profile artifacts and as the `ver` private claim on
39/// compact-JWS portable trust artifacts (RFC-AITP-0001 §5.4.5).
40pub const PROTOCOL_VERSION: &str = "aitp/0.2";
41
42/// Default timestamp tolerance for replay protection (300 seconds, ±).
43pub const DEFAULT_TIMESTAMP_TOLERANCE_SECS: i64 = 300;
44
45/// Length of an AID identifier component when method = `pubkey`
46/// (Ed25519 raw public key encoded as unpadded base64url).
47pub const AID_PUBKEY_IDENTIFIER_LEN: usize = 43;
48
49/// Length of an Ed25519 signature encoded as unpadded base64url.
50pub const ED25519_SIGNATURE_BASE64URL_LEN: usize = 86;