Skip to content

Add optional first-party proof-of-work captcha to login - #41

Merged
alexpricedev merged 4 commits into
mainfrom
alexpricedev/captcha-spam-signups
Jul 22, 2026
Merged

Add optional first-party proof-of-work captcha to login#41
alexpricedev merged 4 commits into
mainfrom
alexpricedev/captcha-spam-signups

Conversation

@alexpricedev

Copy link
Copy Markdown
Owner

Adds layered bot defense to POST /login to stop spammers creating accounts with random emails (Billet is passwordless, so each junk submission both creates a user and fires a magic-link email at a random address). The guards run cheapest-first: per-IP rate limit (activating the previously-dormant middleware/rate-limit.ts), a honeypot field, then an optional self-hosted proof-of-work captcha that signs challenges with the existing CRYPTO_PEPPER — no third party, account, new secret, or CSP change. The captcha is off unless CAPTCHA_ENABLED=true, so /login is unchanged by default; when on, the server embeds a signed challenge that a zero-dependency client bundle solves and the server re-verifies (HMAC + proof + single-use replay). The three captcha files are kept dependency-free so they can later be extracted to a @alexpricedev/billet-captcha module. Full test coverage added (340 pass), including a client↔server cross-check proving the hand-written SHA-256 matches Node's.

🤖 Generated with Claude Code

alexpricedev and others added 4 commits July 21, 2026 12:23
Layered bot defense on POST /login to stop spam magic-link signups:
rate-limit (activates the dormant middleware), a honeypot field, and an
optional self-hosted proof-of-work captcha. The captcha signs challenges
with the existing CRYPTO_PEPPER (no third party, account, new secret, or
CSP change) and is off unless CAPTCHA_ENABLED=true, so /login is unchanged
by default. Ships a zero-dep client solver bundle and full test coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The proof of work runs silently, so drop the visible "Verifying…/Verified."
label that cluttered the login form. Kept as an sr-only aria-live region so
assistive tech still gets feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the signup-spam defense (honeypot + rate limit + optional proof-of-work
captcha) to the Security feature list, the environment variable table
(CAPTCHA_ENABLED, CAPTCHA_DIFFICULTY), and a setup note.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexpricedev
alexpricedev merged commit 9e1fb30 into main Jul 22, 2026
3 checks passed
@alexpricedev
alexpricedev deleted the alexpricedev/captcha-spam-signups branch July 22, 2026 10:26
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