Open tonykaram1993 opened 1 year ago
Bump!
Alright, so I have an update regarding this.
I have been debugging for a week now (on and off), and I found something.
When I remove the following line https://github.com/tonykaram1993/typescript-express-starter/blob/feature/authentication/src/services/authentication.services.ts#L3C1-L3C38 - basically stop using lodash in the file where jsonwebtoken.sign
is called, everything works totally fine. Everything also works when I import lodash but not use it in the file.
So importing lodash
breaks jsonwebtoken
? Did I do something wrong that I need to change?
Alright, so scratch everything I said. It turned out to be that when I was getting the user (at https://github.com/tonykaram1993/typescript-express-starter/blob/feature/authentication/src/controllers/authentication.controllers.ts#L50C60-L50C60), I was getting a MongoDb Document instead of a plain object.
All I did was to transform it into an object using user.toObject()
(https://github.com/tonykaram1993/typescript-express-starter/blob/feature/authentication/src/services/user.services.ts#L27). But it's weird that the error given by jsonwebtoken was not clear. I should have gotten the payload is not a plain object
error instead of validator.isValid
is not a function error.
I am not sure if this should be marked as resolved or if I should keep it open? I will leave that up to you guys.
ISSUE WAS FOUND AND FIXED - LOOK HERE https://github.com/auth0/node-jsonwebtoken/issues/927#issuecomment-1694701319
Description
Basically whenever I try to run
jsonwebtoken.sign()
in typescript it gives me an error. Running the code in a simple javascript code runner works perfectly fine.I have been trying to debug this for a couple of days now, can't seem to figure it out.
Reproduction
Link to code I am working with: https://github.com/tonykaram1993/typescript-express-starter/blob/e6975e805f7f5b332e389d723d63a5641959ce15/src/services/authentication.services.ts#L64
The error log and a couple of log messages above it so you are able to see what is passed:
Environment
Library version:
Express version:
Running macOs 13.4.1 on MacBook Pro 16" M1 Pro.
Happy to answer any questions.
EDIT: an update about a comment i left below https://github.com/auth0/node-jsonwebtoken/issues/927#issuecomment-1694451532
Alright, so I have an update regarding this.
I have been debugging for a week now (on and off), and I found something.
When I remove the following line https://github.com/tonykaram1993/typescript-express-starter/blob/feature/authentication/src/services/authentication.services.ts#L3C1-L3C38 - basically stop using lodash in the file where jsonwebtoken.sign is called, everything works totally fine. Everything also works when I import
lodash
but not use it in the file.So importing lodash breaks jsonwebtoken? Did I do something wrong that I need to change?