import { Injectable } from '@nestjs/common' ; import { PassportStrategy } from '@nestjs/passport' ; import { ExtractJwt , Strategy } from 'passport-jwt' ; import { passportJwtSecret } from 'jwks-rsa' ; import { AUTH0_AUDIENCE , AUTH0_ISSUER , } from '@dark-rush-photography/shared/types' ; @ Injectable ( ) export class JwtStrategy extends PassportStrategy ( Strategy ) { constructor ( ) { super ( { secretOrKeyProvider : passportJwtSecret ( { cache : true , rateLimit : true , jwksRequestsPerMinute : 5 , jwksUri : `${ AUTH0_ISSUER }.well-known/jwks.json` , } ) , jwtFromRequest : ExtractJwt . fromAuthHeaderAsBearerToken ( ) , audience : AUTH0_AUDIENCE , issuer : AUTH0_ISSUER , algorithms : [ 'RS256' ] , } ) ; } validate ( payload ) { return payload ; } }