Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-mac-permissions

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mac-permissions - npm Package Compare versions

Comparing version 2.1.4 to 2.2.0

11

index.js

@@ -25,5 +25,16 @@ const permissions = require('bindings')('permissions.node')

function askForFoldersAccess(folder) {
const validFolders = ['desktop', 'documents', 'downloads']
if (!validFolders.includes(folder)) {
throw new TypeError(`${folder} is not a valid protected folder`)
}
return permissions.askForFoldersAccess.call(this, folder)
}
module.exports = {
askForCalendarAccess: permissions.askForCalendarAccess,
askForContactsAccess: permissions.askForContactsAccess,
askForFoldersAccess,
askForFullDiskAccess: permissions.askForFullDiskAccess,

@@ -30,0 +41,0 @@ askForRemindersAccess: permissions.askForRemindersAccess,

2

package.json
{
"name": "node-mac-permissions",
"version": "2.1.4",
"version": "2.2.0",
"description": "A native node module to manage system permissions on macOS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,3 @@ [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)

* Speech Recognition
* Protected Folders

@@ -144,2 +145,33 @@ ## API

## `permissions.askForFoldersAccess(folder)`
* `type` String - The folder to which you are requesting access. Can be one of `desktop`, `documents`, or `downloads`.
Returns `Promise<String>` - Whether or not the request succeeded or failed; can be `authorized` or `denied`.
Example:
```js
const { askForFoldersAccess } = require('node-mac-permissions')
askForFoldersAccess('desktop').then(status => {
console.log(`Access to Desktop is ${status}`)
})
```
```
<key>NSDesktopFolderUsageDescription</key>
<string>Your reason for wanting to access the Desktop folder</string>
```
```
<key>NSDocumentsFolderUsageDescription</key>
<string>Your reason for wanting to access the Documents folder</string>
```
```
<key>NSDownloadsFolderUsageDescription</key>
<string>Your reason for wanting to access the Downloads folder</string>
```
## `permissions.askForFullDiskAccess()`

@@ -326,2 +358,11 @@

$ tccutil reset AddressBook
# Reset Desktop folder access
$ tccutil reset SystemPolicyDesktopFolder <bundleID>
# Reset Documents folder access
$ tccutil reset SystemPolicyDocumentsFolder <bundleID>
# Reset Downloads folder access
$ tccutil reset SystemPolicyDownloadsFolder <bundleID>
```
const { expect } = require('chai')
const {
const {
askForFoldersAccess,
getAuthStatus,

@@ -36,2 +37,10 @@ } = require('../index')

})
describe('askForFoldersAccess()', () => {
it('should throw on invalid types', () => {
expect(() => {
askForFoldersAccess('bad-type')
}).to.throw(/bad-type is not a valid protected folder/)
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc