@better-auth/core 1.7.0-beta.6 → 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/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 +4 -5
- package/dist/oauth2/create-authorization-url.mjs +4 -5
- package/dist/oauth2/index.d.mts +3 -4
- package/dist/oauth2/index.mjs +2 -3
- package/dist/oauth2/oauth-provider.d.mts +44 -48
- package/dist/oauth2/refresh-access-token.mjs +17 -2
- 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 +3 -5
- package/dist/social-providers/apple.mjs +5 -5
- package/dist/social-providers/atlassian.d.mts +3 -5
- package/dist/social-providers/atlassian.mjs +4 -4
- package/dist/social-providers/cognito.d.mts +3 -5
- package/dist/social-providers/cognito.mjs +11 -18
- package/dist/social-providers/discord.d.mts +3 -5
- package/dist/social-providers/discord.mjs +6 -7
- package/dist/social-providers/dropbox.d.mts +3 -5
- package/dist/social-providers/dropbox.mjs +5 -5
- package/dist/social-providers/facebook.d.mts +3 -5
- package/dist/social-providers/facebook.mjs +5 -5
- package/dist/social-providers/figma.d.mts +3 -5
- package/dist/social-providers/figma.mjs +5 -5
- package/dist/social-providers/github.d.mts +3 -5
- package/dist/social-providers/github.mjs +4 -4
- package/dist/social-providers/gitlab.d.mts +3 -5
- package/dist/social-providers/gitlab.mjs +6 -6
- package/dist/social-providers/google.d.mts +10 -10
- package/dist/social-providers/google.mjs +12 -13
- package/dist/social-providers/huggingface.d.mts +3 -5
- package/dist/social-providers/huggingface.mjs +8 -8
- package/dist/social-providers/index.d.mts +105 -177
- package/dist/social-providers/kakao.d.mts +3 -5
- package/dist/social-providers/kakao.mjs +8 -8
- package/dist/social-providers/kick.d.mts +3 -5
- package/dist/social-providers/kick.mjs +4 -4
- package/dist/social-providers/line.d.mts +3 -5
- package/dist/social-providers/line.mjs +10 -10
- package/dist/social-providers/linear.d.mts +3 -5
- package/dist/social-providers/linear.mjs +4 -4
- package/dist/social-providers/linkedin.d.mts +3 -5
- package/dist/social-providers/linkedin.mjs +10 -10
- package/dist/social-providers/microsoft-entra-id.d.mts +3 -5
- package/dist/social-providers/microsoft-entra-id.mjs +10 -11
- package/dist/social-providers/naver.d.mts +3 -5
- package/dist/social-providers/naver.mjs +4 -4
- package/dist/social-providers/notion.d.mts +3 -5
- package/dist/social-providers/notion.mjs +4 -4
- package/dist/social-providers/paybin.d.mts +3 -5
- package/dist/social-providers/paybin.mjs +10 -10
- package/dist/social-providers/paypal.d.mts +3 -5
- package/dist/social-providers/paypal.mjs +2 -8
- package/dist/social-providers/polar.d.mts +3 -5
- package/dist/social-providers/polar.mjs +8 -8
- package/dist/social-providers/railway.d.mts +3 -5
- package/dist/social-providers/railway.mjs +9 -9
- package/dist/social-providers/reddit.d.mts +3 -5
- package/dist/social-providers/reddit.mjs +5 -5
- package/dist/social-providers/roblox.d.mts +3 -5
- package/dist/social-providers/roblox.mjs +5 -5
- package/dist/social-providers/salesforce.d.mts +3 -5
- package/dist/social-providers/salesforce.mjs +8 -8
- package/dist/social-providers/slack.d.mts +3 -5
- package/dist/social-providers/slack.mjs +9 -9
- package/dist/social-providers/spotify.d.mts +3 -5
- package/dist/social-providers/spotify.mjs +5 -5
- package/dist/social-providers/tiktok.d.mts +3 -5
- package/dist/social-providers/tiktok.mjs +5 -9
- package/dist/social-providers/twitch.d.mts +3 -5
- package/dist/social-providers/twitch.mjs +4 -4
- package/dist/social-providers/twitter.d.mts +3 -5
- package/dist/social-providers/twitter.mjs +9 -9
- package/dist/social-providers/vercel.d.mts +3 -5
- package/dist/social-providers/vercel.mjs +7 -4
- package/dist/social-providers/vk.d.mts +3 -5
- package/dist/social-providers/vk.mjs +5 -5
- package/dist/social-providers/wechat.d.mts +3 -5
- package/dist/social-providers/wechat.mjs +5 -9
- package/dist/social-providers/zoom.d.mts +3 -6
- package/dist/social-providers/zoom.mjs +9 -15
- package/dist/types/context.d.mts +6 -2
- package/dist/utils/host.d.mts +1 -1
- package/dist/utils/host.mjs +3 -0
- 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 +5 -1
- package/src/oauth2/index.ts +3 -12
- package/src/oauth2/oauth-provider.ts +46 -53
- package/src/oauth2/refresh-access-token.ts +30 -5
- package/src/oauth2/utils.ts +39 -1
- package/src/oauth2/verify-id-token.ts +9 -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/src/utils/host.ts +10 -1
- package/dist/oauth2/scopes.d.mts +0 -76
- package/dist/oauth2/scopes.mjs +0 -96
- package/src/oauth2/scopes.ts +0 -118
|
@@ -93,7 +93,6 @@ interface KakaoOptions extends ProviderOptions<KakaoProfile> {
|
|
|
93
93
|
declare const kakao: (options: KakaoOptions) => {
|
|
94
94
|
id: "kakao";
|
|
95
95
|
name: string;
|
|
96
|
-
callbackPath: string;
|
|
97
96
|
createAuthorizationURL({
|
|
98
97
|
state,
|
|
99
98
|
scopes,
|
|
@@ -106,11 +105,9 @@ declare const kakao: (options: KakaoOptions) => {
|
|
|
106
105
|
redirectURI: string;
|
|
107
106
|
display?: string | undefined;
|
|
108
107
|
loginHint?: string | undefined;
|
|
108
|
+
idTokenNonce?: string | undefined;
|
|
109
109
|
additionalParams?: Record<string, string> | undefined;
|
|
110
|
-
}): Promise<
|
|
111
|
-
url: URL;
|
|
112
|
-
requestedScopes: string[];
|
|
113
|
-
}>;
|
|
110
|
+
}): Promise<URL>;
|
|
114
111
|
validateAuthorizationCode: ({
|
|
115
112
|
code,
|
|
116
113
|
redirectURI
|
|
@@ -122,6 +119,7 @@ declare const kakao: (options: KakaoOptions) => {
|
|
|
122
119
|
}) => Promise<OAuth2Tokens>;
|
|
123
120
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
124
121
|
getUserInfo(token: OAuth2Tokens & {
|
|
122
|
+
expectedIdTokenNonce?: string | undefined;
|
|
125
123
|
user?: {
|
|
126
124
|
name?: {
|
|
127
125
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -38,11 +37,9 @@ declare const kick: (options: KickOptions) => {
|
|
|
38
37
|
redirectURI: string;
|
|
39
38
|
display?: string | undefined;
|
|
40
39
|
loginHint?: string | undefined;
|
|
40
|
+
idTokenNonce?: string | undefined;
|
|
41
41
|
additionalParams?: Record<string, string> | undefined;
|
|
42
|
-
}): Promise<
|
|
43
|
-
url: URL;
|
|
44
|
-
requestedScopes: string[];
|
|
45
|
-
}>;
|
|
42
|
+
}): Promise<URL>;
|
|
46
43
|
validateAuthorizationCode({
|
|
47
44
|
code,
|
|
48
45
|
redirectURI,
|
|
@@ -55,6 +52,7 @@ declare const kick: (options: KickOptions) => {
|
|
|
55
52
|
}): Promise<OAuth2Tokens>;
|
|
56
53
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
57
54
|
getUserInfo(token: OAuth2Tokens & {
|
|
55
|
+
expectedIdTokenNonce?: string | undefined;
|
|
58
56
|
user?: {
|
|
59
57
|
name?: {
|
|
60
58
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -48,11 +47,9 @@ declare const line: (options: LineOptions) => {
|
|
|
48
47
|
redirectURI: string;
|
|
49
48
|
display?: string | undefined;
|
|
50
49
|
loginHint?: string | undefined;
|
|
50
|
+
idTokenNonce?: string | undefined;
|
|
51
51
|
additionalParams?: Record<string, string> | undefined;
|
|
52
|
-
}): Promise<
|
|
53
|
-
url: URL;
|
|
54
|
-
requestedScopes: string[];
|
|
55
|
-
}>;
|
|
52
|
+
}): Promise<URL>;
|
|
56
53
|
validateAuthorizationCode: ({
|
|
57
54
|
code,
|
|
58
55
|
codeVerifier,
|
|
@@ -68,6 +65,7 @@ declare const line: (options: LineOptions) => {
|
|
|
68
65
|
verify: (token: string, nonce: string | undefined) => Promise<boolean>;
|
|
69
66
|
};
|
|
70
67
|
getUserInfo(token: OAuth2Tokens & {
|
|
68
|
+
expectedIdTokenNonce?: string | undefined;
|
|
71
69
|
user?: {
|
|
72
70
|
name?: {
|
|
73
71
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -34,11 +33,9 @@ declare const linear: (options: LinearOptions) => {
|
|
|
34
33
|
redirectURI: string;
|
|
35
34
|
display?: string | undefined;
|
|
36
35
|
loginHint?: string | undefined;
|
|
36
|
+
idTokenNonce?: string | undefined;
|
|
37
37
|
additionalParams?: Record<string, string> | undefined;
|
|
38
|
-
}): Promise<
|
|
39
|
-
url: URL;
|
|
40
|
-
requestedScopes: string[];
|
|
41
|
-
}>;
|
|
38
|
+
}): Promise<URL>;
|
|
42
39
|
validateAuthorizationCode: ({
|
|
43
40
|
code,
|
|
44
41
|
redirectURI
|
|
@@ -50,6 +47,7 @@ declare const linear: (options: LinearOptions) => {
|
|
|
50
47
|
}) => Promise<OAuth2Tokens>;
|
|
51
48
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
52
49
|
getUserInfo(token: OAuth2Tokens & {
|
|
50
|
+
expectedIdTokenNonce?: string | undefined;
|
|
53
51
|
user?: {
|
|
54
52
|
name?: {
|
|
55
53
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -33,11 +32,9 @@ declare const linkedin: (options: LinkedInOptions) => {
|
|
|
33
32
|
redirectURI: string;
|
|
34
33
|
display?: string | undefined;
|
|
35
34
|
loginHint?: string | undefined;
|
|
35
|
+
idTokenNonce?: string | undefined;
|
|
36
36
|
additionalParams?: Record<string, string> | undefined;
|
|
37
|
-
}) => Promise<
|
|
38
|
-
url: URL;
|
|
39
|
-
requestedScopes: string[];
|
|
40
|
-
}>;
|
|
37
|
+
}) => Promise<URL>;
|
|
41
38
|
validateAuthorizationCode: ({
|
|
42
39
|
code,
|
|
43
40
|
redirectURI
|
|
@@ -49,6 +46,7 @@ declare const linkedin: (options: LinkedInOptions) => {
|
|
|
49
46
|
}) => Promise<OAuth2Tokens>;
|
|
50
47
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
51
48
|
getUserInfo(token: OAuth2Tokens & {
|
|
49
|
+
expectedIdTokenNonce?: string | undefined;
|
|
52
50
|
user?: {
|
|
53
51
|
name?: {
|
|
54
52
|
firstName?: string;
|
|
@@ -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;
|
|
@@ -147,11 +146,9 @@ declare const microsoft: (options: MicrosoftOptions) => {
|
|
|
147
146
|
redirectURI: string;
|
|
148
147
|
display?: string | undefined;
|
|
149
148
|
loginHint?: string | undefined;
|
|
149
|
+
idTokenNonce?: string | undefined;
|
|
150
150
|
additionalParams?: Record<string, string> | undefined;
|
|
151
|
-
}): Promise<
|
|
152
|
-
url: URL;
|
|
153
|
-
requestedScopes: string[];
|
|
154
|
-
}>;
|
|
151
|
+
}): Promise<URL>;
|
|
155
152
|
validateAuthorizationCode({
|
|
156
153
|
code,
|
|
157
154
|
codeVerifier,
|
|
@@ -184,6 +181,7 @@ declare const microsoft: (options: MicrosoftOptions) => {
|
|
|
184
181
|
verifyClaims: (claims: Record<string, unknown>) => boolean;
|
|
185
182
|
};
|
|
186
183
|
getUserInfo(token: OAuth2Tokens & {
|
|
184
|
+
expectedIdTokenNonce?: string | undefined;
|
|
187
185
|
user?: {
|
|
188
186
|
name?: {
|
|
189
187
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -37,11 +36,9 @@ declare const naver: (options: NaverOptions) => {
|
|
|
37
36
|
redirectURI: string;
|
|
38
37
|
display?: string | undefined;
|
|
39
38
|
loginHint?: string | undefined;
|
|
39
|
+
idTokenNonce?: string | undefined;
|
|
40
40
|
additionalParams?: Record<string, string> | undefined;
|
|
41
|
-
}): Promise<
|
|
42
|
-
url: URL;
|
|
43
|
-
requestedScopes: string[];
|
|
44
|
-
}>;
|
|
41
|
+
}): Promise<URL>;
|
|
45
42
|
validateAuthorizationCode: ({
|
|
46
43
|
code,
|
|
47
44
|
redirectURI
|
|
@@ -53,6 +50,7 @@ declare const naver: (options: NaverOptions) => {
|
|
|
53
50
|
}) => Promise<OAuth2Tokens>;
|
|
54
51
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
55
52
|
getUserInfo(token: OAuth2Tokens & {
|
|
53
|
+
expectedIdTokenNonce?: string | undefined;
|
|
56
54
|
user?: {
|
|
57
55
|
name?: {
|
|
58
56
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -30,11 +29,9 @@ declare const notion: (options: NotionOptions) => {
|
|
|
30
29
|
redirectURI: string;
|
|
31
30
|
display?: string | undefined;
|
|
32
31
|
loginHint?: string | undefined;
|
|
32
|
+
idTokenNonce?: string | undefined;
|
|
33
33
|
additionalParams?: Record<string, string> | undefined;
|
|
34
|
-
}): Promise<
|
|
35
|
-
url: URL;
|
|
36
|
-
requestedScopes: string[];
|
|
37
|
-
}>;
|
|
34
|
+
}): Promise<URL>;
|
|
38
35
|
validateAuthorizationCode: ({
|
|
39
36
|
code,
|
|
40
37
|
redirectURI
|
|
@@ -46,6 +43,7 @@ declare const notion: (options: NotionOptions) => {
|
|
|
46
43
|
}) => Promise<OAuth2Tokens>;
|
|
47
44
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
48
45
|
getUserInfo(token: OAuth2Tokens & {
|
|
46
|
+
expectedIdTokenNonce?: string | undefined;
|
|
49
47
|
user?: {
|
|
50
48
|
name?: {
|
|
51
49
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -36,11 +35,9 @@ declare const paybin: (options: PaybinOptions) => {
|
|
|
36
35
|
redirectURI: string;
|
|
37
36
|
display?: string | undefined;
|
|
38
37
|
loginHint?: string | undefined;
|
|
38
|
+
idTokenNonce?: string | undefined;
|
|
39
39
|
additionalParams?: Record<string, string> | undefined;
|
|
40
|
-
}): Promise<
|
|
41
|
-
url: URL;
|
|
42
|
-
requestedScopes: string[];
|
|
43
|
-
}>;
|
|
40
|
+
}): Promise<URL>;
|
|
44
41
|
validateAuthorizationCode: ({
|
|
45
42
|
code,
|
|
46
43
|
codeVerifier,
|
|
@@ -53,6 +50,7 @@ declare const paybin: (options: PaybinOptions) => {
|
|
|
53
50
|
}) => Promise<OAuth2Tokens>;
|
|
54
51
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
55
52
|
getUserInfo(token: OAuth2Tokens & {
|
|
53
|
+
expectedIdTokenNonce?: string | undefined;
|
|
56
54
|
user?: {
|
|
57
55
|
name?: {
|
|
58
56
|
firstName?: string;
|
|
@@ -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,
|
|
@@ -64,11 +63,9 @@ declare const paypal: (options: PayPalOptions) => {
|
|
|
64
63
|
redirectURI: string;
|
|
65
64
|
display?: string | undefined;
|
|
66
65
|
loginHint?: string | undefined;
|
|
66
|
+
idTokenNonce?: string | undefined;
|
|
67
67
|
additionalParams?: Record<string, string> | undefined;
|
|
68
|
-
}): Promise<
|
|
69
|
-
url: URL;
|
|
70
|
-
requestedScopes: string[];
|
|
71
|
-
}>;
|
|
68
|
+
}): Promise<URL>;
|
|
72
69
|
validateAuthorizationCode: ({
|
|
73
70
|
code,
|
|
74
71
|
redirectURI
|
|
@@ -89,6 +86,7 @@ declare const paypal: (options: PayPalOptions) => {
|
|
|
89
86
|
accessTokenExpiresAt: Date | undefined;
|
|
90
87
|
}>);
|
|
91
88
|
getUserInfo(token: OAuth2Tokens & {
|
|
89
|
+
expectedIdTokenNonce?: string | undefined;
|
|
92
90
|
user?: {
|
|
93
91
|
name?: {
|
|
94
92
|
firstName?: string;
|
|
@@ -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,
|