totp-sos 3.1.0

RFC-compliant TOTP implementation with minimal dependencies.
use thiserror::Error;

/// Errors generated by the library.
#[derive(Debug, Error)]
pub enum Error {
    /// Error generated when a secret is not valid base32.
    #[error("Secret '{0}' is not a valid non-padded base32 string")]

    /// Error generated an issuer mismatch is detected.
    #[error("An issuer '{0}' could be retrieved from the path, but a different issuer '{1}' was found in the issuer URL parameter")]
    IssuerMismatch(String, String),

    /// Error generated an issuer contains a colon.
    #[error("Issuer '{0}' must not contain a colon")]

    /// Error generated an account name contains a colon.
    #[error("Account name '{0}' must not contain a colon")]

    /// Error generated step cannot be parsed as a number.
    #[error("Could not parse step '{0}' as a number")]

    /// Error generated digits cannot be parsed as a number.
    #[error("Could not parse digits '{0}' as a number")]

    /// Error generated when an invalid algorithm is detected.
    #[error("Algorithm can only be SHA1, SHA256 or SHA512, not '{0}'")]

    /// Error generated when decoding a URL.
    #[error("Could not decode URL '{0}'")]

    /// Error generated when a URL host is invalid.
    #[error("Host should be totp, not '{0}'")]

    /// Error generated when a URL scheme is invalid.
    #[error("Scheme should be otpauth, not '{0}'")]

    /// Error generated when the length of the shared secret is not at least 128 bits.
    #[error("The length of the shared secret MUST be at least 128 bits; {0} bits is not enough")]

    /// Error generated when the number of digits is not in the valid range.
    #[error("Implementations MUST extract a 6-digit code at a minimum and possibly 7 and 8-digit code; {0} digits is not allowed")]

    /// Errors generated by the URL library.
    Url(#[from] url::ParseError),

    /// Errors generated by the system time.
    Time(#[from] std::time::SystemTimeError),