Skip to content

fed_cm

Account dataclass

Corresponds to IdentityRequestAccount

Source code in zendriver/cdp/fed_cm.py
@dataclass
class Account:
    """
    Corresponds to IdentityRequestAccount
    """

    account_id: str

    email: str

    name: str

    given_name: str

    picture_url: str

    idp_config_url: str

    idp_login_url: str

    login_state: LoginState

    #: These two are only set if the loginState is signUp
    terms_of_service_url: typing.Optional[str] = None

    privacy_policy_url: typing.Optional[str] = None

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["accountId"] = self.account_id
        json["email"] = self.email
        json["name"] = self.name
        json["givenName"] = self.given_name
        json["pictureUrl"] = self.picture_url
        json["idpConfigUrl"] = self.idp_config_url
        json["idpLoginUrl"] = self.idp_login_url
        json["loginState"] = self.login_state.to_json()
        if self.terms_of_service_url is not None:
            json["termsOfServiceUrl"] = self.terms_of_service_url
        if self.privacy_policy_url is not None:
            json["privacyPolicyUrl"] = self.privacy_policy_url
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> Account:
        return cls(
            account_id=str(json["accountId"]),
            email=str(json["email"]),
            name=str(json["name"]),
            given_name=str(json["givenName"]),
            picture_url=str(json["pictureUrl"]),
            idp_config_url=str(json["idpConfigUrl"]),
            idp_login_url=str(json["idpLoginUrl"]),
            login_state=LoginState.from_json(json["loginState"]),
            terms_of_service_url=(
                str(json["termsOfServiceUrl"])
                if json.get("termsOfServiceUrl", None) is not None
                else None
            ),
            privacy_policy_url=(
                str(json["privacyPolicyUrl"])
                if json.get("privacyPolicyUrl", None) is not None
                else None
            ),
        )

account_id: str instance-attribute

email: str instance-attribute

given_name: str instance-attribute

idp_config_url: str instance-attribute

idp_login_url: str instance-attribute

login_state: LoginState instance-attribute

name: str instance-attribute

picture_url: str instance-attribute

privacy_policy_url: typing.Optional[str] = None class-attribute instance-attribute

terms_of_service_url: typing.Optional[str] = None class-attribute instance-attribute

__init__(account_id, email, name, given_name, picture_url, idp_config_url, idp_login_url, login_state, terms_of_service_url=None, privacy_policy_url=None)

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> Account:
    return cls(
        account_id=str(json["accountId"]),
        email=str(json["email"]),
        name=str(json["name"]),
        given_name=str(json["givenName"]),
        picture_url=str(json["pictureUrl"]),
        idp_config_url=str(json["idpConfigUrl"]),
        idp_login_url=str(json["idpLoginUrl"]),
        login_state=LoginState.from_json(json["loginState"]),
        terms_of_service_url=(
            str(json["termsOfServiceUrl"])
            if json.get("termsOfServiceUrl", None) is not None
            else None
        ),
        privacy_policy_url=(
            str(json["privacyPolicyUrl"])
            if json.get("privacyPolicyUrl", None) is not None
            else None
        ),
    )

to_json()

Source code in zendriver/cdp/fed_cm.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["accountId"] = self.account_id
    json["email"] = self.email
    json["name"] = self.name
    json["givenName"] = self.given_name
    json["pictureUrl"] = self.picture_url
    json["idpConfigUrl"] = self.idp_config_url
    json["idpLoginUrl"] = self.idp_login_url
    json["loginState"] = self.login_state.to_json()
    if self.terms_of_service_url is not None:
        json["termsOfServiceUrl"] = self.terms_of_service_url
    if self.privacy_policy_url is not None:
        json["privacyPolicyUrl"] = self.privacy_policy_url
    return json

AccountUrlType

Bases: Enum

The URLs that each account has

Source code in zendriver/cdp/fed_cm.py
class AccountUrlType(enum.Enum):
    """
    The URLs that each account has
    """

    TERMS_OF_SERVICE = "TermsOfService"
    PRIVACY_POLICY = "PrivacyPolicy"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> AccountUrlType:
        return cls(json)

PRIVACY_POLICY = 'PrivacyPolicy' class-attribute instance-attribute

TERMS_OF_SERVICE = 'TermsOfService' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: str) -> AccountUrlType:
    return cls(json)

to_json()

Source code in zendriver/cdp/fed_cm.py
def to_json(self) -> str:
    return self.value

DialogButton

Bases: Enum

The buttons on the FedCM dialog.

Source code in zendriver/cdp/fed_cm.py
class DialogButton(enum.Enum):
    """
    The buttons on the FedCM dialog.
    """

    CONFIRM_IDP_LOGIN_CONTINUE = "ConfirmIdpLoginContinue"
    ERROR_GOT_IT = "ErrorGotIt"
    ERROR_MORE_DETAILS = "ErrorMoreDetails"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> DialogButton:
        return cls(json)

CONFIRM_IDP_LOGIN_CONTINUE = 'ConfirmIdpLoginContinue' class-attribute instance-attribute

ERROR_GOT_IT = 'ErrorGotIt' class-attribute instance-attribute

ERROR_MORE_DETAILS = 'ErrorMoreDetails' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: str) -> DialogButton:
    return cls(json)

to_json()

Source code in zendriver/cdp/fed_cm.py
def to_json(self) -> str:
    return self.value

DialogClosed dataclass

Triggered when a dialog is closed, either by user action, JS abort, or a command below.

Source code in zendriver/cdp/fed_cm.py
@event_class("FedCm.dialogClosed")
@dataclass
class DialogClosed:
    """
    Triggered when a dialog is closed, either by user action, JS abort,
    or a command below.
    """

    dialog_id: str

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DialogClosed:
        return cls(dialog_id=str(json["dialogId"]))

dialog_id: str instance-attribute

__init__(dialog_id)

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DialogClosed:
    return cls(dialog_id=str(json["dialogId"]))

DialogShown dataclass

Source code in zendriver/cdp/fed_cm.py
@event_class("FedCm.dialogShown")
@dataclass
class DialogShown:
    dialog_id: str
    dialog_type: DialogType
    accounts: typing.List[Account]
    #: These exist primarily so that the caller can verify the
    #: RP context was used appropriately.
    title: str
    subtitle: typing.Optional[str]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DialogShown:
        return cls(
            dialog_id=str(json["dialogId"]),
            dialog_type=DialogType.from_json(json["dialogType"]),
            accounts=[Account.from_json(i) for i in json["accounts"]],
            title=str(json["title"]),
            subtitle=(
                str(json["subtitle"])
                if json.get("subtitle", None) is not None
                else None
            ),
        )

accounts: typing.List[Account] instance-attribute

dialog_id: str instance-attribute

dialog_type: DialogType instance-attribute

subtitle: typing.Optional[str] instance-attribute

title: str instance-attribute

__init__(dialog_id, dialog_type, accounts, title, subtitle)

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DialogShown:
    return cls(
        dialog_id=str(json["dialogId"]),
        dialog_type=DialogType.from_json(json["dialogType"]),
        accounts=[Account.from_json(i) for i in json["accounts"]],
        title=str(json["title"]),
        subtitle=(
            str(json["subtitle"])
            if json.get("subtitle", None) is not None
            else None
        ),
    )

DialogType

Bases: Enum

The types of FedCM dialogs.

Source code in zendriver/cdp/fed_cm.py
class DialogType(enum.Enum):
    """
    The types of FedCM dialogs.
    """

    ACCOUNT_CHOOSER = "AccountChooser"
    AUTO_REAUTHN = "AutoReauthn"
    CONFIRM_IDP_LOGIN = "ConfirmIdpLogin"
    ERROR = "Error"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> DialogType:
        return cls(json)

ACCOUNT_CHOOSER = 'AccountChooser' class-attribute instance-attribute

AUTO_REAUTHN = 'AutoReauthn' class-attribute instance-attribute

CONFIRM_IDP_LOGIN = 'ConfirmIdpLogin' class-attribute instance-attribute

ERROR = 'Error' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: str) -> DialogType:
    return cls(json)

to_json()

Source code in zendriver/cdp/fed_cm.py
def to_json(self) -> str:
    return self.value

LoginState

Bases: Enum

Whether this is a sign-up or sign-in action for this account, i.e. whether this account has ever been used to sign in to this RP before.

Source code in zendriver/cdp/fed_cm.py
class LoginState(enum.Enum):
    """
    Whether this is a sign-up or sign-in action for this account, i.e.
    whether this account has ever been used to sign in to this RP before.
    """

    SIGN_IN = "SignIn"
    SIGN_UP = "SignUp"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> LoginState:
        return cls(json)

SIGN_IN = 'SignIn' class-attribute instance-attribute

SIGN_UP = 'SignUp' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/fed_cm.py
@classmethod
def from_json(cls, json: str) -> LoginState:
    return cls(json)

to_json()

Source code in zendriver/cdp/fed_cm.py
def to_json(self) -> str:
    return self.value

click_dialog_button(dialog_id, dialog_button)

Parameters:

Name Type Description Default
dialog_id str
required
dialog_button DialogButton
required
Source code in zendriver/cdp/fed_cm.py
def click_dialog_button(
    dialog_id: str, dialog_button: DialogButton
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param dialog_id:
    :param dialog_button:
    """
    params: T_JSON_DICT = dict()
    params["dialogId"] = dialog_id
    params["dialogButton"] = dialog_button.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.clickDialogButton",
        "params": params,
    }
    json = yield cmd_dict

disable()

Source code in zendriver/cdp/fed_cm.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:

    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.disable",
    }
    json = yield cmd_dict

dismiss_dialog(dialog_id, trigger_cooldown=None)

Parameters:

Name Type Description Default
dialog_id str
required
trigger_cooldown Optional[bool]

(Optional)

None
Source code in zendriver/cdp/fed_cm.py
def dismiss_dialog(
    dialog_id: str, trigger_cooldown: typing.Optional[bool] = None
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param dialog_id:
    :param trigger_cooldown: *(Optional)*
    """
    params: T_JSON_DICT = dict()
    params["dialogId"] = dialog_id
    if trigger_cooldown is not None:
        params["triggerCooldown"] = trigger_cooldown
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.dismissDialog",
        "params": params,
    }
    json = yield cmd_dict

enable(disable_rejection_delay=None)

Parameters:

Name Type Description Default
disable_rejection_delay Optional[bool]

(Optional) Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)

None
Source code in zendriver/cdp/fed_cm.py
def enable(
    disable_rejection_delay: typing.Optional[bool] = None,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param disable_rejection_delay: *(Optional)* Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
    """
    params: T_JSON_DICT = dict()
    if disable_rejection_delay is not None:
        params["disableRejectionDelay"] = disable_rejection_delay
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.enable",
        "params": params,
    }
    json = yield cmd_dict

open_url(dialog_id, account_index, account_url_type)

Parameters:

Name Type Description Default
dialog_id str
required
account_index int
required
account_url_type AccountUrlType
required
Source code in zendriver/cdp/fed_cm.py
def open_url(
    dialog_id: str, account_index: int, account_url_type: AccountUrlType
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param dialog_id:
    :param account_index:
    :param account_url_type:
    """
    params: T_JSON_DICT = dict()
    params["dialogId"] = dialog_id
    params["accountIndex"] = account_index
    params["accountUrlType"] = account_url_type.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.openUrl",
        "params": params,
    }
    json = yield cmd_dict

reset_cooldown()

Resets the cooldown time, if any, to allow the next FedCM call to show a dialog even if one was recently dismissed by the user.

Source code in zendriver/cdp/fed_cm.py
def reset_cooldown() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Resets the cooldown time, if any, to allow the next FedCM call to show
    a dialog even if one was recently dismissed by the user.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.resetCooldown",
    }
    json = yield cmd_dict

select_account(dialog_id, account_index)

Parameters:

Name Type Description Default
dialog_id str
required
account_index int
required
Source code in zendriver/cdp/fed_cm.py
def select_account(
    dialog_id: str, account_index: int
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param dialog_id:
    :param account_index:
    """
    params: T_JSON_DICT = dict()
    params["dialogId"] = dialog_id
    params["accountIndex"] = account_index
    cmd_dict: T_JSON_DICT = {
        "method": "FedCm.selectAccount",
        "params": params,
    }
    json = yield cmd_dict