Plugins
Plugins are apps from third parties that an admin adds while the server runs, without a rebuild or restart. A plugin is either a WebAssembly component the server runs in a sandbox, or an external service in its own container that HyperCloud proxies to and signs each request for. Both are installed, enabled per group and removed like the built-in apps, and can add a web UI and entries to the apps' menus.
Writing one is covered in Writing a plugin.
Setting up the server
Plugins come with the plugins feature of hc-server (part of --features all and of the Docker image). Configuration is from the environment:
| Variable | |
|---|---|
HC_PLUGIN_KEYS | The Ed25519 public keys (base64, comma-separated) whose signatures this server accepts. A package signed by any other key is refused. |
HC_PLUGINS_DIR | Where packages and plugin databases live. Default: plugins/ beside the database. Back it up with the database. |
HC_PLUGINS_ALLOW_UNSIGNED | 1 also installs unsigned packages. For developing a plugin, never on a server other people use. |
HC_PLUGINS | 0 switches plugins off: no routes, nothing loaded. |
Installing, granting and enabling
Under Settings → Apps → Plugins, or with hc-server apps, which calls the same code:
hc-server apps inspect links.hcapp # what it is and what it asks for
hc-server apps install links.hcapp --grant db # or --grant all, or a URL
hc-server apps enable links --group Team # only for that group
hc-server apps grant links db,kv # change what it may do
hc-server apps disable links
hc-server apps remove links --yes # deletes its dataA package is signed apart from it: links.hcapp.sig beside the file, or <URL>.sig beside a URL. Settings → Apps shows a package's name, author, signer and the permissions it asks for before anything is installed. It also pins the package it showed, by its SHA-256, so a different file at the same URL is refused; an install from a URL without that hash is refused too. Signatures are checked strictly (Ed25519 verify_strict).
A new plugin starts switched off. Enable it for everyone or for some groups once you have read what it asks for. Like an app offered to some groups, it then answers only their members: its API, its web UI in the shell, and its entries in the apps' menus. Everyone else gets 404.
Installing a newer version of an installed plugin upgrades it in place. Its data stays, its new migrations run, and the grants you give with the upgrade replace the old ones.
Remove deletes the plugin's package, its database, its settings and its group choices. A database snapshot carries every installed plugin's package and database beside the main one; restore them together (see Storage and backups). An account's .hypercalendar export, and so its daily backup, carries what each plugin it uses keeps for it, for the plugins that export it . Importing the file on a server without the plugin skips that part and says so.
Changes made with hc-server apps while the server runs reach it within 15 seconds. Changes made under Settings → Apps take effect at once.
Permissions
| Permission | Lets the plugin |
|---|---|
db | Keep data in a SQLite database of its own (<HC_PLUGINS_DIR>/<id>/data.sqlite). |
kv | Keep small settings of its own. |
events | Hear what happens in other apps (which account, what changed), and announce its own changes. |
groups | See which groups the account it serves is in. |
http:<host> | Send requests to that one host. Private and loopback addresses are refused whatever the grant. |
public | Answer people who are not signed in, at its public address. |
calendar | See the role the account it serves has on a calendar event (owner, editor, viewer). |
push | Send notifications to the devices of accounts it is offered to. |
Without a grant, the call fails (denied), and the plugin decides what to do about it. The admin can grant less than a plugin asks for.
What a plugin cannot do
Read or change other apps' data, or another plugin's. Its SQL runs in its own file, and ATTACH, DETACH, PRAGMA, VACUUM, transactions of its own and extensions are refused.
See the caller's cookies, session or credentials. A plugin gets the account's id, display name, admin flag and, with
groups, its groups.Run longer, compute more or take more memory than its limits:
Limit Default At most Fuel (about one WebAssembly instruction each) 1,000,000,000 per call 10,000,000,000 Memory 64 MiB 256 MiB Time, host calls included 10 s 30 s Calls running at once 16 per plugin A manifest may ask for other limits within the maximum. A call past a limit is stopped and answers 503. Each call runs in a fresh instance, so nothing a stopped call left behind reaches the next one.
Run script in the instance's origin. Its API answers carry
Content-Security-Policy: default-src 'none'; sandbox, so even an HTML answer runs without script, cookies or storage. Its web UI runs in a sandboxed frame with an origin of its own and no network.