node-mac-permissions
node-mac-permissions copied to clipboard
Add status and request functions for Files and Folders access
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 - when can we expect this feature.. and why it has to default to prefane opening?
@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 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 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 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.
@codebytere : Any estimate when permissions.askForFoldersAccess(folder)
would be merged to master and be available?
@SinghManmohan thanks for reminding me 🙃 it's in master
and i just published [email protected]
containing permissions.askForFoldersAccess(folder)