react-oidc-context icon indicating copy to clipboard operation
react-oidc-context copied to clipboard

auth provider props and user manager settings have incompatible types

Open satanshiro opened this issue 3 years ago • 1 comments

image after upgrading there is a mismatch between the 2 types of usersettings and authprovider props because of of the following change export declare interface AuthProviderUserManagerProps extends Omit<AuthProviderPropsBase, "redirect_uri" | "client_id" | "authority"> { redirect_uri?: never; client_id?: never; authority?: never; } I'm not quite sure what was the point of this change, would be very happy for an explanataion:) so i can change accordingly.

satanshiro avatar Sep 25 '22 10:09 satanshiro

The idea was to not have both userManager and redirect_uri + client_id + authority. In case you use the later one you can use in you application the type AuthProviderNoUserManagerProps.

I am not very happy with the current definition of this! The combination type export type AuthProviderProps = AuthProviderNoUserManagerProps | AuthProviderUserManagerProps; does not behave as expected: Accept either the first or second definition, but not both. Any better solution?

pamapa avatar Sep 26 '22 07:09 pamapa

~~One alternative could be to just log a warning in case userManager an a userManager settings is provided together. Probably much simpler. Other ideas?~~

pamapa avatar Sep 26 '22 11:09 pamapa

type-wise the modification of the AuthProviderProps was a breaking change, sorry about that.

It would have been better to keep AuthProviderProps exactly the same, namely without optional userManager. But now that we have it, I will keep that and do not change it again...

pamapa avatar Sep 27 '22 09:09 pamapa

The idea was to not have both userManager and redirect_uri + client_id + authority. In case you use the later one you can use in you application the type AuthProviderNoUserManagerProps.

I am not very happy with the current definition of this! The combination type export type AuthProviderProps = AuthProviderNoUserManagerProps | AuthProviderUserManagerProps; does not behave as expected: Accept either the first or second definition, but not both. Any better solution?

I'll have to think of a solution. in general for me it was comfortable that I was able to instantiate usermanager without the context and with the context using the same type depending on how the page loads. as a general sense I think typing should reflect the code behavior as much as possible is there a benefit to enforce you cannot pass the extra params to props?

satanshiro avatar Sep 28 '22 07:09 satanshiro

I have improved the current solution in the MR #528.

pamapa avatar Sep 28 '22 08:09 pamapa

I took a look now and it's understandable, thanks have a nice day

satanshiro avatar Sep 28 '22 09:09 satanshiro