Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/cli/js/permissions.ts>Permissions

A modern runtime for JavaScript and TypeScript.
Go to Latest
class Permissions
import { Permissions } from "https://deno.land/x/deno@v0.28.0/cli/js/permissions.ts";

Methods

query(desc: PermissionDescriptor): Promise<PermissionStatus>

Queries the permission. const status = await Deno.permissions.query({ name: "read", path: "/etc" }); if (status.state === "granted") { file = await Deno.readFile("/etc/passwd"); }

request(desc: PermissionDescriptor): Promise<PermissionStatus>

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."); }

revoke(desc: PermissionDescriptor): Promise<PermissionStatus>

Revokes the permission. const status = await Deno.permissions.revoke({ name: "run" }); assert(status.state !== "granted")