mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
Use account service for account enumeration. (#9023)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { BiometricKey } from "../../auth/types/biometric-key";
|
||||
import { GeneratorOptions } from "../../tools/generator/generator-options";
|
||||
import { GeneratedPasswordHistory, PasswordGeneratorOptions } from "../../tools/generator/password";
|
||||
@@ -24,8 +22,6 @@ export type InitOptions = {
|
||||
};
|
||||
|
||||
export abstract class StateService<T extends Account = Account> {
|
||||
accounts$: Observable<{ [userId: string]: T }>;
|
||||
|
||||
addAccount: (account: T) => Promise<void>;
|
||||
clearDecryptedData: (userId: UserId) => Promise<void>;
|
||||
clean: (options?: StorageOptions) => Promise<void>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BehaviorSubject, firstValueFrom, map } from "rxjs";
|
||||
import { firstValueFrom, map } from "rxjs";
|
||||
import { Jsonify, JsonValue } from "type-fest";
|
||||
|
||||
import { AccountService } from "../../auth/abstractions/account.service";
|
||||
@@ -52,9 +52,6 @@ export class StateService<
|
||||
TAccount extends Account = Account,
|
||||
> implements StateServiceAbstraction<TAccount>
|
||||
{
|
||||
protected accountsSubject = new BehaviorSubject<{ [userId: string]: TAccount }>({});
|
||||
accounts$ = this.accountsSubject.asObservable();
|
||||
|
||||
private hasBeenInited = false;
|
||||
protected isRecoveredSession = false;
|
||||
|
||||
@@ -115,8 +112,6 @@ export class StateService<
|
||||
state = await this.syncAccountFromDisk(authenticatedAccounts[i]);
|
||||
}
|
||||
|
||||
await this.pushAccounts();
|
||||
|
||||
return state;
|
||||
});
|
||||
}
|
||||
@@ -153,7 +148,6 @@ export class StateService<
|
||||
|
||||
await this.removeAccountFromDisk(options?.userId);
|
||||
await this.removeAccountFromMemory(options?.userId);
|
||||
await this.pushAccounts();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -856,7 +850,6 @@ export class StateService<
|
||||
});
|
||||
});
|
||||
}
|
||||
await this.pushAccounts();
|
||||
}
|
||||
|
||||
protected async scaffoldNewAccountStorage(account: TAccount): Promise<void> {
|
||||
@@ -934,17 +927,6 @@ export class StateService<
|
||||
);
|
||||
}
|
||||
|
||||
protected async pushAccounts(): Promise<void> {
|
||||
await this.state().then((state) => {
|
||||
if (state.accounts == null || Object.keys(state.accounts).length < 1) {
|
||||
this.accountsSubject.next({});
|
||||
return;
|
||||
}
|
||||
|
||||
this.accountsSubject.next(state.accounts);
|
||||
});
|
||||
}
|
||||
|
||||
protected reconcileOptions(
|
||||
requestedOptions: StorageOptions,
|
||||
defaultOptions: StorageOptions,
|
||||
@@ -1096,8 +1078,6 @@ export class StateService<
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
await this.pushAccounts();
|
||||
}
|
||||
|
||||
protected createAccount(init: Partial<TAccount> = null): TAccount {
|
||||
|
||||
Reference in New Issue
Block a user