gitmyhub

node-mac-permissions

Objective-C++ ★ 0 updated 3y ago ⑂ fork

A native node module to manage system permissions on macOS.

A library that lets JavaScript developers check and request macOS system permissions (camera, microphone, contacts, files, etc.) without writing native Apple code.

Objective-C++Node.jsJavaScriptsetup: moderatecomplexity 2/5

If you're building a desktop app for macOS, you've likely hit the wall of system permissions. Modern macOS requires explicit user approval before an application can touch things like the camera, microphone, contacts, calendar, or files in the Desktop and Documents folders. This project gives developers a straightforward way to handle those permission requests from JavaScript code, rather than wrestling with Apple's native languages.

The library provides two main capabilities. First, you can check the current permission status for a specific resource—whether the user has already granted access, denied it, or hasn't been asked yet. Second, you can trigger the actual permission prompt that the user sees. For most resources like the microphone or camera, calling the appropriate function pops up the standard macOS dialog asking the user for permission. For a few things like Full Disk Access, where Apple doesn't allow apps to prompt directly, it opens the relevant System Preferences pane so the user can toggle the setting themselves.

This would be useful for anyone building an Electron app or a Node.js desktop tool on macOS. For example, if you're building a video conferencing app, you'd use this to request camera and microphone access before a call starts. If you're building a calendar sync tool, you'd use it to ask for Calendar access. It covers the full range of macOS privacy-protected resources: contacts, reminders, photos, screen capture, speech recognition, input monitoring, and protected folders.

One important detail: Apple requires apps to explain why they need each permission. Developers must include a text explanation in their app's configuration file for each resource they want to access—otherwise the permission request will crash rather than prompt. The library handles the prompting logic, but the usage descriptions are the developer's responsibility.

The library is written in Objective-C++ because it needs to call directly into macOS's native security and privacy APIs. It wraps those native calls into simple JavaScript functions that return promises, so developers can write async/await-style code without dealing with the underlying system complexity. Note that running it as a plain Node.js script requires a compatible terminal app; the standard macOS Terminal won't work for permission prompts.

Where it fits