Repository navigation
fix: renew a proof that expired while the page was in the background - #11
Merged
Merged
Conversation
The widget learns of expiry from a setTimeout, which a phone doesn't run while its screen is off or the tab is backgrounded. Back on the page the widget still says verified while holding an expired proof, and the submit hold lets it through, so the server rejects it as expired. Keep each proof's expiresAt from the verified payload and check the clock: the submit hold renews a stale proof and waits for the new one, and coming back to the tab renews it straight away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A visitor on kokkikartano.fi was turned away from the feedback form today. The rejection was logged as
gform altcha rejected blog 1 form 3 (expired): 575 s past expiry. They were on an Android phone, and the access log shows why: the widget renewed its challenge every 10 minutes while the page was open, then stopped after 14:08:27 (screen off or tab in the background). The POST at 14:28:02 carried a proof that had expired at 14:18:27. They got through on a later try.Cause: the widget learns of expiry from a
setTimeout(expiresAt * 1000 - Date.now()), and a phone doesn't run timers while the page is frozen. Back on the page, the widget still saysverified, sowhenSolved()lets the submit through with the expired proof.Fix: keep each proof's
expiresAt(read from theverifiedevent's payload) and check it against the clock:expiredandunverified.visibilitychangeback to visible renews a stale proof straight away, so the submit doesn't wait on proof-of-work.verified. Otherwise the old expiry would trigger one extra renewal after a normal timer-driven renewal.Tested: there's no JS test harness in the repo, so I ran the script in Node against a stubbed widget and GF filter. A fresh proof submits without renewing. A stale proof holds the submit, renews once and then goes ahead. Coming back to the tab renews a stale proof and leaves a fresh one alone. A normal expiry while a submit waits renews only once. main's version fails the stale-proof cases.
npm run build:productionpasses. I haven't tried it on a real phone yet.🤖 Generated with Claude Code