Restructure passkey routes to me.passkeys namespace
- Remove createPasskey since verifyRegistration handles adding passkeys - Move listPasskeys → me.passkeys.list - Move renamePasskey → me.passkeys.rename - Move deletePasskey → me.passkeys.delete Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,7 +137,7 @@ const setPassword = os.me.setPassword.handler(async () => {
|
|||||||
throw new Error("Not implemented");
|
throw new Error("Not implemented");
|
||||||
});
|
});
|
||||||
|
|
||||||
const listPasskeys = os.me.listPasskeys.handler(async ({ context }) => {
|
const passkeysList = os.me.passkeys.list.handler(async ({ context }) => {
|
||||||
const ctx = context as AuthenticatedContext;
|
const ctx = context as AuthenticatedContext;
|
||||||
|
|
||||||
const passkeys = await getUserPasskeys(ctx.db, ctx.user.id);
|
const passkeys = await getUserPasskeys(ctx.db, ctx.user.id);
|
||||||
@@ -150,23 +150,7 @@ const listPasskeys = os.me.listPasskeys.handler(async ({ context }) => {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
const createPasskey = os.me.createPasskey.handler(
|
const passkeysRename = os.me.passkeys.rename.handler(
|
||||||
async ({ input, context }) => {
|
|
||||||
const ctx = context as AuthenticatedContext;
|
|
||||||
const { name: _name } = input;
|
|
||||||
|
|
||||||
const rpInfo = getRPInfo(ctx.origin, ctx.allowedOrigins, ctx.rpName);
|
|
||||||
const result = await createRegOptions(ctx.db, rpInfo, {
|
|
||||||
id: ctx.user.id,
|
|
||||||
email: ctx.user.email,
|
|
||||||
displayName: ctx.user.displayName,
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const renamePasskey = os.me.renamePasskey.handler(
|
|
||||||
async ({ input, context }) => {
|
async ({ input, context }) => {
|
||||||
const ctx = context as AuthenticatedContext;
|
const ctx = context as AuthenticatedContext;
|
||||||
const { passkeyId, name } = input;
|
const { passkeyId, name } = input;
|
||||||
@@ -180,7 +164,7 @@ const renamePasskey = os.me.renamePasskey.handler(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const deletePasskey = os.me.deletePasskey.handler(
|
const passkeysDelete = os.me.passkeys.delete.handler(
|
||||||
async ({ input, context }) => {
|
async ({ input, context }) => {
|
||||||
const ctx = context as AuthenticatedContext;
|
const ctx = context as AuthenticatedContext;
|
||||||
const { passkeyId } = input;
|
const { passkeyId } = input;
|
||||||
@@ -391,10 +375,11 @@ export const router = os.router({
|
|||||||
updateProfile,
|
updateProfile,
|
||||||
delete: meDelete,
|
delete: meDelete,
|
||||||
setPassword,
|
setPassword,
|
||||||
listPasskeys,
|
passkeys: {
|
||||||
createPasskey,
|
list: passkeysList,
|
||||||
renamePasskey,
|
rename: passkeysRename,
|
||||||
deletePasskey,
|
delete: passkeysDelete,
|
||||||
|
},
|
||||||
listSessions,
|
listSessions,
|
||||||
revokeSession,
|
revokeSession,
|
||||||
revokeAllSessions,
|
revokeAllSessions,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Database } from "@reviq/db-schema";
|
import type { Database } from "@reviq/db-schema";
|
||||||
|
import type { VerifiedRegistrationResponse } from "@simplewebauthn/server";
|
||||||
import type {
|
import type {
|
||||||
AuthenticationResponseJSON,
|
AuthenticationResponseJSON,
|
||||||
PublicKeyCredentialCreationOptionsJSON,
|
PublicKeyCredentialCreationOptionsJSON,
|
||||||
@@ -11,7 +12,6 @@ import type {
|
|||||||
} from "@simplewebauthn/types";
|
} from "@simplewebauthn/types";
|
||||||
import type { Kysely } from "kysely";
|
import type { Kysely } from "kysely";
|
||||||
import type { ParsedPasskey, PasskeyRow } from "./passkey-helpers.js";
|
import type { ParsedPasskey, PasskeyRow } from "./passkey-helpers.js";
|
||||||
import type { VerifiedRegistrationResponse } from "@simplewebauthn/server";
|
|
||||||
import {
|
import {
|
||||||
generateAuthenticationOptions,
|
generateAuthenticationOptions,
|
||||||
generateRegistrationOptions,
|
generateRegistrationOptions,
|
||||||
|
|||||||
@@ -115,19 +115,15 @@ export const contract = oc.router({
|
|||||||
|
|
||||||
// Authentication settings
|
// Authentication settings
|
||||||
setPassword: oc.input(setPasswordInputSchema).output(z.void()),
|
setPassword: oc.input(setPasswordInputSchema).output(z.void()),
|
||||||
listPasskeys: oc.output(z.array(passkeyOutputSchema)),
|
|
||||||
createPasskey: oc.input(z.object({ name: z.string() })).output(
|
// Passkeys
|
||||||
z.object({
|
passkeys: oc.router({
|
||||||
challengeId: z.number(),
|
list: oc.output(z.array(passkeyOutputSchema)),
|
||||||
options: z.custom<PublicKeyCredentialCreationOptionsJSON>(),
|
rename: oc
|
||||||
}),
|
|
||||||
),
|
|
||||||
renamePasskey: oc
|
|
||||||
.input(z.object({ passkeyId: z.number(), name: z.string() }))
|
.input(z.object({ passkeyId: z.number(), name: z.string() }))
|
||||||
.output(z.void()),
|
.output(z.void()),
|
||||||
deletePasskey: oc
|
delete: oc.input(z.object({ passkeyId: z.number() })).output(z.void()),
|
||||||
.input(z.object({ passkeyId: z.number() }))
|
}),
|
||||||
.output(z.void()),
|
|
||||||
|
|
||||||
// Sessions & devices
|
// Sessions & devices
|
||||||
listSessions: oc.output(z.array(sessionOutputSchema)),
|
listSessions: oc.output(z.array(sessionOutputSchema)),
|
||||||
|
|||||||
Reference in New Issue
Block a user