mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 05:43:41 +00:00
PM-19138: Add try-catch to desktop-autofill (#13964)
This commit is contained in:
@@ -147,7 +147,7 @@ export class DesktopAutofillService implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listenIpc() {
|
listenIpc() {
|
||||||
ipc.autofill.listenPasskeyRegistration((clientId, sequenceNumber, request, callback) => {
|
ipc.autofill.listenPasskeyRegistration(async (clientId, sequenceNumber, request, callback) => {
|
||||||
this.logService.warning("listenPasskeyRegistration", clientId, sequenceNumber, request);
|
this.logService.warning("listenPasskeyRegistration", clientId, sequenceNumber, request);
|
||||||
this.logService.warning(
|
this.logService.warning(
|
||||||
"listenPasskeyRegistration2",
|
"listenPasskeyRegistration2",
|
||||||
@@ -155,19 +155,19 @@ export class DesktopAutofillService implements OnDestroy {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
void this.fido2AuthenticatorService
|
|
||||||
.makeCredential(
|
try {
|
||||||
|
const response = await this.fido2AuthenticatorService.makeCredential(
|
||||||
this.convertRegistrationRequest(request),
|
this.convertRegistrationRequest(request),
|
||||||
{ windowXy: request.windowXy },
|
{ windowXy: request.windowXy },
|
||||||
controller,
|
controller,
|
||||||
)
|
);
|
||||||
.then((response) => {
|
|
||||||
callback(null, this.convertRegistrationResponse(request, response));
|
callback(null, this.convertRegistrationResponse(request, response));
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
this.logService.error("listenPasskeyRegistration error", error);
|
this.logService.error("listenPasskeyRegistration error", error);
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.autofill.listenPasskeyAssertionWithoutUserInterface(
|
ipc.autofill.listenPasskeyAssertionWithoutUserInterface(
|
||||||
@@ -179,6 +179,9 @@ export class DesktopAutofillService implements OnDestroy {
|
|||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
try {
|
||||||
// For some reason the credentialId is passed as an empty array in the request, so we need to
|
// For some reason the credentialId is passed as an empty array in the request, so we need to
|
||||||
// get it from the cipher. For that we use the recordIdentifier, which is the cipherId.
|
// get it from the cipher. For that we use the recordIdentifier, which is the cipherId.
|
||||||
if (request.recordIdentifier && request.credentialId.length === 0) {
|
if (request.recordIdentifier && request.credentialId.length === 0) {
|
||||||
@@ -214,20 +217,18 @@ export class DesktopAutofillService implements OnDestroy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = new AbortController();
|
const response = await this.fido2AuthenticatorService.getAssertion(
|
||||||
void this.fido2AuthenticatorService
|
|
||||||
.getAssertion(
|
|
||||||
this.convertAssertionRequest(request),
|
this.convertAssertionRequest(request),
|
||||||
{ windowXy: request.windowXy },
|
{ windowXy: request.windowXy },
|
||||||
controller,
|
controller,
|
||||||
)
|
);
|
||||||
.then((response) => {
|
|
||||||
callback(null, this.convertAssertionResponse(request, response));
|
callback(null, this.convertAssertionResponse(request, response));
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
this.logService.error("listenPasskeyAssertion error", error);
|
this.logService.error("listenPasskeyAssertion error", error);
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -235,19 +236,18 @@ export class DesktopAutofillService implements OnDestroy {
|
|||||||
this.logService.warning("listenPasskeyAssertion", clientId, sequenceNumber, request);
|
this.logService.warning("listenPasskeyAssertion", clientId, sequenceNumber, request);
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
void this.fido2AuthenticatorService
|
try {
|
||||||
.getAssertion(
|
const response = await this.fido2AuthenticatorService.getAssertion(
|
||||||
this.convertAssertionRequest(request),
|
this.convertAssertionRequest(request),
|
||||||
{ windowXy: request.windowXy },
|
{ windowXy: request.windowXy },
|
||||||
controller,
|
controller,
|
||||||
)
|
);
|
||||||
.then((response) => {
|
|
||||||
callback(null, this.convertAssertionResponse(request, response));
|
callback(null, this.convertAssertionResponse(request, response));
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
this.logService.error("listenPasskeyAssertion error", error);
|
this.logService.error("listenPasskeyAssertion error", error);
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user