browser-protocol 0.1.3

Generated Rust types and commands for the Chrome DevTools Protocol (browser-protocol)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
//! This domain allows configuring virtual authenticators to test the WebAuthn
//! API.


use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;


pub type AuthenticatorId<'a> = Cow<'a, str>;


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AuthenticatorProtocol {
    #[default]
    #[serde(rename = "u2f")]
    U2f,
    #[serde(rename = "ctap2")]
    Ctap2,
}


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum Ctap2Version {
    #[default]
    #[serde(rename = "ctap2_0")]
    Ctap20,
    #[serde(rename = "ctap2_1")]
    Ctap21,
    #[serde(rename = "ctap2_2")]
    Ctap22,
}


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AuthenticatorTransport {
    #[default]
    #[serde(rename = "usb")]
    Usb,
    #[serde(rename = "nfc")]
    Nfc,
    #[serde(rename = "ble")]
    Ble,
    #[serde(rename = "cable")]
    Cable,
    #[serde(rename = "internal")]
    Internal,
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct VirtualAuthenticatorOptions {
    protocol: AuthenticatorProtocol,
    /// Defaults to ctap2_0. Ignored if |protocol| == u2f.
    #[serde(skip_serializing_if = "Option::is_none")]
    ctap2Version: Option<Ctap2Version>,
    transport: AuthenticatorTransport,
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasResidentKey: Option<bool>,
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasUserVerification: Option<bool>,
    /// If set to true, the authenticator will support the largeBlob extension.
    /// https://w3c.github.io/webauthn#largeBlob
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasLargeBlob: Option<bool>,
    /// If set to true, the authenticator will support the credBlob extension.
    /// https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasCredBlob: Option<bool>,
    /// If set to true, the authenticator will support the minPinLength extension.
    /// https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasMinPinLength: Option<bool>,
    /// If set to true, the authenticator will support the prf extension.
    /// https://w3c.github.io/webauthn/#prf-extension
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasPrf: Option<bool>,
    /// If set to true, the authenticator will support the hmac-secret extension.
    /// https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasHmacSecret: Option<bool>,
    /// If set to true, the authenticator will support the hmac-secret-mc extension.
    /// 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
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    hasHmacSecretMc: Option<bool>,
    /// If set to true, tests of user presence will succeed immediately.
    /// Otherwise, they will not be resolved. Defaults to true.
    #[serde(skip_serializing_if = "Option::is_none")]
    automaticPresenceSimulation: Option<bool>,
    /// Sets whether User Verification succeeds or fails for an authenticator.
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    isUserVerified: Option<bool>,
    /// Credentials created by this authenticator will have the backup
    /// eligibility (BE) flag set to this value. Defaults to false.
    /// https://w3c.github.io/webauthn/#sctn-credential-backup
    #[serde(skip_serializing_if = "Option::is_none")]
    defaultBackupEligibility: Option<bool>,
    /// Credentials created by this authenticator will have the backup state
    /// (BS) flag set to this value. Defaults to false.
    /// https://w3c.github.io/webauthn/#sctn-credential-backup
    #[serde(skip_serializing_if = "Option::is_none")]
    defaultBackupState: Option<bool>,
}

impl VirtualAuthenticatorOptions {
    pub fn builder(protocol: AuthenticatorProtocol, transport: AuthenticatorTransport) -> VirtualAuthenticatorOptionsBuilder {
        VirtualAuthenticatorOptionsBuilder {
            protocol: protocol,
            ctap2Version: None,
            transport: transport,
            hasResidentKey: None,
            hasUserVerification: None,
            hasLargeBlob: None,
            hasCredBlob: None,
            hasMinPinLength: None,
            hasPrf: None,
            hasHmacSecret: None,
            hasHmacSecretMc: None,
            automaticPresenceSimulation: None,
            isUserVerified: None,
            defaultBackupEligibility: None,
            defaultBackupState: None,
        }
    }
    pub fn protocol(&self) -> &AuthenticatorProtocol { &self.protocol }
    pub fn ctap2Version(&self) -> Option<&Ctap2Version> { self.ctap2Version.as_ref() }
    pub fn transport(&self) -> &AuthenticatorTransport { &self.transport }
    pub fn hasResidentKey(&self) -> Option<bool> { self.hasResidentKey }
    pub fn hasUserVerification(&self) -> Option<bool> { self.hasUserVerification }
    pub fn hasLargeBlob(&self) -> Option<bool> { self.hasLargeBlob }
    pub fn hasCredBlob(&self) -> Option<bool> { self.hasCredBlob }
    pub fn hasMinPinLength(&self) -> Option<bool> { self.hasMinPinLength }
    pub fn hasPrf(&self) -> Option<bool> { self.hasPrf }
    pub fn hasHmacSecret(&self) -> Option<bool> { self.hasHmacSecret }
    pub fn hasHmacSecretMc(&self) -> Option<bool> { self.hasHmacSecretMc }
    pub fn automaticPresenceSimulation(&self) -> Option<bool> { self.automaticPresenceSimulation }
    pub fn isUserVerified(&self) -> Option<bool> { self.isUserVerified }
    pub fn defaultBackupEligibility(&self) -> Option<bool> { self.defaultBackupEligibility }
    pub fn defaultBackupState(&self) -> Option<bool> { self.defaultBackupState }
}


pub struct VirtualAuthenticatorOptionsBuilder {
    protocol: AuthenticatorProtocol,
    ctap2Version: Option<Ctap2Version>,
    transport: AuthenticatorTransport,
    hasResidentKey: Option<bool>,
    hasUserVerification: Option<bool>,
    hasLargeBlob: Option<bool>,
    hasCredBlob: Option<bool>,
    hasMinPinLength: Option<bool>,
    hasPrf: Option<bool>,
    hasHmacSecret: Option<bool>,
    hasHmacSecretMc: Option<bool>,
    automaticPresenceSimulation: Option<bool>,
    isUserVerified: Option<bool>,
    defaultBackupEligibility: Option<bool>,
    defaultBackupState: Option<bool>,
}

impl VirtualAuthenticatorOptionsBuilder {
    /// Defaults to ctap2_0. Ignored if |protocol| == u2f.
    pub fn ctap2Version(mut self, ctap2Version: Ctap2Version) -> Self { self.ctap2Version = Some(ctap2Version); self }
    /// Defaults to false.
    pub fn hasResidentKey(mut self, hasResidentKey: bool) -> Self { self.hasResidentKey = Some(hasResidentKey); self }
    /// Defaults to false.
    pub fn hasUserVerification(mut self, hasUserVerification: bool) -> Self { self.hasUserVerification = Some(hasUserVerification); self }
    /// If set to true, the authenticator will support the largeBlob extension.
    /// https://w3c.github.io/webauthn#largeBlob
    /// Defaults to false.
    pub fn hasLargeBlob(mut self, hasLargeBlob: bool) -> Self { self.hasLargeBlob = Some(hasLargeBlob); self }
    /// If set to true, the authenticator will support the credBlob extension.
    /// https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension
    /// Defaults to false.
    pub fn hasCredBlob(mut self, hasCredBlob: bool) -> Self { self.hasCredBlob = Some(hasCredBlob); self }
    /// If set to true, the authenticator will support the minPinLength extension.
    /// https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension
    /// Defaults to false.
    pub fn hasMinPinLength(mut self, hasMinPinLength: bool) -> Self { self.hasMinPinLength = Some(hasMinPinLength); self }
    /// If set to true, the authenticator will support the prf extension.
    /// https://w3c.github.io/webauthn/#prf-extension
    /// Defaults to false.
    pub fn hasPrf(mut self, hasPrf: bool) -> Self { self.hasPrf = Some(hasPrf); self }
    /// If set to true, the authenticator will support the hmac-secret extension.
    /// https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension
    /// Defaults to false.
    pub fn hasHmacSecret(mut self, hasHmacSecret: bool) -> Self { self.hasHmacSecret = Some(hasHmacSecret); self }
    /// If set to true, the authenticator will support the hmac-secret-mc extension.
    /// 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
    /// Defaults to false.
    pub fn hasHmacSecretMc(mut self, hasHmacSecretMc: bool) -> Self { self.hasHmacSecretMc = Some(hasHmacSecretMc); self }
    /// If set to true, tests of user presence will succeed immediately.
    /// Otherwise, they will not be resolved. Defaults to true.
    pub fn automaticPresenceSimulation(mut self, automaticPresenceSimulation: bool) -> Self { self.automaticPresenceSimulation = Some(automaticPresenceSimulation); self }
    /// Sets whether User Verification succeeds or fails for an authenticator.
    /// Defaults to false.
    pub fn isUserVerified(mut self, isUserVerified: bool) -> Self { self.isUserVerified = Some(isUserVerified); self }
    /// Credentials created by this authenticator will have the backup
    /// eligibility (BE) flag set to this value. Defaults to false.
    /// https://w3c.github.io/webauthn/#sctn-credential-backup
    pub fn defaultBackupEligibility(mut self, defaultBackupEligibility: bool) -> Self { self.defaultBackupEligibility = Some(defaultBackupEligibility); self }
    /// Credentials created by this authenticator will have the backup state
    /// (BS) flag set to this value. Defaults to false.
    /// https://w3c.github.io/webauthn/#sctn-credential-backup
    pub fn defaultBackupState(mut self, defaultBackupState: bool) -> Self { self.defaultBackupState = Some(defaultBackupState); self }
    pub fn build(self) -> VirtualAuthenticatorOptions {
        VirtualAuthenticatorOptions {
            protocol: self.protocol,
            ctap2Version: self.ctap2Version,
            transport: self.transport,
            hasResidentKey: self.hasResidentKey,
            hasUserVerification: self.hasUserVerification,
            hasLargeBlob: self.hasLargeBlob,
            hasCredBlob: self.hasCredBlob,
            hasMinPinLength: self.hasMinPinLength,
            hasPrf: self.hasPrf,
            hasHmacSecret: self.hasHmacSecret,
            hasHmacSecretMc: self.hasHmacSecretMc,
            automaticPresenceSimulation: self.automaticPresenceSimulation,
            isUserVerified: self.isUserVerified,
            defaultBackupEligibility: self.defaultBackupEligibility,
            defaultBackupState: self.defaultBackupState,
        }
    }
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Credential<'a> {
    credentialId: Cow<'a, str>,
    isResidentCredential: bool,
    /// Relying Party ID the credential is scoped to. Must be set when adding a
    /// credential.
    #[serde(skip_serializing_if = "Option::is_none")]
    rpId: Option<Cow<'a, str>>,
    /// The ECDSA P-256 private key in PKCS#8 format. (Encoded as a base64 string when passed over JSON)
    privateKey: Cow<'a, str>,
    /// An opaque byte sequence with a maximum size of 64 bytes mapping the
    /// credential to a specific user. (Encoded as a base64 string when passed over JSON)
    #[serde(skip_serializing_if = "Option::is_none")]
    userHandle: Option<Cow<'a, str>>,
    /// Signature counter. This is incremented by one for each successful
    /// assertion.
    /// See https://w3c.github.io/webauthn/#signature-counter
    signCount: u64,
    /// The large blob associated with the credential.
    /// See https://w3c.github.io/webauthn/#sctn-large-blob-extension (Encoded as a base64 string when passed over JSON)
    #[serde(skip_serializing_if = "Option::is_none")]
    largeBlob: Option<Cow<'a, str>>,
    /// Assertions returned by this credential will have the backup eligibility
    /// (BE) flag set to this value. Defaults to the authenticator's
    /// defaultBackupEligibility value.
    #[serde(skip_serializing_if = "Option::is_none")]
    backupEligibility: Option<bool>,
    /// Assertions returned by this credential will have the backup state (BS)
    /// flag set to this value. Defaults to the authenticator's
    /// defaultBackupState value.
    #[serde(skip_serializing_if = "Option::is_none")]
    backupState: Option<bool>,
    /// The credential's user.name property. Equivalent to empty if not set.
    /// https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name
    #[serde(skip_serializing_if = "Option::is_none")]
    userName: Option<Cow<'a, str>>,
    /// The credential's user.displayName property. Equivalent to empty if
    /// not set.
    /// https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname
    #[serde(skip_serializing_if = "Option::is_none")]
    userDisplayName: Option<Cow<'a, str>>,
}

impl<'a> Credential<'a> {
    pub fn builder(credentialId: impl Into<Cow<'a, str>>, isResidentCredential: bool, privateKey: impl Into<Cow<'a, str>>, signCount: u64) -> CredentialBuilder<'a> {
        CredentialBuilder {
            credentialId: credentialId.into(),
            isResidentCredential: isResidentCredential,
            rpId: None,
            privateKey: privateKey.into(),
            userHandle: None,
            signCount: signCount,
            largeBlob: None,
            backupEligibility: None,
            backupState: None,
            userName: None,
            userDisplayName: None,
        }
    }
    pub fn credentialId(&self) -> &str { self.credentialId.as_ref() }
    pub fn isResidentCredential(&self) -> bool { self.isResidentCredential }
    pub fn rpId(&self) -> Option<&str> { self.rpId.as_deref() }
    pub fn privateKey(&self) -> &str { self.privateKey.as_ref() }
    pub fn userHandle(&self) -> Option<&str> { self.userHandle.as_deref() }
    pub fn signCount(&self) -> u64 { self.signCount }
    pub fn largeBlob(&self) -> Option<&str> { self.largeBlob.as_deref() }
    pub fn backupEligibility(&self) -> Option<bool> { self.backupEligibility }
    pub fn backupState(&self) -> Option<bool> { self.backupState }
    pub fn userName(&self) -> Option<&str> { self.userName.as_deref() }
    pub fn userDisplayName(&self) -> Option<&str> { self.userDisplayName.as_deref() }
}


pub struct CredentialBuilder<'a> {
    credentialId: Cow<'a, str>,
    isResidentCredential: bool,
    rpId: Option<Cow<'a, str>>,
    privateKey: Cow<'a, str>,
    userHandle: Option<Cow<'a, str>>,
    signCount: u64,
    largeBlob: Option<Cow<'a, str>>,
    backupEligibility: Option<bool>,
    backupState: Option<bool>,
    userName: Option<Cow<'a, str>>,
    userDisplayName: Option<Cow<'a, str>>,
}

impl<'a> CredentialBuilder<'a> {
    /// Relying Party ID the credential is scoped to. Must be set when adding a
    /// credential.
    pub fn rpId(mut self, rpId: impl Into<Cow<'a, str>>) -> Self { self.rpId = Some(rpId.into()); self }
    /// An opaque byte sequence with a maximum size of 64 bytes mapping the
    /// credential to a specific user. (Encoded as a base64 string when passed over JSON)
    pub fn userHandle(mut self, userHandle: impl Into<Cow<'a, str>>) -> Self { self.userHandle = Some(userHandle.into()); self }
    /// The large blob associated with the credential.
    /// See https://w3c.github.io/webauthn/#sctn-large-blob-extension (Encoded as a base64 string when passed over JSON)
    pub fn largeBlob(mut self, largeBlob: impl Into<Cow<'a, str>>) -> Self { self.largeBlob = Some(largeBlob.into()); self }
    /// Assertions returned by this credential will have the backup eligibility
    /// (BE) flag set to this value. Defaults to the authenticator's
    /// defaultBackupEligibility value.
    pub fn backupEligibility(mut self, backupEligibility: bool) -> Self { self.backupEligibility = Some(backupEligibility); self }
    /// Assertions returned by this credential will have the backup state (BS)
    /// flag set to this value. Defaults to the authenticator's
    /// defaultBackupState value.
    pub fn backupState(mut self, backupState: bool) -> Self { self.backupState = Some(backupState); self }
    /// The credential's user.name property. Equivalent to empty if not set.
    /// https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name
    pub fn userName(mut self, userName: impl Into<Cow<'a, str>>) -> Self { self.userName = Some(userName.into()); self }
    /// The credential's user.displayName property. Equivalent to empty if
    /// not set.
    /// https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname
    pub fn userDisplayName(mut self, userDisplayName: impl Into<Cow<'a, str>>) -> Self { self.userDisplayName = Some(userDisplayName.into()); self }
    pub fn build(self) -> Credential<'a> {
        Credential {
            credentialId: self.credentialId,
            isResidentCredential: self.isResidentCredential,
            rpId: self.rpId,
            privateKey: self.privateKey,
            userHandle: self.userHandle,
            signCount: self.signCount,
            largeBlob: self.largeBlob,
            backupEligibility: self.backupEligibility,
            backupState: self.backupState,
            userName: self.userName,
            userDisplayName: self.userDisplayName,
        }
    }
}

/// Enable the WebAuthn domain and start intercepting credential storage and
/// retrieval with a virtual authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct EnableParams {
    /// Whether to enable the WebAuthn user interface. Enabling the UI is
    /// recommended for debugging and demo purposes, as it is closer to the real
    /// experience. Disabling the UI is recommended for automated testing.
    /// Supported at the embedder's discretion if UI is available.
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    enableUI: Option<bool>,
}

impl EnableParams {
    pub fn builder() -> EnableParamsBuilder {
        EnableParamsBuilder {
            enableUI: None,
        }
    }
    pub fn enableUI(&self) -> Option<bool> { self.enableUI }
}

#[derive(Default)]
pub struct EnableParamsBuilder {
    enableUI: Option<bool>,
}

impl EnableParamsBuilder {
    /// Whether to enable the WebAuthn user interface. Enabling the UI is
    /// recommended for debugging and demo purposes, as it is closer to the real
    /// experience. Disabling the UI is recommended for automated testing.
    /// Supported at the embedder's discretion if UI is available.
    /// Defaults to false.
    pub fn enableUI(mut self, enableUI: bool) -> Self { self.enableUI = Some(enableUI); self }
    pub fn build(self) -> EnableParams {
        EnableParams {
            enableUI: self.enableUI,
        }
    }
}

impl EnableParams { pub const METHOD: &'static str = "WebAuthn.enable"; }

impl<'a> crate::CdpCommand<'a> for EnableParams {
    const METHOD: &'static str = "WebAuthn.enable";
    type Response = crate::EmptyReturns;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}

impl DisableParams { pub const METHOD: &'static str = "WebAuthn.disable"; }

impl<'a> crate::CdpCommand<'a> for DisableParams {
    const METHOD: &'static str = "WebAuthn.disable";
    type Response = crate::EmptyReturns;
}

/// Creates and adds a virtual authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddVirtualAuthenticatorParams {
    options: VirtualAuthenticatorOptions,
}

impl AddVirtualAuthenticatorParams {
    pub fn builder(options: VirtualAuthenticatorOptions) -> AddVirtualAuthenticatorParamsBuilder {
        AddVirtualAuthenticatorParamsBuilder {
            options: options,
        }
    }
    pub fn options(&self) -> &VirtualAuthenticatorOptions { &self.options }
}


pub struct AddVirtualAuthenticatorParamsBuilder {
    options: VirtualAuthenticatorOptions,
}

impl AddVirtualAuthenticatorParamsBuilder {
    pub fn build(self) -> AddVirtualAuthenticatorParams {
        AddVirtualAuthenticatorParams {
            options: self.options,
        }
    }
}

/// Creates and adds a virtual authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddVirtualAuthenticatorReturns<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> AddVirtualAuthenticatorReturns<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>) -> AddVirtualAuthenticatorReturnsBuilder<'a> {
        AddVirtualAuthenticatorReturnsBuilder {
            authenticatorId: authenticatorId,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
}


pub struct AddVirtualAuthenticatorReturnsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> AddVirtualAuthenticatorReturnsBuilder<'a> {
    pub fn build(self) -> AddVirtualAuthenticatorReturns<'a> {
        AddVirtualAuthenticatorReturns {
            authenticatorId: self.authenticatorId,
        }
    }
}

impl AddVirtualAuthenticatorParams { pub const METHOD: &'static str = "WebAuthn.addVirtualAuthenticator"; }

impl<'a> crate::CdpCommand<'a> for AddVirtualAuthenticatorParams {
    const METHOD: &'static str = "WebAuthn.addVirtualAuthenticator";
    type Response = AddVirtualAuthenticatorReturns<'a>;
}

/// Resets parameters isBogusSignature, isBadUV, isBadUP to false if they are not present.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetResponseOverrideBitsParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    /// If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
    /// Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    isBogusSignature: Option<bool>,
    /// If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
    /// be zero. Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    isBadUV: Option<bool>,
    /// If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
    /// be zero. Defaults to false.
    #[serde(skip_serializing_if = "Option::is_none")]
    isBadUP: Option<bool>,
}

impl<'a> SetResponseOverrideBitsParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>) -> SetResponseOverrideBitsParamsBuilder<'a> {
        SetResponseOverrideBitsParamsBuilder {
            authenticatorId: authenticatorId,
            isBogusSignature: None,
            isBadUV: None,
            isBadUP: None,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn isBogusSignature(&self) -> Option<bool> { self.isBogusSignature }
    pub fn isBadUV(&self) -> Option<bool> { self.isBadUV }
    pub fn isBadUP(&self) -> Option<bool> { self.isBadUP }
}


pub struct SetResponseOverrideBitsParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    isBogusSignature: Option<bool>,
    isBadUV: Option<bool>,
    isBadUP: Option<bool>,
}

impl<'a> SetResponseOverrideBitsParamsBuilder<'a> {
    /// If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
    /// Defaults to false.
    pub fn isBogusSignature(mut self, isBogusSignature: bool) -> Self { self.isBogusSignature = Some(isBogusSignature); self }
    /// If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
    /// be zero. Defaults to false.
    pub fn isBadUV(mut self, isBadUV: bool) -> Self { self.isBadUV = Some(isBadUV); self }
    /// If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
    /// be zero. Defaults to false.
    pub fn isBadUP(mut self, isBadUP: bool) -> Self { self.isBadUP = Some(isBadUP); self }
    pub fn build(self) -> SetResponseOverrideBitsParams<'a> {
        SetResponseOverrideBitsParams {
            authenticatorId: self.authenticatorId,
            isBogusSignature: self.isBogusSignature,
            isBadUV: self.isBadUV,
            isBadUP: self.isBadUP,
        }
    }
}

impl<'a> SetResponseOverrideBitsParams<'a> { pub const METHOD: &'static str = "WebAuthn.setResponseOverrideBits"; }

impl<'a> crate::CdpCommand<'a> for SetResponseOverrideBitsParams<'a> {
    const METHOD: &'static str = "WebAuthn.setResponseOverrideBits";
    type Response = crate::EmptyReturns;
}

/// Removes the given authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveVirtualAuthenticatorParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> RemoveVirtualAuthenticatorParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>) -> RemoveVirtualAuthenticatorParamsBuilder<'a> {
        RemoveVirtualAuthenticatorParamsBuilder {
            authenticatorId: authenticatorId,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
}


pub struct RemoveVirtualAuthenticatorParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> RemoveVirtualAuthenticatorParamsBuilder<'a> {
    pub fn build(self) -> RemoveVirtualAuthenticatorParams<'a> {
        RemoveVirtualAuthenticatorParams {
            authenticatorId: self.authenticatorId,
        }
    }
}

impl<'a> RemoveVirtualAuthenticatorParams<'a> { pub const METHOD: &'static str = "WebAuthn.removeVirtualAuthenticator"; }

impl<'a> crate::CdpCommand<'a> for RemoveVirtualAuthenticatorParams<'a> {
    const METHOD: &'static str = "WebAuthn.removeVirtualAuthenticator";
    type Response = crate::EmptyReturns;
}

/// Adds the credential to the specified authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddCredentialParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credential: Credential<'a>,
}

impl<'a> AddCredentialParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, credential: Credential<'a>) -> AddCredentialParamsBuilder<'a> {
        AddCredentialParamsBuilder {
            authenticatorId: authenticatorId,
            credential: credential,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn credential(&self) -> &Credential<'a> { &self.credential }
}


pub struct AddCredentialParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credential: Credential<'a>,
}

impl<'a> AddCredentialParamsBuilder<'a> {
    pub fn build(self) -> AddCredentialParams<'a> {
        AddCredentialParams {
            authenticatorId: self.authenticatorId,
            credential: self.credential,
        }
    }
}

impl<'a> AddCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.addCredential"; }

impl<'a> crate::CdpCommand<'a> for AddCredentialParams<'a> {
    const METHOD: &'static str = "WebAuthn.addCredential";
    type Response = crate::EmptyReturns;
}

/// Returns a single credential stored in the given virtual authenticator that
/// matches the credential ID.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetCredentialParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
}

impl<'a> GetCredentialParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, credentialId: impl Into<Cow<'a, str>>) -> GetCredentialParamsBuilder<'a> {
        GetCredentialParamsBuilder {
            authenticatorId: authenticatorId,
            credentialId: credentialId.into(),
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn credentialId(&self) -> &str { self.credentialId.as_ref() }
}


pub struct GetCredentialParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
}

impl<'a> GetCredentialParamsBuilder<'a> {
    pub fn build(self) -> GetCredentialParams<'a> {
        GetCredentialParams {
            authenticatorId: self.authenticatorId,
            credentialId: self.credentialId,
        }
    }
}

/// Returns a single credential stored in the given virtual authenticator that
/// matches the credential ID.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetCredentialReturns<'a> {
    credential: Credential<'a>,
}

impl<'a> GetCredentialReturns<'a> {
    pub fn builder(credential: Credential<'a>) -> GetCredentialReturnsBuilder<'a> {
        GetCredentialReturnsBuilder {
            credential: credential,
        }
    }
    pub fn credential(&self) -> &Credential<'a> { &self.credential }
}


pub struct GetCredentialReturnsBuilder<'a> {
    credential: Credential<'a>,
}

impl<'a> GetCredentialReturnsBuilder<'a> {
    pub fn build(self) -> GetCredentialReturns<'a> {
        GetCredentialReturns {
            credential: self.credential,
        }
    }
}

impl<'a> GetCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.getCredential"; }

impl<'a> crate::CdpCommand<'a> for GetCredentialParams<'a> {
    const METHOD: &'static str = "WebAuthn.getCredential";
    type Response = GetCredentialReturns<'a>;
}

/// Returns all the credentials stored in the given virtual authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetCredentialsParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> GetCredentialsParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>) -> GetCredentialsParamsBuilder<'a> {
        GetCredentialsParamsBuilder {
            authenticatorId: authenticatorId,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
}


pub struct GetCredentialsParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> GetCredentialsParamsBuilder<'a> {
    pub fn build(self) -> GetCredentialsParams<'a> {
        GetCredentialsParams {
            authenticatorId: self.authenticatorId,
        }
    }
}

/// Returns all the credentials stored in the given virtual authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetCredentialsReturns<'a> {
    credentials: Vec<Credential<'a>>,
}

impl<'a> GetCredentialsReturns<'a> {
    pub fn builder(credentials: Vec<Credential<'a>>) -> GetCredentialsReturnsBuilder<'a> {
        GetCredentialsReturnsBuilder {
            credentials: credentials,
        }
    }
    pub fn credentials(&self) -> &[Credential<'a>] { &self.credentials }
}


pub struct GetCredentialsReturnsBuilder<'a> {
    credentials: Vec<Credential<'a>>,
}

impl<'a> GetCredentialsReturnsBuilder<'a> {
    pub fn build(self) -> GetCredentialsReturns<'a> {
        GetCredentialsReturns {
            credentials: self.credentials,
        }
    }
}

impl<'a> GetCredentialsParams<'a> { pub const METHOD: &'static str = "WebAuthn.getCredentials"; }

impl<'a> crate::CdpCommand<'a> for GetCredentialsParams<'a> {
    const METHOD: &'static str = "WebAuthn.getCredentials";
    type Response = GetCredentialsReturns<'a>;
}

/// Removes a credential from the authenticator.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveCredentialParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
}

impl<'a> RemoveCredentialParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, credentialId: impl Into<Cow<'a, str>>) -> RemoveCredentialParamsBuilder<'a> {
        RemoveCredentialParamsBuilder {
            authenticatorId: authenticatorId,
            credentialId: credentialId.into(),
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn credentialId(&self) -> &str { self.credentialId.as_ref() }
}


pub struct RemoveCredentialParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
}

impl<'a> RemoveCredentialParamsBuilder<'a> {
    pub fn build(self) -> RemoveCredentialParams<'a> {
        RemoveCredentialParams {
            authenticatorId: self.authenticatorId,
            credentialId: self.credentialId,
        }
    }
}

impl<'a> RemoveCredentialParams<'a> { pub const METHOD: &'static str = "WebAuthn.removeCredential"; }

impl<'a> crate::CdpCommand<'a> for RemoveCredentialParams<'a> {
    const METHOD: &'static str = "WebAuthn.removeCredential";
    type Response = crate::EmptyReturns;
}

/// Clears all the credentials from the specified device.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ClearCredentialsParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> ClearCredentialsParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>) -> ClearCredentialsParamsBuilder<'a> {
        ClearCredentialsParamsBuilder {
            authenticatorId: authenticatorId,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
}


pub struct ClearCredentialsParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
}

impl<'a> ClearCredentialsParamsBuilder<'a> {
    pub fn build(self) -> ClearCredentialsParams<'a> {
        ClearCredentialsParams {
            authenticatorId: self.authenticatorId,
        }
    }
}

impl<'a> ClearCredentialsParams<'a> { pub const METHOD: &'static str = "WebAuthn.clearCredentials"; }

impl<'a> crate::CdpCommand<'a> for ClearCredentialsParams<'a> {
    const METHOD: &'static str = "WebAuthn.clearCredentials";
    type Response = crate::EmptyReturns;
}

/// Sets whether User Verification succeeds or fails for an authenticator.
/// The default is true.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetUserVerifiedParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    isUserVerified: bool,
}

impl<'a> SetUserVerifiedParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, isUserVerified: bool) -> SetUserVerifiedParamsBuilder<'a> {
        SetUserVerifiedParamsBuilder {
            authenticatorId: authenticatorId,
            isUserVerified: isUserVerified,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn isUserVerified(&self) -> bool { self.isUserVerified }
}


pub struct SetUserVerifiedParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    isUserVerified: bool,
}

impl<'a> SetUserVerifiedParamsBuilder<'a> {
    pub fn build(self) -> SetUserVerifiedParams<'a> {
        SetUserVerifiedParams {
            authenticatorId: self.authenticatorId,
            isUserVerified: self.isUserVerified,
        }
    }
}

impl<'a> SetUserVerifiedParams<'a> { pub const METHOD: &'static str = "WebAuthn.setUserVerified"; }

impl<'a> crate::CdpCommand<'a> for SetUserVerifiedParams<'a> {
    const METHOD: &'static str = "WebAuthn.setUserVerified";
    type Response = crate::EmptyReturns;
}

/// Sets whether tests of user presence will succeed immediately (if true) or fail to resolve (if false) for an authenticator.
/// The default is true.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetAutomaticPresenceSimulationParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    enabled: bool,
}

impl<'a> SetAutomaticPresenceSimulationParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, enabled: bool) -> SetAutomaticPresenceSimulationParamsBuilder<'a> {
        SetAutomaticPresenceSimulationParamsBuilder {
            authenticatorId: authenticatorId,
            enabled: enabled,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn enabled(&self) -> bool { self.enabled }
}


pub struct SetAutomaticPresenceSimulationParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    enabled: bool,
}

impl<'a> SetAutomaticPresenceSimulationParamsBuilder<'a> {
    pub fn build(self) -> SetAutomaticPresenceSimulationParams<'a> {
        SetAutomaticPresenceSimulationParams {
            authenticatorId: self.authenticatorId,
            enabled: self.enabled,
        }
    }
}

impl<'a> SetAutomaticPresenceSimulationParams<'a> { pub const METHOD: &'static str = "WebAuthn.setAutomaticPresenceSimulation"; }

impl<'a> crate::CdpCommand<'a> for SetAutomaticPresenceSimulationParams<'a> {
    const METHOD: &'static str = "WebAuthn.setAutomaticPresenceSimulation";
    type Response = crate::EmptyReturns;
}

/// Allows setting credential properties.
/// https://w3c.github.io/webauthn/#sctn-automation-set-credential-properties

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetCredentialPropertiesParams<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
    #[serde(skip_serializing_if = "Option::is_none")]
    backupEligibility: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    backupState: Option<bool>,
}

impl<'a> SetCredentialPropertiesParams<'a> {
    pub fn builder(authenticatorId: AuthenticatorId<'a>, credentialId: impl Into<Cow<'a, str>>) -> SetCredentialPropertiesParamsBuilder<'a> {
        SetCredentialPropertiesParamsBuilder {
            authenticatorId: authenticatorId,
            credentialId: credentialId.into(),
            backupEligibility: None,
            backupState: None,
        }
    }
    pub fn authenticatorId(&self) -> &AuthenticatorId<'a> { &self.authenticatorId }
    pub fn credentialId(&self) -> &str { self.credentialId.as_ref() }
    pub fn backupEligibility(&self) -> Option<bool> { self.backupEligibility }
    pub fn backupState(&self) -> Option<bool> { self.backupState }
}


pub struct SetCredentialPropertiesParamsBuilder<'a> {
    authenticatorId: AuthenticatorId<'a>,
    credentialId: Cow<'a, str>,
    backupEligibility: Option<bool>,
    backupState: Option<bool>,
}

impl<'a> SetCredentialPropertiesParamsBuilder<'a> {
    pub fn backupEligibility(mut self, backupEligibility: bool) -> Self { self.backupEligibility = Some(backupEligibility); self }
    pub fn backupState(mut self, backupState: bool) -> Self { self.backupState = Some(backupState); self }
    pub fn build(self) -> SetCredentialPropertiesParams<'a> {
        SetCredentialPropertiesParams {
            authenticatorId: self.authenticatorId,
            credentialId: self.credentialId,
            backupEligibility: self.backupEligibility,
            backupState: self.backupState,
        }
    }
}

impl<'a> SetCredentialPropertiesParams<'a> { pub const METHOD: &'static str = "WebAuthn.setCredentialProperties"; }

impl<'a> crate::CdpCommand<'a> for SetCredentialPropertiesParams<'a> {
    const METHOD: &'static str = "WebAuthn.setCredentialProperties";
    type Response = crate::EmptyReturns;
}