Skip to main content

passkey_authenticator/authenticator/
get_info.rs

1use passkey_crypto::CryptoBackend;
2use passkey_types::{
3    ctap2::get_info::{Options, Response, Version},
4    webauthn::PublicKeyCredentialParameters,
5};
6
7use crate::{
8    Authenticator, CredentialStore, UserValidationMethod, credential_store::DiscoverabilitySupport,
9};
10
11impl<S, U, C> Authenticator<S, U, C>
12where
13    S: CredentialStore,
14    U: UserValidationMethod,
15    C: CryptoBackend,
16{
17    /// Using this method, the host can request that the authenticator report a list of all
18    /// supported protocol versions, supported extensions, AAGUID of the device, and its capabilities.
19    pub async fn get_info(&self) -> Box<Response> {
20        Box::new(Response {
21            versions: vec![Version::FIDO_2_0, Version::FIDO_2_1],
22            extensions: self.extensions.list_extensions(),
23            aaguid: *self.aaguid(),
24            options: Some(Options {
25                rk: self.store.get_info().await.discoverability
26                    != DiscoverabilitySupport::OnlyNonDiscoverable,
27                uv: self.user_validation.is_verification_enabled(),
28                up: self.user_validation.is_presence_enabled(),
29                ..Default::default()
30            }),
31            max_msg_size: None,
32            pin_protocols: None,
33            transports: Some(self.transports.clone()),
34            algorithms: Some(
35                self.algs
36                    .iter()
37                    .copied()
38                    .map(PublicKeyCredentialParameters::from)
39                    .collect(),
40            ),
41            ..Default::default()
42        })
43    }
44}