ic_auth_client/
auth_client.rs

1use crate::storage::DecodeError;
2use thiserror::Error;
3
4#[cfg(feature = "native")]
5mod native;
6#[cfg(feature = "wasm-js")]
7mod wasm_js;
8
9#[cfg(feature = "native")]
10pub use native::{NativeAuthClient, NativeLoginError};
11#[cfg(feature = "wasm-js")]
12pub use wasm_js::AuthClient;
13
14/// The error type for the auth client.
15#[derive(Error, Debug)]
16pub enum AuthClientError {
17    /// An error from the storage.
18    #[error("Storage error: {0}")]
19    Storage(#[from] crate::storage::StorageError),
20    /// An error from the delegation.
21    #[error("Delegation error: {0}")]
22    Delegation(#[from] ic_agent::identity::DelegationError),
23    /// An error that occurred while loading a PEM file.
24    #[cfg(feature = "pem")]
25    #[error("PEM error: {0}")]
26    Pem(#[from] ic_agent::identity::PemError),
27}
28
29impl From<DecodeError> for AuthClientError {
30    fn from(err: DecodeError) -> Self {
31        AuthClientError::Storage(err.into())
32    }
33}