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