mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Revert "refactor(providers): try Typescript"
This reverts commit 6d74da1f65.
This commit is contained in:
20
src/providers/42.js
Normal file
20
src/providers/42.js
Normal 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,
|
||||
}
|
||||
}
|
||||
@@ -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
1
types/index.d.ts
vendored
@@ -463,7 +463,6 @@ export interface DefaultUser {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
image?: string | null
|
||||
id: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
7
types/providers.d.ts
vendored
7
types/providers.d.ts
vendored
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user