Server — JWT audience validation failing:
Keycloak does not include the client ID in the `aud` claim by default
(uses "account"). ValidateAudience=true with ValidAudience="sor-game"
rejected every token. Disabled audience validation — issuer + signature
+ realm role check is sufficient for a single-realm deployment.
Bumped JWT validation failure log to Information so it appears in default logs.
Client — DISCONNECTED instead of AUTH_FAILED on rejected auth:
When the server sends an error packet immediately followed by a close frame,
the socket transitions to STATE_CLOSING before the next _process frame.
Network.gd returned early during STATE_CLOSING without draining packets,
leaving the pending request unresolved. _on_ws_closed then failed it as
DISCONNECTED. Now drains packets during STATE_CLOSING so the error packet
is resolved with the correct error code before the close is processed.
Also added "invalid_token", "role_required", "invalid_payload",
"auth_service_unavailable", "account_creation_failed" to the close reason
→ error code mapping so they surface as AUTH_FAILED / AUTH_SERVICE_UNAVAILABLE
rather than DISCONNECTED even in the fallback path.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>