@better-auth/passkey 1.6.16 → 1.6.17
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-
|
|
1
|
+
import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-Dpvq05Wg.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-
|
|
1
|
+
import { n as PASSKEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-Dpvq05Wg.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";
|
|
@@ -178,6 +178,7 @@ const generatePasskeyRegistrationOptions = (opts, { maxAgeInSeconds }) => {
|
|
|
178
178
|
await ctx.context.internalAdapter.createVerificationValue({
|
|
179
179
|
identifier: verificationToken,
|
|
180
180
|
value: JSON.stringify({
|
|
181
|
+
type: "registration",
|
|
181
182
|
expectedChallenge: options.challenge,
|
|
182
183
|
userData: {
|
|
183
184
|
id: user.id,
|
|
@@ -268,6 +269,7 @@ const generatePasskeyAuthenticationOptions = (opts, { maxAgeInSeconds }) => crea
|
|
|
268
269
|
})) } : {}
|
|
269
270
|
});
|
|
270
271
|
const data = {
|
|
272
|
+
type: "authentication",
|
|
271
273
|
expectedChallenge: options.challenge,
|
|
272
274
|
userData: { id: session?.user.id || "" }
|
|
273
275
|
};
|
|
@@ -315,7 +317,8 @@ const verifyPasskeyRegistration = (options) => {
|
|
|
315
317
|
if (!verificationToken) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
316
318
|
const data = await ctx.context.internalAdapter.consumeVerificationValue(verificationToken);
|
|
317
319
|
if (!data) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
318
|
-
const { expectedChallenge, userData, context } = JSON.parse(data.value);
|
|
320
|
+
const { type: ceremony, expectedChallenge, userData, context } = JSON.parse(data.value);
|
|
321
|
+
if (ceremony !== void 0 && ceremony !== "registration") throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
319
322
|
const session = requireSession ? ctx.context.session : await getSessionFromCtx(ctx);
|
|
320
323
|
if (session?.user?.id && userData.id !== session.user.id) throw APIError.from("UNAUTHORIZED", PASSKEY_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY);
|
|
321
324
|
try {
|
|
@@ -351,6 +354,7 @@ const verifyPasskeyRegistration = (options) => {
|
|
|
351
354
|
}
|
|
352
355
|
if (!resolvedName) resolvedName = result?.name?.trim() || void 0;
|
|
353
356
|
}
|
|
357
|
+
if (!targetUserId) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.RESOLVED_USER_INVALID);
|
|
354
358
|
const pubKey = base64.encode(credential.publicKey);
|
|
355
359
|
const newPasskey = {
|
|
356
360
|
name: resolvedName,
|
|
@@ -406,7 +410,8 @@ const verifyPasskeyAuthentication = (options) => createAuthEndpoint("/passkey/ve
|
|
|
406
410
|
if (!verificationToken) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
407
411
|
const data = await ctx.context.internalAdapter.consumeVerificationValue(verificationToken);
|
|
408
412
|
if (!data) throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
409
|
-
const { expectedChallenge } = JSON.parse(data.value);
|
|
413
|
+
const { type: ceremony, expectedChallenge } = JSON.parse(data.value);
|
|
414
|
+
if (ceremony !== void 0 && ceremony !== "authentication") throw APIError.from("BAD_REQUEST", PASSKEY_ERROR_CODES.CHALLENGE_NOT_FOUND);
|
|
410
415
|
const passkey = await ctx.context.adapter.findOne({
|
|
411
416
|
model: "passkey",
|
|
412
417
|
where: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/passkey",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.17",
|
|
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.6.
|
|
59
|
-
"better-auth": "1.6.
|
|
58
|
+
"@better-auth/core": "1.6.17",
|
|
59
|
+
"better-auth": "1.6.17"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@better-auth/utils": "0.4.1",
|
|
63
|
-
"@better-fetch/fetch": "1.
|
|
63
|
+
"@better-fetch/fetch": "1.3.0",
|
|
64
64
|
"better-call": "1.3.6",
|
|
65
65
|
"nanostores": "^1.0.1",
|
|
66
|
-
"@better-auth/core": "^1.6.
|
|
67
|
-
"better-auth": "^1.6.
|
|
66
|
+
"@better-auth/core": "^1.6.17",
|
|
67
|
+
"better-auth": "^1.6.17"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|