better-auth 1.3.5-beta.6 → 1.3.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 (226) hide show
  1. package/dist/adapters/drizzle-adapter/index.d.cts +1 -1
  2. package/dist/adapters/drizzle-adapter/index.d.mts +1 -1
  3. package/dist/adapters/drizzle-adapter/index.d.ts +1 -1
  4. package/dist/adapters/index.d.cts +2 -2
  5. package/dist/adapters/index.d.mts +2 -2
  6. package/dist/adapters/index.d.ts +2 -2
  7. package/dist/adapters/kysely-adapter/index.d.cts +1 -1
  8. package/dist/adapters/kysely-adapter/index.d.mts +1 -1
  9. package/dist/adapters/kysely-adapter/index.d.ts +1 -1
  10. package/dist/adapters/memory-adapter/index.d.cts +1 -1
  11. package/dist/adapters/memory-adapter/index.d.mts +1 -1
  12. package/dist/adapters/memory-adapter/index.d.ts +1 -1
  13. package/dist/adapters/mongodb-adapter/index.d.cts +1 -1
  14. package/dist/adapters/mongodb-adapter/index.d.mts +1 -1
  15. package/dist/adapters/mongodb-adapter/index.d.ts +1 -1
  16. package/dist/adapters/prisma-adapter/index.d.cts +1 -1
  17. package/dist/adapters/prisma-adapter/index.d.mts +1 -1
  18. package/dist/adapters/prisma-adapter/index.d.ts +1 -1
  19. package/dist/adapters/test.d.cts +1 -1
  20. package/dist/adapters/test.d.mts +1 -1
  21. package/dist/adapters/test.d.ts +1 -1
  22. package/dist/api/index.cjs +3 -168
  23. package/dist/api/index.d.cts +1 -1
  24. package/dist/api/index.d.mts +1 -1
  25. package/dist/api/index.d.ts +1 -1
  26. package/dist/api/index.mjs +4 -166
  27. package/dist/chunks/index.cjs +9 -121
  28. package/dist/chunks/index.mjs +9 -121
  29. package/dist/client/index.d.cts +3 -3
  30. package/dist/client/index.d.mts +3 -3
  31. package/dist/client/index.d.ts +3 -3
  32. package/dist/client/plugins/index.d.cts +3 -3
  33. package/dist/client/plugins/index.d.mts +3 -3
  34. package/dist/client/plugins/index.d.ts +3 -3
  35. package/dist/client/react/index.d.cts +9 -9
  36. package/dist/client/react/index.d.mts +9 -9
  37. package/dist/client/react/index.d.ts +9 -9
  38. package/dist/client/solid/index.d.cts +3 -3
  39. package/dist/client/solid/index.d.mts +3 -3
  40. package/dist/client/solid/index.d.ts +3 -3
  41. package/dist/client/svelte/index.d.cts +3 -3
  42. package/dist/client/svelte/index.d.mts +3 -3
  43. package/dist/client/svelte/index.d.ts +3 -3
  44. package/dist/client/vue/index.d.cts +12 -12
  45. package/dist/client/vue/index.d.mts +12 -12
  46. package/dist/client/vue/index.d.ts +12 -12
  47. package/dist/cookies/index.d.cts +1 -1
  48. package/dist/cookies/index.d.mts +1 -1
  49. package/dist/cookies/index.d.ts +1 -1
  50. package/dist/db/index.d.cts +2 -2
  51. package/dist/db/index.d.mts +2 -2
  52. package/dist/db/index.d.ts +2 -2
  53. package/dist/index.cjs +2 -5
  54. package/dist/index.d.cts +9 -9
  55. package/dist/index.d.mts +9 -9
  56. package/dist/index.d.ts +9 -9
  57. package/dist/index.mjs +2 -5
  58. package/dist/integrations/next-js.cjs +3 -3
  59. package/dist/integrations/next-js.d.cts +1 -1
  60. package/dist/integrations/next-js.d.mts +1 -1
  61. package/dist/integrations/next-js.d.ts +1 -1
  62. package/dist/integrations/next-js.mjs +3 -3
  63. package/dist/integrations/node.d.cts +1 -1
  64. package/dist/integrations/node.d.mts +1 -1
  65. package/dist/integrations/node.d.ts +1 -1
  66. package/dist/integrations/react-start.cjs +3 -3
  67. package/dist/integrations/react-start.d.cts +1 -1
  68. package/dist/integrations/react-start.d.mts +1 -1
  69. package/dist/integrations/react-start.d.ts +1 -1
  70. package/dist/integrations/react-start.mjs +3 -3
  71. package/dist/integrations/svelte-kit.cjs +2 -2
  72. package/dist/integrations/svelte-kit.d.cts +1 -1
  73. package/dist/integrations/svelte-kit.d.mts +1 -1
  74. package/dist/integrations/svelte-kit.d.ts +1 -1
  75. package/dist/integrations/svelte-kit.mjs +2 -2
  76. package/dist/oauth2/index.cjs +1 -1
  77. package/dist/oauth2/index.d.cts +2 -2
  78. package/dist/oauth2/index.d.mts +2 -2
  79. package/dist/oauth2/index.d.ts +2 -2
  80. package/dist/oauth2/index.mjs +1 -1
  81. package/dist/plugins/admin/index.cjs +2 -2
  82. package/dist/plugins/admin/index.d.cts +6 -6
  83. package/dist/plugins/admin/index.d.mts +6 -6
  84. package/dist/plugins/admin/index.d.ts +6 -6
  85. package/dist/plugins/admin/index.mjs +2 -2
  86. package/dist/plugins/anonymous/index.cjs +2 -2
  87. package/dist/plugins/anonymous/index.d.cts +1 -1
  88. package/dist/plugins/anonymous/index.d.mts +1 -1
  89. package/dist/plugins/anonymous/index.d.ts +1 -1
  90. package/dist/plugins/anonymous/index.mjs +2 -2
  91. package/dist/plugins/bearer/index.cjs +2 -2
  92. package/dist/plugins/bearer/index.d.cts +1 -1
  93. package/dist/plugins/bearer/index.d.mts +1 -1
  94. package/dist/plugins/bearer/index.d.ts +1 -1
  95. package/dist/plugins/bearer/index.mjs +2 -2
  96. package/dist/plugins/captcha/index.d.cts +1 -1
  97. package/dist/plugins/captcha/index.d.mts +1 -1
  98. package/dist/plugins/captcha/index.d.ts +1 -1
  99. package/dist/plugins/custom-session/index.cjs +2 -2
  100. package/dist/plugins/custom-session/index.d.cts +1 -1
  101. package/dist/plugins/custom-session/index.d.mts +1 -1
  102. package/dist/plugins/custom-session/index.d.ts +1 -1
  103. package/dist/plugins/custom-session/index.mjs +2 -2
  104. package/dist/plugins/email-otp/index.cjs +2 -2
  105. package/dist/plugins/email-otp/index.d.cts +1 -1
  106. package/dist/plugins/email-otp/index.d.mts +1 -1
  107. package/dist/plugins/email-otp/index.d.ts +1 -1
  108. package/dist/plugins/email-otp/index.mjs +2 -2
  109. package/dist/plugins/generic-oauth/index.cjs +2 -2
  110. package/dist/plugins/generic-oauth/index.d.cts +1 -1
  111. package/dist/plugins/generic-oauth/index.d.mts +1 -1
  112. package/dist/plugins/generic-oauth/index.d.ts +1 -1
  113. package/dist/plugins/generic-oauth/index.mjs +2 -2
  114. package/dist/plugins/haveibeenpwned/index.cjs +2 -2
  115. package/dist/plugins/haveibeenpwned/index.d.cts +1 -1
  116. package/dist/plugins/haveibeenpwned/index.d.mts +1 -1
  117. package/dist/plugins/haveibeenpwned/index.d.ts +1 -1
  118. package/dist/plugins/haveibeenpwned/index.mjs +2 -2
  119. package/dist/plugins/index.cjs +8 -8
  120. package/dist/plugins/index.d.cts +7 -51
  121. package/dist/plugins/index.d.mts +7 -51
  122. package/dist/plugins/index.d.ts +7 -51
  123. package/dist/plugins/index.mjs +10 -10
  124. package/dist/plugins/jwt/index.cjs +2 -2
  125. package/dist/plugins/jwt/index.d.cts +1 -1
  126. package/dist/plugins/jwt/index.d.mts +1 -1
  127. package/dist/plugins/jwt/index.d.ts +1 -1
  128. package/dist/plugins/jwt/index.mjs +2 -2
  129. package/dist/plugins/magic-link/index.cjs +2 -2
  130. package/dist/plugins/magic-link/index.mjs +2 -2
  131. package/dist/plugins/multi-session/index.cjs +2 -2
  132. package/dist/plugins/multi-session/index.d.cts +1 -1
  133. package/dist/plugins/multi-session/index.d.mts +1 -1
  134. package/dist/plugins/multi-session/index.d.ts +1 -1
  135. package/dist/plugins/multi-session/index.mjs +2 -2
  136. package/dist/plugins/oauth-proxy/index.cjs +2 -2
  137. package/dist/plugins/oauth-proxy/index.d.cts +1 -1
  138. package/dist/plugins/oauth-proxy/index.d.mts +1 -1
  139. package/dist/plugins/oauth-proxy/index.d.ts +1 -1
  140. package/dist/plugins/oauth-proxy/index.mjs +2 -2
  141. package/dist/plugins/oidc-provider/index.cjs +3 -3
  142. package/dist/plugins/oidc-provider/index.d.cts +5 -5
  143. package/dist/plugins/oidc-provider/index.d.mts +5 -5
  144. package/dist/plugins/oidc-provider/index.d.ts +5 -5
  145. package/dist/plugins/oidc-provider/index.mjs +3 -3
  146. package/dist/plugins/one-tap/index.cjs +2 -2
  147. package/dist/plugins/one-tap/index.mjs +2 -2
  148. package/dist/plugins/one-time-token/index.cjs +4 -4
  149. package/dist/plugins/one-time-token/index.d.cts +1 -1
  150. package/dist/plugins/one-time-token/index.d.mts +1 -1
  151. package/dist/plugins/one-time-token/index.d.ts +1 -1
  152. package/dist/plugins/one-time-token/index.mjs +4 -4
  153. package/dist/plugins/open-api/index.cjs +2 -2
  154. package/dist/plugins/open-api/index.d.cts +1 -1
  155. package/dist/plugins/open-api/index.d.mts +1 -1
  156. package/dist/plugins/open-api/index.d.ts +1 -1
  157. package/dist/plugins/open-api/index.mjs +2 -2
  158. package/dist/plugins/organization/index.cjs +3 -3
  159. package/dist/plugins/organization/index.d.cts +9 -9
  160. package/dist/plugins/organization/index.d.mts +9 -9
  161. package/dist/plugins/organization/index.d.ts +9 -9
  162. package/dist/plugins/organization/index.mjs +3 -3
  163. package/dist/plugins/passkey/index.cjs +2 -2
  164. package/dist/plugins/passkey/index.d.cts +1 -1
  165. package/dist/plugins/passkey/index.d.mts +1 -1
  166. package/dist/plugins/passkey/index.d.ts +1 -1
  167. package/dist/plugins/passkey/index.mjs +2 -2
  168. package/dist/plugins/phone-number/index.cjs +5 -8
  169. package/dist/plugins/phone-number/index.d.cts +3 -3
  170. package/dist/plugins/phone-number/index.d.mts +3 -3
  171. package/dist/plugins/phone-number/index.d.ts +3 -3
  172. package/dist/plugins/phone-number/index.mjs +5 -8
  173. package/dist/plugins/siwe/index.cjs +2 -2
  174. package/dist/plugins/siwe/index.mjs +2 -2
  175. package/dist/plugins/sso/index.cjs +2 -2
  176. package/dist/plugins/sso/index.d.cts +3 -3
  177. package/dist/plugins/sso/index.d.mts +3 -3
  178. package/dist/plugins/sso/index.d.ts +3 -3
  179. package/dist/plugins/sso/index.mjs +2 -2
  180. package/dist/plugins/two-factor/index.cjs +2 -2
  181. package/dist/plugins/two-factor/index.d.cts +1 -1
  182. package/dist/plugins/two-factor/index.d.mts +1 -1
  183. package/dist/plugins/two-factor/index.d.ts +1 -1
  184. package/dist/plugins/two-factor/index.mjs +2 -2
  185. package/dist/plugins/username/index.cjs +89 -24
  186. package/dist/plugins/username/index.d.cts +100 -4
  187. package/dist/plugins/username/index.d.mts +100 -4
  188. package/dist/plugins/username/index.d.ts +100 -4
  189. package/dist/plugins/username/index.mjs +89 -24
  190. package/dist/shared/{better-auth.B7x_2TQr.d.ts → better-auth.B96vZfh2.d.ts} +1 -1
  191. package/dist/shared/{better-auth.BJxLUPkP.cjs → better-auth.BCz4-QUh.cjs} +108 -42
  192. package/dist/shared/{better-auth.DCVVfbqi.d.cts → better-auth.BTsdIaVL.d.cts} +1 -1
  193. package/dist/shared/{better-auth.DvIqD5oK.d.mts → better-auth.Bl8InMw5.d.mts} +5 -5
  194. package/dist/shared/{better-auth.C0K3BEUF.d.mts → better-auth.BoBKsnVd.d.mts} +1 -1
  195. package/dist/shared/{better-auth.CMbdjy1W.cjs → better-auth.Bv6xc9eQ.cjs} +1 -2
  196. package/dist/shared/{better-auth.CdpTx0Tt.cjs → better-auth.Bx3RgYZf.cjs} +173 -1
  197. package/dist/shared/{better-auth.CJJar71A.mjs → better-auth.C3R00PmH.mjs} +174 -3
  198. package/dist/shared/{better-auth.DALte7Xu.mjs → better-auth.CCMYns0n.mjs} +108 -39
  199. package/dist/shared/{better-auth.B5dCCYxG.mjs → better-auth.CCxr11mp.mjs} +2 -3
  200. package/dist/shared/{better-auth.BniUWpi1.d.cts → better-auth.CEtc1oG5.d.cts} +5 -5
  201. package/dist/shared/{better-auth.BH6nToRm.mjs → better-auth.CStDZlxp.mjs} +1 -2
  202. package/dist/shared/{better-auth.C6nV8Oy1.mjs → better-auth.CW0oMVtF.mjs} +1 -2
  203. package/dist/shared/{better-auth.CxrwcGql.cjs → better-auth.CX5ucYKP.cjs} +1 -2
  204. package/dist/shared/{better-auth.CugLU3-b.d.ts → better-auth.CpTWU-gb.d.ts} +9 -9
  205. package/dist/shared/{better-auth.B48GI1ye.mjs → better-auth.Cz37zEtO.mjs} +9 -4
  206. package/dist/shared/{better-auth.DGsjZL73.cjs → better-auth.DBscO_L1.cjs} +2 -3
  207. package/dist/shared/{better-auth.13CeQFUR.cjs → better-auth.DKORdAr4.cjs} +1 -2
  208. package/dist/shared/{better-auth.hsgNXBIR.d.mts → better-auth.DPF-nTOv.d.mts} +1 -1
  209. package/dist/shared/{better-auth.CHfsKXFe.d.cts → better-auth.DSYK4jT-.d.cts} +9 -9
  210. package/dist/shared/{better-auth.ZdtzprjG.d.ts → better-auth.DWkfnOhB.d.ts} +1 -1
  211. package/dist/shared/{better-auth.DBNKitmI.d.cts → better-auth.DXpowKDk.d.cts} +1 -1
  212. package/dist/shared/{better-auth.B4JEaXms.d.ts → better-auth.DkcNzUEl.d.ts} +5 -5
  213. package/dist/shared/{better-auth.Sd18O7o8.mjs → better-auth.dA0rT0C-.mjs} +1 -2
  214. package/dist/shared/{better-auth.CRB6xnLW.d.mts → better-auth.jL_zqxTz.d.mts} +9 -9
  215. package/dist/shared/{better-auth.BJBreXFE.cjs → better-auth.kvWPdS5e.cjs} +9 -4
  216. package/dist/social-providers/index.cjs +1 -1
  217. package/dist/social-providers/index.mjs +1 -1
  218. package/dist/test-utils/index.cjs +145 -262
  219. package/dist/test-utils/index.d.cts +2 -2
  220. package/dist/test-utils/index.d.mts +2 -2
  221. package/dist/test-utils/index.d.ts +2 -2
  222. package/dist/test-utils/index.mjs +142 -259
  223. package/dist/types/index.d.cts +2 -2
  224. package/dist/types/index.d.mts +2 -2
  225. package/dist/types/index.d.ts +2 -2
  226. package/package.json +27 -26
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CHfsKXFe.cjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.DSYK4jT-.cjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CRB6xnLW.mjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.jL_zqxTz.mjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CugLU3-b.js';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CpTWU-gb.js';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,5 +1,5 @@
1
- import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CHfsKXFe.cjs';
2
- export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.CHfsKXFe.cjs';
1
+ import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.DSYK4jT-.cjs';
2
+ export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.DSYK4jT-.cjs';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import 'zod/v4';
@@ -1,5 +1,5 @@
1
- import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CRB6xnLW.mjs';
2
- export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.CRB6xnLW.mjs';
1
+ import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.jL_zqxTz.mjs';
2
+ export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.jL_zqxTz.mjs';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import 'zod/v4';
@@ -1,5 +1,5 @@
1
- import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CugLU3-b.js';
2
- export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.CugLU3-b.js';
1
+ import { b as AdapterConfig, C as CreateCustomAdapter, B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CpTWU-gb.js';
2
+ export { A as AdapterDebugLogs, e as AdapterTestDebugLogs, d as CleanedWhere, c as CustomAdapter } from '../shared/better-auth.CpTWU-gb.js';
3
3
  import 'kysely';
4
4
  import 'better-call';
5
5
  import 'zod/v4';
@@ -1,5 +1,5 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.CHfsKXFe.cjs';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.DSYK4jT-.cjs';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
5
5
  import '../../shared/better-auth.BDR52Rf2.cjs';
@@ -1,5 +1,5 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.CRB6xnLW.mjs';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.jL_zqxTz.mjs';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
5
5
  import '../../shared/better-auth.BDR52Rf2.mjs';
@@ -1,5 +1,5 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.CugLU3-b.js';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, A as AdapterDebugLogs, a as Adapter } from '../../shared/better-auth.CpTWU-gb.js';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
5
5
  import '../../shared/better-auth.BDR52Rf2.js';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CHfsKXFe.cjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.DSYK4jT-.cjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CRB6xnLW.mjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.jL_zqxTz.mjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CugLU3-b.js';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CpTWU-gb.js';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CHfsKXFe.cjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.DSYK4jT-.cjs';
2
2
  import { Db } from 'mongodb';
3
3
  import 'kysely';
4
4
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CRB6xnLW.mjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.jL_zqxTz.mjs';
2
2
  import { Db } from 'mongodb';
3
3
  import 'kysely';
4
4
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CugLU3-b.js';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CpTWU-gb.js';
2
2
  import { Db } from 'mongodb';
3
3
  import 'kysely';
4
4
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CHfsKXFe.cjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.DSYK4jT-.cjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CRB6xnLW.mjs';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.jL_zqxTz.mjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CugLU3-b.js';
1
+ import { A as AdapterDebugLogs, B as BetterAuthOptions, a as Adapter } from '../../shared/better-auth.CpTWU-gb.js';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CHfsKXFe.cjs';
1
+ import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.DSYK4jT-.cjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CRB6xnLW.mjs';
1
+ import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.jL_zqxTz.mjs';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CugLU3-b.js';
1
+ import { B as BetterAuthOptions, a as Adapter } from '../shared/better-auth.CpTWU-gb.js';
2
2
  import 'kysely';
3
3
  import 'better-call';
4
4
  import 'zod/v4';
@@ -1,14 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const betterCall = require('better-call');
4
- const socialProviders_index = require('../shared/better-auth.CdpTx0Tt.cjs');
4
+ const socialProviders_index = require('../shared/better-auth.Bx3RgYZf.cjs');
5
5
  const z = require('zod/v4');
6
6
  const cookies_index = require('../cookies/index.cjs');
7
7
  const schema = require('../shared/better-auth.BIMq4RPW.cjs');
8
8
  const env = require('../shared/better-auth.B6fIklBU.cjs');
9
9
  const logger = require('../shared/better-auth.CXhVNgXP.cjs');
10
10
  const getRequestIp = require('../shared/better-auth.Cxlqz5AU.cjs');
11
- const defu = require('defu');
12
11
  require('../shared/better-auth.C1hdVENX.cjs');
13
12
  require('@better-auth/utils/hash');
14
13
  require('@better-auth/utils/base64');
@@ -30,8 +29,7 @@ require('../shared/better-auth.D3mtHEZg.cjs');
30
29
  require('@better-auth/utils/hmac');
31
30
  require('@better-auth/utils/binary');
32
31
  require('jose/errors');
33
-
34
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
32
+ require('defu');
35
33
 
36
34
  function _interopNamespaceCompat(e) {
37
35
  if (e && typeof e === 'object' && 'default' in e) return e;
@@ -46,7 +44,6 @@ function _interopNamespaceCompat(e) {
46
44
  }
47
45
 
48
46
  const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
49
- const defu__default = /*#__PURE__*/_interopDefaultCompat(defu);
50
47
 
51
48
  const signUpEmail = () => socialProviders_index.createAuthEndpoint(
52
49
  "/sign-up/email",
@@ -516,168 +513,6 @@ function getDefaultSpecialRules() {
516
513
  return specialRules;
517
514
  }
518
515
 
519
- function toAuthEndpoints(endpoints, ctx) {
520
- const api = {};
521
- for (const [key, endpoint] of Object.entries(endpoints)) {
522
- api[key] = async (context) => {
523
- const authContext = await ctx;
524
- let internalContext = {
525
- ...context,
526
- context: {
527
- ...authContext,
528
- returned: void 0,
529
- responseHeaders: void 0,
530
- session: null
531
- },
532
- path: endpoint.path,
533
- headers: context?.headers ? new Headers(context?.headers) : void 0
534
- };
535
- const { beforeHooks, afterHooks } = getHooks(authContext);
536
- const before = await runBeforeHooks(internalContext, beforeHooks);
537
- if ("context" in before && before.context && typeof before.context === "object") {
538
- const { headers, ...rest } = before.context;
539
- if (headers) {
540
- headers.forEach((value, key2) => {
541
- internalContext.headers.set(key2, value);
542
- });
543
- }
544
- internalContext = defu__default(rest, internalContext);
545
- } else if (before) {
546
- return before;
547
- }
548
- internalContext.asResponse = false;
549
- internalContext.returnHeaders = true;
550
- const result = await endpoint(internalContext).catch((e) => {
551
- if (e instanceof betterCall.APIError) {
552
- return {
553
- response: e,
554
- headers: e.headers ? new Headers(e.headers) : null
555
- };
556
- }
557
- throw e;
558
- });
559
- internalContext.context.returned = result.response;
560
- internalContext.context.responseHeaders = result.headers;
561
- const after = await runAfterHooks(internalContext, afterHooks);
562
- if (after.response) {
563
- result.response = after.response;
564
- }
565
- if (result.response instanceof betterCall.APIError && !context?.asResponse) {
566
- throw result.response;
567
- }
568
- const response = context?.asResponse ? betterCall.toResponse(result.response, {
569
- headers: result.headers
570
- }) : context?.returnHeaders ? {
571
- headers: result.headers,
572
- response: result.response
573
- } : result.response;
574
- return response;
575
- };
576
- api[key].path = endpoint.path;
577
- api[key].options = endpoint.options;
578
- }
579
- return api;
580
- }
581
- async function runBeforeHooks(context, hooks) {
582
- let modifiedContext = {};
583
- for (const hook of hooks) {
584
- if (hook.matcher(context)) {
585
- const result = await hook.handler({
586
- ...context,
587
- returnHeaders: false
588
- });
589
- if (result && typeof result === "object") {
590
- if ("context" in result && typeof result.context === "object") {
591
- const { headers, ...rest } = result.context;
592
- if (headers instanceof Headers) {
593
- if (modifiedContext.headers) {
594
- headers.forEach((value, key) => {
595
- modifiedContext.headers?.set(key, value);
596
- });
597
- } else {
598
- modifiedContext.headers = headers;
599
- }
600
- }
601
- modifiedContext = defu__default(rest, modifiedContext);
602
- continue;
603
- }
604
- return result;
605
- }
606
- }
607
- }
608
- return { context: modifiedContext };
609
- }
610
- async function runAfterHooks(context, hooks) {
611
- for (const hook of hooks) {
612
- if (hook.matcher(context)) {
613
- const result = await hook.handler(context).catch((e) => {
614
- if (e instanceof betterCall.APIError) {
615
- return {
616
- response: e,
617
- headers: e.headers ? new Headers(e.headers) : null
618
- };
619
- }
620
- throw e;
621
- });
622
- if (result.headers) {
623
- result.headers.forEach((value, key) => {
624
- if (!context.context.responseHeaders) {
625
- context.context.responseHeaders = new Headers({
626
- [key]: value
627
- });
628
- } else {
629
- if (key.toLowerCase() === "set-cookie") {
630
- context.context.responseHeaders.append(key, value);
631
- } else {
632
- context.context.responseHeaders.set(key, value);
633
- }
634
- }
635
- });
636
- }
637
- if (result.response) {
638
- context.context.returned = result.response;
639
- }
640
- }
641
- }
642
- return {
643
- response: context.context.returned,
644
- headers: context.context.responseHeaders
645
- };
646
- }
647
- function getHooks(authContext) {
648
- const plugins = authContext.options.plugins || [];
649
- const beforeHooks = [];
650
- const afterHooks = [];
651
- if (authContext.options.hooks?.before) {
652
- beforeHooks.push({
653
- matcher: () => true,
654
- handler: authContext.options.hooks.before
655
- });
656
- }
657
- if (authContext.options.hooks?.after) {
658
- afterHooks.push({
659
- matcher: () => true,
660
- handler: authContext.options.hooks.after
661
- });
662
- }
663
- const pluginBeforeHooks = plugins.map((plugin) => {
664
- if (plugin.hooks?.before) {
665
- return plugin.hooks.before;
666
- }
667
- }).filter((plugin) => plugin !== void 0).flat();
668
- const pluginAfterHooks = plugins.map((plugin) => {
669
- if (plugin.hooks?.after) {
670
- return plugin.hooks.after;
671
- }
672
- }).filter((plugin) => plugin !== void 0).flat();
673
- pluginBeforeHooks.length && beforeHooks.push(...pluginBeforeHooks);
674
- pluginAfterHooks.length && afterHooks.push(...pluginAfterHooks);
675
- return {
676
- beforeHooks,
677
- afterHooks
678
- };
679
- }
680
-
681
516
  function getEndpoints(ctx, options) {
682
517
  const pluginEndpoints = options.plugins?.reduce(
683
518
  (acc, plugin) => {
@@ -744,7 +579,7 @@ function getEndpoints(ctx, options) {
744
579
  ok: socialProviders_index.ok,
745
580
  error: socialProviders_index.error
746
581
  };
747
- const api = toAuthEndpoints(endpoints, ctx);
582
+ const api = socialProviders_index.toAuthEndpoints(endpoints, ctx);
748
583
  return {
749
584
  api,
750
585
  middlewares
@@ -1,5 +1,5 @@
1
1
  import '../shared/better-auth.DSvLrleU.cjs';
2
- export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.CHfsKXFe.cjs';
2
+ export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.DSYK4jT-.cjs';
3
3
  export { APIError } from 'better-call';
4
4
  import '../shared/better-auth.BDR52Rf2.cjs';
5
5
  import 'zod/v4/core';
@@ -1,5 +1,5 @@
1
1
  import '../shared/better-auth.BFod4hxi.mjs';
2
- export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.CRB6xnLW.mjs';
2
+ export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.jL_zqxTz.mjs';
3
3
  export { APIError } from 'better-call';
4
4
  import '../shared/better-auth.BDR52Rf2.mjs';
5
5
  import 'zod/v4/core';
@@ -1,5 +1,5 @@
1
1
  import '../shared/better-auth.B-pjewPT.js';
2
- export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.CugLU3-b.js';
2
+ export { l as AuthEndpoint, m as AuthMiddleware, bm as accountInfo, aQ as callbackOAuth, bd as changeEmail, b9 as changePassword, k as createAuthEndpoint, j as createAuthMiddleware, b4 as createEmailVerificationToken, bb as deleteUser, bc as deleteUserCallback, be as error, b0 as forgetPassword, b2 as forgetPasswordCallback, aV as freshSessionMiddleware, bk as getAccessToken, aM as getEndpoints, aR as getSession, aS as getSessionFromCtx, bi as linkSocialAccount, aW as listSessions, bh as listUserAccounts, bf as ok, o as optionsMiddleware, bo as originCheck, bn as originCheckMiddleware, bl as refreshToken, aU as requestOnlySessionMiddleware, a$ as requestPasswordReset, b1 as requestPasswordResetCallback, b3 as resetPassword, aZ as revokeOtherSessions, aX as revokeSession, aY as revokeSessions, aN as router, b6 as sendVerificationEmail, b5 as sendVerificationEmailFn, aT as sessionMiddleware, ba as setPassword, aP as signInEmail, aO as signInSocial, a_ as signOut, bg as signUpEmail, bj as unlinkAccount, b8 as updateUser, b7 as verifyEmail } from '../shared/better-auth.CpTWU-gb.js';
3
3
  export { APIError } from 'better-call';
4
4
  import '../shared/better-auth.BDR52Rf2.js';
5
5
  import 'zod/v4/core';
@@ -1,14 +1,13 @@
1
- import { APIError, toResponse, createRouter } from 'better-call';
1
+ import { APIError, createRouter } from 'better-call';
2
2
  export { APIError } from 'better-call';
3
- import { j as createAuthEndpoint, B as BASE_ERROR_CODES, u as createEmailVerificationToken, w as wildcardMatch, x as listSessions, y as updateUser, m as getSession, z as originCheckMiddleware, A as error, C as ok, D as accountInfo, E as getAccessToken, F as refreshToken, G as unlinkAccount, I as deleteUserCallback, J as listUserAccounts, K as linkSocialAccount, L as revokeOtherSessions, M as revokeSessions, N as revokeSession, O as requestPasswordResetCallback, P as requestPasswordReset, Q as forgetPasswordCallback, R as deleteUser, S as setPassword, T as changePassword, U as changeEmail, V as sendVerificationEmail, W as verifyEmail, X as resetPassword, Y as forgetPassword, Z as signInEmail, _ as signOut, $ as callbackOAuth, a0 as signInSocial } from '../shared/better-auth.CJJar71A.mjs';
4
- export { i as createAuthMiddleware, n as freshSessionMiddleware, k as getSessionFromCtx, q as optionsMiddleware, o as originCheck, a1 as requestOnlySessionMiddleware, t as sendVerificationEmailFn, l as sessionMiddleware } from '../shared/better-auth.CJJar71A.mjs';
3
+ import { j as createAuthEndpoint, B as BASE_ERROR_CODES, t as createEmailVerificationToken, w as wildcardMatch, u as listSessions, x as updateUser, m as getSession, y as toAuthEndpoints, z as originCheckMiddleware, A as error, C as ok, D as accountInfo, E as getAccessToken, F as refreshToken, G as unlinkAccount, I as deleteUserCallback, J as listUserAccounts, K as linkSocialAccount, L as revokeOtherSessions, M as revokeSessions, N as revokeSession, O as requestPasswordResetCallback, P as requestPasswordReset, Q as forgetPasswordCallback, R as deleteUser, S as setPassword, T as changePassword, U as changeEmail, V as sendVerificationEmail, W as verifyEmail, X as resetPassword, Y as forgetPassword, Z as signInEmail, _ as signOut, $ as callbackOAuth, a0 as signInSocial } from '../shared/better-auth.C3R00PmH.mjs';
4
+ export { i as createAuthMiddleware, n as freshSessionMiddleware, k as getSessionFromCtx, q as optionsMiddleware, o as originCheck, a1 as requestOnlySessionMiddleware, a2 as sendVerificationEmailFn, l as sessionMiddleware } from '../shared/better-auth.C3R00PmH.mjs';
5
5
  import * as z from 'zod/v4';
6
6
  import { setSessionCookie } from '../cookies/index.mjs';
7
7
  import { f as parseUserInput } from '../shared/better-auth.n2KFGwjY.mjs';
8
8
  import { b as isDevelopment } from '../shared/better-auth.CMQ3rA-I.mjs';
9
9
  import { a as logger } from '../shared/better-auth.DBGfIDnh.mjs';
10
10
  import { g as getIp } from '../shared/better-auth.O2VtDkDK.mjs';
11
- import defu from 'defu';
12
11
  import '../shared/better-auth.CW6D9eSx.mjs';
13
12
  import '@better-auth/utils/hash';
14
13
  import '@better-auth/utils/base64';
@@ -30,6 +29,7 @@ import '../shared/better-auth.tB5eU6EY.mjs';
30
29
  import '@better-auth/utils/hmac';
31
30
  import '@better-auth/utils/binary';
32
31
  import 'jose/errors';
32
+ import 'defu';
33
33
 
34
34
  const signUpEmail = () => createAuthEndpoint(
35
35
  "/sign-up/email",
@@ -499,168 +499,6 @@ function getDefaultSpecialRules() {
499
499
  return specialRules;
500
500
  }
501
501
 
502
- function toAuthEndpoints(endpoints, ctx) {
503
- const api = {};
504
- for (const [key, endpoint] of Object.entries(endpoints)) {
505
- api[key] = async (context) => {
506
- const authContext = await ctx;
507
- let internalContext = {
508
- ...context,
509
- context: {
510
- ...authContext,
511
- returned: void 0,
512
- responseHeaders: void 0,
513
- session: null
514
- },
515
- path: endpoint.path,
516
- headers: context?.headers ? new Headers(context?.headers) : void 0
517
- };
518
- const { beforeHooks, afterHooks } = getHooks(authContext);
519
- const before = await runBeforeHooks(internalContext, beforeHooks);
520
- if ("context" in before && before.context && typeof before.context === "object") {
521
- const { headers, ...rest } = before.context;
522
- if (headers) {
523
- headers.forEach((value, key2) => {
524
- internalContext.headers.set(key2, value);
525
- });
526
- }
527
- internalContext = defu(rest, internalContext);
528
- } else if (before) {
529
- return before;
530
- }
531
- internalContext.asResponse = false;
532
- internalContext.returnHeaders = true;
533
- const result = await endpoint(internalContext).catch((e) => {
534
- if (e instanceof APIError) {
535
- return {
536
- response: e,
537
- headers: e.headers ? new Headers(e.headers) : null
538
- };
539
- }
540
- throw e;
541
- });
542
- internalContext.context.returned = result.response;
543
- internalContext.context.responseHeaders = result.headers;
544
- const after = await runAfterHooks(internalContext, afterHooks);
545
- if (after.response) {
546
- result.response = after.response;
547
- }
548
- if (result.response instanceof APIError && !context?.asResponse) {
549
- throw result.response;
550
- }
551
- const response = context?.asResponse ? toResponse(result.response, {
552
- headers: result.headers
553
- }) : context?.returnHeaders ? {
554
- headers: result.headers,
555
- response: result.response
556
- } : result.response;
557
- return response;
558
- };
559
- api[key].path = endpoint.path;
560
- api[key].options = endpoint.options;
561
- }
562
- return api;
563
- }
564
- async function runBeforeHooks(context, hooks) {
565
- let modifiedContext = {};
566
- for (const hook of hooks) {
567
- if (hook.matcher(context)) {
568
- const result = await hook.handler({
569
- ...context,
570
- returnHeaders: false
571
- });
572
- if (result && typeof result === "object") {
573
- if ("context" in result && typeof result.context === "object") {
574
- const { headers, ...rest } = result.context;
575
- if (headers instanceof Headers) {
576
- if (modifiedContext.headers) {
577
- headers.forEach((value, key) => {
578
- modifiedContext.headers?.set(key, value);
579
- });
580
- } else {
581
- modifiedContext.headers = headers;
582
- }
583
- }
584
- modifiedContext = defu(rest, modifiedContext);
585
- continue;
586
- }
587
- return result;
588
- }
589
- }
590
- }
591
- return { context: modifiedContext };
592
- }
593
- async function runAfterHooks(context, hooks) {
594
- for (const hook of hooks) {
595
- if (hook.matcher(context)) {
596
- const result = await hook.handler(context).catch((e) => {
597
- if (e instanceof APIError) {
598
- return {
599
- response: e,
600
- headers: e.headers ? new Headers(e.headers) : null
601
- };
602
- }
603
- throw e;
604
- });
605
- if (result.headers) {
606
- result.headers.forEach((value, key) => {
607
- if (!context.context.responseHeaders) {
608
- context.context.responseHeaders = new Headers({
609
- [key]: value
610
- });
611
- } else {
612
- if (key.toLowerCase() === "set-cookie") {
613
- context.context.responseHeaders.append(key, value);
614
- } else {
615
- context.context.responseHeaders.set(key, value);
616
- }
617
- }
618
- });
619
- }
620
- if (result.response) {
621
- context.context.returned = result.response;
622
- }
623
- }
624
- }
625
- return {
626
- response: context.context.returned,
627
- headers: context.context.responseHeaders
628
- };
629
- }
630
- function getHooks(authContext) {
631
- const plugins = authContext.options.plugins || [];
632
- const beforeHooks = [];
633
- const afterHooks = [];
634
- if (authContext.options.hooks?.before) {
635
- beforeHooks.push({
636
- matcher: () => true,
637
- handler: authContext.options.hooks.before
638
- });
639
- }
640
- if (authContext.options.hooks?.after) {
641
- afterHooks.push({
642
- matcher: () => true,
643
- handler: authContext.options.hooks.after
644
- });
645
- }
646
- const pluginBeforeHooks = plugins.map((plugin) => {
647
- if (plugin.hooks?.before) {
648
- return plugin.hooks.before;
649
- }
650
- }).filter((plugin) => plugin !== void 0).flat();
651
- const pluginAfterHooks = plugins.map((plugin) => {
652
- if (plugin.hooks?.after) {
653
- return plugin.hooks.after;
654
- }
655
- }).filter((plugin) => plugin !== void 0).flat();
656
- pluginBeforeHooks.length && beforeHooks.push(...pluginBeforeHooks);
657
- pluginAfterHooks.length && afterHooks.push(...pluginAfterHooks);
658
- return {
659
- beforeHooks,
660
- afterHooks
661
- };
662
- }
663
-
664
502
  function getEndpoints(ctx, options) {
665
503
  const pluginEndpoints = options.plugins?.reduce(
666
504
  (acc, plugin) => {