mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2024-11-25 19:05:46 +01:00
🏷️ Update Facebook generic typing for custom profile types
This commit is contained in:
parent
cb1b6ae4e2
commit
923c66df58
@ -19,10 +19,10 @@ export interface FacebookTokens {
|
|||||||
|
|
||||||
interface FacebookOAuth2ProviderConfig<ProfileType = FacebookProfile>
|
interface FacebookOAuth2ProviderConfig<ProfileType = FacebookProfile>
|
||||||
extends OAuth2ProviderConfig<ProfileType, FacebookTokens> {
|
extends OAuth2ProviderConfig<ProfileType, FacebookTokens> {
|
||||||
userProfileFields?: string | (keyof FacebookProfile | string)[];
|
userProfileFields?: string | (keyof ProfileType)[] | (string | number | symbol)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfig: Partial<FacebookOAuth2ProviderConfig> = {
|
const defaultConfig: Partial<FacebookOAuth2ProviderConfig<any>> = {
|
||||||
id: "facebook",
|
id: "facebook",
|
||||||
scope: ["email", "public_profile", "user_link"],
|
scope: ["email", "public_profile", "user_link"],
|
||||||
userProfileFields: [
|
userProfileFields: [
|
||||||
@ -41,12 +41,12 @@ const defaultConfig: Partial<FacebookOAuth2ProviderConfig> = {
|
|||||||
accessTokenUrl: "https://graph.facebook.com/v10.0/oauth/access_token",
|
accessTokenUrl: "https://graph.facebook.com/v10.0/oauth/access_token",
|
||||||
};
|
};
|
||||||
|
|
||||||
export class FacebookOAuth2Provider extends OAuth2Provider<
|
export class FacebookOAuth2Provider<ProfileType = FacebookProfile> extends OAuth2Provider<
|
||||||
FacebookProfile,
|
ProfileType,
|
||||||
FacebookTokens,
|
FacebookTokens,
|
||||||
FacebookOAuth2ProviderConfig
|
FacebookOAuth2ProviderConfig<ProfileType>
|
||||||
> {
|
> {
|
||||||
constructor(config: FacebookOAuth2ProviderConfig) {
|
constructor(config: FacebookOAuth2ProviderConfig<ProfileType>) {
|
||||||
const userProfileFields = config.userProfileFields ?? defaultConfig.userProfileFields;
|
const userProfileFields = config.userProfileFields ?? defaultConfig.userProfileFields;
|
||||||
const data = {
|
const data = {
|
||||||
fields: Array.isArray(userProfileFields) ? userProfileFields.join(",") : userProfileFields!,
|
fields: Array.isArray(userProfileFields) ? userProfileFields.join(",") : userProfileFields!,
|
||||||
|
Loading…
Reference in New Issue
Block a user