reth_rpc_layer/
lib.rs

1//! Layer implementations used in RPC
2
3#![doc(
4    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
5    html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
6    issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
7)]
8#![cfg_attr(not(test), warn(unused_crate_dependencies))]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10
11use http::HeaderMap;
12use jsonrpsee_http_client::HttpResponse;
13
14mod auth_client_layer;
15mod auth_layer;
16mod compression_layer;
17mod jwt_validator;
18
19pub use auth_layer::{AuthService, ResponseFuture};
20pub use compression_layer::CompressionLayer;
21
22// Export alloy JWT types
23pub use alloy_rpc_types_engine::{Claims, JwtError, JwtSecret};
24
25pub use auth_client_layer::{secret_to_bearer_header, AuthClientLayer, AuthClientService};
26pub use auth_layer::AuthLayer;
27pub use jwt_validator::JwtAuthValidator;
28
29/// General purpose trait to validate Http Authorization headers. It's supposed to be integrated as
30/// a validator trait into an [`AuthLayer`].
31pub trait AuthValidator {
32    /// This function is invoked by the [`AuthLayer`] to perform validation on Http headers.
33    /// The result conveys validation errors in the form of an Http response.
34    fn validate(&self, headers: &HeaderMap) -> Result<(), HttpResponse>;
35}