mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: add passkey-first login and management flow
This commit is contained in:
@@ -62,6 +62,13 @@ import {
|
||||
} from './handlers/attachments';
|
||||
import { handleAuthenticatedDeviceRoute } from './router-devices';
|
||||
import { handleAdminRoute } from './router-admin';
|
||||
import {
|
||||
handleBeginPasskeyRegistration,
|
||||
handleDeletePasskey,
|
||||
handleFinishPasskeyRegistration,
|
||||
handleListPasskeys,
|
||||
handleRenamePasskey,
|
||||
} from './handlers/passkeys';
|
||||
|
||||
export async function handleAuthenticatedRoute(
|
||||
request: Request,
|
||||
@@ -107,6 +114,24 @@ export async function handleAuthenticatedRoute(
|
||||
return handleGetTotpRecoveryCode(request, env, userId);
|
||||
}
|
||||
|
||||
if (path === '/api/accounts/passkeys' && method === 'GET') {
|
||||
return handleListPasskeys(request, env, userId);
|
||||
}
|
||||
|
||||
if (path === '/api/accounts/passkeys/begin-registration' && method === 'POST') {
|
||||
return handleBeginPasskeyRegistration(request, env, userId);
|
||||
}
|
||||
|
||||
if (path === '/api/accounts/passkeys/finish-registration' && method === 'POST') {
|
||||
return handleFinishPasskeyRegistration(request, env, userId);
|
||||
}
|
||||
|
||||
const passkeyMatch = path.match(/^\/api\/accounts\/passkeys\/([a-f0-9-]+)$/i);
|
||||
if (passkeyMatch) {
|
||||
if (method === 'PATCH' || method === 'PUT') return handleRenamePasskey(request, env, userId, passkeyMatch[1]);
|
||||
if (method === 'DELETE') return handleDeletePasskey(request, env, userId, passkeyMatch[1]);
|
||||
}
|
||||
|
||||
if (path === '/api/accounts/revision-date' && method === 'GET') {
|
||||
return handleGetRevisionDate(request, env, userId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user