|
| 1 | +import { OAuthConfig, OAuthUserConfig } from "." |
| 2 | + |
| 3 | +export interface SlackProfile { |
| 4 | + ok: boolean |
| 5 | + sub: string |
| 6 | + "https://slack.com/user_id": string |
| 7 | + "https://slack.com/team_id": string |
| 8 | + email: string |
| 9 | + email_verified: boolean |
| 10 | + date_email_verified: number |
| 11 | + name: string |
| 12 | + picture: string |
| 13 | + given_name: string |
| 14 | + family_name: string |
| 15 | + locale: string |
| 16 | + "https://slack.com/team_name": string |
| 17 | + "https://slack.com/team_domain": string |
| 18 | + "https://slack.com/user_image_24": string |
| 19 | + "https://slack.com/user_image_32": string |
| 20 | + "https://slack.com/user_image_48": string |
| 21 | + "https://slack.com/user_image_72": string |
| 22 | + "https://slack.com/user_image_192": string |
| 23 | + "https://slack.com/user_image_512": string |
| 24 | + "https://slack.com/user_image_1024": string |
| 25 | + "https://slack.com/team_image_34": string |
| 26 | + "https://slack.com/team_image_44": string |
| 27 | + "https://slack.com/team_image_68": string |
| 28 | + "https://slack.com/team_image_88": string |
| 29 | + "https://slack.com/team_image_102": string |
| 30 | + "https://slack.com/team_image_132": string |
| 31 | + "https://slack.com/team_image_230": string |
| 32 | + "https://slack.com/team_image_default": boolean |
| 33 | +} |
| 34 | + |
| 35 | +export default function Slack<P extends Record<string, any> = SlackProfile>( |
| 36 | + options: OAuthUserConfig<P> |
| 37 | +): OAuthConfig<P> { |
| 38 | + return { |
| 39 | + id: "slack", |
| 40 | + name: "Slack", |
| 41 | + type: "oauth", |
| 42 | + wellKnown: "https://slack.com/.well-known/openid-configuration", |
| 43 | + authorization: { params: { scope: "openid profile email" } }, |
| 44 | + profile(profile) { |
| 45 | + return { |
| 46 | + id: profile.sub, |
| 47 | + name: profile.name, |
| 48 | + email: profile.email, |
| 49 | + image: profile.picture, |
| 50 | + } |
| 51 | + }, |
| 52 | + options, |
| 53 | + } |
| 54 | +} |
0 commit comments