1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[PM-17479] Load-sdk-once (#12764)

* create service to load sdk on application init

* Eagerly load CLI SDK

* Remove wasm logging to api

* Fix imports

* Eagerly load Desktop renderer SDK

Note: If the main process ever requires an SDK, we'll need to load it there, too.
In that event, it's probably a good idea to move to IPC for all SDK functions to avoid
loading the SDK for every window.

* init wasm module from sdk load service

* Use default client factory

* Fix type imports

* Resolve jest module import errors

A CLI sdk load service that async imports our wasm binary doesn't seem to be needed to run, but jest isn't dealing with the ESM import properly.

* Fix linting

* remove example code
This commit is contained in:
Matt Gibson
2025-01-23 11:34:22 -08:00
committed by GitHub
parent 620affd3d5
commit f9f30f8ec4
19 changed files with 151 additions and 97 deletions

View File

@@ -10,6 +10,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
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";
@@ -35,11 +36,13 @@ export class InitService {
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
private accountService: AccountService,
private versionService: VersionService,
private sdkLoadService: SdkLoadService,
@Inject(DOCUMENT) private document: Document,
) {}
init() {
return async () => {
await this.sdkLoadService.load();
await this.stateService.init();
const activeAccount = await firstValueFrom(this.accountService.activeAccount$);