better-auth 1.6.26 → 1.6.28

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 (210) hide show
  1. package/dist/adapters/index.d.mts +6 -1
  2. package/dist/api/dispatch.d.mts +1 -0
  3. package/dist/api/index.d.mts +508 -505
  4. package/dist/api/middlewares/authorization.d.mts +10 -14
  5. package/dist/api/middlewares/authorization.mjs +1 -2
  6. package/dist/api/middlewares/index.d.mts +1 -2
  7. package/dist/api/middlewares/origin-check.d.mts +5 -3
  8. package/dist/api/routes/account.d.mts +16 -13
  9. package/dist/api/routes/callback.d.mts +3 -1
  10. package/dist/api/routes/email-verification.d.mts +8 -4
  11. package/dist/api/routes/error.d.mts +3 -1
  12. package/dist/api/routes/index.d.mts +1 -2
  13. package/dist/api/routes/ok.d.mts +3 -1
  14. package/dist/api/routes/password.d.mts +10 -8
  15. package/dist/api/routes/session.d.mts +32 -30
  16. package/dist/api/routes/session.mjs +2 -3
  17. package/dist/api/routes/sign-in.d.mts +5 -3
  18. package/dist/api/routes/sign-out.d.mts +3 -1
  19. package/dist/api/routes/sign-up.d.mts +4 -3
  20. package/dist/api/routes/update-session.d.mts +5 -4
  21. package/dist/api/routes/update-user.d.mts +19 -18
  22. package/dist/auth/full.d.mts +1 -1
  23. package/dist/auth/minimal.d.mts +1 -1
  24. package/dist/client/config.d.mts +14 -12
  25. package/dist/client/config.mjs +2 -2
  26. package/dist/client/equality.d.mts +1 -0
  27. package/dist/client/index.d.mts +5 -6
  28. package/dist/client/lynx/index.d.mts +5 -4
  29. package/dist/client/lynx/lynx-store.d.mts +2 -1
  30. package/dist/client/parser.d.mts +3 -7
  31. package/dist/client/path-to-object.d.mts +4 -3
  32. package/dist/client/plugins/index.d.mts +1 -1
  33. package/dist/client/plugins/infer-plugin.d.mts +1 -0
  34. package/dist/client/query.d.mts +1 -0
  35. package/dist/client/react/index.d.mts +5 -4
  36. package/dist/client/react/react-store.d.mts +2 -1
  37. package/dist/client/session-atom.mjs +59 -46
  38. package/dist/client/session-refresh.d.mts +1 -0
  39. package/dist/client/solid/index.d.mts +5 -4
  40. package/dist/client/svelte/index.d.mts +5 -4
  41. package/dist/client/types.d.mts +2 -2
  42. package/dist/client/vanilla.d.mts +2 -1
  43. package/dist/client/vue/index.d.mts +5 -4
  44. package/dist/context/create-context.mjs +3 -3
  45. package/dist/context/helpers.mjs +2 -2
  46. package/dist/cookies/index.d.mts +7 -6
  47. package/dist/cookies/session-store.d.mts +0 -1
  48. package/dist/cookies/session-store.mjs +1 -2
  49. package/dist/crypto/index.d.mts +9 -2
  50. package/dist/crypto/jwt.d.mts +1 -0
  51. package/dist/crypto/password.d.mts +5 -1
  52. package/dist/db/adapter-base.d.mts +1 -0
  53. package/dist/db/adapter-kysely.d.mts +1 -0
  54. package/dist/db/field-converter.d.mts +1 -0
  55. package/dist/db/field.d.mts +10 -9
  56. package/dist/db/get-migration.d.mts +1 -0
  57. package/dist/db/get-schema.d.mts +1 -0
  58. package/dist/db/internal-adapter.d.mts +1 -0
  59. package/dist/db/internal-adapter.mjs +1 -2
  60. package/dist/db/revoke-unproven-account-access.d.mts +1 -0
  61. package/dist/db/schema.d.mts +2 -2
  62. package/dist/db/to-zod.d.mts +7 -3
  63. package/dist/db/with-hooks.d.mts +1 -0
  64. package/dist/index.d.mts +3 -4
  65. package/dist/integrations/next-js.d.mts +7 -4
  66. package/dist/integrations/node.d.mts +3 -2
  67. package/dist/integrations/svelte-kit.d.mts +9 -2
  68. package/dist/integrations/tanstack-start-solid.d.mts +5 -2
  69. package/dist/integrations/tanstack-start.d.mts +5 -2
  70. package/dist/oauth2/link-account.d.mts +1 -1
  71. package/dist/oauth2/state.d.mts +1 -0
  72. package/dist/oauth2/utils.d.mts +1 -0
  73. package/dist/package.mjs +1 -1
  74. package/dist/plugins/access/access.d.mts +1 -0
  75. package/dist/plugins/access/types.d.mts +5 -4
  76. package/dist/plugins/additional-fields/client.d.mts +1 -0
  77. package/dist/plugins/admin/access/statement.d.mts +0 -1
  78. package/dist/plugins/admin/admin.d.mts +137 -132
  79. package/dist/plugins/admin/client.d.mts +30 -30
  80. package/dist/plugins/admin/client.mjs +1 -1
  81. package/dist/plugins/admin/error-codes.d.mts +25 -23
  82. package/dist/plugins/admin/index.d.mts +1 -1
  83. package/dist/plugins/admin/schema.d.mts +1 -1
  84. package/dist/plugins/admin/types.d.mts +2 -3
  85. package/dist/plugins/anonymous/client.d.mts +11 -9
  86. package/dist/plugins/anonymous/client.mjs +1 -1
  87. package/dist/plugins/anonymous/error-codes.d.mts +10 -8
  88. package/dist/plugins/anonymous/index.d.mts +19 -15
  89. package/dist/plugins/anonymous/types.d.mts +1 -1
  90. package/dist/plugins/bearer/index.d.mts +8 -5
  91. package/dist/plugins/captcha/index.d.mts +8 -5
  92. package/dist/plugins/captcha/types.d.mts +1 -0
  93. package/dist/plugins/custom-session/client.d.mts +1 -0
  94. package/dist/plugins/custom-session/index.d.mts +12 -7
  95. package/dist/plugins/device-authorization/client.d.mts +1 -0
  96. package/dist/plugins/device-authorization/index.d.mts +22 -19
  97. package/dist/plugins/email-otp/client.d.mts +6 -4
  98. package/dist/plugins/email-otp/client.mjs +1 -1
  99. package/dist/plugins/email-otp/error-codes.d.mts +5 -3
  100. package/dist/plugins/email-otp/index.d.mts +76 -69
  101. package/dist/plugins/email-otp/types.d.mts +1 -0
  102. package/dist/plugins/generic-oauth/client.d.mts +11 -10
  103. package/dist/plugins/generic-oauth/client.mjs +1 -1
  104. package/dist/plugins/generic-oauth/error-codes.d.mts +10 -8
  105. package/dist/plugins/generic-oauth/index.d.mts +45 -41
  106. package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -0
  107. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -0
  108. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -0
  109. package/dist/plugins/generic-oauth/providers/index.d.mts +1 -2
  110. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -0
  111. package/dist/plugins/generic-oauth/providers/line.d.mts +1 -0
  112. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -0
  113. package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -0
  114. package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -0
  115. package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -0
  116. package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -0
  117. package/dist/plugins/generic-oauth/types.d.mts +2 -1
  118. package/dist/plugins/haveibeenpwned/index.d.mts +6 -3
  119. package/dist/plugins/index.d.mts +1 -4
  120. package/dist/plugins/jwt/client.d.mts +2 -1
  121. package/dist/plugins/jwt/index.d.mts +12 -9
  122. package/dist/plugins/jwt/sign.d.mts +2 -2
  123. package/dist/plugins/jwt/types.d.mts +1 -1
  124. package/dist/plugins/jwt/utils.d.mts +4 -2
  125. package/dist/plugins/jwt/verify.d.mts +1 -0
  126. package/dist/plugins/last-login-method/index.d.mts +6 -3
  127. package/dist/plugins/magic-link/client.d.mts +1 -0
  128. package/dist/plugins/magic-link/index.d.mts +6 -4
  129. package/dist/plugins/mcp/client/adapters.d.mts +1 -0
  130. package/dist/plugins/mcp/client/index.mjs +2 -4
  131. package/dist/plugins/mcp/index.d.mts +12 -11
  132. package/dist/plugins/multi-session/client.d.mts +4 -2
  133. package/dist/plugins/multi-session/client.mjs +1 -1
  134. package/dist/plugins/multi-session/error-codes.d.mts +3 -1
  135. package/dist/plugins/multi-session/index.d.mts +12 -8
  136. package/dist/plugins/oauth-popup/client.d.mts +12 -6
  137. package/dist/plugins/oauth-popup/client.mjs +3 -5
  138. package/dist/plugins/oauth-popup/error-codes.d.mts +6 -4
  139. package/dist/plugins/oauth-popup/index.d.mts +12 -8
  140. package/dist/plugins/oauth-popup/index.mjs +1 -1
  141. package/dist/plugins/oauth-popup/types.d.mts +2 -1
  142. package/dist/plugins/oauth-proxy/index.d.mts +9 -6
  143. package/dist/plugins/oauth-proxy/index.mjs +2 -2
  144. package/dist/plugins/oidc-provider/client.d.mts +2 -1
  145. package/dist/plugins/oidc-provider/index.d.mts +20 -18
  146. package/dist/plugins/oidc-provider/schema.d.mts +1 -0
  147. package/dist/plugins/oidc-provider/types.d.mts +1 -1
  148. package/dist/plugins/one-tap/client.d.mts +3 -1
  149. package/dist/plugins/one-tap/index.d.mts +3 -1
  150. package/dist/plugins/one-time-token/client.d.mts +2 -1
  151. package/dist/plugins/one-time-token/index.d.mts +7 -6
  152. package/dist/plugins/open-api/generator.d.mts +1 -0
  153. package/dist/plugins/open-api/generator.mjs +5 -5
  154. package/dist/plugins/open-api/index.d.mts +5 -3
  155. package/dist/plugins/organization/access/statement.d.mts +0 -1
  156. package/dist/plugins/organization/adapter.d.mts +82 -56
  157. package/dist/plugins/organization/client.d.mts +103 -104
  158. package/dist/plugins/organization/client.mjs +4 -7
  159. package/dist/plugins/organization/error-codes.d.mts +61 -59
  160. package/dist/plugins/organization/has-permission.d.mts +1 -0
  161. package/dist/plugins/organization/has-permission.mjs +1 -1
  162. package/dist/plugins/organization/index.d.mts +1 -1
  163. package/dist/plugins/organization/organization.d.mts +33 -9
  164. package/dist/plugins/organization/organization.mjs +1 -1
  165. package/dist/plugins/organization/permission.d.mts +2 -2
  166. package/dist/plugins/organization/routes/crud-access-control.d.mts +147 -27
  167. package/dist/plugins/organization/routes/crud-invites.d.mts +186 -65
  168. package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
  169. package/dist/plugins/organization/routes/crud-members.d.mts +178 -56
  170. package/dist/plugins/organization/routes/crud-members.mjs +1 -1
  171. package/dist/plugins/organization/routes/crud-org.d.mts +130 -57
  172. package/dist/plugins/organization/routes/crud-team.d.mts +235 -66
  173. package/dist/plugins/organization/schema.d.mts +4 -4
  174. package/dist/plugins/organization/schema.mjs +1 -1
  175. package/dist/plugins/organization/types.d.mts +14 -14
  176. package/dist/plugins/phone-number/client.d.mts +15 -13
  177. package/dist/plugins/phone-number/client.mjs +1 -1
  178. package/dist/plugins/phone-number/error-codes.d.mts +14 -12
  179. package/dist/plugins/phone-number/index.d.mts +47 -41
  180. package/dist/plugins/phone-number/types.d.mts +1 -1
  181. package/dist/plugins/siwe/client.d.mts +1 -0
  182. package/dist/plugins/siwe/index.d.mts +5 -4
  183. package/dist/plugins/test-utils/index.d.mts +4 -2
  184. package/dist/plugins/test-utils/types.d.mts +0 -1
  185. package/dist/plugins/two-factor/backup-codes/index.d.mts +7 -5
  186. package/dist/plugins/two-factor/backup-codes/index.mjs +1 -1
  187. package/dist/plugins/two-factor/client.d.mts +15 -12
  188. package/dist/plugins/two-factor/client.mjs +1 -1
  189. package/dist/plugins/two-factor/error-code.d.mts +12 -10
  190. package/dist/plugins/two-factor/index.d.mts +36 -32
  191. package/dist/plugins/two-factor/otp/index.d.mts +4 -2
  192. package/dist/plugins/two-factor/totp/index.d.mts +7 -5
  193. package/dist/plugins/two-factor/types.d.mts +1 -1
  194. package/dist/plugins/username/client.d.mts +11 -9
  195. package/dist/plugins/username/client.mjs +1 -1
  196. package/dist/plugins/username/error-codes.d.mts +10 -8
  197. package/dist/plugins/username/index.d.mts +22 -17
  198. package/dist/plugins/username/schema.d.mts +5 -3
  199. package/dist/state.d.mts +1 -0
  200. package/dist/test-utils/test-instance.d.mts +3 -5
  201. package/dist/types/adapter.d.mts +1 -1
  202. package/dist/types/api.d.mts +2 -1
  203. package/dist/types/auth.d.mts +1 -0
  204. package/dist/types/helper.d.mts +5 -5
  205. package/dist/types/index.d.mts +2 -2
  206. package/dist/types/models.d.mts +1 -0
  207. package/dist/types/plugins.d.mts +3 -2
  208. package/dist/utils/index.d.mts +1 -2
  209. package/dist/utils/url.d.mts +1 -0
  210. package/package.json +12 -11
@@ -1,8 +1,9 @@
1
1
  import { isJsonEqual, withEquality } from "./equality.mjs";
2
2
  import { createSessionRefreshManager } from "./session-refresh.mjs";
3
- import { atom, onMount } from "nanostores";
3
+ import { STORE_UNMOUNT_DELAY, atom, onMount } from "nanostores";
4
4
  //#region src/client/session-atom.ts
5
5
  const isServer = () => typeof window === "undefined";
6
+ const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
6
7
  /**
7
8
  * Normalize $fetch response: `throw: true` returns data directly,
8
9
  * otherwise `{ data, error }`.
@@ -24,7 +25,13 @@ function isSessionAtomEqual(a, b) {
24
25
  }
25
26
  function getSessionAtom($fetch, options) {
26
27
  const $signal = atom(false);
27
- let abortController;
28
+ let flight;
29
+ let freshUntil = 0;
30
+ let sessionRevision = 0;
31
+ $signal.listen(() => {
32
+ sessionRevision++;
33
+ freshUntil = 0;
34
+ });
28
35
  const refetch = (queryParams) => fetchSession(queryParams);
29
36
  const session = atom({
30
37
  data: null,
@@ -34,23 +41,8 @@ function getSessionAtom($fetch, options) {
34
41
  refetch
35
42
  });
36
43
  withEquality(session, isSessionAtomEqual);
37
- const settleAbortedFetch = (controller) => {
38
- if (abortController !== controller) return;
39
- const current = session.get();
40
- abortController = void 0;
41
- if (!current.isPending && !current.isRefetching) return;
42
- session.set({
43
- ...current,
44
- isPending: false,
45
- isRefetching: false,
46
- refetch
47
- });
48
- };
49
- const fetchSession = async (queryParams) => {
50
- abortController?.abort();
51
- const controller = new AbortController();
52
- abortController = controller;
53
- const current = session.get();
44
+ const executeSessionFetch = async (signal, queryParams) => {
45
+ const current = session.value;
54
46
  session.set({
55
47
  ...current,
56
48
  isPending: current.data === null,
@@ -58,35 +50,29 @@ function getSessionAtom($fetch, options) {
58
50
  error: null,
59
51
  refetch
60
52
  });
53
+ if (signal.aborted) return "aborted";
61
54
  try {
62
55
  const res = await $fetch("/get-session", {
63
56
  method: "GET",
64
57
  query: queryParams?.query,
65
- signal: controller.signal
58
+ signal
66
59
  });
67
- if (controller.signal.aborted) {
68
- settleAbortedFetch(controller);
69
- return;
70
- }
60
+ if (signal.aborted) return "aborted";
71
61
  let { data, error } = normalizeSessionResponse(res);
62
+ let outcome = "fresh";
72
63
  if (data?.needsRefresh) try {
73
64
  const refreshRes = await $fetch("/get-session", {
74
65
  method: "POST",
75
- signal: controller.signal
66
+ signal
76
67
  });
77
- if (controller.signal.aborted) {
78
- settleAbortedFetch(controller);
79
- return;
80
- }
68
+ if (signal.aborted) return "aborted";
81
69
  ({data, error} = normalizeSessionResponse(refreshRes));
82
70
  } catch {
83
- if (controller.signal.aborted) {
84
- settleAbortedFetch(controller);
85
- return;
86
- }
71
+ if (signal.aborted) return "aborted";
72
+ outcome = "stale";
87
73
  }
88
74
  if (error) {
89
- const latest = session.get();
75
+ const latest = session.value;
90
76
  const isUnauthorized = error?.status === 401;
91
77
  session.set({
92
78
  data: isUnauthorized ? null : latest.data,
@@ -95,10 +81,10 @@ function getSessionAtom($fetch, options) {
95
81
  isRefetching: false,
96
82
  refetch
97
83
  });
98
- return;
84
+ return "failed";
99
85
  }
100
86
  const sessionData = normalizeSessionData(data);
101
- const current = session.get();
87
+ const current = session.value;
102
88
  const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
103
89
  session.set({
104
90
  data: stableData,
@@ -107,12 +93,10 @@ function getSessionAtom($fetch, options) {
107
93
  isRefetching: false,
108
94
  refetch
109
95
  });
96
+ return outcome;
110
97
  } catch (fetchError) {
111
- if (controller.signal.aborted) {
112
- settleAbortedFetch(controller);
113
- return;
114
- }
115
- const latest = session.get();
98
+ if (signal.aborted) return "aborted";
99
+ const latest = session.value;
116
100
  session.set({
117
101
  data: latest.data,
118
102
  error: fetchError,
@@ -120,17 +104,49 @@ function getSessionAtom($fetch, options) {
120
104
  isRefetching: false,
121
105
  refetch
122
106
  });
107
+ return "failed";
123
108
  }
124
109
  };
110
+ const getFreshUntil = () => {
111
+ const expiresAt = session.value.data?.session?.expiresAt;
112
+ const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
113
+ return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
114
+ };
115
+ const fetchSession = (queryParams) => {
116
+ freshUntil = 0;
117
+ flight?.cancel();
118
+ const controller = new AbortController();
119
+ const request = {
120
+ cancel: () => controller.abort(),
121
+ promise: Promise.resolve().then(() => {
122
+ if (controller.signal.aborted) return "aborted";
123
+ return executeSessionFetch(controller.signal, queryParams);
124
+ }),
125
+ revision: sessionRevision
126
+ };
127
+ flight = request;
128
+ const settleFlight = (outcome) => {
129
+ if (flight !== request) return;
130
+ flight = void 0;
131
+ if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
132
+ };
133
+ request.promise.then(settleFlight, () => settleFlight("failed"));
134
+ return request.promise.then(() => void 0);
135
+ };
136
+ const fetchSessionOnMount = () => {
137
+ if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
138
+ if (Date.now() < freshUntil) return Promise.resolve();
139
+ return fetchSession();
140
+ };
125
141
  let broadcastSessionUpdate = () => {};
126
142
  onMount(session, () => {
127
143
  let timeoutId;
128
144
  if (!isServer()) timeoutId = setTimeout(() => {
129
- fetchSession();
145
+ fetchSessionOnMount();
130
146
  }, 0);
131
147
  const refreshManager = createSessionRefreshManager({
132
148
  fetchSession,
133
- shouldPollSession: () => session.get().data != null,
149
+ shouldPollSession: () => session.value.data != null,
134
150
  sessionSignal: $signal,
135
151
  options
136
152
  });
@@ -138,9 +154,6 @@ function getSessionAtom($fetch, options) {
138
154
  broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
139
155
  return () => {
140
156
  if (timeoutId) clearTimeout(timeoutId);
141
- const controller = abortController;
142
- controller?.abort();
143
- if (controller) settleAbortedFetch(controller);
144
157
  refreshManager.cleanup();
145
158
  };
146
159
  });
@@ -1,5 +1,6 @@
1
1
  import { BetterAuthClientOptions } from "@better-auth/core";
2
2
  import { WritableAtom } from "nanostores";
3
+
3
4
  //#region src/client/session-refresh.d.ts
4
5
  interface SessionRefreshOptions {
5
6
  fetchSession: () => Promise<void>;
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
7
7
  import { Accessor } from "solid-js";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/solid/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>>; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>> } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -39,4 +40,4 @@ type SolidAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
39
40
  };
40
41
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SolidAuthClient<Option>;
41
42
  //#endregion
42
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, SolidAuthClient, type StripEmptyObjects, type UnionToIntersection, createAuthClient };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, SolidAuthClient, StripEmptyObjects, type UnionToIntersection, createAuthClient };
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { Atom } from "nanostores";
7
7
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/svelte/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key]; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -39,4 +40,4 @@ type SvelteAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersect
39
40
  };
40
41
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SvelteAuthClient<Option>;
41
42
  //#endregion
42
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
@@ -3,9 +3,9 @@ import { StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
3
3
  import { InferRoutes } from "./path-to-object.mjs";
4
4
  import { Session as Session$1, User as User$1 } from "../types/models.mjs";
5
5
  import { Auth } from "../types/auth.mjs";
6
- import "../types/index.mjs";
7
6
  import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener as ClientAtomListener$1, ClientStore as ClientStore$1 } from "@better-auth/core";
8
7
  import { DBFieldAttribute, InferDBFieldsOutput } from "@better-auth/core/db";
8
+
9
9
  //#region src/client/types.d.ts
10
10
  type ClientPluginError<K extends string = string> = {
11
11
  readonly code: K;
@@ -28,7 +28,7 @@ type InferErrorCodes<O extends BetterAuthClientOptions$1> = O["plugins"] extends
28
28
  $InferServerPlugin?: infer ServerPlugin;
29
29
  } ? ServerPlugin extends {
30
30
  $ERROR_CODES?: infer E;
31
- } ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never; } : {} : {}> : {};
31
+ } ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never } : {} : {}> : {};
32
32
  /**
33
33
  * signals are just used to recall a computed value.
34
34
  * as a convention they start with "$"
@@ -5,12 +5,13 @@ import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { Atom } from "nanostores";
7
7
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
+
8
9
  //#region src/client/vanilla.d.ts
9
10
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
10
11
  plugins: Array<infer Plugin>;
11
12
  } ? UnionToIntersection<Plugin extends {
12
13
  getAtoms?: infer GetAtoms;
13
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key]; } : {} : {} : {}> : {};
14
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {};
14
15
  type ClientConfig = ReturnType<typeof getClientConfig>;
15
16
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
16
17
  getSession: () => Promise<infer Res>;
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
7
7
  import { DeepReadonly, Ref } from "vue";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/vue/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>>; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>> } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -51,4 +52,4 @@ type VueAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection
51
52
  };
52
53
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): VueAuthClient<Option>;
53
54
  //#endregion
54
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
55
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
@@ -18,7 +18,7 @@ import { generateId } from "@better-auth/core/utils/id";
18
18
  import { socialProviders } from "@better-auth/core/social-providers";
19
19
  import { findInvalidTrustedProxies } from "@better-auth/core/utils/ip";
20
20
  import { createTelemetry } from "@better-auth/telemetry";
21
- import defu from "defu";
21
+ import defu$1 from "defu";
22
22
  //#region src/context/create-context.ts
23
23
  /**
24
24
  * Estimates the entropy of a string in bits.
@@ -45,13 +45,13 @@ function validateSecret(secret, logger) {
45
45
  }
46
46
  async function createAuthContext(adapter, options, getDatabaseType) {
47
47
  const isStateful = hasServerSessionStore(options);
48
- if (!isStateful) options = defu(options, { session: { cookieCache: {
48
+ if (!isStateful) options = defu$1(options, { session: { cookieCache: {
49
49
  enabled: true,
50
50
  strategy: "jwe",
51
51
  refreshCache: true,
52
52
  maxAge: options.session?.expiresIn || 3600 * 24 * 7
53
53
  } } });
54
- if (!options.database) options = defu(options, { account: { storeAccountCookie: true } });
54
+ if (!options.database) options = defu$1(options, { account: { storeAccountCookie: true } });
55
55
  const plugins = options.plugins || [];
56
56
  const internalPlugins = getInternalPlugins(options);
57
57
  const logger = createLogger(options.logger);
@@ -4,7 +4,7 @@ import { createCookieGetter, getCookies } from "../cookies/index.mjs";
4
4
  import { createInternalAdapter } from "../db/internal-adapter.mjs";
5
5
  import { env } from "@better-auth/core/env";
6
6
  import { BetterAuthError } from "@better-auth/core/error";
7
- import { defu as defu$1 } from "defu";
7
+ import { defu } from "defu";
8
8
  import { isLoopbackHost } from "@better-auth/core/utils/host";
9
9
  //#region src/context/helpers.ts
10
10
  async function runPluginInit(context) {
@@ -25,7 +25,7 @@ async function runPluginInit(context) {
25
25
  hooks: databaseHooks
26
26
  });
27
27
  if (trustedOrigins) pluginTrustedOrigins.push(trustedOrigins);
28
- options = defu$1(options, restOpts);
28
+ options = defu(options, restOpts);
29
29
  }
30
30
  if (result.context) Object.assign(context, result.context);
31
31
  }
@@ -1,9 +1,10 @@
1
1
  import { Session, User } from "../types/models.mjs";
2
- import "../types/index.mjs";
3
2
  import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
4
3
  import { createSessionStore, getAccountCookie, getChunkedCookie } from "./session-store.mjs";
5
4
  import { BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
5
+ import * as _$better_call0 from "better-call";
6
6
  import { CookieOptions } from "better-call";
7
+
7
8
  //#region src/cookies/index.d.ts
8
9
  declare function createCookieGetter(options: BetterAuthOptions): (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
9
10
  name: string;
@@ -16,7 +17,7 @@ declare function createCookieGetter(options: BetterAuthOptions): (cookieName: st
16
17
  secure: boolean;
17
18
  sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
18
19
  partitioned?: boolean;
19
- prefix?: import("better-call").CookiePrefixOptions;
20
+ prefix?: _$better_call0.CookiePrefixOptions;
20
21
  };
21
22
  };
22
23
  declare function getCookies(options: BetterAuthOptions): {
@@ -31,7 +32,7 @@ declare function getCookies(options: BetterAuthOptions): {
31
32
  secure: boolean;
32
33
  sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
33
34
  partitioned?: boolean;
34
- prefix?: import("better-call").CookiePrefixOptions;
35
+ prefix?: _$better_call0.CookiePrefixOptions;
35
36
  };
36
37
  };
37
38
  /**
@@ -49,7 +50,7 @@ declare function getCookies(options: BetterAuthOptions): {
49
50
  secure: boolean;
50
51
  sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
51
52
  partitioned?: boolean;
52
- prefix?: import("better-call").CookiePrefixOptions;
53
+ prefix?: _$better_call0.CookiePrefixOptions;
53
54
  };
54
55
  };
55
56
  dontRememberToken: {
@@ -63,7 +64,7 @@ declare function getCookies(options: BetterAuthOptions): {
63
64
  secure: boolean;
64
65
  sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
65
66
  partitioned?: boolean;
66
- prefix?: import("better-call").CookiePrefixOptions;
67
+ prefix?: _$better_call0.CookiePrefixOptions;
67
68
  };
68
69
  };
69
70
  accountData: {
@@ -77,7 +78,7 @@ declare function getCookies(options: BetterAuthOptions): {
77
78
  secure: boolean;
78
79
  sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
79
80
  partitioned?: boolean;
80
- prefix?: import("better-call").CookiePrefixOptions;
81
+ prefix?: _$better_call0.CookiePrefixOptions;
81
82
  };
82
83
  };
83
84
  };
@@ -1,6 +1,5 @@
1
1
  import { GenericEndpointContext } from "@better-auth/core";
2
2
  import { CookieOptions } from "better-call";
3
- import "zod";
4
3
  //#region src/cookies/session-store.d.ts
5
4
  interface Cookie {
6
5
  name: string;
@@ -24,8 +24,7 @@ const MAX_COOKIE_CHUNKS = 100;
24
24
  * wire. Non-positive when the name and attributes alone overflow.
25
25
  */
26
26
  function getMaxCookieValueSize(name, options) {
27
- const overhead = serializeCookie(name, "", { ...options }).length;
28
- return MAX_COOKIE_SIZE - overhead;
27
+ return MAX_COOKIE_SIZE - serializeCookie(name, "", { ...options }).length;
29
28
  }
30
29
  /**
31
30
  * Read all existing chunks from cookies
@@ -3,6 +3,7 @@ import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "./jw
3
3
  import { hashPassword, verifyPassword } from "./password.mjs";
4
4
  import { generateRandomString } from "./random.mjs";
5
5
  import { SecretConfig } from "@better-auth/core";
6
+
6
7
  //#region src/crypto/index.d.ts
7
8
  declare function parseEnvelope(data: string): {
8
9
  version: number;
@@ -13,12 +14,18 @@ type SymmetricEncryptOptions = {
13
14
  key: string | SecretConfig;
14
15
  data: string;
15
16
  };
16
- declare const symmetricEncrypt: ({ key, data }: SymmetricEncryptOptions) => Promise<string>;
17
+ declare const symmetricEncrypt: ({
18
+ key,
19
+ data
20
+ }: SymmetricEncryptOptions) => Promise<string>;
17
21
  type SymmetricDecryptOptions = {
18
22
  key: string | SecretConfig;
19
23
  data: string;
20
24
  };
21
- declare const symmetricDecrypt: ({ key, data }: SymmetricDecryptOptions) => Promise<string>;
25
+ declare const symmetricDecrypt: ({
26
+ key,
27
+ data
28
+ }: SymmetricDecryptOptions) => Promise<string>;
22
29
  declare const getCryptoKey: (secret: string | BufferSource) => Promise<CryptoKey>;
23
30
  declare const makeSignature: (value: string, secret: string | BufferSource) => Promise<string>;
24
31
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { SecretConfig } from "./index.mjs";
2
+
2
3
  //#region src/crypto/jwt.d.ts
3
4
  declare function signJWT(payload: any, secret: string, expiresIn?: number): Promise<string>;
4
5
  declare function verifyJWT<T = any>(token: string, secret: string): Promise<T | null>;
@@ -1,7 +1,11 @@
1
1
  import { hashPassword } from "@better-auth/utils/password";
2
+
2
3
  //#region src/crypto/password.d.ts
3
4
  declare const hashPassword$1: typeof hashPassword;
4
- declare const verifyPassword$1: ({ hash, password }: {
5
+ declare const verifyPassword$1: ({
6
+ hash,
7
+ password
8
+ }: {
5
9
  hash: string;
6
10
  password: string;
7
11
  }) => Promise<boolean>;
@@ -1,5 +1,6 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBAdapter } from "@better-auth/core/db/adapter";
3
+
3
4
  //#region src/db/adapter-base.d.ts
4
5
  declare function getBaseAdapter(options: BetterAuthOptions, handleDirectDatabase: (options: BetterAuthOptions) => Promise<DBAdapter<BetterAuthOptions>>): Promise<DBAdapter<BetterAuthOptions>>;
5
6
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBAdapter } from "@better-auth/core/db/adapter";
3
+
3
4
  //#region src/db/adapter-kysely.d.ts
4
5
  declare function getAdapter(options: BetterAuthOptions): Promise<DBAdapter<BetterAuthOptions>>;
5
6
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { DBFieldAttribute } from "@better-auth/core/db";
2
+
2
3
  //#region src/db/field-converter.d.ts
3
4
  declare function convertToDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T): T;
4
5
  declare function convertFromDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T | null): T | null;
@@ -1,21 +1,22 @@
1
1
  import { DBFieldAttribute, InferDBValueType } from "@better-auth/core/db";
2
+
2
3
  //#region src/db/field.d.ts
3
- type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]>; } & { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? never : key : never]?: InferFieldOutput<Fields[key]> | null; } : never;
4
+ type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]> } & { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? never : key : never]?: InferFieldOutput<Fields[key]> | null } : never;
4
5
  /**
5
6
  * For client will add "?" on optional fields
6
7
  */
7
- type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]>; } & { [key in Key as Fields[key]["input"] extends false ? never : Fields[key]["required"] extends false ? key : Fields[key]["defaultValue"] extends string | number | boolean | Date ? key : never]?: InferFieldInput<Fields[key]> | undefined | null; } : never;
8
+ type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]> } & { [key in Key as Fields[key]["input"] extends false ? never : Fields[key]["required"] extends false ? key : Fields[key]["defaultValue"] extends string | number | boolean | Date ? key : never]?: InferFieldInput<Fields[key]> | undefined | null } : never;
8
9
  type InferFieldOutput<T extends DBFieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferDBValueType<T["type"]> | undefined | null : InferDBValueType<T["type"]>;
9
10
  /**
10
11
  * Converts a Record<string, DBFieldAttribute> to an object type
11
12
  * with keys and value types inferred from DBFieldAttribute["type"].
12
13
  */
13
- type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]>; }, Fields>;
14
+ type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]> }, Fields>;
14
15
  type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyof T, DBFieldAttribute>> = { [K in keyof T as Fields[K] extends {
15
16
  required: false;
16
- } ? never : K]: T[K]; } & { [K in keyof T as Fields[K] extends {
17
+ } ? never : K]: T[K] } & { [K in keyof T as Fields[K] extends {
17
18
  required: false;
18
- } ? K : never]?: T[K]; };
19
+ } ? K : never]?: T[K] };
19
20
  /**
20
21
  * Infer the additional fields from the plugin options.
21
22
  * For example, you can infer the additional fields of the org plugin's organization schema like this:
@@ -29,12 +30,12 @@ type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyo
29
30
  type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
30
31
  schema?: { [key in SchemaName]?: {
31
32
  additionalFields?: Record<string, DBFieldAttribute>;
32
- }; } | undefined;
33
+ } } | undefined;
33
34
  }, isClientSide extends boolean = true> = Options["schema"] extends { [key in SchemaName]?: {
34
35
  additionalFields: infer Field extends Record<string, DBFieldAttribute>;
35
- }; } ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
36
- type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K]; };
37
- type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K]; };
36
+ } } ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
37
+ type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K] };
38
+ type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K] };
38
39
  type InferFieldInput<T extends DBFieldAttribute> = InferDBValueType<T["type"]>;
39
40
  //#endregion
40
41
  export { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse };
@@ -1,6 +1,7 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBFieldAttribute, DBFieldType } from "@better-auth/core/db";
3
3
  import { KyselyDatabaseType } from "@better-auth/kysely-adapter";
4
+
4
5
  //#region src/db/get-migration.d.ts
5
6
  declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
6
7
  declare function getMigrations(config: BetterAuthOptions): Promise<{
@@ -1,5 +1,6 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBFieldAttribute } from "@better-auth/core/db";
3
+
3
4
  //#region src/db/get-schema.d.ts
4
5
  declare function getSchema(config: BetterAuthOptions): Record<string, {
5
6
  fields: Record<string, DBFieldAttribute>;
@@ -2,6 +2,7 @@ import { DatabaseHooksEntry } from "./with-hooks.mjs";
2
2
  import { AuthContext, BetterAuthOptions, InternalAdapter } from "@better-auth/core";
3
3
  import { InternalLogger } from "@better-auth/core/env";
4
4
  import { DBAdapter } from "@better-auth/core/db/adapter";
5
+
5
6
  //#region src/db/internal-adapter.d.ts
6
7
  declare const createInternalAdapter: (adapter: DBAdapter<BetterAuthOptions>, ctx: {
7
8
  options: Omit<BetterAuthOptions, "logger">;
@@ -698,8 +698,7 @@ const createInternalAdapter = (adapter, ctx) => {
698
698
  logger.warn("Secondary storage does not implement `getAndDelete`, so single-use verification values cannot be consumed atomically across processes. Implement `getAndDelete` or use database-backed verification storage to guarantee single use.");
699
699
  }
700
700
  return withVerificationConsumeLock(key, async () => {
701
- const raw = await secondaryStorage.get(key);
702
- const parsed = hydrateCachedVerification(raw);
701
+ const parsed = hydrateCachedVerification(await secondaryStorage.get(key));
703
702
  if (!parsed) return null;
704
703
  await secondaryStorage.delete(key);
705
704
  return parsed;
@@ -1,4 +1,5 @@
1
1
  import { GenericEndpointContext } from "@better-auth/core";
2
+
2
3
  //#region src/db/revoke-unproven-account-access.d.ts
3
4
  /**
4
5
  * Strip every credential and session a pre-existing account accrued before
@@ -1,7 +1,7 @@
1
1
  import { Account, Session as Session$1, User as User$1 } from "../types/models.mjs";
2
- import "../types/index.mjs";
3
2
  import { BetterAuthOptions } from "@better-auth/core";
4
3
  import { BetterAuthPluginDBSchema, DBFieldAttribute } from "@better-auth/core/db";
4
+
5
5
  //#region src/db/schema.d.ts
6
6
  declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, user: T): T;
7
7
  /**
@@ -57,6 +57,6 @@ declare function mergeSchema<S extends BetterAuthPluginDBSchema>(schema: S, newS
57
57
  fields?: {
58
58
  [P: string]: string;
59
59
  } | undefined;
60
- } | undefined; } | undefined): S;
60
+ } | undefined } | undefined): S;
61
61
  //#endregion
62
62
  export { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput };