Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load-sdk-once #12764

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import { KeyGenerationService as KeyGenerationServiceAbstraction } from "@bitwarden/common/platform/abstractions/key-generation.service";
import { LogService as LogServiceAbstraction } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
import {
Expand Down Expand Up @@ -125,6 +126,7 @@
import { KeyGenerationService } from "@bitwarden/common/platform/services/key-generation.service";
import { MigrationBuilderService } from "@bitwarden/common/platform/services/migration-builder.service";
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
import { DefaultSdkClientFactory } from "@bitwarden/common/platform/services/sdk/default-sdk-client-factory";

Check warning on line 129 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L129

Added line #L129 was not covered by tests
import { DefaultSdkService } from "@bitwarden/common/platform/services/sdk/default-sdk.service";
import { NoopSdkClientFactory } from "@bitwarden/common/platform/services/sdk/noop-sdk-client-factory";
import { StateService } from "@bitwarden/common/platform/services/state.service";
Expand Down Expand Up @@ -260,7 +262,7 @@
import { BackgroundPlatformUtilsService } from "../platform/services/platform-utils/background-platform-utils.service";
import { BrowserPlatformUtilsService } from "../platform/services/platform-utils/browser-platform-utils.service";
import { PopupViewCacheBackgroundService } from "../platform/services/popup-view-cache-background.service";
import { BrowserSdkClientFactory } from "../platform/services/sdk/browser-sdk-client-factory";
import { BrowserSdkLoadService } from "../platform/services/sdk/browser-sdk-load.service";

Check warning on line 265 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L265

Added line #L265 was not covered by tests
import { BackgroundTaskSchedulerService } from "../platform/services/task-scheduler/background-task-scheduler.service";
import { BackgroundMemoryStorageService } from "../platform/storage/background-memory-storage.service";
import { BrowserStorageServiceProvider } from "../platform/storage/browser-storage-service.provider";
Expand Down Expand Up @@ -380,6 +382,7 @@
themeStateService: DefaultThemeStateService;
autoSubmitLoginBackground: AutoSubmitLoginBackground;
sdkService: SdkService;
sdkLoadService: SdkLoadService;
cipherAuthorizationService: CipherAuthorizationService;
inlineMenuFieldQualificationService: InlineMenuFieldQualificationService;

Expand Down Expand Up @@ -731,8 +734,9 @@
);

const sdkClientFactory = flagEnabled("sdk")
? new BrowserSdkClientFactory(this.logService)
? new DefaultSdkClientFactory()
: new NoopSdkClientFactory();
this.sdkLoadService = new BrowserSdkLoadService(this.logService);

Check warning on line 739 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L739

Added line #L739 was not covered by tests
this.sdkService = new DefaultSdkService(
sdkClientFactory,
this.environmentService,
Expand Down Expand Up @@ -1267,6 +1271,7 @@
async bootstrap() {
this.containerService.attachToGlobal(self);

await this.sdkLoadService.load();

Check warning on line 1274 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L1274

Added line #L1274 was not covered by tests
// Only the "true" background should run migrations
await this.stateService.init({ runMigrations: true });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,55 @@ export function runInsideAngular<T>(ngZone: NgZone): MonoTypeOperatorFunction<T>
return () => subscription.unsubscribe();
});
}

// function now() {
// const userId = "userId" as UserId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the reference counting stuff we talked about :) Should we clean this up?

// const otherService: { someSetting: Observable<any> } = null;
// const sdkService: DefaultSdkService = null;

// combineLatest([otherService.someSetting, sdkService.userClient$(userId)]).subscribe(
// ([someSetting, sdkClient]) => {
// using client = sdkClient.take();
// if (someSetting) {
// client.value.echo("some setting");
// } else {
// client.value.echo("no setting");
// }
// },
// );
// }

// function callback() {
// const userId = "userId" as UserId;
// const otherService: { someSetting: Observable<any> } = null;
// const sdkService: DefaultSdkService = null;

// someSetting.pipe(
// switchMap((someSettings) =>
// sdkService.userClientWithCallback$(userId, (client) => {
// // take done in userClient With Callback while calling this callback
// if (someSettings) {
// client.echo("some setting");
// } else {
// client.echo("no setting");
// }
// }),
// ),
// );
// }

// function operator() {
// const userId = "userId" as UserId;
// const otherService: { someSetting: Observable<any> } = null;
// const sdkService: DefaultSdkService = null;

// someSetting.pipe(
// sdkService.withUserClient, // this transforms the stream into [value, client] tuple while ensuring the client it taken
// ).subscribe(([someSetting, client]) => {
// if (someSetting) {
// client.echo("some setting");
// } else {
// client.echo("no setting");
// }
// });
// }
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { SdkClientFactory } from "@bitwarden/common/platform/abstractions/sdk/sdk-client-factory";
import type { BitwardenClient } from "@bitwarden/sdk-internal";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";

import { BrowserApi } from "../../browser/browser-api";

export type GlobalWithWasmInit = typeof globalThis & {
initSdk: () => void;
};

// https://stackoverflow.com/a/47880734
const supported = (() => {
try {
Expand All @@ -17,9 +18,7 @@
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
}
}
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
} catch {
// ignore
}
return false;
Expand All @@ -33,54 +32,42 @@
if (BrowserApi.isManifestVersion(3)) {
if (supported) {
// eslint-disable-next-line no-console
console.debug("WebAssembly is supported in this environment");
console.info("WebAssembly is supported in this environment");

Check warning on line 35 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L35

Added line #L35 was not covered by tests
loadingPromise = import("./wasm");
} else {
// eslint-disable-next-line no-console
console.debug("WebAssembly is not supported in this environment");
console.info("WebAssembly is not supported in this environment");

Check warning on line 39 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L39

Added line #L39 was not covered by tests
loadingPromise = import("./fallback");
}
}

// Manifest v2 expects dynamic imports to prevent timing issues.
async function load() {
async function importModule(): Promise<GlobalWithWasmInit["initSdk"]> {
if (BrowserApi.isManifestVersion(3)) {
// Ensure we have loaded the module
await loadingPromise;
return;
}

if (supported) {
} else if (supported) {
// eslint-disable-next-line no-console
console.debug("WebAssembly is supported in this environment");
console.info("WebAssembly is supported in this environment");

Check warning on line 51 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L51

Added line #L51 was not covered by tests
await import("./wasm");
} else {
// eslint-disable-next-line no-console
console.debug("WebAssembly is not supported in this environment");
console.info("WebAssembly is not supported in this environment");

Check warning on line 55 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L55

Added line #L55 was not covered by tests
await import("./fallback");
}

// the wasm and fallback imports mutate globalThis to add the initSdk function
return (globalThis as GlobalWithWasmInit).initSdk;

Check warning on line 60 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L60

Added line #L60 was not covered by tests
}

/**
* SDK client factory with a js fallback for when WASM is not supported.
*
* Works both in popup and service worker.
*/
export class BrowserSdkClientFactory implements SdkClientFactory {
constructor(private logService: LogService) {}
export class BrowserSdkLoadService implements SdkLoadService {
constructor(readonly logService: LogService) {}

Check warning on line 64 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L63-L64

Added lines #L63 - L64 were not covered by tests

async createSdkClient(
...args: ConstructorParameters<typeof BitwardenClient>
): Promise<BitwardenClient> {
async load(): Promise<void> {
const startTime = performance.now();
await load();

await importModule().then((initSdk) => initSdk());

Check warning on line 68 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L68

Added line #L68 was not covered by tests
const endTime = performance.now();

const instance = (globalThis as any).init_sdk(...args);

this.logService.info("WASM SDK loaded in", Math.round(endTime - startTime), "ms");

return instance;
this.logService.info(`WASM SDK loaded in ${Math.round(endTime - startTime)}ms`);

Check warning on line 71 in apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/browser-sdk-load.service.ts#L71

Added line #L71 was not covered by tests
}
}
6 changes: 3 additions & 3 deletions apps/browser/src/platform/services/sdk/fallback.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as sdk from "@bitwarden/sdk-internal";
import * as wasm from "@bitwarden/sdk-internal/bitwarden_wasm_internal_bg.wasm.js";

(globalThis as any).init_sdk = (...args: ConstructorParameters<typeof sdk.BitwardenClient>) => {
(sdk as any).init(wasm);
import { GlobalWithWasmInit } from "./browser-sdk-load.service";

return new sdk.BitwardenClient(...args);
(globalThis as GlobalWithWasmInit).initSdk = () => {
(sdk as any).init(wasm);

Check warning on line 7 in apps/browser/src/platform/services/sdk/fallback.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/fallback.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
};
6 changes: 3 additions & 3 deletions apps/browser/src/platform/services/sdk/wasm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as sdk from "@bitwarden/sdk-internal";
import * as wasm from "@bitwarden/sdk-internal/bitwarden_wasm_internal_bg.wasm";

(globalThis as any).init_sdk = (...args: ConstructorParameters<typeof sdk.BitwardenClient>) => {
(sdk as any).init(wasm);
import { GlobalWithWasmInit } from "./browser-sdk-load.service";

return new sdk.BitwardenClient(...args);
(globalThis as GlobalWithWasmInit).initSdk = () => {
(sdk as any).init(wasm);

Check warning on line 7 in apps/browser/src/platform/services/sdk/wasm.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/sdk/wasm.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
};
3 changes: 3 additions & 0 deletions apps/browser/src/popup/services/init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService as LogServiceAbstraction } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";

Check warning on line 9 in apps/browser/src/popup/services/init.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/init.service.ts#L9

Added line #L9 was not covered by tests
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";

import { BrowserApi } from "../../platform/browser/browser-api";
Expand All @@ -22,11 +23,13 @@
private twoFactorService: TwoFactorService,
private logService: LogServiceAbstraction,
private themingService: AbstractThemingService,
private sdkLoadService: SdkLoadService,
@Inject(DOCUMENT) private document: Document,
) {}

init() {
return async () => {
await this.sdkLoadService.load();

Check warning on line 32 in apps/browser/src/popup/services/init.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/init.service.ts#L32

Added line #L32 was not covered by tests
await this.stateService.init({ runMigrations: false }); // Browser background is responsible for migrations
await this.i18nService.init();
this.twoFactorService.init();
Expand Down
15 changes: 11 additions & 4 deletions apps/browser/src/popup/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkClientFactory } from "@bitwarden/common/platform/abstractions/sdk/sdk-client-factory";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";

Check warning on line 73 in apps/browser/src/popup/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/services.module.ts#L73

Added line #L73 was not covered by tests
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import {
AbstractStorageService,
Expand All @@ -82,6 +83,7 @@
import { TaskSchedulerService } from "@bitwarden/common/platform/scheduling";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { DefaultSdkClientFactory } from "@bitwarden/common/platform/services/sdk/default-sdk-client-factory";

Check warning on line 86 in apps/browser/src/popup/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/services.module.ts#L86

Added line #L86 was not covered by tests
import { NoopSdkClientFactory } from "@bitwarden/common/platform/services/sdk/noop-sdk-client-factory";
import { StorageServiceProvider } from "@bitwarden/common/platform/services/storage-service.provider";
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
Expand Down Expand Up @@ -144,7 +146,7 @@
import { BrowserScriptInjectorService } from "../../platform/services/browser-script-injector.service";
import I18nService from "../../platform/services/i18n.service";
import { ForegroundPlatformUtilsService } from "../../platform/services/platform-utils/foreground-platform-utils.service";
import { BrowserSdkClientFactory } from "../../platform/services/sdk/browser-sdk-client-factory";
import { BrowserSdkLoadService } from "../../platform/services/sdk/browser-sdk-load.service";

Check warning on line 149 in apps/browser/src/popup/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/services.module.ts#L149

Added line #L149 was not covered by tests
import { ForegroundTaskSchedulerService } from "../../platform/services/task-scheduler/foreground-task-scheduler.service";
import { BrowserStorageServiceProvider } from "../../platform/storage/browser-storage-service.provider";
import { ForegroundMemoryStorageService } from "../../platform/storage/foreground-memory-storage.service";
Expand Down Expand Up @@ -566,11 +568,16 @@
deps: [MessageSender, MessageListener],
}),
safeProvider({
provide: SdkClientFactory,
useFactory: (logService: LogService) =>
flagEnabled("sdk") ? new BrowserSdkClientFactory(logService) : new NoopSdkClientFactory(),
provide: SdkLoadService,
useClass: BrowserSdkLoadService,
deps: [LogService],
}),
safeProvider({
provide: SdkClientFactory,
useFactory: () =>
flagEnabled("sdk") ? new DefaultSdkClientFactory() : new NoopSdkClientFactory(),
deps: [],
}),
safeProvider({
provide: LoginEmailService,
useClass: LoginEmailService,
Expand Down
9 changes: 9 additions & 0 deletions apps/cli/src/platform/services/cli-sdk-load.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
import * as sdk from "@bitwarden/sdk-internal";

export class CliSdkLoadService implements SdkLoadService {
async load(): Promise<void> {
const module = await import("@bitwarden/sdk-internal/bitwarden_wasm_internal_bg.wasm");
(sdk as any).init(module);

Check warning on line 7 in apps/cli/src/platform/services/cli-sdk-load.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/cli/src/platform/services/cli-sdk-load.service.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
}
}
5 changes: 5 additions & 0 deletions apps/cli/src/service-container/service-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
RegionConfig,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { KeyGenerationService as KeyGenerationServiceAbstraction } from "@bitwarden/common/platform/abstractions/key-generation.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { KeySuffixOptions, LogLevelType } from "@bitwarden/common/platform/enums";
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
Expand Down Expand Up @@ -168,6 +169,7 @@
import { CliBiometricsService } from "../key-management/cli-biometrics-service";
import { flagEnabled } from "../platform/flags";
import { CliPlatformUtilsService } from "../platform/services/cli-platform-utils.service";
import { CliSdkLoadService } from "../platform/services/cli-sdk-load.service";
import { ConsoleLogService } from "../platform/services/console-log.service";
import { I18nService } from "../platform/services/i18n.service";
import { LowdbStorageService } from "../platform/services/lowdb-storage.service";
Expand Down Expand Up @@ -266,6 +268,7 @@
kdfConfigService: KdfConfigService;
taskSchedulerService: TaskSchedulerService;
sdkService: SdkService;
sdkLoadService: SdkLoadService;
cipherAuthorizationService: CipherAuthorizationService;

constructor() {
Expand Down Expand Up @@ -566,6 +569,7 @@
const sdkClientFactory = flagEnabled("sdk")
? new DefaultSdkClientFactory()
: new NoopSdkClientFactory();
this.sdkLoadService = new CliSdkLoadService();
this.sdkService = new DefaultSdkService(
sdkClientFactory,
this.environmentService,
Expand Down Expand Up @@ -854,6 +858,7 @@
return;
}

await this.sdkLoadService.load();

Check warning on line 861 in apps/cli/src/service-container/service-container.ts

View check run for this annotation

Codecov / codecov/patch

apps/cli/src/service-container/service-container.ts#L861

Added line #L861 was not covered by tests
await this.storageService.init();
await this.stateService.init();
this.containerService.attachToGlobal(global);
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/app/services/init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";

Check warning on line 14 in apps/desktop/src/app/services/init.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/services/init.service.ts#L14

Added line #L14 was not covered by tests
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
Expand Down Expand Up @@ -47,11 +48,13 @@
private versionService: VersionService,
private sshAgentService: SshAgentService,
private autofillService: DesktopAutofillService,
private sdkLoadService: SdkLoadService,
@Inject(DOCUMENT) private document: Document,
) {}

init() {
return async () => {
await this.sdkLoadService.load();

Check warning on line 57 in apps/desktop/src/app/services/init.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/services/init.service.ts#L57

Added line #L57 was not covered by tests
await this.sshAgentService.init();
this.nativeMessagingService.init();
await this.stateService.init({ runMigrations: false }); // Desktop will run them in main process
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src/app/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkClientFactory } from "@bitwarden/common/platform/abstractions/sdk/sdk-client-factory";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";

Check warning on line 70 in apps/desktop/src/app/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/services/services.module.ts#L70

Added line #L70 was not covered by tests
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
import { SystemService as SystemServiceAbstraction } from "@bitwarden/common/platform/abstractions/system.service";
Expand All @@ -77,7 +78,9 @@
import { Fido2AuthenticatorService } from "@bitwarden/common/platform/services/fido2/fido2-authenticator.service";
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
import { DefaultSdkClientFactory } from "@bitwarden/common/platform/services/sdk/default-sdk-client-factory";
import { DefaultSdkLoadService } from "@bitwarden/common/platform/services/sdk/default-sdk-load.service";

Check warning on line 81 in apps/desktop/src/app/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/services/services.module.ts#L81

Added line #L81 was not covered by tests
import { NoopSdkClientFactory } from "@bitwarden/common/platform/services/sdk/noop-sdk-client-factory";
import { NoopSdkLoadService } from "@bitwarden/common/platform/services/sdk/noop-sdk-load.service";

Check warning on line 83 in apps/desktop/src/app/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/services/services.module.ts#L83

Added line #L83 was not covered by tests
import { SystemService } from "@bitwarden/common/platform/services/system.service";
import { GlobalStateProvider, StateProvider } from "@bitwarden/common/platform/state";
// eslint-disable-next-line import/no-restricted-paths -- Implementation for memory storage
Expand Down Expand Up @@ -393,6 +396,11 @@
useClass: flagEnabled("sdk") ? DefaultSdkClientFactory : NoopSdkClientFactory,
deps: [],
}),
safeProvider({
provide: SdkLoadService,
useClass: flagEnabled("sdk") ? DefaultSdkLoadService : NoopSdkLoadService,
deps: [],
}),
safeProvider({
provide: LoginEmailService,
useClass: LoginEmailService,
Expand Down
Loading
Loading