better-auth 1.7.0-beta.3 → 1.7.0-beta.5

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 (291) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +10 -1
  2. package/dist/api/dispatch.d.mts +34 -0
  3. package/dist/api/dispatch.mjs +272 -0
  4. package/dist/api/index.d.mts +45 -56
  5. package/dist/api/index.mjs +3 -2
  6. package/dist/api/middlewares/origin-check.mjs +1 -0
  7. package/dist/api/routes/account.d.mts +14 -27
  8. package/dist/api/routes/account.mjs +168 -151
  9. package/dist/api/routes/callback.mjs +89 -45
  10. package/dist/api/routes/email-verification.d.mts +1 -0
  11. package/dist/api/routes/email-verification.mjs +4 -3
  12. package/dist/api/routes/password.mjs +1 -1
  13. package/dist/api/routes/session.mjs +19 -12
  14. package/dist/api/routes/sign-in.d.mts +5 -0
  15. package/dist/api/routes/sign-in.mjs +44 -19
  16. package/dist/api/routes/sign-up.d.mts +1 -0
  17. package/dist/api/routes/sign-up.mjs +43 -35
  18. package/dist/api/routes/update-session.mjs +9 -3
  19. package/dist/api/routes/update-user.mjs +8 -8
  20. package/dist/api/state/oauth.d.mts +38 -2
  21. package/dist/api/state/oauth.mjs +35 -2
  22. package/dist/api/to-auth-endpoints.mjs +14 -265
  23. package/dist/auth/trusted-origins.mjs +60 -1
  24. package/dist/client/fetch-plugins.mjs +2 -1
  25. package/dist/client/index.d.mts +2 -2
  26. package/dist/client/lynx/index.d.mts +6 -5
  27. package/dist/client/parser.mjs +0 -1
  28. package/dist/client/plugins/index.d.mts +3 -17
  29. package/dist/client/plugins/index.mjs +1 -4
  30. package/dist/client/proxy.mjs +2 -1
  31. package/dist/client/react/index.d.mts +6 -5
  32. package/dist/client/solid/index.d.mts +6 -5
  33. package/dist/client/svelte/index.d.mts +6 -5
  34. package/dist/client/vanilla.d.mts +6 -5
  35. package/dist/client/vue/index.d.mts +6 -5
  36. package/dist/context/create-context.mjs +11 -15
  37. package/dist/context/helpers.mjs +3 -2
  38. package/dist/cookies/cookie-utils.d.mts +24 -1
  39. package/dist/cookies/cookie-utils.mjs +85 -22
  40. package/dist/cookies/index.d.mts +2 -3
  41. package/dist/cookies/index.mjs +46 -13
  42. package/dist/cookies/session-store.d.mts +1 -1
  43. package/dist/cookies/session-store.mjs +4 -23
  44. package/dist/db/get-migration.mjs +38 -5
  45. package/dist/db/index.d.mts +2 -2
  46. package/dist/db/index.mjs +3 -2
  47. package/dist/db/internal-adapter.mjs +203 -45
  48. package/dist/db/schema.d.mts +15 -2
  49. package/dist/db/schema.mjs +26 -1
  50. package/dist/db/to-zod.d.mts +2 -2
  51. package/dist/db/to-zod.mjs +1 -1
  52. package/dist/db/with-hooks.d.mts +1 -0
  53. package/dist/db/with-hooks.mjs +58 -1
  54. package/dist/index.d.mts +4 -4
  55. package/dist/index.mjs +2 -2
  56. package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/index.mjs +32 -0
  57. package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/linux.mjs +55 -0
  58. package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/macos.mjs +26 -0
  59. package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/termux.mjs +39 -0
  60. package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/windows.mjs +19 -0
  61. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs +845 -0
  62. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs +386 -0
  63. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs +320 -0
  64. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +62 -0
  65. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +190 -0
  66. package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/utils.mjs +2 -0
  67. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.mjs +29 -0
  68. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.mjs +42 -0
  69. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.mjs +67 -0
  70. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.mjs +23 -0
  71. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.mjs +22 -0
  72. package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.mjs +36 -0
  73. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.d.mts +292 -0
  74. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.mjs +127 -0
  75. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/index.d.mts +145 -0
  76. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.BQXMA5bH.d.mts +298 -0
  77. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.By9qWDAI.mjs +9 -0
  78. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.CipVM6lf.mjs +3549 -0
  79. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.D9ehKjSh.mjs +66 -0
  80. package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.DfCzGthR.mjs +227 -0
  81. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.mjs +224 -0
  82. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/command.mjs +52 -0
  83. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.mjs +54 -0
  84. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/kill.mjs +62 -0
  85. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/pipe.mjs +26 -0
  86. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/promise.mjs +32 -0
  87. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stdio.mjs +19 -0
  88. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.mjs +98 -0
  89. package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/verbose.mjs +15 -0
  90. package/dist/node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.d.mts +15 -0
  91. package/dist/node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs +220 -0
  92. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array-buffer.mjs +54 -0
  93. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array.mjs +2 -0
  94. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/buffer.mjs +14 -0
  95. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/contents.mjs +76 -0
  96. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/index.mjs +6 -0
  97. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/string.mjs +35 -0
  98. package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/utils.mjs +10 -0
  99. package/dist/node_modules/.pnpm/http-shutdown@1.2.2/node_modules/http-shutdown/index.mjs +76 -0
  100. package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/core.mjs +274 -0
  101. package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/main.mjs +44 -0
  102. package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/realtime.mjs +15 -0
  103. package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/signals.mjs +23 -0
  104. package/dist/node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.mjs +24 -0
  105. package/dist/node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.mjs +18 -0
  106. package/dist/node_modules/.pnpm/is-stream@3.0.0/node_modules/is-stream/index.mjs +9 -0
  107. package/dist/node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.mjs +20 -0
  108. package/dist/node_modules/.pnpm/is64bit@2.0.0/node_modules/is64bit/index.mjs +13 -0
  109. package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.mjs +47 -0
  110. package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.mjs +33 -0
  111. package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.mjs +33 -0
  112. package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/chunks/xdg-open.mjs +1070 -0
  113. package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/index.mjs +619 -0
  114. package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/shared/listhen.1c46e31d.d.mts +83 -0
  115. package/dist/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.mjs +38 -0
  116. package/dist/node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.mjs +38 -0
  117. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/aes.mjs +597 -0
  118. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/aesCipherSuites.mjs +195 -0
  119. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/asn1-validator.mjs +76 -0
  120. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/asn1.mjs +967 -0
  121. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/baseN.mjs +137 -0
  122. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/cipher.mjs +186 -0
  123. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/cipherModes.mjs +597 -0
  124. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/des.mjs +1187 -0
  125. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/ed25519.mjs +1029 -0
  126. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/forge.mjs +15 -0
  127. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/hmac.mjs +107 -0
  128. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/index.mjs +66 -0
  129. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/jsbn.mjs +1334 -0
  130. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/kem.mjs +146 -0
  131. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/log.mjs +241 -0
  132. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md.all.mjs +24 -0
  133. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md.mjs +18 -0
  134. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md5.mjs +324 -0
  135. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/mgf.mjs +20 -0
  136. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/mgf1.mjs +44 -0
  137. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/oids.mjs +154 -0
  138. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pbe.mjs +815 -0
  139. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pbkdf2.mjs +125 -0
  140. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pem.mjs +175 -0
  141. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs1.mjs +200 -0
  142. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs12.mjs +724 -0
  143. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs7.mjs +642 -0
  144. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs7asn1.mjs +405 -0
  145. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pki.mjs +101 -0
  146. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/prime.mjs +193 -0
  147. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/prng.mjs +290 -0
  148. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pss.mjs +141 -0
  149. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/random.mjs +141 -0
  150. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/rc2.mjs +538 -0
  151. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/rsa.mjs +1309 -0
  152. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha1.mjs +230 -0
  153. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha256.mjs +267 -0
  154. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha512.mjs +413 -0
  155. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/ssh.mjs +194 -0
  156. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/tls.mjs +3655 -0
  157. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/util.mjs +2117 -0
  158. package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/x509.mjs +2168 -0
  159. package/dist/node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.mjs +34 -0
  160. package/dist/node_modules/.pnpm/onetime@6.0.0/node_modules/onetime/index.mjs +26 -0
  161. package/dist/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.mjs +14 -0
  162. package/dist/node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.mjs +8 -0
  163. package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs +176 -0
  164. package/dist/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.mjs +17 -0
  165. package/dist/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.mjs +8 -0
  166. package/dist/node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.mjs +169 -0
  167. package/dist/node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.mjs +33 -0
  168. package/dist/node_modules/.pnpm/std-env@3.10.0/node_modules/std-env/dist/index.mjs +171 -0
  169. package/dist/node_modules/.pnpm/strip-final-newline@3.0.0/node_modules/strip-final-newline/index.mjs +10 -0
  170. package/dist/node_modules/.pnpm/system-architecture@0.1.0/node_modules/system-architecture/index.mjs +16 -0
  171. package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.node.mjs +7 -0
  172. package/dist/node_modules/.pnpm/untun@0.1.3/node_modules/untun/dist/chunks/index.mjs +154 -0
  173. package/dist/node_modules/.pnpm/untun@0.1.3/node_modules/untun/dist/index.mjs +34 -0
  174. package/dist/node_modules/.pnpm/uqr@0.1.2/node_modules/uqr/dist/index.mjs +896 -0
  175. package/dist/node_modules/.pnpm/which@2.0.2/node_modules/which/which.mjs +76 -0
  176. package/dist/oauth2/errors.mjs +36 -1
  177. package/dist/oauth2/index.d.mts +6 -4
  178. package/dist/oauth2/index.mjs +5 -3
  179. package/dist/oauth2/persist-account.d.mts +80 -0
  180. package/dist/oauth2/persist-account.mjs +84 -0
  181. package/dist/oauth2/resolve-account.d.mts +126 -0
  182. package/dist/oauth2/resolve-account.mjs +128 -0
  183. package/dist/oauth2/sign-in-with-oauth-identity.d.mts +83 -0
  184. package/dist/oauth2/sign-in-with-oauth-identity.mjs +133 -0
  185. package/dist/oauth2/state.d.mts +31 -5
  186. package/dist/oauth2/state.mjs +19 -9
  187. package/dist/oauth2/{utils.d.mts → token-encryption.d.mts} +1 -1
  188. package/dist/oauth2/{utils.mjs → token-encryption.mjs} +1 -1
  189. package/dist/{package.mjs → packages/better-auth/package.mjs} +1 -1
  190. package/dist/plugins/access/access.d.mts +3 -15
  191. package/dist/plugins/access/access.mjs +11 -6
  192. package/dist/plugins/access/index.d.mts +2 -2
  193. package/dist/plugins/access/types.d.mts +11 -4
  194. package/dist/plugins/admin/access/statement.d.mts +34 -98
  195. package/dist/plugins/admin/access/statement.mjs +2 -0
  196. package/dist/plugins/admin/admin.d.mts +6 -3
  197. package/dist/plugins/admin/admin.mjs +0 -4
  198. package/dist/plugins/admin/client.d.mts +7 -5
  199. package/dist/plugins/admin/error-codes.d.mts +2 -0
  200. package/dist/plugins/admin/error-codes.mjs +3 -1
  201. package/dist/plugins/admin/routes.mjs +70 -5
  202. package/dist/plugins/admin/schema.d.mts +1 -0
  203. package/dist/plugins/admin/schema.mjs +2 -1
  204. package/dist/plugins/anonymous/client.d.mts +1 -0
  205. package/dist/plugins/anonymous/error-codes.d.mts +1 -0
  206. package/dist/plugins/anonymous/error-codes.mjs +1 -0
  207. package/dist/plugins/anonymous/index.d.mts +5 -0
  208. package/dist/plugins/anonymous/index.mjs +97 -40
  209. package/dist/plugins/bearer/index.mjs +4 -9
  210. package/dist/plugins/captcha/index.mjs +2 -2
  211. package/dist/plugins/device-authorization/error-codes.mjs +1 -0
  212. package/dist/plugins/device-authorization/index.d.mts +1 -0
  213. package/dist/plugins/device-authorization/routes.mjs +34 -3
  214. package/dist/plugins/email-otp/routes.mjs +3 -3
  215. package/dist/plugins/generic-oauth/error-codes.mjs +0 -1
  216. package/dist/plugins/generic-oauth/index.d.mts +4 -6
  217. package/dist/plugins/generic-oauth/index.mjs +53 -23
  218. package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -0
  219. package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -0
  220. package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -0
  221. package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -0
  222. package/dist/plugins/generic-oauth/providers/line.mjs +1 -0
  223. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -0
  224. package/dist/plugins/generic-oauth/providers/okta.mjs +1 -0
  225. package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -0
  226. package/dist/plugins/generic-oauth/providers/slack.mjs +1 -0
  227. package/dist/plugins/generic-oauth/types.d.mts +43 -8
  228. package/dist/plugins/index.d.mts +2 -2
  229. package/dist/plugins/jwt/sign.d.mts +11 -0
  230. package/dist/plugins/jwt/sign.mjs +2 -1
  231. package/dist/plugins/jwt/types.d.mts +9 -1
  232. package/dist/plugins/jwt/utils.d.mts +1 -1
  233. package/dist/plugins/last-login-method/client.mjs +2 -2
  234. package/dist/plugins/magic-link/index.d.mts +8 -1
  235. package/dist/plugins/magic-link/index.mjs +18 -23
  236. package/dist/plugins/mcp/authorize.mjs +8 -2
  237. package/dist/plugins/mcp/index.mjs +75 -35
  238. package/dist/plugins/multi-session/index.mjs +2 -2
  239. package/dist/plugins/oauth-proxy/index.mjs +71 -34
  240. package/dist/plugins/oauth-proxy/utils.mjs +3 -10
  241. package/dist/plugins/oidc-provider/authorize.mjs +8 -2
  242. package/dist/plugins/oidc-provider/index.mjs +65 -38
  243. package/dist/plugins/one-tap/client.mjs +9 -2
  244. package/dist/plugins/one-tap/index.mjs +34 -36
  245. package/dist/plugins/open-api/generator.d.mts +4 -1
  246. package/dist/plugins/open-api/generator.mjs +30 -6
  247. package/dist/plugins/organization/access/statement.d.mts +68 -201
  248. package/dist/plugins/organization/adapter.mjs +63 -56
  249. package/dist/plugins/organization/client.d.mts +3 -1
  250. package/dist/plugins/organization/error-codes.d.mts +2 -0
  251. package/dist/plugins/organization/error-codes.mjs +3 -1
  252. package/dist/plugins/organization/organization.mjs +2 -0
  253. package/dist/plugins/organization/routes/crud-access-control.d.mts +3 -3
  254. package/dist/plugins/organization/routes/crud-invites.mjs +42 -2
  255. package/dist/plugins/organization/routes/crud-org.d.mts +4 -4
  256. package/dist/plugins/organization/routes/crud-org.mjs +2 -2
  257. package/dist/plugins/organization/routes/crud-team.mjs +13 -1
  258. package/dist/plugins/organization/schema.d.mts +2 -0
  259. package/dist/plugins/organization/types.d.mts +22 -5
  260. package/dist/plugins/phone-number/routes.mjs +2 -2
  261. package/dist/plugins/siwe/index.mjs +29 -1
  262. package/dist/plugins/siwe/parse-message.mjs +60 -0
  263. package/dist/plugins/test-utils/db-helpers.mjs +1 -1
  264. package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -3
  265. package/dist/plugins/two-factor/client.mjs +2 -1
  266. package/dist/plugins/two-factor/index.mjs +12 -3
  267. package/dist/plugins/username/index.d.mts +24 -2
  268. package/dist/plugins/username/index.mjs +49 -3
  269. package/dist/state.d.mts +19 -3
  270. package/dist/state.mjs +22 -6
  271. package/dist/test-utils/headers.mjs +2 -7
  272. package/dist/test-utils/http-test-instance.d.mts +418 -0
  273. package/dist/test-utils/http-test-instance.mjs +54 -0
  274. package/dist/test-utils/index.d.mts +2 -1
  275. package/dist/test-utils/index.mjs +2 -1
  276. package/dist/test-utils/test-instance.d.mts +180 -221
  277. package/dist/test-utils/test-instance.mjs +11 -2
  278. package/dist/types/index.d.mts +2 -2
  279. package/dist/utils/index.d.mts +2 -2
  280. package/dist/utils/url.d.mts +2 -1
  281. package/dist/utils/url.mjs +9 -3
  282. package/dist/utils/validate-user-info.mjs +44 -0
  283. package/dist/version.mjs +1 -1
  284. package/package.json +16 -16
  285. package/dist/oauth2/error-codes.d.mts +0 -20
  286. package/dist/oauth2/error-codes.mjs +0 -20
  287. package/dist/oauth2/link-account.d.mts +0 -46
  288. package/dist/oauth2/link-account.mjs +0 -139
  289. package/dist/plugins/generic-oauth/client.d.mts +0 -32
  290. package/dist/plugins/generic-oauth/client.mjs +0 -19
  291. package/dist/plugins/generic-oauth/error-codes.d.mts +0 -10
@@ -1,8 +1,12 @@
1
+ import { createRequire } from "node:module";
1
2
  //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
2
4
  var __defProp = Object.defineProperty;
3
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
5
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
6
10
  var __exportAll = (all, no_symbols) => {
7
11
  let target = {};
8
12
  for (var name in all) __defProp(target, name, {
@@ -23,5 +27,10 @@ var __copyProps = (to, from, except, desc) => {
23
27
  return to;
24
28
  };
25
29
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
26
35
  //#endregion
27
- export { __exportAll, __reExport };
36
+ export { __commonJSMin, __exportAll, __reExport, __require, __toESM };
@@ -0,0 +1,34 @@
1
+ import { AuthContext } from "@better-auth/core";
2
+ import { Endpoint, EndpointContext, InputContext } from "better-call";
3
+
4
+ //#region src/api/dispatch.d.ts
5
+ /**
6
+ * Input accepted by {@link dispatchAuthEndpoint}. `context` must already be a
7
+ * resolved `AuthContext`; the caller owns `baseURL` resolution. A fresh
8
+ * dispatch carries no `session` (the shared context has none), while a resumed
9
+ * dispatch carries the in-flight request's `session` through.
10
+ */
11
+ type DispatchContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
12
+ context: AuthContext & {
13
+ returned?: unknown | undefined;
14
+ responseHeaders?: Headers | undefined;
15
+ };
16
+ operationId?: string | undefined;
17
+ };
18
+ /**
19
+ * Run a single endpoint through the configured `hooks.before` / `hooks.after`
20
+ * pipeline, normalizing the response, headers, and `APIError`s the same way a
21
+ * router or `auth.api.*` dispatch does.
22
+ *
23
+ * This is the canonical hook runner. The HTTP router and `auth.api.*` reach it
24
+ * through {@link toAuthEndpoints}. Plugins call it directly when they need to
25
+ * re-enter the pipeline on purpose, such as resuming `/oauth2/authorize` after
26
+ * a fresh sign-in. Calling an endpoint as a plain function deliberately skips
27
+ * hooks; `dispatchAuthEndpoint` is the supported way to opt back in.
28
+ *
29
+ * @param endpoint The endpoint to dispatch.
30
+ * @param input Input context whose `context` is an already-resolved `AuthContext`.
31
+ */
32
+ declare function dispatchAuthEndpoint(endpoint: Endpoint, input: DispatchContext): Promise<unknown>;
33
+ //#endregion
34
+ export { DispatchContext, dispatchAuthEndpoint };
@@ -0,0 +1,272 @@
1
+ import { isAPIError } from "../utils/is-api-error.mjs";
2
+ import { isRequestLike } from "../utils/url.mjs";
3
+ import { runWithEndpointContext } from "@better-auth/core/context";
4
+ import { shouldPublishLog } from "@better-auth/core/env";
5
+ import { APIError } from "@better-auth/core/error";
6
+ import { createDefu } from "defu";
7
+ import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID, withSpan } from "@better-auth/core/instrumentation";
8
+ import { kAPIErrorHeaderSymbol, toResponse } from "better-call";
9
+ //#region src/api/dispatch.ts
10
+ const defuReplaceArrays = createDefu((obj, key, value) => {
11
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
12
+ obj[key] = value;
13
+ return true;
14
+ }
15
+ });
16
+ const hooksSourceWeakMap = /* @__PURE__ */ new WeakMap();
17
+ /**
18
+ * Resolves the operation id used for spans, preferring an explicit
19
+ * `operationId`, then the OpenAPI one, then the caller's `fallback` (the
20
+ * `auth.api.*` map key), and finally the route path.
21
+ */
22
+ function getOperationId(endpoint, fallback) {
23
+ const opts = endpoint.options;
24
+ return opts?.operationId ?? opts?.metadata?.openapi?.operationId ?? fallback ?? endpoint.path ?? "/:virtual";
25
+ }
26
+ /**
27
+ * Merge a set of response headers onto the dispatch's accumulator, appending
28
+ * `set-cookie` (multiple cookies are legal) and replacing everything else.
29
+ */
30
+ function mergeResponseHeaders(context, headers) {
31
+ if (!headers) return;
32
+ headers.forEach((value, key) => {
33
+ if (!context.responseHeaders) context.responseHeaders = new Headers({ [key]: value });
34
+ else if (key.toLowerCase() === "set-cookie") context.responseHeaders.append(key, value);
35
+ else context.responseHeaders.set(key, value);
36
+ });
37
+ }
38
+ /**
39
+ * Combine the two header sources an `APIError` can carry into one set:
40
+ * - `kAPIErrorHeaderSymbol`: `ctx.responseHeaders` accumulated via
41
+ * `c.setCookie` / `c.setHeader` before the throw.
42
+ * - `e.headers`: explicit headers on the error (e.g. `location` from
43
+ * `c.redirect`).
44
+ *
45
+ * `c.redirect()` reuses `ctx.responseHeaders` as `e.headers`, so when both
46
+ * point at the same object iterating each would duplicate every `set-cookie`;
47
+ * the identity check skips that copy. Explicit error headers override
48
+ * accumulated ones, while cookies from both accumulate.
49
+ */
50
+ function mergeAPIErrorHeaders(error) {
51
+ const ctxHeaders = error[kAPIErrorHeaderSymbol];
52
+ const errHeaders = error.headers && error.headers !== ctxHeaders ? new Headers(error.headers) : null;
53
+ if (!ctxHeaders && !errHeaders) return null;
54
+ const headers = new Headers();
55
+ ctxHeaders?.forEach((value, key) => {
56
+ headers.append(key, value);
57
+ });
58
+ errHeaders?.forEach((value, key) => {
59
+ if (key.toLowerCase() === "set-cookie") headers.append(key, value);
60
+ else headers.set(key, value);
61
+ });
62
+ return headers;
63
+ }
64
+ async function runBeforeHooks(context, hooks, endpoint, operationId) {
65
+ let modifiedContext = {};
66
+ for (const hook of hooks) {
67
+ let matched = false;
68
+ try {
69
+ matched = hook.matcher(context);
70
+ } catch (error) {
71
+ const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
72
+ context.context.logger.error(`An error occurred during ${hookSource} hook matcher execution:`, error);
73
+ throw new APIError("INTERNAL_SERVER_ERROR", { message: "An error occurred during hook matcher execution. Check the logs for more details." });
74
+ }
75
+ if (!matched) continue;
76
+ const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
77
+ const route = endpoint.path ?? "/:virtual";
78
+ const result = await withSpan(`hook before ${route} ${hookSource}`, {
79
+ [ATTR_HOOK_TYPE]: "before",
80
+ [ATTR_HTTP_ROUTE]: route,
81
+ [ATTR_CONTEXT]: hookSource,
82
+ [ATTR_OPERATION_ID]: operationId
83
+ }, () => hook.handler({
84
+ ...context,
85
+ returnHeaders: true
86
+ })).catch((e) => {
87
+ if (isAPIError(e) && shouldPublishLog(context.context.logger.level, "debug")) e.stack = e.errorStack;
88
+ throw e;
89
+ });
90
+ mergeResponseHeaders(context.context, result?.headers);
91
+ const hookReturn = result?.response;
92
+ if (hookReturn && typeof hookReturn === "object") {
93
+ if ("context" in hookReturn && typeof hookReturn.context === "object") {
94
+ const { headers, ...rest } = hookReturn.context;
95
+ if (headers instanceof Headers) if (modifiedContext.headers) headers.forEach((value, key) => {
96
+ modifiedContext.headers?.set(key, value);
97
+ });
98
+ else modifiedContext.headers = headers;
99
+ modifiedContext = defuReplaceArrays(rest, modifiedContext);
100
+ continue;
101
+ }
102
+ return hookReturn;
103
+ }
104
+ }
105
+ return { context: modifiedContext };
106
+ }
107
+ async function runAfterHooks(context, hooks, endpoint, operationId) {
108
+ for (const hook of hooks) {
109
+ if (!hook.matcher(context)) continue;
110
+ const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
111
+ const route = endpoint.path ?? "/:virtual";
112
+ const result = await withSpan(`hook after ${route} ${hookSource}`, {
113
+ [ATTR_HOOK_TYPE]: "after",
114
+ [ATTR_HTTP_ROUTE]: route,
115
+ [ATTR_CONTEXT]: hookSource,
116
+ [ATTR_OPERATION_ID]: operationId
117
+ }, () => hook.handler(context)).catch((e) => {
118
+ if (isAPIError(e)) {
119
+ if (shouldPublishLog(context.context.logger.level, "debug")) e.stack = e.errorStack;
120
+ return {
121
+ response: e,
122
+ headers: mergeAPIErrorHeaders(e)
123
+ };
124
+ }
125
+ throw e;
126
+ });
127
+ mergeResponseHeaders(context.context, result.headers);
128
+ if (result.response !== void 0) context.context.returned = result.response;
129
+ }
130
+ return {
131
+ response: context.context.returned,
132
+ headers: context.context.responseHeaders
133
+ };
134
+ }
135
+ function getHooks(authContext) {
136
+ const plugins = authContext.options.plugins || [];
137
+ const beforeHooks = [];
138
+ const afterHooks = [];
139
+ const beforeHookHandler = authContext.options.hooks?.before;
140
+ if (beforeHookHandler) {
141
+ hooksSourceWeakMap.set(beforeHookHandler, "user");
142
+ beforeHooks.push({
143
+ matcher: () => true,
144
+ handler: beforeHookHandler
145
+ });
146
+ }
147
+ const afterHookHandler = authContext.options.hooks?.after;
148
+ if (afterHookHandler) {
149
+ hooksSourceWeakMap.set(afterHookHandler, "user");
150
+ afterHooks.push({
151
+ matcher: () => true,
152
+ handler: afterHookHandler
153
+ });
154
+ }
155
+ const pluginBeforeHooks = plugins.flatMap((plugin) => (plugin.hooks?.before ?? []).map((h) => {
156
+ hooksSourceWeakMap.set(h.handler, `plugin:${plugin.id}`);
157
+ return h;
158
+ }));
159
+ const pluginAfterHooks = plugins.flatMap((plugin) => (plugin.hooks?.after ?? []).map((h) => {
160
+ hooksSourceWeakMap.set(h.handler, `plugin:${plugin.id}`);
161
+ return h;
162
+ }));
163
+ if (pluginBeforeHooks.length) beforeHooks.push(...pluginBeforeHooks);
164
+ if (pluginAfterHooks.length) afterHooks.push(...pluginAfterHooks);
165
+ return {
166
+ beforeHooks,
167
+ afterHooks
168
+ };
169
+ }
170
+ /**
171
+ * Run a single endpoint through the configured `hooks.before` / `hooks.after`
172
+ * pipeline, normalizing the response, headers, and `APIError`s the same way a
173
+ * router or `auth.api.*` dispatch does.
174
+ *
175
+ * This is the canonical hook runner. The HTTP router and `auth.api.*` reach it
176
+ * through {@link toAuthEndpoints}. Plugins call it directly when they need to
177
+ * re-enter the pipeline on purpose, such as resuming `/oauth2/authorize` after
178
+ * a fresh sign-in. Calling an endpoint as a plain function deliberately skips
179
+ * hooks; `dispatchAuthEndpoint` is the supported way to opt back in.
180
+ *
181
+ * @param endpoint The endpoint to dispatch.
182
+ * @param input Input context whose `context` is an already-resolved `AuthContext`.
183
+ */
184
+ async function dispatchAuthEndpoint(endpoint, input) {
185
+ const operationId = input.operationId ?? getOperationId(endpoint);
186
+ const route = endpoint.path ?? "/:virtual";
187
+ const endpointMethod = endpoint.options?.method;
188
+ const defaultMethod = Array.isArray(endpointMethod) ? endpointMethod[0] : endpointMethod;
189
+ const methodName = input.method ?? input.request?.method ?? defaultMethod ?? "?";
190
+ const shouldReturnResponse = input.asResponse ?? isRequestLike(input.request);
191
+ let internalContext = {
192
+ ...input,
193
+ context: {
194
+ ...input.context,
195
+ returned: void 0,
196
+ responseHeaders: void 0,
197
+ session: input.context.session ?? null
198
+ },
199
+ path: endpoint.path,
200
+ headers: input.headers ? new Headers(input.headers) : void 0
201
+ };
202
+ return withSpan(`${methodName} ${route}`, {
203
+ [ATTR_HTTP_ROUTE]: route,
204
+ [ATTR_OPERATION_ID]: operationId
205
+ }, async () => runWithEndpointContext(internalContext, async () => {
206
+ const { beforeHooks, afterHooks } = getHooks(internalContext.context);
207
+ const before = await runBeforeHooks(internalContext, beforeHooks, endpoint, operationId);
208
+ if ("context" in before && before.context && typeof before.context === "object") {
209
+ const { headers, ...rest } = before.context;
210
+ if (headers) {
211
+ if (!internalContext.headers) internalContext.headers = new Headers();
212
+ const requestHeaders = internalContext.headers;
213
+ headers.forEach((value, key) => {
214
+ requestHeaders.set(key, value);
215
+ });
216
+ }
217
+ internalContext = defuReplaceArrays(rest, internalContext);
218
+ } else if (before) {
219
+ const responseHeaders = internalContext.context.responseHeaders;
220
+ return shouldReturnResponse ? toResponse(before, { headers: responseHeaders }) : input.returnHeaders ? {
221
+ headers: responseHeaders,
222
+ response: before
223
+ } : before;
224
+ }
225
+ internalContext.asResponse = false;
226
+ internalContext.returnHeaders = true;
227
+ internalContext.returnStatus = true;
228
+ const result = await runWithEndpointContext(internalContext, () => withSpan(`handler ${route}`, {
229
+ [ATTR_HTTP_ROUTE]: route,
230
+ [ATTR_OPERATION_ID]: operationId
231
+ }, () => endpoint(internalContext))).catch((e) => {
232
+ if (isAPIError(e)) return {
233
+ response: e,
234
+ status: e.statusCode,
235
+ headers: mergeAPIErrorHeaders(e)
236
+ };
237
+ throw e;
238
+ });
239
+ if (result instanceof Response) return result;
240
+ internalContext.context.returned = result.response;
241
+ internalContext.context.responseHeaders = result.headers ?? void 0;
242
+ const after = await runAfterHooks(internalContext, afterHooks, endpoint, operationId);
243
+ if (after.response !== void 0) result.response = after.response;
244
+ result.headers = after.headers ?? result.headers;
245
+ if (isAPIError(result.response) && shouldPublishLog(internalContext.context.logger.level, "debug")) result.response.stack = result.response.errorStack;
246
+ if (isAPIError(result.response) && !shouldReturnResponse) {
247
+ if (result.headers) Object.defineProperty(result.response, kAPIErrorHeaderSymbol, {
248
+ enumerable: false,
249
+ configurable: true,
250
+ writable: false,
251
+ value: result.headers
252
+ });
253
+ throw result.response;
254
+ }
255
+ return shouldReturnResponse ? toResponse(result.response, {
256
+ headers: result.headers ?? void 0,
257
+ status: result.status
258
+ }) : input.returnHeaders ? input.returnStatus ? {
259
+ headers: result.headers,
260
+ response: result.response,
261
+ status: result.status
262
+ } : {
263
+ headers: result.headers,
264
+ response: result.response
265
+ } : input.returnStatus ? {
266
+ response: result.response,
267
+ status: result.status
268
+ } : result.response;
269
+ }));
270
+ }
271
+ //#endregion
272
+ export { dispatchAuthEndpoint, getOperationId };
@@ -2,6 +2,7 @@ import { OverrideMerge, Prettify as Prettify$1, UnionToIntersection } from "../t
2
2
  import { AdditionalSessionFieldsInput, AdditionalUserFieldsInput } from "../types/models.mjs";
3
3
  import { getIp } from "../utils/get-request-ip.mjs";
4
4
  import { isAPIError } from "../utils/is-api-error.mjs";
5
+ import { DispatchContext, dispatchAuthEndpoint } from "./dispatch.mjs";
5
6
  import { requireOrgRole, requireResourceOwnership } from "./middlewares/authorization.mjs";
6
7
  import { formCsrfMiddleware, originCheck, originCheckMiddleware } from "./middlewares/origin-check.mjs";
7
8
  import { accountInfo, getAccessToken, linkSocialAccount, listUserAccounts, refreshToken, unlinkAccount } from "./routes/account.mjs";
@@ -16,7 +17,7 @@ import { signOut } from "./routes/sign-out.mjs";
16
17
  import { signUpEmail } from "./routes/sign-up.mjs";
17
18
  import { updateSession } from "./routes/update-session.mjs";
18
19
  import { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser } from "./routes/update-user.mjs";
19
- import { getOAuthState } from "./state/oauth.mjs";
20
+ import { addOAuthServerContext, getOAuthState } from "./state/oauth.mjs";
20
21
  import { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh } from "./state/should-session-refresh.mjs";
21
22
  import { AuthContext, Awaitable, BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
22
23
  import * as _better_auth_core_db0 from "@better-auth/core/db";
@@ -99,6 +100,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
99
100
  accessToken: zod.ZodOptional<zod.ZodString>;
100
101
  refreshToken: zod.ZodOptional<zod.ZodString>;
101
102
  expiresAt: zod.ZodOptional<zod.ZodNumber>;
103
+ scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
102
104
  user: zod.ZodOptional<zod.ZodObject<{
103
105
  name: zod.ZodOptional<zod.ZodObject<{
104
106
  firstName: zod.ZodOptional<zod.ZodString>;
@@ -110,6 +112,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
110
112
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
111
113
  requestSignUp: zod.ZodOptional<zod.ZodBoolean>;
112
114
  loginHint: zod.ZodOptional<zod.ZodString>;
115
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
113
116
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
114
117
  }, zod_v4_core0.$strip>;
115
118
  metadata: {
@@ -126,6 +129,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
126
129
  accessToken: zod.ZodOptional<zod.ZodString>;
127
130
  refreshToken: zod.ZodOptional<zod.ZodString>;
128
131
  expiresAt: zod.ZodOptional<zod.ZodNumber>;
132
+ scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
129
133
  user: zod.ZodOptional<zod.ZodObject<{
130
134
  name: zod.ZodOptional<zod.ZodObject<{
131
135
  firstName: zod.ZodOptional<zod.ZodString>;
@@ -137,6 +141,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
137
141
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
138
142
  requestSignUp: zod.ZodOptional<zod.ZodBoolean>;
139
143
  loginHint: zod.ZodOptional<zod.ZodString>;
144
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
140
145
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
141
146
  }, zod_v4_core0.$strip>>;
142
147
  returned: {
@@ -329,6 +334,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
329
334
  callbackURL: zod.ZodOptional<zod.ZodString>;
330
335
  rememberMe: zod.ZodOptional<zod.ZodBoolean>;
331
336
  }, zod_v4_core0.$strip>, zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
337
+ cloneRequest: true;
332
338
  metadata: {
333
339
  allowedMediaTypes: string[];
334
340
  $Infer: {
@@ -495,6 +501,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
495
501
  method: "POST";
496
502
  operationId: string;
497
503
  use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
504
+ cloneRequest: true;
498
505
  body: zod.ZodObject<{
499
506
  email: zod.ZodString;
500
507
  password: zod.ZodString;
@@ -726,6 +733,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
726
733
  readonly sendVerificationEmail: better_call0.StrictEndpoint<"/send-verification-email", {
727
734
  method: "POST";
728
735
  operationId: string;
736
+ cloneRequest: true;
729
737
  body: zod.ZodObject<{
730
738
  email: zod.ZodEmail;
731
739
  callbackURL: zod.ZodOptional<zod.ZodString>;
@@ -1582,6 +1590,8 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1582
1590
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
1583
1591
  errorCallbackURL: zod.ZodOptional<zod.ZodString>;
1584
1592
  disableRedirect: zod.ZodOptional<zod.ZodBoolean>;
1593
+ loginHint: zod.ZodOptional<zod.ZodString>;
1594
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
1585
1595
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
1586
1596
  }, zod_v4_core0.$strip>;
1587
1597
  use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
@@ -1702,7 +1712,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1702
1712
  userId: {
1703
1713
  type: string;
1704
1714
  };
1705
- scopes: {
1715
+ grantedScopes: {
1706
1716
  type: string;
1707
1717
  items: {
1708
1718
  type: string;
@@ -1719,7 +1729,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1719
1729
  };
1720
1730
  };
1721
1731
  }, {
1722
- scopes: string[];
1732
+ grantedScopes: string[];
1723
1733
  id: string;
1724
1734
  createdAt: Date;
1725
1735
  updatedAt: Date;
@@ -1859,6 +1869,12 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1859
1869
  type: string;
1860
1870
  format: string;
1861
1871
  };
1872
+ grantedScopes: {
1873
+ type: string;
1874
+ items: {
1875
+ type: string;
1876
+ };
1877
+ };
1862
1878
  };
1863
1879
  };
1864
1880
  };
@@ -1875,7 +1891,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1875
1891
  refreshToken: string;
1876
1892
  accessTokenExpiresAt: Date | undefined;
1877
1893
  refreshTokenExpiresAt: Date | null | undefined;
1878
- scope: string | null | undefined;
1894
+ grantedScopes: string[];
1879
1895
  idToken: string | null | undefined;
1880
1896
  providerId: string;
1881
1897
  accountId: string;
@@ -1925,34 +1941,11 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1925
1941
  }, {
1926
1942
  accessToken: string;
1927
1943
  accessTokenExpiresAt: Date | undefined;
1928
- scopes: string[];
1944
+ grantedScopes: string[];
1929
1945
  idToken: string | undefined;
1930
1946
  }>;
1931
1947
  readonly accountInfo: better_call0.StrictEndpoint<"/account-info", {
1932
1948
  method: "GET";
1933
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
1934
- session: {
1935
- session: Record<string, any> & {
1936
- id: string;
1937
- createdAt: Date;
1938
- updatedAt: Date;
1939
- userId: string;
1940
- expiresAt: Date;
1941
- token: string;
1942
- ipAddress?: string | null | undefined;
1943
- userAgent?: string | null | undefined;
1944
- };
1945
- user: Record<string, any> & {
1946
- id: string;
1947
- createdAt: Date;
1948
- updatedAt: Date;
1949
- email: string;
1950
- emailVerified: boolean;
1951
- name: string;
1952
- image?: string | null | undefined;
1953
- };
1954
- };
1955
- }>)[];
1956
1949
  metadata: {
1957
1950
  openapi: {
1958
1951
  description: string;
@@ -2002,6 +1995,8 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
2002
1995
  };
2003
1996
  query: zod.ZodOptional<zod.ZodObject<{
2004
1997
  accountId: zod.ZodOptional<zod.ZodString>;
1998
+ providerId: zod.ZodOptional<zod.ZodString>;
1999
+ userId: zod.ZodOptional<zod.ZodString>;
2005
2000
  }, zod_v4_core0.$strip>>;
2006
2001
  }, {
2007
2002
  user: _better_auth_core_oauth20.OAuth2UserInfo;
@@ -2089,6 +2084,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2089
2084
  accessToken: zod.ZodOptional<zod.ZodString>;
2090
2085
  refreshToken: zod.ZodOptional<zod.ZodString>;
2091
2086
  expiresAt: zod.ZodOptional<zod.ZodNumber>;
2087
+ scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
2092
2088
  user: zod.ZodOptional<zod.ZodObject<{
2093
2089
  name: zod.ZodOptional<zod.ZodObject<{
2094
2090
  firstName: zod.ZodOptional<zod.ZodString>;
@@ -2100,6 +2096,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2100
2096
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
2101
2097
  requestSignUp: zod.ZodOptional<zod.ZodBoolean>;
2102
2098
  loginHint: zod.ZodOptional<zod.ZodString>;
2099
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
2103
2100
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
2104
2101
  }, zod_v4_core0.$strip>;
2105
2102
  metadata: {
@@ -2116,6 +2113,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2116
2113
  accessToken: zod.ZodOptional<zod.ZodString>;
2117
2114
  refreshToken: zod.ZodOptional<zod.ZodString>;
2118
2115
  expiresAt: zod.ZodOptional<zod.ZodNumber>;
2116
+ scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
2119
2117
  user: zod.ZodOptional<zod.ZodObject<{
2120
2118
  name: zod.ZodOptional<zod.ZodObject<{
2121
2119
  firstName: zod.ZodOptional<zod.ZodString>;
@@ -2127,6 +2125,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2127
2125
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
2128
2126
  requestSignUp: zod.ZodOptional<zod.ZodBoolean>;
2129
2127
  loginHint: zod.ZodOptional<zod.ZodString>;
2128
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
2130
2129
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
2131
2130
  }, zod_v4_core0.$strip>>;
2132
2131
  returned: {
@@ -2319,6 +2318,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2319
2318
  callbackURL: zod.ZodOptional<zod.ZodString>;
2320
2319
  rememberMe: zod.ZodOptional<zod.ZodBoolean>;
2321
2320
  }, zod_v4_core0.$strip>, zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
2321
+ cloneRequest: true;
2322
2322
  metadata: {
2323
2323
  allowedMediaTypes: string[];
2324
2324
  $Infer: {
@@ -2485,6 +2485,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2485
2485
  method: "POST";
2486
2486
  operationId: string;
2487
2487
  use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
2488
+ cloneRequest: true;
2488
2489
  body: zod.ZodObject<{
2489
2490
  email: zod.ZodString;
2490
2491
  password: zod.ZodString;
@@ -2716,6 +2717,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2716
2717
  readonly sendVerificationEmail: better_call0.StrictEndpoint<"/send-verification-email", {
2717
2718
  method: "POST";
2718
2719
  operationId: string;
2720
+ cloneRequest: true;
2719
2721
  body: zod.ZodObject<{
2720
2722
  email: zod.ZodEmail;
2721
2723
  callbackURL: zod.ZodOptional<zod.ZodString>;
@@ -3572,6 +3574,8 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3572
3574
  scopes: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
3573
3575
  errorCallbackURL: zod.ZodOptional<zod.ZodString>;
3574
3576
  disableRedirect: zod.ZodOptional<zod.ZodBoolean>;
3577
+ loginHint: zod.ZodOptional<zod.ZodString>;
3578
+ additionalParams: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
3575
3579
  additionalData: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
3576
3580
  }, zod_v4_core0.$strip>;
3577
3581
  use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
@@ -3692,7 +3696,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3692
3696
  userId: {
3693
3697
  type: string;
3694
3698
  };
3695
- scopes: {
3699
+ grantedScopes: {
3696
3700
  type: string;
3697
3701
  items: {
3698
3702
  type: string;
@@ -3709,7 +3713,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3709
3713
  };
3710
3714
  };
3711
3715
  }, {
3712
- scopes: string[];
3716
+ grantedScopes: string[];
3713
3717
  id: string;
3714
3718
  createdAt: Date;
3715
3719
  updatedAt: Date;
@@ -3849,6 +3853,12 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3849
3853
  type: string;
3850
3854
  format: string;
3851
3855
  };
3856
+ grantedScopes: {
3857
+ type: string;
3858
+ items: {
3859
+ type: string;
3860
+ };
3861
+ };
3852
3862
  };
3853
3863
  };
3854
3864
  };
@@ -3865,7 +3875,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3865
3875
  refreshToken: string;
3866
3876
  accessTokenExpiresAt: Date | undefined;
3867
3877
  refreshTokenExpiresAt: Date | null | undefined;
3868
- scope: string | null | undefined;
3878
+ grantedScopes: string[];
3869
3879
  idToken: string | null | undefined;
3870
3880
  providerId: string;
3871
3881
  accountId: string;
@@ -3915,34 +3925,11 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3915
3925
  }, {
3916
3926
  accessToken: string;
3917
3927
  accessTokenExpiresAt: Date | undefined;
3918
- scopes: string[];
3928
+ grantedScopes: string[];
3919
3929
  idToken: string | undefined;
3920
3930
  }>;
3921
3931
  readonly accountInfo: better_call0.StrictEndpoint<"/account-info", {
3922
3932
  method: "GET";
3923
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
3924
- session: {
3925
- session: Record<string, any> & {
3926
- id: string;
3927
- createdAt: Date;
3928
- updatedAt: Date;
3929
- userId: string;
3930
- expiresAt: Date;
3931
- token: string;
3932
- ipAddress?: string | null | undefined;
3933
- userAgent?: string | null | undefined;
3934
- };
3935
- user: Record<string, any> & {
3936
- id: string;
3937
- createdAt: Date;
3938
- updatedAt: Date;
3939
- email: string;
3940
- emailVerified: boolean;
3941
- name: string;
3942
- image?: string | null | undefined;
3943
- };
3944
- };
3945
- }>)[];
3946
3933
  metadata: {
3947
3934
  openapi: {
3948
3935
  description: string;
@@ -3992,6 +3979,8 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3992
3979
  };
3993
3980
  query: zod.ZodOptional<zod.ZodObject<{
3994
3981
  accountId: zod.ZodOptional<zod.ZodString>;
3982
+ providerId: zod.ZodOptional<zod.ZodString>;
3983
+ userId: zod.ZodOptional<zod.ZodString>;
3995
3984
  }, zod_v4_core0.$strip>>;
3996
3985
  }, {
3997
3986
  user: _better_auth_core_oauth20.OAuth2UserInfo;
@@ -4000,4 +3989,4 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
4000
3989
  } extends infer T_2 ? { [K in keyof T_2 as K extends keyof T_1 ? never : K]: T_2[K] } : never) & T_1> : never : never : never;
4001
3990
  };
4002
3991
  //#endregion
4003
- export { APIError, type AuthEndpoint, type AuthMiddleware, accountInfo, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, error, formCsrfMiddleware, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, getShouldSkipSessionRefresh, isAPIError, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, requireOrgRole, requireResourceOwnership, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, setShouldSkipSessionRefresh, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
3992
+ export { APIError, type AuthEndpoint, type AuthMiddleware, type DispatchContext, accountInfo, addOAuthServerContext, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, dispatchAuthEndpoint, error, formCsrfMiddleware, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, getShouldSkipSessionRefresh, isAPIError, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, requireOrgRole, requireResourceOwnership, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, setShouldSkipSessionRefresh, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
@@ -3,7 +3,7 @@ import { requireOrgRole, requireResourceOwnership } from "./middlewares/authoriz
3
3
  import { formCsrfMiddleware, originCheck, originCheckMiddleware } from "./middlewares/origin-check.mjs";
4
4
  import { getIp } from "../utils/get-request-ip.mjs";
5
5
  import { onRequestRateLimit, onResponseRateLimit } from "./rate-limiter/index.mjs";
6
- import { getOAuthState } from "./state/oauth.mjs";
6
+ import { addOAuthServerContext, getOAuthState } from "./state/oauth.mjs";
7
7
  import { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh } from "./state/should-session-refresh.mjs";
8
8
  import { freshSessionMiddleware, getSession, getSessionFromCtx, listSessions, requestOnlySessionMiddleware, revokeOtherSessions, revokeSession, revokeSessions, sensitiveSessionMiddleware, sessionMiddleware } from "./routes/session.mjs";
9
9
  import { accountInfo, getAccessToken, linkSocialAccount, listUserAccounts, refreshToken, unlinkAccount } from "./routes/account.mjs";
@@ -17,6 +17,7 @@ import { signOut } from "./routes/sign-out.mjs";
17
17
  import { signUpEmail } from "./routes/sign-up.mjs";
18
18
  import { updateSession } from "./routes/update-session.mjs";
19
19
  import { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser } from "./routes/update-user.mjs";
20
+ import { dispatchAuthEndpoint } from "./dispatch.mjs";
20
21
  import { toAuthEndpoints } from "./to-auth-endpoints.mjs";
21
22
  import { logger } from "@better-auth/core/env";
22
23
  import { APIError } from "@better-auth/core/error";
@@ -213,4 +214,4 @@ const router = (ctx, options) => {
213
214
  });
214
215
  };
215
216
  //#endregion
216
- export { APIError, accountInfo, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, error, formCsrfMiddleware, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, getShouldSkipSessionRefresh, isAPIError, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, requireOrgRole, requireResourceOwnership, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, setShouldSkipSessionRefresh, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
217
+ export { APIError, accountInfo, addOAuthServerContext, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, dispatchAuthEndpoint, error, formCsrfMiddleware, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, getShouldSkipSessionRefresh, isAPIError, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, requireOrgRole, requireResourceOwnership, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, setShouldSkipSessionRefresh, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };