Referencia Pública de API .NETL3 Persistencia e IntegracionesEstableAOT: Completo

EricksonLopez.Webhooks

Production-ready webhook engine for .NET 8/9/10: resilient outbound delivery with Polly v8 & socket-level SSRF mitigation, Redis distributed DLQ & anti-replay defense, and ASP.NET Core inbound verification middleware with Native AOT & OpenTelemetry.

5 namespaces44 tipos180 miembrosGenerado desde XML docs y ensamblados · UTC 2026-12-01

Mostrando 44 de 44 tipos (180 miembros)

EricksonLopez.Webhooks#

24
interface

ITimestampedWebhookVerifier

Ensamblado: EricksonLopez.Webhooks
public interface ITimestampedWebhookVerifier

Defines a cryptographic verifier for inbound webhooks that binds the delivery timestamp directly into the HMAC-SHA256 signature input (`"{timestamp}.{rawPayload}"`), compares digests in constant time, enforces a drift window, and optionally records nonces in a replay store.

Miembros (4)

  • methodVerifyStripeV1
    Result<long> VerifyStripeV1(ReadOnlySpan<byte> rawPayload, string? stripeSignatureHeader, string? endpointSecret, TimeSpan? tolerance = null)

    Synchronously verifies a Stripe-formatted `Stripe-Signature` header (`t=...,v1=...`) using HMAC-SHA256 over `"{t}.{rawPayload}"`.

    rawPayload: ReadOnlySpan<byte>
    The exact UTF-8 payload bytes received over the wire.
    stripeSignatureHeader: string?
    The `Stripe-Signature` header value.
    endpointSecret: string?
    The Stripe webhook endpoint secret.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).

    Retorna: A successful `Result<TValue>` containing the verified Unix timestamp in seconds; otherwise, an error.

  • methodVerifyStripeV1Async
    ValueTask<Result<long>> VerifyStripeV1Async(ReadOnlyMemory<byte> rawPayload, string? stripeSignatureHeader, string? endpointSecret, string? deliveryId = null, TimeSpan? tolerance = null, CancellationToken ct = default)

    Asynchronously verifies a Stripe-formatted `Stripe-Signature` header (`t=...,v1=...`) and enforces replay deduplication when configured.

    rawPayload: ReadOnlyMemory<byte>
    The exact UTF-8 payload bytes received over the wire.
    stripeSignatureHeader: string?
    The `Stripe-Signature` header value.
    endpointSecret: string?
    The Stripe webhook endpoint secret.
    deliveryId: string?
    An optional unique event or delivery identifier.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).
    ct: CancellationToken
    A cancellation token.

    Retorna: A value task containing the verified Unix timestamp in seconds; otherwise, an error.

  • methodVerifyTimestampedHmacSha256
    Result<long> VerifyTimestampedHmacSha256(ReadOnlySpan<byte> rawPayload, string? signatureHeader, string? timestampHeader, ReadOnlySpan<byte> secret, TimeSpan? tolerance = null)

    Synchronously verifies an inbound HMAC-SHA256 webhook signature over `"{timestamp}.{rawPayload}"` within the configured tolerance window.

    rawPayload: ReadOnlySpan<byte>
    The exact UTF-8 payload bytes received over the wire.
    signatureHeader: string?
    The signature header value (supports `v1=hex`, `sha256=hex`, raw hex, or Base64).
    timestampHeader: string?
    The timestamp header value (Unix epoch seconds or ISO-8601 UTC timestamp).
    secret: ReadOnlySpan<byte>
    The shared secret key bytes.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).

    Retorna: A successful `Result<TValue>` containing the verified Unix timestamp in seconds; otherwise, an unauthorized or validation error.

  • methodVerifyTimestampedHmacSha256Async
    ValueTask<Result<long>> VerifyTimestampedHmacSha256Async(ReadOnlyMemory<byte> rawPayload, string? signatureHeader, string? timestampHeader, ReadOnlyMemory<byte> secret, string? deliveryId = null, TimeSpan? tolerance = null, CancellationToken ct = default)

    Asynchronously verifies an inbound HMAC-SHA256 webhook signature over `"{timestamp}.{rawPayload}"` and records the delivery in the configured `IWebhookReplayDetector`.

    rawPayload: ReadOnlyMemory<byte>
    The exact UTF-8 payload bytes received over the wire.
    signatureHeader: string?
    The signature header value.
    timestampHeader: string?
    The timestamp header value.
    secret: ReadOnlyMemory<byte>
    The shared secret key bytes.
    deliveryId: string?
    An optional unique webhook delivery identifier used for replay deduplication.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).
    ct: CancellationToken
    A cancellation token.

    Retorna: A value task containing the verified Unix timestamp in seconds; otherwise, an unauthorized or validation error.

interface

IWebhookDeadLetterSink

Ensamblado: EricksonLopez.Webhooks
public interface IWebhookDeadLetterSink

Defines a storage contract for failed, unrecoverable webhook deliveries that have exceeded retry limits.

Miembros (1)

  • methodEnqueueAsync
    Task EnqueueAsync(Uri targetUrl, WebhookPayload payload, WebhookDeliveryResult lastResult, CancellationToken cancellationToken = default)

    Enqueues a failed webhook delivery into the dead-letter sink.

    targetUrl: Uri
    The target webhook endpoint URL.
    payload: WebhookPayload
    The delivery payload envelope containing event metadata and data.
    lastResult: WebhookDeliveryResult
    The outcome of the final delivery attempt.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

interface

IWebhookReplayDetector

Ensamblado: EricksonLopez.Webhooks
public interface IWebhookReplayDetector

Defines a contract for detecting and preventing replay attacks by tracking processed webhook message identifiers.

Miembros (1)

  • methodTryRecordAsync
    ValueTask<bool> TryRecordAsync(string messageId, CancellationToken cancellationToken = default)

    Attempts to record a webhook message identifier to detect duplicate transmissions.

    messageId: string
    The unique message identifier to record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A value task representing the asynchronous operation. The task result contains `true` if the message identifier was successfully recorded; otherwise, `false` if a replay was detected.

interface

IWebhookSender

Ensamblado: EricksonLopez.Webhooks
public interface IWebhookSender

Defines outbound webhook delivery capabilities with cryptographic signing and automated retry management.

Miembros (1)

  • methodSendAsync
    Task<Result<WebhookDeliveryResult>> SendAsync(WebhookMessage message, CancellationToken cancellationToken = default)

    Delivers an outbound webhook message to the destination endpoint with cryptographic signing.

    message: WebhookMessage
    The webhook message envelope containing destination, payload, and cryptographic key.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a result indicating whether delivery succeeded, along with the delivery metadata.

class

InMemoryWebhookDeadLetterSink

Ensamblado: EricksonLopez.Webhooks
public sealed class InMemoryWebhookDeadLetterSink : IWebhookDeadLetterSink
Implementa: IWebhookDeadLetterSink

Represents an in-memory thread-safe bounded dead-letter sink for development and testing environments.

Notas:

This type is intended for testing and development only. For production deployments, use a durable distributed dead-letter queue such as Redis or a persistent broker.

Miembros (6)

  • constructorInMemoryWebhookDeadLetterSink
    public InMemoryWebhookDeadLetterSink()

    Initializes a new instance of the `InMemoryWebhookDeadLetterSink` class with a default maximum capacity of 1,000 entries.

  • constructorInMemoryWebhookDeadLetterSink
    public InMemoryWebhookDeadLetterSink(int maxCapacity)

    Initializes a new instance of the `InMemoryWebhookDeadLetterSink` class with the specified capacity limit.

    maxCapacity: int
    The maximum number of dead-letter entries to retain before dropping the oldest.

    Exceptions: ArgumentOutOfRangeException: `maxCapacity` is less than or equal to zero

  • methodEnqueueAsync
    public Task EnqueueAsync(Uri targetUrl, WebhookPayload payload, WebhookDeliveryResult lastResult, CancellationToken cancellationToken = default)

    Enqueues a failed webhook delivery into the dead-letter sink.

    targetUrl: Uri
    The target webhook endpoint URL.
    payload: WebhookPayload
    The delivery payload envelope containing event metadata and data.
    lastResult: WebhookDeliveryResult
    The outcome of the final delivery attempt.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `targetUrl` or `payload` is `null`

  • methodGetSnapshot
    public IReadOnlyCollection<(Uri TargetUrl, WebhookPayload Payload, WebhookDeliveryResult LastResult)> GetSnapshot()

    Retrieves a snapshot of all dead-lettered entries currently held in the sink.

    Retorna: A read-only collection containing the snapshot of dead-lettered entries.

  • propertyCount
    public int Count { get; }

    Gets the number of items currently held in the dead-letter sink.

  • propertyMaxCapacity
    public int MaxCapacity { get; }

    Gets the maximum capacity configured for this dead-letter sink.

class

InMemoryWebhookReplayDetector

Ensamblado: EricksonLopez.Webhooks
public sealed class InMemoryWebhookReplayDetector : IWebhookReplayDetector, IDisposable
Implementa: IDisposable, IWebhookReplayDetector

Represents an in-memory replay attack detector for single-node webhook processing.

Notas:

This type is thread-safe. It tracks processed message identifiers in memory and is not suitable for distributed environments or multi-node clusters where a shared store is required.

Miembros (4)

  • constructorInMemoryWebhookReplayDetector
    public InMemoryWebhookReplayDetector()

    Initializes a new instance of the `InMemoryWebhookReplayDetector` class with a default retention period of five minutes.

  • constructorInMemoryWebhookReplayDetector
    public InMemoryWebhookReplayDetector(TimeSpan retentionPeriod)

    Initializes a new instance of the `InMemoryWebhookReplayDetector` class with the specified retention period.

    retentionPeriod: TimeSpan
    The duration to retain message identifiers. Typically matches or exceeds the timestamp tolerance window.
  • methodDispose
    public void Dispose()

    Releases the unmanaged and managed resources used by the `InMemoryWebhookReplayDetector`.

  • methodTryRecordAsync
    public ValueTask<bool> TryRecordAsync(string messageId, CancellationToken cancellationToken = default)

    Attempts to record a webhook message identifier to detect duplicate transmissions.

    messageId: string
    The unique message identifier to record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A value task representing the asynchronous operation. The task result contains `true` if the message identifier was successfully recorded; otherwise, `false` if a replay was detected.

    Exceptions: ObjectDisposedException: The current instance has already been disposed; ArgumentException: `messageId` is `null`, empty, or consists only of white-space characters

class

NoOpWebhookDeadLetterSink

Ensamblado: EricksonLopez.Webhooks
public sealed class NoOpWebhookDeadLetterSink : IWebhookDeadLetterSink
Implementa: IWebhookDeadLetterSink

Represents a dead-letter sink that silently discards failed messages without persistence.

Notas:

Serves as a safe default implementation to avoid unbounded memory consumption when no persistent sink is registered.

Miembros (1)

  • methodEnqueueAsync
    public Task EnqueueAsync(Uri targetUrl, WebhookPayload payload, WebhookDeliveryResult lastResult, CancellationToken cancellationToken = default)

    Enqueues a failed webhook delivery into the dead-letter sink.

    targetUrl: Uri
    The target webhook endpoint URL.
    payload: WebhookPayload
    The delivery payload envelope containing event metadata and data.
    lastResult: WebhookDeliveryResult
    The outcome of the final delivery attempt.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

class

TimestampedWebhookVerifier

Ensamblado: EricksonLopez.Webhooks
public sealed class TimestampedWebhookVerifier : ITimestampedWebhookVerifier
Implementa: ITimestampedWebhookVerifier

Verifies inbound webhook payloads using timestamp-bound HMAC-SHA256 (`"{timestamp}.{rawPayload}"`), `CryptographicOperations.FixedTimeEquals`, configurable clock-skew tolerance, and optional `IWebhookReplayDetector` deduplication.

Miembros (7)

  • constructorTimestampedWebhookVerifier
    public TimestampedWebhookVerifier(TimeProvider? timeProvider = null, IWebhookReplayDetector? replayDetector = null, string? replayScope = null)

    Initializes a new instance of the `TimestampedWebhookVerifier` class.

    timeProvider: TimeProvider?
    Optional time provider for deterministic clock evaluation.
    replayDetector: IWebhookReplayDetector?
    Optional distributed or in-memory replay store (such as Redis `SETNX`).
    replayScope: string?
    Optional logical scope prefix isolating replay keys per provider or tenant.
  • methodComputeSignatureHex
    public static string ComputeSignatureHex(ReadOnlySpan<byte> secret, long timestampSeconds, ReadOnlySpan<byte> rawPayload)

    Computes the lowercase hexadecimal HMAC-SHA256 digest over `"{timestampSeconds}.{rawPayload}"`.

    secret: ReadOnlySpan<byte>
    The secret key bytes.
    timestampSeconds: long
    The Unix epoch timestamp in seconds.
    rawPayload: ReadOnlySpan<byte>
    The raw payload bytes.

    Retorna: The 64-character lowercase hexadecimal HMAC-SHA256 signature.

  • methodVerifyStripeV1
    public Result<long> VerifyStripeV1(ReadOnlySpan<byte> rawPayload, string? stripeSignatureHeader, string? endpointSecret, TimeSpan? tolerance = null)

    Synchronously verifies a Stripe-formatted `Stripe-Signature` header (`t=...,v1=...`) using HMAC-SHA256 over `"{t}.{rawPayload}"`.

    rawPayload: ReadOnlySpan<byte>
    The exact UTF-8 payload bytes received over the wire.
    stripeSignatureHeader: string?
    The `Stripe-Signature` header value.
    endpointSecret: string?
    The Stripe webhook endpoint secret.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).

    Retorna: A successful `Result<TValue>` containing the verified Unix timestamp in seconds; otherwise, an error.

  • methodVerifyStripeV1Async
    public async ValueTask<Result<long>> VerifyStripeV1Async(ReadOnlyMemory<byte> rawPayload, string? stripeSignatureHeader, string? endpointSecret, string? deliveryId = null, TimeSpan? tolerance = null, CancellationToken ct = default)

    Asynchronously verifies a Stripe-formatted `Stripe-Signature` header (`t=...,v1=...`) and enforces replay deduplication when configured.

    rawPayload: ReadOnlyMemory<byte>
    The exact UTF-8 payload bytes received over the wire.
    stripeSignatureHeader: string?
    The `Stripe-Signature` header value.
    endpointSecret: string?
    The Stripe webhook endpoint secret.
    deliveryId: string?
    An optional unique event or delivery identifier.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).
    ct: CancellationToken
    A cancellation token.

    Retorna: A value task containing the verified Unix timestamp in seconds; otherwise, an error.

  • methodVerifyTimestampedHmacSha256
    public Result<long> VerifyTimestampedHmacSha256(ReadOnlySpan<byte> rawPayload, string? signatureHeader, string? timestampHeader, ReadOnlySpan<byte> secret, TimeSpan? tolerance = null)

    Synchronously verifies an inbound HMAC-SHA256 webhook signature over `"{timestamp}.{rawPayload}"` within the configured tolerance window.

    rawPayload: ReadOnlySpan<byte>
    The exact UTF-8 payload bytes received over the wire.
    signatureHeader: string?
    The signature header value (supports `v1=hex`, `sha256=hex`, raw hex, or Base64).
    timestampHeader: string?
    The timestamp header value (Unix epoch seconds or ISO-8601 UTC timestamp).
    secret: ReadOnlySpan<byte>
    The shared secret key bytes.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).

    Retorna: A successful `Result<TValue>` containing the verified Unix timestamp in seconds; otherwise, an unauthorized or validation error.

  • methodVerifyTimestampedHmacSha256Async
    public async ValueTask<Result<long>> VerifyTimestampedHmacSha256Async(ReadOnlyMemory<byte> rawPayload, string? signatureHeader, string? timestampHeader, ReadOnlyMemory<byte> secret, string? deliveryId = null, TimeSpan? tolerance = null, CancellationToken ct = default)

    Asynchronously verifies an inbound HMAC-SHA256 webhook signature over `"{timestamp}.{rawPayload}"` and records the delivery in the configured `IWebhookReplayDetector`.

    rawPayload: ReadOnlyMemory<byte>
    The exact UTF-8 payload bytes received over the wire.
    signatureHeader: string?
    The signature header value.
    timestampHeader: string?
    The timestamp header value.
    secret: ReadOnlyMemory<byte>
    The shared secret key bytes.
    deliveryId: string?
    An optional unique webhook delivery identifier used for replay deduplication.
    tolerance: TimeSpan?
    An optional timestamp drift tolerance overriding the verifier default (300 seconds).
    ct: CancellationToken
    A cancellation token.

    Retorna: A value task containing the verified Unix timestamp in seconds; otherwise, an unauthorized or validation error.

  • fieldDefaultTolerance
    public static readonly TimeSpan DefaultTolerance

    The default anti-replay timestamp tolerance window (300 seconds / 5 minutes).

record

WebhookDeliveryResult

Ensamblado: EricksonLopez.Webhooks
public readonly record struct WebhookDeliveryResult(bool IsSuccess, int StatusCode, int Attempts, TimeSpan Duration, string? ErrorMessage, string? ResponseSnippet)

Represents the outcome and diagnostic telemetry of a webhook transmission attempt.

Miembros (7)

  • constructorWebhookDeliveryResult
    public WebhookDeliveryResult(bool IsSuccess, int StatusCode, int Attempts, TimeSpan Duration, string? ErrorMessage = null, string? ResponseSnippet = null)

    Initializes a new instance of WebhookDeliveryResult.

    IsSuccess: bool
    A value indicating whether the HTTP response was in the successful 2xx status code range.
    StatusCode: int
    The HTTP status code returned by the destination endpoint.
    Attempts: int
    The total number of delivery attempts executed.
    Duration: TimeSpan
    The elapsed time for the delivery attempt or cumulative duration across all retry attempts.
    ErrorMessage: string?
    Diagnostic error details if the delivery attempt failed.
    ResponseSnippet: string?
    A truncated excerpt of the remote HTTP response body when delivery fails.
  • propertyAttempts
    public int Attempts { get; init; }

    The total number of delivery attempts executed.

  • propertyDuration
    public TimeSpan Duration { get; init; }

    The elapsed time for the delivery attempt or cumulative duration across all retry attempts.

  • propertyErrorMessage
    public string? ErrorMessage { get; init; }

    Diagnostic error details if the delivery attempt failed.

  • propertyIsSuccess
    public bool IsSuccess { get; init; }

    A value indicating whether the HTTP response was in the successful 2xx status code range.

  • propertyResponseSnippet
    public string? ResponseSnippet { get; init; }

    A truncated excerpt of the remote HTTP response body when delivery fails.

  • propertyStatusCode
    public int StatusCode { get; init; }

    The HTTP status code returned by the destination endpoint.

class

WebhookDiagnostics

Ensamblado: EricksonLopez.Webhooks
public static class WebhookDiagnostics

Provides diagnostic sources, telemetry meters, and activity sources for distributed tracing and observability.

Miembros (7)

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Represents the distributed tracing activity source for outbound and inbound webhook operations.

  • fieldDeadLetterEscalationsTotal
    public static readonly Counter<long> DeadLetterEscalationsTotal

    Represents a metric counter tracking failed webhook deliveries routed to a dead-letter sink.

  • fieldDeliveriesTotal
    public static readonly Counter<long> DeliveriesTotal

    Represents a metric counter tracking the total number of outbound HTTP delivery attempts.

  • fieldDeliveryDuration
    public static readonly Histogram<double> DeliveryDuration

    Represents a metric histogram tracking the elapsed duration of HTTP delivery attempts in milliseconds.

  • fieldDiagnosticSourceName
    public const string DiagnosticSourceName

    Represents the diagnostic source name applied to the telemetry `ActivitySource` and `Meter`.

  • fieldInboundValidationsTotal
    public static readonly Counter<long> InboundValidationsTotal

    Represents a metric counter tracking inbound webhook validation attempts.

  • fieldMeter
    public static readonly Meter Meter

    Represents the metric meter instance for recording webhook telemetry.

class

WebhookErrors

Ensamblado: EricksonLopez.Webhooks
public static class WebhookErrors

Provides factory methods for constructing strongly-typed domain errors for webhook operations.

Miembros (5)

  • methodDeliveryFailed
    public static Error DeliveryFailed(Uri targetUrl, int attempts, string? detail)

    Creates an error representing a permanent delivery failure after exhausting all retry attempts.

    targetUrl: Uri
    The destination webhook URL.
    attempts: int
    The total number of delivery attempts executed.
    detail: string?
    Additional error details or HTTP status code info.

    Retorna: An `Error` representing the permanent delivery failure.

  • methodInvalidConfiguration
    public static Error InvalidConfiguration(string message)

    Creates an error representing an invalid webhook configuration.

    message: string
    The configuration error message.

    Retorna: An `Error` representing the configuration validation error.

  • methodPayloadTooLarge
    public static Error PayloadTooLarge(long maxSizeBytes)

    Creates an error representing a payload size limit violation.

    maxSizeBytes: long
    The maximum permitted size in bytes.

    Retorna: An `Error` representing the payload size limit violation.

  • methodSecurityViolation
    public static Error SecurityViolation(string reason)

    Creates an error representing a security policy violation, such as an SSRF attempt.

    reason: string
    The explanation of the security violation.

    Retorna: An `Error` representing the security policy violation.

  • methodTimeout
    public static Error Timeout(Uri targetUrl, TimeSpan timeout)

    Creates an error representing an overall delivery timeout.

    targetUrl: Uri
    The destination webhook URL.
    timeout: TimeSpan
    The configured overall delivery timeout that was exceeded.

    Retorna: An `Error` representing the delivery timeout.

class

WebhookHeaders

Ensamblado: EricksonLopez.Webhooks
public static class WebhookHeaders

Defines standard HTTP header constants used in enterprise webhook transmission and signature verification.

Miembros (10)

  • fieldDeliveryId
    public const string DeliveryId

    Represents the unique delivery identifier header name for the EricksonLopez protocol.

  • fieldDgiiSignature
    public const string DgiiSignature

    Represents the HMAC-SHA256 signature header name for the DGII electronic invoicing protocol.

  • fieldDgiiTimestamp
    public const string DgiiTimestamp

    Represents the UNIX timestamp header name for the DGII electronic invoicing protocol.

  • fieldEventType
    public const string EventType

    Represents the domain event type header name for the EricksonLopez protocol.

  • fieldSignature
    public const string Signature

    Represents the HMAC-SHA256 cryptographic signature header name for the EricksonLopez protocol.

  • fieldStandardDeliveryId
    public const string StandardDeliveryId

    Represents the unique message identifier header name for the StandardWebhooks specification.

  • fieldStandardEventType
    public const string StandardEventType

    Represents the event type header name for the StandardWebhooks specification.

  • fieldStandardSignature
    public const string StandardSignature

    Represents the HMAC-SHA256 signature header name for the StandardWebhooks specification.

  • fieldStandardTimestamp
    public const string StandardTimestamp

    Represents the UNIX timestamp header name for the StandardWebhooks specification.

  • fieldTimestamp
    public const string Timestamp

    Represents the UNIX timestamp header name for the EricksonLopez protocol.

record

WebhookMessage

Ensamblado: EricksonLopez.Webhooks
public sealed record WebhookMessage

Encapsulates all necessary parameters and payload data required to deliver an outbound webhook.

Notas:

This type is immutable and thread-safe. Secret material is protected from accidental disclosure in string representations.

Miembros (8)

  • constructorWebhookMessage
    public WebhookMessage(Uri targetUrl, WebhookSecret secretKey, string eventType, string eventId, ReadOnlyMemory<byte> payloadBytes)

    Initializes a new instance of the `WebhookMessage` class with a byte memory payload.

    targetUrl: Uri
    The destination webhook endpoint URL.
    secretKey: WebhookSecret
    The shared secret key that signs the webhook payload.
    eventType: string
    The type name of the domain event.
    eventId: string
    The explicit event or idempotency identifier.
    payloadBytes: ReadOnlyMemory<byte>
    The byte memory containing the serialized payload to deliver.

    Exceptions: ArgumentNullException: `targetUrl` or `eventType` is `null`; ArgumentException: `eventId` is `null`, empty, or consists only of white-space characters

  • constructorWebhookMessage
    public WebhookMessage(Uri targetUrl, WebhookSecret secretKey, string eventType, string eventId, string payloadString)

    Initializes a new instance of the `WebhookMessage` class with a string payload.

    targetUrl: Uri
    The destination webhook endpoint URL.
    secretKey: WebhookSecret
    The shared secret key that signs the webhook payload.
    eventType: string
    The type name of the domain event.
    eventId: string
    The explicit event or idempotency identifier.
    payloadString: string
    The serialized JSON or string payload to deliver.

    Exceptions: ArgumentNullException: `targetUrl`, `eventType`, or `payloadString` is `null`; ArgumentException: `eventId` is `null`, empty, or consists only of white-space characters

  • propertyEventId
    public string EventId { get; }

    Gets the unique event or idempotency identifier.

  • propertyEventType
    public string EventType { get; }

    Gets the type name of the domain event.

  • propertyPayloadBytes
    public ReadOnlyMemory<byte>? PayloadBytes { get; }

    Gets the raw byte payload, or `null` if `PayloadString` is used.

  • propertyPayloadString
    public string? PayloadString { get; }

    Gets the string payload, or `null` if `PayloadBytes` is used.

  • propertySecretKey
    public WebhookSecret SecretKey { get; }

    Gets the shared signing secret key that generates cryptographic signatures.

  • propertyTargetUrl
    public Uri TargetUrl { get; }

    Gets the destination webhook endpoint URL.

record

WebhookPayload

Ensamblado: EricksonLopez.Webhooks
public sealed record WebhookPayload(string DeliveryId, string EventType, string Payload, DateTimeOffset Timestamp, int AttemptNumber)

Represents the outbound envelope containing metadata and content delivered to a webhook subscriber.

Miembros (6)

  • constructorWebhookPayload
    public WebhookPayload(string DeliveryId, string EventType, string Payload, DateTimeOffset Timestamp, int AttemptNumber = 1)

    Initializes a new instance of WebhookPayload.

    DeliveryId: string
    The unique identifier for this delivery attempt.
    EventType: string
    The type name of the emitted domain event.
    Payload: string
    The JSON or structured payload string content.
    Timestamp: DateTimeOffset
    The timestamp at which the webhook was generated.
    AttemptNumber: int
    The transmission attempt count for this delivery.
  • propertyAttemptNumber
    public int AttemptNumber { get; init; }

    The transmission attempt count for this delivery.

  • propertyDeliveryId
    public string DeliveryId { get; init; }

    The unique identifier for this delivery attempt.

  • propertyEventType
    public string EventType { get; init; }

    The type name of the emitted domain event.

  • propertyPayload
    public string Payload { get; init; }

    The JSON or structured payload string content.

  • propertyTimestamp
    public DateTimeOffset Timestamp { get; init; }

    The timestamp at which the webhook was generated.

class

WebhookPayloadTooLargeException

Ensamblado: EricksonLopez.Webhooks
public sealed class WebhookPayloadTooLargeException : InvalidOperationException
Hereda de: InvalidOperationException

Represents an error that occurs when a webhook payload exceeds the maximum permitted byte size.

Miembros (4)

  • constructorWebhookPayloadTooLargeException
    public WebhookPayloadTooLargeException(long maxBytes)

    Initializes a new instance of the `WebhookPayloadTooLargeException` class with the specified maximum byte limit.

    maxBytes: long
    The maximum allowable byte size that was exceeded.
  • constructorWebhookPayloadTooLargeException
    public WebhookPayloadTooLargeException(string message)

    Initializes a new instance of the `WebhookPayloadTooLargeException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorWebhookPayloadTooLargeException
    public WebhookPayloadTooLargeException(string message, Exception innerException)

    Initializes a new instance of the `WebhookPayloadTooLargeException` class with a specified error message and a reference to the inner exception that is the cause of this exception.

    message: string
    The error message that explains the reason for the exception.
    innerException: Exception
    The exception that is the cause of the current exception, or `null` if no inner exception is specified.
  • propertyMaxBytes
    public long MaxBytes { get; }

    Gets the maximum allowable payload size in bytes that was exceeded, if specified.

enum

WebhookProtocol

Ensamblado: EricksonLopez.Webhooks
public enum WebhookProtocol

Specifies the HTTP header protocol convention applied during webhook transmission and signature verification.

Miembros (4)

  • fieldAutoDetect
    AutoDetect = 2

    Specifies that the protocol should be detected automatically from inbound HTTP request headers.

    Applies only to inbound receiver verification and cannot be used during outbound dispatch.

  • fieldDgii
    Dgii = 3

    Specifies the Dominican Republic DGII electronic invoicing webhook protocol format using `X-FE-*` headers and raw lowercase hex signature.

  • fieldEricksonLopez
    EricksonLopez = 0

    Specifies the custom enterprise header format using `X-Webhook-*` headers.

  • fieldStandard
    Standard = 1

    Specifies the StandardWebhooks specification format using `webhook-*` headers.

enum

WebhookReceiverProtocol

Ensamblado: EricksonLopez.Webhooks
public enum WebhookReceiverProtocol

Specifies the HTTP header protocol convention expected when validating inbound webhooks.

Miembros (4)

  • fieldAutoDetect
    AutoDetect = 0

    Detects the protocol convention automatically based on the presence of inbound HTTP request headers.

  • fieldDgii
    Dgii = 3

    Requires the Dominican Republic DGII electronic invoicing protocol headers (`X-FE-*`) and raw lowercase hex signature.

  • fieldEricksonLopez
    EricksonLopez = 1

    Requires the custom EricksonLopez protocol headers (`x-webhook-*`).

  • fieldStandard
    Standard = 2

    Requires the StandardWebhooks specification headers (`webhook-*`).

record

WebhookSecret

Ensamblado: EricksonLopez.Webhooks
public readonly record struct WebhookSecret

Encapsulates a cryptographic webhook secret while preventing accidental leakage in logs and telemetry.

Notas:

This struct overrides `ToString` to return a redacted placeholder.

Miembros (7)

  • constructorWebhookSecret
    public WebhookSecret(string secret)

    Initializes a new instance of the `WebhookSecret` struct with the specified secret string.

    secret: string
    The raw secret string.

    Exceptions: ArgumentException: `secret` is `null`, empty, or consists only of white-space characters

  • methodAsSpan
    public ReadOnlySpan<char> AsSpan()

    Gets the underlying secret characters as a read-only span.

    Retorna: A read-only character span referencing the secret value.

  • methodGetUnsecuredString
    public string GetUnsecuredString()

    Retrieves the underlying secret as an unredacted string.

    Retorna: The unredacted secret string.

  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodexplicit operator string
    public static explicit operator string(WebhookSecret secret)

    Explicitly converts a `WebhookSecret` instance to its underlying secret string.

    secret: WebhookSecret
    The `WebhookSecret` instance to convert.

    Retorna: The underlying secret string.

  • methodimplicit operator WebhookSecret
    public static implicit operator WebhookSecret(string secret)

    Converts a string to a `WebhookSecret` instance.

    secret: string
    The raw secret string to convert.

    Retorna: A new `WebhookSecret` instance wrapping the specified string.

    Exceptions: ArgumentException: `secret` is `null`, empty, or consists only of white-space characters

  • propertyValue
    public string Value { get; }

    Gets the underlying unredacted secret string.

class

WebhookSender

Ensamblado: EricksonLopez.Webhooks
public sealed partial class WebhookSender : IWebhookSender
Implementa: IWebhookSender

Dispatches cryptographically signed outbound HTTP webhooks with SSRF mitigation, distributed tracing, and dead-letter queue escalation.

Notas:

This type is thread-safe. Transient failure resilience and retries should be configured on the underlying `HttpClient` using standard HTTP resilience pipelines.

Miembros (2)

  • methodCreateSafeSender
    public static WebhookSender CreateSafeSender(IWebhookDeadLetterSink? deadLetterQueue = null, WebhookSenderOptions? options = null, ILogger<WebhookSender>? logger = null)

    Creates a new `WebhookSender` configured with `SafeSocketsHttpHandlerFactory` to prevent SSRF and DNS rebinding attacks.

    deadLetterQueue: IWebhookDeadLetterSink?
    An optional sink for persisting deliveries that permanently fail.
    options: WebhookSenderOptions?
    Configuration options controlling timeout, payload size limits, and security constraints.
    logger: ILogger<WebhookSender>?
    An optional logger instance for diagnostic telemetry.

    Retorna: A configured `WebhookSender` instance with built-in SSRF protection.

  • methodSendAsync
    public async Task<Result<WebhookDeliveryResult>> SendAsync(WebhookMessage message, CancellationToken cancellationToken = default)

    Delivers an outbound webhook message to the destination endpoint with cryptographic signing.

    message: WebhookMessage
    The webhook message envelope containing destination, payload, and cryptographic key.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a result indicating whether delivery succeeded, along with the delivery metadata.

    Exceptions: ArgumentNullException: `message` is `null`; OperationCanceledException: The operation was canceled via `cancellationToken`

class

WebhookSenderExtensions

Ensamblado: EricksonLopez.Webhooks
public static class WebhookSenderExtensions

Provides extension methods for `IWebhookSender` supporting Native AOT-compatible serialization.

Miembros (1)

  • methodSendAsync<T>
    public static Task<Result<WebhookDeliveryResult>> SendAsync<T>(this IWebhookSender sender, Uri targetUrl, string secretKey, string eventType, string eventId, T data, JsonTypeInfo<T> jsonTypeInfo, CancellationToken cancellationToken = default)

    Serializes the specified payload using ahead-of-time (AOT) type metadata and delivers the webhook.

    sender: this IWebhookSender
    The webhook sender instance.
    targetUrl: Uri
    The destination endpoint URI.
    secretKey: string
    The shared secret key that computes the HMAC signature.
    eventType: string
    The logical domain event type identifier.
    eventId: string
    The explicit event or idempotency identifier.
    data: T
    The typed data object to serialize as JSON.
    jsonTypeInfo: JsonTypeInfo<T>
    The JSON type information enabling reflection-free Native AOT serialization.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a result indicating whether delivery succeeded, along with the delivery metadata.

    Type parameters: T: The type of the data payload to serialize. Exceptions: ArgumentNullException: `sender` or `jsonTypeInfo` is `null`

class

WebhookSenderOptions

Ensamblado: EricksonLopez.Webhooks
public sealed class WebhookSenderOptions

Configures the behavior and security constraints for outbound webhook delivery.

Miembros (9)

  • propertyAllowPrivateNetworks
    public bool AllowPrivateNetworks { get; set; }

    Gets or sets a value indicating whether connections to private or loopback network addresses are permitted.

  • propertyAttemptTimeout
    public TimeSpan AttemptTimeout { get; set; }

    Gets or sets the per-attempt timeout for delivery requests. Alias for `Timeout`.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to `TimeSpan.Zero`

  • propertyDangerousAllowInsecureHttp
    public bool DangerousAllowInsecureHttp { get; set; }

    Gets or sets a value indicating whether unencrypted HTTP connections are explicitly permitted.

  • propertyEnableSsrfProtection
    public bool EnableSsrfProtection { get; set; }

    Gets or sets a value indicating whether strict SSRF mitigation and private IP blocking are enabled.

  • propertyMaxPayloadSizeBytes
    public int MaxPayloadSizeBytes { get; set; }

    Gets or sets the maximum allowable request payload size in bytes to prevent excessive memory consumption.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to zero

  • propertyProtocol
    public WebhookSenderProtocol Protocol { get; set; }

    Gets or sets the HTTP header protocol convention used when dispatching webhooks.

  • propertySsrfProtection
    public EricksonLopez.Security.Network.SsrfProtectionOptions SsrfProtection { get; }

    Gets the underlying SSRF protection options configuring DNS validation and IP filtering.

  • propertyTimeout
    public TimeSpan Timeout { get; set; }

    Gets or sets the HTTP request timeout for each individual delivery attempt. Defaults to 10 seconds.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to `TimeSpan.Zero`

  • propertyTotalTimeout
    public TimeSpan? TotalTimeout { get; set; }

    Gets or sets the optional maximum total timeout across all retry attempts. When specified, governs the total duration of the delivery pipeline.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to `TimeSpan.Zero`

enum

WebhookSenderProtocol

Ensamblado: EricksonLopez.Webhooks
public enum WebhookSenderProtocol

Specifies the HTTP header protocol convention used when dispatching outbound webhooks.

Miembros (3)

  • fieldDgii
    Dgii = 3

    Specifies the Dominican Republic DGII electronic invoicing webhook protocol format using `X-FE-*` headers and raw lowercase hex signature.

  • fieldEricksonLopez
    EricksonLopez = 0

    Specifies the custom EricksonLopez header format (`x-webhook-*`).

  • fieldStandard
    Standard = 1

    Specifies the StandardWebhooks specification header format (`webhook-*`).

class

WebhookServiceCollectionExtensions

Ensamblado: EricksonLopez.Webhooks
public static class WebhookServiceCollectionExtensions

Provides extension methods for registering webhook services into an `IServiceCollection`.

Miembros (1)

  • methodAddWebhooks
    public static IServiceCollection AddWebhooks(this IServiceCollection services, Action<WebhookSenderOptions>? configure = null)

    Registers the `IWebhookSender` and supporting infrastructure into the dependency injection container.

    services: this IServiceCollection
    The service collection to register services into.
    configure: Action<WebhookSenderOptions>?
    An optional action to configure the `WebhookSenderOptions`.

    Retorna: The original `IServiceCollection` instance for fluent chaining.

    Exceptions: ArgumentNullException: `services` is `null`

class

WebhookSigner

Ensamblado: EricksonLopez.Webhooks
public static class WebhookSigner

Provides HMAC-SHA256 signature generation and constant-time verification for outbound and inbound webhooks.

Notas:

All verification routines perform constant-time comparisons to mitigate timing attacks. Memory-sensitive cryptographic keys are wiped after hashing.

Miembros (15)

  • 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`.

    Retorna: The formatted signature string.

    Exceptions: ArgumentNullException: `secretKey` is `null`; ArgumentException: `protocol` is `WebhookSenderProtocol.Standard` and `webhookId` is `null`, empty, or consists only of white-space characters

  • 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.

    Retorna: 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`.

    Retorna: The formatted signature string.

    Exceptions: ArgumentNullException: `secretKey` or `payload` is `null`; ArgumentException: `protocol` is `WebhookSenderProtocol.Standard` and `webhookId` is `null`, empty, or consists only of white-space characters

  • 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`.

    Retorna: 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`.

    Retorna: 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.

    Retorna: A task representing the asynchronous operation. The task result contains the formatted signature string.

    Employs incremental hashing over rented buffers to avoid large heap allocations and LOH pressure. Exceptions: ArgumentNullException: `secretKey` or `payloadStream` is `null`; ArgumentException: `protocol` is `WebhookSenderProtocol.Standard` and `webhookId` is `null`, empty, or consists only of white-space characters; WebhookPayloadTooLargeException: The payload stream exceeds `maxPayloadBytes`

  • 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.

    Retorna: `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.

    Retorna: `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.

    Retorna: `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.

    Retorna: `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.

    Retorna: `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.

    Retorna: `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.

    Retorna: A task representing the asynchronous operation. The task result contains `true` if the signature is valid for any key; otherwise, `false`.

    Hashing for all keys is performed in a single pass over the stream. Exceptions: WebhookPayloadTooLargeException: The payload stream exceeds `maxPayloadBytes`

  • 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.

    Retorna: A task representing the asynchronous operation. The task result contains `true` if the signature is valid; otherwise, `false`.

    Employs incremental hashing over rented buffers to avoid large heap allocations and LOH pressure.

  • 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.

    Retorna: A task representing the asynchronous operation. The task result contains `true` if the signature is valid; otherwise, `false`.

    Exceptions: WebhookPayloadTooLargeException: The payload stream exceeds `maxPayloadBytes`

EricksonLopez.Webhooks.AspNetCore#

6
interface

IWebhookValidator

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public interface IWebhookValidator

Defines a contract for validating the authenticity, freshness, and replay status of inbound webhook HTTP requests.

Miembros (1)

  • methodValidateRequestAsync
    Task<Result<bool>> ValidateRequestAsync(HttpContext httpContext, CancellationToken cancellationToken = default)

    Validates that an incoming HTTP request contains a fresh timestamp, an authentic cryptographic signature, and is not a replay attack.

    httpContext: HttpContext
    The HTTP context representing the incoming webhook request.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a successful result if the request is authentic; otherwise, an error describing the validation or security failure.

class

WebhookAspNetCoreExtensions

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public static class WebhookAspNetCoreExtensions

Provides extension methods for configuring webhook receiver capabilities in ASP.NET Core applications.

Miembros (5)

  • methodAddInMemoryReplayDetector
    public static IServiceCollection AddInMemoryReplayDetector(this IServiceCollection services, TimeSpan? retentionPeriod = null)

    Registers the `InMemoryWebhookReplayDetector` to protect against replay attacks in single-node environments.

    services: this IServiceCollection
    The service collection to register the detector into.
    retentionPeriod: TimeSpan?
    The duration to keep seen message IDs. Defaults to five minutes if omitted.

    Retorna: The original `IServiceCollection` instance for fluent chaining.

    This in-memory implementation is intended for development, testing, or single-node deployments. For multi-instance deployments, use a distributed replay detector such as Redis. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddWebhookReceiver
    public static IServiceCollection AddWebhookReceiver(this IServiceCollection services, Action<WebhookReceiverOptions> configure)

    Registers the `IWebhookValidator` and receiver options into the service collection.

    services: this IServiceCollection
    The service collection to register services into.
    configure: Action<WebhookReceiverOptions>
    The delegate that configures `WebhookReceiverOptions`.

    Retorna: The original `IServiceCollection` instance for fluent chaining.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

  • methodRequireWebhookSignature
    public static RouteGroupBuilder RequireWebhookSignature(this RouteGroupBuilder builder)

    Adds an endpoint filter to the route group that verifies the authenticity of incoming webhooks via HMAC-SHA256 signature and timestamp validation.

    builder: this RouteGroupBuilder
    The route group builder.

    Retorna: The builder configured with the webhook endpoint filter.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodRequireWebhookSignature
    public static RouteHandlerBuilder RequireWebhookSignature(this RouteHandlerBuilder builder)

    Adds an endpoint filter to the route that verifies the authenticity of incoming webhooks via HMAC-SHA256 signature and timestamp validation.

    builder: this RouteHandlerBuilder
    The route handler builder.

    Retorna: The builder configured with the webhook endpoint filter.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodUseWebhookReceiver
    public static IApplicationBuilder UseWebhookReceiver(this IApplicationBuilder app)

    Adds the `WebhookReceiverMiddleware` to the application request pipeline.

    app: this IApplicationBuilder
    The application builder instance.

    Retorna: The original `IApplicationBuilder` instance for fluent chaining.

    Exceptions: ArgumentNullException: `app` is `null`

class

WebhookEndpointFilter

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public sealed partial class WebhookEndpointFilter : IEndpointFilter
Implementa: IEndpointFilter

Enforces cryptographic HMAC-SHA256 signature verification and anti-replay validation on ASP.NET Core minimal API endpoints.

Miembros (2)

  • constructorWebhookEndpointFilter
    public WebhookEndpointFilter(ILogger<WebhookEndpointFilter>? logger = null)

    Initializes a new instance of the `WebhookEndpointFilter` class with an optional logger.

    logger: ILogger<WebhookEndpointFilter>?
    The optional structured logger for recording filter diagnostics.
  • methodInvokeAsync
    public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)

    Inherits documentation from base type or interface.

    context: EndpointFilterInvocationContext
    next: EndpointFilterDelegate

    Exceptions: ArgumentNullException: `context` or `next` is `null`

class

WebhookReceiverMiddleware

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public sealed partial class WebhookReceiverMiddleware

Intercepts and validates inbound webhook HTTP requests within the ASP.NET Core pipeline.

Miembros (3)

  • constructorWebhookReceiverMiddleware
    public WebhookReceiverMiddleware(RequestDelegate next, IOptions<WebhookReceiverOptions> options)

    Initializes a new instance of the `WebhookReceiverMiddleware` class.

    next: RequestDelegate
    The next middleware delegate in the request pipeline.
    options: IOptions<WebhookReceiverOptions>
    The accessor for receiver configuration options.
  • constructorWebhookReceiverMiddleware
    public WebhookReceiverMiddleware(RequestDelegate next, IOptions<WebhookReceiverOptions> options, ILogger<WebhookReceiverMiddleware>? logger)

    Initializes a new instance of the `WebhookReceiverMiddleware` class with structured logging.

    next: RequestDelegate
    The next middleware delegate in the request pipeline.
    options: IOptions<WebhookReceiverOptions>
    The accessor for receiver configuration options.
    logger: ILogger<WebhookReceiverMiddleware>?
    The structured logger for diagnostic output.

    Exceptions: ArgumentNullException: `next` or `options` is `null`

  • methodInvokeAsync
    public async Task InvokeAsync(HttpContext context, IWebhookValidator validator)

    Processes an HTTP request through the webhook validation pipeline.

    context: HttpContext
    The HTTP context representing the incoming request.
    validator: IWebhookValidator
    The validator responsible for signature and timestamp verification.

    Retorna: A task representing the asynchronous operation.

    Requests whose path does not match `WebhookReceiverOptions.RoutePath`, safe HTTP methods (`GET`, `HEAD`, `OPTIONS`), or non-`POST` requests when `WebhookReceiverOptions.ValidatePostOnly` is `true` bypass signature validation and proceed directly to the next middleware. Failed validations write an HTTP error status code and terminate request execution. Exceptions: ArgumentNullException: `context` or `validator` is `null`

class

WebhookReceiverOptions

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public sealed class WebhookReceiverOptions

Configures options for receiving, authenticating, and validating inbound webhooks in ASP.NET Core.

Miembros (10)

  • methodAddSecret
    public WebhookReceiverOptions AddSecret(string secretKey)

    Adds an active secret key to `SecretKeys` to support cryptographic key rotation.

    secretKey: string
    The secret key to register for signature validation.

    Retorna: The current `WebhookReceiverOptions` instance for fluent chaining.

    Exceptions: ArgumentException: `secretKey` is `null`, empty, or consists only of white-space characters

  • propertyMaxPayloadSizeBytes
    public int MaxPayloadSizeBytes { get; set; }

    Gets or sets the maximum allowable request body size in bytes to prevent excessive memory consumption.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to zero

  • propertyProtocol
    public WebhookReceiverProtocol Protocol { get; set; }

    Gets or sets the HTTP header protocol convention expected when extracting signature and timestamp information.

  • propertyRequireDeliveryId
    public bool RequireDeliveryId { get; set; }

    Gets or sets a value indicating whether a delivery ID header is strictly required. When true, incoming requests missing an ID header are rejected.

  • propertyRoutePath
    public string RoutePath { get; set; }

    Gets or sets the URL route path prefix intercepted by the webhook receiver middleware.

  • propertySecretKey
    public string SecretKey { get; set; }

    Gets or sets the primary shared secret key that verifies incoming HMAC-SHA256 signatures.

    For zero-downtime key rotation across multiple active secrets, use `SecretKeys` or `AddSecret`.

  • propertySecretKeys
    public ImmutableList<string> SecretKeys { get; set; }

    Gets or sets the collection of active secret keys that verify incoming signatures during rotation.

  • propertyTenantId
    public string? TenantId { get; set; }

    Gets or sets an optional tenant identifier scoping replay protection nonces.

  • propertyTimestampTolerance
    public TimeSpan TimestampTolerance { get; set; }

    Gets or sets the maximum allowable clock skew between sender and receiver.

  • propertyValidatePostOnly
    public bool ValidatePostOnly { get; set; }

    Gets or sets a value indicating whether only HTTP POST requests should be intercepted and validated. Defaults to `false`, allowing non-POST requests to pass through to downstream handlers.

class

WebhookValidator

Ensamblado: EricksonLopez.Webhooks.AspNetCore
public sealed partial class WebhookValidator : IWebhookValidator
Implementa: IWebhookValidator

Enforces HMAC-SHA256 signature verification, replay protection, and timestamp validation for inbound webhook requests.

Notas:

This type is thread-safe. It validates inbound headers, calculates streaming hashes to avoid large object heap allocations, and checks replay detectors when configured.

Miembros (2)

  • constructorWebhookValidator
    public WebhookValidator(IOptions<WebhookReceiverOptions> options, TimeProvider? timeProvider = null, IWebhookReplayDetector? replayDetector = null, ILogger<WebhookValidator>? logger = null)

    Initializes a new instance of the `WebhookValidator` class.

    options: IOptions<WebhookReceiverOptions>
    The accessor for receiver configuration options.
    timeProvider: TimeProvider?
    An optional time provider that calculates timestamp drift.
    replayDetector: IWebhookReplayDetector?
    An optional replay detector that prevents duplicate message processing.
    logger: ILogger<WebhookValidator>?
    An optional structured logger for diagnostic logging.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodValidateRequestAsync
    public async Task<Result<bool>> ValidateRequestAsync(HttpContext httpContext, CancellationToken cancellationToken = default)

    Validates that an incoming HTTP request contains a fresh timestamp, an authentic cryptographic signature, and is not a replay attack.

    httpContext: HttpContext
    The HTTP context representing the incoming webhook request.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a successful result if the request is authentic; otherwise, an error describing the validation or security failure.

    Exceptions: ArgumentNullException: `httpContext` is `null`

EricksonLopez.Webhooks.PaymentGateways#

9
class

AzulWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class AzulWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound Azul payment gateway webhooks using timestamp-bound HMAC-SHA256 (`"{timestamp}.{rawPayload}"`).

Miembros (3)

  • constructorAzulWebhookSignatureScheme
    public AzulWebhookSignatureScheme(ITimestampedWebhookVerifier? verifier = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `AzulWebhookSignatureScheme` class.

    verifier: ITimestampedWebhookVerifier?
    Optional timestamped webhook verifier.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

class

BinancePayWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class BinancePayWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound Binance Pay webhooks using `SHA256withRSA` over `"{timestamp}\n{nonce}\n{rawPayload}\n"`, millisecond-epoch drift validation, and optional `IWebhookReplayDetector` nonce deduplication.

Miembros (3)

  • constructorBinancePayWebhookSignatureScheme
    public BinancePayWebhookSignatureScheme(TimeProvider? timeProvider = null, IWebhookReplayDetector? replayDetector = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `BinancePayWebhookSignatureScheme` class.

    timeProvider: TimeProvider?
    Optional time provider.
    replayDetector: IWebhookReplayDetector?
    Optional replay detector.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

class

CardNetWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class CardNetWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound CardNet payment gateway webhooks using timestamp-bound HMAC-SHA256 (`"{timestamp}.{rawPayload}"`).

Miembros (3)

  • constructorCardNetWebhookSignatureScheme
    public CardNetWebhookSignatureScheme(ITimestampedWebhookVerifier? verifier = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `CardNetWebhookSignatureScheme` class.

    verifier: ITimestampedWebhookVerifier?
    Optional timestamped webhook verifier.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

interface

IWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public interface IWebhookSignatureScheme

Defines a pluggable cryptographic signature verification scheme for external payment and messaging webhook providers.

Miembros (2)

  • methodVerifyAsync
    ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

class

MetaWhatsAppWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class MetaWhatsAppWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound Meta / WhatsApp Cloud API webhooks using `X-Hub-Signature-256` (`sha256=...`) with constant-time comparison, optional timestamp freshness validation, and replay deduplication.

Miembros (3)

  • constructorMetaWhatsAppWebhookSignatureScheme
    public MetaWhatsAppWebhookSignatureScheme(TimeProvider? timeProvider = null, IWebhookReplayDetector? replayDetector = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `MetaWhatsAppWebhookSignatureScheme` class.

    timeProvider: TimeProvider?
    Optional time provider.
    replayDetector: IWebhookReplayDetector?
    Optional replay detector.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

class

PayPalWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class PayPalWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound PayPal REST webhooks using IEEE 802.3 CRC32 payload hashing, strict `*.paypal.com` HTTPS SSRF domain validation, 300-second anti-replay window, `SHA256withRSA` verification over `"{transmissionId}|{transmissionTime}|{webhookId}|{crc32}"`, and optional `IWebhookReplayDetector` deduplication.

Miembros (5)

  • constructorPayPalWebhookSignatureScheme
    public PayPalWebhookSignatureScheme(TimeProvider? timeProvider = null, IWebhookReplayDetector? replayDetector = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `PayPalWebhookSignatureScheme` class.

    timeProvider: TimeProvider?
    Optional time provider.
    replayDetector: IWebhookReplayDetector?
    Optional replay detector.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodComputeCrc32
    public static uint ComputeCrc32(ReadOnlySpan<byte> data)

    Computes the unsigned IEEE 802.3 CRC32 checksum over `data`.

    data: ReadOnlySpan<byte>
    The raw payload bytes.

    Retorna: The unsigned 32-bit CRC32 checksum.

  • methodIsValidPayPalCertificateUrl
    public static bool IsValidPayPalCertificateUrl(string? certUrl)

    Validates that a PayPal certificate URL strictly targets an official `*.paypal.com` HTTPS endpoint on port 443.

    certUrl: string?
    The candidate certificate URL.

    Retorna: `true` if safe; otherwise, `false`.

  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

class

PaymentGatewayWebhookServiceCollectionExtensions

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public static class PaymentGatewayWebhookServiceCollectionExtensions

Registers payment and messaging gateway webhook signature schemes into an `IServiceCollection`.

Miembros (1)

  • methodAddPaymentGatewayWebhookSchemes
    public static IServiceCollection AddPaymentGatewayWebhookSchemes(this IServiceCollection services)

    Registers `ITimestampedWebhookVerifier` and built-in `IWebhookSignatureScheme` implementations (`StripeWebhookSignatureScheme`, `CardNetWebhookSignatureScheme`, `AzulWebhookSignatureScheme`, `PayPalWebhookSignatureScheme`, `BinancePayWebhookSignatureScheme`, and `MetaWhatsAppWebhookSignatureScheme`).

    services: this IServiceCollection
    The service collection to configure.

    Retorna: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`.

class

StripeWebhookSignatureScheme

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed class StripeWebhookSignatureScheme : IWebhookSignatureScheme
Implementa: IWebhookSignatureScheme

Verifies inbound Stripe webhooks (`Stripe-Signature: t=...,v1=...`) using `TimestampedWebhookVerifier`.

Miembros (3)

  • constructorStripeWebhookSignatureScheme
    public StripeWebhookSignatureScheme(ITimestampedWebhookVerifier? verifier = null, TimeSpan? tolerance = null)

    Initializes a new instance of the `StripeWebhookSignatureScheme` class.

    verifier: ITimestampedWebhookVerifier?
    Optional timestamped webhook verifier; defaults to a new `TimestampedWebhookVerifier`.
    tolerance: TimeSpan?
    Optional timestamp drift tolerance; defaults to 300 seconds.
  • methodVerifyAsync
    public async ValueTask<Result> VerifyAsync(WebhookVerificationContext context, CancellationToken ct = default)

    Verifies the cryptographic authenticity, timestamp freshness, and replay uniqueness of the inbound webhook context.

    context: WebhookVerificationContext
    The inbound webhook verification context.
    ct: CancellationToken
    A cancellation token.

    Retorna: A successful `Result` if valid; otherwise, an unauthorized or validation error.

  • propertyProviderName
    public string ProviderName { get; }

    Gets the canonical scheme provider name (for example, `"Stripe"`, `"CardNet"`, `"Azul"`, `"PayPal"`, `"MetaWhatsApp"`).

record

WebhookVerificationContext

Ensamblado: EricksonLopez.Webhooks.PaymentGateways
public sealed record WebhookVerificationContext(ReadOnlyMemory<byte> RawPayload, IReadOnlyDictionary<string, string> Headers, string SecretOrKeyMaterial, string? WebhookId, string? DeliveryId)

Encapsulates the raw payload, headers, and provider credentials required to verify an inbound payment or messaging gateway webhook.

Miembros (6)

  • constructorWebhookVerificationContext
    public WebhookVerificationContext(ReadOnlyMemory<byte> RawPayload, IReadOnlyDictionary<string, string> Headers, string SecretOrKeyMaterial, string? WebhookId = null, string? DeliveryId = null)

    Initializes a new instance of WebhookVerificationContext.

    RawPayload: ReadOnlyMemory<byte>
    The exact raw UTF-8 payload bytes received over HTTP.
    Headers: IReadOnlyDictionary<string, string>
    Case-insensitive HTTP header dictionary.
    SecretOrKeyMaterial: string
    Shared HMAC secret, endpoint secret, or PEM public key material configured for the provider.
    WebhookId: string?
    Optional provider-specific webhook registration identifier (e.g., PayPal Webhook ID).
    DeliveryId: string?
    Optional unique event or transmission identifier for replay deduplication.
  • propertyDeliveryId
    public string? DeliveryId { get; init; }

    Optional unique event or transmission identifier for replay deduplication.

  • propertyHeaders
    public IReadOnlyDictionary<string, string> Headers { get; init; }

    Case-insensitive HTTP header dictionary.

  • propertyRawPayload
    public ReadOnlyMemory<byte> RawPayload { get; init; }

    The exact raw UTF-8 payload bytes received over HTTP.

  • propertySecretOrKeyMaterial
    public string SecretOrKeyMaterial { get; init; }

    Shared HMAC secret, endpoint secret, or PEM public key material configured for the provider.

  • propertyWebhookId
    public string? WebhookId { get; init; }

    Optional provider-specific webhook registration identifier (e.g., PayPal Webhook ID).

EricksonLopez.Webhooks.Redis#

4
record

DeadLetterEnvelope

Ensamblado: EricksonLopez.Webhooks.Redis
public sealed record DeadLetterEnvelope(string TargetUrl, WebhookPayload Payload, WebhookDeliveryResult LastResult)

Represents a dead-lettered webhook transmission envelope stored in persistent storage.

Miembros (4)

  • constructorDeadLetterEnvelope
    public DeadLetterEnvelope(string TargetUrl, WebhookPayload Payload, WebhookDeliveryResult LastResult)

    Initializes a new instance of DeadLetterEnvelope.

    TargetUrl: string
    The target webhook endpoint URL string.
    Payload: WebhookPayload
    The webhook payload envelope containing event metadata and data.
    LastResult: WebhookDeliveryResult
    The delivery outcome and telemetry from the final attempt.
  • propertyLastResult
    public WebhookDeliveryResult LastResult { get; init; }

    The delivery outcome and telemetry from the final attempt.

  • propertyPayload
    public WebhookPayload Payload { get; init; }

    The webhook payload envelope containing event metadata and data.

  • propertyTargetUrl
    public string TargetUrl { get; init; }

    The target webhook endpoint URL string.

class

DeadLetterJsonContext

Ensamblado: EricksonLopez.Webhooks.Redis
public sealed partial class DeadLetterJsonContext : JsonSerializerContext
Hereda de: JsonSerializerContext

Provides source-generated JSON serialization metadata for `DeadLetterEnvelope` ensuring Native AOT compatibility.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

RedisWebhookDeadLetterSink

Ensamblado: EricksonLopez.Webhooks.Redis
public sealed class RedisWebhookDeadLetterSink : IWebhookDeadLetterSink
Implementa: IWebhookDeadLetterSink

Represents a distributed dead-letter queue sink backed by a Redis list.

Notas:

Failed delivery attempts are serialized to JSON and pushed to the specified Redis list key.

Miembros (2)

  • constructorRedisWebhookDeadLetterSink
    public RedisWebhookDeadLetterSink(IConnectionMultiplexer connectionMultiplexer, string listKey = "", long? maxCapacity = 10_000, TimeSpan? retentionPeriod = null)

    Initializes a new instance of the `RedisWebhookDeadLetterSink` class.

    connectionMultiplexer: IConnectionMultiplexer
    The Redis connection multiplexer instance.
    listKey: string
    The Redis list key name where failed payloads will be appended.
    maxCapacity: long?
    Optional maximum bounded length of the Redis list (purges oldest via LTRIM). Defaults to 10,000.
    retentionPeriod: TimeSpan?
    Optional TTL expiration period applied to the list key.

    Exceptions: ArgumentNullException: `connectionMultiplexer` is `null`; ArgumentException: `listKey` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `maxCapacity` is less than or equal to zero.

  • methodEnqueueAsync
    public async Task EnqueueAsync(Uri targetUrl, WebhookPayload payload, WebhookDeliveryResult lastResult, CancellationToken cancellationToken = default)

    Enqueues a failed webhook delivery into the dead-letter sink.

    targetUrl: Uri
    The target webhook endpoint URL.
    payload: WebhookPayload
    The delivery payload envelope containing event metadata and data.
    lastResult: WebhookDeliveryResult
    The outcome of the final delivery attempt.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `targetUrl` or `payload` is `null`

class

RedisWebhookReplayDetector

Ensamblado: EricksonLopez.Webhooks.Redis
public sealed class RedisWebhookReplayDetector : IWebhookReplayDetector
Implementa: IWebhookReplayDetector

Represents a distributed webhook replay attack detector backed by Redis.

Notas:

Leverages atomic Redis SETNX operations to prevent duplicate message processing across distributed nodes.

Miembros (2)

  • constructorRedisWebhookReplayDetector
    public RedisWebhookReplayDetector(IConnectionMultiplexer connectionMultiplexer, TimeSpan retentionPeriod, string? tenantId = null)

    Initializes a new instance of the `RedisWebhookReplayDetector` class.

    connectionMultiplexer: IConnectionMultiplexer
    The Redis connection multiplexer instance.
    retentionPeriod: TimeSpan
    The duration for which processed message identifiers are retained in Redis.
    tenantId: string?
    An optional tenant identifier scoping replay keys in multi-tenant environments.

    Exceptions: ArgumentNullException: `connectionMultiplexer` is `null`

  • methodTryRecordAsync
    public async ValueTask<bool> TryRecordAsync(string messageId, CancellationToken cancellationToken = default)

    Attempts to record a webhook message identifier to detect duplicate transmissions.

    messageId: string
    The unique message identifier to record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A value task representing the asynchronous operation. The task result contains `true` if the message identifier was successfully recorded; otherwise, `false` if a replay was detected.

Microsoft.Extensions.DependencyInjection#

1
class

RedisWebhookServiceCollectionExtensions

Ensamblado: EricksonLopez.Webhooks.Redis
public static class RedisWebhookServiceCollectionExtensions

Provides extension methods for configuring Redis-backed webhook services in an `IServiceCollection`.

Miembros (2)

  • methodAddRedisWebhookDeadLetterSink
    public static IServiceCollection AddRedisWebhookDeadLetterSink(this IServiceCollection services, string listKey = "", long? maxCapacity = 10_000, TimeSpan? retentionPeriod = null)

    Registers a distributed, Redis-backed dead-letter queue sink into the service collection.

    services: this IServiceCollection
    The service collection to register the sink into.
    listKey: string
    The Redis list key name where failed payloads are appended. Defaults to `"webhook:dlq"`.
    maxCapacity: long?
    Optional maximum bounded length of the Redis list (purges oldest via LTRIM). Defaults to 10,000.
    retentionPeriod: TimeSpan?
    Optional TTL expiration period applied to the list key.

    Retorna: The original `IServiceCollection` instance for fluent chaining.

    Requires an `IConnectionMultiplexer` to be registered in the service collection.

  • methodAddRedisWebhookReplayDetector
    public static IServiceCollection AddRedisWebhookReplayDetector(this IServiceCollection services, TimeSpan? retentionPeriod = null, string? tenantId = null)

    Registers a distributed, Redis-backed webhook replay detector into the service collection.

    services: this IServiceCollection
    The service collection to register the detector into.
    retentionPeriod: TimeSpan?
    The duration for which processed message identifiers are retained in Redis. Defaults to ten minutes if omitted.
    tenantId: string?
    An optional tenant identifier scoping replay keys in multi-tenant environments.

    Retorna: The original `IServiceCollection` instance for fluent chaining.

    Requires an `IConnectionMultiplexer` to be registered in the service collection.

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.