1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[PM-3763] remove Sweet Alert from desktop and browser (#6138)

* update desktop and browser swal references to use CL

* rename bit-dialog-close

* share fingerprint dialog between desktop and browser

* apply code review

* format fingerprint in template

* apply code review

* fix button color

* fix button types

* update var names

* close awaitDesktop dialog on success AND error

* add DialogService to NativeMessageHandlerService deps

* wrap browser message dialogs in ngZone.run

* wrap native messaging handler in ngzone.run

* apply code review

* fix async ngzone

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Will Martin
2023-09-11 14:54:23 -04:00
committed by GitHub
parent 2323509dee
commit f999e2cea9
20 changed files with 268 additions and 118 deletions

View File

@@ -1,6 +1,6 @@
import { Injectable } from "@angular/core";
import { ipcRenderer } from "electron";
import Swal from "sweetalert2";
import { firstValueFrom } from "rxjs";
import { NativeMessagingVersion } from "@bitwarden/common/enums";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
@@ -11,7 +11,9 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
import { EncryptedString, EncString } from "@bitwarden/common/platform/models/domain/enc-string";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
import { StateService } from "@bitwarden/common/platform/services/state.service";
import { DialogService } from "@bitwarden/components";
import { VerifyNativeMessagingDialogComponent } from "../app/components/verify-native-messaging-dialog.component";
import { DecryptedCommandData } from "../models/native-messaging/decrypted-command-data";
import { EncryptedMessage } from "../models/native-messaging/encrypted-message";
import { EncryptedMessageResponse } from "../models/native-messaging/encrypted-message-response";
@@ -33,7 +35,8 @@ export class NativeMessageHandlerService {
private cryptoFunctionService: CryptoFunctionService,
private messagingService: MessagingService,
private i18nService: I18nService,
private encryptedMessageHandlerService: EncryptedMessageHandlerService
private encryptedMessageHandlerService: EncryptedMessageHandlerService,
private dialogService: DialogService
) {}
async handleMessage(message: Message) {
@@ -87,21 +90,12 @@ export class NativeMessageHandlerService {
// Ask for confirmation from user
this.messagingService.send("setFocus");
const submitted = await Swal.fire({
heightAuto: false,
titleText: this.i18nService.t("verifyNativeMessagingConnectionTitle", applicationName),
html: `${this.i18nService.t("verifyNativeMessagingConnectionDesc")}<br>${this.i18nService.t(
"verifyNativeMessagingConnectionWarning"
)}`,
showCancelButton: true,
cancelButtonText: this.i18nService.t("no"),
showConfirmButton: true,
confirmButtonText: this.i18nService.t("yes"),
allowOutsideClick: false,
focusCancel: true,
});
if (submitted.value !== true) {
const nativeMessagingVerified = await firstValueFrom(
VerifyNativeMessagingDialogComponent.open(this.dialogService, { applicationName }).closed
);
if (nativeMessagingVerified !== true) {
this.sendResponse({
messageId: messageId,
version: NativeMessagingVersion.Latest,