Close all WebSocket connections (for shutdown).
Get count of active WebSocket connections.
Handle a successful provider authentication (login). Called by a
Passport strategy's verify callback after the provider OAuth
succeeds. Provider-parameterized: the verify callback passes its
provider argument so the find-or-create routes to the right
collection/key. runRoot lives here because only backend/** may
push call frames — services/ may not.
which login provider authenticated
normalized profile (Google) / profile+tokens (Twitch)
Passport callback (session principal carries authProvider)
Handle a provider link — the authenticated link OAuth round-trip
attaches the second provider's profile to the current User rather
than minting a session. The services/-layer route never calls
Application across the frame boundary directly; this seam plants
the root frame (only backend/** may push call frames).
which provider is being linked
the currently-authenticated user's id
the link OAuth's resolved profile
callback delivered the LinkResult
Handle a provider unlink — clears the FK on the current User and
deletes the orphaned profile. No OAuth round-trip; plain
authenticated operation behind the same root-frame discipline.
which provider to unlink
the currently-authenticated user's id
callback delivered the UnlinkResult
TEST-ONLY authentication. Mints a session user for a deterministic
synthetic profile, bypassing Google OAuth. Mirrors
handleProviderAuth('google', …) exactly — same runRoot root
frame, same provider-parameterized creation path, same
done(null, { id }) shape — so the resulting session and Avatar
are indistinguishable from a real login.
Hard-gated on AUTH_MODE === 'test': refuses regardless of how it
is reached. The route that calls this is itself only mounted in
test mode (see Server + TestAuthRoutes); this is the second
line of defense. runRoot lives here because only backend/**
(and a few framework dirs) may push call frames — services/ may
not.
stable label → deterministic user/avatar (idempotent)
same callback shape as the OAuth verify path
OptionalstartLocation: stringHandle WebSocket connection. Called by WebSocketService when a new connection is established.
WebSocket connection
User ID from session (sentinel service:broadcast
for the read-only broadcast principal)
Session ID
true for the read-only livestream broadcast
principal: no User/Login/Avatar is created — Application routes it
straight to the BroadcastFeed as a pure push target, so it can't
run commands by construction.
OptionalclientIp: stringInitialize Backend with Application reference.
Application instance
Send an envelope (dispatch-response, activity-update, prompt)
to a specific WebSocket connection. The wire layer is JSON
stringify; envelope and MessageFrame share the same transport.
The client discriminates on the type field.
Send a message to a specific WebSocket connection.
The socket ID to send to
The message object to send
StaticgetGet the singleton instance.
Backend - Singleton for I/O operations.