actions/register_ws_endpoint.ts

Composed WebSocket endpoint registration — the idiomatic consumer entry point for mounting a fuz_app WS endpoint.

Wraps the standard upgrade stack every consumer writes by hand:

1. verify_request_source(allowed_origins) — reject disallowed origins before the upgrade handshake runs. 2. require_auth — reject unauthenticated upgrades. 3. Optional require_role(required_role) — for endpoints gated to a specific role.

Then delegates to register_action_ws for per-message JSON-RPC dispatch.

Declarations
#

2 declarations

view source

register_ws_endpoint
#

actions/register_ws_endpoint.ts view source

<TCtx extends BaseHandlerContext>(options: RegisterWsEndpointOptions<TCtx>): RegisterActionWsResult

Mount a WebSocket endpoint with the standard upgrade stack (origin check + auth + optional role) and JSON-RPC dispatch.

Returns the BackendWebsocketTransport (supplied or freshly created), same as register_action_ws — retain it to wire create_ws_auth_guard on on_audit_event or to broadcast.

options

type RegisterWsEndpointOptions<TCtx>

returns

RegisterActionWsResult

RegisterWsEndpointOptions
#

actions/register_ws_endpoint.ts view source

RegisterWsEndpointOptions<TCtx>

generics

TCtx

inheritance

extends:
  • RegisterActionWsOptions<TCtx>

allowed_origins

Origin allowlist regexes — typically parsed from the ALLOWED_ORIGINS env var via parse_allowed_origins. Passed straight to verify_request_source.

type Array<RegExp>

required_role

Role required to upgrade. Omit for any authenticated account (require_auth alone); set to e.g. ROLE_ADMIN to gate the endpoint behind a role. The per-action auth in each spec still applies at dispatch time — this is a coarse upgrade-time gate.

Depends on
#