Skip to main content

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))]
10
11use http::HeaderMap;
12use jsonrpsee_http_client::HttpResponse;
13
14mod auth_client_layer;
15mod auth_layer;
16mod compression_layer;
17mod decompression_layer;
18mod jwt_validator;
19
20pub use auth_layer::{AuthService, ResponseFuture};
21pub use compression_layer::CompressionLayer;
22pub use decompression_layer::DecompressionLayer;
23
24// Export alloy JWT types
25pub use alloy_rpc_types_engine::{Claims, JwtError, JwtSecret};
26
27pub use auth_client_layer::{secret_to_bearer_header, AuthClientLayer, AuthClientService};
28pub use auth_layer::AuthLayer;
29pub use jwt_validator::JwtAuthValidator;
30
31/// General purpose trait to validate Http Authorization headers. It's supposed to be integrated as
32/// a validator trait into an [`AuthLayer`].
33pub trait AuthValidator {
34    /// This function is invoked by the [`AuthLayer`] to perform validation on Http headers.
35    /// The result conveys validation errors in the form of an Http response.
36    #[expect(clippy::result_large_err)]
37    fn validate(&self, headers: &HeaderMap) -> Result<(), HttpResponse>;
38}