/** * The plugin's host runtime: gateway + device sessions + pairing + public * origin + Quick Tunnel, owned as one lifecycle. * * Deliberately independent of cordis: `apply` in index.ts is a thin adapter * that wires DSH services (webServer port, connection RPC, logger) into this * factory, and the tests drive the factory directly with fakes. * * Security invariants (carried from R02/R03): * - the gateway and its health port bind LOOPBACK only * - the public origin starts CLOSED and only opens with a validated tunnel * URL; tunnel stop/crash closes it first * - the tunnel targets the loopback GATEWAY, never DSH directly * - every management RPC endpoint sits behind the gateway's denied public * prefix, so the public entry can never reach it * - the device-session state file fails closed on corruption * - every unused pairing ticket dies when the tunnel stops or the URL * changes * - plugin load never auto-opens the network: the tunnel starts OFF and * only the user's explicit "enable" gesture starts it */ import type { GatewayLogger } from '../vendor/dsh-remote-web-gateway/dist/logger.js'; import { type QuickTunnelService } from '../vendor/dsh-remote-web-gateway/dist/quick-tunnel.js'; import { type DirHardener } from './acl.js'; import { type PluginConfig } from './config.js'; import { type GithubAuthService, type GithubFlowView, type GithubPollResult, type GithubStatusView } from './github.js'; import { type UpdateService, type UpdateStatusView } from './updater.js'; import type { CommandResult, DeviceRevokeAllResult, DeviceRevokeResult, DeviceSummaryView, DownloadSettingsView, PairingIssueView, PairingStatusView, RemoteErrorCode, RemoteStatusView } from './wire.js'; export type { RemoteErrorCode, RemoteStatusView, PairingIssueView, PairingStatusView, DeviceSummaryView, CommandResult }; export interface RemoteRuntimeOptions { /** Resolved harness home (the plugin never derives it from the checkout). */ readonly dshHome: string; /** DSH web server URL, always http://127.0.0.1:. */ readonly upstream: URL; readonly config: PluginConfig; readonly logger: GatewayLogger; /** Installed plugin package root (reads package.json for the version). */ readonly pluginRootDir: string; /** * R07: build DSH's browser-authenticated root URL for an origin. After a * successful pair the phone is bounced to this instead of bare `/`, because * DSH's web server requires its own session cookie (minted by the `?token=` * launch URL). Injected by the cordis adapter over `ctx.connection.authenticatedUrl`. */ readonly authRootUrl?: (origin: string) => string; /** Test injection for the Windows ACL hardening step. */ readonly hardenDir?: DirHardener; /** Test injection: replace the QuickTunnelService instead of creating one. */ readonly tunnelOverride?: QuickTunnelService; /** Test injection: replace the UpdateService. */ readonly updater?: UpdateService; /** Test injection: replace the GitHubAuthService. */ readonly githubAuth?: GithubAuthService; readonly now?: () => number; } export interface RemoteRuntime { /** The actual loopback gateway port (OS-assigned when configured 0). Local diagnostics only. */ readonly gatewayPort: number; status(): RemoteStatusView; tunnelStart(): Promise; tunnelStop(): Promise; /** * READ-ONLY pairing ticket state (R06C4B). Never creates or invalidates a * ticket — safe for status polling, settings remount and browser reload. */ pairingStatus(): PairingStatusView; /** Explicit mutation: generate a fresh one-time ticket (user action only). */ pairingRotate(): PairingIssueView | RemoteErrorCode; deviceList(): ReadonlyArray; deviceRevoke(deviceId: string): Promise; deviceRevokeAll(): Promise; updateCheck(force: boolean): Promise; updateApply(): Promise; githubStatus(): Promise; githubBindStart(): Promise; githubBindPoll(flowId: string): Promise; githubUnbind(): Promise; /** R06C4: read/write the UI-owned download network/source settings. */ networkConfigGet(): Promise; networkConfigSet(settings: DownloadSettingsView): Promise; dispose(): Promise; } export declare function createRemoteRuntime(options: RemoteRuntimeOptions): Promise;