Registry / storage / secure-store-redis

secure-store-redis

JSON →
library4.1.3jsnpmunverified

A Node.js wrapper for encrypting and decrypting data stored in Redis using AES-256-GCM encryption with unique IVs per entry. Currently at version 4.1.3, actively maintained. Key differentiators include built-in secret key validation via SecretValidator, support for both Redis connection options and existing ioredis clients (including Cluster), automatic UUID-based prefixing, and ESM-only with TypeScript types. Provides simple save/get/delete operations on serialized JSON objects with strong encryption.

storagesecurity
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.

SecureStore is the default export (not named). For TypeScript, use the default import pattern; named import will fail at runtime.

import SecureStore from 'secure-store-redis'

SecretValidator is a named export, not default. Also available as SecretValidator.generate() is a static method.

import { SecretValidator } from 'secure-store-redis'

SecureStoreConfig is a TypeScript interface, imported as type. Importing as a runtime value will produce an error in bundlers.

import type { SecureStoreConfig } from 'secure-store-redis'

Creates an encrypted Redis store, saves and retrieves a JSON object, then disconnects. Uses auto-generated secret and default Redis connection.

import SecureStore, { SecretValidator } from "secure-store-redis"; const store = new SecureStore({ uid: "myApp", secret: SecretValidator.generate(), redis: { url: "redis://localhost:6379" }, }); await store.connect(); await store.save("key", { foo: "bar" }); const data = await store.get("key"); console.log(data); // { foo: "bar" } await store.disconnect();
Debug
Known footguns
breakingIn v4.0.0 the constructor config changed: `redis` option no longer accepts a `host` string directly; use `{ url: '...' }` or `{ client: ... }`.
deprecatedThe `secret` option must be exactly 32 characters; shorter secrets will be rejected by default.
gotchaWhen using an external Redis client, calling `disconnect()` does NOT close the Redis connection. The store assumes you manage the client lifecycle.
gotchaThe `uid` prefix is automatically appended to all Redis keys. For example, with `uid: 'myApp'`, saving `'key'` results in Redis key `'myApp:key'`. This may conflict with other apps using the same prefix.
breakingIn v3.x, the default export was `{ SecureStore, SecretValidator }` (named exports only). In v4.x, SecureStore became the default export and SecretValidator remains a named export.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
29 hits · last 30 days
petalbot
5
gptbot
3
amazonbot
3
bytedance
3
ahrefsbot
1
Resources