incache-jws-session
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "incache-jws-session", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "store json web signature sessions in cache", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,3 +23,2 @@ | ||
```javascript | ||
const Session = require('incache-jws-session') | ||
@@ -36,4 +35,3 @@ | ||
##### Generate a new token passing the user ID and the user type | ||
With user type intends for example ‘root’, ‘admin’, ‘user’, ‘visitor’, etc | ||
##### Generate a new token passing the user ID and the user type for example ‘root’, ‘admin’, ‘user’, ‘visitor’, etc | ||
@@ -47,6 +45,5 @@ ```javascript | ||
```javascript | ||
const session = { | ||
user: 1, | ||
token, | ||
token: 'your token string', | ||
exp: new Date().getTime() + 1, | ||
@@ -53,0 +50,0 @@ type: 'user' |
const jws = require('jws') | ||
const InCache = require('incache') | ||
const store = new InCache({ | ||
storeName: 'jws-session' | ||
}) | ||
const store = new InCache({ autoSave: true, autoSaveMode: 'timer' }) | ||
const TOKEN_NOT_VALID = 'Token is not valid' | ||
@@ -98,10 +97,5 @@ | ||
* decodeToken return the information crypted inside the token | ||
* @param {type} token description | ||
* @param {string} token string | ||
* @return {Object} contain serverHost, expiration date and an identificator | ||
*/ | ||
/** | ||
* | ||
* @param token | ||
* @returns {Promise.<boolean>} | ||
*/ | ||
async decodeToken(token) { | ||
@@ -113,4 +107,3 @@ let decoded = false | ||
decoded = JSON.parse(decoded.payload) | ||
} | ||
catch(error) { | ||
} catch(error) { | ||
if(error){ | ||
@@ -123,4 +116,12 @@ return false | ||
/** | ||
* retrieveKey return the information crypted inside the token | ||
* @param {key} id that we want search | ||
* @return {object} return value or error | ||
*/ | ||
retrieveKey(key) { | ||
return store.get(key) | ||
} | ||
} | ||
module.exports = Session |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6831
6
101