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, Self: FromIdlModel<Self::IdlModel, E>,
{
type Error: std::error::Error + From<JsonError> + From<E>;
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>;
}