@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,9 +1,6 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import {
3
- createAuthorizationURL,
4
- validateAuthorizationCode,
5
- } from "@better-auth/core/oauth2";
6
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import { createAuthorizationURL, validateAuthorizationCode } from "../oauth2";
3
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
7
4
 
8
5
  export interface KickProfile {
9
6
  /**
@@ -1,11 +1,11 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
2
  import { decodeJwt } from "jose";
3
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
3
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
4
4
  import {
5
5
  createAuthorizationURL,
6
6
  refreshAccessToken,
7
7
  validateAuthorizationCode,
8
- } from "@better-auth/core/oauth2";
8
+ } from "../oauth2";
9
9
 
10
10
  export interface LineIdTokenPayload {
11
11
  iss: string;
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  refreshAccessToken,
6
6
  validateAuthorizationCode,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  interface LinearUser {
10
10
  id: string;
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  validateAuthorizationCode,
6
6
  refreshAccessToken,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  export interface LinkedInProfile {
10
10
  sub: string;
@@ -2,10 +2,10 @@ import {
2
2
  validateAuthorizationCode,
3
3
  createAuthorizationURL,
4
4
  refreshAccessToken,
5
- } from "@better-auth/core/oauth2";
6
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
5
+ } from "../oauth2";
6
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
7
7
  import { betterFetch } from "@better-fetch/fetch";
8
- import { logger } from "@better-auth/core/env";
8
+ import { logger } from "../env";
9
9
  import { decodeJwt } from "jose";
10
10
  import { base64 } from "@better-auth/utils/base64";
11
11
 
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  validateAuthorizationCode,
6
6
  refreshAccessToken,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  export interface NaverProfile {
10
10
  /** API response result code */
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  refreshAccessToken,
6
6
  validateAuthorizationCode,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  export interface NotionProfile {
10
10
  object: "user";
@@ -1,8 +1,8 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
2
  import { BetterAuthError } from "../error";
3
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
4
- import { createAuthorizationURL } from "@better-auth/core/oauth2";
5
- import { logger } from "@better-auth/core/env";
3
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
4
+ import { createAuthorizationURL } from "../oauth2";
5
+ import { logger } from "../env";
6
6
  import { decodeJwt } from "jose";
7
7
  import { base64 } from "@better-auth/utils/base64";
8
8
 
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  getOAuth2Tokens,
6
6
  refreshAccessToken,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
  import { base64 } from "@better-auth/utils/base64";
9
9
 
10
10
  export interface RedditProfile {
@@ -1,9 +1,6 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
3
- import {
4
- validateAuthorizationCode,
5
- refreshAccessToken,
6
- } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
+ import { validateAuthorizationCode, refreshAccessToken } from "../oauth2";
7
4
 
8
5
  export interface RobloxProfile extends Record<string, any> {
9
6
  /** the user's id */
@@ -1,12 +1,9 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
2
  import { BetterAuthError } from "../error";
3
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
4
- import {
5
- createAuthorizationURL,
6
- validateAuthorizationCode,
7
- } from "@better-auth/core/oauth2";
8
- import { logger } from "@better-auth/core/env";
9
- import { refreshAccessToken } from "@better-auth/core/oauth2";
3
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
4
+ import { createAuthorizationURL, validateAuthorizationCode } from "../oauth2";
5
+ import { logger } from "../env";
6
+ import { refreshAccessToken } from "../oauth2";
10
7
 
11
8
  export interface SalesforceProfile {
12
9
  sub: string;
@@ -1,9 +1,6 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
3
- import {
4
- validateAuthorizationCode,
5
- refreshAccessToken,
6
- } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
+ import { validateAuthorizationCode, refreshAccessToken } from "../oauth2";
7
4
 
8
5
  export interface SlackProfile extends Record<string, any> {
9
6
  ok: boolean;
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  validateAuthorizationCode,
6
6
  refreshAccessToken,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  export interface SpotifyProfile {
10
10
  id: string;
@@ -1,9 +1,6 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
3
- import {
4
- refreshAccessToken,
5
- validateAuthorizationCode,
6
- } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
+ import { refreshAccessToken, validateAuthorizationCode } from "../oauth2";
7
4
 
8
5
  /**
9
6
  * [More info](https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/)
@@ -1,10 +1,10 @@
1
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
- import { logger } from "@better-auth/core/env";
1
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
2
+ import { logger } from "../env";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  validateAuthorizationCode,
6
6
  refreshAccessToken,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
  import { decodeJwt } from "jose";
9
9
 
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
3
3
  import {
4
4
  createAuthorizationURL,
5
5
  refreshAccessToken,
6
6
  validateAuthorizationCode,
7
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
8
8
 
9
9
  export interface TwitterProfile {
10
10
  data: {
@@ -1,13 +1,10 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import {
3
- type OAuthProvider,
4
- type ProviderOptions,
5
- } from "@better-auth/core/oauth2";
2
+ import { type OAuthProvider, type ProviderOptions } from "../oauth2";
6
3
  import {
7
4
  createAuthorizationURL,
8
5
  validateAuthorizationCode,
9
6
  refreshAccessToken,
10
- } from "@better-auth/core/oauth2";
7
+ } from "../oauth2";
11
8
 
12
9
  export interface VkProfile {
13
10
  user: {
@@ -1,9 +1,6 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- import {
3
- generateCodeChallenge,
4
- validateAuthorizationCode,
5
- } from "@better-auth/core/oauth2";
6
- import type { OAuthProvider, ProviderOptions } from "@better-auth/core/oauth2";
2
+ import { generateCodeChallenge, validateAuthorizationCode } from "../oauth2";
3
+ import type { OAuthProvider, ProviderOptions } from "../oauth2";
7
4
 
8
5
  export type LoginType =
9
6
  | 0 /** Facebook OAuth */
@@ -8,9 +8,9 @@ import type {
8
8
  } from "../db";
9
9
  import type { OAuthProvider } from "../oauth2";
10
10
  import { createLogger } from "../env";
11
- import type { DBAdapter, DBTransactionAdapter, Where } from "../db/adapter";
11
+ import type { DBAdapter, Where } from "../db/adapter";
12
12
  import type { BetterAuthCookies } from "./cookie";
13
- import type { Models } from "../db/type";
13
+ import type { DBPreservedModels } from "../db";
14
14
  import type { LiteralUnion } from "./helper";
15
15
  import type { CookieOptions, EndpointContext } from "better-call";
16
16
  import type {
@@ -31,198 +31,119 @@ export interface InternalAdapter<
31
31
  user: Omit<User, "id" | "createdAt" | "updatedAt">,
32
32
  account: Omit<Account, "userId" | "id" | "createdAt" | "updatedAt"> &
33
33
  Partial<Account>,
34
- context?: GenericEndpointContext<Options>,
35
34
  ): Promise<{ user: User; account: Account }>;
36
35
 
37
36
  createUser<T extends Record<string, any>>(
38
37
  user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> &
39
38
  Partial<User> &
40
39
  Record<string, any>,
41
- context?: GenericEndpointContext<Options>,
42
- trxAdapter?: DBTransactionAdapter<Options>,
43
40
  ): Promise<T & User>;
44
41
 
45
42
  createAccount<T extends Record<string, any>>(
46
43
  account: Omit<Account, "id" | "createdAt" | "updatedAt"> &
47
44
  Partial<Account> &
48
45
  T,
49
- context?: GenericEndpointContext<Options>,
50
- trxAdapter?: DBTransactionAdapter<Options>,
51
46
  ): Promise<T & Account>;
52
47
 
53
- listSessions(
54
- userId: string,
55
- trxAdapter?: DBTransactionAdapter<Options>,
56
- ): Promise<Session[]>;
48
+ listSessions(userId: string): Promise<Session[]>;
57
49
 
58
50
  listUsers(
59
51
  limit?: number,
60
52
  offset?: number,
61
53
  sortBy?: { field: string; direction: "asc" | "desc" },
62
54
  where?: Where[],
63
- trxAdapter?: DBTransactionAdapter<Options>,
64
55
  ): Promise<User[]>;
65
56
 
66
- countTotalUsers(
67
- where?: Where[],
68
- trxAdapter?: DBTransactionAdapter<Options>,
69
- ): Promise<number>;
57
+ countTotalUsers(where?: Where[]): Promise<number>;
70
58
 
71
- deleteUser(
72
- userId: string,
73
- trxAdapter?: DBTransactionAdapter<Options>,
74
- ): Promise<void>;
59
+ deleteUser(userId: string): Promise<void>;
75
60
 
76
61
  createSession(
77
62
  userId: string,
78
- ctx: GenericEndpointContext<Options>,
79
63
  dontRememberMe?: boolean,
80
64
  override?: Partial<Session> & Record<string, any>,
81
65
  overrideAll?: boolean,
82
- trxAdapter?: DBTransactionAdapter<Options>,
83
66
  ): Promise<Session>;
84
67
 
85
- findSession(
86
- token: string,
87
- trxAdapter?: DBTransactionAdapter<Options>,
88
- ): Promise<{
68
+ findSession(token: string): Promise<{
89
69
  session: Session & Record<string, any>;
90
70
  user: User & Record<string, any>;
91
71
  } | null>;
92
72
 
93
73
  findSessions(
94
74
  sessionTokens: string[],
95
- trxAdapter?: DBTransactionAdapter<Options>,
96
75
  ): Promise<{ session: Session; user: User }[]>;
97
76
 
98
77
  updateSession(
99
78
  sessionToken: string,
100
79
  session: Partial<Session> & Record<string, any>,
101
- context?: GenericEndpointContext<Options>,
102
- trxAdapter?: DBTransactionAdapter<Options>,
103
80
  ): Promise<Session | null>;
104
81
 
105
- deleteSession(
106
- token: string,
107
- trxAdapter?: DBTransactionAdapter<Options>,
108
- ): Promise<void>;
82
+ deleteSession(token: string): Promise<void>;
109
83
 
110
- deleteAccounts(
111
- userId: string,
112
- trxAdapter?: DBTransactionAdapter<Options>,
113
- ): Promise<void>;
84
+ deleteAccounts(userId: string): Promise<void>;
114
85
 
115
- deleteAccount(
116
- accountId: string,
117
- trxAdapter?: DBTransactionAdapter<Options>,
118
- ): Promise<void>;
86
+ deleteAccount(accountId: string): Promise<void>;
119
87
 
120
- deleteSessions(
121
- userIdOrSessionTokens: string | string[],
122
- trxAdapter?: DBTransactionAdapter<Options>,
123
- ): Promise<void>;
88
+ deleteSessions(userIdOrSessionTokens: string | string[]): Promise<void>;
124
89
 
125
90
  findOAuthUser(
126
91
  email: string,
127
92
  accountId: string,
128
93
  providerId: string,
129
- trxAdapter?: DBTransactionAdapter<Options>,
130
94
  ): Promise<{ user: User; accounts: Account[] } | null>;
131
95
 
132
96
  findUserByEmail(
133
97
  email: string,
134
98
  options?: { includeAccounts: boolean },
135
- trxAdapter?: DBTransactionAdapter<Options>,
136
99
  ): Promise<{ user: User; accounts: Account[] } | null>;
137
100
 
138
- findUserById(
139
- userId: string,
140
- trxAdapter?: DBTransactionAdapter<Options>,
141
- ): Promise<User | null>;
101
+ findUserById(userId: string): Promise<User | null>;
142
102
 
143
103
  linkAccount(
144
104
  account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account>,
145
- context?: GenericEndpointContext<Options>,
146
- trxAdapter?: DBTransactionAdapter<Options>,
147
105
  ): Promise<Account>;
148
106
 
149
107
  // fixme: any type
150
108
  updateUser(
151
109
  userId: string,
152
110
  data: Partial<User> & Record<string, any>,
153
- context?: GenericEndpointContext<Options>,
154
- trxAdapter?: DBTransactionAdapter<Options>,
155
111
  ): Promise<any>;
156
112
 
157
113
  updateUserByEmail(
158
114
  email: string,
159
115
  data: Partial<User & Record<string, any>>,
160
- context?: GenericEndpointContext<Options>,
161
- trxAdapter?: DBTransactionAdapter<Options>,
162
116
  ): Promise<User>;
163
117
 
164
- updatePassword(
165
- userId: string,
166
- password: string,
167
- context?: GenericEndpointContext<Options>,
168
- trxAdapter?: DBTransactionAdapter<Options>,
169
- ): Promise<void>;
118
+ updatePassword(userId: string, password: string): Promise<void>;
170
119
 
171
- findAccounts(
172
- userId: string,
173
- trxAdapter?: DBTransactionAdapter<Options>,
174
- ): Promise<Account[]>;
120
+ findAccounts(userId: string): Promise<Account[]>;
175
121
 
176
- findAccount(
177
- accountId: string,
178
- trxAdapter?: DBTransactionAdapter<Options>,
179
- ): Promise<Account | null>;
122
+ findAccount(accountId: string): Promise<Account | null>;
180
123
 
181
124
  findAccountByProviderId(
182
125
  accountId: string,
183
126
  providerId: string,
184
- trxAdapter?: DBTransactionAdapter<Options>,
185
127
  ): Promise<Account | null>;
186
128
 
187
- findAccountByUserId(
188
- userId: string,
189
- trxAdapter?: DBTransactionAdapter<Options>,
190
- ): Promise<Account[]>;
129
+ findAccountByUserId(userId: string): Promise<Account[]>;
191
130
 
192
- updateAccount(
193
- id: string,
194
- data: Partial<Account>,
195
- context?: GenericEndpointContext<Options>,
196
- trxAdapter?: DBTransactionAdapter<Options>,
197
- ): Promise<Account>;
131
+ updateAccount(id: string, data: Partial<Account>): Promise<Account>;
198
132
 
199
133
  createVerificationValue(
200
134
  data: Omit<Verification, "createdAt" | "id" | "updatedAt"> &
201
135
  Partial<Verification>,
202
- context?: GenericEndpointContext<Options>,
203
- trxAdapter?: DBTransactionAdapter<Options>,
204
136
  ): Promise<Verification>;
205
137
 
206
- findVerificationValue(
207
- identifier: string,
208
- trxAdapter?: DBTransactionAdapter<Options>,
209
- ): Promise<Verification | null>;
138
+ findVerificationValue(identifier: string): Promise<Verification | null>;
210
139
 
211
- deleteVerificationValue(
212
- id: string,
213
- trxAdapter?: DBTransactionAdapter<Options>,
214
- ): Promise<void>;
140
+ deleteVerificationValue(id: string): Promise<void>;
215
141
 
216
- deleteVerificationByIdentifier(
217
- identifier: string,
218
- trxAdapter?: DBTransactionAdapter<Options>,
219
- ): Promise<void>;
142
+ deleteVerificationByIdentifier(identifier: string): Promise<void>;
220
143
 
221
144
  updateVerificationValue(
222
145
  id: string,
223
146
  data: Partial<Verification>,
224
- context?: GenericEndpointContext<Options>,
225
- trxAdapter?: DBTransactionAdapter<Options>,
226
147
  ): Promise<Verification>;
227
148
  }
228
149
 
@@ -290,7 +211,7 @@ export type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> =
290
211
  freshAge: number;
291
212
  };
292
213
  generateId: (options: {
293
- model: LiteralUnion<Models, string>;
214
+ model: LiteralUnion<DBPreservedModels, string>;
294
215
  size?: number;
295
216
  }) => string | false;
296
217
  secondaryStorage: SecondaryStorage | undefined;
@@ -11,7 +11,7 @@ export type {
11
11
  GenericEndpointContext,
12
12
  InternalAdapter,
13
13
  } from "./context";
14
- export type { BetterAuthPlugin } from "./plugin";
14
+ export type { BetterAuthPlugin, HookEndpointContext } from "./plugin";
15
15
  export type {
16
16
  BetterAuthClientPlugin,
17
17
  BetterAuthClientOptions,
@@ -2,7 +2,11 @@ import type { Dialect, Kysely, MysqlPool, PostgresPool } from "kysely";
2
2
  import type { Database } from "better-sqlite3";
3
3
  import type { CookieOptions } from "better-call";
4
4
  import type { LiteralUnion } from "./helper";
5
- import type { DBFieldAttribute, Models, SecondaryStorage } from "../db/type";
5
+ import type {
6
+ DBFieldAttribute,
7
+ DBPreservedModels,
8
+ SecondaryStorage,
9
+ } from "../db/type";
6
10
  import type { Account, RateLimit, Session, User, Verification } from "../db";
7
11
  import type { Database as BunDatabase } from "bun:sqlite";
8
12
  import type { DatabaseSync } from "node:sqlite";
@@ -10,14 +14,17 @@ import type { DBAdapterDebugLogOption, DBAdapterInstance } from "../db/adapter";
10
14
  import type { SocialProviderList, SocialProviders } from "../social-providers";
11
15
  import type { Logger } from "../env";
12
16
  import type { AuthContext, GenericEndpointContext } from "./context";
13
- import type { AuthMiddleware } from "../middleware";
14
- import type { BetterAuthPlugin } from "@better-auth/core";
17
+ import type { AuthMiddleware } from "../api";
18
+ import type { BetterAuthPlugin } from "..";
15
19
 
16
20
  type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
17
21
  type OmitId<T extends { id: unknown }> = Omit<T, "id">;
22
+ type Optional<T> = {
23
+ [P in keyof T]?: T[P] | undefined;
24
+ };
18
25
 
19
26
  export type GenerateIdFn = (options: {
20
- model: LiteralUnion<Models, string>;
27
+ model: LiteralUnion<DBPreservedModels, string>;
21
28
  size?: number;
22
29
  }) => string | false;
23
30
 
@@ -210,15 +217,6 @@ export type BetterAuthAdvancedOptions = {
210
217
  */
211
218
  generateId?: GenerateIdFn | false;
212
219
  };
213
- /**
214
- * Custom generateId function.
215
- *
216
- * If not provided, random ids will be generated.
217
- * If set to false, the database's auto generated id will be used.
218
- *
219
- * @deprecated Please use `database.generateId` instead. This will be potentially removed in future releases.
220
- */
221
- generateId?: GenerateIdFn | false;
222
220
  };
223
221
 
224
222
  export type BetterAuthOptions = {
@@ -799,7 +797,7 @@ export type BetterAuthOptions = {
799
797
  /**
800
798
  * @deprecated Please use `database.generateId` instead.
801
799
  */
802
- generateId?: GenerateIdFn | false;
800
+ generateId?: never;
803
801
  };
804
802
  logger?: Logger;
805
803
  /**
@@ -825,7 +823,7 @@ export type BetterAuthOptions = {
825
823
  | boolean
826
824
  | void
827
825
  | {
828
- data: Partial<User> & Record<string, any>;
826
+ data: Optional<User> & Record<string, any>;
829
827
  }
830
828
  >;
831
829
  /**
@@ -849,7 +847,7 @@ export type BetterAuthOptions = {
849
847
  | boolean
850
848
  | void
851
849
  | {
852
- data: Partial<User & Record<string, any>>;
850
+ data: Optional<User & Record<string, any>>;
853
851
  }
854
852
  >;
855
853
  /**
@@ -895,7 +893,7 @@ export type BetterAuthOptions = {
895
893
  | boolean
896
894
  | void
897
895
  | {
898
- data: Partial<Session> & Record<string, any>;
896
+ data: Optional<Session> & Record<string, any>;
899
897
  }
900
898
  >;
901
899
  /**
@@ -922,7 +920,7 @@ export type BetterAuthOptions = {
922
920
  | boolean
923
921
  | void
924
922
  | {
925
- data: Partial<Session & Record<string, any>>;
923
+ data: Optional<Session & Record<string, any>>;
926
924
  }
927
925
  >;
928
926
  /**
@@ -968,7 +966,7 @@ export type BetterAuthOptions = {
968
966
  | boolean
969
967
  | void
970
968
  | {
971
- data: Partial<Account> & Record<string, any>;
969
+ data: Optional<Account> & Record<string, any>;
972
970
  }
973
971
  >;
974
972
  /**
@@ -995,7 +993,7 @@ export type BetterAuthOptions = {
995
993
  | boolean
996
994
  | void
997
995
  | {
998
- data: Partial<Account & Record<string, any>>;
996
+ data: Optional<Account & Record<string, any>>;
999
997
  }
1000
998
  >;
1001
999
  /**
@@ -1041,7 +1039,7 @@ export type BetterAuthOptions = {
1041
1039
  | boolean
1042
1040
  | void
1043
1041
  | {
1044
- data: Partial<Verification> & Record<string, any>;
1042
+ data: Optional<Verification> & Record<string, any>;
1045
1043
  }
1046
1044
  >;
1047
1045
  /**
@@ -1065,7 +1063,7 @@ export type BetterAuthOptions = {
1065
1063
  | boolean
1066
1064
  | void
1067
1065
  | {
1068
- data: Partial<Verification & Record<string, any>>;
1066
+ data: Optional<Verification & Record<string, any>>;
1069
1067
  }
1070
1068
  >;
1071
1069
  /**
@@ -9,7 +9,7 @@ import type {
9
9
  import type { BetterAuthPluginDBSchema } from "../db";
10
10
  import type { LiteralString } from "./helper";
11
11
  import type { BetterAuthOptions } from "./init-options";
12
- import type { AuthMiddleware } from "../middleware";
12
+ import type { AuthMiddleware } from "../api";
13
13
 
14
14
  type Awaitable<T> = T | Promise<T>;
15
15
  type DeepPartial<T> = T extends Function
@@ -18,13 +18,13 @@ type DeepPartial<T> = T extends Function
18
18
  ? { [K in keyof T]?: DeepPartial<T[K]> }
19
19
  : T;
20
20
 
21
- type HookEndpointContext = EndpointContext<string, any> &
21
+ export type HookEndpointContext = EndpointContext<string, any> &
22
22
  Omit<InputContext<string, any>, "method"> & {
23
23
  context: AuthContext & {
24
24
  returned?: unknown;
25
25
  responseHeaders?: Headers;
26
26
  };
27
- headers?: Headers;
27
+ headers?: Headers | undefined;
28
28
  };
29
29
 
30
30
  export type BetterAuthPlugin = {