@mario.andreschak/mcp-browser 3.44.0 → 3.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/resources.js CHANGED
@@ -113,6 +113,9 @@ body{background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,-apple-system
113
113
  var note = document.getElementById("note");
114
114
  var fbUrl = document.getElementById("fbUrl");
115
115
  var theme = "light", pollTimer = 0, usingFallback = false;
116
+ // null = host did not report its sandbox CSP grant (unknown policy);
117
+ // [] = host reported a grant that excludes the gateway (denied).
118
+ var grantedFrameDomains = null, viewReady = false, readyTimer = 0;
116
119
 
117
120
  function post(m){ parentWin.postMessage(m, "*"); }
118
121
  function rpc(method, params){
@@ -150,14 +153,34 @@ body{background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,-apple-system
150
153
  }
151
154
 
152
155
  /* ---------- live view ---------- */
156
+ // Whether the host's effective frame-src grant covers the gateway origin.
157
+ // Grants may be exact origins, the loopback port-wildcard form
158
+ // (http://127.0.0.1:*), or the allow-all escape hatch.
159
+ function frameGrantCovers(origin){
160
+ if (grantedFrameDomains === null) return true; /* unknown policy: probe, the ready watchdog still guards */
161
+ var o = String(origin || "").toLowerCase();
162
+ for (var i = 0; i < grantedFrameDomains.length; i++){
163
+ var d = String(grantedFrameDomains[i] || "").toLowerCase();
164
+ if (d === "*" || d === o) return true;
165
+ if (d.slice(-2) === ":*" && o.indexOf(d.slice(0, -1)) === 0) return true;
166
+ }
167
+ return false;
168
+ }
153
169
  function mountLiveView(){
154
170
  frame.src = GATEWAY.origin + "/view?s=" + encodeURIComponent(sessionId) + "&t=" + encodeURIComponent(GATEWAY.token);
171
+ // A CSP-blocked or unreachable iframe fires neither load nor error, so a
172
+ // silent live view must degrade to screenshots on its own.
173
+ clearTimeout(readyTimer);
174
+ readyTimer = setTimeout(function(){
175
+ if (!viewReady) useFallback("The live view is not reachable from this browser; showing periodic screenshots.");
176
+ }, 8000);
155
177
  }
156
178
 
157
179
  /* ---------- screenshot fallback ---------- */
158
180
  function useFallback(reason){
159
181
  if (usingFallback) return;
160
182
  usingFallback = true;
183
+ clearTimeout(readyTimer);
161
184
  frame.classList.add("hide");
162
185
  fallback.classList.add("show");
163
186
  setNote(reason || "Live streaming is unavailable; showing periodic screenshots.", true);
@@ -214,8 +237,9 @@ body{background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,-apple-system
214
237
  var state = payload(result);
215
238
  sessionId = state.sessionId || "";
216
239
  if (!sessionId) throw new Error("The browser session did not report an id.");
217
- if (GATEWAY.origin && GATEWAY.token) mountLiveView();
218
- else useFallback("The live stream gateway is disabled, so this view falls back to screenshots.");
240
+ if (!GATEWAY.origin || !GATEWAY.token) useFallback("The live stream gateway is disabled, so this view falls back to screenshots.");
241
+ else if (!frameGrantCovers(GATEWAY.origin)) useFallback("This deployment cannot frame the local live-view gateway; showing periodic screenshots.");
242
+ else mountLiveView();
219
243
  } catch (e) {
220
244
  starting = false;
221
245
  useFallback(errorText(e));
@@ -246,7 +270,7 @@ body{background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,-apple-system
246
270
  var m = event.data;
247
271
  if (m && m.source === "flujo-browser-view"){
248
272
  if (event.source !== frame.contentWindow) return;
249
- if (m.type === "ready") toView({ type: "theme", theme: theme });
273
+ if (m.type === "ready"){ viewReady = true; clearTimeout(readyTimer); toView({ type: "theme", theme: theme }); }
250
274
  else void runViewCommand(m);
251
275
  return;
252
276
  }
@@ -283,6 +307,8 @@ body{background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,-apple-system
283
307
  appCapabilities: { availableDisplayModes: ["inline", "fullscreen", "pip"] },
284
308
  protocolVersion: "${MCP_APPS_PROTOCOL_VERSION}"
285
309
  }).then(function(result){
310
+ var sandboxCaps = result && result.capabilities && result.capabilities.sandbox;
311
+ if (sandboxCaps) grantedFrameDomains = (sandboxCaps.csp && sandboxCaps.csp.frameDomains) || [];
286
312
  theme = (result && result.hostContext && result.hostContext.theme) === "dark" ? "dark" : "light";
287
313
  document.documentElement.setAttribute("data-theme", theme);
288
314
  notify("ui/notifications/initialized", {});
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAA+B,MAAM,cAAc,CAAC;AAEzG,MAAM,yBAAyB,GAAG,YAAY,CAAC;AAC/C,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAEnD,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,SAAS,EAAE,CAAC;gBACV,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,aAAa;gBACvB,WAAW,EAAE,mEAAmE;aACjF,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW;IACnD,IAAI,GAAG,KAAK,eAAe;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,8EAA8E;IAC9E,4EAA4E;IAC5E,8EAA8E;IAC9E,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAClD,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,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AW,EAAE,EAAE;qBAChB;iBACF;aACwC,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgC;IACnE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE;QAC7B,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE;KAC5B,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsCS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwMA,yBAAyB;;;;;;;;;;;;;;;QAezC,CAAC;AACT,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mario.andreschak/mcp-browser",
3
- "version": "3.44.0",
3
+ "version": "3.45.0",
4
4
  "description": "FLUJO's isolated Patchright browser MCP server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",