fastify-oauth2 icon indicating copy to clipboard operation
fastify-oauth2 copied to clipboard

TypeError when omitting `credentials.auth`

Open Jazcash opened this issue 1 year ago • 1 comments
trafficstars

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.24.3

Plugin version

7.8.0

Node.js version

18.18.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

idk

Description

When using the discovery configuration, this plugin's runtime throws an error stating: when options.discovery.issuer is configured, credentials.auth should not be used. However, when omitting that auth section from the options, this plugin's typings cause a TypeError because credentials.auth is a required property:

fastify.register(fastifyOauth2, {
    name: "googleOAuth2",
    scope: ["openid"],
    credentials: {
        client: {
            id: config.googleClientId,
            secret: config.googleClientSecret,
        },
        //auth: fastifyOauth2.GOOGLE_CONFIGURATION,
    },
    startRedirectPath: "/login/google",
    callbackUri: "http://127.0.0.1:3005/login/google/callback",
    discovery: {
        issuer: "https://accounts.google.com",
    },
});

Property 'auth' is missing in type '{ client: { id: string; secret: string; }; }' but required in type 'Credentials'.

https://github.com/fastify/fastify-oauth2/blob/master/types/index.d.ts#L110

Steps to Reproduce

Example above

Expected Behavior

No response

Jazcash avatar Feb 17 '24 17:02 Jazcash

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests, we use tsd for our types.

mcollina avatar Feb 18 '24 20:02 mcollina

related #246

RodrigoDornelles avatar Apr 22 '24 11:04 RodrigoDornelles

@Jazcash fixed in 7.8.1

RodrigoDornelles avatar Apr 25 '24 17:04 RodrigoDornelles