variable Deno.permissions
Deno's permission management API.
It is a singleton instance of the [`Permissions`](../././~/Deno.Permissions) object and is
based on the web platform
[Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API),
though some proposed parts of the API which are useful in a server side
runtime context were removed or abandoned in the web platform specification
which is why it was chosen to locate it in the [`Deno`](../././~/Deno) namespace
instead.
By default, if the `stdin`/`stdout` is TTY for the Deno CLI (meaning it can
send and receive text), then the CLI will prompt the user to grant
permission when an un-granted permission is requested. This behavior can
be changed by using the `--no-prompt` command at startup. When prompting
the CLI will request the narrowest permission possible, potentially making
it annoying to the user. The permissions APIs allow the code author to
request a wider set of permissions at one time in order to provide a better
user experience.
Requesting already granted permissions will not prompt the user and will
return that the permission was granted.
### Querying
```ts
const status = await Deno.permissions.query({ name: "read", path: "/etc" });
console.log(status.state);
```
```ts
const status = Deno.permissions.querySync({ name: "read", path: "/etc" });
console.log(status.state);
```
### Revoking
```ts
import { assert } from "jsr:@std/assert";
const status = await Deno.permissions.revoke({ name: "run" });
assert(status.state !== "granted")
```
```ts
import { assert } from "jsr:@std/assert";
const status = Deno.permissions.revokeSync({ name: "run" });
assert(status.state !== "granted")
```
### Requesting
```ts
const status = await Deno.permissions.request({ name: "env" });
if (status.state === "granted") {
console.log("'env' permission is granted.");
} else {
console.log("'env' permission is denied.");
}
```
```ts
const status = Deno.permissions.requestSync({ name: "env" });
if (status.state === "granted") {
console.log("'env' permission is granted.");
} else {
console.log("'env' permission is denied.");
}
```