node-mac-permissions
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -10,2 +10,4 @@ const permissions = require('bindings')('permissions.node') | ||
'camera', | ||
'photos', | ||
'speech-recognition', | ||
'microphone', | ||
@@ -31,2 +33,4 @@ 'accessibility', | ||
askForMicrophoneAccess: permissions.askForMicrophoneAccess, | ||
askForPhotosAccess: permissions.askForPhotosAccess, | ||
askForSpeechRecognitionAccess: permissions.askForSpeechRecognitionAccess, | ||
askForScreenCaptureAccess: permissions.askForScreenCaptureAccess, | ||
@@ -33,0 +37,0 @@ askForAccessibilityAccess: permissions.askForAccessibilityAccess, |
{ | ||
"name": "node-mac-permissions", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "A native node module to manage system permissions on macOS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
105
README.md
@@ -18,5 +18,7 @@ [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/) | ||
* Microphone | ||
* Photos | ||
* Accessibility | ||
* Location | ||
* Screen Capture | ||
* Speech Recognition | ||
@@ -27,3 +29,3 @@ ## API | ||
* `type` String - The type of system component to which you are requesting access. Can be one of `accessibility`, `calendar`, `camera`, `contacts`, `full-disk-access`, `location`, `microphone`, `screen`, or `reminders`. | ||
* `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`. | ||
@@ -41,5 +43,7 @@ Returns `String` - Can be one of `not determined`, `denied`, `authorized`, or `restricted`. | ||
**Notes:** | ||
* Access to `contacts` will always return a status of `authorized` prior to macOS 10.11, as access to contacts was unilaterally allowed until that version. | ||
* Access to `camera` and `microphone` will always return a status of `authorized` prior to macOS 10.14, as access to contacts was unilaterally allowed until that version. | ||
* Access to `screen` will always return a status of `authorized` prior to macOS 10.15, as access to screen capture was unilaterally allowed until that version. | ||
* Access to `contacts` will always return a status of `authorized` prior to macOS 10.11, as the underlying API was not introduced until that version. | ||
* Access to `camera` and `microphone` will always return a status of `authorized` prior to macOS 10.14, as the underlying API was not introduced until that version. | ||
* Access to `screen` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version. | ||
* Access to `photos` will always return a status of `authorized` prior to macOS 10.13, as the underlying API was not introduced until that version. | ||
* 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. | ||
@@ -54,2 +58,4 @@ Example: | ||
'camera', | ||
'photos', | ||
'speech-recognition', | ||
'microphone', | ||
@@ -60,3 +66,2 @@ 'accessibility', | ||
const statuses = ['not determined', 'denied', 'authorized', 'restricted'] | ||
for (const type of types) { | ||
@@ -79,3 +84,3 @@ const status = getAuthStatus(type) | ||
**Note:** `status` will be resolved back as `authorized` prior to macOS 10.11, as access to contacts was unilaterally allowed until that version. | ||
**Note:** `status` will be resolved back as `authorized` prior to macOS 10.11, as the underlying API was not introduced until that version. | ||
@@ -104,2 +109,29 @@ Example: | ||
## `permissions.askForSpeechRecognitionAccess()` | ||
Returns `Promise<String>` - Whether or not the request succeeded or failed; can be `authorized` or `denied`. | ||
Checks the authorization status for Speech Recognition access. If the status check returns: | ||
* `not determined` - The Speech Recognition 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 Speech Recognition privacy key highlighted. On open of the `Security & Privacy` window, the Promise is resolved as `denied`. | ||
Your app must provide an explanation for its use of Speech Recognition using the `NSSpeechRecognitionUsageDescription` `Info.plist` key; | ||
``` | ||
<key>NSSpeechRecognitionUsageDescription</key> | ||
<string>Your reason for wanting to access Speech Recognition</string> | ||
``` | ||
Example: | ||
```js | ||
const { askForSpeechRecognitionAccess } = require('node-mac-permissions') | ||
askForSpeechRecognitionAccess().then(status => { | ||
console.log(`Access to Speech Recognition is ${status}`) | ||
}) | ||
``` | ||
**Note:** `status` will be resolved back as `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version. | ||
## `permissions.askForRemindersAccess()` | ||
@@ -149,3 +181,3 @@ | ||
- `status` will be resolved back as `authorized` prior to macOS 10.14 High Sierra, as access to the camera and microphone was unilaterally allowed until that version. | ||
- `status` will be resolved back as `authorized` prior to macOS 10.14, as the underlying API was not introduced until that version. | ||
@@ -155,5 +187,7 @@ Example: | ||
```js | ||
const { askForCameraAccess } = require("node-mac-permissions"); | ||
const { askForCameraAccess } = require('node-mac-permissions') | ||
const status = await askForCameraAccess(); | ||
askForCameraAccess().then(status => { | ||
console.log(`Access to Camera is ${status}`) | ||
}) | ||
``` | ||
@@ -168,3 +202,3 @@ | ||
* `not determined` - The microphone access authorization will prompt the user to authorize or deny. The Promise is resolved after the user selection with either `authorized` or `denied`. | ||
* `denied` -T he `Security & Privacy` System Preferences window is opened with the Microphone privacy key highlighted. On open of the `Security & Privacy` window, the Promise is resolved as `denied`. | ||
* `denied` - The `Security & Privacy` System Preferences window is opened with the Microphone privacy key highlighted. On open of the `Security & Privacy` window, the Promise is resolved as `denied`. | ||
* `restricted` - The Promise is resolved as `restricted`. | ||
@@ -181,3 +215,3 @@ | ||
- `status` will be resolved back as `authorized` prior to macOS 10.14 High Sierra, as access to the camera and microphone was unilaterally allowed until that version. | ||
- `status` will be resolved back as `authorized` prior to macOS 10.14, as the underlying API was not introduced until that version. | ||
@@ -187,7 +221,40 @@ Example: | ||
```js | ||
const { askForMicrophoneAccess } = require("node-mac-permissions"); | ||
const { askForMicrophoneAccess } = require('node-mac-permissions') | ||
const status = await askForMicrophoneAccess(); | ||
askForMicrophoneAccess().then(status => { | ||
console.log(`Access to Microphone is ${status}`) | ||
}) | ||
``` | ||
## `permissions.askForPhotosAccess()` | ||
Returns `Promise<String>` - Current permission status; can be `authorized`, `denied`, or `restricted`. | ||
Checks the authorization status for Photos access. If the status check returns: | ||
* `not determined` - The Photos 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 Photos 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 photo library using the `NSPhotoLibraryUsageDescription` `Info.plist` key. | ||
``` | ||
<key>NSPhotoLibraryUsageDescription</key> | ||
<string>Your reason for wanting to access Photos</string> | ||
``` | ||
**Note:** | ||
- `status` will be resolved back as `authorized` prior to macOS 10.13, as the underlying API was not introduced until that version. | ||
Example: | ||
```js | ||
const { askForPhotosAccess } = require('node-mac-permissions') | ||
askForPhotosAccess().then(status => { | ||
console.log(`Access to Photos is ${status}`) | ||
}) | ||
``` | ||
## `permissions.askForScreenCaptureAccess()` | ||
@@ -257,2 +324,14 @@ | ||
$ tccutil reset Microphone | ||
# Reset Photos access permissions | ||
$ tccutil reset Photos | ||
# Reset Screen Capture access permissions | ||
$ tccutil reset ScreenCapture | ||
# Reset Full Disk Access permissions | ||
$ tccutil reset SystemPolicyAllFiles | ||
# Reset Contacts permissions | ||
$ tccutil reset AddressBook | ||
``` |
@@ -21,2 +21,4 @@ const { expect } = require('chai') | ||
'camera', | ||
'photos', | ||
'speech-recognition', | ||
'microphone', | ||
@@ -23,0 +25,0 @@ 'accessibility', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41403
11
69
325