Skip to main content

clasp_caps/
error.rs

1//! Capability token error types
2
3use thiserror::Error;
4
5/// Capability token errors
6#[derive(Debug, Error)]
7pub enum CapError {
8    /// Token encoding/decoding failed
9    #[error("encoding error: {0}")]
10    Encoding(String),
11
12    /// Signature verification failed
13    #[error("invalid signature")]
14    InvalidSignature,
15
16    /// Token has expired
17    #[error("token expired")]
18    Expired,
19
20    /// Scope attenuation violation (child tried to widen parent's scope)
21    #[error("scope attenuation violation: {0}")]
22    AttenuationViolation(String),
23
24    /// Delegation chain too deep
25    #[error("delegation chain too deep: {depth} exceeds max {max}")]
26    ChainTooDeep { depth: usize, max: usize },
27
28    /// Issuer not trusted (not in trust anchors)
29    #[error("untrusted issuer: {0}")]
30    UntrustedIssuer(String),
31
32    /// Invalid proof chain
33    #[error("invalid proof chain: {0}")]
34    InvalidProof(String),
35
36    /// Key error
37    #[error("key error: {0}")]
38    KeyError(String),
39}
40
41/// Result type for capability operations
42pub type Result<T> = std::result::Result<T, CapError>;