@better-auth/passkey 1.6.0-beta.0 → 1.6.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.
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index-DD5Lute1.d.mts +811 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +18 -23
- package/dist/{version-B7zkjZSd.mjs → version-oKGpZwN_.mjs} +1 -1
- package/package.json +6 -6
- package/dist/index-BzKpmgHh.d.mts +0 -771
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as PASSKEY_ERROR_CODES, o as PasskeyOptions, r as Passkey, t as passkey } from "./index-
|
|
1
|
+
import { n as PASSKEY_ERROR_CODES, o as PasskeyOptions, r as Passkey, t as passkey } from "./index-DD5Lute1.mjs";
|
|
2
2
|
export { PASSKEY_ERROR_CODES, Passkey, PasskeyOptions, passkey };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-oKGpZwN_.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";
|
|
5
5
|
import { base64 } from "@better-auth/utils/base64";
|
|
6
6
|
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";
|
|
7
|
-
import { freshSessionMiddleware, getSessionFromCtx, sessionMiddleware } from "better-auth/api";
|
|
7
|
+
import { freshSessionMiddleware, getSessionFromCtx, requireResourceOwnership, sessionMiddleware } from "better-auth/api";
|
|
8
8
|
import { setSessionCookie } from "better-auth/cookies";
|
|
9
9
|
import { generateRandomString } from "better-auth/crypto";
|
|
10
10
|
import * as z from "zod";
|
|
@@ -523,7 +523,13 @@ const listPasskeys = createAuthEndpoint("/passkey/list-user-passkeys", {
|
|
|
523
523
|
const deletePasskey = createAuthEndpoint("/passkey/delete-passkey", {
|
|
524
524
|
method: "POST",
|
|
525
525
|
body: z.object({ id: z.string().meta({ description: "The ID of the passkey to delete. Eg: \"some-passkey-id\"" }) }),
|
|
526
|
-
use: [sessionMiddleware
|
|
526
|
+
use: [sessionMiddleware, requireResourceOwnership({
|
|
527
|
+
model: "passkey",
|
|
528
|
+
idParam: "id",
|
|
529
|
+
idSource: "body",
|
|
530
|
+
notFoundError: PASSKEY_ERROR_CODES.PASSKEY_NOT_FOUND,
|
|
531
|
+
forbiddenStatus: "UNAUTHORIZED"
|
|
532
|
+
})],
|
|
527
533
|
metadata: { openapi: {
|
|
528
534
|
description: "Delete a specific passkey",
|
|
529
535
|
responses: { "200": {
|
|
@@ -539,20 +545,11 @@ const deletePasskey = createAuthEndpoint("/passkey/delete-passkey", {
|
|
|
539
545
|
} }
|
|
540
546
|
} }
|
|
541
547
|
}, async (ctx) => {
|
|
542
|
-
const passkey = await ctx.context.adapter.findOne({
|
|
543
|
-
model: "passkey",
|
|
544
|
-
where: [{
|
|
545
|
-
field: "id",
|
|
546
|
-
value: ctx.body.id
|
|
547
|
-
}]
|
|
548
|
-
});
|
|
549
|
-
if (!passkey) throw APIError.from("NOT_FOUND", PASSKEY_ERROR_CODES.PASSKEY_NOT_FOUND);
|
|
550
|
-
if (passkey.userId !== ctx.context.session.user.id) throw new APIError("UNAUTHORIZED");
|
|
551
548
|
await ctx.context.adapter.delete({
|
|
552
549
|
model: "passkey",
|
|
553
550
|
where: [{
|
|
554
551
|
field: "id",
|
|
555
|
-
value:
|
|
552
|
+
value: ctx.body.id
|
|
556
553
|
}]
|
|
557
554
|
});
|
|
558
555
|
return ctx.json({ status: true });
|
|
@@ -578,7 +575,14 @@ const updatePasskey = createAuthEndpoint("/passkey/update-passkey", {
|
|
|
578
575
|
id: z.string().meta({ description: `The ID of the passkey which will be updated. Eg: \"passkey-id\"` }),
|
|
579
576
|
name: z.string().meta({ description: `The new name which the passkey will be updated to. Eg: \"my-new-passkey-name\"` })
|
|
580
577
|
}),
|
|
581
|
-
use: [sessionMiddleware
|
|
578
|
+
use: [sessionMiddleware, requireResourceOwnership({
|
|
579
|
+
model: "passkey",
|
|
580
|
+
idParam: "id",
|
|
581
|
+
idSource: "body",
|
|
582
|
+
notFoundError: PASSKEY_ERROR_CODES.PASSKEY_NOT_FOUND,
|
|
583
|
+
forbiddenError: PASSKEY_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY,
|
|
584
|
+
forbiddenStatus: "UNAUTHORIZED"
|
|
585
|
+
})],
|
|
582
586
|
metadata: { openapi: {
|
|
583
587
|
description: "Update a specific passkey's name",
|
|
584
588
|
responses: { "200": {
|
|
@@ -591,15 +595,6 @@ const updatePasskey = createAuthEndpoint("/passkey/update-passkey", {
|
|
|
591
595
|
} }
|
|
592
596
|
} }
|
|
593
597
|
}, async (ctx) => {
|
|
594
|
-
const passkey = await ctx.context.adapter.findOne({
|
|
595
|
-
model: "passkey",
|
|
596
|
-
where: [{
|
|
597
|
-
field: "id",
|
|
598
|
-
value: ctx.body.id
|
|
599
|
-
}]
|
|
600
|
-
});
|
|
601
|
-
if (!passkey) throw APIError.from("NOT_FOUND", PASSKEY_ERROR_CODES.PASSKEY_NOT_FOUND);
|
|
602
|
-
if (passkey.userId !== ctx.context.session.user.id) throw APIError.from("UNAUTHORIZED", PASSKEY_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY);
|
|
603
598
|
const updatedPasskey = await ctx.context.adapter.update({
|
|
604
599
|
model: "passkey",
|
|
605
600
|
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.1",
|
|
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.1",
|
|
59
|
+
"better-auth": "1.6.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@better-auth/utils": "0.4.0",
|
|
63
63
|
"@better-fetch/fetch": "1.1.21",
|
|
64
|
-
"better-call": "
|
|
64
|
+
"better-call": "1.3.5",
|
|
65
65
|
"nanostores": "^1.0.1",
|
|
66
|
-
"@better-auth/core": "^1.6.
|
|
67
|
-
"better-auth": "^1.6.
|
|
66
|
+
"@better-auth/core": "^1.6.1",
|
|
67
|
+
"better-auth": "^1.6.1"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|