@better-auth/core 1.7.0-beta.7 → 1.7.0-beta.8
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/dist/api/index.d.mts +3 -3
- package/dist/context/global.mjs +1 -1
- package/dist/db/adapter/factory.mjs +1 -1
- package/dist/db/get-tables.mjs +3 -3
- package/dist/db/schema/account.d.mts +1 -1
- package/dist/db/schema/account.mjs +1 -1
- package/dist/error/codes.d.mts +0 -5
- package/dist/error/codes.mjs +0 -5
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/oauth2/create-authorization-url.d.mts +1 -4
- package/dist/oauth2/create-authorization-url.mjs +1 -4
- package/dist/oauth2/index.d.mts +3 -4
- package/dist/oauth2/index.mjs +2 -3
- package/dist/oauth2/oauth-provider.d.mts +12 -50
- package/dist/oauth2/refresh-access-token.mjs +2 -1
- package/dist/oauth2/utils.d.mts +6 -1
- package/dist/oauth2/utils.mjs +24 -2
- package/dist/oauth2/verify-id-token.d.mts +6 -5
- package/dist/oauth2/verify-id-token.mjs +2 -2
- package/dist/social-providers/apple.d.mts +1 -5
- package/dist/social-providers/apple.mjs +5 -5
- package/dist/social-providers/atlassian.d.mts +1 -5
- package/dist/social-providers/atlassian.mjs +4 -4
- package/dist/social-providers/cognito.d.mts +1 -5
- package/dist/social-providers/cognito.mjs +11 -18
- package/dist/social-providers/discord.d.mts +1 -5
- package/dist/social-providers/discord.mjs +6 -7
- package/dist/social-providers/dropbox.d.mts +1 -5
- package/dist/social-providers/dropbox.mjs +5 -5
- package/dist/social-providers/facebook.d.mts +1 -5
- package/dist/social-providers/facebook.mjs +5 -5
- package/dist/social-providers/figma.d.mts +1 -5
- package/dist/social-providers/figma.mjs +5 -5
- package/dist/social-providers/github.d.mts +1 -5
- package/dist/social-providers/github.mjs +4 -4
- package/dist/social-providers/gitlab.d.mts +1 -5
- package/dist/social-providers/gitlab.mjs +6 -6
- package/dist/social-providers/google.d.mts +8 -10
- package/dist/social-providers/google.mjs +12 -13
- package/dist/social-providers/huggingface.d.mts +1 -5
- package/dist/social-providers/huggingface.mjs +8 -8
- package/dist/social-providers/index.d.mts +35 -177
- package/dist/social-providers/kakao.d.mts +1 -5
- package/dist/social-providers/kakao.mjs +8 -8
- package/dist/social-providers/kick.d.mts +1 -5
- package/dist/social-providers/kick.mjs +4 -4
- package/dist/social-providers/line.d.mts +1 -5
- package/dist/social-providers/line.mjs +10 -10
- package/dist/social-providers/linear.d.mts +1 -5
- package/dist/social-providers/linear.mjs +4 -4
- package/dist/social-providers/linkedin.d.mts +1 -5
- package/dist/social-providers/linkedin.mjs +10 -10
- package/dist/social-providers/microsoft-entra-id.d.mts +1 -5
- package/dist/social-providers/microsoft-entra-id.mjs +10 -11
- package/dist/social-providers/naver.d.mts +1 -5
- package/dist/social-providers/naver.mjs +4 -4
- package/dist/social-providers/notion.d.mts +1 -5
- package/dist/social-providers/notion.mjs +4 -4
- package/dist/social-providers/paybin.d.mts +1 -5
- package/dist/social-providers/paybin.mjs +10 -10
- package/dist/social-providers/paypal.d.mts +1 -5
- package/dist/social-providers/paypal.mjs +2 -8
- package/dist/social-providers/polar.d.mts +1 -5
- package/dist/social-providers/polar.mjs +8 -8
- package/dist/social-providers/railway.d.mts +1 -5
- package/dist/social-providers/railway.mjs +9 -9
- package/dist/social-providers/reddit.d.mts +1 -5
- package/dist/social-providers/reddit.mjs +5 -5
- package/dist/social-providers/roblox.d.mts +1 -5
- package/dist/social-providers/roblox.mjs +5 -5
- package/dist/social-providers/salesforce.d.mts +1 -5
- package/dist/social-providers/salesforce.mjs +8 -8
- package/dist/social-providers/slack.d.mts +1 -5
- package/dist/social-providers/slack.mjs +9 -9
- package/dist/social-providers/spotify.d.mts +1 -5
- package/dist/social-providers/spotify.mjs +5 -5
- package/dist/social-providers/tiktok.d.mts +1 -5
- package/dist/social-providers/tiktok.mjs +5 -9
- package/dist/social-providers/twitch.d.mts +1 -5
- package/dist/social-providers/twitch.mjs +4 -4
- package/dist/social-providers/twitter.d.mts +1 -5
- package/dist/social-providers/twitter.mjs +9 -9
- package/dist/social-providers/vercel.d.mts +1 -5
- package/dist/social-providers/vercel.mjs +7 -4
- package/dist/social-providers/vk.d.mts +1 -5
- package/dist/social-providers/vk.mjs +5 -5
- package/dist/social-providers/wechat.d.mts +1 -5
- package/dist/social-providers/wechat.mjs +5 -9
- package/dist/social-providers/zoom.d.mts +1 -6
- package/dist/social-providers/zoom.mjs +9 -15
- package/dist/types/context.d.mts +6 -2
- package/package.json +1 -1
- package/src/db/get-tables.ts +3 -8
- package/src/db/schema/account.ts +5 -14
- package/src/error/codes.ts +0 -5
- package/src/oauth2/create-authorization-url.ts +1 -1
- package/src/oauth2/index.ts +2 -12
- package/src/oauth2/oauth-provider.ts +11 -56
- package/src/oauth2/refresh-access-token.ts +3 -2
- package/src/oauth2/utils.ts +39 -1
- package/src/oauth2/verify-id-token.ts +7 -5
- package/src/social-providers/apple.ts +8 -13
- package/src/social-providers/atlassian.ts +8 -12
- package/src/social-providers/cognito.ts +11 -18
- package/src/social-providers/discord.ts +8 -19
- package/src/social-providers/dropbox.ts +7 -13
- package/src/social-providers/facebook.ts +9 -13
- package/src/social-providers/figma.ts +9 -13
- package/src/social-providers/github.ts +8 -12
- package/src/social-providers/gitlab.ts +8 -14
- package/src/social-providers/google.ts +23 -29
- package/src/social-providers/huggingface.ts +8 -12
- package/src/social-providers/kakao.ts +8 -16
- package/src/social-providers/kick.ts +7 -12
- package/src/social-providers/line.ts +10 -14
- package/src/social-providers/linear.ts +6 -12
- package/src/social-providers/linkedin.ts +10 -14
- package/src/social-providers/microsoft-entra-id.ts +8 -18
- package/src/social-providers/naver.ts +6 -12
- package/src/social-providers/notion.ts +6 -12
- package/src/social-providers/paybin.ts +11 -14
- package/src/social-providers/paypal.ts +8 -6
- package/src/social-providers/polar.ts +8 -12
- package/src/social-providers/railway.ts +9 -13
- package/src/social-providers/reddit.ts +7 -18
- package/src/social-providers/roblox.ts +7 -18
- package/src/social-providers/salesforce.ts +8 -12
- package/src/social-providers/slack.ts +9 -18
- package/src/social-providers/spotify.ts +7 -13
- package/src/social-providers/tiktok.ts +7 -13
- package/src/social-providers/twitch.ts +8 -12
- package/src/social-providers/twitter.ts +8 -17
- package/src/social-providers/vercel.ts +10 -16
- package/src/social-providers/vk.ts +7 -13
- package/src/social-providers/wechat.ts +8 -20
- package/src/social-providers/zoom.ts +6 -19
- package/src/types/context.ts +8 -2
- package/dist/oauth2/scopes.d.mts +0 -76
- package/dist/oauth2/scopes.mjs +0 -96
- package/src/oauth2/scopes.ts +0 -118
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -25,8 +24,6 @@ export interface LinkedInOptions extends ProviderOptions<LinkedInProfile> {
|
|
|
25
24
|
clientId: string;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
const LINKEDIN_DEFAULT_SCOPES = ["profile", "email", "openid"];
|
|
29
|
-
|
|
30
27
|
export const linkedin = (options: LinkedInOptions) => {
|
|
31
28
|
const authorizationEndpoint =
|
|
32
29
|
"https://www.linkedin.com/oauth/v2/authorization";
|
|
@@ -35,24 +32,23 @@ export const linkedin = (options: LinkedInOptions) => {
|
|
|
35
32
|
return {
|
|
36
33
|
id: "linkedin",
|
|
37
34
|
name: "Linkedin",
|
|
38
|
-
|
|
39
|
-
createAuthorizationURL: ({
|
|
35
|
+
createAuthorizationURL: async ({
|
|
40
36
|
state,
|
|
41
37
|
scopes,
|
|
42
38
|
redirectURI,
|
|
43
39
|
loginHint,
|
|
44
40
|
additionalParams,
|
|
45
41
|
}) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
return createAuthorizationURL({
|
|
42
|
+
const _scopes = options.disableDefaultScope
|
|
43
|
+
? []
|
|
44
|
+
: ["profile", "email", "openid"];
|
|
45
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
46
|
+
if (scopes) _scopes.push(...scopes);
|
|
47
|
+
return await createAuthorizationURL({
|
|
52
48
|
id: "linkedin",
|
|
53
49
|
options,
|
|
54
50
|
authorizationEndpoint,
|
|
55
|
-
scopes:
|
|
51
|
+
scopes: _scopes,
|
|
56
52
|
state,
|
|
57
53
|
loginHint,
|
|
58
54
|
redirectURI,
|
|
@@ -112,5 +108,5 @@ export const linkedin = (options: LinkedInOptions) => {
|
|
|
112
108
|
};
|
|
113
109
|
},
|
|
114
110
|
options,
|
|
115
|
-
} satisfies
|
|
111
|
+
} satisfies OAuthProvider<LinkedInProfile>;
|
|
116
112
|
};
|
|
@@ -5,15 +5,14 @@ import { logger } from "../env";
|
|
|
5
5
|
import { APIError, BetterAuthError } from "../error";
|
|
6
6
|
import type {
|
|
7
7
|
ClientAssertionGetter,
|
|
8
|
+
OAuthProvider,
|
|
8
9
|
ProviderOptions,
|
|
9
10
|
TokenEndpointAuth,
|
|
10
|
-
UpstreamProvider,
|
|
11
11
|
} from "../oauth2";
|
|
12
12
|
import {
|
|
13
13
|
createAuthorizationURL,
|
|
14
14
|
getPrimaryClientId,
|
|
15
15
|
refreshAccessToken,
|
|
16
|
-
resolveRequestedScopes,
|
|
17
16
|
validateAuthorizationCode,
|
|
18
17
|
} from "../oauth2";
|
|
19
18
|
|
|
@@ -161,14 +160,6 @@ export interface MicrosoftOptions
|
|
|
161
160
|
disableProfilePhoto?: boolean;
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
const MICROSOFT_ENTRA_ID_DEFAULT_SCOPES = [
|
|
165
|
-
"openid",
|
|
166
|
-
"profile",
|
|
167
|
-
"email",
|
|
168
|
-
"User.Read",
|
|
169
|
-
"offline_access",
|
|
170
|
-
];
|
|
171
|
-
|
|
172
163
|
export const microsoft = (options: MicrosoftOptions) => {
|
|
173
164
|
const tenant = options.tenantId || "common";
|
|
174
165
|
// Trim any trailing slash so endpoint URLs and the issuer comparison below
|
|
@@ -196,7 +187,6 @@ export const microsoft = (options: MicrosoftOptions) => {
|
|
|
196
187
|
return {
|
|
197
188
|
id: "microsoft",
|
|
198
189
|
name: "Microsoft EntraID",
|
|
199
|
-
callbackPath: "/callback/microsoft",
|
|
200
190
|
createAuthorizationURL(data) {
|
|
201
191
|
// Microsoft Entra supports public clients (SPA / native apps with
|
|
202
192
|
// PKCE only), so clientSecret is intentionally not required here.
|
|
@@ -207,18 +197,18 @@ export const microsoft = (options: MicrosoftOptions) => {
|
|
|
207
197
|
);
|
|
208
198
|
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
209
199
|
}
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
);
|
|
200
|
+
const scopes = options.disableDefaultScope
|
|
201
|
+
? []
|
|
202
|
+
: ["openid", "profile", "email", "User.Read", "offline_access"];
|
|
203
|
+
if (options.scope) scopes.push(...options.scope);
|
|
204
|
+
if (data.scopes) scopes.push(...data.scopes);
|
|
215
205
|
return createAuthorizationURL({
|
|
216
206
|
id: "microsoft",
|
|
217
207
|
options,
|
|
218
208
|
authorizationEndpoint,
|
|
219
209
|
state: data.state,
|
|
220
210
|
codeVerifier: data.codeVerifier,
|
|
221
|
-
scopes
|
|
211
|
+
scopes,
|
|
222
212
|
redirectURI: data.redirectURI,
|
|
223
213
|
prompt: options.prompt,
|
|
224
214
|
loginHint: data.loginHint,
|
|
@@ -361,7 +351,7 @@ export const microsoft = (options: MicrosoftOptions) => {
|
|
|
361
351
|
});
|
|
362
352
|
},
|
|
363
353
|
options,
|
|
364
|
-
} satisfies
|
|
354
|
+
} satisfies OAuthProvider;
|
|
365
355
|
};
|
|
366
356
|
|
|
367
357
|
export const getMicrosoftPublicKey = async (
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -40,25 +39,20 @@ export interface NaverOptions extends ProviderOptions<NaverProfile> {
|
|
|
40
39
|
clientId: string;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const NAVER_DEFAULT_SCOPES = ["profile", "email"];
|
|
44
|
-
|
|
45
42
|
export const naver = (options: NaverOptions) => {
|
|
46
43
|
const tokenEndpoint = "https://nid.naver.com/oauth2.0/token";
|
|
47
44
|
return {
|
|
48
45
|
id: "naver",
|
|
49
46
|
name: "Naver",
|
|
50
|
-
callbackPath: "/callback/naver",
|
|
51
47
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
scopes,
|
|
56
|
-
);
|
|
48
|
+
const _scopes = options.disableDefaultScope ? [] : ["profile", "email"];
|
|
49
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
50
|
+
if (scopes) _scopes.push(...scopes);
|
|
57
51
|
return createAuthorizationURL({
|
|
58
52
|
id: "naver",
|
|
59
53
|
options,
|
|
60
54
|
authorizationEndpoint: "https://nid.naver.com/oauth2.0/authorize",
|
|
61
|
-
scopes:
|
|
55
|
+
scopes: _scopes,
|
|
62
56
|
state,
|
|
63
57
|
redirectURI,
|
|
64
58
|
additionalParams,
|
|
@@ -116,5 +110,5 @@ export const naver = (options: NaverOptions) => {
|
|
|
116
110
|
};
|
|
117
111
|
},
|
|
118
112
|
options,
|
|
119
|
-
} satisfies
|
|
113
|
+
} satisfies OAuthProvider<NaverProfile>;
|
|
120
114
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -24,14 +23,11 @@ export interface NotionOptions extends ProviderOptions<NotionProfile> {
|
|
|
24
23
|
clientId: string;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
const NOTION_DEFAULT_SCOPES: string[] = [];
|
|
28
|
-
|
|
29
26
|
export const notion = (options: NotionOptions) => {
|
|
30
27
|
const tokenEndpoint = "https://api.notion.com/v1/oauth/token";
|
|
31
28
|
return {
|
|
32
29
|
id: "notion",
|
|
33
30
|
name: "Notion",
|
|
34
|
-
callbackPath: "/callback/notion",
|
|
35
31
|
createAuthorizationURL({
|
|
36
32
|
state,
|
|
37
33
|
scopes,
|
|
@@ -39,16 +35,14 @@ export const notion = (options: NotionOptions) => {
|
|
|
39
35
|
redirectURI,
|
|
40
36
|
additionalParams,
|
|
41
37
|
}) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
scopes,
|
|
46
|
-
);
|
|
38
|
+
const _scopes: string[] = options.disableDefaultScope ? [] : [];
|
|
39
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
40
|
+
if (scopes) _scopes.push(...scopes);
|
|
47
41
|
return createAuthorizationURL({
|
|
48
42
|
id: "notion",
|
|
49
43
|
options,
|
|
50
44
|
authorizationEndpoint: "https://api.notion.com/v1/oauth/authorize",
|
|
51
|
-
scopes:
|
|
45
|
+
scopes: _scopes,
|
|
52
46
|
state,
|
|
53
47
|
redirectURI,
|
|
54
48
|
loginHint,
|
|
@@ -117,5 +111,5 @@ export const notion = (options: NotionOptions) => {
|
|
|
117
111
|
};
|
|
118
112
|
},
|
|
119
113
|
options,
|
|
120
|
-
} satisfies
|
|
114
|
+
} satisfies OAuthProvider<NotionProfile>;
|
|
121
115
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { decodeJwt } from "jose";
|
|
2
2
|
import { logger } from "../env";
|
|
3
3
|
import { BetterAuthError } from "../error";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
5
|
import {
|
|
6
6
|
createAuthorizationURL,
|
|
7
7
|
refreshAccessToken,
|
|
8
|
-
resolveRequestedScopes,
|
|
9
8
|
validateAuthorizationCode,
|
|
10
9
|
} from "../oauth2";
|
|
11
10
|
|
|
@@ -29,8 +28,6 @@ export interface PaybinOptions extends ProviderOptions<PaybinProfile> {
|
|
|
29
28
|
issuer?: string | undefined;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
const PAYBIN_DEFAULT_SCOPES = ["openid", "email", "profile"];
|
|
33
|
-
|
|
34
31
|
export const paybin = (options: PaybinOptions) => {
|
|
35
32
|
const issuer = options.issuer || "https://idp.paybin.io";
|
|
36
33
|
const authorizationEndpoint = `${issuer}/oauth2/authorize`;
|
|
@@ -39,8 +36,7 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
39
36
|
return {
|
|
40
37
|
id: "paybin",
|
|
41
38
|
name: "Paybin",
|
|
42
|
-
|
|
43
|
-
createAuthorizationURL({
|
|
39
|
+
async createAuthorizationURL({
|
|
44
40
|
state,
|
|
45
41
|
scopes,
|
|
46
42
|
codeVerifier,
|
|
@@ -57,16 +53,16 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
57
53
|
if (!codeVerifier) {
|
|
58
54
|
throw new BetterAuthError("codeVerifier is required for Paybin");
|
|
59
55
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
65
|
-
|
|
56
|
+
const _scopes = options.disableDefaultScope
|
|
57
|
+
? []
|
|
58
|
+
: ["openid", "email", "profile"];
|
|
59
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
60
|
+
if (scopes) _scopes.push(...scopes);
|
|
61
|
+
const url = await createAuthorizationURL({
|
|
66
62
|
id: "paybin",
|
|
67
63
|
options,
|
|
68
64
|
authorizationEndpoint,
|
|
69
|
-
scopes:
|
|
65
|
+
scopes: _scopes,
|
|
70
66
|
state,
|
|
71
67
|
codeVerifier,
|
|
72
68
|
redirectURI,
|
|
@@ -74,6 +70,7 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
74
70
|
loginHint,
|
|
75
71
|
additionalParams,
|
|
76
72
|
});
|
|
73
|
+
return url;
|
|
77
74
|
},
|
|
78
75
|
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
79
76
|
return validateAuthorizationCode({
|
|
@@ -119,5 +116,5 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
119
116
|
};
|
|
120
117
|
},
|
|
121
118
|
options,
|
|
122
|
-
} satisfies
|
|
119
|
+
} satisfies OAuthProvider<PaybinProfile>;
|
|
123
120
|
};
|
|
@@ -2,7 +2,7 @@ import { base64 } from "@better-auth/utils/base64";
|
|
|
2
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
3
|
import { logger } from "../env";
|
|
4
4
|
import { BetterAuthError } from "../error";
|
|
5
|
-
import type {
|
|
5
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
6
6
|
import { createAuthorizationURL } from "../oauth2";
|
|
7
7
|
|
|
8
8
|
export interface PayPalProfile {
|
|
@@ -77,8 +77,7 @@ export const paypal = (options: PayPalOptions) => {
|
|
|
77
77
|
return {
|
|
78
78
|
id: "paypal",
|
|
79
79
|
name: "PayPal",
|
|
80
|
-
|
|
81
|
-
createAuthorizationURL({
|
|
80
|
+
async createAuthorizationURL({
|
|
82
81
|
state,
|
|
83
82
|
codeVerifier,
|
|
84
83
|
redirectURI,
|
|
@@ -97,17 +96,20 @@ export const paypal = (options: PayPalOptions) => {
|
|
|
97
96
|
* We don't pass any scopes to avoid "invalid scope" errors
|
|
98
97
|
**/
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
const _scopes: string[] = [];
|
|
100
|
+
|
|
101
|
+
const url = await createAuthorizationURL({
|
|
101
102
|
id: "paypal",
|
|
102
103
|
options,
|
|
103
104
|
authorizationEndpoint,
|
|
104
|
-
scopes:
|
|
105
|
+
scopes: _scopes,
|
|
105
106
|
state,
|
|
106
107
|
codeVerifier,
|
|
107
108
|
redirectURI,
|
|
108
109
|
prompt: options.prompt,
|
|
109
110
|
additionalParams,
|
|
110
111
|
});
|
|
112
|
+
return url;
|
|
111
113
|
},
|
|
112
114
|
|
|
113
115
|
validateAuthorizationCode: async ({ code, redirectURI }) => {
|
|
@@ -246,5 +248,5 @@ export const paypal = (options: PayPalOptions) => {
|
|
|
246
248
|
},
|
|
247
249
|
|
|
248
250
|
options,
|
|
249
|
-
} satisfies
|
|
251
|
+
} satisfies OAuthProvider<PayPalProfile>;
|
|
250
252
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -33,14 +32,11 @@ export interface PolarProfile {
|
|
|
33
32
|
|
|
34
33
|
export interface PolarOptions extends ProviderOptions<PolarProfile> {}
|
|
35
34
|
|
|
36
|
-
const POLAR_DEFAULT_SCOPES = ["openid", "profile", "email"];
|
|
37
|
-
|
|
38
35
|
export const polar = (options: PolarOptions) => {
|
|
39
36
|
const tokenEndpoint = "https://api.polar.sh/v1/oauth2/token";
|
|
40
37
|
return {
|
|
41
38
|
id: "polar",
|
|
42
39
|
name: "Polar",
|
|
43
|
-
callbackPath: "/callback/polar",
|
|
44
40
|
createAuthorizationURL({
|
|
45
41
|
state,
|
|
46
42
|
scopes,
|
|
@@ -48,16 +44,16 @@ export const polar = (options: PolarOptions) => {
|
|
|
48
44
|
redirectURI,
|
|
49
45
|
additionalParams,
|
|
50
46
|
}) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
47
|
+
const _scopes = options.disableDefaultScope
|
|
48
|
+
? []
|
|
49
|
+
: ["openid", "profile", "email"];
|
|
50
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
51
|
+
if (scopes) _scopes.push(...scopes);
|
|
56
52
|
return createAuthorizationURL({
|
|
57
53
|
id: "polar",
|
|
58
54
|
options,
|
|
59
55
|
authorizationEndpoint: "https://polar.sh/oauth2/authorize",
|
|
60
|
-
scopes:
|
|
56
|
+
scopes: _scopes,
|
|
61
57
|
state,
|
|
62
58
|
codeVerifier,
|
|
63
59
|
redirectURI,
|
|
@@ -118,5 +114,5 @@ export const polar = (options: PolarOptions) => {
|
|
|
118
114
|
};
|
|
119
115
|
},
|
|
120
116
|
options,
|
|
121
|
-
} satisfies
|
|
117
|
+
} satisfies OAuthProvider<PolarProfile>;
|
|
122
118
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -26,30 +25,27 @@ export interface RailwayOptions extends ProviderOptions<RailwayProfile> {
|
|
|
26
25
|
clientId: string;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
const RAILWAY_DEFAULT_SCOPES = ["openid", "email", "profile"];
|
|
30
|
-
|
|
31
28
|
export const railway = (options: RailwayOptions) => {
|
|
32
29
|
return {
|
|
33
30
|
id: "railway",
|
|
34
31
|
name: "Railway",
|
|
35
|
-
|
|
36
|
-
async createAuthorizationURL({
|
|
32
|
+
createAuthorizationURL({
|
|
37
33
|
state,
|
|
38
34
|
scopes,
|
|
39
35
|
codeVerifier,
|
|
40
36
|
redirectURI,
|
|
41
37
|
additionalParams,
|
|
42
38
|
}) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
39
|
+
const _scopes = options.disableDefaultScope
|
|
40
|
+
? []
|
|
41
|
+
: ["openid", "email", "profile"];
|
|
42
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
43
|
+
if (scopes) _scopes.push(...scopes);
|
|
48
44
|
return createAuthorizationURL({
|
|
49
45
|
id: "railway",
|
|
50
46
|
options,
|
|
51
47
|
authorizationEndpoint,
|
|
52
|
-
scopes:
|
|
48
|
+
scopes: _scopes,
|
|
53
49
|
state,
|
|
54
50
|
codeVerifier,
|
|
55
51
|
redirectURI,
|
|
@@ -107,5 +103,5 @@ export const railway = (options: RailwayOptions) => {
|
|
|
107
103
|
};
|
|
108
104
|
},
|
|
109
105
|
options,
|
|
110
|
-
} satisfies
|
|
106
|
+
} satisfies OAuthProvider<RailwayProfile>;
|
|
111
107
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { base64 } from "@better-auth/utils/base64";
|
|
2
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
-
import type {
|
|
3
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
4
4
|
import {
|
|
5
5
|
createAuthorizationURL,
|
|
6
6
|
getOAuth2Tokens,
|
|
7
7
|
refreshAccessToken,
|
|
8
|
-
resolveRequestedScopes,
|
|
9
8
|
} from "../oauth2";
|
|
10
9
|
|
|
11
10
|
export interface RedditProfile {
|
|
@@ -22,29 +21,19 @@ export interface RedditOptions extends ProviderOptions<RedditProfile> {
|
|
|
22
21
|
duration?: string | undefined;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
const REDDIT_DEFAULT_SCOPES = ["identity"];
|
|
26
|
-
|
|
27
24
|
export const reddit = (options: RedditOptions) => {
|
|
28
25
|
return {
|
|
29
26
|
id: "reddit",
|
|
30
27
|
name: "Reddit",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
scopes
|
|
35
|
-
redirectURI,
|
|
36
|
-
additionalParams,
|
|
37
|
-
}) {
|
|
38
|
-
const requestedScopes = resolveRequestedScopes(
|
|
39
|
-
options,
|
|
40
|
-
REDDIT_DEFAULT_SCOPES,
|
|
41
|
-
scopes,
|
|
42
|
-
);
|
|
28
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
29
|
+
const _scopes = options.disableDefaultScope ? [] : ["identity"];
|
|
30
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
31
|
+
if (scopes) _scopes.push(...scopes);
|
|
43
32
|
return createAuthorizationURL({
|
|
44
33
|
id: "reddit",
|
|
45
34
|
options,
|
|
46
35
|
authorizationEndpoint: "https://www.reddit.com/api/v1/authorize",
|
|
47
|
-
scopes:
|
|
36
|
+
scopes: _scopes,
|
|
48
37
|
state,
|
|
49
38
|
redirectURI,
|
|
50
39
|
duration: options.duration,
|
|
@@ -134,5 +123,5 @@ export const reddit = (options: RedditOptions) => {
|
|
|
134
123
|
};
|
|
135
124
|
},
|
|
136
125
|
options,
|
|
137
|
-
} satisfies
|
|
126
|
+
} satisfies OAuthProvider<RedditProfile>;
|
|
138
127
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
3
3
|
import {
|
|
4
4
|
createAuthorizationURL,
|
|
5
5
|
refreshAccessToken,
|
|
6
|
-
resolveRequestedScopes,
|
|
7
6
|
validateAuthorizationCode,
|
|
8
7
|
} from "../oauth2";
|
|
9
8
|
|
|
@@ -37,30 +36,20 @@ export interface RobloxOptions extends ProviderOptions<RobloxProfile> {
|
|
|
37
36
|
| undefined;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
const ROBLOX_DEFAULT_SCOPES = ["openid", "profile"];
|
|
41
|
-
|
|
42
39
|
export const roblox = (options: RobloxOptions) => {
|
|
43
40
|
const tokenEndpoint = "https://apis.roblox.com/oauth/v1/token";
|
|
44
41
|
return {
|
|
45
42
|
id: "roblox",
|
|
46
43
|
name: "Roblox",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
scopes
|
|
51
|
-
redirectURI,
|
|
52
|
-
additionalParams,
|
|
53
|
-
}) {
|
|
54
|
-
const requestedScopes = resolveRequestedScopes(
|
|
55
|
-
options,
|
|
56
|
-
ROBLOX_DEFAULT_SCOPES,
|
|
57
|
-
scopes,
|
|
58
|
-
);
|
|
44
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
45
|
+
const _scopes = options.disableDefaultScope ? [] : ["openid", "profile"];
|
|
46
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
47
|
+
if (scopes) _scopes.push(...scopes);
|
|
59
48
|
return createAuthorizationURL({
|
|
60
49
|
id: "roblox",
|
|
61
50
|
options,
|
|
62
51
|
authorizationEndpoint: "https://apis.roblox.com/oauth/v1/authorize",
|
|
63
|
-
scopes:
|
|
52
|
+
scopes: _scopes,
|
|
64
53
|
state,
|
|
65
54
|
redirectURI,
|
|
66
55
|
prompt: options.prompt || "select_account consent",
|
|
@@ -124,5 +113,5 @@ export const roblox = (options: RobloxOptions) => {
|
|
|
124
113
|
};
|
|
125
114
|
},
|
|
126
115
|
options,
|
|
127
|
-
} satisfies
|
|
116
|
+
} satisfies OAuthProvider<RobloxProfile>;
|
|
128
117
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
2
|
import { logger } from "../env";
|
|
3
3
|
import { BetterAuthError } from "../error";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
5
5
|
import {
|
|
6
6
|
createAuthorizationURL,
|
|
7
7
|
refreshAccessToken,
|
|
8
|
-
resolveRequestedScopes,
|
|
9
8
|
validateAuthorizationCode,
|
|
10
9
|
} from "../oauth2";
|
|
11
10
|
|
|
@@ -40,8 +39,6 @@ export interface SalesforceOptions extends ProviderOptions<SalesforceProfile> {
|
|
|
40
39
|
redirectURI?: string | undefined;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const SALESFORCE_DEFAULT_SCOPES = ["openid", "email", "profile"];
|
|
44
|
-
|
|
45
42
|
export const salesforce = (options: SalesforceOptions) => {
|
|
46
43
|
const environment = options.environment ?? "production";
|
|
47
44
|
const isSandbox = environment === "sandbox";
|
|
@@ -66,7 +63,6 @@ export const salesforce = (options: SalesforceOptions) => {
|
|
|
66
63
|
return {
|
|
67
64
|
id: "salesforce",
|
|
68
65
|
name: "Salesforce",
|
|
69
|
-
callbackPath: "/callback/salesforce",
|
|
70
66
|
|
|
71
67
|
async createAuthorizationURL({
|
|
72
68
|
state,
|
|
@@ -85,17 +81,17 @@ export const salesforce = (options: SalesforceOptions) => {
|
|
|
85
81
|
throw new BetterAuthError("codeVerifier is required for Salesforce");
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
84
|
+
const _scopes = options.disableDefaultScope
|
|
85
|
+
? []
|
|
86
|
+
: ["openid", "email", "profile"];
|
|
87
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
88
|
+
if (scopes) _scopes.push(...scopes);
|
|
93
89
|
|
|
94
90
|
return createAuthorizationURL({
|
|
95
91
|
id: "salesforce",
|
|
96
92
|
options,
|
|
97
93
|
authorizationEndpoint,
|
|
98
|
-
scopes:
|
|
94
|
+
scopes: _scopes,
|
|
99
95
|
state,
|
|
100
96
|
codeVerifier,
|
|
101
97
|
redirectURI: options.redirectURI || redirectURI,
|
|
@@ -166,5 +162,5 @@ export const salesforce = (options: SalesforceOptions) => {
|
|
|
166
162
|
},
|
|
167
163
|
|
|
168
164
|
options,
|
|
169
|
-
} satisfies
|
|
165
|
+
} satisfies OAuthProvider<SalesforceProfile>;
|
|
170
166
|
};
|