Module: Axn::Webhooks::Outbound::Signer

Defined in:
lib/axn/webhooks/outbound/signer.rb

Overview

Builds a signer callable (#call(id:, timestamp:, body:) -> header Hash) from a sign declaration. The :standard_webhooks strategy is the outbound face of the inbound verify :standard_webhooks — same scheme, so a receiver using that verifier accepts it.

Defined Under Namespace

Classes: CustomSigner, HmacSigner, StandardWebhooksSigner

Constant Summary collapse

HEADER_NAME =

RFC 7230 field-name token. Net::HTTP stores whatever key it is handed and serializes it straight into the header line, so a space yields a malformed request and a newline appends attacker-shaped wire headers — neither caught until delivery (Codex review). Module-level (not nested under HmacSigner) so Deliver's per-destination headers merge (PRO-3214) can hold a subscriber-supplied header name to the SAME grammar, rather than duplicating it — the identical injection risk, just from runtime data instead of a sign :hmac declaration (Codex P1 finding).

/\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/

Class Method Summary collapse

Class Method Details

.build(strategy:, opts:, block:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/axn/webhooks/outbound/signer.rb', line 21

def build(strategy:, opts:, block:)
  return CustomSigner.new(block) if block

  case strategy&.to_sym
  when :hmac then HmacSigner.new(**opts)
  when :standard_webhooks then StandardWebhooksSigner.new(**opts)
  # A pure declaration mistake (decided once at boot, never at runtime) — ArgumentError, not
  # Axn::Webhooks::Error, matching Config's own misconfiguration-vs-runtime split.
  else raise ArgumentError, "unknown sign strategy #{strategy.inspect}"
  end
end