Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

573 B
Raw Blame
import { FileSystemError, UserError } from './error';

export async function verifyHandlePermission(
  handle: FileSystemFileHandle,
  mode: FileSystemPermissionMode
) {
  const permission = await handle.queryPermission({ mode });
  if (permission === 'denied') {
    throw new FileSystemError(
      `Permission to ${mode} is denied to ${handle.name}`
    );
  }
  if (permission === 'prompt') {
    if ((await handle.requestPermission({ mode })) !== 'granted') {
      throw new UserError(`User denied ${mode} permission to ${handle.name}`);
    }
  }
  return handle;
}