@better-auth/core 1.6.27 → 1.6.28
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 +26 -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 +1 -1
- package/dist/db/adapter/factory.d.mts +5 -3
- package/dist/db/adapter/factory.mjs +2 -2
- 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/get-tables.d.mts +0 -1
- package/dist/db/plugin.d.mts +2 -1
- 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 +10 -6
- 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/client-credentials-token.d.mts +20 -4
- package/dist/oauth2/create-authorization-url.d.mts +20 -3
- package/dist/oauth2/oauth-provider.d.mts +0 -1
- package/dist/oauth2/refresh-access-token.d.mts +22 -4
- package/dist/oauth2/reject-redirects.mjs +1 -1
- package/dist/oauth2/utils.d.mts +1 -0
- package/dist/oauth2/validate-authorization-code.d.mts +37 -6
- package/dist/oauth2/verify.d.mts +10 -12
- package/dist/oauth2/verify.mjs +2 -2
- package/dist/social-providers/apple.d.mts +11 -4
- package/dist/social-providers/atlassian.d.mts +11 -3
- package/dist/social-providers/cognito.d.mts +11 -4
- package/dist/social-providers/discord.d.mts +9 -3
- package/dist/social-providers/dropbox.d.mts +11 -3
- package/dist/social-providers/facebook.d.mts +10 -4
- package/dist/social-providers/figma.d.mts +11 -3
- package/dist/social-providers/github.d.mts +12 -3
- package/dist/social-providers/gitlab.d.mts +12 -3
- package/dist/social-providers/google.d.mts +19 -5
- package/dist/social-providers/huggingface.d.mts +11 -3
- package/dist/social-providers/index.d.mts +364 -78
- package/dist/social-providers/kakao.d.mts +9 -3
- package/dist/social-providers/kick.d.mts +11 -3
- package/dist/social-providers/line.d.mts +12 -4
- package/dist/social-providers/linear.d.mts +10 -3
- package/dist/social-providers/linkedin.d.mts +10 -3
- package/dist/social-providers/microsoft-entra-id.d.mts +5 -3
- package/dist/social-providers/microsoft-entra-id.mjs +1 -2
- package/dist/social-providers/naver.d.mts +18 -22
- package/dist/social-providers/notion.d.mts +10 -3
- package/dist/social-providers/paybin.d.mts +12 -3
- package/dist/social-providers/paypal.d.mts +9 -4
- package/dist/social-providers/polar.d.mts +11 -3
- package/dist/social-providers/railway.d.mts +11 -3
- package/dist/social-providers/reddit.d.mts +9 -3
- package/dist/social-providers/roblox.d.mts +9 -3
- package/dist/social-providers/salesforce.d.mts +11 -3
- package/dist/social-providers/slack.d.mts +9 -3
- package/dist/social-providers/spotify.d.mts +11 -3
- package/dist/social-providers/tiktok.d.mts +10 -5
- package/dist/social-providers/twitch.d.mts +9 -3
- package/dist/social-providers/twitter.d.mts +16 -25
- package/dist/social-providers/vercel.d.mts +11 -3
- package/dist/social-providers/vk.d.mts +12 -3
- package/dist/social-providers/wechat.d.mts +8 -3
- package/dist/social-providers/zoom.d.mts +14 -5
- package/dist/types/context.d.mts +1 -2
- package/dist/types/cookie.d.mts +1 -0
- package/dist/types/helper.d.mts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/init-options.d.mts +7 -10
- 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 +2 -2
- package/src/db/type.ts +2 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, 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
|
/**
|
|
@@ -103,7 +90,11 @@ declare const twitter: (options: TwitterOption) => {
|
|
|
103
90
|
display?: string | undefined;
|
|
104
91
|
loginHint?: string | undefined;
|
|
105
92
|
}): Promise<URL>;
|
|
106
|
-
validateAuthorizationCode: ({
|
|
93
|
+
validateAuthorizationCode: ({
|
|
94
|
+
code,
|
|
95
|
+
codeVerifier,
|
|
96
|
+
redirectURI
|
|
97
|
+
}: {
|
|
107
98
|
code: string;
|
|
108
99
|
redirectURI: string;
|
|
109
100
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, 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,7 +14,12 @@ interface VercelOptions extends ProviderOptions<VercelProfile> {
|
|
|
15
14
|
declare const vercel: (options: VercelOptions) => {
|
|
16
15
|
id: "vercel";
|
|
17
16
|
name: string;
|
|
18
|
-
createAuthorizationURL({
|
|
17
|
+
createAuthorizationURL({
|
|
18
|
+
state,
|
|
19
|
+
scopes,
|
|
20
|
+
codeVerifier,
|
|
21
|
+
redirectURI
|
|
22
|
+
}: {
|
|
19
23
|
state: string;
|
|
20
24
|
codeVerifier: string;
|
|
21
25
|
scopes?: string[] | undefined;
|
|
@@ -23,7 +27,11 @@ declare const vercel: (options: VercelOptions) => {
|
|
|
23
27
|
display?: string | undefined;
|
|
24
28
|
loginHint?: string | undefined;
|
|
25
29
|
}): Promise<URL>;
|
|
26
|
-
validateAuthorizationCode: ({
|
|
30
|
+
validateAuthorizationCode: ({
|
|
31
|
+
code,
|
|
32
|
+
codeVerifier,
|
|
33
|
+
redirectURI
|
|
34
|
+
}: {
|
|
27
35
|
code: string;
|
|
28
36
|
redirectURI: string;
|
|
29
37
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, 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,7 +20,12 @@ interface VkOption extends ProviderOptions {
|
|
|
21
20
|
declare const vk: (options: VkOption) => {
|
|
22
21
|
id: "vk";
|
|
23
22
|
name: string;
|
|
24
|
-
createAuthorizationURL({
|
|
23
|
+
createAuthorizationURL({
|
|
24
|
+
state,
|
|
25
|
+
scopes,
|
|
26
|
+
codeVerifier,
|
|
27
|
+
redirectURI
|
|
28
|
+
}: {
|
|
25
29
|
state: string;
|
|
26
30
|
codeVerifier: string;
|
|
27
31
|
scopes?: string[] | undefined;
|
|
@@ -29,7 +33,12 @@ declare const vk: (options: VkOption) => {
|
|
|
29
33
|
display?: string | undefined;
|
|
30
34
|
loginHint?: string | undefined;
|
|
31
35
|
}): Promise<URL>;
|
|
32
|
-
validateAuthorizationCode: ({
|
|
36
|
+
validateAuthorizationCode: ({
|
|
37
|
+
code,
|
|
38
|
+
codeVerifier,
|
|
39
|
+
redirectURI,
|
|
40
|
+
deviceId
|
|
41
|
+
}: {
|
|
33
42
|
code: string;
|
|
34
43
|
redirectURI: string;
|
|
35
44
|
codeVerifier?: string | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAuth2Tokens, 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,7 +53,11 @@ interface WeChatOptions extends ProviderOptions<WeChatProfile> {
|
|
|
54
53
|
declare const wechat: (options: WeChatOptions) => {
|
|
55
54
|
id: "wechat";
|
|
56
55
|
name: string;
|
|
57
|
-
createAuthorizationURL({
|
|
56
|
+
createAuthorizationURL({
|
|
57
|
+
state,
|
|
58
|
+
scopes,
|
|
59
|
+
redirectURI
|
|
60
|
+
}: {
|
|
58
61
|
state: string;
|
|
59
62
|
codeVerifier: string;
|
|
60
63
|
scopes?: string[] | undefined;
|
|
@@ -62,7 +65,9 @@ declare const wechat: (options: WeChatOptions) => {
|
|
|
62
65
|
display?: string | undefined;
|
|
63
66
|
loginHint?: string | undefined;
|
|
64
67
|
}): URL;
|
|
65
|
-
validateAuthorizationCode: ({
|
|
68
|
+
validateAuthorizationCode: ({
|
|
69
|
+
code
|
|
70
|
+
}: {
|
|
66
71
|
code: string;
|
|
67
72
|
redirectURI: string;
|
|
68
73
|
codeVerifier?: string | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { OAuth2Tokens, 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,7 +116,11 @@ interface ZoomOptions extends ProviderOptions<ZoomProfile> {
|
|
|
115
116
|
declare const zoom: (userOptions: ZoomOptions) => {
|
|
116
117
|
id: "zoom";
|
|
117
118
|
name: string;
|
|
118
|
-
createAuthorizationURL: ({
|
|
119
|
+
createAuthorizationURL: ({
|
|
120
|
+
state,
|
|
121
|
+
redirectURI,
|
|
122
|
+
codeVerifier
|
|
123
|
+
}: {
|
|
119
124
|
state: string;
|
|
120
125
|
codeVerifier: string;
|
|
121
126
|
scopes?: string[] | undefined;
|
|
@@ -123,7 +128,11 @@ declare const zoom: (userOptions: ZoomOptions) => {
|
|
|
123
128
|
display?: string | undefined;
|
|
124
129
|
loginHint?: string | undefined;
|
|
125
130
|
}) => Promise<URL>;
|
|
126
|
-
validateAuthorizationCode: ({
|
|
131
|
+
validateAuthorizationCode: ({
|
|
132
|
+
code,
|
|
133
|
+
redirectURI,
|
|
134
|
+
codeVerifier
|
|
135
|
+
}: {
|
|
127
136
|
code: string;
|
|
128
137
|
redirectURI: string;
|
|
129
138
|
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 } from "./init-options.mjs";
|
|
10
10
|
import { Account } from "../db/schema/account.mjs";
|
|
11
|
-
import "../db/index.mjs";
|
|
12
11
|
import { BetterAuthCookie, BetterAuthCookies } 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
|
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, 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
|
};
|
|
@@ -130,7 +130,7 @@ type BetterAuthDBOptions<ModelName extends string, Keys extends string = string>
|
|
|
130
130
|
/**
|
|
131
131
|
* Additional fields for the model
|
|
132
132
|
*/
|
|
133
|
-
additionalFields?: { [Key in Exclude<string, Keys | "id">]: DBFieldAttribute
|
|
133
|
+
additionalFields?: { [Key in Exclude<string, Keys | "id">]: DBFieldAttribute };
|
|
134
134
|
};
|
|
135
135
|
type BetterAuthRateLimitOptions = Optional<BetterAuthRateLimitRule> & Omit<BetterAuthDBOptions<"rateLimit", keyof BaseRateLimit>, "additionalFields"> & {
|
|
136
136
|
/**
|
|
@@ -314,7 +314,7 @@ type BetterAuthAdvancedOptions = {
|
|
|
314
314
|
/**
|
|
315
315
|
* Trusted proxy headers
|
|
316
316
|
*
|
|
317
|
-
|
|
317
|
+
* - `x-forwarded-host`
|
|
318
318
|
* - `x-forwarded-proto`
|
|
319
319
|
*
|
|
320
320
|
* If set to `true` and no `baseURL` option is provided, we will use the headers to infer the
|
|
@@ -704,18 +704,15 @@ type BetterAuthOptions = {
|
|
|
704
704
|
* ```
|
|
705
705
|
*/
|
|
706
706
|
customSyntheticUser?: (params: {
|
|
707
|
-
/** Core user fields: name, email, emailVerified, image, createdAt, updatedAt */
|
|
708
|
-
coreFields: {
|
|
707
|
+
/** Core user fields: name, email, emailVerified, image, createdAt, updatedAt */coreFields: {
|
|
709
708
|
name: string;
|
|
710
709
|
email: string;
|
|
711
710
|
emailVerified: boolean;
|
|
712
711
|
image: string | null;
|
|
713
712
|
createdAt: Date;
|
|
714
713
|
updatedAt: Date;
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
additionalFields: Record<string, unknown>;
|
|
718
|
-
/** Generated user ID */
|
|
714
|
+
}; /** Processed additional fields from options.user.additionalFields (with defaults applied) */
|
|
715
|
+
additionalFields: Record<string, unknown>; /** Generated user ID */
|
|
719
716
|
id: string;
|
|
720
717
|
}) => Record<string, unknown>;
|
|
721
718
|
} | 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 };
|
package/dist/utils/host.d.mts
CHANGED
|
@@ -26,33 +26,7 @@
|
|
|
26
26
|
* The semantic kind of a host, derived from RFC 6890 special-purpose registries
|
|
27
27
|
* plus a few domain-name categories (localhost, cloud metadata FQDNs).
|
|
28
28
|
*/
|
|
29
|
-
type HostKind =
|
|
30
|
-
/** IPv4 `127.0.0.0/8` or IPv6 `::1`. */
|
|
31
|
-
"loopback" |
|
|
32
|
-
/** DNS name `localhost` or RFC 6761 `.localhost` TLD. */
|
|
33
|
-
"localhost" |
|
|
34
|
-
/** IPv4 `0.0.0.0` or IPv6 `::` — "this host on this network", not loopback. */
|
|
35
|
-
"unspecified" |
|
|
36
|
-
/** RFC 1918 `10/8`, `172.16/12`, `192.168/16`, or IPv6 ULA `fc00::/7`. */
|
|
37
|
-
"private" |
|
|
38
|
-
/** IPv4 `169.254/16` or IPv6 `fe80::/10`. Includes AWS IMDS `169.254.169.254`. */
|
|
39
|
-
"linkLocal" |
|
|
40
|
-
/** RFC 6598 carrier-grade NAT `100.64.0.0/10`. */
|
|
41
|
-
"sharedAddressSpace" |
|
|
42
|
-
/** RFC 5737 `192.0.2/24`, `198.51.100/24`, `203.0.113/24`, or RFC 3849 `2001:db8::/32`. */
|
|
43
|
-
"documentation" |
|
|
44
|
-
/** RFC 2544 `198.18.0.0/15`. */
|
|
45
|
-
"benchmarking" |
|
|
46
|
-
/** IPv4 `224.0.0.0/4` or IPv6 `ff00::/8`. */
|
|
47
|
-
"multicast" |
|
|
48
|
-
/** IPv4 limited broadcast `255.255.255.255`. */
|
|
49
|
-
"broadcast" |
|
|
50
|
-
/** Other RFC 6890 special-purpose ranges (0/8, 192.0.0/24, 240/4, 2001::/32, etc.). */
|
|
51
|
-
"reserved" |
|
|
52
|
-
/** Cloud metadata service FQDN (e.g. `metadata.google.internal`). */
|
|
53
|
-
"cloudMetadata" |
|
|
54
|
-
/** Any host not matching a special-purpose range above. */
|
|
55
|
-
"public";
|
|
29
|
+
type HostKind = /** IPv4 `127.0.0.0/8` or IPv6 `::1`. */"loopback" /** DNS name `localhost` or RFC 6761 `.localhost` TLD. */ | "localhost" /** IPv4 `0.0.0.0` or IPv6 `::` — "this host on this network", not loopback. */ | "unspecified" /** RFC 1918 `10/8`, `172.16/12`, `192.168/16`, or IPv6 ULA `fc00::/7`. */ | "private" /** IPv4 `169.254/16` or IPv6 `fe80::/10`. Includes AWS IMDS `169.254.169.254`. */ | "linkLocal" /** RFC 6598 carrier-grade NAT `100.64.0.0/10`. */ | "sharedAddressSpace" /** RFC 5737 `192.0.2/24`, `198.51.100/24`, `203.0.113/24`, or RFC 3849 `2001:db8::/32`. */ | "documentation" /** RFC 2544 `198.18.0.0/15`. */ | "benchmarking" /** IPv4 `224.0.0.0/4` or IPv6 `ff00::/8`. */ | "multicast" /** IPv4 limited broadcast `255.255.255.255`. */ | "broadcast" /** Other RFC 6890 special-purpose ranges (0/8, 192.0.0/24, 240/4, 2001::/32, etc.). */ | "reserved" /** Cloud metadata service FQDN (e.g. `metadata.google.internal`). */ | "cloudMetadata" /** Any host not matching a special-purpose range above. */ | "public";
|
|
56
30
|
/**
|
|
57
31
|
* The syntactic form of the input host: an IPv4 literal, an IPv6 literal, or
|
|
58
32
|
* a domain name. IPv4-mapped IPv6 (`::ffff:192.0.2.1`) is reported as `ipv4`
|
package/dist/utils/host.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { isValidIP, normalizeIP } from "./ip.mjs";
|
|
|
9
9
|
* only exists for the FQDN form that a naive server-side fetch might resolve
|
|
10
10
|
* via its own resolver.
|
|
11
11
|
*/
|
|
12
|
-
const CLOUD_METADATA_HOSTS =
|
|
12
|
+
const CLOUD_METADATA_HOSTS = new Set([
|
|
13
13
|
"metadata.google.internal",
|
|
14
14
|
"metadata.goog",
|
|
15
15
|
"metadata",
|
package/dist/utils/ip.d.mts
CHANGED
package/dist/utils/ip.mjs
CHANGED
|
@@ -111,7 +111,7 @@ function ipToBytes(ip) {
|
|
|
111
111
|
const mapped = extractIPv4FromMapped(ip);
|
|
112
112
|
if (mapped) return Uint8Array.from(mapped.split(".").map((octet) => Number(octet)));
|
|
113
113
|
const groups = expandIPv6(ip);
|
|
114
|
-
const bytes =
|
|
114
|
+
const bytes = new Uint8Array(16);
|
|
115
115
|
for (let i = 0; i < 8; i++) {
|
|
116
116
|
const group = Number.parseInt(groups[i] ?? "0", 16);
|
|
117
117
|
bytes[i * 2] = group >> 8 & 255;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.28",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"jose": "^6.1.3",
|
|
163
163
|
"kysely": "^0.28.17 || ^0.29.0",
|
|
164
164
|
"nanostores": "^1.1.1",
|
|
165
|
-
"tsdown": "0.
|
|
165
|
+
"tsdown": "0.21.10"
|
|
166
166
|
},
|
|
167
167
|
"peerDependencies": {
|
|
168
168
|
"@better-auth/utils": "0.4.2",
|
package/src/db/type.ts
CHANGED
|
@@ -251,7 +251,8 @@ export type DBFieldAttributeConfig = {
|
|
|
251
251
|
*/
|
|
252
252
|
bigint?: boolean | undefined;
|
|
253
253
|
/**
|
|
254
|
-
* A
|
|
254
|
+
* A Standard Schema to validate the value. Works with any Standard Schema
|
|
255
|
+
* library, such as Zod, Valibot or ArkType.
|
|
255
256
|
*/
|
|
256
257
|
validator?:
|
|
257
258
|
| {
|