@better-auth/core 1.3.27 → 1.4.0-beta.10

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 (136) hide show
  1. package/.turbo/turbo-build.log +72 -25
  2. package/dist/async_hooks/index.cjs +12 -20
  3. package/dist/async_hooks/index.d.cts +4 -7
  4. package/dist/async_hooks/index.d.ts +4 -7
  5. package/dist/async_hooks/index.js +18 -0
  6. package/dist/chunk-CUT6urMc.cjs +30 -0
  7. package/dist/db/adapter/index.cjs +0 -2
  8. package/dist/db/adapter/index.d.cts +7 -23
  9. package/dist/db/adapter/index.d.ts +7 -23
  10. package/dist/db/adapter/index.js +1 -0
  11. package/dist/db/index.cjs +49 -56
  12. package/dist/db/index.d.cts +3 -116
  13. package/dist/db/index.d.ts +3 -116
  14. package/dist/db/index.js +61 -0
  15. package/dist/env/index.cjs +16 -0
  16. package/dist/env/index.d.cts +2 -0
  17. package/dist/env/index.d.ts +2 -0
  18. package/dist/env/index.js +3 -0
  19. package/dist/env-B05JceKx.cjs +330 -0
  20. package/dist/env-BZ5Nwx0e.js +246 -0
  21. package/dist/error/index.cjs +5 -0
  22. package/dist/error/index.d.cts +35 -0
  23. package/dist/error/index.d.ts +35 -0
  24. package/dist/error/index.js +4 -0
  25. package/dist/error-Hbg10Ynz.cjs +56 -0
  26. package/dist/error-ULaqTKlI.js +45 -0
  27. package/dist/helper-5oNxdxzu.d.ts +6 -0
  28. package/dist/helper-DVgWo5zB.d.cts +6 -0
  29. package/dist/index-B7m2jDWm.d.cts +344 -0
  30. package/dist/index-CESTxPyW.d.cts +82 -0
  31. package/dist/index-Cw9Gfaxd.d.cts +4410 -0
  32. package/dist/index-Cx8dCSTo.d.ts +82 -0
  33. package/dist/index-DJdmnKQr.d.ts +4410 -0
  34. package/dist/index-DNvIh1jX.d.cts +1870 -0
  35. package/dist/index-DoyF8K2U.d.ts +344 -0
  36. package/dist/index-ujq2DkG7.d.ts +1870 -0
  37. package/dist/index.cjs +0 -2
  38. package/dist/index.d.cts +7 -124
  39. package/dist/index.d.ts +7 -124
  40. package/dist/index.js +1 -0
  41. package/dist/middleware/index.cjs +22 -0
  42. package/dist/middleware/index.d.cts +7 -0
  43. package/dist/middleware/index.d.ts +7 -0
  44. package/dist/middleware/index.js +18 -0
  45. package/dist/oauth2/index.cjs +12 -0
  46. package/dist/oauth2/index.d.cts +3 -0
  47. package/dist/oauth2/index.d.ts +3 -0
  48. package/dist/oauth2/index.js +3 -0
  49. package/dist/oauth2-BokgssHJ.js +239 -0
  50. package/dist/oauth2-CLON8fY4.cjs +302 -0
  51. package/dist/social-providers/index.cjs +2410 -0
  52. package/dist/social-providers/index.d.cts +4 -0
  53. package/dist/social-providers/index.d.ts +4 -0
  54. package/dist/social-providers/index.js +2370 -0
  55. package/dist/type-BNCR-kIK.d.cts +262 -0
  56. package/dist/type-eT5TjHFp.d.ts +262 -0
  57. package/dist/utils/index.cjs +3 -0
  58. package/dist/utils/index.d.cts +9 -0
  59. package/dist/utils/index.d.ts +9 -0
  60. package/dist/utils/index.js +3 -0
  61. package/dist/utils-AcCtPmwG.cjs +13 -0
  62. package/dist/utils-BQjFFU97.js +7 -0
  63. package/package.json +107 -11
  64. package/src/async_hooks/index.ts +1 -9
  65. package/src/db/adapter/index.ts +424 -0
  66. package/src/db/index.ts +4 -0
  67. package/src/db/schema/rate-limit.ts +21 -0
  68. package/src/db/type.ts +29 -10
  69. package/src/env/color-depth.ts +171 -0
  70. package/src/env/env-impl.ts +123 -0
  71. package/src/env/index.ts +23 -0
  72. package/src/env/logger.test.ts +33 -0
  73. package/src/env/logger.ts +145 -0
  74. package/src/error/codes.ts +31 -0
  75. package/src/error/index.ts +11 -0
  76. package/src/index.ts +0 -2
  77. package/src/middleware/index.ts +33 -0
  78. package/src/oauth2/client-credentials-token.ts +102 -0
  79. package/src/oauth2/create-authorization-url.ts +85 -0
  80. package/src/oauth2/index.ts +22 -0
  81. package/src/oauth2/oauth-provider.ts +194 -0
  82. package/src/oauth2/refresh-access-token.ts +124 -0
  83. package/src/oauth2/utils.ts +36 -0
  84. package/src/oauth2/validate-authorization-code.ts +156 -0
  85. package/src/social-providers/apple.ts +213 -0
  86. package/src/social-providers/atlassian.ts +127 -0
  87. package/src/social-providers/cognito.ts +266 -0
  88. package/src/social-providers/discord.ts +169 -0
  89. package/src/social-providers/dropbox.ts +112 -0
  90. package/src/social-providers/facebook.ts +201 -0
  91. package/src/social-providers/figma.ts +112 -0
  92. package/src/social-providers/github.ts +154 -0
  93. package/src/social-providers/gitlab.ts +152 -0
  94. package/src/social-providers/google.ts +168 -0
  95. package/src/social-providers/huggingface.ts +116 -0
  96. package/src/social-providers/index.ts +118 -0
  97. package/src/social-providers/kakao.ts +178 -0
  98. package/src/social-providers/kick.ts +92 -0
  99. package/src/social-providers/line.ts +169 -0
  100. package/src/social-providers/linear.ts +120 -0
  101. package/src/social-providers/linkedin.ts +110 -0
  102. package/src/social-providers/microsoft-entra-id.ts +243 -0
  103. package/src/social-providers/naver.ts +112 -0
  104. package/src/social-providers/notion.ts +106 -0
  105. package/src/social-providers/paypal.ts +261 -0
  106. package/src/social-providers/reddit.ts +122 -0
  107. package/src/social-providers/roblox.ts +107 -0
  108. package/src/social-providers/salesforce.ts +154 -0
  109. package/src/social-providers/slack.ts +111 -0
  110. package/src/social-providers/spotify.ts +93 -0
  111. package/src/social-providers/tiktok.ts +208 -0
  112. package/src/social-providers/twitch.ts +111 -0
  113. package/src/social-providers/twitter.ts +194 -0
  114. package/src/social-providers/vk.ts +125 -0
  115. package/src/social-providers/zoom.ts +215 -0
  116. package/src/types/context.ts +270 -0
  117. package/src/types/cookie.ts +7 -0
  118. package/src/types/index.ts +19 -1
  119. package/src/types/init-options.ts +1035 -7
  120. package/src/types/plugin-client.ts +69 -0
  121. package/src/types/plugin.ts +134 -0
  122. package/src/utils/error-codes.ts +51 -0
  123. package/src/utils/index.ts +1 -0
  124. package/tsdown.config.ts +19 -0
  125. package/build.config.ts +0 -17
  126. package/dist/async_hooks/index.d.mts +0 -10
  127. package/dist/async_hooks/index.mjs +0 -25
  128. package/dist/db/adapter/index.d.mts +0 -23
  129. package/dist/db/adapter/index.mjs +0 -1
  130. package/dist/db/index.d.mts +0 -116
  131. package/dist/db/index.mjs +0 -55
  132. package/dist/index.d.mts +0 -124
  133. package/dist/index.mjs +0 -1
  134. package/dist/shared/core.CnvFgghY.d.cts +0 -117
  135. package/dist/shared/core.CnvFgghY.d.mts +0 -117
  136. package/dist/shared/core.CnvFgghY.d.ts +0 -117
@@ -0,0 +1,262 @@
1
+ import { LiteralString } from "./helper-DVgWo5zB.cjs";
2
+ import * as z from "zod";
3
+ import { ZodType } from "zod";
4
+
5
+ //#region src/db/plugin.d.ts
6
+ type BetterAuthPluginDBSchema = { [table in string]: {
7
+ fields: { [field in string]: DBFieldAttribute };
8
+ disableMigration?: boolean;
9
+ modelName?: string;
10
+ } };
11
+ //#endregion
12
+ //#region src/db/schema/shared.d.ts
13
+ declare const coreSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ createdAt: z.ZodDefault<z.ZodDate>;
16
+ updatedAt: z.ZodDefault<z.ZodDate>;
17
+ }, z.core.$strip>;
18
+ //#endregion
19
+ //#region src/db/schema/user.d.ts
20
+ declare const userSchema: z.ZodObject<{
21
+ id: z.ZodString;
22
+ createdAt: z.ZodDefault<z.ZodDate>;
23
+ updatedAt: z.ZodDefault<z.ZodDate>;
24
+ email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
25
+ emailVerified: z.ZodDefault<z.ZodBoolean>;
26
+ name: z.ZodString;
27
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ }, z.core.$strip>;
29
+ /**
30
+ * User schema type used by better-auth, note that it's possible that user could have additional fields
31
+ *
32
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
33
+ */
34
+ type User = z.infer<typeof userSchema>;
35
+ //#endregion
36
+ //#region src/db/schema/account.d.ts
37
+ declare const accountSchema: z.ZodObject<{
38
+ id: z.ZodString;
39
+ createdAt: z.ZodDefault<z.ZodDate>;
40
+ updatedAt: z.ZodDefault<z.ZodDate>;
41
+ providerId: z.ZodString;
42
+ accountId: z.ZodString;
43
+ userId: z.ZodCoercedString<unknown>;
44
+ accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
48
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
49
+ scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ /**
53
+ * Account schema type used by better-auth, note that it's possible that account could have additional fields
54
+ *
55
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
56
+ */
57
+ type Account = z.infer<typeof accountSchema>;
58
+ //#endregion
59
+ //#region src/db/schema/session.d.ts
60
+ declare const sessionSchema: z.ZodObject<{
61
+ id: z.ZodString;
62
+ createdAt: z.ZodDefault<z.ZodDate>;
63
+ updatedAt: z.ZodDefault<z.ZodDate>;
64
+ userId: z.ZodCoercedString<unknown>;
65
+ expiresAt: z.ZodDate;
66
+ token: z.ZodString;
67
+ ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
+ userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Session schema type used by better-auth, note that it's possible that session could have additional fields
72
+ *
73
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
74
+ */
75
+ type Session = z.infer<typeof sessionSchema>;
76
+ //#endregion
77
+ //#region src/db/schema/verification.d.ts
78
+ declare const verificationSchema: z.ZodObject<{
79
+ id: z.ZodString;
80
+ createdAt: z.ZodDefault<z.ZodDate>;
81
+ updatedAt: z.ZodDefault<z.ZodDate>;
82
+ value: z.ZodString;
83
+ expiresAt: z.ZodDate;
84
+ identifier: z.ZodString;
85
+ }, z.core.$strip>;
86
+ /**
87
+ * Verification schema type used by better-auth, note that it's possible that verification could have additional fields
88
+ *
89
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
90
+ */
91
+ type Verification = z.infer<typeof verificationSchema>;
92
+ //#endregion
93
+ //#region src/db/schema/rate-limit.d.ts
94
+ declare const rateLimitSchema: z.ZodObject<{
95
+ key: z.ZodString;
96
+ count: z.ZodNumber;
97
+ lastRequest: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ /**
100
+ * Rate limit schema type used by better-auth for rate limiting
101
+ */
102
+ type RateLimit = z.infer<typeof rateLimitSchema>;
103
+ //#endregion
104
+ //#region src/db/index.d.ts
105
+ /**
106
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
107
+ */
108
+ type AuthPluginSchema = BetterAuthPluginDBSchema;
109
+ /**
110
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
111
+ */
112
+ type FieldAttribute = DBFieldAttribute;
113
+ /**
114
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
115
+ */
116
+ type FieldAttributeConfig = DBFieldAttributeConfig;
117
+ /**
118
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
119
+ */
120
+ type FieldType = DBFieldType;
121
+ /**
122
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
123
+ */
124
+ type Primitive = DBPrimitive;
125
+ /**
126
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
127
+ */
128
+ type BetterAuthDbSchema = BetterAuthDBSchema;
129
+ //#endregion
130
+ //#region src/db/type.d.ts
131
+ type DBPreservedModels = "user" | "account" | "session" | "verification" | "rate-limit" | "organization" | "member" | "invitation" | "jwks" | "passkey" | "two-factor";
132
+ type DBFieldType = "string" | "number" | "boolean" | "date" | "json" | `${"string" | "number"}[]` | Array<LiteralString>;
133
+ type DBPrimitive = string | number | boolean | Date | null | undefined | string[] | number[];
134
+ type DBFieldAttributeConfig = {
135
+ /**
136
+ * If the field should be required on a new record.
137
+ * @default true
138
+ */
139
+ required?: boolean;
140
+ /**
141
+ * If the value should be returned on a response body.
142
+ * @default true
143
+ */
144
+ returned?: boolean;
145
+ /**
146
+ * If a value should be provided when creating a new record.
147
+ * @default true
148
+ */
149
+ input?: boolean;
150
+ /**
151
+ * Default value for the field
152
+ *
153
+ * Note: This will not create a default value on the database level. It will only
154
+ * be used when creating a new record.
155
+ */
156
+ defaultValue?: DBPrimitive | (() => DBPrimitive);
157
+ /**
158
+ * Update value for the field
159
+ *
160
+ * Note: This will create an onUpdate trigger on the database level for supported adapters.
161
+ * It will be called when updating a record.
162
+ */
163
+ onUpdate?: () => DBPrimitive;
164
+ /**
165
+ * transform the value before storing it.
166
+ */
167
+ transform?: {
168
+ input?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
169
+ output?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
170
+ };
171
+ /**
172
+ * Reference to another model.
173
+ */
174
+ references?: {
175
+ /**
176
+ * The model to reference.
177
+ */
178
+ model: string;
179
+ /**
180
+ * The field on the referenced model.
181
+ */
182
+ field: string;
183
+ /**
184
+ * The action to perform when the reference is deleted.
185
+ * @default "cascade"
186
+ */
187
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
188
+ };
189
+ unique?: boolean;
190
+ /**
191
+ * If the field should be a bigint on the database instead of integer.
192
+ */
193
+ bigint?: boolean;
194
+ /**
195
+ * A zod schema to validate the value.
196
+ */
197
+ validator?: {
198
+ input?: ZodType;
199
+ output?: ZodType;
200
+ };
201
+ /**
202
+ * The name of the field on the database.
203
+ */
204
+ fieldName?: string;
205
+ /**
206
+ * If the field should be sortable.
207
+ *
208
+ * applicable only for `text` type.
209
+ * It's useful to mark fields varchar instead of text.
210
+ */
211
+ sortable?: boolean;
212
+ };
213
+ type DBFieldAttribute<T extends DBFieldType = DBFieldType> = {
214
+ type: T;
215
+ } & DBFieldAttributeConfig;
216
+ type BetterAuthDBSchema = Record<string, {
217
+ /**
218
+ * The name of the table in the database
219
+ */
220
+ modelName: string;
221
+ /**
222
+ * The fields of the table
223
+ */
224
+ fields: Record<string, DBFieldAttribute>;
225
+ /**
226
+ * Whether to disable migrations for this table
227
+ * @default false
228
+ */
229
+ disableMigrations?: boolean;
230
+ /**
231
+ * The order of the table
232
+ */
233
+ order?: number;
234
+ }>;
235
+ interface SecondaryStorage {
236
+ /**
237
+ *
238
+ * @param key - Key to get
239
+ * @returns - Value of the key
240
+ */
241
+ get: (key: string) => Promise<unknown> | unknown;
242
+ set: (
243
+ /**
244
+ * Key to store
245
+ */
246
+ key: string,
247
+ /**
248
+ * Value to store
249
+ */
250
+ value: string,
251
+ /**
252
+ * Time to live in seconds
253
+ */
254
+ ttl?: number) => Promise<void | null | unknown> | void;
255
+ /**
256
+ *
257
+ * @param key - Key to delete
258
+ */
259
+ delete: (key: string) => Promise<void | null | string> | void;
260
+ }
261
+ //#endregion
262
+ export { type Account, AuthPluginSchema, type BetterAuthDBSchema, BetterAuthDbSchema, type BetterAuthPluginDBSchema, type DBFieldAttribute, type DBFieldAttributeConfig, type DBFieldType, type DBPreservedModels, type DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, type RateLimit, type SecondaryStorage, type Session, type User, type Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -0,0 +1,262 @@
1
+ import { LiteralString } from "./helper-5oNxdxzu.js";
2
+ import * as z from "zod";
3
+ import { ZodType } from "zod";
4
+
5
+ //#region src/db/plugin.d.ts
6
+ type BetterAuthPluginDBSchema = { [table in string]: {
7
+ fields: { [field in string]: DBFieldAttribute };
8
+ disableMigration?: boolean;
9
+ modelName?: string;
10
+ } };
11
+ //#endregion
12
+ //#region src/db/schema/shared.d.ts
13
+ declare const coreSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ createdAt: z.ZodDefault<z.ZodDate>;
16
+ updatedAt: z.ZodDefault<z.ZodDate>;
17
+ }, z.core.$strip>;
18
+ //#endregion
19
+ //#region src/db/schema/user.d.ts
20
+ declare const userSchema: z.ZodObject<{
21
+ id: z.ZodString;
22
+ createdAt: z.ZodDefault<z.ZodDate>;
23
+ updatedAt: z.ZodDefault<z.ZodDate>;
24
+ email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
25
+ emailVerified: z.ZodDefault<z.ZodBoolean>;
26
+ name: z.ZodString;
27
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ }, z.core.$strip>;
29
+ /**
30
+ * User schema type used by better-auth, note that it's possible that user could have additional fields
31
+ *
32
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
33
+ */
34
+ type User = z.infer<typeof userSchema>;
35
+ //#endregion
36
+ //#region src/db/schema/account.d.ts
37
+ declare const accountSchema: z.ZodObject<{
38
+ id: z.ZodString;
39
+ createdAt: z.ZodDefault<z.ZodDate>;
40
+ updatedAt: z.ZodDefault<z.ZodDate>;
41
+ providerId: z.ZodString;
42
+ accountId: z.ZodString;
43
+ userId: z.ZodCoercedString<unknown>;
44
+ accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
48
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
49
+ scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ /**
53
+ * Account schema type used by better-auth, note that it's possible that account could have additional fields
54
+ *
55
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
56
+ */
57
+ type Account = z.infer<typeof accountSchema>;
58
+ //#endregion
59
+ //#region src/db/schema/session.d.ts
60
+ declare const sessionSchema: z.ZodObject<{
61
+ id: z.ZodString;
62
+ createdAt: z.ZodDefault<z.ZodDate>;
63
+ updatedAt: z.ZodDefault<z.ZodDate>;
64
+ userId: z.ZodCoercedString<unknown>;
65
+ expiresAt: z.ZodDate;
66
+ token: z.ZodString;
67
+ ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
+ userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Session schema type used by better-auth, note that it's possible that session could have additional fields
72
+ *
73
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
74
+ */
75
+ type Session = z.infer<typeof sessionSchema>;
76
+ //#endregion
77
+ //#region src/db/schema/verification.d.ts
78
+ declare const verificationSchema: z.ZodObject<{
79
+ id: z.ZodString;
80
+ createdAt: z.ZodDefault<z.ZodDate>;
81
+ updatedAt: z.ZodDefault<z.ZodDate>;
82
+ value: z.ZodString;
83
+ expiresAt: z.ZodDate;
84
+ identifier: z.ZodString;
85
+ }, z.core.$strip>;
86
+ /**
87
+ * Verification schema type used by better-auth, note that it's possible that verification could have additional fields
88
+ *
89
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
90
+ */
91
+ type Verification = z.infer<typeof verificationSchema>;
92
+ //#endregion
93
+ //#region src/db/schema/rate-limit.d.ts
94
+ declare const rateLimitSchema: z.ZodObject<{
95
+ key: z.ZodString;
96
+ count: z.ZodNumber;
97
+ lastRequest: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ /**
100
+ * Rate limit schema type used by better-auth for rate limiting
101
+ */
102
+ type RateLimit = z.infer<typeof rateLimitSchema>;
103
+ //#endregion
104
+ //#region src/db/index.d.ts
105
+ /**
106
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
107
+ */
108
+ type AuthPluginSchema = BetterAuthPluginDBSchema;
109
+ /**
110
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
111
+ */
112
+ type FieldAttribute = DBFieldAttribute;
113
+ /**
114
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
115
+ */
116
+ type FieldAttributeConfig = DBFieldAttributeConfig;
117
+ /**
118
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
119
+ */
120
+ type FieldType = DBFieldType;
121
+ /**
122
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
123
+ */
124
+ type Primitive = DBPrimitive;
125
+ /**
126
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
127
+ */
128
+ type BetterAuthDbSchema = BetterAuthDBSchema;
129
+ //#endregion
130
+ //#region src/db/type.d.ts
131
+ type DBPreservedModels = "user" | "account" | "session" | "verification" | "rate-limit" | "organization" | "member" | "invitation" | "jwks" | "passkey" | "two-factor";
132
+ type DBFieldType = "string" | "number" | "boolean" | "date" | "json" | `${"string" | "number"}[]` | Array<LiteralString>;
133
+ type DBPrimitive = string | number | boolean | Date | null | undefined | string[] | number[];
134
+ type DBFieldAttributeConfig = {
135
+ /**
136
+ * If the field should be required on a new record.
137
+ * @default true
138
+ */
139
+ required?: boolean;
140
+ /**
141
+ * If the value should be returned on a response body.
142
+ * @default true
143
+ */
144
+ returned?: boolean;
145
+ /**
146
+ * If a value should be provided when creating a new record.
147
+ * @default true
148
+ */
149
+ input?: boolean;
150
+ /**
151
+ * Default value for the field
152
+ *
153
+ * Note: This will not create a default value on the database level. It will only
154
+ * be used when creating a new record.
155
+ */
156
+ defaultValue?: DBPrimitive | (() => DBPrimitive);
157
+ /**
158
+ * Update value for the field
159
+ *
160
+ * Note: This will create an onUpdate trigger on the database level for supported adapters.
161
+ * It will be called when updating a record.
162
+ */
163
+ onUpdate?: () => DBPrimitive;
164
+ /**
165
+ * transform the value before storing it.
166
+ */
167
+ transform?: {
168
+ input?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
169
+ output?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
170
+ };
171
+ /**
172
+ * Reference to another model.
173
+ */
174
+ references?: {
175
+ /**
176
+ * The model to reference.
177
+ */
178
+ model: string;
179
+ /**
180
+ * The field on the referenced model.
181
+ */
182
+ field: string;
183
+ /**
184
+ * The action to perform when the reference is deleted.
185
+ * @default "cascade"
186
+ */
187
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
188
+ };
189
+ unique?: boolean;
190
+ /**
191
+ * If the field should be a bigint on the database instead of integer.
192
+ */
193
+ bigint?: boolean;
194
+ /**
195
+ * A zod schema to validate the value.
196
+ */
197
+ validator?: {
198
+ input?: ZodType;
199
+ output?: ZodType;
200
+ };
201
+ /**
202
+ * The name of the field on the database.
203
+ */
204
+ fieldName?: string;
205
+ /**
206
+ * If the field should be sortable.
207
+ *
208
+ * applicable only for `text` type.
209
+ * It's useful to mark fields varchar instead of text.
210
+ */
211
+ sortable?: boolean;
212
+ };
213
+ type DBFieldAttribute<T extends DBFieldType = DBFieldType> = {
214
+ type: T;
215
+ } & DBFieldAttributeConfig;
216
+ type BetterAuthDBSchema = Record<string, {
217
+ /**
218
+ * The name of the table in the database
219
+ */
220
+ modelName: string;
221
+ /**
222
+ * The fields of the table
223
+ */
224
+ fields: Record<string, DBFieldAttribute>;
225
+ /**
226
+ * Whether to disable migrations for this table
227
+ * @default false
228
+ */
229
+ disableMigrations?: boolean;
230
+ /**
231
+ * The order of the table
232
+ */
233
+ order?: number;
234
+ }>;
235
+ interface SecondaryStorage {
236
+ /**
237
+ *
238
+ * @param key - Key to get
239
+ * @returns - Value of the key
240
+ */
241
+ get: (key: string) => Promise<unknown> | unknown;
242
+ set: (
243
+ /**
244
+ * Key to store
245
+ */
246
+ key: string,
247
+ /**
248
+ * Value to store
249
+ */
250
+ value: string,
251
+ /**
252
+ * Time to live in seconds
253
+ */
254
+ ttl?: number) => Promise<void | null | unknown> | void;
255
+ /**
256
+ *
257
+ * @param key - Key to delete
258
+ */
259
+ delete: (key: string) => Promise<void | null | string> | void;
260
+ }
261
+ //#endregion
262
+ export { type Account, AuthPluginSchema, type BetterAuthDBSchema, BetterAuthDbSchema, type BetterAuthPluginDBSchema, type DBFieldAttribute, type DBFieldAttributeConfig, type DBFieldType, type DBPreservedModels, type DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, type RateLimit, type SecondaryStorage, type Session, type User, type Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -0,0 +1,3 @@
1
+ const require_utils = require('../utils-AcCtPmwG.cjs');
2
+
3
+ exports.defineErrorCodes = require_utils.defineErrorCodes;
@@ -0,0 +1,9 @@
1
+ //#region src/utils/error-codes.d.ts
2
+ type UpperLetter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
3
+ type SpecialCharacter = "_";
4
+ type IsValidUpperSnakeCase<S extends string> = S extends `${infer F}${infer R}` ? F extends UpperLetter | SpecialCharacter ? IsValidUpperSnakeCase<R> : false : true;
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] };
7
+ declare function defineErrorCodes<const T extends Record<string, string>>(codes: ValidateErrorCodes<T>): T;
8
+ //#endregion
9
+ export { defineErrorCodes };
@@ -0,0 +1,9 @@
1
+ //#region src/utils/error-codes.d.ts
2
+ type UpperLetter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
3
+ type SpecialCharacter = "_";
4
+ type IsValidUpperSnakeCase<S extends string> = S extends `${infer F}${infer R}` ? F extends UpperLetter | SpecialCharacter ? IsValidUpperSnakeCase<R> : false : true;
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] };
7
+ declare function defineErrorCodes<const T extends Record<string, string>>(codes: ValidateErrorCodes<T>): T;
8
+ //#endregion
9
+ export { defineErrorCodes };
@@ -0,0 +1,3 @@
1
+ import { defineErrorCodes } from "../utils-BQjFFU97.js";
2
+
3
+ export { defineErrorCodes };
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/utils/error-codes.ts
3
+ function defineErrorCodes(codes) {
4
+ return codes;
5
+ }
6
+
7
+ //#endregion
8
+ Object.defineProperty(exports, 'defineErrorCodes', {
9
+ enumerable: true,
10
+ get: function () {
11
+ return defineErrorCodes;
12
+ }
13
+ });
@@ -0,0 +1,7 @@
1
+ //#region src/utils/error-codes.ts
2
+ function defineErrorCodes(codes) {
3
+ return codes;
4
+ }
5
+
6
+ //#endregion
7
+ export { defineErrorCodes };