@jihyunlab/web-secure-storage
TypeScript icon, indicating that this package has built-in type declarations

2.1.6 • Public • Published

@jihyunlab/web-secure-storage

Version Downloads Last commit License Linter code style: prettier
Build Lint Prettier codecov

@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 and provides encryption for AES 256 CBC and AES 256 GCM.

Installation

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 <info@jihyunlab.com>

License

Open source licensed as MIT.

Dependents (0)

Package Sidebar

Install

npm i @jihyunlab/web-secure-storage

Weekly Downloads

45

Version

2.1.6

License

MIT

Unpacked Size

12.5 kB

Total Files

13

Last publish

Collaborators

  • jihyunlab-donghyun
  • jihyunlab-jh
  • jihyunlab-dh
  • jihyunlab-jmin
  • jihyunlab-phil
  • jihyunlab-dev