TypeError: validator.isValid is not a function
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 10/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- express, javascript, node.js, typescript
- Área
- api, authentication, backend
Línea de trabajo
Comienza con el comentario enlazado del issue y la línea referenciada de authentication.services.ts; después, inspecciona la llamada a jsonwebtoken.sign junto con la importación de lodash y las versiones de los paquetes indicadas. El issue afirma que el problema fue encontrado y corregido; se consideraría terminado cuando se confirme esa resolución y se documente o pruebe la interacción entre las dependencias.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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:
[watch]
[watch]
[watch] 2:42:24 PM - Found 0 errors. Watching for file changes.
[server] info: Server is running at https://localhost:5000
[server] info: Connected to MongoDB! [mongodb://localhost:27017/typescript]
[server] TKCL - JWT_TOKEN_SECRET: secretsecretsecretsecretsecretsecretsecret
[server] TKCL - data: {
[server] email: '[email protected]',
[server] passwordHash: '$2b$10$E.w9gKA4KsZU1LdN0KN99eCvAyteG/.xboV.ppGoh3gmiVWsJPyIi',
[server] salt: '$2b$10$E.w9gKA4KsZU1LdN0KN99e',
[server] _id: new ObjectId("64cf8723a2210d51f1731e86"),
[server] __v: 0
[server] }
[server] TKCL - settingsConfig.AUTHENTICATION.jwtTokenExpiry: 1h
[server] POST /authentication/signup 500 72.621 ms - 1051
[server] POST /authentication/signup 500 72.621 ms - 1051
[server] TypeError: validator.isValid is not a function
[server] at /Users/tk/Repositories/typescript-starter/node_modules/jsonwebtoken/sign.js:49:22
[server] at Array.forEach (<anonymous>)
[server] at validate (/Users/tk/Repositories/typescript-starter/node_modules/jsonwebtoken/sign.js:41:6)
[server] at validatePayload (/Users/tk/Repositories/typescript-starter/node_modules/jsonwebtoken/sign.js:60:10)
[server] at Object.module.exports [as sign] (/Users/tk/Repositories/typescript-starter/node_modules/jsonwebtoken/sign.js:138:7)
[server] at Object.generateJwtToken (/Users/tk/Repositories/typescript-starter/dist/src/services/authentication.services.js:31:45)
[server] at signup (/Users/tk/Repositories/typescript-starter/dist/src/controllers/authentication.controllers.js:29:56)
[server] at processTicksAndRejections (node:internal/process/task_queues:96:5)
Environment
Library version:
"@types/jsonwebtoken": "^9.0.2",
"jsonwebtoken": "^9.0.1",
Express version:
"express": "^4.18.2",
"@types/express": "^4.17.14",
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?
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.2k
- Forks
- 1.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de auth0/node-jsonwebtoken
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
auth0/node-jsonwebtoken#1042 · 1 comentario ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errorsPosiblemente ocupada @cobyfrombrooklyn-bot la tomó hace 228 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
auth0/node-jsonwebtoken#1000 · 2 comentarios · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
auth0/node-jsonwebtoken#1048 ·
-
verify() resolves a string secret by attempting createPublicKey() first, costing 4x-52x on the HS* pathPosiblemente ocupada @Hashim1999164 la tomó hace 22 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 65/100
auth0/node-jsonwebtoken#1046 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
auth0/node-jsonwebtoken#1034 ·
Todos los issues de auth0/node-jsonwebtoken
Issues similares
-
documentation good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug release:v5.56
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Jason-Vaughan/TangleClaw#2270 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
style-dictionary/style-dictionary#1773 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SignalK/signalk-server#3143 ·
Los mantenedores suelen responder en 1 día