001package Torello.Browser.BrowserAPI;
002
003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
004// Java-HTML Imports
005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
006
007import Torello.Browser.*;
008import Torello.Browser.helper.*;
009import Torello.Browser.JavaScriptAPI.*;
010import Torello.JSON.*;
011
012import Torello.Java.ReadOnly.ReadOnlyList;
013import Torello.Java.ReadOnly.ReadOnlyArrayList;
014
015import Torello.JavaDoc.Annotations.StaticFunctional;
016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
017
018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.WebAuthn$$Commands;
019
020
021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
022// JDK Imports
023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
024
025import javax.json.JsonObject;
026import javax.json.JsonValue;
027
028/**
029 * <SPAN CLASS=COPIEDJDK><B>This domain allows configuring virtual authenticators to test the WebAuthn
030 * API.</B></SPAN>
031 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE>
032 */
033@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE")
034public class WebAuthn
035{
036    // No Pubic Constructors
037    private WebAuthn() { }
038
039
040    // ********************************************************************************************
041    // ********************************************************************************************
042    // Eliminated Types
043    // ********************************************************************************************
044    // ********************************************************************************************
045
046
047    /**
048     * <CODE>[No Description Provided by Google]</CODE>
049
050     * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType
051     *     DATA-NAME=AuthenticatorId>
052     */
053    public static final String AuthenticatorId =
054        "AuthenticatorId has been eliminated.\n" +
055        "It was replaced with the standard Java-Type: String";
056
057
058    // ********************************************************************************************
059    // ********************************************************************************************
060    // Enumerated String Constants Lists
061    // ********************************************************************************************
062    // ********************************************************************************************
063
064
065    /**
066     * <CODE>[No Description Provided by Google]</CODE>
067     * <BR /><BR /><B CLASS=StrEnumType>String-Enumeration Type</B>
068     */
069    public static final ReadOnlyList<String> AuthenticatorProtocol = new ReadOnlyArrayList<>
070        (String.class, "ctap2", "u2f");
071
072    /**
073     * <CODE>[No Description Provided by Google]</CODE>
074     * <BR /><BR /><B CLASS=StrEnumType>String-Enumeration Type</B>
075     */
076    public static final ReadOnlyList<String> AuthenticatorTransport = new ReadOnlyArrayList<>
077        (String.class, "ble", "cable", "internal", "nfc", "usb");
078
079    /**
080     * <CODE>[No Description Provided by Google]</CODE>
081     * <BR /><BR /><B CLASS=StrEnumType>String-Enumeration Type</B>
082     */
083    public static final ReadOnlyList<String> Ctap2Version = new ReadOnlyArrayList<>
084        (String.class, "ctap2_0", "ctap2_1");
085
086
087
088    // ********************************************************************************************
089    // ********************************************************************************************
090    // Basic Types
091    // ********************************************************************************************
092    // ********************************************************************************************
093
094
095    /**
096     * <CODE>[No Description Provided by Google]</CODE>
097     * 
098     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
099     */
100    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
101    public static class Credential
102        extends BaseType<Credential>
103        implements java.io.Serializable
104    {
105        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
106        protected static final long serialVersionUID = 1;
107
108        private static final NestedHelper<WebAuthn.Credential> singleton =
109            Torello.Browser.BrowserAPI.NestedHelpers.Types.
110                WebAuthn$$Credential$$.singleton;
111
112        /** <CODE>[No Description Provided by Google]</CODE> */
113        public final String credentialId;
114
115        /** <CODE>[No Description Provided by Google]</CODE> */
116        public final boolean isResidentCredential;
117
118        /**
119         * Relying Party ID the credential is scoped to. Must be set when adding a
120         * credential.
121         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
122         */
123        public final String rpId;
124
125        /** The ECDSA P-256 private key in PKCS#8 format. (Encoded as a base64 string when passed over JSON) */
126        public final String privateKey;
127
128        /**
129         * An opaque byte sequence with a maximum size of 64 bytes mapping the
130         * credential to a specific user. (Encoded as a base64 string when passed over JSON)
131         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
132         */
133        public final String userHandle;
134
135        /**
136         * Signature counter. This is incremented by one for each successful
137         * assertion.
138         * See https://w3c.github.io/webauthn/#signature-counter
139         */
140        public final int signCount;
141
142        /**
143         * The large blob associated with the credential.
144         * See https://w3c.github.io/webauthn/#sctn-large-blob-extension (Encoded as a base64 string when passed over JSON)
145         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
146         */
147        public final String largeBlob;
148
149        /**
150         * Assertions returned by this credential will have the backup eligibility
151         * (BE) flag set to this value. Defaults to the authenticator's
152         * defaultBackupEligibility value.
153         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
154         */
155        public final Boolean backupEligibility;
156
157        /**
158         * Assertions returned by this credential will have the backup state (BS)
159         * flag set to this value. Defaults to the authenticator's
160         * defaultBackupState value.
161         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
162         */
163        public final Boolean backupState;
164
165        /**
166         * The credential's user.name property. Equivalent to empty if not set.
167         * https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name
168         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
169         */
170        public final String userName;
171
172        /**
173         * The credential's user.displayName property. Equivalent to empty if
174         * not set.
175         * https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname
176         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
177         */
178        public final String userDisplayName;
179
180        /** Constructor.  Please review this class' fields for documentation. */
181        public Credential(
182                ReadOnlyList<Boolean> isPresent, String credentialId, boolean isResidentCredential,
183                String rpId, String privateKey, String userHandle, int signCount, String largeBlob,
184                Boolean backupEligibility, Boolean backupState, String userName,
185                String userDisplayName
186            )
187        {
188            super(singleton, Domains.WebAuthn, "Credential", 11);
189
190            this.credentialId           = credentialId;
191            this.isResidentCredential   = isResidentCredential;
192            this.rpId                   = rpId;
193            this.privateKey             = privateKey;
194            this.userHandle             = userHandle;
195            this.signCount              = signCount;
196            this.largeBlob              = largeBlob;
197            this.backupEligibility      = backupEligibility;
198            this.backupState            = backupState;
199            this.userName               = userName;
200            this.userDisplayName        = userDisplayName;
201
202            this.isPresent = (isPresent == null)
203                ? singleton.generateIsPresentList(this)
204                : THROWS.check(isPresent, 11, "WebAuthn.Credential");
205        }
206
207        /** Creates an instance of this class from a {@link JsonObject}.*/
208        public static Credential fromJSON(JsonObject jo)
209        { return singleton.fromJSON(jo); }
210
211        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
212        public static NestedDescriptor<Credential> descriptor()
213        { return singleton.descriptor(); }
214    }
215
216    /**
217     * <CODE>[No Description Provided by Google]</CODE>
218     * 
219     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
220     */
221    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
222    public static class VirtualAuthenticatorOptions
223        extends BaseType<VirtualAuthenticatorOptions>
224        implements java.io.Serializable
225    {
226        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
227        protected static final long serialVersionUID = 1;
228
229        private static final NestedHelper<WebAuthn.VirtualAuthenticatorOptions> singleton =
230            Torello.Browser.BrowserAPI.NestedHelpers.Types.
231                WebAuthn$$VirtualAuthenticatorOptions$$.singleton;
232
233        /**
234         * <CODE>[No Description Provided by Google]</CODE>
235         * <EMBED CLASS='external-html' DATA-D=WebAuthn DATA-C=AuthenticatorProtocol DATA-F=protocol DATA-FILE-ID=CDP.EL2>
236         * @see BaseType#enumStrList(String)
237         */
238        public final String protocol;
239
240        /**
241         * Defaults to ctap2_0. Ignored if |protocol| == u2f.
242         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
243         * <EMBED CLASS='external-html' DATA-D=WebAuthn DATA-C=Ctap2Version DATA-F=ctap2Version DATA-FILE-ID=CDP.EL2>
244         * @see BaseType#enumStrList(String)
245         */
246        public final String ctap2Version;
247
248        /**
249         * <CODE>[No Description Provided by Google]</CODE>
250         * <EMBED CLASS='external-html' DATA-D=WebAuthn DATA-C=AuthenticatorTransport DATA-F=transport DATA-FILE-ID=CDP.EL2>
251         * @see BaseType#enumStrList(String)
252         */
253        public final String transport;
254
255        /**
256         * Defaults to false.
257         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
258         */
259        public final Boolean hasResidentKey;
260
261        /**
262         * Defaults to false.
263         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
264         */
265        public final Boolean hasUserVerification;
266
267        /**
268         * If set to true, the authenticator will support the largeBlob extension.
269         * https://w3c.github.io/webauthn#largeBlob
270         * Defaults to false.
271         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
272         */
273        public final Boolean hasLargeBlob;
274
275        /**
276         * If set to true, the authenticator will support the credBlob extension.
277         * https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension
278         * Defaults to false.
279         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
280         */
281        public final Boolean hasCredBlob;
282
283        /**
284         * If set to true, the authenticator will support the minPinLength extension.
285         * https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension
286         * Defaults to false.
287         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
288         */
289        public final Boolean hasMinPinLength;
290
291        /**
292         * If set to true, the authenticator will support the prf extension.
293         * https://w3c.github.io/webauthn/#prf-extension
294         * Defaults to false.
295         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
296         */
297        public final Boolean hasPrf;
298
299        /**
300         * If set to true, tests of user presence will succeed immediately.
301         * Otherwise, they will not be resolved. Defaults to true.
302         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
303         */
304        public final Boolean automaticPresenceSimulation;
305
306        /**
307         * Sets whether User Verification succeeds or fails for an authenticator.
308         * Defaults to false.
309         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
310         */
311        public final Boolean isUserVerified;
312
313        /**
314         * Credentials created by this authenticator will have the backup
315         * eligibility (BE) flag set to this value. Defaults to false.
316         * https://w3c.github.io/webauthn/#sctn-credential-backup
317         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
318         */
319        public final Boolean defaultBackupEligibility;
320
321        /**
322         * Credentials created by this authenticator will have the backup state
323         * (BS) flag set to this value. Defaults to false.
324         * https://w3c.github.io/webauthn/#sctn-credential-backup
325         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
326         */
327        public final Boolean defaultBackupState;
328
329        /** Constructor.  Please review this class' fields for documentation. */
330        public VirtualAuthenticatorOptions(
331                ReadOnlyList<Boolean> isPresent, String protocol, String ctap2Version,
332                String transport, Boolean hasResidentKey, Boolean hasUserVerification,
333                Boolean hasLargeBlob, Boolean hasCredBlob, Boolean hasMinPinLength, Boolean hasPrf,
334                Boolean automaticPresenceSimulation, Boolean isUserVerified,
335                Boolean defaultBackupEligibility, Boolean defaultBackupState
336            )
337        {
338            super(singleton, Domains.WebAuthn, "VirtualAuthenticatorOptions", 13);
339
340            this.protocol                       = protocol;
341            this.ctap2Version                   = ctap2Version;
342            this.transport                      = transport;
343            this.hasResidentKey                 = hasResidentKey;
344            this.hasUserVerification            = hasUserVerification;
345            this.hasLargeBlob                   = hasLargeBlob;
346            this.hasCredBlob                    = hasCredBlob;
347            this.hasMinPinLength                = hasMinPinLength;
348            this.hasPrf                         = hasPrf;
349            this.automaticPresenceSimulation    = automaticPresenceSimulation;
350            this.isUserVerified                 = isUserVerified;
351            this.defaultBackupEligibility       = defaultBackupEligibility;
352            this.defaultBackupState             = defaultBackupState;
353
354            this.isPresent = (isPresent == null)
355                ? singleton.generateIsPresentList(this)
356                : THROWS.check(isPresent, 13, "WebAuthn.VirtualAuthenticatorOptions");
357        }
358
359        /** Creates an instance of this class from a {@link JsonObject}.*/
360        public static VirtualAuthenticatorOptions fromJSON(JsonObject jo)
361        { return singleton.fromJSON(jo); }
362
363        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
364        public static NestedDescriptor<VirtualAuthenticatorOptions> descriptor()
365        { return singleton.descriptor(); }
366    }
367
368
369    // ********************************************************************************************
370    // ********************************************************************************************
371    // Event Types
372    // ********************************************************************************************
373    // ********************************************************************************************
374
375
376    /**
377     * Triggered when a credential is added to an authenticator.
378     * 
379     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
380     */
381    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
382    public static class credentialAdded
383        extends BrowserEvent<credentialAdded>
384        implements java.io.Serializable
385    {
386        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
387        protected static final long serialVersionUID = 1;
388
389        private static final NestedHelper<WebAuthn.credentialAdded> singleton =
390            Torello.Browser.BrowserAPI.NestedHelpers.Events.
391                WebAuthn$$credentialAdded$$.singleton;
392
393        /** <CODE>[No Description Provided by Google]</CODE> */
394        public final String authenticatorId;
395
396        /** <CODE>[No Description Provided by Google]</CODE> */
397        public final WebAuthn.Credential credential;
398
399        /** Constructor.  Please review this class' fields for documentation. */
400        public credentialAdded
401            (ReadOnlyList<Boolean> isPresent, String authenticatorId, Credential credential)
402        {
403            super(singleton, Domains.WebAuthn, "credentialAdded", 2);
404
405            this.authenticatorId    = authenticatorId;
406            this.credential         = credential;
407
408            this.isPresent = (isPresent == null)
409                ? singleton.generateIsPresentList(this)
410                : THROWS.check(isPresent, 2, "WebAuthn.credentialAdded");
411        }
412
413        /** Creates an instance of this class from a {@link JsonObject}.*/
414        public static credentialAdded fromJSON(JsonObject jo)
415        { return singleton.fromJSON(jo); }
416
417        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
418        public static NestedDescriptor<credentialAdded> descriptor()
419        { return singleton.descriptor(); }
420    }
421
422    /**
423     * Triggered when a credential is used in a webauthn assertion.
424     * 
425     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
426     */
427    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
428    public static class credentialAsserted
429        extends BrowserEvent<credentialAsserted>
430        implements java.io.Serializable
431    {
432        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
433        protected static final long serialVersionUID = 1;
434
435        private static final NestedHelper<WebAuthn.credentialAsserted> singleton =
436            Torello.Browser.BrowserAPI.NestedHelpers.Events.
437                WebAuthn$$credentialAsserted$$.singleton;
438
439        /** <CODE>[No Description Provided by Google]</CODE> */
440        public final String authenticatorId;
441
442        /** <CODE>[No Description Provided by Google]</CODE> */
443        public final WebAuthn.Credential credential;
444
445        /** Constructor.  Please review this class' fields for documentation. */
446        public credentialAsserted
447            (ReadOnlyList<Boolean> isPresent, String authenticatorId, Credential credential)
448        {
449            super(singleton, Domains.WebAuthn, "credentialAsserted", 2);
450
451            this.authenticatorId    = authenticatorId;
452            this.credential         = credential;
453
454            this.isPresent = (isPresent == null)
455                ? singleton.generateIsPresentList(this)
456                : THROWS.check(isPresent, 2, "WebAuthn.credentialAsserted");
457        }
458
459        /** Creates an instance of this class from a {@link JsonObject}.*/
460        public static credentialAsserted fromJSON(JsonObject jo)
461        { return singleton.fromJSON(jo); }
462
463        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
464        public static NestedDescriptor<credentialAsserted> descriptor()
465        { return singleton.descriptor(); }
466    }
467
468    /**
469     * Triggered when a credential is deleted, e.g. through
470     * PublicKeyCredential.signalUnknownCredential().
471     * 
472     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
473     */
474    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
475    public static class credentialDeleted
476        extends BrowserEvent<credentialDeleted>
477        implements java.io.Serializable
478    {
479        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
480        protected static final long serialVersionUID = 1;
481
482        private static final NestedHelper<WebAuthn.credentialDeleted> singleton =
483            Torello.Browser.BrowserAPI.NestedHelpers.Events.
484                WebAuthn$$credentialDeleted$$.singleton;
485
486        /** <CODE>[No Description Provided by Google]</CODE> */
487        public final String authenticatorId;
488
489        /** <CODE>[No Description Provided by Google]</CODE> */
490        public final String credentialId;
491
492        /** Constructor.  Please review this class' fields for documentation. */
493        public credentialDeleted
494            (ReadOnlyList<Boolean> isPresent, String authenticatorId, String credentialId)
495        {
496            super(singleton, Domains.WebAuthn, "credentialDeleted", 2);
497
498            this.authenticatorId    = authenticatorId;
499            this.credentialId       = credentialId;
500
501            this.isPresent = (isPresent == null)
502                ? singleton.generateIsPresentList(this)
503                : THROWS.check(isPresent, 2, "WebAuthn.credentialDeleted");
504        }
505
506        /** Creates an instance of this class from a {@link JsonObject}.*/
507        public static credentialDeleted fromJSON(JsonObject jo)
508        { return singleton.fromJSON(jo); }
509
510        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
511        public static NestedDescriptor<credentialDeleted> descriptor()
512        { return singleton.descriptor(); }
513    }
514
515    /**
516     * Triggered when a credential is updated, e.g. through
517     * PublicKeyCredential.signalCurrentUserDetails().
518     * 
519     * <EMBED CLASS=globalDefs DATA-DOMAIN=WebAuthn DATA-API=BrowserAPI>
520     */
521    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
522    public static class credentialUpdated
523        extends BrowserEvent<credentialUpdated>
524        implements java.io.Serializable
525    {
526        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
527        protected static final long serialVersionUID = 1;
528
529        private static final NestedHelper<WebAuthn.credentialUpdated> singleton =
530            Torello.Browser.BrowserAPI.NestedHelpers.Events.
531                WebAuthn$$credentialUpdated$$.singleton;
532
533        /** <CODE>[No Description Provided by Google]</CODE> */
534        public final String authenticatorId;
535
536        /** <CODE>[No Description Provided by Google]</CODE> */
537        public final WebAuthn.Credential credential;
538
539        /** Constructor.  Please review this class' fields for documentation. */
540        public credentialUpdated
541            (ReadOnlyList<Boolean> isPresent, String authenticatorId, Credential credential)
542        {
543            super(singleton, Domains.WebAuthn, "credentialUpdated", 2);
544
545            this.authenticatorId    = authenticatorId;
546            this.credential         = credential;
547
548            this.isPresent = (isPresent == null)
549                ? singleton.generateIsPresentList(this)
550                : THROWS.check(isPresent, 2, "WebAuthn.credentialUpdated");
551        }
552
553        /** Creates an instance of this class from a {@link JsonObject}.*/
554        public static credentialUpdated fromJSON(JsonObject jo)
555        { return singleton.fromJSON(jo); }
556
557        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
558        public static NestedDescriptor<credentialUpdated> descriptor()
559        { return singleton.descriptor(); }
560    }
561
562
563
564
565    // ********************************************************************************************
566    // ********************************************************************************************
567    // Commands
568    // ********************************************************************************************
569    // ********************************************************************************************
570
571
572    /**
573     * Adds the credential to the specified authenticator.
574     * 
575     * @param authenticatorId -
576     * 
577     * @param credential -
578     * 
579     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
580     *
581     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
582     * browser receives the invocation-request.
583     *
584     * <BR /><BR /><DIV CLASS=JDHint>
585     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
586     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
587     * the Browser Function has run to completion.
588     * </DIV>
589     */
590    public static Script<Void> addCredential(String authenticatorId, Credential credential)
591    {
592        // Convert all Method Parameters into a JSON Request-Object (as a String)
593        final String requestJSON = WriteJSON.get(
594            WebAuthn$$Commands.addCredential$$, "WebAuthn.addCredential",
595            authenticatorId, credential
596        );
597
598        return Script.NO_RET(Domains.WebAuthn, "addCredential", requestJSON);
599    }
600
601    /**
602     * Creates and adds a virtual authenticator.
603     * 
604     * @param options -
605     * 
606     * @return An instance of <CODE>{@link Script}&lt;String&gt;</CODE>
607     * 
608     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
609     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
610     * <CODE>&lt;String&gt;</CODE> will be returned
611     *
612     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
613     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
614     * be retrieved.</I>
615     *
616     * <BR /><BR /><DIV CLASS=JDHint>
617     * This Browser Function's {@code Promise} returns:
618     * <CODE>String (<B>authenticatorId</B>)</CODE>
619     * </DIV>
620     */
621    public static Script<String> addVirtualAuthenticator(VirtualAuthenticatorOptions options)
622    {
623        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
624        final String requestJSON = WriteJSON.get
625            (CDPTypes.CDP_TYPE, "options", false, "WebAuthn.addVirtualAuthenticator", options);
626
627        return new Script<>(
628            Domains.WebAuthn, "addVirtualAuthenticator", requestJSON,
629            jo -> ReadJSON.getString(jo, "authenticatorId", true, false),
630            String.class
631        );
632    }
633
634    /**
635     * Clears all the credentials from the specified device.
636     * 
637     * @param authenticatorId -
638     * 
639     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
640     *
641     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
642     * browser receives the invocation-request.
643     *
644     * <BR /><BR /><DIV CLASS=JDHint>
645     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
646     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
647     * the Browser Function has run to completion.
648     * </DIV>
649     */
650    public static Script<Void> clearCredentials(String authenticatorId)
651    {
652        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
653        final String requestJSON = WriteJSON.get(
654            CDPTypes.STRING, "authenticatorId", false, "WebAuthn.clearCredentials",
655            authenticatorId
656        );
657
658        return Script.NO_RET(Domains.WebAuthn, "clearCredentials", requestJSON);
659    }
660
661    /**
662     * Disable the WebAuthn domain.
663     * 
664     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
665     *
666     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
667     * browser receives the invocation-request.
668     *
669     * <BR /><BR /><DIV CLASS=JDHint>
670     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
671     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
672     * the Browser Function has run to completion.
673     * </DIV>
674     */
675    public static Script<Void> disable()
676    {
677        // Ultra-Simple Request JSON - Because this method has no parameters
678        final String requestJSON = "{\"method\":\"WebAuthn.disable\"}";
679
680        return Script.NO_RET(Domains.WebAuthn, "disable", requestJSON);
681    }
682
683    /**
684     * Enable the WebAuthn domain and start intercepting credential storage and
685     * retrieval with a virtual authenticator.
686     * 
687     * @param enableUI 
688     * Whether to enable the WebAuthn user interface. Enabling the UI is
689     * recommended for debugging and demo purposes, as it is closer to the real
690     * experience. Disabling the UI is recommended for automated testing.
691     * Supported at the embedder's discretion if UI is available.
692     * Defaults to false.
693     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
694     * 
695     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
696     *
697     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
698     * browser receives the invocation-request.
699     *
700     * <BR /><BR /><DIV CLASS=JDHint>
701     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
702     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
703     * the Browser Function has run to completion.
704     * </DIV>
705     */
706    public static Script<Void> enable(Boolean enableUI)
707    {
708        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
709        final String requestJSON = WriteJSON.get
710            (CDPTypes.BOXED_BOOLEAN, "enableUI", true, "WebAuthn.enable", enableUI);
711
712        return Script.NO_RET(Domains.WebAuthn, "enable", requestJSON);
713    }
714
715    /**
716     * Returns a single credential stored in the given virtual authenticator that
717     * matches the credential ID.
718     * 
719     * @param authenticatorId -
720     * 
721     * @param credentialId -
722     * 
723     * @return An instance of <CODE>{@link Script}&lt;{@link WebAuthn.Credential}&gt;</CODE>
724     * 
725     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
726     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
727     * <CODE>&lt;{@link WebAuthn.Credential}&gt;</CODE> will be returned
728     *
729     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
730     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
731     * be retrieved.</I>
732     *
733     * <BR /><BR /><DIV CLASS=JDHint>
734     * This Browser Function's {@code Promise} returns:
735     * <CODE>{@link WebAuthn.Credential} (<B>credential</B>)</CODE>
736     * </DIV>
737     */
738    public static Script<WebAuthn.Credential> getCredential
739        (String authenticatorId, String credentialId)
740    {
741        // Convert all Method Parameters into a JSON Request-Object (as a String)
742        final String requestJSON = WriteJSON.get(
743            WebAuthn$$Commands.getCredential$$, "WebAuthn.getCredential",
744            authenticatorId, credentialId
745        );
746
747        return new Script<>(
748            Domains.WebAuthn, "getCredential", requestJSON,
749            WebAuthn$$Commands::getCredential,
750            WebAuthn.Credential.class
751        );
752    }
753
754    /**
755     * Returns all the credentials stored in the given virtual authenticator.
756     * 
757     * @param authenticatorId -
758     * 
759     * @return An instance of <CODE>{@link Script}&lt;{@link WebAuthn.Credential}[]&gt;</CODE>
760     * 
761     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
762     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
763     * <CODE>&lt;{@link WebAuthn.Credential}[]&gt;</CODE> will be returned
764     *
765     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
766     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
767     * be retrieved.</I>
768     *
769     * <BR /><BR /><DIV CLASS=JDHint>
770     * This Browser Function's {@code Promise} returns:
771     * <CODE>{@link WebAuthn.Credential}[] (<B>credentials</B>)</CODE>
772     * </DIV>
773     */
774    public static Script<WebAuthn.Credential[]> getCredentials(String authenticatorId)
775    {
776        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
777        final String requestJSON = WriteJSON.get(
778            CDPTypes.STRING, "authenticatorId", false, "WebAuthn.getCredentials",
779            authenticatorId
780        );
781
782        return new Script<>(
783            Domains.WebAuthn, "getCredentials", requestJSON,
784            WebAuthn$$Commands::getCredentials,
785            WebAuthn.Credential[].class
786        );
787    }
788
789    /**
790     * Removes a credential from the authenticator.
791     * 
792     * @param authenticatorId -
793     * 
794     * @param credentialId -
795     * 
796     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
797     *
798     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
799     * browser receives the invocation-request.
800     *
801     * <BR /><BR /><DIV CLASS=JDHint>
802     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
803     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
804     * the Browser Function has run to completion.
805     * </DIV>
806     */
807    public static Script<Void> removeCredential(String authenticatorId, String credentialId)
808    {
809        // Convert all Method Parameters into a JSON Request-Object (as a String)
810        final String requestJSON = WriteJSON.get(
811            WebAuthn$$Commands.removeCredential$$, "WebAuthn.removeCredential",
812            authenticatorId, credentialId
813        );
814
815        return Script.NO_RET(Domains.WebAuthn, "removeCredential", requestJSON);
816    }
817
818    /**
819     * Removes the given authenticator.
820     * 
821     * @param authenticatorId -
822     * 
823     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
824     *
825     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
826     * browser receives the invocation-request.
827     *
828     * <BR /><BR /><DIV CLASS=JDHint>
829     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
830     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
831     * the Browser Function has run to completion.
832     * </DIV>
833     */
834    public static Script<Void> removeVirtualAuthenticator(String authenticatorId)
835    {
836        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
837        final String requestJSON = WriteJSON.get(
838            CDPTypes.STRING, "authenticatorId", false, "WebAuthn.removeVirtualAuthenticator",
839            authenticatorId
840        );
841
842        return Script.NO_RET(Domains.WebAuthn, "removeVirtualAuthenticator", requestJSON);
843    }
844
845    /**
846     * Sets whether tests of user presence will succeed immediately (if true) or fail to resolve (if false) for an authenticator.
847     * The default is true.
848     * 
849     * @param authenticatorId -
850     * 
851     * @param enabled -
852     * 
853     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
854     *
855     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
856     * browser receives the invocation-request.
857     *
858     * <BR /><BR /><DIV CLASS=JDHint>
859     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
860     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
861     * the Browser Function has run to completion.
862     * </DIV>
863     */
864    public static Script<Void> setAutomaticPresenceSimulation
865        (String authenticatorId, boolean enabled)
866    {
867        // Convert all Method Parameters into a JSON Request-Object (as a String)
868        final String requestJSON = WriteJSON.get(
869            WebAuthn$$Commands.setAutomaticPresenceSimulation$$,
870            "WebAuthn.setAutomaticPresenceSimulation",
871            authenticatorId, enabled
872        );
873
874        return Script.NO_RET(Domains.WebAuthn, "setAutomaticPresenceSimulation", requestJSON);
875    }
876
877    /**
878     * Allows setting credential properties.
879     * https://w3c.github.io/webauthn/#sctn-automation-set-credential-properties
880     * 
881     * @param authenticatorId -
882     * 
883     * @param credentialId -
884     * 
885     * @param backupEligibility -
886     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
887     * 
888     * @param backupState -
889     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
890     * 
891     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
892     *
893     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
894     * browser receives the invocation-request.
895     *
896     * <BR /><BR /><DIV CLASS=JDHint>
897     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
898     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
899     * the Browser Function has run to completion.
900     * </DIV>
901     */
902    public static Script<Void> setCredentialProperties(
903            String authenticatorId, String credentialId, Boolean backupEligibility,
904            Boolean backupState
905        )
906    {
907        // Convert all Method Parameters into a JSON Request-Object (as a String)
908        final String requestJSON = WriteJSON.get(
909            WebAuthn$$Commands.setCredentialProperties$$, "WebAuthn.setCredentialProperties",
910            authenticatorId, credentialId, backupEligibility, backupState
911        );
912
913        return Script.NO_RET(Domains.WebAuthn, "setCredentialProperties", requestJSON);
914    }
915
916    /**
917     * Resets parameters isBogusSignature, isBadUV, isBadUP to false if they are not present.
918     * 
919     * @param authenticatorId -
920     * 
921     * @param isBogusSignature 
922     * If isBogusSignature is set, overrides the signature in the authenticator response to be zero.
923     * Defaults to false.
924     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
925     * 
926     * @param isBadUV 
927     * If isBadUV is set, overrides the UV bit in the flags in the authenticator response to
928     * be zero. Defaults to false.
929     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
930     * 
931     * @param isBadUP 
932     * If isBadUP is set, overrides the UP bit in the flags in the authenticator response to
933     * be zero. Defaults to false.
934     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
935     * 
936     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
937     *
938     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
939     * browser receives the invocation-request.
940     *
941     * <BR /><BR /><DIV CLASS=JDHint>
942     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
943     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
944     * the Browser Function has run to completion.
945     * </DIV>
946     */
947    public static Script<Void> setResponseOverrideBits
948        (String authenticatorId, Boolean isBogusSignature, Boolean isBadUV, Boolean isBadUP)
949    {
950        // Convert all Method Parameters into a JSON Request-Object (as a String)
951        final String requestJSON = WriteJSON.get(
952            WebAuthn$$Commands.setResponseOverrideBits$$, "WebAuthn.setResponseOverrideBits",
953            authenticatorId, isBogusSignature, isBadUV, isBadUP
954        );
955
956        return Script.NO_RET(Domains.WebAuthn, "setResponseOverrideBits", requestJSON);
957    }
958
959    /**
960     * Sets whether User Verification succeeds or fails for an authenticator.
961     * The default is true.
962     * 
963     * @param authenticatorId -
964     * 
965     * @param isUserVerified -
966     * 
967     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
968     *
969     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
970     * browser receives the invocation-request.
971     *
972     * <BR /><BR /><DIV CLASS=JDHint>
973     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
974     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
975     * the Browser Function has run to completion.
976     * </DIV>
977     */
978    public static Script<Void> setUserVerified(String authenticatorId, boolean isUserVerified)
979    {
980        // Convert all Method Parameters into a JSON Request-Object (as a String)
981        final String requestJSON = WriteJSON.get(
982            WebAuthn$$Commands.setUserVerified$$, "WebAuthn.setUserVerified",
983            authenticatorId, isUserVerified
984        );
985
986        return Script.NO_RET(Domains.WebAuthn, "setUserVerified", requestJSON);
987    }
988
989
990}