import type { KbxPermissionContext } from '@kbx/contracts'

export function createPermissionContext(granted: Iterable<string>): KbxPermissionContext {
  const permissions = new Set(granted)
  return {
    has: permission => permissions.has(permission),
    hasAny: required => required.some(x => permissions.has(x)),
    hasAll: required => required.every(x => permissions.has(x)),
  }
}
