webhookValidationMiddleware
Create a Hono middleware that captures the raw request body,
validates the SignalWire signature via
validateWebhookSignature(), and rejects requests
that fail. On failure it responds 403 Forbidden with no body detail (to avoid
leaking which check failed); on success it calls next().
AgentBase auto-mounts this middleware on POST /, /swaig, and
/post_prompt when you set its signingKey constructor option. Use this factory
directly only when wiring validation into your own Hono app.
Parameters
opts
Middleware options.
opts.signingKey
Your SignalWire Signing Key. An empty string throws at construction time.
opts.trustProxy
When true, honor X-Forwarded-Proto and X-Forwarded-Host when
reconstructing the public URL. Defaults to false because those headers are
spoofable. SWML_PROXY_URL_BASE always takes precedence.
Returns
MiddlewareHandler — A Hono middleware that validates the signature, responds
403 on failure, and calls next() on success.