mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50: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-permitted-cross-domain-policies",
|
||||||
"x-powered-by",
|
"x-powered-by",
|
||||||
"x-xss-protection",
|
"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 = [
|
const urlHeaders = [
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
import IDBMapSync from "@webreflection/idb-map/sync";
|
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 {
|
function storageProxy(scope: Storage): Storage {
|
||||||
const store = new IDBMapSync(window.__location.host);
|
|
||||||
|
|
||||||
return new Proxy(scope, {
|
return new Proxy(scope, {
|
||||||
async get(target, prop) {
|
get(target, prop) {
|
||||||
await store.sync();
|
|
||||||
|
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case "getItem":
|
case "getItem":
|
||||||
return (key: string) => {
|
return (key: string) => {
|
||||||
|
@ -35,11 +39,14 @@ function storageProxy(scope: Storage): Storage {
|
||||||
|
|
||||||
case "length":
|
case "length":
|
||||||
return store.size;
|
return store.size;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return store.get(prop);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
defineProperty(target, property, attributes) {
|
defineProperty(target, property, attributes) {
|
||||||
target.setItem(property as string, attributes.value);
|
store.set(property as string, attributes.value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
// "allowJs": true,
|
// "allowJs": true,
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"target": "ES2020",
|
"target": "ES2022",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
|
"module": "ES2022",
|
||||||
"noEmit": true
|
"noEmit": true
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue