pub struct VortexWebhooks { /* private fields */ }Expand description
Vortex webhook verification and parsing.
§Example
use vortex_sdk::VortexWebhooks;
let webhooks = VortexWebhooks::new("whsec_your_secret").unwrap();Implementations§
Source§impl VortexWebhooks
impl VortexWebhooks
Sourcepub fn new(secret: impl Into<String>) -> Result<Self, VortexError>
pub fn new(secret: impl Into<String>) -> Result<Self, VortexError>
Create a new webhook verifier with the given signing secret.
§Errors
Returns VortexError::WebhookSignatureError if the secret is empty.
Sourcepub fn verify_signature(&self, payload: &[u8], signature: &str) -> bool
pub fn verify_signature(&self, payload: &[u8], signature: &str) -> bool
Verify the HMAC-SHA256 signature of an incoming webhook payload.
Uses constant-time comparison to prevent timing attacks.
Sourcepub fn construct_event(
&self,
payload: &[u8],
signature: &str,
) -> Result<VortexEvent, VortexError>
pub fn construct_event( &self, payload: &[u8], signature: &str, ) -> Result<VortexEvent, VortexError>
Verify and parse an incoming webhook payload.
Returns a typed VortexEvent on success, or a VortexError::WebhookSignatureError
if the signature is invalid.
§Arguments
payload- The raw request body bytessignature- The value of theX-Vortex-Signatureheader
Auto Trait Implementations§
impl Freeze for VortexWebhooks
impl RefUnwindSafe for VortexWebhooks
impl Send for VortexWebhooks
impl Sync for VortexWebhooks
impl Unpin for VortexWebhooks
impl UnsafeUnpin for VortexWebhooks
impl UnwindSafe for VortexWebhooks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more