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.

//! The `Security` domain.
//!
//! Types, command parameters and event payloads for the `Security`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].

use serde::{Deserialize, Serialize};

/// An internal certificate ID value.
pub type CertificateId = i64;

/// A description of mixed content (HTTP resources on HTTPS pages), as defined
/// by <https://www.w3.org/TR/mixed-content/#categories>
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MixedContentType {
    /// `blockable`
    #[serde(rename = "blockable")]
    Blockable,
    /// `optionally-blockable`
    #[serde(rename = "optionally-blockable")]
    OptionallyBlockable,
    /// `none`
    #[serde(rename = "none")]
    None,
    /// 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 security level of a page or resource.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SecurityState {
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// `neutral`
    #[serde(rename = "neutral")]
    Neutral,
    /// `insecure`
    #[serde(rename = "insecure")]
    Insecure,
    /// `secure`
    #[serde(rename = "secure")]
    Secure,
    /// `info`
    #[serde(rename = "info")]
    Info,
    /// `insecure-broken`
    #[serde(rename = "insecure-broken")]
    InsecureBroken,
    /// 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),
}

/// Details about the security state of the page certificate.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CertificateSecurityState {
    /// Protocol name (e.g. "TLS 1.2" or "QUIC").
    pub protocol: String,
    /// Key Exchange used by the connection, or the empty string if not
    /// applicable.
    #[serde(rename = "keyExchange")]
    pub key_exchange: String,
    /// (EC)DH group used by the connection, if applicable.
    #[serde(
        rename = "keyExchangeGroup",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub key_exchange_group: Option<String>,
    /// Cipher name.
    pub cipher: String,
    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mac: Option<String>,
    /// Page certificate.
    pub certificate: Vec<String>,
    /// Certificate subject name.
    #[serde(rename = "subjectName")]
    pub subject_name: String,
    /// Name of the issuing CA.
    pub issuer: String,
    /// Certificate valid from date.
    #[serde(rename = "validFrom")]
    pub valid_from: crate::protocol::network::TimeSinceEpoch,
    /// Certificate valid to (expiration) date
    #[serde(rename = "validTo")]
    pub valid_to: crate::protocol::network::TimeSinceEpoch,
    /// The highest priority network error code, if the certificate has an error.
    #[serde(
        rename = "certificateNetworkError",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub certificate_network_error: Option<String>,
    /// True if the certificate uses a weak signature algorithm.
    #[serde(rename = "certificateHasWeakSignature")]
    pub certificate_has_weak_signature: bool,
    /// True if the certificate has a SHA1 signature in the chain.
    #[serde(rename = "certificateHasSha1Signature")]
    pub certificate_has_sha1_signature: bool,
    /// True if modern SSL
    #[serde(rename = "modernSSL")]
    pub modern_ssl: bool,
    /// True if the connection is using an obsolete SSL protocol.
    #[serde(rename = "obsoleteSslProtocol")]
    pub obsolete_ssl_protocol: bool,
    /// True if the connection is using an obsolete SSL key exchange.
    #[serde(rename = "obsoleteSslKeyExchange")]
    pub obsolete_ssl_key_exchange: bool,
    /// True if the connection is using an obsolete SSL cipher.
    #[serde(rename = "obsoleteSslCipher")]
    pub obsolete_ssl_cipher: bool,
    /// True if the connection is using an obsolete SSL signature.
    #[serde(rename = "obsoleteSslSignature")]
    pub obsolete_ssl_signature: bool,
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SafetyTipStatus {
    /// `badReputation`
    #[serde(rename = "badReputation")]
    BadReputation,
    /// `lookalike`
    #[serde(rename = "lookalike")]
    Lookalike,
    /// 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),
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SafetyTipInfo {
    /// Describes whether the page triggers any safety tips or reputation
    /// warnings. Default is unknown.
    #[serde(rename = "safetyTipStatus")]
    pub safety_tip_status: SafetyTipStatus,
    /// The URL the safety tip suggested ("Did you mean?"). Only filled in for
    /// lookalike matches.
    #[serde(rename = "safeUrl", default, skip_serializing_if = "Option::is_none")]
    pub safe_url: Option<String>,
}

/// Security state information about the page.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VisibleSecurityState {
    /// The security level of the page.
    #[serde(rename = "securityState")]
    pub security_state: SecurityState,
    /// Security state details about the page certificate.
    #[serde(
        rename = "certificateSecurityState",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub certificate_security_state: Option<CertificateSecurityState>,
    /// The type of Safety Tip triggered on the page. Note that this field will be
    /// set even if the Safety Tip UI was not actually shown.
    #[serde(
        rename = "safetyTipInfo",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub safety_tip_info: Option<SafetyTipInfo>,
    /// Array of security state issues ids.
    #[serde(rename = "securityStateIssueIds")]
    pub security_state_issue_ids: Vec<String>,
}

/// An explanation of an factor contributing to the security state.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SecurityStateExplanation {
    /// Security state representing the severity of the factor being explained.
    #[serde(rename = "securityState")]
    pub security_state: SecurityState,
    /// Title describing the type of factor.
    pub title: String,
    /// Short phrase describing the type of factor.
    pub summary: String,
    /// Full text explanation of the factor.
    pub description: String,
    /// The type of mixed content described by the explanation.
    #[serde(rename = "mixedContentType")]
    pub mixed_content_type: MixedContentType,
    /// Page certificate.
    pub certificate: Vec<String>,
    /// Recommendations to fix any issues.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub recommendations: Option<Vec<String>>,
}

/// Information about insecure content on the page.
///
/// Deprecated in the protocol.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InsecureContentStatus {
    /// Always false.
    #[serde(rename = "ranMixedContent")]
    pub ran_mixed_content: bool,
    /// Always false.
    #[serde(rename = "displayedMixedContent")]
    pub displayed_mixed_content: bool,
    /// Always false.
    #[serde(rename = "containedMixedForm")]
    pub contained_mixed_form: bool,
    /// Always false.
    #[serde(rename = "ranContentWithCertErrors")]
    pub ran_content_with_cert_errors: bool,
    /// Always false.
    #[serde(rename = "displayedContentWithCertErrors")]
    pub displayed_content_with_cert_errors: bool,
    /// Always set to unknown.
    #[serde(rename = "ranInsecureContentStyle")]
    pub ran_insecure_content_style: SecurityState,
    /// Always set to unknown.
    #[serde(rename = "displayedInsecureContentStyle")]
    pub displayed_insecure_content_style: SecurityState,
}

/// The action to take when a certificate error occurs. continue will continue
/// processing the request and cancel will cancel the request.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CertificateErrorAction {
    /// `continue`
    #[serde(rename = "continue")]
    Continue,
    /// `cancel`
    #[serde(rename = "cancel")]
    Cancel,
    /// 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),
}

/// Disables tracking security state changes.
///
/// Parameters of `Security.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

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

/// Enables tracking security state changes.
///
/// Parameters of `Security.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

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

/// Enable/disable whether all certificate errors should be ignored.
///
/// Parameters of `Security.setIgnoreCertificateErrors`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetIgnoreCertificateErrorsParams {
    /// If true, all certificate errors will be ignored.
    pub ignore: bool,
}

impl crate::typed::Command for SetIgnoreCertificateErrorsParams {
    const METHOD: &'static str = "Security.setIgnoreCertificateErrors";
    type Returns = crate::typed::NoReturns;
}

/// Handles a certificate error that fired a certificateError event.
///
/// Deprecated in the protocol.
///
/// Parameters of `Security.handleCertificateError`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HandleCertificateErrorParams {
    /// The ID of the event.
    #[serde(rename = "eventId")]
    pub event_id: i64,
    /// The action to take on the certificate error.
    pub action: CertificateErrorAction,
}

impl crate::typed::Command for HandleCertificateErrorParams {
    const METHOD: &'static str = "Security.handleCertificateError";
    type Returns = crate::typed::NoReturns;
}

/// Enable/disable overriding certificate errors. If enabled, all certificate
/// error events need to be handled by the DevTools client and should be
/// answered with `handleCertificateError` commands.
///
/// Deprecated in the protocol.
///
/// Parameters of `Security.setOverrideCertificateErrors`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetOverrideCertificateErrorsParams {
    /// If true, certificate errors will be overridden.
    pub r#override: bool,
}

impl crate::typed::Command for SetOverrideCertificateErrorsParams {
    const METHOD: &'static str = "Security.setOverrideCertificateErrors";
    type Returns = crate::typed::NoReturns;
}

/// There is a certificate error. If overriding certificate errors is enabled,
/// then it should be handled with the `handleCertificateError` command. Note:
/// this event does not fire if the certificate error has been allowed
/// internally. Only one client per target should override certificate errors
/// at the same time.
///
/// Deprecated in the protocol.
///
/// Payload of the `Security.certificateError` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CertificateErrorEvent {
    /// The ID of the event.
    #[serde(rename = "eventId")]
    pub event_id: i64,
    /// The type of the error.
    #[serde(rename = "errorType")]
    pub error_type: String,
    /// The url that was requested.
    #[serde(rename = "requestURL")]
    pub request_url: String,
}

impl crate::typed::Event for CertificateErrorEvent {
    const METHOD: &'static str = "Security.certificateError";
}

/// The security state of the page changed.
///
/// Experimental: may change without notice.
///
/// Payload of the `Security.visibleSecurityStateChanged` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VisibleSecurityStateChangedEvent {
    /// Security state information about the page.
    #[serde(rename = "visibleSecurityState")]
    pub visible_security_state: VisibleSecurityState,
}

impl crate::typed::Event for VisibleSecurityStateChangedEvent {
    const METHOD: &'static str = "Security.visibleSecurityStateChanged";
}

/// The security state of the page changed. No longer being sent.
///
/// Deprecated in the protocol.
///
/// Payload of the `Security.securityStateChanged` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SecurityStateChangedEvent {
    /// Security state.
    #[serde(rename = "securityState")]
    pub security_state: SecurityState,
    /// True if the page was loaded over cryptographic transport such as HTTPS.
    ///
    /// Deprecated in the protocol.
    #[serde(rename = "schemeIsCryptographic")]
    pub scheme_is_cryptographic: bool,
    /// Previously a list of explanations for the security state. Now always
    /// empty.
    ///
    /// Deprecated in the protocol.
    pub explanations: Vec<SecurityStateExplanation>,
    /// Information about insecure content on the page.
    ///
    /// Deprecated in the protocol.
    #[serde(rename = "insecureContentStatus")]
    pub insecure_content_status: InsecureContentStatus,
    /// Overrides user-visible description of the state. Always omitted.
    ///
    /// Deprecated in the protocol.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub summary: Option<String>,
}

impl crate::typed::Event for SecurityStateChangedEvent {
    const METHOD: &'static str = "Security.securityStateChanged";
}