Commit 7ba7a4e
committed
feat: webhooks — outbound HMAC-signed dispatch + admin UI · palette icon
Schema (migrate.ts + db/schema.ts)
- vaultbase_webhooks: id, name, url, events (JSON), secret, enabled,
retry_max, retry_backoff (exponential|fixed), retry_delay_ms,
timeout_ms, custom_headers (JSON map), created_at, updated_at
- vaultbase_webhook_deliveries: append-only delivery log with status
(pending|succeeded|failed|dead), attempt counter, response code +
body (truncated 2 KB), error msg, scheduled_at, delivered_at
- indexes on (status, scheduled_at) for hot dispatcher claim path
Core dispatcher (core/webhooks.ts)
- dispatchEvent({ event, data }) inserts a delivery row per matching
webhook (events match `*`, `coll.*`, or exact event string)
- 2 s tick claims due pending rows, POSTs them with:
X-Vaultbase-Event <event>
X-Vaultbase-Delivery <delivery-id>
X-Vaultbase-Timestamp <unix-seconds>
X-Vaultbase-Signature sha256=<hmac of "ts.body" using webhook.secret>
- Outbound URL passes through the existing egress CIDR filter so a
webhook can't be (ab)used for SSRF probes against private RFC1918
space — same envelope as helpers.http
- Failures: bump attempt + reschedule with exponential or fixed
backoff until retry_max → status=dead
Wired
- Record CRUD in core/records.ts fires `<collection>.create/update/delete`
after the existing realtime broadcast (fire-and-forget; never blocks
the response)
- server.ts boots startWebhookDispatcher alongside other schedulers
- ctx.helpers.webhooks.dispatch(event, data) lets hooks/routes/cron
emit custom events (e.g. "billing.invoice_paid")
Admin API (api/webhooks.ts)
- GET/POST/PATCH/DELETE /api/admin/webhooks
- GET /api/admin/webhooks/:id/deliveries (paginated + since filter)
- POST /api/admin/webhooks/:id/test fires a synthetic event scoped
only to that webhook (event-list temporarily augmented during the
dispatch call so other webhooks don't receive the test traffic)
Admin UI (admin/src/pages/Webhooks.tsx + sidebar entry under Logic)
- Two-pane editor: list left, full editor + recent deliveries right
- Event chips, custom headers editor, retry config, timeout
- HMAC secret with regenerate button + receiver verification snippet
- Delivery row click opens detail drawer (payload, response body,
error, attempts, timestamps)
- Fire-test button enqueues a synthetic delivery to validate wiring
Misc
- palette icon added to Icon.tsx for the Theme Settings tab (was
pointing at the non-existent "fill" icon)
Bumps version 0.4.0 → 0.5.0 (minor — new public surface).1 parent 76c2a87 commit 7ba7a4e
13 files changed
Lines changed: 1107 additions & 3 deletions
File tree
- admin/src
- components
- pages
- src
- api
- core
- db
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
0 commit comments