Skip to content

Commit 65e6d6c

Browse files
committed
fix: give camera and recorder write permission to Desktop
1 parent 01725ff commit 65e6d6c

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/gui/src/UI/UIDesktop.js

+41-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,48 @@ async function UIDesktop(options){
5151
channel.onmessage = function(e){
5252
}
5353

54-
// channel.postMessage({'hello': 'world'});
5554

55+
// Give Camera and Recorder write permissions to Desktop
56+
puter.kv.get('has_set_default_app_user_permissions').then(async (user_permissions) => {
57+
if(!user_permissions){
58+
// Camera
59+
try{
60+
await fetch( window.api_origin + "/auth/grant-user-app", {
61+
"headers": {
62+
"Content-Type": "application/json",
63+
"Authorization": "Bearer " + window.auth_token,
64+
},
65+
"body": JSON.stringify({
66+
app_uid: 'app-5584fbf7-ed69-41fc-99cd-85da21b1ef51',
67+
permission: `fs:${html_encode(window.desktop_path)}:write`
68+
}),
69+
"method": "POST",
70+
});
71+
}catch(err){
72+
console.error(err);
73+
}
74+
75+
// Recorder
76+
try{
77+
await fetch( window.api_origin + "/auth/grant-user-app", {
78+
"headers": {
79+
"Content-Type": "application/json",
80+
"Authorization": "Bearer " + window.auth_token,
81+
},
82+
"body": JSON.stringify({
83+
app_uid: 'app-7bdca1a4-6373-4c98-ad97-03ff2d608ca1',
84+
permission: `fs:${html_encode(window.desktop_path)}:write`
85+
}),
86+
"method": "POST",
87+
});
88+
}catch(err){
89+
console.error(err);
90+
}
91+
92+
// Set flag to true
93+
puter.kv.set('has_set_default_app_user_permissions', true);
94+
}
95+
})
5696
// connect socket.
5797
window.socket = io(window.gui_origin + '/', {
5898
auth: {

src/gui/src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ window.gui = async function(options){
6262
// DEV: Load the initgui.js file if we are in development mode
6363
if(!window.gui_env || window.gui_env === "dev"){
6464
await window.loadScript('/sdk/puter.dev.js');
65-
// await window.loadScript(`${options.asset_dir}/initgui.js`, {isModule: true});
6665
}
6766

6867
if (window.gui_env === 'dev2') {

0 commit comments

Comments
 (0)