Socket
Socket
Sign inDemoInstall

@walletconnect/keyvaluestorage

Package Overview
Dependencies
Maintainers
10
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/keyvaluestorage - npm Package Compare versions

Comparing version 1.0.2-canary.1 to 1.0.2-canary.758d7ff

dist/types/browser/lib/browserMigration.d.ts

2

dist/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("@walletconnect/safe-json");function h(){try{const e=require("unstorage"),t=require("unstorage/drivers/fs-lite");return{db:e,driver:t}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let s;const i=class{constructor(e){this.writeActionsQueue={state:"idle",actions:[]},s||(s=h()),e?.dbName===":memory:"?this.database=s.db.createStorage():this.database=s.db.createStorage({driver:s.driver({base:`${e?.dbName}`})})}static create(e){const t=e.dbName;return t===":memory:"?new i(e):(i.instances[t]||(i.instances[t]=new i(e)),i.instances[t])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(e=>[e.key,e.value])}async onWriteAction(e){const{key:t,value:a,action:r}=e;let n=()=>({});const l=new Promise(d=>n=d);this.writeActionsQueue.actions.push({key:t,value:a,action:r,callback:n}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await l}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const e=this.writeActionsQueue.actions.shift();if(!e)continue;const{key:t,value:a,action:r,callback:n}=e;switch(r){case"setItem":await this.database.setItem(t),await this.database.setItem(t,o.safeJsonStringify(a));break;case"removeItem":await this.database.removeItem(t);break}n()}this.writeActionsQueue.state="idle"}async getItem(e){const t=await this.database.getItem(e);if(t!==null)return t}async setItem(e,t){await this.onWriteAction({key:e,value:t,action:"setItem"})}async removeItem(e){await this.onWriteAction({key:e,action:"removeItem"})}};let c=i;c.instances={};const y="walletconnect.db";class u{constructor(t){this.initialized=!1,console.log("node db opts",t),this.database=c.create({dbName:t?.database||t?.table||y}),this.performMigration()}async performMigration(){this.initialized=!0}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(t){return await this.initilization(),this.database.getItem(t)}async setItem(t,a){await this.initilization(),await this.database.setItem(t,a)}async removeItem(t){await this.initilization(),await this.database.removeItem(t)}async initilization(){this.initialized||await new Promise(t=>{const a=setInterval(()=>{this.initialized&&(clearInterval(a),t())},20)})}}class m{}function w(e){var t;return[e[0],o.safeJsonParse((t=e[1])!=null?t:"")]}exports.IKeyValueStorage=m,exports.KeyValueStorage=u,exports.default=u,exports.parseEntry=w;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var d=require("@walletconnect/safe-json"),z=require("fs");function S(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var g=S(z);function k(){try{const t=require("unstorage"),e=require("unstorage/drivers/fs-lite");return{db:t,driver:e}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let o;const n=class{constructor(t){this.writeActionsQueue={state:"idle",actions:[]},o||(o=k()),t?.dbName===":memory:"?this.database=o.db.createStorage():this.database=o.db.createStorage({driver:o.driver({base:t?.dbName})})}static create(t){const e=t.dbName;return e===":memory:"?new n(t):(n.instances[e]||(n.instances[e]=new n(t)),n.instances[e])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(t=>[t.key,t.value])}async onWriteAction(t){const{key:e,value:a,action:i}=t;let s=()=>({});const r=new Promise(c=>s=c);this.writeActionsQueue.actions.push({key:e,value:a,action:i,callback:s}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await r}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const t=this.writeActionsQueue.actions.shift();if(!t)continue;const{key:e,value:a,action:i,callback:s}=t;switch(i){case"setItem":await this.database.setItem(e),await this.database.setItem(e,d.safeJsonStringify(a));break;case"removeItem":await this.database.removeItem(e);break}s()}this.writeActionsQueue.state="idle"}async getItem(t){const e=await this.database.getItem(t);if(e!==null)return e}async setItem(t,e){await this.onWriteAction({key:t,value:e,action:"setItem"})}async removeItem(t){await this.onWriteAction({key:t,action:"removeItem"})}};let w=n;w.instances={};const p="wc_storage_version",h=".to_migrate",$=".migrated",b=":memory:",v=1,K=async(t,e,a)=>{var i;if(t===b){a();return}console.log("\u{1F6A2} migrate: start",t);const s=p,r=await e.getItem(s);if(r&&r>=v){console.log("\u{1F6A2} migrate: already migrated"),a();return}const c=await Q(`${t}${h}`);if(!c){console.log("\u{1F6A2} migrate: old db file not fount"),a();return}const l=d.safeJsonParse(c);if(!l){console.log("\u{1F6A2} migrate: old db is empty"),a();return}console.log("\u{1F6A2} migrate: reading old file");const m=(i=l?.collections)==null?void 0:i[0];console.log("\u{1F6A2} migrate: collection",l.collections.length,m.data.length);const u=m?.data;if(!u||!u.length){console.log("\u{1F6A2} migrate: no data in collection"),a();return}for(;u.length;){const y=u.shift();if(!y){console.log("\u{1F6A2} migrate: no item");continue}const{id:f,value:F}=y;console.log("\u{1F6A2} migrate: item",f),await e.setItem(f,d.safeJsonParse(F))}await e.setItem(s,v),console.log("\u{1F6A2} migrate: done"),A(`${t}${h}`,`${t}${$}`),a()},Q=async t=>await new Promise(e=>{g.default.readFile(t,{encoding:"utf8"},(a,i)=>{a&&(console.log("\u{1F6A2} migrate: error reading old file",a),e(void 0)),e(i)})}),_=t=>{t!==b&&(console.log("\u{1F6A2} beforeMigrate: start",typeof t),g.default.existsSync(t)&&(g.default.lstatSync(t).isDirectory()||(console.log("\u{1F6A2} beforeMigrate: exists",t),A(t,`${t}${h}`))))},A=(t,e)=>{try{console.log("\u{1F6A2} beforeMigrate: renaming",t),g.default.renameSync(t,e),console.log("\u{1F6A2} beforeMigrate: renamed",`${e}`)}catch(a){console.log("\u{1F6A2} beforeMigrate: error renaming",a)}},M="walletconnect.db";class I{constructor(e){this.initialized=!1,this.isInitialized=()=>{this.initialized=!0,console.log("isInitialized dd",this.initialized)};const a=e?.database||e?.table||M;_(a),this.database=w.create({dbName:a}),K(a,this.database,this.isInitialized)}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(e){return await this.initilization(),this.database.getItem(e)}async setItem(e,a){await this.initilization(),await this.database.setItem(e,a)}async removeItem(e){await this.initilization(),await this.database.removeItem(e)}async initilization(){this.initialized||await new Promise(e=>{const a=setInterval(()=>{this.initialized&&(clearInterval(a),e())},20)})}}class P{}function E(t){var e;return[t[0],d.safeJsonParse((e=t[1])!=null?e:"")]}exports.IKeyValueStorage=P,exports.KeyValueStorage=I,exports.default=I,exports.parseEntry=E;
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import{safeJsonStringify as d,safeJsonParse as h}from"@walletconnect/safe-json";function m(){try{const e=require("unstorage"),t=require("unstorage/drivers/fs-lite");return{db:e,driver:t}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let s;const i=class{constructor(e){this.writeActionsQueue={state:"idle",actions:[]},s||(s=m()),e?.dbName===":memory:"?this.database=s.db.createStorage():this.database=s.db.createStorage({driver:s.driver({base:`${e?.dbName}`})})}static create(e){const t=e.dbName;return t===":memory:"?new i(e):(i.instances[t]||(i.instances[t]=new i(e)),i.instances[t])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(e=>[e.key,e.value])}async onWriteAction(e){const{key:t,value:a,action:r}=e;let n=()=>({});const l=new Promise(u=>n=u);this.writeActionsQueue.actions.push({key:t,value:a,action:r,callback:n}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await l}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const e=this.writeActionsQueue.actions.shift();if(!e)continue;const{key:t,value:a,action:r,callback:n}=e;switch(r){case"setItem":await this.database.setItem(t),await this.database.setItem(t,d(a));break;case"removeItem":await this.database.removeItem(t);break}n()}this.writeActionsQueue.state="idle"}async getItem(e){const t=await this.database.getItem(e);if(t!==null)return t}async setItem(e,t){await this.onWriteAction({key:e,value:t,action:"setItem"})}async removeItem(e){await this.onWriteAction({key:e,action:"removeItem"})}};let o=i;o.instances={};const y="walletconnect.db";class c{constructor(t){this.initialized=!1,console.log("node db opts",t),this.database=o.create({dbName:t?.database||t?.table||y}),this.performMigration()}async performMigration(){this.initialized=!0}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(t){return await this.initilization(),this.database.getItem(t)}async setItem(t,a){await this.initilization(),await this.database.setItem(t,a)}async removeItem(t){await this.initilization(),await this.database.removeItem(t)}async initilization(){this.initialized||await new Promise(t=>{const a=setInterval(()=>{this.initialized&&(clearInterval(a),t())},20)})}}class w{}function b(e){var t;return[e[0],h((t=e[1])!=null?t:"")]}export{w as IKeyValueStorage,c as KeyValueStorage,c as default,b as parseEntry};
import{safeJsonStringify as z,safeJsonParse as m}from"@walletconnect/safe-json";import d from"fs";function k(){try{const t=require("unstorage"),e=require("unstorage/drivers/fs-lite");return{db:t,driver:e}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let o;const n=class{constructor(t){this.writeActionsQueue={state:"idle",actions:[]},o||(o=k()),t?.dbName===":memory:"?this.database=o.db.createStorage():this.database=o.db.createStorage({driver:o.driver({base:t?.dbName})})}static create(t){const e=t.dbName;return e===":memory:"?new n(t):(n.instances[e]||(n.instances[e]=new n(t)),n.instances[e])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(t=>[t.key,t.value])}async onWriteAction(t){const{key:e,value:i,action:a}=t;let s=()=>({});const r=new Promise(c=>s=c);this.writeActionsQueue.actions.push({key:e,value:i,action:a,callback:s}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await r}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const t=this.writeActionsQueue.actions.shift();if(!t)continue;const{key:e,value:i,action:a,callback:s}=t;switch(a){case"setItem":await this.database.setItem(e),await this.database.setItem(e,z(i));break;case"removeItem":await this.database.removeItem(e);break}s()}this.writeActionsQueue.state="idle"}async getItem(t){const e=await this.database.getItem(t);if(e!==null)return e}async setItem(t,e){await this.onWriteAction({key:t,value:e,action:"setItem"})}async removeItem(t){await this.onWriteAction({key:t,action:"removeItem"})}};let b=n;b.instances={};const $="wc_storage_version",h=".to_migrate",p=".migrated",f=":memory:",v=1,S=async(t,e,i)=>{var a;if(t===f){i();return}console.log("\u{1F6A2} migrate: start",t);const s=$,r=await e.getItem(s);if(r&&r>=v){console.log("\u{1F6A2} migrate: already migrated"),i();return}const c=await Q(`${t}${h}`);if(!c){console.log("\u{1F6A2} migrate: old db file not fount"),i();return}const l=m(c);if(!l){console.log("\u{1F6A2} migrate: old db is empty"),i();return}console.log("\u{1F6A2} migrate: reading old file");const g=(a=l?.collections)==null?void 0:a[0];console.log("\u{1F6A2} migrate: collection",l.collections.length,g.data.length);const u=g?.data;if(!u||!u.length){console.log("\u{1F6A2} migrate: no data in collection"),i();return}for(;u.length;){const y=u.shift();if(!y){console.log("\u{1F6A2} migrate: no item");continue}const{id:w,value:F}=y;console.log("\u{1F6A2} migrate: item",w),await e.setItem(w,m(F))}await e.setItem(s,v),console.log("\u{1F6A2} migrate: done"),A(`${t}${h}`,`${t}${p}`),i()},Q=async t=>await new Promise(e=>{d.readFile(t,{encoding:"utf8"},(i,a)=>{i&&(console.log("\u{1F6A2} migrate: error reading old file",i),e(void 0)),e(a)})}),K=t=>{t!==f&&(console.log("\u{1F6A2} beforeMigrate: start",typeof t),d.existsSync(t)&&(d.lstatSync(t).isDirectory()||(console.log("\u{1F6A2} beforeMigrate: exists",t),A(t,`${t}${h}`))))},A=(t,e)=>{try{console.log("\u{1F6A2} beforeMigrate: renaming",t),d.renameSync(t,e),console.log("\u{1F6A2} beforeMigrate: renamed",`${e}`)}catch(i){console.log("\u{1F6A2} beforeMigrate: error renaming",i)}},M="walletconnect.db";class I{constructor(e){this.initialized=!1,this.isInitialized=()=>{this.initialized=!0,console.log("isInitialized dd",this.initialized)};const i=e?.database||e?.table||M;K(i),this.database=b.create({dbName:i}),S(i,this.database,this.isInitialized)}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(e){return await this.initilization(),this.database.getItem(e)}async setItem(e,i){await this.initilization(),await this.database.setItem(e,i)}async removeItem(e){await this.initilization(),await this.database.removeItem(e)}async initilization(){this.initialized||await new Promise(e=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),e())},20)})}}class W{}function E(t){var e;return[t[0],m((e=t[1])!=null?e:"")]}export{W as IKeyValueStorage,I as KeyValueStorage,I as default,E as parseEntry};
//# sourceMappingURL=index.es.js.map

@@ -1,2 +0,2 @@

(function(n,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(n=typeof globalThis<"u"?globalThis:n||self,r(n["@walletconnect/keyvaluestorage"]={}))})(this,function(n){"use strict";const r=t=>JSON.stringify(t,(e,i)=>typeof i=="bigint"?i.toString()+"n":i),h=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=t.replace(e,'$1"$2n"$3');return JSON.parse(i,(c,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function y(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return h(t)}catch{return t}}function g(t){return typeof t=="string"?t:r(t)||""}function m(){try{const t=require("unstorage"),e=require("unstorage/drivers/fs-lite");return{db:t,driver:e}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let o;const s=class{constructor(t){this.writeActionsQueue={state:"idle",actions:[]},o||(o=m()),t?.dbName===":memory:"?this.database=o.db.createStorage():this.database=o.db.createStorage({driver:o.driver({base:`${t?.dbName}`})})}static create(t){const e=t.dbName;return e===":memory:"?new s(t):(s.instances[e]||(s.instances[e]=new s(t)),s.instances[e])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(t=>[t.key,t.value])}async onWriteAction(t){const{key:e,value:i,action:c}=t;let a=()=>({});const l=new Promise(I=>a=I);this.writeActionsQueue.actions.push({key:e,value:i,action:c,callback:a}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await l}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const t=this.writeActionsQueue.actions.shift();if(!t)continue;const{key:e,value:i,action:c,callback:a}=t;switch(c){case"setItem":await this.database.setItem(e),await this.database.setItem(e,g(i));break;case"removeItem":await this.database.removeItem(e);break}a()}this.writeActionsQueue.state="idle"}async getItem(t){const e=await this.database.getItem(t);if(e!==null)return e}async setItem(t,e){await this.onWriteAction({key:t,value:e,action:"setItem"})}async removeItem(t){await this.onWriteAction({key:t,action:"removeItem"})}};let u=s;u.instances={};const f="walletconnect.db";class d{constructor(e){this.initialized=!1,console.log("node db opts",e),this.database=u.create({dbName:e?.database||e?.table||f}),this.performMigration()}async performMigration(){this.initialized=!0}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(e){return await this.initilization(),this.database.getItem(e)}async setItem(e,i){await this.initilization(),await this.database.setItem(e,i)}async removeItem(e){await this.initilization(),await this.database.removeItem(e)}async initilization(){this.initialized||await new Promise(e=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),e())},20)})}}class w{}function b(t){var e;return[t[0],y((e=t[1])!=null?e:"")]}n.IKeyValueStorage=w,n.KeyValueStorage=d,n.default=d,n.parseEntry=b,Object.defineProperty(n,"__esModule",{value:!0})});
(function(n,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("fs")):typeof define=="function"&&define.amd?define(["exports","fs"],r):(n=typeof globalThis<"u"?globalThis:n||self,r(n["@walletconnect/keyvaluestorage"]={},n.g))})(this,function(n,r){"use strict";function S(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var u=S(r);const $=t=>JSON.stringify(t,(e,i)=>typeof i=="bigint"?i.toString()+"n":i),z=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=t.replace(e,'$1"$2n"$3');return JSON.parse(i,(s,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function f(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return z(t)}catch{return t}}function k(t){return typeof t=="string"?t:$(t)||""}function _(){try{const t=require("unstorage"),e=require("unstorage/drivers/fs-lite");return{db:t,driver:e}}catch{throw new Error(`To use WalletConnect server side, you'll need to install the "unstorage" dependency. If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.`)}}let c;const o=class{constructor(t){this.writeActionsQueue={state:"idle",actions:[]},c||(c=_()),t?.dbName===":memory:"?this.database=c.db.createStorage():this.database=c.db.createStorage({driver:c.driver({base:t?.dbName})})}static create(t){const e=t.dbName;return e===":memory:"?new o(t):(o.instances[e]||(o.instances[e]=new o(t)),o.instances[e])}async getKeys(){return this.database.getKeys()}async getEntries(){return(await this.database.getItems(await this.database.getKeys())).map(t=>[t.key,t.value])}async onWriteAction(t){const{key:e,value:i,action:s}=t;let a=()=>({});const l=new Promise(d=>a=d);this.writeActionsQueue.actions.push({key:e,value:i,action:s,callback:a}),this.writeActionsQueue.state==="idle"&&this.startWriteActions(),await l}async startWriteActions(){if(this.writeActionsQueue.actions.length===0){this.writeActionsQueue.state="idle";return}for(this.writeActionsQueue.state="active";this.writeActionsQueue.actions.length>0;){const t=this.writeActionsQueue.actions.shift();if(!t)continue;const{key:e,value:i,action:s,callback:a}=t;switch(s){case"setItem":await this.database.setItem(e),await this.database.setItem(e,k(i));break;case"removeItem":await this.database.removeItem(e);break}a()}this.writeActionsQueue.state="idle"}async getItem(t){const e=await this.database.getItem(t);if(e!==null)return e}async setItem(t,e){await this.onWriteAction({key:t,value:e,action:"setItem"})}async removeItem(t){await this.onWriteAction({key:t,action:"removeItem"})}};let w=o;w.instances={};const K="wc_storage_version",y=".to_migrate",M=".migrated",b=":memory:",I=1,Q=async(t,e,i)=>{var s;if(t===b){i();return}console.log("\u{1F6A2} migrate: start",t);const a=K,l=await e.getItem(a);if(l&&l>=I){console.log("\u{1F6A2} migrate: already migrated"),i();return}const d=await N(`${t}${y}`);if(!d){console.log("\u{1F6A2} migrate: old db file not fount"),i();return}const g=f(d);if(!g){console.log("\u{1F6A2} migrate: old db is empty"),i();return}console.log("\u{1F6A2} migrate: reading old file");const h=(s=g?.collections)==null?void 0:s[0];console.log("\u{1F6A2} migrate: collection",g.collections.length,h.data.length);const m=h?.data;if(!m||!m.length){console.log("\u{1F6A2} migrate: no data in collection"),i();return}for(;m.length;){const p=m.shift();if(!p){console.log("\u{1F6A2} migrate: no item");continue}const{id:F,value:O}=p;console.log("\u{1F6A2} migrate: item",F),await e.setItem(F,f(O))}await e.setItem(a,I),console.log("\u{1F6A2} migrate: done"),A(`${t}${y}`,`${t}${M}`),i()},N=async t=>await new Promise(e=>{u.default.readFile(t,{encoding:"utf8"},(i,s)=>{i&&(console.log("\u{1F6A2} migrate: error reading old file",i),e(void 0)),e(s)})}),E=t=>{t!==b&&(console.log("\u{1F6A2} beforeMigrate: start",typeof t),u.default.existsSync(t)&&(u.default.lstatSync(t).isDirectory()||(console.log("\u{1F6A2} beforeMigrate: exists",t),A(t,`${t}${y}`))))},A=(t,e)=>{try{console.log("\u{1F6A2} beforeMigrate: renaming",t),u.default.renameSync(t,e),console.log("\u{1F6A2} beforeMigrate: renamed",`${e}`)}catch(i){console.log("\u{1F6A2} beforeMigrate: error renaming",i)}},J="walletconnect.db";class v{constructor(e){this.initialized=!1,this.isInitialized=()=>{this.initialized=!0,console.log("isInitialized dd",this.initialized)};const i=e?.database||e?.table||J;E(i),this.database=w.create({dbName:i}),Q(i,this.database,this.isInitialized)}async getKeys(){return await this.initilization(),this.database.getKeys()}async getEntries(){return await this.initilization(),this.database.getEntries()}async getItem(e){return await this.initilization(),this.database.getItem(e)}async setItem(e,i){await this.initilization(),await this.database.setItem(e,i)}async removeItem(e){await this.initilization(),await this.database.removeItem(e)}async initilization(){this.initialized||await new Promise(e=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),e())},20)})}}class P{}function W(t){var e;return[t[0],f((e=t[1])!=null?e:"")]}n.IKeyValueStorage=P,n.KeyValueStorage=v,n.default=v,n.parseEntry=W,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=index.umd.js.map
import { IKeyValueStorage } from "../shared";
export declare class KeyValueStorage implements IKeyValueStorage {
private readonly localStorage;
constructor(opts: any);
private storage;
private initialized;
constructor();
private isInitialized;
getKeys(): Promise<string[]>;

@@ -10,4 +12,5 @@ getEntries<T = any>(): Promise<[string, T][]>;

removeItem(key: string): Promise<void>;
private initilization;
}
export default KeyValueStorage;
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,3 @@ import { IKeyValueStorage, KeyValueStorageOptions } from "../shared";

constructor(opts?: KeyValueStorageOptions);
performMigration(): Promise<void>;
private isInitialized;
getKeys(): Promise<string[]>;

@@ -9,0 +9,0 @@ getEntries<T = any>(): Promise<[string, T][]>;

{
"name": "@walletconnect/keyvaluestorage",
"description": "Isomorphic Key-Value Storage",
"version": "1.0.2-canary.1",
"version": "1.0.2-canary.758d7ff",
"author": "WalletConnect, Inc. <walletconnect.com>",

@@ -6,0 +6,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc