From 28ba4c73b5beed572eb010be56841b5302566797 Mon Sep 17 00:00:00 2001 From: cpu Date: Fri, 4 Sep 2026 21:49:40 +0200 Subject: [PATCH] added camera permissions and patch file --- allow_camera.patch | 54 +++++++++++++++++++++++++++++++++++++++++++++ gsender-plugin.json | 1 + 2 files changed, 55 insertions(+) create mode 100644 allow_camera.patch diff --git a/allow_camera.patch b/allow_camera.patch new file mode 100644 index 0000000..33f2624 --- /dev/null +++ b/allow_camera.patch @@ -0,0 +1,54 @@ +diff --git a/src/app/src/features/Plugins/components/PluginPanel.tsx b/src/app/src/features/Plugins/components/PluginPanel.tsx +index 36ba576fe..109479304 100644 +--- a/src/app/src/features/Plugins/components/PluginPanel.tsx ++++ b/src/app/src/features/Plugins/components/PluginPanel.tsx +@@ -21,6 +21,9 @@ type PluginPanelProps = { + // bridge instead and have no iframe-level equivalent. + const IFRAME_ALLOW_MAP: Partial> = { + "local-fonts": "local-fonts", ++ // Camera / mic for getUserMedia in plugin iframes ++ camera: "camera", ++ microphone: "microphone", + }; + + const buildIframeAllow = (permissions: PluginRecord["permissions"]): string => +diff --git a/src/app/src/features/Plugins/types.ts b/src/app/src/features/Plugins/types.ts +index eecb2e44c..cd77d2681 100644 +--- a/src/app/src/features/Plugins/types.ts ++++ b/src/app/src/features/Plugins/types.ts +@@ -52,7 +52,9 @@ export type PluginPermissionsType = + | "visualizer:load" + | "workspace:read" + | "redux:read" +- | "local-fonts"; ++ | "local-fonts" ++ | "camera" ++ | "microphone"; + + export type PluginTopicsType = "workspace" | "redux" + +diff --git a/src/main.js b/src/main.js +index 19953f74a..1cf699f5b 100644 +--- a/src/main.js ++++ b/src/main.js +@@ -209,15 +209,17 @@ const main = () => { + // grant is enough — per-plugin scoping happens at the iframe's + // `allow="local-fonts"` attribute (see PluginPanel.tsx), which is only + // set for plugins that declare "local-fonts" in their manifest. ++ // Plugin iframes are same-origin with the app. ++ // Allow local-fonts (existing) and media (camera/mic for plugins). ++ const allowedPermissions = new Set(["local-fonts", "media"]); + session.defaultSession.setPermissionCheckHandler( +- (_webContents, permission) => permission === "local-fonts", ++ (_webContents, permission) => allowedPermissions.has(permission), + ); + session.defaultSession.setPermissionRequestHandler( + (_webContents, permission, callback) => { +- callback(permission === "local-fonts"); ++ callback(allowedPermissions.has(permission)); + }, + ); +- + windowManager = new WindowManager(); + // Create and show splash before server starts + const splashScreen = windowManager.createSplashScreen({ diff --git a/gsender-plugin.json b/gsender-plugin.json index 3780945..a11b497 100644 --- a/gsender-plugin.json +++ b/gsender-plugin.json @@ -14,6 +14,7 @@ } ] }, + "permissions": ["camera", "microphone"], "capabilities": { "requestTypes": [ "gcode:load:to:visualizer",