Headless pakket src/cms-client met importgrens, formulier dat pas verschijnt als de API antwoordt (anders blijft de mailto-knop), honeypot, idempotentie, token-vernieuwing en property-based tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1.6 KiB
1.6 KiB
NFR Design Patterns — contact-form (U4)
| Pattern | Where | Purpose |
|---|---|---|
| Progressive enhancement | ContactPanel + useContactAvailability |
form only when the API answers 200; mailto otherwise |
| Fail closed to a safe fallback | client/hook | any unexpected response or error ends in the failure state with the mail address |
| Idempotent retry | hook + Idempotency-Key |
a retry never creates a second message |
| Pure core / thin shell | validateContact, reducer, mapApiErrors |
testable without DOM or network (PBT) |
| Honeypot + server token | hook + API | bots learn nothing; no client clock |
| Request timeout | client | AbortController 10 s so the UI never hangs in sending |
| Data minimisation in telemetry | analytics calls | events without data; no values in logs |
| Single token refresh | client | expired handled once, then generic failure (no loops) |
| Layout reservation | ContactPanel |
minimum height keeps the page stable when upgrading from mailto to form |
Misuse / abuse scenarios considered
- A bot fills every field including the honeypot: silent success on the client, the server drops or stores it as spam.
- Rapid repeated submits (double click, flaky network): ignored while
sending; same idempotency key on retry. - Visitor tampers with the token: the API answers
expired; one refresh, then failure. - Very large input pasted: client length errors; the API answers 413, message "Je bericht is te groot."
- API unavailable or deliberately closed (switches): the form never appears or falls back to mailto; no console spam.