Resolved build error.

This commit is contained in:
Adrian Astles 2025-07-08 22:04:24 +08:00
parent f0a1c10ec5
commit f97b133c8c

View file

@ -24,7 +24,9 @@ import type {
} from "@simplewebauthn/server"; } from "@simplewebauthn/server";
import type { import type {
AuthenticatorTransport, AuthenticatorTransport,
PublicKeyCredentialDescriptorJSON AuthenticatorTransportFuture,
PublicKeyCredentialDescriptorJSON,
PublicKeyCredentialDescriptorFuture
} from "@simplewebauthn/types"; } from "@simplewebauthn/types";
import config from "@server/lib/config"; import config from "@server/lib/config";
import { UserType } from "@server/types/UserTypes"; import { UserType } from "@server/types/UserTypes";
@ -168,10 +170,10 @@ export async function startRegistration(
.where(eq(securityKeys.userId, user.userId)); .where(eq(securityKeys.userId, user.userId));
const excludeCredentials = existingSecurityKeys.map(key => ({ const excludeCredentials = existingSecurityKeys.map(key => ({
id: Buffer.from(key.credentialId, 'base64').toString('base64url'), id: new Uint8Array(Buffer.from(key.credentialId, 'base64')),
type: 'public-key' as const, type: 'public-key' as const,
transports: key.transports ? JSON.parse(key.transports) as AuthenticatorTransport[] : undefined transports: key.transports ? JSON.parse(key.transports) as AuthenticatorTransportFuture[] : undefined
} satisfies PublicKeyCredentialDescriptorJSON)); }));
const options: GenerateRegistrationOptionsOpts = { const options: GenerateRegistrationOptionsOpts = {
rpName, rpName,
@ -460,11 +462,7 @@ export async function startAuthentication(
const { email } = parsedBody.data; const { email } = parsedBody.data;
try { try {
let allowCredentials: Array<{ let allowCredentials: PublicKeyCredentialDescriptorFuture[] = [];
id: Buffer;
type: 'public-key';
transports?: string[];
}> = [];
let userId; let userId;
// If email is provided, get security keys for that specific user // If email is provided, get security keys for that specific user
@ -501,9 +499,9 @@ export async function startAuthentication(
} }
allowCredentials = userSecurityKeys.map(key => ({ allowCredentials = userSecurityKeys.map(key => ({
id: Buffer.from(key.credentialId, 'base64'), id: new Uint8Array(Buffer.from(key.credentialId, 'base64')),
type: 'public-key' as const, type: 'public-key' as const,
transports: key.transports ? JSON.parse(key.transports) as AuthenticatorTransport[] : undefined transports: key.transports ? JSON.parse(key.transports) as AuthenticatorTransportFuture[] : undefined
})); }));
} else { } else {
// If no email provided, allow any security key (for resident key authentication) // If no email provided, allow any security key (for resident key authentication)
@ -625,7 +623,7 @@ export async function verifyAuthentication(
credentialID: Buffer.from(securityKey.credentialId, 'base64'), credentialID: Buffer.from(securityKey.credentialId, 'base64'),
credentialPublicKey: Buffer.from(securityKey.publicKey, 'base64'), credentialPublicKey: Buffer.from(securityKey.publicKey, 'base64'),
counter: securityKey.signCount, counter: securityKey.signCount,
transports: securityKey.transports ? JSON.parse(securityKey.transports) as AuthenticatorTransport[] : undefined transports: securityKey.transports ? JSON.parse(securityKey.transports) as AuthenticatorTransportFuture[] : undefined
}, },
requireUserVerification: false requireUserVerification: false
}); });