better-auth 1.7.20 → 1.7.22

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 (441) 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 +5 -4
  7. package/dist/api/index.mjs +9 -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 +26 -16
  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 +10 -13
  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 +25 -11
  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 +18 -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 +1 -6
  240. package/dist/plugins/generic-oauth/index.mjs +43 -30
  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 +6 -5
  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 +6 -7
  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 +2 -7
  405. package/dist/state.mjs +3 -7
  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 +5 -6
  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/hide-metadata.d.mts +2 -5
  424. package/dist/utils/hide-metadata.mjs +1 -4
  425. package/dist/utils/index.d.mts +1 -1
  426. package/dist/utils/is-atom.mjs +1 -2
  427. package/dist/utils/is-promise.mjs +1 -2
  428. package/dist/utils/middleware-response.mjs +1 -2
  429. package/dist/utils/password.mjs +1 -2
  430. package/dist/utils/plugin-helper.mjs +1 -2
  431. package/dist/utils/request.mjs +1 -2
  432. package/dist/utils/shim.mjs +1 -2
  433. package/dist/utils/time.d.mts +0 -2
  434. package/dist/utils/time.mjs +1 -2
  435. package/dist/utils/url.d.mts +1 -3
  436. package/dist/utils/url.mjs +1 -2
  437. package/dist/utils/validate-user-info.mjs +1 -2
  438. package/dist/utils/wildcard.mjs +1 -2
  439. package/dist/version.mjs +1 -2
  440. package/package.json +10 -10
  441. package/dist/utils/boolean.mjs +0 -6
@@ -1,4 +1,3 @@
1
- import { toBoolean } from "../../utils/boolean.mjs";
2
1
  import { PACKAGE_VERSION } from "../../version.mjs";
3
2
  import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes.mjs";
4
3
  import { auth0 } from "./providers/auth0.mjs";
@@ -12,11 +11,11 @@ import { patreon } from "./providers/patreon.mjs";
12
11
  import { slack } from "./providers/slack.mjs";
13
12
  import { yandex } from "./providers/yandex.mjs";
14
13
  import { APIError } from "@better-auth/core/error";
15
- import { applyDefaultAccessTokenExpiry, createAuthorizationURL, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
14
+ import { applyDefaultAccessTokenExpiry, createAuthorizationURL, parseStringBoolean, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
16
15
  import { createAuthMiddleware } from "@better-auth/core/api";
17
16
  import { createRemoteJWKSet, decodeJwt } from "jose";
18
17
  import { betterFetch } from "@better-fetch/fetch";
19
- //#region src/plugins/generic-oauth/index.ts
18
+ // src/plugins/generic-oauth/index.ts
20
19
  function isSecretlessTokenEndpointAuth(tokenEndpointAuth) {
21
20
  return tokenEndpointAuth?.method === "private_key_jwt" || tokenEndpointAuth?.method === "none";
22
21
  }
@@ -25,6 +24,7 @@ function isClientSecretTokenEndpointAuth(tokenEndpointAuth) {
25
24
  }
26
25
  /** A request waits on a discovery retry, so bound it (the SSO plugin uses 10s too). */
27
26
  const DISCOVERY_RETRY_TIMEOUT_MS = 1e4;
27
+ const MAX_DISCOVERY_REDIRECTS = 5;
28
28
  /**
29
29
  * Providers skipped because startup discovery failed. Init stores them on each auth
30
30
  * instance's context, so one plugin object can serve several instances. It is a context
@@ -44,25 +44,42 @@ const readIdTokenClaims = (idToken) => {
44
44
  }
45
45
  };
46
46
  async function fetchDiscovery(url, headers, timeout) {
47
- const result = await betterFetch(url, {
48
- method: "GET",
49
- headers,
50
- signal: timeout ? AbortSignal.timeout(timeout) : void 0
51
- });
52
- if (result.error || !result.data) return null;
53
- if (result.data.issuer) try {
54
- new URL(result.data.issuer);
55
- } catch {
56
- return null;
47
+ const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
48
+ let target = url;
49
+ for (let hop = 0;; hop++) {
50
+ const redirect = {};
51
+ const result = await betterFetch(target, {
52
+ method: "GET",
53
+ headers,
54
+ redirect: headers ? "manual" : void 0,
55
+ signal,
56
+ onError: ({ response }) => {
57
+ if (response.status >= 300 && response.status < 400) redirect.location = response.headers.get("location");
58
+ }
59
+ });
60
+ if (headers && redirect.location) {
61
+ const next = new URL(redirect.location, target);
62
+ if (next.origin !== new URL(url).origin) throw new Error(`discovery redirected to ${next.origin}; with discoveryHeaders set, only same-origin redirects are followed. Set discoveryUrl to the final URL.`);
63
+ if (hop >= MAX_DISCOVERY_REDIRECTS) throw new Error(`discovery redirected more than ${MAX_DISCOVERY_REDIRECTS} times. Set discoveryUrl to the final URL.`);
64
+ target = next.href;
65
+ continue;
66
+ }
67
+ if (headers && result.error?.status === 0) throw new Error("discovery redirected; with discoveryHeaders set, set discoveryUrl to the final URL.");
68
+ if (result.error || !result.data) return null;
69
+ if (result.data.issuer) try {
70
+ new URL(result.data.issuer);
71
+ } catch {
72
+ return null;
73
+ }
74
+ return result.data;
57
75
  }
58
- return result.data;
59
76
  }
60
77
  async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
61
78
  if (tokens.idToken) {
62
79
  const decoded = idTokenClaims ?? readIdTokenClaims(tokens.idToken);
63
80
  if (decoded?.sub && decoded?.email) return {
64
81
  id: decoded.sub,
65
- emailVerified: toBoolean(decoded.email_verified),
82
+ emailVerified: parseStringBoolean(decoded.email_verified) ?? false,
66
83
  image: decoded.picture,
67
84
  ...decoded
68
85
  };
@@ -76,7 +93,7 @@ async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
76
93
  return {
77
94
  ...userInfo.data,
78
95
  email: userInfo.data.email,
79
- emailVerified: toBoolean(userInfo.data.email_verified),
96
+ emailVerified: parseStringBoolean(userInfo.data.email_verified) ?? false,
80
97
  image: userInfo.data.picture,
81
98
  name: userInfo.data.name
82
99
  };
@@ -128,8 +145,9 @@ const genericOAuth = (options) => {
128
145
  ctx.logger.error(`Provider "${c.providerId}": invalid jwks_uri "${discovered.jwks_uri}" in discovery document. Provider skipped.`);
129
146
  continue;
130
147
  }
148
+ const jwksHeaders = jwksUrl.origin === new URL(c.discoveryUrl).origin ? c.discoveryHeaders : void 0;
131
149
  idTokenConfig = {
132
- jwks: createRemoteJWKSet(jwksUrl),
150
+ jwks: createRemoteJWKSet(jwksUrl, jwksHeaders && { headers: jwksHeaders }),
133
151
  issuer: discovered.issuer,
134
152
  audience: c.clientId,
135
153
  algorithms: isOidc ? signingAlgs : void 0
@@ -160,7 +178,7 @@ const genericOAuth = (options) => {
160
178
  const mapped = c.mapProfileToUser ? await c.mapProfileToUser(raw) : {};
161
179
  const user = {
162
180
  email: raw.email,
163
- emailVerified: toBoolean(raw.emailVerified),
181
+ emailVerified: parseStringBoolean(raw.emailVerified) ?? false,
164
182
  image: raw.image,
165
183
  name: raw.name,
166
184
  ...mapped
@@ -287,7 +305,8 @@ const genericOAuth = (options) => {
287
305
  authentication: c.authentication,
288
306
  tokenEndpointAuth,
289
307
  tokenEndpoint: tokenUrl,
290
- extraParams: resolvedRefreshParams
308
+ extraParams: resolvedRefreshParams,
309
+ headers: c.authorizationHeaders
291
310
  });
292
311
  return applyDefaultAccessTokenExpiry(tokens, c.accessTokenExpiresIn);
293
312
  },
@@ -303,18 +322,13 @@ const genericOAuth = (options) => {
303
322
  }
304
323
  return genericProviders;
305
324
  };
306
- const retryDiscovery = (ctx, providerId) => {
325
+ const retryDiscovery = async (ctx, providerId) => {
307
326
  const pendingDiscovery = getPendingDiscovery(ctx);
308
327
  const pending = pendingDiscovery?.get(providerId);
309
328
  if (!pending) return;
310
- pending.attempt ??= buildProviders([pending.config], ctx, DISCOVERY_RETRY_TIMEOUT_MS).then(([provider]) => {
311
- if (!provider) return;
312
- pendingDiscovery?.delete(providerId);
313
- ctx.socialProviders.unshift(provider);
314
- }).finally(() => {
315
- pending.attempt = void 0;
316
- });
317
- return pending.attempt;
329
+ const [provider] = await buildProviders([pending], ctx, DISCOVERY_RETRY_TIMEOUT_MS);
330
+ if (!provider || !pendingDiscovery?.delete(providerId)) return;
331
+ ctx.socialProviders.unshift(provider);
318
332
  };
319
333
  const requestedProviderId = (context) => {
320
334
  const id = context.body?.provider ?? context.body?.providerId ?? context.query?.provider ?? context.params?.id;
@@ -326,7 +340,7 @@ const genericOAuth = (options) => {
326
340
  init: async (ctx) => {
327
341
  const genericProviders = await buildProviders(options.config, ctx);
328
342
  const built = new Set(genericProviders.map((p) => p.id));
329
- const genericOAuthPendingDiscovery = new Map(options.config.filter((c) => !built.has(c.providerId)).map((c) => [c.providerId, { config: c }]));
343
+ const genericOAuthPendingDiscovery = new Map(options.config.filter((c) => !built.has(c.providerId)).map((c) => [c.providerId, c]));
330
344
  const existingIds = new Set(ctx.socialProviders.map((p) => p.id));
331
345
  for (const gp of genericProviders) if (existingIds.has(gp.id)) ctx.logger.warn(`Generic OAuth provider "${gp.id}" shadows a built-in social provider with the same ID`);
332
346
  return { context: {
@@ -344,5 +358,4 @@ const genericOAuth = (options) => {
344
358
  $ERROR_CODES: GENERIC_OAUTH_ERROR_CODES
345
359
  };
346
360
  };
347
- //#endregion
348
361
  export { auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/auth0.d.ts
4
3
  export interface Auth0Options extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * Auth0 domain (e.g., dev-xxx.eu.auth0.com)
@@ -30,5 +29,4 @@ export interface Auth0Options extends BaseOAuthProviderOptions {
30
29
  * });
31
30
  * ```
32
31
  */
33
- export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
34
- //#endregion
32
+ export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
@@ -1,4 +1,4 @@
1
- //#region src/plugins/generic-oauth/providers/auth0.ts
1
+ // src/plugins/generic-oauth/providers/auth0.ts
2
2
  /**
3
3
  * Auth0 OAuth provider helper
4
4
  *
@@ -45,5 +45,4 @@ function auth0(options) {
45
45
  overrideUserInfo: options.overrideUserInfo
46
46
  };
47
47
  }
48
- //#endregion
49
48
  export { auth0 };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/gumroad.d.ts
4
3
  export interface GumroadOptions extends BaseOAuthProviderOptions {}
5
4
  /**
6
5
  * Gumroad OAuth provider helper
@@ -25,5 +24,4 @@ export interface GumroadOptions extends BaseOAuthProviderOptions {}
25
24
  *
26
25
  * @see https://app.gumroad.com/oauth
27
26
  */
28
- export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
29
- //#endregion
27
+ export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
@@ -1,5 +1,5 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- //#region src/plugins/generic-oauth/providers/gumroad.ts
2
+ // src/plugins/generic-oauth/providers/gumroad.ts
3
3
  /**
4
4
  * Gumroad OAuth provider helper
5
5
  *
@@ -58,5 +58,4 @@ function gumroad(options) {
58
58
  getUserInfo
59
59
  };
60
60
  }
61
- //#endregion
62
61
  export { gumroad };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/hubspot.d.ts
4
3
  export interface HubSpotOptions extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * OAuth scopes to request.
@@ -30,5 +29,4 @@ export interface HubSpotOptions extends BaseOAuthProviderOptions {
30
29
  * });
31
30
  * ```
32
31
  */
33
- export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
34
- //#endregion
32
+ export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
@@ -1,5 +1,5 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- //#region src/plugins/generic-oauth/providers/hubspot.ts
2
+ // src/plugins/generic-oauth/providers/hubspot.ts
3
3
  /**
4
4
  * HubSpot OAuth provider helper
5
5
  *
@@ -62,5 +62,4 @@ function hubspot(options) {
62
62
  getUserInfo
63
63
  };
64
64
  }
65
- //#endregion
66
65
  export { hubspot };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/keycloak.d.ts
4
3
  export interface KeycloakOptions extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * Keycloak issuer URL (includes realm, e.g., https://my-domain/realms/MyRealm)
@@ -30,5 +29,4 @@ export interface KeycloakOptions extends BaseOAuthProviderOptions {
30
29
  * });
31
30
  * ```
32
31
  */
33
- export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
34
- //#endregion
32
+ export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
@@ -1,4 +1,4 @@
1
- //#region src/plugins/generic-oauth/providers/keycloak.ts
1
+ // src/plugins/generic-oauth/providers/keycloak.ts
2
2
  /**
3
3
  * Keycloak OAuth provider helper
4
4
  *
@@ -43,5 +43,4 @@ function keycloak(options) {
43
43
  overrideUserInfo: options.overrideUserInfo
44
44
  };
45
45
  }
46
- //#endregion
47
46
  export { keycloak };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/line.d.ts
4
3
  export interface LineOptions extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * Unique provider identifier for this LINE channel.
@@ -48,5 +47,4 @@ export interface LineOptions extends BaseOAuthProviderOptions {
48
47
  * });
49
48
  * ```
50
49
  */
51
- export declare function line(options: LineOptions): GenericOAuthConfig;
52
- //#endregion
50
+ export declare function line(options: LineOptions): GenericOAuthConfig;
@@ -1,6 +1,6 @@
1
1
  import { decodeJwt } from "jose";
2
2
  import { betterFetch } from "@better-fetch/fetch";
3
- //#region src/plugins/generic-oauth/providers/line.ts
3
+ // src/plugins/generic-oauth/providers/line.ts
4
4
  /**
5
5
  * LINE OAuth provider helper
6
6
  *
@@ -89,5 +89,4 @@ function line(options) {
89
89
  getUserInfo
90
90
  };
91
91
  }
92
- //#endregion
93
92
  export { line };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/microsoft-entra-id.d.ts
4
3
  export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * Concrete Microsoft Entra ID tenant GUID.
@@ -33,5 +32,4 @@ export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
33
32
  * });
34
33
  * ```
35
34
  */
36
- export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
37
- //#endregion
35
+ export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
@@ -1,7 +1,7 @@
1
1
  import { decodeJwt } from "jose";
2
2
  import { betterFetch } from "@better-fetch/fetch";
3
3
  import { createPlaceholderEmail } from "@better-auth/core/utils/email";
4
- //#region src/plugins/generic-oauth/providers/microsoft-entra-id.ts
4
+ // src/plugins/generic-oauth/providers/microsoft-entra-id.ts
5
5
  function getMicrosoftProfileName(profile) {
6
6
  return profile.name ?? (`${profile.given_name ?? profile.givenname ?? ""} ${profile.family_name ?? profile.familyname ?? ""}`.trim() || void 0);
7
7
  }
@@ -100,5 +100,4 @@ function microsoftEntraId(options) {
100
100
  getUserInfo
101
101
  };
102
102
  }
103
- //#endregion
104
103
  export { microsoftEntraId };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/okta.d.ts
4
3
  export interface OktaOptions extends BaseOAuthProviderOptions {
5
4
  /**
6
5
  * Okta issuer URL (e.g., https://dev-xxxxx.okta.com/oauth2/default)
@@ -30,5 +29,4 @@ export interface OktaOptions extends BaseOAuthProviderOptions {
30
29
  * });
31
30
  * ```
32
31
  */
33
- export declare function okta(options: OktaOptions): GenericOAuthConfig<"okta">;
34
- //#endregion
32
+ export declare function okta(options: OktaOptions): GenericOAuthConfig<"okta">;
@@ -1,4 +1,4 @@
1
- //#region src/plugins/generic-oauth/providers/okta.ts
1
+ // src/plugins/generic-oauth/providers/okta.ts
2
2
  /**
3
3
  * Okta OAuth provider helper
4
4
  *
@@ -43,5 +43,4 @@ function okta(options) {
43
43
  overrideUserInfo: options.overrideUserInfo
44
44
  };
45
45
  }
46
- //#endregion
47
46
  export { okta };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/patreon.d.ts
4
3
  export interface PatreonOptions extends BaseOAuthProviderOptions {}
5
4
  /**
6
5
  * Patreon OAuth provider helper
@@ -23,5 +22,4 @@ export interface PatreonOptions extends BaseOAuthProviderOptions {}
23
22
  * });
24
23
  * ```
25
24
  */
26
- export declare function patreon(options: PatreonOptions): GenericOAuthConfig<"patreon">;
27
- //#endregion
25
+ export declare function patreon(options: PatreonOptions): GenericOAuthConfig<"patreon">;
@@ -1,5 +1,5 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- //#region src/plugins/generic-oauth/providers/patreon.ts
2
+ // src/plugins/generic-oauth/providers/patreon.ts
3
3
  /**
4
4
  * Patreon OAuth provider helper
5
5
  *
@@ -57,5 +57,4 @@ function patreon(options) {
57
57
  getUserInfo
58
58
  };
59
59
  }
60
- //#endregion
61
60
  export { patreon };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/slack.d.ts
4
3
  export interface SlackOptions extends BaseOAuthProviderOptions {}
5
4
  /**
6
5
  * Slack OAuth provider helper
@@ -23,5 +22,4 @@ export interface SlackOptions extends BaseOAuthProviderOptions {}
23
22
  * });
24
23
  * ```
25
24
  */
26
- export declare function slack(options: SlackOptions): GenericOAuthConfig<"slack">;
27
- //#endregion
25
+ export declare function slack(options: SlackOptions): GenericOAuthConfig<"slack">;
@@ -1,5 +1,5 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- //#region src/plugins/generic-oauth/providers/slack.ts
2
+ // src/plugins/generic-oauth/providers/slack.ts
3
3
  /**
4
4
  * Slack OAuth provider helper
5
5
  *
@@ -59,5 +59,4 @@ function slack(options) {
59
59
  getUserInfo
60
60
  };
61
61
  }
62
- //#endregion
63
62
  export { slack };
@@ -1,6 +1,5 @@
1
1
  import { GenericOAuthConfig } from "../types.mjs";
2
2
  import { BaseOAuthProviderOptions } from "../index.mjs";
3
- //#region src/plugins/generic-oauth/providers/yandex.d.ts
4
3
  export interface YandexOptions extends BaseOAuthProviderOptions {}
5
4
  /**
6
5
  * Yandex OAuth provider helper
@@ -23,5 +22,4 @@ export interface YandexOptions extends BaseOAuthProviderOptions {}
23
22
  * });
24
23
  * ```
25
24
  */
26
- export declare function yandex(options: YandexOptions): GenericOAuthConfig;
27
- //#endregion
25
+ export declare function yandex(options: YandexOptions): GenericOAuthConfig;
@@ -1,5 +1,5 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
- //#region src/plugins/generic-oauth/providers/yandex.ts
2
+ // src/plugins/generic-oauth/providers/yandex.ts
3
3
  /**
4
4
  * Yandex OAuth provider helper
5
5
  *
@@ -63,5 +63,4 @@ function yandex(options) {
63
63
  getUserInfo
64
64
  };
65
65
  }
66
- //#endregion
67
66
  export { yandex };
@@ -1,6 +1,5 @@
1
1
  import { Awaitable } from "@better-auth/core";
2
2
  import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, OAuthMappedUser, OAuthRefreshContext, TokenEndpointAuth } from "@better-auth/core/oauth2";
3
- //#region src/plugins/generic-oauth/types.d.ts
4
3
  /** Raw profile returned by a Generic OAuth provider. */
5
4
  export type GenericOAuthUserInfo = Omit<OAuth2UserInfo, "id"> & {
6
5
  id?: string | number | null | undefined;
@@ -211,12 +210,15 @@ export interface GenericOAuthConfig<ID extends string = string> {
211
210
  */
212
211
  authentication?: ("basic" | "post") | undefined;
213
212
  /**
214
- * Custom headers to include in the discovery request.
213
+ * Custom headers to include in the discovery request, and in the JWKS request when
214
+ * `jwks_uri` has the same origin as `discoveryUrl`. When set, discovery follows
215
+ * redirects only within that origin and fails on a redirect to another origin.
215
216
  * Useful for providers like Epic that require specific headers (e.g., Epic-Client-ID).
216
217
  */
217
218
  discoveryHeaders?: Record<string, string> | undefined;
218
219
  /**
219
- * Custom headers to include in the authorization request.
220
+ * Custom headers to include in token endpoint requests: the authorization
221
+ * code exchange and token refresh.
220
222
  * Useful for providers like Qonto that require specific headers (e.g., X-Qonto-Staging-Token for local development).
221
223
  */
222
224
  authorizationHeaders?: Record<string, string> | undefined;
@@ -263,5 +265,4 @@ export interface GenericOAuthConfig<ID extends string = string> {
263
265
  * @default false
264
266
  */
265
267
  disableIdTokenNonceBinding?: boolean | undefined;
266
- }
267
- //#endregion
268
+ }
@@ -1,4 +1,3 @@
1
- //#region src/plugins/haveibeenpwned/index.d.ts
2
1
  declare module "@better-auth/core" {
3
2
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
4
3
  "have-i-been-pwned": {
@@ -55,5 +54,4 @@ export declare const haveIBeenPwned: (options?: HaveIBeenPwnedOptions | undefine
55
54
  $ERROR_CODES: {
56
55
  PASSWORD_COMPROMISED: import("@better-auth/core/utils/error-codes").RawError<"PASSWORD_COMPROMISED">;
57
56
  };
58
- };
59
- //#endregion
57
+ };
@@ -1,11 +1,11 @@
1
- import { isAPIError } from "../../utils/is-api-error.mjs";
2
1
  import { APIError } from "../../api/index.mjs";
2
+ import { isAPIError } from "../../utils/is-api-error.mjs";
3
3
  import { PACKAGE_VERSION } from "../../version.mjs";
4
4
  import { getCurrentAuthEndpointContext } from "@better-auth/core/context";
5
5
  import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
6
6
  import { createHash } from "@better-auth/utils/hash";
7
7
  import { betterFetch } from "@better-fetch/fetch";
8
- //#region src/plugins/haveibeenpwned/index.ts
8
+ // src/plugins/haveibeenpwned/index.ts
9
9
  const ERROR_CODES = defineErrorCodes({ PASSWORD_COMPROMISED: "The password you entered has been compromised. Please choose a different password." });
10
10
  function getPasswordCompromiseCount(response, hashSuffix) {
11
11
  const matchingEntryPrefix = `${hashSuffix.toUpperCase()}:`;
@@ -77,5 +77,4 @@ const haveIBeenPwned = (options) => {
77
77
  $ERROR_CODES: ERROR_CODES
78
78
  };
79
79
  };
80
- //#endregion
81
80
  export { haveIBeenPwned, isPasswordCompromised };
@@ -53,21 +53,21 @@ import { OneTimeTokenOptions, oneTimeToken } from "./one-time-token/index.mjs";
53
53
  import { FieldSchema, OpenAPIModelSchema, OpenAPIParameter, OpenAPISchema, Path, generator } from "./open-api/generator.mjs";
54
54
  import { OpenAPIOptions, openAPI } from "./open-api/index.mjs";
55
55
  import { PhoneNumberOptions, UserWithPhoneNumber } from "./phone-number/types.mjs";
56
+ import "./organization/index.mjs";
56
57
  import { phoneNumber } from "./phone-number/index.mjs";
57
- import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
58
58
  import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./test-utils/types.mjs";
59
- import { testUtils } from "./test-utils/index.mjs";
59
+ import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
60
60
  import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./two-factor/backup-codes/index.mjs";
61
61
  import { OTPOptions, otp2fa } from "./two-factor/otp/index.mjs";
62
62
  import { TOTPOptions, totp2fa } from "./two-factor/totp/index.mjs";
63
63
  import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./two-factor/types.mjs";
64
64
  import { TWO_FACTOR_ERROR_CODES } from "./two-factor/error-code.mjs";
65
65
  import { twoFactorClient } from "./two-factor/client.mjs";
66
- import { twoFactor } from "./two-factor/index.mjs";
66
+ import { testUtils } from "./test-utils/index.mjs";
67
67
  import { USERNAME_ERROR_CODES } from "./username/error-codes.mjs";
68
- import { UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, username } from "./username/index.mjs";
68
+ import { twoFactor } from "./two-factor/index.mjs";
69
69
  import { hasPermission } from "./organization/has-permission.mjs";
70
70
  import { parseRoles } from "./organization/roles.mjs";
71
71
  import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization } from "./organization/organization.mjs";
72
- import "./organization/index.mjs";
72
+ import { UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, username } from "./username/index.mjs";
73
73
  export { AccessControl, type AdminOptions, type AnonymousOptions, type AnonymousSession, ArrayElement, type Auth0Options, AuthorizeResponse, type BackupCodeOptions, type BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, type BotIdVerification, type CaptchaFoxOptions, type CaptchaOptions, type CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationGrant, DeviceAuthorizationGrantAuthorization, DeviceAuthorizationOptions, DeviceAuthorizationPluginOptions, DeviceAuthorizationRequest, type DeviceCode, type DeviceCodeRedemptionAuthorization, type DeviceCodeRedemptionResult, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, type EmailOTPOptions, ExactRoleStatements, type FieldSchema, type GenericOAuthConfig, type GenericOAuthOptions, type GenericOAuthUserInfo, type GoogleRecaptchaOptions, type GumroadOptions, type HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, type HubSpotOptions, type InferAdminRolesFromOption, type InferInvitation, type InferMember, InferOptionSchema, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, type InferTeam, type Invitation, type InvitationInput, type InvitationStatus, type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type KeycloakOptions, LastLoginMethodOptions, type LineOptions, type LoginResult, MagicLinkOptions, type Member, type MemberInput, type MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, type OAuthPopupData, type OAuthPopupMessage, OAuthProxyOptions, type OTPOptions, type OktaOptions, OneTapOptions, OneTimeTokenOptions, type OpenAPIModelSchema, OpenAPIOptions, type OpenAPIParameter, type OpenAPISchema, type Organization, OrganizationCreator, OrganizationEndpoints, type OrganizationInput, type OrganizationOptions, OrganizationPlugin, type OrganizationRole, type OrganizationSchema, POPUP_MARKER_COOKIE, type Path, type PatreonOptions, type PhoneNumberOptions, type Provider, type ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, type SessionWithImpersonatedBy, type SlackOptions, Statements, SubArray, Subset, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type Team, TeamEndpoints, type TeamInput, type TeamMember, type TeamMemberInput, type TestAuthOptions, type TestCookie, type TestHelpers, type TestUtilsOptions, type TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, type UserWithAnonymous, type UserWithPhoneNumber, type UserWithRole, UserWithTwoFactor, UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, type ValidateRequestContext, type VercelBotIdOptions, type YandexOptions, admin, anonymous, auth0, type backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, type defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, type encodeBackupCodes, type generateBackupCodes, generateExportedKeyPair, type generator, genericOAuth, type getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, type invitationSchema, type invitationStatus, isPasswordCompromised, jwt, keycloak, lastLoginMethod, line, magicLink, type memberSchema, microsoftEntraId, type ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, type organizationRoleSchema, type organizationSchema, type otp2fa, parseRoles, patreon, phoneNumber, redeemDeviceCode, resolveSigningKey, role, type roleSchema, type sec, signJWT, siwe, slack, type teamMemberSchema, type teamSchema, testUtils, toExpJWT, type totp2fa, twoFactor, twoFactorClient, username, type verifyBackupCode, verifyJWT, yandex };
@@ -1,5 +1,5 @@
1
1
  import { getCurrentAdapter } from "@better-auth/core/context";
2
- //#region src/plugins/jwt/adapter.ts
2
+ // src/plugins/jwt/adapter.ts
3
3
  /**
4
4
  * Algorithm of the key the plugin generates when `jwks.keyPairConfig` is unset.
5
5
  */
@@ -75,5 +75,4 @@ const getJwksAdapter = (baseAdapter, options) => {
75
75
  }
76
76
  };
77
77
  };
78
- //#endregion
79
78
  export { DEFAULT_JWK_ALG, getDefaultKeyAlg, getJwksAdapter };
@@ -1,9 +1,8 @@
1
- import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
2
1
  import { jwt } from "./index.mjs";
2
+ import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
3
3
  import { BetterAuthClientOptions, ClientFetchOption, ClientStore } from "@better-auth/core";
4
4
  import { JSONWebKeySet } from "jose";
5
5
  import { BetterFetch } from "@better-fetch/fetch";
6
- //#region src/plugins/jwt/client.d.ts
7
6
  interface JwtClientOptions {
8
7
  jwks?: {
9
8
  /**
@@ -36,5 +35,4 @@ export declare const jwtClient: (options?: JwtClientOptions) => {
36
35
  }>;
37
36
  };
38
37
  };
39
- //#endregion
40
38
  export type { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey };
@@ -1,5 +1,5 @@
1
1
  import { PACKAGE_VERSION } from "../../version.mjs";
2
- //#region src/plugins/jwt/client.ts
2
+ // src/plugins/jwt/client.ts
3
3
  const jwtClient = (options) => {
4
4
  const jwksPath = options?.jwks?.jwksPath ?? "/jwks";
5
5
  return {
@@ -15,5 +15,4 @@ const jwtClient = (options) => {
15
15
  } })
16
16
  };
17
17
  };
18
- //#endregion
19
18
  export { jwtClient };
@@ -3,7 +3,7 @@ import { getDefaultKeyAlg, getJwksAdapter } from "./adapter.mjs";
3
3
  import { resolveSigningKey } from "./sign.mjs";
4
4
  import { BetterAuthError } from "@better-auth/core/error";
5
5
  import { SignJWT, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
6
- //#region src/plugins/jwt/cookie-cache.ts
6
+ // src/plugins/jwt/cookie-cache.ts
7
7
  function getCookieCacheJwtIssuer(ctx) {
8
8
  const baseURL = ctx.context.options.baseURL;
9
9
  return typeof baseURL === "string" ? baseURL || "better-auth:session-cache" : ctx.context.baseURL || "better-auth:session-cache";
@@ -68,5 +68,4 @@ function createCookieCacheSigner(options) {
68
68
  verify: (ctx, token) => verifyCookieCacheJWT(ctx, token, options)
69
69
  };
70
70
  }
71
- //#endregion
72
71
  export { createCookieCacheSigner };
@@ -1,10 +1,9 @@
1
- import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
2
1
  import { getJwtToken, resolveSigningKey, signJWT } from "./sign.mjs";
2
+ import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
3
3
  import { createJwk, generateExportedKeyPair, toExpJWT } from "./utils.mjs";
4
4
  import { verifyJWT } from "./verify.mjs";
5
5
  import * as z from "zod";
6
6
  import { JSONWebKeySet, JWTPayload } from "jose";
7
- //#region src/plugins/jwt/index.d.ts
8
7
  declare module "@better-auth/core" {
9
8
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
10
9
  jwt: {
@@ -239,5 +238,4 @@ export declare const jwt: <O extends JwtOptions>(options?: O) => {
239
238
  };
240
239
  };
241
240
  };
242
- //#endregion
243
241
  export { type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type ResolvedSigningKey, createJwk, generateExportedKeyPair, getJwtToken, resolveSigningKey, signJWT, toExpJWT, verifyJWT };