Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
935 B ยท 28 lines
TypeScript
at incident-api
1234567891011121314151617181920212223242526272829import type { Scope } from "@openstatus/db/src/schema";
/** * Pure scope matcher. Returns true when `held` (the scopes carried by * the actor) satisfies `required` (the scope the verb demands). * * Hierarchy: * * '*' โ 'write' โ 'read' * * Forward-compatible: when per-resource scopes land * (`'monitor.write' โ 'monitor.read'`, etc.) extend this matcher in * place. The actor-aware wrapper (`require-scope.ts`) is unaffected. * * Fail-closed: any unrecognized string in `held` matches nothing. A * corrupt row, manual SQL edit, or future migration bug results in * "no permission," not a permissive default. */export function matchesScope(held: readonly Scope[], required: Scope): boolean { if (held.length === 0) return false;
for (const h of held) { if (h === "*") return true; if (h === required) return true; if (required === "read" && h === "write") return true; } return false;}