/** * Defense-in-depth CSRF check for framework state-changing routes. * * Threat model: action endpoints (`/_agent-native/actions/*`), extension * endpoints (`/_agent-native/extensions/*` and the legacy * `/_agent-native/tools/*` alias), and a handful of other state-changing * `/_agent-native/*` routes use the better-auth session cookie, which is * configured with `SameSite=None; Secure; Partitioned` so the iframe editor * (and other cross-site embeds) can authenticate. `SameSite=None` means the * browser ships the session cookie on top-level form POSTs from any origin — * which is exactly the precondition for classic cross-site request forgery. * * The browser still gates "non-simple" requests behind a CORS preflight, so * an attacker who has to send `Content-Type: application/json` is forced * through OPTIONS, which our CORS middleware (`create-server.ts`) rejects * for disallowed origins. But the simple-request bypass (`Content-Type: * text/plain` on a `