@better-auth/core 1.7.0-rc.4 → 1.7.0-rc.6
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 +39 -60
- package/dist/api/index.mjs +39 -26
- package/dist/async_hooks/index.d.mts +1 -0
- package/dist/async_hooks/pure.index.d.mts +1 -0
- package/dist/context/endpoint-context.d.mts +1 -1
- package/dist/context/global.d.mts +1 -0
- package/dist/context/global.mjs +1 -1
- package/dist/context/request-state.d.mts +1 -0
- package/dist/context/transaction.d.mts +2 -3
- package/dist/db/adapter/factory.d.mts +5 -3
- package/dist/db/adapter/factory.mjs +1 -1
- package/dist/db/adapter/get-default-field-name.d.mts +9 -2
- package/dist/db/adapter/get-default-model-name.d.mts +5 -1
- package/dist/db/adapter/get-field-attributes.d.mts +11 -4
- package/dist/db/adapter/get-field-name.d.mts +9 -2
- package/dist/db/adapter/get-id-field.d.mts +12 -4
- package/dist/db/adapter/get-model-name.d.mts +5 -1
- package/dist/db/adapter/index.d.mts +32 -7
- package/dist/db/adapter/types.d.mts +17 -5
- package/dist/db/adapter/utils.d.mts +1 -0
- package/dist/db/database-index.d.mts +12 -2
- package/dist/db/get-tables.d.mts +0 -1
- package/dist/db/plugin.d.mts +3 -3
- package/dist/db/schema/account.d.mts +1 -1
- package/dist/db/schema/rate-limit.d.mts +1 -1
- package/dist/db/schema/session.d.mts +1 -1
- package/dist/db/schema/shared.d.mts +1 -0
- package/dist/db/schema/user.d.mts +1 -1
- package/dist/db/schema/verification.d.mts +1 -1
- package/dist/db/type.d.mts +11 -8
- package/dist/env/logger.d.mts +25 -25
- package/dist/error/codes.d.mts +1 -0
- package/dist/error/index.d.mts +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/instrumentation/attributes.d.mts +1 -0
- package/dist/instrumentation/pure.index.d.mts +1 -0
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/oauth2/authorization-params.d.mts +1 -0
- package/dist/oauth2/client-assertion.d.mts +13 -3
- package/dist/oauth2/client-credentials-token.d.mts +17 -3
- package/dist/oauth2/create-authorization-url.d.mts +21 -3
- package/dist/oauth2/dpop.d.mts +23 -2
- package/dist/oauth2/dpop.mjs +1 -1
- package/dist/oauth2/oauth-provider.d.mts +7 -13
- package/dist/oauth2/refresh-access-token.d.mts +19 -3
- package/dist/oauth2/refresh-access-token.mjs +1 -1
- package/dist/oauth2/reject-redirects.mjs +1 -1
- package/dist/oauth2/token-endpoint-auth.d.mts +1 -0
- package/dist/oauth2/utils.d.mts +1 -0
- package/dist/oauth2/utils.mjs +1 -1
- package/dist/oauth2/validate-authorization-code.d.mts +29 -5
- package/dist/oauth2/verify-id-token.d.mts +1 -1
- package/dist/oauth2/verify.d.mts +7 -5
- package/dist/oauth2/verify.mjs +2 -2
- package/dist/social-providers/apple.d.mts +18 -5
- package/dist/social-providers/atlassian.d.mts +15 -4
- package/dist/social-providers/cognito.d.mts +18 -5
- package/dist/social-providers/discord.d.mts +13 -4
- package/dist/social-providers/dropbox.d.mts +15 -4
- package/dist/social-providers/facebook.d.mts +18 -6
- package/dist/social-providers/figma.d.mts +15 -4
- package/dist/social-providers/github.d.mts +16 -4
- package/dist/social-providers/gitlab.d.mts +16 -4
- package/dist/social-providers/google.d.mts +25 -6
- package/dist/social-providers/huggingface.d.mts +15 -4
- package/dist/social-providers/index.d.mts +504 -113
- package/dist/social-providers/kakao.d.mts +13 -4
- package/dist/social-providers/kick.d.mts +15 -4
- package/dist/social-providers/line.d.mts +16 -4
- package/dist/social-providers/linear.d.mts +14 -4
- package/dist/social-providers/linkedin.d.mts +14 -4
- package/dist/social-providers/microsoft-entra-id.d.mts +14 -5
- package/dist/social-providers/microsoft-entra-id.mjs +1 -2
- package/dist/social-providers/naver.d.mts +22 -23
- package/dist/social-providers/notion.d.mts +14 -4
- package/dist/social-providers/paybin.d.mts +16 -4
- package/dist/social-providers/paypal.d.mts +13 -4
- package/dist/social-providers/polar.d.mts +15 -4
- package/dist/social-providers/railway.d.mts +15 -4
- package/dist/social-providers/reddit.d.mts +13 -4
- package/dist/social-providers/roblox.d.mts +13 -4
- package/dist/social-providers/salesforce.d.mts +15 -4
- package/dist/social-providers/slack.d.mts +13 -4
- package/dist/social-providers/spotify.d.mts +15 -4
- package/dist/social-providers/tiktok.d.mts +14 -6
- package/dist/social-providers/twitch.d.mts +13 -4
- package/dist/social-providers/twitter.d.mts +19 -26
- package/dist/social-providers/vercel.d.mts +15 -4
- package/dist/social-providers/vk.d.mts +16 -4
- package/dist/social-providers/wechat.d.mts +12 -4
- package/dist/social-providers/zoom.d.mts +18 -6
- package/dist/types/context.d.mts +2 -2
- package/dist/types/cookie.d.mts +1 -1
- package/dist/types/helper.d.mts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/init-options.d.mts +18 -26
- package/dist/types/plugin-client.d.mts +3 -1
- package/dist/types/plugin.d.mts +2 -2
- package/dist/utils/async.d.mts +1 -0
- package/dist/utils/db.d.mts +0 -1
- package/dist/utils/deprecate.d.mts +1 -0
- package/dist/utils/email.d.mts +4 -1
- package/dist/utils/error-codes.d.mts +2 -2
- package/dist/utils/host.d.mts +1 -27
- package/dist/utils/host.mjs +1 -1
- package/dist/utils/ip.d.mts +0 -1
- package/dist/utils/ip.mjs +1 -1
- package/dist/utils/is-api-error.d.mts +1 -0
- package/dist/utils/redirect-uri.d.mts +1 -0
- package/package.json +4 -4
- package/src/api/index.ts +96 -95
- package/src/db/type.ts +2 -1
- package/src/types/init-options.ts +6 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/spotify.d.ts
|
|
4
3
|
interface SpotifyProfile {
|
|
5
4
|
id: string;
|
|
@@ -15,8 +14,16 @@ interface SpotifyOptions extends ProviderOptions<SpotifyProfile> {
|
|
|
15
14
|
declare const spotify: (options: SpotifyOptions) => {
|
|
16
15
|
id: "spotify";
|
|
17
16
|
name: string;
|
|
18
|
-
accountSubject: ({
|
|
19
|
-
|
|
17
|
+
accountSubject: ({
|
|
18
|
+
profile
|
|
19
|
+
}: OAuthAccountKeyContext<SpotifyProfile>) => string;
|
|
20
|
+
createAuthorizationURL({
|
|
21
|
+
state,
|
|
22
|
+
scopes,
|
|
23
|
+
codeVerifier,
|
|
24
|
+
redirectURI,
|
|
25
|
+
additionalParams
|
|
26
|
+
}: {
|
|
20
27
|
state: string;
|
|
21
28
|
codeVerifier: string;
|
|
22
29
|
scopes?: string[] | undefined;
|
|
@@ -26,7 +33,11 @@ declare const spotify: (options: SpotifyOptions) => {
|
|
|
26
33
|
idTokenNonce?: string | undefined;
|
|
27
34
|
additionalParams?: Record<string, string> | undefined;
|
|
28
35
|
}): Promise<URL>;
|
|
29
|
-
validateAuthorizationCode: ({
|
|
36
|
+
validateAuthorizationCode: ({
|
|
37
|
+
code,
|
|
38
|
+
codeVerifier,
|
|
39
|
+
redirectURI
|
|
40
|
+
}: {
|
|
30
41
|
code: string;
|
|
31
42
|
redirectURI: string;
|
|
32
43
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/tiktok.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* [More info](https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/)
|
|
@@ -52,8 +51,7 @@ interface TiktokProfile extends Record<string, any> {
|
|
|
52
51
|
*
|
|
53
52
|
* To return this field, add `fields=username` in the user profile request's query parameter.
|
|
54
53
|
*/
|
|
55
|
-
username: string;
|
|
56
|
-
/** @note Email is currently unsupported by TikTok */
|
|
54
|
+
username: string; /** @note Email is currently unsupported by TikTok */
|
|
57
55
|
email?: string | undefined;
|
|
58
56
|
/**
|
|
59
57
|
* User's bio description if there is a valid one.
|
|
@@ -123,8 +121,15 @@ interface TiktokOptions extends ProviderOptions<TiktokProfile> {
|
|
|
123
121
|
declare const tiktok: (options: TiktokOptions) => {
|
|
124
122
|
id: "tiktok";
|
|
125
123
|
name: string;
|
|
126
|
-
accountSubject: ({
|
|
127
|
-
|
|
124
|
+
accountSubject: ({
|
|
125
|
+
profile
|
|
126
|
+
}: OAuthAccountKeyContext<TiktokProfile>) => string;
|
|
127
|
+
createAuthorizationURL({
|
|
128
|
+
state,
|
|
129
|
+
scopes,
|
|
130
|
+
redirectURI,
|
|
131
|
+
additionalParams
|
|
132
|
+
}: {
|
|
128
133
|
state: string;
|
|
129
134
|
codeVerifier: string;
|
|
130
135
|
scopes?: string[] | undefined;
|
|
@@ -134,7 +139,10 @@ declare const tiktok: (options: TiktokOptions) => {
|
|
|
134
139
|
idTokenNonce?: string | undefined;
|
|
135
140
|
additionalParams?: Record<string, string> | undefined;
|
|
136
141
|
}): URL;
|
|
137
|
-
validateAuthorizationCode: ({
|
|
142
|
+
validateAuthorizationCode: ({
|
|
143
|
+
code,
|
|
144
|
+
redirectURI
|
|
145
|
+
}: {
|
|
138
146
|
code: string;
|
|
139
147
|
redirectURI: string;
|
|
140
148
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/twitch.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* @see https://dev.twitch.tv/docs/authentication/getting-tokens-oidc/#requesting-claims
|
|
@@ -33,8 +32,15 @@ interface TwitchOptions extends ProviderOptions<TwitchProfile> {
|
|
|
33
32
|
declare const twitch: (options: TwitchOptions) => {
|
|
34
33
|
id: "twitch";
|
|
35
34
|
name: string;
|
|
36
|
-
accountSubject: ({
|
|
37
|
-
|
|
35
|
+
accountSubject: ({
|
|
36
|
+
profile
|
|
37
|
+
}: OAuthAccountKeyContext<TwitchProfile>) => string;
|
|
38
|
+
createAuthorizationURL({
|
|
39
|
+
state,
|
|
40
|
+
scopes,
|
|
41
|
+
redirectURI,
|
|
42
|
+
additionalParams
|
|
43
|
+
}: {
|
|
38
44
|
state: string;
|
|
39
45
|
codeVerifier: string;
|
|
40
46
|
scopes?: string[] | undefined;
|
|
@@ -44,7 +50,10 @@ declare const twitch: (options: TwitchOptions) => {
|
|
|
44
50
|
idTokenNonce?: string | undefined;
|
|
45
51
|
additionalParams?: Record<string, string> | undefined;
|
|
46
52
|
}): Promise<URL>;
|
|
47
|
-
validateAuthorizationCode: ({
|
|
53
|
+
validateAuthorizationCode: ({
|
|
54
|
+
code,
|
|
55
|
+
redirectURI
|
|
56
|
+
}: {
|
|
48
57
|
code: string;
|
|
49
58
|
redirectURI: string;
|
|
50
59
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/twitter.d.ts
|
|
4
3
|
interface TwitterProfile {
|
|
5
4
|
data: {
|
|
@@ -7,12 +6,9 @@ interface TwitterProfile {
|
|
|
7
6
|
* Unique identifier of this user. This is returned as a string in order to avoid complications with languages and tools
|
|
8
7
|
* that cannot handle large integers.
|
|
9
8
|
*/
|
|
10
|
-
id: string;
|
|
11
|
-
/** The
|
|
12
|
-
|
|
13
|
-
/** The email address of this user. */
|
|
14
|
-
email?: string | undefined;
|
|
15
|
-
/** The Twitter handle (screen name) of this user. */
|
|
9
|
+
id: string; /** The friendly name of this user, as shown on their profile. */
|
|
10
|
+
name: string; /** The email address of this user. */
|
|
11
|
+
email?: string | undefined; /** The Twitter handle (screen name) of this user. */
|
|
16
12
|
username: string;
|
|
17
13
|
/**
|
|
18
14
|
* The location specified in the user's profile, if the user provided one.
|
|
@@ -27,23 +23,15 @@ interface TwitterProfile {
|
|
|
27
23
|
*To return this field, add `user.fields=entities` in the authorization request's query parameter.
|
|
28
24
|
*/
|
|
29
25
|
entities?: {
|
|
30
|
-
/** Contains details about the user's profile website. */
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/** The
|
|
35
|
-
|
|
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. */
|
|
26
|
+
/** Contains details about the user's profile website. */url: {
|
|
27
|
+
/** Contains details about the user's profile website. */urls: Array<{
|
|
28
|
+
/** The start position (zero-based) of the recognized user's profile website. All start indices are inclusive. */start: number; /** The end position (zero-based) of the recognized user's profile website. This end index is exclusive. */
|
|
29
|
+
end: number; /** The URL in the format entered by the user. */
|
|
30
|
+
url: string; /** The fully resolved URL. */
|
|
31
|
+
expanded_url: string; /** The URL as displayed in the user's profile. */
|
|
43
32
|
display_url: string;
|
|
44
33
|
}>;
|
|
45
|
-
};
|
|
46
|
-
/** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */
|
|
34
|
+
}; /** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */
|
|
47
35
|
description: {
|
|
48
36
|
hashtags: Array<{
|
|
49
37
|
start: number;
|
|
@@ -69,8 +57,7 @@ interface TwitterProfile {
|
|
|
69
57
|
*
|
|
70
58
|
* To return this field, add `user.fields=url` in the authorization request's query parameter.
|
|
71
59
|
*/
|
|
72
|
-
url?: string | undefined;
|
|
73
|
-
/** The URL to the profile image for this user, as shown on the user's profile. */
|
|
60
|
+
url?: string | undefined; /** The URL to the profile image for this user, as shown on the user's profile. */
|
|
74
61
|
profile_image_url?: string | undefined;
|
|
75
62
|
protected?: boolean | undefined;
|
|
76
63
|
/**
|
|
@@ -95,7 +82,9 @@ interface TwitterOption extends ProviderOptions<TwitterProfile> {
|
|
|
95
82
|
declare const twitter: (options: TwitterOption) => {
|
|
96
83
|
id: "twitter";
|
|
97
84
|
name: string;
|
|
98
|
-
accountSubject: ({
|
|
85
|
+
accountSubject: ({
|
|
86
|
+
profile
|
|
87
|
+
}: OAuthAccountKeyContext<TwitterProfile>) => string;
|
|
99
88
|
createAuthorizationURL(data: {
|
|
100
89
|
state: string;
|
|
101
90
|
codeVerifier: string;
|
|
@@ -106,7 +95,11 @@ declare const twitter: (options: TwitterOption) => {
|
|
|
106
95
|
idTokenNonce?: string | undefined;
|
|
107
96
|
additionalParams?: Record<string, string> | undefined;
|
|
108
97
|
}): Promise<URL>;
|
|
109
|
-
validateAuthorizationCode: ({
|
|
98
|
+
validateAuthorizationCode: ({
|
|
99
|
+
code,
|
|
100
|
+
codeVerifier,
|
|
101
|
+
redirectURI
|
|
102
|
+
}: {
|
|
110
103
|
code: string;
|
|
111
104
|
redirectURI: string;
|
|
112
105
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/vercel.d.ts
|
|
4
3
|
interface VercelProfile {
|
|
5
4
|
sub: string;
|
|
@@ -15,8 +14,16 @@ interface VercelOptions extends ProviderOptions<VercelProfile> {
|
|
|
15
14
|
declare const vercel: (options: VercelOptions) => {
|
|
16
15
|
id: "vercel";
|
|
17
16
|
name: string;
|
|
18
|
-
accountSubject: ({
|
|
19
|
-
|
|
17
|
+
accountSubject: ({
|
|
18
|
+
profile
|
|
19
|
+
}: OAuthAccountKeyContext<VercelProfile>) => string;
|
|
20
|
+
createAuthorizationURL({
|
|
21
|
+
state,
|
|
22
|
+
scopes,
|
|
23
|
+
codeVerifier,
|
|
24
|
+
redirectURI,
|
|
25
|
+
additionalParams
|
|
26
|
+
}: {
|
|
20
27
|
state: string;
|
|
21
28
|
codeVerifier: string;
|
|
22
29
|
scopes?: string[] | undefined;
|
|
@@ -26,7 +33,11 @@ declare const vercel: (options: VercelOptions) => {
|
|
|
26
33
|
idTokenNonce?: string | undefined;
|
|
27
34
|
additionalParams?: Record<string, string> | undefined;
|
|
28
35
|
}): Promise<URL>;
|
|
29
|
-
validateAuthorizationCode: ({
|
|
36
|
+
validateAuthorizationCode: ({
|
|
37
|
+
code,
|
|
38
|
+
codeVerifier,
|
|
39
|
+
redirectURI
|
|
40
|
+
}: {
|
|
30
41
|
code: string;
|
|
31
42
|
redirectURI: string;
|
|
32
43
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/vk.d.ts
|
|
4
3
|
interface VkProfile {
|
|
5
4
|
user: {
|
|
@@ -21,8 +20,16 @@ interface VkOption extends ProviderOptions<VkProfile> {
|
|
|
21
20
|
declare const vk: (options: VkOption) => {
|
|
22
21
|
id: "vk";
|
|
23
22
|
name: string;
|
|
24
|
-
accountSubject: ({
|
|
25
|
-
|
|
23
|
+
accountSubject: ({
|
|
24
|
+
profile
|
|
25
|
+
}: OAuthAccountKeyContext<VkProfile>) => string;
|
|
26
|
+
createAuthorizationURL({
|
|
27
|
+
state,
|
|
28
|
+
scopes,
|
|
29
|
+
codeVerifier,
|
|
30
|
+
redirectURI,
|
|
31
|
+
additionalParams
|
|
32
|
+
}: {
|
|
26
33
|
state: string;
|
|
27
34
|
codeVerifier: string;
|
|
28
35
|
scopes?: string[] | undefined;
|
|
@@ -32,7 +39,12 @@ declare const vk: (options: VkOption) => {
|
|
|
32
39
|
idTokenNonce?: string | undefined;
|
|
33
40
|
additionalParams?: Record<string, string> | undefined;
|
|
34
41
|
}): Promise<URL>;
|
|
35
|
-
validateAuthorizationCode: ({
|
|
42
|
+
validateAuthorizationCode: ({
|
|
43
|
+
code,
|
|
44
|
+
codeVerifier,
|
|
45
|
+
redirectURI,
|
|
46
|
+
deviceId
|
|
47
|
+
}: {
|
|
36
48
|
code: string;
|
|
37
49
|
redirectURI: string;
|
|
38
50
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/wechat.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* WeChat user profile information
|
|
@@ -54,8 +53,15 @@ interface WeChatOptions extends ProviderOptions<WeChatProfile> {
|
|
|
54
53
|
declare const wechat: (options: WeChatOptions) => {
|
|
55
54
|
id: "wechat";
|
|
56
55
|
name: string;
|
|
57
|
-
accountSubject: ({
|
|
58
|
-
|
|
56
|
+
accountSubject: ({
|
|
57
|
+
profile
|
|
58
|
+
}: OAuthAccountKeyContext<WeChatProfile>) => string;
|
|
59
|
+
createAuthorizationURL({
|
|
60
|
+
state,
|
|
61
|
+
scopes,
|
|
62
|
+
redirectURI,
|
|
63
|
+
additionalParams
|
|
64
|
+
}: {
|
|
59
65
|
state: string;
|
|
60
66
|
codeVerifier: string;
|
|
61
67
|
scopes?: string[] | undefined;
|
|
@@ -65,7 +71,9 @@ declare const wechat: (options: WeChatOptions) => {
|
|
|
65
71
|
idTokenNonce?: string | undefined;
|
|
66
72
|
additionalParams?: Record<string, string> | undefined;
|
|
67
73
|
}): URL;
|
|
68
|
-
validateAuthorizationCode: ({
|
|
74
|
+
validateAuthorizationCode: ({
|
|
75
|
+
code
|
|
76
|
+
}: {
|
|
69
77
|
code: string;
|
|
70
78
|
redirectURI: string;
|
|
71
79
|
codeVerifier?: string | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
-
import "../oauth2/index.mjs";
|
|
3
2
|
//#region src/social-providers/zoom.d.ts
|
|
4
|
-
type LoginType = 0
|
|
3
|
+
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;
|
|
4
|
+
/** Single Sign-On (SSO) */
|
|
5
5
|
type AccountStatus = "pending" | "active" | "inactive";
|
|
6
|
-
type PronounOption = 1
|
|
6
|
+
type PronounOption = 1 /** Ask the user every time */ | 2 /** Always display */ | 3;
|
|
7
|
+
/** Do not display */
|
|
7
8
|
interface PhoneNumber {
|
|
8
9
|
/** The country code of the phone number (Example: "+1") */
|
|
9
10
|
code: string;
|
|
@@ -115,8 +116,15 @@ interface ZoomOptions extends ProviderOptions<ZoomProfile> {
|
|
|
115
116
|
declare const zoom: (userOptions: ZoomOptions) => {
|
|
116
117
|
id: "zoom";
|
|
117
118
|
name: string;
|
|
118
|
-
accountSubject: ({
|
|
119
|
-
|
|
119
|
+
accountSubject: ({
|
|
120
|
+
profile
|
|
121
|
+
}: OAuthAccountKeyContext<ZoomProfile>) => string;
|
|
122
|
+
createAuthorizationURL: ({
|
|
123
|
+
state,
|
|
124
|
+
redirectURI,
|
|
125
|
+
codeVerifier,
|
|
126
|
+
additionalParams
|
|
127
|
+
}: {
|
|
120
128
|
state: string;
|
|
121
129
|
codeVerifier: string;
|
|
122
130
|
scopes?: string[] | undefined;
|
|
@@ -126,7 +134,11 @@ declare const zoom: (userOptions: ZoomOptions) => {
|
|
|
126
134
|
idTokenNonce?: string | undefined;
|
|
127
135
|
additionalParams?: Record<string, string> | undefined;
|
|
128
136
|
}) => Promise<URL>;
|
|
129
|
-
validateAuthorizationCode: ({
|
|
137
|
+
validateAuthorizationCode: ({
|
|
138
|
+
code,
|
|
139
|
+
redirectURI,
|
|
140
|
+
codeVerifier
|
|
141
|
+
}: {
|
|
130
142
|
code: string;
|
|
131
143
|
redirectURI: string;
|
|
132
144
|
codeVerifier?: string | undefined;
|
package/dist/types/context.d.mts
CHANGED
|
@@ -8,12 +8,11 @@ import { Awaitable, LiteralString } from "./helper.mjs";
|
|
|
8
8
|
import { BetterAuthPlugin } from "./plugin.mjs";
|
|
9
9
|
import { BetterAuthOptions, BetterAuthRateLimitOptions, UserProvisioningSource } from "./init-options.mjs";
|
|
10
10
|
import { Account, AccountKey } from "../db/schema/account.mjs";
|
|
11
|
-
import "../db/index.mjs";
|
|
12
11
|
import { BetterAuthCookie, BetterAuthCookies, CookieCachePayload } from "./cookie.mjs";
|
|
13
12
|
import { SecretConfig } from "./secret.mjs";
|
|
14
13
|
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
15
|
-
import "../oauth2/index.mjs";
|
|
16
14
|
import { CookieOptions, EndpointContext } from "better-call";
|
|
15
|
+
|
|
17
16
|
//#region src/types/context.d.ts
|
|
18
17
|
/**
|
|
19
18
|
* @internal
|
|
@@ -74,6 +73,7 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
74
73
|
* Provisioning source. The creation seam adds `action: "create-user"` and
|
|
75
74
|
* runs the `user.validateUserInfo` gate.
|
|
76
75
|
*/
|
|
76
|
+
|
|
77
77
|
source: UserProvisioningSource): Promise<T & User>;
|
|
78
78
|
createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
|
|
79
79
|
listSessions(userId: string, options?: {
|
package/dist/types/cookie.d.mts
CHANGED
package/dist/types/helper.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ type Awaitable<T> = T | Promise<T>;
|
|
|
4
4
|
type AwaitableFunction<T> = T | (() => Awaitable<T>);
|
|
5
5
|
type LiteralString = "" | (string & Record<never, never>);
|
|
6
6
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
7
|
-
type Prettify<T> = { [K in keyof T]: T[K]
|
|
7
|
+
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
8
8
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -6,4 +6,4 @@ import { SecretConfig } from "./secret.mjs";
|
|
|
6
6
|
import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, CookieCacheSigner, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "./context.mjs";
|
|
7
7
|
import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore } from "./plugin-client.mjs";
|
|
8
8
|
import { StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
|
|
9
|
-
export
|
|
9
|
+
export { type StandardSchemaV1$1 as StandardSchemaV1 };
|
|
@@ -9,7 +9,6 @@ import { SocialProviderList, SocialProviders } from "../social-providers/index.m
|
|
|
9
9
|
import { Awaitable, LiteralString, LiteralUnion } from "./helper.mjs";
|
|
10
10
|
import { BetterAuthPlugin } from "./plugin.mjs";
|
|
11
11
|
import { Account, BaseAccount } from "../db/schema/account.mjs";
|
|
12
|
-
import "../db/index.mjs";
|
|
13
12
|
import { AuthContext, GenericEndpointContext } from "./context.mjs";
|
|
14
13
|
import { AuthMiddleware } from "../api/index.mjs";
|
|
15
14
|
import { CookieOptions } from "better-call";
|
|
@@ -17,9 +16,10 @@ import { Database } from "bun:sqlite";
|
|
|
17
16
|
import { DatabaseSync } from "node:sqlite";
|
|
18
17
|
import { D1Database } from "@cloudflare/workers-types";
|
|
19
18
|
import { Dialect, Kysely, MysqlPool, PostgresPool, SqliteDatabase } from "kysely";
|
|
19
|
+
|
|
20
20
|
//#region src/types/init-options.d.ts
|
|
21
21
|
type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
|
|
22
|
-
type Optional<T> = { [P in keyof T]?: T[P] | undefined
|
|
22
|
+
type Optional<T> = { [P in keyof T]?: T[P] | undefined };
|
|
23
23
|
type StoreIdentifierOption = "plain" | "hashed" | {
|
|
24
24
|
hash: (identifier: string) => Promise<string>;
|
|
25
25
|
};
|
|
@@ -53,24 +53,18 @@ type ValidateUserInfoAction = "create-user" | "link-account" | "sign-in";
|
|
|
53
53
|
type ValidateUserInfoMethod = "oauth" | "sso-oidc" | "sso-saml" | "email-password" | "magic-link" | "email-otp" | "anonymous" | "siwe" | "phone-number" | "admin" | (string & {});
|
|
54
54
|
/** OAuth-specific provisioning context; present only when `method` is `"oauth"`. */
|
|
55
55
|
type ValidateUserInfoOAuthInfo = {
|
|
56
|
-
/** The social or generic OAuth provider id (e.g. `"google"`). */
|
|
57
|
-
providerId: string;
|
|
58
|
-
/** The raw provider profile (userinfo or id-token claims), unmapped. */
|
|
56
|
+
/** The social or generic OAuth provider id (e.g. `"google"`). */providerId: string; /** The raw provider profile (userinfo or id-token claims), unmapped. */
|
|
59
57
|
profile?: Record<string, unknown> | undefined;
|
|
60
58
|
};
|
|
61
59
|
/** SSO-specific provisioning context; present for OIDC and SAML SSO methods. */
|
|
62
60
|
type ValidateUserInfoSSOInfo = {
|
|
63
|
-
/** The configured SSO provider id. */
|
|
64
|
-
providerId: string;
|
|
65
|
-
/** The raw OIDC claims or SAML assertion attributes, unmapped. */
|
|
61
|
+
/** The configured SSO provider id. */providerId: string; /** The raw OIDC claims or SAML assertion attributes, unmapped. */
|
|
66
62
|
profile?: Record<string, unknown> | undefined;
|
|
67
63
|
};
|
|
68
64
|
/** Provisioning origin passed to `createUser`; the creation seam adds `action: "create-user"` to build {@link ValidateUserInfoSource}. */
|
|
69
65
|
type UserProvisioningSource = {
|
|
70
|
-
method: ValidateUserInfoMethod;
|
|
71
|
-
/** Provider id and raw profile; present iff `method` is `"
|
|
72
|
-
oauth?: ValidateUserInfoOAuthInfo | undefined;
|
|
73
|
-
/** Provider id and raw profile; present iff `method` is `"sso-oidc"` or `"sso-saml"`. */
|
|
66
|
+
method: ValidateUserInfoMethod; /** Provider id and raw profile; present iff `method` is `"oauth"`. */
|
|
67
|
+
oauth?: ValidateUserInfoOAuthInfo | undefined; /** Provider id and raw profile; present iff `method` is `"sso-oidc"` or `"sso-saml"`. */
|
|
74
68
|
sso?: ValidateUserInfoSSOInfo | undefined;
|
|
75
69
|
};
|
|
76
70
|
/**
|
|
@@ -93,8 +87,7 @@ type ValidateUserInfoSource = UserProvisioningSource & {
|
|
|
93
87
|
action: ValidateUserInfoAction;
|
|
94
88
|
};
|
|
95
89
|
type ValidateUserInfoResult = {
|
|
96
|
-
/** A short, machine-readable rejection code, surfaced to the client. */
|
|
97
|
-
error: string;
|
|
90
|
+
/** A short, machine-readable rejection code, surfaced to the client. */error: string;
|
|
98
91
|
/**
|
|
99
92
|
* A human-readable reason, surfaced to the client. Do not put sensitive
|
|
100
93
|
* details here.
|
|
@@ -109,7 +102,8 @@ type DynamicBaseURLConfig = {
|
|
|
109
102
|
/**
|
|
110
103
|
* List of allowed hostnames. Supports wildcard patterns.
|
|
111
104
|
*
|
|
112
|
-
*
|
|
105
|
+
* `x-forwarded-host` is used only when `advanced.trustedProxyHeaders` is
|
|
106
|
+
* enabled.
|
|
113
107
|
* Uses the same wildcard matching as `trustedOrigins`.
|
|
114
108
|
*
|
|
115
109
|
* @example
|
|
@@ -123,8 +117,9 @@ type DynamicBaseURLConfig = {
|
|
|
123
117
|
*/
|
|
124
118
|
allowedHosts: string[];
|
|
125
119
|
/**
|
|
126
|
-
* Fallback URL
|
|
127
|
-
* If
|
|
120
|
+
* Fallback URL used when no allowed request host can be resolved.
|
|
121
|
+
* If omitted, Better Auth throws when the request host is unavailable or not
|
|
122
|
+
* allowed.
|
|
128
123
|
*
|
|
129
124
|
* @example "https://myapp.com"
|
|
130
125
|
*/
|
|
@@ -133,7 +128,7 @@ type DynamicBaseURLConfig = {
|
|
|
133
128
|
* Protocol to use when constructing the URL.
|
|
134
129
|
* - `"https"`: Always use HTTPS (recommended for production)
|
|
135
130
|
* - `"http"`: Always use HTTP (for local development)
|
|
136
|
-
* - `"auto"`:
|
|
131
|
+
* - `"auto"`: Trust `x-forwarded-proto` only when proxy headers are enabled
|
|
137
132
|
*
|
|
138
133
|
* @default "auto"
|
|
139
134
|
*/
|
|
@@ -197,7 +192,7 @@ type BetterAuthDBOptions<ModelName extends string, Keys extends string = string>
|
|
|
197
192
|
/**
|
|
198
193
|
* Additional fields for the model
|
|
199
194
|
*/
|
|
200
|
-
additionalFields?: { [Key in Exclude<string, Keys | "id">]: DBFieldAttribute
|
|
195
|
+
additionalFields?: { [Key in Exclude<string, Keys | "id">]: DBFieldAttribute };
|
|
201
196
|
};
|
|
202
197
|
type BetterAuthRateLimitOptions = Optional<BetterAuthRateLimitRule> & Omit<BetterAuthDBOptions<"rateLimit", keyof BaseRateLimit>, "additionalFields"> & {
|
|
203
198
|
/**
|
|
@@ -396,7 +391,7 @@ type BetterAuthAdvancedOptions = {
|
|
|
396
391
|
/**
|
|
397
392
|
* Trusted proxy headers
|
|
398
393
|
*
|
|
399
|
-
|
|
394
|
+
* - `x-forwarded-host`
|
|
400
395
|
* - `x-forwarded-proto`
|
|
401
396
|
*
|
|
402
397
|
* If set to `true` and no `baseURL` option is provided, we will use the headers to infer the
|
|
@@ -786,18 +781,15 @@ type BetterAuthOptions = {
|
|
|
786
781
|
* ```
|
|
787
782
|
*/
|
|
788
783
|
customSyntheticUser?: (params: {
|
|
789
|
-
/** Core user fields: name, email, emailVerified, image, createdAt, updatedAt */
|
|
790
|
-
coreFields: {
|
|
784
|
+
/** Core user fields: name, email, emailVerified, image, createdAt, updatedAt */coreFields: {
|
|
791
785
|
name: string;
|
|
792
786
|
email: string;
|
|
793
787
|
emailVerified: boolean;
|
|
794
788
|
image: string | null;
|
|
795
789
|
createdAt: Date;
|
|
796
790
|
updatedAt: Date;
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
additionalFields: Record<string, unknown>;
|
|
800
|
-
/** Generated user ID */
|
|
791
|
+
}; /** Processed additional fields from options.user.additionalFields (with defaults applied) */
|
|
792
|
+
additionalFields: Record<string, unknown>; /** Generated user ID */
|
|
801
793
|
id: string;
|
|
802
794
|
}) => Record<string, unknown>;
|
|
803
795
|
} | undefined;
|
|
@@ -2,6 +2,7 @@ import { LiteralString } from "./helper.mjs";
|
|
|
2
2
|
import { BetterAuthOptions } from "./init-options.mjs";
|
|
3
3
|
import { BetterFetch, BetterFetchOption, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
4
4
|
import { Atom, WritableAtom } from "nanostores";
|
|
5
|
+
|
|
5
6
|
//#region src/types/plugin-client.d.ts
|
|
6
7
|
type InferableServerPlugin = {
|
|
7
8
|
id?: LiteralString | undefined;
|
|
@@ -88,6 +89,7 @@ interface BetterAuthClientPlugin {
|
|
|
88
89
|
/**
|
|
89
90
|
* better-auth client options
|
|
90
91
|
*/
|
|
92
|
+
|
|
91
93
|
options: BetterAuthClientOptions | undefined) => Record<string, any>;
|
|
92
94
|
/**
|
|
93
95
|
* State atoms that'll be resolved by each framework
|
|
@@ -118,4 +120,4 @@ interface BetterAuthClientPlugin {
|
|
|
118
120
|
}>;
|
|
119
121
|
}
|
|
120
122
|
//#endregion
|
|
121
|
-
export { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore
|
|
123
|
+
export { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore };
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -2,13 +2,13 @@ import { BetterAuthPluginDBSchema } from "../db/plugin.mjs";
|
|
|
2
2
|
import { Awaitable, LiteralString } from "./helper.mjs";
|
|
3
3
|
import { RawError } from "../utils/error-codes.mjs";
|
|
4
4
|
import { BetterAuthOptions } from "./init-options.mjs";
|
|
5
|
-
import "../db/index.mjs";
|
|
6
5
|
import { AuthContext } from "./context.mjs";
|
|
7
6
|
import { AuthMiddleware } from "../api/index.mjs";
|
|
8
7
|
import { Endpoint, EndpointContext, InputContext, Middleware } from "better-call";
|
|
9
8
|
import { Migration } from "kysely";
|
|
9
|
+
|
|
10
10
|
//#region src/types/plugin.d.ts
|
|
11
|
-
type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]
|
|
11
|
+
type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
12
12
|
type HookEndpointContext = Partial<EndpointContext<string, any> & Omit<InputContext<string, any>, "method">> & {
|
|
13
13
|
path?: string;
|
|
14
14
|
context: AuthContext & {
|
package/dist/utils/async.d.mts
CHANGED
package/dist/utils/db.d.mts
CHANGED
package/dist/utils/email.d.mts
CHANGED
|
@@ -14,6 +14,9 @@ interface PlaceholderEmailOptions {
|
|
|
14
14
|
*
|
|
15
15
|
* @throws TypeError if the generated email is invalid.
|
|
16
16
|
*/
|
|
17
|
-
declare function createPlaceholderEmail({
|
|
17
|
+
declare function createPlaceholderEmail({
|
|
18
|
+
identifier,
|
|
19
|
+
namespace
|
|
20
|
+
}: PlaceholderEmailOptions): string;
|
|
18
21
|
//#endregion
|
|
19
22
|
export { PlaceholderEmailOptions, createPlaceholderEmail };
|
|
@@ -3,11 +3,11 @@ type UpperLetter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "
|
|
|
3
3
|
type SpecialCharacter = "_";
|
|
4
4
|
type IsValidUpperSnakeCase<S extends string> = S extends `${infer F}${infer R}` ? F extends UpperLetter | SpecialCharacter ? IsValidUpperSnakeCase<R> : false : true;
|
|
5
5
|
type InvalidKeyError<K extends string> = `Invalid error code key: "${K}" - must only contain uppercase letters (A-Z) and underscores (_)`;
|
|
6
|
-
type ValidateErrorCodes<T> = { [K in keyof T]: K extends string ? IsValidUpperSnakeCase<K> extends false ? InvalidKeyError<K> : T[K] : T[K]
|
|
6
|
+
type ValidateErrorCodes<T> = { [K in keyof T]: K extends string ? IsValidUpperSnakeCase<K> extends false ? InvalidKeyError<K> : T[K] : T[K] };
|
|
7
7
|
type RawError<K extends string = string> = {
|
|
8
8
|
readonly code: K;
|
|
9
9
|
message: string;
|
|
10
10
|
};
|
|
11
|
-
declare function defineErrorCodes<const T extends Record<string, string>, R extends { [K in keyof T & string]: RawError<K
|
|
11
|
+
declare function defineErrorCodes<const T extends Record<string, string>, R extends { [K in keyof T & string]: RawError<K> }>(codes: ValidateErrorCodes<T>): R;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { RawError, defineErrorCodes };
|