RequestSeal.Replay.Claim (RequestSeal v0.2.0)

Copy Markdown View Source

Bounded caller uniqueness and exclusive retention end in Unix seconds.

Summary

Functions

Validate the bounded shape of a replay claim without claiming or storing it.

Types

t()

@type t() :: %RequestSeal.Replay.Claim{
  key: binary(),
  namespace: binary(),
  retain_until: integer()
}

Functions

valid?(claim)

@spec valid?(term()) :: boolean()

Validate the bounded shape of a replay claim without claiming or storing it.

Requires exactly a RequestSeal.Replay.Claim struct with namespace and key binaries of 1–256 bytes each and retain_until in the signed 64-bit integer range (-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807). Binaries need not be UTF-8. Other values, maps, and structs with extra fields return false. Validation does not check a clock, require a future retention end, derive uniqueness, or establish replay protection. Stores enforce the exclusive Unix-second retention end when claiming.

iex> claim = %RequestSeal.Replay.Claim{namespace: "scope", key: "nonce", retain_until: 0}
iex> RequestSeal.Replay.Claim.valid?(claim)
true
iex> RequestSeal.Replay.Claim.valid?(%{claim | key: ""})
false