@better-auth/passkey 1.7.0-beta.3 → 1.7.0-beta.4

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/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-kd5ipnRY.mjs";
1
+ import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-D_0sS5d6.mjs";
2
2
  import { WebAuthnError, startAuthentication, startRegistration } from "@simplewebauthn/browser";
3
3
  import { useAuthQuery } from "better-auth/client";
4
4
  import { atom } from "nanostores";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-kd5ipnRY.mjs";
1
+ import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-D_0sS5d6.mjs";
2
2
  import { mergeSchema } from "better-auth/db";
3
3
  import { createAuthEndpoint } from "@better-auth/core/api";
4
4
  import { APIError } from "@better-auth/core/error";
@@ -313,7 +313,7 @@ const verifyPasskeyRegistration = (options) => {
313
313
  const webAuthnCookie = ctx.context.createAuthCookie(options.advanced.webAuthnChallengeCookie);
314
314
  const verificationToken = await ctx.getSignedCookie(webAuthnCookie.name, ctx.context.secret);
315
315
  if (!verificationToken) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
316
- const data = await ctx.context.internalAdapter.findVerificationValue(verificationToken);
316
+ const data = await ctx.context.internalAdapter.consumeVerificationValue(verificationToken);
317
317
  if (!data) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
318
318
  const { expectedChallenge, userData, context } = JSON.parse(data.value);
319
319
  const session = requireSession ? ctx.context.session : await getSessionFromCtx(ctx);
@@ -357,7 +357,7 @@ const verifyPasskeyRegistration = (options) => {
357
357
  publicKey: pubKey,
358
358
  counter: credential.counter,
359
359
  deviceType: credentialDeviceType,
360
- transports: resp.response.transports.join(","),
360
+ transports: resp.response.transports?.join(",") ?? "",
361
361
  backedUp: credentialBackedUp,
362
362
  createdAt: /* @__PURE__ */ new Date(),
363
363
  aaguid
@@ -366,9 +366,9 @@ const verifyPasskeyRegistration = (options) => {
366
366
  model: "passkey",
367
367
  data: newPasskey
368
368
  });
369
- await ctx.context.internalAdapter.deleteVerificationByIdentifier(verificationToken);
370
369
  return ctx.json(newPasskeyRes, { status: 200 });
371
370
  } catch (e) {
371
+ if (e instanceof APIError) throw e;
372
372
  ctx.context.logger.error("Failed to verify registration", e);
373
373
  throw APIError.from("INTERNAL_SERVER_ERROR", PASSKEY_ERROR_CODES.FAILED_TO_VERIFY_REGISTRATION);
374
374
  }
@@ -402,7 +402,7 @@ const verifyPasskeyAuthentication = (options) => createAuthEndpoint("/passkey/ve
402
402
  const webAuthnCookie = ctx.context.createAuthCookie(options.advanced.webAuthnChallengeCookie);
403
403
  const verificationToken = await ctx.getSignedCookie(webAuthnCookie.name, ctx.context.secret);
404
404
  if (!verificationToken) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
405
- const data = await ctx.context.internalAdapter.findVerificationValue(verificationToken);
405
+ const data = await ctx.context.internalAdapter.consumeVerificationValue(verificationToken);
406
406
  if (!data) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
407
407
  const { expectedChallenge } = JSON.parse(data.value);
408
408
  const passkey = await ctx.context.adapter.findOne({
@@ -450,12 +450,12 @@ const verifyPasskeyAuthentication = (options) => createAuthEndpoint("/passkey/ve
450
450
  session: s,
451
451
  user
452
452
  });
453
- await ctx.context.internalAdapter.deleteVerificationByIdentifier(verificationToken);
454
453
  return ctx.json({
455
454
  session: s,
456
455
  user
457
456
  }, { status: 200 });
458
457
  } catch (e) {
458
+ if (e instanceof APIError) throw e;
459
459
  ctx.context.logger.error("Failed to verify authentication", e);
460
460
  throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.AUTHENTICATION_FAILED);
461
461
  }
@@ -18,6 +18,6 @@ const PASSKEY_ERROR_CODES = defineErrorCodes({
18
18
  });
19
19
  //#endregion
20
20
  //#region src/version.ts
21
- const PACKAGE_VERSION = "1.7.0-beta.3";
21
+ const PACKAGE_VERSION = "1.7.0-beta.4";
22
22
  //#endregion
23
23
  export { PASSKEY_ERROR_CODES as n, PACKAGE_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/passkey",
3
- "version": "1.7.0-beta.3",
3
+ "version": "1.7.0-beta.4",
4
4
  "description": "Passkey plugin for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -55,16 +55,16 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "tsdown": "0.21.1",
58
- "@better-auth/core": "1.7.0-beta.3",
59
- "better-auth": "1.7.0-beta.3"
58
+ "@better-auth/core": "1.7.0-beta.4",
59
+ "better-auth": "1.7.0-beta.4"
60
60
  },
61
61
  "peerDependencies": {
62
- "@better-auth/utils": "0.4.0",
62
+ "@better-auth/utils": "0.4.1",
63
63
  "@better-fetch/fetch": "1.1.21",
64
64
  "better-call": "1.3.5",
65
65
  "nanostores": "^1.0.1",
66
- "@better-auth/core": "^1.7.0-beta.3",
67
- "better-auth": "^1.7.0-beta.3"
66
+ "@better-auth/core": "^1.7.0-beta.4",
67
+ "better-auth": "^1.7.0-beta.4"
68
68
  },
69
69
  "scripts": {
70
70
  "build": "tsdown",