2.7 KiB
2.7 KiB
Code Generation Plan — captcha-slp (U7: Friendly Captcha for the SLP site, B and E)
Reason: Bryan wants SLP to support the captcha like ASF (2026-11-11). Until now the SLP form falls back to the mail button when the token response carries captcha. Production keeps captcha OFF (server Contact__Captcha__Enabled=false) until a paid Friendly Captcha plan exists; this unit makes the SLP site able to use it. Base: ASF's tested CaptchaWidget (read only) and the cms-client slot (93fa729).
Steps
- 1. Dependency: add
@friendlycaptcha/sdk1.1.3 (pinned; check pnpmminimumReleaseAge,pnpm audit --prodstays clean). - 2. Shared widget
src/shared/contact/CaptchaWidget.tsx(framework-neutral styling, Tailwind): lazy SDK import (own chunk),startMode: focus,language: nl,apiEndpointfrom the server,onToken(token|null)on complete/expire/error,onProblem(boolean)(error, blocked script/iframe, no sign of life within 15 s),resetCountresets the widget and clears the token,destroy()on unmount, reserved height (no layout shift),themeprop (light|dark),ariafriendly label; loaded only when the form is open AND the server asks for a captcha. - 3. Availability
useContactAvailability:captcha != nullwith providerfriendlycaptchaopens the form (other providers keep the mail button). - 4. Form B
ContactFormView: render the widget (Suspense, reserved height), wiresetCaptchaToken,captchaResetCount; widget problem => clear message with the mail button (never silently blocked);captchaRequiredmessage (role alert) from the package. - 5. Form E
TerminalForm: same wiring in terminal style (widget theme dark, amber frame), messages in terminal casing. - 6. Tests: fake SDK (complete, expire, error, no sign of life, reset after attempt); B and E: widget only when captcha required, expired token never sent, submit blocked with message until solved, problem => mail button, captcha provider unknown => mail button, no widget chunk when no captcha.
- 7. Quality gates: lint, tests, build (new lazy chunk size noted; main bundle must not grow),
pnpm audit --prod. - 8. Docs + infra note: update code summary and
operations/host-config-checklist.md: frame-src for the three hosts must be set where the SLP site HTML is served (not yet confirmed which server that is); captcha stays off in production until a paid plan. - 9. Commit, push, test-deploy (deploy_test only). Real-browser run with the widget against the local SLP API (5290, captcha on) as Bryan's check.
Not in this unit
Enabling captcha in production, paid plan, EU switch (config only), privacy page for SLP (separate), CSP on the host that serves slpsoftware.nl (needs confirmation from the infra owner).