use passkey_types::ctap2::{StatusCode, get_assertion, get_info, make_credential};
use crate::{Authenticator, CredentialStore, UserValidationMethod};
mod sealed {
use crate::{Authenticator, CredentialStore, UserValidationMethod};
pub trait Sealed {}
impl<S: CredentialStore, U: UserValidationMethod> Sealed for Authenticator<S, U> {}
}
#[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> Ctap2Api for Authenticator<S, U>
where
S: CredentialStore + Sync + Send,
U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + 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
}
}