webauthn_rp

WebAuthn Level 3 RP library.
git clone https://git.philomathiclife.com/repos/webauthn_rp
Log | Files | Refs | README

error.rs (1780B)


      1 #[cfg(doc)]
      2 use super::{
      3     AllowedCredentials, CredentialSpecificExtension, DiscoverableCredentialRequestOptions,
      4     Extension, NonDiscoverableCredentialRequestOptions, PublicKeyCredentialRequestOptions,
      5     UserVerificationRequirement,
      6 };
      7 use core::{
      8     error::Error,
      9     fmt::{self, Display, Formatter},
     10 };
     11 #[cfg(doc)]
     12 use std::time::{Instant, SystemTime};
     13 /// Error returned from [`NonDiscoverableCredentialRequestOptions::second_factor`] when
     14 /// [`AllowedCredentials`] is empty.
     15 #[derive(Clone, Copy, Debug)]
     16 pub struct SecondFactorErr;
     17 impl Display for SecondFactorErr {
     18     #[inline]
     19     fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
     20         f.write_str("allowed credentials was empty")
     21     }
     22 }
     23 impl Error for SecondFactorErr {}
     24 /// Error returned by [`DiscoverableCredentialRequestOptions::start_ceremony`]
     25 /// and [`NonDiscoverableCredentialRequestOptions::start_ceremony`]
     26 #[derive(Clone, Copy, Debug)]
     27 pub enum RequestOptionsErr {
     28     /// Error when [`Extension::prf`] or [`CredentialSpecificExtension::prf`] is [`Some`] but
     29     /// [`PublicKeyCredentialRequestOptions::user_verification`] is not
     30     /// [`UserVerificationRequirement::Required`].
     31     PrfWithoutUserVerification,
     32     /// [`PublicKeyCredentialRequestOptions::timeout`] could not be added to [`Instant::now`] or [`SystemTime::now`].
     33     InvalidTimeout,
     34 }
     35 impl Display for RequestOptionsErr {
     36     #[inline]
     37     fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
     38         f.write_str(match *self {
     39             Self::PrfWithoutUserVerification => {
     40                 "prf extension was requested without requiring user verification"
     41             }
     42             Self::InvalidTimeout => "the timeout could not be added to the current Instant",
     43         })
     44     }
     45 }
     46 impl Error for RequestOptionsErr {}