libwebauthn 0.5.1

FIDO2 (WebAuthn) and FIDO U2F platform library for Linux written in Rust
Documentation
mod base64url;
pub mod create;
pub mod get;
pub mod origin;
pub mod response;
pub mod rpid;

pub use base64url::Base64UrlString;
pub use response::{
    AuthenticationExtensionsClientOutputsJSON, AuthenticationResponseJSON,
    AuthenticatorAssertionResponseJSON, AuthenticatorAttestationResponseJSON,
    CredentialPropertiesOutputJSON, HMACGetSecretOutputJSON, JsonFormat, LargeBlobOutputJSON,
    PRFOutputJSON, PRFValuesJSON, RegistrationResponseJSON, ResponseSerializationError,
    WebAuthnIDLResponse,
};

use origin::RequestOrigin;

use super::psl::PublicSuffixList;

use serde::de::DeserializeOwned;
use serde_json;

pub type JsonError = serde_json::Error;

pub trait WebAuthnIDL<E>: Sized
where
    E: std::error::Error, // Validation error type.
    Self: FromIdlModel<Self::IdlModel, E>,
{
    /// An error type that can be returned when deserializing from JSON, including
    /// JSON parsing errors and any additional validation errors.
    type Error: std::error::Error + From<JsonError> + From<E>;

    /// The JSON model that this IDL can deserialize from.
    type IdlModel: DeserializeOwned;

    fn from_json(
        request_origin: &RequestOrigin,
        psl: &dyn PublicSuffixList,
        json: &str,
    ) -> Result<Self, Self::Error> {
        let idl_model: Self::IdlModel = serde_json::from_str(json)?;
        Self::from_idl_model(request_origin, psl, idl_model).map_err(From::from)
    }
}

pub trait FromIdlModel<T, E>: Sized
where
    T: DeserializeOwned,
    E: std::error::Error,
{
    fn from_idl_model(
        request_origin: &RequestOrigin,
        psl: &dyn PublicSuffixList,
        model: T,
    ) -> Result<Self, E>;
}