Skip to content

Commit

Permalink
allow to verify Alby webhook requests
Browse files Browse the repository at this point in the history
  • Loading branch information
joksas committed Aug 16, 2024
1 parent 68fa572 commit db10913
Show file tree
Hide file tree
Showing 3 changed files with 437 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["RSS Blue", "Dovydas Joksas"]
name = "v4v"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "Value-for-value helper utilities for Podcasting 2.0"
license = "MIT OR Apache-2.0"
Expand All @@ -14,6 +14,8 @@ pretty_assertions = "1.4.0"
paste = "1.0.15"

[dependencies]

[lib]
doctest = false
base64 = "0.22.1"
hmac-sha256 = "1.1.7"
http02 = { package = "http", version = "0.2.12" }
http1 = { package = "http", version = "1.1.0" }
time = "0.3.36"
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]

mod svix_webhooks;
pub use svix_webhooks::{HeaderMap, WebhookError};

/// Distributes [satoshis (sats)](https://en.wikipedia.org/wiki/Bitcoin#Units_and_divisibility) to
/// a list of recipients based on their splits.
///
Expand Down Expand Up @@ -174,3 +177,12 @@ pub fn fee_recipients_to_splits(

Ok(result)
}

/// Verifies Alby webhook requests.
pub fn verify_alby_signature<HM: HeaderMap>(
secret: &str,
payload: &[u8],
headers: &HM,
) -> Result<(), WebhookError> {
crate::svix_webhooks::Webhook::new(secret)?.verify(payload, headers)
}
Loading

0 comments on commit db10913

Please sign in to comment.