# Permissions

> What each permission allows, who grants it, and how the network permissions name their hosts.

Page: https://songstress.app/docs/develop/permissions/

Nothing is allowed until a person allows it. Your manifest asks for each permission with a `reason`, 10 to 200
characters, in words the person granting it will read:

```json title="songstress.json"
"permissions": {
  "network": { "reason": "Send your plays to Tunelog.", "hosts": ["api.tunelog.example"] },
  "listening.read": { "reason": "Know what you play, to send it to your profile." }
}
```

## Every permission [#every-permission]

| Permission | Allows | Unlocks | Granted by |
| --- | --- | --- | --- |
| `network` | Requests to the public hosts it names, over http or https. The address a name resolves to is checked when connecting and on every redirect | `net.fetch` | The admin |
| `network.local` | Requests to targets on the user's own network, from server code only | `net.fetch` to those targets, in the server entry | The admin, who confirms twice |
| `library.read` | Reading the catalogue and hearing when it changes | `library.*`; `onPlaylistChange`, `onLibraryChange`, `onScanComplete` | The admin |
| `users.read` | Members' ids and display names, nothing else | `users.*` | The admin |
| `listening.read` | One member's plays, what they're playing now and what they like | `onPlay`, `onScrobble`, `onFavorite`; the client hooks; `player.getState`, `queue.get`; a `scrobble` provider | That member, for themselves, once the admin allows the extension |
| `player.control` | Starting, pausing, skipping and seeking the player of the device the code runs on, and adding to its queue | `player.play`, `pause`, `next`, `previous`, `seek`; `queue.add` | The admin |
| `providers` | Answering beside Songstress's own sources. Each source joins switched off or last | `providers.*.register` | The admin |
| `routes` | Serving the extension's own signed-in routes | `routes.register` | The admin |
| `jobs` | Scheduled and background work | `jobs.*` | The admin |
| `storage` | Keeping the extension's own data, under a quota | `storage.*` | Listed at install, no question asked |
| `secrets` | Keeping the extension's own credentials, sealed | `secrets.*`; `signIn.register` | Listed at install, no question asked |

The permission each single call needs is in [The host API](/docs/develop/api/#every-call-and-its-permission).

## Network hosts [#network-hosts]

`network` takes `hosts`: 1 to 20 public hosts, each by name (`api.example.com`) or as every host under a domain
(`*.example.com`), with an optional port. Never an address, a scheme, a path, a bare `*` or a whole top-level domain.
A server may also refuse a wildcard over a domain where anyone can have a name (`*.github.io`, `*.co.uk`): name the
domain that is yours.

`network.local` may take `targets`: up to 20 on the user's own network, each an IPv4 address (`192.168.1.20`), a
block (`192.168.1.0/24`) or a host name (`nas.local`), with an optional port. An address or a block must lie inside
`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16` or `127.0.0.0/8` (`NETWORK_LOCAL_NOT_PRIVATE`). Leave `targets`
out, and the admin names them when granting.

`net.fetch` from client code reaches the public hosts of `network` and nowhere else, never a `network.local` target.

## The rules [#the-rules]

- A permission your manifest needs and doesn't ask for is an error (`PERMISSION_REQUIRED`), and so is one it asks for
  and could never use (`PERMISSION_UNUSED`).
- A call the manifest didn't ask for, or that nobody granted, fails with the code `permission-denied`.
- When an update asks for a permission the installed version didn't have, the update waits until an admin accepts
  it. The version installed keeps running meanwhile.
- A hook's event carries the id of the member it concerns whether or not the extension may read their name.
  `users.read` turns an id into a name.
