mirror of
https://github.com/bitwarden/browser
synced 2025-12-23 11:43:46 +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:
@@ -1,4 +1,4 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { Observable, combineLatest, firstValueFrom, map } from "rxjs";
|
||||
import { Opaque } from "type-fest";
|
||||
|
||||
import { decodeJwtTokenToJson } from "@bitwarden/auth/common";
|
||||
@@ -135,6 +135,15 @@ export class TokenService implements TokenServiceAbstraction {
|
||||
this.initializeState();
|
||||
}
|
||||
|
||||
hasAccessToken$(userId: UserId): Observable<boolean> {
|
||||
// FIXME Once once vault timeout action is observable, we can use it to determine storage location
|
||||
// and avoid the need to check both disk and memory.
|
||||
return combineLatest([
|
||||
this.singleUserStateProvider.get(userId, ACCESS_TOKEN_DISK).state$,
|
||||
this.singleUserStateProvider.get(userId, ACCESS_TOKEN_MEMORY).state$,
|
||||
]).pipe(map(([disk, memory]) => Boolean(disk || memory)));
|
||||
}
|
||||
|
||||
// pivoting to an approach where we create a symmetric key we store in secure storage
|
||||
// which is used to protect the data before persisting to disk.
|
||||
// We will also use the same symmetric key to decrypt the data when reading from disk.
|
||||
|
||||
Reference in New Issue
Block a user