@better-auth/core 1.7.0-rc.1 → 1.7.0-rc.2
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 +2 -2
- package/dist/oauth2/oauth-provider.d.mts +85 -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 +5 -7
- package/dist/oauth2/verify.mjs +2 -2
- 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 +18 -2
- 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 +0 -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 +24 -18
- 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/oauth2/index.ts +3 -0
- package/src/oauth2/oauth-provider.ts +94 -36
- package/src/oauth2/verify-id-token.ts +4 -2
- 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 +3 -2
- 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
|
@@ -36,6 +36,8 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
36
36
|
return {
|
|
37
37
|
id: "paybin",
|
|
38
38
|
name: "Paybin",
|
|
39
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
40
|
+
accountIssuer: issuer,
|
|
39
41
|
async createAuthorizationURL({
|
|
40
42
|
state,
|
|
41
43
|
scopes,
|
|
@@ -105,7 +107,6 @@ export const paybin = (options: PaybinOptions) => {
|
|
|
105
107
|
const userMap = await options.mapProfileToUser?.(user);
|
|
106
108
|
return {
|
|
107
109
|
user: {
|
|
108
|
-
id: user.sub,
|
|
109
110
|
name: user.name || user.preferred_username || "",
|
|
110
111
|
email: user.email,
|
|
111
112
|
image: user.picture,
|
|
@@ -79,6 +79,7 @@ export const paypal = (options: PayPalOptions) => {
|
|
|
79
79
|
return {
|
|
80
80
|
id: "paypal",
|
|
81
81
|
name: "PayPal",
|
|
82
|
+
accountSubject: ({ profile }) => profile.user_id,
|
|
82
83
|
async createAuthorizationURL({
|
|
83
84
|
state,
|
|
84
85
|
codeVerifier,
|
|
@@ -252,7 +253,6 @@ export const paypal = (options: PayPalOptions) => {
|
|
|
252
253
|
|
|
253
254
|
const result = {
|
|
254
255
|
user: {
|
|
255
|
-
id: userInfo.user_id,
|
|
256
256
|
name: userInfo.name,
|
|
257
257
|
email: userInfo.email,
|
|
258
258
|
image: userInfo.picture,
|
|
@@ -37,6 +37,7 @@ export const polar = (options: PolarOptions) => {
|
|
|
37
37
|
return {
|
|
38
38
|
id: "polar",
|
|
39
39
|
name: "Polar",
|
|
40
|
+
accountSubject: ({ profile }) => profile.id,
|
|
40
41
|
createAuthorizationURL({
|
|
41
42
|
state,
|
|
42
43
|
scopes,
|
|
@@ -103,7 +104,6 @@ export const polar = (options: PolarOptions) => {
|
|
|
103
104
|
// We check for it first, then default to false for security consistency.
|
|
104
105
|
return {
|
|
105
106
|
user: {
|
|
106
|
-
id: profile.id,
|
|
107
107
|
name: profile.public_name || profile.username || "",
|
|
108
108
|
email: profile.email,
|
|
109
109
|
image: profile.avatar_url,
|
|
@@ -29,6 +29,7 @@ export const railway = (options: RailwayOptions) => {
|
|
|
29
29
|
return {
|
|
30
30
|
id: "railway",
|
|
31
31
|
name: "Railway",
|
|
32
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
32
33
|
createAuthorizationURL({
|
|
33
34
|
state,
|
|
34
35
|
scopes,
|
|
@@ -92,7 +93,6 @@ export const railway = (options: RailwayOptions) => {
|
|
|
92
93
|
// We default to false for security consistency.
|
|
93
94
|
return {
|
|
94
95
|
user: {
|
|
95
|
-
id: profile.sub,
|
|
96
96
|
name: profile.name,
|
|
97
97
|
email: profile.email,
|
|
98
98
|
image: profile.picture,
|
|
@@ -25,6 +25,7 @@ export const reddit = (options: RedditOptions) => {
|
|
|
25
25
|
return {
|
|
26
26
|
id: "reddit",
|
|
27
27
|
name: "Reddit",
|
|
28
|
+
accountSubject: ({ profile }) => profile.id,
|
|
28
29
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
29
30
|
const _scopes = options.disableDefaultScope ? [] : ["identity"];
|
|
30
31
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -112,7 +113,6 @@ export const reddit = (options: RedditOptions) => {
|
|
|
112
113
|
const email = userMap?.email || `${profile.id}@reddit.invalid`;
|
|
113
114
|
return {
|
|
114
115
|
user: {
|
|
115
|
-
id: profile.id,
|
|
116
116
|
name: profile.name,
|
|
117
117
|
image: profile.icon_img?.split("?")[0]!,
|
|
118
118
|
...userMap,
|
|
@@ -41,6 +41,7 @@ export const roblox = (options: RobloxOptions) => {
|
|
|
41
41
|
return {
|
|
42
42
|
id: "roblox",
|
|
43
43
|
name: "Roblox",
|
|
44
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
44
45
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
45
46
|
const _scopes = options.disableDefaultScope ? [] : ["openid", "profile"];
|
|
46
47
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -100,7 +101,6 @@ export const roblox = (options: RobloxOptions) => {
|
|
|
100
101
|
// We default to false for security consistency.
|
|
101
102
|
return {
|
|
102
103
|
user: {
|
|
103
|
-
id: profile.sub,
|
|
104
104
|
name: profile.nickname || profile.preferred_username || "",
|
|
105
105
|
image: profile.picture,
|
|
106
106
|
email: profile.preferred_username || null, // Roblox does not provide email
|
|
@@ -63,6 +63,7 @@ export const salesforce = (options: SalesforceOptions) => {
|
|
|
63
63
|
return {
|
|
64
64
|
id: "salesforce",
|
|
65
65
|
name: "Salesforce",
|
|
66
|
+
accountSubject: ({ profile }) => profile.user_id,
|
|
66
67
|
|
|
67
68
|
async createAuthorizationURL({
|
|
68
69
|
state,
|
|
@@ -146,7 +147,6 @@ export const salesforce = (options: SalesforceOptions) => {
|
|
|
146
147
|
|
|
147
148
|
return {
|
|
148
149
|
user: {
|
|
149
|
-
id: user.user_id,
|
|
150
150
|
name: user.name,
|
|
151
151
|
email: user.email,
|
|
152
152
|
image: user.photos?.picture || user.photos?.thumbnail,
|
|
@@ -46,6 +46,7 @@ export const slack = (options: SlackOptions) => {
|
|
|
46
46
|
return {
|
|
47
47
|
id: "slack",
|
|
48
48
|
name: "Slack",
|
|
49
|
+
accountSubject: ({ profile }) => profile["https://slack.com/user_id"],
|
|
49
50
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
50
51
|
const _scopes = options.disableDefaultScope
|
|
51
52
|
? []
|
|
@@ -103,7 +104,6 @@ export const slack = (options: SlackOptions) => {
|
|
|
103
104
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
104
105
|
return {
|
|
105
106
|
user: {
|
|
106
|
-
id: profile["https://slack.com/user_id"],
|
|
107
107
|
name: profile.name || "",
|
|
108
108
|
email: profile.email,
|
|
109
109
|
emailVerified: profile.email_verified,
|
|
@@ -24,6 +24,7 @@ export const spotify = (options: SpotifyOptions) => {
|
|
|
24
24
|
return {
|
|
25
25
|
id: "spotify",
|
|
26
26
|
name: "Spotify",
|
|
27
|
+
accountSubject: ({ profile }) => profile.id,
|
|
27
28
|
createAuthorizationURL({
|
|
28
29
|
state,
|
|
29
30
|
scopes,
|
|
@@ -86,7 +87,6 @@ export const spotify = (options: SpotifyOptions) => {
|
|
|
86
87
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
87
88
|
return {
|
|
88
89
|
user: {
|
|
89
|
-
id: profile.id,
|
|
90
90
|
name: profile.display_name,
|
|
91
91
|
email: profile.email,
|
|
92
92
|
image: profile.images[0]?.url,
|
|
@@ -123,7 +123,7 @@ export interface TiktokProfile extends Record<string, any> {
|
|
|
123
123
|
| undefined;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export interface TiktokOptions extends ProviderOptions {
|
|
126
|
+
export interface TiktokOptions extends ProviderOptions<TiktokProfile> {
|
|
127
127
|
// Client ID is not used in TikTok, we delete it from the options
|
|
128
128
|
clientId?: never | undefined;
|
|
129
129
|
clientSecret: string;
|
|
@@ -135,6 +135,7 @@ export const tiktok = (options: TiktokOptions) => {
|
|
|
135
135
|
return {
|
|
136
136
|
id: "tiktok",
|
|
137
137
|
name: "TikTok",
|
|
138
|
+
accountSubject: ({ profile }) => profile.data.user.open_id,
|
|
138
139
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
139
140
|
const _scopes = options.disableDefaultScope ? [] : ["user.info.profile"];
|
|
140
141
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -210,7 +211,6 @@ export const tiktok = (options: TiktokOptions) => {
|
|
|
210
211
|
return {
|
|
211
212
|
user: {
|
|
212
213
|
email: profile.data.user.email || profile.data.user.username,
|
|
213
|
-
id: profile.data.user.open_id,
|
|
214
214
|
name:
|
|
215
215
|
profile.data.user.display_name || profile.data.user.username || "",
|
|
216
216
|
image: profile.data.user.avatar_large_url,
|
|
@@ -42,6 +42,7 @@ export const twitch = (options: TwitchOptions) => {
|
|
|
42
42
|
return {
|
|
43
43
|
id: "twitch",
|
|
44
44
|
name: "Twitch",
|
|
45
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
45
46
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
46
47
|
const _scopes = options.disableDefaultScope
|
|
47
48
|
? []
|
|
@@ -98,7 +99,6 @@ export const twitch = (options: TwitchOptions) => {
|
|
|
98
99
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
99
100
|
return {
|
|
100
101
|
user: {
|
|
101
|
-
id: profile.sub,
|
|
102
102
|
name: profile.preferred_username,
|
|
103
103
|
email: profile.email,
|
|
104
104
|
image: profile.picture,
|
|
@@ -108,6 +108,7 @@ export const twitter = (options: TwitterOption) => {
|
|
|
108
108
|
return {
|
|
109
109
|
id: "twitter",
|
|
110
110
|
name: "Twitter",
|
|
111
|
+
accountSubject: ({ profile }) => profile.data.id,
|
|
111
112
|
createAuthorizationURL(data) {
|
|
112
113
|
const _scopes = options.disableDefaultScope
|
|
113
114
|
? []
|
|
@@ -185,7 +186,6 @@ export const twitter = (options: TwitterOption) => {
|
|
|
185
186
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
186
187
|
return {
|
|
187
188
|
user: {
|
|
188
|
-
id: profile.data.id,
|
|
189
189
|
name: profile.data.name,
|
|
190
190
|
email: profile.data.email || profile.data.username || null,
|
|
191
191
|
image: profile.data.profile_image_url,
|
|
@@ -20,6 +20,7 @@ export const vercel = (options: VercelOptions) => {
|
|
|
20
20
|
return {
|
|
21
21
|
id: "vercel",
|
|
22
22
|
name: "Vercel",
|
|
23
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
23
24
|
createAuthorizationURL({
|
|
24
25
|
state,
|
|
25
26
|
scopes,
|
|
@@ -79,7 +80,6 @@ export const vercel = (options: VercelOptions) => {
|
|
|
79
80
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
80
81
|
return {
|
|
81
82
|
user: {
|
|
82
|
-
id: profile.sub,
|
|
83
83
|
name: profile.name ?? profile.preferred_username ?? "",
|
|
84
84
|
email: profile.email,
|
|
85
85
|
image: profile.picture,
|
|
@@ -20,7 +20,7 @@ export interface VkProfile {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export interface VkOption extends ProviderOptions {
|
|
23
|
+
export interface VkOption extends ProviderOptions<VkProfile> {
|
|
24
24
|
clientId: string;
|
|
25
25
|
scheme?: ("light" | "dark") | undefined;
|
|
26
26
|
}
|
|
@@ -30,6 +30,7 @@ export const vk = (options: VkOption) => {
|
|
|
30
30
|
return {
|
|
31
31
|
id: "vk",
|
|
32
32
|
name: "VK",
|
|
33
|
+
accountSubject: ({ profile }) => profile.user.user_id,
|
|
33
34
|
async createAuthorizationURL({
|
|
34
35
|
state,
|
|
35
36
|
scopes,
|
|
@@ -113,7 +114,6 @@ export const vk = (options: VkOption) => {
|
|
|
113
114
|
|
|
114
115
|
return {
|
|
115
116
|
user: {
|
|
116
|
-
id: profile.user.user_id,
|
|
117
117
|
first_name: profile.user.first_name,
|
|
118
118
|
last_name: profile.user.last_name,
|
|
119
119
|
email: profile.user.email,
|
|
@@ -59,6 +59,7 @@ export const wechat = (options: WeChatOptions) => {
|
|
|
59
59
|
return {
|
|
60
60
|
id: "wechat",
|
|
61
61
|
name: "WeChat",
|
|
62
|
+
accountSubject: ({ profile }) => profile.unionid || profile.openid,
|
|
62
63
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
63
64
|
const _scopes = options.disableDefaultScope ? [] : ["snsapi_login"];
|
|
64
65
|
options.scope && _scopes.push(...options.scope);
|
|
@@ -206,7 +207,6 @@ export const wechat = (options: WeChatOptions) => {
|
|
|
206
207
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
207
208
|
return {
|
|
208
209
|
user: {
|
|
209
|
-
id: profile.unionid || profile.openid || openid,
|
|
210
210
|
name: profile.nickname,
|
|
211
211
|
// WeChat does not return an email, and the OAuth callback rejects a
|
|
212
212
|
// missing one, so the default sign-in would always fail. Synthesize a
|
|
@@ -152,6 +152,7 @@ export const zoom = (userOptions: ZoomOptions) => {
|
|
|
152
152
|
return {
|
|
153
153
|
id: "zoom",
|
|
154
154
|
name: "Zoom",
|
|
155
|
+
accountSubject: ({ profile }) => profile.id,
|
|
155
156
|
createAuthorizationURL: async ({
|
|
156
157
|
state,
|
|
157
158
|
redirectURI,
|
|
@@ -210,7 +211,6 @@ export const zoom = (userOptions: ZoomOptions) => {
|
|
|
210
211
|
|
|
211
212
|
return {
|
|
212
213
|
user: {
|
|
213
|
-
id: profile.id,
|
|
214
214
|
name: profile.display_name,
|
|
215
215
|
image: profile.pic_url,
|
|
216
216
|
email: profile.email,
|
package/src/types/context.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
Verification,
|
|
10
10
|
} from "../db";
|
|
11
11
|
import type { DBAdapter, Where } from "../db/adapter";
|
|
12
|
+
import type { AccountKey } from "../db/schema/account";
|
|
12
13
|
import type { createLogger } from "../env";
|
|
13
14
|
import type { OAuthProvider } from "../oauth2";
|
|
14
15
|
import type { BetterAuthCookie, BetterAuthCookies } from "./cookie";
|
|
@@ -132,6 +133,9 @@ export interface InternalAdapter<
|
|
|
132
133
|
dontRememberMe?: boolean | undefined,
|
|
133
134
|
override?: (Partial<Session> & Record<string, any>) | undefined,
|
|
134
135
|
overrideAll?: boolean | undefined,
|
|
136
|
+
storageOptions?:
|
|
137
|
+
| { deferSecondaryStorageWrites?: boolean | undefined }
|
|
138
|
+
| undefined,
|
|
135
139
|
): Promise<Session>;
|
|
136
140
|
|
|
137
141
|
findSession(token: string): Promise<{
|
|
@@ -160,7 +164,7 @@ export interface InternalAdapter<
|
|
|
160
164
|
/**
|
|
161
165
|
* Delete an account by its primary key.
|
|
162
166
|
*
|
|
163
|
-
* @param id - The account row's primary key
|
|
167
|
+
* @param id - The account row's primary key, not its provider account ID.
|
|
164
168
|
*/
|
|
165
169
|
deleteAccount(id: string): Promise<void>;
|
|
166
170
|
|
|
@@ -174,15 +178,18 @@ export interface InternalAdapter<
|
|
|
174
178
|
*/
|
|
175
179
|
deleteSessions(sessionTokens: string[]): Promise<void>;
|
|
176
180
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
findAccountOwnerByKey(accountKey: AccountKey): Promise<
|
|
182
|
+
| {
|
|
183
|
+
kind: "owned";
|
|
184
|
+
user: User;
|
|
185
|
+
account: Account;
|
|
186
|
+
}
|
|
187
|
+
| {
|
|
188
|
+
kind: "orphaned";
|
|
189
|
+
account: Account;
|
|
190
|
+
}
|
|
191
|
+
| null
|
|
192
|
+
>;
|
|
186
193
|
|
|
187
194
|
findUserByEmail(
|
|
188
195
|
email: string,
|
|
@@ -210,10 +217,10 @@ export interface InternalAdapter<
|
|
|
210
217
|
|
|
211
218
|
findAccounts(userId: string): Promise<Account[]>;
|
|
212
219
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
): Promise<Account | null>;
|
|
220
|
+
/** Find the credential account whose stable local subject is the user ID. */
|
|
221
|
+
findCredentialAccount(userId: string): Promise<Account | null>;
|
|
222
|
+
|
|
223
|
+
findAccountByKey(accountKey: AccountKey): Promise<Account | null>;
|
|
217
224
|
|
|
218
225
|
findAccountByUserId(userId: string): Promise<Account[]>;
|
|
219
226
|
|
|
@@ -454,6 +454,21 @@ export type BetterAuthAdvancedOptions = {
|
|
|
454
454
|
* function.
|
|
455
455
|
*/
|
|
456
456
|
generateId?: GenerateIdFn | false | "serial" | "uuid";
|
|
457
|
+
/**
|
|
458
|
+
* Enable database joins for adapters that support them.
|
|
459
|
+
*
|
|
460
|
+
* When disabled (default), related data is fetched via
|
|
461
|
+
* separate queries. When enabled, adapters that support
|
|
462
|
+
* native joins use them; otherwise Better Auth falls back
|
|
463
|
+
* to separate queries.
|
|
464
|
+
*
|
|
465
|
+
* Please read the adapter documentation for more
|
|
466
|
+
* information regarding joins before enabling this.
|
|
467
|
+
* Not all adapters support joins.
|
|
468
|
+
*
|
|
469
|
+
* @default false
|
|
470
|
+
*/
|
|
471
|
+
joins?: boolean;
|
|
457
472
|
}
|
|
458
473
|
| undefined;
|
|
459
474
|
/**
|
|
@@ -1783,18 +1798,4 @@ export type BetterAuthOptions = {
|
|
|
1783
1798
|
debug?: boolean;
|
|
1784
1799
|
}
|
|
1785
1800
|
| undefined;
|
|
1786
|
-
/**
|
|
1787
|
-
* Experimental features
|
|
1788
|
-
*/
|
|
1789
|
-
experimental?: {
|
|
1790
|
-
/**
|
|
1791
|
-
* Enable experimental joins for your database adapter.
|
|
1792
|
-
*
|
|
1793
|
-
* Please read the adapter documentation for more information regarding joins before enabling this.
|
|
1794
|
-
* Not all adapters support joins.
|
|
1795
|
-
*
|
|
1796
|
-
* @default false
|
|
1797
|
-
*/
|
|
1798
|
-
joins?: boolean;
|
|
1799
|
-
};
|
|
1800
1801
|
};
|