tweak: add puter.perms.requestPermission

It calls requestPermission on the UI module. The method on the UI model
needs to still exist because the UI module is tightly-coupled with IPC.
A refactor of the IPC mechanism on the puter.js side could solve this.
This commit is contained in:
KernelDeimos
2025-12-04 19:37:08 -05:00
committed by Eric Dubé
parent 237dc2ef9a
commit 2db3331729

View File

@@ -112,6 +112,19 @@ export default class Perms {
return await this.req_('/group/list');
}
/**
* Request a specific permission string to be granted. Note that some
* permission strings are not supported and will be denied silently.
* @param {string} permission - permission string to request
* @returns {boolean} true if permission was granted, false otherwise
*/
async requestPermission (permission) {
// note: we cannot move this fully from "puter.ui" without
// a significant refactor because the UI module contains
// all of the IPC communication logic.
return await this.puter.ui.requestPermission({ permission });
};
// #region shorthand functions
/**
* Request to see a user's email. If the user has already granted this