You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a library around the plugin to add routes and functionality for a full auth flow with all of the providers. The issue arises from the fact that the user needs to be able to pass the options from the parent plugin to the oauth2 plugin. The type inference that is gained by having the oauth2 object with its specific providers is lost when it is passed as a parameter. The code for the auth wrapper functions as intended however it causes type errors and the type inference of knowing what providers are available is lost. When making a regular auth plugin using a predefined provider like Google works as intended, the issue is you would have to make 48 of those and then keep them updated. The point of my auth library would be to allow any provider listed by the user and give them the routes and functionality for auth.
The google-plugin is the individual specified provider and has type safety. In this scenario both Google and GitHub were listed as providers to the oauth2, so it knew what was available for authorize()
The auth-plugin is where the options are taken as a parameter by the parent and passed to oauth2 plugin. This passing of the options object losses the type safety and inference.
I am trying to write a library around the plugin to add routes and functionality for a full auth flow with all of the providers. The issue arises from the fact that the user needs to be able to pass the options from the parent plugin to the oauth2 plugin. The type inference that is gained by having the oauth2 object with its specific providers is lost when it is passed as a parameter. The code for the auth wrapper functions as intended however it causes type errors and the type inference of knowing what providers are available is lost. When making a regular auth plugin using a predefined provider like Google works as intended, the issue is you would have to make 48 of those and then keep them updated. The point of my auth library would be to allow any provider listed by the user and give them the routes and functionality for auth.
I created a sample repository to show the problem I'm describing https://github.com/alexkahndev/oauth2-type-example it has two files of note the
auth-plugin
andgoogle-plugin
.The
google-plugin
is the individual specified provider and has type safety. In this scenario both Google and GitHub were listed as providers to the oauth2, so it knew what was available forauthorize()
The
auth-plugin
is where the options are taken as a parameter by the parent and passed to oauth2 plugin. This passing of the options object losses the type safety and inference.Authorize still works but it loses inference
Refresh and revoke work functionally but produce a type error
The text was updated successfully, but these errors were encountered: