supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
321 stars 153 forks source link

Improved typing of provider fields #748

Closed TheOnlyTails closed 11 months ago

TheOnlyTails commented 11 months ago

What kind of change does this PR introduce?

This changes the type of the provider fields on UserAppMetadata and UserIdentity from string to Provider, which is the more accurate type.

What is the current behavior?

Right now, the field is typed as string, which tells typescript it can be any string, when in fact it can only ever be one of the values of Provider.

this is my first PR here, let me know of there's something I missed!

hf commented 11 months ago

Hey, actually it can only be a string. This is the information that is coming out from the GoTrue server. If you use an older version of gotrue-js, but a newer version of gotrue (the server) you will not be able to recognize any new providers supported by the server. This is why it has to be a string.

Furthermore, SSO providers are not enumerable, i.e. the provider name is sso:<uuid> as they're registered on the server. In that case you also can't use a const-style type.

I'll close this PR, though absolutely feel free to suggest changes whenever you see anything that can be improved. If you want to change something but are not sure, open an issue where you can discuss approaches with the team and community before spending time on it.

TheOnlyTails commented 11 months ago

Alright, no problem! it only took me 2 minutes so I didn't waste too much time :sweat_smile: