Registry / security / storage-encryption

storage-encryption

JSON →
library1.0.16jsnpmunverified

Encrypt Storage is a lightweight library for encrypting client-side storage (localStorage and sessionStorage) using AES symmetric encryption. Version 1.0.16 is the most recent stable release, with slow release cadence. It simplifies securing sensitive data in the browser with a minimal API. Compared to alternatives like crypto-js or browser-native crypto, it provides a dedicated high-level interface for storage encryption with TypeScript support. It is actively maintained.

npm install storage-encryption
INSTALL
IMPORT
SIG · STORAGE-ENCRYPTION
S
storage-encryption
securityjavascriptv1.0.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EncryptStorage
import { EncryptStorage } from 'storage-encryption'
import EncryptStorage from 'storage-encryption'
Named export in all versions. Default export does not exist despite README example showing default import.
EncryptStorage
const { EncryptStorage } = require('storage-encryption')
const EncryptStorage = require('storage-encryption')
CommonJS usage requires destructuring.
EncryptStorage
import type { EncryptStorage } from 'storage-encryption'
TypeScript type import is available.

Demonstrates instantiation with secret key and storage type, encryption, decryption, and removal of data.

import { EncryptStorage } from 'storage-encryption'; const secretKey = process.env.SECRET_KEY ?? 'fallback-key'; const encryptStorage = new EncryptStorage(secretKey, 'sessionStorage'); encryptStorage.encrypt('myKey', 'Hello, world!'); const decrypted = encryptStorage.decrypt('myKey'); console.log(decrypted); // 'Hello, world!' encryptStorage.encrypt('myKey', { foo: 'bar' }); const obj = encryptStorage.decrypt('myKey'); console.log(obj); // { foo: 'bar' } encryptStorage.remove('myKey');
Debug
Known issues
gotchaThe constructor's second parameter (storage) is a string ('localStorage' or 'sessionStorage'), not the actual storage object. Using an invalid string falls back silently to localStorage.
fix
Use exactly 'localStorage' or 'sessionStorage' (case-sensitive).
affects: >=1.0.0
deprecatedThe README shows an incorrect default import (import EncryptStorage from 'storage-encryption'), which will result in undefined. Only named import works.
fix
Use import { EncryptStorage } from 'storage-encryption'.
affects: >=1.0.0
gotchaThe encrypt method serializes data using JSON.stringify internally. Circular references or non-serializable values will throw an error.
fix
Ensure data is JSON-serializable before encrypting.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'storage-encryption' or its corresponding type declarations.
Missing TypeScript declaration files or incorrect import path.
fix
Ensure package is installed and types are included (package ships types). Use import { EncryptStorage } from 'storage-encryption'.
EncryptStorage is not a constructor
Using default import instead of named import.
fix
Use import { EncryptStorage } from 'storage-encryption'.
TypeError: Converting circular structure to JSON
Passing non-serializable data (e.g., object with circular reference) to encrypt().
fix
Use a library like flatted for circular references or ensure data is plain JSON.
Upgrade
Version history
1.0.16latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
Amazon
1
Resources
storage-encryption — npm install storage-encryption · libregistry