mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
Add permissions.request (#3296)
This commit is contained in:
parent
b3baab6d14
commit
31115067cd
5 changed files with 393 additions and 64 deletions
|
@ -68,6 +68,19 @@ export class Permissions {
|
|||
const { state } = sendSync(dispatch.OP_REVOKE_PERMISSION, desc);
|
||||
return new PermissionStatus(state);
|
||||
}
|
||||
|
||||
/** Requests the permission.
|
||||
* const status = await Deno.permissions.request({ name: "env" });
|
||||
* if (status.state === "granted") {
|
||||
* console.log(Deno.homeDir());
|
||||
* } else {
|
||||
* console.log("'env' permission is denied.");
|
||||
* }
|
||||
*/
|
||||
async request(desc: PermissionDescriptor): Promise<PermissionStatus> {
|
||||
const { state } = sendSync(dispatch.OP_REQUEST_PERMISSION, desc);
|
||||
return new PermissionStatus(state);
|
||||
}
|
||||
}
|
||||
|
||||
export const permissions = new Permissions();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue