import { Injectable } from '@nestjs/common' import { PassportStrategy } from '@nestjs/passport' import { ExtractJwt, Strategy } from 'passport-jwt' import { ConfigService } from '@nestjs/config' export interface JwtPayload { sub: string walletAddress?: string roles?: string[] iat?: number exp?: number } @Injectable() export class JwtStrategy extends PassportStrategy(Strategy) { constructor(private configService: ConfigService) { super({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), ignoreExpiration: false, secretOrKey: configService.get('JWT_SECRET'), }) } async validate(payload: JwtPayload) { return { userId: payload.sub, walletAddress: payload.walletAddress, roles: payload.roles, } } }