mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
Observable auth statuses (#8537)
* Observable has token * Allow access to user key state observable * Create observable auth status * Fix DI
This commit is contained in:
@@ -13,6 +13,14 @@ import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key";
|
||||
|
||||
export abstract class CryptoService {
|
||||
abstract activeUserKey$: Observable<UserKey>;
|
||||
|
||||
/**
|
||||
* Returns the an observable key for the given user id.
|
||||
*
|
||||
* @note this observable represents only user keys stored in memory. A null value does not indicate that we cannot load a user key from storage.
|
||||
* @param userId The desired user
|
||||
*/
|
||||
abstract getInMemoryUserKeyFor$(userId: UserId): Observable<UserKey>;
|
||||
/**
|
||||
* Sets the provided user key and stores
|
||||
* any other necessary versions (such as auto, biometrics,
|
||||
|
||||
@@ -160,6 +160,10 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
await this.setUserKey(key);
|
||||
}
|
||||
|
||||
getInMemoryUserKeyFor$(userId: UserId): Observable<UserKey> {
|
||||
return this.stateProvider.getUserState$(USER_KEY, userId);
|
||||
}
|
||||
|
||||
async getUserKey(userId?: UserId): Promise<UserKey> {
|
||||
let userKey = await firstValueFrom(this.stateProvider.getUserState$(USER_KEY, userId));
|
||||
if (userKey) {
|
||||
|
||||
Reference in New Issue
Block a user