nbrc-store
v0.0.7
Published
Wrapper for localStorage, sessionStorage, chrome.storage.local, chrome.storage.sync, chrome.storage.session, provide unified API interfaces.
Downloads
2
Readme
Wrapper for localStorage, sessionStorage, chrome.storage.local, chrome.storage.sync, chrome.storage.session, provide unified API interfaces.
JWK
Keypair for encrypting sensitive data using rsa algorithm
const jwk = {
"public": {
"alg": "RSA-OAEP-256",
"e": "AQAB",
"ext": true,
"key_ops": [
"encrypt"
],
"kty": "RSA",
"n": "8FdE83-ymB2kPxAHLXmLCG9vRVOGxmgVpsxMnZqUqlRffx3dByUQ5yVKsU65f-Gaf0AI2Y5QcQczzejlXd2Y8p3p-Dkn1M143VjkpdsvsnGOG0qt0VYwUDkezJ_Ikb6o-MVZKPsvyx8YDhGIDHqWoBPjNfb3Jz1bKvzim8heGGHiWw49rqP4cwzEVrd2by2vUP0Qgh3dVTdBwv-SM2KOzcIfl87HUuHDVzjwqthZa03FsyAmTtO60Xbcy8jvpzcUJ8wLxj8r5ngmkG1aY40yyva6Auh0MqpA1Udmp7zLhf8AmWMmqUq-uL3XRgRtz5fdRacyxLIdvDMsvfo7XKYW7w"
},
"private": {
"alg": "RSA-OAEP-256",
"d": "A89uYWnh2_WEWBeZ9Yeaw6x4mCHF3jliNn3ArTL5LmYeCXbgvS9CQFfgAkWcPUHHYEMUoNZXwiL6GEab9EwCE76bKftF_WKwitnQ7iw2al7QgPBDJzF1nJ_7NAVIeb8LEL6YNkUdMdwxVm_Ct2fuIWWPUZizvGSFoH3X3d5kV4CV55jGfSlHVXMlqpcSHwNgGWaw6BecR-3ONDBSCFauS1k5Kc8BqZ2UG7XlkqJ_CCU9WXuuIh0jm6BjcurfgUHzRD9rIgwGAuyRWQGjmStNlN5cEa3ekrHJYP_X3E23NuN9wBpZ8FYMmDSMhpS8reY_R6bKuUpZT-KiuCZ4UHiTkQ",
"dp": "V-X_Bdo3Z8FxXj2RzZvXZwFfXaUyEjCVjfZzcinAKyYJs0dg7NjX6rnAHiBmC1wSQjGxS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zZw13gudDh6R15J_eHKuwApDbBC9J9kAqdg639h37QvugxZ-gMLCuJ6YUoTz4lHzMG2b-AnU26qz4JLYHF2TPuVYSH8703YEIrRGriSjEsjBzUcgrp2H9lQUC1hT-z6yIg3W_w"
}
}
Configuration
let configuration = {
driver: 'origin', // origin | session | crx.local | crx.sync | crx.session
key: {
prefix: 'nbrc-', // key prefix
hashKey: '' // factor for hashing key ( empty will not hash key )
},
value: {
rsa: true,// encrypt or not
jwk: jwk // rsa keypair
},
};
Examples
import storeLib from 'nbrc-store'
let store = storeLib.createInstance(configuration);
// methods: get, set, remove, clear
// all of the methods return a Promise
store.set('key1', 'hello')
store.get('key1','default value....').then(v => {
console.log(v)
})
store.remove('key1')
store.clear()