SHADE is young: 0.1.0-next.2 is a pre-release, and 0.1.0 isn't out yet.

SHADE
Developers

Capabilities

What a module may do is one declaration in its manifest, capabilities. Each entry names a capability, says whether the module needs it (required, the default) or works without it (optional), and gives its parameters. SHADE decides for each capability whether untrusted modules, trusted modules or both may have it; nothing a module writes changes that. The install consent and the Modules page are made from the declaration, in English and Dutch. The code is shade/kernel/modules/capabilities.ts (types, registry, checks) and shade/features/packages/server/capabilities.ts (states, the optional switch, the refusals).

export default defineModule({
  name: 'readme-cards',
  // …
  capabilities: {
    http: {},                                         // its routes
    network: { hosts: ['api.github.com'] },           // the hosts its code calls
    email: { need: 'optional' },                      // works without; an admin switches it on
    kv: { data: { purpose: 'readmeCards.keeps', personal: 'none' } }
  }
})

How it is checked

  • Strict. A capability or parameter SHADE doesn't know is refused, never ignored, at load and at install.
  • Against trust (validateCapabilities). A required capability the module's trust doesn't allow refuses the install in one sentence: "readme-cards requires the process capability, which needs a trusted module" (Dutch: "readme-cards vraagt de mogelijkheid process, die alleen een vertrouwde module krijgt"). An optional one is skipped, and the consent and the Modules page say why. What an untrusted module may have is one property of each capability's definition, untrusted (the Allowed for column below): false (trusted only), true (both), 'only' (untrusted only) or limits on its parameters and lines, such as no account routes or sockets.
  • An untrusted module's parts (untrustedPartProblems). The same property decides which manifest parts an untrusted module may have: a part is allowed when every capability it needs is one an untrusted module may have, within its limits ("server: account and token routes need a trusted module: GET /mine (account)", "schedules needs the schedule capability, which needs a trusted module"). Parts that need no capability stay open (who it is, its declaration, settings, health check and contributions); any other part, and one giving no lines, is refused.
  • Not set up. A capability this instance has not set up refuses the install when it is required ("readme-cards requires the accounts capability, which needs setting up first: switch accounts on"); optional, it is skipped.
  • Against the manifest. shade-module build refuses a manifest whose parts need a capability or a line it doesn't declare, naming it: "its manifest needs the http capability for GET /card (public): add capabilities.http". shade-module capabilities prints what the manifest needs. The build writes the declaration, resolved, into the package (capabilities, with each capability's need, parameters and lines), beside uses and bundled; the signature covers it.
  • At start. A package whose code needs more than its signed declaration is left out with the reason capabilities (unlistedCapabilities).
  • At run time. What a capability gives refuses a module that does not have it active (FORBIDDEN, counted for the module): the sandbox's bridge (needCapability), the email service and kv (requireCapability, which asks the module manager's activeCapabilityParams and gives the provider the parameters agreed to, such as kv's quotas), moduleFetch and the sandbox's egress (network, every refusal counted where it happens), a module's routes while its optional http is off (404), its schedules while its optional schedule is off (they skip) and its processes while its optional process is off (they don't run). A module asks with hasCapability(ctx, name).

The capabilities

CapabilityAllowed forParametersIts linesOptional?
httpboth (untrusted: public and session routes only)noneeach route: GET /card (public), GET /mine (account: tasks.read), POST /notes (session), GET /export (token); a public GET route's cache with it, GET /card.svg (public, cached 300 s, stale 60 s), so a changed cache asks again (cache headers)yes: its routes answer 404 while it is off
scheduletrustednoneeach schedule, with its interval or its cron expression and time zone: tidy (every 60 s), nightly-report (cron 0 3 * * * in Europe/Amsterdam), morning-digest (cron 30 8 * * mon-fri in the site's time zone); a changed interval, expression or time zone asks againyes
kvboth (untrusted: data.personal must be none)maxKeys (default 10 000, ≤ 100 000), maxValueBytes (default 256 KB, ≤ 1 MB), datanone; its limits in words; a higher quota asks again. See kvyes: every call is refused while it is off
cachetrusted (untrusted modules keep kv with ttlMs)maxKeys (default 1000, ≤ 10 000), maxValueBytes (default 64 KB, ≤ 1 MB)none; its limits in words; a higher quota asks again. See Cacheyes: every call is refused while it is off
queuetrustedqueues: { <name>: { retries ≤ 20, backoffMs, concurrency ≤ 10, timeoutMs? } }, data; the jobs in the manifest part jobseach queueyes
processtrustedprocesses: { <name>: { mode, memoryMb, stopTimeoutMs, maxRestarts } } (mode singleton or per-instance; memoryMb 64–256, default 64; stopTimeoutMs 1000–30000, default 10000; maxRestarts 1–50, default 10)each process of the manifest's processes; in words its mode, memory and restarts; a new process, more memory or restarts, or per-instance replacing singleton asks again. See Processesyes: its processes don't run while it is off
networkbothhosts (public names; *.example.com for trusted modules only), fromSettings (trusted only), streams (trusted only): each host with its protocol, wss://feed.example.com or https://events.example.com (*.example.com for the names under it)each host, from setting <name>, stream <host with its protocol>; a new one asks again. Trusted modules call out with moduleFetch, untrusted ones with the sandbox's fetch, under the same rules: https, declared hosts, public addresses only, redirects checked. See Network. A process holds the streams open with ctx.connections: at most 8 at once, 1 MB per message, closed after 2 minutes without data. See Processesyes: every call and every new stream is refused while it is off
filestrustedmaxBytes (at most 1 GB), data (Private files)noneyes
webhookstrustednone: it sends the events the module emits with an external view; where they go is the admins', on the Webhooks screeneach eventyes
channelstrustedkinds: { <kind>: '<what it is about>' }, 1 to 20 kinds: the messages it sends to the team's chats; which channels take a kind is the admins', on the Channels screeneach kind, with what it is aboutyes
subscribeboth (untrusted: its sandbox package's on, ids only, never an immediate-only event)none: the events it hears, from the manifest part oneach eventyes
realtimeboth (untrusted: updates only, no sockets)none: two channels, worded apart on the consent (Realtime): updates, the routes with realtime (an untrusted module's public GET routes too), and a trusted module's sockets, the manifest part realtime: { sockets } (two-way connections with visitors)each realtime route (GET /order-status), each socket (socket /rooms/:room (account))yes
notifybothmethods (by name, email so far; each person's choice decides which they get, Notify); an untrusted module to the instance's admins onlyeach notification methodyes
emailboth (untrusted: to the instance's admins only)nonenoneyes
accountstrustednonerole …, route …, table …, shared role … from its account roles, account routes, tables and shared rolesyes: its account routes answer 404 while it is skipped; it is skipped while accounts' accounts are off
contentboth (untrusted: reading only)nonewhat it serves under /api/v1/content/<plugin> and its site data keysonly while it serves nothing
rebuildtrustednonerebuildno
personalDatatrustednoneits personal data sourcesno
allowedSourcestrustednone<site|admin> <kind> <source>no
consenttrustednonecategory …, category … loads from …, category … sets … cookie …, or exempt: <reason>, from consentno
sharedCollectionstrustednoneits shared collectionsno
teamRolestrustednonerole …, role … always holds …, role … holds …, role … manages … from permissions.roles; a new line asks againno
adminPlacestrustednonewidgets …, panels …, settings …: for information, asks nothing againno
programstrustednames: the client programs it callseach client program; a new one asks again. It calls them with callProgram, through the host (Client programs). A module that needs a container next to SHADE (a headless browser, another runtime) names that program here; there is no capability that starts a containeryes: every call is refused while it is off
blocks, adminPagesuntrustednonefrom the sandbox packageno

uses is not a capability: it lists the core actions the module's own actor may perform, worded per action on the same consent.

What it keeps

kv, files and queue declare what they keep (data; webhooks keep nothing of the module's own: the delivery log is core's, with its own retention): a purpose (a key of the module's own texts), personal (none, account for rows tied to an account account, person for other personal data) and, unless nothing is about a person, a retention kind of the module's own retention part. Personal data of kind person needs a source in the module's personalData named after the capability. The consent shows it: "Keeps: …; nothing about a person".

Updates

An update asks again (asksForMore) for a new capability, a new line (route, host, schedule, role, ability, table), an optional capability made required, and what a capability's definition calls wider: more memory, a higher quota, per-instance replacing singleton, keeping data about a person where it kept none. Taking something away asks nothing, and neither do new admin places. Installing sends what the admin agreed to; a package install refuses unless it names every capability that asks again, and a sandbox package's typed name agrees to its required ones.

Optional capabilities

An optional capability is off after install unless the admin switched it on in the consent. On the Modules page each module's card lists its capabilities, active or skipped with the reason, with a switch for each optional one (admins, packages.manage): PUT /api/packages/capabilities/<name>/<capability> with { on }, audited packages.capability. Switching on asks nothing more: the declaration is the one agreed to. The states are in module_capabilities.

Packages built before

A package built before the declaration is refused: a server package needs its signed capabilities, uses and adminPlaces, and a sandbox package its capabilities declaration; build such a package again with shade-module build. A manifest with a services key is refused at load: declare the email or accounts capability instead.

Capability settings

A module is switched on only once the services behind its required capabilities are set up: email needs email, accounts needs accounts on (the Accounts screen). While a module that is on requires one, that service cannot be switched off. A required accounts while accounts are off is refused when switching on, in one sentence ("appointments requires the accounts capability, which needs setting up first: switch accounts on"; Dutch: "appointments vraagt de mogelijkheid accounts, die eerst ingesteld moet zijn: zet gebruikersaccounts aan") and shown as skipped. An optional accounts lets the module work without accounts (appointments' guest booking): it stays skipped while they are off, can be switched on once they are on, and the module's account routes answer 404 while it is skipped.