1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-29 06:33:40 +00:00

[PM-25521] Move importer metadata to native code (#16695)

* Add importer metadata to native code

* Impl napi code in ts

* Impl napi code in ts

* Fix clippy

* Fix clippy

* remove ts util tests

* Check for installed browsers

* PR fixes

* test fix

* fix clippy

* fix tests

* Bug fix

* clippy fix

* Correct tests

* fix clippy

* fix clippy

* Correct tests

* Correct tests

* [PM-25521] Wire up loading metadata on desktop (#16813)

* Initial commit

* Fix issues regarding now unused feature flag

* Fixed ts-strict issues

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
Co-authored-by: adudek-bw <adudek@bitwarden.com>

* Remove logic to skip Brave as that now happens via the native code

* Define default capabilities which can be overwritten by specifc client/platform

* Fix DI issues

* Do not overwrite existing importers, just add new ones or update existing ones

* feat: [PM-25521] return metadata directly (not as JSON) (#16882)

* feat: return metadata directly (not as JSON)

* Fix broken builds

Move getMetaData into chromium_importer
Remove chromium_importer_metadata and any related service
Parse object from native instead of json

* Run cargo fmt

* Fix cargo dependency sort order

* Use exposed type from NAPI instead of redefining it.

* Run cargo fmt

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>

* Only enable chromium loader for installed and supported browsers

---------

Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
This commit is contained in:
adudek-bw
2025-10-17 09:46:10 -04:00
committed by GitHub
parent 9ba1de702e
commit 7015663c38
32 changed files with 641 additions and 337 deletions

View File

@@ -3,6 +3,15 @@
/* auto-generated by NAPI-RS */
/** Mechanisms that load data into the importer */
export interface NativeImporterMetadata {
/** Identifies the importer */
id: string
/** Describes the strategies used to obtain imported data */
loaders: Array<string>
/** Identifies the instructions for the importer */
instructions: string
}
export declare namespace passwords {
/** The error message returned when a password is not found during retrieval or deletion. */
export const PASSWORD_NOT_FOUND: string
@@ -228,6 +237,8 @@ export declare namespace chromium_importer {
login?: Login
failure?: LoginImportFailure
}
/** Returns OS aware metadata describing supported Chromium based importers as a JSON string. */
export function getMetadata(): Record<string, NativeImporterMetadata>
export function getInstalledBrowsers(): Array<string>
export function getAvailableProfiles(browser: string): Array<ProfileInfo>
export function importLogins(browser: string, profileId: string): Promise<Array<LoginImportResult>>

View File

@@ -944,8 +944,12 @@ pub mod logging {
#[napi]
pub mod chromium_importer {
use bitwarden_chromium_importer::chromium::DefaultInstalledBrowserRetriever;
use bitwarden_chromium_importer::chromium::InstalledBrowserRetriever;
use bitwarden_chromium_importer::chromium::LoginImportResult as _LoginImportResult;
use bitwarden_chromium_importer::chromium::ProfileInfo as _ProfileInfo;
use bitwarden_chromium_importer::metadata::NativeImporterMetadata;
use std::collections::HashMap;
#[napi(object)]
pub struct ProfileInfo {
@@ -1007,9 +1011,17 @@ pub mod chromium_importer {
}
}
#[napi]
/// Returns OS aware metadata describing supported Chromium based importers as a JSON string.
pub fn get_metadata() -> HashMap<String, NativeImporterMetadata> {
bitwarden_chromium_importer::metadata::get_supported_importers::<
DefaultInstalledBrowserRetriever,
>()
}
#[napi]
pub fn get_installed_browsers() -> napi::Result<Vec<String>> {
bitwarden_chromium_importer::chromium::get_installed_browsers()
bitwarden_chromium_importer::chromium::DefaultInstalledBrowserRetriever::get_installed_browsers()
.map_err(|e| napi::Error::from_reason(e.to_string()))
}