mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
[BEEEP: PM-10190] Use strict TS checks in CLI service container (#10298)
* move cli service-container to new folder * fix imports * add tsconfig and fix type issues in other services * fix more imports in service-container * make ts server happy in service-container * fix actual bugs in cli service-container * fix package json reference path * fix service-container import * update type on cipher service
This commit is contained in:
@@ -72,7 +72,7 @@ export abstract class AccountService {
|
||||
* Updates the `activeAccount$` observable with the new active account.
|
||||
* @param userId
|
||||
*/
|
||||
abstract switchAccount(userId: UserId): Promise<void>;
|
||||
abstract switchAccount(userId: UserId | null): Promise<void>;
|
||||
/**
|
||||
* Cleans personal information for the given account from the `accounts$` observable. Does not remove the userId from the observable.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { combineLatestWith, map, distinctUntilChanged, shareReplay, combineLatest } from "rxjs";
|
||||
import {
|
||||
combineLatestWith,
|
||||
map,
|
||||
distinctUntilChanged,
|
||||
shareReplay,
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from "rxjs";
|
||||
|
||||
import {
|
||||
AccountInfo,
|
||||
@@ -42,11 +49,11 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
private accountsState: GlobalState<Record<UserId, AccountInfo>>;
|
||||
private activeAccountIdState: GlobalState<UserId | undefined>;
|
||||
|
||||
accounts$;
|
||||
activeAccount$;
|
||||
accountActivity$;
|
||||
sortedUserIds$;
|
||||
nextUpAccount$;
|
||||
accounts$: Observable<Record<UserId, AccountInfo>>;
|
||||
activeAccount$: Observable<{ id: UserId | undefined } & AccountInfo>;
|
||||
accountActivity$: Observable<Record<UserId, Date>>;
|
||||
sortedUserIds$: Observable<UserId[]>;
|
||||
nextUpAccount$: Observable<{ id: UserId } & AccountInfo>;
|
||||
|
||||
constructor(
|
||||
private messagingService: MessagingService,
|
||||
@@ -61,7 +68,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
);
|
||||
this.activeAccount$ = this.activeAccountIdState.state$.pipe(
|
||||
combineLatestWith(this.accounts$),
|
||||
map(([id, accounts]) => (id ? { id, ...accounts[id] } : undefined)),
|
||||
map(([id, accounts]) => (id ? { id, ...(accounts[id] as AccountInfo) } : undefined)),
|
||||
distinctUntilChanged((a, b) => a?.id === b?.id && accountInfoEqual(a, b)),
|
||||
shareReplay({ bufferSize: 1, refCount: false }),
|
||||
);
|
||||
@@ -118,7 +125,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
await this.removeAccountActivity(userId);
|
||||
}
|
||||
|
||||
async switchAccount(userId: UserId): Promise<void> {
|
||||
async switchAccount(userId: UserId | null): Promise<void> {
|
||||
let updateActivity = false;
|
||||
await this.activeAccountIdState.update(
|
||||
(_, accounts) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { LogoutReason } from "@bitwarden/auth/common";
|
||||
import { ApiService } from "../../abstractions/api.service";
|
||||
import { OrganizationService } from "../../admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationUserType } from "../../admin-console/enums";
|
||||
import { Organization } from "../../admin-console/models/domain/organization";
|
||||
import { KeysRequest } from "../../models/request/keys.request";
|
||||
import { CryptoService } from "../../platform/abstractions/crypto.service";
|
||||
import { KeyGenerationService } from "../../platform/abstractions/key-generation.service";
|
||||
@@ -114,7 +115,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async getManagingOrganization() {
|
||||
async getManagingOrganization(): Promise<Organization> {
|
||||
const orgs = await this.organizationService.getAll();
|
||||
return orgs.find(
|
||||
(o) =>
|
||||
|
||||
Reference in New Issue
Block a user