From 77d7ad61f39641b79a60a99da2f939cbc1d8fe39 Mon Sep 17 00:00:00 2001 From: Simon Menke Date: Mon, 4 Mar 2019 17:04:19 +0100 Subject: Allow inspection and revocation of permissions (#1875) --- website/manual.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'website') diff --git a/website/manual.md b/website/manual.md index 9081637a1..43b79d003 100644 --- a/website/manual.md +++ b/website/manual.md @@ -286,6 +286,35 @@ It's worth noting that like the `cat.ts` example, the `copy()` function here also does not make unnecessary memory copies. It receives a packet from the kernel and sends back, without further complexity. +### Inspecting and revoking permissions + +Sometimes a program may want to revoke previously granted permissions. When a +program, at a later stage, needs those permissions, a new prompt will be +presented to the user. + +```ts +const { permissions, revokePermission, open, remove } = Deno; + +(async () => { + // lookup a permission + if (!permissions().write) { + throw new Error("need write permission"); + } + + const log = await open("request.log", "a+"); + + // revoke some permissions + revokePermission("read"); + revokePermission("write"); + + // use the log file + await log.write(encoder.encode("hello\n")); + + // this will prompt for the write permission or fail. + await remove("request.log"); +})(); +``` + ### File server This one serves a local directory in HTTP. -- cgit v1.2.3