tauri
tauri copied to clipboard
[feat] (macOS) (MAS) Security Scoped Resources via startAccessingSecurityScopedResource
Describe the problem
For macOS it is important to have the functions startAccessingSecurityScopedResource() and stopAccessingSecurityScopedResource(). This is required for apps from the Apple MacStore.
Without it, you can't save folder or file selections in MacOS. This means that when a new file is accessed, a file dialog must be displayed again.
Describe the solution you'd like
The app API has following function
app.startAccessingSecurityScopedResource(bookmarkData)
bookmarkData string - The base64 encoded security scoped bookmark data returned by the dialog.open or dialog.save methods
Returns Function - This function must be called once you have finished accessing the security scoped file. If you do not remember to stop accessing the bookmark, kernel resources will be leaked and your app will lose its ability to reach outside the sandbox completely, until your app is restarted.
// Start accessing the file.
const stopAccessingSecurityScopedResource = app.startAccessingSecurityScopedResource(data)
// You can now access the file outside of the sandbox 🎉
// Remember to stop accessing the file once you've finished with it.
stopAccessingSecurityScopedResource()
Alternatives considered
No response
Additional context
No response
This is a great finding! Thankyou for the insight.
We may want to consider this from an upstream perspective at TAO or WRY though...
@nothingismagick for this integration is also good to know if the app is running in the MacOS App Store (MAS). For that you can implement a boolean maybe in process like that:
process.mas // A boolean. For Mac App Store build, this property is true, for other builds it is undefined.
This is a big must-have for our project. It's also important that dialog.open
has an option to create and return security scoped bookmarks, like how it works for Electron's dialog.showOpenDialog
.
Thanks for the bump. @amrbashir what do you think?
Better Mac App Store support is definitely something we should focus ASAP.
This remains a critical must-have for any macOS App Store app that asks the user to select files or folders.
Any news on this? Are there any changes in Tauri v2?