node-mac-permissions
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -6,2 +6,3 @@ // Type definitions for node-mac-permissions | ||
export function askForContactsAccess(): Promise<'authorized' | 'denied'> | ||
export function askForFoldersAccess(): Promise<'authorized' | 'denied'> | ||
export function askForFullDiskAccess(): undefined | ||
@@ -8,0 +9,0 @@ export function askForRemindersAccess(): Promise<'authorized' | 'denied'> |
@@ -13,5 +13,7 @@ const permissions = require('bindings')('permissions.node') | ||
'microphone', | ||
'music-library', | ||
'accessibility', | ||
'location', | ||
'screen', | ||
'bluetooth', | ||
] | ||
@@ -44,2 +46,3 @@ | ||
askForMicrophoneAccess: permissions.askForMicrophoneAccess, | ||
askForMusicLibraryAccess: permissions.askForMusicLibraryAccess, | ||
askForPhotosAccess: permissions.askForPhotosAccess, | ||
@@ -46,0 +49,0 @@ askForSpeechRecognitionAccess: permissions.askForSpeechRecognitionAccess, |
{ | ||
"name": "node-mac-permissions", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A native node module to manage system permissions on macOS", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"clean": "node-gyp clean", | ||
"lint": "prettier --check index.js", | ||
"lint": "clang-format --dry-run -Werror permissions.mm && prettier --check index.js", | ||
"format": "clang-format -i permissions.mm && prettier --write index.js", | ||
@@ -34,11 +34,27 @@ "test": "./node_modules/.bin/mocha --reporter spec" | ||
"bindings": "^1.5.0", | ||
"node-addon-api": "^2.0.0" | ||
"node-addon-api": "^3.0.2" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"clang-format": "^1.3.0", | ||
"mocha": "^6.2.2", | ||
"node-gyp": "^6.0.1", | ||
"prettier": "^2.0.4" | ||
} | ||
"clang-format": "^1.4.0", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.5.3", | ||
"mocha": "^8.2.1", | ||
"node-gyp": "^7.1.2", | ||
"prettier": "^2.2.1" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier --write" | ||
], | ||
"*.mm": [ | ||
"clang-format -i" | ||
] | ||
}, | ||
"os": ["darwin"] | ||
} |
@@ -25,2 +25,9 @@ [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/) | ||
If you need to ask for permissions, your app must be allowed to ask for permission : | ||
* For a Nodejs script/app, you can use a terminal app such as [iTerm2](https://iterm2.com/) (it won't work on macOS Terminal.app) | ||
* For an Electron app (or equivalent), you'll have to update `Info.plist` to include a usage description key like `NSMicrophoneUsageDescription` for microphone permission. | ||
If you're using macOS 12.3 or newer, you'll need to ensure you have Python installed on your system, as macOS does not bundle it anymore. | ||
## API | ||
@@ -30,3 +37,3 @@ | ||
* `type` String - The type of system component to which you are requesting access. Can be one of `accessibility`, `calendar`, `camera`, `contacts`, `full-disk-access`, `speech-recognition`, `location`, `microphone`, `photos`, `screen`, or `reminders`. | ||
* `type` String - The type of system component to which you are requesting access. Can be one of `accessibility`, `bluetooth`, `calendar`, `camera`, `contacts`, `full-disk-access`, `speech-recognition`, `location`, `microphone`, `photos`, `screen`, or `reminders`. | ||
@@ -49,2 +56,4 @@ Returns `String` - Can be one of `not determined`, `denied`, `authorized`, or `restricted`. | ||
* Access to `speech-recognition` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version. | ||
* Access to `bluetooth` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version. | ||
* Access to `music-library` will always return a status of `authorized` prior to macOS 11.0, as the underlying API was not introduced until that version. | ||
@@ -54,12 +63,15 @@ Example: | ||
const types = [ | ||
'accessibility', | ||
'bluetooth', | ||
'calendar', | ||
'camera', | ||
'contacts', | ||
'calendar', | ||
'reminders', | ||
'full-disk-access', | ||
'camera', | ||
'location', | ||
'microphone', | ||
'music-library', | ||
'photos', | ||
'speech-recognition', | ||
'microphone', | ||
'accessibility', | ||
'location' | ||
'screen', | ||
'speech-recognition' | ||
] | ||
@@ -253,2 +265,30 @@ | ||
## `permissions.askForMusicLibraryAccess()` | ||
Returns `Promise<String>` - Whether or not the request succeeded or failed; can be `authorized` or `denied`. | ||
* `not determined` - The Music Library access authorization will prompt the user to authorize or deny. The Promise is resolved after the user selection with either `authorized` or `denied`. | ||
* `denied` - The `Security & Privacy` System Preferences window is opened with the Music Library privacy key highlighted. On open of the `Security & Privacy` window, the Promise is resolved as `denied`. | ||
* `restricted` - The Promise is resolved as `restricted`. | ||
Your app must provide an explanation for its use of the music library using the `NSAppleMusicUsageDescription` `Info.plist` key. | ||
``` | ||
<key>NSAppleMusicUsageDescription</key> | ||
<string>Your reason for wanting to access the user’s media library.</string> | ||
``` | ||
**Note:** | ||
- `status` will be resolved back as `authorized` prior to macOS 11.0, as the underlying API was not introduced until that version. | ||
Example: | ||
```js | ||
const { askForMusicLibraryAccess } = require('node-mac-permissions') | ||
askForMusicLibraryAccess().then(status => { | ||
console.log(`Access to Apple Music Library is ${status}`) | ||
}) | ||
``` | ||
## `permissions.askForPhotosAccess()` | ||
@@ -255,0 +295,0 @@ |
const { expect } = require('chai') | ||
const { | ||
askForFoldersAccess, | ||
getAuthStatus, | ||
} = require('../index') | ||
const { askForFoldersAccess, getAuthStatus } = require('../index') | ||
@@ -25,5 +22,6 @@ describe('node-mac-permissions', () => { | ||
'microphone', | ||
'music-library', | ||
'accessibility', | ||
'location', | ||
'screen' | ||
'screen', | ||
] | ||
@@ -30,0 +28,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51006
110
406
7
+ Addednode-addon-api@3.2.1(transitive)
- Removednode-addon-api@2.0.2(transitive)
Updatednode-addon-api@^3.0.2