@better-auth/core 1.3.28 → 1.4.0-beta.11

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 (157) hide show
  1. package/.turbo/turbo-build.log +81 -76
  2. package/dist/api/index.cjs +30 -0
  3. package/dist/api/index.d.cts +7 -0
  4. package/dist/api/index.d.ts +7 -0
  5. package/dist/api/index.js +26 -0
  6. package/dist/async_hooks/index.cjs +2 -26
  7. package/dist/async_hooks/index.d.cts +4 -7
  8. package/dist/async_hooks/index.d.ts +4 -7
  9. package/dist/async_hooks/index.js +3 -0
  10. package/dist/async_hooks-CaXONcb9.cjs +24 -0
  11. package/dist/async_hooks-CkLtIFa6.js +18 -0
  12. package/dist/chunk-CUT6urMc.cjs +30 -0
  13. package/dist/context/index.cjs +8 -0
  14. package/dist/context/index.d.cts +17 -0
  15. package/dist/context/index.d.ts +17 -0
  16. package/dist/context/index.js +4 -0
  17. package/dist/context-DAu9ytQl.cjs +85 -0
  18. package/dist/context-rhoB1CVr.js +56 -0
  19. package/dist/db/adapter/index.cjs +0 -2
  20. package/dist/db/adapter/index.d.cts +7 -14
  21. package/dist/db/adapter/index.d.ts +7 -14
  22. package/dist/db/adapter/index.js +1 -0
  23. package/dist/db/index.cjs +46 -69
  24. package/dist/db/index.d.cts +3 -39
  25. package/dist/db/index.d.ts +3 -39
  26. package/dist/db/index.js +61 -0
  27. package/dist/env/index.cjs +15 -311
  28. package/dist/env/index.d.cts +2 -36
  29. package/dist/env/index.d.ts +2 -36
  30. package/dist/env/index.js +3 -0
  31. package/dist/env-D1OdwBk9.cjs +330 -0
  32. package/dist/env-DzHiLVFb.js +246 -0
  33. package/dist/error/index.cjs +4 -43
  34. package/dist/error/index.d.cts +31 -29
  35. package/dist/error/index.d.ts +31 -29
  36. package/dist/error/index.js +4 -0
  37. package/dist/error-H6U5qGNP.js +45 -0
  38. package/dist/error-k9KM7GAb.cjs +56 -0
  39. package/dist/helper-DVgWo5zB.d.cts +6 -0
  40. package/dist/helper-Dm5AtPVS.d.ts +6 -0
  41. package/dist/index-BPsqLi68.d.ts +4410 -0
  42. package/dist/index-CgIE2ECh.d.cts +262 -0
  43. package/dist/index-ChlC5Vy3.d.ts +344 -0
  44. package/dist/index-Cmh0x42V.d.ts +262 -0
  45. package/dist/index-CsHMVqbX.d.ts +82 -0
  46. package/dist/index-DFwrZMma.d.cts +82 -0
  47. package/dist/index-OrTFOyAG.d.ts +1871 -0
  48. package/dist/index-_Oiv-VVr.d.cts +344 -0
  49. package/dist/index-ehsSkBxt.d.cts +4410 -0
  50. package/dist/index-yBChAjSS.d.cts +1871 -0
  51. package/dist/index.cjs +0 -2
  52. package/dist/index.d.cts +7 -180
  53. package/dist/index.d.ts +7 -180
  54. package/dist/index.js +1 -0
  55. package/dist/oauth2/index.cjs +12 -368
  56. package/dist/oauth2/index.d.cts +3 -100
  57. package/dist/oauth2/index.d.ts +3 -100
  58. package/dist/oauth2/index.js +3 -0
  59. package/dist/oauth2-D_FUKfC8.js +239 -0
  60. package/dist/oauth2-DqX_pPhp.cjs +302 -0
  61. package/dist/social-providers/index.cjs +2262 -2645
  62. package/dist/social-providers/index.d.cts +4 -3903
  63. package/dist/social-providers/index.d.ts +4 -3903
  64. package/dist/social-providers/index.js +2370 -0
  65. package/dist/utils/index.cjs +2 -6
  66. package/dist/utils/index.d.cts +4 -5
  67. package/dist/utils/index.d.ts +4 -5
  68. package/dist/utils/index.js +3 -0
  69. package/dist/utils-Bs-jKit4.cjs +13 -0
  70. package/dist/utils-Sn10glI8.js +7 -0
  71. package/package.json +35 -25
  72. package/src/api/index.ts +57 -0
  73. package/src/async_hooks/index.ts +1 -9
  74. package/src/context/endpoint-context.ts +32 -0
  75. package/src/context/index.ts +6 -0
  76. package/src/context/transaction.ts +63 -0
  77. package/src/db/index.ts +2 -0
  78. package/src/db/type.ts +1 -10
  79. package/src/env/color-depth.ts +4 -5
  80. package/src/error/codes.ts +1 -1
  81. package/src/social-providers/apple.ts +2 -2
  82. package/src/social-providers/atlassian.ts +4 -7
  83. package/src/social-providers/cognito.ts +4 -7
  84. package/src/social-providers/discord.ts +2 -5
  85. package/src/social-providers/dropbox.ts +2 -2
  86. package/src/social-providers/facebook.ts +3 -6
  87. package/src/social-providers/figma.ts +4 -7
  88. package/src/social-providers/github.ts +2 -2
  89. package/src/social-providers/gitlab.ts +2 -2
  90. package/src/social-providers/google.ts +4 -7
  91. package/src/social-providers/huggingface.ts +2 -2
  92. package/src/social-providers/kakao.ts +2 -2
  93. package/src/social-providers/kick.ts +2 -5
  94. package/src/social-providers/line.ts +2 -2
  95. package/src/social-providers/linear.ts +2 -2
  96. package/src/social-providers/linkedin.ts +2 -2
  97. package/src/social-providers/microsoft-entra-id.ts +3 -3
  98. package/src/social-providers/naver.ts +2 -2
  99. package/src/social-providers/notion.ts +2 -2
  100. package/src/social-providers/paypal.ts +3 -3
  101. package/src/social-providers/reddit.ts +2 -2
  102. package/src/social-providers/roblox.ts +2 -5
  103. package/src/social-providers/salesforce.ts +4 -7
  104. package/src/social-providers/slack.ts +2 -5
  105. package/src/social-providers/spotify.ts +2 -2
  106. package/src/social-providers/tiktok.ts +2 -5
  107. package/src/social-providers/twitch.ts +3 -3
  108. package/src/social-providers/twitter.ts +2 -2
  109. package/src/social-providers/vk.ts +2 -5
  110. package/src/social-providers/zoom.ts +2 -5
  111. package/src/types/context.ts +20 -99
  112. package/src/types/index.ts +1 -1
  113. package/src/types/init-options.ts +20 -22
  114. package/src/types/plugin.ts +3 -3
  115. package/{build.config.ts → tsdown.config.ts} +8 -11
  116. package/dist/async_hooks/index.d.mts +0 -10
  117. package/dist/async_hooks/index.mjs +0 -25
  118. package/dist/db/adapter/index.d.mts +0 -14
  119. package/dist/db/adapter/index.mjs +0 -1
  120. package/dist/db/index.d.mts +0 -39
  121. package/dist/db/index.mjs +0 -70
  122. package/dist/env/index.d.mts +0 -36
  123. package/dist/env/index.mjs +0 -297
  124. package/dist/error/index.d.mts +0 -33
  125. package/dist/error/index.mjs +0 -41
  126. package/dist/index.d.mts +0 -180
  127. package/dist/index.mjs +0 -1
  128. package/dist/middleware/index.cjs +0 -25
  129. package/dist/middleware/index.d.cts +0 -14
  130. package/dist/middleware/index.d.mts +0 -14
  131. package/dist/middleware/index.d.ts +0 -14
  132. package/dist/middleware/index.mjs +0 -21
  133. package/dist/oauth2/index.d.mts +0 -100
  134. package/dist/oauth2/index.mjs +0 -357
  135. package/dist/shared/core.BJPBStdk.d.ts +0 -1693
  136. package/dist/shared/core.Bl6TpxyD.d.mts +0 -181
  137. package/dist/shared/core.Bqe5IGAi.d.ts +0 -13
  138. package/dist/shared/core.BwoNUcJQ.d.cts +0 -53
  139. package/dist/shared/core.BwoNUcJQ.d.mts +0 -53
  140. package/dist/shared/core.BwoNUcJQ.d.ts +0 -53
  141. package/dist/shared/core.CajxAutx.d.cts +0 -143
  142. package/dist/shared/core.CajxAutx.d.mts +0 -143
  143. package/dist/shared/core.CajxAutx.d.ts +0 -143
  144. package/dist/shared/core.CkkLHQWc.d.mts +0 -1693
  145. package/dist/shared/core.DkdZ1o38.d.ts +0 -181
  146. package/dist/shared/core.Dl-70uns.d.cts +0 -84
  147. package/dist/shared/core.Dl-70uns.d.mts +0 -84
  148. package/dist/shared/core.Dl-70uns.d.ts +0 -84
  149. package/dist/shared/core.DyEdx0m7.d.cts +0 -181
  150. package/dist/shared/core.E9DfzGLz.d.mts +0 -13
  151. package/dist/shared/core.HqYn20Fi.d.cts +0 -13
  152. package/dist/shared/core.gYIBmdi1.d.cts +0 -1693
  153. package/dist/social-providers/index.d.mts +0 -3903
  154. package/dist/social-providers/index.mjs +0 -2743
  155. package/dist/utils/index.d.mts +0 -10
  156. package/dist/utils/index.mjs +0 -5
  157. package/src/middleware/index.ts +0 -33
@@ -1,14 +1,7 @@
1
- import '../../shared/core.CajxAutx.cjs';
2
- export { C as CleanedWhere, j as CustomAdapter, i as DBAdapter, D as DBAdapterDebugLogOption, g as DBAdapterFactoryConfig, k as DBAdapterInstance, f as DBAdapterSchemaCreation, h as DBTransactionAdapter, W as Where } from '../../shared/core.gYIBmdi1.cjs';
3
- import 'zod';
4
- import 'kysely';
5
- import 'better-sqlite3';
6
- import 'better-call';
7
- import '../../shared/core.Dl-70uns.cjs';
8
- import 'bun:sqlite';
9
- import 'node:sqlite';
10
- import '../../social-providers/index.cjs';
11
- import '@better-auth/core/oauth2';
12
- import '../../shared/core.DyEdx0m7.cjs';
13
- import '../../shared/core.BwoNUcJQ.cjs';
14
- import '@better-auth/core';
1
+ import "../../helper-DVgWo5zB.cjs";
2
+ import "../../index-CgIE2ECh.cjs";
3
+ import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-yBChAjSS.cjs";
4
+ import "../../index-_Oiv-VVr.cjs";
5
+ import "../../index-ehsSkBxt.cjs";
6
+ import "../../index-DFwrZMma.cjs";
7
+ export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -1,14 +1,7 @@
1
- import '../../shared/core.CajxAutx.js';
2
- export { C as CleanedWhere, j as CustomAdapter, i as DBAdapter, D as DBAdapterDebugLogOption, g as DBAdapterFactoryConfig, k as DBAdapterInstance, f as DBAdapterSchemaCreation, h as DBTransactionAdapter, W as Where } from '../../shared/core.BJPBStdk.js';
3
- import 'zod';
4
- import 'kysely';
5
- import 'better-sqlite3';
6
- import 'better-call';
7
- import '../../shared/core.Dl-70uns.js';
8
- import 'bun:sqlite';
9
- import 'node:sqlite';
10
- import '../../social-providers/index.js';
11
- import '@better-auth/core/oauth2';
12
- import '../../shared/core.DkdZ1o38.js';
13
- import '../../shared/core.BwoNUcJQ.js';
14
- import '@better-auth/core';
1
+ import "../../helper-Dm5AtPVS.js";
2
+ import "../../index-Cmh0x42V.js";
3
+ import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-OrTFOyAG.js";
4
+ import "../../index-ChlC5Vy3.js";
5
+ import "../../index-BPsqLi68.js";
6
+ import "../../index-CsHMVqbX.js";
7
+ export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -0,0 +1 @@
1
+ export { };
package/dist/db/index.cjs CHANGED
@@ -1,91 +1,68 @@
1
- 'use strict';
1
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
2
+ let zod = require("zod");
3
+ zod = require_chunk.__toESM(zod);
2
4
 
3
- const z = require('zod');
4
-
5
- function _interopNamespaceCompat(e) {
6
- if (e && typeof e === 'object' && 'default' in e) return e;
7
- const n = Object.create(null);
8
- if (e) {
9
- for (const k in e) {
10
- n[k] = e[k];
11
- }
12
- }
13
- n.default = e;
14
- return n;
15
- }
16
-
17
- const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
18
-
19
- const coreSchema = z__namespace.object({
20
- id: z__namespace.string(),
21
- createdAt: z__namespace.date().default(() => /* @__PURE__ */ new Date()),
22
- updatedAt: z__namespace.date().default(() => /* @__PURE__ */ new Date())
5
+ //#region src/db/schema/shared.ts
6
+ const coreSchema = zod.object({
7
+ id: zod.string(),
8
+ createdAt: zod.date().default(() => /* @__PURE__ */ new Date()),
9
+ updatedAt: zod.date().default(() => /* @__PURE__ */ new Date())
23
10
  });
24
11
 
12
+ //#endregion
13
+ //#region src/db/schema/user.ts
25
14
  const userSchema = coreSchema.extend({
26
- email: z__namespace.string().transform((val) => val.toLowerCase()),
27
- emailVerified: z__namespace.boolean().default(false),
28
- name: z__namespace.string(),
29
- image: z__namespace.string().nullish()
15
+ email: zod.string().transform((val) => val.toLowerCase()),
16
+ emailVerified: zod.boolean().default(false),
17
+ name: zod.string(),
18
+ image: zod.string().nullish()
30
19
  });
31
20
 
21
+ //#endregion
22
+ //#region src/db/schema/account.ts
32
23
  const accountSchema = coreSchema.extend({
33
- providerId: z__namespace.string(),
34
- accountId: z__namespace.string(),
35
- userId: z__namespace.coerce.string(),
36
- accessToken: z__namespace.string().nullish(),
37
- refreshToken: z__namespace.string().nullish(),
38
- idToken: z__namespace.string().nullish(),
39
- /**
40
- * Access token expires at
41
- */
42
- accessTokenExpiresAt: z__namespace.date().nullish(),
43
- /**
44
- * Refresh token expires at
45
- */
46
- refreshTokenExpiresAt: z__namespace.date().nullish(),
47
- /**
48
- * The scopes that the user has authorized
49
- */
50
- scope: z__namespace.string().nullish(),
51
- /**
52
- * Password is only stored in the credential provider
53
- */
54
- password: z__namespace.string().nullish()
24
+ providerId: zod.string(),
25
+ accountId: zod.string(),
26
+ userId: zod.coerce.string(),
27
+ accessToken: zod.string().nullish(),
28
+ refreshToken: zod.string().nullish(),
29
+ idToken: zod.string().nullish(),
30
+ accessTokenExpiresAt: zod.date().nullish(),
31
+ refreshTokenExpiresAt: zod.date().nullish(),
32
+ scope: zod.string().nullish(),
33
+ password: zod.string().nullish()
55
34
  });
56
35
 
36
+ //#endregion
37
+ //#region src/db/schema/session.ts
57
38
  const sessionSchema = coreSchema.extend({
58
- userId: z__namespace.coerce.string(),
59
- expiresAt: z__namespace.date(),
60
- token: z__namespace.string(),
61
- ipAddress: z__namespace.string().nullish(),
62
- userAgent: z__namespace.string().nullish()
39
+ userId: zod.coerce.string(),
40
+ expiresAt: zod.date(),
41
+ token: zod.string(),
42
+ ipAddress: zod.string().nullish(),
43
+ userAgent: zod.string().nullish()
63
44
  });
64
45
 
46
+ //#endregion
47
+ //#region src/db/schema/verification.ts
65
48
  const verificationSchema = coreSchema.extend({
66
- value: z__namespace.string(),
67
- expiresAt: z__namespace.date(),
68
- identifier: z__namespace.string()
49
+ value: zod.string(),
50
+ expiresAt: zod.date(),
51
+ identifier: zod.string()
69
52
  });
70
53
 
71
- const rateLimitSchema = z__namespace.object({
72
- /**
73
- * The key to use for rate limiting
74
- */
75
- key: z__namespace.string(),
76
- /**
77
- * The number of requests made
78
- */
79
- count: z__namespace.number(),
80
- /**
81
- * The last request time in milliseconds
82
- */
83
- lastRequest: z__namespace.number()
54
+ //#endregion
55
+ //#region src/db/schema/rate-limit.ts
56
+ const rateLimitSchema = zod.object({
57
+ key: zod.string(),
58
+ count: zod.number(),
59
+ lastRequest: zod.number()
84
60
  });
85
61
 
62
+ //#endregion
86
63
  exports.accountSchema = accountSchema;
87
64
  exports.coreSchema = coreSchema;
88
65
  exports.rateLimitSchema = rateLimitSchema;
89
66
  exports.sessionSchema = sessionSchema;
90
67
  exports.userSchema = userSchema;
91
- exports.verificationSchema = verificationSchema;
68
+ exports.verificationSchema = verificationSchema;
@@ -1,39 +1,3 @@
1
- import { D as DBFieldAttribute, b as DBFieldAttributeConfig, c as DBFieldType, d as DBPrimitive, B as BetterAuthDBSchema } from '../shared/core.CajxAutx.cjs';
2
- export { S as SecondaryStorage } from '../shared/core.CajxAutx.cjs';
3
- import { B as BetterAuthPluginDBSchema } from '../shared/core.HqYn20Fi.cjs';
4
- import * as z from 'zod';
5
- export { A as Account, R as RateLimit, S as Session, U as User, V as Verification, a as accountSchema, r as rateLimitSchema, s as sessionSchema, u as userSchema, v as verificationSchema } from '../shared/core.Dl-70uns.cjs';
6
-
7
- declare const coreSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- createdAt: z.ZodDefault<z.ZodDate>;
10
- updatedAt: z.ZodDefault<z.ZodDate>;
11
- }, z.core.$strip>;
12
-
13
- /**
14
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
15
- */
16
- type AuthPluginSchema = BetterAuthPluginDBSchema;
17
- /**
18
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
19
- */
20
- type FieldAttribute = DBFieldAttribute;
21
- /**
22
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
23
- */
24
- type FieldAttributeConfig = DBFieldAttributeConfig;
25
- /**
26
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
27
- */
28
- type FieldType = DBFieldType;
29
- /**
30
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
31
- */
32
- type Primitive = DBPrimitive;
33
- /**
34
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
35
- */
36
- type BetterAuthDbSchema = BetterAuthDBSchema;
37
-
38
- export { BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, coreSchema };
39
- export type { AuthPluginSchema, BetterAuthDbSchema, FieldAttribute, FieldAttributeConfig, FieldType, Primitive };
1
+ import "../helper-DVgWo5zB.cjs";
2
+ import { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema } from "../index-CgIE2ECh.cjs";
3
+ export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -1,39 +1,3 @@
1
- import { D as DBFieldAttribute, b as DBFieldAttributeConfig, c as DBFieldType, d as DBPrimitive, B as BetterAuthDBSchema } from '../shared/core.CajxAutx.js';
2
- export { S as SecondaryStorage } from '../shared/core.CajxAutx.js';
3
- import { B as BetterAuthPluginDBSchema } from '../shared/core.Bqe5IGAi.js';
4
- import * as z from 'zod';
5
- export { A as Account, R as RateLimit, S as Session, U as User, V as Verification, a as accountSchema, r as rateLimitSchema, s as sessionSchema, u as userSchema, v as verificationSchema } from '../shared/core.Dl-70uns.js';
6
-
7
- declare const coreSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- createdAt: z.ZodDefault<z.ZodDate>;
10
- updatedAt: z.ZodDefault<z.ZodDate>;
11
- }, z.core.$strip>;
12
-
13
- /**
14
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
15
- */
16
- type AuthPluginSchema = BetterAuthPluginDBSchema;
17
- /**
18
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
19
- */
20
- type FieldAttribute = DBFieldAttribute;
21
- /**
22
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
23
- */
24
- type FieldAttributeConfig = DBFieldAttributeConfig;
25
- /**
26
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
27
- */
28
- type FieldType = DBFieldType;
29
- /**
30
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
31
- */
32
- type Primitive = DBPrimitive;
33
- /**
34
- * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
35
- */
36
- type BetterAuthDbSchema = BetterAuthDBSchema;
37
-
38
- export { BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, coreSchema };
39
- export type { AuthPluginSchema, BetterAuthDbSchema, FieldAttribute, FieldAttributeConfig, FieldType, Primitive };
1
+ import "../helper-Dm5AtPVS.js";
2
+ import { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema } from "../index-Cmh0x42V.js";
3
+ export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -0,0 +1,61 @@
1
+ import * as z from "zod";
2
+
3
+ //#region src/db/schema/shared.ts
4
+ const coreSchema = z.object({
5
+ id: z.string(),
6
+ createdAt: z.date().default(() => /* @__PURE__ */ new Date()),
7
+ updatedAt: z.date().default(() => /* @__PURE__ */ new Date())
8
+ });
9
+
10
+ //#endregion
11
+ //#region src/db/schema/user.ts
12
+ const userSchema = coreSchema.extend({
13
+ email: z.string().transform((val) => val.toLowerCase()),
14
+ emailVerified: z.boolean().default(false),
15
+ name: z.string(),
16
+ image: z.string().nullish()
17
+ });
18
+
19
+ //#endregion
20
+ //#region src/db/schema/account.ts
21
+ const accountSchema = coreSchema.extend({
22
+ providerId: z.string(),
23
+ accountId: z.string(),
24
+ userId: z.coerce.string(),
25
+ accessToken: z.string().nullish(),
26
+ refreshToken: z.string().nullish(),
27
+ idToken: z.string().nullish(),
28
+ accessTokenExpiresAt: z.date().nullish(),
29
+ refreshTokenExpiresAt: z.date().nullish(),
30
+ scope: z.string().nullish(),
31
+ password: z.string().nullish()
32
+ });
33
+
34
+ //#endregion
35
+ //#region src/db/schema/session.ts
36
+ const sessionSchema = coreSchema.extend({
37
+ userId: z.coerce.string(),
38
+ expiresAt: z.date(),
39
+ token: z.string(),
40
+ ipAddress: z.string().nullish(),
41
+ userAgent: z.string().nullish()
42
+ });
43
+
44
+ //#endregion
45
+ //#region src/db/schema/verification.ts
46
+ const verificationSchema = coreSchema.extend({
47
+ value: z.string(),
48
+ expiresAt: z.date(),
49
+ identifier: z.string()
50
+ });
51
+
52
+ //#endregion
53
+ //#region src/db/schema/rate-limit.ts
54
+ const rateLimitSchema = z.object({
55
+ key: z.string(),
56
+ count: z.number(),
57
+ lastRequest: z.number()
58
+ });
59
+
60
+ //#endregion
61
+ export { accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -1,312 +1,16 @@
1
- 'use strict';
1
+ const require_env = require('../env-D1OdwBk9.cjs');
2
2
 
3
- const _envShim = /* @__PURE__ */ Object.create(null);
4
- const _getEnv = (useShim) => globalThis.process?.env || //@ts-expect-error
5
- globalThis.Deno?.env.toObject() || //@ts-expect-error
6
- globalThis.__env__ || (useShim ? _envShim : globalThis);
7
- const env = new Proxy(_envShim, {
8
- get(_, prop) {
9
- const env2 = _getEnv();
10
- return env2[prop] ?? _envShim[prop];
11
- },
12
- has(_, prop) {
13
- const env2 = _getEnv();
14
- return prop in env2 || prop in _envShim;
15
- },
16
- set(_, prop, value) {
17
- const env2 = _getEnv(true);
18
- env2[prop] = value;
19
- return true;
20
- },
21
- deleteProperty(_, prop) {
22
- if (!prop) {
23
- return false;
24
- }
25
- const env2 = _getEnv(true);
26
- delete env2[prop];
27
- return true;
28
- },
29
- ownKeys() {
30
- const env2 = _getEnv(true);
31
- return Object.keys(env2);
32
- }
33
- });
34
- function toBoolean(val) {
35
- return val ? val !== "false" : false;
36
- }
37
- const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
38
- const isProduction = nodeENV === "production";
39
- const isDevelopment = nodeENV === "dev" || nodeENV === "development";
40
- const isTest = () => nodeENV === "test" || toBoolean(env.TEST);
41
- function getEnvVar(key, fallback) {
42
- if (typeof process !== "undefined" && process.env) {
43
- return process.env[key] ?? fallback;
44
- }
45
- if (typeof Deno !== "undefined") {
46
- return Deno.env.get(key) ?? fallback;
47
- }
48
- if (typeof Bun !== "undefined") {
49
- return Bun.env[key] ?? fallback;
50
- }
51
- return fallback;
52
- }
53
- function getBooleanEnvVar(key, fallback = true) {
54
- const value = getEnvVar(key);
55
- if (!value) return fallback;
56
- return value !== "0" && value.toLowerCase() !== "false" && value !== "";
57
- }
58
- const ENV = Object.freeze({
59
- get BETTER_AUTH_SECRET() {
60
- return getEnvVar("BETTER_AUTH_SECRET");
61
- },
62
- get AUTH_SECRET() {
63
- return getEnvVar("AUTH_SECRET");
64
- },
65
- get BETTER_AUTH_TELEMETRY() {
66
- return getEnvVar("BETTER_AUTH_TELEMETRY");
67
- },
68
- get BETTER_AUTH_TELEMETRY_ID() {
69
- return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
70
- },
71
- get NODE_ENV() {
72
- return getEnvVar("NODE_ENV", "development");
73
- },
74
- get PACKAGE_VERSION() {
75
- return getEnvVar("PACKAGE_VERSION", "0.0.0");
76
- },
77
- get BETTER_AUTH_TELEMETRY_ENDPOINT() {
78
- return getEnvVar(
79
- "BETTER_AUTH_TELEMETRY_ENDPOINT",
80
- "https://telemetry.better-auth.com/v1/track"
81
- );
82
- }
83
- });
84
-
85
- const COLORS_2 = 1;
86
- const COLORS_16 = 4;
87
- const COLORS_256 = 8;
88
- const COLORS_16m = 24;
89
- const TERM_ENVS = {
90
- eterm: COLORS_16,
91
- cons25: COLORS_16,
92
- console: COLORS_16,
93
- cygwin: COLORS_16,
94
- dtterm: COLORS_16,
95
- gnome: COLORS_16,
96
- hurd: COLORS_16,
97
- jfbterm: COLORS_16,
98
- konsole: COLORS_16,
99
- kterm: COLORS_16,
100
- mlterm: COLORS_16,
101
- mosh: COLORS_16m,
102
- putty: COLORS_16,
103
- st: COLORS_16,
104
- // http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
105
- "rxvt-unicode-24bit": COLORS_16m,
106
- // https://bugs.launchpad.net/terminator/+bug/1030562
107
- terminator: COLORS_16m,
108
- "xterm-kitty": COLORS_16m
109
- };
110
- const CI_ENVS_MAP = new Map(
111
- Object.entries({
112
- APPVEYOR: COLORS_256,
113
- BUILDKITE: COLORS_256,
114
- CIRCLECI: COLORS_16m,
115
- DRONE: COLORS_256,
116
- GITEA_ACTIONS: COLORS_16m,
117
- GITHUB_ACTIONS: COLORS_16m,
118
- GITLAB_CI: COLORS_256,
119
- TRAVIS: COLORS_256
120
- })
121
- );
122
- const TERM_ENVS_REG_EXP = [
123
- /ansi/,
124
- /color/,
125
- /linux/,
126
- /direct/,
127
- /^con[0-9]*x[0-9]/,
128
- /^rxvt/,
129
- /^screen/,
130
- /^xterm/,
131
- /^vt100/,
132
- /^vt220/
133
- ];
134
- function getColorDepth() {
135
- if (getEnvVar("FORCE_COLOR") !== void 0) {
136
- switch (getEnvVar("FORCE_COLOR")) {
137
- case "":
138
- case "1":
139
- case "true":
140
- return COLORS_16;
141
- case "2":
142
- return COLORS_256;
143
- case "3":
144
- return COLORS_16m;
145
- default:
146
- return COLORS_2;
147
- }
148
- }
149
- if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || // See https://no-color.org/
150
- getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || // The "dumb" special terminal, as defined by terminfo, doesn't support
151
- // ANSI color control codes.
152
- // See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
153
- getEnvVar("TERM") === "dumb") {
154
- return COLORS_2;
155
- }
156
- if (getEnvVar("TMUX")) {
157
- return COLORS_16m;
158
- }
159
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
160
- return COLORS_16;
161
- }
162
- if ("CI" in env) {
163
- for (const { 0: envName, 1: colors } of CI_ENVS_MAP) {
164
- if (envName in env) {
165
- return colors;
166
- }
167
- }
168
- if (getEnvVar("CI_NAME") === "codeship") {
169
- return COLORS_256;
170
- }
171
- return COLORS_2;
172
- }
173
- if ("TEAMCITY_VERSION" in env) {
174
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(
175
- getEnvVar("TEAMCITY_VERSION")
176
- ) !== null ? COLORS_16 : COLORS_2;
177
- }
178
- switch (getEnvVar("TERM_PROGRAM")) {
179
- case "iTerm.app":
180
- if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) {
181
- return COLORS_256;
182
- }
183
- return COLORS_16m;
184
- case "HyperTerm":
185
- case "MacTerm":
186
- return COLORS_16m;
187
- case "Apple_Terminal":
188
- return COLORS_256;
189
- }
190
- if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") {
191
- return COLORS_16m;
192
- }
193
- if (getEnvVar("TERM")) {
194
- if (/truecolor/.exec(getEnvVar("TERM")) !== null) {
195
- return COLORS_16m;
196
- }
197
- if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) {
198
- return COLORS_256;
199
- }
200
- const termEnv = getEnvVar("TERM").toLowerCase();
201
- if (TERM_ENVS[termEnv]) {
202
- return TERM_ENVS[termEnv];
203
- }
204
- if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {
205
- return COLORS_16;
206
- }
207
- }
208
- if (getEnvVar("COLORTERM")) {
209
- return COLORS_16;
210
- }
211
- return COLORS_2;
212
- }
213
-
214
- const TTY_COLORS = {
215
- reset: "\x1B[0m",
216
- bright: "\x1B[1m",
217
- dim: "\x1B[2m",
218
- undim: "\x1B[22m",
219
- underscore: "\x1B[4m",
220
- blink: "\x1B[5m",
221
- reverse: "\x1B[7m",
222
- hidden: "\x1B[8m",
223
- fg: {
224
- black: "\x1B[30m",
225
- red: "\x1B[31m",
226
- green: "\x1B[32m",
227
- yellow: "\x1B[33m",
228
- blue: "\x1B[34m",
229
- magenta: "\x1B[35m",
230
- cyan: "\x1B[36m",
231
- white: "\x1B[37m"
232
- },
233
- bg: {
234
- black: "\x1B[40m",
235
- red: "\x1B[41m",
236
- green: "\x1B[42m",
237
- yellow: "\x1B[43m",
238
- blue: "\x1B[44m",
239
- magenta: "\x1B[45m",
240
- cyan: "\x1B[46m",
241
- white: "\x1B[47m"
242
- }
243
- };
244
- const levels = ["info", "success", "warn", "error", "debug"];
245
- function shouldPublishLog(currentLogLevel, logLevel) {
246
- return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
247
- }
248
- const levelColors = {
249
- info: TTY_COLORS.fg.blue,
250
- success: TTY_COLORS.fg.green,
251
- warn: TTY_COLORS.fg.yellow,
252
- error: TTY_COLORS.fg.red,
253
- debug: TTY_COLORS.fg.magenta
254
- };
255
- const formatMessage = (level, message, colorsEnabled) => {
256
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
257
- if (colorsEnabled) {
258
- return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
259
- }
260
- return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
261
- };
262
- const createLogger = (options) => {
263
- const enabled = options?.disabled !== true;
264
- const logLevel = options?.level ?? "error";
265
- const isDisableColorsSpecified = options?.disableColors !== void 0;
266
- const colorsEnabled = isDisableColorsSpecified ? !options.disableColors : getColorDepth() !== 1;
267
- const LogFunc = (level, message, args = []) => {
268
- if (!enabled || !shouldPublishLog(logLevel, level)) {
269
- return;
270
- }
271
- const formattedMessage = formatMessage(level, message, colorsEnabled);
272
- if (!options || typeof options.log !== "function") {
273
- if (level === "error") {
274
- console.error(formattedMessage, ...args);
275
- } else if (level === "warn") {
276
- console.warn(formattedMessage, ...args);
277
- } else {
278
- console.log(formattedMessage, ...args);
279
- }
280
- return;
281
- }
282
- options.log(level === "success" ? "info" : level, message, ...args);
283
- };
284
- const logger2 = Object.fromEntries(
285
- levels.map((level) => [
286
- level,
287
- (...[message, ...args]) => LogFunc(level, message, args)
288
- ])
289
- );
290
- return {
291
- ...logger2,
292
- get level() {
293
- return logLevel;
294
- }
295
- };
296
- };
297
- const logger = createLogger();
298
-
299
- exports.ENV = ENV;
300
- exports.TTY_COLORS = TTY_COLORS;
301
- exports.createLogger = createLogger;
302
- exports.env = env;
303
- exports.getBooleanEnvVar = getBooleanEnvVar;
304
- exports.getColorDepth = getColorDepth;
305
- exports.getEnvVar = getEnvVar;
306
- exports.isDevelopment = isDevelopment;
307
- exports.isProduction = isProduction;
308
- exports.isTest = isTest;
309
- exports.levels = levels;
310
- exports.logger = logger;
311
- exports.nodeENV = nodeENV;
312
- exports.shouldPublishLog = shouldPublishLog;
3
+ exports.ENV = require_env.ENV;
4
+ exports.TTY_COLORS = require_env.TTY_COLORS;
5
+ exports.createLogger = require_env.createLogger;
6
+ exports.env = require_env.env;
7
+ exports.getBooleanEnvVar = require_env.getBooleanEnvVar;
8
+ exports.getColorDepth = require_env.getColorDepth;
9
+ exports.getEnvVar = require_env.getEnvVar;
10
+ exports.isDevelopment = require_env.isDevelopment;
11
+ exports.isProduction = require_env.isProduction;
12
+ exports.isTest = require_env.isTest;
13
+ exports.levels = require_env.levels;
14
+ exports.logger = require_env.logger;
15
+ exports.nodeENV = require_env.nodeENV;
16
+ exports.shouldPublishLog = require_env.shouldPublishLog;