Update passkey.service.ts

This commit is contained in:
Baobhan Sith
2025-05-08 14:34:59 +08:00
parent a39262ec4b
commit 6504ea121f
@@ -121,19 +121,22 @@ export class PasskeyService {
if (verification.verified && verification.registrationInfo) { if (verification.verified && verification.registrationInfo) {
const regInfo = verification.registrationInfo; const regInfo = verification.registrationInfo;
// Assuming regInfo has these properties based on standard WebAuthn structures. // Based on the logs, credentialPublicKey, credentialID, counter, and transports
// If these are incorrect for @simplewebauthn/server@13.1.1, this needs adjustment. // are nested within regInfo.credential.
const credentialPublicKey = (regInfo as any).credentialPublicKey; // credentialBackedUp is at the top level of regInfo.
const credentialID = (regInfo as any).credentialID; const credentialDetails = (regInfo as any).credential;
const counter = (regInfo as any).counter; const credentialBackedUp = (regInfo as any).credentialBackedUp; // This seems to be at the top level
const transports = (regInfo as any).transports;
const credentialBackedUp = (regInfo as any).credentialBackedUp;
if (!credentialPublicKey || typeof credentialID !== 'string' || typeof counter !== 'number') { if (!credentialDetails || typeof credentialDetails.publicKey !== 'object' || typeof credentialDetails.id !== 'string' || typeof credentialDetails.counter !== 'number') {
console.error('Verification successful, but registrationInfo structure is unexpected:', regInfo); console.error('Verification successful, but registrationInfo.credential structure is unexpected or missing:', regInfo);
throw new Error('Failed to process registration info due to unexpected structure.'); throw new Error('Failed to process registration info due to unexpected credential structure.');
} }
const credentialPublicKey = credentialDetails.publicKey;
const credentialID = credentialDetails.id;
const counter = credentialDetails.counter;
const transports = credentialDetails.transports; // This might be undefined, handle appropriately
const publicKeyBase64 = Buffer.from(credentialPublicKey).toString('base64'); const publicKeyBase64 = Buffer.from(credentialPublicKey).toString('base64');
const newPasskeyEntry: NewPasskey = { const newPasskeyEntry: NewPasskey = {