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.
31mod cdp_ext;
32mod config;
33#[cfg(feature = "cookie-export")]
34pub mod cookie_export;
35pub mod cookies;
36pub mod design_mode;
37mod error;
38mod fixture;
39mod fixture_protocol;
40mod fixture_server;
41#[cfg(feature = "install")]
42pub mod install;
43mod keys;
44mod page;
45#[cfg(windows)]
46mod pipe_transport;
47mod policy;
48mod proc;
49mod proxy;
50mod real_session;
51mod sandbox_access;
52mod session;
53
54pub use cdp_ext::{
55 AxNode, AxSummary, ContinueOverrides, DownloadBehavior, ExceptionFrame, InterceptDecision,
56 InterceptFailure, InterceptStage, InterceptedRequest, PageException, RequestInterceptor,
57 MAX_EXCEPTIONS,
58};
59pub use config::{
60 chrome_for_testing_candidates, chrome_for_testing_path, find_chrome, LaunchOptions,
61 ManagedRoot, ProfileSpec, CHROME_FOR_TESTING_ENV, CHROME_FOR_TESTING_INSTALL_HINT,
62 CHROME_FOR_TESTING_ROOT_ENV,
63};
64#[cfg(feature = "cookie-export")]
65pub use cookie_export::{ClearOutcome, CookieExport, CookieExportError, ExportReport};
66pub use cookies::{
67 parse_netscape, CookieFieldError, CookieParseError, NetscapeCookie, MAX_COOKIES,
68 MAX_COOKIES_FILE_BYTES,
69};
70pub use error::{BrowserError, Result};
71pub use fixture::{
72 FixtureAttestation, FixtureCancellation, FixtureCleanupEvidence, FixtureConfinementBackend,
73 FixtureOutcome, FixtureOutcomeStatus, FixtureRunFailure, FixtureSession,
74};
75pub use fixture_protocol::{
76 actions_digest, FixtureAction, FixtureBundle, FixtureError, FixtureFile, FixtureIntent,
77 FixtureKey, FIXTURE_SCHEMA,
78};
79pub use fixture_server::FixtureServer;
80pub use page::{
81 BrowserPage, ConsoleLine, Observation, ObservedNode, Rect, ScreenshotOptions, Target,
82 OBSERVE_AX_DEPTH,
83};
84pub use policy::{
85 classify_ip, ActionKind, AddressClass, AdmissionHook, AdmissionRequest, AllowCallback,
86 BlockReason, BlockedRequest, BrowserEvent, BrowserRequest, Decision, EventSink, LifecycleKind,
87 NetworkPolicy, NetworkRequest, PolicyDecision, PolicyDenial, Resolver,
88};
89pub use proxy::PinnedConnection;
90pub use real_session::{
91 browser_executable, default_browser, list_profiles, purge_imported_profile, user_data_dir,
92 BrowserKind, BrowserSource, ConsentRevocation, ImportReport, ImportSpec, SourceProfile,
93 UserConsentReceipt, CONSENT_SCHEMA,
94};
95pub use session::{BrowserSession, PageSetup};