https://github.com/jihyunlab/web-secure-storage
JihyunLab Web secure storage.
https://github.com/jihyunlab/web-secure-storage
cipher crypto local-storage secure session-storage storage web
Last synced: about 1 year ago
JSON representation
JihyunLab Web secure storage.
- Host: GitHub
- URL: https://github.com/jihyunlab/web-secure-storage
- Owner: jihyunlab
- License: mit
- Created: 2023-02-22T12:39:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T09:34:54.000Z (almost 2 years ago)
- Last Synced: 2024-12-01T15:40:37.337Z (over 1 year ago)
- Topics: cipher, crypto, local-storage, secure, session-storage, storage, web
- Language: TypeScript
- Homepage:
- Size: 496 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @jihyunlab/web-secure-storage
[](https://www.npmjs.com/package/@jihyunlab/web-secure-storage?activeTab=versions) [](https://www.npmjs.com/package/@jihyunlab/web-secure-storage) [](https://github.com/jihyunlab/web-secure-storage/graphs/commit-activity) [](https://github.com/jihyunlab/web-secure-storage/blob/master/LICENSE) [](https://eslint.org) [](https://github.com/prettier/prettier)\
[](https://github.com/jihyunlab/web-secure-storage/actions/workflows/build.yml) [](https://github.com/jihyunlab/web-secure-storage/actions/workflows/lint.yml) [](https://github.com/jihyunlab/web-secure-storage/actions/workflows/prettier.yml) [](https://codecov.io/gh/jihyunlab/web-secure-storage)
@jihyunlab/web-secure-storage can be used by web applications.
@jihyunlab/web-secure-storage encrypts values and stores them in local or session storage. When retrieving stored values, they are decrypted back to their original values
The encryption function is implemented with [@jihyunlab/web-crypto](https://www.npmjs.com/package/@jihyunlab/web-crypto) and provides encryption for AES 256 CBC and AES 256 GCM.
## Installation
```bash
npm i @jihyunlab/web-secure-storage
```
## Usage
You can easily encrypt data and store it in storage, then retrieve it.
```
import {
CIPHER,
STORAGE,
WebSecureStorage,
} from '@jihyunlab/web-secure-storage';
const storage = await WebSecureStorage.create(
STORAGE.LOCAL,
CIPHER.AES_256_GCM,
'your secret key'
);
storage.clear();
await storage.setItem('item', 'jihyunlab'); // 89b1e3c2996e08d5549ecb9d625faca6db785c7d0f9ba51c3985e80ae1143263273308f5eb
const value = await storage.getItem('item');
console.log(value); // jihyunlab
storage.removeItem('item');
```
You can configure encryption options such as salt and iteration.
```
const storage = await WebSecureStorage.create(
STORAGE.LOCAL,
CIPHER.AES_256_GCM,
'your secret key',
{
salt: 'salt',
iterations: 256,
}
);
```
## Credits
Authored and maintained by JihyunLab <>
## License
Open source [licensed as MIT](https://github.com/jihyunlab/web-secure-storage/blob/master/LICENSE).