001package Torello.Browser.BrowserAPI;
002
003import java.util.*;
004import javax.json.*;
005import javax.json.stream.*;
006import java.io.*;
007
008import java.lang.reflect.Method;
009import java.lang.reflect.Parameter;
010import java.util.function.Function;
011
012import Torello.Browser.BrowserEvent;
013import Torello.Browser.JavaScriptAPI.*;
014import Torello.Browser.helper.*;
015
016import Torello.Java.Additional.*;
017import Torello.Java.JSON.*;
018
019import static Torello.Java.JSON.JFlag.*;
020
021import Torello.Java.StrCmpr;
022import Torello.JavaDoc.StaticFunctional;
023import Torello.JavaDoc.JDHeaderBackgroundImg;
024import Torello.JavaDoc.Excuse;
025
026/**
027 * <SPAN CLASS=COPIEDJDK><B>This domain allows interacting with the FedCM dialog.</B></SPAN>
028 * 
029 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
030 */
031@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
032@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
033public class FedCm
034{
035    // ********************************************************************************************
036    // ********************************************************************************************
037    // Class Header Stuff
038    // ********************************************************************************************
039    // ********************************************************************************************
040
041
042    // No Pubic Constructors
043    private FedCm () { }
044
045    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
046    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
047    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
048    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
049
050    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
051    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
052    // offically, two empty-vectors.  One for String's, and the other for Classes.
053
054    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
055    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
056
057    static
058    {
059        for (Method m : FedCm.class.getMethods())
060        {
061            // This doesn't work!  The parameter names are all "arg0" ... "argN"
062            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
063            //
064            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
065
066            Vector<Class<?>> parameterTypesList = new Vector<>();
067        
068            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
069
070            parameterTypes.put(
071                m.getName(),
072                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
073            );
074        }
075    }
076
077    static
078    {
079        Vector<String> v = null;
080
081        v = new Vector<String>(1);
082        parameterNames.put("enable", v);
083        Collections.addAll(v, new String[]
084        { "disableRejectionDelay", });
085
086        parameterNames.put("disable", EMPTY_VEC_STR);
087
088        v = new Vector<String>(2);
089        parameterNames.put("selectAccount", v);
090        Collections.addAll(v, new String[]
091        { "dialogId", "accountIndex", });
092
093        v = new Vector<String>(2);
094        parameterNames.put("clickDialogButton", v);
095        Collections.addAll(v, new String[]
096        { "dialogId", "dialogButton", });
097
098        v = new Vector<String>(3);
099        parameterNames.put("openUrl", v);
100        Collections.addAll(v, new String[]
101        { "dialogId", "accountIndex", "accountUrlType", });
102
103        v = new Vector<String>(2);
104        parameterNames.put("dismissDialog", v);
105        Collections.addAll(v, new String[]
106        { "dialogId", "triggerCooldown", });
107
108        parameterNames.put("resetCooldown", EMPTY_VEC_STR);
109    }
110
111
112    // ********************************************************************************************
113    // ********************************************************************************************
114    // Types - Static Inner Classes
115    // ********************************************************************************************
116    // ********************************************************************************************
117
118    /**
119     * Whether this is a sign-up or sign-in action for this account, i.e.
120     * whether this account has ever been used to sign in to this RP before.
121     */
122    public static final String[] LoginState =
123    { "SignIn", "SignUp", };
124    
125    /** The types of FedCM dialogs. */
126    public static final String[] DialogType =
127    { "AccountChooser", "AutoReauthn", "ConfirmIdpLogin", "Error", };
128    
129    /** The buttons on the FedCM dialog. */
130    public static final String[] DialogButton =
131    { "ConfirmIdpLoginContinue", "ErrorGotIt", "ErrorMoreDetails", };
132    
133    /** The URLs that each account has */
134    public static final String[] AccountUrlType =
135    { "TermsOfService", "PrivacyPolicy", };
136    
137    /** Corresponds to IdentityRequestAccount */
138    public static class Account
139        extends BaseType
140        implements java.io.Serializable
141    {
142        /** For Object Serialization.  java.io.Serializable */
143        protected static final long serialVersionUID = 1;
144        
145        public boolean[] optionals()
146        { return new boolean[] { false, false, false, false, false, false, false, false, true, true, }; }
147        
148        /** <CODE>[No Description Provided by Google]</CODE> */
149        public final String accountId;
150        
151        /** <CODE>[No Description Provided by Google]</CODE> */
152        public final String email;
153        
154        /** <CODE>[No Description Provided by Google]</CODE> */
155        public final String name;
156        
157        /** <CODE>[No Description Provided by Google]</CODE> */
158        public final String givenName;
159        
160        /** <CODE>[No Description Provided by Google]</CODE> */
161        public final String pictureUrl;
162        
163        /** <CODE>[No Description Provided by Google]</CODE> */
164        public final String idpConfigUrl;
165        
166        /** <CODE>[No Description Provided by Google]</CODE> */
167        public final String idpLoginUrl;
168        
169        /** <CODE>[No Description Provided by Google]</CODE> */
170        public final String loginState;
171        
172        /**
173         * These two are only set if the loginState is signUp
174         * <BR /><B CLASS=Opt>OPTIONAL</B>
175         */
176        public final String termsOfServiceUrl;
177        
178        /**
179         * <CODE>[No Description Provided by Google]</CODE>
180         * <BR /><B CLASS=Opt>OPTIONAL</B>
181         */
182        public final String privacyPolicyUrl;
183        
184        /**
185         * Constructor
186         *
187         * @param accountId -
188         * 
189         * @param email -
190         * 
191         * @param name -
192         * 
193         * @param givenName -
194         * 
195         * @param pictureUrl -
196         * 
197         * @param idpConfigUrl -
198         * 
199         * @param idpLoginUrl -
200         * 
201         * @param loginState -
202         * 
203         * @param termsOfServiceUrl These two are only set if the loginState is signUp
204         * <BR /><B CLASS=Opt>OPTIONAL</B>
205         * 
206         * @param privacyPolicyUrl -
207         * <BR /><B CLASS=Opt>OPTIONAL</B>
208         */
209        public Account(
210                String accountId, String email, String name, String givenName, String pictureUrl, 
211                String idpConfigUrl, String idpLoginUrl, String loginState, 
212                String termsOfServiceUrl, String privacyPolicyUrl
213            )
214        {
215            // Exception-Check(s) to ensure that if any parameters which are not declared as
216            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
217            
218            if (accountId == null)    THROWS.throwNPE("accountId");
219            if (email == null)        THROWS.throwNPE("email");
220            if (name == null)         THROWS.throwNPE("name");
221            if (givenName == null)    THROWS.throwNPE("givenName");
222            if (pictureUrl == null)   THROWS.throwNPE("pictureUrl");
223            if (idpConfigUrl == null) THROWS.throwNPE("idpConfigUrl");
224            if (idpLoginUrl == null)  THROWS.throwNPE("idpLoginUrl");
225            if (loginState == null)   THROWS.throwNPE("loginState");
226            
227            // Exception-Check(s) to ensure that if any parameters which must adhere to a
228            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
229            
230            THROWS.checkIAE("loginState", loginState, "FedCm.LoginState", FedCm.LoginState);
231            
232            this.accountId          = accountId;
233            this.email              = email;
234            this.name               = name;
235            this.givenName          = givenName;
236            this.pictureUrl         = pictureUrl;
237            this.idpConfigUrl       = idpConfigUrl;
238            this.idpLoginUrl        = idpLoginUrl;
239            this.loginState         = loginState;
240            this.termsOfServiceUrl  = termsOfServiceUrl;
241            this.privacyPolicyUrl   = privacyPolicyUrl;
242        }
243        
244        /**
245         * JSON Object Constructor
246         * @param jo A Json-Object having data about an instance of {@code 'Account'}.
247         */
248        public Account (JsonObject jo)
249        {
250            this.accountId          = ReadJSON.getString(jo, "accountId", false, true);
251            this.email              = ReadJSON.getString(jo, "email", false, true);
252            this.name               = ReadJSON.getString(jo, "name", false, true);
253            this.givenName          = ReadJSON.getString(jo, "givenName", false, true);
254            this.pictureUrl         = ReadJSON.getString(jo, "pictureUrl", false, true);
255            this.idpConfigUrl       = ReadJSON.getString(jo, "idpConfigUrl", false, true);
256            this.idpLoginUrl        = ReadJSON.getString(jo, "idpLoginUrl", false, true);
257            this.loginState         = ReadJSON.getString(jo, "loginState", false, true);
258            this.termsOfServiceUrl  = ReadJSON.getString(jo, "termsOfServiceUrl", true, false);
259            this.privacyPolicyUrl   = ReadJSON.getString(jo, "privacyPolicyUrl", true, false);
260        }
261        
262        
263        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
264        public boolean equals(Object other)
265        {
266            if (this == other)                       return true;
267            if (other == null)                       return false;
268            if (other.getClass() != this.getClass()) return false;
269        
270            Account o = (Account) other;
271        
272            return
273                    Objects.equals(this.accountId, o.accountId)
274                &&  Objects.equals(this.email, o.email)
275                &&  Objects.equals(this.name, o.name)
276                &&  Objects.equals(this.givenName, o.givenName)
277                &&  Objects.equals(this.pictureUrl, o.pictureUrl)
278                &&  Objects.equals(this.idpConfigUrl, o.idpConfigUrl)
279                &&  Objects.equals(this.idpLoginUrl, o.idpLoginUrl)
280                &&  Objects.equals(this.loginState, o.loginState)
281                &&  Objects.equals(this.termsOfServiceUrl, o.termsOfServiceUrl)
282                &&  Objects.equals(this.privacyPolicyUrl, o.privacyPolicyUrl);
283        }
284        
285        /** Generates a Hash-Code for {@code 'this'} instance */
286        public int hashCode()
287        {
288            return
289                    Objects.hashCode(this.accountId)
290                +   Objects.hashCode(this.email)
291                +   Objects.hashCode(this.name)
292                +   Objects.hashCode(this.givenName)
293                +   Objects.hashCode(this.pictureUrl)
294                +   Objects.hashCode(this.idpConfigUrl)
295                +   Objects.hashCode(this.idpLoginUrl)
296                +   Objects.hashCode(this.loginState)
297                +   Objects.hashCode(this.termsOfServiceUrl)
298                +   Objects.hashCode(this.privacyPolicyUrl);
299        }
300    }
301    
302    /** <CODE>[No Description Provided by Google]</CODE> */
303    public static class dialogShown
304        extends BrowserEvent
305        implements java.io.Serializable
306    {
307        /** For Object Serialization.  java.io.Serializable */
308        protected static final long serialVersionUID = 1;
309        
310        public boolean[] optionals()
311        { return new boolean[] { false, false, false, false, true, }; }
312        
313        /** <CODE>[No Description Provided by Google]</CODE> */
314        public final String dialogId;
315        
316        /** <CODE>[No Description Provided by Google]</CODE> */
317        public final String dialogType;
318        
319        /** <CODE>[No Description Provided by Google]</CODE> */
320        public final FedCm.Account[] accounts;
321        
322        /**
323         * These exist primarily so that the caller can verify the
324         * RP context was used appropriately.
325         */
326        public final String title;
327        
328        /**
329         * <CODE>[No Description Provided by Google]</CODE>
330         * <BR /><B CLASS=Opt>OPTIONAL</B>
331         */
332        public final String subtitle;
333        
334        /**
335         * Constructor
336         *
337         * @param dialogId -
338         * 
339         * @param dialogType -
340         * 
341         * @param accounts -
342         * 
343         * @param title 
344         * These exist primarily so that the caller can verify the
345         * RP context was used appropriately.
346         * 
347         * @param subtitle -
348         * <BR /><B CLASS=Opt>OPTIONAL</B>
349         */
350        public dialogShown(
351                String dialogId, String dialogType, FedCm.Account[] accounts, String title, 
352                String subtitle
353            )
354        {
355            super("FedCm", "dialogShown", 5);
356            
357            // Exception-Check(s) to ensure that if any parameters which are not declared as
358            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
359            
360            if (dialogId == null)   THROWS.throwNPE("dialogId");
361            if (dialogType == null) THROWS.throwNPE("dialogType");
362            if (accounts == null)   THROWS.throwNPE("accounts");
363            if (title == null)      THROWS.throwNPE("title");
364            
365            // Exception-Check(s) to ensure that if any parameters which must adhere to a
366            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
367            
368            THROWS.checkIAE("dialogType", dialogType, "FedCm.DialogType", FedCm.DialogType);
369            
370            this.dialogId    = dialogId;
371            this.dialogType  = dialogType;
372            this.accounts    = accounts;
373            this.title       = title;
374            this.subtitle    = subtitle;
375        }
376        
377        /**
378         * JSON Object Constructor
379         * @param jo A Json-Object having data about an instance of {@code 'dialogShown'}.
380         */
381        public dialogShown (JsonObject jo)
382        {
383            super("FedCm", "dialogShown", 5);
384        
385            this.dialogId    = ReadJSON.getString(jo, "dialogId", false, true);
386            this.dialogType  = ReadJSON.getString(jo, "dialogType", false, true);
387            this.accounts = (jo.getJsonArray("accounts") == null)
388                ? null
389                : RJArrIntoStream.objArr(jo.getJsonArray("accounts"), null, 0, FedCm.Account.class).toArray(FedCm.Account[]::new);
390        
391            this.title       = ReadJSON.getString(jo, "title", false, true);
392            this.subtitle    = ReadJSON.getString(jo, "subtitle", true, false);
393        }
394        
395        
396        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
397        public boolean equals(Object other)
398        {
399            if (this == other)                       return true;
400            if (other == null)                       return false;
401            if (other.getClass() != this.getClass()) return false;
402        
403            dialogShown o = (dialogShown) other;
404        
405            return
406                    Objects.equals(this.dialogId, o.dialogId)
407                &&  Objects.equals(this.dialogType, o.dialogType)
408                &&  Arrays.deepEquals(this.accounts, o.accounts)
409                &&  Objects.equals(this.title, o.title)
410                &&  Objects.equals(this.subtitle, o.subtitle);
411        }
412        
413        /** Generates a Hash-Code for {@code 'this'} instance */
414        public int hashCode()
415        {
416            return
417                    Objects.hashCode(this.dialogId)
418                +   Objects.hashCode(this.dialogType)
419                +   Arrays.deepHashCode(this.accounts)
420                +   Objects.hashCode(this.title)
421                +   Objects.hashCode(this.subtitle);
422        }
423    }
424    
425    /**
426     * Triggered when a dialog is closed, either by user action, JS abort,
427     * or a command below.
428     */
429    public static class dialogClosed
430        extends BrowserEvent
431        implements java.io.Serializable
432    {
433        /** For Object Serialization.  java.io.Serializable */
434        protected static final long serialVersionUID = 1;
435        
436        public boolean[] optionals()
437        { return new boolean[] { false, }; }
438        
439        /** <CODE>[No Description Provided by Google]</CODE> */
440        public final String dialogId;
441        
442        /**
443         * Constructor
444         *
445         * @param dialogId -
446         */
447        public dialogClosed(String dialogId)
448        {
449            super("FedCm", "dialogClosed", 1);
450            
451            // Exception-Check(s) to ensure that if any parameters which are not declared as
452            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
453            
454            if (dialogId == null) THROWS.throwNPE("dialogId");
455            
456            this.dialogId  = dialogId;
457        }
458        
459        /**
460         * JSON Object Constructor
461         * @param jo A Json-Object having data about an instance of {@code 'dialogClosed'}.
462         */
463        public dialogClosed (JsonObject jo)
464        {
465            super("FedCm", "dialogClosed", 1);
466        
467            this.dialogId  = ReadJSON.getString(jo, "dialogId", false, true);
468        }
469        
470        
471        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
472        public boolean equals(Object other)
473        {
474            if (this == other)                       return true;
475            if (other == null)                       return false;
476            if (other.getClass() != this.getClass()) return false;
477        
478            dialogClosed o = (dialogClosed) other;
479        
480            return
481                    Objects.equals(this.dialogId, o.dialogId);
482        }
483        
484        /** Generates a Hash-Code for {@code 'this'} instance */
485        public int hashCode()
486        {
487            return
488                    Objects.hashCode(this.dialogId);
489        }
490    }
491    
492    
493    // Counter for keeping the WebSocket Request ID's distinct.
494    private static int counter = 1;
495    
496    /**
497     * <CODE>[No Description Provided by Google]</CODE>
498     * 
499     * @param disableRejectionDelay 
500     * Allows callers to disable the promise rejection delay that would
501     * normally happen, if this is unimportant to what's being tested.
502     * (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
503     * <BR /><B CLASS=Opt>OPTIONAL</B>
504     * 
505     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
506     * {@link Ret0}&gt;</CODE>
507     *
508     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
509     * browser receives the invocation-request.
510     *
511     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
512     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
513     * {@code >} to ensure the Browser Function has run to completion.
514     */
515    public static Script<String, JsonObject, Ret0> enable(Boolean disableRejectionDelay)
516    {
517        final int       webSocketID = 51000000 + counter++;
518        final boolean[] optionals   = { true, };
519        
520        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
521        String requestJSON = WriteJSON.get(
522            parameterTypes.get("enable"),
523            parameterNames.get("enable"),
524            optionals, webSocketID,
525            "FedCm.enable",
526            disableRejectionDelay
527        );
528        
529        // This Remote Command does not have a Return-Value.
530        return new Script<>
531            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
532    }
533    
534    /**
535     * <CODE>[No Description Provided by Google]</CODE>
536     * 
537     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
538     * {@link Ret0}&gt;</CODE>
539     *
540     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
541     * browser receives the invocation-request.
542     *
543     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
544     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
545     * {@code >} to ensure the Browser Function has run to completion.
546     */
547    public static Script<String, JsonObject, Ret0> disable()
548    {
549        final int          webSocketID = 51001000 + counter++;
550        final boolean[]    optionals   = new boolean[0];
551        
552        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
553        String requestJSON = WriteJSON.get(
554            parameterTypes.get("disable"),
555            parameterNames.get("disable"),
556            optionals, webSocketID,
557            "FedCm.disable"
558        );
559        
560        // This Remote Command does not have a Return-Value.
561        return new Script<>
562            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
563    }
564    
565    /**
566     * <CODE>[No Description Provided by Google]</CODE>
567     * 
568     * @param dialogId -
569     * 
570     * @param accountIndex -
571     * 
572     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
573     * {@link Ret0}&gt;</CODE>
574     *
575     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
576     * browser receives the invocation-request.
577     *
578     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
579     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
580     * {@code >} to ensure the Browser Function has run to completion.
581     */
582    public static Script<String, JsonObject, Ret0> selectAccount
583        (String dialogId, int accountIndex)
584    {
585        // Exception-Check(s) to ensure that if any parameters which are not declared as
586        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
587        
588        if (dialogId == null) THROWS.throwNPE("dialogId");
589        
590        final int       webSocketID = 51002000 + counter++;
591        final boolean[] optionals   = { false, false, };
592        
593        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
594        String requestJSON = WriteJSON.get(
595            parameterTypes.get("selectAccount"),
596            parameterNames.get("selectAccount"),
597            optionals, webSocketID,
598            "FedCm.selectAccount",
599            dialogId, accountIndex
600        );
601        
602        // This Remote Command does not have a Return-Value.
603        return new Script<>
604            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
605    }
606    
607    /**
608     * <CODE>[No Description Provided by Google]</CODE>
609     * 
610     * @param dialogId -
611     * 
612     * @param dialogButton -
613     * 
614     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
615     * {@link Ret0}&gt;</CODE>
616     *
617     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
618     * browser receives the invocation-request.
619     *
620     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
621     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
622     * {@code >} to ensure the Browser Function has run to completion.
623     */
624    public static Script<String, JsonObject, Ret0> clickDialogButton
625        (String dialogId, String dialogButton)
626    {
627        // Exception-Check(s) to ensure that if any parameters which are not declared as
628        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
629        
630        if (dialogId == null)     THROWS.throwNPE("dialogId");
631        if (dialogButton == null) THROWS.throwNPE("dialogButton");
632        
633        // Exception-Check(s) to ensure that if any parameters which must adhere to a
634        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
635        
636        THROWS.checkIAE("dialogButton", dialogButton, "FedCm.DialogButton", FedCm.DialogButton);
637        
638        final int       webSocketID = 51003000 + counter++;
639        final boolean[] optionals   = { false, false, };
640        
641        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
642        String requestJSON = WriteJSON.get(
643            parameterTypes.get("clickDialogButton"),
644            parameterNames.get("clickDialogButton"),
645            optionals, webSocketID,
646            "FedCm.clickDialogButton",
647            dialogId, dialogButton
648        );
649        
650        // This Remote Command does not have a Return-Value.
651        return new Script<>
652            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
653    }
654    
655    /**
656     * <CODE>[No Description Provided by Google]</CODE>
657     * 
658     * @param dialogId -
659     * 
660     * @param accountIndex -
661     * 
662     * @param accountUrlType -
663     * 
664     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
665     * {@link Ret0}&gt;</CODE>
666     *
667     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
668     * browser receives the invocation-request.
669     *
670     * <BR /><BR />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 <JsonObject,} {@link Ret0}
672     * {@code >} to ensure the Browser Function has run to completion.
673     */
674    public static Script<String, JsonObject, Ret0> openUrl
675        (String dialogId, int accountIndex, String accountUrlType)
676    {
677        // Exception-Check(s) to ensure that if any parameters which are not declared as
678        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
679        
680        if (dialogId == null)       THROWS.throwNPE("dialogId");
681        if (accountUrlType == null) THROWS.throwNPE("accountUrlType");
682        
683        // Exception-Check(s) to ensure that if any parameters which must adhere to a
684        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
685        
686        THROWS.checkIAE("accountUrlType", accountUrlType, "FedCm.AccountUrlType", FedCm.AccountUrlType);
687        
688        final int       webSocketID = 51004000 + counter++;
689        final boolean[] optionals   = { false, false, false, };
690        
691        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
692        String requestJSON = WriteJSON.get(
693            parameterTypes.get("openUrl"),
694            parameterNames.get("openUrl"),
695            optionals, webSocketID,
696            "FedCm.openUrl",
697            dialogId, accountIndex, accountUrlType
698        );
699        
700        // This Remote Command does not have a Return-Value.
701        return new Script<>
702            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
703    }
704    
705    /**
706     * <CODE>[No Description Provided by Google]</CODE>
707     * 
708     * @param dialogId -
709     * 
710     * @param triggerCooldown -
711     * <BR /><B CLASS=Opt>OPTIONAL</B>
712     * 
713     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
714     * {@link Ret0}&gt;</CODE>
715     *
716     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
717     * browser receives the invocation-request.
718     *
719     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
720     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
721     * {@code >} to ensure the Browser Function has run to completion.
722     */
723    public static Script<String, JsonObject, Ret0> dismissDialog
724        (String dialogId, Boolean triggerCooldown)
725    {
726        // Exception-Check(s) to ensure that if any parameters which are not declared as
727        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
728        
729        if (dialogId == null) THROWS.throwNPE("dialogId");
730        
731        final int       webSocketID = 51005000 + counter++;
732        final boolean[] optionals   = { false, true, };
733        
734        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
735        String requestJSON = WriteJSON.get(
736            parameterTypes.get("dismissDialog"),
737            parameterNames.get("dismissDialog"),
738            optionals, webSocketID,
739            "FedCm.dismissDialog",
740            dialogId, triggerCooldown
741        );
742        
743        // This Remote Command does not have a Return-Value.
744        return new Script<>
745            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
746    }
747    
748    /**
749     * Resets the cooldown time, if any, to allow the next FedCM call to show
750     * a dialog even if one was recently dismissed by the user.
751     * 
752     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
753     * {@link Ret0}&gt;</CODE>
754     *
755     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
756     * browser receives the invocation-request.
757     *
758     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
759     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
760     * {@code >} to ensure the Browser Function has run to completion.
761     */
762    public static Script<String, JsonObject, Ret0> resetCooldown()
763    {
764        final int          webSocketID = 51006000 + counter++;
765        final boolean[]    optionals   = new boolean[0];
766        
767        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
768        String requestJSON = WriteJSON.get(
769            parameterTypes.get("resetCooldown"),
770            parameterNames.get("resetCooldown"),
771            optionals, webSocketID,
772            "FedCm.resetCooldown"
773        );
774        
775        // This Remote Command does not have a Return-Value.
776        return new Script<>
777            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
778    }
779    
780}