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

Add status and request functions for Files and Folders access

Open codebytere opened this issue 4 years ago • 7 comments

This one might be a little trickier - the request function will also likely just default to prefpane opening. Only implemented on 10.15 and beyond.

codebytere avatar Apr 28 '20 04:04 codebytere

@codebytere - when can we expect this feature.. and why it has to default to prefane opening?

harshitsilly avatar Jul 01 '20 06:07 harshitsilly

@harshitsilly the UI for it is somewhat unwieldy and also not documented/discussed by Apple anywhere, so i need to do some detective work.

The reason it will more than likely default to preference pane opening is that Apple doesn't document their permissions functionality very well nor do they provide good API interfaces for it. So in this case, there is no API that exists to trigger this, which means that the best we can do in the short term is use System Preferences as a proxy.

As a comparable example, you can look at the logic for Full Disk Access: https://github.com/codebytere/node-mac-permissions/blob/master/permissions.mm#L128-L151

It's a bit of a hack since Apple doesn't let us directly query for that information programmatically.

codebytere avatar Jul 15 '20 03:07 codebytere

@codebytere i am finding it difficult how CloudTabs.db will help in full-disk access as I am getting an empty table for it. And right now the function call askForFullDiskAccess() default to prefane opening as mentioned in readme.

For our project we need files and folder status. So we were thinking that we can have a dummy function that will query on each folder location for /desktop,/documents,/downloads, removable drives path and from there we can derive the status of each location for that respective application. Disadvantage of this approach - if the application not uses files and folders access than it will prompt for it..

harshitsilly avatar Jul 17 '20 06:07 harshitsilly

@harshitsilly partially implemented in: https://github.com/codebytere/node-mac-permissions/commit/4516160d308003e579717a43f62b5cd455650c0e. I'm not sure if it's possible to get status without first issuing a request, and i'm still trying to find a way to get status for the volumes folder. Does this help for now though? I'll publish to npm soon.

codebytere avatar Aug 30 '20 17:08 codebytere

@codebytere yeah i have checked, this will work 👍 .. for volumes folder can we list all the drives mounted and then you can request on any removable volume path if exist(https://github.com/balena-io-modules/drivelist. check for system:false) and if there is no removable volume than the status can be unresolved.

harshitsilly avatar Sep 01 '20 19:09 harshitsilly

@codebytere : Any estimate when permissions.askForFoldersAccess(folder) would be merged to master and be available?

SinghManmohan avatar Sep 25 '20 19:09 SinghManmohan

@SinghManmohan thanks for reminding me 🙃 it's in master and i just published [email protected] containing permissions.askForFoldersAccess(folder)

codebytere avatar Sep 26 '20 01:09 codebytere