Skip to content

Add webhook signature verification middleware and automated retry scheduler #103

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Astroid API dispatches webhooks to external agent endpoints for transaction status changes and risk alerts. To ensure secure and reliable event delivery, external receivers need cryptographic verification signatures (HMAC-SHA256), and the platform needs a reliable delivery retry mechanism with exponential backoff.

Context & Requirements — background, constraints, design references, edge cases;

  • Located in src/modules/webhooks.
  • Generate HMAC signature headers (X-Astroid-Signature) for outgoing webhooks using a shared secret.
  • Implement a BullMQ worker processor for webhook delivery with configurable backoff strategies (e.g., 5s, 30s, 5m, 1h).
  • Handle endpoint timeout and non-2xx responses gracefully.

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Implement cryptographic signature generator utility for outgoing HTTP requests.
  • Create a BullMQ webhook worker supporting exponential backoff retries.
  • Record delivery attempts, response status codes, and failure reasons in the database.
  • Add unit tests for signature generation and worker retry logic.

Implementation Guidance — likely files/modules to touch and a suggested approach

  • Likely touch files under src/modules/webhooks/ (controllers, services, workers).
  • Use Node.js built-in crypto module for HMAC generation.

Testing & Validation — how the contributor should prove it works

  • Run npm test and ensure all tests pass successfully.
  • Add unit tests verifying signature headers match expected cryptographic outputs.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting; follow the repo's existing style and conventions.


Wave complexity: Medium

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions