better-auth 1.2.5-beta.9 → 1.2.6-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 (197) hide show
  1. package/dist/adapters/drizzle-adapter/index.d.cts +3 -3
  2. package/dist/adapters/drizzle-adapter/index.d.mts +3 -3
  3. package/dist/adapters/drizzle-adapter/index.d.ts +3 -3
  4. package/dist/adapters/kysely-adapter/index.d.cts +3 -3
  5. package/dist/adapters/kysely-adapter/index.d.mts +3 -3
  6. package/dist/adapters/kysely-adapter/index.d.ts +3 -3
  7. package/dist/adapters/memory-adapter/index.d.cts +3 -3
  8. package/dist/adapters/memory-adapter/index.d.mts +3 -3
  9. package/dist/adapters/memory-adapter/index.d.ts +3 -3
  10. package/dist/adapters/mongodb-adapter/index.d.cts +3 -3
  11. package/dist/adapters/mongodb-adapter/index.d.mts +3 -3
  12. package/dist/adapters/mongodb-adapter/index.d.ts +3 -3
  13. package/dist/adapters/prisma-adapter/index.d.cts +3 -3
  14. package/dist/adapters/prisma-adapter/index.d.mts +3 -3
  15. package/dist/adapters/prisma-adapter/index.d.ts +3 -3
  16. package/dist/adapters/test.d.cts +3 -3
  17. package/dist/adapters/test.d.mts +3 -3
  18. package/dist/adapters/test.d.ts +3 -3
  19. package/dist/api/index.cjs +77 -75
  20. package/dist/api/index.d.cts +4 -4
  21. package/dist/api/index.d.mts +4 -4
  22. package/dist/api/index.d.ts +4 -4
  23. package/dist/api/index.mjs +6 -5
  24. package/dist/client/index.d.cts +4 -4
  25. package/dist/client/index.d.mts +4 -4
  26. package/dist/client/index.d.ts +4 -4
  27. package/dist/client/plugins/index.d.cts +4 -4
  28. package/dist/client/plugins/index.d.mts +4 -4
  29. package/dist/client/plugins/index.d.ts +4 -4
  30. package/dist/client/react/index.d.cts +4 -4
  31. package/dist/client/react/index.d.mts +4 -4
  32. package/dist/client/react/index.d.ts +4 -4
  33. package/dist/client/solid/index.d.cts +4 -4
  34. package/dist/client/solid/index.d.mts +4 -4
  35. package/dist/client/solid/index.d.ts +4 -4
  36. package/dist/client/svelte/index.d.cts +4 -4
  37. package/dist/client/svelte/index.d.mts +4 -4
  38. package/dist/client/svelte/index.d.ts +4 -4
  39. package/dist/client/vue/index.d.cts +4 -4
  40. package/dist/client/vue/index.d.mts +4 -4
  41. package/dist/client/vue/index.d.ts +4 -4
  42. package/dist/cookies/index.d.cts +3 -3
  43. package/dist/cookies/index.d.mts +3 -3
  44. package/dist/cookies/index.d.ts +3 -3
  45. package/dist/db/index.cjs +1 -1
  46. package/dist/db/index.d.cts +4 -4
  47. package/dist/db/index.d.mts +4 -4
  48. package/dist/db/index.d.ts +4 -4
  49. package/dist/db/index.mjs +1 -1
  50. package/dist/index.cjs +5 -5
  51. package/dist/index.d.cts +4 -4
  52. package/dist/index.d.mts +4 -4
  53. package/dist/index.d.ts +4 -4
  54. package/dist/index.mjs +4 -4
  55. package/dist/integrations/next-js.cjs +5 -5
  56. package/dist/integrations/next-js.d.cts +3 -3
  57. package/dist/integrations/next-js.d.mts +3 -3
  58. package/dist/integrations/next-js.d.ts +3 -3
  59. package/dist/integrations/next-js.mjs +4 -4
  60. package/dist/integrations/node.d.cts +3 -3
  61. package/dist/integrations/node.d.mts +3 -3
  62. package/dist/integrations/node.d.ts +3 -3
  63. package/dist/integrations/svelte-kit.d.cts +3 -3
  64. package/dist/integrations/svelte-kit.d.mts +3 -3
  65. package/dist/integrations/svelte-kit.d.ts +3 -3
  66. package/dist/oauth2/index.cjs +7 -6
  67. package/dist/oauth2/index.d.cts +14 -5
  68. package/dist/oauth2/index.d.mts +14 -5
  69. package/dist/oauth2/index.d.ts +14 -5
  70. package/dist/oauth2/index.mjs +1 -1
  71. package/dist/plugins/admin/index.cjs +3 -3
  72. package/dist/plugins/admin/index.d.cts +3 -3
  73. package/dist/plugins/admin/index.d.mts +3 -3
  74. package/dist/plugins/admin/index.d.ts +3 -3
  75. package/dist/plugins/admin/index.mjs +3 -3
  76. package/dist/plugins/anonymous/index.cjs +5 -5
  77. package/dist/plugins/anonymous/index.d.cts +3 -3
  78. package/dist/plugins/anonymous/index.d.mts +3 -3
  79. package/dist/plugins/anonymous/index.d.ts +3 -3
  80. package/dist/plugins/anonymous/index.mjs +2 -2
  81. package/dist/plugins/bearer/index.cjs +4 -4
  82. package/dist/plugins/bearer/index.d.cts +3 -3
  83. package/dist/plugins/bearer/index.d.mts +3 -3
  84. package/dist/plugins/bearer/index.d.ts +3 -3
  85. package/dist/plugins/bearer/index.mjs +2 -2
  86. package/dist/plugins/custom-session/index.cjs +4 -4
  87. package/dist/plugins/custom-session/index.d.cts +3 -3
  88. package/dist/plugins/custom-session/index.d.mts +3 -3
  89. package/dist/plugins/custom-session/index.d.ts +3 -3
  90. package/dist/plugins/custom-session/index.mjs +2 -2
  91. package/dist/plugins/email-otp/index.cjs +10 -10
  92. package/dist/plugins/email-otp/index.d.cts +3 -3
  93. package/dist/plugins/email-otp/index.d.mts +3 -3
  94. package/dist/plugins/email-otp/index.d.ts +3 -3
  95. package/dist/plugins/email-otp/index.mjs +2 -2
  96. package/dist/plugins/generic-oauth/index.cjs +43 -19
  97. package/dist/plugins/generic-oauth/index.d.cts +4 -4
  98. package/dist/plugins/generic-oauth/index.d.mts +4 -4
  99. package/dist/plugins/generic-oauth/index.d.ts +4 -4
  100. package/dist/plugins/generic-oauth/index.mjs +29 -5
  101. package/dist/plugins/index.cjs +22 -22
  102. package/dist/plugins/index.d.cts +4 -4
  103. package/dist/plugins/index.d.mts +4 -4
  104. package/dist/plugins/index.d.ts +4 -4
  105. package/dist/plugins/index.mjs +6 -6
  106. package/dist/plugins/jwt/index.cjs +6 -6
  107. package/dist/plugins/jwt/index.d.cts +3 -3
  108. package/dist/plugins/jwt/index.d.mts +3 -3
  109. package/dist/plugins/jwt/index.d.ts +3 -3
  110. package/dist/plugins/jwt/index.mjs +2 -2
  111. package/dist/plugins/magic-link/index.cjs +6 -6
  112. package/dist/plugins/magic-link/index.mjs +2 -2
  113. package/dist/plugins/multi-session/index.cjs +9 -9
  114. package/dist/plugins/multi-session/index.d.cts +3 -3
  115. package/dist/plugins/multi-session/index.d.mts +3 -3
  116. package/dist/plugins/multi-session/index.d.ts +3 -3
  117. package/dist/plugins/multi-session/index.mjs +2 -2
  118. package/dist/plugins/oauth-proxy/index.cjs +6 -6
  119. package/dist/plugins/oauth-proxy/index.d.cts +3 -3
  120. package/dist/plugins/oauth-proxy/index.d.mts +3 -3
  121. package/dist/plugins/oauth-proxy/index.d.ts +3 -3
  122. package/dist/plugins/oauth-proxy/index.mjs +2 -2
  123. package/dist/plugins/oidc-provider/index.cjs +14 -14
  124. package/dist/plugins/oidc-provider/index.d.cts +3 -3
  125. package/dist/plugins/oidc-provider/index.d.mts +3 -3
  126. package/dist/plugins/oidc-provider/index.d.ts +3 -3
  127. package/dist/plugins/oidc-provider/index.mjs +2 -2
  128. package/dist/plugins/one-tap/index.cjs +3 -3
  129. package/dist/plugins/one-tap/index.mjs +2 -2
  130. package/dist/plugins/open-api/index.cjs +4 -4
  131. package/dist/plugins/open-api/index.d.cts +3 -3
  132. package/dist/plugins/open-api/index.d.mts +3 -3
  133. package/dist/plugins/open-api/index.d.ts +3 -3
  134. package/dist/plugins/open-api/index.mjs +2 -2
  135. package/dist/plugins/organization/index.cjs +3 -3
  136. package/dist/plugins/organization/index.d.cts +3 -3
  137. package/dist/plugins/organization/index.d.mts +3 -3
  138. package/dist/plugins/organization/index.d.ts +3 -3
  139. package/dist/plugins/organization/index.mjs +3 -3
  140. package/dist/plugins/passkey/index.cjs +15 -15
  141. package/dist/plugins/passkey/index.d.cts +3 -3
  142. package/dist/plugins/passkey/index.d.mts +3 -3
  143. package/dist/plugins/passkey/index.d.ts +3 -3
  144. package/dist/plugins/passkey/index.mjs +2 -2
  145. package/dist/plugins/phone-number/index.cjs +13 -13
  146. package/dist/plugins/phone-number/index.d.cts +3 -3
  147. package/dist/plugins/phone-number/index.d.mts +3 -3
  148. package/dist/plugins/phone-number/index.d.ts +3 -3
  149. package/dist/plugins/phone-number/index.mjs +2 -2
  150. package/dist/plugins/sso/index.cjs +11 -11
  151. package/dist/plugins/sso/index.d.cts +2 -2
  152. package/dist/plugins/sso/index.d.mts +2 -2
  153. package/dist/plugins/sso/index.d.ts +2 -2
  154. package/dist/plugins/sso/index.mjs +3 -3
  155. package/dist/plugins/two-factor/index.cjs +20 -20
  156. package/dist/plugins/two-factor/index.d.cts +3 -3
  157. package/dist/plugins/two-factor/index.d.mts +3 -3
  158. package/dist/plugins/two-factor/index.d.ts +3 -3
  159. package/dist/plugins/two-factor/index.mjs +3 -3
  160. package/dist/plugins/username/index.cjs +9 -9
  161. package/dist/plugins/username/index.d.cts +3 -3
  162. package/dist/plugins/username/index.d.mts +3 -3
  163. package/dist/plugins/username/index.d.ts +3 -3
  164. package/dist/plugins/username/index.mjs +2 -2
  165. package/dist/shared/{better-auth.oyDBIJLs.mjs → better-auth.2rfXmCNS.mjs} +1 -1
  166. package/dist/shared/{better-auth.KTt7CS7L.mjs → better-auth.9knM1kR4.mjs} +1 -1
  167. package/dist/shared/{better-auth.DiMBK1Ep.mjs → better-auth.B2THyVQH.mjs} +54 -1
  168. package/dist/shared/{better-auth.C8tekzhG.cjs → better-auth.B7irTavj.cjs} +35 -35
  169. package/dist/shared/{better-auth.Dd96RDNl.d.ts → better-auth.BAfIsot3.d.ts} +41 -2
  170. package/dist/shared/{better-auth.Dunt9jpN.d.cts → better-auth.BBG0jAhH.d.mts} +2 -2
  171. package/dist/shared/{better-auth.CxMUffeh.d.cts → better-auth.BDAwKjlL.d.cts} +567 -46
  172. package/dist/shared/{better-auth.CbBX7Xla.mjs → better-auth.BK4Kh5QZ.mjs} +19 -17
  173. package/dist/shared/{better-auth.DgXCgiHI.cjs → better-auth.BLV8UOn8.cjs} +54 -0
  174. package/dist/shared/{better-auth.BjoUuJNr.d.mts → better-auth.BTnAiI8e.d.mts} +41 -2
  175. package/dist/shared/{better-auth.CzK7QJBv.d.cts → better-auth.CH6fRG6d.d.cts} +41 -2
  176. package/dist/shared/{better-auth.dzwyqpra.d.mts → better-auth.CTQDLJN7.d.mts} +567 -46
  177. package/dist/shared/{better-auth.CEuqoYDM.d.mts → better-auth.CtSY9Kmu.d.cts} +2 -2
  178. package/dist/shared/{better-auth.Cz2saE_0.d.cts → better-auth.DAnkIG1r.d.cts} +1 -1
  179. package/dist/shared/{better-auth.4ZqMps6Z.d.ts → better-auth.DCxEy-As.d.ts} +1 -1
  180. package/dist/shared/{better-auth.D7hUw1_Y.d.ts → better-auth.DIOWNBS2.d.ts} +1 -1
  181. package/dist/shared/{better-auth.ybwxmbrM.mjs → better-auth.DQ-pFMwp.mjs} +118 -5
  182. package/dist/shared/{better-auth.BxC2ipUB.d.mts → better-auth.DZPJQ81N.d.mts} +1 -1
  183. package/dist/shared/{better-auth.CL_N_Cfq.cjs → better-auth.DqGx7Ip8.cjs} +20 -20
  184. package/dist/shared/{better-auth.wspQErD2.cjs → better-auth.TNTVT6jt.cjs} +3 -3
  185. package/dist/shared/{better-auth.4J4_zAGP.cjs → better-auth.b0MLzqQX.cjs} +118 -4
  186. package/dist/shared/{better-auth.CdPDif0r.mjs → better-auth.cN4sTcuQ.mjs} +1 -1
  187. package/dist/shared/{better-auth.X0ynzeu1.cjs → better-auth.q7ChvjiM.cjs} +19 -17
  188. package/dist/shared/{better-auth.CixnJ90x.d.ts → better-auth.tpz8D0AA.d.ts} +567 -46
  189. package/dist/social-providers/index.cjs +197 -32
  190. package/dist/social-providers/index.d.cts +1 -1
  191. package/dist/social-providers/index.d.mts +1 -1
  192. package/dist/social-providers/index.d.ts +1 -1
  193. package/dist/social-providers/index.mjs +166 -1
  194. package/dist/types/index.d.cts +4 -4
  195. package/dist/types/index.d.mts +4 -4
  196. package/dist/types/index.d.ts +4 -4
  197. package/package.json +3 -3
@@ -2,7 +2,7 @@
2
2
 
3
3
  const random = require('../../shared/better-auth.CYeOI8C-.cjs');
4
4
  const zod = require('zod');
5
- const account = require('../../shared/better-auth.4J4_zAGP.cjs');
5
+ const refreshToken = require('../../shared/better-auth.b0MLzqQX.cjs');
6
6
  const betterCall = require('better-call');
7
7
  const cookies_index = require('../../cookies/index.cjs');
8
8
  const schema$1 = require('../../shared/better-auth.C5H9XEzZ.cjs');
@@ -10,7 +10,7 @@ require('../../shared/better-auth.DiSjtgs9.cjs');
10
10
  require('../../shared/better-auth.GpOOav9x.cjs');
11
11
  require('defu');
12
12
  const crypto_index = require('../../crypto/index.cjs');
13
- const verifyMiddleware = require('../../shared/better-auth.wspQErD2.cjs');
13
+ const verifyMiddleware = require('../../shared/better-auth.TNTVT6jt.cjs');
14
14
  const errorCode = require('../../shared/better-auth.C1-vpKly.cjs');
15
15
  require('@better-auth/utils/hash');
16
16
  require('@noble/ciphers/chacha');
@@ -29,7 +29,7 @@ const client = require('../../shared/better-auth.DnER2-iT.cjs');
29
29
  require('@better-auth/utils/random');
30
30
  require('../../social-providers/index.cjs');
31
31
  require('@better-fetch/fetch');
32
- require('../../shared/better-auth.DgXCgiHI.cjs');
32
+ require('../../shared/better-auth.BLV8UOn8.cjs');
33
33
  require('../../shared/better-auth.C1hdVENX.cjs');
34
34
  require('../../shared/better-auth.ANpbi45u.cjs');
35
35
  require('../../shared/better-auth.QbbyHMYf.cjs');
@@ -87,7 +87,7 @@ const backupCode2fa = (options) => {
87
87
  return {
88
88
  id: "backup_code",
89
89
  endpoints: {
90
- verifyBackupCode: account.createAuthEndpoint(
90
+ verifyBackupCode: refreshToken.createAuthEndpoint(
91
91
  "/two-factor/verify-backup-code",
92
92
  {
93
93
  method: "POST",
@@ -166,14 +166,14 @@ const backupCode2fa = (options) => {
166
166
  });
167
167
  }
168
168
  ),
169
- generateBackupCodes: account.createAuthEndpoint(
169
+ generateBackupCodes: refreshToken.createAuthEndpoint(
170
170
  "/two-factor/generate-backup-codes",
171
171
  {
172
172
  method: "POST",
173
173
  body: zod.z.object({
174
174
  password: zod.z.string()
175
175
  }),
176
- use: [account.sessionMiddleware]
176
+ use: [refreshToken.sessionMiddleware]
177
177
  },
178
178
  async (ctx) => {
179
179
  const user = ctx.context.session.user;
@@ -205,7 +205,7 @@ const backupCode2fa = (options) => {
205
205
  });
206
206
  }
207
207
  ),
208
- viewBackupCodes: account.createAuthEndpoint(
208
+ viewBackupCodes: refreshToken.createAuthEndpoint(
209
209
  "/two-factor/view-backup-codes",
210
210
  {
211
211
  method: "GET",
@@ -257,7 +257,7 @@ const otp2fa = (options) => {
257
257
  period: (options?.period || 3) * 60 * 1e3
258
258
  };
259
259
  const twoFactorTable = "twoFactor";
260
- const send2FaOTP = account.createAuthEndpoint(
260
+ const send2FaOTP = refreshToken.createAuthEndpoint(
261
261
  "/two-factor/send-otp",
262
262
  {
263
263
  method: "POST",
@@ -328,7 +328,7 @@ const otp2fa = (options) => {
328
328
  return ctx.json({ status: true });
329
329
  }
330
330
  );
331
- const verifyOTP = account.createAuthEndpoint(
331
+ const verifyOTP = refreshToken.createAuthEndpoint(
332
332
  "/two-factor/verify-otp",
333
333
  {
334
334
  method: "POST",
@@ -436,11 +436,11 @@ const totp2fa = (options) => {
436
436
  period: options?.period || 30
437
437
  };
438
438
  const twoFactorTable = "twoFactor";
439
- const generateTOTP = account.createAuthEndpoint(
439
+ const generateTOTP = refreshToken.createAuthEndpoint(
440
440
  "/totp/generate",
441
441
  {
442
442
  method: "POST",
443
- use: [account.sessionMiddleware],
443
+ use: [refreshToken.sessionMiddleware],
444
444
  metadata: {
445
445
  openapi: {
446
446
  summary: "Generate TOTP code",
@@ -496,11 +496,11 @@ const totp2fa = (options) => {
496
496
  return { code };
497
497
  }
498
498
  );
499
- const getTOTPURI = account.createAuthEndpoint(
499
+ const getTOTPURI = refreshToken.createAuthEndpoint(
500
500
  "/two-factor/get-totp-uri",
501
501
  {
502
502
  method: "POST",
503
- use: [account.sessionMiddleware],
503
+ use: [refreshToken.sessionMiddleware],
504
504
  body: zod.z.object({
505
505
  password: zod.z.string({
506
506
  description: "User password"
@@ -568,7 +568,7 @@ const totp2fa = (options) => {
568
568
  };
569
569
  }
570
570
  );
571
- const verifyTOTP = account.createAuthEndpoint(
571
+ const verifyTOTP = refreshToken.createAuthEndpoint(
572
572
  "/two-factor/verify-totp",
573
573
  {
574
574
  method: "POST",
@@ -731,7 +731,7 @@ const twoFactor = (options) => {
731
731
  ...totp.endpoints,
732
732
  ...otp$1.endpoints,
733
733
  ...backupCode.endpoints,
734
- enableTwoFactor: account.createAuthEndpoint(
734
+ enableTwoFactor: refreshToken.createAuthEndpoint(
735
735
  "/two-factor/enable",
736
736
  {
737
737
  method: "POST",
@@ -740,7 +740,7 @@ const twoFactor = (options) => {
740
740
  description: "User password"
741
741
  })
742
742
  }),
743
- use: [account.sessionMiddleware],
743
+ use: [refreshToken.sessionMiddleware],
744
744
  metadata: {
745
745
  openapi: {
746
746
  summary: "Enable two factor authentication",
@@ -782,7 +782,7 @@ const twoFactor = (options) => {
782
782
  });
783
783
  if (!isPasswordValid) {
784
784
  throw new betterCall.APIError("BAD_REQUEST", {
785
- message: account.BASE_ERROR_CODES.INVALID_PASSWORD
785
+ message: refreshToken.BASE_ERROR_CODES.INVALID_PASSWORD
786
786
  });
787
787
  }
788
788
  const secret = random.generateRandomString(32);
@@ -840,7 +840,7 @@ const twoFactor = (options) => {
840
840
  return ctx.json({ totpURI, backupCodes: backupCodes.backupCodes });
841
841
  }
842
842
  ),
843
- disableTwoFactor: account.createAuthEndpoint(
843
+ disableTwoFactor: refreshToken.createAuthEndpoint(
844
844
  "/two-factor/disable",
845
845
  {
846
846
  method: "POST",
@@ -849,7 +849,7 @@ const twoFactor = (options) => {
849
849
  description: "User password"
850
850
  }).min(8)
851
851
  }),
852
- use: [account.sessionMiddleware],
852
+ use: [refreshToken.sessionMiddleware],
853
853
  metadata: {
854
854
  openapi: {
855
855
  summary: "Disable two factor authentication",
@@ -926,7 +926,7 @@ const twoFactor = (options) => {
926
926
  matcher(context) {
927
927
  return context.path === "/sign-in/email" || context.path === "/sign-in/username" || context.path === "/sign-in/phone-number";
928
928
  },
929
- handler: account.createAuthMiddleware(async (ctx) => {
929
+ handler: refreshToken.createAuthMiddleware(async (ctx) => {
930
930
  const data = ctx.context.newSession;
931
931
  if (!data) {
932
932
  return;
@@ -1,11 +1,11 @@
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, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.CxMUffeh.cjs';
3
+ import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.BDAwKjlL.cjs';
4
4
  import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.cjs';
5
5
  import * as _better_fetch_fetch from '@better-fetch/fetch';
6
- import 'kysely';
7
- import '../../shared/better-auth.CzK7QJBv.cjs';
6
+ import '../../shared/better-auth.CH6fRG6d.cjs';
8
7
  import 'jose';
8
+ import 'kysely';
9
9
  import 'better-sqlite3';
10
10
 
11
11
  interface BackupCodeOptions {
@@ -1,11 +1,11 @@
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, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.dzwyqpra.mjs';
3
+ import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.CTQDLJN7.mjs';
4
4
  import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.mjs';
5
5
  import * as _better_fetch_fetch from '@better-fetch/fetch';
6
- import 'kysely';
7
- import '../../shared/better-auth.BjoUuJNr.mjs';
6
+ import '../../shared/better-auth.BTnAiI8e.mjs';
8
7
  import 'jose';
8
+ import 'kysely';
9
9
  import 'better-sqlite3';
10
10
 
11
11
  interface BackupCodeOptions {
@@ -1,11 +1,11 @@
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, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.CixnJ90x.js';
3
+ import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.tpz8D0AA.js';
4
4
  import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.js';
5
5
  import * as _better_fetch_fetch from '@better-fetch/fetch';
6
- import 'kysely';
7
- import '../../shared/better-auth.Dd96RDNl.js';
6
+ import '../../shared/better-auth.BAfIsot3.js';
8
7
  import 'jose';
8
+ import 'kysely';
9
9
  import 'better-sqlite3';
10
10
 
11
11
  interface BackupCodeOptions {
@@ -1,6 +1,6 @@
1
1
  import { g as generateRandomString } from '../../shared/better-auth.B4Qoxdgc.mjs';
2
2
  import { z } from 'zod';
3
- import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.ybwxmbrM.mjs';
3
+ import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.DQ-pFMwp.mjs';
4
4
  import { APIError } from 'better-call';
5
5
  import { setSessionCookie, deleteSessionCookie } from '../../cookies/index.mjs';
6
6
  import { m as mergeSchema } from '../../shared/better-auth.CepcSj5H.mjs';
@@ -8,7 +8,7 @@ import '../../shared/better-auth.8zoxzg-F.mjs';
8
8
  import '../../shared/better-auth.DH3YjMQH.mjs';
9
9
  import 'defu';
10
10
  import { symmetricEncrypt, symmetricDecrypt } from '../../crypto/index.mjs';
11
- import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.oyDBIJLs.mjs';
11
+ import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.2rfXmCNS.mjs';
12
12
  import { T as TWO_FACTOR_ERROR_CODES } from '../../shared/better-auth.BcoSd9tC.mjs';
13
13
  import '@better-auth/utils/hash';
14
14
  import '@noble/ciphers/chacha';
@@ -27,7 +27,7 @@ export { t as twoFactorClient } from '../../shared/better-auth.Ddw8bVyV.mjs';
27
27
  import '@better-auth/utils/random';
28
28
  import '../../social-providers/index.mjs';
29
29
  import '@better-fetch/fetch';
30
- import '../../shared/better-auth.DiMBK1Ep.mjs';
30
+ import '../../shared/better-auth.B2THyVQH.mjs';
31
31
  import '../../shared/better-auth.CW6D9eSx.mjs';
32
32
  import '../../shared/better-auth.DdzSJf-n.mjs';
33
33
  import '../../shared/better-auth.BdyOG_p4.mjs';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zod = require('zod');
4
- const account = require('../../shared/better-auth.4J4_zAGP.cjs');
4
+ const refreshToken = require('../../shared/better-auth.b0MLzqQX.cjs');
5
5
  const betterCall = require('better-call');
6
6
  const cookies_index = require('../../cookies/index.cjs');
7
7
  const schema$1 = require('../../shared/better-auth.C5H9XEzZ.cjs');
@@ -12,7 +12,7 @@ const errorCode = require('../../shared/better-auth.C1-vpKly.cjs');
12
12
  require('../../social-providers/index.cjs');
13
13
  require('@better-fetch/fetch');
14
14
  require('jose');
15
- require('../../shared/better-auth.DgXCgiHI.cjs');
15
+ require('../../shared/better-auth.BLV8UOn8.cjs');
16
16
  require('../../shared/better-auth.C1hdVENX.cjs');
17
17
  require('@better-auth/utils/hash');
18
18
  require('@better-auth/utils/base64');
@@ -73,7 +73,7 @@ const username = (options) => {
73
73
  return {
74
74
  id: "username",
75
75
  endpoints: {
76
- signInUsername: account.createAuthEndpoint(
76
+ signInUsername: refreshToken.createAuthEndpoint(
77
77
  "/sign-in/username",
78
78
  {
79
79
  method: "POST",
@@ -163,12 +163,12 @@ const username = (options) => {
163
163
  });
164
164
  }
165
165
  if (!user.emailVerified && ctx.context.options.emailAndPassword?.requireEmailVerification) {
166
- await account.sendVerificationEmailFn(ctx, user);
166
+ await refreshToken.sendVerificationEmailFn(ctx, user);
167
167
  throw new betterCall.APIError("FORBIDDEN", {
168
168
  message: ERROR_CODES.EMAIL_NOT_VERIFIED
169
169
  });
170
170
  }
171
- const account$1 = await ctx.context.adapter.findOne({
171
+ const account = await ctx.context.adapter.findOne({
172
172
  model: "account",
173
173
  where: [
174
174
  {
@@ -181,12 +181,12 @@ const username = (options) => {
181
181
  }
182
182
  ]
183
183
  });
184
- if (!account$1) {
184
+ if (!account) {
185
185
  throw new betterCall.APIError("UNAUTHORIZED", {
186
186
  message: ERROR_CODES.INVALID_USERNAME_OR_PASSWORD
187
187
  });
188
188
  }
189
- const currentPassword = account$1?.password;
189
+ const currentPassword = account?.password;
190
190
  if (!currentPassword) {
191
191
  ctx.context.logger.error("Password not found", { username });
192
192
  throw new betterCall.APIError("UNAUTHORIZED", {
@@ -212,7 +212,7 @@ const username = (options) => {
212
212
  return ctx.json(null, {
213
213
  status: 500,
214
214
  body: {
215
- message: account.BASE_ERROR_CODES.FAILED_TO_CREATE_SESSION
215
+ message: refreshToken.BASE_ERROR_CODES.FAILED_TO_CREATE_SESSION
216
216
  }
217
217
  });
218
218
  }
@@ -244,7 +244,7 @@ const username = (options) => {
244
244
  matcher(context) {
245
245
  return context.path === "/sign-up/email" || context.path === "/update-user";
246
246
  },
247
- handler: account.createAuthMiddleware(async (ctx) => {
247
+ handler: refreshToken.createAuthMiddleware(async (ctx) => {
248
248
  const username2 = ctx.body.username;
249
249
  if (username2) {
250
250
  const minUsernameLength = options?.minUsernameLength || 3;
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import * as better_call from 'better-call';
3
- import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.CxMUffeh.cjs';
3
+ import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.BDAwKjlL.cjs';
4
4
  import '../../shared/better-auth.Bi8FQwDD.cjs';
5
- import 'kysely';
6
- import '../../shared/better-auth.CzK7QJBv.cjs';
5
+ import '../../shared/better-auth.CH6fRG6d.cjs';
7
6
  import 'jose';
7
+ import 'kysely';
8
8
  import 'better-sqlite3';
9
9
 
10
10
  declare const schema: {
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import * as better_call from 'better-call';
3
- import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.dzwyqpra.mjs';
3
+ import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.CTQDLJN7.mjs';
4
4
  import '../../shared/better-auth.Bi8FQwDD.mjs';
5
- import 'kysely';
6
- import '../../shared/better-auth.BjoUuJNr.mjs';
5
+ import '../../shared/better-auth.BTnAiI8e.mjs';
7
6
  import 'jose';
7
+ import 'kysely';
8
8
  import 'better-sqlite3';
9
9
 
10
10
  declare const schema: {
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import * as better_call from 'better-call';
3
- import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.CixnJ90x.js';
3
+ import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.tpz8D0AA.js';
4
4
  import '../../shared/better-auth.Bi8FQwDD.js';
5
- import 'kysely';
6
- import '../../shared/better-auth.Dd96RDNl.js';
5
+ import '../../shared/better-auth.BAfIsot3.js';
7
6
  import 'jose';
7
+ import 'kysely';
8
8
  import 'better-sqlite3';
9
9
 
10
10
  declare const schema: {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.ybwxmbrM.mjs';
2
+ import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.DQ-pFMwp.mjs';
3
3
  import { APIError } from 'better-call';
4
4
  import { setSessionCookie } from '../../cookies/index.mjs';
5
5
  import { m as mergeSchema } from '../../shared/better-auth.CepcSj5H.mjs';
@@ -10,7 +10,7 @@ import { T as TWO_FACTOR_ERROR_CODES } from '../../shared/better-auth.BcoSd9tC.m
10
10
  import '../../social-providers/index.mjs';
11
11
  import '@better-fetch/fetch';
12
12
  import 'jose';
13
- import '../../shared/better-auth.DiMBK1Ep.mjs';
13
+ import '../../shared/better-auth.B2THyVQH.mjs';
14
14
  import '../../shared/better-auth.CW6D9eSx.mjs';
15
15
  import '@better-auth/utils/hash';
16
16
  import '@better-auth/utils/base64';
@@ -1,5 +1,5 @@
1
1
  import { APIError } from 'better-call';
2
- import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.ybwxmbrM.mjs';
2
+ import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.DQ-pFMwp.mjs';
3
3
  import { setSessionCookie } from '../cookies/index.mjs';
4
4
  import { z } from 'zod';
5
5
  import './better-auth.CepcSj5H.mjs';
@@ -1,6 +1,6 @@
1
1
  import { APIError } from 'better-call';
2
2
  import { z } from 'zod';
3
- import { c as createAuthMiddleware, s as sessionMiddleware, a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES, M as requestOnlySessionMiddleware } from './better-auth.ybwxmbrM.mjs';
3
+ import { c as createAuthMiddleware, s as sessionMiddleware, a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES, N as requestOnlySessionMiddleware } from './better-auth.DQ-pFMwp.mjs';
4
4
  import './better-auth.8zoxzg-F.mjs';
5
5
  import '@better-auth/utils/base64';
6
6
  import '@better-auth/utils/hmac';
@@ -144,4 +144,57 @@ async function validateToken(token, jwksEndpoint) {
144
144
  return verified;
145
145
  }
146
146
 
147
- export { validateToken as a, getOAuth2Tokens as b, createAuthorizationURL as c, generateCodeChallenge as g, validateAuthorizationCode as v };
147
+ async function refreshAccessToken({
148
+ refreshToken,
149
+ options,
150
+ tokenEndpoint,
151
+ authentication,
152
+ extraParams,
153
+ grantType = "refresh_token"
154
+ }) {
155
+ const body = new URLSearchParams();
156
+ const headers = {
157
+ "content-type": "application/x-www-form-urlencoded",
158
+ accept: "application/json"
159
+ };
160
+ body.set("grant_type", grantType);
161
+ body.set("refresh_token", refreshToken);
162
+ if (authentication === "basic") {
163
+ const encodedCredentials = btoa(
164
+ `${options.clientId}:${options.clientSecret}`
165
+ );
166
+ headers["authorization"] = `Basic ${encodedCredentials}`;
167
+ } else {
168
+ body.set("client_id", options.clientId);
169
+ body.set("client_secret", options.clientSecret);
170
+ }
171
+ if (extraParams) {
172
+ for (const [key, value] of Object.entries(extraParams)) {
173
+ body.set(key, value);
174
+ }
175
+ }
176
+ const { data, error } = await betterFetch(tokenEndpoint, {
177
+ method: "POST",
178
+ body,
179
+ headers
180
+ });
181
+ if (error) {
182
+ throw error;
183
+ }
184
+ const tokens = {
185
+ accessToken: data.access_token,
186
+ refreshToken: data.refresh_token,
187
+ tokenType: data.token_type,
188
+ scopes: data.scope?.split(" "),
189
+ idToken: data.id_token
190
+ };
191
+ if (data.expires_in) {
192
+ const now = /* @__PURE__ */ new Date();
193
+ tokens.accessTokenExpiresAt = new Date(
194
+ now.getTime() + data.expires_in * 1e3
195
+ );
196
+ }
197
+ return tokens;
198
+ }
199
+
200
+ export { validateToken as a, getOAuth2Tokens as b, createAuthorizationURL as c, generateCodeChallenge as g, refreshAccessToken as r, validateAuthorizationCode as v };