auth0 / express-jwt

connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetVerificationKey type doesn't match auth0/node-jwks-rsa

kylerm42 opened this issue · comments

Description

A PR was recently merged to auth0/node-jwks-rsa that changed the type of GetVerificationKey, which breaks the interaction with express-jwt.

Reproduction

import * as jwks from "jwks-rsa";
import { expressjwt } from "express-jwt";
const secret = jwks.expressJwtSecret({...}) as jwks.GetVerificationKey;
expressjwt({ secret });

This code gives the TypeScript error:

Type 'GetVerificationKey' is not assignable to type 'Secret | GetVerificationKey'.
  Type 'import("/node_modules/jwks-rsa/index").GetVerificationKey' is not assignable to type 'import("/node_modules/express-jwt/dist/index").GetVerificationKey'.
    Type 'Secret | Promise<Secret | undefined> | undefined' is not assignable to type 'Secret | Promise<Secret>'.
      Type 'undefined' is not assignable to type 'Secret | Promise<Secret>'

Environment

  • Version of this library used: 7.7.5
  • Version of node-jwks-rsa library used: 2.1.5