import { guard } from "https://deno.land/x/permissionGuard@2.4.0/mod.ts";
Provides a set of defences for your application.
This is done by verifying:
- No unnecessary permissions have been set at runtime.
- Requested / required permissions have been set at runtime.
Optional configuration parameters for the guard include:
granted
- a list of Deno permission names or descriptors that should be permitted by the guard. Default:[]
.exitOnMissing
- a flag to determine whether the guard should stop the process when permissions listed in thegranted
array have not been granted. Default:false
.exitOnExtra
- a flag to determine whether the guard should stop the process when permissions not listed in thegranted
array have been granted. Default:true
.revoke
- flag to determine whether the guard should revoke top-level permissions not listed in thegranted
array.log
- a flag to determine the guard should log any warnings or errors to the console. Default:false
.
If the guard determines to stop the process, the exit code will
be 1
, i.e. Deno.exit(1)
.
As the Deno Permissions API is currently tagged as "unstable", this
method will currently only perform the above defenses if the process
is started with the --unstable
flag. Once the API becomes stable,
this flag will no longer be required. If the flag is not provided,
guard will simply return as a no-op, so it is safe to use the guard
in applications that won't be passed the --unstable
flag.
Parameters
optional
options: GuardOptions = [UNSUPPORTED]