@better-auth/core 1.3.26 → 1.3.27

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.
@@ -0,0 +1,128 @@
1
+ import type { CookieOptions } from "better-call";
2
+ import type { LiteralUnion } from "./helper";
3
+ import type { Models } from "../db/type";
4
+
5
+ export type GenerateIdFn = (options: {
6
+ model: LiteralUnion<Models, string>;
7
+ size?: number;
8
+ }) => string | false;
9
+
10
+ export 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
+ /*
66
+ * Allows you to change default cookie names and attributes
67
+ *
68
+ * default cookie names:
69
+ * - "session_token"
70
+ * - "session_data"
71
+ * - "dont_remember"
72
+ *
73
+ * plugins can also add additional cookies
74
+ */
75
+ cookies?: {
76
+ [key: string]: {
77
+ name?: string;
78
+ attributes?: CookieOptions;
79
+ };
80
+ };
81
+ defaultCookieAttributes?: CookieOptions;
82
+ /**
83
+ * Prefix for cookies. If a cookie name is provided
84
+ * in cookies config, this will be overridden.
85
+ *
86
+ * @default
87
+ * ```txt
88
+ * "appName" -> which defaults to "better-auth"
89
+ * ```
90
+ */
91
+ cookiePrefix?: string;
92
+ /**
93
+ * Database configuration.
94
+ */
95
+ database?: {
96
+ /**
97
+ * The default number of records to return from the database
98
+ * when using the `findMany` adapter method.
99
+ *
100
+ * @default 100
101
+ */
102
+ defaultFindManyLimit?: number;
103
+ /**
104
+ * If your database auto increments number ids, set this to `true`.
105
+ *
106
+ * 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.
107
+ *
108
+ * @default false
109
+ */
110
+ useNumberId?: boolean;
111
+ /**
112
+ * Custom generateId function.
113
+ *
114
+ * If not provided, random ids will be generated.
115
+ * If set to false, the database's auto generated id will be used.
116
+ */
117
+ generateId?: GenerateIdFn | false;
118
+ };
119
+ /**
120
+ * Custom generateId function.
121
+ *
122
+ * If not provided, random ids will be generated.
123
+ * If set to false, the database's auto generated id will be used.
124
+ *
125
+ * @deprecated Please use `database.generateId` instead. This will be potentially removed in future releases.
126
+ */
127
+ generateId?: GenerateIdFn | false;
128
+ };