use snafu::Snafu;
use crate::error::Error;
#[non_exhaustive]
#[derive(Debug, Snafu)]
pub enum VerifyError {
#[snafu(display("no matching key"))]
NoMatchingKey,
#[snafu(display("ambiguous key: multiple keys match but token has no kid"))]
AmbiguousKeyMatch,
#[snafu(display("signature mismatch"))]
SignatureMismatch,
#[snafu(transparent)]
Other {
source: Error,
},
}
impl VerifyError {
#[must_use]
pub fn is_retryable(&self) -> bool {
match self {
VerifyError::NoMatchingKey
| VerifyError::AmbiguousKeyMatch
| VerifyError::SignatureMismatch => false,
VerifyError::Other { source } => source.is_retryable(),
}
}
}
#[derive(Debug, Snafu)]
pub enum CreateVerifierError {
#[snafu(display("Unsupported key"))]
UnsupportedKey,
#[snafu(display("A JWKS URI is required to build a JWS verifier"))]
MissingJwksUri,
#[snafu(transparent)]
Other {
source: Error,
},
}