1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

add auth status to auth service (#8377)

* add auth status to auth service

* fix auth service factory
This commit is contained in:
Jake Fink
2024-03-26 09:56:20 -04:00
committed by GitHub
parent d000f081da
commit a46767dee2
7 changed files with 88 additions and 3 deletions

View File

@@ -1,18 +1,30 @@
import { Observable, distinctUntilChanged, map, shareReplay } from "rxjs";
import { ApiService } from "../../abstractions/api.service";
import { CryptoService } from "../../platform/abstractions/crypto.service";
import { MessagingService } from "../../platform/abstractions/messaging.service";
import { StateService } from "../../platform/abstractions/state.service";
import { KeySuffixOptions } from "../../platform/enums";
import { AccountService } from "../abstractions/account.service";
import { AuthService as AuthServiceAbstraction } from "../abstractions/auth.service";
import { AuthenticationStatus } from "../enums/authentication-status";
export class AuthService implements AuthServiceAbstraction {
activeAccountStatus$: Observable<AuthenticationStatus>;
constructor(
protected accountService: AccountService,
protected messagingService: MessagingService,
protected cryptoService: CryptoService,
protected apiService: ApiService,
protected stateService: StateService,
) {}
) {
this.activeAccountStatus$ = this.accountService.activeAccount$.pipe(
map((account) => account.status),
distinctUntilChanged(),
shareReplay({ bufferSize: 1, refCount: false }),
);
}
async getAuthStatus(userId?: string): Promise<AuthenticationStatus> {
// If we don't have an access token or userId, we're logged out