sos-login 0.17.3

Login authentication for the Save Our Secrets SDK
Documentation
use sos_core::{SecretId, VaultId};
use thiserror::Error;
use urn::Urn;

/// Errors generated by the library.
#[derive(Debug, Error)]
pub enum Error {
    /// Error generated when an account does not exist.
    #[error("account not found '{0}'")]
    NoAccount(String),

    /// Error generated when a folder password could not be located.
    #[error("folder password not found for '{0}'")]
    NoFolderPassword(VaultId),

    /// Error generated when a login vault does not contain
    /// the identity bit flag.
    #[error("vault is not an identity vault")]
    NotIdentityFolder,

    /// Error generated parsing an AGE identity from a string.
    #[error("failed to parse AGE identity: '{0}'")]
    AgeIdentityParse(String),

    /// Error generated when an identity key could not be
    /// found in an identity vault.
    #[error("identity vault does not contain a valid account identity key")]
    NoIdentityKey,

    /// Error generated when a vault entry in an identity vault is of
    /// the wrong secret kind.
    #[error("vault entry for {0} is of an unexpected type")]
    VaultEntryKind(String),

    /// Error generated when attempting to parse an AGE identity.
    #[error(r#"invalid x25519 identity '{0}'"#)]
    InvalidX25519Identity(String),

    /// Error generated when a vault does not contain a secret by URN.
    #[error("vault {0} does not contain {1}")]
    NoSecretUrn(VaultId, Urn),

    /// Error generated when a vault does not contain a secret by identifier.
    #[error("vault {0} does not contain {1}")]
    NoSecretId(VaultId, SecretId),

    /// Error generated when a file encryption password could not be found.
    #[error("could not find file encryption password in identity folder")]
    NoFileEncryptionPassword,

    /// Error generated converting to fixed length slice.
    #[error(transparent)]
    TryFromSlice(#[from] std::array::TryFromSliceError),

    /// Error generated by the IO module.
    #[error(transparent)]
    Io(#[from] std::io::Error),

    /// Error generated by the core library.
    #[error(transparent)]
    Core(#[from] sos_core::Error),

    /// Authentication errors.
    #[error(transparent)]
    Authentication(#[from] sos_core::AuthenticationError),

    /// Error generated by the backend library.
    #[error(transparent)]
    Backend(#[from] sos_backend::Error),

    /// Error generated by the database library.
    #[error(transparent)]
    Database(#[from] sos_backend::database::Error),

    /// Error generated by the async sqlite library.
    #[error(transparent)]
    AsyncSqlite(#[from] sos_backend::database::async_sqlite::Error),

    /// Error generated by the sqlite library.
    #[error(transparent)]
    Sqlite(#[from] sos_backend::database::async_sqlite::rusqlite::Error),

    /// Error generated by the password library.
    #[error(transparent)]
    Password(#[from] sos_password::Error),

    /// Error generated by the signer library.
    #[error(transparent)]
    Signer(#[from] sos_signer::Error),

    /// Error generated by the vault library.
    #[error(transparent)]
    Vault(#[from] sos_vault::Error),

    /// Error generated by the Ed25519 library.
    #[error(transparent)]
    Ed25519(#[from] ed25519_dalek::ed25519::Error),

    /// Error generated by the URN library.
    #[error(transparent)]
    Urn(#[from] urn::Error),
}