methodComputeSignature
public static string ComputeSignature(string secretKey, long timestampSeconds, ReadOnlySpan<byte> payloadBytes, WebhookSenderProtocol protocol, string? webhookId = null)
Computes the HMAC-SHA256 signature for raw webhook payload bytes according to the specified protocol.
- secretKey: string
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payloadBytes: ReadOnlySpan<byte>
- The raw payload byte span.
- protocol: WebhookSenderProtocol
- The webhook protocol specification determining the signature format and canonicalization.
- webhookId: string?
- The unique message or delivery identifier. Required when `protocol` is `WebhookSenderProtocol.Standard`.
Returns: The formatted signature string.
methodComputeSignature
public static string ComputeSignature(string secretKey, long timestampSeconds, string payload)
Computes the HMAC-SHA256 signature for a string payload using the default EricksonLopez protocol.
- secretKey: string
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payload: string
- The UTF-8 string payload content to sign.
Returns: The formatted signature string.
methodComputeSignature
public static string ComputeSignature(string secretKey, long timestampSeconds, string payload, WebhookSenderProtocol protocol, string? webhookId = null)
Computes the HMAC-SHA256 signature for a string payload according to the specified protocol.
- secretKey: string
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payload: string
- The UTF-8 string payload content to sign.
- protocol: WebhookSenderProtocol
- The webhook protocol specification determining the signature format and canonicalization.
- webhookId: string?
- The unique message or delivery identifier. Required when `protocol` is `WebhookSenderProtocol.Standard`.
Returns: The formatted signature string.
methodComputeSignature
public static string ComputeSignature(WebhookSecret secretKey, long timestampSeconds, ReadOnlySpan<byte> payloadBytes, WebhookSenderProtocol protocol = WebhookSenderProtocol.EricksonLopez, string? webhookId = null)
Computes the HMAC-SHA256 signature for raw webhook payload bytes using a `WebhookSecret`.
- secretKey: WebhookSecret
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payloadBytes: ReadOnlySpan<byte>
- The raw payload byte span to sign.
- protocol: WebhookSenderProtocol
- The webhook protocol specification determining the signature format and canonicalization.
- webhookId: string?
- The unique message or delivery identifier. Required when `protocol` is `WebhookSenderProtocol.Standard`.
Returns: The formatted signature string.
methodComputeSignature
public static string ComputeSignature(WebhookSecret secretKey, long timestampSeconds, string payload, WebhookSenderProtocol protocol = WebhookSenderProtocol.EricksonLopez, string? webhookId = null)
Computes the HMAC-SHA256 signature for a string payload using a `WebhookSecret`.
- secretKey: WebhookSecret
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payload: string
- The UTF-8 string payload content to sign.
- protocol: WebhookSenderProtocol
- The webhook protocol specification determining the signature format and canonicalization.
- webhookId: string?
- The unique message or delivery identifier. Required when `protocol` is `WebhookSenderProtocol.Standard`.
Returns: The formatted signature string.
methodComputeSignatureAsync
public static async Task<string> ComputeSignatureAsync(string secretKey, long timestampSeconds, Stream payloadStream, WebhookSenderProtocol protocol, string? webhookId = null, long? maxPayloadBytes = null, CancellationToken cancellationToken = default)
Computes the HMAC-SHA256 signature for a payload stream at a specific timestamp according to the specified protocol.
- secretKey: string
- The shared secret key that generates the signature.
- timestampSeconds: long
- The UNIX timestamp in seconds at which the signature was generated.
- payloadStream: Stream
- The readable payload stream to hash incrementally.
- protocol: WebhookSenderProtocol
- The webhook protocol specification determining the signature format.
- webhookId: string?
- The unique message or delivery identifier. Required when `protocol` is `WebhookSenderProtocol.Standard`.
- maxPayloadBytes: long?
- The optional maximum allowable bytes to read from the stream before aborting.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A task representing the asynchronous operation. The task result contains the formatted signature string.
methodVerifySignature
public static bool VerifySignature(string secretKey, long timestampSeconds, ReadOnlySpan<byte> payloadBytes, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId = null)
Verifies the signature of raw incoming webhook payload bytes using constant-time comparison according to protocol rules.
- secretKey: string
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payloadBytes: ReadOnlySpan<byte>
- The raw request payload byte span.
- receivedSignature: string
- The signature header value received, which may contain multiple space-delimited signatures.
- protocol: WebhookReceiverProtocol
- The expected webhook protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignature
public static bool VerifySignature(string secretKey, long timestampSeconds, string payload, string receivedSignature)
Verifies the signature of an incoming string payload using constant-time comparison with auto-detected protocol.
- secretKey: string
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payload: string
- The raw string payload to verify.
- receivedSignature: string
- The signature header value received from the request.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignature
public static bool VerifySignature(string secretKey, long timestampSeconds, string payload, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId = null)
Verifies the signature of an incoming string payload using constant-time comparison according to protocol rules.
- secretKey: string
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payload: string
- The raw request payload string to verify.
- receivedSignature: string
- The signature header value received, which may contain multiple space-delimited signatures.
- protocol: WebhookReceiverProtocol
- The expected webhook protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignature
public static bool VerifySignature(WebhookSecret secretKey, long timestampSeconds, ReadOnlySpan<byte> payloadBytes, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId = null)
Verifies the signature of raw incoming webhook payload bytes using a `WebhookSecret` and constant-time comparison according to protocol rules.
- secretKey: WebhookSecret
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payloadBytes: ReadOnlySpan<byte>
- The raw request payload byte span.
- receivedSignature: string
- The signature header value received from the request.
- protocol: WebhookReceiverProtocol
- The expected webhook protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignature
public static bool VerifySignature(WebhookSecret secretKey, long timestampSeconds, string payload, string receivedSignature)
Verifies the signature of an incoming string payload using a `WebhookSecret` and constant-time comparison with auto-detected protocol.
- secretKey: WebhookSecret
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payload: string
- The raw string payload to verify.
- receivedSignature: string
- The signature header value received from the request.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignature
public static bool VerifySignature(WebhookSecret secretKey, long timestampSeconds, string payload, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId = null)
Verifies the signature of an incoming string payload using a `WebhookSecret` and constant-time comparison according to protocol rules.
- secretKey: WebhookSecret
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payload: string
- The raw string payload to verify.
- receivedSignature: string
- The signature header value received from the request.
- protocol: WebhookReceiverProtocol
- The expected webhook protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
Returns: `true` if the signature is valid; otherwise, `false`.
methodVerifySignatureAsync
public static async Task<bool> VerifySignatureAsync(IEnumerable<string> secretKeys, long timestampSeconds, Stream payloadStream, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId, long? maxPayloadBytes, CancellationToken cancellationToken = default)
Verifies the signature of an incoming webhook payload stream against multiple secret keys using constant-time comparison, aborting early if the stream exceeds `maxPayloadBytes`.
- secretKeys: IEnumerable<string>
- The collection of shared secret keys to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payloadStream: Stream
- The readable payload stream to verify.
- receivedSignature: string
- The signature header value received, which may contain multiple space-delimited signatures.
- protocol: WebhookReceiverProtocol
- The expected webhook receiver protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
- maxPayloadBytes: long?
- The optional maximum allowable bytes to read from the stream before aborting.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A task representing the asynchronous operation. The task result contains `true` if the signature is valid for any key; otherwise, `false`.
methodVerifySignatureAsync
public static Task<bool> VerifySignatureAsync(string secretKey, long timestampSeconds, Stream payloadStream, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId = null, CancellationToken cancellationToken = default)
Verifies the signature of an incoming webhook payload stream using constant-time comparison according to protocol rules.
- secretKey: string
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payloadStream: Stream
- The readable payload stream to verify.
- receivedSignature: string
- The signature header value received, which may contain multiple space-delimited signatures.
- protocol: WebhookReceiverProtocol
- The expected webhook receiver protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A task representing the asynchronous operation. The task result contains `true` if the signature is valid; otherwise, `false`.
methodVerifySignatureAsync
public static Task<bool> VerifySignatureAsync(string secretKey, long timestampSeconds, Stream payloadStream, string receivedSignature, WebhookReceiverProtocol protocol, string? webhookId, long? maxPayloadBytes, CancellationToken cancellationToken = default)
Verifies the signature of an incoming webhook payload stream using constant-time comparison according to protocol rules, aborting early if the stream exceeds `maxPayloadBytes`.
- secretKey: string
- The shared secret key to verify against the signature.
- timestampSeconds: long
- The timestamp header value in seconds.
- payloadStream: Stream
- The readable payload stream to verify.
- receivedSignature: string
- The signature header value received, which may contain multiple space-delimited signatures.
- protocol: WebhookReceiverProtocol
- The expected webhook receiver protocol convention.
- webhookId: string?
- The unique message or delivery identifier, if available.
- maxPayloadBytes: long?
- The optional maximum allowable bytes to read from the stream before aborting.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A task representing the asynchronous operation. The task result contains `true` if the signature is valid; otherwise, `false`.