mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 15:40:02 -04:00
fix storage proxy and delete clear-site-data header
This commit is contained in:
parent
263ceaa5e9
commit
bc9a16720e
3 changed files with 17 additions and 6 deletions
|
@ -18,6 +18,9 @@ const cspHeaders = [
|
|||
"x-permitted-cross-domain-policies",
|
||||
"x-powered-by",
|
||||
"x-xss-protection",
|
||||
// This needs to be emulated, but for right now it isn't that important of a feature to be worried about
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data
|
||||
"clear-site-data"
|
||||
];
|
||||
|
||||
const urlHeaders = [
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import IDBMapSync from "@webreflection/idb-map/sync";
|
||||
|
||||
const store = new IDBMapSync(window.__location.host, {
|
||||
prefix: "Storage",
|
||||
durability: "relaxed"
|
||||
});
|
||||
|
||||
await store.sync();
|
||||
|
||||
function storageProxy(scope: Storage): Storage {
|
||||
const store = new IDBMapSync(window.__location.host);
|
||||
|
||||
return new Proxy(scope, {
|
||||
async get(target, prop) {
|
||||
await store.sync();
|
||||
|
||||
get(target, prop) {
|
||||
switch (prop) {
|
||||
case "getItem":
|
||||
return (key: string) => {
|
||||
|
@ -35,11 +39,14 @@ function storageProxy(scope: Storage): Storage {
|
|||
|
||||
case "length":
|
||||
return store.size;
|
||||
|
||||
default:
|
||||
return store.get(prop);
|
||||
}
|
||||
},
|
||||
|
||||
defineProperty(target, property, attributes) {
|
||||
target.setItem(property as string, attributes.value);
|
||||
store.set(property as string, attributes.value);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
// "allowJs": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"rootDir": "./src",
|
||||
"target": "ES2020",
|
||||
"target": "ES2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"module": "ES2022",
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue