Skip to content

implement createWebhookMiddleware factory with configurable security …#428

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
canicefavour:split1
Jul 21, 2026
Merged

implement createWebhookMiddleware factory with configurable security …#428
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
canicefavour:split1

Conversation

@canicefavour

Copy link
Copy Markdown

Implemented a production-ready webhook middleware for securely handling incoming StellarSplit invoice events. The middleware validates webhook authenticity using HMAC-SHA256 signatures with constant-time comparison (crypto.timingSafeEqual) to protect against timing attacks and signature spoofing. Configurable timestamp validation was added to enforce request expiration windows, while an in-memory Least Recently Used (LRU) nonce cache provides replay attack protection by rejecting duplicate or previously processed requests.

The implementation introduces a clean, strongly typed middleware factory with configurable security options and typed invoice event definitions, making integration straightforward across Express or Next.js applications. Comprehensive request validation ensures malformed, expired, replayed, or unauthorized webhook payloads are rejected with consistent error responses before reaching application logic. Extensive unit tests were added to verify signature validation, replay protection, timestamp tolerance, nonce cache behavior, and failure scenarios, while accompanying documentation outlines the webhook authentication flow, security model, configuration options, and operational best practices for production deployments.

Closes #424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement webhook server middleware with HMAC validation and replay attack protection

2 participants