Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Added

- Added the `Facebook` OAuth provider to the supported integrations in Aura Auth. [#210](https://github.com/aura-stack-ts/auth/pull/210)

- Added the `Authentik` OpenID Connect provider, enabling authentication through Authentik accounts with minimal configuration. [#199](https://github.com/aura-stack-ts/auth/pull/199)

- Added the `Hugging Face` OpenID Connect provider, enabling authentication through Hugging Face accounts with minimal configuration. [#198](https://github.com/aura-stack-ts/auth/pull/198)
Expand Down
64 changes: 64 additions & 0 deletions packages/core/src/oauth/facebook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import type { OAuthProviderCredentials, User } from "@/@types/index.js"

export interface FacebookProfile {
id: string
first_name: string
last_name: string
middle_name: string
name: string
name_format: string
picture: unknown
short_name: string
about: string
age_range: unknown
birthday: string
client_business_id: string
education: string
favorite_athletes: string[]
favorite_teams: string[]
gender: string
hometown: {
id: string
description: string
from: string | null
name: string | null
with: string
}
}

/**
* Facebook OAuth Provider
*
* @see [Facebook - Getting Started with Facebook Login](https://developers.facebook.com/docs/facebook-login/getting-started)
* @see [Facebook - Configure Your OAuth Settings](https://developers.facebook.com/docs/facebook-login/security#redirect-uris)
* @see [Facebook - Permissions Reference](https://developers.facebook.com/docs/permissions/reference)
* @see [Facebook - Login Review](https://developers.facebook.com/docs/facebook-login/review/)
* @see [Facebook - Manually Build a Login Flow](https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow)
* @see [Facebook - App](https://developers.facebook.com/)
* @see [Facebook - User](https://developers.facebook.com/docs/graph-api/reference/user)
*/
export const facebook = <DefaultUser extends User = User>(
options?: Partial<OAuthProviderCredentials<FacebookProfile, DefaultUser>>
): OAuthProviderCredentials<FacebookProfile, DefaultUser> => {
return {
id: "facebook",
name: "Facebook",
authorize: {
url: "https://www.facebook.com/v24.0/dialog/oauth",
params: {
scope: "email public_profile",
responseType: "code",
},
},
accessToken: "https://graph.facebook.com/v24.0/oauth/access_token",
userInfo: "https://graph.facebook.com/me?fields=id,name,email,picture",
profile: (profile) =>
({
sub: profile.id.toString(),
name: profile.name,
email: null,
image: profile.picture,
}) as DefaultUser,
...options,
}
}
Loading