Update passkey.service.ts
This commit is contained in:
@@ -99,20 +99,23 @@ export class PasskeyService {
|
|||||||
throw new Error('User not found for the provided handle.');
|
throw new Error('User not found for the provided handle.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The actual WebAuthn response is nested within the received object
|
||||||
|
const actualRegistrationResponse = (registrationResponseJSON as any).registrationResponse;
|
||||||
|
|
||||||
|
// Add a check for the presence of credential ID before calling the library
|
||||||
|
if (!actualRegistrationResponse || !actualRegistrationResponse.id) {
|
||||||
|
console.error('Missing credential ID in actualRegistrationResponse from client:', registrationResponseJSON);
|
||||||
|
throw new Error('Registration failed: Missing or malformed credential ID from client.');
|
||||||
|
}
|
||||||
|
|
||||||
const verifyOpts: VerifyRegistrationResponseOpts = {
|
const verifyOpts: VerifyRegistrationResponseOpts = {
|
||||||
response: registrationResponseJSON,
|
response: actualRegistrationResponse, // Use the nested object
|
||||||
expectedChallenge,
|
expectedChallenge,
|
||||||
expectedOrigin: RP_ORIGIN,
|
expectedOrigin: RP_ORIGIN,
|
||||||
expectedRPID: RP_ID,
|
expectedRPID: RP_ID,
|
||||||
requireUserVerification: true,
|
requireUserVerification: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add a check for the presence of credential ID before calling the library
|
|
||||||
if (!registrationResponseJSON || !registrationResponseJSON.id) {
|
|
||||||
console.error('Missing credential ID in registrationResponseJSON from client:', registrationResponseJSON);
|
|
||||||
throw new Error('Registration failed: Missing credential ID from client.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const verification = await verifyRegistrationResponse(verifyOpts);
|
const verification = await verifyRegistrationResponse(verifyOpts);
|
||||||
|
|
||||||
if (verification.verified && verification.registrationInfo) {
|
if (verification.verified && verification.registrationInfo) {
|
||||||
|
|||||||
Reference in New Issue
Block a user