Skip to main content

hyperlane_plugin_webhook/
enum.rs

1/// Signature header encoding and payload-framing scheme for an inbound [`WebhookEndpoint`].
2#[derive(Clone, Debug, Eq, PartialEq)]
3pub enum WebhookScheme {
4    /// Hex-encoded 32-byte HMAC-SHA256 digest with an optional prefix (for example `Some("sha256=")` for GitHub).
5    Hex {
6        /// Optional literal prefix stripped before decoding 64 hex characters.
7        prefix: Option<String>,
8    },
9    /// Base64-encoded 32-byte HMAC-SHA256 digest with an optional prefix (for example Shopify or `Some("v1,")`).
10    Base64 {
11        /// Optional literal prefix stripped before decoding RFC 4648 base64.
12        prefix: Option<String>,
13    },
14    /// Stripe-style `t=<unix_secs>,<version>=<hex>[,<version>=<hex>...]` header signing `b"<t>.<body>"`.
15    StripeTimestamped {
16        /// Signature scheme version key (typically `"v1"`).
17        version: String,
18    },
19}
20
21/// Specific reason an inbound webhook request was rejected by [`WebhookVerifier`].
22#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23pub enum WebhookRejectReason {
24    /// Request body exceeded the configured `max_body_bytes` cap (`413 Payload Too Large`).
25    BodyTooLarge,
26    /// Required signature header was absent (`401 Unauthorized`).
27    MissingSignature,
28    /// Signature header could not be parsed or decoded (`401 Unauthorized`).
29    MalformedSignature,
30    /// Required timestamp header or `t=` parameter was absent or invalid (`401 Unauthorized`).
31    MissingTimestamp,
32    /// Timestamp fell outside the configured `±tolerance_secs` skew window (`401 Unauthorized`).
33    TimestampOutOfRange,
34    /// Constant-time HMAC-SHA256 comparison failed across all configured secrets (`401 Unauthorized`).
35    InvalidSignature,
36    /// Nonce/signature was already processed within `replay_ttl_secs` (`409 Conflict`).
37    ReplayDetected,
38}