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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use reqwest::StatusCode;
use world_id_primitives::{PrimitiveError, ValidationError};
use world_id_proof::ProofError;
/// Errors that can occur when interacting with the Authenticator.
#[derive(Debug, thiserror::Error)]
pub enum AuthenticatorError {
/// Primitive error
#[error(transparent)]
PrimitiveError(#[from] PrimitiveError),
/// This operation requires a registered account and an account is not registered
/// for this authenticator. Call `create_account` first to register it.
#[error("Account is not registered for this authenticator.")]
AccountDoesNotExist,
/// An error occurred while interacting with the EVM contract.
#[error("Error interacting with EVM contract: {0}")]
ContractError(#[from] alloy::contract::Error),
/// Network/HTTP request error.
#[error("Network error: {0}")]
NetworkError(#[from] reqwest::Error),
/// Public key not found in the Authenticator public key set. Usually indicates the local state is out of sync with the registry.
#[error("Public key not found.")]
PublicKeyNotFound,
/// Gateway returned an error response.
#[error("Gateway error (status {status}): {body}")]
GatewayError {
/// HTTP status code
status: StatusCode,
/// Response body
body: String,
},
/// Indexer returned an error response.
#[error("Indexer error (status {status}): {body}")]
IndexerError {
/// HTTP status code
status: StatusCode,
/// Response body
body: String,
},
/// Account creation timed out while polling for confirmation.
#[error("Account creation timed out")]
Timeout,
/// Configuration is invalid or missing required values.
#[error("Invalid configuration for {attribute}: {reason}")]
InvalidConfig {
/// The config attribute that is invalid.
attribute: String,
/// Description of why it is invalid.
reason: String,
},
/// The provided credential is not valid for the provided proof request.
#[error("The provided credential is not valid for the provided proof request")]
InvalidCredentialForProofRequest,
/// The provided credentials do not satisfy the proof request.
///
/// This usually means the authenticator made an incorrect selection of credentials.
#[error("Proof request cannot be fulfilled with the provided credentials.")]
UnfullfilableRequest,
/// Error during the World ID registration process.
///
/// This usually occurs from an on-chain revert.
#[error("Registration error ({error_code}): {error_message}")]
RegistrationError {
/// Error code from the registration process.
error_code: String,
/// Detailed error message.
error_message: String,
},
/// Error on proof generation
#[error(transparent)]
ProofError(#[from] ProofError),
/// Indexer returned an authenticator key slot that exceeds supported key capacity.
#[error(
"Invalid indexer authenticator pubkey slot {slot_index}; max supported slot is {max_supported_slot}"
)]
InvalidIndexerPubkeySlot {
/// Slot index returned by the indexer.
slot_index: usize,
/// Highest supported slot index.
max_supported_slot: usize,
},
/// OHTTP encapsulation or decapsulation error.
#[error("OHTTP encapsulation error: {0}")]
OhttpEncapsulationError(#[from] ohttp::Error),
/// Binary HTTP framing error.
#[error("Binary HTTP error: {0}")]
BhttpError(#[from] bhttp::Error),
/// The OHTTP relay itself returned a non-success status.
#[error("OHTTP relay error (status {status}): {body}")]
OhttpRelayError {
/// HTTP status code from the relay.
status: StatusCode,
/// Response body from the relay.
body: String,
},
/// A service returned a success status but the response body could not be
/// deserialized into the expected type.
#[error("Invalid service response: {0}")]
InvalidServiceResponse(String),
/// The assembled proof response failed self-validation against the request.
#[error(transparent)]
ResponseValidationError(#[from] ValidationError),
/// Proof materials not loaded. Call `with_proof_materials` before generating proofs.
#[error("Proof materials not loaded. Call `with_proof_materials` before generating proofs.")]
ProofMaterialsNotLoaded,
/// The session ID computed for this proof does not match the expected session ID from the proof request.
///
/// This indicates the `session_id` provided by the RP is invalid or compromised, or
/// the authenticator cached the wrong `session_id_r_seed` for the `oprf_seed`.
#[error("the expected session id and the generated session id do not match")]
SessionIdMismatch,
/// Generic error for other unexpected issues.
#[error("{0}")]
Generic(String),
}
#[derive(Debug)]
pub(crate) enum PollResult {
Retryable,
TerminalError(AuthenticatorError),
}