The data will be stored using CryptoJS AES (Advanced Encryption Standard)
npm install secured-web-storage --save
or
yarn add secured-web-storage --save
In side index.html
<script src="node_modules/secured-web-storage/dist/index.min.js"></script>
In js
file where you want to use this package
var config = { name: 'test', type: 'localStorage', secretKey: 'test' };
var store = new SecuredWebStorage(config);
store.setItem('key1', { a: 12345 });
store.getItem('key1');
In your main.js
file
import SecuredWebStorage from 'secured-web-storage';
var config = { name: 'test', type: 'localStorage', secretKey: 'test', secure: true };
var store = new SecuredWebStorage(config);
Vue.prototype.store = store;
In vue.js components
where you want to use this package
this.store.setItem('key1', { a: 12345 });
this.store.get('key1');
Option | Type | Default Value | Description |
---|---|---|---|
name |
String | app | You can give your application name so that all your keys in browser storage will be prepended with your name of the application |
type |
Storage | localStorage | You can use either localStorage or sessionStorage |
secretKey |
String | SECRET_KEY | You can use any secret key |
secure |
Boolean | true | You can enable or disable encryption / decryption with this value |
var config = { name: 'test', type: 'localStorage', secretKey: 'test', secure: true };
var store = new SecuredWebStorage(config);
Method | Syntax | Description |
---|---|---|
setItem | setItem('key', value) |
Set the item in to browser storage. |
getItem | getItem('key') |
Get the item from browser storage. |
deleteItem | deleteItem('key') |
Delete the item from storage. |
getAllItems | getAllItems() |
Get all the items from storage. |
deleteAllItems | deleteAllItems() |
Delete all the items from storage. |
getAllKeys | getAllKeys() |
Get all the keys stored. |
getLength | getLength() |
Get the length of items stored. |
You can find npm registry link here
- Initial version with basic storage with encryption and decryption
- Initial version with basic storage with encryption and decryption
- Added demo for web application
- Added optional feature to enable or disabled encryption and decryption
- Added vue.js app demo
- Stable version release
- Keys will be fetched based on the configuration
- Updated Readme with configuration options and methods
- Pacakge name modified to secured-web-storage
- Demos updated to work with latest version of secured-web-storage
- Script file path modified in readme.md file
- Gmail : [email protected]
- Github : https://github.com/rajeshwarpatlolla
- Twitter : https://twitter.com/rajeshwar_9032
- Facebook : https://www.facebook.com/rajeshwarpatlolla