Skip to main content

browser_protocol/webauthn/
mod.rs

1//! This domain allows configuring virtual authenticators to test the WebAuthn
2//! API.
3
4
5use serde::{Serialize, Deserialize};
6use serde_json::Value as JsonValue;
7use std::borrow::Cow;
8
9
10pub type AuthenticatorId<'a> = Cow<'a, str>;
11
12
13#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
14pub enum AuthenticatorProtocol {
15    #[default]
16    #[serde(rename = "u2f")]
17    U2f,
18    #[serde(rename = "ctap2")]
19    Ctap2,
20}
21
22
23#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
24pub enum Ctap2Version {
25    #[default]
26    #[serde(rename = "ctap2_0")]
27    Ctap20,
28    #[serde(rename = "ctap2_1")]
29    Ctap21,
30    #[serde(rename = "ctap2_2")]
31    Ctap22,
32}
33
34
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
36pub enum AuthenticatorTransport {
37    #[default]
38    #[serde(rename = "usb")]
39    Usb,
40    #[serde(rename = "nfc")]
41    Nfc,
42    #[serde(rename = "ble")]
43    Ble,
44    #[serde(rename = "cable")]
45    Cable,
46    #[serde(rename = "internal")]
47    Internal,
48}
49
50
51#[derive(Debug, Clone, Serialize, Deserialize, Default)]
52#[serde(rename_all = "camelCase")]
53pub struct VirtualAuthenticatorOptions {
54    protocol: AuthenticatorProtocol,
55    /// Defaults to ctap2_0. Ignored if |protocol| == u2f.
56    #[serde(skip_serializing_if = "Option::is_none", rename = "ctap2Version")]
57    ctap2_version: Option<Ctap2Version>,
58    transport: AuthenticatorTransport,
59    /// Defaults to false.
60    #[serde(skip_serializing_if = "Option::is_none", rename = "hasResidentKey")]
61    has_resident_key: Option<bool>,
62    /// Defaults to false.
63    #[serde(skip_serializing_if = "Option::is_none", rename = "hasUserVerification")]
64    has_user_verification: Option<bool>,
65    /// If set to true, the authenticator will support the largeBlob extension.
66    /// <https://w3c.github.io/webauthn#largeBlob>
67    /// Defaults to false.
68    #[serde(skip_serializing_if = "Option::is_none", rename = "hasLargeBlob")]
69    has_large_blob: Option<bool>,
70    /// If set to true, the authenticator will support the credBlob extension.
71    /// <https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension>
72    /// Defaults to false.
73    #[serde(skip_serializing_if = "Option::is_none", rename = "hasCredBlob")]
74    has_cred_blob: Option<bool>,
75    /// If set to true, the authenticator will support the minPinLength extension.
76    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension>
77    /// Defaults to false.
78    #[serde(skip_serializing_if = "Option::is_none", rename = "hasMinPinLength")]
79    has_min_pin_length: Option<bool>,
80    /// If set to true, the authenticator will support the prf extension.
81    /// <https://w3c.github.io/webauthn/#prf-extension>
82    /// Defaults to false.
83    #[serde(skip_serializing_if = "Option::is_none", rename = "hasPrf")]
84    has_prf: Option<bool>,
85    /// If set to true, the authenticator will support the hmac-secret extension.
86    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension>
87    /// Defaults to false.
88    #[serde(skip_serializing_if = "Option::is_none", rename = "hasHmacSecret")]
89    has_hmac_secret: Option<bool>,
90    /// If set to true, the authenticator will support the hmac-secret-mc extension.
91    /// <https://fidoalliance.org/specs/fido-v2.2-rd-20241003/fido-client-to-authenticator-protocol-v2.2-rd-20241003.html#sctn-hmac-secret-make-cred-extension>
92    /// Defaults to false.
93    #[serde(skip_serializing_if = "Option::is_none", rename = "hasHmacSecretMc")]
94    has_hmac_secret_mc: Option<bool>,
95    /// If set to true, tests of user presence will succeed immediately.
96    /// Otherwise, they will not be resolved. Defaults to true.
97    #[serde(skip_serializing_if = "Option::is_none", rename = "automaticPresenceSimulation")]
98    automatic_presence_simulation: Option<bool>,
99    /// Sets whether User Verification succeeds or fails for an authenticator.
100    /// Defaults to false.
101    #[serde(skip_serializing_if = "Option::is_none", rename = "isUserVerified")]
102    is_user_verified: Option<bool>,
103    /// Credentials created by this authenticator will have the backup
104    /// eligibility (BE) flag set to this value. Defaults to false.
105    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
106    #[serde(skip_serializing_if = "Option::is_none", rename = "defaultBackupEligibility")]
107    default_backup_eligibility: Option<bool>,
108    /// Credentials created by this authenticator will have the backup state
109    /// (BS) flag set to this value. Defaults to false.
110    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
111    #[serde(skip_serializing_if = "Option::is_none", rename = "defaultBackupState")]
112    default_backup_state: Option<bool>,
113}
114
115impl VirtualAuthenticatorOptions {
116    /// Creates a builder for this type with the required parameters:
117    /// * `protocol`: 
118    /// * `transport`: 
119    pub fn builder(protocol: impl Into<AuthenticatorProtocol>, transport: impl Into<AuthenticatorTransport>) -> VirtualAuthenticatorOptionsBuilder {
120        VirtualAuthenticatorOptionsBuilder {
121            protocol: protocol.into(),
122            ctap2_version: None,
123            transport: transport.into(),
124            has_resident_key: None,
125            has_user_verification: None,
126            has_large_blob: None,
127            has_cred_blob: None,
128            has_min_pin_length: None,
129            has_prf: None,
130            has_hmac_secret: None,
131            has_hmac_secret_mc: None,
132            automatic_presence_simulation: None,
133            is_user_verified: None,
134            default_backup_eligibility: None,
135            default_backup_state: None,
136        }
137    }
138    pub fn protocol(&self) -> &AuthenticatorProtocol { &self.protocol }
139    /// Defaults to ctap2_0. Ignored if |protocol| == u2f.
140    pub fn ctap2_version(&self) -> Option<&Ctap2Version> { self.ctap2_version.as_ref() }
141    pub fn transport(&self) -> &AuthenticatorTransport { &self.transport }
142    /// Defaults to false.
143    pub fn has_resident_key(&self) -> Option<bool> { self.has_resident_key }
144    /// Defaults to false.
145    pub fn has_user_verification(&self) -> Option<bool> { self.has_user_verification }
146    /// If set to true, the authenticator will support the largeBlob extension.
147    /// <https://w3c.github.io/webauthn#largeBlob>
148    /// Defaults to false.
149    pub fn has_large_blob(&self) -> Option<bool> { self.has_large_blob }
150    /// If set to true, the authenticator will support the credBlob extension.
151    /// <https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension>
152    /// Defaults to false.
153    pub fn has_cred_blob(&self) -> Option<bool> { self.has_cred_blob }
154    /// If set to true, the authenticator will support the minPinLength extension.
155    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension>
156    /// Defaults to false.
157    pub fn has_min_pin_length(&self) -> Option<bool> { self.has_min_pin_length }
158    /// If set to true, the authenticator will support the prf extension.
159    /// <https://w3c.github.io/webauthn/#prf-extension>
160    /// Defaults to false.
161    pub fn has_prf(&self) -> Option<bool> { self.has_prf }
162    /// If set to true, the authenticator will support the hmac-secret extension.
163    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension>
164    /// Defaults to false.
165    pub fn has_hmac_secret(&self) -> Option<bool> { self.has_hmac_secret }
166    /// If set to true, the authenticator will support the hmac-secret-mc extension.
167    /// <https://fidoalliance.org/specs/fido-v2.2-rd-20241003/fido-client-to-authenticator-protocol-v2.2-rd-20241003.html#sctn-hmac-secret-make-cred-extension>
168    /// Defaults to false.
169    pub fn has_hmac_secret_mc(&self) -> Option<bool> { self.has_hmac_secret_mc }
170    /// If set to true, tests of user presence will succeed immediately.
171    /// Otherwise, they will not be resolved. Defaults to true.
172    pub fn automatic_presence_simulation(&self) -> Option<bool> { self.automatic_presence_simulation }
173    /// Sets whether User Verification succeeds or fails for an authenticator.
174    /// Defaults to false.
175    pub fn is_user_verified(&self) -> Option<bool> { self.is_user_verified }
176    /// Credentials created by this authenticator will have the backup
177    /// eligibility (BE) flag set to this value. Defaults to false.
178    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
179    pub fn default_backup_eligibility(&self) -> Option<bool> { self.default_backup_eligibility }
180    /// Credentials created by this authenticator will have the backup state
181    /// (BS) flag set to this value. Defaults to false.
182    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
183    pub fn default_backup_state(&self) -> Option<bool> { self.default_backup_state }
184}
185
186
187pub struct VirtualAuthenticatorOptionsBuilder {
188    protocol: AuthenticatorProtocol,
189    ctap2_version: Option<Ctap2Version>,
190    transport: AuthenticatorTransport,
191    has_resident_key: Option<bool>,
192    has_user_verification: Option<bool>,
193    has_large_blob: Option<bool>,
194    has_cred_blob: Option<bool>,
195    has_min_pin_length: Option<bool>,
196    has_prf: Option<bool>,
197    has_hmac_secret: Option<bool>,
198    has_hmac_secret_mc: Option<bool>,
199    automatic_presence_simulation: Option<bool>,
200    is_user_verified: Option<bool>,
201    default_backup_eligibility: Option<bool>,
202    default_backup_state: Option<bool>,
203}
204
205impl VirtualAuthenticatorOptionsBuilder {
206    /// Defaults to ctap2_0. Ignored if |protocol| == u2f.
207    pub fn ctap2_version(mut self, ctap2_version: impl Into<Ctap2Version>) -> Self { self.ctap2_version = Some(ctap2_version.into()); self }
208    /// Defaults to false.
209    pub fn has_resident_key(mut self, has_resident_key: bool) -> Self { self.has_resident_key = Some(has_resident_key); self }
210    /// Defaults to false.
211    pub fn has_user_verification(mut self, has_user_verification: bool) -> Self { self.has_user_verification = Some(has_user_verification); self }
212    /// If set to true, the authenticator will support the largeBlob extension.
213    /// <https://w3c.github.io/webauthn#largeBlob>
214    /// Defaults to false.
215    pub fn has_large_blob(mut self, has_large_blob: bool) -> Self { self.has_large_blob = Some(has_large_blob); self }
216    /// If set to true, the authenticator will support the credBlob extension.
217    /// <https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension>
218    /// Defaults to false.
219    pub fn has_cred_blob(mut self, has_cred_blob: bool) -> Self { self.has_cred_blob = Some(has_cred_blob); self }
220    /// If set to true, the authenticator will support the minPinLength extension.
221    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension>
222    /// Defaults to false.
223    pub fn has_min_pin_length(mut self, has_min_pin_length: bool) -> Self { self.has_min_pin_length = Some(has_min_pin_length); self }
224    /// If set to true, the authenticator will support the prf extension.
225    /// <https://w3c.github.io/webauthn/#prf-extension>
226    /// Defaults to false.
227    pub fn has_prf(mut self, has_prf: bool) -> Self { self.has_prf = Some(has_prf); self }
228    /// If set to true, the authenticator will support the hmac-secret extension.
229    /// <https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension>
230    /// Defaults to false.
231    pub fn has_hmac_secret(mut self, has_hmac_secret: bool) -> Self { self.has_hmac_secret = Some(has_hmac_secret); self }
232    /// If set to true, the authenticator will support the hmac-secret-mc extension.
233    /// <https://fidoalliance.org/specs/fido-v2.2-rd-20241003/fido-client-to-authenticator-protocol-v2.2-rd-20241003.html#sctn-hmac-secret-make-cred-extension>
234    /// Defaults to false.
235    pub fn has_hmac_secret_mc(mut self, has_hmac_secret_mc: bool) -> Self { self.has_hmac_secret_mc = Some(has_hmac_secret_mc); self }
236    /// If set to true, tests of user presence will succeed immediately.
237    /// Otherwise, they will not be resolved. Defaults to true.
238    pub fn automatic_presence_simulation(mut self, automatic_presence_simulation: bool) -> Self { self.automatic_presence_simulation = Some(automatic_presence_simulation); self }
239    /// Sets whether User Verification succeeds or fails for an authenticator.
240    /// Defaults to false.
241    pub fn is_user_verified(mut self, is_user_verified: bool) -> Self { self.is_user_verified = Some(is_user_verified); self }
242    /// Credentials created by this authenticator will have the backup
243    /// eligibility (BE) flag set to this value. Defaults to false.
244    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
245    pub fn default_backup_eligibility(mut self, default_backup_eligibility: bool) -> Self { self.default_backup_eligibility = Some(default_backup_eligibility); self }
246    /// Credentials created by this authenticator will have the backup state
247    /// (BS) flag set to this value. Defaults to false.
248    /// <https://w3c.github.io/webauthn/#sctn-credential-backup>
249    pub fn default_backup_state(mut self, default_backup_state: bool) -> Self { self.default_backup_state = Some(default_backup_state); self }
250    pub fn build(self) -> VirtualAuthenticatorOptions {
251        VirtualAuthenticatorOptions {
252            protocol: self.protocol,
253            ctap2_version: self.ctap2_version,
254            transport: self.transport,
255            has_resident_key: self.has_resident_key,
256            has_user_verification: self.has_user_verification,
257            has_large_blob: self.has_large_blob,
258            has_cred_blob: self.has_cred_blob,
259            has_min_pin_length: self.has_min_pin_length,
260            has_prf: self.has_prf,
261            has_hmac_secret: self.has_hmac_secret,
262            has_hmac_secret_mc: self.has_hmac_secret_mc,
263            automatic_presence_simulation: self.automatic_presence_simulation,
264            is_user_verified: self.is_user_verified,
265            default_backup_eligibility: self.default_backup_eligibility,
266            default_backup_state: self.default_backup_state,
267        }
268    }
269}
270
271
272#[derive(Debug, Clone, Serialize, Deserialize, Default)]
273#[serde(rename_all = "camelCase")]
274pub struct Credential<'a> {
275    #[serde(rename = "credentialId")]
276    credential_id: Cow<'a, str>,
277    #[serde(rename = "isResidentCredential")]
278    is_resident_credential: bool,
279    /// Relying Party ID the credential is scoped to. Must be set when adding a
280    /// credential.
281    #[serde(skip_serializing_if = "Option::is_none", rename = "rpId")]
282    rp_id: Option<Cow<'a, str>>,
283    /// The ECDSA P-256 private key in PKCS#8 format. (Encoded as a base64 string when passed over JSON)
284    #[serde(rename = "privateKey")]
285    private_key: Cow<'a, str>,
286    /// An opaque byte sequence with a maximum size of 64 bytes mapping the
287    /// credential to a specific user. (Encoded as a base64 string when passed over JSON)
288    #[serde(skip_serializing_if = "Option::is_none", rename = "userHandle")]
289    user_handle: Option<Cow<'a, str>>,
290    /// Signature counter. This is incremented by one for each successful
291    /// assertion.
292    /// See <https://w3c.github.io/webauthn/#signature-counter>
293    #[serde(rename = "signCount")]
294    sign_count: u64,
295    /// The large blob associated with the credential.
296    /// See <https://w3c.github.io/webauthn/#sctn-large-blob-extension> (Encoded as a base64 string when passed over JSON)
297    #[serde(skip_serializing_if = "Option::is_none", rename = "largeBlob")]
298    large_blob: Option<Cow<'a, str>>,
299    /// Assertions returned by this credential will have the backup eligibility
300    /// (BE) flag set to this value. Defaults to the authenticator's
301    /// defaultBackupEligibility value.
302    #[serde(skip_serializing_if = "Option::is_none", rename = "backupEligibility")]
303    backup_eligibility: Option<bool>,
304    /// Assertions returned by this credential will have the backup state (BS)
305    /// flag set to this value. Defaults to the authenticator's
306    /// defaultBackupState value.
307    #[serde(skip_serializing_if = "Option::is_none", rename = "backupState")]
308    backup_state: Option<bool>,
309    /// The credential's user.name property. Equivalent to empty if not set.
310    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name>
311    #[serde(skip_serializing_if = "Option::is_none", rename = "userName")]
312    user_name: Option<Cow<'a, str>>,
313    /// The credential's user.displayName property. Equivalent to empty if
314    /// not set.
315    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname>
316    #[serde(skip_serializing_if = "Option::is_none", rename = "userDisplayName")]
317    user_display_name: Option<Cow<'a, str>>,
318}
319
320impl<'a> Credential<'a> {
321    /// Creates a builder for this type with the required parameters:
322    /// * `credential_id`: 
323    /// * `is_resident_credential`: 
324    /// * `private_key`: The ECDSA P-256 private key in PKCS#8 format. (Encoded as a base64 string when passed over JSON)
325    /// * `sign_count`: Signature counter. This is incremented by one for each successful assertion. See <https://w3c.github.io/webauthn/#signature-counter>
326    pub fn builder(credential_id: impl Into<Cow<'a, str>>, is_resident_credential: bool, private_key: impl Into<Cow<'a, str>>, sign_count: u64) -> CredentialBuilder<'a> {
327        CredentialBuilder {
328            credential_id: credential_id.into(),
329            is_resident_credential: is_resident_credential,
330            rp_id: None,
331            private_key: private_key.into(),
332            user_handle: None,
333            sign_count: sign_count,
334            large_blob: None,
335            backup_eligibility: None,
336            backup_state: None,
337            user_name: None,
338            user_display_name: None,
339        }
340    }
341    pub fn credential_id(&self) -> &str { self.credential_id.as_ref() }
342    pub fn is_resident_credential(&self) -> bool { self.is_resident_credential }
343    /// Relying Party ID the credential is scoped to. Must be set when adding a
344    /// credential.
345    pub fn rp_id(&self) -> Option<&str> { self.rp_id.as_deref() }
346    /// The ECDSA P-256 private key in PKCS#8 format. (Encoded as a base64 string when passed over JSON)
347    pub fn private_key(&self) -> &str { self.private_key.as_ref() }
348    /// An opaque byte sequence with a maximum size of 64 bytes mapping the
349    /// credential to a specific user. (Encoded as a base64 string when passed over JSON)
350    pub fn user_handle(&self) -> Option<&str> { self.user_handle.as_deref() }
351    /// Signature counter. This is incremented by one for each successful
352    /// assertion.
353    /// See <https://w3c.github.io/webauthn/#signature-counter>
354    pub fn sign_count(&self) -> u64 { self.sign_count }
355    /// The large blob associated with the credential.
356    /// See <https://w3c.github.io/webauthn/#sctn-large-blob-extension> (Encoded as a base64 string when passed over JSON)
357    pub fn large_blob(&self) -> Option<&str> { self.large_blob.as_deref() }
358    /// Assertions returned by this credential will have the backup eligibility
359    /// (BE) flag set to this value. Defaults to the authenticator's
360    /// defaultBackupEligibility value.
361    pub fn backup_eligibility(&self) -> Option<bool> { self.backup_eligibility }
362    /// Assertions returned by this credential will have the backup state (BS)
363    /// flag set to this value. Defaults to the authenticator's
364    /// defaultBackupState value.
365    pub fn backup_state(&self) -> Option<bool> { self.backup_state }
366    /// The credential's user.name property. Equivalent to empty if not set.
367    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name>
368    pub fn user_name(&self) -> Option<&str> { self.user_name.as_deref() }
369    /// The credential's user.displayName property. Equivalent to empty if
370    /// not set.
371    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname>
372    pub fn user_display_name(&self) -> Option<&str> { self.user_display_name.as_deref() }
373}
374
375
376pub struct CredentialBuilder<'a> {
377    credential_id: Cow<'a, str>,
378    is_resident_credential: bool,
379    rp_id: Option<Cow<'a, str>>,
380    private_key: Cow<'a, str>,
381    user_handle: Option<Cow<'a, str>>,
382    sign_count: u64,
383    large_blob: Option<Cow<'a, str>>,
384    backup_eligibility: Option<bool>,
385    backup_state: Option<bool>,
386    user_name: Option<Cow<'a, str>>,
387    user_display_name: Option<Cow<'a, str>>,
388}
389
390impl<'a> CredentialBuilder<'a> {
391    /// Relying Party ID the credential is scoped to. Must be set when adding a
392    /// credential.
393    pub fn rp_id(mut self, rp_id: impl Into<Cow<'a, str>>) -> Self { self.rp_id = Some(rp_id.into()); self }
394    /// An opaque byte sequence with a maximum size of 64 bytes mapping the
395    /// credential to a specific user. (Encoded as a base64 string when passed over JSON)
396    pub fn user_handle(mut self, user_handle: impl Into<Cow<'a, str>>) -> Self { self.user_handle = Some(user_handle.into()); self }
397    /// The large blob associated with the credential.
398    /// See <https://w3c.github.io/webauthn/#sctn-large-blob-extension> (Encoded as a base64 string when passed over JSON)
399    pub fn large_blob(mut self, large_blob: impl Into<Cow<'a, str>>) -> Self { self.large_blob = Some(large_blob.into()); self }
400    /// Assertions returned by this credential will have the backup eligibility
401    /// (BE) flag set to this value. Defaults to the authenticator's
402    /// defaultBackupEligibility value.
403    pub fn backup_eligibility(mut self, backup_eligibility: bool) -> Self { self.backup_eligibility = Some(backup_eligibility); self }
404    /// Assertions returned by this credential will have the backup state (BS)
405    /// flag set to this value. Defaults to the authenticator's
406    /// defaultBackupState value.
407    pub fn backup_state(mut self, backup_state: bool) -> Self { self.backup_state = Some(backup_state); self }
408    /// The credential's user.name property. Equivalent to empty if not set.
409    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name>
410    pub fn user_name(mut self, user_name: impl Into<Cow<'a, str>>) -> Self { self.user_name = Some(user_name.into()); self }
411    /// The credential's user.displayName property. Equivalent to empty if
412    /// not set.
413    /// <https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname>
414    pub fn user_display_name(mut self, user_display_name: impl Into<Cow<'a, str>>) -> Self { self.user_display_name = Some(user_display_name.into()); self }
415    pub fn build(self) -> Credential<'a> {
416        Credential {
417            credential_id: self.credential_id,
418            is_resident_credential: self.is_resident_credential,
419            rp_id: self.rp_id,
420            private_key: self.private_key,
421            user_handle: self.user_handle,
422            sign_count: self.sign_count,
423            large_blob: self.large_blob,
424            backup_eligibility: self.backup_eligibility,
425            backup_state: self.backup_state,
426            user_name: self.user_name,
427            user_display_name: self.user_display_name,
428        }
429    }
430}
431
432/// Enable the WebAuthn domain and start intercepting credential storage and
433/// retrieval with a virtual authenticator.
434
435#[derive(Debug, Clone, Serialize, Deserialize, Default)]
436#[serde(rename_all = "camelCase")]
437pub struct EnableParams {
438    /// Whether to enable the WebAuthn user interface. Enabling the UI is
439    /// recommended for debugging and demo purposes, as it is closer to the real
440    /// experience. Disabling the UI is recommended for automated testing.
441    /// Supported at the embedder's discretion if UI is available.
442    /// Defaults to false.
443    #[serde(skip_serializing_if = "Option::is_none", rename = "enableUI")]
444    enable_ui: Option<bool>,
445}
446
447impl EnableParams {
448    /// Creates a builder for this type.
449    pub fn builder() -> EnableParamsBuilder {
450        EnableParamsBuilder {
451            enable_ui: None,
452        }
453    }
454    /// Whether to enable the WebAuthn user interface. Enabling the UI is
455    /// recommended for debugging and demo purposes, as it is closer to the real
456    /// experience. Disabling the UI is recommended for automated testing.
457    /// Supported at the embedder's discretion if UI is available.
458    /// Defaults to false.
459    pub fn enable_ui(&self) -> Option<bool> { self.enable_ui }
460}
461
462#[derive(Default)]
463pub struct EnableParamsBuilder {
464    enable_ui: Option<bool>,
465}
466
467impl EnableParamsBuilder {
468    /// Whether to enable the WebAuthn user interface. Enabling the UI is
469    /// recommended for debugging and demo purposes, as it is closer to the real
470    /// experience. Disabling the UI is recommended for automated testing.
471    /// Supported at the embedder's discretion if UI is available.
472    /// Defaults to false.
473    pub fn enable_ui(mut self, enable_ui: bool) -> Self { self.enable_ui = Some(enable_ui); self }
474    pub fn build(self) -> EnableParams {
475        EnableParams {
476            enable_ui: self.enable_ui,
477        }
478    }
479}
480
481impl EnableParams { pub const METHOD: &'static str = "WebAuthn.enable"; }
482
483impl<'a> crate::CdpCommand<'a> for EnableParams {
484    const METHOD: &'static str = "WebAuthn.enable";
485    type Response = crate::EmptyReturns;
486}
487
488#[derive(Debug, Clone, Serialize, Deserialize, Default)]
489pub struct DisableParams {}
490
491impl DisableParams { pub const METHOD: &'static str = "WebAuthn.disable"; }
492
493impl<'a> crate::CdpCommand<'a> for DisableParams {
494    const METHOD: &'static str = "WebAuthn.disable";
495    type Response = crate::EmptyReturns;
496}
497
498/// Creates and adds a virtual authenticator.
499
500#[derive(Debug, Clone, Serialize, Deserialize, Default)]
501#[serde(rename_all = "camelCase")]
502pub struct AddVirtualAuthenticatorParams {
503    options: VirtualAuthenticatorOptions,
504}
505
506impl AddVirtualAuthenticatorParams {
507    /// Creates a builder for this type with the required parameters:
508    /// * `options`: 
509    pub fn builder(options: VirtualAuthenticatorOptions) -> AddVirtualAuthenticatorParamsBuilder {
510        AddVirtualAuthenticatorParamsBuilder {
511            options: options,
512        }
513    }
514    pub fn options(&self) -> &VirtualAuthenticatorOptions { &self.options }
515}
516
517
518pub struct AddVirtualAuthenticatorParamsBuilder {
519    options: VirtualAuthenticatorOptions,
520}
521
522impl AddVirtualAuthenticatorParamsBuilder {
523    pub fn build(self) -> AddVirtualAuthenticatorParams {
524        AddVirtualAuthenticatorParams {
525            options: self.options,
526        }
527    }
528}
529
530/// Creates and adds a virtual authenticator.
531
532#[derive(Debug, Clone, Serialize, Deserialize, Default)]
533#[serde(rename_all = "camelCase")]
534pub struct AddVirtualAuthenticatorReturns<'a> {
535    #[serde(rename = "authenticatorId")]
536    authenticator_id: AuthenticatorId<'a>,
537}
538
539impl<'a> AddVirtualAuthenticatorReturns<'a> {
540    /// Creates a builder for this type with the required parameters:
541    /// * `authenticator_id`: 
542    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>) -> AddVirtualAuthenticatorReturnsBuilder<'a> {
543        AddVirtualAuthenticatorReturnsBuilder {
544            authenticator_id: authenticator_id.into(),
545        }
546    }
547    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
548}
549
550
551pub struct AddVirtualAuthenticatorReturnsBuilder<'a> {
552    authenticator_id: AuthenticatorId<'a>,
553}
554
555impl<'a> AddVirtualAuthenticatorReturnsBuilder<'a> {
556    pub fn build(self) -> AddVirtualAuthenticatorReturns<'a> {
557        AddVirtualAuthenticatorReturns {
558            authenticator_id: self.authenticator_id,
559        }
560    }
561}
562
563impl AddVirtualAuthenticatorParams { pub const METHOD: &'static str = "WebAuthn.addVirtualAuthenticator"; }
564
565impl<'a> crate::CdpCommand<'a> for AddVirtualAuthenticatorParams {
566    const METHOD: &'static str = "WebAuthn.addVirtualAuthenticator";
567    type Response = AddVirtualAuthenticatorReturns<'a>;
568}
569
570/// Resets parameters isBogusSignature, isBadUV, isBadUP to false if they are not present.
571
572#[derive(Debug, Clone, Serialize, Deserialize, Default)]
573#[serde(rename_all = "camelCase")]
574pub struct SetResponseOverrideBitsParams<'a> {
575    #[serde(rename = "authenticatorId")]
576    authenticator_id: AuthenticatorId<'a>,
577    /// If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
578    /// Defaults to false.
579    #[serde(skip_serializing_if = "Option::is_none", rename = "isBogusSignature")]
580    is_bogus_signature: Option<bool>,
581    /// If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
582    /// be zero. Defaults to false.
583    #[serde(skip_serializing_if = "Option::is_none", rename = "isBadUV")]
584    is_bad_uv: Option<bool>,
585    /// If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
586    /// be zero. Defaults to false.
587    #[serde(skip_serializing_if = "Option::is_none", rename = "isBadUP")]
588    is_bad_up: Option<bool>,
589}
590
591impl<'a> SetResponseOverrideBitsParams<'a> {
592    /// Creates a builder for this type with the required parameters:
593    /// * `authenticator_id`: 
594    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>) -> SetResponseOverrideBitsParamsBuilder<'a> {
595        SetResponseOverrideBitsParamsBuilder {
596            authenticator_id: authenticator_id.into(),
597            is_bogus_signature: None,
598            is_bad_uv: None,
599            is_bad_up: None,
600        }
601    }
602    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
603    /// If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
604    /// Defaults to false.
605    pub fn is_bogus_signature(&self) -> Option<bool> { self.is_bogus_signature }
606    /// If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
607    /// be zero. Defaults to false.
608    pub fn is_bad_uv(&self) -> Option<bool> { self.is_bad_uv }
609    /// If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
610    /// be zero. Defaults to false.
611    pub fn is_bad_up(&self) -> Option<bool> { self.is_bad_up }
612}
613
614
615pub struct SetResponseOverrideBitsParamsBuilder<'a> {
616    authenticator_id: AuthenticatorId<'a>,
617    is_bogus_signature: Option<bool>,
618    is_bad_uv: Option<bool>,
619    is_bad_up: Option<bool>,
620}
621
622impl<'a> SetResponseOverrideBitsParamsBuilder<'a> {
623    /// If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
624    /// Defaults to false.
625    pub fn is_bogus_signature(mut self, is_bogus_signature: bool) -> Self { self.is_bogus_signature = Some(is_bogus_signature); self }
626    /// If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
627    /// be zero. Defaults to false.
628    pub fn is_bad_uv(mut self, is_bad_uv: bool) -> Self { self.is_bad_uv = Some(is_bad_uv); self }
629    /// If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
630    /// be zero. Defaults to false.
631    pub fn is_bad_up(mut self, is_bad_up: bool) -> Self { self.is_bad_up = Some(is_bad_up); self }
632    pub fn build(self) -> SetResponseOverrideBitsParams<'a> {
633        SetResponseOverrideBitsParams {
634            authenticator_id: self.authenticator_id,
635            is_bogus_signature: self.is_bogus_signature,
636            is_bad_uv: self.is_bad_uv,
637            is_bad_up: self.is_bad_up,
638        }
639    }
640}
641
642impl<'a> SetResponseOverrideBitsParams<'a> { pub const METHOD: &'static str = "WebAuthn.setResponseOverrideBits"; }
643
644impl<'a> crate::CdpCommand<'a> for SetResponseOverrideBitsParams<'a> {
645    const METHOD: &'static str = "WebAuthn.setResponseOverrideBits";
646    type Response = crate::EmptyReturns;
647}
648
649/// Removes the given authenticator.
650
651#[derive(Debug, Clone, Serialize, Deserialize, Default)]
652#[serde(rename_all = "camelCase")]
653pub struct RemoveVirtualAuthenticatorParams<'a> {
654    #[serde(rename = "authenticatorId")]
655    authenticator_id: AuthenticatorId<'a>,
656}
657
658impl<'a> RemoveVirtualAuthenticatorParams<'a> {
659    /// Creates a builder for this type with the required parameters:
660    /// * `authenticator_id`: 
661    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>) -> RemoveVirtualAuthenticatorParamsBuilder<'a> {
662        RemoveVirtualAuthenticatorParamsBuilder {
663            authenticator_id: authenticator_id.into(),
664        }
665    }
666    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
667}
668
669
670pub struct RemoveVirtualAuthenticatorParamsBuilder<'a> {
671    authenticator_id: AuthenticatorId<'a>,
672}
673
674impl<'a> RemoveVirtualAuthenticatorParamsBuilder<'a> {
675    pub fn build(self) -> RemoveVirtualAuthenticatorParams<'a> {
676        RemoveVirtualAuthenticatorParams {
677            authenticator_id: self.authenticator_id,
678        }
679    }
680}
681
682impl<'a> RemoveVirtualAuthenticatorParams<'a> { pub const METHOD: &'static str = "WebAuthn.removeVirtualAuthenticator"; }
683
684impl<'a> crate::CdpCommand<'a> for RemoveVirtualAuthenticatorParams<'a> {
685    const METHOD: &'static str = "WebAuthn.removeVirtualAuthenticator";
686    type Response = crate::EmptyReturns;
687}
688
689/// Adds the credential to the specified authenticator.
690
691#[derive(Debug, Clone, Serialize, Deserialize, Default)]
692#[serde(rename_all = "camelCase")]
693pub struct AddCredentialParams<'a> {
694    #[serde(rename = "authenticatorId")]
695    authenticator_id: AuthenticatorId<'a>,
696    credential: Credential<'a>,
697}
698
699impl<'a> AddCredentialParams<'a> {
700    /// Creates a builder for this type with the required parameters:
701    /// * `authenticator_id`: 
702    /// * `credential`: 
703    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, credential: Credential<'a>) -> AddCredentialParamsBuilder<'a> {
704        AddCredentialParamsBuilder {
705            authenticator_id: authenticator_id.into(),
706            credential: credential,
707        }
708    }
709    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
710    pub fn credential(&self) -> &Credential<'a> { &self.credential }
711}
712
713
714pub struct AddCredentialParamsBuilder<'a> {
715    authenticator_id: AuthenticatorId<'a>,
716    credential: Credential<'a>,
717}
718
719impl<'a> AddCredentialParamsBuilder<'a> {
720    pub fn build(self) -> AddCredentialParams<'a> {
721        AddCredentialParams {
722            authenticator_id: self.authenticator_id,
723            credential: self.credential,
724        }
725    }
726}
727
728impl<'a> AddCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.addCredential"; }
729
730impl<'a> crate::CdpCommand<'a> for AddCredentialParams<'a> {
731    const METHOD: &'static str = "WebAuthn.addCredential";
732    type Response = crate::EmptyReturns;
733}
734
735/// Returns a single credential stored in the given virtual authenticator that
736/// matches the credential ID.
737
738#[derive(Debug, Clone, Serialize, Deserialize, Default)]
739#[serde(rename_all = "camelCase")]
740pub struct GetCredentialParams<'a> {
741    #[serde(rename = "authenticatorId")]
742    authenticator_id: AuthenticatorId<'a>,
743    #[serde(rename = "credentialId")]
744    credential_id: Cow<'a, str>,
745}
746
747impl<'a> GetCredentialParams<'a> {
748    /// Creates a builder for this type with the required parameters:
749    /// * `authenticator_id`: 
750    /// * `credential_id`: 
751    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, credential_id: impl Into<Cow<'a, str>>) -> GetCredentialParamsBuilder<'a> {
752        GetCredentialParamsBuilder {
753            authenticator_id: authenticator_id.into(),
754            credential_id: credential_id.into(),
755        }
756    }
757    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
758    pub fn credential_id(&self) -> &str { self.credential_id.as_ref() }
759}
760
761
762pub struct GetCredentialParamsBuilder<'a> {
763    authenticator_id: AuthenticatorId<'a>,
764    credential_id: Cow<'a, str>,
765}
766
767impl<'a> GetCredentialParamsBuilder<'a> {
768    pub fn build(self) -> GetCredentialParams<'a> {
769        GetCredentialParams {
770            authenticator_id: self.authenticator_id,
771            credential_id: self.credential_id,
772        }
773    }
774}
775
776/// Returns a single credential stored in the given virtual authenticator that
777/// matches the credential ID.
778
779#[derive(Debug, Clone, Serialize, Deserialize, Default)]
780#[serde(rename_all = "camelCase")]
781pub struct GetCredentialReturns<'a> {
782    credential: Credential<'a>,
783}
784
785impl<'a> GetCredentialReturns<'a> {
786    /// Creates a builder for this type with the required parameters:
787    /// * `credential`: 
788    pub fn builder(credential: Credential<'a>) -> GetCredentialReturnsBuilder<'a> {
789        GetCredentialReturnsBuilder {
790            credential: credential,
791        }
792    }
793    pub fn credential(&self) -> &Credential<'a> { &self.credential }
794}
795
796
797pub struct GetCredentialReturnsBuilder<'a> {
798    credential: Credential<'a>,
799}
800
801impl<'a> GetCredentialReturnsBuilder<'a> {
802    pub fn build(self) -> GetCredentialReturns<'a> {
803        GetCredentialReturns {
804            credential: self.credential,
805        }
806    }
807}
808
809impl<'a> GetCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.getCredential"; }
810
811impl<'a> crate::CdpCommand<'a> for GetCredentialParams<'a> {
812    const METHOD: &'static str = "WebAuthn.getCredential";
813    type Response = GetCredentialReturns<'a>;
814}
815
816/// Returns all the credentials stored in the given virtual authenticator.
817
818#[derive(Debug, Clone, Serialize, Deserialize, Default)]
819#[serde(rename_all = "camelCase")]
820pub struct GetCredentialsParams<'a> {
821    #[serde(rename = "authenticatorId")]
822    authenticator_id: AuthenticatorId<'a>,
823}
824
825impl<'a> GetCredentialsParams<'a> {
826    /// Creates a builder for this type with the required parameters:
827    /// * `authenticator_id`: 
828    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>) -> GetCredentialsParamsBuilder<'a> {
829        GetCredentialsParamsBuilder {
830            authenticator_id: authenticator_id.into(),
831        }
832    }
833    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
834}
835
836
837pub struct GetCredentialsParamsBuilder<'a> {
838    authenticator_id: AuthenticatorId<'a>,
839}
840
841impl<'a> GetCredentialsParamsBuilder<'a> {
842    pub fn build(self) -> GetCredentialsParams<'a> {
843        GetCredentialsParams {
844            authenticator_id: self.authenticator_id,
845        }
846    }
847}
848
849/// Returns all the credentials stored in the given virtual authenticator.
850
851#[derive(Debug, Clone, Serialize, Deserialize, Default)]
852#[serde(rename_all = "camelCase")]
853pub struct GetCredentialsReturns<'a> {
854    credentials: Vec<Credential<'a>>,
855}
856
857impl<'a> GetCredentialsReturns<'a> {
858    /// Creates a builder for this type with the required parameters:
859    /// * `credentials`: 
860    pub fn builder(credentials: Vec<Credential<'a>>) -> GetCredentialsReturnsBuilder<'a> {
861        GetCredentialsReturnsBuilder {
862            credentials: credentials,
863        }
864    }
865    pub fn credentials(&self) -> &[Credential<'a>] { &self.credentials }
866}
867
868
869pub struct GetCredentialsReturnsBuilder<'a> {
870    credentials: Vec<Credential<'a>>,
871}
872
873impl<'a> GetCredentialsReturnsBuilder<'a> {
874    pub fn build(self) -> GetCredentialsReturns<'a> {
875        GetCredentialsReturns {
876            credentials: self.credentials,
877        }
878    }
879}
880
881impl<'a> GetCredentialsParams<'a> { pub const METHOD: &'static str = "WebAuthn.getCredentials"; }
882
883impl<'a> crate::CdpCommand<'a> for GetCredentialsParams<'a> {
884    const METHOD: &'static str = "WebAuthn.getCredentials";
885    type Response = GetCredentialsReturns<'a>;
886}
887
888/// Removes a credential from the authenticator.
889
890#[derive(Debug, Clone, Serialize, Deserialize, Default)]
891#[serde(rename_all = "camelCase")]
892pub struct RemoveCredentialParams<'a> {
893    #[serde(rename = "authenticatorId")]
894    authenticator_id: AuthenticatorId<'a>,
895    #[serde(rename = "credentialId")]
896    credential_id: Cow<'a, str>,
897}
898
899impl<'a> RemoveCredentialParams<'a> {
900    /// Creates a builder for this type with the required parameters:
901    /// * `authenticator_id`: 
902    /// * `credential_id`: 
903    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, credential_id: impl Into<Cow<'a, str>>) -> RemoveCredentialParamsBuilder<'a> {
904        RemoveCredentialParamsBuilder {
905            authenticator_id: authenticator_id.into(),
906            credential_id: credential_id.into(),
907        }
908    }
909    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
910    pub fn credential_id(&self) -> &str { self.credential_id.as_ref() }
911}
912
913
914pub struct RemoveCredentialParamsBuilder<'a> {
915    authenticator_id: AuthenticatorId<'a>,
916    credential_id: Cow<'a, str>,
917}
918
919impl<'a> RemoveCredentialParamsBuilder<'a> {
920    pub fn build(self) -> RemoveCredentialParams<'a> {
921        RemoveCredentialParams {
922            authenticator_id: self.authenticator_id,
923            credential_id: self.credential_id,
924        }
925    }
926}
927
928impl<'a> RemoveCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.removeCredential"; }
929
930impl<'a> crate::CdpCommand<'a> for RemoveCredentialParams<'a> {
931    const METHOD: &'static str = "WebAuthn.removeCredential";
932    type Response = crate::EmptyReturns;
933}
934
935/// Clears all the credentials from the specified device.
936
937#[derive(Debug, Clone, Serialize, Deserialize, Default)]
938#[serde(rename_all = "camelCase")]
939pub struct ClearCredentialsParams<'a> {
940    #[serde(rename = "authenticatorId")]
941    authenticator_id: AuthenticatorId<'a>,
942}
943
944impl<'a> ClearCredentialsParams<'a> {
945    /// Creates a builder for this type with the required parameters:
946    /// * `authenticator_id`: 
947    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>) -> ClearCredentialsParamsBuilder<'a> {
948        ClearCredentialsParamsBuilder {
949            authenticator_id: authenticator_id.into(),
950        }
951    }
952    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
953}
954
955
956pub struct ClearCredentialsParamsBuilder<'a> {
957    authenticator_id: AuthenticatorId<'a>,
958}
959
960impl<'a> ClearCredentialsParamsBuilder<'a> {
961    pub fn build(self) -> ClearCredentialsParams<'a> {
962        ClearCredentialsParams {
963            authenticator_id: self.authenticator_id,
964        }
965    }
966}
967
968impl<'a> ClearCredentialsParams<'a> { pub const METHOD: &'static str = "WebAuthn.clearCredentials"; }
969
970impl<'a> crate::CdpCommand<'a> for ClearCredentialsParams<'a> {
971    const METHOD: &'static str = "WebAuthn.clearCredentials";
972    type Response = crate::EmptyReturns;
973}
974
975/// Sets whether User Verification succeeds or fails for an authenticator.
976/// The default is true.
977
978#[derive(Debug, Clone, Serialize, Deserialize, Default)]
979#[serde(rename_all = "camelCase")]
980pub struct SetUserVerifiedParams<'a> {
981    #[serde(rename = "authenticatorId")]
982    authenticator_id: AuthenticatorId<'a>,
983    #[serde(rename = "isUserVerified")]
984    is_user_verified: bool,
985}
986
987impl<'a> SetUserVerifiedParams<'a> {
988    /// Creates a builder for this type with the required parameters:
989    /// * `authenticator_id`: 
990    /// * `is_user_verified`: 
991    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, is_user_verified: bool) -> SetUserVerifiedParamsBuilder<'a> {
992        SetUserVerifiedParamsBuilder {
993            authenticator_id: authenticator_id.into(),
994            is_user_verified: is_user_verified,
995        }
996    }
997    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
998    pub fn is_user_verified(&self) -> bool { self.is_user_verified }
999}
1000
1001
1002pub struct SetUserVerifiedParamsBuilder<'a> {
1003    authenticator_id: AuthenticatorId<'a>,
1004    is_user_verified: bool,
1005}
1006
1007impl<'a> SetUserVerifiedParamsBuilder<'a> {
1008    pub fn build(self) -> SetUserVerifiedParams<'a> {
1009        SetUserVerifiedParams {
1010            authenticator_id: self.authenticator_id,
1011            is_user_verified: self.is_user_verified,
1012        }
1013    }
1014}
1015
1016impl<'a> SetUserVerifiedParams<'a> { pub const METHOD: &'static str = "WebAuthn.setUserVerified"; }
1017
1018impl<'a> crate::CdpCommand<'a> for SetUserVerifiedParams<'a> {
1019    const METHOD: &'static str = "WebAuthn.setUserVerified";
1020    type Response = crate::EmptyReturns;
1021}
1022
1023/// Sets whether tests of user presence will succeed immediately (if true) or fail to resolve (if false) for an authenticator.
1024/// The default is true.
1025
1026#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1027#[serde(rename_all = "camelCase")]
1028pub struct SetAutomaticPresenceSimulationParams<'a> {
1029    #[serde(rename = "authenticatorId")]
1030    authenticator_id: AuthenticatorId<'a>,
1031    enabled: bool,
1032}
1033
1034impl<'a> SetAutomaticPresenceSimulationParams<'a> {
1035    /// Creates a builder for this type with the required parameters:
1036    /// * `authenticator_id`: 
1037    /// * `enabled`: 
1038    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, enabled: bool) -> SetAutomaticPresenceSimulationParamsBuilder<'a> {
1039        SetAutomaticPresenceSimulationParamsBuilder {
1040            authenticator_id: authenticator_id.into(),
1041            enabled: enabled,
1042        }
1043    }
1044    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
1045    pub fn enabled(&self) -> bool { self.enabled }
1046}
1047
1048
1049pub struct SetAutomaticPresenceSimulationParamsBuilder<'a> {
1050    authenticator_id: AuthenticatorId<'a>,
1051    enabled: bool,
1052}
1053
1054impl<'a> SetAutomaticPresenceSimulationParamsBuilder<'a> {
1055    pub fn build(self) -> SetAutomaticPresenceSimulationParams<'a> {
1056        SetAutomaticPresenceSimulationParams {
1057            authenticator_id: self.authenticator_id,
1058            enabled: self.enabled,
1059        }
1060    }
1061}
1062
1063impl<'a> SetAutomaticPresenceSimulationParams<'a> { pub const METHOD: &'static str = "WebAuthn.setAutomaticPresenceSimulation"; }
1064
1065impl<'a> crate::CdpCommand<'a> for SetAutomaticPresenceSimulationParams<'a> {
1066    const METHOD: &'static str = "WebAuthn.setAutomaticPresenceSimulation";
1067    type Response = crate::EmptyReturns;
1068}
1069
1070/// Allows setting credential properties.
1071/// <https://w3c.github.io/webauthn/#sctn-automation-set-credential-properties>
1072
1073#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1074#[serde(rename_all = "camelCase")]
1075pub struct SetCredentialPropertiesParams<'a> {
1076    #[serde(rename = "authenticatorId")]
1077    authenticator_id: AuthenticatorId<'a>,
1078    #[serde(rename = "credentialId")]
1079    credential_id: Cow<'a, str>,
1080    #[serde(skip_serializing_if = "Option::is_none", rename = "backupEligibility")]
1081    backup_eligibility: Option<bool>,
1082    #[serde(skip_serializing_if = "Option::is_none", rename = "backupState")]
1083    backup_state: Option<bool>,
1084}
1085
1086impl<'a> SetCredentialPropertiesParams<'a> {
1087    /// Creates a builder for this type with the required parameters:
1088    /// * `authenticator_id`: 
1089    /// * `credential_id`: 
1090    pub fn builder(authenticator_id: impl Into<AuthenticatorId<'a>>, credential_id: impl Into<Cow<'a, str>>) -> SetCredentialPropertiesParamsBuilder<'a> {
1091        SetCredentialPropertiesParamsBuilder {
1092            authenticator_id: authenticator_id.into(),
1093            credential_id: credential_id.into(),
1094            backup_eligibility: None,
1095            backup_state: None,
1096        }
1097    }
1098    pub fn authenticator_id(&self) -> &AuthenticatorId<'a> { &self.authenticator_id }
1099    pub fn credential_id(&self) -> &str { self.credential_id.as_ref() }
1100    pub fn backup_eligibility(&self) -> Option<bool> { self.backup_eligibility }
1101    pub fn backup_state(&self) -> Option<bool> { self.backup_state }
1102}
1103
1104
1105pub struct SetCredentialPropertiesParamsBuilder<'a> {
1106    authenticator_id: AuthenticatorId<'a>,
1107    credential_id: Cow<'a, str>,
1108    backup_eligibility: Option<bool>,
1109    backup_state: Option<bool>,
1110}
1111
1112impl<'a> SetCredentialPropertiesParamsBuilder<'a> {
1113    pub fn backup_eligibility(mut self, backup_eligibility: bool) -> Self { self.backup_eligibility = Some(backup_eligibility); self }
1114    pub fn backup_state(mut self, backup_state: bool) -> Self { self.backup_state = Some(backup_state); self }
1115    pub fn build(self) -> SetCredentialPropertiesParams<'a> {
1116        SetCredentialPropertiesParams {
1117            authenticator_id: self.authenticator_id,
1118            credential_id: self.credential_id,
1119            backup_eligibility: self.backup_eligibility,
1120            backup_state: self.backup_state,
1121        }
1122    }
1123}
1124
1125impl<'a> SetCredentialPropertiesParams<'a> { pub const METHOD: &'static str = "WebAuthn.setCredentialProperties"; }
1126
1127impl<'a> crate::CdpCommand<'a> for SetCredentialPropertiesParams<'a> {
1128    const METHOD: &'static str = "WebAuthn.setCredentialProperties";
1129    type Response = crate::EmptyReturns;
1130}