Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

secure-store-redis

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

secure-store-redis - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

11

dist/index.d.ts

@@ -0,1 +1,2 @@

/// <reference types="node" />
import { RedisConnectionPoolConfig } from "redis-connection-pool";

@@ -10,7 +11,13 @@ interface SecureStoreConfig {

private pool;
private config;
constructor(uid: string, secret: string, cfg?: SecureStoreConfig);
init(): Promise<void>;
save(key: string, data: any, postfix?: string): Promise<any>;
save(key: string, data: never, postfix?: string): Promise<number>;
get(key: string, postfix?: string): Promise<any>;
delete(key: string, postfix?: string): Promise<any>;
delete(key: string, postfix?: string): Promise<string | number | boolean | Buffer | (string | Buffer)[] | {
key: string | Buffer;
element: string | Buffer;
} | {
[x: string]: string | Buffer;
}>;
private encrypt;

@@ -17,0 +24,0 @@ private decrypt;

4

dist/index.js

@@ -36,6 +36,7 @@ "use strict";

}
this.pool = (0, redis_connection_pool_1.default)(this.uid, redisConnectionPoolConfig);
this.config = redisConnectionPoolConfig;
}
init() {
return __awaiter(this, void 0, void 0, function* () {
this.pool = yield (0, redis_connection_pool_1.default)(this.uid, this.config);
yield this.pool.init();

@@ -100,2 +101,3 @@ });

const hash = SecureStore.shasum(key);
// @ts-ignore
return yield this.pool.hdel(this.uid + postfix, hash);

@@ -102,0 +104,0 @@ });

{
"name": "secure-store-redis",
"version": "2.0.2",
"version": "2.0.3",
"description": "A simple wrapper to encrypt and decrypt data stored in Redis",

@@ -28,14 +28,19 @@ "license": "MIT",

"test": "npm run build && jaribu",
"lint": "eslint src/",
"lint:fix": "eslint --fix src/",
"build": "tsc"
},
"dependencies": {
"redis-connection-pool": "^2.0.2"
"redis-connection-pool": "^3.0.0"
},
"devDependencies": {
"@types/eslint": "8.4.1",
"@types/node": "17.0.23",
"@typescript-eslint/parser": "5.16.0",
"eslint": "8.11.0",
"@types/eslint": "^8.4.6",
"@types/node": "^18.7.9",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"eslint": "^8.22.0",
"eslint-plugin-security-node": "^1.1.1",
"jaribu": "2.2.3",
"typescript": "4.6.2"
"typescript": "4.7.4",
"typescript-eslint": "^0.0.1-alpha.0"
},

@@ -42,0 +47,0 @@ "repository": {

@@ -16,6 +16,8 @@ # secure-store-redis

const store = new SecureStore('myApp:store', '823HD8DG26JA0LK1239Hgb651TWfs0j1', {
host: 'localhost', // optional
port: 6379, // optional
// optionally use the 'url' property to specify entire redis connect string
// url: 'redis://localhost:6379',
redis: {
host: 'localhost',
port: 6379, // optional
// optionally use the 'url' property to specify entire redis connect string
// url: 'redis://localhost:6379',
} // optional
});

@@ -22,0 +24,0 @@ await store.init();

@@ -1,2 +0,4 @@

import redisConnectionPoolFactory, {RedisConnectionPool, RedisConnectionPoolConfig} from "redis-connection-pool";
import redisConnectionPoolFactory, {
RedisConnectionPool, RedisConnectionPoolConfig
} from "redis-connection-pool";
import {randomBytes, createCipheriv, createDecipheriv, createHash} from 'crypto';

@@ -16,2 +18,3 @@

private pool: RedisConnectionPool;
private config: object;

@@ -33,14 +36,15 @@ constructor(uid: string, secret: string, cfg: SecureStoreConfig = {}) {

}
this.pool = redisConnectionPoolFactory(this.uid, redisConnectionPoolConfig);
this.config = redisConnectionPoolConfig;
}
async init() {
this.pool = await redisConnectionPoolFactory(this.uid, this.config);
await this.pool.init();
}
async save(key: string, data: any, postfix: string = '') {
async save(key: string, data: never, postfix: string = '') {
if (typeof key !== 'string') {
throw new Error('No hash key specified');
} else if (!data) {
throw new Error('No data provided, nothing to save')
throw new Error('No data provided, nothing to save');
}

@@ -51,3 +55,3 @@ postfix = postfix ? ':' + postfix : '';

try {
data = JSON.stringify(data);
data = JSON.stringify(data) as never;
} catch (e) {

@@ -58,4 +62,4 @@ throw new Error(e);

data = this.encrypt(data);
const hash = SecureStore.shasum(key)
data = this.encrypt(data) as never;
const hash = SecureStore.shasum(key);
return await this.pool.hset(this.uid + postfix, hash, data);

@@ -70,15 +74,15 @@ }

const hash = SecureStore.shasum(key)
const hash = SecureStore.shasum(key);
const res = await this.pool.hget(this.uid + postfix, hash);
let data;
if (typeof res === 'string') {
try {
data = this.decrypt(res);
} catch (e) {
throw new Error(e);
}
try {
data = this.decrypt(res);
} catch (e) {
throw new Error(e);
}
try {
data = JSON.parse(data);
} catch (e) {}
try {
data = JSON.parse(data);
} catch (e) {}
} else {

@@ -90,3 +94,3 @@ data = res;

async delete(key: string, postfix: string = '') {
async delete(key: string, postfix = '') {
if (typeof key !== 'string') {

@@ -96,3 +100,4 @@ throw new Error('No hash key specified');

postfix = postfix ? ':' + postfix : '';
const hash = SecureStore.shasum(key)
const hash = SecureStore.shasum(key);
// @ts-ignore
return await this.pool.hdel(this.uid + postfix, hash);

@@ -99,0 +104,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc