attenuable_jwt/verify/
error.rs

1use thiserror::Error;
2
3/// An error that may occur during attenuable JWT verification.
4#[derive(Debug, Error)]
5pub enum Error {
6    /// An error decoding or validating a JWT's claims.
7    #[error("jwt error")]
8    JWTError(Option<Box<dyn std::error::Error>>),
9    /// An error indicating a bad algorithm for the JWT.
10    #[error("invalid algorithm")]
11    InvalidAlgorithm,
12    /// An error indicating an invalid signature.
13    #[error("invalid signature")]
14    InvalidSignature,
15    /// An error indicating invalid claims.
16    #[error("invalid claims")]
17    InvalidClaims,
18    /// An error indicating invalid claim format (e.g. deserialization error).
19    #[error("invalid claim format")]
20    InvalidClaimFormat(Box<dyn std::error::Error>),
21    /// An error indicating invalid JWT format.
22    #[error("invalid jwt format")]
23    InvalidJWTFormat,
24    /// An error indicating invalid base64 encoding.
25    #[error("invalid base64 encoding")]
26    InvalidBase64Encoding(Box<dyn std::error::Error>),
27    /// An error indicating that the final attenuation key in an envelope (the key that should be used to sign the envelope itself) is missing.
28    #[error("missing final attenuation key")]
29    MissingFinalAttenuationKey,
30    /// An invalid attenuation key was encountered somewhere in the JWT chain.
31    #[error("invalid attenuation key")]
32    InvalidAttenuationKey(Box<dyn std::error::Error>),
33    /// The envelope key was invalid.
34    #[error("invalid envelope key")]
35    InvalidEnvelopeKey,
36    /// No key was found for the given key id.
37    #[error("missing key for key id: {0:?}")]
38    MissingKey(Option<String>),
39    /// A JWK representing the public key for one of the attenuation keys in the JWT chain was malformed.
40    #[error("malformed jwk for attenuation key")]
41    MalformedAttenuationKeyJWK,
42    /// Invalid key.
43    #[error("invalid key")]
44    InvalidKey,
45}
46
47/// Result type for verification operations.
48pub type Result<R> = std::result::Result<R, Error>;