Skip to main content

hyperlane_plugin_webhook/
lib.rs

1//! hyperlane-plugin-webhook
2//!
3//! Production inbound HTTP webhook verification plugin for Hyperlane with
4//! zero-allocation precomputed-midstate pure-Rust HMAC-SHA256 (`Hex`, `Base64`,
5//! and Stripe-style `t=...,v1=...` schemes), per-route secret rotation,
6//! timestamp skew enforcement, 64-shard bounded TTL replay-nonce caching, and
7//! verified [`WebhookEvent`] `Context` injection.
8
9mod r#const;
10mod r#enum;
11mod r#fn;
12mod r#impl;
13mod r#static;
14mod r#struct;
15mod r#type;
16
17#[cfg(test)]
18#[path = "../tests/mod.rs"]
19mod tests;
20
21pub use {r#const::*, r#enum::*, r#fn::*, r#struct::*};
22
23pub(crate) use {r#static::*, r#type::*};
24
25#[cfg(target_arch = "aarch64")]
26#[cfg(target_feature = "sha2")]
27#[cfg(target_endian = "little")]
28use std::arch::aarch64::{
29    uint32x4_t, vaddq_u32, vld1q_u8, vld1q_u32, vreinterpretq_u32_u8, vrev32q_u8, vsha256h2q_u32,
30    vsha256hq_u32, vsha256su0q_u32, vsha256su1q_u32, vst1q_u32,
31};
32use std::{
33    array::from_fn,
34    cmp::Reverse,
35    collections::{HashMap, VecDeque, hash_map::Entry},
36    fmt::{self, Debug, Formatter},
37    hash::{BuildHasherDefault, Hasher},
38    sync::{
39        Arc, Mutex, MutexGuard, OnceLock,
40        atomic::{AtomicUsize, Ordering},
41    },
42    time::{Duration, SystemTime, UNIX_EPOCH},
43};
44
45use {
46    hyperlane::{
47        CONTENT_TYPE, Context, HttpStatus, RequestHeaders, Response, ResponseError, ServerHook,
48        Status, Stream,
49    },
50    lombok_macros::*,
51};