Skip to content

fix(client): replace an expired proof-of-work challenge - #49

Merged
cport1 merged 2 commits into
mainfrom
fix/client-challenge-refresh
Aug 30, 2026
Merged

fix(client): replace an expired proof-of-work challenge#49
cport1 merged 2 commits into
mainfrom
fix/client-challenge-refresh

Conversation

@cport1

@cport1 cport1 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

The widget fetched a PoW challenge on load and never replaced it, so a page open
longer than the server's five-minute window submitted a solution to a challenge
the server had already dropped. The server refused the proof and withheld the
token while scoring the visitor as human — the checkbox showed "Verification
failed". _showFailure kept the spent challenge, so retries repeated the same
refusal until a reload.

_solve now replaces a challenge at or inside a 15s margin of its expiry, and a
failed attempt fetches a replacement.

Tests: test/browser/tests/challenge-refresh.spec.ts (expired challenge
replaced, live challenge kept, retry gets a fresh one). Full browser suite: 41
passed.

cport1 added 2 commits August 30, 2026 10:31
The widget fetched a challenge when it loaded and never replaced it: _solve
asked for one only when it held none at all. A page open longer than the
server's five-minute window therefore submitted a solution to a challenge the
server had already dropped, which it refused — withholding the token while
scoring the visitor as human and recommending allow. The checkbox reported
"Verification failed" to someone who had done nothing wrong.

_showFailure then left the spent challenge in place, so every retry repeated
the same refusal until the page was reloaded.

_solve now replaces a challenge at or inside a 15s margin of its expiry, and a
failed attempt drops the spent one and fetches a replacement so the retry has
something to work with. Browser tests cover the expired case, the still-live
case that must not throw a good challenge away, and the retry.

Found running a real Statamic site against the server: a contact form filled
in slowly failed on the first click and every click after it.
@cport1
cport1 force-pushed the fix/client-challenge-refresh branch from 0acecd6 to 5701476 Compare August 30, 2026 15:33
@cport1
cport1 merged commit ed3d20f into main Aug 30, 2026
14 checks passed
@cport1
cport1 deleted the fix/client-challenge-refresh branch August 30, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant