Bug 259637 - Unable to use OPFS in web extension because of changing origin
Summary: Unable to use OPFS in web extension because of changing origin
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Extensions (show other bugs)
Version: Safari 16
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-07-30 14:41 PDT by OlegWock
Modified: 2023-08-06 14:41 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description OlegWock 2023-07-30 14:41:01 PDT
I'm porting my Web Extension to Safari. This extension has a feature where user can upload images which later can be used in the extension. In chrome/firefox I currently use OPFS (https://webkit.org/blog/12257/the-file-system-access-api-with-origin-private-file-system/) to store icons. But because Safari changes extension's origin on every browser restart, extension can't utilize OPFS, since it will lost access to it after browser restart (which makes it unusable for persisting data).

This is a bit related to this bug https://bugs.webkit.org/show_bug.cgi?id=244330
In a way that it's caused by same thing

I assume origin is changed on every run to resist fingerprinting, so making it stable probably isn't a feasible solution. But can we have some alternative way to use OPFS in web extension? For example, webkit can use extension id (`browser.runtime.id`) as origin to persist OPFS between runs?
Comment 1 OlegWock 2023-07-30 15:47:14 PDT
After a bit more searching I found mention from Timothy Hatcher (https://github.com/w3c/webextensions/blob/main/_minutes/2023-05-11-wecg.md) that Safari currently migrates DOM Storage when origin changes. So my initial proposal (to use extension id as origin) doesn't make much sense anymore, as there is already established solution for this kind of problem (just for other storage types). If we could get same treatment form OPFS that would be awesome
Comment 2 Radar WebKit Bug Importer 2023-08-06 14:41:12 PDT
<rdar://problem/113473959>