passport icon indicating copy to clipboard operation
passport copied to clipboard

PassportStrategy interface does not contain validate()

Open MickL opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

When following the documentation and extending PassportStrategy the interface does not contain a validate() function and is therefor kinda useless.

import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-local';

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
...
}

The interface passport.strategy.d.ts looks like this:

import { Type } from '../interfaces';
export declare function PassportStrategy<T extends Type<any> = any>(Strategy: T, name?: string | undefined): {
    new (...args: any[]): InstanceType<T>;
};

I guess this is a bug because in the source file there is an abstract method.

The behavior is the same in latest 7.x and 8.x

Minimum reproduction code

https://github.com/nestjs/nest/tree/master/sample/19-auth-jwt

Steps to reproduce

No response

Expected behavior

The class PassportStrategy should contain an abstract validate() function

Package version

8.x

Passport version

No response

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • [X] macOS
  • [ ] Windows
  • [ ] Linux

Other

In general it is weird that there is no functions what so ever. For example there are functions available like this.success(), this.pass(), this.error() that are also not part of the interface.

MickL avatar Jun 13 '22 13:06 MickL

a year has passed

AarNtyon avatar Aug 15 '23 01:08 AarNtyon

a year has passed

And no one has made a PR for it. Would you like to @AarNtyon?

jmcdo29 avatar Aug 15 '23 01:08 jmcdo29