1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! # modo::client
//!
//! Client-context types and helpers shared across HTTP, audit, and session
//! code paths.
//!
//! Provides:
//!
//! - [`ClientInfo`] — structured client metadata (IP, user-agent, parsed
//! device fields, server-computed fingerprint). Populated automatically
//! in handlers via [`FromRequestParts`](axum::extract::FromRequestParts),
//! or built manually for non-HTTP contexts (background jobs, CLI tools).
//! - [`parse_device_name`] / [`parse_device_type`] — `User-Agent` classifiers.
//! - [`compute_fingerprint`] — SHA-256 hash of UA + Accept-Language +
//! Accept-Encoding for session-hijack detection.
//! - [`header_str`] — small helper that reads a header as `&str`, returning
//! `""` when absent or non-UTF-8. Useful for code paths that already hold
//! a `&HeaderMap` and need the same defaulting `ClientInfo` uses
//! internally.
//!
//! Used by [`crate::audit`] (persisted with audit events) and
//! [`crate::auth::session`] (session creation, fingerprint validation).
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use modo::client::ClientInfo;
//!
//! async fn handler(info: ClientInfo) -> String {
//! format!(
//! "{} from {}",
//! info.device_name_value().unwrap_or("Unknown"),
//! info.ip_value().unwrap_or("?"),
//! )
//! }
//! ```
pub use ;
pub use compute_fingerprint;
pub use ;