Saxonberg Server API
    Preparing search index...

    Backend - Singleton for I/O operations.

    Implements

    Index

    Methods

    • 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.

      Parameters

      • provider: AuthProvider

        which login provider authenticated

      • profile: ProviderProfile

        normalized profile (Google) / profile+tokens (Twitch)

      • done: (error: unknown, user?: { authProvider: AuthProvider; id: string }) => void

        Passport callback (session principal carries authProvider)

      Returns Promise<void>

    • 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).

      Parameters

      • provider: AuthProvider

        which provider is being linked

      • userId: string

        the currently-authenticated user's id

      • profile: ProviderProfile

        the link OAuth's resolved profile

      • done: (error: unknown, result?: LinkResult) => void

        callback delivered the LinkResult

      Returns Promise<void>

    • 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.

      Parameters

      • provider: AuthProvider

        which provider to unlink

      • userId: string

        the currently-authenticated user's id

      • done: (error: unknown, result?: UnlinkResult) => void

        callback delivered the UnlinkResult

      Returns Promise<void>

    • 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.

      Parameters

      • handle: string

        stable label → deterministic user/avatar (idempotent)

      • done: (error: unknown, user?: { id: string }) => void

        same callback shape as the OAuth verify path

      • withCharacter: boolean = false
      • OptionalstartLocation: string

      Returns Promise<void>

    • Handle WebSocket connection. Called by WebSocketService when a new connection is established.

      Parameters

      • ws: WebSocket

        WebSocket connection

      • userId: string

        User ID from session (sentinel service:broadcast for the read-only broadcast principal)

      • sessionId: string

        Session ID

      • isBroadcast: boolean = false

        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: string

      Returns void

    • 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.

      Parameters

      • socketId: string
      • envelope: Envelope

      Returns void