Keeps the server and the client agreed on what each role may do. The server enforces this table (api/lib/permissions.ts, api/routes/ws.ts) and the client reads the same one to hide what a role can't do (src/utils/auth/permissions.ts).

Functions

f
hasPermission(
role: Role,
permission: Permission
): boolean

Checks whether role grants permission. The server's can and the client's can both wrap it.

Type Aliases

T
Permission =
"dump:moderate"
| "comment:moderate"
| "playlist:moderate"
| "chat:moderate"
| "chat:everyone"
| "user:manage"
| "category:manage"
| "federation:manage"

An action only some roles may take. A new one goes in this union and in ALL_PERMISSIONS, which is what grants it to admins.

Variables

v
ROLE_PERMISSIONS: Record<Role, readonly Permission[]>

Read through hasPermission. Roles are fixed in code. An admin holds every permission, and a moderator the moderation ones and @everyone in the chat.