#![allow(missing_docs)]
use thiserror::Error;
pub use crate::generated::{Error as PrivyApiError, types::error::ConversionError};
#[derive(Error, Debug)]
pub enum PrivyCreateError {
#[error("Invalid header value: {0}")]
InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
#[error("Unable to create client: {0}")]
Client(#[from] reqwest::Error),
#[error("Invalid app id")]
InvalidAppId,
#[error("Invalid app secret")]
InvalidAppSecret,
}
#[derive(Error, Debug)]
pub enum PrivySignedApiError {
#[error("API request failed")]
Api(#[from] PrivyApiError),
#[error("Signature generation failed: {0}")]
SignatureGeneration(#[from] SignatureGenerationError),
}
#[derive(Error, Debug)]
pub enum PrivyExportError {
#[error("API request failed")]
Api(#[from] PrivyApiError),
#[error("Signature generation failed: {0}")]
SignatureGeneration(#[from] SignatureGenerationError),
#[error("Unable to decrypt key: {0}")]
Key(#[from] KeyError),
}
#[derive(Error, Debug)]
pub enum CryptoError {
#[error("Signing failed: {0}")]
Signing(#[from] SigningError),
#[error("Key handling failed: {0}")]
Key(#[from] KeyError),
}
#[derive(Error, Debug)]
pub enum KeyError {
#[error("Key I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Invalid key format: {0}")]
InvalidFormat(String),
#[error("HPKE decryption failed: {0}")]
HpkeDecryption(#[from] hpke::HpkeError),
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
}
#[derive(Error, Debug)]
pub enum SigningError {
#[error("Invalid key for signing: {0}")]
Key(#[from] KeyError),
#[error("Signature creation failed: {0}")]
Signature(#[from] p256::ecdsa::Error),
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
}
#[derive(Debug, Error)]
pub enum SignatureGenerationError {
#[error("Unable to serialize request for signing: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Error when signing request: {0}")]
Signing(#[from] SigningError),
}