Skip to content

ash_hooks 3.0.0

Choose a tag to compare

@palermo-git palermo-git released this 11 Nov 12:34
· 678 commits to main since this release

Inbound verification becomes generic: describe any sender's signature scheme in
configuration, or write one callback with public primitives. The package no
longer ships vendor-specific verifiers. Two breaking changes, listed below with
their replacements; UPGRADING.md gives the configuration for
each removed module. No schema or dependency changes.

Breaking

  • Removed the vendor verifier modules AshHooks.Provider.ComplyCube (and
    ComplyCube.Event), AshHooks.Provider.HubSpotV3 (and HubSpotV3.Event and
    decode_request_uri/1), AshHooks.Provider.Twilio, AshHooks.Provider.Stripe,
    AshHooks.Provider.Shopify, AshHooks.Provider.WooCommerce,
    AshHooks.Provider.Shippo, AshHooks.Provider.EasyPost,
    AshHooks.Provider.Magento2, AshHooks.Provider.BigCommerce,
    AshHooks.Provider.Ecwid, AshHooks.Provider.Squarespace, and
    AshHooks.Provider.Wix. Replacement: a provider module in your application,
    usually use AshHooks.Provider, verify: [...] with the options UPGRADING lists
    for each one.
  • Removed the name-to-module convention. An inbound declaration without
    provider no longer resolves AshHooks.Provider.<CamelizedName>; it fails to
    compile with a message naming the fix. Replacement: set provider on every
    inbound declaration, keeping the inbound name unchanged so existing
    deduplication identities still match.

Added

  • use AshHooks.Provider, verify: [...] generates a provider from configuration:
    HMAC with SHA-1, SHA-256, SHA-384 or SHA-512; RSA PKCS#1 v1.5 and RSA-PSS with
    SHA-256, SHA-384 or SHA-512; ECDSA P-256 and P-384 with DER or raw r || s
    signatures; Ed25519; and compact JWS bodies with the algorithm pinned by the
    host. Signatures come from a named header (optionally prefixed), a structured
    header of key/value pairs carrying up to 16 signatures, or the body. Hex,
    base64 and base64url encodings; raw, hex or base64 secrets with an optional
    prefix; PEM public keys, X.509 certificates or raw Ed25519 keys; a signed input
    built from the body, timestamp, method, URL, path, headers and literals, or by a
    host function; timestamps in seconds or milliseconds from a header, a signature
    field or a host function, with a symmetric tolerance. Options are checked at
    compile time and every generated callback can be overridden.
  • AshHooks.Provider.Scheme documents those options. new!/1 validates them,
    verify/4 verifies with them directly, and payload_identity/1,
    decode_payload/2, timestamp_header/1 and signature_source/1 back the
    generated callbacks.
  • A provider configured with signature: :jws_body also gets decode_payload/1,
    which stores the verified JWS payload, and event_identity/1, which
    deduplicates on the SHA-256 of that payload as canonical JSON
    (AshHooks.Provider.Scheme.payload_identity/1) instead of the raw-body digest.
    Two encodings of the same signed content share one ledger row.
  • AshHooks.Provider.Signature.jws/3 and :jws_body accept only unpadded
    base64url segments, as RFC 7515 requires. A token that contains = fails with
    :invalid_signature.
  • AshHooks.Provider.Signature is public: hmac/4, rsa/4, ecdsa/4,
    ed25519/4, jws/3, compare/2, header/2 and check_timestamp/3, for
    providers that implement verify_signature/3 themselves.
  • The optional signature_source/0 callback accepts :request, for providers
    that read their own signature from the request headers; ingress then needs no
    ctx.signature.
  • AshHooks.Ingress.ingest/4 accepts the request headers as an ordered list of
    {name, value} pairs, such as conn.req_headers, as well as a map. Providers
    receive every line in arrival order in the new ctx.header_list, and repeated
    lines are joined with ", " in ctx.headers. A map the host passes is
    delivered unchanged, as before.
  • AshHooks.Provider.Hmac accepts :sha384 and :sha512 algorithms.
  • A "Verify any sender" guide with recipes for common signature shapes.

Changed

  • AshHooks.Ingress.ingest/4 fails verification when headers is neither a map
    nor a list of binary {name, value} pairs. A list reaches providers as a map in
    ctx.headers and in full in ctx.header_list.

See UPGRADING.md for the replacement configuration of each removed module, and the Verify any sender guide.