Permissions
Say what your plugin needs, and which part needs it.
Say what the plugin needs. Its user allows or refuses each one, and it gets nothing else:
const plugin = createPlugin({
id: "sdeck-plugin-weather",
// …
permissions: [Permissions.network],
});Permissions has all of them, so your editor completes them; their names as text work too.
| Permission | Needed for |
|---|---|
network | fetch, WebSocket, node:http, node:net, Bun.serve… |
filesystem | Files outside the plugin's own folders; SQLite |
process | Starting a program: Bun.spawn, child_process, opening apps and links |
shell | Command lines: Bun.$, exec, spawning cmd, powershell or sh |
input | Pressing keys, typing, media keys |
clipboard | Reading and changing the clipboard |
audio | Volumes and audio devices |
environment | Environment variables, other than everyday ones such as PATH |
variables | The user's variables |
state | Other plugins' live values |
actions | Running other plugins' actions |
overlay | Drawing over the user's buttons |
native | .node addons, bun:ffi, workers: code sdeck cannot limit, so it allows anything |
Reading the plugin's own package and using its own data folder (context.dataDir) needs nothing.
Ask for little, and say which part needs it. Actions, state, triggers and commands need all of the plugin's permissions unless they list their own. Then refusing one turns off only those parts:
const copy = plugin.action({
id: "copy",
name: "Copy the forecast",
permissions: [Permissions.network, Permissions.clipboard],
// …
});
const umbrella = plugin.action({
id: "umbrella",
name: "Umbrella counter",
permissions: [] /* … */,
});When something is refused, it throws a PermissionError (its code is "EACCES") that tells
the user what to allow. Let it through rather than hiding it. fetch rejects, everything else
throws at the call.
Some things are never available: eval and new Function, process.exit, and changing the
globals other plugins see. If a dependency needs one of them, look for another.
Until its user has decided, a plugin that asks for something does not run. Your own gets the same question: choose Permissions in its menu.