Skip to content

Commit 2e28718

Browse files
committed
feat: allow query for a11y access status
1 parent 9d84d28 commit 2e28718

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ This native Node.js module allows you to manage an app's access to:
1616
* Photos
1717
* Camera
1818
* Microphone
19+
* Accessibility
1920

2021
## API
2122

2223
## `permissions.getAuthStatus(type)`
2324

24-
* `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'.
25+
* `type` String - The type of system component to which you are requesting access. Can be one of 'contacts', 'full-disk-access', 'photos', 'reminders', 'camera', 'accessibility', 'microphone', or 'calendar'.
2526

2627
Returns `String` - Can be one of 'not determined', 'denied', 'authorized', or 'restricted'.
2728

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ function getAuthStatus(type) {
77
'reminders',
88
'full-disk-access',
99
'camera',
10-
'microphone'
10+
'microphone',
11+
'accessibility'
1112
]
1213

1314
if (!validTypes.includes(type)) {
1415
throw new TypeError(`${type} is not a valid type`)
1516
}
1617

1718
return permissions.getAuthStatus.call(this, type)
18-
}
19+
}
1920

2021
function askForMediaAccess(type, callback) {
2122
if (!['microphone', 'camera'].includes(type)) {

permissions.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
auth_status = MediaAuthStatus("microphone");
126126
} else if (type == "camera") {
127127
auth_status = MediaAuthStatus("camera");
128+
} else if (type == "accessibility") {
129+
auth_status = AXIsProcessTrusted() ? "authorized" : "denied";
128130
}
129131

130132
return Napi::Value::From(env, auth_status);

test/module.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ describe('node-mac-permissions', () => {
1919
'reminders',
2020
'full-disk-access',
2121
'camera',
22-
'microphone'
22+
'microphone',
23+
'accessibility'
2324
]
2425

2526
const statuses = ['not determined', 'denied', 'authorized', 'restricted']

0 commit comments

Comments
 (0)