pub struct Signer;Expand description
Signs and checks webhook bodies.
Implementations§
Source§impl Signer
impl Signer
Sourcepub const HEADER: &'static str = "Webhook-Signature"
pub const HEADER: &'static str = "Webhook-Signature"
The request header that carries the signature.
Sourcepub fn sign(body: &str, secret: &str, timestamp: i64) -> String
pub fn sign(body: &str, secret: &str, timestamp: i64) -> String
The signature of body with secret, made at timestamp (unix seconds).
Sourcepub fn verify(
body: &str,
header: Option<&str>,
secret: &str,
tolerance: i64,
now: i64,
) -> bool
pub fn verify( body: &str, header: Option<&str>, secret: &str, tolerance: i64, now: i64, ) -> bool
Whether header is a valid signature of body with secret, made within tolerance
seconds of now. Any of several v1 signatures may match, so a sender can sign with an
old and a new secret while receivers switch.
Auto Trait Implementations§
impl Forget for Signer
impl Freeze for Signer
impl Move for Signer
impl RefUnwindSafe for Signer
impl Send for Signer
impl Sync for Signer
impl Unpin for Signer
impl UnsafeUnpin for Signer
impl UnwindSafe for Signer
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