passkey_authenticator/
ctap2.rs1use passkey_types::ctap2::{StatusCode, get_assertion, get_info, make_credential};
9
10use crate::{Authenticator, CredentialStore, UserValidationMethod};
11
12mod sealed {
13 use crate::{Authenticator, CredentialStore, UserValidationMethod};
14
15 pub trait Sealed {}
16
17 impl<S: CredentialStore, U: UserValidationMethod> Sealed for Authenticator<S, U> {}
18}
19
20#[async_trait::async_trait]
31pub trait Ctap2Api: sealed::Sealed {
32 async fn get_info(&self) -> Box<get_info::Response>;
34
35 async fn make_credential(
37 &mut self,
38 request: make_credential::Request,
39 ) -> Result<make_credential::Response, StatusCode>;
40
41 async fn get_assertion(
43 &mut self,
44 request: get_assertion::Request,
45 ) -> Result<get_assertion::Response, StatusCode>;
46}
47
48#[async_trait::async_trait]
49impl<S, U> Ctap2Api for Authenticator<S, U>
50where
51 S: CredentialStore + Sync + Send,
52 U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Sync + Send,
53{
54 async fn get_info(&self) -> Box<get_info::Response> {
55 Authenticator::get_info(self).await
56 }
57
58 async fn make_credential(
59 &mut self,
60 request: make_credential::Request,
61 ) -> Result<make_credential::Response, StatusCode> {
62 Authenticator::make_credential(self, request).await
63 }
64
65 async fn get_assertion(
66 &mut self,
67 request: get_assertion::Request,
68 ) -> Result<get_assertion::Response, StatusCode> {
69 Authenticator::get_assertion(self, request).await
70 }
71}