Skip to main content

nab/
lib.rs

1// Cast-precision and float-comparison lints are noise in audio/PDF processing
2// code where exact precision is irrelevant and the casts are intentional.
3#![allow(
4    clippy::cast_possible_truncation,
5    clippy::cast_possible_wrap,
6    clippy::cast_precision_loss,
7    clippy::cast_sign_loss,
8    clippy::cast_lossless,
9    clippy::float_cmp
10)]
11
12//! `nab` - Multimodal web microfetch for LLM agents
13//!
14//! # Features
15//!
16//! - **HTTP Acceleration**: HTTP/2 multiplexing, TLS 1.3, Brotli/Zstd compression
17//! - **Browser Fingerprinting**: Realistic Chrome/Firefox/Safari profiles
18//! - **Authentication**: 1Password CLI integration, cookie extraction
19//! - **JavaScript**: `QuickJS` engine with minimal DOM
20//!
21//! # Example
22//!
23//! ```rust,no_run
24//! use nab::AcceleratedClient;
25//!
26//! #[tokio::main]
27//! async fn main() -> anyhow::Result<()> {
28//!     let client = AcceleratedClient::new()?;
29//!     let html = client.fetch_text("https://example.com").await?;
30//!     println!("Fetched {} bytes", html.len());
31//!     Ok(())
32//! }
33//! ```
34
35pub mod error;
36
37/// Internal implementation modules — not stable public API.
38#[doc(hidden)]
39pub mod analyze;
40/// Internal implementation modules — not stable public API.
41#[doc(hidden)]
42pub mod annotate;
43pub mod api_discovery;
44pub mod arena;
45pub mod auth;
46#[cfg(any(feature = "browser", feature = "browser-launcher"))]
47pub mod browser;
48pub mod browser_detect;
49pub mod content;
50pub mod detect;
51/// Internal implementation modules — not stable public API.
52#[doc(hidden)]
53pub mod fetch_bridge;
54pub mod fingerprint;
55pub mod form;
56pub mod http3_client;
57pub mod http_client;
58#[cfg(feature = "impersonate")]
59pub mod impersonate_client;
60/// Internal implementation modules — not stable public API.
61#[doc(hidden)]
62pub mod js_engine;
63pub mod login;
64pub mod mfa;
65pub mod plugin;
66pub mod prefetch;
67pub mod rate_limit;
68pub mod security;
69pub mod session;
70pub mod site;
71pub mod ssrf;
72pub mod stream;
73/// Internal implementation modules — not stable public API.
74#[doc(hidden)]
75pub mod util;
76pub mod waf;
77pub mod watch;
78pub mod webmcp;
79pub mod websocket;
80
81pub use error::NabError;
82
83pub use api_discovery::{ApiDiscovery, ApiEndpoint};
84pub use auth::{
85    CookieSource, Credential, CredentialRetriever, CredentialSource, OnePasswordAuth, OtpCode,
86    OtpRetriever, OtpSource,
87};
88#[cfg(any(feature = "browser", feature = "browser-launcher"))]
89pub use browser::open_and_wait;
90#[cfg(feature = "browser")]
91pub use browser::{BrowserLogin, Cookie};
92pub use browser_detect::{BrowserType, detect_default_browser};
93pub use fingerprint::{
94    BrowserProfile, chrome_profile, firefox_profile, random_profile, safari_profile,
95};
96pub use form::{Form, parse_field_args};
97pub use http_client::{
98    AcceleratedClient, SafeFetchConfig, SafeFetchResponse, SafeRequestOptions, TOR_PROXY_URL,
99};
100pub use http3_client::Http3Client;
101#[cfg(feature = "http3")]
102pub use http3_client::Http3Response;
103pub use login::{LoginFlow, LoginResult};
104pub use mfa::{MfaHandler, MfaResult, MfaType, NotificationConfig, detect_mfa_type};
105pub use prefetch::{EarlyHintLink, EarlyHints, PrefetchManager, extract_link_hints};
106pub use session::{MAX_SESSIONS, SessionStore, get_session_dir};
107pub use ssrf::{
108    DEFAULT_MAX_BODY_SIZE, DEFAULT_MAX_REDIRECTS, extract_mapped_ipv4, is_denied_ipv4,
109    is_denied_ipv6, validate_ip, validate_redirect_target, validate_url,
110};
111pub use stream::{StreamBackend, StreamInfo, StreamProvider};
112pub use watch::{AddOptions, Watch, WatchEvent, WatchId, WatchManager, WatchOptions};
113pub use webmcp::{
114    DiscoveryResult, McpManifest, McpTool, extract_link_href, parse_manifest_bytes,
115    resolve_manifest_url, well_known_url,
116};
117pub use websocket::{JsonRpcWebSocket, WebSocket, WebSocketMessage};
118
119/// Version of nab
120pub const VERSION: &str = env!("CARGO_PKG_VERSION");