1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 11:31:44 +00:00

[PM-19479] Client-Managed SDK state definition

This commit is contained in:
Daniel García
2025-05-19 16:05:05 +02:00
parent a82eb8c22b
commit 78b7dd59f5
5 changed files with 125 additions and 2 deletions

View File

@@ -775,6 +775,7 @@ export default class MainBackground {
this.accountService,
this.kdfConfigService,
this.keyService,
this.stateProvider,
);
this.passwordStrengthService = new PasswordStrengthService();

View File

@@ -3,7 +3,7 @@
import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit, inject } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { NavigationEnd, Router, RouterOutlet } from "@angular/router";
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap } from "rxjs";
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap, map } from "rxjs";
import { DeviceTrustToastService } from "@bitwarden/angular/auth/services/device-trust-toast.service.abstraction";
import { LogoutReason } from "@bitwarden/auth/common";
@@ -13,6 +13,7 @@ import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authenticatio
import { AnimationControlService } from "@bitwarden/common/platform/abstractions/animation-control.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { MessageListener } from "@bitwarden/common/platform/messaging";
import { UserId } from "@bitwarden/common/types/guid";
@@ -74,10 +75,27 @@ export class AppComponent implements OnInit, OnDestroy {
private biometricsService: BiometricsService,
private deviceTrustToastService: DeviceTrustToastService,
private popupSizeService: PopupSizeService,
private sdkService: SdkService,
) {
this.deviceTrustToastService.setupListeners$.pipe(takeUntilDestroyed()).subscribe();
}
/* eslint-disable no-console */
async testSdkState() {
const userId = (await firstValueFrom(this.accountService.activeAccount$)).id;
await firstValueFrom(
this.sdkService.userClient$(userId).pipe(
map(async (clientRc) => {
using clientRef = clientRc.take();
const client = clientRef.value;
const ciphers = await client.vault().print_the_ciphers();
console.log("Ciphers2: ", ciphers);
}),
),
);
}
async ngOnInit() {
initPopupClosedListener();
@@ -200,6 +218,10 @@ export class AppComponent implements OnInit, OnDestroy {
.subscribe((state) => {
this.routerAnimations = state;
});
this.testSdkState().catch((e) => {
console.error("Error in testSdkState()", e);
});
}
ngOnDestroy(): void {

View File

@@ -599,6 +599,7 @@ export class ServiceContainer {
this.accountService,
this.kdfConfigService,
this.keyService,
this.stateProvider,
customUserAgent,
);