1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-09 13:10:17 +00:00

moving message sending side effect to sync

This commit is contained in:
Maciej Zieniuk
2025-03-25 20:06:47 +00:00
parent dd62397226
commit 7bed47b6d1
5 changed files with 6 additions and 21 deletions

View File

@@ -743,7 +743,6 @@ export default class MainBackground {
this.keyGenerationService,
logoutCallback,
this.stateProvider,
this.messagingService,
);
const sdkClientFactory = flagEnabled("sdk")

View File

@@ -573,7 +573,6 @@ export class ServiceContainer {
this.keyGenerationService,
logoutCallback,
this.stateProvider,
this.messagingService,
);
this.twoFactorService = new TwoFactorService(

View File

@@ -987,7 +987,6 @@ const safeProviders: SafeProvider[] = [
KeyGenerationServiceAbstraction,
LOGOUT_CALLBACK,
StateProvider,
MessagingServiceAbstraction,
],
}),
safeProvider({

View File

@@ -1,18 +1,9 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import {
combineLatest,
distinctUntilChanged,
filter,
firstValueFrom,
Observable,
of,
switchMap,
} from "rxjs";
import { combineLatest, filter, firstValueFrom, Observable, of, switchMap } from "rxjs";
import { LogoutReason } from "@bitwarden/auth/common";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import {
Argon2KdfConfig,
KdfConfig,
@@ -64,7 +55,6 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
private keyGenerationService: KeyGenerationService,
private logoutCallback: (logoutReason: LogoutReason, userId?: string) => Promise<void>,
private stateProvider: StateProvider,
private messagingService: MessagingService,
) {
this.convertAccountRequired$ = accountService.activeAccount$.pipe(
filter((account) => account != null),
@@ -80,18 +70,12 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
tokenService.hasAccessToken$(account.id).pipe(filter((hasToken) => hasToken)),
]),
),
distinctUntilChanged(),
switchMap(async ([userId, organizations, usesKeyConnector]) => {
const loggedInUsingSso = await this.tokenService.getIsExternal(userId);
const requiredByOrganization = this.findManagingOrganization(organizations) != null;
const userIsNotUsingKeyConnector = !usesKeyConnector;
const needsMigration =
loggedInUsingSso && requiredByOrganization && userIsNotUsingKeyConnector;
if (needsMigration) {
this.messagingService.send("convertAccountToKeyConnector");
}
return needsMigration;
return loggedInUsingSso && requiredByOrganization && userIsNotUsingKeyConnector;
}),
);
}

View File

@@ -214,6 +214,10 @@ export class DefaultSyncService extends CoreSyncService {
await this.providerService.save(providers, response.id);
await this.syncProfileOrganizations(response, response.id);
if (await firstValueFrom(this.keyConnectorService.convertAccountRequired$)) {
this.messageSender.send("convertAccountToKeyConnector");
}
}
private async setForceSetPasswordReasonIfNeeded(profileResponse: ProfileResponse) {