1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[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 <djsmith85@users.noreply.github.com>
Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
This commit is contained in:
Daniel James Smith
2025-11-06 20:53:13 +01:00
committed by GitHub
parent 1be9e19fad
commit 3c2f44095a
3 changed files with 40 additions and 5 deletions

View File

@@ -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<any[]> {
protected onLoadProfilesFromBrowser(browser: string): Promise<chromium_importer.ProfileInfo[]> {
return ipc.tools.chromiumImporter.getAvailableProfiles(browser);
}
protected onImportFromBrowser(browser: string, profile: string): Promise<any[]> {
protected onImportFromBrowser(
browser: string,
profile: string,
): Promise<chromium_importer.LoginImportResult[]> {
return ipc.tools.chromiumImporter.importLogins(browser, profile);
}
}

View File

@@ -5,9 +5,12 @@ import type { chromium_importer } from "@bitwarden/desktop-napi";
const chromiumImporter = {
getMetadata: (): Promise<Record<string, chromium_importer.NativeImporterMetadata>> =>
ipcRenderer.invoke("chromium_importer.getMetadata"),
getAvailableProfiles: (browser: string): Promise<any[]> =>
getAvailableProfiles: (browser: string): Promise<chromium_importer.ProfileInfo[]> =>
ipcRenderer.invoke("chromium_importer.getAvailableProfiles", browser),
importLogins: (browser: string, profileId: string): Promise<any[]> =>
importLogins: (
browser: string,
profileId: string,
): Promise<chromium_importer.LoginImportResult[]> =>
ipcRenderer.invoke("chromium_importer.importLogins", browser, profileId),
};

View File

@@ -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<any[]>;
onImportFromBrowser: (browser: string, profile: string) => Promise<LoginImportResult[]>;
// 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: {