jwt-redis-v2's People
jwt-redis-v2's Issues
node_redis: The SET command contains a invalid argument type.
Hello!
I'm using this package since version 6. i updated the package to the current version ^7.0.3.
When I try to sign a new token for a user I get this error :
node_redis: The SET command contains a invalid argument type.
Only strings, dates and buffers are accepted. Please update your code to use valid argument types
Only strings, dates and buffers are accepted. Please update your code to use valid argument types.
at RedisClient.internal_send_command (node_modules\redis\index.js:835:39)
at RedisClient.set (node_modules\redis\lib\commands.js:46:25)
at Redis.setExp (node_modules\jwt-redis\build\Redis.js:11:33)
at JWTRedis.sign (node_modules\jwt-redis\build\JWTRedis.js:19:38)
at exports.login (api\controllers\userController.js:210:33)
my code in login :
const newToken = await jwtr.sign({
sub: user.uid,
iss: process.env.ISS,
aud: process.env.AU,
level : user.level
},
process.env.SECERT_KEY,
{
expiresIn: '1d',
}
)
any idea what's wrong here?
Error on Express start after npm install
Hi,
I've done the package upgrade to v.7.0.2 and I've also upgraded redis library.
When I try to start the server, on the console I see this error:
Error: Cannot find module '****/node_modules/jwt-redis/build/index.js'. Please verify that the package.json has a valid "main" entry
If I go to that folder, I only see package.json, tsconfig.build.json and tsconfig.json files, without folders and without src files.
How could I fix this?
Thanks in advance
JWT cannot be verify if JTI is not provided in options
Hello,
I found a bug in the sign method that cause the token cannot be validated if the jti options is not provided.
To reproduce :
var secret = 'shhh';
let token = await jwt.sign({
item1 : "blabla"
},
secret,
{
algorithm: 'RS256',
expiresIn: '1h'
});try {
await jwt.verify(token)
} catch (error) {
//Here is throw InvalidTokenError
}
To get it work juste add a jti in the sign method options.
Regards.
ioredis support
ERR wrong number of arguments for 'set' command
i am getting this error while creating token
I am using this code
const redis = require("redis");
const JWTR = require("jwt-redis").default;
var redisClient = redis.createClient();
var jwtr = new JWTR(redisClient);
UserSchema.methods.getSignedJwtToken = async function () {
return await jwtr.sign({ id: this._id, role: this.role }, process.env.JWT_SECRET, {expiresIn: process.env.JWT_EXPIRE});
};
jwtr.destroy() return undefined.
Hi, I have created token using jwtr but when destroying It returns undefined.
const isDestroy = await jwtr.destroy(req.user.jti);
I passed jti to destroy function. How do I know that token is destroyed?
TypeError: this.redisClient.set is not a function
Hi I am getting this error
TypeError: this.redisClient.set is not a function
app-0 | at /var/www/html/aneh/koows-server/node_modules/jwt-redis/build/Redis.js:9:37
app-0 | at new Promise (<anonymous>)
app-0 | at Redis.set (/var/www/html/aneh/koows-server/node_modules/jwt-redis/build/Redis.js:8:16)
app-0 | at JWTRedis.sign (/var/www/html/aneh/koows-server/node_modules/jwt-redis/build/JWTRedis.js:19:34)
app-0 | at login (file:///var/www/html/aneh/koows-server/controllers/auth.js:54:22)
Here is my code
import Prisma from '@prisma/client';
import bcrypt from 'bcrypt'
import redis from 'redis'
import JWTR from 'jwt-redis';
const { PrismaClient } = Prisma
const prisma = new PrismaClient()
const redisClient = redis.createClient();
redisClient.on("error", function(error) {
console.error(error);
});
let jwtr = new JWTR.default({
client: redisClient,
})
// Login api for account managers
const login = async (req, res) => {
const { username, password } = req.body
const user = await prisma.account_managers.findUnique({
where: {
username: username
}
})
if (!user) {
return res.status(400).json({
status: 'error',
message: 'Username does not exist'
})
}
const isMatch = await bcrypt.compare(password, user.password)
if (!isMatch) {
return res.status(400).json({
status: 'error',
message: 'Incorrect password'
})
}
let token = await jwtr.sign({
user_id: user._id,
username: user.username,
role: user.account_type
}, process.env.TOKEN_KEY);
return res.status(200).json({
status: 'success',
token: token
})
}
export {
login
}
Please tell me how to fix this
Not destroying redis keys
It isn't destroying the keys in redis after running jwtr.destroy()
TypeError: JWTR is not a constructor
const redis = require('redis');
const JWTR = require('jwt-redis');
const redisClient = redis.createClient();
const jwtr = new JWTR(redisClient);
const jwtr = new JWTR(redisClient);
^
TypeError: JWTR is not a constructor
TTL is not properly set with keys
On signing a key which has an expiry, this.redis.set()
is overriding this.redis.setExp()
ending up not setting TTL for that key and the key not being removed from redis.
if (decoded.exp) {
await this.redis.setExp(key, 'true', 'EX', Math.floor(decoded.exp - Date.now() / 1000));
}
await this.redis.set(key, 'true')
Error: secret must be a string or bufferor a KeyObject
why i am getting this even after using 2 parameters
Error: secret must be a string or bufferor a KeyObject
return await jwtr.sign( '07FEF41CA582A9C777F5B05528E4386C2733AD375632C0483B384BEBB679D0C7', {expiresIn: 60*60*24*30});
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.