@better-auth/core 1.4.0-beta.6 → 1.4.0-beta.8

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.
Files changed (62) hide show
  1. package/.turbo/turbo-build.log +22 -9
  2. package/build.config.ts +8 -1
  3. package/dist/async_hooks/index.cjs +27 -0
  4. package/dist/async_hooks/index.d.cts +10 -0
  5. package/dist/async_hooks/index.d.mts +10 -0
  6. package/dist/async_hooks/index.d.ts +10 -0
  7. package/dist/async_hooks/index.mjs +25 -0
  8. package/dist/db/adapter/index.cjs +2 -0
  9. package/dist/db/adapter/index.d.cts +23 -0
  10. package/dist/db/adapter/index.d.mts +23 -0
  11. package/dist/db/adapter/index.d.ts +23 -0
  12. package/dist/db/adapter/index.mjs +1 -0
  13. package/dist/db/index.cjs +89 -0
  14. package/dist/db/index.d.cts +102 -105
  15. package/dist/db/index.d.mts +102 -105
  16. package/dist/db/index.d.ts +102 -105
  17. package/dist/db/index.mjs +69 -0
  18. package/dist/env/index.cjs +315 -0
  19. package/dist/env/index.d.cts +85 -0
  20. package/dist/env/index.d.mts +85 -0
  21. package/dist/env/index.d.ts +85 -0
  22. package/dist/env/index.mjs +300 -0
  23. package/dist/index.d.cts +114 -1
  24. package/dist/index.d.mts +114 -1
  25. package/dist/index.d.ts +114 -1
  26. package/dist/oauth2/index.cjs +368 -0
  27. package/dist/oauth2/index.d.cts +277 -0
  28. package/dist/oauth2/index.d.mts +277 -0
  29. package/dist/oauth2/index.d.ts +277 -0
  30. package/dist/oauth2/index.mjs +357 -0
  31. package/dist/shared/core.DeNN5HMO.d.cts +143 -0
  32. package/dist/shared/core.DeNN5HMO.d.mts +143 -0
  33. package/dist/shared/core.DeNN5HMO.d.ts +143 -0
  34. package/package.json +52 -1
  35. package/src/async_hooks/index.ts +43 -0
  36. package/src/db/adapter/index.ts +24 -0
  37. package/src/db/index.ts +13 -0
  38. package/src/db/plugin.ts +11 -0
  39. package/src/db/schema/account.ts +34 -0
  40. package/src/db/schema/rate-limit.ts +21 -0
  41. package/src/db/schema/session.ts +17 -0
  42. package/src/db/schema/shared.ts +7 -0
  43. package/src/db/schema/user.ts +16 -0
  44. package/src/db/schema/verification.ts +15 -0
  45. package/src/db/type.ts +50 -0
  46. package/src/env/color-depth.ts +171 -0
  47. package/src/env/env-impl.ts +123 -0
  48. package/src/env/index.ts +23 -0
  49. package/src/env/logger.test.ts +33 -0
  50. package/src/env/logger.ts +145 -0
  51. package/src/index.ts +3 -1
  52. package/src/oauth2/client-credentials-token.ts +102 -0
  53. package/src/oauth2/create-authorization-url.ts +85 -0
  54. package/src/oauth2/index.ts +22 -0
  55. package/src/oauth2/oauth-provider.ts +194 -0
  56. package/src/oauth2/refresh-access-token.ts +124 -0
  57. package/src/oauth2/utils.ts +36 -0
  58. package/src/oauth2/validate-authorization-code.ts +156 -0
  59. package/src/types/helper.ts +5 -0
  60. package/src/types/index.ts +2 -1
  61. package/src/types/init-options.ts +119 -0
  62. package/tsconfig.json +1 -1
@@ -0,0 +1,300 @@
1
+ const _envShim = /* @__PURE__ */ Object.create(null);
2
+ const _getEnv = (useShim) => globalThis.process?.env || //@ts-expect-error
3
+ globalThis.Deno?.env.toObject() || //@ts-expect-error
4
+ globalThis.__env__ || (useShim ? _envShim : globalThis);
5
+ const env = new Proxy(_envShim, {
6
+ get(_, prop) {
7
+ const env2 = _getEnv();
8
+ return env2[prop] ?? _envShim[prop];
9
+ },
10
+ has(_, prop) {
11
+ const env2 = _getEnv();
12
+ return prop in env2 || prop in _envShim;
13
+ },
14
+ set(_, prop, value) {
15
+ const env2 = _getEnv(true);
16
+ env2[prop] = value;
17
+ return true;
18
+ },
19
+ deleteProperty(_, prop) {
20
+ if (!prop) {
21
+ return false;
22
+ }
23
+ const env2 = _getEnv(true);
24
+ delete env2[prop];
25
+ return true;
26
+ },
27
+ ownKeys() {
28
+ const env2 = _getEnv(true);
29
+ return Object.keys(env2);
30
+ }
31
+ });
32
+ function toBoolean(val) {
33
+ return val ? val !== "false" : false;
34
+ }
35
+ const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
36
+ const isProduction = nodeENV === "production";
37
+ const isDevelopment = nodeENV === "dev" || nodeENV === "development";
38
+ const isTest = () => nodeENV === "test" || toBoolean(env.TEST);
39
+ function getEnvVar(key, fallback) {
40
+ if (typeof process !== "undefined" && process.env) {
41
+ return process.env[key] ?? fallback;
42
+ }
43
+ if (typeof Deno !== "undefined") {
44
+ return Deno.env.get(key) ?? fallback;
45
+ }
46
+ if (typeof Bun !== "undefined") {
47
+ return Bun.env[key] ?? fallback;
48
+ }
49
+ return fallback;
50
+ }
51
+ function getBooleanEnvVar(key, fallback = true) {
52
+ const value = getEnvVar(key);
53
+ if (!value) return fallback;
54
+ return value !== "0" && value.toLowerCase() !== "false" && value !== "";
55
+ }
56
+ const ENV = Object.freeze({
57
+ get BETTER_AUTH_SECRET() {
58
+ return getEnvVar("BETTER_AUTH_SECRET");
59
+ },
60
+ get AUTH_SECRET() {
61
+ return getEnvVar("AUTH_SECRET");
62
+ },
63
+ get BETTER_AUTH_TELEMETRY() {
64
+ return getEnvVar("BETTER_AUTH_TELEMETRY");
65
+ },
66
+ get BETTER_AUTH_TELEMETRY_ID() {
67
+ return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
68
+ },
69
+ get NODE_ENV() {
70
+ return getEnvVar("NODE_ENV", "development");
71
+ },
72
+ get PACKAGE_VERSION() {
73
+ return getEnvVar("PACKAGE_VERSION", "0.0.0");
74
+ },
75
+ get BETTER_AUTH_TELEMETRY_ENDPOINT() {
76
+ return getEnvVar(
77
+ "BETTER_AUTH_TELEMETRY_ENDPOINT",
78
+ "https://telemetry.better-auth.com/v1/track"
79
+ );
80
+ }
81
+ });
82
+
83
+ const COLORS_2 = 1;
84
+ const COLORS_16 = 4;
85
+ const COLORS_256 = 8;
86
+ const COLORS_16m = 24;
87
+ const TERM_ENVS = {
88
+ eterm: COLORS_16,
89
+ cons25: COLORS_16,
90
+ console: COLORS_16,
91
+ cygwin: COLORS_16,
92
+ dtterm: COLORS_16,
93
+ gnome: COLORS_16,
94
+ hurd: COLORS_16,
95
+ jfbterm: COLORS_16,
96
+ konsole: COLORS_16,
97
+ kterm: COLORS_16,
98
+ mlterm: COLORS_16,
99
+ mosh: COLORS_16m,
100
+ putty: COLORS_16,
101
+ st: COLORS_16,
102
+ // http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
103
+ "rxvt-unicode-24bit": COLORS_16m,
104
+ // https://bugs.launchpad.net/terminator/+bug/1030562
105
+ terminator: COLORS_16m,
106
+ "xterm-kitty": COLORS_16m
107
+ };
108
+ const CI_ENVS_MAP = new Map(
109
+ Object.entries({
110
+ APPVEYOR: COLORS_256,
111
+ BUILDKITE: COLORS_256,
112
+ CIRCLECI: COLORS_16m,
113
+ DRONE: COLORS_256,
114
+ GITEA_ACTIONS: COLORS_16m,
115
+ GITHUB_ACTIONS: COLORS_16m,
116
+ GITLAB_CI: COLORS_256,
117
+ TRAVIS: COLORS_256
118
+ })
119
+ );
120
+ const TERM_ENVS_REG_EXP = [
121
+ /ansi/,
122
+ /color/,
123
+ /linux/,
124
+ /direct/,
125
+ /^con[0-9]*x[0-9]/,
126
+ /^rxvt/,
127
+ /^screen/,
128
+ /^xterm/,
129
+ /^vt100/,
130
+ /^vt220/
131
+ ];
132
+ function getColorDepth() {
133
+ if (getEnvVar("FORCE_COLOR") !== void 0) {
134
+ switch (getEnvVar("FORCE_COLOR")) {
135
+ case "":
136
+ case "1":
137
+ case "true":
138
+ return COLORS_16;
139
+ case "2":
140
+ return COLORS_256;
141
+ case "3":
142
+ return COLORS_16m;
143
+ default:
144
+ return COLORS_2;
145
+ }
146
+ }
147
+ if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || // See https://no-color.org/
148
+ getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || // The "dumb" special terminal, as defined by terminfo, doesn't support
149
+ // ANSI color control codes.
150
+ // See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
151
+ getEnvVar("TERM") === "dumb") {
152
+ return COLORS_2;
153
+ }
154
+ if (typeof process !== "undefined" && process.platform === "win32") {
155
+ return COLORS_16m;
156
+ }
157
+ if (getEnvVar("TMUX")) {
158
+ return COLORS_16m;
159
+ }
160
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
161
+ return COLORS_16;
162
+ }
163
+ if ("CI" in env) {
164
+ for (const { 0: envName, 1: colors } of CI_ENVS_MAP) {
165
+ if (envName in env) {
166
+ return colors;
167
+ }
168
+ }
169
+ if (getEnvVar("CI_NAME") === "codeship") {
170
+ return COLORS_256;
171
+ }
172
+ return COLORS_2;
173
+ }
174
+ if ("TEAMCITY_VERSION" in env) {
175
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(
176
+ getEnvVar("TEAMCITY_VERSION")
177
+ ) !== null ? COLORS_16 : COLORS_2;
178
+ }
179
+ switch (getEnvVar("TERM_PROGRAM")) {
180
+ case "iTerm.app":
181
+ if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) {
182
+ return COLORS_256;
183
+ }
184
+ return COLORS_16m;
185
+ case "HyperTerm":
186
+ case "MacTerm":
187
+ return COLORS_16m;
188
+ case "Apple_Terminal":
189
+ return COLORS_256;
190
+ }
191
+ if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") {
192
+ return COLORS_16m;
193
+ }
194
+ if (getEnvVar("TERM")) {
195
+ if (/truecolor/.exec(getEnvVar("TERM")) !== null) {
196
+ return COLORS_16m;
197
+ }
198
+ if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) {
199
+ return COLORS_256;
200
+ }
201
+ const termEnv = getEnvVar("TERM").toLowerCase();
202
+ if (TERM_ENVS[termEnv]) {
203
+ return TERM_ENVS[termEnv];
204
+ }
205
+ if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {
206
+ return COLORS_16;
207
+ }
208
+ }
209
+ if (getEnvVar("COLORTERM")) {
210
+ return COLORS_16;
211
+ }
212
+ return COLORS_2;
213
+ }
214
+
215
+ const TTY_COLORS = {
216
+ reset: "\x1B[0m",
217
+ bright: "\x1B[1m",
218
+ dim: "\x1B[2m",
219
+ undim: "\x1B[22m",
220
+ underscore: "\x1B[4m",
221
+ blink: "\x1B[5m",
222
+ reverse: "\x1B[7m",
223
+ hidden: "\x1B[8m",
224
+ fg: {
225
+ black: "\x1B[30m",
226
+ red: "\x1B[31m",
227
+ green: "\x1B[32m",
228
+ yellow: "\x1B[33m",
229
+ blue: "\x1B[34m",
230
+ magenta: "\x1B[35m",
231
+ cyan: "\x1B[36m",
232
+ white: "\x1B[37m"
233
+ },
234
+ bg: {
235
+ black: "\x1B[40m",
236
+ red: "\x1B[41m",
237
+ green: "\x1B[42m",
238
+ yellow: "\x1B[43m",
239
+ blue: "\x1B[44m",
240
+ magenta: "\x1B[45m",
241
+ cyan: "\x1B[46m",
242
+ white: "\x1B[47m"
243
+ }
244
+ };
245
+ const levels = ["info", "success", "warn", "error", "debug"];
246
+ function shouldPublishLog(currentLogLevel, logLevel) {
247
+ return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
248
+ }
249
+ const levelColors = {
250
+ info: TTY_COLORS.fg.blue,
251
+ success: TTY_COLORS.fg.green,
252
+ warn: TTY_COLORS.fg.yellow,
253
+ error: TTY_COLORS.fg.red,
254
+ debug: TTY_COLORS.fg.magenta
255
+ };
256
+ const formatMessage = (level, message, colorsEnabled) => {
257
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
258
+ if (colorsEnabled) {
259
+ return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
260
+ }
261
+ return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
262
+ };
263
+ const createLogger = (options) => {
264
+ const enabled = options?.disabled !== true;
265
+ const logLevel = options?.level ?? "error";
266
+ const isDisableColorsSpecified = options?.disableColors !== void 0;
267
+ const colorsEnabled = isDisableColorsSpecified ? !options.disableColors : getColorDepth() !== 1;
268
+ const LogFunc = (level, message, args = []) => {
269
+ if (!enabled || !shouldPublishLog(logLevel, level)) {
270
+ return;
271
+ }
272
+ const formattedMessage = formatMessage(level, message, colorsEnabled);
273
+ if (!options || typeof options.log !== "function") {
274
+ if (level === "error") {
275
+ console.error(formattedMessage, ...args);
276
+ } else if (level === "warn") {
277
+ console.warn(formattedMessage, ...args);
278
+ } else {
279
+ console.log(formattedMessage, ...args);
280
+ }
281
+ return;
282
+ }
283
+ options.log(level === "success" ? "info" : level, message, ...args);
284
+ };
285
+ const logger2 = Object.fromEntries(
286
+ levels.map((level) => [
287
+ level,
288
+ (...[message, ...args]) => LogFunc(level, message, args)
289
+ ])
290
+ );
291
+ return {
292
+ ...logger2,
293
+ get level() {
294
+ return logLevel;
295
+ }
296
+ };
297
+ };
298
+ const logger = createLogger();
299
+
300
+ export { ENV, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
package/dist/index.d.cts CHANGED
@@ -1,2 +1,115 @@
1
+ import { L as LiteralUnion, M as Models } from './shared/core.DeNN5HMO.cjs';
2
+ export { a as LiteralString } from './shared/core.DeNN5HMO.cjs';
3
+ import { CookieOptions } from 'better-call';
4
+ import 'zod';
1
5
 
2
- export { };
6
+ type GenerateIdFn = (options: {
7
+ model: LiteralUnion<Models, string>;
8
+ size?: number;
9
+ }) => string | false;
10
+ type BetterAuthAdvancedOptions = {
11
+ /**
12
+ * Ip address configuration
13
+ */
14
+ ipAddress?: {
15
+ /**
16
+ * List of headers to use for ip address
17
+ *
18
+ * Ip address is used for rate limiting and session tracking
19
+ *
20
+ * @example ["x-client-ip", "x-forwarded-for", "cf-connecting-ip"]
21
+ *
22
+ * @default
23
+ * @link https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/utils/get-request-ip.ts#L8
24
+ */
25
+ ipAddressHeaders?: string[];
26
+ /**
27
+ * Disable ip tracking
28
+ *
29
+ * ⚠︎ This is a security risk and it may expose your application to abuse
30
+ */
31
+ disableIpTracking?: boolean;
32
+ };
33
+ /**
34
+ * Use secure cookies
35
+ *
36
+ * @default false
37
+ */
38
+ useSecureCookies?: boolean;
39
+ /**
40
+ * Disable trusted origins check
41
+ *
42
+ * ⚠︎ This is a security risk and it may expose your application to CSRF attacks
43
+ */
44
+ disableCSRFCheck?: boolean;
45
+ /**
46
+ * Configure cookies to be cross subdomains
47
+ */
48
+ crossSubDomainCookies?: {
49
+ /**
50
+ * Enable cross subdomain cookies
51
+ */
52
+ enabled: boolean;
53
+ /**
54
+ * Additional cookies to be shared across subdomains
55
+ */
56
+ additionalCookies?: string[];
57
+ /**
58
+ * The domain to use for the cookies
59
+ *
60
+ * By default, the domain will be the root
61
+ * domain from the base URL.
62
+ */
63
+ domain?: string;
64
+ };
65
+ cookies?: {
66
+ [key: string]: {
67
+ name?: string;
68
+ attributes?: CookieOptions;
69
+ };
70
+ };
71
+ defaultCookieAttributes?: CookieOptions;
72
+ /**
73
+ * Prefix for cookies. If a cookie name is provided
74
+ * in cookies config, this will be overridden.
75
+ *
76
+ * @default
77
+ * ```txt
78
+ * "appName" -> which defaults to "better-auth"
79
+ * ```
80
+ */
81
+ cookiePrefix?: string;
82
+ /**
83
+ * Database configuration.
84
+ */
85
+ database?: {
86
+ /**
87
+ * The default number of records to return from the database
88
+ * when using the `findMany` adapter method.
89
+ *
90
+ * @default 100
91
+ */
92
+ defaultFindManyLimit?: number;
93
+ /**
94
+ * If your database auto increments number ids, set this to `true`.
95
+ *
96
+ * Note: If enabled, we will not handle ID generation (including if you use `generateId`), and it would be expected that your database will provide the ID automatically.
97
+ *
98
+ * @default false
99
+ */
100
+ useNumberId?: boolean;
101
+ /**
102
+ * Custom generateId function.
103
+ *
104
+ * If not provided, random ids will be generated.
105
+ * If set to false, the database's auto generated id will be used.
106
+ */
107
+ generateId?: GenerateIdFn | false;
108
+ };
109
+ };
110
+
111
+ interface BetterAuthMutators<O, C> {
112
+ }
113
+
114
+ export { LiteralUnion };
115
+ export type { BetterAuthAdvancedOptions, BetterAuthMutators, GenerateIdFn };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,115 @@
1
+ import { L as LiteralUnion, M as Models } from './shared/core.DeNN5HMO.mjs';
2
+ export { a as LiteralString } from './shared/core.DeNN5HMO.mjs';
3
+ import { CookieOptions } from 'better-call';
4
+ import 'zod';
1
5
 
2
- export { };
6
+ type GenerateIdFn = (options: {
7
+ model: LiteralUnion<Models, string>;
8
+ size?: number;
9
+ }) => string | false;
10
+ type BetterAuthAdvancedOptions = {
11
+ /**
12
+ * Ip address configuration
13
+ */
14
+ ipAddress?: {
15
+ /**
16
+ * List of headers to use for ip address
17
+ *
18
+ * Ip address is used for rate limiting and session tracking
19
+ *
20
+ * @example ["x-client-ip", "x-forwarded-for", "cf-connecting-ip"]
21
+ *
22
+ * @default
23
+ * @link https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/utils/get-request-ip.ts#L8
24
+ */
25
+ ipAddressHeaders?: string[];
26
+ /**
27
+ * Disable ip tracking
28
+ *
29
+ * ⚠︎ This is a security risk and it may expose your application to abuse
30
+ */
31
+ disableIpTracking?: boolean;
32
+ };
33
+ /**
34
+ * Use secure cookies
35
+ *
36
+ * @default false
37
+ */
38
+ useSecureCookies?: boolean;
39
+ /**
40
+ * Disable trusted origins check
41
+ *
42
+ * ⚠︎ This is a security risk and it may expose your application to CSRF attacks
43
+ */
44
+ disableCSRFCheck?: boolean;
45
+ /**
46
+ * Configure cookies to be cross subdomains
47
+ */
48
+ crossSubDomainCookies?: {
49
+ /**
50
+ * Enable cross subdomain cookies
51
+ */
52
+ enabled: boolean;
53
+ /**
54
+ * Additional cookies to be shared across subdomains
55
+ */
56
+ additionalCookies?: string[];
57
+ /**
58
+ * The domain to use for the cookies
59
+ *
60
+ * By default, the domain will be the root
61
+ * domain from the base URL.
62
+ */
63
+ domain?: string;
64
+ };
65
+ cookies?: {
66
+ [key: string]: {
67
+ name?: string;
68
+ attributes?: CookieOptions;
69
+ };
70
+ };
71
+ defaultCookieAttributes?: CookieOptions;
72
+ /**
73
+ * Prefix for cookies. If a cookie name is provided
74
+ * in cookies config, this will be overridden.
75
+ *
76
+ * @default
77
+ * ```txt
78
+ * "appName" -> which defaults to "better-auth"
79
+ * ```
80
+ */
81
+ cookiePrefix?: string;
82
+ /**
83
+ * Database configuration.
84
+ */
85
+ database?: {
86
+ /**
87
+ * The default number of records to return from the database
88
+ * when using the `findMany` adapter method.
89
+ *
90
+ * @default 100
91
+ */
92
+ defaultFindManyLimit?: number;
93
+ /**
94
+ * If your database auto increments number ids, set this to `true`.
95
+ *
96
+ * Note: If enabled, we will not handle ID generation (including if you use `generateId`), and it would be expected that your database will provide the ID automatically.
97
+ *
98
+ * @default false
99
+ */
100
+ useNumberId?: boolean;
101
+ /**
102
+ * Custom generateId function.
103
+ *
104
+ * If not provided, random ids will be generated.
105
+ * If set to false, the database's auto generated id will be used.
106
+ */
107
+ generateId?: GenerateIdFn | false;
108
+ };
109
+ };
110
+
111
+ interface BetterAuthMutators<O, C> {
112
+ }
113
+
114
+ export { LiteralUnion };
115
+ export type { BetterAuthAdvancedOptions, BetterAuthMutators, GenerateIdFn };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,115 @@
1
+ import { L as LiteralUnion, M as Models } from './shared/core.DeNN5HMO.js';
2
+ export { a as LiteralString } from './shared/core.DeNN5HMO.js';
3
+ import { CookieOptions } from 'better-call';
4
+ import 'zod';
1
5
 
2
- export { };
6
+ type GenerateIdFn = (options: {
7
+ model: LiteralUnion<Models, string>;
8
+ size?: number;
9
+ }) => string | false;
10
+ type BetterAuthAdvancedOptions = {
11
+ /**
12
+ * Ip address configuration
13
+ */
14
+ ipAddress?: {
15
+ /**
16
+ * List of headers to use for ip address
17
+ *
18
+ * Ip address is used for rate limiting and session tracking
19
+ *
20
+ * @example ["x-client-ip", "x-forwarded-for", "cf-connecting-ip"]
21
+ *
22
+ * @default
23
+ * @link https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/utils/get-request-ip.ts#L8
24
+ */
25
+ ipAddressHeaders?: string[];
26
+ /**
27
+ * Disable ip tracking
28
+ *
29
+ * ⚠︎ This is a security risk and it may expose your application to abuse
30
+ */
31
+ disableIpTracking?: boolean;
32
+ };
33
+ /**
34
+ * Use secure cookies
35
+ *
36
+ * @default false
37
+ */
38
+ useSecureCookies?: boolean;
39
+ /**
40
+ * Disable trusted origins check
41
+ *
42
+ * ⚠︎ This is a security risk and it may expose your application to CSRF attacks
43
+ */
44
+ disableCSRFCheck?: boolean;
45
+ /**
46
+ * Configure cookies to be cross subdomains
47
+ */
48
+ crossSubDomainCookies?: {
49
+ /**
50
+ * Enable cross subdomain cookies
51
+ */
52
+ enabled: boolean;
53
+ /**
54
+ * Additional cookies to be shared across subdomains
55
+ */
56
+ additionalCookies?: string[];
57
+ /**
58
+ * The domain to use for the cookies
59
+ *
60
+ * By default, the domain will be the root
61
+ * domain from the base URL.
62
+ */
63
+ domain?: string;
64
+ };
65
+ cookies?: {
66
+ [key: string]: {
67
+ name?: string;
68
+ attributes?: CookieOptions;
69
+ };
70
+ };
71
+ defaultCookieAttributes?: CookieOptions;
72
+ /**
73
+ * Prefix for cookies. If a cookie name is provided
74
+ * in cookies config, this will be overridden.
75
+ *
76
+ * @default
77
+ * ```txt
78
+ * "appName" -> which defaults to "better-auth"
79
+ * ```
80
+ */
81
+ cookiePrefix?: string;
82
+ /**
83
+ * Database configuration.
84
+ */
85
+ database?: {
86
+ /**
87
+ * The default number of records to return from the database
88
+ * when using the `findMany` adapter method.
89
+ *
90
+ * @default 100
91
+ */
92
+ defaultFindManyLimit?: number;
93
+ /**
94
+ * If your database auto increments number ids, set this to `true`.
95
+ *
96
+ * Note: If enabled, we will not handle ID generation (including if you use `generateId`), and it would be expected that your database will provide the ID automatically.
97
+ *
98
+ * @default false
99
+ */
100
+ useNumberId?: boolean;
101
+ /**
102
+ * Custom generateId function.
103
+ *
104
+ * If not provided, random ids will be generated.
105
+ * If set to false, the database's auto generated id will be used.
106
+ */
107
+ generateId?: GenerateIdFn | false;
108
+ };
109
+ };
110
+
111
+ interface BetterAuthMutators<O, C> {
112
+ }
113
+
114
+ export { LiteralUnion };
115
+ export type { BetterAuthAdvancedOptions, BetterAuthMutators, GenerateIdFn };