mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-31 22:51:28 +01:00
[EC-598] chore: clean up page-script
This commit is contained in:
parent
cc31f1efc0
commit
f70feebd73
@ -16,12 +16,6 @@ navigator.credentials.create = async (
|
||||
options?: CredentialCreationOptions,
|
||||
abortController?: AbortController
|
||||
): Promise<Credential> => {
|
||||
// if (options.publicKey?.authenticatorSelection?.authenticatorAttachment === "platform") {
|
||||
// return await browserCredentials.create(options);
|
||||
// }
|
||||
|
||||
console.log("navigator.credentials.create", options.publicKey);
|
||||
|
||||
try {
|
||||
const response = await messenger.request(
|
||||
{
|
||||
@ -36,24 +30,10 @@ navigator.credentials.create = async (
|
||||
throw new Error("Something went wrong.");
|
||||
}
|
||||
|
||||
console.log(response.result);
|
||||
|
||||
let mappedResult;
|
||||
try {
|
||||
mappedResult = WebauthnUtils.mapCredentialRegistrationResult(response.result);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
console.log(mappedResult);
|
||||
|
||||
return mappedResult;
|
||||
return WebauthnUtils.mapCredentialRegistrationResult(response.result);
|
||||
} catch (error) {
|
||||
if (error && error.fallbackRequested) {
|
||||
const browserResponse = await browserCredentials.create(options);
|
||||
console.log("browserResponse", browserResponse);
|
||||
return browserResponse;
|
||||
return await browserCredentials.create(options);
|
||||
}
|
||||
|
||||
throw error;
|
||||
@ -64,8 +44,6 @@ navigator.credentials.get = async (
|
||||
options?: CredentialRequestOptions,
|
||||
abortController?: AbortController
|
||||
): Promise<Credential> => {
|
||||
console.log("navigator.credentials.get()", options);
|
||||
|
||||
try {
|
||||
const response = await messenger.request(
|
||||
{
|
||||
@ -76,19 +54,14 @@ navigator.credentials.get = async (
|
||||
abortController
|
||||
);
|
||||
|
||||
console.log("Response from background", response);
|
||||
|
||||
if (response.type !== MessageType.CredentialGetResponse) {
|
||||
throw new Error("Something went wrong.");
|
||||
}
|
||||
|
||||
return WebauthnUtils.mapCredentialAssertResult(response.result);
|
||||
} catch (error) {
|
||||
console.log("Error from background", error);
|
||||
if (error && error.fallbackRequested) {
|
||||
const browserResponse = await browserCredentials.get(options);
|
||||
console.log("browserResponse", browserResponse);
|
||||
return browserResponse;
|
||||
return await browserCredentials.get(options);
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
Loading…
Reference in New Issue
Block a user