cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! This domain allows interacting with the FedCM dialog.
//!
//! Types, command parameters and event payloads for the `FedCm`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

/// 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.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum LoginState {
    /// `SignIn`
    SignIn,
    /// `SignUp`
    SignUp,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// The types of FedCM dialogs.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DialogType {
    /// `AccountChooser`
    AccountChooser,
    /// `AutoReauthn`
    AutoReauthn,
    /// `ConfirmIdpLogin`
    ConfirmIdpLogin,
    /// `Error`
    Error,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// The buttons on the FedCM dialog.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DialogButton {
    /// `ConfirmIdpLoginContinue`
    ConfirmIdpLoginContinue,
    /// `ErrorGotIt`
    ErrorGotIt,
    /// `ErrorMoreDetails`
    ErrorMoreDetails,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// The URLs that each account has
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AccountUrlType {
    /// `TermsOfService`
    TermsOfService,
    /// `PrivacyPolicy`
    PrivacyPolicy,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Corresponds to IdentityRequestAccount
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Account {
    #[serde(rename = "accountId")]
    pub account_id: String,
    pub email: String,
    pub name: String,
    #[serde(rename = "givenName")]
    pub given_name: String,
    #[serde(rename = "pictureUrl")]
    pub picture_url: String,
    #[serde(rename = "idpConfigUrl")]
    pub idp_config_url: String,
    #[serde(rename = "idpLoginUrl")]
    pub idp_login_url: String,
    #[serde(rename = "loginState")]
    pub login_state: LoginState,
    /// These two are only set if the loginState is signUp
    #[serde(
        rename = "termsOfServiceUrl",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub terms_of_service_url: Option<String>,
    #[serde(
        rename = "privacyPolicyUrl",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub privacy_policy_url: Option<String>,
}

/// Parameters of `FedCm.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {
    /// 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>)
    #[serde(
        rename = "disableRejectionDelay",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub disable_rejection_delay: Option<bool>,
}

impl crate::typed::Command for EnableParams {
    const METHOD: &'static str = "FedCm.enable";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `FedCm.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

impl crate::typed::Command for DisableParams {
    const METHOD: &'static str = "FedCm.disable";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `FedCm.selectAccount`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SelectAccountParams {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
    #[serde(rename = "accountIndex")]
    pub account_index: i64,
}

impl crate::typed::Command for SelectAccountParams {
    const METHOD: &'static str = "FedCm.selectAccount";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `FedCm.clickDialogButton`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ClickDialogButtonParams {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
    #[serde(rename = "dialogButton")]
    pub dialog_button: DialogButton,
}

impl crate::typed::Command for ClickDialogButtonParams {
    const METHOD: &'static str = "FedCm.clickDialogButton";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `FedCm.openUrl`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OpenUrlParams {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
    #[serde(rename = "accountIndex")]
    pub account_index: i64,
    #[serde(rename = "accountUrlType")]
    pub account_url_type: AccountUrlType,
}

impl crate::typed::Command for OpenUrlParams {
    const METHOD: &'static str = "FedCm.openUrl";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `FedCm.dismissDialog`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DismissDialogParams {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
    #[serde(
        rename = "triggerCooldown",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trigger_cooldown: Option<bool>,
}

impl crate::typed::Command for DismissDialogParams {
    const METHOD: &'static str = "FedCm.dismissDialog";
    type Returns = crate::typed::NoReturns;
}

/// 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.
///
/// Parameters of `FedCm.resetCooldown`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ResetCooldownParams {}

impl crate::typed::Command for ResetCooldownParams {
    const METHOD: &'static str = "FedCm.resetCooldown";
    type Returns = crate::typed::NoReturns;
}

/// Payload of the `FedCm.dialogShown` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DialogShownEvent {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
    #[serde(rename = "dialogType")]
    pub dialog_type: DialogType,
    pub accounts: Vec<Account>,
    /// These exist primarily so that the caller can verify the RP context was
    /// used appropriately.
    pub title: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subtitle: Option<String>,
}

impl crate::typed::Event for DialogShownEvent {
    const METHOD: &'static str = "FedCm.dialogShown";
}

/// Triggered when a dialog is closed, either by user action, JS abort, or a
/// command below.
///
/// Payload of the `FedCm.dialogClosed` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DialogClosedEvent {
    #[serde(rename = "dialogId")]
    pub dialog_id: String,
}

impl crate::typed::Event for DialogClosedEvent {
    const METHOD: &'static str = "FedCm.dialogClosed";
}