Web Writable Files API: Simplifying Local File Access
developers.google.com
developers.google.com
For this, the browser must make all the traditional OS interfaces available. It has interfaces for accelerated 2D and 3D graphics, audio, USB, process management (workers), networking (including peer-to-peer), and a number of persistence mechanisms. But before it takes over completely, it has to interoperate with the host OS a bit, too, by exposing the filesystem.
(A decade more, and maybe the vision of Inferno [1] will sort of kind of be implemented.)
[1]: https://en.wikipedia.org/wiki/Inferno_(operating_system)
The entire point of ChromeOS is aggressive sandboxing, not breaking out of the sandbox.
Yes the user needs to install it, and then it is free reign for $HOME.
So it isn't Download location only.
I worry the next talented generation of developers is being alienated from the desktop, and as a result my computing experience will degrade as Chrome's piecemeal attempts to reinvent the OS leave me with an inferior selection of browser-based toys that are awkward and clunky compared to their native counterparts.
I grant the browser fixes a couple things my OS got wrong: installation/uninstallation and updates. But it feels like it does everything else worse.
It doesn't matter that it's clunky and bad, CS people love working with hard to use systems, it just matters that it works.
google.com doesn't try to search my local drive. faceboook.com doesn't offer to share my local photos. Their usage of "browser as an OS" is extremely limited.
I worry about the other problem: the browser becomes so ubiquitous the OS disappears, along with any platform conventions and application interop.
I'm excited about things like WASM that will allow browser-based experiences to close the gap more and more with native apps. The web infrastructure is extremely powerful and has a fairly low barrier to entry so lots of people throw crappy experiences up, granted, but it's generally a good thing to have the resources so accessible.
WASM solves certain problems like arithmetic being slow. This doesn't fix the web's problems; it merely enables a new class of bad apps to be written on the web.
The best streaming video services are not web based. Thank goodness Netflix and Hulu have native iPad apps to spare me their websites.
As not everyone even has a network connection, I find this kind of viewpoint outright dangerous because it leaves out hundreds of millions of people. Streaming video, in particular, seems to choke if you don't if you don't have the absolutely best connection.
And it goes without saying that, for your own safety, none of these platforms will run code that hasn't been delivered by a trusted and approved corporate appstore.
The future of computing is very grim.
I think the main driving forces on this are:
1. It's easier for computer illiterate people to use web services, since they don't have to go through an installation process.
2. It's easier for developers to support their users because they don't have to worry about their users' computer environments, which is largely out of their control.
3. It's also harder/impossible for their users to pirate their software, since they it never runs in their machines.
I think the biggest reason (and the one harder to fix) is the piracy one.
I think your second point is actually the dominant one, but you're not wrong about this either. In some sense, we get the computing landscape that we (collectively) asked for.
I also get to pick native development over Web whenever possible.
However many of the gigs happen to be Web based, thus here we are.
Nah, replacing the desktop OS has been the goal of browser-makers since the founding of Netscape nearly 25 years ago.
There was a bit of a lull in progress in the mid-2000s, after the fall of Netscape Inc, until the rise of the mobile app threat you mention.
It feels like 5 years later this will come to bite us in the ass as another way of exploiting access to our computer and data.
What if websites start requiring specific files to exist before allowing access?
Like session cookies, or SSL certificates?
This is certainly going to be immediately abused for encrypted storage of persistent cookies and tracking identifiers.
- If my site generates cat pics, I'll put identifiers in the metadata fields of the image format.
- If my site generates markdown, I'll put identifiers in an alternate data stream (Windows) or encoded in the whitespace.
Since the files exist outside of the sandbox, they'll be outside of the scope of privacy features like clearing the cache or cookies, and outside of the reach of adblocker extensions.
Also, why would they be outside the reach of adblockers? WebExtensions can already intercept and manipulate the use of certain APIs by sites, the same can easily apply here.
This isn't just unrestricted filesystem access. The site would need to request file system permission first, _and_ get the user to select the file in a file picker.
In short, that's not a serious concern.
Suppose an app which does not really needs file permission to work, like Facebook, but asks anyhow. If you opt out, you cannot access the app.
That pattern does not need to exist.
I wonder about ulterior motives too.
But in a world where even local apps increasingly try to make me store files in the cloud, I can only consider this as a move in the right direction.
All web apps can offer today is either (1) re-download the file (as the article mentions) or (2) save to GDrive/iCloud /OneDrive.
Working with local files is a win for user freedom.
Anyway, more interoperability with the native environment is a good thing. Right now browsers are an alien implant in every operating system that can't communicate with anything else.
Congrats, you're two clicks away from having your entire machine bricked & held for ransom.
I'm glad they are taking a security-focused approach from the beginning of the design phase. I expect no less from Google. However, I worry that the approach of putting the end user in charge of approving/denying access to resources puts an unreasonably high burden on users. Many people simply click to dismiss dialogs without even reading them, let alone thinking carefully about what they are agreeing to. This is asking for trouble. I would rather see a sandbox approach that restricts the locations and types of files that can be read and written.
Which is exactly what is in the security proposal linked at the bottom of the article.
Limiting access to certain directories: https://github.com/WICG/writable-files/blob/master/EXPLAINER...
Limiting write access to certain file types: https://github.com/WICG/writable-files/blob/master/EXPLAINER...
FWIW: On the surface, this appears to contradict the following quote from tfa:
> ...ensures that the user is always in full control over what files and directories a website has access to.
A sandbox is not full control.
The problem with that is there is no hard distinction between a data file and an executable. Essentially every kind of file, when opened, causes code to be executed, usually significantly influenced by the content of the file.
This API is moving the security perimeter back, making it the responsibility of every local app that may open a file touched by this API — essentially every file it might open — to ensure unexpected/malicious content can’t do anything bad. That’s not going to happen. Instead, users are going to have to be “sure” not to open files via this API using sites they don’t trust. That’s pretty weak compared to what we’re generally used to today (which doesn’t seem strong enough already).
On the other hand, the last example (FileSystemDirectoryHandle.getSystemDirectory) might devolve into the sort of "user presses yes before even reading" permissions system that is so troublesome today. But I feel like the kinds of directories exposed through such a mechanism would likely be fairly innocent (the proposed example being the user's set of installed fonts.)
[1] https://github.com/WICG/writable-files/blob/master/EXPLAINER...
I realized PWA's potential was on Desktop and not really on mobile.
I came to realize that PWA missed really two things to change Desktop for good :
- Sandboxed FileSystem API
- Standard Operating System Support
Most apps like Slack, Discord or Twitch can barely justify their usage of Electron... beside the possibility to have those apps in a separate OS Window they don't make an extensive usage of Node.JS like VSCode which spawn "child_process".
They just seat there , in a separate OS Window and they can launch at OS startup too..but in order to have those two features you must completely give up on security and give access to almost everything on your computer...
PWA really bring a new dimension to Desktop App, if Windows and MacOS brought native support to PWA ( using Edge and Safari without the need for Chrome ) this would change the industry for ever.
1. If when you ran a .net application all .net applications shared the same parent process that'd be a significant problem.
2. Many electron clients control their versions because there are bugs, quirks, removal of features, or other changes in chromium versions. Discord last time I checked is still on 56.
3. PWA's do not have native access. Discord requires that to spawn IPC communications with game overalys, which are another native process.
PWA's are meant more for mobile, but even there you are of course, limited.
Firefox and Safari would change the world if they actually cared about doing that. They're about market share, not about the technology anymore. Firefox was in a position of making it possible to simply ship the firefox binary, and you could add your js and css changes, effectively having the full firefox browser as your 'app'. Which means it could be triggered to auto-update like normal firefox, but still have your UI and act as a browser.
Firefox abandoned that route and instead is focusing upon whatever Chrome impliments, like Custom Components. Safari also doesn't care about anything but linux and mac.
https://a9t9.com/kantu/x#fileaccess
The advantage of an explicit app installation is that users/companies that want to avoid such file access (and the many other things that native apps can do) can simply avoid/block app installations.
In the last two decades users have learned that "as long as it's inside the web browser, it's safe". If web apps themselves become too powerful this security approach breaks down.
However your equivalence in this case is a completely false one, because file system API's are not going to just be 'removed' as that would break literally every application that uses standard fopen. over 20 years of standard is a pretty good boat to stand on unless there's signals that say otherwise.
But that's not how I understood your comment above, which was to not rely on any browser features for native access, which IMO isn't good advice.
Sure, you shouldn't go out and build a business around the "Web Writable Files API" tomorrow, but if it gets standardized, and if it gets implemented in a few major browser engines (which is a requirement for standardization in this context), then yeah go ahead and start to rely on it more.
But this has very little to do with these new proposed APIs, and more with general software development.
I think a lot of what you'd store in Appdata in a "real" application will remain in browser storage or pulled from the server. A single file or folder with app settings, drafts, etc. should suffice. And even settings are probably better stored server side for user convenience so they can easily switch devices.
2. Native will be much faster
3. Native will allow for features from the kernel that browsers do not impliment.
4. You cannot plan for how people will use such a wide feature as the Filesystem. Saying 'X and Y should fit' requires a significant amount of honest research and testing, with a very good reason as to why the change is necessary.
Electron ones is another matter, I already have enough browsers installed.
But if you stick with the HTTP listener, as someone else mentioned, while you're installing your app, you can edit the user's host file to add a domain name to the loopback adapter, and then you can also create a one-off SSL cert for the computer.
In a lot of use cases, all you really want is a simple way to read and save a small blob of data.
But to achieve this today you would have to do one of:
- Save it in local storage, but lose their data if they clear it or use another device.
- Build out a REST API backend, but need to also build auth and account management.
- Use a backend as service such as firebase, but still costing you to store the data.
- Use a filepicker api to save to the user's cloud storage. For example Google Drive has a file picker: https://developers.google.com/picker/. But not everyone use the same cloud drive (icloud, dropbox, onedrive, etc).
With local file access, it's more or less the same as the filepicker api solution except they are free to save it to a non-syncing file location too if they choose.
Also it's too opaque so the typical user won't understand that clearing their browser data means losing their work. They have already been trained by other sites to believe that their data should be persisted to the site's servers and that they should see their data even if they open the site on a different device.
Forcing them to choose where to save the data should hopefully clear up where their data lives. If they need multidevice they can sync their filesystem folders with one of many third party cloud storage of their choosing (such as dropbox).
I think it's a perfect fit for webapps like as photopea.com (photoshop clone in the browser) that came up on HN the other day.
...so what would be difference to today, where a user can "upload" files to the browser's local storage, and then the web app can work with the file(s)?
I get it that you avoid to have to "re-download" the file, but that seems to be a small benefit for the risks we get.
It's an offline-first app for managing and annotating PDF and web documents.
The idea was that with Electron I can have direct access to the filesystem and be fully integrated into the browser as well.
For the most part it works. The users can easily browse the local filesystem and also access some operating specific features.
But let me tell you -it's rather schizophrenic to use something like Electron. It just doesn't know whether it's a browser or a web server and then there's the issue of dealing with process communication within Electron. Chrome is its own process and node the main process and you have to communicate via message passing - not super fun.
Now we have PWAs and they're far from idea but it might be that an API like this, along with PWAs, and maybe a bit more functionality could replace Electron for building these types of hybrid apps.
On Plan 9 and Inferno everything is indeed a file.
I've written some extensions for personal use and so far it's been a great trade-off.
I can understand syncing Google Drive and saving stuff there. Or Resilio Sync or any number of other solutions such as Dat.
You Already have filepickers to open and read files. And you can save files as I indicated - via syncing to a service, where you have control of what goes where and it’s still there if you lose the device. And it can be encrypted where the local devices have keys for syncing.
The only new use case I can think of that this enables is overwriting existing files - which is dangerous!