mirror of
https://github.com/bitwarden/browser
synced 2026-02-04 10:43:47 +00:00
* 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>
28 lines
837 B
TypeScript
28 lines
837 B
TypeScript
import { ClientType } from "@bitwarden/client-type";
|
|
|
|
import { LoaderAvailability, ImportersMetadata } from "./metadata";
|
|
import { ImportType } from "./models";
|
|
|
|
/** Lookup the loaders supported by a specific client.
|
|
* WARNING: this method does not supply metadata for every import type.
|
|
* @returns `undefined` when metadata is not defined for the type, or
|
|
* an array identifying the supported clients.
|
|
*/
|
|
export function availableLoaders(
|
|
importersMetadata: ImportersMetadata,
|
|
type: ImportType,
|
|
client: ClientType,
|
|
) {
|
|
if (!importersMetadata) {
|
|
return undefined;
|
|
}
|
|
|
|
if (!(type in importersMetadata)) {
|
|
return undefined;
|
|
}
|
|
|
|
const capabilities = importersMetadata[type]?.loaders ?? [];
|
|
const available = capabilities.filter((loader) => LoaderAvailability[loader].includes(client));
|
|
return available;
|
|
}
|