@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
|
@@ -2,79 +2,79 @@ 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
|
interface Partner {
|
|
10
10
|
/** Partner-specific ID (consent required: kakaotalk_message) */
|
|
11
|
-
uuid?: string;
|
|
11
|
+
uuid?: string | undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
interface Profile {
|
|
15
15
|
/** Nickname (consent required: profile/nickname) */
|
|
16
|
-
nickname?: string;
|
|
16
|
+
nickname?: string | undefined;
|
|
17
17
|
/** Thumbnail image URL (consent required: profile/profile image) */
|
|
18
|
-
thumbnail_image_url?: string;
|
|
18
|
+
thumbnail_image_url?: string | undefined;
|
|
19
19
|
/** Profile image URL (consent required: profile/profile image) */
|
|
20
|
-
profile_image_url?: string;
|
|
20
|
+
profile_image_url?: string | undefined;
|
|
21
21
|
/** Whether the profile image is the default */
|
|
22
|
-
is_default_image?: boolean;
|
|
22
|
+
is_default_image?: boolean | undefined;
|
|
23
23
|
/** Whether the nickname is the default */
|
|
24
|
-
is_default_nickname?: boolean;
|
|
24
|
+
is_default_nickname?: boolean | undefined;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
interface KakaoAccount {
|
|
28
28
|
/** Consent required: profile info (nickname/profile image) */
|
|
29
|
-
profile_needs_agreement?: boolean;
|
|
29
|
+
profile_needs_agreement?: boolean | undefined;
|
|
30
30
|
/** Consent required: nickname */
|
|
31
|
-
profile_nickname_needs_agreement?: boolean;
|
|
31
|
+
profile_nickname_needs_agreement?: boolean | undefined;
|
|
32
32
|
/** Consent required: profile image */
|
|
33
|
-
profile_image_needs_agreement?: boolean;
|
|
33
|
+
profile_image_needs_agreement?: boolean | undefined;
|
|
34
34
|
/** Profile info */
|
|
35
|
-
profile?: Profile;
|
|
35
|
+
profile?: Profile | undefined;
|
|
36
36
|
/** Consent required: name */
|
|
37
|
-
name_needs_agreement?: boolean;
|
|
37
|
+
name_needs_agreement?: boolean | undefined;
|
|
38
38
|
/** Name */
|
|
39
|
-
name?: string;
|
|
39
|
+
name?: string | undefined;
|
|
40
40
|
/** Consent required: email */
|
|
41
|
-
email_needs_agreement?: boolean;
|
|
41
|
+
email_needs_agreement?: boolean | undefined;
|
|
42
42
|
/** Email valid */
|
|
43
|
-
is_email_valid?: boolean;
|
|
43
|
+
is_email_valid?: boolean | undefined;
|
|
44
44
|
/** Email verified */
|
|
45
|
-
is_email_verified?: boolean;
|
|
45
|
+
is_email_verified?: boolean | undefined;
|
|
46
46
|
/** Email */
|
|
47
|
-
email?: string;
|
|
47
|
+
email?: string | undefined;
|
|
48
48
|
/** Consent required: age range */
|
|
49
|
-
age_range_needs_agreement?: boolean;
|
|
49
|
+
age_range_needs_agreement?: boolean | undefined;
|
|
50
50
|
/** Age range */
|
|
51
|
-
age_range?: string;
|
|
51
|
+
age_range?: string | undefined;
|
|
52
52
|
/** Consent required: birth year */
|
|
53
|
-
birthyear_needs_agreement?: boolean;
|
|
53
|
+
birthyear_needs_agreement?: boolean | undefined;
|
|
54
54
|
/** Birth year (YYYY) */
|
|
55
|
-
birthyear?: string;
|
|
55
|
+
birthyear?: string | undefined;
|
|
56
56
|
/** Consent required: birthday */
|
|
57
|
-
birthday_needs_agreement?: boolean;
|
|
57
|
+
birthday_needs_agreement?: boolean | undefined;
|
|
58
58
|
/** Birthday (MMDD) */
|
|
59
|
-
birthday?: string;
|
|
59
|
+
birthday?: string | undefined;
|
|
60
60
|
/** Birthday type (SOLAR/LUNAR) */
|
|
61
|
-
birthday_type?: string;
|
|
61
|
+
birthday_type?: string | undefined;
|
|
62
62
|
/** Whether birthday is in a leap month */
|
|
63
|
-
is_leap_month?: boolean;
|
|
63
|
+
is_leap_month?: boolean | undefined;
|
|
64
64
|
/** Consent required: gender */
|
|
65
|
-
gender_needs_agreement?: boolean;
|
|
65
|
+
gender_needs_agreement?: boolean | undefined;
|
|
66
66
|
/** Gender (male/female) */
|
|
67
|
-
gender?: string;
|
|
67
|
+
gender?: string | undefined;
|
|
68
68
|
/** Consent required: phone number */
|
|
69
|
-
phone_number_needs_agreement?: boolean;
|
|
69
|
+
phone_number_needs_agreement?: boolean | undefined;
|
|
70
70
|
/** Phone number */
|
|
71
|
-
phone_number?: string;
|
|
71
|
+
phone_number?: string | undefined;
|
|
72
72
|
/** Consent required: CI */
|
|
73
|
-
ci_needs_agreement?: boolean;
|
|
73
|
+
ci_needs_agreement?: boolean | undefined;
|
|
74
74
|
/** CI (unique identifier) */
|
|
75
|
-
ci?: string;
|
|
75
|
+
ci?: string | undefined;
|
|
76
76
|
/** CI authentication time (UTC) */
|
|
77
|
-
ci_authenticated_at?: string;
|
|
77
|
+
ci_authenticated_at?: string | undefined;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export interface KakaoProfile {
|
|
@@ -84,17 +84,17 @@ export interface KakaoProfile {
|
|
|
84
84
|
* Whether the user has signed up (only present if auto-connection is disabled)
|
|
85
85
|
* false: preregistered, true: registered
|
|
86
86
|
*/
|
|
87
|
-
has_signed_up?: boolean;
|
|
87
|
+
has_signed_up?: boolean | undefined;
|
|
88
88
|
/** UTC datetime when the user connected the service */
|
|
89
|
-
connected_at?: string;
|
|
89
|
+
connected_at?: string | undefined;
|
|
90
90
|
/** UTC datetime when the user signed up via Kakao Sync */
|
|
91
|
-
synched_at?: string;
|
|
91
|
+
synched_at?: string | undefined;
|
|
92
92
|
/** Custom user properties */
|
|
93
|
-
properties?: Record<string, any
|
|
93
|
+
properties?: Record<string, any> | undefined;
|
|
94
94
|
/** Kakao account info */
|
|
95
95
|
kakao_account: KakaoAccount;
|
|
96
96
|
/** Partner info */
|
|
97
|
-
for_partner?: Partner;
|
|
97
|
+
for_partner?: Partner | undefined;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export interface KakaoOptions extends ProviderOptions<KakaoProfile> {
|
|
@@ -109,8 +109,8 @@ export const kakao = (options: KakaoOptions) => {
|
|
|
109
109
|
const _scopes = options.disableDefaultScope
|
|
110
110
|
? []
|
|
111
111
|
: ["account_email", "profile_image", "profile_nickname"];
|
|
112
|
-
options.scope
|
|
113
|
-
scopes
|
|
112
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
113
|
+
if (scopes) _scopes.push(...scopes);
|
|
114
114
|
return createAuthorizationURL({
|
|
115
115
|
id: "kakao",
|
|
116
116
|
options,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import { createAuthorizationURL, validateAuthorizationCode } from "../oauth2";
|
|
3
2
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
|
+
import { createAuthorizationURL, validateAuthorizationCode } from "../oauth2";
|
|
4
4
|
|
|
5
5
|
export interface KickProfile {
|
|
6
6
|
/**
|
|
@@ -31,8 +31,8 @@ export const kick = (options: KickOptions) => {
|
|
|
31
31
|
name: "Kick",
|
|
32
32
|
createAuthorizationURL({ state, scopes, redirectURI, codeVerifier }) {
|
|
33
33
|
const _scopes = options.disableDefaultScope ? [] : ["user:read"];
|
|
34
|
-
options.scope
|
|
35
|
-
scopes
|
|
34
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
35
|
+
if (scopes) _scopes.push(...scopes);
|
|
36
36
|
|
|
37
37
|
return createAuthorizationURL({
|
|
38
38
|
id: "kick",
|
|
@@ -13,18 +13,18 @@ export interface LineIdTokenPayload {
|
|
|
13
13
|
aud: string;
|
|
14
14
|
exp: number;
|
|
15
15
|
iat: number;
|
|
16
|
-
name?: string;
|
|
17
|
-
picture?: string;
|
|
18
|
-
email?: string;
|
|
19
|
-
amr?: string[];
|
|
20
|
-
nonce?: string;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
picture?: string | undefined;
|
|
18
|
+
email?: string | undefined;
|
|
19
|
+
amr?: string[] | undefined;
|
|
20
|
+
nonce?: string | undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface LineUserInfo {
|
|
24
24
|
sub: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
picture?: string;
|
|
27
|
-
email?: string;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
picture?: string | undefined;
|
|
27
|
+
email?: string | undefined;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface LineOptions
|
|
@@ -60,8 +60,8 @@ export const line = (options: LineOptions) => {
|
|
|
60
60
|
const _scopes = options.disableDefaultScope
|
|
61
61
|
? []
|
|
62
62
|
: ["openid", "profile", "email"];
|
|
63
|
-
options.scope
|
|
64
|
-
scopes
|
|
63
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
64
|
+
if (scopes) _scopes.push(...scopes);
|
|
65
65
|
return await createAuthorizationURL({
|
|
66
66
|
id: "line",
|
|
67
67
|
options,
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
validateAuthorizationCode,
|
|
7
7
|
} from "../oauth2";
|
|
8
8
|
|
|
9
|
-
interface LinearUser {
|
|
9
|
+
export interface LinearUser {
|
|
10
10
|
id: string;
|
|
11
11
|
name: string;
|
|
12
12
|
email: string;
|
|
13
|
-
avatarUrl?: string;
|
|
13
|
+
avatarUrl?: string | undefined;
|
|
14
14
|
active: boolean;
|
|
15
15
|
createdAt: string;
|
|
16
16
|
updatedAt: string;
|
|
@@ -33,8 +33,8 @@ export const linear = (options: LinearOptions) => {
|
|
|
33
33
|
name: "Linear",
|
|
34
34
|
createAuthorizationURL({ state, scopes, loginHint, redirectURI }) {
|
|
35
35
|
const _scopes = options.disableDefaultScope ? [] : ["read"];
|
|
36
|
-
options.scope
|
|
37
|
-
scopes
|
|
36
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
37
|
+
if (scopes) _scopes.push(...scopes);
|
|
38
38
|
return createAuthorizationURL({
|
|
39
39
|
id: "linear",
|
|
40
40
|
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 LinkedInProfile {
|
|
@@ -41,8 +41,8 @@ export const linkedin = (options: LinkedInOptions) => {
|
|
|
41
41
|
const _scopes = options.disableDefaultScope
|
|
42
42
|
? []
|
|
43
43
|
: ["profile", "email", "openid"];
|
|
44
|
-
options.scope
|
|
45
|
-
scopes
|
|
44
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
45
|
+
if (scopes) _scopes.push(...scopes);
|
|
46
46
|
return await createAuthorizationURL({
|
|
47
47
|
id: "linkedin",
|
|
48
48
|
options,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { base64 } from "@better-auth/utils/base64";
|
|
2
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
+
import { decodeJwt } from "jose";
|
|
4
|
+
import { logger } from "../env";
|
|
5
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
1
6
|
import {
|
|
2
|
-
validateAuthorizationCode,
|
|
3
7
|
createAuthorizationURL,
|
|
4
8
|
refreshAccessToken,
|
|
9
|
+
validateAuthorizationCode,
|
|
5
10
|
} from "../oauth2";
|
|
6
|
-
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
7
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
8
|
-
import { logger } from "../env";
|
|
9
|
-
import { decodeJwt } from "jose";
|
|
10
|
-
import { base64 } from "@better-auth/utils/base64";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @see [Microsoft Identity Platform - Optional claims reference](https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims-reference)
|
|
@@ -118,21 +118,23 @@ export interface MicrosoftOptions
|
|
|
118
118
|
* The tenant ID of the Microsoft account
|
|
119
119
|
* @default "common"
|
|
120
120
|
*/
|
|
121
|
-
tenantId?: string;
|
|
121
|
+
tenantId?: string | undefined;
|
|
122
122
|
/**
|
|
123
123
|
* The authentication authority URL. Use the default "https://login.microsoftonline.com" for standard Entra ID or "https://<tenant-id>.ciamlogin.com" for CIAM scenarios.
|
|
124
124
|
* @default "https://login.microsoftonline.com"
|
|
125
125
|
*/
|
|
126
|
-
authority?: string;
|
|
126
|
+
authority?: string | undefined;
|
|
127
127
|
/**
|
|
128
128
|
* The size of the profile photo
|
|
129
129
|
* @default 48
|
|
130
130
|
*/
|
|
131
|
-
profilePhotoSize?:
|
|
131
|
+
profilePhotoSize?:
|
|
132
|
+
| (48 | 64 | 96 | 120 | 240 | 360 | 432 | 504 | 648)
|
|
133
|
+
| undefined;
|
|
132
134
|
/**
|
|
133
135
|
* Disable profile photo
|
|
134
136
|
*/
|
|
135
|
-
disableProfilePhoto?: boolean;
|
|
137
|
+
disableProfilePhoto?: boolean | undefined;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
export const microsoft = (options: MicrosoftOptions) => {
|
|
@@ -147,8 +149,8 @@ export const microsoft = (options: MicrosoftOptions) => {
|
|
|
147
149
|
const scopes = options.disableDefaultScope
|
|
148
150
|
? []
|
|
149
151
|
: ["openid", "profile", "email", "User.Read", "offline_access"];
|
|
150
|
-
options.scope
|
|
151
|
-
data.scopes
|
|
152
|
+
if (options.scope) scopes.push(...options.scope);
|
|
153
|
+
if (data.scopes) scopes.push(...data.scopes);
|
|
152
154
|
return createAuthorizationURL({
|
|
153
155
|
id: "microsoft",
|
|
154
156
|
options,
|
|
@@ -224,7 +226,7 @@ export const microsoft = (options: MicrosoftOptions) => {
|
|
|
224
226
|
const scopes = options.disableDefaultScope
|
|
225
227
|
? []
|
|
226
228
|
: ["openid", "profile", "email", "User.Read", "offline_access"];
|
|
227
|
-
options.scope
|
|
229
|
+
if (options.scope) scopes.push(...options.scope);
|
|
228
230
|
|
|
229
231
|
return refreshAccessToken({
|
|
230
232
|
refreshToken,
|
|
@@ -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 NaverProfile {
|
|
@@ -45,8 +45,8 @@ export const naver = (options: NaverOptions) => {
|
|
|
45
45
|
name: "Naver",
|
|
46
46
|
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
47
47
|
const _scopes = options.disableDefaultScope ? [] : ["profile", "email"];
|
|
48
|
-
options.scope
|
|
49
|
-
scopes
|
|
48
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
49
|
+
if (scopes) _scopes.push(...scopes);
|
|
50
50
|
return createAuthorizationURL({
|
|
51
51
|
id: "naver",
|
|
52
52
|
options,
|
|
@@ -10,11 +10,13 @@ export interface NotionProfile {
|
|
|
10
10
|
object: "user";
|
|
11
11
|
id: string;
|
|
12
12
|
type: "person" | "bot";
|
|
13
|
-
name?: string;
|
|
14
|
-
avatar_url?: string;
|
|
15
|
-
person?:
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
avatar_url?: string | undefined;
|
|
15
|
+
person?:
|
|
16
|
+
| {
|
|
17
|
+
email?: string;
|
|
18
|
+
}
|
|
19
|
+
| undefined;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export interface NotionOptions extends ProviderOptions<NotionProfile> {
|
|
@@ -28,8 +30,8 @@ export const notion = (options: NotionOptions) => {
|
|
|
28
30
|
name: "Notion",
|
|
29
31
|
createAuthorizationURL({ state, scopes, loginHint, redirectURI }) {
|
|
30
32
|
const _scopes: string[] = options.disableDefaultScope ? [] : [];
|
|
31
|
-
options.scope
|
|
32
|
-
scopes
|
|
33
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
34
|
+
if (scopes) _scopes.push(...scopes);
|
|
33
35
|
return createAuthorizationURL({
|
|
34
36
|
id: "notion",
|
|
35
37
|
options,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { decodeJwt } from "jose";
|
|
2
|
+
import { logger } from "../env";
|
|
3
|
+
import { BetterAuthError } from "../error";
|
|
4
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
|
+
import {
|
|
6
|
+
createAuthorizationURL,
|
|
7
|
+
refreshAccessToken,
|
|
8
|
+
validateAuthorizationCode,
|
|
9
|
+
} from "../oauth2";
|
|
10
|
+
|
|
11
|
+
export interface PaybinProfile {
|
|
12
|
+
sub: string;
|
|
13
|
+
email: string;
|
|
14
|
+
email_verified?: boolean | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
preferred_username?: string | undefined;
|
|
17
|
+
picture?: string | undefined;
|
|
18
|
+
given_name?: string | undefined;
|
|
19
|
+
family_name?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PaybinOptions extends ProviderOptions<PaybinProfile> {
|
|
23
|
+
clientId: string;
|
|
24
|
+
/**
|
|
25
|
+
* The issuer URL of your Paybin OAuth server
|
|
26
|
+
* @default "https://idp.paybin.io"
|
|
27
|
+
*/
|
|
28
|
+
issuer?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const paybin = (options: PaybinOptions) => {
|
|
32
|
+
const issuer = options.issuer || "https://idp.paybin.io";
|
|
33
|
+
const authorizationEndpoint = `${issuer}/oauth2/authorize`;
|
|
34
|
+
const tokenEndpoint = `${issuer}/oauth2/token`;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id: "paybin",
|
|
38
|
+
name: "Paybin",
|
|
39
|
+
async createAuthorizationURL({
|
|
40
|
+
state,
|
|
41
|
+
scopes,
|
|
42
|
+
codeVerifier,
|
|
43
|
+
redirectURI,
|
|
44
|
+
loginHint,
|
|
45
|
+
}) {
|
|
46
|
+
if (!options.clientId || !options.clientSecret) {
|
|
47
|
+
logger.error(
|
|
48
|
+
"Client Id and Client Secret is required for Paybin. Make sure to provide them in the options.",
|
|
49
|
+
);
|
|
50
|
+
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
51
|
+
}
|
|
52
|
+
if (!codeVerifier) {
|
|
53
|
+
throw new BetterAuthError("codeVerifier is required for Paybin");
|
|
54
|
+
}
|
|
55
|
+
const _scopes = options.disableDefaultScope
|
|
56
|
+
? []
|
|
57
|
+
: ["openid", "email", "profile"];
|
|
58
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
59
|
+
if (scopes) _scopes.push(...scopes);
|
|
60
|
+
const url = await createAuthorizationURL({
|
|
61
|
+
id: "paybin",
|
|
62
|
+
options,
|
|
63
|
+
authorizationEndpoint,
|
|
64
|
+
scopes: _scopes,
|
|
65
|
+
state,
|
|
66
|
+
codeVerifier,
|
|
67
|
+
redirectURI,
|
|
68
|
+
prompt: options.prompt,
|
|
69
|
+
loginHint,
|
|
70
|
+
});
|
|
71
|
+
return url;
|
|
72
|
+
},
|
|
73
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
74
|
+
return validateAuthorizationCode({
|
|
75
|
+
code,
|
|
76
|
+
codeVerifier,
|
|
77
|
+
redirectURI,
|
|
78
|
+
options,
|
|
79
|
+
tokenEndpoint,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
refreshAccessToken: options.refreshAccessToken
|
|
83
|
+
? options.refreshAccessToken
|
|
84
|
+
: async (refreshToken) => {
|
|
85
|
+
return refreshAccessToken({
|
|
86
|
+
refreshToken,
|
|
87
|
+
options: {
|
|
88
|
+
clientId: options.clientId,
|
|
89
|
+
clientKey: options.clientKey,
|
|
90
|
+
clientSecret: options.clientSecret,
|
|
91
|
+
},
|
|
92
|
+
tokenEndpoint,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
async getUserInfo(token) {
|
|
96
|
+
if (options.getUserInfo) {
|
|
97
|
+
return options.getUserInfo(token);
|
|
98
|
+
}
|
|
99
|
+
if (!token.idToken) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const user = decodeJwt(token.idToken) as PaybinProfile;
|
|
103
|
+
const userMap = await options.mapProfileToUser?.(user);
|
|
104
|
+
return {
|
|
105
|
+
user: {
|
|
106
|
+
id: user.sub,
|
|
107
|
+
name:
|
|
108
|
+
user.name ||
|
|
109
|
+
user.preferred_username ||
|
|
110
|
+
(user.email ? user.email.split("@")[0] : "User") ||
|
|
111
|
+
"User",
|
|
112
|
+
email: user.email,
|
|
113
|
+
image: user.picture,
|
|
114
|
+
emailVerified: user.email_verified || false,
|
|
115
|
+
...userMap,
|
|
116
|
+
},
|
|
117
|
+
data: user,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
options,
|
|
121
|
+
} satisfies OAuthProvider<PaybinProfile>;
|
|
122
|
+
};
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
+
import { base64 } from "@better-auth/utils/base64";
|
|
1
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
+
import { decodeJwt } from "jose";
|
|
4
|
+
import { logger } from "../env";
|
|
2
5
|
import { BetterAuthError } from "../error";
|
|
3
6
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
4
7
|
import { createAuthorizationURL } from "../oauth2";
|
|
5
|
-
import { logger } from "../env";
|
|
6
|
-
import { decodeJwt } from "jose";
|
|
7
|
-
import { base64 } from "@better-auth/utils/base64";
|
|
8
8
|
|
|
9
9
|
export interface PayPalProfile {
|
|
10
10
|
user_id: string;
|
|
11
11
|
name: string;
|
|
12
12
|
given_name: string;
|
|
13
13
|
family_name: string;
|
|
14
|
-
middle_name?: string;
|
|
15
|
-
picture?: string;
|
|
14
|
+
middle_name?: string | undefined;
|
|
15
|
+
picture?: string | undefined;
|
|
16
16
|
email: string;
|
|
17
17
|
email_verified: boolean;
|
|
18
|
-
gender?: string;
|
|
19
|
-
birthdate?: string;
|
|
20
|
-
zoneinfo?: string;
|
|
21
|
-
locale?: string;
|
|
22
|
-
phone_number?: string;
|
|
23
|
-
address?:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
gender?: string | undefined;
|
|
19
|
+
birthdate?: string | undefined;
|
|
20
|
+
zoneinfo?: string | undefined;
|
|
21
|
+
locale?: string | undefined;
|
|
22
|
+
phone_number?: string | undefined;
|
|
23
|
+
address?:
|
|
24
|
+
| {
|
|
25
|
+
street_address?: string;
|
|
26
|
+
locality?: string;
|
|
27
|
+
region?: string;
|
|
28
|
+
postal_code?: string;
|
|
29
|
+
country?: string;
|
|
30
|
+
}
|
|
31
|
+
| undefined;
|
|
32
|
+
verified_account?: boolean | undefined;
|
|
33
|
+
account_type?: string | undefined;
|
|
34
|
+
age_range?: string | undefined;
|
|
35
|
+
payer_id?: string | undefined;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export interface PayPalTokenResponse {
|
|
37
|
-
scope?: string;
|
|
39
|
+
scope?: string | undefined;
|
|
38
40
|
access_token: string;
|
|
39
|
-
refresh_token?: string;
|
|
41
|
+
refresh_token?: string | undefined;
|
|
40
42
|
token_type: "Bearer";
|
|
41
|
-
id_token?: string;
|
|
43
|
+
id_token?: string | undefined;
|
|
42
44
|
expires_in: number;
|
|
43
|
-
nonce?: string;
|
|
45
|
+
nonce?: string | undefined;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export interface PayPalOptions extends ProviderOptions<PayPalProfile> {
|
|
@@ -49,12 +51,12 @@ export interface PayPalOptions extends ProviderOptions<PayPalProfile> {
|
|
|
49
51
|
* PayPal environment - 'sandbox' for testing, 'live' for production
|
|
50
52
|
* @default 'sandbox'
|
|
51
53
|
*/
|
|
52
|
-
environment?: "sandbox" | "live";
|
|
54
|
+
environment?: ("sandbox" | "live") | undefined;
|
|
53
55
|
/**
|
|
54
56
|
* Whether to request shipping address information
|
|
55
57
|
* @default false
|
|
56
58
|
*/
|
|
57
|
-
requestShippingAddress?: boolean;
|
|
59
|
+
requestShippingAddress?: boolean | undefined;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
export const paypal = (options: PayPalOptions) => {
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type { OAuthProvider, ProviderOptions } from "
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
6
|
validateAuthorizationCode,
|
|
7
|
-
} from "
|
|
7
|
+
} from "../oauth2";
|
|
8
8
|
|
|
9
9
|
export interface PolarProfile {
|
|
10
10
|
id: string;
|
|
11
11
|
email: string;
|
|
12
12
|
username: string;
|
|
13
13
|
avatar_url: string;
|
|
14
|
-
github_username?: string;
|
|
15
|
-
account_id?: string;
|
|
16
|
-
public_name?: string;
|
|
17
|
-
profile_settings?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
github_username?: string | undefined;
|
|
15
|
+
account_id?: string | undefined;
|
|
16
|
+
public_name?: string | undefined;
|
|
17
|
+
profile_settings?:
|
|
18
|
+
| {
|
|
19
|
+
profile_settings_enabled?: boolean;
|
|
20
|
+
profile_settings_public_name?: string;
|
|
21
|
+
profile_settings_public_avatar?: string;
|
|
22
|
+
profile_settings_public_bio?: string;
|
|
23
|
+
profile_settings_public_location?: string;
|
|
24
|
+
profile_settings_public_website?: string;
|
|
25
|
+
profile_settings_public_twitter?: string;
|
|
26
|
+
profile_settings_public_github?: string;
|
|
27
|
+
profile_settings_public_email?: string;
|
|
28
|
+
}
|
|
29
|
+
| undefined;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export interface PolarOptions extends ProviderOptions<PolarProfile> {}
|
|
@@ -37,8 +39,8 @@ export const polar = (options: PolarOptions) => {
|
|
|
37
39
|
const _scopes = options.disableDefaultScope
|
|
38
40
|
? []
|
|
39
41
|
: ["openid", "profile", "email"];
|
|
40
|
-
options.scope
|
|
41
|
-
scopes
|
|
42
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
43
|
+
if (scopes) _scopes.push(...scopes);
|
|
42
44
|
return createAuthorizationURL({
|
|
43
45
|
id: "polar",
|
|
44
46
|
options,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { base64 } from "@better-auth/utils/base64";
|
|
1
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
3
|
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
4
|
import {
|
|
@@ -5,7 +6,6 @@ import {
|
|
|
5
6
|
getOAuth2Tokens,
|
|
6
7
|
refreshAccessToken,
|
|
7
8
|
} from "../oauth2";
|
|
8
|
-
import { base64 } from "@better-auth/utils/base64";
|
|
9
9
|
|
|
10
10
|
export interface RedditProfile {
|
|
11
11
|
id: string;
|
|
@@ -18,7 +18,7 @@ export interface RedditProfile {
|
|
|
18
18
|
|
|
19
19
|
export interface RedditOptions extends ProviderOptions<RedditProfile> {
|
|
20
20
|
clientId: string;
|
|
21
|
-
duration?: string;
|
|
21
|
+
duration?: string | undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const reddit = (options: RedditOptions) => {
|
|
@@ -27,8 +27,8 @@ export const reddit = (options: RedditOptions) => {
|
|
|
27
27
|
name: "Reddit",
|
|
28
28
|
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
29
29
|
const _scopes = options.disableDefaultScope ? [] : ["identity"];
|
|
30
|
-
options.scope
|
|
31
|
-
scopes
|
|
30
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
31
|
+
if (scopes) _scopes.push(...scopes);
|
|
32
32
|
return createAuthorizationURL({
|
|
33
33
|
id: "reddit",
|
|
34
34
|
options,
|