Skip to Content
sdeck docs

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.

PermissionNeeded for
networkfetch, WebSocket, node:http, node:net, Bun.serve…
filesystemFiles outside the plugin's own folders; SQLite
processStarting a program: Bun.spawn, child_process, opening apps and links
shellCommand lines: Bun.$, exec, spawning cmd, powershell or sh
inputPressing keys, typing, media keys
clipboardReading and changing the clipboard
audioVolumes and audio devices
environmentEnvironment variables, other than everyday ones such as PATH
variablesThe user's variables
stateOther plugins' live values
actionsRunning other plugins' actions
overlayDrawing 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.