verifySolution() is called server-side in your verify endpoint to check that the browser correctly solved all challenge tokens. It checks the JWT signature, token expiry, the SHA-256 hash proof, and (by default) prevents token reuse.
Import
Signature
Parameters
The original JWT token(s) returned by
createChallenge(). Pass the same tokens your challenge endpoint issued.The solution(s) submitted by the browser. Can be:
- A single nonce string
- An array of nonce strings
- A
ChallengeSolutionobject{ nonce: string; hash: string } - An array of
ChallengeSolutionobjects (what the widget sends assolutions)
Optional configuration object. See the options table below.
Options
| Option | Type | Default | Description |
|---|---|---|---|
replayPrevention | 'local' | 'remote' | 'disabled' | 'local' | Controls how token reuse is prevented |
replayStore | ReplayStore | undefined | Required when replayPrevention is 'remote'. Implements the consume() method. |
debug | boolean | auto (true in dev) | Log verification warnings to console |
onWarning | (warning: VerifyWarning) => void | undefined | Callback for structured warning events |
Return value
Promise<boolean>. Returns true only if ALL tokens have valid solutions and pass replay checks. Returns false for any failure without throwing.
Examples
Basic usage:Warning reasons
| Reason | Description |
|---|---|
invalid-token | JWT signature is invalid or malformed |
expired-token | Challenge TTL has passed |
invalid-solution | The nonce does not produce a valid hash |
replay-detected | Token was already consumed |
configuration-error | replayPrevention is 'remote' but no replayStore provided |