better-auth 1.7.12 → 1.7.14

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 (270) hide show
  1. package/dist/adapters/index.d.mts +5 -10
  2. package/dist/api/dispatch.d.mts +3 -5
  3. package/dist/api/dispatch.mjs +6 -4
  4. package/dist/api/index.d.mts +506 -508
  5. package/dist/api/index.mjs +35 -34
  6. package/dist/api/middlewares/authorization.d.mts +15 -12
  7. package/dist/api/middlewares/authorization.mjs +2 -1
  8. package/dist/api/middlewares/index.d.mts +2 -1
  9. package/dist/api/middlewares/origin-check.d.mts +4 -7
  10. package/dist/api/routes/account.d.mts +11 -15
  11. package/dist/api/routes/account.mjs +7 -4
  12. package/dist/api/routes/callback.d.mts +2 -5
  13. package/dist/api/routes/callback.mjs +4 -2
  14. package/dist/api/routes/email-verification.d.mts +7 -12
  15. package/dist/api/routes/error.d.mts +2 -5
  16. package/dist/api/routes/index.d.mts +2 -1
  17. package/dist/api/routes/ok.d.mts +2 -5
  18. package/dist/api/routes/password.d.mts +8 -11
  19. package/dist/api/routes/password.mjs +3 -2
  20. package/dist/api/routes/session.d.mts +26 -29
  21. package/dist/api/routes/sign-in.d.mts +4 -6
  22. package/dist/api/routes/sign-out.d.mts +2 -5
  23. package/dist/api/routes/sign-up.d.mts +4 -6
  24. package/dist/api/routes/update-session.d.mts +4 -6
  25. package/dist/api/routes/update-user.d.mts +14 -16
  26. package/dist/api/routes/update-user.mjs +1 -1
  27. package/dist/api/state/oauth.d.mts +0 -3
  28. package/dist/api/state/oauth.mjs +2 -1
  29. package/dist/auth/full.d.mts +3 -4
  30. package/dist/auth/minimal.d.mts +3 -3
  31. package/dist/client/broadcast-channel.d.mts +6 -7
  32. package/dist/client/config.d.mts +15 -19
  33. package/dist/client/config.mjs +2 -2
  34. package/dist/client/equality.d.mts +3 -5
  35. package/dist/client/focus-manager.d.mts +4 -5
  36. package/dist/client/index.d.mts +8 -7
  37. package/dist/client/lynx/index.d.mts +6 -7
  38. package/dist/client/lynx/index.mjs +3 -2
  39. package/dist/client/lynx/lynx-store.d.mts +3 -4
  40. package/dist/client/online-manager.d.mts +4 -5
  41. package/dist/client/parser.d.mts +9 -5
  42. package/dist/client/path-to-object.d.mts +13 -14
  43. package/dist/client/plugins/index.d.mts +1 -1
  44. package/dist/client/plugins/infer-plugin.d.mts +2 -4
  45. package/dist/client/query.d.mts +4 -6
  46. package/dist/client/react/index.d.mts +6 -7
  47. package/dist/client/react/index.mjs +3 -2
  48. package/dist/client/react/react-store.d.mts +3 -4
  49. package/dist/client/session-atom.d.mts +4 -4
  50. package/dist/client/session-refresh.d.mts +3 -5
  51. package/dist/client/solid/index.d.mts +6 -7
  52. package/dist/client/solid/index.mjs +3 -2
  53. package/dist/client/svelte/index.d.mts +6 -7
  54. package/dist/client/svelte/index.mjs +3 -2
  55. package/dist/client/types.d.mts +11 -11
  56. package/dist/client/vanilla.d.mts +4 -5
  57. package/dist/client/vanilla.mjs +3 -2
  58. package/dist/client/vue/index.d.mts +6 -7
  59. package/dist/client/vue/index.mjs +3 -2
  60. package/dist/context/create-context.mjs +7 -7
  61. package/dist/context/helpers.mjs +9 -7
  62. package/dist/cookies/cookie-utils.d.mts +13 -13
  63. package/dist/cookies/cookie-utils.mjs +1 -3
  64. package/dist/cookies/index.d.mts +17 -18
  65. package/dist/cookies/index.mjs +11 -7
  66. package/dist/cookies/jwt.mjs +2 -1
  67. package/dist/cookies/session-store.d.mts +6 -5
  68. package/dist/cookies/session-store.mjs +3 -2
  69. package/dist/crypto/buffer.d.mts +2 -3
  70. package/dist/crypto/index.d.mts +9 -16
  71. package/dist/crypto/index.mjs +2 -1
  72. package/dist/crypto/jwt.d.mts +5 -7
  73. package/dist/crypto/jwt.mjs +2 -1
  74. package/dist/crypto/password.d.mts +1 -5
  75. package/dist/crypto/random.d.mts +2 -3
  76. package/dist/db/adapter-base.d.mts +2 -4
  77. package/dist/db/adapter-kysely.d.mts +2 -4
  78. package/dist/db/field-converter.d.mts +3 -5
  79. package/dist/db/field.d.mts +11 -12
  80. package/dist/db/get-migration.d.mts +4 -8
  81. package/dist/db/get-migration.mjs +22 -22
  82. package/dist/db/get-schema.d.mts +2 -4
  83. package/dist/db/internal-adapter.d.mts +2 -4
  84. package/dist/db/internal-adapter.mjs +6 -4
  85. package/dist/db/revoke-unproven-account-access.d.mts +3 -4
  86. package/dist/db/schema.d.mts +15 -16
  87. package/dist/db/schema.mjs +6 -3
  88. package/dist/db/to-zod.d.mts +5 -9
  89. package/dist/db/with-hooks.d.mts +3 -5
  90. package/dist/index.d.mts +4 -3
  91. package/dist/integrations/next-js.d.mts +7 -11
  92. package/dist/integrations/node.d.mts +5 -7
  93. package/dist/integrations/node.mjs +4 -2
  94. package/dist/integrations/solid-start.d.mts +2 -3
  95. package/dist/integrations/svelte-kit.d.mts +6 -14
  96. package/dist/integrations/tanstack-start-solid.d.mts +4 -8
  97. package/dist/integrations/tanstack-start.d.mts +4 -8
  98. package/dist/oauth2/link-account.d.mts +5 -11
  99. package/dist/oauth2/link-account.mjs +12 -6
  100. package/dist/oauth2/state.d.mts +5 -7
  101. package/dist/oauth2/state.mjs +1 -1
  102. package/dist/oauth2/utils.d.mts +4 -6
  103. package/dist/package.mjs +1 -1
  104. package/dist/plugins/access/access.d.mts +4 -6
  105. package/dist/plugins/access/index.mjs +1 -2
  106. package/dist/plugins/access/types.d.mts +12 -14
  107. package/dist/plugins/additional-fields/client.d.mts +2 -4
  108. package/dist/plugins/admin/access/index.mjs +1 -2
  109. package/dist/plugins/admin/access/statement.d.mts +7 -7
  110. package/dist/plugins/admin/admin.d.mts +122 -128
  111. package/dist/plugins/admin/client.d.mts +32 -32
  112. package/dist/plugins/admin/client.mjs +1 -1
  113. package/dist/plugins/admin/error-codes.d.mts +25 -28
  114. package/dist/plugins/admin/index.d.mts +1 -1
  115. package/dist/plugins/admin/index.mjs +1 -2
  116. package/dist/plugins/admin/schema.d.mts +3 -4
  117. package/dist/plugins/admin/types.d.mts +8 -8
  118. package/dist/plugins/anonymous/client.d.mts +10 -12
  119. package/dist/plugins/anonymous/client.mjs +1 -1
  120. package/dist/plugins/anonymous/error-codes.d.mts +10 -13
  121. package/dist/plugins/anonymous/index.d.mts +17 -21
  122. package/dist/plugins/anonymous/schema.d.mts +2 -3
  123. package/dist/plugins/anonymous/types.d.mts +5 -6
  124. package/dist/plugins/bearer/index.d.mts +7 -11
  125. package/dist/plugins/captcha/constants.d.mts +2 -3
  126. package/dist/plugins/captcha/index.d.mts +6 -9
  127. package/dist/plugins/captcha/types.d.mts +11 -13
  128. package/dist/plugins/custom-session/client.d.mts +2 -4
  129. package/dist/plugins/custom-session/index.d.mts +10 -16
  130. package/dist/plugins/device-authorization/client.d.mts +2 -4
  131. package/dist/plugins/device-authorization/index.d.mts +39 -44
  132. package/dist/plugins/device-authorization/index.mjs +10 -9
  133. package/dist/plugins/device-authorization/routes.d.mts +7 -5
  134. package/dist/plugins/device-authorization/routes.mjs +6 -5
  135. package/dist/plugins/device-authorization/schema.d.mts +2 -3
  136. package/dist/plugins/email-otp/client.d.mts +5 -7
  137. package/dist/plugins/email-otp/client.mjs +1 -1
  138. package/dist/plugins/email-otp/error-codes.d.mts +5 -8
  139. package/dist/plugins/email-otp/index.d.mts +69 -76
  140. package/dist/plugins/email-otp/otp-token.mjs +19 -7
  141. package/dist/plugins/email-otp/types.d.mts +2 -4
  142. package/dist/plugins/generic-oauth/index.d.mts +9 -13
  143. package/dist/plugins/generic-oauth/index.mjs +6 -4
  144. package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
  145. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
  146. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
  147. package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
  148. package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
  149. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
  150. package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
  151. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
  152. package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
  153. package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
  154. package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
  155. package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
  156. package/dist/plugins/generic-oauth/types.d.mts +6 -7
  157. package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
  158. package/dist/plugins/index.d.mts +4 -1
  159. package/dist/plugins/jwt/client.d.mts +2 -3
  160. package/dist/plugins/jwt/index.d.mts +11 -14
  161. package/dist/plugins/jwt/index.mjs +1 -1
  162. package/dist/plugins/jwt/schema.d.mts +2 -3
  163. package/dist/plugins/jwt/sign.d.mts +9 -8
  164. package/dist/plugins/jwt/types.d.mts +7 -8
  165. package/dist/plugins/jwt/utils.d.mts +6 -9
  166. package/dist/plugins/jwt/verify.d.mts +2 -4
  167. package/dist/plugins/last-login-method/client.d.mts +3 -4
  168. package/dist/plugins/last-login-method/index.d.mts +5 -9
  169. package/dist/plugins/last-login-method/index.mjs +1 -1
  170. package/dist/plugins/magic-link/client.d.mts +2 -4
  171. package/dist/plugins/magic-link/index.d.mts +7 -10
  172. package/dist/plugins/magic-link/index.mjs +20 -17
  173. package/dist/plugins/multi-session/client.d.mts +3 -5
  174. package/dist/plugins/multi-session/client.mjs +1 -1
  175. package/dist/plugins/multi-session/error-codes.d.mts +3 -6
  176. package/dist/plugins/multi-session/index.d.mts +10 -14
  177. package/dist/plugins/oauth-popup/client.d.mts +11 -17
  178. package/dist/plugins/oauth-popup/client.mjs +6 -4
  179. package/dist/plugins/oauth-popup/constants.d.mts +5 -6
  180. package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
  181. package/dist/plugins/oauth-popup/index.d.mts +11 -15
  182. package/dist/plugins/oauth-popup/index.mjs +8 -7
  183. package/dist/plugins/oauth-popup/types.d.mts +4 -6
  184. package/dist/plugins/oauth-proxy/index.d.mts +11 -15
  185. package/dist/plugins/oauth-proxy/index.mjs +10 -7
  186. package/dist/plugins/one-tap/client.d.mts +6 -9
  187. package/dist/plugins/one-tap/index.d.mts +4 -7
  188. package/dist/plugins/one-time-token/client.d.mts +2 -3
  189. package/dist/plugins/one-time-token/index.d.mts +8 -10
  190. package/dist/plugins/open-api/generator.d.mts +8 -8
  191. package/dist/plugins/open-api/generator.mjs +5 -5
  192. package/dist/plugins/open-api/index.d.mts +5 -7
  193. package/dist/plugins/organization/access/index.mjs +1 -2
  194. package/dist/plugins/organization/access/statement.d.mts +8 -8
  195. package/dist/plugins/organization/adapter.d.mts +60 -87
  196. package/dist/plugins/organization/adapter.mjs +14 -10
  197. package/dist/plugins/organization/client.d.mts +108 -107
  198. package/dist/plugins/organization/client.mjs +9 -5
  199. package/dist/plugins/organization/error-codes.d.mts +61 -64
  200. package/dist/plugins/organization/has-permission.d.mts +2 -4
  201. package/dist/plugins/organization/has-permission.mjs +1 -1
  202. package/dist/plugins/organization/index.d.mts +1 -1
  203. package/dist/plugins/organization/organization.d.mts +20 -20
  204. package/dist/plugins/organization/organization.mjs +13 -8
  205. package/dist/plugins/organization/permission.d.mts +4 -5
  206. package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
  207. package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
  208. package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
  209. package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
  210. package/dist/plugins/organization/routes/crud-members.mjs +23 -21
  211. package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
  212. package/dist/plugins/organization/routes/crud-org.mjs +4 -2
  213. package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
  214. package/dist/plugins/organization/routes/crud-team.mjs +4 -2
  215. package/dist/plugins/organization/schema.d.mts +33 -33
  216. package/dist/plugins/organization/schema.mjs +1 -1
  217. package/dist/plugins/organization/types.d.mts +16 -17
  218. package/dist/plugins/phone-number/client.d.mts +14 -16
  219. package/dist/plugins/phone-number/client.mjs +1 -1
  220. package/dist/plugins/phone-number/error-codes.d.mts +14 -17
  221. package/dist/plugins/phone-number/index.d.mts +48 -54
  222. package/dist/plugins/phone-number/schema.d.mts +2 -3
  223. package/dist/plugins/phone-number/types.d.mts +4 -5
  224. package/dist/plugins/siwe/client.d.mts +2 -4
  225. package/dist/plugins/siwe/index.d.mts +7 -9
  226. package/dist/plugins/siwe/index.mjs +1 -1
  227. package/dist/plugins/siwe/parse-message.mjs +1 -3
  228. package/dist/plugins/siwe/schema.d.mts +3 -4
  229. package/dist/plugins/siwe/types.d.mts +4 -4
  230. package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
  231. package/dist/plugins/test-utils/index.d.mts +3 -5
  232. package/dist/plugins/test-utils/types.d.mts +7 -7
  233. package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
  234. package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
  235. package/dist/plugins/two-factor/client.d.mts +16 -19
  236. package/dist/plugins/two-factor/client.mjs +1 -1
  237. package/dist/plugins/two-factor/constant.mjs +1 -1
  238. package/dist/plugins/two-factor/error-code.d.mts +15 -18
  239. package/dist/plugins/two-factor/index.d.mts +31 -35
  240. package/dist/plugins/two-factor/index.mjs +6 -3
  241. package/dist/plugins/two-factor/otp/index.d.mts +5 -8
  242. package/dist/plugins/two-factor/otp/index.mjs +159 -154
  243. package/dist/plugins/two-factor/schema.d.mts +2 -3
  244. package/dist/plugins/two-factor/totp/index.d.mts +7 -10
  245. package/dist/plugins/two-factor/totp/index.mjs +164 -148
  246. package/dist/plugins/two-factor/types.d.mts +6 -7
  247. package/dist/plugins/username/client.d.mts +12 -14
  248. package/dist/plugins/username/client.mjs +1 -1
  249. package/dist/plugins/username/error-codes.d.mts +11 -14
  250. package/dist/plugins/username/index.d.mts +26 -31
  251. package/dist/plugins/username/schema.d.mts +7 -10
  252. package/dist/state.d.mts +4 -5
  253. package/dist/test-utils/headers.d.mts +2 -3
  254. package/dist/test-utils/http-test-instance.d.mts +26 -29
  255. package/dist/test-utils/test-instance.d.mts +7 -6
  256. package/dist/test-utils/test-instance.mjs +4 -2
  257. package/dist/types/adapter.d.mts +1 -1
  258. package/dist/types/api.d.mts +4 -6
  259. package/dist/types/auth.d.mts +2 -4
  260. package/dist/types/helper.d.mts +11 -12
  261. package/dist/types/index.d.mts +2 -2
  262. package/dist/types/models.d.mts +4 -5
  263. package/dist/types/plugins.d.mts +7 -8
  264. package/dist/utils/hide-metadata.d.mts +2 -3
  265. package/dist/utils/index.d.mts +2 -1
  266. package/dist/utils/is-api-error.mjs +1 -2
  267. package/dist/utils/time.d.mts +4 -4
  268. package/dist/utils/url.d.mts +13 -15
  269. package/dist/utils/wildcard.mjs +5 -3
  270. package/package.json +12 -12
@@ -1,10 +1,8 @@
1
1
  import { SecretConfig } from "../../../crypto/index.mjs";
2
2
  import { UserWithTwoFactor } from "../types.mjs";
3
- import * as _$better_call0 from "better-call";
4
3
  import * as z from "zod";
5
-
6
4
  //#region src/plugins/two-factor/backup-codes/index.d.ts
7
- interface BackupCodeOptions {
5
+ export interface BackupCodeOptions {
8
6
  /**
9
7
  * The amount of backup codes to generate
10
8
  *
@@ -36,12 +34,12 @@ interface BackupCodeOptions {
36
34
  */
37
35
  allowPasswordless?: boolean | undefined;
38
36
  }
39
- declare function encodeBackupCodes(codes: string[], secret: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<string>;
40
- declare function generateBackupCodes(secret: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<{
37
+ export declare function encodeBackupCodes(codes: string[], secret: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<string>;
38
+ export declare function generateBackupCodes(secret: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<{
41
39
  backupCodes: string[];
42
40
  encryptedBackupCodes: string;
43
41
  }>;
44
- declare function verifyBackupCode(data: {
42
+ export declare function verifyBackupCode(data: {
45
43
  backupCodes: string;
46
44
  code: string;
47
45
  }, key: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<{
@@ -51,8 +49,8 @@ declare function verifyBackupCode(data: {
51
49
  status: boolean;
52
50
  updated: string[];
53
51
  }>;
54
- declare function getBackupCodes(backupCodes: string, key: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<string[] | null>;
55
- declare const backupCode2fa: (opts: BackupCodeOptions) => {
52
+ export declare function getBackupCodes(backupCodes: string, key: string | SecretConfig, options?: BackupCodeOptions | undefined): Promise<string[] | null>;
53
+ export declare const backupCode2fa: (opts: BackupCodeOptions) => {
56
54
  id: "backup_code";
57
55
  version: string;
58
56
  endpoints: {
@@ -71,7 +69,7 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
71
69
  *
72
70
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-backup-code)
73
71
  */
74
- verifyBackupCode: _$better_call0.StrictEndpoint<"/two-factor/verify-backup-code", {
72
+ verifyBackupCode: import("better-call").StrictEndpoint<"/two-factor/verify-backup-code", {
75
73
  method: "POST";
76
74
  body: z.ZodObject<{
77
75
  code: z.ZodString;
@@ -197,14 +195,14 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
197
195
  *
198
196
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-generate-backup-codes)
199
197
  */
200
- generateBackupCodes: _$better_call0.StrictEndpoint<"/two-factor/generate-backup-codes", {
198
+ generateBackupCodes: import("better-call").StrictEndpoint<"/two-factor/generate-backup-codes", {
201
199
  method: "POST";
202
200
  body: z.ZodObject<{
203
201
  password: z.ZodOptional<z.ZodString>;
204
202
  }, z.core.$strip> | z.ZodObject<{
205
203
  password: z.ZodString;
206
204
  }, z.core.$strip>;
207
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
205
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
208
206
  session: {
209
207
  session: Record<string, any> & {
210
208
  id: string;
@@ -276,7 +274,7 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
276
274
  *
277
275
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-view-backup-codes)
278
276
  */
279
- viewBackupCodes: _$better_call0.StrictEndpoint<string, {
277
+ viewBackupCodes: import("better-call").StrictEndpoint<string, {
280
278
  method: "POST";
281
279
  body: z.ZodObject<{
282
280
  userId: z.ZodCoercedString<unknown>;
@@ -287,5 +285,4 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
287
285
  }>;
288
286
  };
289
287
  };
290
- //#endregion
291
- export { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode };
288
+ //#endregion
@@ -42,11 +42,17 @@ async function verifyBackupCode(data, key, options) {
42
42
  };
43
43
  }
44
44
  async function getBackupCodes(backupCodes, key, options) {
45
- if (options?.storeBackupCodes === "encrypted") return safeJSONParse(await symmetricDecrypt({
46
- key,
47
- data: backupCodes
48
- }));
49
- if (typeof options?.storeBackupCodes === "object" && "decrypt" in options?.storeBackupCodes) return safeJSONParse(await options?.storeBackupCodes.decrypt(backupCodes));
45
+ if (options?.storeBackupCodes === "encrypted") {
46
+ const decrypted = await symmetricDecrypt({
47
+ key,
48
+ data: backupCodes
49
+ });
50
+ return safeJSONParse(decrypted);
51
+ }
52
+ if (typeof options?.storeBackupCodes === "object" && "decrypt" in options?.storeBackupCodes) {
53
+ const decrypted = await options?.storeBackupCodes.decrypt(backupCodes);
54
+ return safeJSONParse(decrypted);
55
+ }
50
56
  return safeJSONParse(backupCodes);
51
57
  }
52
58
  const verifyBackupCodeBodySchema = z.object({
@@ -338,4 +344,4 @@ const backupCode2fa = (opts) => {
338
344
  };
339
345
  };
340
346
  //#endregion
341
- export { backupCode2fa, generateBackupCodes };
347
+ export { backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode };
@@ -4,11 +4,8 @@ import { TOTPOptions, totp2fa } from "./totp/index.mjs";
4
4
  import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
5
5
  import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
6
6
  import { twoFactor } from "./index.mjs";
7
- import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
8
- import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
9
-
10
7
  //#region src/plugins/two-factor/client.d.ts
11
- declare const twoFactorClient: (options?: {
8
+ export declare const twoFactorClient: (options?: {
12
9
  /**
13
10
  * the page to redirect if a user needs to verify
14
11
  * their two factor
@@ -53,24 +50,24 @@ declare const twoFactorClient: (options?: {
53
50
  id: string;
54
51
  name: string;
55
52
  hooks: {
56
- onSuccess(context: _$_better_fetch_fetch0.SuccessContext<any>): Promise<void>;
53
+ onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): Promise<void>;
57
54
  };
58
55
  }[];
59
56
  $ERROR_CODES: {
60
- OTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_ENABLED">;
61
- OTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_CONFIGURED">;
62
- OTP_HAS_EXPIRED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_HAS_EXPIRED">;
63
- TOTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_ENABLED">;
64
- TOTP_ALREADY_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_ALREADY_ENABLED">;
65
- TOTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_CONFIGURED">;
66
- TWO_FACTOR_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TWO_FACTOR_NOT_ENABLED">;
67
- BACKUP_CODES_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"BACKUP_CODES_NOT_ENABLED">;
68
- INVALID_BACKUP_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_BACKUP_CODE">;
69
- INVALID_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_CODE">;
70
- TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: _$_better_auth_core_utils_error_codes0.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
71
- ACCOUNT_TEMPORARILY_LOCKED: _$_better_auth_core_utils_error_codes0.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
72
- INVALID_TWO_FACTOR_COOKIE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_TWO_FACTOR_COOKIE">;
57
+ OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
58
+ OTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_CONFIGURED">;
59
+ OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
60
+ TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
61
+ TOTP_ALREADY_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_ALREADY_ENABLED">;
62
+ TOTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_CONFIGURED">;
63
+ TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
64
+ BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
65
+ INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
66
+ INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
67
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
68
+ ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
69
+ INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
73
70
  };
74
71
  };
75
72
  //#endregion
76
- export { twoFactorClient };
73
+ export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type TwoFactorOptions, type TwoFactorProvider, type TwoFactorTable, type UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, type verifyBackupCode };
@@ -38,4 +38,4 @@ const twoFactorClient = (options) => {
38
38
  };
39
39
  };
40
40
  //#endregion
41
- export { twoFactorClient };
41
+ export { TWO_FACTOR_ERROR_CODES, twoFactorClient };
@@ -1,6 +1,6 @@
1
1
  //#region src/plugins/two-factor/constant.ts
2
2
  const TWO_FACTOR_COOKIE_NAME = "two_factor";
3
3
  const TRUST_DEVICE_COOKIE_NAME = "trust_device";
4
- const TRUST_DEVICE_COOKIE_MAX_AGE = 720 * 60 * 60;
4
+ const TRUST_DEVICE_COOKIE_MAX_AGE = 2592e3;
5
5
  //#endregion
6
6
  export { TRUST_DEVICE_COOKIE_MAX_AGE, TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME };
@@ -1,20 +1,17 @@
1
- import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
2
-
3
1
  //#region src/plugins/two-factor/error-code.d.ts
4
- declare const TWO_FACTOR_ERROR_CODES: {
5
- OTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_ENABLED">;
6
- OTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_CONFIGURED">;
7
- OTP_HAS_EXPIRED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_HAS_EXPIRED">;
8
- TOTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_ENABLED">;
9
- TOTP_ALREADY_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_ALREADY_ENABLED">;
10
- TOTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_CONFIGURED">;
11
- TWO_FACTOR_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TWO_FACTOR_NOT_ENABLED">;
12
- BACKUP_CODES_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"BACKUP_CODES_NOT_ENABLED">;
13
- INVALID_BACKUP_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_BACKUP_CODE">;
14
- INVALID_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_CODE">;
15
- TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: _$_better_auth_core_utils_error_codes0.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
16
- ACCOUNT_TEMPORARILY_LOCKED: _$_better_auth_core_utils_error_codes0.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
17
- INVALID_TWO_FACTOR_COOKIE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_TWO_FACTOR_COOKIE">;
2
+ export declare const TWO_FACTOR_ERROR_CODES: {
3
+ OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
4
+ OTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_CONFIGURED">;
5
+ OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
6
+ TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
7
+ TOTP_ALREADY_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_ALREADY_ENABLED">;
8
+ TOTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_CONFIGURED">;
9
+ TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
10
+ BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
11
+ INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
12
+ INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
13
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
14
+ ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
15
+ INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
18
16
  };
19
- //#endregion
20
- export { TWO_FACTOR_ERROR_CODES };
17
+ //#endregion
@@ -4,11 +4,7 @@ import { TOTPOptions, totp2fa } from "./totp/index.mjs";
4
4
  import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
5
5
  import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
6
6
  import { twoFactorClient } from "./client.mjs";
7
- import * as _$_better_auth_core0 from "@better-auth/core";
8
- import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
9
- import * as _$better_call0 from "better-call";
10
7
  import * as z from "zod";
11
-
12
8
  //#region src/plugins/two-factor/index.d.ts
13
9
  declare module "@better-auth/core" {
14
10
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
@@ -17,7 +13,7 @@ declare module "@better-auth/core" {
17
13
  };
18
14
  }
19
15
  }
20
- declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
16
+ export declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
21
17
  id: "two-factor";
22
18
  version: string;
23
19
  endpoints: {
@@ -36,7 +32,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
36
32
  *
37
33
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-enable)
38
34
  */
39
- enableTwoFactor: _$better_call0.StrictEndpoint<"/two-factor/enable", {
35
+ enableTwoFactor: import("better-call").StrictEndpoint<"/two-factor/enable", {
40
36
  method: "POST";
41
37
  body: z.ZodObject<{
42
38
  password: z.ZodOptional<z.ZodString>;
@@ -53,7 +49,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
53
49
  }>>;
54
50
  issuer: z.ZodOptional<z.ZodString>;
55
51
  }, z.core.$strip>;
56
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
52
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
57
53
  session: {
58
54
  session: Record<string, any> & {
59
55
  id: string;
@@ -135,14 +131,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
135
131
  *
136
132
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-disable)
137
133
  */
138
- disableTwoFactor: _$better_call0.StrictEndpoint<"/two-factor/disable", {
134
+ disableTwoFactor: import("better-call").StrictEndpoint<"/two-factor/disable", {
139
135
  method: "POST";
140
136
  body: z.ZodObject<{
141
137
  password: z.ZodOptional<z.ZodString>;
142
138
  }, z.core.$strip> | z.ZodObject<{
143
139
  password: z.ZodString;
144
140
  }, z.core.$strip>;
145
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
141
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
146
142
  session: {
147
143
  session: Record<string, any> & {
148
144
  id: string;
@@ -191,7 +187,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
191
187
  }, {
192
188
  status: boolean;
193
189
  }>;
194
- verifyBackupCode: _$better_call0.StrictEndpoint<"/two-factor/verify-backup-code", {
190
+ verifyBackupCode: import("better-call").StrictEndpoint<"/two-factor/verify-backup-code", {
195
191
  method: "POST";
196
192
  body: z.ZodObject<{
197
193
  code: z.ZodString;
@@ -302,14 +298,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
302
298
  image?: string | null | undefined;
303
299
  }) | UserWithTwoFactor;
304
300
  }>;
305
- generateBackupCodes: _$better_call0.StrictEndpoint<"/two-factor/generate-backup-codes", {
301
+ generateBackupCodes: import("better-call").StrictEndpoint<"/two-factor/generate-backup-codes", {
306
302
  method: "POST";
307
303
  body: z.ZodObject<{
308
304
  password: z.ZodOptional<z.ZodString>;
309
305
  }, z.core.$strip> | z.ZodObject<{
310
306
  password: z.ZodString;
311
307
  }, z.core.$strip>;
312
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
308
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
313
309
  session: {
314
310
  session: Record<string, any> & {
315
311
  id: string;
@@ -368,7 +364,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
368
364
  status: boolean;
369
365
  backupCodes: string[];
370
366
  }>;
371
- viewBackupCodes: _$better_call0.StrictEndpoint<string, {
367
+ viewBackupCodes: import("better-call").StrictEndpoint<string, {
372
368
  method: "POST";
373
369
  body: z.ZodObject<{
374
370
  userId: z.ZodCoercedString<unknown>;
@@ -377,7 +373,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
377
373
  status: boolean;
378
374
  backupCodes: string[];
379
375
  }>;
380
- sendTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/send-otp", {
376
+ sendTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/send-otp", {
381
377
  method: "POST";
382
378
  body: z.ZodOptional<z.ZodObject<{
383
379
  trustDevice: z.ZodOptional<z.ZodBoolean>;
@@ -408,7 +404,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
408
404
  }, {
409
405
  status: boolean;
410
406
  }>;
411
- verifyTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-otp", {
407
+ verifyTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/verify-otp", {
412
408
  method: "POST";
413
409
  body: z.ZodObject<{
414
410
  code: z.ZodString;
@@ -497,7 +493,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
497
493
  image?: string | null | undefined;
498
494
  };
499
495
  }>;
500
- generateTOTP: _$better_call0.StrictEndpoint<string, {
496
+ generateTOTP: import("better-call").StrictEndpoint<string, {
501
497
  method: "POST";
502
498
  body: z.ZodObject<{
503
499
  secret: z.ZodString;
@@ -528,9 +524,9 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
528
524
  }, {
529
525
  code: string;
530
526
  }>;
531
- getTOTPURI: _$better_call0.StrictEndpoint<"/two-factor/get-totp-uri", {
527
+ getTOTPURI: import("better-call").StrictEndpoint<"/two-factor/get-totp-uri", {
532
528
  method: "POST";
533
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
529
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
534
530
  session: {
535
531
  session: Record<string, any> & {
536
532
  id: string;
@@ -584,7 +580,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
584
580
  }, {
585
581
  totpURI: string;
586
582
  }>;
587
- verifyTOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-totp", {
583
+ verifyTOTP: import("better-call").StrictEndpoint<"/two-factor/verify-totp", {
588
584
  method: "POST";
589
585
  body: z.ZodObject<{
590
586
  code: z.ZodString;
@@ -632,8 +628,8 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
632
628
  options: NoInfer<O>;
633
629
  hooks: {
634
630
  after: {
635
- matcher(context: _$_better_auth_core0.HookEndpointContext): boolean;
636
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
631
+ matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
632
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
637
633
  twoFactorRedirect: boolean;
638
634
  twoFactorMethods: string[];
639
635
  } | undefined>>;
@@ -701,20 +697,20 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
701
697
  max: number;
702
698
  }[];
703
699
  $ERROR_CODES: {
704
- OTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_ENABLED">;
705
- OTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_CONFIGURED">;
706
- OTP_HAS_EXPIRED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_HAS_EXPIRED">;
707
- TOTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_ENABLED">;
708
- TOTP_ALREADY_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_ALREADY_ENABLED">;
709
- TOTP_NOT_CONFIGURED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_CONFIGURED">;
710
- TWO_FACTOR_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TWO_FACTOR_NOT_ENABLED">;
711
- BACKUP_CODES_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"BACKUP_CODES_NOT_ENABLED">;
712
- INVALID_BACKUP_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_BACKUP_CODE">;
713
- INVALID_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_CODE">;
714
- TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: _$_better_auth_core_utils_error_codes0.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
715
- ACCOUNT_TEMPORARILY_LOCKED: _$_better_auth_core_utils_error_codes0.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
716
- INVALID_TWO_FACTOR_COOKIE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_TWO_FACTOR_COOKIE">;
700
+ OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
701
+ OTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_CONFIGURED">;
702
+ OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
703
+ TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
704
+ TOTP_ALREADY_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_ALREADY_ENABLED">;
705
+ TOTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_CONFIGURED">;
706
+ TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
707
+ BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
708
+ INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
709
+ INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
710
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
711
+ ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
712
+ INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
717
713
  };
718
714
  };
719
715
  //#endregion
720
- export { BackupCodeOptions, OTPOptions, TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, otp2fa, totp2fa, twoFactor, twoFactorClient, verifyBackupCode };
716
+ export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, twoFactorClient, type verifyBackupCode };
@@ -115,8 +115,9 @@ const twoFactor = (options) => {
115
115
  if (method === "totp" && options?.totpOptions?.disable) throw APIError.from("BAD_REQUEST", TWO_FACTOR_ERROR_CODES.TOTP_NOT_CONFIGURED);
116
116
  if (method === "otp") {
117
117
  const updatedUser = await ctx.context.internalAdapter.updateUser(user.id, { twoFactorEnabled: true });
118
+ const newSession = await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session);
118
119
  await setSessionCookie(ctx, {
119
- session: await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session),
120
+ session: newSession,
120
121
  user: updatedUser
121
122
  });
122
123
  await ctx.context.internalAdapter.deleteSession(ctx.context.session.session.token);
@@ -138,8 +139,9 @@ const twoFactor = (options) => {
138
139
  });
139
140
  if (options?.skipVerificationOnEnable) {
140
141
  const updatedUser = await ctx.context.internalAdapter.updateUser(user.id, { twoFactorEnabled: true });
142
+ const newSession = await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session);
141
143
  await setSessionCookie(ctx, {
142
- session: await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session),
144
+ session: newSession,
143
145
  user: updatedUser
144
146
  });
145
147
  await ctx.context.internalAdapter.deleteSession(ctx.context.session.session.token);
@@ -222,11 +224,12 @@ const twoFactor = (options) => {
222
224
  value: updatedUser.id
223
225
  }]
224
226
  });
227
+ const newSession = await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session);
225
228
  /**
226
229
  * Update the session cookie with the new user data
227
230
  */
228
231
  await setSessionCookie(ctx, {
229
- session: await ctx.context.internalAdapter.createSession(updatedUser.id, false, ctx.context.session.session),
232
+ session: newSession,
230
233
  user: updatedUser
231
234
  });
232
235
  await ctx.context.internalAdapter.deleteSession(ctx.context.session.session.token);
@@ -1,10 +1,8 @@
1
1
  import { UserWithTwoFactor } from "../types.mjs";
2
2
  import { Awaitable, GenericEndpointContext } from "@better-auth/core";
3
- import * as _$better_call0 from "better-call";
4
3
  import * as z from "zod";
5
-
6
4
  //#region src/plugins/two-factor/otp/index.d.ts
7
- interface OTPOptions {
5
+ export interface OTPOptions {
8
6
  /**
9
7
  * How long the opt will be valid for in
10
8
  * minutes
@@ -56,7 +54,7 @@ interface OTPOptions {
56
54
  /**
57
55
  * The otp adapter is created from the totp adapter.
58
56
  */
59
- declare const otp2fa: (options?: OTPOptions | undefined) => {
57
+ export declare const otp2fa: (options?: OTPOptions | undefined) => {
60
58
  id: "otp";
61
59
  version: string;
62
60
  endpoints: {
@@ -75,7 +73,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
75
73
  *
76
74
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-send-otp)
77
75
  */
78
- sendTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/send-otp", {
76
+ sendTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/send-otp", {
79
77
  method: "POST";
80
78
  body: z.ZodOptional<z.ZodObject<{
81
79
  trustDevice: z.ZodOptional<z.ZodBoolean>;
@@ -121,7 +119,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
121
119
  *
122
120
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-otp)
123
121
  */
124
- verifyTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-otp", {
122
+ verifyTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/verify-otp", {
125
123
  method: "POST";
126
124
  body: z.ZodObject<{
127
125
  code: z.ZodString;
@@ -212,5 +210,4 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
212
210
  }>;
213
211
  };
214
212
  };
215
- //#endregion
216
- export { OTPOptions, otp2fa };
213
+ //#endregion