@better-auth/core 1.7.0-rc.1 → 1.7.0-rc.3
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 +28 -28
- package/dist/async_hooks/index.d.mts +0 -1
- package/dist/async_hooks/pure.index.d.mts +0 -1
- package/dist/context/endpoint-context.d.mts +1 -1
- package/dist/context/global.d.mts +0 -1
- package/dist/context/global.mjs +1 -1
- package/dist/context/request-state.d.mts +0 -1
- package/dist/context/request-state.mjs +8 -5
- package/dist/context/transaction.d.mts +8 -3
- package/dist/context/transaction.mjs +27 -10
- package/dist/db/adapter/factory.d.mts +3 -5
- package/dist/db/adapter/factory.mjs +7 -5
- package/dist/db/adapter/get-default-field-name.d.mts +2 -9
- package/dist/db/adapter/get-default-model-name.d.mts +1 -5
- package/dist/db/adapter/get-default-model-name.mjs +6 -5
- package/dist/db/adapter/get-field-attributes.d.mts +4 -11
- package/dist/db/adapter/get-field-name.d.mts +2 -9
- package/dist/db/adapter/get-id-field.d.mts +4 -12
- package/dist/db/adapter/get-model-name.d.mts +1 -5
- package/dist/db/adapter/index.d.mts +7 -32
- package/dist/db/adapter/types.d.mts +5 -17
- package/dist/db/adapter/utils.d.mts +0 -1
- package/dist/db/database-index.d.mts +44 -0
- package/dist/db/database-index.mjs +168 -0
- package/dist/db/get-tables.d.mts +7 -1
- package/dist/db/get-tables.mjs +47 -6
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +2 -2
- package/dist/db/internal.d.mts +3 -0
- package/dist/db/internal.mjs +3 -0
- package/dist/db/plugin.d.mts +4 -3
- package/dist/db/schema/account.d.mts +16 -3
- package/dist/db/schema/account.mjs +35 -2
- package/dist/db/schema/rate-limit.d.mts +1 -1
- package/dist/db/schema/rate-limit.mjs +9 -0
- package/dist/db/schema/session.d.mts +1 -1
- package/dist/db/schema/shared.d.mts +0 -1
- package/dist/db/schema/user.d.mts +1 -1
- package/dist/db/schema/verification.d.mts +1 -1
- package/dist/db/type.d.mts +17 -9
- package/dist/env/logger.d.mts +25 -25
- package/dist/error/codes.d.mts +0 -1
- package/dist/error/index.d.mts +0 -1
- package/dist/index.d.mts +1 -1
- package/dist/instrumentation/attributes.d.mts +0 -1
- package/dist/instrumentation/pure.index.d.mts +0 -1
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/oauth2/authorization-params.d.mts +0 -1
- package/dist/oauth2/client-assertion.d.mts +3 -13
- package/dist/oauth2/client-credentials-token.d.mts +3 -17
- package/dist/oauth2/client-credentials-token.mjs +1 -4
- package/dist/oauth2/create-authorization-url.d.mts +3 -21
- package/dist/oauth2/dpop.d.mts +2 -23
- package/dist/oauth2/dpop.mjs +1 -1
- package/dist/oauth2/index.d.mts +3 -3
- package/dist/oauth2/index.mjs +2 -2
- package/dist/oauth2/oauth-provider.d.mts +94 -36
- package/dist/oauth2/refresh-access-token.d.mts +3 -19
- package/dist/oauth2/refresh-access-token.mjs +3 -9
- package/dist/oauth2/reject-redirects.mjs +1 -1
- package/dist/oauth2/token-endpoint-auth.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/oauth2/utils.mjs +2 -3
- package/dist/oauth2/validate-authorization-code.d.mts +5 -29
- package/dist/oauth2/verify-id-token.d.mts +3 -2
- package/dist/oauth2/verify-id-token.mjs +3 -3
- package/dist/oauth2/verify.d.mts +18 -9
- package/dist/oauth2/verify.mjs +68 -5
- package/dist/social-providers/apple.d.mts +9 -24
- package/dist/social-providers/apple.mjs +2 -1
- package/dist/social-providers/atlassian.d.mts +18 -19
- package/dist/social-providers/atlassian.mjs +1 -1
- package/dist/social-providers/cognito.d.mts +33 -22
- package/dist/social-providers/cognito.mjs +2 -2
- package/dist/social-providers/discord.d.mts +7 -20
- package/dist/social-providers/discord.mjs +1 -1
- package/dist/social-providers/dropbox.d.mts +7 -22
- package/dist/social-providers/dropbox.mjs +1 -1
- package/dist/social-providers/facebook.d.mts +19 -27
- package/dist/social-providers/facebook.mjs +6 -17
- package/dist/social-providers/figma.d.mts +7 -22
- package/dist/social-providers/figma.mjs +1 -1
- package/dist/social-providers/github.d.mts +7 -23
- package/dist/social-providers/github.mjs +1 -1
- package/dist/social-providers/gitlab.d.mts +6 -43
- package/dist/social-providers/gitlab.mjs +1 -1
- package/dist/social-providers/google.d.mts +10 -32
- package/dist/social-providers/google.mjs +2 -1
- package/dist/social-providers/huggingface.d.mts +7 -22
- package/dist/social-providers/huggingface.mjs +1 -1
- package/dist/social-providers/index.d.mts +229 -787
- package/dist/social-providers/kakao.d.mts +8 -33
- package/dist/social-providers/kakao.mjs +1 -1
- package/dist/social-providers/kick.d.mts +7 -22
- package/dist/social-providers/kick.mjs +1 -1
- package/dist/social-providers/line.d.mts +8 -44
- package/dist/social-providers/line.mjs +4 -6
- package/dist/social-providers/linear.d.mts +7 -21
- package/dist/social-providers/linear.mjs +1 -1
- package/dist/social-providers/linkedin.d.mts +7 -21
- package/dist/social-providers/linkedin.mjs +1 -1
- package/dist/social-providers/microsoft-entra-id.d.mts +8 -18
- package/dist/social-providers/microsoft-entra-id.mjs +24 -4
- package/dist/social-providers/naver.d.mts +27 -42
- package/dist/social-providers/naver.mjs +1 -1
- package/dist/social-providers/notion.d.mts +7 -21
- package/dist/social-providers/notion.mjs +1 -1
- package/dist/social-providers/paybin.d.mts +8 -23
- package/dist/social-providers/paybin.mjs +2 -1
- package/dist/social-providers/paypal.d.mts +8 -33
- package/dist/social-providers/paypal.mjs +1 -1
- package/dist/social-providers/polar.d.mts +7 -22
- package/dist/social-providers/polar.mjs +1 -1
- package/dist/social-providers/railway.d.mts +7 -22
- package/dist/social-providers/railway.mjs +1 -1
- package/dist/social-providers/reddit.d.mts +7 -20
- package/dist/social-providers/reddit.mjs +1 -1
- package/dist/social-providers/roblox.d.mts +7 -20
- package/dist/social-providers/roblox.mjs +1 -1
- package/dist/social-providers/salesforce.d.mts +7 -22
- package/dist/social-providers/salesforce.mjs +1 -1
- package/dist/social-providers/slack.d.mts +7 -20
- package/dist/social-providers/slack.mjs +1 -1
- package/dist/social-providers/spotify.d.mts +7 -22
- package/dist/social-providers/spotify.mjs +1 -1
- package/dist/social-providers/tiktok.d.mts +10 -22
- package/dist/social-providers/tiktok.mjs +1 -1
- package/dist/social-providers/twitch.d.mts +7 -20
- package/dist/social-providers/twitch.mjs +1 -1
- package/dist/social-providers/twitter.d.mts +29 -26
- package/dist/social-providers/twitter.mjs +1 -1
- package/dist/social-providers/vercel.d.mts +7 -22
- package/dist/social-providers/vercel.mjs +1 -1
- package/dist/social-providers/vk.d.mts +8 -24
- package/dist/social-providers/vk.mjs +5 -6
- package/dist/social-providers/wechat.d.mts +7 -19
- package/dist/social-providers/wechat.mjs +1 -1
- package/dist/social-providers/zoom.d.mts +9 -25
- package/dist/social-providers/zoom.mjs +1 -1
- package/dist/types/context.d.mts +16 -9
- package/dist/types/cookie.d.mts +0 -1
- package/dist/types/helper.d.mts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/init-options.d.mts +37 -26
- package/dist/types/plugin-client.d.mts +1 -3
- package/dist/types/plugin.d.mts +2 -2
- package/dist/utils/async.d.mts +0 -1
- package/dist/utils/db.d.mts +1 -0
- package/dist/utils/deprecate.d.mts +0 -1
- package/dist/utils/error-codes.d.mts +2 -2
- package/dist/utils/host.d.mts +27 -1
- package/dist/utils/host.mjs +1 -1
- package/dist/utils/ip.d.mts +1 -0
- package/dist/utils/ip.mjs +1 -1
- package/dist/utils/is-api-error.d.mts +0 -1
- package/dist/utils/redirect-uri.d.mts +6 -2
- package/dist/utils/redirect-uri.mjs +11 -1
- package/package.json +10 -2
- package/src/context/request-state.ts +26 -6
- package/src/context/transaction.ts +37 -18
- package/src/db/adapter/factory.ts +34 -28
- package/src/db/adapter/get-default-model-name.ts +23 -14
- package/src/db/database-index.ts +351 -0
- package/src/db/get-tables.ts +89 -9
- package/src/db/index.ts +4 -0
- package/src/db/internal.ts +12 -0
- package/src/db/plugin.ts +3 -1
- package/src/db/schema/account.ts +27 -1
- package/src/db/schema/user.ts +1 -1
- package/src/db/type.ts +12 -0
- package/src/error/codes.ts +1 -0
- package/src/oauth2/index.ts +5 -0
- package/src/oauth2/oauth-provider.ts +105 -36
- package/src/oauth2/verify-id-token.ts +4 -2
- package/src/oauth2/verify.ts +121 -12
- package/src/social-providers/apple.ts +2 -1
- package/src/social-providers/atlassian.ts +1 -1
- package/src/social-providers/cognito.ts +2 -2
- package/src/social-providers/discord.ts +1 -1
- package/src/social-providers/dropbox.ts +1 -1
- package/src/social-providers/facebook.ts +21 -28
- package/src/social-providers/figma.ts +1 -1
- package/src/social-providers/github.ts +1 -1
- package/src/social-providers/gitlab.ts +1 -1
- package/src/social-providers/google.ts +2 -1
- package/src/social-providers/huggingface.ts +1 -1
- package/src/social-providers/kakao.ts +1 -1
- package/src/social-providers/kick.ts +1 -1
- package/src/social-providers/line.ts +7 -12
- package/src/social-providers/linear.ts +1 -1
- package/src/social-providers/linkedin.ts +1 -1
- package/src/social-providers/microsoft-entra-id.ts +36 -27
- package/src/social-providers/naver.ts +1 -1
- package/src/social-providers/notion.ts +1 -1
- package/src/social-providers/paybin.ts +2 -1
- package/src/social-providers/paypal.ts +1 -1
- package/src/social-providers/polar.ts +1 -1
- package/src/social-providers/railway.ts +1 -1
- package/src/social-providers/reddit.ts +1 -1
- package/src/social-providers/roblox.ts +1 -1
- package/src/social-providers/salesforce.ts +1 -1
- package/src/social-providers/slack.ts +1 -1
- package/src/social-providers/spotify.ts +1 -1
- package/src/social-providers/tiktok.ts +2 -2
- package/src/social-providers/twitch.ts +1 -1
- package/src/social-providers/twitter.ts +1 -1
- package/src/social-providers/vercel.ts +1 -1
- package/src/social-providers/vk.ts +2 -2
- package/src/social-providers/wechat.ts +1 -1
- package/src/social-providers/zoom.ts +1 -1
- package/src/types/context.ts +21 -14
- package/src/types/init-options.ts +15 -14
- package/src/utils/redirect-uri.ts +20 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/kakao.d.ts
|
|
3
4
|
interface Partner {
|
|
4
5
|
/** Partner-specific ID (consent required: kakaotalk_message) */
|
|
@@ -93,12 +94,8 @@ interface KakaoOptions extends ProviderOptions<KakaoProfile> {
|
|
|
93
94
|
declare const kakao: (options: KakaoOptions) => {
|
|
94
95
|
id: "kakao";
|
|
95
96
|
name: string;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
scopes,
|
|
99
|
-
redirectURI,
|
|
100
|
-
additionalParams
|
|
101
|
-
}: {
|
|
97
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<KakaoProfile>) => number;
|
|
98
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }: {
|
|
102
99
|
state: string;
|
|
103
100
|
codeVerifier: string;
|
|
104
101
|
scopes?: string[] | undefined;
|
|
@@ -108,10 +105,7 @@ declare const kakao: (options: KakaoOptions) => {
|
|
|
108
105
|
idTokenNonce?: string | undefined;
|
|
109
106
|
additionalParams?: Record<string, string> | undefined;
|
|
110
107
|
}): Promise<URL>;
|
|
111
|
-
validateAuthorizationCode: ({
|
|
112
|
-
code,
|
|
113
|
-
redirectURI
|
|
114
|
-
}: {
|
|
108
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
115
109
|
code: string;
|
|
116
110
|
redirectURI: string;
|
|
117
111
|
codeVerifier?: string | undefined;
|
|
@@ -128,30 +122,11 @@ declare const kakao: (options: KakaoOptions) => {
|
|
|
128
122
|
email?: string;
|
|
129
123
|
} | undefined;
|
|
130
124
|
}): Promise<{
|
|
131
|
-
user:
|
|
132
|
-
|
|
133
|
-
name?: string;
|
|
134
|
-
email?: string | null;
|
|
135
|
-
image?: string;
|
|
136
|
-
emailVerified: boolean;
|
|
137
|
-
[key: string]: any;
|
|
138
|
-
};
|
|
139
|
-
data: any;
|
|
125
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
126
|
+
data: KakaoProfile;
|
|
140
127
|
} | {
|
|
141
128
|
user: {
|
|
142
|
-
id
|
|
143
|
-
name: string;
|
|
144
|
-
email: string | undefined;
|
|
145
|
-
image: string | undefined;
|
|
146
|
-
emailVerified: boolean;
|
|
147
|
-
} | {
|
|
148
|
-
id: string;
|
|
149
|
-
name: string;
|
|
150
|
-
email: string | null;
|
|
151
|
-
image: string;
|
|
152
|
-
emailVerified: boolean;
|
|
153
|
-
} | {
|
|
154
|
-
id: string;
|
|
129
|
+
id?: never;
|
|
155
130
|
name: string;
|
|
156
131
|
email: string | null;
|
|
157
132
|
image: string;
|
|
@@ -8,6 +8,7 @@ const kakao = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "kakao",
|
|
10
10
|
name: "Kakao",
|
|
11
|
+
accountSubject: ({ profile }) => profile.id,
|
|
11
12
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : [
|
|
13
14
|
"account_email",
|
|
@@ -54,7 +55,6 @@ const kakao = (options) => {
|
|
|
54
55
|
const kakaoProfile = account.profile || {};
|
|
55
56
|
return {
|
|
56
57
|
user: {
|
|
57
|
-
id: String(profile.id),
|
|
58
58
|
name: kakaoProfile.nickname || account.name || "",
|
|
59
59
|
email: account.email,
|
|
60
60
|
image: kakaoProfile.profile_image_url || kakaoProfile.thumbnail_image_url,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/kick.d.ts
|
|
3
4
|
interface KickProfile {
|
|
4
5
|
/**
|
|
@@ -24,13 +25,8 @@ interface KickOptions extends ProviderOptions<KickProfile> {
|
|
|
24
25
|
declare const kick: (options: KickOptions) => {
|
|
25
26
|
id: "kick";
|
|
26
27
|
name: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
scopes,
|
|
30
|
-
redirectURI,
|
|
31
|
-
codeVerifier,
|
|
32
|
-
additionalParams
|
|
33
|
-
}: {
|
|
28
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<KickProfile>) => string;
|
|
29
|
+
createAuthorizationURL({ state, scopes, redirectURI, codeVerifier, additionalParams }: {
|
|
34
30
|
state: string;
|
|
35
31
|
codeVerifier: string;
|
|
36
32
|
scopes?: string[] | undefined;
|
|
@@ -40,11 +36,7 @@ declare const kick: (options: KickOptions) => {
|
|
|
40
36
|
idTokenNonce?: string | undefined;
|
|
41
37
|
additionalParams?: Record<string, string> | undefined;
|
|
42
38
|
}): Promise<URL>;
|
|
43
|
-
validateAuthorizationCode({
|
|
44
|
-
code,
|
|
45
|
-
redirectURI,
|
|
46
|
-
codeVerifier
|
|
47
|
-
}: {
|
|
39
|
+
validateAuthorizationCode({ code, redirectURI, codeVerifier }: {
|
|
48
40
|
code: string;
|
|
49
41
|
redirectURI: string;
|
|
50
42
|
codeVerifier?: string | undefined;
|
|
@@ -61,15 +53,8 @@ declare const kick: (options: KickOptions) => {
|
|
|
61
53
|
email?: string;
|
|
62
54
|
} | undefined;
|
|
63
55
|
}): Promise<{
|
|
64
|
-
user:
|
|
65
|
-
|
|
66
|
-
name?: string;
|
|
67
|
-
email?: string | null;
|
|
68
|
-
image?: string;
|
|
69
|
-
emailVerified: boolean;
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
};
|
|
72
|
-
data: any;
|
|
56
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
57
|
+
data: KickProfile;
|
|
73
58
|
} | null>;
|
|
74
59
|
options: KickOptions;
|
|
75
60
|
};
|
|
@@ -7,6 +7,7 @@ const kick = (options) => {
|
|
|
7
7
|
return {
|
|
8
8
|
id: "kick",
|
|
9
9
|
name: "Kick",
|
|
10
|
+
accountSubject: ({ profile }) => profile.user_id,
|
|
10
11
|
createAuthorizationURL({ state, scopes, redirectURI, codeVerifier, additionalParams }) {
|
|
11
12
|
const _scopes = options.disableDefaultScope ? [] : ["user:read"];
|
|
12
13
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -52,7 +53,6 @@ const kick = (options) => {
|
|
|
52
53
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
53
54
|
return {
|
|
54
55
|
user: {
|
|
55
|
-
id: profile.user_id,
|
|
56
56
|
name: profile.name,
|
|
57
57
|
email: profile.email,
|
|
58
58
|
image: profile.profile_picture,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/line.d.ts
|
|
3
4
|
interface LineIdTokenPayload {
|
|
4
5
|
iss: string;
|
|
@@ -33,14 +34,9 @@ interface LineOptions extends ProviderOptions<LineUserInfo | LineIdTokenPayload>
|
|
|
33
34
|
declare const line: (options: LineOptions) => {
|
|
34
35
|
id: "line";
|
|
35
36
|
name: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
codeVerifier,
|
|
40
|
-
redirectURI,
|
|
41
|
-
loginHint,
|
|
42
|
-
additionalParams
|
|
43
|
-
}: {
|
|
37
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<LineIdTokenPayload | LineUserInfo>) => string;
|
|
38
|
+
accountIssuer: string;
|
|
39
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint, additionalParams }: {
|
|
44
40
|
state: string;
|
|
45
41
|
codeVerifier: string;
|
|
46
42
|
scopes?: string[] | undefined;
|
|
@@ -50,11 +46,7 @@ declare const line: (options: LineOptions) => {
|
|
|
50
46
|
idTokenNonce?: string | undefined;
|
|
51
47
|
additionalParams?: Record<string, string> | undefined;
|
|
52
48
|
}): Promise<URL>;
|
|
53
|
-
validateAuthorizationCode: ({
|
|
54
|
-
code,
|
|
55
|
-
codeVerifier,
|
|
56
|
-
redirectURI
|
|
57
|
-
}: {
|
|
49
|
+
validateAuthorizationCode: ({ code, codeVerifier, redirectURI }: {
|
|
58
50
|
code: string;
|
|
59
51
|
redirectURI: string;
|
|
60
52
|
codeVerifier?: string | undefined;
|
|
@@ -74,36 +66,8 @@ declare const line: (options: LineOptions) => {
|
|
|
74
66
|
email?: string;
|
|
75
67
|
} | undefined;
|
|
76
68
|
}): Promise<{
|
|
77
|
-
user:
|
|
78
|
-
|
|
79
|
-
name?: string;
|
|
80
|
-
email?: string | null;
|
|
81
|
-
image?: string;
|
|
82
|
-
emailVerified: boolean;
|
|
83
|
-
[key: string]: any;
|
|
84
|
-
};
|
|
85
|
-
data: any;
|
|
86
|
-
} | {
|
|
87
|
-
user: {
|
|
88
|
-
id: any;
|
|
89
|
-
name: any;
|
|
90
|
-
email: any;
|
|
91
|
-
image: any;
|
|
92
|
-
emailVerified: false;
|
|
93
|
-
} | {
|
|
94
|
-
id: any;
|
|
95
|
-
name: any;
|
|
96
|
-
email: any;
|
|
97
|
-
image: any;
|
|
98
|
-
emailVerified: boolean;
|
|
99
|
-
} | {
|
|
100
|
-
id: any;
|
|
101
|
-
name: any;
|
|
102
|
-
email: any;
|
|
103
|
-
image: any;
|
|
104
|
-
emailVerified: boolean;
|
|
105
|
-
};
|
|
106
|
-
data: any;
|
|
69
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
70
|
+
data: LineIdTokenPayload | LineUserInfo;
|
|
107
71
|
} | null>;
|
|
108
72
|
options: LineOptions;
|
|
109
73
|
};
|
|
@@ -21,6 +21,8 @@ const line = (options) => {
|
|
|
21
21
|
return {
|
|
22
22
|
id: "line",
|
|
23
23
|
name: "LINE",
|
|
24
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
25
|
+
accountIssuer: "https://access.line.me",
|
|
24
26
|
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint, additionalParams }) {
|
|
25
27
|
const _scopes = options.disableDefaultScope ? [] : [
|
|
26
28
|
"openid",
|
|
@@ -87,15 +89,11 @@ const line = (options) => {
|
|
|
87
89
|
}
|
|
88
90
|
if (!profile) return null;
|
|
89
91
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
90
|
-
const id = profile.sub || profile.userId;
|
|
91
|
-
const name = profile.name || profile.displayName || "";
|
|
92
|
-
const image = profile.picture || profile.pictureUrl || void 0;
|
|
93
92
|
return {
|
|
94
93
|
user: {
|
|
95
|
-
|
|
96
|
-
name,
|
|
94
|
+
name: profile.name || "",
|
|
97
95
|
email: profile.email,
|
|
98
|
-
image,
|
|
96
|
+
image: profile.picture,
|
|
99
97
|
emailVerified: false,
|
|
100
98
|
...userMap
|
|
101
99
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/linear.d.ts
|
|
3
4
|
interface LinearUser {
|
|
4
5
|
id: string;
|
|
@@ -20,13 +21,8 @@ interface LinearOptions extends ProviderOptions<LinearUser> {
|
|
|
20
21
|
declare const linear: (options: LinearOptions) => {
|
|
21
22
|
id: "linear";
|
|
22
23
|
name: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
scopes,
|
|
26
|
-
loginHint,
|
|
27
|
-
redirectURI,
|
|
28
|
-
additionalParams
|
|
29
|
-
}: {
|
|
24
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<LinearUser>) => string;
|
|
25
|
+
createAuthorizationURL({ state, scopes, loginHint, redirectURI, additionalParams }: {
|
|
30
26
|
state: string;
|
|
31
27
|
codeVerifier: string;
|
|
32
28
|
scopes?: string[] | undefined;
|
|
@@ -36,10 +32,7 @@ declare const linear: (options: LinearOptions) => {
|
|
|
36
32
|
idTokenNonce?: string | undefined;
|
|
37
33
|
additionalParams?: Record<string, string> | undefined;
|
|
38
34
|
}): Promise<URL>;
|
|
39
|
-
validateAuthorizationCode: ({
|
|
40
|
-
code,
|
|
41
|
-
redirectURI
|
|
42
|
-
}: {
|
|
35
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
43
36
|
code: string;
|
|
44
37
|
redirectURI: string;
|
|
45
38
|
codeVerifier?: string | undefined;
|
|
@@ -56,15 +49,8 @@ declare const linear: (options: LinearOptions) => {
|
|
|
56
49
|
email?: string;
|
|
57
50
|
} | undefined;
|
|
58
51
|
}): Promise<{
|
|
59
|
-
user:
|
|
60
|
-
|
|
61
|
-
name?: string;
|
|
62
|
-
email?: string | null;
|
|
63
|
-
image?: string;
|
|
64
|
-
emailVerified: boolean;
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
};
|
|
67
|
-
data: any;
|
|
52
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
53
|
+
data: LinearUser;
|
|
68
54
|
} | null>;
|
|
69
55
|
options: LinearOptions;
|
|
70
56
|
};
|
|
@@ -8,6 +8,7 @@ const linear = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "linear",
|
|
10
10
|
name: "Linear",
|
|
11
|
+
accountSubject: ({ profile }) => profile.id,
|
|
11
12
|
createAuthorizationURL({ state, scopes, loginHint, redirectURI, additionalParams }) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : ["read"];
|
|
13
14
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -69,7 +70,6 @@ const linear = (options) => {
|
|
|
69
70
|
const userMap = await options.mapProfileToUser?.(userData);
|
|
70
71
|
return {
|
|
71
72
|
user: {
|
|
72
|
-
id: profile.data.viewer.id,
|
|
73
73
|
name: profile.data.viewer.name,
|
|
74
74
|
email: profile.data.viewer.email,
|
|
75
75
|
image: profile.data.viewer.avatarUrl,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/linkedin.d.ts
|
|
3
4
|
interface LinkedInProfile {
|
|
4
5
|
sub: string;
|
|
@@ -19,13 +20,8 @@ interface LinkedInOptions extends ProviderOptions<LinkedInProfile> {
|
|
|
19
20
|
declare const linkedin: (options: LinkedInOptions) => {
|
|
20
21
|
id: "linkedin";
|
|
21
22
|
name: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
scopes,
|
|
25
|
-
redirectURI,
|
|
26
|
-
loginHint,
|
|
27
|
-
additionalParams
|
|
28
|
-
}: {
|
|
23
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<LinkedInProfile>) => string;
|
|
24
|
+
createAuthorizationURL: ({ state, scopes, redirectURI, loginHint, additionalParams }: {
|
|
29
25
|
state: string;
|
|
30
26
|
codeVerifier: string;
|
|
31
27
|
scopes?: string[] | undefined;
|
|
@@ -35,10 +31,7 @@ declare const linkedin: (options: LinkedInOptions) => {
|
|
|
35
31
|
idTokenNonce?: string | undefined;
|
|
36
32
|
additionalParams?: Record<string, string> | undefined;
|
|
37
33
|
}) => Promise<URL>;
|
|
38
|
-
validateAuthorizationCode: ({
|
|
39
|
-
code,
|
|
40
|
-
redirectURI
|
|
41
|
-
}: {
|
|
34
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
42
35
|
code: string;
|
|
43
36
|
redirectURI: string;
|
|
44
37
|
codeVerifier?: string | undefined;
|
|
@@ -55,15 +48,8 @@ declare const linkedin: (options: LinkedInOptions) => {
|
|
|
55
48
|
email?: string;
|
|
56
49
|
} | undefined;
|
|
57
50
|
}): Promise<{
|
|
58
|
-
user:
|
|
59
|
-
|
|
60
|
-
name?: string;
|
|
61
|
-
email?: string | null;
|
|
62
|
-
image?: string;
|
|
63
|
-
emailVerified: boolean;
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
};
|
|
66
|
-
data: any;
|
|
51
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
52
|
+
data: LinkedInProfile;
|
|
67
53
|
} | null>;
|
|
68
54
|
options: LinkedInOptions;
|
|
69
55
|
};
|
|
@@ -9,6 +9,7 @@ const linkedin = (options) => {
|
|
|
9
9
|
return {
|
|
10
10
|
id: "linkedin",
|
|
11
11
|
name: "Linkedin",
|
|
12
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
12
13
|
createAuthorizationURL: async ({ state, scopes, redirectURI, loginHint, additionalParams }) => {
|
|
13
14
|
const _scopes = options.disableDefaultScope ? [] : [
|
|
14
15
|
"profile",
|
|
@@ -57,7 +58,6 @@ const linkedin = (options) => {
|
|
|
57
58
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
58
59
|
return {
|
|
59
60
|
user: {
|
|
60
|
-
id: profile.sub,
|
|
61
61
|
name: profile.name,
|
|
62
62
|
email: profile.email,
|
|
63
63
|
emailVerified: profile.email_verified ?? false,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ClientAssertionGetter } from "../oauth2/client-assertion.mjs";
|
|
2
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
3
|
+
import "../oauth2/index.mjs";
|
|
5
4
|
//#region src/social-providers/microsoft-entra-id.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* @see [Microsoft Identity Platform - Optional claims reference](https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims-reference)
|
|
@@ -139,6 +138,8 @@ interface MicrosoftOptions extends ProviderOptions<MicrosoftEntraIDProfile> {
|
|
|
139
138
|
declare const microsoft: (options: MicrosoftOptions) => {
|
|
140
139
|
id: "microsoft";
|
|
141
140
|
name: string;
|
|
141
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<MicrosoftEntraIDProfile>) => string;
|
|
142
|
+
accountIssuer: ({ profile }: OAuthAccountKeyContext<MicrosoftEntraIDProfile>) => string;
|
|
142
143
|
createAuthorizationURL(data: {
|
|
143
144
|
state: string;
|
|
144
145
|
codeVerifier: string;
|
|
@@ -149,18 +150,14 @@ declare const microsoft: (options: MicrosoftOptions) => {
|
|
|
149
150
|
idTokenNonce?: string | undefined;
|
|
150
151
|
additionalParams?: Record<string, string> | undefined;
|
|
151
152
|
}): Promise<URL>;
|
|
152
|
-
validateAuthorizationCode({
|
|
153
|
-
code,
|
|
154
|
-
codeVerifier,
|
|
155
|
-
redirectURI
|
|
156
|
-
}: {
|
|
153
|
+
validateAuthorizationCode({ code, codeVerifier, redirectURI }: {
|
|
157
154
|
code: string;
|
|
158
155
|
redirectURI: string;
|
|
159
156
|
codeVerifier?: string | undefined;
|
|
160
157
|
deviceId?: string | undefined;
|
|
161
158
|
}): Promise<OAuth2Tokens>;
|
|
162
159
|
idToken: {
|
|
163
|
-
jwks: (header: jose.JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
|
|
160
|
+
jwks: (header: import("jose").JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
|
|
164
161
|
audience: string | string[];
|
|
165
162
|
maxTokenAge: string;
|
|
166
163
|
/**
|
|
@@ -190,15 +187,8 @@ declare const microsoft: (options: MicrosoftOptions) => {
|
|
|
190
187
|
email?: string;
|
|
191
188
|
} | undefined;
|
|
192
189
|
}): Promise<{
|
|
193
|
-
user:
|
|
194
|
-
|
|
195
|
-
name?: string;
|
|
196
|
-
email?: string | null;
|
|
197
|
-
image?: string;
|
|
198
|
-
emailVerified: boolean;
|
|
199
|
-
[key: string]: any;
|
|
200
|
-
};
|
|
201
|
-
data: any;
|
|
190
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
191
|
+
data: MicrosoftEntraIDProfile;
|
|
202
192
|
} | null>;
|
|
203
193
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
204
194
|
options: MicrosoftOptions;
|
|
@@ -29,6 +29,8 @@ const microsoft = (options) => {
|
|
|
29
29
|
return {
|
|
30
30
|
id: "microsoft",
|
|
31
31
|
name: "Microsoft EntraID",
|
|
32
|
+
accountSubject: ({ profile }) => profile.oid,
|
|
33
|
+
accountIssuer: ({ profile }) => profile.iss,
|
|
32
34
|
createAuthorizationURL(data) {
|
|
33
35
|
if (!getPrimaryClientId(options.clientId)) {
|
|
34
36
|
logger.error("Client Id is required for Microsoft Entra ID. Make sure to provide it in the options.");
|
|
@@ -70,7 +72,21 @@ const microsoft = (options) => {
|
|
|
70
72
|
jwks: (header) => getMicrosoftPublicKey(header.kid, tenant, authority),
|
|
71
73
|
audience: options.clientId,
|
|
72
74
|
maxTokenAge: "1h",
|
|
75
|
+
/**
|
|
76
|
+
* Issuer varies per tenant for multi-tenant endpoints, so only validate it for
|
|
77
|
+
* specific tenants.
|
|
78
|
+
* @see https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols#endpoints
|
|
79
|
+
*/
|
|
73
80
|
issuer: tenant !== "common" && tenant !== "organizations" && tenant !== "consumers" ? `${authority}/${tenant}/v2.0` : void 0,
|
|
81
|
+
/**
|
|
82
|
+
* The multi-tenant endpoints (common/organizations/consumers) skip the
|
|
83
|
+
* issuer check above because the issuer varies per tenant, and the
|
|
84
|
+
* organizations and consumers JWKS sets overlap. Enforce the tenant
|
|
85
|
+
* binding explicitly so a token from a disallowed account class cannot
|
|
86
|
+
* pass: the issuer must name the token's own tenant, and the account
|
|
87
|
+
* class must match the configured restriction.
|
|
88
|
+
* @see https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference
|
|
89
|
+
*/
|
|
74
90
|
verifyClaims: (claims) => {
|
|
75
91
|
const tid = claims.tid;
|
|
76
92
|
if (typeof tid !== "string" || claims.iss !== `${authority}/${tid}/v2.0`) return false;
|
|
@@ -83,14 +99,19 @@ const microsoft = (options) => {
|
|
|
83
99
|
if (options.getUserInfo) return options.getUserInfo(token);
|
|
84
100
|
if (!token.idToken) return null;
|
|
85
101
|
const user = decodeJwt(token.idToken);
|
|
102
|
+
if (typeof user.oid !== "string" || user.oid.trim().length === 0) {
|
|
103
|
+
logger.error("Microsoft Entra ID token did not include a valid oid claim; unable to resolve a stable account identifier.");
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
86
106
|
const profilePhotoSize = options.profilePhotoSize || 48;
|
|
87
|
-
await betterFetch(`https://graph.microsoft.com/v1.0/me/photos/${profilePhotoSize}x${profilePhotoSize}/$value`, {
|
|
107
|
+
if (!options.disableProfilePhoto && token.accessToken) await betterFetch(`https://graph.microsoft.com/v1.0/me/photos/${profilePhotoSize}x${profilePhotoSize}/$value`, {
|
|
88
108
|
headers: { Authorization: `Bearer ${token.accessToken}` },
|
|
89
109
|
async onResponse(context) {
|
|
90
|
-
if (
|
|
110
|
+
if (!context.response.ok) return;
|
|
91
111
|
try {
|
|
92
112
|
const pictureBuffer = await context.response.clone().arrayBuffer();
|
|
93
|
-
|
|
113
|
+
const pictureBase64 = base64.encode(pictureBuffer);
|
|
114
|
+
user.picture = `data:image/jpeg;base64, ${pictureBase64}`;
|
|
94
115
|
} catch (e) {
|
|
95
116
|
logger.error(e && typeof e === "object" && "name" in e ? e.name : "", e);
|
|
96
117
|
}
|
|
@@ -100,7 +121,6 @@ const microsoft = (options) => {
|
|
|
100
121
|
const emailVerified = user.email_verified !== void 0 ? user.email_verified : user.email && (user.verified_primary_email?.includes(user.email) || user.verified_secondary_email?.includes(user.email)) ? true : false;
|
|
101
122
|
return {
|
|
102
123
|
user: {
|
|
103
|
-
id: user.sub,
|
|
104
124
|
name: user.name,
|
|
105
125
|
email: user.email,
|
|
106
126
|
image: user.picture,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
1
|
+
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
import "../oauth2/index.mjs";
|
|
2
3
|
//#region src/social-providers/naver.d.ts
|
|
3
4
|
interface NaverProfile {
|
|
4
5
|
/** API response result code */
|
|
@@ -6,15 +7,25 @@ interface NaverProfile {
|
|
|
6
7
|
/** API response message */
|
|
7
8
|
message: string;
|
|
8
9
|
response: {
|
|
9
|
-
/** Unique Naver user identifier */
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
/** Unique Naver user identifier */
|
|
11
|
+
id: string;
|
|
12
|
+
/** User nickname */
|
|
13
|
+
nickname: string;
|
|
14
|
+
/** User real name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** User email address */
|
|
17
|
+
email: string;
|
|
18
|
+
/** Gender (F: female, M: male, U: unknown) */
|
|
19
|
+
gender: string;
|
|
20
|
+
/** Age range */
|
|
21
|
+
age: string;
|
|
22
|
+
/** Birthday (MM-DD format) */
|
|
23
|
+
birthday: string;
|
|
24
|
+
/** Birth year */
|
|
25
|
+
birthyear: string;
|
|
26
|
+
/** Profile image URL */
|
|
27
|
+
profile_image: string;
|
|
28
|
+
/** Mobile phone number */
|
|
18
29
|
mobile: string;
|
|
19
30
|
};
|
|
20
31
|
}
|
|
@@ -24,12 +35,8 @@ interface NaverOptions extends ProviderOptions<NaverProfile> {
|
|
|
24
35
|
declare const naver: (options: NaverOptions) => {
|
|
25
36
|
id: "naver";
|
|
26
37
|
name: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
scopes,
|
|
30
|
-
redirectURI,
|
|
31
|
-
additionalParams
|
|
32
|
-
}: {
|
|
38
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<NaverProfile>) => string;
|
|
39
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }: {
|
|
33
40
|
state: string;
|
|
34
41
|
codeVerifier: string;
|
|
35
42
|
scopes?: string[] | undefined;
|
|
@@ -39,10 +46,7 @@ declare const naver: (options: NaverOptions) => {
|
|
|
39
46
|
idTokenNonce?: string | undefined;
|
|
40
47
|
additionalParams?: Record<string, string> | undefined;
|
|
41
48
|
}): Promise<URL>;
|
|
42
|
-
validateAuthorizationCode: ({
|
|
43
|
-
code,
|
|
44
|
-
redirectURI
|
|
45
|
-
}: {
|
|
49
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
46
50
|
code: string;
|
|
47
51
|
redirectURI: string;
|
|
48
52
|
codeVerifier?: string | undefined;
|
|
@@ -59,30 +63,11 @@ declare const naver: (options: NaverOptions) => {
|
|
|
59
63
|
email?: string;
|
|
60
64
|
} | undefined;
|
|
61
65
|
}): Promise<{
|
|
62
|
-
user:
|
|
63
|
-
|
|
64
|
-
name?: string;
|
|
65
|
-
email?: string | null;
|
|
66
|
-
image?: string;
|
|
67
|
-
emailVerified: boolean;
|
|
68
|
-
[key: string]: any;
|
|
69
|
-
};
|
|
70
|
-
data: any;
|
|
66
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
67
|
+
data: NaverProfile;
|
|
71
68
|
} | {
|
|
72
69
|
user: {
|
|
73
|
-
id
|
|
74
|
-
name: string;
|
|
75
|
-
email: string;
|
|
76
|
-
image: string;
|
|
77
|
-
emailVerified: boolean;
|
|
78
|
-
} | {
|
|
79
|
-
id: string;
|
|
80
|
-
name: string;
|
|
81
|
-
email: string | null;
|
|
82
|
-
image: string;
|
|
83
|
-
emailVerified: boolean;
|
|
84
|
-
} | {
|
|
85
|
-
id: string;
|
|
70
|
+
id?: never;
|
|
86
71
|
name: string;
|
|
87
72
|
email: string | null;
|
|
88
73
|
image: string;
|
|
@@ -8,6 +8,7 @@ const naver = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "naver",
|
|
10
10
|
name: "Naver",
|
|
11
|
+
accountSubject: ({ profile }) => profile.response.id,
|
|
11
12
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : ["profile", "email"];
|
|
13
14
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -49,7 +50,6 @@ const naver = (options) => {
|
|
|
49
50
|
const res = profile.response || {};
|
|
50
51
|
return {
|
|
51
52
|
user: {
|
|
52
|
-
id: res.id,
|
|
53
53
|
name: res.name || res.nickname || "",
|
|
54
54
|
email: res.email,
|
|
55
55
|
image: res.profile_image,
|