rocketseat-education / ignite-lab-00-aulas

152 stars 71 forks source link

Problema no express-jwt #6

Open tufcoder opened 1 year ago

tufcoder commented 1 year ago

Pessoal, estava tendo um problema com o módulo express-jwt na versão maior que 7.6.0. Ficava dando uma mensagem que o tipo do secret (GetVerificationKey) não era o esperado.

Segue os links sobre a solução do problema:

Refatorando o código ficou assim:

import { expressjwt as jwt, GetVerificationKey } from 'express-jwt';

const checkJWT = promisify(
      jwt({
        secret: expressJwtSecret({
          cache: true,
          rateLimit: true,
          jwksRequestsPerMinute: 5,
          jwksUri: `${this.AUTH0_DOMAIN}.well-known/jwks.json`,
        }) as GetVerificationKey,
        audience: this.AUTH0_AUDIENCE,
        issuer: this.AUTH0_DOMAIN,
        algorithms: ['RS256'],
      }),
    );