TypeScript
fix(desktop): browser tabs no longer report loopback access as denied (#22835)
Arjun Radhakrishnan515330058a07
diff --git a/apps/desktop/src/preview/BrowserSession.test.ts b/apps/desktop/src/preview/BrowserSession.test.tsindex b1f2b7ca0df..df41a9821bf 100644--- a/apps/desktop/src/preview/BrowserSession.test.ts+++ b/apps/desktop/src/preview/BrowserSession.test.ts@@ -145,7 +145,7 @@ describe("BrowserSession", () => {}).pipe(Effect.provide(layer)),);- it.effect("grants clipboard-sanitized-write through both the request and check handlers", () =>+ it.effect("grants preview permissions through both the request and check handlers", () =>Effect.gen(function* () {const browserSessions = yield* BrowserSession.BrowserSession;const partition = yield* browserSessions.getPartition("scope-a");@@ -168,7 +168,12 @@ describe("BrowserSession", () => {return granted;};- for (const permission of ["clipboard-sanitized-write", "geolocation", "fullscreen"]) {+ for (const permission of [+ "clipboard-sanitized-write",+ "geolocation",+ "fullscreen",+ "loopback-network",+ ]) {assert.isTrue(requestAllows(permission), `request handler should allow ${permission}`);assert.isTrue(checkHandler(null, permission) as boolean,@@ -179,7 +184,13 @@ describe("BrowserSession", () => {// `clipboard-write` is not a real Electron permission — the async write API// uses `clipboard-sanitized-write` — so the stale name must not be granted,// and unrelated permissions stay denied.- for (const permission of ["clipboard-write", "notifications", "midi"]) {+ for (const permission of [+ "clipboard-write",+ "notifications",+ "midi",+ "local-network",+ "local-network-access",+ ]) {assert.isFalse(requestAllows(permission), `request handler should deny ${permission}`);assert.isFalse(checkHandler(null, permission) as boolean,diff --git a/apps/desktop/src/preview/BrowserSession.ts b/apps/desktop/src/preview/BrowserSession.tsindex e467c370d0f..f8f23aca6af 100644--- a/apps/desktop/src/preview/BrowserSession.ts+++ b/apps/desktop/src/preview/BrowserSession.ts@@ -24,6 +24,8 @@ const ALLOWED_PREVIEW_PERMISSIONS: ReadonlySet<string> = new Set(["geolocation",// DesktopWindow confines HTML fullscreen to the guest's webview."fullscreen",+ // Loopback requests already succeed in Electron 44; permission-aware sign-in widgets query first.+ "loopback-network",// Deny local-fonts to untrusted previews: it exposes installed-font fingerprints and file bytes.// Deny notifications: pages could impersonate T3 Code; app notifications use the default session.]);