@better-auth/core 1.5.0-beta.4 → 1.5.0-beta.5
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/.turbo/turbo-build.log +170 -37
- package/dist/api/index.d.mts +188 -1
- package/dist/api/index.mjs +2 -1
- package/dist/context/endpoint-context.d.mts +19 -0
- package/dist/context/endpoint-context.mjs +27 -0
- package/dist/context/index.d.mts +3 -52
- package/dist/context/index.mjs +22 -1
- package/dist/context/request-state.d.mts +27 -0
- package/dist/context/request-state.mjs +45 -0
- package/dist/context/transaction.d.mts +16 -0
- package/dist/context/transaction.mjs +48 -0
- package/dist/db/adapter/factory.d.mts +27 -0
- package/dist/db/adapter/factory.mjs +738 -0
- package/dist/db/adapter/get-default-field-name.d.mts +18 -0
- package/dist/db/adapter/get-default-field-name.mjs +38 -0
- package/dist/db/adapter/get-default-model-name.d.mts +12 -0
- package/dist/db/adapter/get-default-model-name.mjs +32 -0
- package/dist/db/adapter/get-field-attributes.d.mts +29 -0
- package/dist/db/adapter/get-field-attributes.mjs +39 -0
- package/dist/db/adapter/get-field-name.d.mts +18 -0
- package/dist/db/adapter/get-field-name.mjs +33 -0
- package/dist/db/adapter/get-id-field.d.mts +39 -0
- package/dist/db/adapter/get-id-field.mjs +67 -0
- package/dist/db/adapter/get-model-name.d.mts +12 -0
- package/dist/db/adapter/get-model-name.mjs +23 -0
- package/dist/db/adapter/index.d.mts +513 -1
- package/dist/db/adapter/index.mjs +8 -970
- package/dist/db/adapter/types.d.mts +139 -0
- package/dist/db/adapter/utils.d.mts +7 -0
- package/dist/db/adapter/utils.mjs +38 -0
- package/dist/db/get-tables.d.mts +8 -0
- package/dist/{get-tables-CMc_Emww.mjs → db/get-tables.mjs} +1 -1
- package/dist/db/index.d.mts +10 -2
- package/dist/db/index.mjs +7 -60
- package/dist/db/plugin.d.mts +12 -0
- package/dist/db/schema/account.d.mts +26 -0
- package/dist/db/schema/account.mjs +19 -0
- package/dist/db/schema/rate-limit.d.mts +14 -0
- package/dist/db/schema/rate-limit.mjs +11 -0
- package/dist/db/schema/session.d.mts +21 -0
- package/dist/db/schema/session.mjs +14 -0
- package/dist/db/schema/shared.d.mts +10 -0
- package/dist/db/schema/shared.mjs +11 -0
- package/dist/db/schema/user.d.mts +20 -0
- package/dist/db/schema/user.mjs +13 -0
- package/dist/db/schema/verification.d.mts +19 -0
- package/dist/db/schema/verification.mjs +12 -0
- package/dist/db/type.d.mts +143 -0
- package/dist/env/color-depth.d.mts +4 -0
- package/dist/env/color-depth.mjs +88 -0
- package/dist/env/env-impl.d.mts +32 -0
- package/dist/env/env-impl.mjs +82 -0
- package/dist/env/index.d.mts +4 -2
- package/dist/env/index.mjs +3 -1
- package/dist/{index-BRBu0-5h.d.mts → env/logger.d.mts} +1 -35
- package/dist/env/logger.mjs +81 -0
- package/dist/error/codes.d.mts +186 -0
- package/dist/{error-GNtLPYaS.mjs → error/codes.mjs} +2 -29
- package/dist/error/index.d.mts +1 -185
- package/dist/error/index.mjs +28 -3
- package/dist/index.d.mts +7 -1
- package/dist/oauth2/client-credentials-token.d.mts +36 -0
- package/dist/oauth2/client-credentials-token.mjs +54 -0
- package/dist/oauth2/create-authorization-url.d.mts +45 -0
- package/dist/oauth2/create-authorization-url.mjs +42 -0
- package/dist/oauth2/index.d.mts +8 -2
- package/dist/oauth2/index.mjs +6 -2
- package/dist/oauth2/oauth-provider.d.mts +194 -0
- package/dist/oauth2/refresh-access-token.d.mts +36 -0
- package/dist/oauth2/refresh-access-token.mjs +58 -0
- package/dist/oauth2/utils.d.mts +7 -0
- package/dist/oauth2/utils.mjs +27 -0
- package/dist/oauth2/validate-authorization-code.d.mts +55 -0
- package/dist/oauth2/validate-authorization-code.mjs +71 -0
- package/dist/oauth2/verify.d.mts +49 -0
- package/dist/oauth2/verify.mjs +95 -0
- package/dist/social-providers/apple.d.mts +119 -0
- package/dist/social-providers/apple.mjs +102 -0
- package/dist/social-providers/atlassian.d.mts +72 -0
- package/dist/social-providers/atlassian.mjs +83 -0
- package/dist/social-providers/cognito.d.mts +87 -0
- package/dist/social-providers/cognito.mjs +165 -0
- package/dist/social-providers/discord.d.mts +126 -0
- package/dist/social-providers/discord.mjs +64 -0
- package/dist/social-providers/dropbox.d.mts +71 -0
- package/dist/social-providers/dropbox.mjs +75 -0
- package/dist/social-providers/facebook.d.mts +81 -0
- package/dist/social-providers/facebook.mjs +120 -0
- package/dist/social-providers/figma.d.mts +63 -0
- package/dist/social-providers/figma.mjs +84 -0
- package/dist/social-providers/github.d.mts +104 -0
- package/dist/social-providers/github.mjs +80 -0
- package/dist/social-providers/gitlab.d.mts +125 -0
- package/dist/social-providers/gitlab.mjs +82 -0
- package/dist/social-providers/google.d.mts +99 -0
- package/dist/social-providers/google.mjs +108 -0
- package/dist/social-providers/huggingface.d.mts +85 -0
- package/dist/social-providers/huggingface.mjs +75 -0
- package/dist/social-providers/index.d.mts +1723 -1
- package/dist/social-providers/index.mjs +33 -2569
- package/dist/social-providers/kakao.d.mts +163 -0
- package/dist/social-providers/kakao.mjs +72 -0
- package/dist/social-providers/kick.d.mts +75 -0
- package/dist/social-providers/kick.mjs +71 -0
- package/dist/social-providers/line.d.mts +107 -0
- package/dist/social-providers/line.mjs +113 -0
- package/dist/social-providers/linear.d.mts +70 -0
- package/dist/social-providers/linear.mjs +88 -0
- package/dist/social-providers/linkedin.d.mts +69 -0
- package/dist/social-providers/linkedin.mjs +76 -0
- package/dist/social-providers/microsoft-entra-id.d.mts +174 -0
- package/dist/social-providers/microsoft-entra-id.mjs +106 -0
- package/dist/social-providers/naver.d.mts +104 -0
- package/dist/social-providers/naver.mjs +67 -0
- package/dist/social-providers/notion.d.mts +66 -0
- package/dist/social-providers/notion.mjs +75 -0
- package/dist/social-providers/paybin.d.mts +73 -0
- package/dist/social-providers/paybin.mjs +85 -0
- package/dist/social-providers/paypal.d.mts +131 -0
- package/dist/social-providers/paypal.mjs +144 -0
- package/dist/social-providers/polar.d.mts +76 -0
- package/dist/social-providers/polar.mjs +73 -0
- package/dist/social-providers/reddit.d.mts +64 -0
- package/dist/social-providers/reddit.mjs +83 -0
- package/dist/social-providers/roblox.d.mts +72 -0
- package/dist/social-providers/roblox.mjs +59 -0
- package/dist/social-providers/salesforce.d.mts +81 -0
- package/dist/social-providers/salesforce.mjs +91 -0
- package/dist/social-providers/slack.d.mts +85 -0
- package/dist/social-providers/slack.mjs +68 -0
- package/dist/social-providers/spotify.d.mts +65 -0
- package/dist/social-providers/spotify.mjs +71 -0
- package/dist/social-providers/tiktok.d.mts +171 -0
- package/dist/social-providers/tiktok.mjs +62 -0
- package/dist/social-providers/twitch.d.mts +81 -0
- package/dist/social-providers/twitch.mjs +78 -0
- package/dist/social-providers/twitter.d.mts +140 -0
- package/dist/social-providers/twitter.mjs +87 -0
- package/dist/social-providers/vercel.d.mts +64 -0
- package/dist/social-providers/vercel.mjs +61 -0
- package/dist/social-providers/vk.d.mts +72 -0
- package/dist/social-providers/vk.mjs +83 -0
- package/dist/social-providers/zoom.d.mts +173 -0
- package/dist/social-providers/zoom.mjs +72 -0
- package/dist/types/context.d.mts +246 -0
- package/dist/types/cookie.d.mts +23 -0
- package/dist/types/helper.d.mts +8 -0
- package/dist/types/index.d.mts +8 -0
- package/dist/types/init-options.d.mts +1266 -0
- package/dist/types/plugin-client.d.mts +110 -0
- package/dist/types/plugin.d.mts +124 -0
- package/dist/utils/deprecate.d.mts +10 -0
- package/dist/utils/deprecate.mjs +17 -0
- package/dist/utils/{index.d.mts → error-codes.d.mts} +1 -19
- package/dist/utils/error-codes.mjs +11 -0
- package/dist/utils/id.d.mts +4 -0
- package/dist/utils/id.mjs +9 -0
- package/dist/utils/json.d.mts +4 -0
- package/dist/utils/json.mjs +25 -0
- package/dist/utils/string.d.mts +4 -0
- package/dist/utils/string.mjs +7 -0
- package/package.json +9 -6
- package/src/db/adapter/get-id-field.ts +1 -1
- package/src/error/codes.ts +1 -1
- package/src/oauth2/create-authorization-url.ts +1 -1
- package/src/oauth2/oauth-provider.ts +6 -0
- package/tsdown.config.ts +3 -1
- package/dist/context-BBNwughv.mjs +0 -133
- package/dist/env-DbssmzoK.mjs +0 -245
- package/dist/index-B5x_W0dM.d.mts +0 -8054
- package/dist/oauth2-BjWM15hm.mjs +0 -326
- package/dist/utils/index.mjs +0 -4
- package/dist/utils-puAL36Bz.mjs +0 -63
- package/src/utils/index.ts +0 -5
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { BetterAuthDBSchema, ModelNames, SecondaryStorage } from "../db/type.mjs";
|
|
2
|
+
import { Account } from "../db/schema/account.mjs";
|
|
3
|
+
import { Session } from "../db/schema/session.mjs";
|
|
4
|
+
import { User } from "../db/schema/user.mjs";
|
|
5
|
+
import { Verification } from "../db/schema/verification.mjs";
|
|
6
|
+
import "../db/index.mjs";
|
|
7
|
+
import { LiteralString } from "./helper.mjs";
|
|
8
|
+
import { DBAdapter, Where } from "../db/adapter/index.mjs";
|
|
9
|
+
import { createLogger } from "../env/logger.mjs";
|
|
10
|
+
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
11
|
+
import "../oauth2/index.mjs";
|
|
12
|
+
import { BetterAuthCookies } from "./cookie.mjs";
|
|
13
|
+
import { BetterAuthPlugin } from "./plugin.mjs";
|
|
14
|
+
import { BetterAuthOptions, BetterAuthRateLimitOptions } from "./init-options.mjs";
|
|
15
|
+
import { CookieOptions, EndpointContext } from "better-call";
|
|
16
|
+
|
|
17
|
+
//#region src/types/context.d.ts
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Mutators are defined in each plugin
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* declare module "@better-auth/core" {
|
|
25
|
+
* interface BetterAuthPluginRegistry<Auth, Context> {
|
|
26
|
+
* 'jwt': {
|
|
27
|
+
* creator: typeof jwt
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
interface BetterAuthPluginRegistry<Auth, Context> {}
|
|
34
|
+
type BetterAuthPluginRegistryIdentifier = keyof BetterAuthPluginRegistry<unknown, unknown>;
|
|
35
|
+
type GenericEndpointContext<Options extends BetterAuthOptions = BetterAuthOptions> = EndpointContext<string, any> & {
|
|
36
|
+
context: AuthContext<Options>;
|
|
37
|
+
};
|
|
38
|
+
interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions> {
|
|
39
|
+
createOAuthUser(user: Omit<User, "id" | "createdAt" | "updatedAt">, account: Omit<Account, "userId" | "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<{
|
|
40
|
+
user: User;
|
|
41
|
+
account: Account;
|
|
42
|
+
}>;
|
|
43
|
+
createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>): Promise<T & User>;
|
|
44
|
+
createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
|
|
45
|
+
listSessions(userId: string): Promise<Session[]>;
|
|
46
|
+
listUsers(limit?: number | undefined, offset?: number | undefined, sortBy?: {
|
|
47
|
+
field: string;
|
|
48
|
+
direction: "asc" | "desc";
|
|
49
|
+
} | undefined, where?: Where[] | undefined): Promise<User[]>;
|
|
50
|
+
countTotalUsers(where?: Where[] | undefined): Promise<number>;
|
|
51
|
+
deleteUser(userId: string): Promise<void>;
|
|
52
|
+
createSession(userId: string, dontRememberMe?: boolean | undefined, override?: (Partial<Session> & Record<string, any>) | undefined, overrideAll?: boolean | undefined): Promise<Session>;
|
|
53
|
+
findSession(token: string): Promise<{
|
|
54
|
+
session: Session & Record<string, any>;
|
|
55
|
+
user: User & Record<string, any>;
|
|
56
|
+
} | null>;
|
|
57
|
+
findSessions(sessionTokens: string[]): Promise<{
|
|
58
|
+
session: Session;
|
|
59
|
+
user: User;
|
|
60
|
+
}[]>;
|
|
61
|
+
updateSession(sessionToken: string, session: Partial<Session> & Record<string, any>): Promise<Session | null>;
|
|
62
|
+
deleteSession(token: string): Promise<void>;
|
|
63
|
+
deleteAccounts(userId: string): Promise<void>;
|
|
64
|
+
deleteAccount(accountId: string): Promise<void>;
|
|
65
|
+
deleteSessions(userIdOrSessionTokens: string | string[]): Promise<void>;
|
|
66
|
+
findOAuthUser(email: string, accountId: string, providerId: string): Promise<{
|
|
67
|
+
user: User;
|
|
68
|
+
accounts: Account[];
|
|
69
|
+
} | null>;
|
|
70
|
+
findUserByEmail(email: string, options?: {
|
|
71
|
+
includeAccounts: boolean;
|
|
72
|
+
} | undefined): Promise<{
|
|
73
|
+
user: User;
|
|
74
|
+
accounts: Account[];
|
|
75
|
+
} | null>;
|
|
76
|
+
findUserById(userId: string): Promise<User | null>;
|
|
77
|
+
linkAccount(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<Account>;
|
|
78
|
+
updateUser<T extends Record<string, any>>(userId: string, data: Partial<User> & Record<string, any>): Promise<User & T>;
|
|
79
|
+
updateUserByEmail<T extends Record<string, any>>(email: string, data: Partial<User & Record<string, any>>): Promise<User & T>;
|
|
80
|
+
updatePassword(userId: string, password: string): Promise<void>;
|
|
81
|
+
findAccounts(userId: string): Promise<Account[]>;
|
|
82
|
+
findAccount(accountId: string): Promise<Account | null>;
|
|
83
|
+
findAccountByProviderId(accountId: string, providerId: string): Promise<Account | null>;
|
|
84
|
+
findAccountByUserId(userId: string): Promise<Account[]>;
|
|
85
|
+
updateAccount(id: string, data: Partial<Account>): Promise<Account>;
|
|
86
|
+
createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
|
|
87
|
+
findVerificationValue(identifier: string): Promise<Verification | null>;
|
|
88
|
+
deleteVerificationValue(id: string): Promise<void>;
|
|
89
|
+
deleteVerificationByIdentifier(identifier: string): Promise<void>;
|
|
90
|
+
updateVerificationValue(id: string, data: Partial<Verification>): Promise<Verification>;
|
|
91
|
+
}
|
|
92
|
+
type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => {
|
|
93
|
+
name: string;
|
|
94
|
+
attributes: CookieOptions;
|
|
95
|
+
};
|
|
96
|
+
type CheckPasswordFn<Options extends BetterAuthOptions = BetterAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
|
|
97
|
+
type PluginContext = {
|
|
98
|
+
getPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString>(pluginId: ID) => (ID extends BetterAuthPluginRegistryIdentifier ? ReturnType<BetterAuthPluginRegistry<unknown, unknown>[ID]["creator"]> : BetterAuthPlugin) | null;
|
|
99
|
+
/**
|
|
100
|
+
* Checks if a plugin is enabled by its ID.
|
|
101
|
+
*
|
|
102
|
+
* @param pluginId - The ID of the plugin to check
|
|
103
|
+
* @returns `true` if the plugin is enabled, `false` otherwise
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* if (ctx.context.hasPlugin("organization")) {
|
|
108
|
+
* // organization plugin is enabled
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
hasPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString>(pluginId: ID) => boolean;
|
|
113
|
+
};
|
|
114
|
+
type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = PluginContext & {
|
|
115
|
+
options: Options;
|
|
116
|
+
appName: string;
|
|
117
|
+
baseURL: string;
|
|
118
|
+
trustedOrigins: string[];
|
|
119
|
+
/**
|
|
120
|
+
* Verifies whether url is a trusted origin according to the "trustedOrigins" configuration
|
|
121
|
+
* @param url The url to verify against the "trustedOrigins" configuration
|
|
122
|
+
* @param settings Specify supported pattern matching settings
|
|
123
|
+
* @returns {boolean} true if the URL matches the origin pattern, false otherwise.
|
|
124
|
+
*/
|
|
125
|
+
isTrustedOrigin: (url: string, settings?: {
|
|
126
|
+
allowRelativePaths: boolean;
|
|
127
|
+
}) => boolean;
|
|
128
|
+
oauthConfig: {
|
|
129
|
+
/**
|
|
130
|
+
* This is dangerous and should only be used in dev or staging environments.
|
|
131
|
+
*/
|
|
132
|
+
skipStateCookieCheck?: boolean | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Strategy for storing OAuth state
|
|
135
|
+
*
|
|
136
|
+
* - "cookie": Store state in an encrypted cookie (stateless)
|
|
137
|
+
* - "database": Store state in the database
|
|
138
|
+
*
|
|
139
|
+
* @default "cookie"
|
|
140
|
+
*/
|
|
141
|
+
storeStateStrategy: "database" | "cookie";
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* New session that will be set after the request
|
|
145
|
+
* meaning: there is a `set-cookie` header that will set
|
|
146
|
+
* the session cookie. This is the fetched session. And it's set
|
|
147
|
+
* by `setNewSession` method.
|
|
148
|
+
*/
|
|
149
|
+
newSession: {
|
|
150
|
+
session: Session & Record<string, any>;
|
|
151
|
+
user: User & Record<string, any>;
|
|
152
|
+
} | null;
|
|
153
|
+
session: {
|
|
154
|
+
session: Session & Record<string, any>;
|
|
155
|
+
user: User & Record<string, any>;
|
|
156
|
+
} | null;
|
|
157
|
+
setNewSession: (session: {
|
|
158
|
+
session: Session & Record<string, any>;
|
|
159
|
+
user: User & Record<string, any>;
|
|
160
|
+
} | null) => void;
|
|
161
|
+
socialProviders: OAuthProvider[];
|
|
162
|
+
authCookies: BetterAuthCookies;
|
|
163
|
+
logger: ReturnType<typeof createLogger>;
|
|
164
|
+
rateLimit: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
window: number;
|
|
167
|
+
max: number;
|
|
168
|
+
storage: "memory" | "database" | "secondary-storage";
|
|
169
|
+
} & BetterAuthRateLimitOptions;
|
|
170
|
+
adapter: DBAdapter<Options>;
|
|
171
|
+
internalAdapter: InternalAdapter<Options>;
|
|
172
|
+
createAuthCookie: CreateCookieGetterFn;
|
|
173
|
+
secret: string;
|
|
174
|
+
sessionConfig: {
|
|
175
|
+
updateAge: number;
|
|
176
|
+
expiresIn: number;
|
|
177
|
+
freshAge: number;
|
|
178
|
+
cookieRefreshCache: false | {
|
|
179
|
+
enabled: true;
|
|
180
|
+
updateAge: number;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
generateId: (options: {
|
|
184
|
+
model: ModelNames;
|
|
185
|
+
size?: number | undefined;
|
|
186
|
+
}) => string | false;
|
|
187
|
+
secondaryStorage: SecondaryStorage | undefined;
|
|
188
|
+
password: {
|
|
189
|
+
hash: (password: string) => Promise<string>;
|
|
190
|
+
verify: (data: {
|
|
191
|
+
password: string;
|
|
192
|
+
hash: string;
|
|
193
|
+
}) => Promise<boolean>;
|
|
194
|
+
config: {
|
|
195
|
+
minPasswordLength: number;
|
|
196
|
+
maxPasswordLength: number;
|
|
197
|
+
};
|
|
198
|
+
checkPassword: CheckPasswordFn<Options>;
|
|
199
|
+
};
|
|
200
|
+
tables: BetterAuthDBSchema;
|
|
201
|
+
runMigrations: () => Promise<void>;
|
|
202
|
+
publishTelemetry: (event: {
|
|
203
|
+
type: string;
|
|
204
|
+
anonymousId?: string | undefined;
|
|
205
|
+
payload: Record<string, any>;
|
|
206
|
+
}) => Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* This skips the origin check for all requests.
|
|
209
|
+
*
|
|
210
|
+
* set to true by default for `test` environments and `false`
|
|
211
|
+
* for other environments.
|
|
212
|
+
*
|
|
213
|
+
* It's inferred from the `options.advanced?.disableCSRFCheck`
|
|
214
|
+
* option or `options.advanced?.disableOriginCheck` option.
|
|
215
|
+
*
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
skipOriginCheck: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* This skips the CSRF check for all requests.
|
|
221
|
+
*
|
|
222
|
+
* This is inferred from the `options.advanced?.
|
|
223
|
+
* disableCSRFCheck` option.
|
|
224
|
+
*
|
|
225
|
+
* @default false
|
|
226
|
+
*/
|
|
227
|
+
skipCSRFCheck: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Background task handler for deferred operations.
|
|
230
|
+
*
|
|
231
|
+
* This is inferred from the `options.advanced?.backgroundTasks?.handler` option.
|
|
232
|
+
* Defaults to a no-op that just runs the promise.
|
|
233
|
+
*/
|
|
234
|
+
runInBackground: (promise: Promise<void>) => void;
|
|
235
|
+
/**
|
|
236
|
+
* Runs a task in the background if `runInBackground` is configured,
|
|
237
|
+
* otherwise awaits the task directly.
|
|
238
|
+
*
|
|
239
|
+
* This is useful for operations like sending emails where we want
|
|
240
|
+
* to avoid blocking the response when possible (for timing attack
|
|
241
|
+
* mitigation), but still ensure the operation completes.
|
|
242
|
+
*/
|
|
243
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | Promise<void> | void | unknown) => Promise<unknown>;
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
export { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InternalAdapter, PluginContext };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CookieOptions } from "better-call";
|
|
2
|
+
|
|
3
|
+
//#region src/types/cookie.d.ts
|
|
4
|
+
type BetterAuthCookies = {
|
|
5
|
+
sessionToken: {
|
|
6
|
+
name: string;
|
|
7
|
+
options: CookieOptions;
|
|
8
|
+
};
|
|
9
|
+
sessionData: {
|
|
10
|
+
name: string;
|
|
11
|
+
options: CookieOptions;
|
|
12
|
+
};
|
|
13
|
+
accountData: {
|
|
14
|
+
name: string;
|
|
15
|
+
options: CookieOptions;
|
|
16
|
+
};
|
|
17
|
+
dontRememberToken: {
|
|
18
|
+
name: string;
|
|
19
|
+
options: CookieOptions;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { BetterAuthCookies };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/types/helper.d.ts
|
|
2
|
+
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
3
|
+
type Awaitable<T> = T | Promise<T>;
|
|
4
|
+
type LiteralString = "" | (string & Record<never, never>);
|
|
5
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
6
|
+
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive } from "./helper.mjs";
|
|
2
|
+
import { BetterAuthCookies } from "./cookie.mjs";
|
|
3
|
+
import { BetterAuthPlugin, HookEndpointContext } from "./plugin.mjs";
|
|
4
|
+
import { BetterAuthAdvancedOptions, BetterAuthOptions, BetterAuthRateLimitOptions, GenerateIdFn } from "./init-options.mjs";
|
|
5
|
+
import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InternalAdapter, PluginContext } from "./context.mjs";
|
|
6
|
+
import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore } from "./plugin-client.mjs";
|
|
7
|
+
import { StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
|
|
8
|
+
export { type StandardSchemaV1$1 as StandardSchemaV1 };
|