@auth/core
Advanced tools
Comparing version 0.20.0 to 0.21.0
{ | ||
"name": "@auth/core", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "Authentication for the Web.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -118,3 +118,9 @@ /** | ||
*/ | ||
export default function GitHub(config: OAuthUserConfig<GitHubProfile>): OAuthConfig<GitHubProfile>; | ||
export default function GitHub(config: OAuthUserConfig<GitHubProfile> & { | ||
/** Configuration for usage with [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server/get-started). */ | ||
enterprise?: { | ||
/** The base URL of your GitHub Enterprise Server instance. */ | ||
baseUrl?: string; | ||
}; | ||
}): OAuthConfig<GitHubProfile>; | ||
//# sourceMappingURL=github.d.ts.map |
@@ -63,2 +63,6 @@ /** | ||
export default function GitHub(config) { | ||
const baseUrl = config?.enterprise?.baseUrl ?? "https://github.com"; | ||
const apiBaseUrl = config?.enterprise?.baseUrl | ||
? `${config?.enterprise?.baseUrl}/api/v3` | ||
: "https://api.github.com"; | ||
return { | ||
@@ -69,8 +73,8 @@ id: "github", | ||
authorization: { | ||
url: "https://github.com/login/oauth/authorize", | ||
url: `${baseUrl}/login/oauth/authorize`, | ||
params: { scope: "read:user user:email" }, | ||
}, | ||
token: "https://github.com/login/oauth/access_token", | ||
token: `${baseUrl}/login/oauth/access_token`, | ||
userinfo: { | ||
url: "https://api.github.com/user", | ||
url: `${apiBaseUrl}/user`, | ||
async request({ tokens, provider }) { | ||
@@ -86,3 +90,3 @@ const profile = await fetch(provider.userinfo?.url, { | ||
// See https://docs.github.com/en/rest/users/emails#list-public-email-addresses-for-the-authenticated-user | ||
const res = await fetch("https://api.github.com/user/emails", { | ||
const res = await fetch(`${apiBaseUrl}/user/emails`, { | ||
headers: { | ||
@@ -89,0 +93,0 @@ Authorization: `Bearer ${tokens.access_token}`, |
@@ -162,3 +162,3 @@ import type { Client } from "oauth4webapi"; | ||
type: "oidc"; | ||
checks?: Array<Exclude<OAuth2Config<Profile>["checks"], undefined>[number] | "nonce">; | ||
checks?: Array<NonNullable<OAuth2Config<Profile>["checks"]>[number] | "nonce">; | ||
} | ||
@@ -165,0 +165,0 @@ export type OAuthConfig<Profile> = OIDCConfig<Profile> | OAuth2Config<Profile>; |
@@ -54,4 +54,5 @@ /** | ||
style: { logo: "/okta.svg", bg: "#000", text: "#fff" }, | ||
checks: ['pkce', 'state'], | ||
options, | ||
}; | ||
} |
@@ -123,4 +123,15 @@ /** | ||
export default function GitHub( | ||
config: OAuthUserConfig<GitHubProfile> | ||
config: OAuthUserConfig<GitHubProfile> & { | ||
/** Configuration for usage with [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server/get-started). */ | ||
enterprise?: { | ||
/** The base URL of your GitHub Enterprise Server instance. */ | ||
baseUrl?: string | ||
} | ||
} | ||
): OAuthConfig<GitHubProfile> { | ||
const baseUrl = config?.enterprise?.baseUrl ?? "https://github.com" | ||
const apiBaseUrl = config?.enterprise?.baseUrl | ||
? `${config?.enterprise?.baseUrl}/api/v3` | ||
: "https://api.github.com" | ||
return { | ||
@@ -131,8 +142,8 @@ id: "github", | ||
authorization: { | ||
url: "https://github.com/login/oauth/authorize", | ||
url: `${baseUrl}/login/oauth/authorize`, | ||
params: { scope: "read:user user:email" }, | ||
}, | ||
token: "https://github.com/login/oauth/access_token", | ||
token: `${baseUrl}/login/oauth/access_token`, | ||
userinfo: { | ||
url: "https://api.github.com/user", | ||
url: `${apiBaseUrl}/user`, | ||
async request({ tokens, provider }) { | ||
@@ -149,3 +160,3 @@ const profile = await fetch(provider.userinfo?.url as URL, { | ||
// See https://docs.github.com/en/rest/users/emails#list-public-email-addresses-for-the-authenticated-user | ||
const res = await fetch("https://api.github.com/user/emails", { | ||
const res = await fetch(`${apiBaseUrl}/user/emails`, { | ||
headers: { | ||
@@ -152,0 +163,0 @@ Authorization: `Bearer ${tokens.access_token}`, |
@@ -242,5 +242,3 @@ import type { Client } from "oauth4webapi" | ||
type: "oidc" | ||
checks?: Array< | ||
Exclude<OAuth2Config<Profile>["checks"], undefined>[number] | "nonce" | ||
> | ||
checks?: Array<NonNullable<OAuth2Config<Profile>["checks"]>[number] | "nonce"> | ||
} | ||
@@ -247,0 +245,0 @@ |
@@ -102,4 +102,5 @@ /** | ||
style: { logo: "/okta.svg", bg: "#000", text: "#fff" }, | ||
checks: ['pkce', 'state'], | ||
options, | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1386843
35163