better-auth 1.8.0-beta.2 → 1.8.0-beta.3

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 (273) hide show
  1. package/dist/adapters/index.d.mts +5 -10
  2. package/dist/api/dispatch.d.mts +3 -5
  3. package/dist/api/dispatch.mjs +6 -4
  4. package/dist/api/index.d.mts +506 -508
  5. package/dist/api/index.mjs +35 -34
  6. package/dist/api/middlewares/authorization.d.mts +15 -12
  7. package/dist/api/middlewares/authorization.mjs +2 -1
  8. package/dist/api/middlewares/index.d.mts +2 -1
  9. package/dist/api/middlewares/origin-check.d.mts +4 -7
  10. package/dist/api/routes/account.d.mts +11 -15
  11. package/dist/api/routes/account.mjs +7 -4
  12. package/dist/api/routes/callback.d.mts +2 -5
  13. package/dist/api/routes/callback.mjs +4 -2
  14. package/dist/api/routes/email-verification.d.mts +7 -12
  15. package/dist/api/routes/error.d.mts +2 -5
  16. package/dist/api/routes/index.d.mts +2 -1
  17. package/dist/api/routes/ok.d.mts +2 -5
  18. package/dist/api/routes/password.d.mts +8 -11
  19. package/dist/api/routes/password.mjs +3 -2
  20. package/dist/api/routes/session.d.mts +26 -29
  21. package/dist/api/routes/sign-in.d.mts +4 -6
  22. package/dist/api/routes/sign-out.d.mts +2 -5
  23. package/dist/api/routes/sign-up.d.mts +4 -6
  24. package/dist/api/routes/update-session.d.mts +4 -6
  25. package/dist/api/routes/update-user.d.mts +14 -16
  26. package/dist/api/routes/update-user.mjs +1 -1
  27. package/dist/api/state/oauth.d.mts +0 -3
  28. package/dist/api/state/oauth.mjs +2 -1
  29. package/dist/auth/full.d.mts +3 -4
  30. package/dist/auth/minimal.d.mts +3 -3
  31. package/dist/client/broadcast-channel.d.mts +6 -7
  32. package/dist/client/config.d.mts +15 -19
  33. package/dist/client/config.mjs +2 -2
  34. package/dist/client/equality.d.mts +3 -5
  35. package/dist/client/focus-manager.d.mts +4 -5
  36. package/dist/client/index.d.mts +8 -7
  37. package/dist/client/lynx/index.d.mts +6 -7
  38. package/dist/client/lynx/index.mjs +3 -2
  39. package/dist/client/lynx/lynx-store.d.mts +3 -4
  40. package/dist/client/online-manager.d.mts +4 -5
  41. package/dist/client/parser.d.mts +9 -5
  42. package/dist/client/path-to-object.d.mts +13 -14
  43. package/dist/client/plugins/index.d.mts +1 -1
  44. package/dist/client/plugins/infer-plugin.d.mts +2 -4
  45. package/dist/client/query.d.mts +4 -6
  46. package/dist/client/react/index.d.mts +6 -7
  47. package/dist/client/react/index.mjs +3 -2
  48. package/dist/client/react/react-store.d.mts +3 -4
  49. package/dist/client/session-atom.d.mts +4 -4
  50. package/dist/client/session-refresh.d.mts +3 -5
  51. package/dist/client/solid/index.d.mts +6 -7
  52. package/dist/client/solid/index.mjs +3 -2
  53. package/dist/client/svelte/index.d.mts +6 -7
  54. package/dist/client/svelte/index.mjs +3 -2
  55. package/dist/client/types.d.mts +11 -11
  56. package/dist/client/vanilla.d.mts +4 -5
  57. package/dist/client/vanilla.mjs +3 -2
  58. package/dist/client/vue/index.d.mts +6 -7
  59. package/dist/client/vue/index.mjs +3 -2
  60. package/dist/context/create-context.mjs +7 -7
  61. package/dist/context/helpers.mjs +9 -7
  62. package/dist/cookies/cookie-utils.d.mts +13 -13
  63. package/dist/cookies/cookie-utils.mjs +1 -3
  64. package/dist/cookies/index.d.mts +17 -18
  65. package/dist/cookies/index.mjs +11 -7
  66. package/dist/cookies/jwt.mjs +2 -1
  67. package/dist/cookies/session-store.d.mts +6 -5
  68. package/dist/cookies/session-store.mjs +3 -2
  69. package/dist/crypto/buffer.d.mts +2 -3
  70. package/dist/crypto/index.d.mts +9 -16
  71. package/dist/crypto/index.mjs +2 -1
  72. package/dist/crypto/jwt.d.mts +5 -7
  73. package/dist/crypto/jwt.mjs +2 -1
  74. package/dist/crypto/password.d.mts +1 -5
  75. package/dist/crypto/random.d.mts +2 -3
  76. package/dist/db/adapter-base.d.mts +2 -4
  77. package/dist/db/adapter-kysely.d.mts +2 -4
  78. package/dist/db/field-converter.d.mts +3 -5
  79. package/dist/db/field.d.mts +11 -12
  80. package/dist/db/get-migration.d.mts +4 -8
  81. package/dist/db/get-migration.mjs +22 -22
  82. package/dist/db/get-schema.d.mts +2 -4
  83. package/dist/db/internal-adapter.d.mts +2 -4
  84. package/dist/db/internal-adapter.mjs +6 -4
  85. package/dist/db/revoke-unproven-account-access.d.mts +3 -4
  86. package/dist/db/schema.d.mts +15 -16
  87. package/dist/db/schema.mjs +6 -3
  88. package/dist/db/to-zod.d.mts +5 -9
  89. package/dist/db/with-hooks.d.mts +3 -5
  90. package/dist/index.d.mts +4 -3
  91. package/dist/integrations/next-js.d.mts +7 -11
  92. package/dist/integrations/node.d.mts +5 -7
  93. package/dist/integrations/node.mjs +4 -2
  94. package/dist/integrations/solid-start.d.mts +2 -3
  95. package/dist/integrations/svelte-kit.d.mts +6 -14
  96. package/dist/integrations/tanstack-start-solid.d.mts +4 -8
  97. package/dist/integrations/tanstack-start.d.mts +4 -8
  98. package/dist/oauth2/link-account.d.mts +5 -11
  99. package/dist/oauth2/link-account.mjs +12 -6
  100. package/dist/oauth2/state.d.mts +5 -7
  101. package/dist/oauth2/state.mjs +1 -1
  102. package/dist/oauth2/utils.d.mts +4 -6
  103. package/dist/package.mjs +1 -1
  104. package/dist/plugins/access/access.d.mts +4 -6
  105. package/dist/plugins/access/index.mjs +1 -2
  106. package/dist/plugins/access/types.d.mts +12 -14
  107. package/dist/plugins/additional-fields/client.d.mts +2 -4
  108. package/dist/plugins/admin/access/index.mjs +1 -2
  109. package/dist/plugins/admin/access/statement.d.mts +7 -7
  110. package/dist/plugins/admin/admin.d.mts +122 -128
  111. package/dist/plugins/admin/client.d.mts +32 -32
  112. package/dist/plugins/admin/client.mjs +1 -1
  113. package/dist/plugins/admin/error-codes.d.mts +25 -28
  114. package/dist/plugins/admin/index.d.mts +1 -1
  115. package/dist/plugins/admin/index.mjs +1 -2
  116. package/dist/plugins/admin/schema.d.mts +3 -4
  117. package/dist/plugins/admin/types.d.mts +8 -8
  118. package/dist/plugins/anonymous/client.d.mts +10 -12
  119. package/dist/plugins/anonymous/client.mjs +1 -1
  120. package/dist/plugins/anonymous/error-codes.d.mts +10 -13
  121. package/dist/plugins/anonymous/index.d.mts +17 -21
  122. package/dist/plugins/anonymous/schema.d.mts +2 -3
  123. package/dist/plugins/anonymous/types.d.mts +5 -6
  124. package/dist/plugins/bearer/index.d.mts +7 -11
  125. package/dist/plugins/captcha/constants.d.mts +2 -3
  126. package/dist/plugins/captcha/index.d.mts +6 -9
  127. package/dist/plugins/captcha/types.d.mts +11 -13
  128. package/dist/plugins/custom-session/client.d.mts +2 -4
  129. package/dist/plugins/custom-session/index.d.mts +10 -16
  130. package/dist/plugins/device-authorization/client.d.mts +2 -4
  131. package/dist/plugins/device-authorization/index.d.mts +39 -44
  132. package/dist/plugins/device-authorization/index.mjs +9 -8
  133. package/dist/plugins/device-authorization/routes.d.mts +11 -9
  134. package/dist/plugins/device-authorization/routes.mjs +6 -5
  135. package/dist/plugins/device-authorization/schema.d.mts +2 -3
  136. package/dist/plugins/email-otp/client.d.mts +5 -7
  137. package/dist/plugins/email-otp/client.mjs +1 -1
  138. package/dist/plugins/email-otp/error-codes.d.mts +5 -8
  139. package/dist/plugins/email-otp/index.d.mts +69 -76
  140. package/dist/plugins/email-otp/otp-token.mjs +19 -7
  141. package/dist/plugins/email-otp/types.d.mts +2 -4
  142. package/dist/plugins/generic-oauth/index.d.mts +9 -13
  143. package/dist/plugins/generic-oauth/index.mjs +6 -4
  144. package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
  145. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
  146. package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -1
  147. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
  148. package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
  149. package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
  150. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
  151. package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
  152. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
  153. package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
  154. package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
  155. package/dist/plugins/generic-oauth/providers/patreon.mjs +2 -2
  156. package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
  157. package/dist/plugins/generic-oauth/providers/slack.mjs +5 -2
  158. package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
  159. package/dist/plugins/generic-oauth/types.d.mts +6 -7
  160. package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
  161. package/dist/plugins/index.d.mts +4 -1
  162. package/dist/plugins/jwt/client.d.mts +2 -3
  163. package/dist/plugins/jwt/index.d.mts +11 -14
  164. package/dist/plugins/jwt/index.mjs +1 -1
  165. package/dist/plugins/jwt/schema.d.mts +2 -3
  166. package/dist/plugins/jwt/sign.d.mts +9 -8
  167. package/dist/plugins/jwt/types.d.mts +7 -8
  168. package/dist/plugins/jwt/utils.d.mts +6 -9
  169. package/dist/plugins/jwt/verify.d.mts +2 -4
  170. package/dist/plugins/last-login-method/client.d.mts +3 -4
  171. package/dist/plugins/last-login-method/index.d.mts +5 -9
  172. package/dist/plugins/last-login-method/index.mjs +1 -1
  173. package/dist/plugins/magic-link/client.d.mts +2 -4
  174. package/dist/plugins/magic-link/index.d.mts +7 -10
  175. package/dist/plugins/magic-link/index.mjs +20 -17
  176. package/dist/plugins/multi-session/client.d.mts +3 -5
  177. package/dist/plugins/multi-session/client.mjs +1 -1
  178. package/dist/plugins/multi-session/error-codes.d.mts +3 -6
  179. package/dist/plugins/multi-session/index.d.mts +10 -14
  180. package/dist/plugins/oauth-popup/client.d.mts +11 -17
  181. package/dist/plugins/oauth-popup/client.mjs +6 -4
  182. package/dist/plugins/oauth-popup/constants.d.mts +5 -6
  183. package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
  184. package/dist/plugins/oauth-popup/index.d.mts +11 -15
  185. package/dist/plugins/oauth-popup/index.mjs +8 -7
  186. package/dist/plugins/oauth-popup/types.d.mts +4 -6
  187. package/dist/plugins/oauth-proxy/index.d.mts +11 -15
  188. package/dist/plugins/oauth-proxy/index.mjs +10 -7
  189. package/dist/plugins/one-tap/client.d.mts +6 -9
  190. package/dist/plugins/one-tap/index.d.mts +4 -7
  191. package/dist/plugins/one-time-token/client.d.mts +2 -3
  192. package/dist/plugins/one-time-token/index.d.mts +8 -10
  193. package/dist/plugins/open-api/generator.d.mts +8 -8
  194. package/dist/plugins/open-api/generator.mjs +5 -5
  195. package/dist/plugins/open-api/index.d.mts +5 -7
  196. package/dist/plugins/organization/access/index.mjs +1 -2
  197. package/dist/plugins/organization/access/statement.d.mts +8 -8
  198. package/dist/plugins/organization/adapter.d.mts +60 -87
  199. package/dist/plugins/organization/adapter.mjs +14 -10
  200. package/dist/plugins/organization/client.d.mts +108 -107
  201. package/dist/plugins/organization/client.mjs +9 -5
  202. package/dist/plugins/organization/error-codes.d.mts +61 -64
  203. package/dist/plugins/organization/has-permission.d.mts +2 -4
  204. package/dist/plugins/organization/has-permission.mjs +1 -1
  205. package/dist/plugins/organization/index.d.mts +1 -1
  206. package/dist/plugins/organization/organization.d.mts +20 -20
  207. package/dist/plugins/organization/organization.mjs +13 -8
  208. package/dist/plugins/organization/permission.d.mts +4 -5
  209. package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
  210. package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
  211. package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
  212. package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
  213. package/dist/plugins/organization/routes/crud-members.mjs +23 -21
  214. package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
  215. package/dist/plugins/organization/routes/crud-org.mjs +4 -2
  216. package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
  217. package/dist/plugins/organization/routes/crud-team.mjs +4 -2
  218. package/dist/plugins/organization/schema.d.mts +33 -33
  219. package/dist/plugins/organization/schema.mjs +1 -1
  220. package/dist/plugins/organization/types.d.mts +16 -17
  221. package/dist/plugins/phone-number/client.d.mts +14 -16
  222. package/dist/plugins/phone-number/client.mjs +1 -1
  223. package/dist/plugins/phone-number/error-codes.d.mts +14 -17
  224. package/dist/plugins/phone-number/index.d.mts +48 -54
  225. package/dist/plugins/phone-number/schema.d.mts +2 -3
  226. package/dist/plugins/phone-number/types.d.mts +4 -5
  227. package/dist/plugins/siwe/client.d.mts +2 -4
  228. package/dist/plugins/siwe/index.d.mts +7 -9
  229. package/dist/plugins/siwe/index.mjs +1 -1
  230. package/dist/plugins/siwe/parse-message.mjs +1 -3
  231. package/dist/plugins/siwe/schema.d.mts +3 -4
  232. package/dist/plugins/siwe/types.d.mts +4 -4
  233. package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
  234. package/dist/plugins/test-utils/index.d.mts +3 -5
  235. package/dist/plugins/test-utils/types.d.mts +7 -7
  236. package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
  237. package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
  238. package/dist/plugins/two-factor/client.d.mts +16 -19
  239. package/dist/plugins/two-factor/client.mjs +1 -1
  240. package/dist/plugins/two-factor/constant.mjs +1 -1
  241. package/dist/plugins/two-factor/error-code.d.mts +15 -18
  242. package/dist/plugins/two-factor/index.d.mts +31 -35
  243. package/dist/plugins/two-factor/index.mjs +6 -3
  244. package/dist/plugins/two-factor/otp/index.d.mts +5 -8
  245. package/dist/plugins/two-factor/otp/index.mjs +159 -154
  246. package/dist/plugins/two-factor/schema.d.mts +2 -3
  247. package/dist/plugins/two-factor/totp/index.d.mts +7 -10
  248. package/dist/plugins/two-factor/totp/index.mjs +164 -148
  249. package/dist/plugins/two-factor/types.d.mts +6 -7
  250. package/dist/plugins/username/client.d.mts +12 -14
  251. package/dist/plugins/username/client.mjs +1 -1
  252. package/dist/plugins/username/error-codes.d.mts +11 -14
  253. package/dist/plugins/username/index.d.mts +26 -31
  254. package/dist/plugins/username/schema.d.mts +7 -10
  255. package/dist/state.d.mts +4 -5
  256. package/dist/test-utils/headers.d.mts +2 -3
  257. package/dist/test-utils/http-test-instance.d.mts +26 -29
  258. package/dist/test-utils/test-instance.d.mts +7 -6
  259. package/dist/test-utils/test-instance.mjs +4 -2
  260. package/dist/types/adapter.d.mts +1 -1
  261. package/dist/types/api.d.mts +4 -6
  262. package/dist/types/auth.d.mts +2 -4
  263. package/dist/types/helper.d.mts +11 -12
  264. package/dist/types/index.d.mts +2 -2
  265. package/dist/types/models.d.mts +4 -5
  266. package/dist/types/plugins.d.mts +7 -8
  267. package/dist/utils/hide-metadata.d.mts +2 -3
  268. package/dist/utils/index.d.mts +2 -1
  269. package/dist/utils/is-api-error.mjs +1 -2
  270. package/dist/utils/time.d.mts +4 -4
  271. package/dist/utils/url.d.mts +13 -15
  272. package/dist/utils/wildcard.mjs +5 -3
  273. package/package.json +12 -12
@@ -1,22 +1,21 @@
1
1
  import { DBFieldAttribute, InferDBValueType } from "@better-auth/core/db";
2
-
3
2
  //#region src/db/field.d.ts
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;
3
+ export 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;
5
4
  /**
6
5
  * For client will add "?" on optional fields
7
6
  */
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;
7
+ export 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;
9
8
  type InferFieldOutput<T extends DBFieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferDBValueType<T["type"]> | undefined | null : InferDBValueType<T["type"]>;
10
9
  /**
11
10
  * Converts a Record<string, DBFieldAttribute> to an object type
12
11
  * with keys and value types inferred from DBFieldAttribute["type"].
13
12
  */
14
- type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]> }, Fields>;
13
+ export type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]>; }, Fields>;
15
14
  type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyof T, DBFieldAttribute>> = { [K in keyof T as Fields[K] extends {
16
15
  required: false;
17
- } ? never : K]: T[K] } & { [K in keyof T as Fields[K] extends {
16
+ } ? never : K]: T[K]; } & { [K in keyof T as Fields[K] extends {
18
17
  required: false;
19
- } ? K : never]?: T[K] };
18
+ } ? K : never]?: T[K]; };
20
19
  /**
21
20
  * Infer the additional fields from the plugin options.
22
21
  * For example, you can infer the additional fields of the org plugin's organization schema like this:
@@ -27,15 +26,15 @@ type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyo
27
26
  * @param isClientSide - When `true` (default), filters out `input: false` fields (clients can't send these).
28
27
  * When `false`, includes all fields (for internal/server-side use).
29
28
  */
30
- type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
29
+ export type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
31
30
  schema?: { [key in SchemaName]?: {
32
31
  additionalFields?: Record<string, DBFieldAttribute>;
33
- } } | undefined;
32
+ }; } | undefined;
34
33
  }, isClientSide extends boolean = true> = Options["schema"] extends { [key in SchemaName]?: {
35
34
  additionalFields: infer Field extends Record<string, DBFieldAttribute>;
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] };
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
+ export type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K]; };
39
38
  type InferFieldInput<T extends DBFieldAttribute> = InferDBValueType<T["type"]>;
40
39
  //#endregion
41
- export { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse };
40
+ export {};
@@ -3,7 +3,6 @@ import { DBFieldAttribute, DBFieldType } from "@better-auth/core/db";
3
3
  import { BetterAuthError } from "@better-auth/core/error";
4
4
  import { KyselyDatabaseType } from "@better-auth/kysely-adapter";
5
5
  import { ResolvedDBTableIndex } from "@better-auth/core/db/internal";
6
-
7
6
  //#region src/db/get-migration.d.ts
8
7
  /**
9
8
  * Thrown when {@link getMigrations} refuses to add a required column with no
@@ -11,8 +10,8 @@ import { ResolvedDBTableIndex } from "@better-auth/core/db/internal";
11
10
  * {@link BetterAuthError} thrown for index-definition conflicts, so callers
12
11
  * can tell the two apart without matching on message text.
13
12
  */
14
- declare class UnsafeMigrationError extends BetterAuthError {}
15
- declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
13
+ export declare class UnsafeMigrationError extends BetterAuthError {}
14
+ export declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
16
15
  /**
17
16
  * Build the migration plan that `auth migrate` executes and `auth generate`
18
17
  * prints for the Kysely adapter.
@@ -27,9 +26,7 @@ declare function matchType(columnDataType: string, fieldType: DBFieldType, dbTyp
27
26
  * @throws {BetterAuthError} when an index definition conflicts with an
28
27
  * existing or already-planned index.
29
28
  */
30
- declare function getMigrations(config: BetterAuthOptions, {
31
- throwOnUnsafe
32
- }?: {
29
+ export declare function getMigrations(config: BetterAuthOptions, { throwOnUnsafe }?: {
33
30
  throwOnUnsafe?: boolean;
34
31
  }): Promise<{
35
32
  toBeCreated: {
@@ -52,5 +49,4 @@ declare function getMigrations(config: BetterAuthOptions, {
52
49
  runMigrations: () => Promise<void>;
53
50
  compileMigrations: () => Promise<string>;
54
51
  }>;
55
- //#endregion
56
- export { UnsafeMigrationError, getMigrations, matchType };
52
+ //#endregion
@@ -176,8 +176,7 @@ async function getDatabaseIndexMap(db, target, tableNames, introspectIndexes) {
176
176
  WHERE table_schema = DATABASE()
177
177
  `.execute(db)).rows;
178
178
  break;
179
- case "mssql":
180
- rows = (await sql`
179
+ case "mssql": rows = (await sql`
181
180
  SELECT
182
181
  tables.name AS "tableName",
183
182
  indexes.name AS "indexName",
@@ -202,7 +201,6 @@ async function getDatabaseIndexMap(db, target, tableNames, introspectIndexes) {
202
201
  AND indexes.name IS NOT NULL
203
202
  AND index_columns.key_ordinal > 0
204
203
  `.execute(db)).rows;
205
- break;
206
204
  }
207
205
  const indexMetadata = /* @__PURE__ */ new Map();
208
206
  for (const row of rows) {
@@ -253,8 +251,7 @@ async function getDatabaseColumnBounds(db, target) {
253
251
  WHERE table_schema = DATABASE()
254
252
  `.execute(db)).rows;
255
253
  break;
256
- case "mssql":
257
- rows = (await sql`
254
+ case "mssql": rows = (await sql`
258
255
  SELECT
259
256
  tables.name AS "tableName",
260
257
  columns.name AS "columnName",
@@ -266,7 +263,6 @@ async function getDatabaseColumnBounds(db, target) {
266
263
  ON table_schemas.schema_id = tables.schema_id
267
264
  WHERE table_schemas.name = ${target.schema}
268
265
  `.execute(db)).rows;
269
- break;
270
266
  }
271
267
  const bounds = /* @__PURE__ */ new Map();
272
268
  for (const row of rows) {
@@ -370,8 +366,10 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
370
366
  };
371
367
  logger.debug(`PostgreSQL migration: Using schema '${schema}' (${schemaName ? "from database.schemaName" : "from search_path"})`);
372
368
  try {
373
- if (!(await db.introspection.getSchemas()).some(({ name }) => name === schema)) if (schemaName) logger.debug(`Schema '${schema}' does not exist yet. The migration creates it before creating tables.`);
374
- else logger.warn(`Schema '${schema}' does not exist. Create it before running migrations or check your database configuration.`);
369
+ if (!(await db.introspection.getSchemas()).some(({ name }) => name === schema)) {
370
+ if (schemaName) logger.debug(`Schema '${schema}' does not exist yet. The migration creates it before creating tables.`);
371
+ else logger.warn(`Schema '${schema}' does not exist. Create it before running migrations or check your database configuration.`);
372
+ }
375
373
  } catch (error) {
376
374
  logger.debug(`Could not verify schema existence: ${error instanceof Error ? error.message : String(error)}`);
377
375
  }
@@ -396,9 +394,7 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
396
394
  case "mysql":
397
395
  target = { type: "mysql" };
398
396
  break;
399
- case "sqlite":
400
- target = { type: "sqlite" };
401
- break;
397
+ case "sqlite": target = { type: "sqlite" };
402
398
  }
403
399
  const databaseIndexMap = await getDatabaseIndexMap(db, target, allTableMetadata.map((table) => table.name), introspectIndexes);
404
400
  const databaseColumnBounds = await getDatabaseColumnBounds(db, target);
@@ -457,12 +453,13 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
457
453
  order: value.order || Infinity
458
454
  };
459
455
  const insertIndex = toBeCreated.findIndex((t) => (t.order || Infinity) > tableData.order);
460
- if (insertIndex === -1) if (tIndex === -1) toBeCreated.push(tableData);
461
- else toBeCreated[tIndex].fields = {
462
- ...toBeCreated[tIndex].fields,
463
- ...value.fields
464
- };
465
- else toBeCreated.splice(insertIndex, 0, tableData);
456
+ if (insertIndex === -1) {
457
+ if (tIndex === -1) toBeCreated.push(tableData);
458
+ else toBeCreated[tIndex].fields = {
459
+ ...toBeCreated[tIndex].fields,
460
+ ...value.fields
461
+ };
462
+ } else toBeCreated.splice(insertIndex, 0, tableData);
466
463
  continue;
467
464
  }
468
465
  const toBeAddedFields = {};
@@ -618,9 +615,10 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
618
615
  const built = builder.addColumn(fieldName, type, (col) => {
619
616
  col = field.required !== false ? col.notNull() : col;
620
617
  if (field.references) col = col.references(getReferencePath(field)).onDelete(field.references.onDelete || "cascade");
621
- if (timestampDefault) if (dbType === "mysql") col = col.defaultTo(sql`CURRENT_TIMESTAMP(3)`);
622
- else col = col.defaultTo(sql`CURRENT_TIMESTAMP`);
623
- else if (staticDefault) col = col.defaultTo(typeof field.defaultValue === "boolean" && (dbType === "sqlite" || dbType === "mssql") ? field.defaultValue ? 1 : 0 : field.defaultValue);
618
+ if (timestampDefault) {
619
+ if (dbType === "mysql") col = col.defaultTo(sql`CURRENT_TIMESTAMP(3)`);
620
+ else col = col.defaultTo(sql`CURRENT_TIMESTAMP`);
621
+ } else if (staticDefault) col = col.defaultTo(typeof field.defaultValue === "boolean" && (dbType === "sqlite" || dbType === "mssql") ? field.defaultValue ? 1 : 0 : field.defaultValue);
624
622
  return col;
625
623
  });
626
624
  migrations.push(built);
@@ -647,8 +645,10 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
647
645
  col = field.required !== false ? col.notNull() : col;
648
646
  if (field.references) col = col.references(getReferencePath(field)).onDelete(field.references.onDelete || "cascade");
649
647
  if (field.unique) col = col.unique();
650
- if (field.type === "date" && typeof field.defaultValue === "function" && (dbType === "postgres" || dbType === "mysql" || dbType === "mssql")) if (dbType === "mysql") col = col.defaultTo(sql`CURRENT_TIMESTAMP(3)`);
651
- else col = col.defaultTo(sql`CURRENT_TIMESTAMP`);
648
+ if (field.type === "date" && typeof field.defaultValue === "function" && (dbType === "postgres" || dbType === "mysql" || dbType === "mssql")) {
649
+ if (dbType === "mysql") col = col.defaultTo(sql`CURRENT_TIMESTAMP(3)`);
650
+ else col = col.defaultTo(sql`CURRENT_TIMESTAMP`);
651
+ }
652
652
  return col;
653
653
  });
654
654
  if (field.index && !field.unique) {
@@ -1,13 +1,11 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBFieldAttribute } from "@better-auth/core/db";
3
3
  import { ResolvedDBTableIndex } from "@better-auth/core/db/internal";
4
-
5
4
  //#region src/db/get-schema.d.ts
6
- declare function getSchema(config: BetterAuthOptions): Record<string, {
5
+ export declare function getSchema(config: BetterAuthOptions): Record<string, {
7
6
  fields: Record<string, DBFieldAttribute>;
8
7
  indexes?: readonly ResolvedDBTableIndex[] | undefined;
9
8
  order: number;
10
9
  disableMigrations?: boolean | undefined;
11
10
  }>;
12
- //#endregion
13
- export { getSchema };
11
+ //#endregion
@@ -2,13 +2,11 @@ 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
-
6
5
  //#region src/db/internal-adapter.d.ts
7
- declare const createInternalAdapter: (adapter: DBAdapter<BetterAuthOptions>, ctx: {
6
+ export declare const createInternalAdapter: (adapter: DBAdapter<BetterAuthOptions>, ctx: {
8
7
  options: Omit<BetterAuthOptions, "logger">;
9
8
  logger: InternalLogger;
10
9
  hooks: DatabaseHooksEntry[];
11
10
  generateId: AuthContext["generateId"];
12
11
  }) => InternalAdapter;
13
- //#endregion
14
- export { createInternalAdapter };
12
+ //#endregion
@@ -20,7 +20,7 @@ const createInternalAdapter = (adapter, ctx) => {
20
20
  const options = ctx.options;
21
21
  const secondaryStorage = options.secondaryStorage;
22
22
  const verificationConsumeLocks = /* @__PURE__ */ new Map();
23
- const sessionExpiration = options.session?.expiresIn || 3600 * 24 * 7;
23
+ const sessionExpiration = options.session?.expiresIn || 604800;
24
24
  const databaseSessionFallbackEnabled = !!secondaryStorage && options.session?.storeSessionInDatabase === true && options.session?.preserveSessionInDatabase !== true;
25
25
  const { createWithHooks, updateWithHooks, updateManyWithHooks, deleteWithHooks, deleteManyWithHooks, consumeOneWithHooks } = getWithHooks(adapter, ctx);
26
26
  /**
@@ -280,7 +280,7 @@ const createInternalAdapter = (adapter, ctx) => {
280
280
  * set the session to expire in 1 day.
281
281
  * The cookie will be set to expire at the end of the session
282
282
  */
283
- expiresAt: dontRememberMe ? getDate(3600 * 24, "sec") : getDate(sessionExpiration, "sec"),
283
+ expiresAt: dontRememberMe ? getDate(86400, "sec") : getDate(sessionExpiration, "sec"),
284
284
  userId,
285
285
  token: generateId(32),
286
286
  createdAt: /* @__PURE__ */ new Date(),
@@ -773,7 +773,8 @@ const createInternalAdapter = (adapter, ctx) => {
773
773
  return verification[0] || null;
774
774
  },
775
775
  deleteVerificationByIdentifier: async (identifier) => {
776
- const storedIdentifier = await processIdentifier(identifier, getStorageOption(identifier, options.verification?.storeIdentifier));
776
+ const storageOption = getStorageOption(identifier, options.verification?.storeIdentifier);
777
+ const storedIdentifier = await processIdentifier(identifier, storageOption);
777
778
  if (secondaryStorage) await secondaryStorage.delete(`verification:${storedIdentifier}`);
778
779
  if (!secondaryStorage || options.verification?.storeInDatabase) await deleteWithHooks([{
779
780
  field: "identifier",
@@ -938,7 +939,8 @@ const createInternalAdapter = (adapter, ctx) => {
938
939
  return true;
939
940
  },
940
941
  updateVerificationByIdentifier: async (identifier, data) => {
941
- const storedIdentifier = await processIdentifier(identifier, getStorageOption(identifier, options.verification?.storeIdentifier));
942
+ const storageOption = getStorageOption(identifier, options.verification?.storeIdentifier);
943
+ const storedIdentifier = await processIdentifier(identifier, storageOption);
942
944
  if (secondaryStorage) {
943
945
  const cached = await secondaryStorage.get(`verification:${storedIdentifier}`);
944
946
  if (cached) {
@@ -1,6 +1,6 @@
1
1
  import { User } from "../types/models.mjs";
2
+ import "../types/index.mjs";
2
3
  import { GenericEndpointContext } from "@better-auth/core";
3
-
4
4
  //#region src/db/revoke-unproven-account-access.d.ts
5
5
  /**
6
6
  * Strip every account link and session a pre-existing account accrued before
@@ -16,6 +16,5 @@ import { GenericEndpointContext } from "@better-auth/core";
16
16
  *
17
17
  * @param userId - The pre-existing, not-yet-verified user being promoted.
18
18
  */
19
- declare function revokeUnprovenAccountAccess(ctx: GenericEndpointContext, userId: string): Promise<User | null>;
20
- //#endregion
21
- export { revokeUnprovenAccountAccess };
19
+ export declare function revokeUnprovenAccountAccess(ctx: GenericEndpointContext, userId: string): Promise<User | null>;
20
+ //#endregion
@@ -1,9 +1,9 @@
1
1
  import { Account, Session as Session$1, User as User$1 } from "../types/models.mjs";
2
+ import "../types/index.mjs";
2
3
  import { BetterAuthOptions } from "@better-auth/core";
3
4
  import { BetterAuthPluginDBSchema, DBFieldAttribute } from "@better-auth/core/db";
4
-
5
5
  //#region src/db/schema.d.ts
6
- declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, user: T): T;
6
+ export declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, user: T): T;
7
7
  /**
8
8
  * Builds a synthetic user object that matches the shape of a real user
9
9
  * returned from the database. This ensures enumeration protection works
@@ -16,17 +16,17 @@ declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, u
16
16
  * - Applies default values where defined
17
17
  * - Always includes the 'id' field (not part of schema but always present)
18
18
  */
19
- declare function buildSyntheticUserOutput(options: BetterAuthOptions, data: Record<string, unknown>): Record<string, unknown>;
20
- declare function parseSessionOutput<T extends Session$1>(options: BetterAuthOptions, session: T): T;
21
- declare function parseAccountOutput<T extends Account>(options: BetterAuthOptions, account: T): Omit<T, "idToken" | "accessToken" | "refreshToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt" | "password">;
22
- declare function parseInputData<T extends Record<string, any>>(data: T, schema: {
19
+ export declare function buildSyntheticUserOutput(options: BetterAuthOptions, data: Record<string, unknown>): Record<string, unknown>;
20
+ export declare function parseSessionOutput<T extends Session$1>(options: BetterAuthOptions, session: T): T;
21
+ export declare function parseAccountOutput<T extends Account>(options: BetterAuthOptions, account: T): Omit<T, "idToken" | "accessToken" | "refreshToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt" | "password">;
22
+ export declare function parseInputData<T extends Record<string, any>>(data: T, schema: {
23
23
  fields: Record<string, DBFieldAttribute>;
24
24
  action?: ("create" | "update") | undefined;
25
25
  }): Partial<T>;
26
- declare function parseUserInput(options: BetterAuthOptions, user: Record<string, any> | undefined, action: "create" | "update"): Partial<Record<string, any>>;
27
- declare function parseAdditionalUserInputFromProviderProfile(options: BetterAuthOptions, profile: Record<string, unknown> | undefined, action: "create" | "update"): Partial<Record<string, unknown>>;
28
- declare function parseAdditionalUserInput(options: BetterAuthOptions, user?: Record<string, any> | undefined): Partial<Record<string, any>>;
29
- declare function parseAccountInput(options: BetterAuthOptions, account: Partial<Account>): Partial<Partial<{
26
+ export declare function parseUserInput(options: BetterAuthOptions, user: Record<string, any> | undefined, action: "create" | "update"): Partial<Record<string, any>>;
27
+ export declare function parseAdditionalUserInputFromProviderProfile(options: BetterAuthOptions, profile: Record<string, unknown> | undefined, action: "create" | "update"): Partial<Record<string, unknown>>;
28
+ export declare function parseAdditionalUserInput(options: BetterAuthOptions, user?: Record<string, any> | undefined): Partial<Record<string, any>>;
29
+ export declare function parseAccountInput(options: BetterAuthOptions, account: Partial<Account>): Partial<Partial<{
30
30
  id: string;
31
31
  createdAt: Date;
32
32
  updatedAt: Date;
@@ -41,7 +41,7 @@ declare function parseAccountInput(options: BetterAuthOptions, account: Partial<
41
41
  scope?: string | null | undefined;
42
42
  password?: string | null | undefined;
43
43
  }>>;
44
- declare function parseSessionInput(options: BetterAuthOptions, session: Partial<Session$1>, action?: "create" | "update"): Partial<Partial<{
44
+ export declare function parseSessionInput(options: BetterAuthOptions, session: Partial<Session$1>, action?: "create" | "update"): Partial<Partial<{
45
45
  id: string;
46
46
  createdAt: Date;
47
47
  updatedAt: Date;
@@ -51,12 +51,11 @@ declare function parseSessionInput(options: BetterAuthOptions, session: Partial<
51
51
  ipAddress?: string | null | undefined;
52
52
  userAgent?: string | null | undefined;
53
53
  }>>;
54
- declare function getSessionDefaultFields(options: BetterAuthOptions): Record<string, any>;
55
- declare function mergeSchema<S extends BetterAuthPluginDBSchema>(schema: S, newSchema?: { [K in keyof S]?: {
54
+ export declare function getSessionDefaultFields(options: BetterAuthOptions): Record<string, any>;
55
+ export declare function mergeSchema<S extends BetterAuthPluginDBSchema>(schema: S, newSchema?: { [K in keyof S]?: {
56
56
  modelName?: string | undefined;
57
57
  fields?: {
58
58
  [P: string]: string;
59
59
  } | undefined;
60
- } | undefined } | undefined): S;
61
- //#endregion
62
- export { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput };
60
+ } | undefined; } | undefined): S;
61
+ //#endregion
@@ -22,7 +22,8 @@ function getFields(options, modelName, mode) {
22
22
  return schema;
23
23
  }
24
24
  function parseUserOutput(options, user) {
25
- return filterOutputFields(user, getFields(options, "user", "output"));
25
+ const schema = getFields(options, "user", "output");
26
+ return filterOutputFields(user, schema);
26
27
  }
27
28
  /**
28
29
  * Builds a synthetic user object that matches the shape of a real user
@@ -50,10 +51,12 @@ function buildSyntheticUserOutput(options, data) {
50
51
  return result;
51
52
  }
52
53
  function parseSessionOutput(options, session) {
53
- return filterOutputFields(session, getFields(options, "session", "output"));
54
+ const schema = getFields(options, "session", "output");
55
+ return filterOutputFields(session, schema);
54
56
  }
55
57
  function parseAccountOutput(options, account) {
56
- const { accessToken: _accessToken, refreshToken: _refreshToken, idToken: _idToken, accessTokenExpiresAt: _accessTokenExpiresAt, refreshTokenExpiresAt: _refreshTokenExpiresAt, password: _password, ...rest } = filterOutputFields(account, getFields(options, "account", "output"));
58
+ const schema = getFields(options, "account", "output");
59
+ const { accessToken: _accessToken, refreshToken: _refreshToken, idToken: _idToken, accessTokenExpiresAt: _accessTokenExpiresAt, refreshTokenExpiresAt: _refreshTokenExpiresAt, password: _password, ...rest } = filterOutputFields(account, schema);
57
60
  return rest;
58
61
  }
59
62
  function parseInputData(data, schema) {
@@ -1,11 +1,7 @@
1
1
  import { DBFieldAttribute } from "@better-auth/core/db";
2
2
  import * as z from "zod";
3
-
4
3
  //#region src/db/to-zod.d.ts
5
- declare function toZodSchema<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean>({
6
- fields,
7
- isClientSide
8
- }: {
4
+ export declare function toZodSchema<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean>({ fields, isClientSide }: {
9
5
  fields: Fields;
10
6
  /**
11
7
  * If true, then any fields that have `input: false` will be removed from the schema to prevent user input.
@@ -13,8 +9,8 @@ declare function toZodSchema<Fields extends Record<string, DBFieldAttribute | ne
13
9
  isClientSide: IsClientSide;
14
10
  }): ZodSchemaForSide<Fields, IsClientSide>;
15
11
  type ZodSchemaForSide<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean> = IsClientSide extends true ? z.ZodObject<SchemaShape<Fields, true>, z.core.$strip> : z.ZodObject<SchemaShape<Fields, false>, z.core.$strip>;
16
- type SchemaShape<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean> = RemoveNeverProps<{ [key in keyof Fields]: FieldAttributeToSchema<Fields[key], IsClientSide> }>;
17
- type FieldAttributeToSchema<Field extends DBFieldAttribute | Record<string, never>, isClientSide extends boolean = false> = Field extends DBFieldAttribute ? GetSchemaForSide<isClientSide, Field, GetRequired<Field, GetType<Field>>> : Record<string, never>;
12
+ type SchemaShape<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean> = RemoveNeverProps<{ [key in keyof Fields]: FieldAttributeToSchema<Fields[key], IsClientSide>; }>;
13
+ export type FieldAttributeToSchema<Field extends DBFieldAttribute | Record<string, never>, isClientSide extends boolean = false> = Field extends DBFieldAttribute ? GetSchemaForSide<isClientSide, Field, GetRequired<Field, GetType<Field>>> : Record<string, never>;
18
14
  type GetType<F extends DBFieldAttribute> = F extends {
19
15
  type: "string";
20
16
  } ? z.ZodString : F extends {
@@ -32,6 +28,6 @@ type GetSchemaForSide<isClientSide extends boolean, Field extends DBFieldAttribu
32
28
  } ? never : Schema : Field extends {
33
29
  returned: false;
34
30
  } ? never : Schema;
35
- type RemoveNeverProps<T> = { [K in keyof T as [T[K]] extends [never] ? never : K]: T[K] };
31
+ type RemoveNeverProps<T> = { [K in keyof T as [T[K]] extends [never] ? never : K]: T[K]; };
36
32
  //#endregion
37
- export { FieldAttributeToSchema, toZodSchema };
33
+ export {};
@@ -1,13 +1,12 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
2
  import { BaseModelNames } from "@better-auth/core/db";
3
3
  import { DBAdapter, Where } from "@better-auth/core/db/adapter";
4
-
5
4
  //#region src/db/with-hooks.d.ts
6
- type DatabaseHooksEntry = {
5
+ export type DatabaseHooksEntry = {
7
6
  source: string;
8
7
  hooks: Exclude<BetterAuthOptions["databaseHooks"], undefined>;
9
8
  };
10
- declare function getWithHooks(adapter: DBAdapter<BetterAuthOptions>, ctx: {
9
+ export declare function getWithHooks(adapter: DBAdapter<BetterAuthOptions>, ctx: {
11
10
  options: BetterAuthOptions;
12
11
  hooks: DatabaseHooksEntry[];
13
12
  }): {
@@ -33,5 +32,4 @@ declare function getWithHooks(adapter: DBAdapter<BetterAuthOptions>, ctx: {
33
32
  } | undefined) => Promise<any>;
34
33
  consumeOneWithHooks: <T extends Record<string, any>>(model: BaseModelNames, hookWhere: Where[], consumeFn: () => Promise<T | null>, preSnapshot?: T | null) => Promise<T | null>;
35
34
  };
36
- //#endregion
37
- export { DatabaseHooksEntry, getWithHooks };
35
+ //#endregion
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState }
11
11
  import { StateData, generateGenericState, parseGenericState } from "./state.mjs";
12
12
  import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
13
13
  import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes } from "./utils/url.mjs";
14
+ import "./utils/index.mjs";
14
15
  import { APIError } from "./api/index.mjs";
15
16
  import { StandardSchemaV1 } from "@better-auth/core";
16
17
  import { getCurrentAdapter } from "@better-auth/core/context";
@@ -25,6 +26,6 @@ export * from "@better-auth/core/utils/error-codes";
25
26
  export * from "@better-auth/core/utils/id";
26
27
  export * from "@better-auth/core/utils/json";
27
28
  export * from "@better-auth/core/social-providers";
28
- export * from "better-call";
29
- export * from "zod";
30
- export { APIError, Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, GenerateStateOptions, HIDE_METADATA, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, type JSONWebKeySet, type JWTPayload, JoinConfig, JoinOption, OverrideMerge, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StandardSchemaV1, StateData, StoreIdentifierOption, StripEmptyObjects, type TelemetryEvent, UnionToIntersection, User, UserProvisioningSource, ValidateUserInfoAction, ValidateUserInfoMethod, ValidateUserInfoOAuthInfo, ValidateUserInfoResult, ValidateUserInfoSSOInfo, ValidateUserInfoSource, Verification, Where, betterAuth, createTelemetry, generateGenericState, generateIdTokenNonce, generateState, getBaseURL, getCurrentAdapter, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, getTelemetryAuthConfig, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, parseGenericState, parseState, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes };
29
+ export type * from "better-call";
30
+ export type * from "zod";
31
+ export { APIError, type Account, type AdditionalSessionFieldsInput, type AdditionalUserFieldsInput, type Auth, type BetterAuthAdvancedOptions, type BetterAuthClientOptions, type BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, type ClientAtomListener, type ClientStore, type DBAdapter, type DBAdapterInstance, type DBAdapterSchemaCreation, type DBTransactionAdapter, type ExtractPluginField, FilteredAPI, GenerateStateOptions, HIDE_METADATA, type HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, type InferOptionSchema, type InferPluginContext, type InferPluginErrorCodes, type InferPluginFieldFromTuple, type InferPluginIDs, type InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, type IsAny, IsSignal, type JSONWebKeySet, type JWTPayload, type JoinConfig, type JoinOption, type OverrideMerge, type Prettify, type PrettifyDeep, type RateLimit, type RequiredKeysOf, type Session, SessionQueryParams, type StandardSchemaV1, type StateData, type StoreIdentifierOption, type StripEmptyObjects, type TelemetryEvent, type UnionToIntersection, type User, type UserProvisioningSource, type ValidateUserInfoAction, type ValidateUserInfoMethod, type ValidateUserInfoOAuthInfo, type ValidateUserInfoResult, type ValidateUserInfoSSOInfo, type ValidateUserInfoSource, type Verification, type Where, betterAuth, createTelemetry, generateGenericState, generateIdTokenNonce, generateState, getBaseURL, getCurrentAdapter, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, getTelemetryAuthConfig, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, parseGenericState, parseState, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes };
@@ -1,8 +1,5 @@
1
- import * as _$_better_auth_core0 from "@better-auth/core";
2
- import * as _$better_call0 from "better-call";
3
-
4
1
  //#region src/integrations/next-js.d.ts
5
- declare function toNextJsHandler(auth: {
2
+ export declare function toNextJsHandler(auth: {
6
3
  handler: (request: Request) => Promise<Response>;
7
4
  } | ((request: Request) => Promise<Response>)): {
8
5
  GET: (request: Request) => Promise<Response>;
@@ -11,19 +8,18 @@ declare function toNextJsHandler(auth: {
11
8
  PUT: (request: Request) => Promise<Response>;
12
9
  DELETE: (request: Request) => Promise<Response>;
13
10
  };
14
- declare const nextCookies: () => {
11
+ export declare const nextCookies: () => {
15
12
  id: "next-cookies";
16
13
  version: string;
17
14
  hooks: {
18
15
  before: {
19
- matcher(ctx: _$_better_auth_core0.HookEndpointContext): boolean;
20
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
16
+ matcher(ctx: import("@better-auth/core").HookEndpointContext): boolean;
17
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
21
18
  }[];
22
19
  after: {
23
- matcher(ctx: _$_better_auth_core0.HookEndpointContext): true;
24
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
20
+ matcher(ctx: import("@better-auth/core").HookEndpointContext): true;
21
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
25
22
  }[];
26
23
  };
27
24
  };
28
- //#endregion
29
- export { nextCookies, toNextJsHandler };
25
+ //#endregion
@@ -1,11 +1,9 @@
1
1
  import { Auth } from "../types/auth.mjs";
2
- import * as _$node_http0 from "node:http";
2
+ import "../types/index.mjs";
3
3
  import { IncomingHttpHeaders } from "node:http";
4
-
5
4
  //#region src/integrations/node.d.ts
6
- declare const toNodeHandler: (auth: {
5
+ export declare const toNodeHandler: (auth: {
7
6
  handler: Auth["handler"];
8
- } | Auth["handler"]) => (req: _$node_http0.IncomingMessage, res: _$node_http0.ServerResponse) => Promise<void>;
9
- declare function fromNodeHeaders(nodeHeaders: IncomingHttpHeaders): Headers;
10
- //#endregion
11
- export { fromNodeHeaders, toNodeHandler };
7
+ } | Auth["handler"]) => (req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse) => Promise<void>;
8
+ export declare function fromNodeHeaders(nodeHeaders: IncomingHttpHeaders): Headers;
9
+ //#endregion
@@ -5,8 +5,10 @@ const toNodeHandler = (auth) => {
5
5
  };
6
6
  function fromNodeHeaders(nodeHeaders) {
7
7
  const webHeaders = new Headers();
8
- for (const [key, value] of Object.entries(nodeHeaders)) if (value !== void 0) if (Array.isArray(value)) value.forEach((v) => webHeaders.append(key, v));
9
- else webHeaders.set(key, value);
8
+ for (const [key, value] of Object.entries(nodeHeaders)) if (value !== void 0) {
9
+ if (Array.isArray(value)) value.forEach((v) => webHeaders.append(key, v));
10
+ else webHeaders.set(key, value);
11
+ }
10
12
  return webHeaders;
11
13
  }
12
14
  //#endregion
@@ -1,5 +1,5 @@
1
1
  //#region src/integrations/solid-start.d.ts
2
- declare function toSolidStartHandler(auth: {
2
+ export declare function toSolidStartHandler(auth: {
3
3
  handler: (request: Request) => Promise<Response>;
4
4
  } | ((request: Request) => Promise<Response>)): {
5
5
  GET: (event: {
@@ -18,5 +18,4 @@ declare function toSolidStartHandler(auth: {
18
18
  request: Request;
19
19
  }) => Promise<Response>;
20
20
  };
21
- //#endregion
22
- export { toSolidStartHandler };
21
+ //#endregion
@@ -1,20 +1,13 @@
1
1
  import { BetterAuthOptions } from "../types/index.mjs";
2
- import * as _$better_call0 from "better-call";
3
2
  import { RequestEvent } from "@sveltejs/kit";
4
-
5
3
  //#region src/integrations/svelte-kit.d.ts
6
- declare const toSvelteKitHandler: (auth: {
4
+ export declare const toSvelteKitHandler: (auth: {
7
5
  handler: (request: Request) => Response | Promise<Response>;
8
6
  options: BetterAuthOptions;
9
7
  }) => (event: {
10
8
  request: Request;
11
9
  }) => Response | Promise<Response>;
12
- declare const svelteKitHandler: ({
13
- auth,
14
- event,
15
- resolve,
16
- building
17
- }: {
10
+ export declare const svelteKitHandler: ({ auth, event, resolve, building }: {
18
11
  auth: {
19
12
  handler: (request: Request) => Response | Promise<Response>;
20
13
  options: BetterAuthOptions;
@@ -23,16 +16,15 @@ declare const svelteKitHandler: ({
23
16
  resolve: (event: RequestEvent) => Response | Promise<Response>;
24
17
  building: boolean;
25
18
  }) => Promise<Response>;
26
- declare function isAuthPath(url: string, options: BetterAuthOptions): boolean;
27
- declare const sveltekitCookies: (getRequestEvent: () => RequestEvent<any, any>) => {
19
+ export declare function isAuthPath(url: string, options: BetterAuthOptions): boolean;
20
+ export declare const sveltekitCookies: (getRequestEvent: () => RequestEvent<any, any>) => {
28
21
  id: "sveltekit-cookies";
29
22
  version: string;
30
23
  hooks: {
31
24
  after: {
32
25
  matcher(): true;
33
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
26
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
34
27
  }[];
35
28
  };
36
29
  };
37
- //#endregion
38
- export { isAuthPath, svelteKitHandler, sveltekitCookies, toSvelteKitHandler };
30
+ //#endregion
@@ -1,6 +1,3 @@
1
- import * as _$_better_auth_core0 from "@better-auth/core";
2
- import * as _$better_call0 from "better-call";
3
-
4
1
  //#region src/integrations/tanstack-start-solid.d.ts
5
2
  /**
6
3
  * TanStack Start cookie plugin for Solid.js.
@@ -19,15 +16,14 @@ import * as _$better_call0 from "better-call";
19
16
  * });
20
17
  * ```
21
18
  */
22
- declare const tanstackStartCookies: () => {
19
+ export declare const tanstackStartCookies: () => {
23
20
  id: "tanstack-start-cookies-solid";
24
21
  version: string;
25
22
  hooks: {
26
23
  after: {
27
- matcher(ctx: _$_better_auth_core0.HookEndpointContext): true;
28
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
24
+ matcher(ctx: import("@better-auth/core").HookEndpointContext): true;
25
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
29
26
  }[];
30
27
  };
31
28
  };
32
- //#endregion
33
- export { tanstackStartCookies };
29
+ //#endregion