From bdc11ffcf8f4d1538b40316bb351c1bc613a9ab1 Mon Sep 17 00:00:00 2001 From: jelveh Date: Sat, 25 Jul 2026 21:02:45 -0700 Subject: [PATCH] Restrict the permission popup flow to third-party websites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit requestPermission's new web path ran in every environment with a window, including env='gui' — so a permission_denied driver retry inside the Puter GUI would open a popup to the Puter origin from the desktop itself and try to grant the permission to a phantom app for Puter's own origin. Resolve false everywhere except env='web', the previous behavior. --- src/puter-js/src/modules/UI.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/puter-js/src/modules/UI.js b/src/puter-js/src/modules/UI.js index 8b2c9eccb..ac327ceee 100644 --- a/src/puter-js/src/modules/UI.js +++ b/src/puter-js/src/modules/UI.js @@ -1119,8 +1119,15 @@ class UI extends EventListener { return result.granted === true; } - // Web environment: open the GUI's permission popup. Not available in - // workers (no window to open a popup from). + // The popup flow is for third-party websites only. In every other + // environment it either can't work (workers and node have no window + // to open a popup from) or makes no sense — inside the Puter GUI + // itself ('gui') the popup would prompt the user to grant this + // permission to Puter's own origin. Those callers keep the previous + // behavior of resolving false. + if ( this.env !== 'web' ) { + return false; + } if ( ! globalThis.open || ! globalThis.document ) { return false; }