From f59628bbf1a26bd7212f277fdbcf1bb5e8588c78 Mon Sep 17 00:00:00 2001
From: William Martin
Date: Tue, 29 Aug 2023 10:58:41 -0400
Subject: [PATCH 1/7] update desktop and browser swal references to use CL
---
apps/browser/src/popup/app.component.ts | 20 +++-----
...op-sync-verification-dialog.component.html | 15 ++++++
...ktop-sync-verification-dialog.component.ts | 29 +++++++++++
.../await-desktop-dialog.component.html | 11 ++++
.../await-desktop-dialog.component.ts | 22 ++++++++
.../fingerprint-dialog.component.html | 22 ++++++++
.../settings/fingerprint-dialog.component.ts | 33 ++++++++++++
.../src/popup/settings/settings.component.ts | 50 +++++--------------
...er-sync-verification-dialog.component.html | 18 +++++++
...wser-sync-verification-dialog.component.ts | 25 ++++++++++
...ify-native-messaging-dialog.component.html | 18 +++++++
...erify-native-messaging-dialog.component.ts | 24 +++++++++
.../native-message-handler.service.ts | 26 ++++------
.../src/services/native-messaging.service.ts | 35 ++++++-------
14 files changed, 261 insertions(+), 87 deletions(-)
create mode 100644 apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
create mode 100644 apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
create mode 100644 apps/browser/src/popup/settings/await-desktop-dialog.component.html
create mode 100644 apps/browser/src/popup/settings/await-desktop-dialog.component.ts
create mode 100644 apps/browser/src/popup/settings/fingerprint-dialog.component.html
create mode 100644 apps/browser/src/popup/settings/fingerprint-dialog.component.ts
create mode 100644 apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
create mode 100644 apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
create mode 100644 apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
create mode 100644 apps/desktop/src/app/components/verify-native-messaging-dialog.component.ts
diff --git a/apps/browser/src/popup/app.component.ts b/apps/browser/src/popup/app.component.ts
index 815109c5499..179abf5a8cb 100644
--- a/apps/browser/src/popup/app.component.ts
+++ b/apps/browser/src/popup/app.component.ts
@@ -9,8 +9,7 @@ import {
import { DomSanitizer } from "@angular/platform-browser";
import { NavigationEnd, Router, RouterOutlet } from "@angular/router";
import { IndividualConfig, ToastrService } from "ngx-toastr";
-import { filter, concatMap, Subject, takeUntil } from "rxjs";
-import Swal from "sweetalert2";
+import { filter, concatMap, Subject, takeUntil, firstValueFrom } from "rxjs";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
@@ -23,6 +22,7 @@ import { BrowserApi } from "../platform/browser/browser-api";
import { BrowserStateService } from "../platform/services/abstractions/browser-state.service";
import { routerTransition } from "./app-routing.animations";
+import { DesktopSyncVerificationDialogComponent } from "./components/desktop-sync-verification-dialog.component";
@Component({
selector: "app-root",
@@ -242,19 +242,11 @@ export class AppComponent implements OnInit, OnDestroy {
}
private async showNativeMessagingFingerprintDialog(msg: any) {
- await Swal.fire({
- heightAuto: false,
- buttonsStyling: false,
- icon: "warning",
- iconHtml: '',
- html: `${this.i18nService.t("desktopIntegrationVerificationText")}
${
- msg.fingerprint
- }`,
- titleText: this.i18nService.t("desktopSyncVerificationTitle"),
- showConfirmButton: true,
- confirmButtonText: this.i18nService.t("ok"),
- timer: 300000,
+ const dialogRef = DesktopSyncVerificationDialogComponent.open(this.dialogService, {
+ fingerprint: msg.fingerprint,
});
+
+ return firstValueFrom(dialogRef.closed);
}
private async clearComponentStates() {
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
new file mode 100644
index 00000000000..d9bb0e33b2a
--- /dev/null
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
@@ -0,0 +1,15 @@
+
+
+ {{ "desktopSyncVerificationTitle" | i18n }}
+
+
+ {{ "desktopIntegrationVerificationText" | i18n }}
+
+ {{ params.fingerprint }}
+
+
+
+
+
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
new file mode 100644
index 00000000000..4e5bbe18f74
--- /dev/null
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
@@ -0,0 +1,29 @@
+import { DIALOG_DATA } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import {
+ AsyncActionsModule,
+ ButtonModule,
+ DialogModule,
+ DialogService,
+} from "@bitwarden/components";
+
+export type DesktopSyncVerificationDialogParams = {
+ fingerprint: string;
+};
+
+@Component({
+ templateUrl: "desktop-sync-verification-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
+})
+export class DesktopSyncVerificationDialogComponent {
+ constructor(@Inject(DIALOG_DATA) protected params: DesktopSyncVerificationDialogParams) {}
+
+ static open(dialogService: DialogService, data: DesktopSyncVerificationDialogParams) {
+ return dialogService.open(DesktopSyncVerificationDialogComponent, {
+ data,
+ });
+ }
+}
diff --git a/apps/browser/src/popup/settings/await-desktop-dialog.component.html b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
new file mode 100644
index 00000000000..765bc3d1408
--- /dev/null
+++ b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
@@ -0,0 +1,11 @@
+
+ {{ "awaitDesktop" | i18n }}:
+
+ {{ "awaitDesktopDesc" | i18n }}
+
+
+
+
+
diff --git a/apps/browser/src/popup/settings/await-desktop-dialog.component.ts b/apps/browser/src/popup/settings/await-desktop-dialog.component.ts
new file mode 100644
index 00000000000..6bccc927e6a
--- /dev/null
+++ b/apps/browser/src/popup/settings/await-desktop-dialog.component.ts
@@ -0,0 +1,22 @@
+import { Component } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import {
+ AsyncActionsModule,
+ ButtonModule,
+ DialogModule,
+ DialogService,
+} from "@bitwarden/components";
+
+@Component({
+ templateUrl: "await-desktop-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
+})
+export class AwaitDesktopDialogComponent {
+ static open(dialogService: DialogService) {
+ return dialogService.open(AwaitDesktopDialogComponent, {
+ disableClose: true,
+ });
+ }
+}
diff --git a/apps/browser/src/popup/settings/fingerprint-dialog.component.html b/apps/browser/src/popup/settings/fingerprint-dialog.component.html
new file mode 100644
index 00000000000..c6b806ee032
--- /dev/null
+++ b/apps/browser/src/popup/settings/fingerprint-dialog.component.html
@@ -0,0 +1,22 @@
+
+ {{ "yourAccountsFingerprint" | i18n }}:
+
+ {{ data.fingerprint }}
+
+
+
+
+ {{ "learnMore" | i18n }}
+
+
+
diff --git a/apps/browser/src/popup/settings/fingerprint-dialog.component.ts b/apps/browser/src/popup/settings/fingerprint-dialog.component.ts
new file mode 100644
index 00000000000..81562190830
--- /dev/null
+++ b/apps/browser/src/popup/settings/fingerprint-dialog.component.ts
@@ -0,0 +1,33 @@
+import { DIALOG_DATA } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
+import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
+import {
+ AsyncActionsModule,
+ ButtonModule,
+ DialogModule,
+ DialogService,
+} from "@bitwarden/components";
+
+export type FingerprintDialogData = {
+ fingerprint: string;
+};
+
+@Component({
+ templateUrl: "fingerprint-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
+})
+export class FingerprintDialogComponent {
+ constructor(
+ @Inject(DIALOG_DATA) protected data: FingerprintDialogData,
+ private cryptoService: CryptoService,
+ private stateService: StateService
+ ) {}
+
+ static open(dialogService: DialogService, data: FingerprintDialogData) {
+ return dialogService.open(FingerprintDialogComponent, { data });
+ }
+}
diff --git a/apps/browser/src/popup/settings/settings.component.ts b/apps/browser/src/popup/settings/settings.component.ts
index 30a1f03eacf..965a74c3f7b 100644
--- a/apps/browser/src/popup/settings/settings.component.ts
+++ b/apps/browser/src/popup/settings/settings.component.ts
@@ -15,7 +15,6 @@ import {
switchMap,
takeUntil,
} from "rxjs";
-import Swal from "sweetalert2";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
@@ -39,6 +38,8 @@ import { SetPinComponent } from "../components/set-pin.component";
import { PopupUtilsService } from "../services/popup-utils.service";
import { AboutComponent } from "./about.component";
+import { AwaitDesktopDialogComponent } from "./await-desktop-dialog.component";
+import { FingerprintDialogComponent } from "./fingerprint-dialog.component";
const RateUrls = {
[DeviceType.ChromeExtension]:
@@ -361,25 +362,15 @@ export class SettingsComponent implements OnInit {
return;
}
- const submitted = Swal.fire({
- heightAuto: false,
- buttonsStyling: false,
- titleText: this.i18nService.t("awaitDesktop"),
- text: this.i18nService.t("awaitDesktopDesc"),
- icon: "info",
- iconHtml: '',
- showCancelButton: true,
- cancelButtonText: this.i18nService.t("cancel"),
- showConfirmButton: false,
- allowOutsideClick: false,
- });
+ const awaitDesktopDialogRef = AwaitDesktopDialogComponent.open(this.dialogService);
+ const awaitDesktopDialogClosed = firstValueFrom(awaitDesktopDialogRef.closed);
await this.stateService.setBiometricAwaitingAcceptance(true);
await this.cryptoService.refreshAdditionalKeys();
await Promise.race([
- submitted.then(async (result) => {
- if (result.dismiss === Swal.DismissReason.cancel) {
+ awaitDesktopDialogClosed.then(async (result) => {
+ if (result) {
this.form.controls.biometric.setValue(false);
await this.stateService.setBiometricAwaitingAcceptance(null);
}
@@ -389,7 +380,7 @@ export class SettingsComponent implements OnInit {
.then((result) => {
this.form.controls.biometric.setValue(result);
- Swal.close();
+ awaitDesktopDialogRef.close(false);
if (!result) {
this.platformUtilsService.showToast(
"error",
@@ -494,30 +485,15 @@ export class SettingsComponent implements OnInit {
}
async fingerprint() {
- const fingerprint = await this.cryptoService.getFingerprint(
- await this.stateService.getUserId()
- );
- const p = document.createElement("p");
- p.innerText = this.i18nService.t("yourAccountsFingerprint") + ":";
- const p2 = document.createElement("p");
- p2.innerText = fingerprint.join("-");
- const div = document.createElement("div");
- div.appendChild(p);
- div.appendChild(p2);
+ const fingerprint = await this.cryptoService
+ .getFingerprint(await this.stateService.getUserId())
+ .then((rawFingerprint) => rawFingerprint.join("-"));
- const result = await Swal.fire({
- heightAuto: false,
- buttonsStyling: false,
- html: div,
- showCancelButton: true,
- cancelButtonText: this.i18nService.t("close"),
- showConfirmButton: true,
- confirmButtonText: this.i18nService.t("learnMore"),
+ const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
+ fingerprint,
});
- if (result.value) {
- this.platformUtilsService.launchUri("https://bitwarden.com/help/fingerprint-phrase/");
- }
+ return firstValueFrom(dialogRef.closed);
}
rate() {
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
new file mode 100644
index 00000000000..558e317bead
--- /dev/null
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
@@ -0,0 +1,18 @@
+
+
+ {{ "verifyBrowserTitle" | i18n }}
+
+
+ {{ "verifyBrowserDesc" | i18n }}
+
+ {{ params.fingerprint }}
+
+
+
+
+
+
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
new file mode 100644
index 00000000000..f627380860d
--- /dev/null
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
@@ -0,0 +1,25 @@
+import { DIALOG_DATA } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
+
+export type BrowserSyncVerificationDialogParams = {
+ fingerprint: string;
+};
+
+@Component({
+ templateUrl: "browser-sync-verification-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule],
+})
+export class BrowserSyncVerificationDialogComponent {
+ constructor(@Inject(DIALOG_DATA) protected params: BrowserSyncVerificationDialogParams) {}
+
+ static open(dialogService: DialogService, data: BrowserSyncVerificationDialogParams) {
+ return dialogService.open(BrowserSyncVerificationDialogComponent, {
+ data,
+ disableClose: true,
+ });
+ }
+}
diff --git a/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
new file mode 100644
index 00000000000..5c35870f777
--- /dev/null
+++ b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
@@ -0,0 +1,18 @@
+
+
+ {{ "verifyNativeMessagingConnectionTitle" | i18n : data.applicationName }}:
+
+
+ {{ "verifyNativeMessagingConnectionDesc" | i18n }}
+
+ {{ "verifyNativeMessagingConnectionWarning" | i18n }}
+
+
+
+
+
+
diff --git a/apps/desktop/src/app/components/verify-native-messaging-dialog.component.ts b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.ts
new file mode 100644
index 00000000000..507d566336b
--- /dev/null
+++ b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.ts
@@ -0,0 +1,24 @@
+import { DIALOG_DATA } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
+
+export type VerifyNativeMessagingDialogData = {
+ applicationName: string;
+};
+
+@Component({
+ templateUrl: "verify-native-messaging-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule],
+})
+export class VerifyNativeMessagingDialogComponent {
+ constructor(@Inject(DIALOG_DATA) protected data: VerifyNativeMessagingDialogData) {}
+
+ static open(dialogService: DialogService, data: VerifyNativeMessagingDialogData) {
+ return dialogService.open(VerifyNativeMessagingDialogComponent, {
+ data,
+ });
+ }
+}
diff --git a/apps/desktop/src/services/native-message-handler.service.ts b/apps/desktop/src/services/native-message-handler.service.ts
index 9f5f1d460df..b9107c0ecd0 100644
--- a/apps/desktop/src/services/native-message-handler.service.ts
+++ b/apps/desktop/src/services/native-message-handler.service.ts
@@ -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")}
${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 submitted = await firstValueFrom(
+ VerifyNativeMessagingDialogComponent.open(this.dialogService, { applicationName }).closed
+ );
+
+ if (submitted !== true) {
this.sendResponse({
messageId: messageId,
version: NativeMessagingVersion.Latest,
diff --git a/apps/desktop/src/services/native-messaging.service.ts b/apps/desktop/src/services/native-messaging.service.ts
index 3928778f313..646e7bcc508 100644
--- a/apps/desktop/src/services/native-messaging.service.ts
+++ b/apps/desktop/src/services/native-messaging.service.ts
@@ -1,7 +1,6 @@
import { Injectable } from "@angular/core";
import { ipcRenderer } from "electron";
import { firstValueFrom } from "rxjs";
-import Swal from "sweetalert2";
import { KeySuffixOptions } from "@bitwarden/common/enums";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
@@ -14,7 +13,9 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
+import { DialogService } from "@bitwarden/components";
+import { BrowserSyncVerificationDialogComponent } from "../app/components/browser-sync-verification-dialog.component";
import { LegacyMessage } from "../models/native-messaging/legacy-message";
import { LegacyMessageWrapper } from "../models/native-messaging/legacy-message-wrapper";
import { Message } from "../models/native-messaging/message";
@@ -36,7 +37,8 @@ export class NativeMessagingService {
private i18nService: I18nService,
private messagingService: MessagingService,
private stateService: StateService,
- private nativeMessageHandler: NativeMessageHandlerService
+ private nativeMessageHandler: NativeMessageHandlerService,
+ private dialogService: DialogService
) {}
init() {
@@ -74,22 +76,15 @@ export class NativeMessagingService {
await this.stateService.getUserId(),
remotePublicKey
)
- ).join(" ");
+ ).join("-");
this.messagingService.send("setFocus");
- // Await confirmation that fingerprint is correct
- const submitted = await Swal.fire({
- titleText: this.i18nService.t("verifyBrowserTitle"),
- html: `${this.i18nService.t("verifyBrowserDesc")}
${fingerprint}`,
- showCancelButton: true,
- cancelButtonText: this.i18nService.t("cancel"),
- showConfirmButton: true,
- confirmButtonText: this.i18nService.t("approve"),
- allowOutsideClick: false,
- });
+ const submitted = await firstValueFrom(
+ BrowserSyncVerificationDialogComponent.open(this.dialogService, { fingerprint }).closed
+ );
- if (submitted.value !== true) {
+ if (submitted !== true) {
return;
}
}
@@ -127,12 +122,12 @@ export class NativeMessagingService {
if (!(await this.stateService.getBiometricUnlock({ userId: message.userId }))) {
this.send({ command: "biometricUnlock", response: "not enabled" }, appId);
- return await Swal.fire({
- title: this.i18nService.t("biometricsNotEnabledTitle"),
- text: this.i18nService.t("biometricsNotEnabledDesc"),
- showCancelButton: true,
- cancelButtonText: this.i18nService.t("cancel"),
- showConfirmButton: false,
+ return this.dialogService.openSimpleDialog({
+ type: "warning",
+ title: { key: "biometricsNotEnabledTitle" },
+ content: { key: "biometricsNotEnabledDesc" },
+ cancelButtonText: null,
+ acceptButtonText: { key: "cancel" },
});
}
From b655da747ccb8f656c46c07d95526f2763989755 Mon Sep 17 00:00:00 2001
From: William Martin
Date: Wed, 30 Aug 2023 21:26:14 -0400
Subject: [PATCH 2/7] rename bit-dialog-close
---
.../popup/settings/await-desktop-dialog.component.html | 2 +-
.../browser-sync-verification-dialog.component.html | 4 ++--
.../verify-native-messaging-dialog.component.html | 4 ++--
.../organizations/manage/group-add-edit.component.html | 8 +-------
.../src/dialog/directives/dialog-close.directive.ts | 4 ++--
5 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/apps/browser/src/popup/settings/await-desktop-dialog.component.html b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
index 765bc3d1408..ed388075ce8 100644
--- a/apps/browser/src/popup/settings/await-desktop-dialog.component.html
+++ b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
@@ -4,7 +4,7 @@
{{ "awaitDesktopDesc" | i18n }}
-
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
index 558e317bead..c05c7f26d89 100644
--- a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
@@ -8,10 +8,10 @@
{{ params.fingerprint }}
-
+
{{ "approve" | i18n }}
-
+
{{ "cancel" | i18n }}
diff --git a/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
index 5c35870f777..0334857962b 100644
--- a/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
+++ b/apps/desktop/src/app/components/verify-native-messaging-dialog.component.html
@@ -8,10 +8,10 @@
{{ "verifyNativeMessagingConnectionWarning" | i18n }}
-
+
{{ "yes" | i18n }}
-
+
{{ "no" | i18n }}
diff --git a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html
index 4978842fb4d..b6175d80297 100644
--- a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html
+++ b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html
@@ -69,13 +69,7 @@
{{ "save" | i18n }}
-
+
{{ "cancel" | i18n }}
) {}
+ constructor(@Optional() public dialogRef: DialogRef) {}
@HostListener("click") close(): void {
this.dialogRef.close(this.dialogResult);
From 3bdb52c613b02c804301638d0291102d02ca9a29 Mon Sep 17 00:00:00 2001
From: William Martin
Date: Fri, 1 Sep 2023 10:55:58 -0400
Subject: [PATCH 3/7] share fingerprint dialog between desktop and browser
---
.../settings/fingerprint-dialog.component.ts | 33 -------------------
.../src/popup/settings/settings.component.ts | 8 ++---
apps/desktop/src/app/app.component.ts | 15 ++-------
.../fingerprint-dialog.component.html | 13 ++++----
.../fingerprint-dialog.component.ts | 22 +++++++++++++
libs/auth/src/index.ts | 1 +
6 files changed, 37 insertions(+), 55 deletions(-)
delete mode 100644 apps/browser/src/popup/settings/fingerprint-dialog.component.ts
rename {apps/browser/src/popup/settings => libs/auth/src/components}/fingerprint-dialog.component.html (64%)
create mode 100644 libs/auth/src/components/fingerprint-dialog.component.ts
diff --git a/apps/browser/src/popup/settings/fingerprint-dialog.component.ts b/apps/browser/src/popup/settings/fingerprint-dialog.component.ts
deleted file mode 100644
index 81562190830..00000000000
--- a/apps/browser/src/popup/settings/fingerprint-dialog.component.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { DIALOG_DATA } from "@angular/cdk/dialog";
-import { Component, Inject } from "@angular/core";
-
-import { JslibModule } from "@bitwarden/angular/jslib.module";
-import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
-import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
-import {
- AsyncActionsModule,
- ButtonModule,
- DialogModule,
- DialogService,
-} from "@bitwarden/components";
-
-export type FingerprintDialogData = {
- fingerprint: string;
-};
-
-@Component({
- templateUrl: "fingerprint-dialog.component.html",
- standalone: true,
- imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
-})
-export class FingerprintDialogComponent {
- constructor(
- @Inject(DIALOG_DATA) protected data: FingerprintDialogData,
- private cryptoService: CryptoService,
- private stateService: StateService
- ) {}
-
- static open(dialogService: DialogService, data: FingerprintDialogData) {
- return dialogService.open(FingerprintDialogComponent, { data });
- }
-}
diff --git a/apps/browser/src/popup/settings/settings.component.ts b/apps/browser/src/popup/settings/settings.component.ts
index 965a74c3f7b..e26a7d0409a 100644
--- a/apps/browser/src/popup/settings/settings.component.ts
+++ b/apps/browser/src/popup/settings/settings.component.ts
@@ -17,6 +17,7 @@ import {
} from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
+import { FingerprintDialogComponent } from "@bitwarden/auth";
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
@@ -39,7 +40,6 @@ import { PopupUtilsService } from "../services/popup-utils.service";
import { AboutComponent } from "./about.component";
import { AwaitDesktopDialogComponent } from "./await-desktop-dialog.component";
-import { FingerprintDialogComponent } from "./fingerprint-dialog.component";
const RateUrls = {
[DeviceType.ChromeExtension]:
@@ -485,9 +485,9 @@ export class SettingsComponent implements OnInit {
}
async fingerprint() {
- const fingerprint = await this.cryptoService
- .getFingerprint(await this.stateService.getUserId())
- .then((rawFingerprint) => rawFingerprint.join("-"));
+ const fingerprint = await this.cryptoService.getFingerprint(
+ await this.stateService.getUserId()
+ );
const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
fingerprint,
diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts
index b5321a2bc83..2d24ac6e97e 100644
--- a/apps/desktop/src/app/app.component.ts
+++ b/apps/desktop/src/app/app.component.ts
@@ -16,6 +16,7 @@ import { firstValueFrom, Subject, takeUntil } from "rxjs";
import { ModalRef } from "@bitwarden/angular/components/modal/modal.ref";
import { ModalService } from "@bitwarden/angular/services/modal.service";
+import { FingerprintDialogComponent } from "@bitwarden/auth";
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
@@ -244,18 +245,8 @@ export class AppComponent implements OnInit, OnDestroy {
const fingerprint = await this.cryptoService.getFingerprint(
await this.stateService.getUserId()
);
- const result = await this.dialogService.openSimpleDialog({
- title: { key: "fingerprintPhrase" },
- content:
- this.i18nService.t("yourAccountsFingerprint") + ":\n" + fingerprint.join("-"),
- acceptButtonText: { key: "learnMore" },
- cancelButtonText: { key: "close" },
- type: "info",
- });
-
- if (result) {
- this.platformUtilsService.launchUri("https://bitwarden.com/help/fingerprint-phrase/");
- }
+ const dialogRef = FingerprintDialogComponent.open(this.dialogService, { fingerprint });
+ await firstValueFrom(dialogRef.closed);
break;
}
case "deleteAccount":
diff --git a/apps/browser/src/popup/settings/fingerprint-dialog.component.html b/libs/auth/src/components/fingerprint-dialog.component.html
similarity index 64%
rename from apps/browser/src/popup/settings/fingerprint-dialog.component.html
rename to libs/auth/src/components/fingerprint-dialog.component.html
index c6b806ee032..2bb95ecf050 100644
--- a/apps/browser/src/popup/settings/fingerprint-dialog.component.html
+++ b/libs/auth/src/components/fingerprint-dialog.component.html
@@ -1,22 +1,23 @@
- {{ "yourAccountsFingerprint" | i18n }}:
+
+ {{ "yourAccountsFingerprint" | i18n }}:
- {{ data.fingerprint }}
+ {{ data.fingerprint.join("-") }}
-
- {{ "close" | i18n }}
-
{{ "learnMore" | i18n }}
+
+
+ {{ "close" | i18n }}
+
diff --git a/libs/auth/src/components/fingerprint-dialog.component.ts b/libs/auth/src/components/fingerprint-dialog.component.ts
new file mode 100644
index 00000000000..2a7b3e10997
--- /dev/null
+++ b/libs/auth/src/components/fingerprint-dialog.component.ts
@@ -0,0 +1,22 @@
+import { DIALOG_DATA } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+
+import { JslibModule } from "@bitwarden/angular/jslib.module";
+import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
+
+export type FingerprintDialogData = {
+ fingerprint: string[];
+};
+
+@Component({
+ templateUrl: "fingerprint-dialog.component.html",
+ standalone: true,
+ imports: [JslibModule, ButtonModule, DialogModule],
+})
+export class FingerprintDialogComponent {
+ constructor(@Inject(DIALOG_DATA) protected data: FingerprintDialogData) {}
+
+ static open(dialogService: DialogService, data: FingerprintDialogData) {
+ return dialogService.open(FingerprintDialogComponent, { data });
+ }
+}
diff --git a/libs/auth/src/index.ts b/libs/auth/src/index.ts
index e69de29bb2d..0b4f07fc29d 100644
--- a/libs/auth/src/index.ts
+++ b/libs/auth/src/index.ts
@@ -0,0 +1 @@
+export * from "./components/fingerprint-dialog.component";
From 5c99e278b690fb2753f90e57e43da1b770b2182d Mon Sep 17 00:00:00 2001
From: William Martin
Date: Fri, 1 Sep 2023 11:16:09 -0400
Subject: [PATCH 4/7] apply code review
---
.../desktop-sync-verification-dialog.component.ts | 9 ++-------
.../popup/settings/await-desktop-dialog.component.html | 2 +-
.../src/popup/settings/await-desktop-dialog.component.ts | 9 ++-------
.../browser-sync-verification-dialog.component.html | 7 ++++---
4 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
index 4e5bbe18f74..78705e1ed57 100644
--- a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
@@ -2,12 +2,7 @@ import { DIALOG_DATA } from "@angular/cdk/dialog";
import { Component, Inject } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
-import {
- AsyncActionsModule,
- ButtonModule,
- DialogModule,
- DialogService,
-} from "@bitwarden/components";
+import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
export type DesktopSyncVerificationDialogParams = {
fingerprint: string;
@@ -16,7 +11,7 @@ export type DesktopSyncVerificationDialogParams = {
@Component({
templateUrl: "desktop-sync-verification-dialog.component.html",
standalone: true,
- imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
+ imports: [JslibModule, ButtonModule, DialogModule],
})
export class DesktopSyncVerificationDialogComponent {
constructor(@Inject(DIALOG_DATA) protected params: DesktopSyncVerificationDialogParams) {}
diff --git a/apps/browser/src/popup/settings/await-desktop-dialog.component.html b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
index ed388075ce8..688071a15d6 100644
--- a/apps/browser/src/popup/settings/await-desktop-dialog.component.html
+++ b/apps/browser/src/popup/settings/await-desktop-dialog.component.html
@@ -1,5 +1,5 @@
- {{ "awaitDesktop" | i18n }}:
+ {{ "awaitDesktop" | i18n }}
{{ "awaitDesktopDesc" | i18n }}
diff --git a/apps/browser/src/popup/settings/await-desktop-dialog.component.ts b/apps/browser/src/popup/settings/await-desktop-dialog.component.ts
index 6bccc927e6a..9ed6efe036f 100644
--- a/apps/browser/src/popup/settings/await-desktop-dialog.component.ts
+++ b/apps/browser/src/popup/settings/await-desktop-dialog.component.ts
@@ -1,17 +1,12 @@
import { Component } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
-import {
- AsyncActionsModule,
- ButtonModule,
- DialogModule,
- DialogService,
-} from "@bitwarden/components";
+import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
@Component({
templateUrl: "await-desktop-dialog.component.html",
standalone: true,
- imports: [JslibModule, ButtonModule, DialogModule, AsyncActionsModule],
+ imports: [JslibModule, ButtonModule, DialogModule],
})
export class AwaitDesktopDialogComponent {
static open(dialogService: DialogService) {
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
index c05c7f26d89..caf2d47698b 100644
--- a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
@@ -3,9 +3,10 @@
{{ "verifyBrowserTitle" | i18n }}
- {{ "verifyBrowserDesc" | i18n }}
-
- {{ params.fingerprint }}
+ {{ "verifyBrowserDesc" | i18n }}
+
+ {{ params.fingerprint }}
+
From 8e33e0baf78d6ff69d0c08f9e842b8bcf1379b1c Mon Sep 17 00:00:00 2001
From: William Martin
Date: Fri, 1 Sep 2023 12:30:30 -0400
Subject: [PATCH 5/7] format fingerprint in template
---
.../src/background/nativeMessaging.background.ts | 7 ++++---
.../desktop-sync-verification-dialog.component.html | 2 +-
.../desktop-sync-verification-dialog.component.ts | 2 +-
.../browser-sync-verification-dialog.component.html | 2 +-
.../browser-sync-verification-dialog.component.ts | 2 +-
apps/desktop/src/services/native-messaging.service.ts | 10 ++++------
6 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/apps/browser/src/background/nativeMessaging.background.ts b/apps/browser/src/background/nativeMessaging.background.ts
index d393022b7b9..88fd81a3a70 100644
--- a/apps/browser/src/background/nativeMessaging.background.ts
+++ b/apps/browser/src/background/nativeMessaging.background.ts
@@ -422,9 +422,10 @@ export class NativeMessagingBackground {
}
private async showFingerprintDialog() {
- const fingerprint = (
- await this.cryptoService.getFingerprint(await this.stateService.getUserId(), this.publicKey)
- ).join(" ");
+ const fingerprint = await this.cryptoService.getFingerprint(
+ await this.stateService.getUserId(),
+ this.publicKey
+ );
this.messagingService.send("showNativeMessagingFinterprintDialog", {
fingerprint: fingerprint,
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
index d9bb0e33b2a..20cbd2890f0 100644
--- a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
@@ -5,7 +5,7 @@
{{ "desktopIntegrationVerificationText" | i18n }}
- {{ params.fingerprint }}
+ {{ params.fingerprint.join("-") }}
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
index 78705e1ed57..c860ef1e342 100644
--- a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.ts
@@ -5,7 +5,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
export type DesktopSyncVerificationDialogParams = {
- fingerprint: string;
+ fingerprint: string[];
};
@Component({
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
index caf2d47698b..1efcccf3f84 100644
--- a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.html
@@ -5,7 +5,7 @@
{{ "verifyBrowserDesc" | i18n }}
- {{ params.fingerprint }}
+ {{ params.fingerprint.join("-") }}
diff --git a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
index f627380860d..aefa5672a94 100644
--- a/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
+++ b/apps/desktop/src/app/components/browser-sync-verification-dialog.component.ts
@@ -5,7 +5,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { ButtonModule, DialogModule, DialogService } from "@bitwarden/components";
export type BrowserSyncVerificationDialogParams = {
- fingerprint: string;
+ fingerprint: string[];
};
@Component({
diff --git a/apps/desktop/src/services/native-messaging.service.ts b/apps/desktop/src/services/native-messaging.service.ts
index 646e7bcc508..7948daf502d 100644
--- a/apps/desktop/src/services/native-messaging.service.ts
+++ b/apps/desktop/src/services/native-messaging.service.ts
@@ -71,12 +71,10 @@ export class NativeMessagingService {
if (await this.stateService.getEnableBrowserIntegrationFingerprint()) {
ipcRenderer.send("nativeMessagingReply", { command: "verifyFingerprint", appId: appId });
- const fingerprint = (
- await this.cryptoService.getFingerprint(
- await this.stateService.getUserId(),
- remotePublicKey
- )
- ).join("-");
+ const fingerprint = await this.cryptoService.getFingerprint(
+ await this.stateService.getUserId(),
+ remotePublicKey
+ );
this.messagingService.send("setFocus");
From 407aadc0ebd26026a723ec5b34bb91886b7ebf0e Mon Sep 17 00:00:00 2001
From: William Martin
Date: Fri, 1 Sep 2023 12:36:51 -0400
Subject: [PATCH 6/7] apply code review
---
.../desktop-sync-verification-dialog.component.html | 9 ++++++---
.../src/components/fingerprint-dialog.component.html | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
index 20cbd2890f0..491e90971f2 100644
--- a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
@@ -3,9 +3,12 @@
{{ "desktopSyncVerificationTitle" | i18n }}
- {{ "desktopIntegrationVerificationText" | i18n }}
-
- {{ params.fingerprint.join("-") }}
+
+ {{ "desktopIntegrationVerificationText" | i18n }}
+
+
+ {{ params.fingerprint.join("-") }}
+
diff --git a/libs/auth/src/components/fingerprint-dialog.component.html b/libs/auth/src/components/fingerprint-dialog.component.html
index 2bb95ecf050..709cc4747d2 100644
--- a/libs/auth/src/components/fingerprint-dialog.component.html
+++ b/libs/auth/src/components/fingerprint-dialog.component.html
@@ -2,7 +2,7 @@
{{ "yourAccountsFingerprint" | i18n }}:
- {{ data.fingerprint.join("-") }}
+ {{ data.fingerprint.join("-") }}
Date: Fri, 1 Sep 2023 14:31:54 -0400
Subject: [PATCH 7/7] fix button color
---
.../components/desktop-sync-verification-dialog.component.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
index 491e90971f2..73d57882147 100644
--- a/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
+++ b/apps/browser/src/popup/components/desktop-sync-verification-dialog.component.html
@@ -11,7 +11,7 @@
-
+
{{ "ok" | i18n }}