use passkey_crypto::CryptoBackend;
use passkey_types::ctap2::{StatusCode, get_assertion, get_info, make_credential};
use crate::{Authenticator, CredentialStore, UserValidationMethod};
mod sealed {
use super::{Authenticator, CredentialStore, CryptoBackend, UserValidationMethod};
pub trait Sealed {}
#[cfg(all(feature = "linux", target_os = "linux"))]
impl Sealed for crate::linux::LinuxAuthenticator {}
impl<S: CredentialStore, U: UserValidationMethod, C: CryptoBackend> Sealed
for Authenticator<S, U, C>
{
}
}
#[async_trait::async_trait]
pub trait Ctap2Api: sealed::Sealed {
async fn get_info(&self) -> Box<get_info::Response>;
async fn make_credential(
&mut self,
request: make_credential::Request,
) -> Result<make_credential::Response, StatusCode>;
async fn get_assertion(
&mut self,
request: get_assertion::Request,
) -> Result<get_assertion::Response, StatusCode>;
}
#[async_trait::async_trait]
impl<S, U, C> Ctap2Api for Authenticator<S, U, C>
where
S: CredentialStore + Sync + Send,
U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Sync + Send,
C: CryptoBackend<SecretKey: Sync + Send> + Sync + Send,
{
async fn get_info(&self) -> Box<get_info::Response> {
Authenticator::get_info(self).await
}
async fn make_credential(
&mut self,
request: make_credential::Request,
) -> Result<make_credential::Response, StatusCode> {
Authenticator::make_credential(self, request).await
}
async fn get_assertion(
&mut self,
request: get_assertion::Request,
) -> Result<get_assertion::Response, StatusCode> {
Authenticator::get_assertion(self, request).await
}
}