1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

added try-catch around ext module calls (#143)

This commit is contained in:
Chad Scharf
2020-08-06 12:27:49 -04:00
committed by GitHub
parent 1513b25a35
commit 7c0c06705e

View File

@@ -62,12 +62,17 @@ export default class BiometricWindowsMain implements BiometricMain {
const module = this.getWindowsSecurityCredentialsUiModule(); const module = this.getWindowsSecurityCredentialsUiModule();
if (module != null) { if (module != null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
module.UserConsentVerifier.checkAvailabilityAsync((error: Error, result: any) => { try {
if (error) { module.UserConsentVerifier.checkAvailabilityAsync((error: Error, result: any) => {
return resolve(null); if (error) {
} return resolve(null);
return resolve(result); }
}); return resolve(result);
});
} catch {
this.isError = true;
return resolve(null);
}
}); });
} }
return Promise.resolve(null); return Promise.resolve(null);
@@ -77,25 +82,32 @@ export default class BiometricWindowsMain implements BiometricMain {
const module = this.getWindowsSecurityCredentialsUiModule(); const module = this.getWindowsSecurityCredentialsUiModule();
if (module != null) { if (module != null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
module.UserConsentVerifier.requestVerificationAsync(message, (error: Error, result: any) => { try {
if (error) { module.UserConsentVerifier.requestVerificationAsync(message, (error: Error, result: any) => {
return resolve(null); if (error) {
} return resolve(null);
return resolve(result); }
}); return resolve(result);
});
} catch (error) {
this.isError = true;
return reject(error);
}
}); });
} }
return Promise.resolve(null); return Promise.resolve(null);
} }
getAllowedAvailabilities(): any[] { getAllowedAvailabilities(): any[] {
const module = this.getWindowsSecurityCredentialsUiModule(); try {
if (module != null) { const module = this.getWindowsSecurityCredentialsUiModule();
return [ if (module != null) {
module.UserConsentVerifierAvailability.available, return [
module.UserConsentVerifierAvailability.deviceBusy, module.UserConsentVerifierAvailability.available,
]; module.UserConsentVerifierAvailability.deviceBusy,
} ];
}
} catch { /*Ignore error*/ }
return []; return [];
} }
} }