@better-auth/core 1.4.0-beta.13 → 1.4.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +34 -58
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +2 -6
- package/dist/api/index.d.ts +2 -6
- package/dist/api/index.js +1 -1
- package/dist/async_hooks/index.d.cts +1 -1
- package/dist/async_hooks/index.d.ts +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.cts +14 -18
- package/dist/context/index.d.ts +14 -18
- package/dist/context/index.js +1 -1
- package/dist/{context-Bm0rm76r.js → context-BAOGRjRS.js} +30 -30
- package/dist/{context-7VgEbfs3.cjs → context-BRDf96na.cjs} +29 -29
- package/dist/db/adapter/index.d.cts +2 -6
- package/dist/db/adapter/index.d.ts +2 -6
- package/dist/db/index.cjs +17 -17
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +17 -17
- package/dist/env/index.d.cts +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/error/index.d.cts +1 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/{index-D5uj-vER.d.ts → index-B_YiOlcX.d.cts} +9 -9
- package/dist/index-Bab6W0hG.d.ts +7155 -0
- package/dist/index-CGS5U4X6.d.cts +7155 -0
- package/dist/{index-Dy_s5RNc.d.cts → index-CSISZQGm.d.ts} +9 -9
- package/dist/index.d.cts +3 -65
- package/dist/index.d.ts +3 -65
- package/dist/oauth2/index.cjs +1 -1
- package/dist/oauth2/index.d.cts +2 -2
- package/dist/oauth2/index.d.ts +2 -2
- package/dist/oauth2/index.js +1 -1
- package/dist/{oauth2-C8-hfKTF.cjs → oauth2-C4Pt8KMZ.cjs} +87 -87
- package/dist/{oauth2-CjVUvPq7.js → oauth2-CP3eVHS_.js} +88 -88
- package/dist/social-providers/index.cjs +963 -888
- package/dist/social-providers/index.d.cts +3 -4
- package/dist/social-providers/index.d.ts +3 -4
- package/dist/social-providers/index.js +1023 -948
- package/package.json +4 -3
- package/src/api/index.ts +3 -3
- package/src/context/endpoint-context.ts +1 -1
- package/src/context/index.ts +7 -7
- package/src/context/transaction.ts +2 -2
- package/src/db/adapter/index.ts +146 -128
- package/src/db/index.ts +11 -11
- package/src/db/plugin.ts +3 -3
- package/src/db/type.ts +47 -41
- package/src/env/index.ts +9 -9
- package/src/env/logger.test.ts +2 -2
- package/src/env/logger.ts +11 -9
- package/src/error/index.ts +1 -1
- package/src/oauth2/client-credentials-token.ts +9 -9
- package/src/oauth2/create-authorization-url.ts +12 -12
- package/src/oauth2/index.ts +10 -11
- package/src/oauth2/oauth-provider.ts +91 -74
- package/src/oauth2/refresh-access-token.ts +12 -12
- package/src/oauth2/validate-authorization-code.ts +13 -13
- package/src/social-providers/apple.ts +6 -6
- package/src/social-providers/atlassian.ts +23 -18
- package/src/social-providers/cognito.ts +17 -14
- package/src/social-providers/discord.ts +6 -6
- package/src/social-providers/dropbox.ts +3 -3
- package/src/social-providers/facebook.ts +10 -7
- package/src/social-providers/figma.ts +8 -5
- package/src/social-providers/github.ts +2 -2
- package/src/social-providers/gitlab.ts +7 -7
- package/src/social-providers/google.ts +15 -12
- package/src/social-providers/huggingface.ts +25 -23
- package/src/social-providers/index.ts +29 -26
- package/src/social-providers/kakao.ts +39 -39
- package/src/social-providers/kick.ts +3 -3
- package/src/social-providers/line.ts +10 -10
- package/src/social-providers/linear.ts +4 -4
- package/src/social-providers/linkedin.ts +3 -3
- package/src/social-providers/microsoft-entra-id.ts +15 -13
- package/src/social-providers/naver.ts +3 -3
- package/src/social-providers/notion.ts +9 -7
- package/src/social-providers/paybin.ts +122 -0
- package/src/social-providers/paypal.ts +29 -27
- package/src/social-providers/polar.ts +20 -18
- package/src/social-providers/reddit.ts +4 -4
- package/src/social-providers/roblox.ts +11 -8
- package/src/social-providers/salesforce.ts +22 -17
- package/src/social-providers/slack.ts +3 -3
- package/src/social-providers/spotify.ts +3 -3
- package/src/social-providers/tiktok.ts +30 -28
- package/src/social-providers/twitch.ts +6 -6
- package/src/social-providers/twitter.ts +47 -43
- package/src/social-providers/vk.ts +11 -10
- package/src/social-providers/zoom.ts +15 -13
- package/src/types/context.ts +23 -17
- package/src/types/index.ts +11 -10
- package/src/types/init-options.ts +1037 -932
- package/src/types/plugin-client.ts +44 -13
- package/src/types/plugin.ts +66 -52
- package/dist/helper-BH5srn6K.d.ts +0 -6
- package/dist/helper-ChPUVnMr.d.cts +0 -6
- package/dist/index-BCxkjvux.d.cts +0 -344
- package/dist/index-CZCOI9An.d.ts +0 -344
- package/dist/index-Cg7SVnu9.d.cts +0 -4645
- package/dist/index-DQNPxXof.d.ts +0 -262
- package/dist/index-DXj1sY8B.d.cts +0 -1772
- package/dist/index-DgTKobWC.d.ts +0 -1772
- package/dist/index-RfHoxHB4.d.ts +0 -4531
- package/dist/index-daoIWR6L.d.cts +0 -262
- /package/dist/{index-CR-gJyzm.d.ts → index-BzepAavo.d.cts} +0 -0
- /package/dist/{index-CilaMiAm.d.cts → index-DT7CRnvv.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { base64 } from "@better-auth/utils/base64";
|
|
1
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
3
|
import { jwtVerify } from "jose";
|
|
3
4
|
import type { ProviderOptions } from "./index";
|
|
4
5
|
import { getOAuth2Tokens } from "./index";
|
|
5
|
-
import { base64 } from "@better-auth/utils/base64";
|
|
6
6
|
|
|
7
7
|
export function createAuthorizationCodeRequest({
|
|
8
8
|
code,
|
|
@@ -18,12 +18,12 @@ export function createAuthorizationCodeRequest({
|
|
|
18
18
|
code: string;
|
|
19
19
|
redirectURI: string;
|
|
20
20
|
options: Partial<ProviderOptions>;
|
|
21
|
-
codeVerifier?: string;
|
|
22
|
-
deviceId?: string;
|
|
23
|
-
authentication?: "basic" | "post";
|
|
24
|
-
headers?: Record<string, string
|
|
25
|
-
additionalParams?: Record<string, string
|
|
26
|
-
resource?: string | string[];
|
|
21
|
+
codeVerifier?: string | undefined;
|
|
22
|
+
deviceId?: string | undefined;
|
|
23
|
+
authentication?: ("basic" | "post") | undefined;
|
|
24
|
+
headers?: Record<string, string> | undefined;
|
|
25
|
+
additionalParams?: Record<string, string> | undefined;
|
|
26
|
+
resource?: (string | string[]) | undefined;
|
|
27
27
|
}) {
|
|
28
28
|
const body = new URLSearchParams();
|
|
29
29
|
const requestHeaders: Record<string, any> = {
|
|
@@ -91,13 +91,13 @@ export async function validateAuthorizationCode({
|
|
|
91
91
|
code: string;
|
|
92
92
|
redirectURI: string;
|
|
93
93
|
options: Partial<ProviderOptions>;
|
|
94
|
-
codeVerifier?: string;
|
|
95
|
-
deviceId?: string;
|
|
94
|
+
codeVerifier?: string | undefined;
|
|
95
|
+
deviceId?: string | undefined;
|
|
96
96
|
tokenEndpoint: string;
|
|
97
|
-
authentication?: "basic" | "post";
|
|
98
|
-
headers?: Record<string, string
|
|
99
|
-
additionalParams?: Record<string, string
|
|
100
|
-
resource?: string | string[];
|
|
97
|
+
authentication?: ("basic" | "post") | undefined;
|
|
98
|
+
headers?: Record<string, string> | undefined;
|
|
99
|
+
additionalParams?: Record<string, string> | undefined;
|
|
100
|
+
resource?: (string | string[]) | undefined;
|
|
101
101
|
}) {
|
|
102
102
|
const { body, headers: requestHeaders } = createAuthorizationCodeRequest({
|
|
103
103
|
code,
|
|
@@ -3,8 +3,8 @@ import { APIError } from "better-call";
|
|
|
3
3
|
import { decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
4
4
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
5
|
import {
|
|
6
|
-
refreshAccessToken,
|
|
7
6
|
createAuthorizationURL,
|
|
7
|
+
refreshAccessToken,
|
|
8
8
|
validateAuthorizationCode,
|
|
9
9
|
} from "../oauth2";
|
|
10
10
|
export interface AppleProfile {
|
|
@@ -52,7 +52,7 @@ export interface AppleProfile {
|
|
|
52
52
|
* The URL to the user's profile picture.
|
|
53
53
|
*/
|
|
54
54
|
picture: string;
|
|
55
|
-
user?: AppleNonConformUser;
|
|
55
|
+
user?: AppleNonConformUser | undefined;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -70,8 +70,8 @@ export interface AppleNonConformUser {
|
|
|
70
70
|
|
|
71
71
|
export interface AppleOptions extends ProviderOptions<AppleProfile> {
|
|
72
72
|
clientId: string;
|
|
73
|
-
appBundleIdentifier?: string;
|
|
74
|
-
audience?: string | string[];
|
|
73
|
+
appBundleIdentifier?: string | undefined;
|
|
74
|
+
audience?: (string | string[]) | undefined;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export const apple = (options: AppleOptions) => {
|
|
@@ -81,8 +81,8 @@ export const apple = (options: AppleOptions) => {
|
|
|
81
81
|
name: "Apple",
|
|
82
82
|
async createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
83
83
|
const _scope = options.disableDefaultScope ? [] : ["email", "name"];
|
|
84
|
-
options.scope
|
|
85
|
-
scopes
|
|
84
|
+
if (options.scope) _scope.push(...options.scope);
|
|
85
|
+
if (scopes) _scope.push(...scopes);
|
|
86
86
|
const url = await createAuthorizationURL({
|
|
87
87
|
id: "apple",
|
|
88
88
|
options,
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { logger } from "../env";
|
|
2
3
|
import { BetterAuthError } from "../error";
|
|
3
4
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
createAuthorizationURL,
|
|
7
|
+
refreshAccessToken,
|
|
8
|
+
validateAuthorizationCode,
|
|
9
|
+
} from "../oauth2";
|
|
7
10
|
|
|
8
11
|
export interface AtlassianProfile {
|
|
9
|
-
account_type?: string;
|
|
12
|
+
account_type?: string | undefined;
|
|
10
13
|
account_id: string;
|
|
11
|
-
email?: string;
|
|
14
|
+
email?: string | undefined;
|
|
12
15
|
name: string;
|
|
13
|
-
picture?: string;
|
|
14
|
-
nickname?: string;
|
|
15
|
-
locale?: string;
|
|
16
|
-
extended_profile?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
picture?: string | undefined;
|
|
17
|
+
nickname?: string | undefined;
|
|
18
|
+
locale?: string | undefined;
|
|
19
|
+
extended_profile?:
|
|
20
|
+
| {
|
|
21
|
+
job_title?: string;
|
|
22
|
+
organization?: string;
|
|
23
|
+
department?: string;
|
|
24
|
+
location?: string;
|
|
25
|
+
}
|
|
26
|
+
| undefined;
|
|
22
27
|
}
|
|
23
28
|
export interface AtlassianOptions extends ProviderOptions<AtlassianProfile> {
|
|
24
29
|
clientId: string;
|
|
@@ -41,8 +46,8 @@ export const atlassian = (options: AtlassianOptions) => {
|
|
|
41
46
|
const _scopes = options.disableDefaultScope
|
|
42
47
|
? []
|
|
43
48
|
: ["read:jira-user", "offline_access"];
|
|
44
|
-
options.scope
|
|
45
|
-
scopes
|
|
49
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
50
|
+
if (scopes) _scopes.push(...scopes);
|
|
46
51
|
|
|
47
52
|
return createAuthorizationURL({
|
|
48
53
|
id: "atlassian",
|
|
@@ -95,8 +100,8 @@ export const atlassian = (options: AtlassianOptions) => {
|
|
|
95
100
|
const { data: profile } = await betterFetch<{
|
|
96
101
|
account_id: string;
|
|
97
102
|
name: string;
|
|
98
|
-
email?: string;
|
|
99
|
-
picture?: string;
|
|
103
|
+
email?: string | undefined;
|
|
104
|
+
picture?: string | undefined;
|
|
100
105
|
}>("https://api.atlassian.com/me", {
|
|
101
106
|
headers: { Authorization: `Bearer ${token.accessToken}` },
|
|
102
107
|
});
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { APIError } from "better-call";
|
|
2
3
|
import { decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
4
|
+
import { logger } from "../env";
|
|
3
5
|
import { BetterAuthError } from "../error";
|
|
4
6
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
createAuthorizationURL,
|
|
9
|
+
refreshAccessToken,
|
|
10
|
+
validateAuthorizationCode,
|
|
11
|
+
} from "../oauth2";
|
|
9
12
|
|
|
10
13
|
export interface CognitoProfile {
|
|
11
14
|
sub: string;
|
|
12
15
|
email: string;
|
|
13
16
|
email_verified: boolean;
|
|
14
17
|
name: string;
|
|
15
|
-
given_name?: string;
|
|
16
|
-
family_name?: string;
|
|
17
|
-
picture?: string;
|
|
18
|
-
username?: string;
|
|
19
|
-
locale?: string;
|
|
20
|
-
phone_number?: string;
|
|
21
|
-
phone_number_verified?: boolean;
|
|
18
|
+
given_name?: string | undefined;
|
|
19
|
+
family_name?: string | undefined;
|
|
20
|
+
picture?: string | undefined;
|
|
21
|
+
username?: string | undefined;
|
|
22
|
+
locale?: string | undefined;
|
|
23
|
+
phone_number?: string | undefined;
|
|
24
|
+
phone_number_verified?: boolean | undefined;
|
|
22
25
|
aud: string;
|
|
23
26
|
iss: string;
|
|
24
27
|
exp: number;
|
|
@@ -38,7 +41,7 @@ export interface CognitoOptions extends ProviderOptions<CognitoProfile> {
|
|
|
38
41
|
*/
|
|
39
42
|
region: string;
|
|
40
43
|
userPoolId: string;
|
|
41
|
-
requireClientSecret?: boolean;
|
|
44
|
+
requireClientSecret?: boolean | undefined;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
export const cognito = (options: CognitoOptions) => {
|
|
@@ -74,8 +77,8 @@ export const cognito = (options: CognitoOptions) => {
|
|
|
74
77
|
const _scopes = options.disableDefaultScope
|
|
75
78
|
? []
|
|
76
79
|
: ["openid", "profile", "email"];
|
|
77
|
-
options.scope
|
|
78
|
-
scopes
|
|
80
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
81
|
+
if (scopes) _scopes.push(...scopes);
|
|
79
82
|
|
|
80
83
|
const url = await createAuthorizationURL({
|
|
81
84
|
id: "cognito",
|
|
@@ -16,12 +16,12 @@ export interface DiscordProfile extends Record<string, any> {
|
|
|
16
16
|
*/
|
|
17
17
|
avatar: string | null;
|
|
18
18
|
/** whether the user belongs to an OAuth2 application */
|
|
19
|
-
bot?: boolean;
|
|
19
|
+
bot?: boolean | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* whether the user is an Official Discord System user (part of the urgent
|
|
22
22
|
* message system)
|
|
23
23
|
*/
|
|
24
|
-
system?: boolean;
|
|
24
|
+
system?: boolean | undefined;
|
|
25
25
|
/** whether the user has two factor enabled on their account */
|
|
26
26
|
mfa_enabled: boolean;
|
|
27
27
|
/**
|
|
@@ -75,8 +75,8 @@ export interface DiscordProfile extends Record<string, any> {
|
|
|
75
75
|
|
|
76
76
|
export interface DiscordOptions extends ProviderOptions<DiscordProfile> {
|
|
77
77
|
clientId: string;
|
|
78
|
-
prompt?: "none" | "consent";
|
|
79
|
-
permissions?: number;
|
|
78
|
+
prompt?: ("none" | "consent") | undefined;
|
|
79
|
+
permissions?: number | undefined;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export const discord = (options: DiscordOptions) => {
|
|
@@ -85,8 +85,8 @@ export const discord = (options: DiscordOptions) => {
|
|
|
85
85
|
name: "Discord",
|
|
86
86
|
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
87
87
|
const _scopes = options.disableDefaultScope ? [] : ["identify", "email"];
|
|
88
|
-
scopes
|
|
89
|
-
options.scope
|
|
88
|
+
if (scopes) _scopes.push(...scopes);
|
|
89
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
90
90
|
const hasBotScope = _scopes.includes("bot");
|
|
91
91
|
const permissionsParam =
|
|
92
92
|
hasBotScope && options.permissions !== undefined
|
|
@@ -22,7 +22,7 @@ export interface DropboxProfile {
|
|
|
22
22
|
|
|
23
23
|
export interface DropboxOptions extends ProviderOptions<DropboxProfile> {
|
|
24
24
|
clientId: string;
|
|
25
|
-
accessType?: "offline" | "online" | "legacy";
|
|
25
|
+
accessType?: ("offline" | "online" | "legacy") | undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const dropbox = (options: DropboxOptions) => {
|
|
@@ -38,8 +38,8 @@ export const dropbox = (options: DropboxOptions) => {
|
|
|
38
38
|
redirectURI,
|
|
39
39
|
}) => {
|
|
40
40
|
const _scopes = options.disableDefaultScope ? [] : ["account_info.read"];
|
|
41
|
-
options.scope
|
|
42
|
-
scopes
|
|
41
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
42
|
+
if (scopes) _scopes.push(...scopes);
|
|
43
43
|
const additionalParams: Record<string, string> = {};
|
|
44
44
|
if (options.accessType) {
|
|
45
45
|
additionalParams.token_access_type = options.accessType;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";
|
|
2
3
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
createAuthorizationURL,
|
|
6
|
+
refreshAccessToken,
|
|
7
|
+
validateAuthorizationCode,
|
|
8
|
+
} from "../oauth2";
|
|
6
9
|
export interface FacebookProfile {
|
|
7
10
|
id: string;
|
|
8
11
|
name: string;
|
|
@@ -25,12 +28,12 @@ export interface FacebookOptions extends ProviderOptions<FacebookProfile> {
|
|
|
25
28
|
*
|
|
26
29
|
* @default ["id", "name", "email", "picture"]
|
|
27
30
|
*/
|
|
28
|
-
fields?: string[];
|
|
31
|
+
fields?: string[] | undefined;
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* The config id to use when undergoing oauth
|
|
32
35
|
*/
|
|
33
|
-
configId?: string;
|
|
36
|
+
configId?: string | undefined;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export const facebook = (options: FacebookOptions) => {
|
|
@@ -41,8 +44,8 @@ export const facebook = (options: FacebookOptions) => {
|
|
|
41
44
|
const _scopes = options.disableDefaultScope
|
|
42
45
|
? []
|
|
43
46
|
: ["email", "public_profile"];
|
|
44
|
-
options.scope
|
|
45
|
-
scopes
|
|
47
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
48
|
+
if (scopes) _scopes.push(...scopes);
|
|
46
49
|
return await createAuthorizationURL({
|
|
47
50
|
id: "facebook",
|
|
48
51
|
options,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { logger } from "../env";
|
|
2
3
|
import { BetterAuthError } from "../error";
|
|
3
4
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
createAuthorizationURL,
|
|
7
|
+
refreshAccessToken,
|
|
8
|
+
validateAuthorizationCode,
|
|
9
|
+
} from "../oauth2";
|
|
7
10
|
|
|
8
11
|
export interface FigmaProfile {
|
|
9
12
|
id: string;
|
|
@@ -32,8 +35,8 @@ export const figma = (options: FigmaOptions) => {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
const _scopes = options.disableDefaultScope ? [] : ["file_read"];
|
|
35
|
-
options.scope
|
|
36
|
-
scopes
|
|
38
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
39
|
+
if (scopes) _scopes.push(...scopes);
|
|
37
40
|
|
|
38
41
|
const url = await createAuthorizationURL({
|
|
39
42
|
id: "figma",
|
|
@@ -65,8 +65,8 @@ export const github = (options: GithubOptions) => {
|
|
|
65
65
|
const _scopes = options.disableDefaultScope
|
|
66
66
|
? []
|
|
67
67
|
: ["read:user", "user:email"];
|
|
68
|
-
options.scope
|
|
69
|
-
scopes
|
|
68
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
69
|
+
if (scopes) _scopes.push(...scopes);
|
|
70
70
|
return createAuthorizationURL({
|
|
71
71
|
id: "github",
|
|
72
72
|
options,
|
|
@@ -2,8 +2,8 @@ import { betterFetch } from "@better-fetch/fetch";
|
|
|
2
2
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
|
-
validateAuthorizationCode,
|
|
6
5
|
refreshAccessToken,
|
|
6
|
+
validateAuthorizationCode,
|
|
7
7
|
} from "../oauth2";
|
|
8
8
|
|
|
9
9
|
export interface GitlabProfile extends Record<string, any> {
|
|
@@ -16,7 +16,7 @@ export interface GitlabProfile extends Record<string, any> {
|
|
|
16
16
|
web_url: string;
|
|
17
17
|
created_at: string;
|
|
18
18
|
bio: string;
|
|
19
|
-
location?: string;
|
|
19
|
+
location?: string | undefined;
|
|
20
20
|
public_email: string;
|
|
21
21
|
skype: string;
|
|
22
22
|
linkedin: string;
|
|
@@ -26,7 +26,7 @@ export interface GitlabProfile extends Record<string, any> {
|
|
|
26
26
|
job_title: string;
|
|
27
27
|
pronouns: string;
|
|
28
28
|
bot: boolean;
|
|
29
|
-
work_information?: string;
|
|
29
|
+
work_information?: string | undefined;
|
|
30
30
|
followers: number;
|
|
31
31
|
following: number;
|
|
32
32
|
local_time: string;
|
|
@@ -53,7 +53,7 @@ export interface GitlabProfile extends Record<string, any> {
|
|
|
53
53
|
|
|
54
54
|
export interface GitlabOptions extends ProviderOptions<GitlabProfile> {
|
|
55
55
|
clientId: string;
|
|
56
|
-
issuer?: string;
|
|
56
|
+
issuer?: string | undefined;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const cleanDoubleSlashes = (input: string = "") => {
|
|
@@ -63,7 +63,7 @@ const cleanDoubleSlashes = (input: string = "") => {
|
|
|
63
63
|
.join("://");
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const issuerToEndpoints = (issuer?: string) => {
|
|
66
|
+
const issuerToEndpoints = (issuer?: string | undefined) => {
|
|
67
67
|
let baseUrl = issuer || "https://gitlab.com";
|
|
68
68
|
return {
|
|
69
69
|
authorizationEndpoint: cleanDoubleSlashes(`${baseUrl}/oauth/authorize`),
|
|
@@ -88,8 +88,8 @@ export const gitlab = (options: GitlabOptions) => {
|
|
|
88
88
|
redirectURI,
|
|
89
89
|
}) => {
|
|
90
90
|
const _scopes = options.disableDefaultScope ? [] : ["read_user"];
|
|
91
|
-
options.scope
|
|
92
|
-
scopes
|
|
91
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
92
|
+
if (scopes) _scopes.push(...scopes);
|
|
93
93
|
return await createAuthorizationURL({
|
|
94
94
|
id: issuerId,
|
|
95
95
|
options,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
2
|
import { decodeJwt } from "jose";
|
|
3
|
+
import { logger } from "../env";
|
|
3
4
|
import { BetterAuthError } from "../error";
|
|
4
5
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
createAuthorizationURL,
|
|
8
|
+
refreshAccessToken,
|
|
9
|
+
validateAuthorizationCode,
|
|
10
|
+
} from "../oauth2";
|
|
8
11
|
|
|
9
12
|
export interface GoogleProfile {
|
|
10
13
|
aud: string;
|
|
@@ -22,13 +25,13 @@ export interface GoogleProfile {
|
|
|
22
25
|
* Western languages.
|
|
23
26
|
*/
|
|
24
27
|
given_name: string;
|
|
25
|
-
hd?: string;
|
|
28
|
+
hd?: string | undefined;
|
|
26
29
|
iat: number;
|
|
27
30
|
iss: string;
|
|
28
|
-
jti?: string;
|
|
29
|
-
locale?: string;
|
|
31
|
+
jti?: string | undefined;
|
|
32
|
+
locale?: string | undefined;
|
|
30
33
|
name: string;
|
|
31
|
-
nbf?: number;
|
|
34
|
+
nbf?: number | undefined;
|
|
32
35
|
picture: string;
|
|
33
36
|
sub: string;
|
|
34
37
|
}
|
|
@@ -38,15 +41,15 @@ export interface GoogleOptions extends ProviderOptions<GoogleProfile> {
|
|
|
38
41
|
/**
|
|
39
42
|
* The access type to use for the authorization code request
|
|
40
43
|
*/
|
|
41
|
-
accessType?: "offline" | "online";
|
|
44
|
+
accessType?: ("offline" | "online") | undefined;
|
|
42
45
|
/**
|
|
43
46
|
* The display mode to use for the authorization code request
|
|
44
47
|
*/
|
|
45
|
-
display?: "page" | "popup" | "touch" | "wap";
|
|
48
|
+
display?: ("page" | "popup" | "touch" | "wap") | undefined;
|
|
46
49
|
/**
|
|
47
50
|
* The hosted domain of the user
|
|
48
51
|
*/
|
|
49
|
-
hd?: string;
|
|
52
|
+
hd?: string | undefined;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export const google = (options: GoogleOptions) => {
|
|
@@ -73,8 +76,8 @@ export const google = (options: GoogleOptions) => {
|
|
|
73
76
|
const _scopes = options.disableDefaultScope
|
|
74
77
|
? []
|
|
75
78
|
: ["email", "profile", "openid"];
|
|
76
|
-
options.scope
|
|
77
|
-
scopes
|
|
79
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
80
|
+
if (scopes) _scopes.push(...scopes);
|
|
78
81
|
const url = await createAuthorizationURL({
|
|
79
82
|
id: "google",
|
|
80
83
|
options,
|
|
@@ -2,8 +2,8 @@ import { betterFetch } from "@better-fetch/fetch";
|
|
|
2
2
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
|
-
validateAuthorizationCode,
|
|
6
5
|
refreshAccessToken,
|
|
6
|
+
validateAuthorizationCode,
|
|
7
7
|
} from "../oauth2";
|
|
8
8
|
|
|
9
9
|
export interface HuggingFaceProfile {
|
|
@@ -12,27 +12,29 @@ export interface HuggingFaceProfile {
|
|
|
12
12
|
preferred_username: string;
|
|
13
13
|
profile: string;
|
|
14
14
|
picture: string;
|
|
15
|
-
website?: string;
|
|
16
|
-
email?: string;
|
|
17
|
-
email_verified?: boolean;
|
|
15
|
+
website?: string | undefined;
|
|
16
|
+
email?: string | undefined;
|
|
17
|
+
email_verified?: boolean | undefined;
|
|
18
18
|
isPro: boolean;
|
|
19
|
-
canPay?: boolean;
|
|
20
|
-
orgs?:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
canPay?: boolean | undefined;
|
|
20
|
+
orgs?:
|
|
21
|
+
| {
|
|
22
|
+
sub: string;
|
|
23
|
+
name: string;
|
|
24
|
+
picture: string;
|
|
25
|
+
preferred_username: string;
|
|
26
|
+
isEnterprise: boolean | "plus";
|
|
27
|
+
canPay?: boolean;
|
|
28
|
+
roleInOrg?: "admin" | "write" | "contributor" | "read";
|
|
29
|
+
pendingSSO?: boolean;
|
|
30
|
+
missingMFA?: boolean;
|
|
31
|
+
resourceGroups?: {
|
|
32
|
+
sub: string;
|
|
33
|
+
name: string;
|
|
34
|
+
role: "admin" | "write" | "contributor" | "read";
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
| undefined;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export interface HuggingFaceOptions
|
|
@@ -48,8 +50,8 @@ export const huggingface = (options: HuggingFaceOptions) => {
|
|
|
48
50
|
const _scopes = options.disableDefaultScope
|
|
49
51
|
? []
|
|
50
52
|
: ["openid", "profile", "email"];
|
|
51
|
-
options.scope
|
|
52
|
-
scopes
|
|
53
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
54
|
+
if (scopes) _scopes.push(...scopes);
|
|
53
55
|
return createAuthorizationURL({
|
|
54
56
|
id: "huggingface",
|
|
55
57
|
options,
|
|
@@ -3,33 +3,34 @@ import { apple } from "./apple";
|
|
|
3
3
|
import { atlassian } from "./atlassian";
|
|
4
4
|
import { cognito } from "./cognito";
|
|
5
5
|
import { discord } from "./discord";
|
|
6
|
+
import { dropbox } from "./dropbox";
|
|
6
7
|
import { facebook } from "./facebook";
|
|
7
8
|
import { figma } from "./figma";
|
|
8
9
|
import { github } from "./github";
|
|
10
|
+
import { gitlab } from "./gitlab";
|
|
9
11
|
import { google } from "./google";
|
|
10
|
-
import { kick } from "./kick";
|
|
11
12
|
import { huggingface } from "./huggingface";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { spotify } from "./spotify";
|
|
16
|
-
import { twitch } from "./twitch";
|
|
17
|
-
import { twitter } from "./twitter";
|
|
18
|
-
import { dropbox } from "./dropbox";
|
|
13
|
+
import { kakao } from "./kakao";
|
|
14
|
+
import { kick } from "./kick";
|
|
15
|
+
import { line } from "./line";
|
|
19
16
|
import { linear } from "./linear";
|
|
20
17
|
import { linkedin } from "./linkedin";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
18
|
+
import { microsoft } from "./microsoft-entra-id";
|
|
19
|
+
import { naver } from "./naver";
|
|
20
|
+
import { notion } from "./notion";
|
|
21
|
+
import { paybin } from "./paybin";
|
|
22
|
+
import { paypal } from "./paypal";
|
|
23
|
+
import { polar } from "./polar";
|
|
23
24
|
import { reddit } from "./reddit";
|
|
24
25
|
import { roblox } from "./roblox";
|
|
25
26
|
import { salesforce } from "./salesforce";
|
|
27
|
+
import { slack } from "./slack";
|
|
28
|
+
import { spotify } from "./spotify";
|
|
29
|
+
import { tiktok } from "./tiktok";
|
|
30
|
+
import { twitch } from "./twitch";
|
|
31
|
+
import { twitter } from "./twitter";
|
|
26
32
|
import { vk } from "./vk";
|
|
27
33
|
import { zoom } from "./zoom";
|
|
28
|
-
import { kakao } from "./kakao";
|
|
29
|
-
import { naver } from "./naver";
|
|
30
|
-
import { line } from "./line";
|
|
31
|
-
import { paypal } from "./paypal";
|
|
32
|
-
import { polar } from "./polar";
|
|
33
34
|
|
|
34
35
|
export const socialProviders = {
|
|
35
36
|
apple,
|
|
@@ -61,6 +62,7 @@ export const socialProviders = {
|
|
|
61
62
|
kakao,
|
|
62
63
|
naver,
|
|
63
64
|
line,
|
|
65
|
+
paybin,
|
|
64
66
|
paypal,
|
|
65
67
|
polar,
|
|
66
68
|
};
|
|
@@ -80,7 +82,7 @@ export type SocialProviders = {
|
|
|
80
82
|
[K in SocialProviderList[number]]?: Parameters<
|
|
81
83
|
(typeof socialProviders)[K]
|
|
82
84
|
>[0] & {
|
|
83
|
-
enabled?: boolean;
|
|
85
|
+
enabled?: boolean | undefined;
|
|
84
86
|
};
|
|
85
87
|
};
|
|
86
88
|
|
|
@@ -92,30 +94,31 @@ export * from "./dropbox";
|
|
|
92
94
|
export * from "./facebook";
|
|
93
95
|
export * from "./figma";
|
|
94
96
|
export * from "./github";
|
|
95
|
-
export * from "./linear";
|
|
96
|
-
export * from "./linkedin";
|
|
97
97
|
export * from "./gitlab";
|
|
98
98
|
export * from "./google";
|
|
99
|
+
export * from "./huggingface";
|
|
100
|
+
export * from "./kakao";
|
|
101
|
+
export * from "./kick";
|
|
99
102
|
export * from "./kick";
|
|
103
|
+
export * from "./line";
|
|
104
|
+
export * from "./linear";
|
|
105
|
+
export * from "./linkedin";
|
|
100
106
|
export * from "./linkedin";
|
|
101
107
|
export * from "./microsoft-entra-id";
|
|
108
|
+
export * from "./naver";
|
|
102
109
|
export * from "./notion";
|
|
110
|
+
export * from "./paybin";
|
|
111
|
+
export * from "./paypal";
|
|
112
|
+
export * from "./polar";
|
|
103
113
|
export * from "./reddit";
|
|
104
114
|
export * from "./roblox";
|
|
105
115
|
export * from "./salesforce";
|
|
116
|
+
export * from "./slack";
|
|
106
117
|
export * from "./spotify";
|
|
107
118
|
export * from "./tiktok";
|
|
108
119
|
export * from "./twitch";
|
|
109
120
|
export * from "./twitter";
|
|
110
121
|
export * from "./vk";
|
|
111
122
|
export * from "./zoom";
|
|
112
|
-
export * from "./kick";
|
|
113
|
-
export * from "./huggingface";
|
|
114
|
-
export * from "./slack";
|
|
115
|
-
export * from "./kakao";
|
|
116
|
-
export * from "./naver";
|
|
117
|
-
export * from "./line";
|
|
118
|
-
export * from "./paypal";
|
|
119
|
-
export * from "./polar";
|
|
120
123
|
|
|
121
124
|
export type SocialProviderList = typeof socialProviderList;
|