passkey_authenticator/authenticator/
get_info.rs

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