-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: add types #140
base: main
Are you sure you want to change the base?
feat!: add types #140
Conversation
I really like the idea @Barbapapazes What I am afraid is potentially the maintenance might be harder but I think it's worth it, do you feel like updating all the providers? Also, this PR is a breaking change as we don't return the same data anymore. |
One that I know of is Paypal doc's link: /**
* Paypal User
*
* @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
*/
type PaypalUser = {
user_id: string
sub: string
name: string
given_name: string
family_name: string
middle_name: string
picture: string
email: string
email_verified: boolean
gender: string
birthdate: string
zoneinfo: string
locale: string
phone_number: string
address: {
street_address: string
locality: string
region: string
postal_code: string
country: string
}
verified_account: boolean
account_type: 'PERSONAL' | 'BUSINESS' | 'PREMIER'
age_range: string
} As I get some free time I'll hope to help looking for missing ones |
I like the initiative as I am a Laravel Socialite user and this works fine for most cases. Would be nice to also include the raw user response object too, what do you think? return onSuccess(event, {
user: normalizeAuth0User(user),
tokens: normalizeAuth0Tokens(tokens as OAuthAccessTokenSuccess),
_data: rawUserInfoResponse
}) This is just an example but would be nice to access some provider specific data. Edit: My bad I just was it's nested in the user object, good enough!: |
Im not sure what is the actual state of this PR, but i think it could be more reliable / easier to allow for type casting when we retrieve the session with the useUserSession composable (e.g useUserSession<MyAppUser>()). |
No need to type cast atm, we already have // auth.d.ts
declare module '#auth-utils' {
interface User {
// Add your own fields
}
interface UserSession {
// Add your own fields
}
interface SecureSessionData {
// Add your own fields
}
}
export {} |
Yeah, I know, I’m just not convinced by the utility of adding hard-typed user types, as most claims are request-based on the scopes. |
Ah, my bad 🙌
Personally I would say that having it act more like a ground truth between the different oauth providers and your own application logic. |
Hello 👋,
This is a proposal to add more types and to standardize the
OAuthUser
andOAuthToken
in order to simplify the usage. This is inspire by the adonis social authentication package, https://docs.adonisjs.com/guides/authentication/social-authentication#user-properties, and laravel socialite package, https://github.com/laravel/socialite/blob/5.x/src/AbstractUser.php#L8. I also read the RFC6749For this first draft, I update the GitHub and Discord providers.Happy to have some feedback about it!/oauth/userinfo
)How to help?
<Provider>User
typeExample