incache-jws-session
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "incache-jws-session", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "store json web signature sessions in cache", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"incache": "^4.0.0", | ||
"incache": "^4.0.2", | ||
"jws": "^3.1.4" | ||
@@ -21,0 +21,0 @@ }, |
@@ -36,2 +36,3 @@ | ||
##### Generate a new token passing the user ID and the user type | ||
With user type intends for example ‘root’, ‘admin’, ‘user’, ‘visitor’, etc | ||
@@ -38,0 +39,0 @@ ```javascript |
const jws = require('jws') | ||
const InCache = require('incache') | ||
const store = new InCache() | ||
const store = new InCache({ | ||
storeName: 'jws-session' | ||
}) | ||
const TOKEN_NOT_VALID = 'Token is not valid' | ||
@@ -9,5 +11,5 @@ | ||
* constructor config | ||
* @param {string} secret a secret key used to generate the token | ||
* @param {string} serverHost hostname of the server | ||
* @param {int} time minutes of life for the token | ||
* @param {string} config.secret a secret key used to generate the token | ||
* @param {string} config.serverHost hostname of the server | ||
* @param {int} config.time minutes of life for the token | ||
*/ | ||
@@ -22,5 +24,5 @@ constructor(config){ | ||
* insert admin or user session | ||
* @param {int} session.user id of the user | ||
* @param {string} session.token generated token | ||
* @param {unixtime} session.exp expiration time of token | ||
* @param {int} session.user id of the user | ||
* @param {string} session.token generated token | ||
* @param {int} session.exp expiration time of token | ||
*/ | ||
@@ -42,4 +44,3 @@ insert(session){ | ||
* check the token status | ||
* @param {string} token user token | ||
* @param {object} error internal error list params | ||
* @param {string} token user token | ||
* @return {Object} isLogged: boolean, token: 'string', message: 'string', updated: boolean | ||
@@ -80,4 +81,5 @@ */ | ||
* createToken | ||
* @param {type} id user id or anything that you like to use as identificator | ||
* @return {string} token | ||
* @param {int} id user id or anything that you like to use as identificator | ||
* @param {string} type user type for example ‘root’, ‘admin’, ‘user’, ‘visitor’, etc | ||
* @return {string} token | ||
*/ | ||
@@ -100,5 +102,10 @@ async createToken(id, type) { | ||
* decodeToken return the information crypted inside the token | ||
* @param {type} token description | ||
* @return {decoded} contain serverHost, expiration date and an identificator | ||
* @param {type} token description | ||
* @return {Object} contain serverHost, expiration date and an identificator | ||
*/ | ||
/** | ||
* | ||
* @param token | ||
* @returns {Promise.<boolean>} | ||
*/ | ||
async decodeToken(token) { | ||
@@ -105,0 +112,0 @@ let decoded = false |
Sorry, the diff of this file is not supported yet
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
102
104
6776
7
Updatedincache@^4.0.2