From 6ab15532b8ad5f4054c3b81671fb1c83df0aff9d Mon Sep 17 00:00:00 2001 From: Joe Feinour <1733707+feinoujc@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:05:39 -0500 Subject: [PATCH] feat(webhooks): add override for verify that takes string --- .../Model/WebHook/WebHookSignatureHelper.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mandrill.net/Model/WebHook/WebHookSignatureHelper.cs b/src/Mandrill.net/Model/WebHook/WebHookSignatureHelper.cs index 83cf8f8..9f219d3 100644 --- a/src/Mandrill.net/Model/WebHook/WebHookSignatureHelper.cs +++ b/src/Mandrill.net/Model/WebHook/WebHookSignatureHelper.cs @@ -8,13 +8,12 @@ namespace Mandrill.Model { public static class WebHookSignatureHelper { - public static bool VerifyWebHookSignature(string signature, string key, Uri absoluteUri, NameValueCollection formPost) + public static bool VerifyWebHookSignature(string signature, string key, string absoluteUri, NameValueCollection formPost) { if (signature == null) throw new ArgumentNullException(nameof(signature)); if (key == null) throw new ArgumentNullException(nameof(key)); if (absoluteUri == null) throw new ArgumentNullException(nameof(absoluteUri)); if (formPost == null) throw new ArgumentNullException(nameof(formPost)); - if (!absoluteUri.IsAbsoluteUri) throw new ArgumentException("uri must be an absolute uri", nameof(absoluteUri)); var toSign = new StringBuilder(); toSign.Append(absoluteUri); @@ -32,5 +31,12 @@ public static bool VerifyWebHookSignature(string signature, string key, Uri abso return signature == hash; } } + public static bool VerifyWebHookSignature(string signature, string key, Uri absoluteUri, NameValueCollection formPost) + { + if (absoluteUri == null) throw new ArgumentNullException(nameof(absoluteUri)); + if (!absoluteUri.IsAbsoluteUri) throw new ArgumentException("uri must be an absolute uri", nameof(absoluteUri)); + + return VerifyWebHookSignature(signature, key, absoluteUri.ToString(), formPost); + } } }