@better-auth/core 1.4.17 → 1.5.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 (278) hide show
  1. package/.turbo/turbo-build.log +259 -178
  2. package/LICENSE.md +15 -12
  3. package/dist/api/index.d.mts +27 -28
  4. package/dist/api/index.mjs +2 -1
  5. package/dist/api/index.mjs.map +1 -0
  6. package/dist/async_hooks/index.d.mts +2 -1
  7. package/dist/async_hooks/index.mjs +2 -1
  8. package/dist/async_hooks/index.mjs.map +1 -0
  9. package/dist/async_hooks/pure.index.d.mts +2 -1
  10. package/dist/async_hooks/pure.index.mjs +2 -1
  11. package/dist/async_hooks/pure.index.mjs.map +1 -0
  12. package/dist/context/endpoint-context.d.mts +3 -2
  13. package/dist/context/endpoint-context.mjs +4 -3
  14. package/dist/context/endpoint-context.mjs.map +1 -0
  15. package/dist/context/global.d.mts +2 -2
  16. package/dist/context/global.mjs +3 -2
  17. package/dist/context/global.mjs.map +1 -0
  18. package/dist/context/index.d.mts +2 -2
  19. package/dist/context/index.mjs +2 -2
  20. package/dist/context/request-state.d.mts +2 -1
  21. package/dist/context/request-state.mjs +4 -3
  22. package/dist/context/request-state.mjs.map +1 -0
  23. package/dist/context/transaction.d.mts +12 -3
  24. package/dist/context/transaction.mjs +55 -11
  25. package/dist/context/transaction.mjs.map +1 -0
  26. package/dist/db/adapter/factory.d.mts +3 -10
  27. package/dist/db/adapter/factory.mjs +27 -54
  28. package/dist/db/adapter/factory.mjs.map +1 -0
  29. package/dist/db/adapter/get-default-field-name.d.mts +2 -1
  30. package/dist/db/adapter/get-default-field-name.mjs +3 -2
  31. package/dist/db/adapter/get-default-field-name.mjs.map +1 -0
  32. package/dist/db/adapter/get-default-model-name.d.mts +2 -1
  33. package/dist/db/adapter/get-default-model-name.mjs +5 -4
  34. package/dist/db/adapter/get-default-model-name.mjs.map +1 -0
  35. package/dist/db/adapter/get-field-attributes.d.mts +3 -2
  36. package/dist/db/adapter/get-field-attributes.mjs +2 -1
  37. package/dist/db/adapter/get-field-attributes.mjs.map +1 -0
  38. package/dist/db/adapter/get-field-name.d.mts +2 -1
  39. package/dist/db/adapter/get-field-name.mjs +2 -1
  40. package/dist/db/adapter/get-field-name.mjs.map +1 -0
  41. package/dist/db/adapter/get-id-field.d.mts +3 -2
  42. package/dist/db/adapter/get-id-field.mjs +3 -3
  43. package/dist/db/adapter/get-id-field.mjs.map +1 -0
  44. package/dist/db/adapter/get-model-name.d.mts +2 -1
  45. package/dist/db/adapter/get-model-name.mjs +2 -1
  46. package/dist/db/adapter/get-model-name.mjs.map +1 -0
  47. package/dist/db/adapter/index.d.mts +4 -3
  48. package/dist/db/adapter/index.mjs +2 -2
  49. package/dist/db/adapter/types.d.mts +4 -35
  50. package/dist/db/adapter/utils.d.mts +2 -1
  51. package/dist/db/adapter/utils.mjs +2 -1
  52. package/dist/db/adapter/utils.mjs.map +1 -0
  53. package/dist/db/get-tables.d.mts +2 -1
  54. package/dist/db/get-tables.mjs +46 -39
  55. package/dist/db/get-tables.mjs.map +1 -0
  56. package/dist/db/plugin.d.mts +2 -1
  57. package/dist/db/schema/account.d.mts +2 -1
  58. package/dist/db/schema/account.mjs +2 -1
  59. package/dist/db/schema/account.mjs.map +1 -0
  60. package/dist/db/schema/rate-limit.d.mts +2 -1
  61. package/dist/db/schema/rate-limit.mjs +2 -1
  62. package/dist/db/schema/rate-limit.mjs.map +1 -0
  63. package/dist/db/schema/session.d.mts +2 -1
  64. package/dist/db/schema/session.mjs +2 -1
  65. package/dist/db/schema/session.mjs.map +1 -0
  66. package/dist/db/schema/shared.d.mts +2 -1
  67. package/dist/db/schema/shared.mjs +2 -1
  68. package/dist/db/schema/shared.mjs.map +1 -0
  69. package/dist/db/schema/user.d.mts +2 -1
  70. package/dist/db/schema/user.mjs +2 -1
  71. package/dist/db/schema/user.mjs.map +1 -0
  72. package/dist/db/schema/verification.d.mts +2 -1
  73. package/dist/db/schema/verification.mjs +2 -1
  74. package/dist/db/schema/verification.mjs.map +1 -0
  75. package/dist/db/type.d.mts +5 -1
  76. package/dist/env/color-depth.d.mts +2 -1
  77. package/dist/env/color-depth.mjs +2 -1
  78. package/dist/env/color-depth.mjs.map +1 -0
  79. package/dist/env/env-impl.d.mts +3 -2
  80. package/dist/env/env-impl.mjs +9 -8
  81. package/dist/env/env-impl.mjs.map +1 -0
  82. package/dist/env/logger.d.mts +2 -1
  83. package/dist/env/logger.mjs +3 -2
  84. package/dist/env/logger.mjs.map +1 -0
  85. package/dist/error/codes.d.mts +65 -44
  86. package/dist/error/codes.mjs +8 -3
  87. package/dist/error/codes.mjs.map +1 -0
  88. package/dist/error/index.d.mts +12 -2
  89. package/dist/error/index.mjs +17 -1
  90. package/dist/error/index.mjs.map +1 -0
  91. package/dist/index.d.mts +5 -5
  92. package/dist/oauth2/client-credentials-token.d.mts +2 -1
  93. package/dist/oauth2/client-credentials-token.mjs +2 -1
  94. package/dist/oauth2/client-credentials-token.mjs.map +1 -0
  95. package/dist/oauth2/create-authorization-url.d.mts +2 -1
  96. package/dist/oauth2/create-authorization-url.mjs +2 -1
  97. package/dist/oauth2/create-authorization-url.mjs.map +1 -0
  98. package/dist/oauth2/oauth-provider.d.mts +3 -2
  99. package/dist/oauth2/refresh-access-token.d.mts +2 -3
  100. package/dist/oauth2/refresh-access-token.mjs +2 -1
  101. package/dist/oauth2/refresh-access-token.mjs.map +1 -0
  102. package/dist/oauth2/utils.d.mts +2 -1
  103. package/dist/oauth2/utils.mjs +2 -1
  104. package/dist/oauth2/utils.mjs.map +1 -0
  105. package/dist/oauth2/validate-authorization-code.d.mts +2 -1
  106. package/dist/oauth2/validate-authorization-code.mjs +6 -5
  107. package/dist/oauth2/validate-authorization-code.mjs.map +1 -0
  108. package/dist/oauth2/verify.d.mts +7 -13
  109. package/dist/oauth2/verify.mjs +3 -2
  110. package/dist/oauth2/verify.mjs.map +1 -0
  111. package/dist/social-providers/apple.d.mts +2 -1
  112. package/dist/social-providers/apple.mjs +6 -3
  113. package/dist/social-providers/apple.mjs.map +1 -0
  114. package/dist/social-providers/atlassian.d.mts +2 -1
  115. package/dist/social-providers/atlassian.mjs +2 -1
  116. package/dist/social-providers/atlassian.mjs.map +1 -0
  117. package/dist/social-providers/cognito.d.mts +2 -1
  118. package/dist/social-providers/cognito.mjs +3 -3
  119. package/dist/social-providers/cognito.mjs.map +1 -0
  120. package/dist/social-providers/discord.d.mts +2 -1
  121. package/dist/social-providers/discord.mjs +2 -1
  122. package/dist/social-providers/discord.mjs.map +1 -0
  123. package/dist/social-providers/dropbox.d.mts +2 -1
  124. package/dist/social-providers/dropbox.mjs +3 -2
  125. package/dist/social-providers/dropbox.mjs.map +1 -0
  126. package/dist/social-providers/facebook.d.mts +2 -1
  127. package/dist/social-providers/facebook.mjs +13 -12
  128. package/dist/social-providers/facebook.mjs.map +1 -0
  129. package/dist/social-providers/figma.d.mts +2 -1
  130. package/dist/social-providers/figma.mjs +2 -1
  131. package/dist/social-providers/figma.mjs.map +1 -0
  132. package/dist/social-providers/github.d.mts +3 -2
  133. package/dist/social-providers/github.mjs +22 -5
  134. package/dist/social-providers/github.mjs.map +1 -0
  135. package/dist/social-providers/gitlab.d.mts +2 -1
  136. package/dist/social-providers/gitlab.mjs +2 -1
  137. package/dist/social-providers/gitlab.mjs.map +1 -0
  138. package/dist/social-providers/google.d.mts +2 -1
  139. package/dist/social-providers/google.mjs +5 -5
  140. package/dist/social-providers/google.mjs.map +1 -0
  141. package/dist/social-providers/huggingface.d.mts +2 -1
  142. package/dist/social-providers/huggingface.mjs +2 -1
  143. package/dist/social-providers/huggingface.mjs.map +1 -0
  144. package/dist/social-providers/index.d.mts +3 -2
  145. package/dist/social-providers/index.mjs +2 -1
  146. package/dist/social-providers/index.mjs.map +1 -0
  147. package/dist/social-providers/kakao.d.mts +2 -1
  148. package/dist/social-providers/kakao.mjs +2 -1
  149. package/dist/social-providers/kakao.mjs.map +1 -0
  150. package/dist/social-providers/kick.d.mts +2 -1
  151. package/dist/social-providers/kick.mjs +2 -1
  152. package/dist/social-providers/kick.mjs.map +1 -0
  153. package/dist/social-providers/line.d.mts +2 -1
  154. package/dist/social-providers/line.mjs +2 -1
  155. package/dist/social-providers/line.mjs.map +1 -0
  156. package/dist/social-providers/linear.d.mts +2 -1
  157. package/dist/social-providers/linear.mjs +2 -1
  158. package/dist/social-providers/linear.mjs.map +1 -0
  159. package/dist/social-providers/linkedin.d.mts +2 -1
  160. package/dist/social-providers/linkedin.mjs +2 -1
  161. package/dist/social-providers/linkedin.mjs.map +1 -0
  162. package/dist/social-providers/microsoft-entra-id.d.mts +2 -1
  163. package/dist/social-providers/microsoft-entra-id.mjs +2 -1
  164. package/dist/social-providers/microsoft-entra-id.mjs.map +1 -0
  165. package/dist/social-providers/naver.d.mts +11 -20
  166. package/dist/social-providers/naver.mjs +2 -1
  167. package/dist/social-providers/naver.mjs.map +1 -0
  168. package/dist/social-providers/notion.d.mts +2 -1
  169. package/dist/social-providers/notion.mjs +2 -1
  170. package/dist/social-providers/notion.mjs.map +1 -0
  171. package/dist/social-providers/paybin.d.mts +2 -1
  172. package/dist/social-providers/paybin.mjs +2 -1
  173. package/dist/social-providers/paybin.mjs.map +1 -0
  174. package/dist/social-providers/paypal.d.mts +2 -1
  175. package/dist/social-providers/paypal.mjs +2 -1
  176. package/dist/social-providers/paypal.mjs.map +1 -0
  177. package/dist/social-providers/polar.d.mts +2 -1
  178. package/dist/social-providers/polar.mjs +2 -1
  179. package/dist/social-providers/polar.mjs.map +1 -0
  180. package/dist/social-providers/reddit.d.mts +2 -1
  181. package/dist/social-providers/reddit.mjs +2 -1
  182. package/dist/social-providers/reddit.mjs.map +1 -0
  183. package/dist/social-providers/roblox.d.mts +2 -1
  184. package/dist/social-providers/roblox.mjs +2 -1
  185. package/dist/social-providers/roblox.mjs.map +1 -0
  186. package/dist/social-providers/salesforce.d.mts +2 -1
  187. package/dist/social-providers/salesforce.mjs +2 -1
  188. package/dist/social-providers/salesforce.mjs.map +1 -0
  189. package/dist/social-providers/slack.d.mts +2 -1
  190. package/dist/social-providers/slack.mjs +2 -1
  191. package/dist/social-providers/slack.mjs.map +1 -0
  192. package/dist/social-providers/spotify.d.mts +2 -1
  193. package/dist/social-providers/spotify.mjs +2 -1
  194. package/dist/social-providers/spotify.mjs.map +1 -0
  195. package/dist/social-providers/tiktok.d.mts +3 -3
  196. package/dist/social-providers/tiktok.mjs +2 -1
  197. package/dist/social-providers/tiktok.mjs.map +1 -0
  198. package/dist/social-providers/twitch.d.mts +2 -1
  199. package/dist/social-providers/twitch.mjs +2 -1
  200. package/dist/social-providers/twitch.mjs.map +1 -0
  201. package/dist/social-providers/twitter.d.mts +14 -25
  202. package/dist/social-providers/twitter.mjs +2 -1
  203. package/dist/social-providers/twitter.mjs.map +1 -0
  204. package/dist/social-providers/vercel.d.mts +2 -1
  205. package/dist/social-providers/vercel.mjs +2 -1
  206. package/dist/social-providers/vercel.mjs.map +1 -0
  207. package/dist/social-providers/vk.d.mts +2 -1
  208. package/dist/social-providers/vk.mjs +2 -1
  209. package/dist/social-providers/vk.mjs.map +1 -0
  210. package/dist/social-providers/zoom.d.mts +3 -10
  211. package/dist/social-providers/zoom.mjs +2 -1
  212. package/dist/social-providers/zoom.mjs.map +1 -0
  213. package/dist/types/context.d.mts +64 -11
  214. package/dist/types/cookie.d.mts +2 -1
  215. package/dist/types/helper.d.mts +3 -1
  216. package/dist/types/index.d.mts +4 -4
  217. package/dist/types/init-options.d.mts +79 -86
  218. package/dist/types/plugin-client.d.mts +10 -1
  219. package/dist/types/plugin.d.mts +12 -8
  220. package/dist/utils/db.d.mts +12 -0
  221. package/dist/utils/db.mjs +17 -0
  222. package/dist/utils/db.mjs.map +1 -0
  223. package/dist/utils/deprecate.d.mts +2 -2
  224. package/dist/utils/deprecate.mjs +2 -1
  225. package/dist/utils/deprecate.mjs.map +1 -0
  226. package/dist/utils/error-codes.d.mts +8 -3
  227. package/dist/utils/error-codes.mjs +7 -2
  228. package/dist/utils/error-codes.mjs.map +1 -0
  229. package/dist/utils/id.d.mts +2 -1
  230. package/dist/utils/id.mjs +2 -1
  231. package/dist/utils/id.mjs.map +1 -0
  232. package/dist/utils/ip.d.mts +2 -1
  233. package/dist/utils/ip.mjs +2 -1
  234. package/dist/utils/ip.mjs.map +1 -0
  235. package/dist/utils/json.d.mts +2 -1
  236. package/dist/utils/json.mjs +2 -1
  237. package/dist/utils/json.mjs.map +1 -0
  238. package/dist/utils/string.d.mts +2 -1
  239. package/dist/utils/string.mjs +2 -1
  240. package/dist/utils/string.mjs.map +1 -0
  241. package/dist/utils/url.d.mts +2 -1
  242. package/dist/utils/url.mjs +2 -1
  243. package/dist/utils/url.mjs.map +1 -0
  244. package/package.json +16 -13
  245. package/src/context/index.ts +1 -0
  246. package/src/context/transaction.ts +72 -9
  247. package/src/db/adapter/factory.ts +4 -54
  248. package/src/db/adapter/get-id-field.ts +2 -4
  249. package/src/db/adapter/types.ts +2 -41
  250. package/src/db/get-tables.ts +48 -37
  251. package/src/db/test/get-tables.test.ts +33 -0
  252. package/src/env/env-impl.ts +2 -2
  253. package/src/env/logger.ts +1 -1
  254. package/src/error/codes.ts +22 -1
  255. package/src/error/index.ts +26 -1
  256. package/src/oauth2/oauth-provider.ts +1 -1
  257. package/src/oauth2/refresh-access-token.ts +0 -2
  258. package/src/oauth2/validate-authorization-code.ts +7 -12
  259. package/src/oauth2/validate-token.test.ts +174 -0
  260. package/src/social-providers/apple.ts +14 -4
  261. package/src/social-providers/cognito.ts +1 -2
  262. package/src/social-providers/dropbox.ts +1 -1
  263. package/src/social-providers/facebook.ts +3 -3
  264. package/src/social-providers/github.ts +25 -3
  265. package/src/social-providers/google.ts +3 -4
  266. package/src/social-providers/zoom.ts +0 -8
  267. package/src/types/context.ts +94 -8
  268. package/src/types/helper.ts +8 -0
  269. package/src/types/index.ts +14 -2
  270. package/src/types/init-options.ts +83 -86
  271. package/src/types/plugin-client.ts +10 -0
  272. package/src/types/plugin.ts +9 -5
  273. package/src/utils/db.ts +20 -0
  274. package/src/utils/error-codes.ts +21 -4
  275. package/tsdown.config.ts +5 -1
  276. package/dist/utils/index.d.mts +0 -8
  277. package/dist/utils/index.mjs +0 -9
  278. package/src/utils/index.ts +0 -7
@@ -4,4 +4,5 @@ import { DBFieldAttribute } from "../type.mjs";
4
4
  declare function withApplyDefault(value: any, field: DBFieldAttribute, action: "create" | "update" | "findOne" | "findMany"): any;
5
5
  declare function deepmerge<T>(target: T, source: Partial<T>): T;
6
6
  //#endregion
7
- export { deepmerge, withApplyDefault };
7
+ export { deepmerge, withApplyDefault };
8
+ //# sourceMappingURL=utils.d.mts.map
@@ -35,4 +35,5 @@ function deepmerge(target, source) {
35
35
  }
36
36
 
37
37
  //#endregion
38
- export { deepmerge, withApplyDefault };
38
+ export { deepmerge, withApplyDefault };
39
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/db/adapter/utils.ts"],"sourcesContent":["import type { DBFieldAttribute } from \"../type\";\n\nexport function withApplyDefault(\n\tvalue: any,\n\tfield: DBFieldAttribute,\n\taction: \"create\" | \"update\" | \"findOne\" | \"findMany\",\n) {\n\tif (action === \"update\") {\n\t\t// Apply onUpdate if value is undefined\n\t\tif (value === undefined && field.onUpdate !== undefined) {\n\t\t\tif (typeof field.onUpdate === \"function\") {\n\t\t\t\treturn field.onUpdate();\n\t\t\t}\n\t\t\treturn field.onUpdate;\n\t\t}\n\t\treturn value;\n\t}\n\tif (action === \"create\") {\n\t\t// we do not want to apply default values if the value is null & not required\n\t\tif (value === undefined || (field.required === true && value === null)) {\n\t\t\tif (field.defaultValue !== undefined) {\n\t\t\t\tif (typeof field.defaultValue === \"function\") {\n\t\t\t\t\treturn field.defaultValue();\n\t\t\t\t}\n\t\t\t\treturn field.defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}\n\nfunction isObject(item: unknown): item is Record<string, unknown> {\n\treturn item !== null && typeof item === \"object\" && !Array.isArray(item);\n}\n\nexport function deepmerge<T>(target: T, source: Partial<T>): T {\n\tif (Array.isArray(target) && Array.isArray(source)) {\n\t\t// merge arrays by concatenation\n\t\treturn [...target, ...source] as T;\n\t} else if (isObject(target) && isObject(source)) {\n\t\tconst result: Record<string, unknown> = { ...target };\n\n\t\tfor (const [key, value] of Object.entries(source)) {\n\t\t\tif (value === undefined) continue; // skip undefined\n\n\t\t\tif (key in target) {\n\t\t\t\tresult[key] = deepmerge(\n\t\t\t\t\t(target as Record<string, unknown>)[key],\n\t\t\t\t\tvalue as unknown as Partial<T>,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tresult[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn result as T;\n\t}\n\n\t// primitives and fallback: source overrides target\n\treturn source as T;\n}\n"],"mappings":";AAEA,SAAgB,iBACf,OACA,OACA,QACC;AACD,KAAI,WAAW,UAAU;AAExB,MAAI,UAAU,UAAa,MAAM,aAAa,QAAW;AACxD,OAAI,OAAO,MAAM,aAAa,WAC7B,QAAO,MAAM,UAAU;AAExB,UAAO,MAAM;;AAEd,SAAO;;AAER,KAAI,WAAW,UAEd;MAAI,UAAU,UAAc,MAAM,aAAa,QAAQ,UAAU,MAChE;OAAI,MAAM,iBAAiB,QAAW;AACrC,QAAI,OAAO,MAAM,iBAAiB,WACjC,QAAO,MAAM,cAAc;AAE5B,WAAO,MAAM;;;;AAIhB,QAAO;;AAGR,SAAS,SAAS,MAAgD;AACjE,QAAO,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,KAAK;;AAGzE,SAAgB,UAAa,QAAW,QAAuB;AAC9D,KAAI,MAAM,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,CAEjD,QAAO,CAAC,GAAG,QAAQ,GAAG,OAAO;UACnB,SAAS,OAAO,IAAI,SAAS,OAAO,EAAE;EAChD,MAAM,SAAkC,EAAE,GAAG,QAAQ;AAErD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAAE;AAClD,OAAI,UAAU,OAAW;AAEzB,OAAI,OAAO,OACV,QAAO,OAAO,UACZ,OAAmC,MACpC,MACA;OAED,QAAO,OAAO;;AAIhB,SAAO;;AAIR,QAAO"}
@@ -5,4 +5,5 @@ import "../types/index.mjs";
5
5
  //#region src/db/get-tables.d.ts
6
6
  declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDBSchema;
7
7
  //#endregion
8
- export { getAuthTables };
8
+ export { getAuthTables };
9
+ //# sourceMappingURL=get-tables.d.mts.map
@@ -18,20 +18,62 @@ const getAuthTables = (options) => {
18
18
  fields: {
19
19
  key: {
20
20
  type: "string",
21
+ unique: true,
22
+ required: true,
21
23
  fieldName: options.rateLimit?.fields?.key || "key"
22
24
  },
23
25
  count: {
24
26
  type: "number",
27
+ required: true,
25
28
  fieldName: options.rateLimit?.fields?.count || "count"
26
29
  },
27
30
  lastRequest: {
28
31
  type: "number",
29
32
  bigint: true,
30
- fieldName: options.rateLimit?.fields?.lastRequest || "lastRequest"
33
+ required: true,
34
+ fieldName: options.rateLimit?.fields?.lastRequest || "lastRequest",
35
+ defaultValue: () => Date.now()
31
36
  }
32
37
  }
33
38
  } };
34
39
  const { user, session, account, verification, ...pluginTables } = pluginSchema;
40
+ const verificationTable = { verification: {
41
+ modelName: options.verification?.modelName || "verification",
42
+ fields: {
43
+ identifier: {
44
+ type: "string",
45
+ required: true,
46
+ fieldName: options.verification?.fields?.identifier || "identifier",
47
+ index: true
48
+ },
49
+ value: {
50
+ type: "string",
51
+ required: true,
52
+ fieldName: options.verification?.fields?.value || "value"
53
+ },
54
+ expiresAt: {
55
+ type: "date",
56
+ required: true,
57
+ fieldName: options.verification?.fields?.expiresAt || "expiresAt"
58
+ },
59
+ createdAt: {
60
+ type: "date",
61
+ required: true,
62
+ defaultValue: () => /* @__PURE__ */ new Date(),
63
+ fieldName: options.verification?.fields?.createdAt || "createdAt"
64
+ },
65
+ updatedAt: {
66
+ type: "date",
67
+ required: true,
68
+ defaultValue: () => /* @__PURE__ */ new Date(),
69
+ onUpdate: () => /* @__PURE__ */ new Date(),
70
+ fieldName: options.verification?.fields?.updatedAt || "updatedAt"
71
+ },
72
+ ...verification?.fields,
73
+ ...options.verification?.additionalFields
74
+ },
75
+ order: 4
76
+ } };
35
77
  const sessionTable = { session: {
36
78
  modelName: options.session?.modelName || "session",
37
79
  fields: {
@@ -214,47 +256,12 @@ const getAuthTables = (options) => {
214
256
  },
215
257
  order: 3
216
258
  },
217
- verification: {
218
- modelName: options.verification?.modelName || "verification",
219
- fields: {
220
- identifier: {
221
- type: "string",
222
- required: true,
223
- fieldName: options.verification?.fields?.identifier || "identifier",
224
- index: true
225
- },
226
- value: {
227
- type: "string",
228
- required: true,
229
- fieldName: options.verification?.fields?.value || "value"
230
- },
231
- expiresAt: {
232
- type: "date",
233
- required: true,
234
- fieldName: options.verification?.fields?.expiresAt || "expiresAt"
235
- },
236
- createdAt: {
237
- type: "date",
238
- required: true,
239
- defaultValue: () => /* @__PURE__ */ new Date(),
240
- fieldName: options.verification?.fields?.createdAt || "createdAt"
241
- },
242
- updatedAt: {
243
- type: "date",
244
- required: true,
245
- defaultValue: () => /* @__PURE__ */ new Date(),
246
- onUpdate: () => /* @__PURE__ */ new Date(),
247
- fieldName: options.verification?.fields?.updatedAt || "updatedAt"
248
- },
249
- ...verification?.fields,
250
- ...options.verification?.additionalFields
251
- },
252
- order: 4
253
- },
259
+ ...!options.secondaryStorage || options.verification?.storeInDatabase ? verificationTable : {},
254
260
  ...pluginTables,
255
261
  ...shouldAddRateLimitTable ? rateLimitTable : {}
256
262
  };
257
263
  };
258
264
 
259
265
  //#endregion
260
- export { getAuthTables };
266
+ export { getAuthTables };
267
+ //# sourceMappingURL=get-tables.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-tables.mjs","names":[],"sources":["../../src/db/get-tables.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"../types\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"./type\";\n\nexport const getAuthTables = (\n\toptions: BetterAuthOptions,\n): BetterAuthDBSchema => {\n\tconst pluginSchema = (options.plugins ?? []).reduce(\n\t\t(acc, plugin) => {\n\t\t\tconst schema = plugin.schema;\n\t\t\tif (!schema) return acc;\n\t\t\tfor (const [key, value] of Object.entries(schema)) {\n\t\t\t\tacc[key] = {\n\t\t\t\t\tfields: {\n\t\t\t\t\t\t...acc[key]?.fields,\n\t\t\t\t\t\t...value.fields,\n\t\t\t\t\t},\n\t\t\t\t\tmodelName: value.modelName || key,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<\n\t\t\tstring,\n\t\t\t{ fields: Record<string, DBFieldAttribute>; modelName: string }\n\t\t>,\n\t);\n\n\tconst shouldAddRateLimitTable = options.rateLimit?.storage === \"database\";\n\tconst rateLimitTable = {\n\t\trateLimit: {\n\t\t\tmodelName: options.rateLimit?.modelName || \"rateLimit\",\n\t\t\tfields: {\n\t\t\t\tkey: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.key || \"key\",\n\t\t\t\t},\n\t\t\t\tcount: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.count || \"count\",\n\t\t\t\t},\n\t\t\t\tlastRequest: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\tbigint: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.lastRequest || \"lastRequest\",\n\t\t\t\t\tdefaultValue: () => Date.now(),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst { user, session, account, verification, ...pluginTables } =\n\t\tpluginSchema;\n\n\tconst verificationTable = {\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName || \"verification\",\n\t\t\tfields: {\n\t\t\t\tidentifier: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.identifier || \"identifier\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.value || \"value\",\n\t\t\t\t},\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...verification?.fields,\n\t\t\t\t...options.verification?.additionalFields,\n\t\t\t},\n\t\t\torder: 4,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst sessionTable = {\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName || \"session\",\n\t\t\tfields: {\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\ttoken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.token || \"token\",\n\t\t\t\t\tunique: true,\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\tipAddress: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.ipAddress || \"ipAddress\",\n\t\t\t\t},\n\t\t\t\tuserAgent: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.userAgent || \"userAgent\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tfieldName: options.session?.fields?.userId || \"userId\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\t...session?.fields,\n\t\t\t\t...options.session?.additionalFields,\n\t\t\t},\n\t\t\torder: 2,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\treturn {\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName || \"user\",\n\t\t\tfields: {\n\t\t\t\tname: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.name || \"name\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.email || \"email\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\temailVerified: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\tdefaultValue: false,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.emailVerified || \"emailVerified\",\n\t\t\t\t\tinput: false,\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.user?.fields?.image || \"image\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...user?.fields,\n\t\t\t\t...options.user?.additionalFields,\n\t\t\t},\n\t\t\torder: 1,\n\t\t},\n\t\t//only add session table if it's not stored in secondary storage\n\t\t...(!options.secondaryStorage || options.session?.storeSessionInDatabase\n\t\t\t? sessionTable\n\t\t\t: {}),\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName || \"account\",\n\t\t\tfields: {\n\t\t\t\taccountId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.accountId || \"accountId\",\n\t\t\t\t},\n\t\t\t\tproviderId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.providerId || \"providerId\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.userId || \"userId\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\taccessToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.accessToken || \"accessToken\",\n\t\t\t\t},\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.refreshToken || \"refreshToken\",\n\t\t\t\t},\n\t\t\t\tidToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.idToken || \"idToken\",\n\t\t\t\t},\n\t\t\t\taccessTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.accessTokenExpiresAt ||\n\t\t\t\t\t\t\"accessTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\trefreshTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.refreshTokenExpiresAt ||\n\t\t\t\t\t\t\"refreshTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\tscope: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.account?.fields?.scope || \"scope\",\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.password || \"password\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\t...account?.fields,\n\t\t\t\t...options.account?.additionalFields,\n\t\t\t},\n\t\t\torder: 3,\n\t\t},\n\t\t...(!options.secondaryStorage || options.verification?.storeInDatabase\n\t\t\t? verificationTable\n\t\t\t: {}),\n\t\t...pluginTables,\n\t\t...(shouldAddRateLimitTable ? rateLimitTable : {}),\n\t} satisfies BetterAuthDBSchema;\n};\n"],"mappings":";AAGA,MAAa,iBACZ,YACwB;CACxB,MAAM,gBAAgB,QAAQ,WAAW,EAAE,EAAE,QAC3C,KAAK,WAAW;EAChB,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,OAAQ,QAAO;AACpB,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAChD,KAAI,OAAO;GACV,QAAQ;IACP,GAAG,IAAI,MAAM;IACb,GAAG,MAAM;IACT;GACD,WAAW,MAAM,aAAa;GAC9B;AAEF,SAAO;IAER,EAAE,CAIF;CAED,MAAM,0BAA0B,QAAQ,WAAW,YAAY;CAC/D,MAAM,iBAAiB,EACtB,WAAW;EACV,WAAW,QAAQ,WAAW,aAAa;EAC3C,QAAQ;GACP,KAAK;IACJ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,OAAO;IAC7C;GACD,OAAO;IACN,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,SAAS;IAC/C;GACD,aAAa;IACZ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,eAAe;IACrD,oBAAoB,KAAK,KAAK;IAC9B;GACD;EACD,EACD;CAED,MAAM,EAAE,MAAM,SAAS,SAAS,cAAc,GAAG,iBAChD;CAED,MAAM,oBAAoB,EACzB,cAAc;EACb,WAAW,QAAQ,cAAc,aAAa;EAC9C,QAAQ;GACP,YAAY;IACX,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,cAAc,QAAQ,cAAc;IACvD,OAAO;IACP;GACD,OAAO;IACN,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,cAAc,QAAQ,SAAS;IAClD;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,cAAc,QAAQ,aAAa;IACtD;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,oCAAoB,IAAI,MAAM;IAC9B,WAAW,QAAQ,cAAc,QAAQ,aAAa;IACtD;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,oCAAoB,IAAI,MAAM;IAC9B,gCAAgB,IAAI,MAAM;IAC1B,WAAW,QAAQ,cAAc,QAAQ,aAAa;IACtD;GACD,GAAG,cAAc;GACjB,GAAG,QAAQ,cAAc;GACzB;EACD,OAAO;EACP,EACD;CAED,MAAM,eAAe,EACpB,SAAS;EACR,WAAW,QAAQ,SAAS,aAAa;EACzC,QAAQ;GACP,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;IACjD;GACD,OAAO;IACN,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,SAAS;IAC7C,QAAQ;IACR;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;IACjD,oCAAoB,IAAI,MAAM;IAC9B;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;IACjD,gCAAgB,IAAI,MAAM;IAC1B;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;IACjD;GACD,WAAW;IACV,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;IACjD;GACD,QAAQ;IACP,MAAM;IACN,WAAW,QAAQ,SAAS,QAAQ,UAAU;IAC9C,YAAY;KACX,OAAO,QAAQ,MAAM,aAAa;KAClC,OAAO;KACP,UAAU;KACV;IACD,UAAU;IACV,OAAO;IACP;GACD,GAAG,SAAS;GACZ,GAAG,QAAQ,SAAS;GACpB;EACD,OAAO;EACP,EACD;AAED,QAAO;EACN,MAAM;GACL,WAAW,QAAQ,MAAM,aAAa;GACtC,QAAQ;IACP,MAAM;KACL,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,QAAQ;KACzC,UAAU;KACV;IACD,OAAO;KACN,MAAM;KACN,QAAQ;KACR,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,SAAS;KAC1C,UAAU;KACV;IACD,eAAe;KACd,MAAM;KACN,cAAc;KACd,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,iBAAiB;KAClD,OAAO;KACP;IACD,OAAO;KACN,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,SAAS;KAC1C;IACD,WAAW;KACV,MAAM;KACN,oCAAoB,IAAI,MAAM;KAC9B,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,aAAa;KAC9C;IACD,WAAW;KACV,MAAM;KACN,oCAAoB,IAAI,MAAM;KAC9B,gCAAgB,IAAI,MAAM;KAC1B,UAAU;KACV,WAAW,QAAQ,MAAM,QAAQ,aAAa;KAC9C;IACD,GAAG,MAAM;IACT,GAAG,QAAQ,MAAM;IACjB;GACD,OAAO;GACP;EAED,GAAI,CAAC,QAAQ,oBAAoB,QAAQ,SAAS,yBAC/C,eACA,EAAE;EACL,SAAS;GACR,WAAW,QAAQ,SAAS,aAAa;GACzC,QAAQ;IACP,WAAW;KACV,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;KACjD;IACD,YAAY;KACX,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,cAAc;KAClD;IACD,QAAQ;KACP,MAAM;KACN,YAAY;MACX,OAAO,QAAQ,MAAM,aAAa;MAClC,OAAO;MACP,UAAU;MACV;KACD,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,UAAU;KAC9C,OAAO;KACP;IACD,aAAa;KACZ,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,eAAe;KACnD;IACD,cAAc;KACb,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,gBAAgB;KACpD;IACD,SAAS;KACR,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,WAAW;KAC/C;IACD,sBAAsB;KACrB,MAAM;KACN,UAAU;KACV,UAAU;KACV,WACC,QAAQ,SAAS,QAAQ,wBACzB;KACD;IACD,uBAAuB;KACtB,MAAM;KACN,UAAU;KACV,UAAU;KACV,WACC,QAAQ,SAAS,QAAQ,yBACzB;KACD;IACD,OAAO;KACN,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,SAAS;KAC7C;IACD,UAAU;KACT,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,YAAY;KAChD;IACD,WAAW;KACV,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;KACjD,oCAAoB,IAAI,MAAM;KAC9B;IACD,WAAW;KACV,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;KACjD,gCAAgB,IAAI,MAAM;KAC1B;IACD,GAAG,SAAS;IACZ,GAAG,QAAQ,SAAS;IACpB;GACD,OAAO;GACP;EACD,GAAI,CAAC,QAAQ,oBAAoB,QAAQ,cAAc,kBACpD,oBACA,EAAE;EACL,GAAG;EACH,GAAI,0BAA0B,iBAAiB,EAAE;EACjD"}
@@ -9,4 +9,5 @@ type BetterAuthPluginDBSchema = { [table in string]: {
9
9
  modelName?: string | undefined;
10
10
  } };
11
11
  //#endregion
12
- export { BetterAuthPluginDBSchema };
12
+ export { BetterAuthPluginDBSchema };
13
+ //# sourceMappingURL=plugin.d.mts.map
@@ -23,4 +23,5 @@ declare const accountSchema: z.ZodObject<{
23
23
  */
24
24
  type Account = z.infer<typeof accountSchema>;
25
25
  //#endregion
26
- export { Account, accountSchema };
26
+ export { Account, accountSchema };
27
+ //# sourceMappingURL=account.d.mts.map
@@ -16,4 +16,5 @@ const accountSchema = coreSchema.extend({
16
16
  });
17
17
 
18
18
  //#endregion
19
- export { accountSchema };
19
+ export { accountSchema };
20
+ //# sourceMappingURL=account.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.mjs","names":[],"sources":["../../../src/db/schema/account.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { coreSchema } from \"./shared\";\n\nexport const accountSchema = coreSchema.extend({\n\tproviderId: z.string(),\n\taccountId: z.string(),\n\tuserId: z.coerce.string(),\n\taccessToken: z.string().nullish(),\n\trefreshToken: z.string().nullish(),\n\tidToken: z.string().nullish(),\n\t/**\n\t * Access token expires at\n\t */\n\taccessTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * Refresh token expires at\n\t */\n\trefreshTokenExpiresAt: z.date().nullish(),\n\t/**\n\t * The scopes that the user has authorized\n\t */\n\tscope: z.string().nullish(),\n\t/**\n\t * Password is only stored in the credential provider\n\t */\n\tpassword: z.string().nullish(),\n});\n\n/**\n * Account schema type used by better-auth, note that it's possible that account could have additional fields\n *\n * todo: we should use generics to extend this type with additional fields from plugins and options in the future\n */\nexport type Account = z.infer<typeof accountSchema>;\n"],"mappings":";;;;AAGA,MAAa,gBAAgB,WAAW,OAAO;CAC9C,YAAY,EAAE,QAAQ;CACtB,WAAW,EAAE,QAAQ;CACrB,QAAQ,EAAE,OAAO,QAAQ;CACzB,aAAa,EAAE,QAAQ,CAAC,SAAS;CACjC,cAAc,EAAE,QAAQ,CAAC,SAAS;CAClC,SAAS,EAAE,QAAQ,CAAC,SAAS;CAI7B,sBAAsB,EAAE,MAAM,CAAC,SAAS;CAIxC,uBAAuB,EAAE,MAAM,CAAC,SAAS;CAIzC,OAAO,EAAE,QAAQ,CAAC,SAAS;CAI3B,UAAU,EAAE,QAAQ,CAAC,SAAS;CAC9B,CAAC"}
@@ -11,4 +11,5 @@ declare const rateLimitSchema: z.ZodObject<{
11
11
  */
12
12
  type RateLimit = z.infer<typeof rateLimitSchema>;
13
13
  //#endregion
14
- export { RateLimit, rateLimitSchema };
14
+ export { RateLimit, rateLimitSchema };
15
+ //# sourceMappingURL=rate-limit.d.mts.map
@@ -8,4 +8,5 @@ const rateLimitSchema = z.object({
8
8
  });
9
9
 
10
10
  //#endregion
11
- export { rateLimitSchema };
11
+ export { rateLimitSchema };
12
+ //# sourceMappingURL=rate-limit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit.mjs","names":[],"sources":["../../../src/db/schema/rate-limit.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport const rateLimitSchema = z.object({\n\t/**\n\t * The key to use for rate limiting\n\t */\n\tkey: z.string(),\n\t/**\n\t * The number of requests made\n\t */\n\tcount: z.number(),\n\t/**\n\t * The last request time in milliseconds\n\t */\n\tlastRequest: z.number(),\n});\n\n/**\n * Rate limit schema type used by better-auth for rate limiting\n */\nexport type RateLimit = z.infer<typeof rateLimitSchema>;\n"],"mappings":";;;AAEA,MAAa,kBAAkB,EAAE,OAAO;CAIvC,KAAK,EAAE,QAAQ;CAIf,OAAO,EAAE,QAAQ;CAIjB,aAAa,EAAE,QAAQ;CACvB,CAAC"}
@@ -18,4 +18,5 @@ declare const sessionSchema: z.ZodObject<{
18
18
  */
19
19
  type Session = z.infer<typeof sessionSchema>;
20
20
  //#endregion
21
- export { Session, sessionSchema };
21
+ export { Session, sessionSchema };
22
+ //# sourceMappingURL=session.d.mts.map
@@ -11,4 +11,5 @@ const sessionSchema = coreSchema.extend({
11
11
  });
12
12
 
13
13
  //#endregion
14
- export { sessionSchema };
14
+ export { sessionSchema };
15
+ //# sourceMappingURL=session.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.mjs","names":[],"sources":["../../../src/db/schema/session.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { coreSchema } from \"./shared\";\n\nexport const sessionSchema = coreSchema.extend({\n\tuserId: z.coerce.string(),\n\texpiresAt: z.date(),\n\ttoken: z.string(),\n\tipAddress: z.string().nullish(),\n\tuserAgent: z.string().nullish(),\n});\n\n/**\n * Session schema type used by better-auth, note that it's possible that session could have additional fields\n *\n * todo: we should use generics to extend this type with additional fields from plugins and options in the future\n */\nexport type Session = z.infer<typeof sessionSchema>;\n"],"mappings":";;;;AAGA,MAAa,gBAAgB,WAAW,OAAO;CAC9C,QAAQ,EAAE,OAAO,QAAQ;CACzB,WAAW,EAAE,MAAM;CACnB,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,CAAC"}
@@ -7,4 +7,5 @@ declare const coreSchema: z.ZodObject<{
7
7
  updatedAt: z.ZodDefault<z.ZodDate>;
8
8
  }, z.core.$strip>;
9
9
  //#endregion
10
- export { coreSchema };
10
+ export { coreSchema };
11
+ //# sourceMappingURL=shared.d.mts.map
@@ -8,4 +8,5 @@ const coreSchema = z.object({
8
8
  });
9
9
 
10
10
  //#endregion
11
- export { coreSchema };
11
+ export { coreSchema };
12
+ //# sourceMappingURL=shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.mjs","names":[],"sources":["../../../src/db/schema/shared.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport const coreSchema = z.object({\n\tid: z.string(),\n\tcreatedAt: z.date().default(() => new Date()),\n\tupdatedAt: z.date().default(() => new Date()),\n});\n"],"mappings":";;;AAEA,MAAa,aAAa,EAAE,OAAO;CAClC,IAAI,EAAE,QAAQ;CACd,WAAW,EAAE,MAAM,CAAC,8BAAc,IAAI,MAAM,CAAC;CAC7C,WAAW,EAAE,MAAM,CAAC,8BAAc,IAAI,MAAM,CAAC;CAC7C,CAAC"}
@@ -17,4 +17,5 @@ declare const userSchema: z.ZodObject<{
17
17
  */
18
18
  type User = z.infer<typeof userSchema>;
19
19
  //#endregion
20
- export { User, userSchema };
20
+ export { User, userSchema };
21
+ //# sourceMappingURL=user.d.mts.map
@@ -10,4 +10,5 @@ const userSchema = coreSchema.extend({
10
10
  });
11
11
 
12
12
  //#endregion
13
- export { userSchema };
13
+ export { userSchema };
14
+ //# sourceMappingURL=user.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/db/schema/user.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { coreSchema } from \"./shared\";\n\nexport const userSchema = coreSchema.extend({\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().nullish(),\n});\n\n/**\n * User schema type used by better-auth, note that it's possible that user could have additional fields\n *\n * todo: we should use generics to extend this type with additional fields from plugins and options in the future\n */\nexport type User = z.infer<typeof userSchema>;\n"],"mappings":";;;;AAGA,MAAa,aAAa,WAAW,OAAO;CAC3C,OAAO,EAAE,QAAQ,CAAC,WAAW,QAAQ,IAAI,aAAa,CAAC;CACvD,eAAe,EAAE,SAAS,CAAC,QAAQ,MAAM;CACzC,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,CAAC"}
@@ -16,4 +16,5 @@ declare const verificationSchema: z.ZodObject<{
16
16
  */
17
17
  type Verification = z.infer<typeof verificationSchema>;
18
18
  //#endregion
19
- export { Verification, verificationSchema };
19
+ export { Verification, verificationSchema };
20
+ //# sourceMappingURL=verification.d.mts.map
@@ -9,4 +9,5 @@ const verificationSchema = coreSchema.extend({
9
9
  });
10
10
 
11
11
  //#endregion
12
- export { verificationSchema };
12
+ export { verificationSchema };
13
+ //# sourceMappingURL=verification.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification.mjs","names":[],"sources":["../../../src/db/schema/verification.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { coreSchema } from \"./shared\";\n\nexport const verificationSchema = coreSchema.extend({\n\tvalue: z.string(),\n\texpiresAt: z.date(),\n\tidentifier: z.string(),\n});\n\n/**\n * Verification schema type used by better-auth, note that it's possible that verification could have additional fields\n *\n * todo: we should use generics to extend this type with additional fields from plugins and options in the future\n */\nexport type Verification = z.infer<typeof verificationSchema>;\n"],"mappings":";;;;AAGA,MAAa,qBAAqB,WAAW,OAAO;CACnD,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,MAAM;CACnB,YAAY,EAAE,QAAQ;CACtB,CAAC"}
@@ -124,14 +124,17 @@ interface SecondaryStorage {
124
124
  /**
125
125
  * Key to store
126
126
  */
127
+
127
128
  key: string,
128
129
  /**
129
130
  * Value to store
130
131
  */
132
+
131
133
  value: string,
132
134
  /**
133
135
  * Time to live in seconds
134
136
  */
137
+
135
138
  ttl?: number | undefined) => Awaitable<void | null | unknown>;
136
139
  /**
137
140
  *
@@ -140,4 +143,5 @@ interface SecondaryStorage {
140
143
  delete: (key: string) => Awaitable<void | null | string>;
141
144
  }
142
145
  //#endregion
143
- export { BaseModelNames, BetterAuthDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, ModelNames, SecondaryStorage };
146
+ export { BaseModelNames, BetterAuthDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, ModelNames, SecondaryStorage };
147
+ //# sourceMappingURL=type.d.mts.map
@@ -1,4 +1,5 @@
1
1
  //#region src/env/color-depth.d.ts
2
2
  declare function getColorDepth(): number;
3
3
  //#endregion
4
- export { getColorDepth };
4
+ export { getColorDepth };
5
+ //# sourceMappingURL=color-depth.d.mts.map
@@ -85,4 +85,5 @@ function getColorDepth() {
85
85
  }
86
86
 
87
87
  //#endregion
88
- export { getColorDepth };
88
+ export { getColorDepth };
89
+ //# sourceMappingURL=color-depth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-depth.mjs","names":[],"sources":["../../src/env/color-depth.ts"],"sourcesContent":["// Source code copied & modified from node internals: https://github.com/nodejs/node/blob/5b32bb1573dace2dd058c05ac4fab1e4e446c775/lib/internal/tty.js#L123\nimport { env, getEnvVar } from \"./env-impl\";\n\nconst COLORS_2 = 1;\nconst COLORS_16 = 4;\nconst COLORS_256 = 8;\nconst COLORS_16m = 24;\n\nconst TERM_ENVS: Record<string, number> = {\n\teterm: COLORS_16,\n\tcons25: COLORS_16,\n\tconsole: COLORS_16,\n\tcygwin: COLORS_16,\n\tdtterm: COLORS_16,\n\tgnome: COLORS_16,\n\thurd: COLORS_16,\n\tjfbterm: COLORS_16,\n\tkonsole: COLORS_16,\n\tkterm: COLORS_16,\n\tmlterm: COLORS_16,\n\tmosh: COLORS_16m,\n\tputty: COLORS_16,\n\tst: COLORS_16,\n\t// http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html\n\t\"rxvt-unicode-24bit\": COLORS_16m,\n\t// https://bugs.launchpad.net/terminator/+bug/1030562\n\tterminator: COLORS_16m,\n\t\"xterm-kitty\": COLORS_16m,\n};\n\nconst CI_ENVS_MAP = new Map(\n\tObject.entries({\n\t\tAPPVEYOR: COLORS_256,\n\t\tBUILDKITE: COLORS_256,\n\t\tCIRCLECI: COLORS_16m,\n\t\tDRONE: COLORS_256,\n\t\tGITEA_ACTIONS: COLORS_16m,\n\t\tGITHUB_ACTIONS: COLORS_16m,\n\t\tGITLAB_CI: COLORS_256,\n\t\tTRAVIS: COLORS_256,\n\t}),\n);\n\nconst TERM_ENVS_REG_EXP = [\n\t/ansi/,\n\t/color/,\n\t/linux/,\n\t/direct/,\n\t/^con[0-9]*x[0-9]/,\n\t/^rxvt/,\n\t/^screen/,\n\t/^xterm/,\n\t/^vt100/,\n\t/^vt220/,\n];\n\n// The `getColorDepth` API got inspired by multiple sources such as\n// https://github.com/chalk/supports-color,\n// https://github.com/isaacs/color-support.\nexport function getColorDepth(): number {\n\t// Use level 0-3 to support the same levels as `chalk` does. This is done for\n\t// consistency throughout the ecosystem.\n\tif (getEnvVar(\"FORCE_COLOR\") !== undefined) {\n\t\tswitch (getEnvVar(\"FORCE_COLOR\")) {\n\t\t\tcase \"\":\n\t\t\tcase \"1\":\n\t\t\tcase \"true\":\n\t\t\t\treturn COLORS_16;\n\t\t\tcase \"2\":\n\t\t\t\treturn COLORS_256;\n\t\t\tcase \"3\":\n\t\t\t\treturn COLORS_16m;\n\t\t\tdefault:\n\t\t\t\treturn COLORS_2;\n\t\t}\n\t}\n\n\tif (\n\t\t(getEnvVar(\"NODE_DISABLE_COLORS\") !== undefined &&\n\t\t\tgetEnvVar(\"NODE_DISABLE_COLORS\") !== \"\") ||\n\t\t// See https://no-color.org/\n\t\t(getEnvVar(\"NO_COLOR\") !== undefined && getEnvVar(\"NO_COLOR\") !== \"\") ||\n\t\t// The \"dumb\" special terminal, as defined by terminfo, doesn't support\n\t\t// ANSI color control codes.\n\t\t// See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials\n\t\tgetEnvVar(\"TERM\") === \"dumb\"\n\t) {\n\t\treturn COLORS_2;\n\t}\n\n\t// Edge runtime doesn't support `process?.platform` syntax\n\t// if (typeof process !== \"undefined\" && process?.platform === \"win32\") {\n\t// \t// Windows 10 build 14931 (from 2016) has true color support\n\t// \treturn COLORS_16m;\n\t// }\n\n\tif (getEnvVar(\"TMUX\")) {\n\t\treturn COLORS_16m;\n\t}\n\n\t// Azure DevOps\n\tif (\"TF_BUILD\" in env && \"AGENT_NAME\" in env) {\n\t\treturn COLORS_16;\n\t}\n\n\tif (\"CI\" in env) {\n\t\tfor (const { 0: envName, 1: colors } of CI_ENVS_MAP) {\n\t\t\tif (envName in env) {\n\t\t\t\treturn colors;\n\t\t\t}\n\t\t}\n\t\tif (getEnvVar(\"CI_NAME\") === \"codeship\") {\n\t\t\treturn COLORS_256;\n\t\t}\n\t\treturn COLORS_2;\n\t}\n\n\tif (\"TEAMCITY_VERSION\" in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.exec(\n\t\t\tgetEnvVar(\"TEAMCITY_VERSION\"),\n\t\t) !== null\n\t\t\t? COLORS_16\n\t\t\t: COLORS_2;\n\t}\n\n\tswitch (getEnvVar(\"TERM_PROGRAM\")) {\n\t\tcase \"iTerm.app\":\n\t\t\tif (\n\t\t\t\t!getEnvVar(\"TERM_PROGRAM_VERSION\") ||\n\t\t\t\t/^[0-2]\\./.exec(getEnvVar(\"TERM_PROGRAM_VERSION\")) !== null\n\t\t\t) {\n\t\t\t\treturn COLORS_256;\n\t\t\t}\n\t\t\treturn COLORS_16m;\n\t\tcase \"HyperTerm\":\n\t\tcase \"MacTerm\":\n\t\t\treturn COLORS_16m;\n\t\tcase \"Apple_Terminal\":\n\t\t\treturn COLORS_256;\n\t}\n\n\tif (\n\t\tgetEnvVar(\"COLORTERM\") === \"truecolor\" ||\n\t\tgetEnvVar(\"COLORTERM\") === \"24bit\"\n\t) {\n\t\treturn COLORS_16m;\n\t}\n\n\tif (getEnvVar(\"TERM\")) {\n\t\tif (/truecolor/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_16m;\n\t\t}\n\n\t\tif (/^xterm-256/.exec(getEnvVar(\"TERM\")) !== null) {\n\t\t\treturn COLORS_256;\n\t\t}\n\n\t\tconst termEnv = getEnvVar(\"TERM\").toLowerCase();\n\n\t\tif (TERM_ENVS[termEnv]) {\n\t\t\treturn TERM_ENVS[termEnv];\n\t\t}\n\t\tif (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {\n\t\t\treturn COLORS_16;\n\t\t}\n\t}\n\t// Move 16 color COLORTERM below 16m and 256\n\tif (getEnvVar(\"COLORTERM\")) {\n\t\treturn COLORS_16;\n\t}\n\treturn COLORS_2;\n}\n"],"mappings":";;;AAGA,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,YAAoC;CACzC,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;CACP,QAAQ;CACR,MAAM;CACN,OAAO;CACP,IAAI;CAEJ,sBAAsB;CAEtB,YAAY;CACZ,eAAe;CACf;AAED,MAAM,cAAc,IAAI,IACvB,OAAO,QAAQ;CACd,UAAU;CACV,WAAW;CACX,UAAU;CACV,OAAO;CACP,eAAe;CACf,gBAAgB;CAChB,WAAW;CACX,QAAQ;CACR,CAAC,CACF;AAED,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAKD,SAAgB,gBAAwB;AAGvC,KAAI,UAAU,cAAc,KAAK,OAChC,SAAQ,UAAU,cAAc,EAAhC;EACC,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO;EACR,KAAK,IACJ,QAAO;EACR,KAAK,IACJ,QAAO;EACR,QACC,QAAO;;AAIV,KACE,UAAU,sBAAsB,KAAK,UACrC,UAAU,sBAAsB,KAAK,MAErC,UAAU,WAAW,KAAK,UAAa,UAAU,WAAW,KAAK,MAIlE,UAAU,OAAO,KAAK,OAEtB,QAAO;AASR,KAAI,UAAU,OAAO,CACpB,QAAO;AAIR,KAAI,cAAc,OAAO,gBAAgB,IACxC,QAAO;AAGR,KAAI,QAAQ,KAAK;AAChB,OAAK,MAAM,EAAE,GAAG,SAAS,GAAG,YAAY,YACvC,KAAI,WAAW,IACd,QAAO;AAGT,MAAI,UAAU,UAAU,KAAK,WAC5B,QAAO;AAER,SAAO;;AAGR,KAAI,sBAAsB,IACzB,QAAO,gCAAgC,KACtC,UAAU,mBAAmB,CAC7B,KAAK,OACH,YACA;AAGJ,SAAQ,UAAU,eAAe,EAAjC;EACC,KAAK;AACJ,OACC,CAAC,UAAU,uBAAuB,IAClC,WAAW,KAAK,UAAU,uBAAuB,CAAC,KAAK,KAEvD,QAAO;AAER,UAAO;EACR,KAAK;EACL,KAAK,UACJ,QAAO;EACR,KAAK,iBACJ,QAAO;;AAGT,KACC,UAAU,YAAY,KAAK,eAC3B,UAAU,YAAY,KAAK,QAE3B,QAAO;AAGR,KAAI,UAAU,OAAO,EAAE;AACtB,MAAI,YAAY,KAAK,UAAU,OAAO,CAAC,KAAK,KAC3C,QAAO;AAGR,MAAI,aAAa,KAAK,UAAU,OAAO,CAAC,KAAK,KAC5C,QAAO;EAGR,MAAM,UAAU,UAAU,OAAO,CAAC,aAAa;AAE/C,MAAI,UAAU,SACb,QAAO,UAAU;AAElB,MAAI,kBAAkB,MAAM,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,CAChE,QAAO;;AAIT,KAAI,UAAU,YAAY,CACzB,QAAO;AAER,QAAO"}
@@ -26,7 +26,8 @@ declare const ENV: Readonly<{
26
26
  readonly BETTER_AUTH_TELEMETRY_ID: string;
27
27
  readonly NODE_ENV: string;
28
28
  readonly PACKAGE_VERSION: string;
29
- readonly BETTER_AUTH_TELEMETRY_ENDPOINT: string;
29
+ readonly BETTER_AUTH_TELEMETRY_ENDPOINT: string | undefined;
30
30
  }>;
31
31
  //#endregion
32
- export { ENV, EnvObject, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV };
32
+ export { ENV, EnvObject, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV };
33
+ //# sourceMappingURL=env-impl.d.mts.map
@@ -9,19 +9,19 @@ const env = new Proxy(_envShim, {
9
9
  return prop in _getEnv() || prop in _envShim;
10
10
  },
11
11
  set(_, prop, value) {
12
- const env$1 = _getEnv(true);
13
- env$1[prop] = value;
12
+ const env = _getEnv(true);
13
+ env[prop] = value;
14
14
  return true;
15
15
  },
16
16
  deleteProperty(_, prop) {
17
17
  if (!prop) return false;
18
- const env$1 = _getEnv(true);
19
- delete env$1[prop];
18
+ const env = _getEnv(true);
19
+ delete env[prop];
20
20
  return true;
21
21
  },
22
22
  ownKeys() {
23
- const env$1 = _getEnv(true);
24
- return Object.keys(env$1);
23
+ const env = _getEnv(true);
24
+ return Object.keys(env);
25
25
  }
26
26
  });
27
27
  function toBoolean(val) {
@@ -74,9 +74,10 @@ const ENV = Object.freeze({
74
74
  return getEnvVar("PACKAGE_VERSION", "0.0.0");
75
75
  },
76
76
  get BETTER_AUTH_TELEMETRY_ENDPOINT() {
77
- return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "https://telemetry.better-auth.com/v1/track");
77
+ return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
78
78
  }
79
79
  });
80
80
 
81
81
  //#endregion
82
- export { ENV, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV };
82
+ export { ENV, env, getBooleanEnvVar, getEnvVar, isDevelopment, isProduction, isTest, nodeENV };
83
+ //# sourceMappingURL=env-impl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-impl.mjs","names":[],"sources":["../../src/env/env-impl.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/// <reference types=\"bun\" />\n//https://github.com/unjs/std-env/blob/main/src/env.ts\n\nconst _envShim = Object.create(null);\n\nexport type EnvObject = Record<string, string | undefined>;\n\nconst _getEnv = (useShim?: boolean) =>\n\tglobalThis.process?.env ||\n\t//@ts-expect-error\n\tglobalThis.Deno?.env.toObject() ||\n\t//@ts-expect-error\n\tglobalThis.__env__ ||\n\t(useShim ? _envShim : globalThis);\n\nexport const env = new Proxy<EnvObject>(_envShim, {\n\tget(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn env[prop as any] ?? _envShim[prop];\n\t},\n\thas(_, prop) {\n\t\tconst env = _getEnv();\n\t\treturn prop in env || prop in _envShim;\n\t},\n\tset(_, prop, value) {\n\t\tconst env = _getEnv(true);\n\t\tenv[prop as any] = value;\n\t\treturn true;\n\t},\n\tdeleteProperty(_, prop) {\n\t\tif (!prop) {\n\t\t\treturn false;\n\t\t}\n\t\tconst env = _getEnv(true);\n\t\tdelete env[prop as any];\n\t\treturn true;\n\t},\n\townKeys() {\n\t\tconst env = _getEnv(true);\n\t\treturn Object.keys(env);\n\t},\n});\n\nfunction toBoolean(val: boolean | string | undefined) {\n\treturn val ? val !== \"false\" : false;\n}\n\nexport const nodeENV =\n\t(typeof process !== \"undefined\" && process.env && process.env.NODE_ENV) || \"\";\n\n/** Detect if `NODE_ENV` environment variable is `production` */\nexport const isProduction = nodeENV === \"production\";\n\n/** Detect if `NODE_ENV` environment variable is `dev` or `development` */\nexport const isDevelopment = () =>\n\tnodeENV === \"dev\" || nodeENV === \"development\";\n\n/** Detect if `NODE_ENV` environment variable is `test` */\nexport const isTest = () => nodeENV === \"test\" || toBoolean(env.TEST);\n\n/**\n * Get environment variable with fallback\n */\nexport function getEnvVar<Fallback extends string>(\n\tkey: string,\n\tfallback?: Fallback,\n): Fallback extends string ? string : string | undefined {\n\tif (typeof process !== \"undefined\" && process.env) {\n\t\treturn process.env[key] ?? (fallback as any);\n\t}\n\n\t// @ts-expect-error deno\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error deno\n\t\treturn Deno.env.get(key) ?? (fallback as string);\n\t}\n\n\t// Handle Bun\n\tif (typeof Bun !== \"undefined\") {\n\t\treturn Bun.env[key] ?? (fallback as string);\n\t}\n\n\treturn fallback as any;\n}\n\n/**\n * Get boolean environment variable\n */\nexport function getBooleanEnvVar(key: string, fallback = true): boolean {\n\tconst value = getEnvVar(key);\n\tif (!value) return fallback;\n\treturn value !== \"0\" && value.toLowerCase() !== \"false\" && value !== \"\";\n}\n\n/**\n * Common environment variables used in Better Auth\n */\nexport const ENV = Object.freeze({\n\tget BETTER_AUTH_SECRET() {\n\t\treturn getEnvVar(\"BETTER_AUTH_SECRET\");\n\t},\n\tget AUTH_SECRET() {\n\t\treturn getEnvVar(\"AUTH_SECRET\");\n\t},\n\tget BETTER_AUTH_TELEMETRY() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ID() {\n\t\treturn getEnvVar(\"BETTER_AUTH_TELEMETRY_ID\");\n\t},\n\tget NODE_ENV() {\n\t\treturn getEnvVar(\"NODE_ENV\", \"development\");\n\t},\n\tget PACKAGE_VERSION() {\n\t\treturn getEnvVar(\"PACKAGE_VERSION\", \"0.0.0\");\n\t},\n\tget BETTER_AUTH_TELEMETRY_ENDPOINT(): string | undefined {\n\t\treturn getEnvVar(\n\t\t\t\"BETTER_AUTH_TELEMETRY_ENDPOINT\",\n\t\t\timport.meta.env.BETTER_AUTH_TELEMETRY_ENDPOINT,\n\t\t);\n\t},\n});\n"],"mappings":";AAIA,MAAM,WAAW,OAAO,OAAO,KAAK;AAIpC,MAAM,WAAW,YAChB,WAAW,SAAS,OAEpB,WAAW,MAAM,IAAI,UAAU,IAE/B,WAAW,YACV,UAAU,WAAW;AAEvB,MAAa,MAAM,IAAI,MAAiB,UAAU;CACjD,IAAI,GAAG,MAAM;AAEZ,SADY,SAAS,CACV,SAAgB,SAAS;;CAErC,IAAI,GAAG,MAAM;AAEZ,SAAO,QADK,SAAS,IACC,QAAQ;;CAE/B,IAAI,GAAG,MAAM,OAAO;EACnB,MAAM,MAAM,QAAQ,KAAK;AACzB,MAAI,QAAe;AACnB,SAAO;;CAER,eAAe,GAAG,MAAM;AACvB,MAAI,CAAC,KACJ,QAAO;EAER,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,IAAI;AACX,SAAO;;CAER,UAAU;EACT,MAAM,MAAM,QAAQ,KAAK;AACzB,SAAO,OAAO,KAAK,IAAI;;CAExB,CAAC;AAEF,SAAS,UAAU,KAAmC;AACrD,QAAO,MAAM,QAAQ,UAAU;;AAGhC,MAAa,UACX,OAAO,YAAY,eAAe,QAAQ,OAAO,QAAQ,IAAI,YAAa;;AAG5E,MAAa,eAAe,YAAY;;AAGxC,MAAa,sBACZ,YAAY,SAAS,YAAY;;AAGlC,MAAa,eAAe,YAAY,UAAU,UAAU,IAAI,KAAK;;;;AAKrE,SAAgB,UACf,KACA,UACwD;AACxD,KAAI,OAAO,YAAY,eAAe,QAAQ,IAC7C,QAAO,QAAQ,IAAI,QAAS;AAI7B,KAAI,OAAO,SAAS,YAEnB,QAAO,KAAK,IAAI,IAAI,IAAI,IAAK;AAI9B,KAAI,OAAO,QAAQ,YAClB,QAAO,IAAI,IAAI,QAAS;AAGzB,QAAO;;;;;AAMR,SAAgB,iBAAiB,KAAa,WAAW,MAAe;CACvE,MAAM,QAAQ,UAAU,IAAI;AAC5B,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,UAAU,OAAO,MAAM,aAAa,KAAK,WAAW,UAAU;;;;;AAMtE,MAAa,MAAM,OAAO,OAAO;CAChC,IAAI,qBAAqB;AACxB,SAAO,UAAU,qBAAqB;;CAEvC,IAAI,cAAc;AACjB,SAAO,UAAU,cAAc;;CAEhC,IAAI,wBAAwB;AAC3B,SAAO,UAAU,wBAAwB;;CAE1C,IAAI,2BAA2B;AAC9B,SAAO,UAAU,2BAA2B;;CAE7C,IAAI,WAAW;AACd,SAAO,UAAU,YAAY,cAAc;;CAE5C,IAAI,kBAAkB;AACrB,SAAO,UAAU,mBAAmB,QAAQ;;CAE7C,IAAI,iCAAqD;AACxD,SAAO,UACN,qCAEA;;CAEF,CAAC"}
@@ -45,4 +45,5 @@ type InternalLogger = { [K in LogLevel]: (...params: LogHandlerParams) => void }
45
45
  declare const createLogger: (options?: Logger | undefined) => InternalLogger;
46
46
  declare const logger: InternalLogger;
47
47
  //#endregion
48
- export { InternalLogger, LogHandlerParams, LogLevel, Logger, TTY_COLORS, createLogger, levels, logger, shouldPublishLog };
48
+ export { InternalLogger, LogHandlerParams, LogLevel, Logger, TTY_COLORS, createLogger, levels, logger, shouldPublishLog };
49
+ //# sourceMappingURL=logger.d.mts.map
@@ -55,7 +55,7 @@ const formatMessage = (level, message, colorsEnabled) => {
55
55
  };
56
56
  const createLogger = (options) => {
57
57
  const enabled = options?.disabled !== true;
58
- const logLevel = options?.level ?? "error";
58
+ const logLevel = options?.level ?? "warn";
59
59
  const colorsEnabled = options?.disableColors !== void 0 ? !options.disableColors : getColorDepth() !== 1;
60
60
  const LogFunc = (level, message, args = []) => {
61
61
  if (!enabled || !shouldPublishLog(logLevel, level)) return;
@@ -78,4 +78,5 @@ const createLogger = (options) => {
78
78
  const logger = createLogger();
79
79
 
80
80
  //#endregion
81
- export { TTY_COLORS, createLogger, levels, logger, shouldPublishLog };
81
+ export { TTY_COLORS, createLogger, levels, logger, shouldPublishLog };
82
+ //# sourceMappingURL=logger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/env/logger.ts"],"sourcesContent":["import { getColorDepth } from \"./color-depth\";\n\nexport const TTY_COLORS = {\n\treset: \"\\x1b[0m\",\n\tbright: \"\\x1b[1m\",\n\tdim: \"\\x1b[2m\",\n\tundim: \"\\x1b[22m\",\n\tunderscore: \"\\x1b[4m\",\n\tblink: \"\\x1b[5m\",\n\treverse: \"\\x1b[7m\",\n\thidden: \"\\x1b[8m\",\n\tfg: {\n\t\tblack: \"\\x1b[30m\",\n\t\tred: \"\\x1b[31m\",\n\t\tgreen: \"\\x1b[32m\",\n\t\tyellow: \"\\x1b[33m\",\n\t\tblue: \"\\x1b[34m\",\n\t\tmagenta: \"\\x1b[35m\",\n\t\tcyan: \"\\x1b[36m\",\n\t\twhite: \"\\x1b[37m\",\n\t},\n\tbg: {\n\t\tblack: \"\\x1b[40m\",\n\t\tred: \"\\x1b[41m\",\n\t\tgreen: \"\\x1b[42m\",\n\t\tyellow: \"\\x1b[43m\",\n\t\tblue: \"\\x1b[44m\",\n\t\tmagenta: \"\\x1b[45m\",\n\t\tcyan: \"\\x1b[46m\",\n\t\twhite: \"\\x1b[47m\",\n\t},\n} as const;\n\nexport type LogLevel = \"debug\" | \"info\" | \"success\" | \"warn\" | \"error\";\n\nexport const levels = [\"debug\", \"info\", \"success\", \"warn\", \"error\"] as const;\n\nexport function shouldPublishLog(\n\tcurrentLogLevel: LogLevel,\n\tlogLevel: LogLevel,\n): boolean {\n\treturn levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);\n}\n\nexport interface Logger {\n\tdisabled?: boolean | undefined;\n\tdisableColors?: boolean | undefined;\n\tlevel?: Exclude<LogLevel, \"success\"> | undefined;\n\tlog?:\n\t\t| ((\n\t\t\t\tlevel: Exclude<LogLevel, \"success\">,\n\t\t\t\tmessage: string,\n\t\t\t\t...args: any[]\n\t\t ) => void)\n\t\t| undefined;\n}\n\nexport type LogHandlerParams =\n\tParameters<NonNullable<Logger[\"log\"]>> extends [LogLevel, ...infer Rest]\n\t\t? Rest\n\t\t: never;\n\nconst levelColors: Record<LogLevel, string> = {\n\tinfo: TTY_COLORS.fg.blue,\n\tsuccess: TTY_COLORS.fg.green,\n\twarn: TTY_COLORS.fg.yellow,\n\terror: TTY_COLORS.fg.red,\n\tdebug: TTY_COLORS.fg.magenta,\n};\n\nconst formatMessage = (\n\tlevel: LogLevel,\n\tmessage: string,\n\tcolorsEnabled: boolean,\n): string => {\n\tconst timestamp = new Date().toISOString();\n\n\tif (colorsEnabled) {\n\t\treturn `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${\n\t\t\tlevelColors[level]\n\t\t}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${\n\t\t\tTTY_COLORS.reset\n\t\t} ${message}`;\n\t}\n\n\treturn `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;\n};\n\nexport type InternalLogger = {\n\t[K in LogLevel]: (...params: LogHandlerParams) => void;\n} & {\n\tget level(): LogLevel;\n};\n\nexport const createLogger = (options?: Logger | undefined): InternalLogger => {\n\tconst enabled = options?.disabled !== true;\n\tconst logLevel = options?.level ?? \"warn\";\n\n\tconst isDisableColorsSpecified = options?.disableColors !== undefined;\n\tconst colorsEnabled = isDisableColorsSpecified\n\t\t? !options.disableColors\n\t\t: getColorDepth() !== 1;\n\n\tconst LogFunc = (\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\targs: any[] = [],\n\t): void => {\n\t\tif (!enabled || !shouldPublishLog(logLevel, level)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst formattedMessage = formatMessage(level, message, colorsEnabled);\n\n\t\tif (!options || typeof options.log !== \"function\") {\n\t\t\tif (level === \"error\") {\n\t\t\t\tconsole.error(formattedMessage, ...args);\n\t\t\t} else if (level === \"warn\") {\n\t\t\t\tconsole.warn(formattedMessage, ...args);\n\t\t\t} else {\n\t\t\t\tconsole.log(formattedMessage, ...args);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\toptions.log(level === \"success\" ? \"info\" : level, message, ...args);\n\t};\n\n\tconst logger = Object.fromEntries(\n\t\tlevels.map((level) => [\n\t\t\tlevel,\n\t\t\t(...[message, ...args]: LogHandlerParams) =>\n\t\t\t\tLogFunc(level, message, args),\n\t\t]),\n\t) as Record<LogLevel, (...params: LogHandlerParams) => void>;\n\n\treturn {\n\t\t...logger,\n\t\tget level() {\n\t\t\treturn logLevel;\n\t\t},\n\t};\n};\n\nexport const logger = createLogger();\n"],"mappings":";;;AAEA,MAAa,aAAa;CACzB,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,YAAY;CACZ,OAAO;CACP,SAAS;CACT,QAAQ;CACR,IAAI;EACH,OAAO;EACP,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM;EACN,OAAO;EACP;CACD,IAAI;EACH,OAAO;EACP,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM;EACN,OAAO;EACP;CACD;AAID,MAAa,SAAS;CAAC;CAAS;CAAQ;CAAW;CAAQ;CAAQ;AAEnE,SAAgB,iBACf,iBACA,UACU;AACV,QAAO,OAAO,QAAQ,SAAS,IAAI,OAAO,QAAQ,gBAAgB;;AAqBnE,MAAM,cAAwC;CAC7C,MAAM,WAAW,GAAG;CACpB,SAAS,WAAW,GAAG;CACvB,MAAM,WAAW,GAAG;CACpB,OAAO,WAAW,GAAG;CACrB,OAAO,WAAW,GAAG;CACrB;AAED,MAAM,iBACL,OACA,SACA,kBACY;CACZ,MAAM,6BAAY,IAAI,MAAM,EAAC,aAAa;AAE1C,KAAI,cACH,QAAO,GAAG,WAAW,MAAM,YAAY,WAAW,MAAM,GACvD,YAAY,SACV,MAAM,aAAa,GAAG,WAAW,MAAM,GAAG,WAAW,OAAO,gBAC9D,WAAW,MACX,GAAG;AAGL,QAAO,GAAG,UAAU,GAAG,MAAM,aAAa,CAAC,kBAAkB;;AAS9D,MAAa,gBAAgB,YAAiD;CAC7E,MAAM,UAAU,SAAS,aAAa;CACtC,MAAM,WAAW,SAAS,SAAS;CAGnC,MAAM,gBAD2B,SAAS,kBAAkB,SAEzD,CAAC,QAAQ,gBACT,eAAe,KAAK;CAEvB,MAAM,WACL,OACA,SACA,OAAc,EAAE,KACN;AACV,MAAI,CAAC,WAAW,CAAC,iBAAiB,UAAU,MAAM,CACjD;EAGD,MAAM,mBAAmB,cAAc,OAAO,SAAS,cAAc;AAErE,MAAI,CAAC,WAAW,OAAO,QAAQ,QAAQ,YAAY;AAClD,OAAI,UAAU,QACb,SAAQ,MAAM,kBAAkB,GAAG,KAAK;YAC9B,UAAU,OACpB,SAAQ,KAAK,kBAAkB,GAAG,KAAK;OAEvC,SAAQ,IAAI,kBAAkB,GAAG,KAAK;AAEvC;;AAGD,UAAQ,IAAI,UAAU,YAAY,SAAS,OAAO,SAAS,GAAG,KAAK;;AAWpE,QAAO;EACN,GATc,OAAO,YACrB,OAAO,KAAK,UAAU,CACrB,QACC,GAAG,CAAC,SAAS,GAAG,UAChB,QAAQ,OAAO,SAAS,KAAK,CAC9B,CAAC,CACF;EAIA,IAAI,QAAQ;AACX,UAAO;;EAER;;AAGF,MAAa,SAAS,cAAc"}
@@ -1,48 +1,69 @@
1
+ import { RawError } from "../utils/error-codes.mjs";
2
+
1
3
  //#region src/error/codes.d.ts
4
+ declare module "@better-auth/core" {
5
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
6
+ /**
7
+ * This plugin does not exist, do not use it in runtime.
8
+ */
9
+ "$internal:base": {
10
+ creator: () => {
11
+ $ERROR_CODES: typeof BASE_ERROR_CODES;
12
+ };
13
+ };
14
+ }
15
+ }
2
16
  declare const BASE_ERROR_CODES: {
3
- readonly USER_NOT_FOUND: "User not found";
4
- readonly FAILED_TO_CREATE_USER: "Failed to create user";
5
- readonly FAILED_TO_CREATE_SESSION: "Failed to create session";
6
- readonly FAILED_TO_UPDATE_USER: "Failed to update user";
7
- readonly FAILED_TO_GET_SESSION: "Failed to get session";
8
- readonly INVALID_PASSWORD: "Invalid password";
9
- readonly INVALID_EMAIL: "Invalid email";
10
- readonly INVALID_EMAIL_OR_PASSWORD: "Invalid email or password";
11
- readonly SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked";
12
- readonly PROVIDER_NOT_FOUND: "Provider not found";
13
- readonly INVALID_TOKEN: "Invalid token";
14
- readonly ID_TOKEN_NOT_SUPPORTED: "id_token not supported";
15
- readonly FAILED_TO_GET_USER_INFO: "Failed to get user info";
16
- readonly USER_EMAIL_NOT_FOUND: "User email not found";
17
- readonly EMAIL_NOT_VERIFIED: "Email not verified";
18
- readonly PASSWORD_TOO_SHORT: "Password too short";
19
- readonly PASSWORD_TOO_LONG: "Password too long";
20
- readonly USER_ALREADY_EXISTS: "User already exists.";
21
- readonly USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.";
22
- readonly EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated";
23
- readonly CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found";
24
- readonly SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.";
25
- readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
26
- readonly ACCOUNT_NOT_FOUND: "Account not found";
27
- readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
28
- readonly CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.";
29
- readonly VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled";
30
- readonly EMAIL_ALREADY_VERIFIED: "Email is already verified";
31
- readonly EMAIL_MISMATCH: "Email mismatch";
32
- readonly SESSION_NOT_FRESH: "Session is not fresh";
33
- readonly LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists";
34
- readonly INVALID_ORIGIN: "Invalid origin";
35
- readonly INVALID_CALLBACK_URL: "Invalid callbackURL";
36
- readonly INVALID_REDIRECT_URL: "Invalid redirectURL";
37
- readonly INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL";
38
- readonly INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL";
39
- readonly MISSING_OR_NULL_ORIGIN: "Missing or null Origin";
40
- readonly CALLBACK_URL_REQUIRED: "callbackURL is required";
41
- readonly FAILED_TO_CREATE_VERIFICATION: "Unable to create verification";
42
- readonly FIELD_NOT_ALLOWED: "Field not allowed to be set";
43
- readonly ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported";
44
- readonly VALIDATION_ERROR: "Validation Error";
45
- readonly MISSING_FIELD: "Field is required";
17
+ USER_NOT_FOUND: RawError<"USER_NOT_FOUND">;
18
+ FAILED_TO_CREATE_USER: RawError<"FAILED_TO_CREATE_USER">;
19
+ FAILED_TO_CREATE_SESSION: RawError<"FAILED_TO_CREATE_SESSION">;
20
+ FAILED_TO_UPDATE_USER: RawError<"FAILED_TO_UPDATE_USER">;
21
+ FAILED_TO_GET_SESSION: RawError<"FAILED_TO_GET_SESSION">;
22
+ INVALID_PASSWORD: RawError<"INVALID_PASSWORD">;
23
+ INVALID_EMAIL: RawError<"INVALID_EMAIL">;
24
+ INVALID_EMAIL_OR_PASSWORD: RawError<"INVALID_EMAIL_OR_PASSWORD">;
25
+ INVALID_USER: RawError<"INVALID_USER">;
26
+ SOCIAL_ACCOUNT_ALREADY_LINKED: RawError<"SOCIAL_ACCOUNT_ALREADY_LINKED">;
27
+ PROVIDER_NOT_FOUND: RawError<"PROVIDER_NOT_FOUND">;
28
+ INVALID_TOKEN: RawError<"INVALID_TOKEN">;
29
+ TOKEN_EXPIRED: RawError<"TOKEN_EXPIRED">;
30
+ ID_TOKEN_NOT_SUPPORTED: RawError<"ID_TOKEN_NOT_SUPPORTED">;
31
+ FAILED_TO_GET_USER_INFO: RawError<"FAILED_TO_GET_USER_INFO">;
32
+ USER_EMAIL_NOT_FOUND: RawError<"USER_EMAIL_NOT_FOUND">;
33
+ EMAIL_NOT_VERIFIED: RawError<"EMAIL_NOT_VERIFIED">;
34
+ PASSWORD_TOO_SHORT: RawError<"PASSWORD_TOO_SHORT">;
35
+ PASSWORD_TOO_LONG: RawError<"PASSWORD_TOO_LONG">;
36
+ USER_ALREADY_EXISTS: RawError<"USER_ALREADY_EXISTS">;
37
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
38
+ EMAIL_CAN_NOT_BE_UPDATED: RawError<"EMAIL_CAN_NOT_BE_UPDATED">;
39
+ CREDENTIAL_ACCOUNT_NOT_FOUND: RawError<"CREDENTIAL_ACCOUNT_NOT_FOUND">;
40
+ ACCOUNT_NOT_FOUND: RawError<"ACCOUNT_NOT_FOUND">;
41
+ SESSION_EXPIRED: RawError<"SESSION_EXPIRED">;
42
+ FAILED_TO_UNLINK_LAST_ACCOUNT: RawError<"FAILED_TO_UNLINK_LAST_ACCOUNT">;
43
+ USER_ALREADY_HAS_PASSWORD: RawError<"USER_ALREADY_HAS_PASSWORD">;
44
+ CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: RawError<"CROSS_SITE_NAVIGATION_LOGIN_BLOCKED">;
45
+ VERIFICATION_EMAIL_NOT_ENABLED: RawError<"VERIFICATION_EMAIL_NOT_ENABLED">;
46
+ EMAIL_ALREADY_VERIFIED: RawError<"EMAIL_ALREADY_VERIFIED">;
47
+ EMAIL_MISMATCH: RawError<"EMAIL_MISMATCH">;
48
+ SESSION_NOT_FRESH: RawError<"SESSION_NOT_FRESH">;
49
+ LINKED_ACCOUNT_ALREADY_EXISTS: RawError<"LINKED_ACCOUNT_ALREADY_EXISTS">;
50
+ INVALID_ORIGIN: RawError<"INVALID_ORIGIN">;
51
+ INVALID_CALLBACK_URL: RawError<"INVALID_CALLBACK_URL">;
52
+ INVALID_REDIRECT_URL: RawError<"INVALID_REDIRECT_URL">;
53
+ INVALID_ERROR_CALLBACK_URL: RawError<"INVALID_ERROR_CALLBACK_URL">;
54
+ INVALID_NEW_USER_CALLBACK_URL: RawError<"INVALID_NEW_USER_CALLBACK_URL">;
55
+ MISSING_OR_NULL_ORIGIN: RawError<"MISSING_OR_NULL_ORIGIN">;
56
+ CALLBACK_URL_REQUIRED: RawError<"CALLBACK_URL_REQUIRED">;
57
+ FAILED_TO_CREATE_VERIFICATION: RawError<"FAILED_TO_CREATE_VERIFICATION">;
58
+ FIELD_NOT_ALLOWED: RawError<"FIELD_NOT_ALLOWED">;
59
+ ASYNC_VALIDATION_NOT_SUPPORTED: RawError<"ASYNC_VALIDATION_NOT_SUPPORTED">;
60
+ VALIDATION_ERROR: RawError<"VALIDATION_ERROR">;
61
+ MISSING_FIELD: RawError<"MISSING_FIELD">;
62
+ METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED: RawError<"METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED">;
63
+ BODY_MUST_BE_AN_OBJECT: RawError<"BODY_MUST_BE_AN_OBJECT">;
64
+ PASSWORD_ALREADY_SET: RawError<"PASSWORD_ALREADY_SET">;
46
65
  };
66
+ type APIErrorCode = keyof typeof BASE_ERROR_CODES;
47
67
  //#endregion
48
- export { BASE_ERROR_CODES };
68
+ export { APIErrorCode, BASE_ERROR_CODES };
69
+ //# sourceMappingURL=codes.d.mts.map