node-mac-permissions icon indicating copy to clipboard operation
node-mac-permissions copied to clipboard

Proposal to support Automation permissions

Open ArtemAvramenko opened this issue 2 years ago • 2 comments
trafficstars

The library does a great job with almost all Privacy settings.

But it lacks support for Automation. It would be great to be able to check permission like this:

permissions.getAuthStatus('automation', 'com.apple.SystemEvents')

And ask for automation permission like this:

permissions.askForAutomation('com.apple.SystemEvents')

To check this, some simple automation command from Standard Suite can be tried to run, such as count:

tell app id 'some.your.application' to get count

And if the command returns an error, request permission via a call like this:

open x-apple.systempreferences:com.apple.preference.security?Privacy_Automation

ArtemAvramenko avatar Sep 22 '23 20:09 ArtemAvramenko

@ArtemAvramenko i'm not sure what the underlying API capabilities are here but i'm happy to look into it!

codebytere avatar Sep 27 '23 13:09 codebytere

@codebytere I think that Automation is only accessible by executing AppleScript via a system command, for example:

osascript -e 'tell app id "com.apple.Safari" to get count'

If permissions are given, the exit code will be zero. A non-zero value means that there are no permissions.

If this approach will be used, you should probably also escape the AppId to avoid script injection.

ArtemAvramenko avatar Oct 12 '23 14:10 ArtemAvramenko