Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/deno/cli/js/lib.deno.unstable.d.ts>Deno.Permissions

A modern runtime for JavaScript and TypeScript.
Go to Latest
class Deno.Permissions
import { Deno } from "https://deno.land/x/deno@v1.0.0/cli/js/lib.deno.unstable.d.ts";
const { Permissions } = Deno;

Methods

Resolves to the current status of a permission.

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

Requests the permission, and resolves to the state of 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.");
  }

Revokes a permission, and resolves to the state of the permission.

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