From 3c2f44095ab2ad87821754f31d072f743a444429 Mon Sep 17 00:00:00 2001 From: Daniel James Smith <2670567+djsmith85@users.noreply.github.com> Date: Thu, 6 Nov 2025 20:53:13 +0100 Subject: [PATCH] [PM-27656] Show error message when detecting Chromium v3 encryption, which isn't supported yet (#17156) * Replace any-returns with types * Show an error message when a failure from the native call is returned --------- Co-authored-by: Daniel James Smith Co-authored-by: Oscar Hinton --- .../tools/import/import-desktop.component.ts | 8 +++-- apps/desktop/src/app/tools/preload.ts | 7 +++-- .../chrome/import-chrome.component.ts | 30 ++++++++++++++++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/app/tools/import/import-desktop.component.ts b/apps/desktop/src/app/tools/import/import-desktop.component.ts index dd34855f41..6b1d26562f 100644 --- a/apps/desktop/src/app/tools/import/import-desktop.component.ts +++ b/apps/desktop/src/app/tools/import/import-desktop.component.ts @@ -3,6 +3,7 @@ import { Component } from "@angular/core"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { DialogRef, AsyncActionsModule, ButtonModule, DialogModule } from "@bitwarden/components"; +import type { chromium_importer } from "@bitwarden/desktop-napi"; import { ImportMetadataServiceAbstraction } from "@bitwarden/importer-core"; import { ImportComponent, @@ -47,11 +48,14 @@ export class ImportDesktopComponent { this.dialogRef.close(); } - protected onLoadProfilesFromBrowser(browser: string): Promise { + protected onLoadProfilesFromBrowser(browser: string): Promise { return ipc.tools.chromiumImporter.getAvailableProfiles(browser); } - protected onImportFromBrowser(browser: string, profile: string): Promise { + protected onImportFromBrowser( + browser: string, + profile: string, + ): Promise { return ipc.tools.chromiumImporter.importLogins(browser, profile); } } diff --git a/apps/desktop/src/app/tools/preload.ts b/apps/desktop/src/app/tools/preload.ts index c21a1ac0bf..ff0a4ffbbd 100644 --- a/apps/desktop/src/app/tools/preload.ts +++ b/apps/desktop/src/app/tools/preload.ts @@ -5,9 +5,12 @@ import type { chromium_importer } from "@bitwarden/desktop-napi"; const chromiumImporter = { getMetadata: (): Promise> => ipcRenderer.invoke("chromium_importer.getMetadata"), - getAvailableProfiles: (browser: string): Promise => + getAvailableProfiles: (browser: string): Promise => ipcRenderer.invoke("chromium_importer.getAvailableProfiles", browser), - importLogins: (browser: string, profileId: string): Promise => + importLogins: ( + browser: string, + profileId: string, + ): Promise => ipcRenderer.invoke("chromium_importer.importLogins", browser, profileId), }; diff --git a/libs/importer/src/components/chrome/import-chrome.component.ts b/libs/importer/src/components/chrome/import-chrome.component.ts index 10f924e9c6..fd41d49513 100644 --- a/libs/importer/src/components/chrome/import-chrome.component.ts +++ b/libs/importer/src/components/chrome/import-chrome.component.ts @@ -38,6 +38,23 @@ import { ImportType } from "../../models"; type ProfileOption = { id: string; name: string }; +type Login = { + url: string; + username: string; + password: string; + note: string; +}; +type LoginImportFailure = { + url: string; + username: string; + error: string; +}; + +type LoginImportResult = { + login?: Login; + failure?: LoginImportFailure; +}; + // FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush // eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection @Component({ @@ -82,7 +99,7 @@ export class ImportChromeComponent implements OnInit, OnDestroy { // FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals // eslint-disable-next-line @angular-eslint/prefer-signals @Input() - onImportFromBrowser: (browser: string, profile: string) => Promise; + onImportFromBrowser: (browser: string, profile: string) => Promise; // FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals // eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref @@ -121,6 +138,17 @@ export class ImportChromeComponent implements OnInit, OnDestroy { this.getBrowserName(this.format()), this.formGroup.controls.profile.value, ); + + // If any of the login items has a failure return a generic error message + // Introduced because we ran into a new type of V3 encryption added on Chrome that we don't yet support + if (logins.some((l) => l.failure != null)) { + return { + errors: { + message: this.i18nService.t("errorOccurred"), + }, + }; + } + if (logins.length === 0) { return { errors: {