Skip to content
On this page

Function: createReplayGuard()

TypeScript
function createReplayGuard(maxSkewMs?: number): {
  firstUse: boolean;
};

Defined in: agent-core/src/verify.ts:620 (opens in a new tab)

Remembers the ids of accepted actions, so one signed action is acted on once. An action passes the freshness bound for maxSkewMs either side of its signed_at, so its id is kept until signed_at + maxSkewMs. In-memory and per process: a server on several instances keeps the same record in a shared store. Two identical calls signed in the same second share an id.

ParametersLink to this section

ParameterTypeDefault
maxSkewMsnumberDefault DEFAULT_MAX_SKEW_MS

ReturnsLink to this section

TypeScript
{
  firstUse: boolean;
}
NameTypeDefined in
firstUse()(action: Pick<ActionEnvelope, "id" | "signed_at">, now?: Date) => booleanagent-core/src/verify.ts:621 (opens in a new tab)