@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,26 +1,26 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/kakao.ts
|
|
7
|
-
const KAKAO_DEFAULT_SCOPES = [
|
|
8
|
-
"account_email",
|
|
9
|
-
"profile_image",
|
|
10
|
-
"profile_nickname"
|
|
11
|
-
];
|
|
12
6
|
const kakao = (options) => {
|
|
13
7
|
const tokenEndpoint = "https://kauth.kakao.com/oauth/token";
|
|
14
8
|
return {
|
|
15
9
|
id: "kakao",
|
|
16
10
|
name: "Kakao",
|
|
17
|
-
callbackPath: "/callback/kakao",
|
|
18
11
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
13
|
+
"account_email",
|
|
14
|
+
"profile_image",
|
|
15
|
+
"profile_nickname"
|
|
16
|
+
];
|
|
17
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
18
|
+
if (scopes) _scopes.push(...scopes);
|
|
19
19
|
return createAuthorizationURL({
|
|
20
20
|
id: "kakao",
|
|
21
21
|
options,
|
|
22
22
|
authorizationEndpoint: "https://kauth.kakao.com/oauth/authorize",
|
|
23
|
-
scopes:
|
|
23
|
+
scopes: _scopes,
|
|
24
24
|
state,
|
|
25
25
|
redirectURI,
|
|
26
26
|
additionalParams
|
|
@@ -24,7 +24,6 @@ interface KickOptions extends ProviderOptions<KickProfile> {
|
|
|
24
24
|
declare const kick: (options: KickOptions) => {
|
|
25
25
|
id: "kick";
|
|
26
26
|
name: string;
|
|
27
|
-
callbackPath: string;
|
|
28
27
|
createAuthorizationURL({
|
|
29
28
|
state,
|
|
30
29
|
scopes,
|
|
@@ -40,10 +39,7 @@ declare const kick: (options: KickOptions) => {
|
|
|
40
39
|
loginHint?: string | undefined;
|
|
41
40
|
idTokenNonce?: string | undefined;
|
|
42
41
|
additionalParams?: Record<string, string> | undefined;
|
|
43
|
-
}): Promise<
|
|
44
|
-
url: URL;
|
|
45
|
-
requestedScopes: string[];
|
|
46
|
-
}>;
|
|
42
|
+
}): Promise<URL>;
|
|
47
43
|
validateAuthorizationCode({
|
|
48
44
|
code,
|
|
49
45
|
redirectURI,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/kick.ts
|
|
7
|
-
const KICK_DEFAULT_SCOPES = ["user:read"];
|
|
8
6
|
const kick = (options) => {
|
|
9
7
|
return {
|
|
10
8
|
id: "kick",
|
|
11
9
|
name: "Kick",
|
|
12
|
-
callbackPath: "/callback/kick",
|
|
13
10
|
createAuthorizationURL({ state, scopes, redirectURI, codeVerifier, additionalParams }) {
|
|
11
|
+
const _scopes = options.disableDefaultScope ? [] : ["user:read"];
|
|
12
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
13
|
+
if (scopes) _scopes.push(...scopes);
|
|
14
14
|
return createAuthorizationURL({
|
|
15
15
|
id: "kick",
|
|
16
16
|
redirectURI,
|
|
17
17
|
options,
|
|
18
18
|
authorizationEndpoint: "https://id.kick.com/oauth/authorize",
|
|
19
|
-
scopes:
|
|
19
|
+
scopes: _scopes,
|
|
20
20
|
codeVerifier,
|
|
21
21
|
state,
|
|
22
22
|
additionalParams
|
|
@@ -33,7 +33,6 @@ interface LineOptions extends ProviderOptions<LineUserInfo | LineIdTokenPayload>
|
|
|
33
33
|
declare const line: (options: LineOptions) => {
|
|
34
34
|
id: "line";
|
|
35
35
|
name: string;
|
|
36
|
-
callbackPath: string;
|
|
37
36
|
createAuthorizationURL({
|
|
38
37
|
state,
|
|
39
38
|
scopes,
|
|
@@ -50,10 +49,7 @@ declare const line: (options: LineOptions) => {
|
|
|
50
49
|
loginHint?: string | undefined;
|
|
51
50
|
idTokenNonce?: string | undefined;
|
|
52
51
|
additionalParams?: Record<string, string> | undefined;
|
|
53
|
-
}): Promise<
|
|
54
|
-
url: URL;
|
|
55
|
-
requestedScopes: string[];
|
|
56
|
-
}>;
|
|
52
|
+
}): Promise<URL>;
|
|
57
53
|
validateAuthorizationCode: ({
|
|
58
54
|
code,
|
|
59
55
|
codeVerifier,
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { decodeJwt } from "jose";
|
|
6
5
|
import { betterFetch } from "@better-fetch/fetch";
|
|
7
6
|
//#region src/social-providers/line.ts
|
|
8
|
-
const LINE_DEFAULT_SCOPES = [
|
|
9
|
-
"openid",
|
|
10
|
-
"profile",
|
|
11
|
-
"email"
|
|
12
|
-
];
|
|
13
7
|
/**
|
|
14
8
|
* LINE Login v2.1
|
|
15
9
|
* - Authorization endpoint: https://access.line.me/oauth2/v2.1/authorize
|
|
@@ -27,13 +21,19 @@ const line = (options) => {
|
|
|
27
21
|
return {
|
|
28
22
|
id: "line",
|
|
29
23
|
name: "LINE",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint, additionalParams }) {
|
|
25
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
26
|
+
"openid",
|
|
27
|
+
"profile",
|
|
28
|
+
"email"
|
|
29
|
+
];
|
|
30
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
31
|
+
if (scopes) _scopes.push(...scopes);
|
|
32
|
+
return await createAuthorizationURL({
|
|
33
33
|
id: "line",
|
|
34
34
|
options,
|
|
35
35
|
authorizationEndpoint,
|
|
36
|
-
scopes:
|
|
36
|
+
scopes: _scopes,
|
|
37
37
|
state,
|
|
38
38
|
codeVerifier,
|
|
39
39
|
redirectURI,
|
|
@@ -20,7 +20,6 @@ interface LinearOptions extends ProviderOptions<LinearUser> {
|
|
|
20
20
|
declare const linear: (options: LinearOptions) => {
|
|
21
21
|
id: "linear";
|
|
22
22
|
name: string;
|
|
23
|
-
callbackPath: string;
|
|
24
23
|
createAuthorizationURL({
|
|
25
24
|
state,
|
|
26
25
|
scopes,
|
|
@@ -36,10 +35,7 @@ declare const linear: (options: LinearOptions) => {
|
|
|
36
35
|
loginHint?: string | undefined;
|
|
37
36
|
idTokenNonce?: string | undefined;
|
|
38
37
|
additionalParams?: Record<string, string> | undefined;
|
|
39
|
-
}): Promise<
|
|
40
|
-
url: URL;
|
|
41
|
-
requestedScopes: string[];
|
|
42
|
-
}>;
|
|
38
|
+
}): Promise<URL>;
|
|
43
39
|
validateAuthorizationCode: ({
|
|
44
40
|
code,
|
|
45
41
|
redirectURI
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/linear.ts
|
|
7
|
-
const LINEAR_DEFAULT_SCOPES = ["read"];
|
|
8
6
|
const linear = (options) => {
|
|
9
7
|
const tokenEndpoint = "https://api.linear.app/oauth/token";
|
|
10
8
|
return {
|
|
11
9
|
id: "linear",
|
|
12
10
|
name: "Linear",
|
|
13
|
-
callbackPath: "/callback/linear",
|
|
14
11
|
createAuthorizationURL({ state, scopes, loginHint, redirectURI, additionalParams }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : ["read"];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
15
|
return createAuthorizationURL({
|
|
16
16
|
id: "linear",
|
|
17
17
|
options,
|
|
18
18
|
authorizationEndpoint: "https://linear.app/oauth/authorize",
|
|
19
|
-
scopes:
|
|
19
|
+
scopes: _scopes,
|
|
20
20
|
state,
|
|
21
21
|
redirectURI,
|
|
22
22
|
loginHint,
|
|
@@ -19,7 +19,6 @@ interface LinkedInOptions extends ProviderOptions<LinkedInProfile> {
|
|
|
19
19
|
declare const linkedin: (options: LinkedInOptions) => {
|
|
20
20
|
id: "linkedin";
|
|
21
21
|
name: string;
|
|
22
|
-
callbackPath: string;
|
|
23
22
|
createAuthorizationURL: ({
|
|
24
23
|
state,
|
|
25
24
|
scopes,
|
|
@@ -35,10 +34,7 @@ declare const linkedin: (options: LinkedInOptions) => {
|
|
|
35
34
|
loginHint?: string | undefined;
|
|
36
35
|
idTokenNonce?: string | undefined;
|
|
37
36
|
additionalParams?: Record<string, string> | undefined;
|
|
38
|
-
}) => Promise<
|
|
39
|
-
url: URL;
|
|
40
|
-
requestedScopes: string[];
|
|
41
|
-
}>;
|
|
37
|
+
}) => Promise<URL>;
|
|
42
38
|
validateAuthorizationCode: ({
|
|
43
39
|
code,
|
|
44
40
|
redirectURI
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/linkedin.ts
|
|
7
|
-
const LINKEDIN_DEFAULT_SCOPES = [
|
|
8
|
-
"profile",
|
|
9
|
-
"email",
|
|
10
|
-
"openid"
|
|
11
|
-
];
|
|
12
6
|
const linkedin = (options) => {
|
|
13
7
|
const authorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization";
|
|
14
8
|
const tokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken";
|
|
15
9
|
return {
|
|
16
10
|
id: "linkedin",
|
|
17
11
|
name: "Linkedin",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
createAuthorizationURL: async ({ state, scopes, redirectURI, loginHint, additionalParams }) => {
|
|
13
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
14
|
+
"profile",
|
|
15
|
+
"email",
|
|
16
|
+
"openid"
|
|
17
|
+
];
|
|
18
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
19
|
+
if (scopes) _scopes.push(...scopes);
|
|
20
|
+
return await createAuthorizationURL({
|
|
21
21
|
id: "linkedin",
|
|
22
22
|
options,
|
|
23
23
|
authorizationEndpoint,
|
|
24
|
-
scopes:
|
|
24
|
+
scopes: _scopes,
|
|
25
25
|
state,
|
|
26
26
|
loginHint,
|
|
27
27
|
redirectURI,
|
|
@@ -139,7 +139,6 @@ interface MicrosoftOptions extends ProviderOptions<MicrosoftEntraIDProfile> {
|
|
|
139
139
|
declare const microsoft: (options: MicrosoftOptions) => {
|
|
140
140
|
id: "microsoft";
|
|
141
141
|
name: string;
|
|
142
|
-
callbackPath: string;
|
|
143
142
|
createAuthorizationURL(data: {
|
|
144
143
|
state: string;
|
|
145
144
|
codeVerifier: string;
|
|
@@ -149,10 +148,7 @@ declare const microsoft: (options: MicrosoftOptions) => {
|
|
|
149
148
|
loginHint?: string | undefined;
|
|
150
149
|
idTokenNonce?: string | undefined;
|
|
151
150
|
additionalParams?: Record<string, string> | undefined;
|
|
152
|
-
}): Promise<
|
|
153
|
-
url: URL;
|
|
154
|
-
requestedScopes: string[];
|
|
155
|
-
}>;
|
|
151
|
+
}): Promise<URL>;
|
|
156
152
|
validateAuthorizationCode({
|
|
157
153
|
code,
|
|
158
154
|
codeVerifier,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { APIError, BetterAuthError } from "../error/index.mjs";
|
|
2
2
|
import { logger } from "../env/logger.mjs";
|
|
3
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
4
3
|
import { getPrimaryClientId } from "../oauth2/utils.mjs";
|
|
5
4
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
6
5
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
@@ -16,13 +15,6 @@ import { betterFetch } from "@better-fetch/fetch";
|
|
|
16
15
|
* @see https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference
|
|
17
16
|
*/
|
|
18
17
|
const MICROSOFT_CONSUMER_TENANT_ID = "9188040d-6c67-4c5b-b112-36a304b66dad";
|
|
19
|
-
const MICROSOFT_ENTRA_ID_DEFAULT_SCOPES = [
|
|
20
|
-
"openid",
|
|
21
|
-
"profile",
|
|
22
|
-
"email",
|
|
23
|
-
"User.Read",
|
|
24
|
-
"offline_access"
|
|
25
|
-
];
|
|
26
18
|
const microsoft = (options) => {
|
|
27
19
|
const tenant = options.tenantId || "common";
|
|
28
20
|
let authority = options.authority || "https://login.microsoftonline.com";
|
|
@@ -37,20 +29,27 @@ const microsoft = (options) => {
|
|
|
37
29
|
return {
|
|
38
30
|
id: "microsoft",
|
|
39
31
|
name: "Microsoft EntraID",
|
|
40
|
-
callbackPath: "/callback/microsoft",
|
|
41
32
|
createAuthorizationURL(data) {
|
|
42
33
|
if (!getPrimaryClientId(options.clientId)) {
|
|
43
34
|
logger.error("Client Id is required for Microsoft Entra ID. Make sure to provide it in the options.");
|
|
44
35
|
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
45
36
|
}
|
|
46
|
-
const
|
|
37
|
+
const scopes = options.disableDefaultScope ? [] : [
|
|
38
|
+
"openid",
|
|
39
|
+
"profile",
|
|
40
|
+
"email",
|
|
41
|
+
"User.Read",
|
|
42
|
+
"offline_access"
|
|
43
|
+
];
|
|
44
|
+
if (options.scope) scopes.push(...options.scope);
|
|
45
|
+
if (data.scopes) scopes.push(...data.scopes);
|
|
47
46
|
return createAuthorizationURL({
|
|
48
47
|
id: "microsoft",
|
|
49
48
|
options,
|
|
50
49
|
authorizationEndpoint,
|
|
51
50
|
state: data.state,
|
|
52
51
|
codeVerifier: data.codeVerifier,
|
|
53
|
-
scopes
|
|
52
|
+
scopes,
|
|
54
53
|
redirectURI: data.redirectURI,
|
|
55
54
|
prompt: options.prompt,
|
|
56
55
|
loginHint: data.loginHint,
|
|
@@ -24,7 +24,6 @@ interface NaverOptions extends ProviderOptions<NaverProfile> {
|
|
|
24
24
|
declare const naver: (options: NaverOptions) => {
|
|
25
25
|
id: "naver";
|
|
26
26
|
name: string;
|
|
27
|
-
callbackPath: string;
|
|
28
27
|
createAuthorizationURL({
|
|
29
28
|
state,
|
|
30
29
|
scopes,
|
|
@@ -39,10 +38,7 @@ declare const naver: (options: NaverOptions) => {
|
|
|
39
38
|
loginHint?: string | undefined;
|
|
40
39
|
idTokenNonce?: string | undefined;
|
|
41
40
|
additionalParams?: Record<string, string> | undefined;
|
|
42
|
-
}): Promise<
|
|
43
|
-
url: URL;
|
|
44
|
-
requestedScopes: string[];
|
|
45
|
-
}>;
|
|
41
|
+
}): Promise<URL>;
|
|
46
42
|
validateAuthorizationCode: ({
|
|
47
43
|
code,
|
|
48
44
|
redirectURI
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/naver.ts
|
|
7
|
-
const NAVER_DEFAULT_SCOPES = ["profile", "email"];
|
|
8
6
|
const naver = (options) => {
|
|
9
7
|
const tokenEndpoint = "https://nid.naver.com/oauth2.0/token";
|
|
10
8
|
return {
|
|
11
9
|
id: "naver",
|
|
12
10
|
name: "Naver",
|
|
13
|
-
callbackPath: "/callback/naver",
|
|
14
11
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : ["profile", "email"];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
15
|
return createAuthorizationURL({
|
|
16
16
|
id: "naver",
|
|
17
17
|
options,
|
|
18
18
|
authorizationEndpoint: "https://nid.naver.com/oauth2.0/authorize",
|
|
19
|
-
scopes:
|
|
19
|
+
scopes: _scopes,
|
|
20
20
|
state,
|
|
21
21
|
redirectURI,
|
|
22
22
|
additionalParams
|
|
@@ -16,7 +16,6 @@ interface NotionOptions extends ProviderOptions<NotionProfile> {
|
|
|
16
16
|
declare const notion: (options: NotionOptions) => {
|
|
17
17
|
id: "notion";
|
|
18
18
|
name: string;
|
|
19
|
-
callbackPath: string;
|
|
20
19
|
createAuthorizationURL({
|
|
21
20
|
state,
|
|
22
21
|
scopes,
|
|
@@ -32,10 +31,7 @@ declare const notion: (options: NotionOptions) => {
|
|
|
32
31
|
loginHint?: string | undefined;
|
|
33
32
|
idTokenNonce?: string | undefined;
|
|
34
33
|
additionalParams?: Record<string, string> | undefined;
|
|
35
|
-
}): Promise<
|
|
36
|
-
url: URL;
|
|
37
|
-
requestedScopes: string[];
|
|
38
|
-
}>;
|
|
34
|
+
}): Promise<URL>;
|
|
39
35
|
validateAuthorizationCode: ({
|
|
40
36
|
code,
|
|
41
37
|
redirectURI
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/notion.ts
|
|
7
|
-
const NOTION_DEFAULT_SCOPES = [];
|
|
8
6
|
const notion = (options) => {
|
|
9
7
|
const tokenEndpoint = "https://api.notion.com/v1/oauth/token";
|
|
10
8
|
return {
|
|
11
9
|
id: "notion",
|
|
12
10
|
name: "Notion",
|
|
13
|
-
callbackPath: "/callback/notion",
|
|
14
11
|
createAuthorizationURL({ state, scopes, loginHint, redirectURI, additionalParams }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : [];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
15
|
return createAuthorizationURL({
|
|
16
16
|
id: "notion",
|
|
17
17
|
options,
|
|
18
18
|
authorizationEndpoint: "https://api.notion.com/v1/oauth/authorize",
|
|
19
|
-
scopes:
|
|
19
|
+
scopes: _scopes,
|
|
20
20
|
state,
|
|
21
21
|
redirectURI,
|
|
22
22
|
loginHint,
|
|
@@ -21,7 +21,6 @@ interface PaybinOptions extends ProviderOptions<PaybinProfile> {
|
|
|
21
21
|
declare const paybin: (options: PaybinOptions) => {
|
|
22
22
|
id: "paybin";
|
|
23
23
|
name: string;
|
|
24
|
-
callbackPath: string;
|
|
25
24
|
createAuthorizationURL({
|
|
26
25
|
state,
|
|
27
26
|
scopes,
|
|
@@ -38,10 +37,7 @@ declare const paybin: (options: PaybinOptions) => {
|
|
|
38
37
|
loginHint?: string | undefined;
|
|
39
38
|
idTokenNonce?: string | undefined;
|
|
40
39
|
additionalParams?: Record<string, string> | undefined;
|
|
41
|
-
}): Promise<
|
|
42
|
-
url: URL;
|
|
43
|
-
requestedScopes: string[];
|
|
44
|
-
}>;
|
|
40
|
+
}): Promise<URL>;
|
|
45
41
|
validateAuthorizationCode: ({
|
|
46
42
|
code,
|
|
47
43
|
codeVerifier,
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { BetterAuthError } from "../error/index.mjs";
|
|
2
2
|
import { logger } from "../env/logger.mjs";
|
|
3
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
4
3
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
5
4
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
6
5
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
7
6
|
import { decodeJwt } from "jose";
|
|
8
7
|
//#region src/social-providers/paybin.ts
|
|
9
|
-
const PAYBIN_DEFAULT_SCOPES = [
|
|
10
|
-
"openid",
|
|
11
|
-
"email",
|
|
12
|
-
"profile"
|
|
13
|
-
];
|
|
14
8
|
const paybin = (options) => {
|
|
15
9
|
const issuer = options.issuer || "https://idp.paybin.io";
|
|
16
10
|
const authorizationEndpoint = `${issuer}/oauth2/authorize`;
|
|
@@ -18,18 +12,24 @@ const paybin = (options) => {
|
|
|
18
12
|
return {
|
|
19
13
|
id: "paybin",
|
|
20
14
|
name: "Paybin",
|
|
21
|
-
|
|
22
|
-
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint, additionalParams }) {
|
|
15
|
+
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint, additionalParams }) {
|
|
23
16
|
if (!options.clientId || !options.clientSecret) {
|
|
24
17
|
logger.error("Client Id and Client Secret is required for Paybin. Make sure to provide them in the options.");
|
|
25
18
|
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
26
19
|
}
|
|
27
20
|
if (!codeVerifier) throw new BetterAuthError("codeVerifier is required for Paybin");
|
|
28
|
-
|
|
21
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
22
|
+
"openid",
|
|
23
|
+
"email",
|
|
24
|
+
"profile"
|
|
25
|
+
];
|
|
26
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
27
|
+
if (scopes) _scopes.push(...scopes);
|
|
28
|
+
return await createAuthorizationURL({
|
|
29
29
|
id: "paybin",
|
|
30
30
|
options,
|
|
31
31
|
authorizationEndpoint,
|
|
32
|
-
scopes:
|
|
32
|
+
scopes: _scopes,
|
|
33
33
|
state,
|
|
34
34
|
codeVerifier,
|
|
35
35
|
redirectURI,
|
|
@@ -51,7 +51,6 @@ interface PayPalOptions extends ProviderOptions<PayPalProfile> {
|
|
|
51
51
|
declare const paypal: (options: PayPalOptions) => {
|
|
52
52
|
id: "paypal";
|
|
53
53
|
name: string;
|
|
54
|
-
callbackPath: string;
|
|
55
54
|
createAuthorizationURL({
|
|
56
55
|
state,
|
|
57
56
|
codeVerifier,
|
|
@@ -66,10 +65,7 @@ declare const paypal: (options: PayPalOptions) => {
|
|
|
66
65
|
loginHint?: string | undefined;
|
|
67
66
|
idTokenNonce?: string | undefined;
|
|
68
67
|
additionalParams?: Record<string, string> | undefined;
|
|
69
|
-
}): Promise<
|
|
70
|
-
url: URL;
|
|
71
|
-
requestedScopes: string[];
|
|
72
|
-
}>;
|
|
68
|
+
}): Promise<URL>;
|
|
73
69
|
validateAuthorizationCode: ({
|
|
74
70
|
code,
|
|
75
71
|
redirectURI
|
|
@@ -12,18 +12,12 @@ const paypal = (options) => {
|
|
|
12
12
|
return {
|
|
13
13
|
id: "paypal",
|
|
14
14
|
name: "PayPal",
|
|
15
|
-
|
|
16
|
-
createAuthorizationURL({ state, codeVerifier, redirectURI, additionalParams }) {
|
|
15
|
+
async createAuthorizationURL({ state, codeVerifier, redirectURI, additionalParams }) {
|
|
17
16
|
if (!options.clientId || !options.clientSecret) {
|
|
18
17
|
logger.error("Client Id and Client Secret is required for PayPal. Make sure to provide them in the options.");
|
|
19
18
|
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
* Log in with PayPal doesn't use traditional OAuth2 scopes
|
|
23
|
-
* Instead, permissions are configured in the PayPal Developer Dashboard
|
|
24
|
-
* We don't pass any scopes to avoid "invalid scope" errors
|
|
25
|
-
**/
|
|
26
|
-
return createAuthorizationURL({
|
|
20
|
+
return await createAuthorizationURL({
|
|
27
21
|
id: "paypal",
|
|
28
22
|
options,
|
|
29
23
|
authorizationEndpoint,
|
|
@@ -25,7 +25,6 @@ interface PolarOptions extends ProviderOptions<PolarProfile> {}
|
|
|
25
25
|
declare const polar: (options: PolarOptions) => {
|
|
26
26
|
id: "polar";
|
|
27
27
|
name: string;
|
|
28
|
-
callbackPath: string;
|
|
29
28
|
createAuthorizationURL({
|
|
30
29
|
state,
|
|
31
30
|
scopes,
|
|
@@ -41,10 +40,7 @@ declare const polar: (options: PolarOptions) => {
|
|
|
41
40
|
loginHint?: string | undefined;
|
|
42
41
|
idTokenNonce?: string | undefined;
|
|
43
42
|
additionalParams?: Record<string, string> | undefined;
|
|
44
|
-
}): Promise<
|
|
45
|
-
url: URL;
|
|
46
|
-
requestedScopes: string[];
|
|
47
|
-
}>;
|
|
43
|
+
}): Promise<URL>;
|
|
48
44
|
validateAuthorizationCode: ({
|
|
49
45
|
code,
|
|
50
46
|
codeVerifier,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
5
|
//#region src/social-providers/polar.ts
|
|
7
|
-
const POLAR_DEFAULT_SCOPES = [
|
|
8
|
-
"openid",
|
|
9
|
-
"profile",
|
|
10
|
-
"email"
|
|
11
|
-
];
|
|
12
6
|
const polar = (options) => {
|
|
13
7
|
const tokenEndpoint = "https://api.polar.sh/v1/oauth2/token";
|
|
14
8
|
return {
|
|
15
9
|
id: "polar",
|
|
16
10
|
name: "Polar",
|
|
17
|
-
callbackPath: "/callback/polar",
|
|
18
11
|
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
13
|
+
"openid",
|
|
14
|
+
"profile",
|
|
15
|
+
"email"
|
|
16
|
+
];
|
|
17
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
18
|
+
if (scopes) _scopes.push(...scopes);
|
|
19
19
|
return createAuthorizationURL({
|
|
20
20
|
id: "polar",
|
|
21
21
|
options,
|
|
22
22
|
authorizationEndpoint: "https://polar.sh/oauth2/authorize",
|
|
23
|
-
scopes:
|
|
23
|
+
scopes: _scopes,
|
|
24
24
|
state,
|
|
25
25
|
codeVerifier,
|
|
26
26
|
redirectURI,
|
|
@@ -16,7 +16,6 @@ interface RailwayOptions extends ProviderOptions<RailwayProfile> {
|
|
|
16
16
|
declare const railway: (options: RailwayOptions) => {
|
|
17
17
|
id: "railway";
|
|
18
18
|
name: string;
|
|
19
|
-
callbackPath: string;
|
|
20
19
|
createAuthorizationURL({
|
|
21
20
|
state,
|
|
22
21
|
scopes,
|
|
@@ -32,10 +31,7 @@ declare const railway: (options: RailwayOptions) => {
|
|
|
32
31
|
loginHint?: string | undefined;
|
|
33
32
|
idTokenNonce?: string | undefined;
|
|
34
33
|
additionalParams?: Record<string, string> | undefined;
|
|
35
|
-
}): Promise<
|
|
36
|
-
url: URL;
|
|
37
|
-
requestedScopes: string[];
|
|
38
|
-
}>;
|
|
34
|
+
}): Promise<URL>;
|
|
39
35
|
validateAuthorizationCode: ({
|
|
40
36
|
code,
|
|
41
37
|
codeVerifier,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveRequestedScopes } from "../oauth2/scopes.mjs";
|
|
2
1
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
2
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
3
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
@@ -7,22 +6,23 @@ import { betterFetch } from "@better-fetch/fetch";
|
|
|
7
6
|
const authorizationEndpoint = "https://backboard.railway.com/oauth/auth";
|
|
8
7
|
const tokenEndpoint = "https://backboard.railway.com/oauth/token";
|
|
9
8
|
const userinfoEndpoint = "https://backboard.railway.com/oauth/me";
|
|
10
|
-
const RAILWAY_DEFAULT_SCOPES = [
|
|
11
|
-
"openid",
|
|
12
|
-
"email",
|
|
13
|
-
"profile"
|
|
14
|
-
];
|
|
15
9
|
const railway = (options) => {
|
|
16
10
|
return {
|
|
17
11
|
id: "railway",
|
|
18
12
|
name: "Railway",
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }) {
|
|
14
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
15
|
+
"openid",
|
|
16
|
+
"email",
|
|
17
|
+
"profile"
|
|
18
|
+
];
|
|
19
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
20
|
+
if (scopes) _scopes.push(...scopes);
|
|
21
21
|
return createAuthorizationURL({
|
|
22
22
|
id: "railway",
|
|
23
23
|
options,
|
|
24
24
|
authorizationEndpoint,
|
|
25
|
-
scopes:
|
|
25
|
+
scopes: _scopes,
|
|
26
26
|
state,
|
|
27
27
|
codeVerifier,
|
|
28
28
|
redirectURI,
|