question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting an error when calling "jsonwebtoken.verify"

See original GitHub issue

Just ran the generator. The generated app is throwing an error src/shared/JwtService.ts - the jsonwebtoken.verify has parameters that aren’t matching.

I’m running Win10, Node v12, Typescript 3.6.3.

The error message:

`src/shared/JwtService.ts:45:51 - error TS2769: No overload matches this call. Overload 1 of 3, ‘(token: string, secretOrPublicKey: Secret, options?: VerifyOptions | undefined): string | object’, gave the following error. Type ‘(err: VerifyErrors, decoded: string | object) => void’ has no properties in common with type ‘VerifyOptions’. Overload 2 of 3, ‘(token: string, secretOrPublicKey: string | Buffer | { key: string | Buffer; passphrase: string; } | GetPublicKeyOrSecret, callback?: VerifyCallback | undefined): void’, gave the following error. Argument of type ‘(err: VerifyErrors, decoded: object | string) => void’ is not assignable to parameter of type ‘VerifyCallback’. Types of parameters ‘err’ and ‘err’ are incompatible. Type ‘JsonWebTokenError | NotBeforeError | TokenExpiredError | null’ is not assignable to type ‘VerifyErrors’. Type ‘null’ is not assignable to type ‘VerifyErrors’. Overload 3 of 3, ‘(token: string, secretOrPublicKey: string | Buffer | { key: string | Buffer; passphrase: string; } | GetPublicKeyOrSecret, options?: VerifyOptions | undefined, callback?: VerifyCallback | undefined): void’, gave the following error. Type ‘(err: VerifyErrors, decoded: string | object) => void’ has no properties in common with type ‘VerifyOptions’.

45 jsonwebtoken.verify(jwt, this.secret, (err: VerifyErrors, decoded: object | string) => { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

at createTSError (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:434:12)
at reportTSError (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:438:19)
at getOutput (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:578:36)
at Object.compile (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:775:32)
at Module.m._compile (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:858:43)
at Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Object.require.extensions.<computed> [as .ts] (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:861:12)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)`

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
seanpmaxwellcommented, May 26, 2020

those are equivalent

0reactions
digizencommented, May 26, 2020

Yep, that fixed it. I was only slightly off on the signature too 😃. You did “decoded? object” and I had “decoded: object | undefined”. Would my type have worked?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle JWT Verify Failure - node.js - Stack Overflow
Currently, if a user is logged in and the JWT secret key is changed, their browser throws an error. This can only be...
Read more >
jwt.verify fails to throw error for expired tokens #370 - GitHub
I am creating a jwt like this: return jwt.sign({ some_key: some_value }, Authentication.secret, { expiresIn: '1s'}); And verifying it like: ...
Read more >
Troubleshooting JWT validation - Google Cloud
This page provides troubleshooting information if the JWT validation fails and ESP returns an error in the response to the client. See RFC...
Read more >
JWT Errors | Documentation - Web3Auth
Invalid JWT Verifiers ID field. Error occurred while verifying params could not verify identity ; Failed to verify JWS signature. Error occurred while...
Read more >
Implementing JWT Authentication in Node.js
verify (token, jwtKey) } catch (e) { if (e instanceof jwt.JsonWebTokenError) { // if the error thrown is because the JWT is unauthorized,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found