-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61e610c
commit a559774
Showing
9 changed files
with
2,912 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2021, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": false | ||
} | ||
}, | ||
"rules": { | ||
"comma-spacing": [2, { "before": false, "after": true }], | ||
"eqeqeq": 2, | ||
"handle-callback-err": 2, | ||
"indent": ["error", 2, { | ||
"SwitchCase": 1, | ||
"VariableDeclarator": { "var": 2, "let": 2, "const": 3 }, | ||
"FunctionDeclaration": { "parameters": "first" }, | ||
"FunctionExpression": { "parameters": "first" }, | ||
"CallExpression": { "arguments": 1 } | ||
}], | ||
"keyword-spacing": 2, | ||
"max-len": [2, { "code": 99 }], | ||
"no-eq-null": 2, | ||
"no-eval": 2, | ||
"no-tabs": 2, | ||
"no-var": 2, | ||
"semi": 2, | ||
"space-before-blocks": 2, | ||
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}] | ||
}, | ||
"plugins": [ | ||
"security-node" | ||
], | ||
"extends": [ | ||
// "eslint:recommended", | ||
"plugin:security-node/recommended" | ||
], | ||
"ignorePatterns": ["*.d.ts", "*.test.ts", "*.data.js", "packages/platform-irc/index.js"], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": [ | ||
"./tsconfig.json" | ||
] | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"security-node" | ||
] | ||
// "extends": [ | ||
// "plugin:@typescript-eslint/recommended" | ||
// ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.tmp | ||
.idea | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,41 @@ | ||
# secure-store-redis | ||
|
||
A simple wrapper to encrypt and decrypt data stored in redis. The main point is to ensure that any data you store in redis cannot be accessed by anyone else outside of the process, without the key. | ||
A simple wrapper to encrypt and decrypt data stored in redis. | ||
The main point is to ensure that any data you store in redis cannot be accessed | ||
by anyone else, without the key. | ||
|
||
|
||
**NOTE** version `2.x` is a rewrite in TypeScript, using async functions, and is | ||
backwards incompatible with `1.x` | ||
|
||
|
||
```javascript | ||
var SecureStore = require('secure-store-redis'); | ||
|
||
var store = new SecureStore({ | ||
namespace: 'myApp:store', | ||
secret: '823HD8DG26JA0LK1239Hgb651TWfs0j1', // must be 32 char secret | ||
errorOnNotFound: true, //optional; will cb error if data can't be found | ||
redis: { | ||
host: 'localhost', // optional | ||
port: 6379, // optional | ||
// optionally use the 'url' property to specify entire redis connect string | ||
// url: 'redis://localhost:6379', | ||
max_clients: 30, // optional | ||
database: 0, // optional | ||
options: { | ||
auth_pass: 'password' | ||
} //options for createClient of node-redis, optional | ||
} | ||
}); | ||
const SecureStore = require('secure-store-redis').default; | ||
|
||
store.save('quote', 'i see dead people', function (err, reply) { | ||
//... | ||
store.get('quote', function (err, reply) { | ||
// err: null | ||
// reply: 'i see dead people' | ||
}); | ||
store.get('quote', function (err, reply) { | ||
// err: record not found | ||
// reply: undefined | ||
}); | ||
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', | ||
}); | ||
await store.init(); | ||
|
||
store.delete('quote', function (err, reply) { | ||
// err: null | ||
// reply: 1 | ||
}); | ||
await store.save('quote', 'i see dead people'); | ||
let res = await store.get('quote'); | ||
// res: 'i see dead people' | ||
let res = await store.get('quote'); | ||
// res: null | ||
const num = await store.delete('quote'); | ||
// num: 1 | ||
|
||
await store.save('quote', 'i see dead people again'); | ||
|
||
var otherStore = new SecureStore({ | ||
prefix: 'myApp:store', | ||
secret: 'this is the wrong secret', | ||
redis: { // standard redis config object | ||
host: "127.0.0.1", | ||
port: 6379 | ||
} | ||
const otherStore = new SecureStore('myApp:store', 'this is the wrong secret', { | ||
host: "127.0.0.1", | ||
port: 6379 | ||
}); | ||
await otherStore.init(); | ||
|
||
otherStore.get('quote', function (err, reply) { | ||
// err: record not found | ||
// reply: undefined | ||
}); | ||
let res = await otherStore.get('quote'); | ||
// res: undefined | ||
``` |
Oops, something went wrong.