1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-29 14:43:31 +00:00

revert breaking changes from review suggestions

This commit is contained in:
John Harrington
2025-12-15 09:22:42 -07:00
parent 7e270b6d62
commit 1a018fb687
2 changed files with 13 additions and 8 deletions

View File

@@ -19,9 +19,10 @@ const BROWSER_BUNDLE_IDS: &[(&str, &str)] = &[
#[derive(Debug, Deserialize)]
#[serde(tag = "type")]
enum CommandResult<T> {
#[serde(rename_all = "camelCase")]
// rename = "camelCase" was a review suggestion with breaking changes
#[serde(rename = "success")]
Success { value: T },
#[serde(rename_all = "camelCase")]
#[serde(rename = "error")]
Error { error: String },
}
@@ -175,8 +176,11 @@ async fn is_browser_installed(browser_name: &str) -> Result<bool> {
let bundle_id = BROWSER_BUNDLE_IDS
.iter()
.find(|(name, _)| *name == browser_name)
.map(|(_, id)| *id)
.ok_or(true);
.map(|(_, id)| *id);
let Some(bundle_id) = bundle_id else {
return Ok(true); // ok_or(true) was a review suggestion with breaking changes
// Avoid ok_or(true): serializes Result as {"Ok": "..."} instead of string value
let input = CommandInput {
namespace: "chromium_importer".to_string(),
@@ -195,7 +199,7 @@ async fn is_browser_installed(browser_name: &str) -> Result<bool> {
match result {
CommandResult::Success { value } => Ok(value.is_installed),
CommandResult::Error { error } => Err(anyhow!("{}", error)),
CommandResult::Error { error} => Err(anyhow!("{}", error)),
}
}

View File

@@ -130,10 +130,10 @@ export declare namespace biometrics_v2 {
}
export declare namespace chromium_importer {
export function getAvailableProfiles(browser: string): Array<ProfileInfo>
export function getAvailableProfiles(browser: string, masBuild: boolean): Promise<Array<ProfileInfo>>
/** Returns OS aware metadata describing supported Chromium based importers as a JSON string. */
export function getMetadata(): Record<string, NativeImporterMetadata>
export function importLogins(browser: string, profileId: string): Promise<Array<LoginImportResult>>
export function getMetadata(masBuild: boolean): Record<string, NativeImporterMetadata>
export function importLogins(browser: string, profileId: string, masBuild: boolean): Promise<Array<LoginImportResult>>
export interface Login {
url: string
username: string
@@ -158,6 +158,7 @@ export declare namespace chromium_importer {
id: string
name: string
}
export function requestBrowserAccess(browser: string, masBuild: boolean): Promise<void>
}
export declare namespace clipboards {