use crate::prelude::MlsCredentialType;
use core_crypto_keystore::CryptoKeystoreError;
pub type E2eIdentityResult<T> = Result<T, E2eIdentityError>;
#[derive(Debug, thiserror::Error)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Error))]
#[cfg_attr(feature = "uniffi", uniffi(flat_error))]
pub enum E2eIdentityError {
#[error("Incorrect usage of this API")]
ImplementationError,
#[error("Not yet supported")]
NotYetSupported,
#[error("Expected a MLS client with credential type {0:?} but none found")]
MissingExistingClient(MlsCredentialType),
#[error("Enrollment methods are called out of order: {0}")]
OutOfOrderEnrollment(&'static str),
#[error("Invalid OIDC RefreshToken supplied")]
InvalidRefreshToken,
#[error("An error occurred while trying to persist the RefreshToken in the keystore")]
KeyStoreError(#[from] CryptoKeystoreError),
#[error(transparent)]
IdentityError(#[from] wire_e2e_identity::prelude::E2eIdentityError),
#[error(transparent)]
X509Error(#[from] wire_e2e_identity::prelude::x509::RustyX509CheckError),
#[error(transparent)]
UrlError(#[from] url::ParseError),
#[error(transparent)]
JsonError(#[from] serde_json::Error),
#[error("We already have an ACME Root Trust Anchor registered. Cannot proceed but this is usually indicative of double registration and can be ignored")]
TrustAnchorAlreadyRegistered,
}