feat(server): proxy browser desktop with lease-based control/view credentials
/api/v1/browser/desktop/{sessionId}/* proxies Selkies HTTP and WebSocket,
console sessions only. The holder of the active human lease gets the control
password, everyone else the view-only one; the WS bridge rechecks every 3s
and drops the connection on role change so the client reconnects downgraded.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
880cec4d23
commit
7e028fa23e
5 files changed
+563
-1
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import type { ServerContext, ServerModule } from "../types.ts";
|
||||
import { dbSessionChecks, desktopUpstream, registerDesktopRoutes } from "./desktop.ts";
|
||||
|
||||
/**
|
||||
* WT-1 原站视图桌面模式:/api/v1/browser/desktop/{sessionId}/* 反代浏览器桌面容器(Selkies)的 HTTP 与 WebSocket,
|
||||
* 按人工租约注入控制 / 只读口令。只用会话 / 租约表(只读),不改浏览器模块。
|
||||
* 桌面地址:BROWSER_DESKTOP_URL,缺省由 BROWSER_PROVIDER_URL 推出(端口换 3000)。
|
||||
*/
|
||||
export function createDesktopModule(): ServerModule {
|
||||
let closeAll: (() => void) | null = null;
|
||||
return {
|
||||
name: "desktop",
|
||||
registerRoutes(app, ctx: ServerContext) {
|
||||
const r = registerDesktopRoutes(app, {
|
||||
upstream: desktopUpstream({
|
||||
providerUrl: ctx.config?.BROWSER_PROVIDER_URL,
|
||||
desktopUrl: Deno.env.get("BROWSER_DESKTOP_URL") || undefined,
|
||||
}),
|
||||
accessKey: ctx.config?.BROWSER_ACCESS_KEY ?? null,
|
||||
...dbSessionChecks(ctx.db),
|
||||
log: (msg, extra) => ctx.logger.warn({ component: "desktop", ...extra }, msg),
|
||||
});
|
||||
closeAll = r.closeAll;
|
||||
},
|
||||
registerTasks() {},
|
||||
stop() {
|
||||
closeAll?.();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const desktopModule = createDesktopModule();
|
||||
Reference in new issue
Block a user