Skip to main content

rightkit_browser/
lib.rs

1//! Shared Chrome DevTools Protocol browser runtime for Right Suite products.
2//!
3//! * [`BrowserSession`] owns one Chrome process and any number of pages. Launch uses Chrome
4//!   for Testing ([`chrome_for_testing_path`]); the system browser only with
5//!   [`LaunchOptions::system_chrome`] or [`LaunchOptions::system_chrome_only`].
6//!   Shutdown and drop close gracefully (CDP
7//!   `Browser.close` / SIGTERM to the process group, bounded waits, SIGKILL last).
8//! * [`ProfileSpec`] selects a temporary, named persistent, or caller-owned directory profile.
9//! * Pointer and keyboard actions use real `Input.dispatch*Event` commands, so
10//!   `event.isTrusted`, `:hover`, focus, and default actions behave as for a user.
11//! * [`NetworkPolicy`] blocks loopback/link-local/private/reserved/`file:` targets
12//!   (redirects, subresources, and every proxied connection included) before they
13//!   reach the network; denials are typed ([`BrowserError::Blocked`]).
14//! * [`AdmissionHook`] then gates every effect before it happens.
15//! * [`BrowserEvent`] reports start/stop/crash/denied with session id, reason, and time.
16//! * [`BrowserPage::set_request_interceptor`] lets the caller continue, rewrite, fulfil or fail
17//!   every request after the network policy; [`BrowserPage::accessibility_tree`],
18//!   [`BrowserPage::exceptions`], [`BrowserPage::set_page_scale`] and
19//!   [`BrowserPage::set_download_behavior`] expose the matching CDP domains.
20//! * Real-session mode (consent-gated): [`default_browser`], [`UserConsentReceipt`],
21//!   [`ProfileSpec::ImportedFrom`] and [`BrowserSession::attach_user_browser`] reuse the user's
22//!   own sign-ins in a private copy, confined to the consented domains. See [`ImportSpec`].
23//! * [`cookies::parse_netscape`] reads a Netscape `cookies.txt` (bounded; values redacted in
24//!   `Debug` and errors) and [`BrowserPage::import_cookies`] sets the result in the profile.
25//!   With feature `cookie-export`, `CookieExport` goes the other way: it keeps the cookies of
26//!   declared domains and publishes them as a private Netscape file through rightkit-fs; an
27//!   empty or invalid export never replaces the previous file.
28//! * [`BrowserPage::observe`] returns refs that are checked for staleness before use.
29//! * [`design_mode`] holds the element-picker primitives: an isolated-world binding bridge,
30//!   a one-shot native-gesture submit gate, device-pixel capture geometry and the picker script builder.
31// The source-only fixture browser is confined by macOS Seatbelt / the Windows sandbox; on other hosts its
32// constructors refuse and the rest of the fixture machinery is unreachable.
33#![cfg_attr(not(any(target_os = "macos", windows)), allow(dead_code))]
34mod cdp_ext;
35mod config;
36#[cfg(feature = "cookie-export")]
37pub mod cookie_export;
38pub mod cookies;
39pub mod design_mode;
40mod error;
41mod fixture;
42mod fixture_protocol;
43mod fixture_server;
44#[cfg(feature = "install")]
45pub mod install;
46mod keys;
47mod page;
48#[cfg(windows)]
49mod pipe_transport;
50mod policy;
51mod proc;
52mod proxy;
53mod real_session;
54mod sandbox_access;
55mod session;
56
57pub use cdp_ext::{
58    AxNode, AxSummary, ContinueOverrides, DownloadBehavior, ExceptionFrame, InterceptDecision,
59    InterceptFailure, InterceptStage, InterceptedRequest, PageException, RequestInterceptor,
60    MAX_EXCEPTIONS,
61};
62pub use config::{
63    chrome_for_testing_candidates, chrome_for_testing_path, find_chrome, LaunchOptions,
64    ManagedRoot, ProfileSpec, CHROME_FOR_TESTING_ENV, CHROME_FOR_TESTING_INSTALL_HINT,
65    CHROME_FOR_TESTING_ROOT_ENV,
66};
67#[cfg(feature = "cookie-export")]
68pub use cookie_export::{ClearOutcome, CookieExport, CookieExportError, ExportReport};
69pub use cookies::{
70    parse_netscape, CookieFieldError, CookieParseError, NetscapeCookie, MAX_COOKIES,
71    MAX_COOKIES_FILE_BYTES,
72};
73pub use error::{BrowserError, Result};
74pub use fixture::{
75    FixtureAttestation, FixtureCancellation, FixtureCleanupEvidence, FixtureConfinementBackend,
76    FixtureOutcome, FixtureOutcomeStatus, FixtureRunFailure, FixtureSession,
77};
78pub use fixture_protocol::{
79    actions_digest, FixtureAction, FixtureBundle, FixtureError, FixtureFile, FixtureIntent,
80    FixtureKey, FIXTURE_SCHEMA,
81};
82pub use fixture_server::FixtureServer;
83pub use page::{
84    BrowserPage, ConsoleLine, Observation, ObservedNode, Rect, ScreenshotOptions, Target,
85    OBSERVE_AX_DEPTH,
86};
87pub use policy::{
88    classify_ip, ActionKind, AddressClass, AdmissionHook, AdmissionRequest, AllowCallback,
89    BlockReason, BlockedRequest, BrowserEvent, BrowserRequest, Decision, EventSink, LifecycleKind,
90    NetworkPolicy, NetworkRequest, PolicyDecision, PolicyDenial, Resolver,
91};
92pub use proxy::PinnedConnection;
93pub use real_session::{
94    browser_executable, default_browser, list_profiles, purge_imported_profile, user_data_dir,
95    BrowserKind, BrowserSource, ConsentRevocation, ImportReport, ImportSpec, SourceProfile,
96    UserConsentReceipt, CONSENT_SCHEMA,
97};
98pub use session::{BrowserSession, PageSetup};