webchain/patches/@walletconnect+browser-utils+1.8.0.patch
2022-10-27 15:25:15 +08:00

59 lines
1.7 KiB
Diff

diff --git a/node_modules/@walletconnect/browser-utils/dist/esm/local.js b/node_modules/@walletconnect/browser-utils/dist/esm/local.js
index c7f4db3..9dd7e88 100644
--- a/node_modules/@walletconnect/browser-utils/dist/esm/local.js
+++ b/node_modules/@walletconnect/browser-utils/dist/esm/local.js
@@ -1,26 +1,39 @@
import { safeJsonParse, safeJsonStringify } from "./json";
import { getLocalStorage } from "./browser";
+var Cookies = require('js-cookie')
+
+export const generateDomain = () => {
+ let host = location.host;
+ let hostArr = host.split(".");
+ if (host.length > 1) {
+ host = hostArr.slice(hostArr.length - 2).join(".");
+ }
+ return host;
+ };
+
export function setLocal(key, data) {
const raw = safeJsonStringify(data);
- const local = getLocalStorage();
- if (local) {
- local.setItem(key, raw);
- }
+ Cookies.set(key, raw, { domain: generateDomain() });
+ // const local = getLocalStorage();
+ // if (local) {
+ // local.setItem(key, raw);
+ // }
}
export function getLocal(key) {
let data = null;
- let raw = null;
- const local = getLocalStorage();
- if (local) {
- raw = local.getItem(key);
- }
+ let raw = Cookies.get(key);
+ // const local = getLocalStorage();
+ // if (local) {
+ // raw = local.getItem(key);
+ // }
data = raw ? safeJsonParse(raw) : raw;
return data;
}
export function removeLocal(key) {
- const local = getLocalStorage();
- if (local) {
- local.removeItem(key);
- }
+ Cookies.remove(key, { domain: generateDomain() });
+ // const local = getLocalStorage();
+ // if (local) {
+ // local.removeItem(key);
+ // }
}
//# sourceMappingURL=local.js.map
\ No newline at end of file