better-auth 1.7.13 → 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.
package/dist/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.7.13";
2
+ var version = "1.7.14";
3
3
  //#endregion
4
4
  export { version };
@@ -9,7 +9,18 @@ import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
9
9
  import { createAuthEndpoint } from "@better-auth/core/api";
10
10
  import * as z from "zod";
11
11
  import { createOTP } from "@better-auth/utils/otp";
12
+ import { base32 } from "@better-auth/utils/base32";
12
13
  //#region src/plugins/two-factor/totp/index.ts
14
+ const BASE32_PREFIX = "base32:";
15
+ /**
16
+ * Secrets imported from other providers are stored as `base32:<secret>`.
17
+ * Generated secrets never contain `:`, so they are used as-is.
18
+ */
19
+ async function decryptTOTPSecret(options) {
20
+ const secret = await symmetricDecrypt(options);
21
+ if (!secret.startsWith(BASE32_PREFIX)) return secret;
22
+ return base32.decode(secret.slice(7).toUpperCase());
23
+ }
13
24
  const generateTOTPBodySchema = z.object({ secret: z.string().meta({ description: "The secret to generate the TOTP code" }) });
14
25
  const verifyTOTPBodySchema = z.object({
15
26
  code: z.string().meta({ description: "The otp code to verify. Eg: \"012345\"" }),
@@ -88,7 +99,7 @@ const totp2fa = (options) => {
88
99
  }]
89
100
  });
90
101
  if (!twoFactor) throw APIError.from("BAD_REQUEST", TWO_FACTOR_ERROR_CODES.TOTP_NOT_ENABLED);
91
- const secret = await symmetricDecrypt({
102
+ const secret = await decryptTOTPSecret({
92
103
  key: ctx.context.secretConfig,
93
104
  data: twoFactor.secret
94
105
  });
@@ -139,7 +150,7 @@ const totp2fa = (options) => {
139
150
  const attempt = isSignIn ? await beginAttempt(5) : null;
140
151
  let status;
141
152
  try {
142
- const decrypted = await symmetricDecrypt({
153
+ const decrypted = await decryptTOTPSecret({
143
154
  key: ctx.context.secretConfig,
144
155
  data: twoFactor.secret
145
156
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "1.7.13",
3
+ "version": "1.7.14",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -503,13 +503,13 @@
503
503
  "kysely": "^0.28.17 || ^0.29.0",
504
504
  "nanostores": "^1.3.0",
505
505
  "zod": "^4.5.4",
506
- "@better-auth/core": "1.7.13",
507
- "@better-auth/drizzle-adapter": "1.7.13",
508
- "@better-auth/kysely-adapter": "1.7.13",
509
- "@better-auth/memory-adapter": "1.7.13",
510
- "@better-auth/mongo-adapter": "1.7.13",
511
- "@better-auth/prisma-adapter": "1.7.13",
512
- "@better-auth/telemetry": "1.7.13"
506
+ "@better-auth/core": "1.7.14",
507
+ "@better-auth/drizzle-adapter": "1.7.14",
508
+ "@better-auth/kysely-adapter": "1.7.14",
509
+ "@better-auth/memory-adapter": "1.7.14",
510
+ "@better-auth/mongo-adapter": "1.7.14",
511
+ "@better-auth/prisma-adapter": "1.7.14",
512
+ "@better-auth/telemetry": "1.7.14"
513
513
  },
514
514
  "devDependencies": {
515
515
  "@lynx-js/react": "^0.121.2",