15
15
using Microsoft . AspNetCore . Http ;
16
16
17
17
namespace Deveel . Webhooks {
18
- /// <summary>
19
- /// A service that is used to verify a request of acknowledgement
20
- /// by the sender of a webhook, before the webhook is sent.
21
- /// </summary>
22
- /// <typeparam name="TWebhook">
23
- /// The type of webhook that is being verified
24
- /// </typeparam>
25
- /// <remarks>
26
- /// In several case scenarios, providers of webhooks require a verification
27
- /// of the party to ensure they are the ones who should be receiving the
28
- /// webhooks, and not a malicious party.
29
- /// </remarks>
30
- public interface IWebhookRequestVerifier < TWebhook > {
18
+ /// <summary>
19
+ /// A service that is used to verify a request of acknowledgement
20
+ /// by the sender of a webhook, before the webhook is sent.
21
+ /// </summary>
22
+ /// <typeparam name="TWebhook">
23
+ /// The type of webhook that is being verified
24
+ /// </typeparam>
25
+ /// <remarks>
26
+ /// <para>
27
+ /// In several case scenarios, providers of webhooks require a verification
28
+ /// of the party to ensure they are the ones who should be receiving the
29
+ /// webhooks, and not a malicious party.
30
+ /// </para>
31
+ /// <para>
32
+ /// The process of verification is usually a two-step process, where the
33
+ /// request is first validated, and then the instance of the result of the
34
+ /// validation is passed back to the verifier to handle the result towards
35
+ /// the sender: this mechanism is used to ensure that the verification process
36
+ /// is specific for the provider of the webhook, since the different methodologies
37
+ /// implemented by various providers.
38
+ /// </para>
39
+ /// </remarks>
40
+ public interface IWebhookRequestVerifier < TWebhook > {
31
41
/// <summary>
32
42
/// Verifies the request of acknowledgement of a webhook.
33
43
/// </summary>
@@ -42,6 +52,20 @@ public interface IWebhookRequestVerifier<TWebhook> {
42
52
/// Returns a <see cref="WebhookVerificationResult"/> that indicates the result
43
53
/// of the verification operation.
44
54
/// </returns>
45
- Task < WebhookVerificationResult > VerifyRequestAsync ( HttpRequest httpRequest , CancellationToken cancellationToken = default ) ;
55
+ Task < IWebhookVerificationResult > VerifyRequestAsync ( HttpRequest httpRequest , CancellationToken cancellationToken = default ) ;
56
+
57
+
58
+ /// <summary>
59
+ /// Handles the result of the verification of a webhook request.
60
+ /// </summary>
61
+ /// <param name="result">The result of the verification that should be handled</param>
62
+ /// <param name="httpResponse">The HTTP response used to notify the sender</param>
63
+ /// <param name="cancellationToken">
64
+ /// A token that can be used to cancel the operation
65
+ /// </param>
66
+ /// <returns>
67
+ /// Returns a <see cref="Task"/> that completes when the result is handled.
68
+ /// </returns>
69
+ Task HandleResultAsync ( IWebhookVerificationResult result , HttpResponse httpResponse , CancellationToken cancellationToken ) ;
46
70
}
47
71
}
0 commit comments