fastify-oauth2
fastify-oauth2 copied to clipboard
TypeError when omitting `credentials.auth`
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
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.
related #246
@Jazcash fixed in 7.8.1