Revert "refactor(providers): try Typescript"

This reverts commit 6d74da1f65.
This commit is contained in:
Lluis Agusti
2021-07-17 21:58:25 +02:00
parent 6d74da1f65
commit bececbc200
4 changed files with 24 additions and 37 deletions

20
src/providers/42.js Normal file
View File

@@ -0,0 +1,20 @@
export default function FortyTwo(options) {
return {
id: '42-school',
name: '42 School',
type: 'oauth',
version: '2.0',
params: { grant_type: 'authorization_code' },
accessTokenUrl: 'https://api.intra.42.fr/oauth/token',
authorizationUrl:
'https://api.intra.42.fr/oauth/authorize?response_type=code',
profileUrl: 'https://api.intra.42.fr/v2/me',
profile: (profile) => ({
id: profile.id,
email: profile.email,
image: profile.image_url,
name: profile.usual_full_name,
}),
...options,
}
}

View File

@@ -1,33 +0,0 @@
import type { OAuthConfig } from "./../../types/providers.d"
interface DefaultFortyTwoProfile {
id: string
email: string
image_url: string
usual_full_name: string
}
type FortyTwoConfig = Partial<OAuthConfig<DefaultFortyTwoProfile>>
export default function FortyTwo(options?: FortyTwoConfig): FortyTwoConfig {
return {
id: "42-school",
name: "42 School",
type: "oauth",
version: "2.0",
params: { grant_type: "authorization_code" },
accessTokenUrl: "https://api.intra.42.fr/oauth/token",
authorizationUrl:
"https://api.intra.42.fr/oauth/authorize?response_type=code",
profileUrl: "https://api.intra.42.fr/v2/me",
profile(profile) {
return {
id: profile.id,
email: profile.email,
image: profile.image_url,
name: profile.usual_full_name,
}
},
...options,
}
}

1
types/index.d.ts vendored
View File

@@ -463,7 +463,6 @@ export interface DefaultUser {
name?: string | null
email?: string | null
image?: string | null
id: string
}
/**

View File

@@ -1,6 +1,6 @@
import { Profile, TokenSet, User } from "."
import { Awaitable, NextApiRequest } from "./internals/utils"
import { Options as SMTPConnectionOptions } from "nodemailer/lib/smtp-connection"
import { Options as SMTPConnectionOptions } from 'nodemailer/lib/smtp-connection'
export type ProviderType = "oauth" | "email" | "credentials"
@@ -21,7 +21,8 @@ type ChecksType = "pkce" | "state" | "both" | "none"
*
* [Documentation](https://next-auth.js.org/configuration/providers#oauth-provider-options)
*/
export interface OAuthConfig<P = Profile> extends CommonProviderOptions {
export interface OAuthConfig<P extends Record<string, unknown> = Profile>
extends CommonProviderOptions {
authorizationParams?: Record<string, string>
headers?: Record<string, any>
type: "oauth"
@@ -32,7 +33,7 @@ export interface OAuthConfig<P = Profile> extends CommonProviderOptions {
requestTokenUrl?: string
authorizationUrl: string
profileUrl: string
profile(profile: P, tokens: TokenSet): Awaitable<User>
profile(profile: P, tokens: TokenSet): Awaitable<User & { id: string }>
checks?: ChecksType | ChecksType[]
clientId: string
clientSecret: