feat: add webhook subscription system#263
Open
GreatShinro wants to merge 4 commits into
Open
Conversation
- Add WebhookSubscription and WebhookDelivery Prisma models - CRUD endpoints under /api/webhooks (Bearer JWT auth) - HMAC-SHA256 payload signing via X-Neurowealth-Signature header - Dispatch with 3-attempt exponential back-off, persisted delivery log - Wire dispatch into stellar events, agent loop, and tx controller - Unit tests for signature generation and retry logic (13 tests) - OpenAPI spec updated with webhooks tag and schemas
|
@GreatShinro Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- lint-staged runs eslint --fix + prettier --write on staged src/tests *.ts - pre-push runs full test suite with --passWithNoTests - prepare script wires husky on npm install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Webhook Subscription System
Summary
Adds a full server-push webhook system so integrators (mobile apps, dashboards) can receive real-time event notifications without polling.
What Changed
Database
WebhookSubscriptionWebhookDeliveryMigration:
prisma/migrations/20260627000000_add_webhook_tables/API —
POST /api/webhooks(new endpoint group)All routes require
Authorization: Bearer <JWT>.POST/api/webhooksGET/api/webhooksGET/api/webhooks/:idPATCH/api/webhooks/:idDELETE/api/webhooks/:idPayload Signing
Every outbound webhook POST carries:
Computed as
HMAC-SHA256(secret, raw_body). Recipients verify by recomputing with their stored secret.Events Dispatched
transaction.confirmedtransaction-controller.ts— on-chain tx confirmeddeposit.receivedstellar/events.ts— deposit event processedwithdraw.completedstellar/events.ts— withdraw event processedagent.rebalancedstellar/events.ts+agent/loop.ts— rebalance executedRetry Logic
Failed deliveries are retried up to 3 times with exponential back-off:
Each attempt is logged in
WebhookDelivery. After all attempts fail the record is markedFAILEDand logged as an error. Dispatch is always fire-and-forget — failures never block the request path.Files Changed
Tests
Covers: secret uniqueness, HMAC correctness, success on first attempt, exhausted retry → FAILED, partial retry → SUCCESS, signature header format, subscription event filtering.
Acceptance Criteria
POST /api/webhookscreates subscription, returns signing secret onceX-Neurowealth-SignatureWebhookDeliverytableTesting Locally
closes #226