Skip to content

Implement a webhook dispatcher in the Rust service #188

@mftee

Description

@mftee

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 WebhookConfig struct 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 WebhookDispatcher with:
    • 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 secret and include as X-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::spawn so 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions