1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Error types for the auth module.
use thiserror::Error;
/// Unified error type for all authentication operations.
#[derive(Debug, Error)]
pub enum AuthError {
/// Session not found for the given identity key.
#[error("session not found: {0}")]
SessionNotFound(String),
/// Peer is not authenticated.
#[error("not authenticated: {0}")]
NotAuthenticated(String),
/// Authentication handshake failed.
#[error("authentication failed: {0}")]
AuthFailed(String),
/// Received an invalid or malformed message.
#[error("invalid message: {0}")]
InvalidMessage(String),
/// Signature verification failed.
#[error("invalid signature: {0}")]
InvalidSignature(String),
/// Operation timed out.
#[error("timeout: {0}")]
Timeout(String),
/// Transport is not connected.
#[error("transport not connected: {0}")]
TransportNotConnected(String),
/// Nonce verification failed.
#[error("invalid nonce: {0}")]
InvalidNonce(String),
/// A message replay was detected: this exact `(session, message-nonce)`
/// pair has already been accepted. Receiver-side anti-replay guard.
#[error("replay detected: {0}")]
ReplayDetected(String),
/// Required certificate is missing.
#[error("missing certificate: {0}")]
MissingCertificate(String),
/// Certificate validation failed.
#[error("certificate validation error: {0}")]
CertificateValidation(String),
/// Transport-level error.
#[error("transport error: {0}")]
TransportError(String),
/// Serialization or deserialization error.
#[error("serialization error: {0}")]
SerializationError(String),
/// Error from the wallet layer.
#[error("wallet error: {0}")]
Wallet(#[from] crate::wallet::WalletError),
/// Error from the primitives layer.
#[error("primitives error: {0}")]
Primitives(#[from] crate::primitives::PrimitivesError),
/// Generic payment flow error (bad header, missing tx, etc.).
#[error("payment flow error: {0}")]
Payment(String),
/// Paid request exhausted all retry attempts.
#[error("paid request failed after {attempts}/{max_attempts} attempts: {message}")]
PaymentFailed {
attempts: u32,
max_attempts: u32,
message: String,
},
}