1// Who may do what. One permission table for both doors: the NIP-86 methods2// the console calls (each names its action in manage.ts) and the NIP-293// moderation events clients send. The owner may do everything; a moderator4// keeps the peace and nothing more.56export type Role = "owner" | "moderator" | "member";78export type Action =9 | "read" // stats, policy and the lists the console renders10 | "members" // add, edit and remove plain members11 | "ban"12 | "deleteEvent"13 | "invites"14 | "reports"15 | "rules" // access rules, kinds, retention16 | "identity" // name, description, icon17 | "storage"18 | "config" // export and import19 | "jobs" // pulls, backfills, rebroadcasts20 | "fork" // lease a new name and copy this relay into it21 | "transfer"22 | "deleteRelay";2324const MODERATOR = new Set<Action>(["read", "members", "ban", "deleteEvent", "invites", "reports"]);2526export function can(role: Role | null | undefined, action: Action): boolean {27 if (role === "owner") return true;28 if (role === "moderator") return MODERATOR.has(action);29 return false;30}3132// The roles a relay advertises in its NIP-29 kind 39003.33export const ROLES: { role: Role; about: string }[] = [34 { role: "owner", about: "everything: rules, identity, people, storage, fuel" },35 { role: "moderator", about: "people, bans, deletions, invites, reports" },36];