use super::*;
#[derive(Clone)]
pub struct Sha256State {
pub(crate) state: [u32; 8],
pub(crate) buf: [u8; 64],
pub(crate) buf_len: usize,
pub(crate) total_bytes: u64,
}
#[derive(Clone)]
pub struct HmacSha256Key {
pub(crate) ipad_state: [u32; 8],
pub(crate) opad_state: [u32; 8],
}
#[derive(Clone, Data, Eq, PartialEq)]
pub struct WebhookSecret {
pub(crate) id: String,
pub(crate) secret: Vec<u8>,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct WebhookEndpoint {
pub(crate) path_prefix: String,
pub(crate) signature_header: String,
pub(crate) scheme: WebhookScheme,
pub(crate) secrets: Vec<WebhookSecret>,
#[get(type(clone))]
pub(crate) timestamp_header: Option<String>,
#[get(type(clone))]
pub(crate) timestamp_payload_separator: Option<String>,
#[get(type(clone))]
pub(crate) id_header: Option<String>,
#[get(type(copy))]
pub(crate) tolerance_secs: u64,
#[get(type(copy))]
pub(crate) replay_ttl_secs: u64,
#[get(type(copy))]
pub(crate) max_body_bytes: usize,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct WebhookConfig {
pub(crate) endpoints: Vec<WebhookEndpoint>,
#[get(type(copy))]
pub(crate) replay_max_entries: usize,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct WebhookEvent {
pub(crate) endpoint_prefix: String,
pub(crate) secret_id: String,
#[get(type(copy))]
pub(crate) timestamp: Option<u64>,
#[get(type(clone))]
pub(crate) delivery_id: Option<String>,
#[get(type(copy))]
pub(crate) body_len: usize,
#[get(type(copy))]
pub(crate) verified: bool,
}
#[derive(Clone)]
pub(crate) struct CompiledSecret {
pub(crate) id: String,
pub(crate) key: HmacSha256Key,
}
#[derive(Clone)]
pub(crate) struct CompiledEndpoint {
pub(crate) prefix: String,
pub(crate) signature_header: String,
pub(crate) scheme: WebhookScheme,
pub(crate) secrets: Vec<CompiledSecret>,
pub(crate) timestamp_header: Option<String>,
pub(crate) timestamp_payload_separator: Option<String>,
pub(crate) id_header: Option<String>,
pub(crate) tolerance_secs: u64,
pub(crate) replay_ttl_secs: u64,
pub(crate) max_body_bytes: usize,
}
pub(crate) struct ReplayNonceCacheInner {
pub(crate) max_entries: usize,
pub(crate) count: AtomicUsize,
pub(crate) shards: ReplayShardArray,
}
#[derive(Clone)]
pub struct ReplayNonceCache {
pub(crate) inner: Arc<ReplayNonceCacheInner>,
}
#[derive(Clone)]
pub struct WebhookVerifier {
pub(crate) endpoints: Arc<Vec<CompiledEndpoint>>,
pub(crate) replay_cache: ReplayNonceCache,
pub(crate) prebuilt_unauthorized_wire: ResponseData,
pub(crate) prebuilt_replay_wire: ResponseData,
pub(crate) prebuilt_too_large_wire: ResponseData,
}
#[derive(Clone)]
pub struct WebhookPlugin {
pub(crate) verifier: WebhookVerifier,
}
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::request_middleware(-58)]
pub struct WebhookHook;