Skip to content

Interface: HandoffStateStore

Defined in: packages/core/src/handoff/types.ts:19

Pluggable persistence interface for the Claim-Check pattern.

When carryOverState exceeds 2 KB, the SwarmGateway persists it under a UUID key and embeds only the key inside the HMAC token, keeping HTTP headers within safe limits (< 8 KB nginx/ALB limit).

Default implementation: InMemoryHandoffStateStore (same package). Platform adapters: implement this interface (e.g. @vurb/cloudflare).

Methods

delete()?

ts
optional delete(stateId): Promise<void>;

Defined in: packages/core/src/handoff/types.ts:50

Delete the state without reading it.

Used in the two-phase read-then-delete pattern (see get above). Falls back to a no-op if not implemented.

Parameters

ParameterType
stateIdstring

Returns

Promise<void>


get()?

ts
optional get(stateId): Promise<Record<string, unknown> | undefined>;

Defined in: packages/core/src/handoff/types.ts:43

Read the state without deleting it.

(optional method): allows the two-phase read-then-delete pattern so that verifyDelegationToken can read the state into memory before deleting it. This prevents irrecoverable data loss if an error occurs between the read and the return of the claims to the caller.

Falls back to getAndDelete if not implemented (old implementations).

Parameters

ParameterType
stateIdstring

Returns

Promise<Record<string, unknown> | undefined>


getAndDelete()

ts
getAndDelete(stateId): Promise<Record<string, unknown> | undefined>;

Defined in: packages/core/src/handoff/types.ts:32

Retrieve and atomically delete the state (one-shot). Prevents state leaks after successful handoff hydration. Returns undefined if the key does not exist or has expired.

Parameters

ParameterType
stateIdstring

Returns

Promise<Record<string, unknown> | undefined>


set()

ts
set(
   stateId, 
   state, 
ttlSeconds): Promise<void>;

Defined in: packages/core/src/handoff/types.ts:26

Persist a state object under stateId with a TTL.

Parameters

ParameterTypeDescription
stateIdstringUUID key
stateRecord<string, unknown>Arbitrary carry-over state
ttlSecondsnumberExpiry in seconds

Returns

Promise<void>