@agconnect/storage
Advanced tools
Comparing version 1.0.0 to 1.1.0-beta1
@@ -1,1 +0,1 @@ | ||
"use strict";var e,t,r=(e=require("@agconnect/api"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("fs");!function(e){e.BROWSER="Browser",e.NODE_JS="Node",e.WX_MICROPROGRAM="Wx",e.REACT_NATIVE="ReactNative",e.QUICK_APP="QuickApp",e.UNKNOWN="Unknown"}(t||(t={}));var o=function(){function e(){}return e.setEncryptImp=function(e){this.encryptImpl=e},e.decrypt=function(e){return null!=this.encryptImpl&&null!=this.encryptImpl&&null!=e&&null!=e?this.encryptImpl.decrypt(e):e},e.encrypt=function(e){return null!=this.encryptImpl&&null!=this.encryptImpl&&null!=e&&null!=e?this.encryptImpl.encrypt(e):e},e}(),i=function(){function e(){this.storage={}}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){return Promise.resolve(this.storage[e])},e.prototype.remove=function(e){return delete this.storage[e],Promise.resolve()},e.prototype.set=function(e,t){return this.storage[e]=t,Promise.resolve()},e.prototype.setCryptImp=function(e){o.setEncryptImp(e)},e.instance=new e,e}(),c=function(){function e(){this.DB_NAME="agcLocalStorageDb",this.OBJECT_STORE_NAME="agc",this.KEY_PATH="agcStorage",this.VERSION=1}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.initIndexedDb=function(e){var t=this;return window.indexedDB?new Promise((function(r,n){var o=window.indexedDB.open(t.DB_NAME,t.VERSION),i=t;o.onupgradeneeded=function(e){var t=e.target.result;try{t.objectStoreNames.contains(i.OBJECT_STORE_NAME)||t.createObjectStore(i.OBJECT_STORE_NAME,{keyPath:i.KEY_PATH})}catch(e){n(e)}},o.onsuccess=function(t){try{r(t.target.result.transaction([i.OBJECT_STORE_NAME],e).objectStore(i.OBJECT_STORE_NAME))}catch(e){n(e)}},o.onerror=function(e){n(new Error(e.target.error))}})):Promise.reject("Your browser doesn't support a stable version of IndexedDB.")},e.prototype.get=function(e){return e?this.initIndexedDb("readonly").then((function(t){return new Promise((function(r,n){try{var i=t.get(e);i.onsuccess=function(){var e=i.result;r(null!=e&&"value"in e?o.decrypt(e.value):e)},i.onerror=function(e){n(e.target.error)}}catch(e){n(e)}}))})).catch((function(e){return Promise.reject(e)})):Promise.reject(new Error("key is null"))},e.prototype.set=function(e,t){if(!e||!t)return Promise.reject(new Error("key or value is null"));var r={},n={};r[this.KEY_PATH]=e,n.value=o.encrypt(t);var i=Object.assign(n,r);return this.initIndexedDb("readwrite").then((function(t){try{var r=t.get(e);return r.onsuccess=function(){var e=r.result,n=null!=e&&"value"in e?t.put(i):t.add(i);n.onsuccess=function(){return Promise.resolve()},n.onerror=function(e){return Promise.reject(e.target.error)}},r.onerror=function(e){return console.log("---get value from db error."),Promise.reject("get value from db error.")},Promise.resolve()}catch(e){return console.log("---set value to db error."+e),Promise.reject("set value to db error."+e)}})).catch((function(e){return Promise.reject("init db error."+e)}))},e.prototype.remove=function(e){return e?this.initIndexedDb("readwrite").then((function(t){try{var r=t.delete(e);return r.onsuccess=function(){return Promise.resolve()},r.onerror=function(e){return Promise.reject(e.target.error)},Promise.resolve()}catch(e){return Promise.reject(e)}})).catch((function(e){return Promise.reject(e)})):Promise.reject(new Error("key is null"))},e.prototype.setCryptImp=function(e){o.setEncryptImp(e)},e.instance=new e,e}(),s=function(){function e(){}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){if(!e)return Promise.reject(new Error("key is null"));try{var t=sessionStorage.getItem(e);return Promise.resolve(""===t?null:o.decrypt(t))}catch(e){return Promise.reject(e)}},e.prototype.set=function(e,t){if(!e||!t)return Promise.reject(new Error("key or value is null"));try{return sessionStorage.setItem(e,o.encrypt(t)),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.remove=function(e){if(!e)return Promise.reject(new Error("key is null"));try{return sessionStorage.removeItem(e),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.setCryptImp=function(e){o.setEncryptImp(e)},e.instance=new e,e}(),u=function(){function e(){}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){if(!e)return Promise.reject(new Error("key is null"));try{var t=n.readFileSync(e,"utf-8");return Promise.resolve(""===t?null:o.decrypt(t))}catch(e){return Promise.reject(e)}},e.prototype.set=function(e,t){if(!e||!t)return Promise.reject(new Error("key or value is null"));try{return n.writeFileSync(e,o.encrypt(t),"utf-8"),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.remove=function(e){if(!e)return Promise.reject(new Error("key is null"));try{return n.unlinkSync(e),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.setCryptImp=function(e){o.setEncryptImp(e)},e.instance=new e,e}(),a=function(){function e(e){this.env=e}return e.prototype.getStorage=function(e){if(null==e||null==e)return this.createMemoryStorage();switch(e){case 0:return this.createPersistentStorage();case 1:return this.createTemporaryStorage();case 2:default:return this.createMemoryStorage()}},e.prototype.createPersistentStorage=function(){return this.env.persist()},e.prototype.createTemporaryStorage=function(){return this.env.temp()},e.prototype.createMemoryStorage=function(){return this.env.memory()},e.getEnvConfig=function(){var e={};return e[t.BROWSER]=l,e[t.NODE_JS]=p,e[t.WX_MICROPROGRAM]=f,e[t.REACT_NATIVE]=m,e[t.QUICK_APP]=y,e[t.UNKNOWN]=l,e["object"==typeof self&&self.self===self?t.BROWSER:"object"==typeof navigator&&"ReactNative"===navigator.product?t.REACT_NATIVE:"[object process]"===Object.prototype.toString.call(global.process)?t.NODE_JS:global&&"fastapp"in global?t.QUICK_APP:self.navigator.userAgent.toLowerCase().match(/MicroMessenger/i)?t.WX_MICROPROGRAM:t.UNKNOWN]},e}(),l={persist:function(){return c.getInstance()},temp:function(){return s.getInstance()},memory:function(){return i.getInstance()}},p={persist:function(){return u.getInstance()},temp:function(){return s.getInstance()},memory:function(){return i.getInstance()}},f={persist:function(){return s.getInstance()},temp:function(){return s.getInstance()},memory:function(){return i.getInstance()}},m={persist:function(){return s.getInstance()},temp:function(){return s.getInstance()},memory:function(){return i.getInstance()}},y={persist:function(){return s.getInstance()},temp:function(){return s.getInstance()},memory:function(){return i.getInstance()}};r.registerInternalService({name:"AGCStorageService",serviceFactory:function(e){return new a(a.getEnvConfig())}}); | ||
"use strict";var e=require("@agconnect/api"),t=require("fs");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,o=r(e);!function(e){e.BROWSER="Browser",e.NODE_JS="Node",e.WX_MICROPROGRAM="Wx",e.REACT_NATIVE="ReactNative",e.QUICK_APP="QuickApp",e.UNKNOWN="Unknown"}(n||(n={}));var i=function(){function e(){}return e.setEncryptImp=function(e){this.encryptImpl=e},e.decrypt=function(e){return null!=this.encryptImpl&&null!=this.encryptImpl&&null!=e&&null!=e?this.encryptImpl.decrypt(e):e},e.encrypt=function(e){return null!=this.encryptImpl&&null!=this.encryptImpl&&null!=e&&null!=e?this.encryptImpl.encrypt(e):e},e}(),c=function(){function e(){this.storage={}}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){return Promise.resolve(this.storage[e])},e.prototype.remove=function(e){return delete this.storage[e],Promise.resolve()},e.prototype.set=function(e,t){return this.storage[e]=t,Promise.resolve()},e.prototype.setCryptImp=function(e){i.setEncryptImp(e)},e.instance=new e,e}(),s=function(){function e(){this.DB_NAME="agcLocalStorageDb",this.OBJECT_STORE_NAME="agc",this.KEY_PATH="agcStorage",this.VERSION=1}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.initIndexedDb=function(e){var t=this;return window.indexedDB?new Promise((function(r,n){var o=window.indexedDB.open(t.DB_NAME,t.VERSION),i=t;o.onupgradeneeded=function(e){var t=e.target.result;try{t.objectStoreNames.contains(i.OBJECT_STORE_NAME)||t.createObjectStore(i.OBJECT_STORE_NAME,{keyPath:i.KEY_PATH})}catch(e){n(e)}},o.onsuccess=function(t){try{r(t.target.result.transaction([i.OBJECT_STORE_NAME],e).objectStore(i.OBJECT_STORE_NAME))}catch(e){n(e)}},o.onerror=function(e){n(new Error(e.target.error))}})):Promise.reject("Your browser doesn't support a stable version of IndexedDB.")},e.prototype.get=function(e){return e?this.initIndexedDb("readonly").then((function(t){return new Promise((function(r,n){try{var o=t.get(e);o.onsuccess=function(){var e=o.result;r(null!=e&&"value"in e?i.decrypt(e.value):e)},o.onerror=function(e){n(e.target.error)}}catch(e){n(e)}}))})).catch((function(e){return Promise.reject(e)})):Promise.reject(new Error("key is null"))},e.prototype.set=function(e,t){if(!e||!t)return Promise.reject(new Error("key or value is null"));var r={},n={};r[this.KEY_PATH]=e,n.value=i.encrypt(t);var o=Object.assign(n,r);return this.initIndexedDb("readwrite").then((function(t){try{var r=t.get(e);return r.onsuccess=function(){var e=r.result,n=null!=e&&"value"in e?t.put(o):t.add(o);n.onsuccess=function(){return Promise.resolve()},n.onerror=function(e){return Promise.reject(e.target.error)}},r.onerror=function(e){return console.log("---get value from db error."),Promise.reject("get value from db error.")},Promise.resolve()}catch(e){return console.log("---set value to db error."+e),Promise.reject("set value to db error."+e)}})).catch((function(e){return Promise.reject("init db error."+e)}))},e.prototype.remove=function(e){return e?this.initIndexedDb("readwrite").then((function(t){try{var r=t.delete(e);return r.onsuccess=function(){return Promise.resolve()},r.onerror=function(e){return Promise.reject(e.target.error)},Promise.resolve()}catch(e){return Promise.reject(e)}})).catch((function(e){return Promise.reject(e)})):Promise.reject(new Error("key is null"))},e.prototype.setCryptImp=function(e){i.setEncryptImp(e)},e.instance=new e,e}(),u=function(){function e(){}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){if(!e)return Promise.reject(new Error("key is null"));try{var t=sessionStorage.getItem(e);return Promise.resolve(""===t?null:i.decrypt(t))}catch(e){return Promise.reject(e)}},e.prototype.set=function(e,t){if(!e||!t)return Promise.reject(new Error("key or value is null"));try{return sessionStorage.setItem(e,i.encrypt(t)),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.remove=function(e){if(!e)return Promise.reject(new Error("key is null"));try{return sessionStorage.removeItem(e),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.setCryptImp=function(e){i.setEncryptImp(e)},e.instance=new e,e}(),a=function(){function e(){}return e.getInstance=function(){return null==this.instance&&(this.instance=new e),this.instance},e.prototype.get=function(e){if(!e)return Promise.reject(new Error("key is null"));try{var r=t.readFileSync(e,"utf-8");return Promise.resolve(""===r?null:i.decrypt(r))}catch(e){return Promise.reject(e)}},e.prototype.set=function(e,r){if(!e||!r)return Promise.reject(new Error("key or value is null"));try{return t.writeFileSync(e,i.encrypt(r),"utf-8"),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.remove=function(e){if(!e)return Promise.reject(new Error("key is null"));try{return t.unlinkSync(e),Promise.resolve()}catch(e){return Promise.reject(e)}},e.prototype.setCryptImp=function(e){i.setEncryptImp(e)},e.instance=new e,e}(),l=function(){function e(e){this.env=e}return e.prototype.getStorage=function(e){if(null==e||null==e)return this.createMemoryStorage();switch(e){case 0:return this.createPersistentStorage();case 1:return this.createTemporaryStorage();case 2:default:return this.createMemoryStorage()}},e.prototype.createPersistentStorage=function(){return this.env.persist()},e.prototype.createTemporaryStorage=function(){return this.env.temp()},e.prototype.createMemoryStorage=function(){return this.env.memory()},e.getEnvConfig=function(){var e={};return e[n.BROWSER]=p,e[n.NODE_JS]=f,e[n.WX_MICROPROGRAM]=m,e[n.REACT_NATIVE]=y,e[n.QUICK_APP]=g,e[n.UNKNOWN]=p,e["object"==typeof self&&self.self===self?n.BROWSER:"object"==typeof navigator&&"ReactNative"===navigator.product?n.REACT_NATIVE:"[object process]"===Object.prototype.toString.call(global.process)?n.NODE_JS:global&&"fastapp"in global?n.QUICK_APP:self.navigator.userAgent.toLowerCase().match(/MicroMessenger/i)?n.WX_MICROPROGRAM:n.UNKNOWN]},e}(),p={persist:function(){return s.getInstance()},temp:function(){return u.getInstance()},memory:function(){return c.getInstance()}},f={persist:function(){return a.getInstance()},temp:function(){return u.getInstance()},memory:function(){return c.getInstance()}},m={persist:function(){return u.getInstance()},temp:function(){return u.getInstance()},memory:function(){return c.getInstance()}},y={persist:function(){return u.getInstance()},temp:function(){return u.getInstance()},memory:function(){return c.getInstance()}},g={persist:function(){return u.getInstance()},temp:function(){return u.getInstance()},memory:function(){return c.getInstance()}};o.default.registerInternalService({name:"AGCStorageService",serviceFactory:function(e){return new l(l.getEnvConfig())}}); |
{ | ||
"name": "@agconnect/storage", | ||
"version": "1.0.0", | ||
"main": "./dist/index.node.cjs.js", | ||
"module": "./dist/index.esm.js", | ||
"description": "@agconnect/storage", | ||
"author": " ", | ||
"license": " ", | ||
"scripts": { | ||
"build": "rollup -c" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"typings": "dist/index.d.ts", | ||
"devDependencies": { | ||
"typescript": "3.7.5", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"rollup-plugin-typescript2": "0.25.3", | ||
"@types/node": "^13.13.5", | ||
"rollup-plugin-terser": "^5.3.0" | ||
}, | ||
"repository": { | ||
"directory": "agconnect/storage", | ||
"type": "git", | ||
"url": "" | ||
}, | ||
"dependencies": { | ||
"@agconnect/api": "1.0.0", | ||
"@agconnect/api-types": "1.0.0", | ||
"@agconnect/core": "1.0.0", | ||
"@agconnect/storage-types": "1.0.0", | ||
"@agconnect/instance-types": "1.0.0" | ||
} | ||
"name": "@agconnect/storage", | ||
"version": "1.1.0-beta1", | ||
"main": "./dist/index.node.cjs.js", | ||
"module": "./dist/index.esm.js", | ||
"description": "@agconnect/storage", | ||
"author": " ", | ||
"license": " ", | ||
"scripts": { | ||
"build": "rollup -c" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"typings": "dist/index.d.ts", | ||
"devDependencies": { | ||
"typescript": "3.7.5", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"rollup-plugin-typescript2": "0.25.3", | ||
"@types/node": "^13.13.5", | ||
"rollup-plugin-terser": "^5.3.1" | ||
}, | ||
"repository": { | ||
"directory": "agconnect/storage", | ||
"type": "git", | ||
"url": "" | ||
}, | ||
"dependencies": { | ||
"@agconnect/api": "1.1.0-beta1", | ||
"@agconnect/api-types": "1.1.0-beta1", | ||
"@agconnect/core": "1.1.0-beta1", | ||
"@agconnect/storage-types": "1.1.0-beta1", | ||
"@agconnect/instance-types": "1.1.0-beta1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
17505
91
1
3
+ Added@agconnect/api@1.1.0-beta1(transitive)
+ Added@agconnect/api-types@1.1.0-beta1(transitive)
+ Added@agconnect/core@1.1.0-beta1(transitive)
+ Added@agconnect/instance-types@1.1.0-beta1(transitive)
+ Added@agconnect/storage-types@1.1.0-beta1(transitive)
- Removed@agconnect/api@1.0.0(transitive)
- Removed@agconnect/api-types@1.0.0(transitive)
- Removed@agconnect/core@1.0.0(transitive)
- Removed@agconnect/instance-types@1.0.0(transitive)
- Removed@agconnect/storage-types@1.0.0(transitive)
Updated@agconnect/api@1.1.0-beta1
Updated@agconnect/core@1.1.0-beta1