-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Implement a webhook dispatcher in the Rust service that emits HTTP POST callbacks to registered URLs when significant verification events occur (hash submitted, hash verified, document revoked).
Requirements:
- Create a
WebhookConfigstruct read from environment:pub struct WebhookConfig { pub urls: Vec<String>, // comma-separated WEBHOOK_URLS env var pub secret: String, // WEBHOOK_SECRET env var pub timeout_secs: u64, // WEBHOOK_TIMEOUT_SECS, default 5 }
- Create a
WebhookDispatcherwith:dispatch(event_type: &str, payload: serde_json::Value) -> Vec<DeliveryResult>— POSTs the payload to all configured URLs concurrently- Sign the request body with HMAC-SHA256 using
secretand include asX-SMALDA-Signature - Retry failed deliveries once after a 1-second delay
DeliveryResult:pub struct DeliveryResult { pub url: String, pub success: bool, pub status_code: Option<u16>, pub error: Option<String>, }
- Fire webhooks asynchronously using
tokio::spawnso they do not block the response
Acceptance Criteria:
- Dispatching is non-blocking — the main request response is not delayed
- HMAC signature is computed correctly and verifiable by the receiver
- Unreachable URLs are logged but do not panic
- Unit tests mock HTTP calls and verify HMAC signature computation
Reactions are currently unavailable