@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
|
@@ -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/tiktok.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* [More info](https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/)
|
|
@@ -51,7 +52,8 @@ interface TiktokProfile extends Record<string, any> {
|
|
|
51
52
|
*
|
|
52
53
|
* To return this field, add `fields=username` in the user profile request's query parameter.
|
|
53
54
|
*/
|
|
54
|
-
username: string;
|
|
55
|
+
username: string;
|
|
56
|
+
/** @note Email is currently unsupported by TikTok */
|
|
55
57
|
email?: string | undefined;
|
|
56
58
|
/**
|
|
57
59
|
* User's bio description if there is a valid one.
|
|
@@ -113,7 +115,7 @@ interface TiktokProfile extends Record<string, any> {
|
|
|
113
115
|
log_id?: string;
|
|
114
116
|
} | undefined;
|
|
115
117
|
}
|
|
116
|
-
interface TiktokOptions extends ProviderOptions {
|
|
118
|
+
interface TiktokOptions extends ProviderOptions<TiktokProfile> {
|
|
117
119
|
clientId?: never | undefined;
|
|
118
120
|
clientSecret: string;
|
|
119
121
|
clientKey: string;
|
|
@@ -121,12 +123,8 @@ interface TiktokOptions extends ProviderOptions {
|
|
|
121
123
|
declare const tiktok: (options: TiktokOptions) => {
|
|
122
124
|
id: "tiktok";
|
|
123
125
|
name: string;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
scopes,
|
|
127
|
-
redirectURI,
|
|
128
|
-
additionalParams
|
|
129
|
-
}: {
|
|
126
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<TiktokProfile>) => string;
|
|
127
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }: {
|
|
130
128
|
state: string;
|
|
131
129
|
codeVerifier: string;
|
|
132
130
|
scopes?: string[] | undefined;
|
|
@@ -136,10 +134,7 @@ declare const tiktok: (options: TiktokOptions) => {
|
|
|
136
134
|
idTokenNonce?: string | undefined;
|
|
137
135
|
additionalParams?: Record<string, string> | undefined;
|
|
138
136
|
}): URL;
|
|
139
|
-
validateAuthorizationCode: ({
|
|
140
|
-
code,
|
|
141
|
-
redirectURI
|
|
142
|
-
}: {
|
|
137
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
143
138
|
code: string;
|
|
144
139
|
redirectURI: string;
|
|
145
140
|
codeVerifier?: string | undefined;
|
|
@@ -156,15 +151,8 @@ declare const tiktok: (options: TiktokOptions) => {
|
|
|
156
151
|
email?: string;
|
|
157
152
|
} | undefined;
|
|
158
153
|
}): Promise<{
|
|
159
|
-
user:
|
|
160
|
-
|
|
161
|
-
name?: string;
|
|
162
|
-
email?: string | null;
|
|
163
|
-
image?: string;
|
|
164
|
-
emailVerified: boolean;
|
|
165
|
-
[key: string]: any;
|
|
166
|
-
};
|
|
167
|
-
data: any;
|
|
154
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
155
|
+
data: TiktokProfile;
|
|
168
156
|
} | null>;
|
|
169
157
|
options: TiktokOptions;
|
|
170
158
|
};
|
|
@@ -8,6 +8,7 @@ const tiktok = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "tiktok",
|
|
10
10
|
name: "TikTok",
|
|
11
|
+
accountSubject: ({ profile }) => profile.data.user.open_id,
|
|
11
12
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : ["user.info.profile"];
|
|
13
14
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -57,7 +58,6 @@ const tiktok = (options) => {
|
|
|
57
58
|
return {
|
|
58
59
|
user: {
|
|
59
60
|
email: profile.data.user.email || profile.data.user.username,
|
|
60
|
-
id: profile.data.user.open_id,
|
|
61
61
|
name: profile.data.user.display_name || profile.data.user.username || "",
|
|
62
62
|
image: profile.data.user.avatar_large_url,
|
|
63
63
|
emailVerified: false
|
|
@@ -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/twitch.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* @see https://dev.twitch.tv/docs/authentication/getting-tokens-oidc/#requesting-claims
|
|
@@ -32,12 +33,8 @@ interface TwitchOptions extends ProviderOptions<TwitchProfile> {
|
|
|
32
33
|
declare const twitch: (options: TwitchOptions) => {
|
|
33
34
|
id: "twitch";
|
|
34
35
|
name: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
scopes,
|
|
38
|
-
redirectURI,
|
|
39
|
-
additionalParams
|
|
40
|
-
}: {
|
|
36
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<TwitchProfile>) => string;
|
|
37
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }: {
|
|
41
38
|
state: string;
|
|
42
39
|
codeVerifier: string;
|
|
43
40
|
scopes?: string[] | undefined;
|
|
@@ -47,10 +44,7 @@ declare const twitch: (options: TwitchOptions) => {
|
|
|
47
44
|
idTokenNonce?: string | undefined;
|
|
48
45
|
additionalParams?: Record<string, string> | undefined;
|
|
49
46
|
}): Promise<URL>;
|
|
50
|
-
validateAuthorizationCode: ({
|
|
51
|
-
code,
|
|
52
|
-
redirectURI
|
|
53
|
-
}: {
|
|
47
|
+
validateAuthorizationCode: ({ code, redirectURI }: {
|
|
54
48
|
code: string;
|
|
55
49
|
redirectURI: string;
|
|
56
50
|
codeVerifier?: string | undefined;
|
|
@@ -67,15 +61,8 @@ declare const twitch: (options: TwitchOptions) => {
|
|
|
67
61
|
email?: string;
|
|
68
62
|
} | undefined;
|
|
69
63
|
}): Promise<{
|
|
70
|
-
user:
|
|
71
|
-
|
|
72
|
-
name?: string;
|
|
73
|
-
email?: string | null;
|
|
74
|
-
image?: string;
|
|
75
|
-
emailVerified: boolean;
|
|
76
|
-
[key: string]: any;
|
|
77
|
-
};
|
|
78
|
-
data: any;
|
|
64
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
65
|
+
data: TwitchProfile;
|
|
79
66
|
} | null>;
|
|
80
67
|
options: TwitchOptions;
|
|
81
68
|
};
|
|
@@ -9,6 +9,7 @@ const twitch = (options) => {
|
|
|
9
9
|
return {
|
|
10
10
|
id: "twitch",
|
|
11
11
|
name: "Twitch",
|
|
12
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
12
13
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
13
14
|
const _scopes = options.disableDefaultScope ? [] : ["user:read:email", "openid"];
|
|
14
15
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -59,7 +60,6 @@ const twitch = (options) => {
|
|
|
59
60
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
60
61
|
return {
|
|
61
62
|
user: {
|
|
62
|
-
id: profile.sub,
|
|
63
63
|
name: profile.preferred_username,
|
|
64
64
|
email: profile.email,
|
|
65
65
|
image: 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/twitter.d.ts
|
|
3
4
|
interface TwitterProfile {
|
|
4
5
|
data: {
|
|
@@ -6,9 +7,12 @@ interface TwitterProfile {
|
|
|
6
7
|
* Unique identifier of this user. This is returned as a string in order to avoid complications with languages and tools
|
|
7
8
|
* that cannot handle large integers.
|
|
8
9
|
*/
|
|
9
|
-
id: string;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
id: string;
|
|
11
|
+
/** The friendly name of this user, as shown on their profile. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The email address of this user. */
|
|
14
|
+
email?: string | undefined;
|
|
15
|
+
/** The Twitter handle (screen name) of this user. */
|
|
12
16
|
username: string;
|
|
13
17
|
/**
|
|
14
18
|
* The location specified in the user's profile, if the user provided one.
|
|
@@ -23,15 +27,23 @@ interface TwitterProfile {
|
|
|
23
27
|
*To return this field, add `user.fields=entities` in the authorization request's query parameter.
|
|
24
28
|
*/
|
|
25
29
|
entities?: {
|
|
26
|
-
/** Contains details about the user's profile website. */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
/** Contains details about the user's profile website. */
|
|
31
|
+
url: {
|
|
32
|
+
/** Contains details about the user's profile website. */
|
|
33
|
+
urls: Array<{
|
|
34
|
+
/** The start position (zero-based) of the recognized user's profile website. All start indices are inclusive. */
|
|
35
|
+
start: number;
|
|
36
|
+
/** The end position (zero-based) of the recognized user's profile website. This end index is exclusive. */
|
|
37
|
+
end: number;
|
|
38
|
+
/** The URL in the format entered by the user. */
|
|
39
|
+
url: string;
|
|
40
|
+
/** The fully resolved URL. */
|
|
41
|
+
expanded_url: string;
|
|
42
|
+
/** The URL as displayed in the user's profile. */
|
|
32
43
|
display_url: string;
|
|
33
44
|
}>;
|
|
34
|
-
};
|
|
45
|
+
};
|
|
46
|
+
/** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */
|
|
35
47
|
description: {
|
|
36
48
|
hashtags: Array<{
|
|
37
49
|
start: number;
|
|
@@ -57,7 +69,8 @@ interface TwitterProfile {
|
|
|
57
69
|
*
|
|
58
70
|
* To return this field, add `user.fields=url` in the authorization request's query parameter.
|
|
59
71
|
*/
|
|
60
|
-
url?: string | undefined;
|
|
72
|
+
url?: string | undefined;
|
|
73
|
+
/** The URL to the profile image for this user, as shown on the user's profile. */
|
|
61
74
|
profile_image_url?: string | undefined;
|
|
62
75
|
protected?: boolean | undefined;
|
|
63
76
|
/**
|
|
@@ -82,6 +95,7 @@ interface TwitterOption extends ProviderOptions<TwitterProfile> {
|
|
|
82
95
|
declare const twitter: (options: TwitterOption) => {
|
|
83
96
|
id: "twitter";
|
|
84
97
|
name: string;
|
|
98
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<TwitterProfile>) => string;
|
|
85
99
|
createAuthorizationURL(data: {
|
|
86
100
|
state: string;
|
|
87
101
|
codeVerifier: string;
|
|
@@ -92,11 +106,7 @@ declare const twitter: (options: TwitterOption) => {
|
|
|
92
106
|
idTokenNonce?: string | undefined;
|
|
93
107
|
additionalParams?: Record<string, string> | undefined;
|
|
94
108
|
}): Promise<URL>;
|
|
95
|
-
validateAuthorizationCode: ({
|
|
96
|
-
code,
|
|
97
|
-
codeVerifier,
|
|
98
|
-
redirectURI
|
|
99
|
-
}: {
|
|
109
|
+
validateAuthorizationCode: ({ code, codeVerifier, redirectURI }: {
|
|
100
110
|
code: string;
|
|
101
111
|
redirectURI: string;
|
|
102
112
|
codeVerifier?: string | undefined;
|
|
@@ -113,15 +123,8 @@ declare const twitter: (options: TwitterOption) => {
|
|
|
113
123
|
email?: string;
|
|
114
124
|
} | undefined;
|
|
115
125
|
}): Promise<{
|
|
116
|
-
user:
|
|
117
|
-
|
|
118
|
-
name?: string;
|
|
119
|
-
email?: string | null;
|
|
120
|
-
image?: string;
|
|
121
|
-
emailVerified: boolean;
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
};
|
|
124
|
-
data: any;
|
|
126
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
127
|
+
data: TwitterProfile;
|
|
125
128
|
} | null>;
|
|
126
129
|
options: TwitterOption;
|
|
127
130
|
};
|
|
@@ -8,6 +8,7 @@ const twitter = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "twitter",
|
|
10
10
|
name: "Twitter",
|
|
11
|
+
accountSubject: ({ profile }) => profile.data.id,
|
|
11
12
|
createAuthorizationURL(data) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : [
|
|
13
14
|
"users.read",
|
|
@@ -69,7 +70,6 @@ const twitter = (options) => {
|
|
|
69
70
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
70
71
|
return {
|
|
71
72
|
user: {
|
|
72
|
-
id: profile.data.id,
|
|
73
73
|
name: profile.data.name,
|
|
74
74
|
email: profile.data.email || profile.data.username || null,
|
|
75
75
|
image: profile.data.profile_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/vercel.d.ts
|
|
3
4
|
interface VercelProfile {
|
|
4
5
|
sub: string;
|
|
@@ -14,13 +15,8 @@ interface VercelOptions extends ProviderOptions<VercelProfile> {
|
|
|
14
15
|
declare const vercel: (options: VercelOptions) => {
|
|
15
16
|
id: "vercel";
|
|
16
17
|
name: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
scopes,
|
|
20
|
-
codeVerifier,
|
|
21
|
-
redirectURI,
|
|
22
|
-
additionalParams
|
|
23
|
-
}: {
|
|
18
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<VercelProfile>) => string;
|
|
19
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }: {
|
|
24
20
|
state: string;
|
|
25
21
|
codeVerifier: string;
|
|
26
22
|
scopes?: string[] | undefined;
|
|
@@ -30,11 +26,7 @@ declare const vercel: (options: VercelOptions) => {
|
|
|
30
26
|
idTokenNonce?: string | undefined;
|
|
31
27
|
additionalParams?: Record<string, string> | undefined;
|
|
32
28
|
}): Promise<URL>;
|
|
33
|
-
validateAuthorizationCode: ({
|
|
34
|
-
code,
|
|
35
|
-
codeVerifier,
|
|
36
|
-
redirectURI
|
|
37
|
-
}: {
|
|
29
|
+
validateAuthorizationCode: ({ code, codeVerifier, redirectURI }: {
|
|
38
30
|
code: string;
|
|
39
31
|
redirectURI: string;
|
|
40
32
|
codeVerifier?: string | undefined;
|
|
@@ -50,15 +42,8 @@ declare const vercel: (options: VercelOptions) => {
|
|
|
50
42
|
email?: string;
|
|
51
43
|
} | undefined;
|
|
52
44
|
}): Promise<{
|
|
53
|
-
user:
|
|
54
|
-
|
|
55
|
-
name?: string;
|
|
56
|
-
email?: string | null;
|
|
57
|
-
image?: string;
|
|
58
|
-
emailVerified: boolean;
|
|
59
|
-
[key: string]: any;
|
|
60
|
-
};
|
|
61
|
-
data: any;
|
|
45
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
46
|
+
data: VercelProfile;
|
|
62
47
|
} | null>;
|
|
63
48
|
options: VercelOptions;
|
|
64
49
|
};
|
|
@@ -7,6 +7,7 @@ const vercel = (options) => {
|
|
|
7
7
|
return {
|
|
8
8
|
id: "vercel",
|
|
9
9
|
name: "Vercel",
|
|
10
|
+
accountSubject: ({ profile }) => profile.sub,
|
|
10
11
|
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }) {
|
|
11
12
|
if (!codeVerifier) throw new BetterAuthError("codeVerifier is required for Vercel");
|
|
12
13
|
let _scopes = void 0;
|
|
@@ -42,7 +43,6 @@ const vercel = (options) => {
|
|
|
42
43
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
43
44
|
return {
|
|
44
45
|
user: {
|
|
45
|
-
id: profile.sub,
|
|
46
46
|
name: profile.name ?? profile.preferred_username ?? "",
|
|
47
47
|
email: profile.email,
|
|
48
48
|
image: 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/vk.d.ts
|
|
3
4
|
interface VkProfile {
|
|
4
5
|
user: {
|
|
@@ -13,20 +14,15 @@ interface VkProfile {
|
|
|
13
14
|
birthday: string;
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
interface VkOption extends ProviderOptions {
|
|
17
|
+
interface VkOption extends ProviderOptions<VkProfile> {
|
|
17
18
|
clientId: string;
|
|
18
19
|
scheme?: ("light" | "dark") | undefined;
|
|
19
20
|
}
|
|
20
21
|
declare const vk: (options: VkOption) => {
|
|
21
22
|
id: "vk";
|
|
22
23
|
name: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
scopes,
|
|
26
|
-
codeVerifier,
|
|
27
|
-
redirectURI,
|
|
28
|
-
additionalParams
|
|
29
|
-
}: {
|
|
24
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<VkProfile>) => string;
|
|
25
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }: {
|
|
30
26
|
state: string;
|
|
31
27
|
codeVerifier: string;
|
|
32
28
|
scopes?: string[] | undefined;
|
|
@@ -36,12 +32,7 @@ declare const vk: (options: VkOption) => {
|
|
|
36
32
|
idTokenNonce?: string | undefined;
|
|
37
33
|
additionalParams?: Record<string, string> | undefined;
|
|
38
34
|
}): Promise<URL>;
|
|
39
|
-
validateAuthorizationCode: ({
|
|
40
|
-
code,
|
|
41
|
-
codeVerifier,
|
|
42
|
-
redirectURI,
|
|
43
|
-
deviceId
|
|
44
|
-
}: {
|
|
35
|
+
validateAuthorizationCode: ({ code, codeVerifier, redirectURI, deviceId }: {
|
|
45
36
|
code: string;
|
|
46
37
|
redirectURI: string;
|
|
47
38
|
codeVerifier?: string | undefined;
|
|
@@ -58,15 +49,8 @@ declare const vk: (options: VkOption) => {
|
|
|
58
49
|
email?: string;
|
|
59
50
|
} | undefined;
|
|
60
51
|
}): Promise<{
|
|
61
|
-
user:
|
|
62
|
-
|
|
63
|
-
name?: string;
|
|
64
|
-
email?: string | null;
|
|
65
|
-
image?: string;
|
|
66
|
-
emailVerified: boolean;
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
};
|
|
69
|
-
data: any;
|
|
52
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
53
|
+
data: VkProfile;
|
|
70
54
|
} | null>;
|
|
71
55
|
options: VkOption;
|
|
72
56
|
};
|
|
@@ -8,6 +8,7 @@ const vk = (options) => {
|
|
|
8
8
|
return {
|
|
9
9
|
id: "vk",
|
|
10
10
|
name: "VK",
|
|
11
|
+
accountSubject: ({ profile }) => profile.user.user_id,
|
|
11
12
|
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, additionalParams }) {
|
|
12
13
|
const _scopes = options.disableDefaultScope ? [] : ["email", "phone"];
|
|
13
14
|
if (options.scope) _scopes.push(...options.scope);
|
|
@@ -47,21 +48,19 @@ const vk = (options) => {
|
|
|
47
48
|
async getUserInfo(data) {
|
|
48
49
|
if (options.getUserInfo) return options.getUserInfo(data);
|
|
49
50
|
if (!data.accessToken) return null;
|
|
50
|
-
const formBody = new URLSearchParams({
|
|
51
|
-
access_token: data.accessToken,
|
|
52
|
-
client_id: options.clientId
|
|
53
|
-
}).toString();
|
|
54
51
|
const { data: profile, error } = await betterFetch("https://id.vk.com/oauth2/user_info", {
|
|
55
52
|
method: "POST",
|
|
56
53
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
57
|
-
body:
|
|
54
|
+
body: new URLSearchParams({
|
|
55
|
+
access_token: data.accessToken,
|
|
56
|
+
client_id: options.clientId
|
|
57
|
+
}).toString()
|
|
58
58
|
});
|
|
59
59
|
if (error) return null;
|
|
60
60
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
61
61
|
if (!profile.user.email && !userMap?.email) return null;
|
|
62
62
|
return {
|
|
63
63
|
user: {
|
|
64
|
-
id: profile.user.user_id,
|
|
65
64
|
first_name: profile.user.first_name,
|
|
66
65
|
last_name: profile.user.last_name,
|
|
67
66
|
email: profile.user.email,
|
|
@@ -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/wechat.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* WeChat user profile information
|
|
@@ -53,12 +54,8 @@ interface WeChatOptions extends ProviderOptions<WeChatProfile> {
|
|
|
53
54
|
declare const wechat: (options: WeChatOptions) => {
|
|
54
55
|
id: "wechat";
|
|
55
56
|
name: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
scopes,
|
|
59
|
-
redirectURI,
|
|
60
|
-
additionalParams
|
|
61
|
-
}: {
|
|
57
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<WeChatProfile>) => string;
|
|
58
|
+
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }: {
|
|
62
59
|
state: string;
|
|
63
60
|
codeVerifier: string;
|
|
64
61
|
scopes?: string[] | undefined;
|
|
@@ -68,9 +65,7 @@ declare const wechat: (options: WeChatOptions) => {
|
|
|
68
65
|
idTokenNonce?: string | undefined;
|
|
69
66
|
additionalParams?: Record<string, string> | undefined;
|
|
70
67
|
}): URL;
|
|
71
|
-
validateAuthorizationCode: ({
|
|
72
|
-
code
|
|
73
|
-
}: {
|
|
68
|
+
validateAuthorizationCode: ({ code }: {
|
|
74
69
|
code: string;
|
|
75
70
|
redirectURI: string;
|
|
76
71
|
codeVerifier?: string | undefined;
|
|
@@ -101,15 +96,8 @@ declare const wechat: (options: WeChatOptions) => {
|
|
|
101
96
|
email?: string;
|
|
102
97
|
} | undefined;
|
|
103
98
|
}): Promise<{
|
|
104
|
-
user:
|
|
105
|
-
|
|
106
|
-
name?: string;
|
|
107
|
-
email?: string | null;
|
|
108
|
-
image?: string;
|
|
109
|
-
emailVerified: boolean;
|
|
110
|
-
[key: string]: any;
|
|
111
|
-
};
|
|
112
|
-
data: any;
|
|
99
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
100
|
+
data: WeChatProfile;
|
|
113
101
|
} | null>;
|
|
114
102
|
options: WeChatOptions;
|
|
115
103
|
};
|
|
@@ -5,6 +5,7 @@ const wechat = (options) => {
|
|
|
5
5
|
return {
|
|
6
6
|
id: "wechat",
|
|
7
7
|
name: "WeChat",
|
|
8
|
+
accountSubject: ({ profile }) => profile.unionid || profile.openid,
|
|
8
9
|
createAuthorizationURL({ state, scopes, redirectURI, additionalParams }) {
|
|
9
10
|
const _scopes = options.disableDefaultScope ? [] : ["snsapi_login"];
|
|
10
11
|
options.scope && _scopes.push(...options.scope);
|
|
@@ -70,7 +71,6 @@ const wechat = (options) => {
|
|
|
70
71
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
71
72
|
return {
|
|
72
73
|
user: {
|
|
73
|
-
id: profile.unionid || profile.openid || openid,
|
|
74
74
|
name: profile.nickname,
|
|
75
75
|
email: profile.email || `${profile.unionid || profile.openid || openid}@wechat.invalid`,
|
|
76
76
|
image: profile.headimgurl,
|
|
@@ -1,10 +1,9 @@
|
|
|
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/zoom.d.ts
|
|
3
|
-
type LoginType = 0 /** Facebook OAuth */ |
|
|
4
|
-
/** Single Sign-On (SSO) */
|
|
4
|
+
type LoginType = 0 | /** Facebook OAuth */ 1 | /** Google OAuth */ 24 | /** Apple OAuth */ 27 | /** Microsoft OAuth */ 97 | /** Mobile device */ 98 | /** RingCentral OAuth */ 99 | /** API user */ 100 | /** Zoom Work email */ 101; /** Single Sign-On (SSO) */
|
|
5
5
|
type AccountStatus = "pending" | "active" | "inactive";
|
|
6
|
-
type PronounOption = 1 /** Ask the user every time */ |
|
|
7
|
-
/** Do not display */
|
|
6
|
+
type PronounOption = 1 | /** Ask the user every time */ 2 | /** Always display */ 3; /** Do not display */
|
|
8
7
|
interface PhoneNumber {
|
|
9
8
|
/** The country code of the phone number (Example: "+1") */
|
|
10
9
|
code: string;
|
|
@@ -116,12 +115,8 @@ interface ZoomOptions extends ProviderOptions<ZoomProfile> {
|
|
|
116
115
|
declare const zoom: (userOptions: ZoomOptions) => {
|
|
117
116
|
id: "zoom";
|
|
118
117
|
name: string;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
redirectURI,
|
|
122
|
-
codeVerifier,
|
|
123
|
-
additionalParams
|
|
124
|
-
}: {
|
|
118
|
+
accountSubject: ({ profile }: OAuthAccountKeyContext<ZoomProfile>) => string;
|
|
119
|
+
createAuthorizationURL: ({ state, redirectURI, codeVerifier, additionalParams }: {
|
|
125
120
|
state: string;
|
|
126
121
|
codeVerifier: string;
|
|
127
122
|
scopes?: string[] | undefined;
|
|
@@ -131,11 +126,7 @@ declare const zoom: (userOptions: ZoomOptions) => {
|
|
|
131
126
|
idTokenNonce?: string | undefined;
|
|
132
127
|
additionalParams?: Record<string, string> | undefined;
|
|
133
128
|
}) => Promise<URL>;
|
|
134
|
-
validateAuthorizationCode: ({
|
|
135
|
-
code,
|
|
136
|
-
redirectURI,
|
|
137
|
-
codeVerifier
|
|
138
|
-
}: {
|
|
129
|
+
validateAuthorizationCode: ({ code, redirectURI, codeVerifier }: {
|
|
139
130
|
code: string;
|
|
140
131
|
redirectURI: string;
|
|
141
132
|
codeVerifier?: string | undefined;
|
|
@@ -152,15 +143,8 @@ declare const zoom: (userOptions: ZoomOptions) => {
|
|
|
152
143
|
email?: string;
|
|
153
144
|
} | undefined;
|
|
154
145
|
}): Promise<{
|
|
155
|
-
user:
|
|
156
|
-
|
|
157
|
-
name?: string;
|
|
158
|
-
email?: string | null;
|
|
159
|
-
image?: string;
|
|
160
|
-
emailVerified: boolean;
|
|
161
|
-
[key: string]: any;
|
|
162
|
-
};
|
|
163
|
-
data: any;
|
|
146
|
+
user: OAuth2UserInfo & Record<string, unknown>;
|
|
147
|
+
data: ZoomProfile;
|
|
164
148
|
} | null>;
|
|
165
149
|
};
|
|
166
150
|
//#endregion
|
|
@@ -11,6 +11,7 @@ const zoom = (userOptions) => {
|
|
|
11
11
|
return {
|
|
12
12
|
id: "zoom",
|
|
13
13
|
name: "Zoom",
|
|
14
|
+
accountSubject: ({ profile }) => profile.id,
|
|
14
15
|
createAuthorizationURL: async ({ state, redirectURI, codeVerifier, additionalParams }) => createAuthorizationURL({
|
|
15
16
|
id: "zoom",
|
|
16
17
|
options,
|
|
@@ -46,7 +47,6 @@ const zoom = (userOptions) => {
|
|
|
46
47
|
const userMap = await options.mapProfileToUser?.(profile);
|
|
47
48
|
return {
|
|
48
49
|
user: {
|
|
49
|
-
id: profile.id,
|
|
50
50
|
name: profile.display_name,
|
|
51
51
|
image: profile.pic_url,
|
|
52
52
|
email: profile.email,
|
package/dist/types/context.d.mts
CHANGED
|
@@ -7,12 +7,13 @@ import { createLogger } from "../env/logger.mjs";
|
|
|
7
7
|
import { Awaitable, LiteralString } from "./helper.mjs";
|
|
8
8
|
import { BetterAuthPlugin } from "./plugin.mjs";
|
|
9
9
|
import { BetterAuthOptions, BetterAuthRateLimitOptions, UserProvisioningSource } from "./init-options.mjs";
|
|
10
|
-
import { Account } from "../db/schema/account.mjs";
|
|
10
|
+
import { Account, AccountKey } from "../db/schema/account.mjs";
|
|
11
|
+
import "../db/index.mjs";
|
|
11
12
|
import { BetterAuthCookie, BetterAuthCookies } from "./cookie.mjs";
|
|
12
13
|
import { SecretConfig } from "./secret.mjs";
|
|
13
14
|
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
15
|
+
import "../oauth2/index.mjs";
|
|
14
16
|
import { CookieOptions, EndpointContext } from "better-call";
|
|
15
|
-
|
|
16
17
|
//#region src/types/context.d.ts
|
|
17
18
|
/**
|
|
18
19
|
* @internal
|
|
@@ -63,7 +64,6 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
63
64
|
* Provisioning source. The creation seam adds `action: "create-user"` and
|
|
64
65
|
* runs the `user.validateUserInfo` gate.
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
67
|
source: UserProvisioningSource): Promise<T & User>;
|
|
68
68
|
createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
|
|
69
69
|
listSessions(userId: string, options?: {
|
|
@@ -75,7 +75,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
75
75
|
} | undefined, where?: Where[] | undefined): Promise<User[]>;
|
|
76
76
|
countTotalUsers(where?: Where[] | undefined): Promise<number>;
|
|
77
77
|
deleteUser(userId: string): Promise<void>;
|
|
78
|
-
createSession(userId: string, dontRememberMe?: boolean | undefined, override?: (Partial<Session> & Record<string, any>) | undefined, overrideAll?: boolean | undefined
|
|
78
|
+
createSession(userId: string, dontRememberMe?: boolean | undefined, override?: (Partial<Session> & Record<string, any>) | undefined, overrideAll?: boolean | undefined, storageOptions?: {
|
|
79
|
+
deferSecondaryStorageWrites?: boolean | undefined;
|
|
80
|
+
} | undefined): Promise<Session>;
|
|
79
81
|
findSession(token: string): Promise<{
|
|
80
82
|
session: Session & Record<string, any>;
|
|
81
83
|
user: User & Record<string, any>;
|
|
@@ -92,7 +94,7 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
92
94
|
/**
|
|
93
95
|
* Delete an account by its primary key.
|
|
94
96
|
*
|
|
95
|
-
* @param id - The account row's primary key
|
|
97
|
+
* @param id - The account row's primary key, not its provider account ID.
|
|
96
98
|
*/
|
|
97
99
|
deleteAccount(id: string): Promise<void>;
|
|
98
100
|
/**
|
|
@@ -103,10 +105,13 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
103
105
|
* Delete sessions by their session tokens.
|
|
104
106
|
*/
|
|
105
107
|
deleteSessions(sessionTokens: string[]): Promise<void>;
|
|
106
|
-
|
|
108
|
+
findAccountOwnerByKey(accountKey: AccountKey): Promise<{
|
|
109
|
+
kind: "owned";
|
|
107
110
|
user: User;
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
account: Account;
|
|
112
|
+
} | {
|
|
113
|
+
kind: "orphaned";
|
|
114
|
+
account: Account;
|
|
110
115
|
} | null>;
|
|
111
116
|
findUserByEmail(email: string, options?: {
|
|
112
117
|
includeAccounts: boolean;
|
|
@@ -120,7 +125,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
120
125
|
updateUserByEmail<T extends Record<string, any>>(email: string, data: Partial<User & Record<string, any>>): Promise<User & T>;
|
|
121
126
|
updatePassword(userId: string, password: string): Promise<void>;
|
|
122
127
|
findAccounts(userId: string): Promise<Account[]>;
|
|
123
|
-
|
|
128
|
+
/** Find the credential account whose stable local subject is the user ID. */
|
|
129
|
+
findCredentialAccount(userId: string): Promise<Account | null>;
|
|
130
|
+
findAccountByKey(accountKey: AccountKey): Promise<Account | null>;
|
|
124
131
|
findAccountByUserId(userId: string): Promise<Account[]>;
|
|
125
132
|
updateAccount(id: string, data: Partial<Account>): Promise<Account>;
|
|
126
133
|
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|