soft_fido2/
options.rs

1/// Authenticator options for controlling device capabilities
2#[derive(Debug, Clone)]
3pub struct AuthenticatorOptions {
4    /// Resident key (discoverable credentials) support
5    pub rk: bool,
6
7    /// User presence capable
8    pub up: bool,
9
10    /// User verification capability
11    pub uv: Option<bool>,
12
13    /// Platform device (cannot be removed)
14    pub plat: bool,
15
16    /// Client PIN capability. When `Some(true)` and UV is available, the
17    /// browser/client may defer verification to the authenticator instead of
18    /// prompting the user locally.
19    pub client_pin: Option<bool>,
20
21    /// PIN/UV auth token support
22    pub pin_uv_auth_token: Option<bool>,
23
24    /// Credential management support
25    pub cred_mgmt: Option<bool>,
26
27    /// Biometric enrollment support
28    pub bio_enroll: Option<bool>,
29
30    /// Large blobs support
31    pub large_blobs: Option<bool>,
32
33    /// Enterprise attestation
34    pub ep: Option<bool>,
35
36    /// Always require user verification
37    pub always_uv: Option<bool>,
38
39    /// Make credential without UV (makeCredUvNotRqd)
40    ///
41    /// When true, indicates that the authenticator can create credentials
42    /// without performing UV when UV is not required by the relying party.
43    /// This provides more flexible UV behavior for testing.
44    pub make_cred_uv_not_required: Option<bool>,
45}
46
47impl Default for AuthenticatorOptions {
48    fn default() -> Self {
49        Self {
50            rk: true,
51            up: true,
52            uv: None,
53            plat: false,
54            client_pin: Some(true),
55            pin_uv_auth_token: Some(true),
56            cred_mgmt: None,
57            bio_enroll: None,
58            large_blobs: None,
59            ep: None,
60            always_uv: None,
61            make_cred_uv_not_required: None,
62        }
63    }
64}
65
66impl AuthenticatorOptions {
67    /// Create new options with default values
68    pub fn new() -> Self {
69        Self::default()
70    }
71
72    /// Set resident key support
73    pub fn with_resident_keys(mut self, enabled: bool) -> Self {
74        self.rk = enabled;
75        self
76    }
77
78    /// Set user presence capability
79    pub fn with_user_presence(mut self, enabled: bool) -> Self {
80        self.up = enabled;
81        self
82    }
83
84    /// Set user verification capability
85    pub fn with_user_verification(mut self, state: Option<bool>) -> Self {
86        self.uv = state;
87        self
88    }
89
90    /// Set platform device flag
91    pub fn with_platform_device(mut self, is_platform: bool) -> Self {
92        self.plat = is_platform;
93        self
94    }
95
96    /// Set client PIN capability
97    pub fn with_client_pin(mut self, state: Option<bool>) -> Self {
98        self.client_pin = state;
99        self
100    }
101
102    /// Set PIN/UV auth token support
103    pub fn with_pin_uv_auth_token(mut self, state: Option<bool>) -> Self {
104        self.pin_uv_auth_token = state;
105        self
106    }
107
108    /// Set credential management support
109    pub fn with_credential_management(mut self, state: Option<bool>) -> Self {
110        self.cred_mgmt = state;
111        self
112    }
113
114    /// Set biometric enrollment support
115    pub fn with_biometric_enrollment(mut self, state: Option<bool>) -> Self {
116        self.bio_enroll = state;
117        self
118    }
119
120    /// Set large blobs support
121    pub fn with_large_blobs(mut self, state: Option<bool>) -> Self {
122        self.large_blobs = state;
123        self
124    }
125
126    /// Set enterprise attestation support
127    pub fn with_enterprise_attestation(mut self, state: Option<bool>) -> Self {
128        self.ep = state;
129        self
130    }
131
132    /// Set always require user verification
133    pub fn with_always_uv(mut self, state: Option<bool>) -> Self {
134        self.always_uv = state;
135        self
136    }
137
138    /// Set make credential without UV support
139    pub fn with_make_cred_uv_not_required(mut self, state: Option<bool>) -> Self {
140        self.make_cred_uv_not_required = state;
141        self
142    }
143}