1#![allow(missing_docs)]
2
3use thiserror::Error;
4
5pub use crate::generated::{Error as PrivyApiError, types::error::ConversionError};
6
7#[derive(Error, Debug)]
9pub enum PrivyCreateError {
10 #[error("Invalid header value: {0}")]
11 InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
12 #[error("Unable to create client: {0}")]
13 Client(#[from] reqwest::Error),
14 #[error("Invalid app id")]
15 InvalidAppId,
16 #[error("Invalid app secret")]
17 InvalidAppSecret,
18}
19
20#[derive(Error, Debug)]
25pub enum PrivySignedApiError {
26 #[error("API request failed")]
29 Api(#[from] PrivyApiError),
30
31 #[error("Signature generation failed: {0}")]
33 SignatureGeneration(#[from] SignatureGenerationError),
34}
35
36#[derive(Error, Debug)]
38pub enum PrivyExportError {
39 #[error("API request failed")]
42 Api(#[from] PrivyApiError),
43
44 #[error("Signature generation failed: {0}")]
46 SignatureGeneration(#[from] SignatureGenerationError),
47
48 #[error("Unable to decrypt key: {0}")]
50 Key(#[from] KeyError),
51}
52
53#[derive(Error, Debug)]
55pub enum CryptoError {
56 #[error("Signing failed: {0}")]
58 Signing(#[from] SigningError),
59
60 #[error("Key handling failed: {0}")]
62 Key(#[from] KeyError),
63}
64
65#[derive(Error, Debug)]
67pub enum KeyError {
68 #[error("Key I/O error: {0}")]
70 Io(#[from] std::io::Error),
71
72 #[error("Invalid key format: {0}")]
74 InvalidFormat(String),
75
76 #[error("HPKE decryption failed: {0}")]
78 HpkeDecryption(#[from] hpke::HpkeError),
79
80 #[error(transparent)]
82 Other(Box<dyn std::error::Error + Send + Sync>),
83}
84
85#[derive(Error, Debug)]
87pub enum SigningError {
88 #[error("Invalid key for signing: {0}")]
90 Key(#[from] KeyError),
91
92 #[error("Signature creation failed: {0}")]
94 Signature(#[from] p256::ecdsa::Error),
95
96 #[error(transparent)]
98 Other(Box<dyn std::error::Error + Send + Sync>),
99}
100
101#[derive(Debug, Error)]
106pub enum SignatureGenerationError {
107 #[error("Unable to serialize request for signing: {0}")]
108 Serialization(#[from] serde_json::Error),
109 #[error("Error when signing request: {0}")]
110 Signing(#[from] SigningError),
111}