Skip to content

Function: fetchChallenge() ​

fetchChallenge(gatewayHost, opts?): Promise<Challenge>

Defined in: challenge.ts:60

Fetch a fresh challenge from a gateway's GET /v1/challenge endpoint.

The request is aborted after timeoutMs (default 10 s) or when signal aborts, whichever comes first. Redirects are refused (a gateway that redirects is not the gateway the caller chose), the response is never taken from or stored in an HTTP cache (cache: 'no-store'), no cookies or other ambient credentials are sent (credentials: 'omit'), and the body is cut off at 4 KiB while it is being read.

Parameters ​

gatewayHost ​

string

opts? ​

signal? ​

AbortSignal

timeoutMs? ​

number

Returns ​

Promise<Challenge>

Throws ​

if the host is not an https URL (http is allowed for loopback hosts only).

Throws ​

if the request fails, times out, is redirected, or the gateway returns a non-2xx status.

Throws ​

if the response is oversized, not JSON, or lacks a valid nonce or a positive numeric expiresAt.

2026 Meddleware. All jams preserved.