better-auth 1.7.21 → 1.7.23

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 (439) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +1 -2
  2. package/dist/adapters/index.d.mts +0 -2
  3. package/dist/adapters/index.mjs +1 -2
  4. package/dist/api/dispatch.d.mts +1 -3
  5. package/dist/api/dispatch.mjs +1 -2
  6. package/dist/api/index.d.mts +3 -3
  7. package/dist/api/index.mjs +8 -9
  8. package/dist/api/middlewares/authorization.d.mts +1 -3
  9. package/dist/api/middlewares/authorization.mjs +1 -2
  10. package/dist/api/middlewares/origin-check.d.mts +1 -3
  11. package/dist/api/middlewares/origin-check.mjs +2 -3
  12. package/dist/api/rate-limiter/index.mjs +1 -2
  13. package/dist/api/routes/account.d.mts +1 -3
  14. package/dist/api/routes/account.mjs +10 -10
  15. package/dist/api/routes/callback.d.mts +1 -3
  16. package/dist/api/routes/callback.mjs +5 -6
  17. package/dist/api/routes/email-verification.d.mts +1 -3
  18. package/dist/api/routes/email-verification.mjs +4 -5
  19. package/dist/api/routes/error.d.mts +1 -3
  20. package/dist/api/routes/error.mjs +1 -2
  21. package/dist/api/routes/ok.d.mts +1 -3
  22. package/dist/api/routes/ok.mjs +1 -2
  23. package/dist/api/routes/password.d.mts +1 -3
  24. package/dist/api/routes/password.mjs +3 -4
  25. package/dist/api/routes/session.d.mts +2 -3
  26. package/dist/api/routes/session.mjs +10 -6
  27. package/dist/api/routes/sign-in.d.mts +0 -2
  28. package/dist/api/routes/sign-in.mjs +6 -7
  29. package/dist/api/routes/sign-out.d.mts +1 -3
  30. package/dist/api/routes/sign-out.mjs +1 -2
  31. package/dist/api/routes/sign-up.d.mts +1 -3
  32. package/dist/api/routes/sign-up.mjs +5 -6
  33. package/dist/api/routes/update-session.d.mts +1 -3
  34. package/dist/api/routes/update-session.mjs +2 -3
  35. package/dist/api/routes/update-user.d.mts +1 -3
  36. package/dist/api/routes/update-user.mjs +31 -28
  37. package/dist/api/state/oauth.d.mts +0 -2
  38. package/dist/api/state/oauth.mjs +1 -2
  39. package/dist/api/state/session-source.d.mts +1 -3
  40. package/dist/api/state/session-source.mjs +1 -2
  41. package/dist/api/state/should-session-refresh.d.mts +0 -2
  42. package/dist/api/state/should-session-refresh.mjs +1 -2
  43. package/dist/api/to-auth-endpoints.mjs +2 -3
  44. package/dist/auth/base.mjs +3 -9
  45. package/dist/auth/full.d.mts +1 -3
  46. package/dist/auth/full.mjs +1 -2
  47. package/dist/auth/minimal.d.mts +0 -2
  48. package/dist/auth/minimal.mjs +2 -3
  49. package/dist/auth/trusted-origins.mjs +2 -3
  50. package/dist/client/broadcast-channel.d.mts +1 -3
  51. package/dist/client/broadcast-channel.mjs +4 -4
  52. package/dist/client/config.d.mts +1 -3
  53. package/dist/client/config.mjs +2 -3
  54. package/dist/client/equality.d.mts +1 -3
  55. package/dist/client/equality.mjs +1 -2
  56. package/dist/client/fetch-plugins.mjs +1 -2
  57. package/dist/client/focus-manager.d.mts +1 -3
  58. package/dist/client/focus-manager.mjs +4 -4
  59. package/dist/client/index.d.mts +5 -7
  60. package/dist/client/index.mjs +1 -2
  61. package/dist/client/lynx/index.d.mts +1 -3
  62. package/dist/client/lynx/index.mjs +1 -2
  63. package/dist/client/lynx/lynx-store.d.mts +0 -2
  64. package/dist/client/lynx/lynx-store.mjs +1 -2
  65. package/dist/client/online-manager.d.mts +1 -3
  66. package/dist/client/online-manager.mjs +7 -7
  67. package/dist/client/parser.d.mts +0 -2
  68. package/dist/client/parser.mjs +1 -2
  69. package/dist/client/path-to-object.d.mts +0 -2
  70. package/dist/client/plugins/index.d.mts +6 -6
  71. package/dist/client/plugins/infer-plugin.d.mts +1 -3
  72. package/dist/client/plugins/infer-plugin.mjs +1 -2
  73. package/dist/client/proxy.mjs +1 -2
  74. package/dist/client/query-atom.mjs +1 -2
  75. package/dist/client/query.d.mts +1 -3
  76. package/dist/client/query.mjs +1 -2
  77. package/dist/client/react/index.d.mts +1 -3
  78. package/dist/client/react/index.mjs +1 -2
  79. package/dist/client/react/react-store.d.mts +0 -2
  80. package/dist/client/react/react-store.mjs +1 -2
  81. package/dist/client/session-atom.d.mts +1 -3
  82. package/dist/client/session-atom.mjs +2 -2
  83. package/dist/client/session-refresh.d.mts +1 -3
  84. package/dist/client/session-refresh.mjs +3 -3
  85. package/dist/client/solid/index.d.mts +1 -3
  86. package/dist/client/solid/index.mjs +1 -2
  87. package/dist/client/solid/solid-store.mjs +1 -2
  88. package/dist/client/svelte/index.d.mts +1 -3
  89. package/dist/client/svelte/index.mjs +1 -2
  90. package/dist/client/types.d.mts +2 -4
  91. package/dist/client/vanilla.d.mts +1 -3
  92. package/dist/client/vanilla.mjs +1 -2
  93. package/dist/client/vue/index.d.mts +1 -3
  94. package/dist/client/vue/index.mjs +1 -2
  95. package/dist/client/vue/vue-store.mjs +1 -2
  96. package/dist/context/create-context.mjs +8 -9
  97. package/dist/context/helpers.mjs +3 -4
  98. package/dist/context/init-minimal.mjs +1 -2
  99. package/dist/context/init.mjs +1 -2
  100. package/dist/context/secret-utils.mjs +1 -2
  101. package/dist/context/store-capabilities.mjs +1 -2
  102. package/dist/cookies/cache.mjs +1 -2
  103. package/dist/cookies/cookie-utils.d.mts +0 -2
  104. package/dist/cookies/cookie-utils.mjs +1 -2
  105. package/dist/cookies/index.d.mts +0 -2
  106. package/dist/cookies/index.mjs +2 -3
  107. package/dist/cookies/jwt.mjs +1 -2
  108. package/dist/cookies/session-store.d.mts +0 -2
  109. package/dist/cookies/session-store.mjs +1 -2
  110. package/dist/crypto/buffer.d.mts +1 -3
  111. package/dist/crypto/buffer.mjs +1 -2
  112. package/dist/crypto/index.d.mts +0 -2
  113. package/dist/crypto/index.mjs +2 -3
  114. package/dist/crypto/jwt.d.mts +1 -3
  115. package/dist/crypto/jwt.mjs +1 -2
  116. package/dist/crypto/password.d.mts +0 -2
  117. package/dist/crypto/password.mjs +1 -2
  118. package/dist/crypto/purpose.mjs +1 -2
  119. package/dist/crypto/random.d.mts +1 -3
  120. package/dist/crypto/random.mjs +1 -2
  121. package/dist/db/adapter-base.d.mts +1 -3
  122. package/dist/db/adapter-base.mjs +1 -2
  123. package/dist/db/adapter-kysely.d.mts +1 -3
  124. package/dist/db/adapter-kysely.mjs +1 -2
  125. package/dist/db/field-converter.d.mts +1 -3
  126. package/dist/db/field-converter.mjs +1 -2
  127. package/dist/db/field.d.mts +0 -2
  128. package/dist/db/get-migration.d.mts +1 -3
  129. package/dist/db/get-migration.mjs +1 -2
  130. package/dist/db/get-schema.d.mts +1 -3
  131. package/dist/db/get-schema.mjs +1 -2
  132. package/dist/db/index.d.mts +1 -1
  133. package/dist/db/index.mjs +4 -5
  134. package/dist/db/internal-adapter.d.mts +1 -3
  135. package/dist/db/internal-adapter.mjs +21 -10
  136. package/dist/db/revoke-unproven-account-access.d.mts +1 -3
  137. package/dist/db/revoke-unproven-account-access.mjs +1 -2
  138. package/dist/db/schema.d.mts +1 -3
  139. package/dist/db/schema.mjs +1 -2
  140. package/dist/db/to-zod.d.mts +0 -2
  141. package/dist/db/to-zod.mjs +1 -2
  142. package/dist/db/verification-token-storage.mjs +1 -2
  143. package/dist/db/with-hooks.d.mts +1 -3
  144. package/dist/db/with-hooks.mjs +1 -2
  145. package/dist/index.d.mts +1 -1
  146. package/dist/index.mjs +1 -1
  147. package/dist/integrations/cookie-plugin-guard.mjs +1 -2
  148. package/dist/integrations/next-js.d.mts +1 -3
  149. package/dist/integrations/next-js.mjs +2 -3
  150. package/dist/integrations/node.d.mts +1 -3
  151. package/dist/integrations/node.mjs +1 -2
  152. package/dist/integrations/solid-start.d.mts +1 -3
  153. package/dist/integrations/solid-start.mjs +1 -2
  154. package/dist/integrations/svelte-kit.d.mts +1 -3
  155. package/dist/integrations/svelte-kit.mjs +1 -2
  156. package/dist/integrations/tanstack-start-solid.d.mts +1 -3
  157. package/dist/integrations/tanstack-start-solid.mjs +1 -2
  158. package/dist/integrations/tanstack-start.d.mts +1 -3
  159. package/dist/integrations/tanstack-start.mjs +1 -2
  160. package/dist/oauth2/account-key.mjs +1 -2
  161. package/dist/oauth2/callback.mjs +1 -2
  162. package/dist/oauth2/errors.mjs +1 -2
  163. package/dist/oauth2/index.d.mts +1 -1
  164. package/dist/oauth2/index.mjs +1 -1
  165. package/dist/oauth2/link-account.d.mts +1 -3
  166. package/dist/oauth2/link-account.mjs +18 -13
  167. package/dist/oauth2/state.d.mts +1 -3
  168. package/dist/oauth2/state.mjs +3 -4
  169. package/dist/oauth2/utils.d.mts +1 -3
  170. package/dist/oauth2/utils.mjs +1 -2
  171. package/dist/package.mjs +2 -3
  172. package/dist/plugins/access/access.d.mts +1 -3
  173. package/dist/plugins/access/access.mjs +1 -2
  174. package/dist/plugins/access/index.d.mts +1 -1
  175. package/dist/plugins/access/types.d.mts +1 -3
  176. package/dist/plugins/additional-fields/client.d.mts +1 -3
  177. package/dist/plugins/additional-fields/client.mjs +1 -2
  178. package/dist/plugins/admin/access/statement.d.mts +1 -3
  179. package/dist/plugins/admin/access/statement.mjs +1 -2
  180. package/dist/plugins/admin/admin.d.mts +1 -3
  181. package/dist/plugins/admin/admin.mjs +2 -3
  182. package/dist/plugins/admin/client.d.mts +2 -4
  183. package/dist/plugins/admin/client.mjs +1 -2
  184. package/dist/plugins/admin/error-codes.d.mts +1 -3
  185. package/dist/plugins/admin/error-codes.mjs +1 -2
  186. package/dist/plugins/admin/has-permission.mjs +1 -2
  187. package/dist/plugins/admin/index.d.mts +1 -1
  188. package/dist/plugins/admin/routes.mjs +3 -4
  189. package/dist/plugins/admin/schema.d.mts +1 -3
  190. package/dist/plugins/admin/schema.mjs +1 -2
  191. package/dist/plugins/admin/types.d.mts +1 -3
  192. package/dist/plugins/anonymous/client.d.mts +1 -3
  193. package/dist/plugins/anonymous/client.mjs +1 -2
  194. package/dist/plugins/anonymous/error-codes.d.mts +1 -3
  195. package/dist/plugins/anonymous/error-codes.mjs +1 -2
  196. package/dist/plugins/anonymous/index.d.mts +0 -2
  197. package/dist/plugins/anonymous/index.mjs +3 -4
  198. package/dist/plugins/anonymous/schema.d.mts +1 -3
  199. package/dist/plugins/anonymous/schema.mjs +1 -2
  200. package/dist/plugins/anonymous/types.d.mts +1 -3
  201. package/dist/plugins/bearer/index.d.mts +1 -3
  202. package/dist/plugins/bearer/index.mjs +1 -2
  203. package/dist/plugins/captcha/constants.d.mts +1 -3
  204. package/dist/plugins/captcha/constants.mjs +1 -2
  205. package/dist/plugins/captcha/error-codes.mjs +1 -2
  206. package/dist/plugins/captcha/index.d.mts +0 -2
  207. package/dist/plugins/captcha/index.mjs +2 -3
  208. package/dist/plugins/captcha/types.d.mts +1 -3
  209. package/dist/plugins/captcha/utils.mjs +1 -2
  210. package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -2
  211. package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -2
  212. package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -2
  213. package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -2
  214. package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +1 -2
  215. package/dist/plugins/custom-session/client.d.mts +1 -3
  216. package/dist/plugins/custom-session/client.mjs +1 -2
  217. package/dist/plugins/custom-session/index.d.mts +1 -3
  218. package/dist/plugins/custom-session/index.mjs +3 -4
  219. package/dist/plugins/device-authorization/client.d.mts +1 -3
  220. package/dist/plugins/device-authorization/client.mjs +1 -2
  221. package/dist/plugins/device-authorization/error-codes.mjs +1 -2
  222. package/dist/plugins/device-authorization/index.d.mts +1 -3
  223. package/dist/plugins/device-authorization/index.mjs +2 -3
  224. package/dist/plugins/device-authorization/routes.d.mts +4 -6
  225. package/dist/plugins/device-authorization/routes.mjs +3 -4
  226. package/dist/plugins/device-authorization/schema.d.mts +0 -2
  227. package/dist/plugins/device-authorization/schema.mjs +1 -2
  228. package/dist/plugins/email-otp/client.d.mts +0 -2
  229. package/dist/plugins/email-otp/client.mjs +1 -2
  230. package/dist/plugins/email-otp/error-codes.d.mts +1 -3
  231. package/dist/plugins/email-otp/error-codes.mjs +1 -2
  232. package/dist/plugins/email-otp/index.d.mts +0 -2
  233. package/dist/plugins/email-otp/index.mjs +4 -5
  234. package/dist/plugins/email-otp/otp-token.mjs +3 -4
  235. package/dist/plugins/email-otp/routes.mjs +6 -7
  236. package/dist/plugins/email-otp/types.d.mts +1 -3
  237. package/dist/plugins/email-otp/utils.mjs +1 -2
  238. package/dist/plugins/generic-oauth/error-codes.mjs +1 -2
  239. package/dist/plugins/generic-oauth/index.d.mts +0 -2
  240. package/dist/plugins/generic-oauth/index.mjs +5 -7
  241. package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -3
  242. package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -2
  243. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -3
  244. package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -2
  245. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -3
  246. package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -2
  247. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -3
  248. package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -2
  249. package/dist/plugins/generic-oauth/providers/line.d.mts +1 -3
  250. package/dist/plugins/generic-oauth/providers/line.mjs +1 -2
  251. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -3
  252. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -2
  253. package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -3
  254. package/dist/plugins/generic-oauth/providers/okta.mjs +1 -2
  255. package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -3
  256. package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -2
  257. package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -3
  258. package/dist/plugins/generic-oauth/providers/slack.mjs +1 -2
  259. package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -3
  260. package/dist/plugins/generic-oauth/providers/yandex.mjs +1 -2
  261. package/dist/plugins/generic-oauth/types.d.mts +1 -3
  262. package/dist/plugins/haveibeenpwned/index.d.mts +1 -3
  263. package/dist/plugins/haveibeenpwned/index.mjs +2 -3
  264. package/dist/plugins/index.d.mts +5 -5
  265. package/dist/plugins/jwt/adapter.mjs +1 -2
  266. package/dist/plugins/jwt/client.d.mts +1 -3
  267. package/dist/plugins/jwt/client.mjs +1 -2
  268. package/dist/plugins/jwt/cookie-cache.mjs +1 -2
  269. package/dist/plugins/jwt/index.d.mts +1 -3
  270. package/dist/plugins/jwt/index.mjs +5 -6
  271. package/dist/plugins/jwt/schema.d.mts +1 -3
  272. package/dist/plugins/jwt/schema.mjs +1 -2
  273. package/dist/plugins/jwt/sign.d.mts +0 -2
  274. package/dist/plugins/jwt/sign.mjs +1 -2
  275. package/dist/plugins/jwt/types.d.mts +1 -3
  276. package/dist/plugins/jwt/utils.d.mts +1 -3
  277. package/dist/plugins/jwt/utils.mjs +2 -3
  278. package/dist/plugins/jwt/verify.d.mts +1 -3
  279. package/dist/plugins/jwt/verify.mjs +1 -2
  280. package/dist/plugins/last-login-method/client.d.mts +1 -3
  281. package/dist/plugins/last-login-method/client.mjs +1 -2
  282. package/dist/plugins/last-login-method/index.d.mts +1 -3
  283. package/dist/plugins/last-login-method/index.mjs +1 -2
  284. package/dist/plugins/magic-link/client.d.mts +1 -3
  285. package/dist/plugins/magic-link/client.mjs +1 -2
  286. package/dist/plugins/magic-link/index.d.mts +1 -3
  287. package/dist/plugins/magic-link/index.mjs +4 -5
  288. package/dist/plugins/magic-link/utils.mjs +1 -2
  289. package/dist/plugins/multi-session/client.d.mts +0 -2
  290. package/dist/plugins/multi-session/client.mjs +1 -2
  291. package/dist/plugins/multi-session/error-codes.d.mts +1 -3
  292. package/dist/plugins/multi-session/error-codes.mjs +1 -2
  293. package/dist/plugins/multi-session/index.d.mts +0 -2
  294. package/dist/plugins/multi-session/index.mjs +3 -4
  295. package/dist/plugins/oauth-popup/client.d.mts +0 -2
  296. package/dist/plugins/oauth-popup/client.mjs +1 -2
  297. package/dist/plugins/oauth-popup/constants.d.mts +1 -3
  298. package/dist/plugins/oauth-popup/constants.mjs +1 -2
  299. package/dist/plugins/oauth-popup/error-codes.d.mts +1 -3
  300. package/dist/plugins/oauth-popup/error-codes.mjs +1 -2
  301. package/dist/plugins/oauth-popup/index.d.mts +0 -2
  302. package/dist/plugins/oauth-popup/index.mjs +5 -6
  303. package/dist/plugins/oauth-popup/types.d.mts +1 -3
  304. package/dist/plugins/oauth-proxy/index.d.mts +1 -3
  305. package/dist/plugins/oauth-proxy/index.mjs +7 -8
  306. package/dist/plugins/oauth-proxy/utils.mjs +1 -2
  307. package/dist/plugins/one-tap/client.d.mts +1 -3
  308. package/dist/plugins/one-tap/client.mjs +1 -2
  309. package/dist/plugins/one-tap/index.d.mts +1 -3
  310. package/dist/plugins/one-tap/index.mjs +7 -8
  311. package/dist/plugins/one-time-token/client.d.mts +0 -2
  312. package/dist/plugins/one-time-token/client.mjs +1 -2
  313. package/dist/plugins/one-time-token/index.d.mts +1 -3
  314. package/dist/plugins/one-time-token/index.mjs +3 -4
  315. package/dist/plugins/one-time-token/utils.mjs +1 -2
  316. package/dist/plugins/open-api/generator.d.mts +0 -2
  317. package/dist/plugins/open-api/generator.mjs +2 -3
  318. package/dist/plugins/open-api/index.d.mts +0 -2
  319. package/dist/plugins/open-api/index.mjs +2 -3
  320. package/dist/plugins/open-api/logo.mjs +1 -2
  321. package/dist/plugins/organization/access/statement.d.mts +1 -3
  322. package/dist/plugins/organization/access/statement.mjs +1 -2
  323. package/dist/plugins/organization/adapter.d.mts +3 -5
  324. package/dist/plugins/organization/adapter.mjs +2 -3
  325. package/dist/plugins/organization/call.mjs +1 -2
  326. package/dist/plugins/organization/client.d.mts +9 -11
  327. package/dist/plugins/organization/client.mjs +2 -3
  328. package/dist/plugins/organization/error-codes.d.mts +1 -3
  329. package/dist/plugins/organization/error-codes.mjs +1 -2
  330. package/dist/plugins/organization/has-permission.d.mts +1 -3
  331. package/dist/plugins/organization/has-permission.mjs +2 -3
  332. package/dist/plugins/organization/index.d.mts +3 -3
  333. package/dist/plugins/organization/organization.d.mts +3 -5
  334. package/dist/plugins/organization/organization.mjs +3 -4
  335. package/dist/plugins/organization/permission.d.mts +1 -3
  336. package/dist/plugins/organization/permission.mjs +1 -2
  337. package/dist/plugins/organization/roles.d.mts +1 -3
  338. package/dist/plugins/organization/roles.mjs +1 -2
  339. package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -4
  340. package/dist/plugins/organization/routes/crud-access-control.mjs +3 -4
  341. package/dist/plugins/organization/routes/crud-invites.d.mts +4 -6
  342. package/dist/plugins/organization/routes/crud-invites.mjs +5 -6
  343. package/dist/plugins/organization/routes/crud-members.d.mts +4 -6
  344. package/dist/plugins/organization/routes/crud-members.mjs +4 -5
  345. package/dist/plugins/organization/routes/crud-org.d.mts +4 -6
  346. package/dist/plugins/organization/routes/crud-org.mjs +8 -9
  347. package/dist/plugins/organization/routes/crud-team.d.mts +4 -6
  348. package/dist/plugins/organization/routes/crud-team.mjs +3 -4
  349. package/dist/plugins/organization/schema.d.mts +0 -2
  350. package/dist/plugins/organization/schema.mjs +1 -2
  351. package/dist/plugins/organization/types.d.mts +1 -3
  352. package/dist/plugins/phone-number/client.d.mts +1 -3
  353. package/dist/plugins/phone-number/client.mjs +1 -2
  354. package/dist/plugins/phone-number/error-codes.d.mts +1 -3
  355. package/dist/plugins/phone-number/error-codes.mjs +1 -2
  356. package/dist/plugins/phone-number/index.d.mts +0 -2
  357. package/dist/plugins/phone-number/index.mjs +1 -2
  358. package/dist/plugins/phone-number/routes.mjs +6 -7
  359. package/dist/plugins/phone-number/schema.d.mts +1 -3
  360. package/dist/plugins/phone-number/schema.mjs +1 -2
  361. package/dist/plugins/phone-number/types.d.mts +2 -4
  362. package/dist/plugins/siwe/client.d.mts +1 -3
  363. package/dist/plugins/siwe/client.mjs +1 -2
  364. package/dist/plugins/siwe/index.d.mts +1 -3
  365. package/dist/plugins/siwe/index.mjs +5 -6
  366. package/dist/plugins/siwe/parse-message.mjs +1 -2
  367. package/dist/plugins/siwe/schema.d.mts +1 -3
  368. package/dist/plugins/siwe/schema.mjs +1 -2
  369. package/dist/plugins/siwe/types.d.mts +0 -2
  370. package/dist/plugins/test-utils/auth-helpers.mjs +1 -2
  371. package/dist/plugins/test-utils/cookie-builder.mjs +1 -2
  372. package/dist/plugins/test-utils/db-helpers.mjs +1 -2
  373. package/dist/plugins/test-utils/factories.mjs +1 -2
  374. package/dist/plugins/test-utils/index.d.mts +0 -2
  375. package/dist/plugins/test-utils/index.mjs +2 -3
  376. package/dist/plugins/test-utils/otp-sink.mjs +1 -2
  377. package/dist/plugins/test-utils/types.d.mts +1 -3
  378. package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -3
  379. package/dist/plugins/two-factor/backup-codes/index.mjs +4 -5
  380. package/dist/plugins/two-factor/client.d.mts +2 -4
  381. package/dist/plugins/two-factor/client.mjs +1 -2
  382. package/dist/plugins/two-factor/constant.mjs +1 -2
  383. package/dist/plugins/two-factor/error-code.d.mts +1 -3
  384. package/dist/plugins/two-factor/error-code.mjs +1 -2
  385. package/dist/plugins/two-factor/index.d.mts +0 -2
  386. package/dist/plugins/two-factor/index.mjs +9 -10
  387. package/dist/plugins/two-factor/otp/index.d.mts +1 -3
  388. package/dist/plugins/two-factor/otp/index.mjs +4 -5
  389. package/dist/plugins/two-factor/schema.d.mts +1 -3
  390. package/dist/plugins/two-factor/schema.mjs +1 -2
  391. package/dist/plugins/two-factor/totp/index.d.mts +1 -3
  392. package/dist/plugins/two-factor/totp/index.mjs +3 -4
  393. package/dist/plugins/two-factor/types.d.mts +1 -3
  394. package/dist/plugins/two-factor/utils.mjs +1 -2
  395. package/dist/plugins/two-factor/verify-two-factor.mjs +5 -6
  396. package/dist/plugins/username/client.d.mts +0 -2
  397. package/dist/plugins/username/client.mjs +1 -2
  398. package/dist/plugins/username/error-codes.d.mts +1 -3
  399. package/dist/plugins/username/error-codes.mjs +1 -2
  400. package/dist/plugins/username/index.d.mts +0 -2
  401. package/dist/plugins/username/index.mjs +4 -5
  402. package/dist/plugins/username/schema.d.mts +1 -3
  403. package/dist/plugins/username/schema.mjs +1 -2
  404. package/dist/state.d.mts +0 -2
  405. package/dist/state.mjs +2 -3
  406. package/dist/test-utils/headers.d.mts +1 -3
  407. package/dist/test-utils/headers.mjs +1 -2
  408. package/dist/test-utils/http-test-instance.d.mts +0 -2
  409. package/dist/test-utils/http-test-instance.mjs +1 -2
  410. package/dist/test-utils/index.d.mts +1 -1
  411. package/dist/test-utils/index.mjs +1 -1
  412. package/dist/test-utils/test-instance.d.mts +4 -6
  413. package/dist/test-utils/test-instance.mjs +35 -22
  414. package/dist/types/api.d.mts +1 -3
  415. package/dist/types/auth.d.mts +2 -4
  416. package/dist/types/helper.d.mts +1 -3
  417. package/dist/types/index.d.mts +2 -2
  418. package/dist/types/models.d.mts +0 -2
  419. package/dist/types/plugins.d.mts +0 -2
  420. package/dist/utils/constants.mjs +1 -2
  421. package/dist/utils/date.mjs +1 -2
  422. package/dist/utils/hashing.mjs +1 -2
  423. package/dist/utils/index.d.mts +1 -1
  424. package/dist/utils/is-atom.mjs +1 -2
  425. package/dist/utils/is-promise.mjs +1 -2
  426. package/dist/utils/middleware-response.mjs +1 -2
  427. package/dist/utils/password.mjs +1 -2
  428. package/dist/utils/plugin-helper.mjs +1 -2
  429. package/dist/utils/request.mjs +1 -2
  430. package/dist/utils/shim.mjs +1 -2
  431. package/dist/utils/time.d.mts +0 -2
  432. package/dist/utils/time.mjs +1 -2
  433. package/dist/utils/url.d.mts +1 -3
  434. package/dist/utils/url.mjs +1 -2
  435. package/dist/utils/validate-user-info.mjs +1 -2
  436. package/dist/utils/wildcard.mjs +1 -2
  437. package/dist/version.mjs +1 -2
  438. package/package.json +10 -10
  439. package/dist/utils/boolean.mjs +0 -6
@@ -1,5 +1,4 @@
1
1
  import * as z from "zod";
2
- //#region src/api/routes/sign-out.d.ts
3
2
  export declare const signOut: import("better-call").StrictEndpoint<"/sign-out", {
4
3
  method: "POST";
5
4
  body: z.ZodOptional<z.ZodObject<{
@@ -44,5 +43,4 @@ export declare const signOut: import("better-call").StrictEndpoint<"/sign-out",
44
43
  success: boolean;
45
44
  url: string | undefined;
46
45
  redirect: boolean | undefined;
47
- }>;
48
- //#endregion
46
+ }>;
@@ -1,7 +1,7 @@
1
1
  import { deleteSessionCookie } from "../../cookies/index.mjs";
2
2
  import { createAuthEndpoint } from "@better-auth/core/api";
3
3
  import * as z from "zod";
4
- //#region src/api/routes/sign-out.ts
4
+ // src/api/routes/sign-out.ts
5
5
  const signOutBodySchema = z.object({
6
6
  callbackURL: z.string().meta({ description: "The URL to redirect to after provider logout" }).optional(),
7
7
  disableRedirect: z.boolean().meta({ description: "Return the provider logout URL without redirecting" }).optional(),
@@ -92,5 +92,4 @@ const signOut = createAuthEndpoint("/sign-out", {
92
92
  }
93
93
  return ctx.json(signOutResponse());
94
94
  });
95
- //#endregion
96
95
  export { signOut };
@@ -2,7 +2,6 @@ import { AdditionalUserFieldsInput, User } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- //#region src/api/routes/sign-up.d.ts
6
5
  export declare const signUpEmail: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/sign-up/email", {
7
6
  method: "POST";
8
7
  operationId: string;
@@ -153,5 +152,4 @@ export declare const signUpEmail: <O extends BetterAuthOptions>() => import("bet
153
152
  } | {
154
153
  token: string;
155
154
  user: User<O["user"], O["plugins"]>;
156
- }>;
157
- //#endregion
155
+ }>;
@@ -1,17 +1,17 @@
1
- import { isAPIError } from "../../utils/is-api-error.mjs";
2
- import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
3
- import { buildSyntheticUserOutput, parseUserInput, parseUserOutput } from "../../db/schema.mjs";
4
1
  import { setSessionCookie } from "../../cookies/index.mjs";
2
+ import { buildSyntheticUserOutput, parseUserInput, parseUserOutput } from "../../db/schema.mjs";
3
+ import { isAPIError } from "../../utils/is-api-error.mjs";
4
+ import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
5
5
  import { safeCloneRequest } from "../../utils/request.mjs";
6
+ import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
6
7
  import { createEmailVerificationToken } from "./email-verification.mjs";
7
- import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
8
8
  import { queueAfterTransactionHook, runWithTransaction } from "@better-auth/core/context";
9
9
  import { isDevelopment } from "@better-auth/core/env";
10
10
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
11
11
  import { generateId } from "@better-auth/core/utils/id";
12
12
  import { createAuthEndpoint } from "@better-auth/core/api";
13
13
  import * as z from "zod";
14
- //#region src/api/routes/sign-up.ts
14
+ // src/api/routes/sign-up.ts
15
15
  const signUpEmailBodySchema = z.object({
16
16
  name: z.string(),
17
17
  email: z.email(),
@@ -275,5 +275,4 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
275
275
  });
276
276
  });
277
277
  });
278
- //#endregion
279
278
  export { signUpEmail };
@@ -2,7 +2,6 @@ import { AdditionalSessionFieldsInput } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- //#region src/api/routes/update-session.d.ts
6
5
  export declare const updateSession: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-session", {
7
6
  method: "POST";
8
7
  operationId: string;
@@ -68,5 +67,4 @@ export declare const updateSession: <O extends BetterAuthOptions>() => import("b
68
67
  ipAddress?: string | null | undefined;
69
68
  userAgent?: string | null | undefined;
70
69
  };
71
- }>;
72
- //#endregion
70
+ }>;
@@ -1,10 +1,10 @@
1
- import { parseSessionInput, parseSessionOutput } from "../../db/schema.mjs";
2
1
  import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
2
+ import { parseSessionInput, parseSessionOutput } from "../../db/schema.mjs";
3
3
  import { isStateful, sessionMiddleware } from "./session.mjs";
4
4
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
5
5
  import { createAuthEndpoint } from "@better-auth/core/api";
6
6
  import * as z from "zod";
7
- //#region src/api/routes/update-session.ts
7
+ // src/api/routes/update-session.ts
8
8
  const updateSessionBodySchema = z.record(z.string().meta({ description: "Field name must be a string" }), z.any());
9
9
  const updateSession = () => createAuthEndpoint("/update-session", {
10
10
  method: "POST",
@@ -53,5 +53,4 @@ const updateSession = () => createAuthEndpoint("/update-session", {
53
53
  });
54
54
  return ctx.json({ session: parseSessionOutput(ctx.context.options, newSession) });
55
55
  });
56
- //#endregion
57
56
  export { updateSession };
@@ -2,7 +2,6 @@ import { AdditionalUserFieldsInput } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- //#region src/api/routes/update-user.d.ts
6
5
  export declare const updateUser: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-user", {
7
6
  method: "POST";
8
7
  operationId: string;
@@ -422,5 +421,4 @@ export declare const changeEmail: import("better-call").StrictEndpoint<"/change-
422
421
  };
423
422
  }, {
424
423
  status: boolean;
425
- }>;
426
- //#endregion
424
+ }>;
@@ -1,15 +1,15 @@
1
- import { originCheck } from "../middlewares/origin-check.mjs";
2
- import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
3
- import { generateRandomString } from "../../crypto/random.mjs";
4
1
  import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
5
- import { getSessionFromCtx, isStateful, sensitiveSessionMiddleware, sessionMiddleware } from "./session.mjs";
6
- import { createEmailVerificationToken } from "./email-verification.mjs";
2
+ import { generateRandomString } from "../../crypto/random.mjs";
3
+ import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
7
4
  import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
5
+ import { originCheck } from "../middlewares/origin-check.mjs";
6
+ import { createEmailVerificationToken } from "./email-verification.mjs";
7
+ import { getSessionFromCtx, isStateful, sensitiveSessionMiddleware, sessionMiddleware } from "./session.mjs";
8
8
  import { runWithTransaction } from "@better-auth/core/context";
9
9
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
10
10
  import { createAuthEndpoint } from "@better-auth/core/api";
11
11
  import * as z from "zod";
12
- //#region src/api/routes/update-user.ts
12
+ // src/api/routes/update-user.ts
13
13
  const updateUserBodySchema = z.record(z.string().meta({ description: "Field name must be a string" }), z.any());
14
14
  const updateUser = () => createAuthEndpoint("/update-user", {
15
15
  method: "POST",
@@ -221,6 +221,28 @@ newPassword: z.string().meta({ description: "The new password to set is required
221
221
  }
222
222
  throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.PASSWORD_ALREADY_SET);
223
223
  });
224
+ /**
225
+ * Deletes the signed-in user and expires the session cookies on the
226
+ * caller's response.
227
+ */
228
+ async function deleteCurrentUser(ctx, user) {
229
+ const beforeDelete = ctx.context.options.user?.deleteUser?.beforeDelete;
230
+ if (beforeDelete) await beforeDelete(user, ctx.request);
231
+ await ctx.context.internalAdapter.deleteUser(user.id);
232
+ await ctx.context.internalAdapter.deleteUserSessions(user.id);
233
+ deleteSessionCookie(ctx);
234
+ const afterDelete = ctx.context.options.user?.deleteUser?.afterDelete;
235
+ if (afterDelete) await afterDelete(user, ctx.request);
236
+ }
237
+ /**
238
+ * Consumes a delete-account token issued to `user` and deletes the user.
239
+ * Runs on the caller's context so the expired cookies reach its response.
240
+ */
241
+ async function deleteUserWithToken(ctx, user, token) {
242
+ const verification = await ctx.context.internalAdapter.consumeVerificationValue(`delete-account-${token}`);
243
+ if (!verification || verification.value !== user.id) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.INVALID_TOKEN);
244
+ await deleteCurrentUser(ctx, user);
245
+ }
224
246
  const deleteUser = createAuthEndpoint("/delete-user", {
225
247
  method: "POST",
226
248
  use: [sensitiveSessionMiddleware],
@@ -295,10 +317,7 @@ const deleteUser = createAuthEndpoint("/delete-user", {
295
317
  })) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
296
318
  }
297
319
  if (ctx.body.token) {
298
- await deleteUserCallback({
299
- ...ctx,
300
- query: { token: ctx.body.token }
301
- });
320
+ await deleteUserWithToken(ctx, session.user, ctx.body.token);
302
321
  return ctx.json({
303
322
  success: true,
304
323
  message: "User deleted"
@@ -327,13 +346,7 @@ const deleteUser = createAuthEndpoint("/delete-user", {
327
346
  const freshAge = ctx.context.sessionConfig.freshAge * 1e3;
328
347
  if (Date.now() - createdAt >= freshAge) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.SESSION_EXPIRED);
329
348
  }
330
- const beforeDelete = ctx.context.options.user.deleteUser?.beforeDelete;
331
- if (beforeDelete) await beforeDelete(session.user, ctx.request);
332
- await ctx.context.internalAdapter.deleteUser(session.user.id);
333
- await ctx.context.internalAdapter.deleteUserSessions(session.user.id);
334
- deleteSessionCookie(ctx);
335
- const afterDelete = ctx.context.options.user.deleteUser?.afterDelete;
336
- if (afterDelete) await afterDelete(session.user, ctx.request);
349
+ await deleteCurrentUser(ctx, session.user);
337
350
  return ctx.json({
338
351
  success: true,
339
352
  message: "User deleted"
@@ -377,16 +390,7 @@ const deleteUserCallback = createAuthEndpoint("/delete-user/callback", {
377
390
  }
378
391
  const session = await getSessionFromCtx(ctx, { disableCookieCache: isStateful(ctx) });
379
392
  if (!session) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.FAILED_TO_GET_USER_INFO);
380
- const token = await ctx.context.internalAdapter.consumeVerificationValue(`delete-account-${ctx.query.token}`);
381
- if (!token || token.value !== session.user.id) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.INVALID_TOKEN);
382
- const beforeDelete = ctx.context.options.user.deleteUser?.beforeDelete;
383
- if (beforeDelete) await beforeDelete(session.user, ctx.request);
384
- await ctx.context.internalAdapter.deleteUser(session.user.id);
385
- await ctx.context.internalAdapter.deleteUserSessions(session.user.id);
386
- await ctx.context.internalAdapter.deleteAccounts(session.user.id);
387
- deleteSessionCookie(ctx);
388
- const afterDelete = ctx.context.options.user.deleteUser?.afterDelete;
389
- if (afterDelete) await afterDelete(session.user, ctx.request);
393
+ await deleteUserWithToken(ctx, session.user, ctx.query.token);
390
394
  if (ctx.query.callbackURL) throw ctx.redirect(ctx.query.callbackURL || "/");
391
395
  return ctx.json({
392
396
  success: true,
@@ -516,5 +520,4 @@ const changeEmail = createAuthEndpoint("/change-email", {
516
520
  }, ctx.request));
517
521
  return ctx.json({ status: true });
518
522
  });
519
- //#endregion
520
523
  export { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser };
@@ -1,4 +1,3 @@
1
- //#region src/api/state/oauth.d.ts
2
1
  type OAuthState = {
3
2
  callbackURL: string;
4
3
  codeVerifier: string;
@@ -46,5 +45,4 @@ declare const getOAuthState: <T extends Record<string, unknown> = Record<string,
46
45
  * stored as `unknown`, so narrow their shape when reading them back.
47
46
  */
48
47
  declare const addOAuthServerContext: (values: Record<string, unknown>) => Promise<void>;
49
- //#endregion
50
48
  export { addOAuthServerContext, getOAuthState };
@@ -1,5 +1,5 @@
1
1
  import { defineRequestState } from "@better-auth/core/context";
2
- //#region src/api/state/oauth.ts
2
+ // src/api/state/oauth.ts
3
3
  const { get: getRawOAuthState, set: setOAuthState } = defineRequestState(() => null);
4
4
  /**
5
5
  * Reads the OAuth state for the current request. During a callback it holds the
@@ -35,5 +35,4 @@ const addOAuthServerContext = async (values) => {
35
35
  ...values
36
36
  });
37
37
  };
38
- //#endregion
39
38
  export { addOAuthServerContext, getOAuthServerContext, getOAuthState, setOAuthState };
@@ -1,4 +1,3 @@
1
- //#region src/api/state/session-source.d.ts
2
1
  /**
3
2
  * Marks the request session with `token` as built without a session-store
4
3
  * row. Checks that re-read the store to catch a concurrent revocation skip
@@ -6,5 +5,4 @@
6
5
  *
7
6
  * @internal Shared by Better Auth packages; not a supported public API.
8
7
  */
9
- export declare function markSessionOutsideStore(token: string): Promise<void>;
10
- //#endregion
8
+ export declare function markSessionOutsideStore(token: string): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { defineRequestState } from "@better-auth/core/context";
2
- //#region src/api/state/session-source.ts
2
+ // src/api/state/session-source.ts
3
3
  /**
4
4
  * Tokens of request sessions that a plugin built without a session-store
5
5
  * row, such as one authenticated by an API key on every request.
@@ -24,5 +24,4 @@ async function markSessionOutsideStore(token) {
24
24
  async function isSessionOutsideStore(token) {
25
25
  return (await getTokensOutsideStore().catch(() => null))?.has(token) ?? false;
26
26
  }
27
- //#endregion
28
27
  export { isSessionOutsideStore, markSessionOutsideStore };
@@ -1,4 +1,3 @@
1
- //#region src/api/state/should-session-refresh.d.ts
2
1
  /**
3
2
  * State for skipping session refresh
4
3
  *
@@ -8,5 +7,4 @@
8
7
  * data stored in cookies.
9
8
  */
10
9
  declare const getShouldSkipSessionRefresh: () => Promise<boolean | null>, setShouldSkipSessionRefresh: (value: boolean | null) => Promise<void>;
11
- //#endregion
12
10
  export { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh };
@@ -1,5 +1,5 @@
1
1
  import { defineRequestState } from "@better-auth/core/context";
2
- //#region src/api/state/should-session-refresh.ts
2
+ // src/api/state/should-session-refresh.ts
3
3
  /**
4
4
  * State for skipping session refresh
5
5
  *
@@ -9,5 +9,4 @@ import { defineRequestState } from "@better-auth/core/context";
9
9
  * data stored in cookies.
10
10
  */
11
11
  const { get: getShouldSkipSessionRefresh, set: setShouldSkipSessionRefresh } = defineRequestState(() => false);
12
- //#endregion
13
12
  export { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh };
@@ -1,9 +1,9 @@
1
- import { isDynamicBaseURLConfig, isRequestLike } from "../utils/url.mjs";
2
1
  import { pickSource, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
2
+ import { isDynamicBaseURLConfig, isRequestLike } from "../utils/url.mjs";
3
3
  import { dispatchAuthEndpoint, getOperationId } from "./dispatch.mjs";
4
4
  import { hasRequestState, runWithRequestState } from "@better-auth/core/context";
5
5
  import { APIError, BetterAuthError } from "@better-auth/core/error";
6
- //#region src/api/to-auth-endpoints.ts
6
+ // src/api/to-auth-endpoints.ts
7
7
  /**
8
8
  * Resolves the per-call `AuthContext` for endpoints with a dynamic `baseURL`.
9
9
  *
@@ -56,5 +56,4 @@ function toAuthEndpoints(endpoints, ctx) {
56
56
  }
57
57
  return api;
58
58
  }
59
- //#endregion
60
59
  export { toAuthEndpoints };
@@ -1,10 +1,9 @@
1
- import { getBaseURL, getOrigin, isDynamicBaseURLConfig } from "../utils/url.mjs";
2
- import { getTrustedOrigins, getTrustedProviders, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
3
1
  import { getEndpoints, router } from "../api/index.mjs";
2
+ import { getTrustedOrigins, getTrustedProviders, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
3
+ import { getBaseURL, getOrigin, isDynamicBaseURLConfig } from "../utils/url.mjs";
4
4
  import { runWithAdapter } from "@better-auth/core/context";
5
5
  import { BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
6
- import { SchemaMismatchError } from "@better-auth/core/db/internal";
7
- //#region src/auth/base.ts
6
+ // src/auth/base.ts
8
7
  const createBetterAuth = (options, initFn) => {
9
8
  const authContext = initFn(options).then((ctx) => {
10
9
  const validateSchema = ctx.options.advanced?.database?.validateSchema;
@@ -12,10 +11,6 @@ const createBetterAuth = (options, initFn) => {
12
11
  const level = validateSchema === true ? "warn" : "debug";
13
12
  ctx.logger[level](`Schema validation is not available for adapter "${ctx.adapter.id}". Skipping schema validation. Database operations will proceed normally.`);
14
13
  }
15
- const pendingSchemaCheck = ctx.checkSchema?.();
16
- if (pendingSchemaCheck) pendingSchemaCheck.catch((error) => {
17
- ctx.logger.error(error instanceof SchemaMismatchError ? error.message : "Could not validate the database schema. Check your database connection.");
18
- });
19
14
  return ctx;
20
15
  });
21
16
  const { api } = getEndpoints(authContext, options);
@@ -62,5 +57,4 @@ const createBetterAuth = (options, initFn) => {
62
57
  }
63
58
  };
64
59
  };
65
- //#endregion
66
60
  export { createBetterAuth };
@@ -1,7 +1,6 @@
1
1
  import { Auth } from "../types/auth.mjs";
2
2
  import "../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
- //#region src/auth/full.d.ts
5
4
  /**
6
5
  * Better Auth initializer for full mode (with Kysely)
7
6
  *
@@ -23,5 +22,4 @@ import { BetterAuthOptions } from "@better-auth/core";
23
22
  * database: drizzleAdapter(db, { provider: "pg" }),
24
23
  * });
25
24
  */
26
- export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
27
- //#endregion
25
+ export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
@@ -1,6 +1,6 @@
1
1
  import { init } from "../context/init.mjs";
2
2
  import { createBetterAuth } from "./base.mjs";
3
- //#region src/auth/full.ts
3
+ // src/auth/full.ts
4
4
  /**
5
5
  * Better Auth initializer for full mode (with Kysely)
6
6
  *
@@ -25,5 +25,4 @@ import { createBetterAuth } from "./base.mjs";
25
25
  const betterAuth = (options) => {
26
26
  return createBetterAuth(options, init);
27
27
  };
28
- //#endregion
29
28
  export { betterAuth };
@@ -1,10 +1,8 @@
1
1
  import { Auth } from "../types/auth.mjs";
2
2
  import "../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
- //#region src/auth/minimal.d.ts
5
4
  /**
6
5
  * Better Auth initializer for minimal mode (without Kysely)
7
6
  */
8
7
  export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
9
- //#endregion
10
8
  export type { BetterAuthOptions };
@@ -1,11 +1,10 @@
1
- import { createBetterAuth } from "./base.mjs";
2
1
  import { initMinimal } from "../context/init-minimal.mjs";
3
- //#region src/auth/minimal.ts
2
+ import { createBetterAuth } from "./base.mjs";
3
+ // src/auth/minimal.ts
4
4
  /**
5
5
  * Better Auth initializer for minimal mode (without Kysely)
6
6
  */
7
7
  const betterAuth = (options) => {
8
8
  return createBetterAuth(options, initMinimal);
9
9
  };
10
- //#endregion
11
10
  export { betterAuth };
@@ -1,7 +1,7 @@
1
- import { wildcardMatch } from "../utils/wildcard.mjs";
2
1
  import { getHost, getOrigin, getProtocol } from "../utils/url.mjs";
2
+ import { wildcardMatch } from "../utils/wildcard.mjs";
3
3
  import * as z from "zod";
4
- //#region src/auth/trusted-origins.ts
4
+ // src/auth/trusted-origins.ts
5
5
  const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f-\u009f]/;
6
6
  const RELATIVE_URL_PARSER_ORIGIN = "https://better-auth.invalid";
7
7
  const ENCODED_PATH_SEPARATOR_PATTERN = /%2[fF]|%5[cC]/;
@@ -127,5 +127,4 @@ const matchesOriginPattern = (url, pattern, settings) => {
127
127
  if (!parsedPattern.path) return true;
128
128
  return parsed.path === parsedPattern.path || parsed.path.startsWith(`${parsedPattern.path}/`);
129
129
  };
130
- //#endregion
131
130
  export { matchesOriginPattern };
@@ -1,4 +1,3 @@
1
- //#region src/client/broadcast-channel.d.ts
2
1
  export interface BroadcastMessage {
3
2
  event?: "session" | undefined;
4
3
  data?: {
@@ -14,5 +13,4 @@ export interface BroadcastChannel {
14
13
  subscribe(listener: BroadcastListener): () => void;
15
14
  setup(): () => void;
16
15
  }
17
- export declare function getGlobalBroadcastChannel(name?: string): BroadcastChannel;
18
- //#endregion
16
+ export declare function getGlobalBroadcastChannel(name?: string): BroadcastChannel;
@@ -1,4 +1,4 @@
1
- //#region src/client/broadcast-channel.ts
1
+ // src/client/broadcast-channel.ts
2
2
  const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
3
3
  const now = () => Math.floor(Date.now() / 1e3);
4
4
  var WindowBroadcastChannel = class {
@@ -24,15 +24,16 @@ var WindowBroadcastChannel = class {
24
24
  }
25
25
  setup() {
26
26
  if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
27
+ const target = window;
27
28
  const handler = (event) => {
28
29
  if (event.key !== this.name) return;
29
30
  const message = JSON.parse(event.newValue ?? "{}");
30
31
  if (message?.event !== "session" || !message?.data) return;
31
32
  this.listeners.forEach((listener) => listener(message));
32
33
  };
33
- window.addEventListener("storage", handler);
34
+ target.addEventListener("storage", handler);
34
35
  return () => {
35
- window.removeEventListener("storage", handler);
36
+ target.removeEventListener("storage", handler);
36
37
  };
37
38
  }
38
39
  };
@@ -40,5 +41,4 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
40
41
  if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
41
42
  return globalThis[kBroadcastChannel];
42
43
  }
43
- //#endregion
44
44
  export { getGlobalBroadcastChannel, kBroadcastChannel };
@@ -1,7 +1,6 @@
1
1
  import { SessionData } from "./session-atom.mjs";
2
2
  import { BetterAuthClientOptions, ClientAtomListener } from "@better-auth/core";
3
3
  import { WritableAtom } from "nanostores";
4
- //#region src/client/config.d.ts
5
4
  export declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, loadEnv?: boolean | undefined) => {
6
5
  readonly baseURL: string;
7
6
  pluginsActions: Record<string, any>;
@@ -82,5 +81,4 @@ export declare const getClientConfig: (options?: BetterAuthClientOptions | undef
82
81
  listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
83
82
  atoms: Record<string, WritableAtom<any>>;
84
83
  };
85
- };
86
- //#endregion
84
+ };
@@ -1,10 +1,10 @@
1
1
  import { getBaseURL } from "../utils/url.mjs";
2
- import { parseJSON } from "./parser.mjs";
3
2
  import { redirectPlugin } from "./fetch-plugins.mjs";
3
+ import { parseJSON } from "./parser.mjs";
4
4
  import { getSessionAtom, hydrateSessionAtom } from "./session-atom.mjs";
5
5
  import { defu as defu$1 } from "defu";
6
6
  import { createFetch } from "@better-fetch/fetch";
7
- //#region src/client/config.ts
7
+ // src/client/config.ts
8
8
  const resolvePublicAuthUrl = (basePath) => {
9
9
  if (typeof process === "undefined") return void 0;
10
10
  const path = basePath ?? "/api/auth";
@@ -108,5 +108,4 @@ const getClientConfig = (options, loadEnv) => {
108
108
  $store
109
109
  };
110
110
  };
111
- //#endregion
112
111
  export { getClientConfig, matchesSessionSignal };
@@ -1,5 +1,4 @@
1
1
  import { Store, StoreValue } from "nanostores";
2
- //#region src/client/equality.d.ts
3
2
  /**
4
3
  * Deep structural equality for JSON-serializable values.
5
4
  * Handles: primitives, null, arrays, and plain objects.
@@ -13,5 +12,4 @@ export declare function isJsonEqual(a: unknown, b: unknown): boolean;
13
12
  *
14
13
  * Returns the unsubscribe function from `onSet`.
15
14
  */
16
- export declare function withEquality<S extends Store>(store: S, isEqual: (a: StoreValue<S>, b: StoreValue<S>) => boolean): () => void;
17
- //#endregion
15
+ export declare function withEquality<S extends Store>(store: S, isEqual: (a: StoreValue<S>, b: StoreValue<S>) => boolean): () => void;
@@ -1,5 +1,5 @@
1
1
  import { onSet } from "nanostores";
2
- //#region src/client/equality.ts
2
+ // src/client/equality.ts
3
3
  function isPlainObject(value) {
4
4
  if (typeof value !== "object" || value === null) return false;
5
5
  const prototype = Object.getPrototypeOf(value);
@@ -38,5 +38,4 @@ function withEquality(store, isEqual) {
38
38
  if (isEqual(store.value, newValue)) abort();
39
39
  });
40
40
  }
41
- //#endregion
42
41
  export { isJsonEqual, withEquality };
@@ -1,5 +1,5 @@
1
1
  import { isSafeUrlScheme } from "@better-auth/core/utils/url";
2
- //#region src/client/fetch-plugins.ts
2
+ // src/client/fetch-plugins.ts
3
3
  const redirectPlugin = {
4
4
  id: "redirect",
5
5
  name: "Redirect",
@@ -13,5 +13,4 @@ const redirectPlugin = {
13
13
  }
14
14
  } }
15
15
  };
16
- //#endregion
17
16
  export { redirectPlugin };
@@ -1,9 +1,7 @@
1
- //#region src/client/focus-manager.d.ts
2
1
  export type FocusListener = (focused: boolean) => void;
3
2
  export declare const kFocusManager: unique symbol;
4
3
  export interface FocusManager {
5
4
  setFocused(focused: boolean): void;
6
5
  subscribe(listener: FocusListener): () => void;
7
6
  setup(): () => void;
8
- }
9
- //#endregion
7
+ }
@@ -1,4 +1,4 @@
1
- //#region src/client/focus-manager.ts
1
+ // src/client/focus-manager.ts
2
2
  const kFocusManager = Symbol.for("better-auth:focus-manager");
3
3
  var WindowFocusManager = class {
4
4
  listeners = /* @__PURE__ */ new Set();
@@ -13,12 +13,13 @@ var WindowFocusManager = class {
13
13
  }
14
14
  setup() {
15
15
  if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {};
16
+ const target = document;
16
17
  const visibilityHandler = () => {
17
18
  if (document.visibilityState === "visible") this.setFocused(true);
18
19
  };
19
- document.addEventListener("visibilitychange", visibilityHandler, false);
20
+ target.addEventListener("visibilitychange", visibilityHandler, false);
20
21
  return () => {
21
- document.removeEventListener("visibilitychange", visibilityHandler, false);
22
+ target.removeEventListener("visibilitychange", visibilityHandler, false);
22
23
  };
23
24
  }
24
25
  };
@@ -26,5 +27,4 @@ function getGlobalFocusManager() {
26
27
  if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
27
28
  return globalThis[kFocusManager];
28
29
  }
29
- //#endregion
30
30
  export { getGlobalFocusManager, kFocusManager };
@@ -1,6 +1,3 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
2
- import { CamelCase, InferCtx, InferRoute, InferRoutes, InferSessionUpdateCtx, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest } from "./path-to-object.mjs";
3
- import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "./types.mjs";
4
1
  import { BroadcastChannel, BroadcastListener, BroadcastMessage, getGlobalBroadcastChannel, kBroadcastChannel } from "./broadcast-channel.mjs";
5
2
  import { isJsonEqual, withEquality } from "./equality.mjs";
6
3
  import { FocusListener, FocusManager, kFocusManager } from "./focus-manager.mjs";
@@ -8,23 +5,25 @@ import { OnlineListener, OnlineManager, kOnlineManager } from "./online-manager.
8
5
  import { parseJSON } from "./parser.mjs";
9
6
  import { AuthQueryAtom, AuthQueryState, useAuthQuery } from "./query.mjs";
10
7
  import { SessionRefreshOptions, createSessionRefreshManager } from "./session-refresh.mjs";
8
+ import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "./types.mjs";
11
9
  import { AuthClient, createAuthClient } from "./vanilla.mjs";
10
+ import "../plugins/access/index.mjs";
11
+ import "../plugins/organization/index.mjs";
12
12
  import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "../plugins/access/types.mjs";
13
13
  import { AuthorizeResponse, createAccessControl, role } from "../plugins/access/access.mjs";
14
- import "../plugins/access/index.mjs";
14
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
15
15
  import { OrganizationOptions } from "../plugins/organization/types.mjs";
16
16
  import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../plugins/organization/schema.mjs";
17
17
  import { getOrgAdapter } from "../plugins/organization/adapter.mjs";
18
18
  import { hasPermission } from "../plugins/organization/has-permission.mjs";
19
19
  import { parseRoles } from "../plugins/organization/roles.mjs";
20
20
  import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization } from "../plugins/organization/organization.mjs";
21
- import "../plugins/organization/index.mjs";
21
+ import { CamelCase, InferCtx, InferRoute, InferRoutes, InferSessionUpdateCtx, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest } from "./path-to-object.mjs";
22
22
  import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
23
23
  import { DBPrimitive } from "@better-auth/core/db";
24
24
  export type * from "@better-auth/core/db";
25
25
  export type * from "nanostores";
26
26
  export type * from "@better-fetch/fetch";
27
- //#region src/client/index.d.ts
28
27
  export declare const InferPlugin: <T extends BetterAuthPlugin>() => {
29
28
  id: "infer-server-plugin";
30
29
  version: string;
@@ -33,5 +32,4 @@ export declare const InferPlugin: <T extends BetterAuthPlugin>() => {
33
32
  export declare function InferAuth<O extends {
34
33
  options: BetterAuthOptions;
35
34
  }>(): O["options"];
36
- //#endregion
37
35
  export { type AccessControl, type ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, type AuthorizeResponse, type BetterAuthClientOptions, type BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, type CamelCase, type ClientAtomListener, type ClientStore, type DBPrimitive, type DefaultOrganizationPlugin, type DynamicAccessControlEndpoints, type ExactRoleStatements, type ExtractPluginField, type FocusListener, type FocusManager, type HasRequiredKeys, InferActions, InferAdditionalFromClient, InferClientAPI, type InferCtx, InferErrorCodes, type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, type InferPluginFieldFromTuple, type InferRoute, type InferRoutes, InferSessionFromClient, type InferSessionUpdateCtx, type InferSignUpEmailCtx, type InferTeam, InferUserFromClient, type InferUserUpdateCtx, type Invitation, type InvitationInput, type InvitationStatus, type IsAny, IsSignal, type Member, type MemberInput, type MergeRoutes, type OnlineListener, type OnlineManager, type Organization, type OrganizationCreator, type OrganizationEndpoints, type OrganizationInput, type OrganizationOptions, type OrganizationPlugin, type OrganizationRole, type OrganizationSchema, type OverrideMerge, type PathToObject, type Prettify, type PrettifyDeep, type ProxyRequest, type RequiredKeysOf, type Role, type RoleAuthorizeRequest, type RoleInput, type RoleStatements, SessionQueryParams, SessionRefreshOptions, type Statements, type StripEmptyObjects, type SubArray, type Subset, type Team, type TeamEndpoints, type TeamInput, type TeamMember, type TeamMemberInput, type UnionToIntersection, type createAccessControl, createAuthClient, createSessionRefreshManager, type defaultRolesSchema, getGlobalBroadcastChannel, type getOrgAdapter, type hasPermission, type invitationSchema, type invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, type memberSchema, type organization, type organizationRoleSchema, type organizationSchema, parseJSON, type parseRoles, type role, type roleSchema, type teamMemberSchema, type teamSchema, useAuthQuery, withEquality };