Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
node-mac-permissions
Advanced tools
$ npm i node-mac-permissions
This native Node.js module allows you to manage an app's access to:
permissions.getAuthStatus(type)
type
String - The type of system component to which you are requesting access. Can be one of 'contacts', 'full-disk-access', 'photos', 'reminders', 'camera', 'microphone', or 'calendar'.Returns String
- Can be one of 'not determined', 'denied', 'authorized', or 'restricted'.
Checks the authorization status of the application to access type
on macOS.
Return Value Descriptions:
type
data.type
data. The user cannot change this application’s status, possibly due to active restrictions such as parental controls being in place.type
data for the application.type
data.Notes:
permissions.askForContactsAccess(callback)
callback
Function
error
String | null - An error in performing the request, if one occurred.status
String - Whether or not the request succeeded or failed; can be 'authorized' or 'denied'.Your app’s Info.plist
file must provide a value for the NSContactsUsageDescription
key that explains to the user why your app is requesting Contacts access.
<key>NSContactsUsageDescription</key>
<string>Your reason for wanting to access the Contact store</string>
Note: status
will be called back as 'authorized' prior to macOS 10.11, as access to contacts was unilaterally allowed until that version.
Example:
const { askForContactsAccess } = require('node-mac-permissions')
askForContactsAccess((err, status) => {
if (err) throw new Error(err)
console.log(`Access to Contacts is ${status}`)
})
permissions.askForCalendarAccess(callback)
callback
Function
error
String | null - An error in performing the request, if one occurred.status
String - Whether or not the request succeeded or failed; can be 'authorized' or 'denied'.Example:
const { askForCalendarAccess } = require('node-mac-permissions')
askForCalendarAccess((err, status) => {
if (err) throw new Error(err)
console.log(`Access to Calendar is ${status}`)
})
permissions.askForRemindersAccess(callback)
callback
Function
error
String | null - An error in performing the request, if one occurred.status
String - Whether or not the request succeeded or failed; can be 'authorized' or 'denied'.Example:
const { askForRemindersAccess } = require('node-mac-permissions')
askForRemindersAccess((err, status) => {
if (err) throw new Error(err)
console.log(`Access to Reminders is ${status}`)
})
permissions.askForFullDiskAccess()
There is no API for programmatically requesting Full Disk Access on macOS at this time, and so calling this method will trigger opening of System Preferences at the Full Disk pane of Security and Privacy.
Example:
const { askForFullDiskAccess } = require('node-mac-permissions')
askForFullDiskAccess()
permissions.askForMediaAccess(type, callback)
type
String - The type of media to which you are requesting access. Can be 'microphone' or 'camera'.
callback
Function
error
String | null - An error in performing the request, if one occurred.status
String - Whether or not the request succeeded or failed; can be 'authorized' or 'denied'.Your app must provide an explanation for its use of capture devices using the NSCameraUsageDescription
or NSMicrophoneUsageDescription
Info.plist
keys; Calling this method or attempting to start a capture session without a usage description raises an exception.
<key>`NSCameraUsageDescription</key>
<string>Your reason for wanting to access the Camera</string>
<key>`NSMicrophoneUsageDescription</key>
<string>Your reason for wanting to access the Microphone</string>
Note: status
will be called back as 'authorized' prior to macOS 10.14 High Sierra, as access to the camera and microphone was unilaterally allowed until that version.
Example:
const { askForMediaAccess } = require('node-mac-permissions')
for (const type of ['microphone', 'camera']) {
askForMediaAccess(type, (err, status) => {
if (err) throw new Error(err)
console.log(`Access to media type ${type} is ${status}`)
})
}
FAQs
A native node module to manage system permissions on macOS
The npm package node-mac-permissions receives a total of 949 weekly downloads. As such, node-mac-permissions popularity was classified as not popular.
We found that node-mac-permissions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.