WebSocket auth guard — bridges audit events to BackendWebsocketTransport.
Why this exists. register_action_ws captures account_id and
credential_type at upgrade time and reuses them for every message.
perform_action's per-message authorization phase reloads role_grants
from the DB, but session and token VALIDITY are not re-queried — that
trade-off keeps chatty WS connections fast. The cost: nothing in the
dispatch path notices when a session is revoked or a token is rotated.
This guard is the enforcement mechanism — it listens on the audit
chain and closes affected sockets when revocation events fire, so
revocation actually takes effect on existing connections. Without it,
session_revoke / token_revoke are no-ops for open WS connections.
Mirror of realtime/sse_auth_guard.ts for the backend WebSocket
transport. Dispatches audit events to the right close_sockets_for_*
method so consumers do not re-implement the switch themselves.
For standard WS endpoints mounted via AppServerOptions.ws_endpoints,
create_app_server composes the guard automatically per
WsEndpointSpec.auth_guard. For custom wiring, append the handler
inside the consumer's audit_factory body (or via
audit.on_event_chain.push(...) post-assembly).