Skip to content

Commit bbaf3be

Browse files
committed
feat: implement FDA request
1 parent 1d2e106 commit bbaf3be

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,11 @@ askForRemindersAccess((err, status) => {
7878
console.log(`Access to Reminders is ${status}`)
7979
})
8080
```
81+
82+
## `permissions.askForFullDiskAccess()`
83+
84+
```js
85+
const { askForFullAccess } = require('node-mac-permissions')
86+
87+
askForRemindersAccess()
88+
```

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ module.exports = {
1313
getAuthStatus,
1414
askForContactsAccess: permissions.askForContactsAccess,
1515
askForCalendarAccess: permissions.askForCalendarAccess,
16-
askForRemindersAccess: permissions.askForRemindersAccess
16+
askForRemindersAccess: permissions.askForRemindersAccess,
17+
askForFullDiskAccess: permissions.askForFullDiskAccess
1718
}

permissions.mm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ void AskForRemindersAccess(const Napi::CallbackInfo &info) {
151151
}];
152152
}
153153

154+
// Request Full Disk Access.
155+
void AskForFullDiskAccess(const Napi::CallbackInfo &info) {
156+
NSWorkspace* workspace = [[NSWorkspace alloc] init];
157+
NSString* pref_string = @"x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles";
158+
[workspace openURL:[NSURL URLWithString:pref_string]];
159+
}
160+
154161
// Initializes all functions exposed to JS
155162
Napi::Object Init(Napi::Env env, Napi::Object exports) {
156163
exports.Set(
@@ -165,6 +172,9 @@ void AskForRemindersAccess(const Napi::CallbackInfo &info) {
165172
exports.Set(
166173
Napi::String::New(env, "askForRemindersAccess"), Napi::Function::New(env, AskForRemindersAccess)
167174
);
175+
exports.Set(
176+
Napi::String::New(env, "askForFullDiskAccess"), Napi::Function::New(env, AskForFullDiskAccess)
177+
);
168178

169179
return exports;
170180
}

0 commit comments

Comments
 (0)