Skip to content

Add HMAC-SHA256 webhook payload signing for merchant verification #351

Description

@therealjhay

Current behavior:
Webhooks sent without signature — merchants cannot verify authenticity.

Expected behavior:
Compute HMAC-SHA256 over JSON body using signingSecret. Include in X-BettaPay-Signature: t={unix_ts},s={hex_hmac}. Timestamp prevents replay attacks (merchant should reject >5min old). Skip signing if no secret configured.

Files to modify:

  • shared/webhook-delivery/index.ts — add HMAC signing
  • services/indexer/src/index.ts — include signingSecret in job data
  • Test: shared/webhook-delivery/index.test.ts

Test requirements:

  1. With secret — signature header present, correctly formatted.
  2. Without secret — no signature header.
  3. Signature can be recomputed by consumer (same body + secret + timestamp = same HMAC).

Acceptance criteria:

  • Webhooks signed with HMAC-SHA256 when secret configured.
  • Backward compatible with existing unsigned webhooks.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions