better-auth 1.2.6-beta.7 → 1.2.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/dist/adapters/drizzle-adapter/index.cjs +186 -249
  2. package/dist/adapters/drizzle-adapter/index.d.cts +11 -49
  3. package/dist/adapters/drizzle-adapter/index.d.mts +11 -49
  4. package/dist/adapters/drizzle-adapter/index.d.ts +11 -49
  5. package/dist/adapters/drizzle-adapter/index.mjs +186 -249
  6. package/dist/adapters/index.cjs +26 -0
  7. package/dist/adapters/index.d.cts +17 -0
  8. package/dist/adapters/index.d.mts +17 -0
  9. package/dist/adapters/index.d.ts +17 -0
  10. package/dist/adapters/index.mjs +20 -0
  11. package/dist/adapters/kysely-adapter/index.cjs +7 -7
  12. package/dist/adapters/kysely-adapter/index.d.cts +17 -49
  13. package/dist/adapters/kysely-adapter/index.d.mts +17 -49
  14. package/dist/adapters/kysely-adapter/index.d.ts +17 -49
  15. package/dist/adapters/kysely-adapter/index.mjs +8 -8
  16. package/dist/adapters/memory-adapter/index.cjs +7 -8
  17. package/dist/adapters/memory-adapter/index.d.cts +9 -49
  18. package/dist/adapters/memory-adapter/index.d.mts +9 -49
  19. package/dist/adapters/memory-adapter/index.d.ts +9 -49
  20. package/dist/adapters/memory-adapter/index.mjs +8 -9
  21. package/dist/adapters/mongodb-adapter/index.cjs +2 -2
  22. package/dist/adapters/mongodb-adapter/index.d.cts +4 -4
  23. package/dist/adapters/mongodb-adapter/index.d.mts +4 -4
  24. package/dist/adapters/mongodb-adapter/index.d.ts +4 -4
  25. package/dist/adapters/mongodb-adapter/index.mjs +3 -3
  26. package/dist/adapters/prisma-adapter/index.cjs +130 -203
  27. package/dist/adapters/prisma-adapter/index.d.cts +17 -49
  28. package/dist/adapters/prisma-adapter/index.d.mts +17 -49
  29. package/dist/adapters/prisma-adapter/index.d.ts +17 -49
  30. package/dist/adapters/prisma-adapter/index.mjs +131 -204
  31. package/dist/adapters/test.cjs +710 -377
  32. package/dist/adapters/test.d.cts +64 -5
  33. package/dist/adapters/test.d.mts +64 -5
  34. package/dist/adapters/test.d.ts +64 -5
  35. package/dist/adapters/test.mjs +712 -380
  36. package/dist/api/index.cjs +61 -25
  37. package/dist/api/index.d.cts +3 -3
  38. package/dist/api/index.d.mts +3 -3
  39. package/dist/api/index.d.ts +3 -3
  40. package/dist/api/index.mjs +63 -27
  41. package/dist/client/index.d.cts +3 -3
  42. package/dist/client/index.d.mts +3 -3
  43. package/dist/client/index.d.ts +3 -3
  44. package/dist/client/plugins/index.cjs +13 -15
  45. package/dist/client/plugins/index.d.cts +80 -19
  46. package/dist/client/plugins/index.d.mts +80 -19
  47. package/dist/client/plugins/index.d.ts +80 -19
  48. package/dist/client/plugins/index.mjs +13 -16
  49. package/dist/client/react/index.cjs +4 -4
  50. package/dist/client/react/index.d.cts +3 -3
  51. package/dist/client/react/index.d.mts +3 -3
  52. package/dist/client/react/index.d.ts +3 -3
  53. package/dist/client/solid/index.d.cts +3 -3
  54. package/dist/client/solid/index.d.mts +3 -3
  55. package/dist/client/solid/index.d.ts +3 -3
  56. package/dist/client/svelte/index.d.cts +3 -3
  57. package/dist/client/svelte/index.d.mts +3 -3
  58. package/dist/client/svelte/index.d.ts +3 -3
  59. package/dist/client/vue/index.d.cts +3 -3
  60. package/dist/client/vue/index.d.mts +3 -3
  61. package/dist/client/vue/index.d.ts +3 -3
  62. package/dist/cookies/index.cjs +13 -2
  63. package/dist/cookies/index.d.cts +3 -3
  64. package/dist/cookies/index.d.mts +3 -3
  65. package/dist/cookies/index.d.ts +3 -3
  66. package/dist/cookies/index.mjs +13 -2
  67. package/dist/db/index.cjs +6 -5
  68. package/dist/db/index.d.cts +4 -4
  69. package/dist/db/index.d.mts +4 -4
  70. package/dist/db/index.d.ts +4 -4
  71. package/dist/db/index.mjs +7 -6
  72. package/dist/index.cjs +11 -7
  73. package/dist/index.d.cts +4 -4
  74. package/dist/index.d.mts +4 -4
  75. package/dist/index.d.ts +4 -4
  76. package/dist/index.mjs +14 -10
  77. package/dist/integrations/next-js.cjs +4 -5
  78. package/dist/integrations/next-js.d.cts +3 -3
  79. package/dist/integrations/next-js.d.mts +3 -3
  80. package/dist/integrations/next-js.d.ts +3 -3
  81. package/dist/integrations/next-js.mjs +5 -6
  82. package/dist/integrations/node.d.cts +3 -3
  83. package/dist/integrations/node.d.mts +3 -3
  84. package/dist/integrations/node.d.ts +3 -3
  85. package/dist/integrations/react-start.cjs +5 -6
  86. package/dist/integrations/react-start.d.cts +3 -3
  87. package/dist/integrations/react-start.d.mts +3 -3
  88. package/dist/integrations/react-start.d.ts +3 -3
  89. package/dist/integrations/react-start.mjs +6 -7
  90. package/dist/integrations/svelte-kit.d.cts +3 -3
  91. package/dist/integrations/svelte-kit.d.mts +3 -3
  92. package/dist/integrations/svelte-kit.d.ts +3 -3
  93. package/dist/oauth2/index.d.cts +5 -5
  94. package/dist/oauth2/index.d.mts +5 -5
  95. package/dist/oauth2/index.d.ts +5 -5
  96. package/dist/plugins/access/index.d.cts +1 -1
  97. package/dist/plugins/access/index.d.mts +1 -1
  98. package/dist/plugins/access/index.d.ts +1 -1
  99. package/dist/plugins/admin/access/index.d.cts +1 -1
  100. package/dist/plugins/admin/access/index.d.mts +1 -1
  101. package/dist/plugins/admin/access/index.d.ts +1 -1
  102. package/dist/plugins/admin/index.cjs +4 -4
  103. package/dist/plugins/admin/index.d.cts +74 -14
  104. package/dist/plugins/admin/index.d.mts +74 -14
  105. package/dist/plugins/admin/index.d.ts +74 -14
  106. package/dist/plugins/admin/index.mjs +5 -5
  107. package/dist/plugins/anonymous/index.cjs +4 -5
  108. package/dist/plugins/anonymous/index.d.cts +3 -3
  109. package/dist/plugins/anonymous/index.d.mts +3 -3
  110. package/dist/plugins/anonymous/index.d.ts +3 -3
  111. package/dist/plugins/anonymous/index.mjs +5 -6
  112. package/dist/plugins/bearer/index.cjs +2 -2
  113. package/dist/plugins/bearer/index.d.cts +3 -3
  114. package/dist/plugins/bearer/index.d.mts +3 -3
  115. package/dist/plugins/bearer/index.d.ts +3 -3
  116. package/dist/plugins/bearer/index.mjs +3 -3
  117. package/dist/plugins/captcha/index.cjs +110 -45
  118. package/dist/plugins/captcha/index.d.cts +26 -6
  119. package/dist/plugins/captcha/index.d.mts +26 -6
  120. package/dist/plugins/captcha/index.d.ts +26 -6
  121. package/dist/plugins/captcha/index.mjs +110 -45
  122. package/dist/plugins/custom-session/index.cjs +24 -5
  123. package/dist/plugins/custom-session/index.d.cts +25 -6
  124. package/dist/plugins/custom-session/index.d.mts +25 -6
  125. package/dist/plugins/custom-session/index.d.ts +25 -6
  126. package/dist/plugins/custom-session/index.mjs +25 -6
  127. package/dist/plugins/email-otp/index.cjs +96 -30
  128. package/dist/plugins/email-otp/index.d.cts +33 -10
  129. package/dist/plugins/email-otp/index.d.mts +33 -10
  130. package/dist/plugins/email-otp/index.d.ts +33 -10
  131. package/dist/plugins/email-otp/index.mjs +97 -31
  132. package/dist/plugins/generic-oauth/index.cjs +81 -20
  133. package/dist/plugins/generic-oauth/index.d.cts +46 -3
  134. package/dist/plugins/generic-oauth/index.d.mts +46 -3
  135. package/dist/plugins/generic-oauth/index.d.ts +46 -3
  136. package/dist/plugins/generic-oauth/index.mjs +82 -21
  137. package/dist/plugins/haveibeenpwned/index.cjs +98 -0
  138. package/dist/plugins/haveibeenpwned/index.d.cts +36 -0
  139. package/dist/plugins/haveibeenpwned/index.d.mts +36 -0
  140. package/dist/plugins/haveibeenpwned/index.d.ts +36 -0
  141. package/dist/plugins/haveibeenpwned/index.mjs +96 -0
  142. package/dist/plugins/index.cjs +583 -19
  143. package/dist/plugins/index.d.cts +7 -5
  144. package/dist/plugins/index.d.mts +7 -5
  145. package/dist/plugins/index.d.ts +7 -5
  146. package/dist/plugins/index.mjs +583 -21
  147. package/dist/plugins/jwt/index.cjs +45 -21
  148. package/dist/plugins/jwt/index.d.cts +52 -6
  149. package/dist/plugins/jwt/index.d.mts +52 -6
  150. package/dist/plugins/jwt/index.d.ts +52 -6
  151. package/dist/plugins/jwt/index.mjs +46 -22
  152. package/dist/plugins/magic-link/index.cjs +3 -3
  153. package/dist/plugins/magic-link/index.mjs +4 -4
  154. package/dist/plugins/multi-session/index.cjs +3 -3
  155. package/dist/plugins/multi-session/index.d.cts +3 -3
  156. package/dist/plugins/multi-session/index.d.mts +3 -3
  157. package/dist/plugins/multi-session/index.d.ts +3 -3
  158. package/dist/plugins/multi-session/index.mjs +4 -4
  159. package/dist/plugins/oauth-proxy/index.cjs +4 -4
  160. package/dist/plugins/oauth-proxy/index.d.cts +3 -3
  161. package/dist/plugins/oauth-proxy/index.d.mts +3 -3
  162. package/dist/plugins/oauth-proxy/index.d.ts +3 -3
  163. package/dist/plugins/oauth-proxy/index.mjs +5 -5
  164. package/dist/plugins/oidc-provider/index.cjs +227 -8
  165. package/dist/plugins/oidc-provider/index.d.cts +215 -3
  166. package/dist/plugins/oidc-provider/index.d.mts +215 -3
  167. package/dist/plugins/oidc-provider/index.d.ts +215 -3
  168. package/dist/plugins/oidc-provider/index.mjs +228 -9
  169. package/dist/plugins/one-tap/index.cjs +5 -5
  170. package/dist/plugins/one-tap/index.mjs +6 -6
  171. package/dist/plugins/one-time-token/index.cjs +119 -0
  172. package/dist/plugins/one-time-token/index.d.cts +134 -0
  173. package/dist/plugins/one-time-token/index.d.mts +134 -0
  174. package/dist/plugins/one-time-token/index.d.ts +134 -0
  175. package/dist/plugins/one-time-token/index.mjs +117 -0
  176. package/dist/plugins/open-api/index.cjs +3 -3
  177. package/dist/plugins/open-api/index.d.cts +3 -3
  178. package/dist/plugins/open-api/index.d.mts +3 -3
  179. package/dist/plugins/open-api/index.d.ts +3 -3
  180. package/dist/plugins/open-api/index.mjs +4 -4
  181. package/dist/plugins/organization/access/index.d.cts +1 -1
  182. package/dist/plugins/organization/access/index.d.mts +1 -1
  183. package/dist/plugins/organization/access/index.d.ts +1 -1
  184. package/dist/plugins/organization/index.cjs +4 -4
  185. package/dist/plugins/organization/index.d.cts +708 -55
  186. package/dist/plugins/organization/index.d.mts +708 -55
  187. package/dist/plugins/organization/index.d.ts +708 -55
  188. package/dist/plugins/organization/index.mjs +5 -5
  189. package/dist/plugins/passkey/index.cjs +82 -8
  190. package/dist/plugins/passkey/index.d.cts +72 -3
  191. package/dist/plugins/passkey/index.d.mts +72 -3
  192. package/dist/plugins/passkey/index.d.ts +72 -3
  193. package/dist/plugins/passkey/index.mjs +83 -9
  194. package/dist/plugins/phone-number/index.cjs +194 -26
  195. package/dist/plugins/phone-number/index.d.cts +132 -8
  196. package/dist/plugins/phone-number/index.d.mts +132 -8
  197. package/dist/plugins/phone-number/index.d.ts +132 -8
  198. package/dist/plugins/phone-number/index.mjs +195 -27
  199. package/dist/plugins/sso/index.cjs +190 -7
  200. package/dist/plugins/sso/index.d.cts +181 -15
  201. package/dist/plugins/sso/index.d.mts +181 -15
  202. package/dist/plugins/sso/index.d.ts +181 -15
  203. package/dist/plugins/sso/index.mjs +191 -8
  204. package/dist/plugins/two-factor/index.cjs +443 -92
  205. package/dist/plugins/two-factor/index.d.cts +230 -396
  206. package/dist/plugins/two-factor/index.d.mts +230 -396
  207. package/dist/plugins/two-factor/index.d.ts +230 -396
  208. package/dist/plugins/two-factor/index.mjs +431 -80
  209. package/dist/plugins/username/index.cjs +34 -31
  210. package/dist/plugins/username/index.d.cts +15 -12
  211. package/dist/plugins/username/index.d.mts +15 -12
  212. package/dist/plugins/username/index.d.ts +15 -12
  213. package/dist/plugins/username/index.mjs +35 -32
  214. package/dist/shared/better-auth.1DR6suCQ.mjs +307 -0
  215. package/dist/shared/{better-auth.BSsp73pg.cjs → better-auth.B7cZ2juS.cjs} +15 -14
  216. package/dist/shared/{better-auth.bKwabe3I.d.mts → better-auth.B88xucNq.d.mts} +529 -39
  217. package/dist/shared/{better-auth.CApEjVDP.cjs → better-auth.BW8BpneG.cjs} +4 -1
  218. package/dist/shared/{better-auth.BiQsvaIP.d.cts → better-auth.BcU1Kjyq.d.cts} +2051 -518
  219. package/dist/shared/better-auth.BfG24BjZ.cjs +118 -0
  220. package/dist/shared/{better-auth.A3TjrU8G.mjs → better-auth.Bk5IMdhM.mjs} +32 -12
  221. package/dist/shared/{better-auth.D9VnBkRI.mjs → better-auth.Bm9HxIzE.mjs} +47 -24
  222. package/dist/shared/{better-auth.BRf6Iynu.d.ts → better-auth.Bwc-6kOr.d.ts} +1 -1
  223. package/dist/shared/{better-auth.D-oLmHIj.d.mts → better-auth.CA2hFK4N.d.ts} +2051 -518
  224. package/dist/shared/{better-auth.Dmhe30iW.d.mts → better-auth.CGukGrxT.d.cts} +1 -1
  225. package/dist/shared/{better-auth.CsSpq0zL.cjs → better-auth.CHUzBidy.cjs} +46 -23
  226. package/dist/shared/{better-auth.DWRligF8.d.cts → better-auth.CT9J6rD-.d.cts} +539 -7
  227. package/dist/shared/better-auth.CVCo5Z2T.cjs +310 -0
  228. package/dist/shared/{better-auth.D4jH-sJA.mjs → better-auth.CWwVo_61.mjs} +458 -118
  229. package/dist/shared/{better-auth.Bi8FQwDD.d.cts → better-auth.CYegVoq1.d.cts} +1 -1
  230. package/dist/shared/{better-auth.Bi8FQwDD.d.mts → better-auth.CYegVoq1.d.mts} +1 -1
  231. package/dist/shared/{better-auth.Bi8FQwDD.d.ts → better-auth.CYegVoq1.d.ts} +1 -1
  232. package/dist/shared/{better-auth.CepcSj5H.mjs → better-auth.Cc72UxUH.mjs} +1 -2
  233. package/dist/shared/{better-auth.BWp5dztg.d.ts → better-auth.CmN4mlPh.d.ts} +539 -7
  234. package/dist/shared/{better-auth.DH3YjMQH.mjs → better-auth.Cqykj82J.mjs} +1 -1
  235. package/dist/shared/{better-auth.wcdMj2cT.d.mts → better-auth.DIt2e3lu.d.mts} +539 -7
  236. package/dist/shared/{better-auth.BANAxdkL.d.ts → better-auth.DNTAFSt1.d.ts} +529 -39
  237. package/dist/shared/{better-auth.DU2QNVc_.d.ts → better-auth.DQ7OSJbI.d.mts} +2051 -518
  238. package/dist/shared/{better-auth.DLTzKoOS.cjs → better-auth.DSVbLSt7.cjs} +4 -1
  239. package/dist/shared/{better-auth.B2Fw1vhH.d.cts → better-auth.DTiSPWEk.d.cts} +529 -39
  240. package/dist/shared/better-auth.DURsStt9.mjs +116 -0
  241. package/dist/shared/{better-auth.BIjcZ_vt.cjs → better-auth.DYoLD99C.cjs} +31 -11
  242. package/dist/shared/{better-auth.CV1L7TPV.cjs → better-auth.D_ZIX1O8.cjs} +317 -47
  243. package/dist/shared/{better-auth.C5H9XEzZ.cjs → better-auth.DcWKCjjf.cjs} +1 -2
  244. package/dist/shared/{better-auth.BDYXUcLv.cjs → better-auth.Dg0siV5C.cjs} +457 -117
  245. package/dist/shared/better-auth.DjryM8pE.cjs +760 -0
  246. package/dist/shared/{better-auth.DPBQN9Fs.mjs → better-auth.Dn_Ms1Uf.mjs} +318 -48
  247. package/dist/shared/{better-auth.DiG4KL2x.mjs → better-auth.OuYYTHC7.mjs} +4 -1
  248. package/dist/shared/{better-auth.DtC8i3pf.d.cts → better-auth.S1jimRbX.d.mts} +1 -1
  249. package/dist/shared/better-auth.SPmq4a4z.d.mts +344 -0
  250. package/dist/shared/{better-auth.cOCrlspr.mjs → better-auth.bkwPl2G4.mjs} +4 -1
  251. package/dist/shared/better-auth.cp2rC2iM.d.ts +344 -0
  252. package/dist/shared/better-auth.eVy4DZvP.d.cts +344 -0
  253. package/dist/shared/{better-auth.BrOpzmqo.mjs → better-auth.iKoUsdFE.mjs} +15 -14
  254. package/dist/shared/better-auth.rSYJCd3o.mjs +758 -0
  255. package/dist/social-providers/index.cjs +75 -3
  256. package/dist/social-providers/index.d.cts +2 -2
  257. package/dist/social-providers/index.d.mts +2 -2
  258. package/dist/social-providers/index.d.ts +2 -2
  259. package/dist/social-providers/index.mjs +77 -6
  260. package/dist/types/index.d.cts +4 -4
  261. package/dist/types/index.d.mts +4 -4
  262. package/dist/types/index.d.ts +4 -4
  263. package/package.json +42 -5
  264. package/dist/chunks/server.cjs +0 -905
  265. package/dist/chunks/server.mjs +0 -895
  266. package/dist/shared/better-auth.BcoSd9tC.mjs +0 -10
  267. package/dist/shared/better-auth.BnRFp-t0.mjs +0 -405
  268. package/dist/shared/better-auth.C1-vpKly.cjs +0 -12
  269. package/dist/shared/better-auth.ClTSOgiD.mjs +0 -140
  270. package/dist/shared/better-auth.DC8JQbiE.mjs +0 -173
  271. package/dist/shared/better-auth.DWHWPllD.cjs +0 -175
  272. package/dist/shared/better-auth.DqLjzBlO.cjs +0 -408
  273. package/dist/shared/better-auth.m575EIBC.cjs +0 -144
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import * as better_call from 'better-call';
3
- import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.D-oLmHIj.mjs';
4
- import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.mjs';
3
+ import { U as User, I as InferOptionSchema, d as AuthEndpoint, H as HookEndpointContext } from '../../shared/better-auth.DQ7OSJbI.mjs';
4
+ import { L as LiteralString } from '../../shared/better-auth.CYegVoq1.mjs';
5
5
  import * as _better_fetch_fetch from '@better-fetch/fetch';
6
- import '../../shared/better-auth.bKwabe3I.mjs';
6
+ import '../../shared/better-auth.B88xucNq.mjs';
7
7
  import 'jose';
8
8
  import 'kysely';
9
9
  import 'better-sqlite3';
@@ -60,6 +60,12 @@ interface OTPOptions {
60
60
  * The request object
61
61
  */
62
62
  request?: Request) => Promise<void> | void;
63
+ /**
64
+ * The number of allowed attempts for the OTP
65
+ *
66
+ * @default 5
67
+ */
68
+ allowedAttempts?: number;
63
69
  }
64
70
 
65
71
  type TOTPOptions = {
@@ -175,6 +181,9 @@ declare const TWO_FACTOR_ERROR_CODES: {
175
181
  readonly TWO_FACTOR_NOT_ENABLED: "Two factor isn't enabled";
176
182
  readonly BACKUP_CODES_NOT_ENABLED: "Backup codes aren't enabled";
177
183
  readonly INVALID_BACKUP_CODE: "Invalid backup code";
184
+ readonly INVALID_CODE: "Invalid code";
185
+ readonly TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: "Too many attempts. Please request a new code.";
186
+ readonly INVALID_TWO_FACTOR_COOKIE: "Invalid two factor cookie";
178
187
  };
179
188
 
180
189
  declare const twoFactorClient: (options?: {
@@ -212,6 +221,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
212
221
  <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
213
222
  body: {
214
223
  password: string;
224
+ issuer?: string | undefined;
215
225
  };
216
226
  } & {
217
227
  method?: "POST" | undefined;
@@ -245,10 +255,13 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
245
255
  method: "POST";
246
256
  body: z.ZodObject<{
247
257
  password: z.ZodString;
258
+ issuer: z.ZodOptional<z.ZodString>;
248
259
  }, "strip", z.ZodTypeAny, {
249
260
  password: string;
261
+ issuer?: string | undefined;
250
262
  }, {
251
263
  password: string;
264
+ issuer?: string | undefined;
252
265
  }>;
253
266
  use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
254
267
  session: {
@@ -428,82 +441,28 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
428
441
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
429
442
  headers: Headers;
430
443
  response: {
431
- user: UserWithTwoFactor;
432
- session: {
433
- session: Session & Record<string, any>;
434
- user: User & Record<string, any>;
435
- } & {
436
- session: {
437
- id: string;
438
- createdAt: Date;
439
- updatedAt: Date;
440
- userId: string;
441
- expiresAt: Date;
442
- token: string;
443
- ipAddress?: string | null | undefined;
444
- userAgent?: string | null | undefined;
445
- };
446
- user: UserWithTwoFactor;
447
- } & {
448
- session: Record<string, any> & {
449
- id: string;
450
- createdAt: Date;
451
- updatedAt: Date;
452
- userId: string;
453
- expiresAt: Date;
454
- token: string;
455
- ipAddress?: string | null | undefined;
456
- userAgent?: string | null | undefined;
457
- };
458
- user: Record<string, any> & {
459
- id: string;
460
- name: string;
461
- email: string;
462
- emailVerified: boolean;
463
- createdAt: Date;
464
- updatedAt: Date;
465
- image?: string | null | undefined;
466
- };
467
- };
468
- };
469
- } : {
470
- user: UserWithTwoFactor;
471
- session: {
472
- session: Session & Record<string, any>;
473
- user: User & Record<string, any>;
474
- } & {
475
- session: {
476
- id: string;
477
- createdAt: Date;
478
- updatedAt: Date;
479
- userId: string;
480
- expiresAt: Date;
481
- token: string;
482
- ipAddress?: string | null | undefined;
483
- userAgent?: string | null | undefined;
484
- };
485
- user: UserWithTwoFactor;
486
- } & {
487
- session: Record<string, any> & {
488
- id: string;
489
- createdAt: Date;
490
- updatedAt: Date;
491
- userId: string;
492
- expiresAt: Date;
493
- token: string;
494
- ipAddress?: string | null | undefined;
495
- userAgent?: string | null | undefined;
496
- };
497
- user: Record<string, any> & {
444
+ token: string | undefined;
445
+ user: {
498
446
  id: string;
499
- name: string;
500
447
  email: string;
501
448
  emailVerified: boolean;
449
+ name: string;
450
+ image: string | null | undefined;
502
451
  createdAt: Date;
503
452
  updatedAt: Date;
504
- image?: string | null | undefined;
505
453
  };
506
454
  };
455
+ } : {
456
+ token: string | undefined;
457
+ user: {
458
+ id: string;
459
+ email: string;
460
+ emailVerified: boolean;
461
+ name: string;
462
+ image: string | null | undefined;
463
+ createdAt: Date;
464
+ updatedAt: Date;
465
+ };
507
466
  }>;
508
467
  options: {
509
468
  method: "POST";
@@ -520,77 +479,98 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
520
479
  trustDevice?: boolean | undefined;
521
480
  disableSession?: boolean | undefined;
522
481
  }>;
523
- use: ((inputContext: better_call.MiddlewareInputContext<{
524
- body: z.ZodObject<{
525
- trustDevice: z.ZodOptional<z.ZodBoolean>;
526
- }, "strip", z.ZodTypeAny, {
527
- trustDevice?: boolean | undefined;
528
- }, {
529
- trustDevice?: boolean | undefined;
530
- }>;
531
- }>) => Promise<{
532
- valid: (ctx: GenericEndpointContext) => Promise<{
533
- token: string;
534
- user: {
535
- id: string;
536
- email: string;
537
- emailVerified: boolean;
538
- name: string;
539
- image: string | null | undefined;
540
- createdAt: Date;
541
- updatedAt: Date;
542
- };
543
- }>;
544
- invalid: () => Promise<never>;
545
- session: {
546
- session: {
547
- id: string;
548
- createdAt: Date;
549
- updatedAt: Date;
550
- userId: string;
551
- expiresAt: Date;
552
- token: string;
553
- ipAddress?: string | null | undefined;
554
- userAgent?: string | null | undefined;
555
- };
556
- user: UserWithTwoFactor;
557
- };
558
- } | {
559
- valid: (ctx: GenericEndpointContext) => Promise<{
560
- token: string;
561
- user: {
562
- id: string;
563
- email: string;
564
- emailVerified: boolean;
565
- name: string;
566
- image: string | null | undefined;
567
- createdAt: Date;
568
- updatedAt: Date;
569
- };
570
- }>;
571
- invalid: () => Promise<never>;
572
- session: {
573
- session: Record<string, any> & {
574
- id: string;
575
- createdAt: Date;
576
- updatedAt: Date;
577
- userId: string;
578
- expiresAt: Date;
579
- token: string;
580
- ipAddress?: string | null | undefined;
581
- userAgent?: string | null | undefined;
582
- };
583
- user: Record<string, any> & {
584
- id: string;
585
- name: string;
586
- email: string;
587
- emailVerified: boolean;
588
- createdAt: Date;
589
- updatedAt: Date;
590
- image?: string | null | undefined;
482
+ metadata: {
483
+ openapi: {
484
+ description: string;
485
+ responses: {
486
+ "200": {
487
+ description: string;
488
+ content: {
489
+ "application/json": {
490
+ schema: {
491
+ type: "object";
492
+ properties: {
493
+ user: {
494
+ type: string;
495
+ properties: {
496
+ id: {
497
+ type: string;
498
+ description: string;
499
+ };
500
+ email: {
501
+ type: string;
502
+ format: string;
503
+ nullable: boolean;
504
+ description: string;
505
+ };
506
+ emailVerified: {
507
+ type: string;
508
+ nullable: boolean;
509
+ description: string;
510
+ };
511
+ name: {
512
+ type: string;
513
+ nullable: boolean;
514
+ description: string;
515
+ };
516
+ image: {
517
+ type: string;
518
+ format: string;
519
+ nullable: boolean;
520
+ description: string;
521
+ };
522
+ twoFactorEnabled: {
523
+ type: string;
524
+ description: string;
525
+ };
526
+ createdAt: {
527
+ type: string;
528
+ format: string;
529
+ description: string;
530
+ };
531
+ updatedAt: {
532
+ type: string;
533
+ format: string;
534
+ description: string;
535
+ };
536
+ };
537
+ required: string[];
538
+ description: string;
539
+ };
540
+ session: {
541
+ type: string;
542
+ properties: {
543
+ token: {
544
+ type: string;
545
+ description: string;
546
+ };
547
+ userId: {
548
+ type: string;
549
+ description: string;
550
+ };
551
+ createdAt: {
552
+ type: string;
553
+ format: string;
554
+ description: string;
555
+ };
556
+ expiresAt: {
557
+ type: string;
558
+ format: string;
559
+ description: string;
560
+ };
561
+ };
562
+ required: string[];
563
+ description: string;
564
+ };
565
+ };
566
+ required: string[];
567
+ };
568
+ };
569
+ };
570
+ };
591
571
  };
592
572
  };
593
- }>)[];
573
+ };
594
574
  } & {
595
575
  use: any[];
596
576
  };
@@ -661,6 +641,38 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
661
641
  };
662
642
  };
663
643
  }>)[];
644
+ metadata: {
645
+ openapi: {
646
+ description: string;
647
+ responses: {
648
+ "200": {
649
+ description: string;
650
+ content: {
651
+ "application/json": {
652
+ schema: {
653
+ type: "object";
654
+ properties: {
655
+ status: {
656
+ type: string;
657
+ description: string;
658
+ enum: boolean[];
659
+ };
660
+ backupCodes: {
661
+ type: string;
662
+ items: {
663
+ type: string;
664
+ };
665
+ description: string;
666
+ };
667
+ };
668
+ required: string[];
669
+ };
670
+ };
671
+ };
672
+ };
673
+ };
674
+ };
675
+ };
664
676
  } & {
665
677
  use: any[];
666
678
  };
@@ -756,77 +768,6 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
756
768
  }, {
757
769
  trustDevice?: boolean | undefined;
758
770
  }>>;
759
- use: ((inputContext: better_call.MiddlewareInputContext<{
760
- body: z.ZodObject<{
761
- trustDevice: z.ZodOptional<z.ZodBoolean>;
762
- }, "strip", z.ZodTypeAny, {
763
- trustDevice?: boolean | undefined;
764
- }, {
765
- trustDevice?: boolean | undefined;
766
- }>;
767
- }>) => Promise<{
768
- valid: (ctx: GenericEndpointContext) => Promise<{
769
- token: string;
770
- user: {
771
- id: string;
772
- email: string;
773
- emailVerified: boolean;
774
- name: string;
775
- image: string | null | undefined;
776
- createdAt: Date;
777
- updatedAt: Date;
778
- };
779
- }>;
780
- invalid: () => Promise<never>;
781
- session: {
782
- session: {
783
- id: string;
784
- createdAt: Date;
785
- updatedAt: Date;
786
- userId: string;
787
- expiresAt: Date;
788
- token: string;
789
- ipAddress?: string | null | undefined;
790
- userAgent?: string | null | undefined;
791
- };
792
- user: UserWithTwoFactor;
793
- };
794
- } | {
795
- valid: (ctx: GenericEndpointContext) => Promise<{
796
- token: string;
797
- user: {
798
- id: string;
799
- email: string;
800
- emailVerified: boolean;
801
- name: string;
802
- image: string | null | undefined;
803
- createdAt: Date;
804
- updatedAt: Date;
805
- };
806
- }>;
807
- invalid: () => Promise<never>;
808
- session: {
809
- session: Record<string, any> & {
810
- id: string;
811
- createdAt: Date;
812
- updatedAt: Date;
813
- userId: string;
814
- expiresAt: Date;
815
- token: string;
816
- ipAddress?: string | null | undefined;
817
- userAgent?: string | null | undefined;
818
- };
819
- user: Record<string, any> & {
820
- id: string;
821
- name: string;
822
- email: string;
823
- emailVerified: boolean;
824
- createdAt: Date;
825
- updatedAt: Date;
826
- image?: string | null | undefined;
827
- };
828
- };
829
- }>)[];
830
771
  metadata: {
831
772
  openapi: {
832
773
  summary: string;
@@ -884,25 +825,25 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
884
825
  response: {
885
826
  token: string;
886
827
  user: {
887
- id: string;
888
- email: string;
889
- emailVerified: boolean;
890
- name: string;
891
- image: string | null | undefined;
892
- createdAt: Date;
893
- updatedAt: Date;
828
+ id: any;
829
+ email: any;
830
+ emailVerified: any;
831
+ name: any;
832
+ image: any;
833
+ createdAt: any;
834
+ updatedAt: any;
894
835
  };
895
836
  };
896
837
  } : {
897
838
  token: string;
898
839
  user: {
899
- id: string;
900
- email: string;
901
- emailVerified: boolean;
902
- name: string;
903
- image: string | null | undefined;
904
- createdAt: Date;
905
- updatedAt: Date;
840
+ id: any;
841
+ email: any;
842
+ emailVerified: any;
843
+ name: any;
844
+ image: any;
845
+ createdAt: any;
846
+ updatedAt: any;
906
847
  };
907
848
  }>;
908
849
  options: {
@@ -917,93 +858,67 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
917
858
  code: string;
918
859
  trustDevice?: boolean | undefined;
919
860
  }>;
920
- use: ((inputContext: better_call.MiddlewareInputContext<{
921
- body: z.ZodObject<{
922
- trustDevice: z.ZodOptional<z.ZodBoolean>;
923
- }, "strip", z.ZodTypeAny, {
924
- trustDevice?: boolean | undefined;
925
- }, {
926
- trustDevice?: boolean | undefined;
927
- }>;
928
- }>) => Promise<{
929
- valid: (ctx: GenericEndpointContext) => Promise<{
930
- token: string;
931
- user: {
932
- id: string;
933
- email: string;
934
- emailVerified: boolean;
935
- name: string;
936
- image: string | null | undefined;
937
- createdAt: Date;
938
- updatedAt: Date;
939
- };
940
- }>;
941
- invalid: () => Promise<never>;
942
- session: {
943
- session: {
944
- id: string;
945
- createdAt: Date;
946
- updatedAt: Date;
947
- userId: string;
948
- expiresAt: Date;
949
- token: string;
950
- ipAddress?: string | null | undefined;
951
- userAgent?: string | null | undefined;
952
- };
953
- user: UserWithTwoFactor;
954
- };
955
- } | {
956
- valid: (ctx: GenericEndpointContext) => Promise<{
957
- token: string;
958
- user: {
959
- id: string;
960
- email: string;
961
- emailVerified: boolean;
962
- name: string;
963
- image: string | null | undefined;
964
- createdAt: Date;
965
- updatedAt: Date;
966
- };
967
- }>;
968
- invalid: () => Promise<never>;
969
- session: {
970
- session: Record<string, any> & {
971
- id: string;
972
- createdAt: Date;
973
- updatedAt: Date;
974
- userId: string;
975
- expiresAt: Date;
976
- token: string;
977
- ipAddress?: string | null | undefined;
978
- userAgent?: string | null | undefined;
979
- };
980
- user: Record<string, any> & {
981
- id: string;
982
- name: string;
983
- email: string;
984
- emailVerified: boolean;
985
- createdAt: Date;
986
- updatedAt: Date;
987
- image?: string | null | undefined;
988
- };
989
- };
990
- }>)[];
991
861
  metadata: {
992
862
  openapi: {
993
863
  summary: string;
994
864
  description: string;
995
865
  responses: {
996
- 200: {
866
+ "200": {
997
867
  description: string;
998
868
  content: {
999
869
  "application/json": {
1000
870
  schema: {
1001
871
  type: "object";
1002
872
  properties: {
1003
- status: {
873
+ token: {
1004
874
  type: string;
875
+ description: string;
876
+ };
877
+ user: {
878
+ type: string;
879
+ properties: {
880
+ id: {
881
+ type: string;
882
+ description: string;
883
+ };
884
+ email: {
885
+ type: string;
886
+ format: string;
887
+ nullable: boolean;
888
+ description: string;
889
+ };
890
+ emailVerified: {
891
+ type: string;
892
+ nullable: boolean;
893
+ description: string;
894
+ };
895
+ name: {
896
+ type: string;
897
+ nullable: boolean;
898
+ description: string;
899
+ };
900
+ image: {
901
+ type: string;
902
+ format: string;
903
+ nullable: boolean;
904
+ description: string;
905
+ };
906
+ createdAt: {
907
+ type: string;
908
+ format: string;
909
+ description: string;
910
+ };
911
+ updatedAt: {
912
+ type: string;
913
+ format: string;
914
+ description: string;
915
+ };
916
+ };
917
+ required: string[];
918
+ description: string;
1005
919
  };
1006
920
  };
921
+ required: string[];
1007
922
  };
1008
923
  };
1009
924
  };
@@ -1017,8 +932,10 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1017
932
  path: "/two-factor/verify-otp";
1018
933
  };
1019
934
  generateTOTP: {
1020
- <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
1021
- body?: undefined;
935
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
936
+ body: {
937
+ secret: string;
938
+ };
1022
939
  } & {
1023
940
  method?: "POST" | undefined;
1024
941
  } & {
@@ -1037,7 +954,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1037
954
  } & {
1038
955
  asResponse?: AsResponse | undefined;
1039
956
  returnHeaders?: ReturnHeaders | undefined;
1040
- }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
957
+ }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
1041
958
  headers: Headers;
1042
959
  response: {
1043
960
  code: string;
@@ -1047,29 +964,13 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1047
964
  }>;
1048
965
  options: {
1049
966
  method: "POST";
1050
- use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1051
- session: {
1052
- session: Record<string, any> & {
1053
- id: string;
1054
- createdAt: Date;
1055
- updatedAt: Date;
1056
- userId: string;
1057
- expiresAt: Date;
1058
- token: string;
1059
- ipAddress?: string | null | undefined;
1060
- userAgent?: string | null | undefined;
1061
- };
1062
- user: Record<string, any> & {
1063
- id: string;
1064
- name: string;
1065
- email: string;
1066
- emailVerified: boolean;
1067
- createdAt: Date;
1068
- updatedAt: Date;
1069
- image?: string | null | undefined;
1070
- };
1071
- };
1072
- }>)[];
967
+ body: z.ZodObject<{
968
+ secret: z.ZodString;
969
+ }, "strip", z.ZodTypeAny, {
970
+ secret: string;
971
+ }, {
972
+ secret: string;
973
+ }>;
1073
974
  metadata: {
1074
975
  openapi: {
1075
976
  summary: string;
@@ -1092,6 +993,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1092
993
  };
1093
994
  };
1094
995
  };
996
+ SERVER_ONLY: true;
1095
997
  };
1096
998
  } & {
1097
999
  use: any[];
@@ -1251,77 +1153,6 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1251
1153
  code: string;
1252
1154
  trustDevice?: boolean | undefined;
1253
1155
  }>;
1254
- use: ((inputContext: better_call.MiddlewareInputContext<{
1255
- body: z.ZodObject<{
1256
- trustDevice: z.ZodOptional<z.ZodBoolean>;
1257
- }, "strip", z.ZodTypeAny, {
1258
- trustDevice?: boolean | undefined;
1259
- }, {
1260
- trustDevice?: boolean | undefined;
1261
- }>;
1262
- }>) => Promise<{
1263
- valid: (ctx: GenericEndpointContext) => Promise<{
1264
- token: string;
1265
- user: {
1266
- id: string;
1267
- email: string;
1268
- emailVerified: boolean;
1269
- name: string;
1270
- image: string | null | undefined;
1271
- createdAt: Date;
1272
- updatedAt: Date;
1273
- };
1274
- }>;
1275
- invalid: () => Promise<never>;
1276
- session: {
1277
- session: {
1278
- id: string;
1279
- createdAt: Date;
1280
- updatedAt: Date;
1281
- userId: string;
1282
- expiresAt: Date;
1283
- token: string;
1284
- ipAddress?: string | null | undefined;
1285
- userAgent?: string | null | undefined;
1286
- };
1287
- user: UserWithTwoFactor;
1288
- };
1289
- } | {
1290
- valid: (ctx: GenericEndpointContext) => Promise<{
1291
- token: string;
1292
- user: {
1293
- id: string;
1294
- email: string;
1295
- emailVerified: boolean;
1296
- name: string;
1297
- image: string | null | undefined;
1298
- createdAt: Date;
1299
- updatedAt: Date;
1300
- };
1301
- }>;
1302
- invalid: () => Promise<never>;
1303
- session: {
1304
- session: Record<string, any> & {
1305
- id: string;
1306
- createdAt: Date;
1307
- updatedAt: Date;
1308
- userId: string;
1309
- expiresAt: Date;
1310
- token: string;
1311
- ipAddress?: string | null | undefined;
1312
- userAgent?: string | null | undefined;
1313
- };
1314
- user: Record<string, any> & {
1315
- id: string;
1316
- name: string;
1317
- email: string;
1318
- emailVerified: boolean;
1319
- createdAt: Date;
1320
- updatedAt: Date;
1321
- image?: string | null | undefined;
1322
- };
1323
- };
1324
- }>)[];
1325
1156
  metadata: {
1326
1157
  openapi: {
1327
1158
  summary: string;
@@ -1407,6 +1238,9 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1407
1238
  readonly TWO_FACTOR_NOT_ENABLED: "Two factor isn't enabled";
1408
1239
  readonly BACKUP_CODES_NOT_ENABLED: "Backup codes aren't enabled";
1409
1240
  readonly INVALID_BACKUP_CODE: "Invalid backup code";
1241
+ readonly INVALID_CODE: "Invalid code";
1242
+ readonly TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: "Too many attempts. Please request a new code.";
1243
+ readonly INVALID_TWO_FACTOR_COOKIE: "Invalid two factor cookie";
1410
1244
  };
1411
1245
  };
1412
1246