Skip to main content

agent_id_handshake/
error.rs

1//! Error types for handshake protocol.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum HandshakeError {
7    #[error("Invalid message type: expected {expected}, got {got}")]
8    InvalidMessageType { expected: String, got: String },
9
10    #[error("Timestamp out of acceptable range")]
11    TimestampOutOfRange,
12
13    #[error("Nonce already seen (replay attack)")]
14    NonceReplay,
15
16    #[error("Audience mismatch: expected {expected}, got {got}")]
17    AudienceMismatch { expected: String, got: String },
18
19    #[error("Invalid signature")]
20    InvalidSignature,
21
22    #[error("Invalid delegation")]
23    InvalidDelegation,
24
25    #[error("Core error: {0}")]
26    Core(#[from] agent_id_core::Error),
27
28    #[error("Serialization error: {0}")]
29    Serialization(#[from] serde_json::Error),
30
31    #[error("Protocol version not supported: {0}")]
32    UnsupportedVersion(String),
33
34    #[error("Missing required field: {0}")]
35    MissingField(String),
36}
37
38pub type Result<T> = std::result::Result<T, HandshakeError>;