Contactformulier: cms-client (validatie, reducer, client, hook), formulier in stijl B en beschikbaarheid
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>
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
# NFR Requirements — contact-form (U4)
|
||||
|
||||
| Id | Category | Requirement |
|
||||
|---|---|---|
|
||||
| NFR-U4-1 | Security / input | Client-side validation mirrors the API limits (100/254/100/2000, control characters, email regex); the API is authoritative. All API strings are rendered as plain text (no `dangerouslySetInnerHTML`). |
|
||||
| NFR-U4-2 | Security / abuse | Honeypot, server-signed token (no client clock), idempotency key; no external captcha provider is loaded (captcha required => mailto fallback). The client never retries automatically except the single token refresh. |
|
||||
| NFR-U4-3 | Privacy | No form values, token, idempotency key or response bodies in console output, Sentry (events, breadcrumbs, extra) or Umami. Only `contact-sent` / `contact-failed` events without data. Privacy sentence below the form (12 months). |
|
||||
| NFR-U4-4 | Availability / resilience | The form is progressive: if the API is closed, slow or failing, the mailto panel stays. A failed submit keeps the visitor's input and offers retry plus the mail address. Token and submit requests abort after 10 s. |
|
||||
| NFR-U4-5 | Performance | No request on page load; the token request starts when the contact section nears the viewport. The form code is part of the main bundle (small); no new runtime dependencies. No layout shift when the panel is upgraded (the panel keeps its minimum height). |
|
||||
| NFR-U4-6 | Accessibility | WCAG 2.1 AA: labels, error association, focus handling, live regions, 44px targets, contrast (tokens already tested), no motion dependency. |
|
||||
| NFR-U4-7 | Maintainability | `src/cms-client/` has no imports from the app (lint-enforced) and is documented as the future package; texts injectable; Dutch defaults. |
|
||||
| NFR-U4-8 | Testability | Pure functions and the reducer are property/round-trip tested (partial PBT); the client is tested against a mocked `fetch` that follows the contract; the hook against the client interface. |
|
||||
| NFR-U4-9 | Compatibility | Works with hash routing, static hosting and the same-origin API path `/api/v1/...`; `VITE_API_BASE_URL` stays a local-development override only. |
|
||||
|
||||
## Security Baseline compliance (extension enabled) — U4 scope
|
||||
| Rule | Status | Note |
|
||||
|---|---|---|
|
||||
| SECURITY-01 | N/A | the frontend stores nothing; message storage and encryption belong to the CMS |
|
||||
| SECURITY-02 | N/A | no load balancer/gateway defined in this unit (reverse-proxy logging is an Operations item) |
|
||||
| SECURITY-03 | Compliant | no values/tokens/PII logged; no ad-hoc logging in the form code |
|
||||
| SECURITY-04 | Open (Infrastructure) | security headers must be set by the web servers, not by the SPA; whether they are set today is **unconfirmed** (see infrastructure-design.md); must be confirmed or fixed before the contact routes go live |
|
||||
| SECURITY-05 | Compliant (client side) | validation with allow-list regex and bounds, plain-text rendering; server validation by the API |
|
||||
| SECURITY-06/07 | N/A | no IAM/network resources in this unit |
|
||||
| SECURITY-08 | Compliant | only public endpoints are called (explicit public marker on the API); no admin calls from this site |
|
||||
| SECURITY-09 | Compliant | generic error messages; no stack traces to visitors |
|
||||
| SECURITY-10 | Compliant | no new runtime dependencies; lock file committed (dev dependency fast-check for tests only) |
|
||||
| SECURITY-11 | Compliant | API rate limiting, honeypot/token/idempotency; misuse cases in nfr-design-patterns.md |
|
||||
| SECURITY-12 | N/A | no authentication in this unit |
|
||||
| SECURITY-13 | Compliant | JSON only with typed parsing; no new external scripts |
|
||||
| SECURITY-14 | N/A (Operations) | alerting belongs to the Operations phase (undecided) |
|
||||
| SECURITY-15 | Compliant | every external call has error handling; failure ends in the mailto fallback; global ErrorBoundary exists |
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# Tech Stack Decisions — contact-form (U4)
|
||||
|
||||
- **No new runtime dependencies.** Plain `fetch` with `AbortController`, `crypto.randomUUID()` for the idempotency key (fallback to a `getRandomValues` based UUID where unavailable), React hooks/reducer.
|
||||
- **Forms**: no form library; the headless hook owns state and validation (reusable by other sites).
|
||||
- **Tests**: Vitest + Testing Library; `fast-check` as a **dev** dependency for the partial property-based testing (validation, reducer invariants, serialization round trips): vetted npm package, lock file committed, no runtime impact, respecting the repo's release-age policy (stop and report if blocked).
|
||||
- **API types**: hand-written minimal types now; generated from the CMS file `openapi/slpsoftware.v1.json` is a follow-up when `cms-client` moves to SlpModularCms.
|
||||
- **Boundary enforcement**: ESLint `no-restricted-imports` on `src/cms-client/**` (no imports from the app folders).
|
||||
Reference in New Issue
Block a user