MessageSignatures.Error exception (MessageSignatures v0.1.0)

Copy Markdown View Source

Error struct returned by all MessageSignatures functions.

The reason atoms are a stable, SemVer-guarded contract:

Message / input shape:

  • :invalid_message — constructor input is not a usable HTTP message (relative URL, missing method/status, bad header shape)
  • :malformed_signature_inputSignature-Input is not a valid SF dictionary of inner lists, or a parameter has the wrong type
  • :malformed_signatureSignature is not a valid SF dictionary of byte sequences, or its labels do not match Signature-Input
  • :malformed_component — component identifier is not a valid sf-string item, uses an unknown/ill-typed parameter, or combines exclusive parameters (bs with sf/key, sf with key)
  • :unsupported_component_parameter — the tr (trailers) parameter; parsed, deliberately unsupported in MVP

Signature base construction:

  • :component_not_found — a covered component (field, query param, derived value, or req target) is absent from the message
  • :duplicate_component — the same component identifier appears twice in the covered list
  • :unknown_sf_typesf parameter on a field whose Structured Fields type is not registered and not given via :sf_types
  • :malformed_field_value — a component value cannot be represented in an ASCII signature base, or sf/key re-serialization failed

Selection:

  • :missing_signature — no Signature-Input/Signature headers, or no signature matches the requested tag
  • :multiple_signatures — more than one candidate and no label:/tag: selector given
  • :label_not_found — requested label absent from either header

Crypto:

  • :signature_mismatch — the signature does not verify
  • :invalid_signature_encoding — ECDSA raw signature has the wrong length, or DER decoding failed
  • :invalid_key — key material does not match the algorithm
  • :unknown_key — the key resolver returned an error
  • :unknown_algorithm — an alg parameter names an algorithm outside the registry

Policy:

  • :algorithm_not_allowed — resolved algorithm outside the policy list
  • :algorithm_mismatchalg parameter contradicts the resolved key
  • :missing_required_component — policy-required component not covered
  • :missing_created — policy requires a created parameter
  • :expiredexpires passed, or created older than max_age
  • :not_yet_validcreated in the future beyond clock_skew
  • :nonce_rejected — the nonce checker refused the nonce

Summary

Types

t()

@type t() :: %MessageSignatures.Error{
  __exception__: true,
  algorithm: atom() | String.t() | nil,
  component: String.t() | nil,
  detail: term() | nil,
  key_id: String.t() | nil,
  label: String.t() | nil,
  reason: atom()
}