Skip to main content

extractIdempotencyKey

@rotorsoft/act-root


@rotorsoft/act-root / act-http/src/receiver / extractIdempotencyKey

Function: extractIdempotencyKey()

extractIdempotencyKey(headers): string | undefined

Defined in: libs/act-http/src/receiver/extract.ts:23

Pull the Idempotency-Key header from a Node-style headers bag, case-insensitive. Returns undefined when any of the following carries no usable key:

  • the header is missing
  • its value is an array (ambiguous โ€” can't pick one without a policy the receiver hasn't declared)
  • its value is the empty string (carries no idempotency information; structurally equivalent to "no header at all")

Pair with IdempotencyStore.claim from @rotorsoft/act-ops/idempotency: extract the key from the inbound request, claim it on the store, return a deduped marker when the claim fails. The framework-agnostic middleware that wires these together lands in #744.

Validation beyond "is there a usable key?" (length bounds, format checks, normalization) is intentionally out of scope. Receivers picking a policy can layer it on top โ€” or, when #744 ships, opt into the middleware's opinionated defaults.

Parametersโ€‹

headersโ€‹

Record<string, string | string[] | undefined>

Returnsโ€‹

string | undefined