1- // FIXME: Update this file to be type safe and remove this and next line
2- // @ts -strict-ignore
31import { firstValueFrom , map } from "rxjs" ;
42
53import { AccountService } from "@bitwarden/common/auth/abstractions/account.service" ;
64import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service" ;
75import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status" ;
86import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service" ;
7+ import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service" ;
98import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction" ;
9+ import { UserId } from "@bitwarden/user-core" ;
1010
1111import { Response } from "../models/response" ;
1212import { TemplateResponse } from "../models/response/template.response" ;
@@ -17,16 +17,17 @@ export class StatusCommand {
1717 private syncService : SyncService ,
1818 private accountService : AccountService ,
1919 private authService : AuthService ,
20+ private userAutoUnlockKeyService : UserAutoUnlockKeyService ,
2021 ) { }
2122
2223 async run ( ) : Promise < Response > {
2324 try {
2425 const baseUrl = await this . baseUrl ( ) ;
25- const status = await this . status ( ) ;
2626 const lastSync = await this . syncService . getLastSync ( ) ;
2727 const [ userId , email ] = await firstValueFrom (
2828 this . accountService . activeAccount$ . pipe ( map ( ( a ) => [ a ?. id , a ?. email ] ) ) ,
2929 ) ;
30+ const status = await this . status ( userId ) ;
3031
3132 return Response . success (
3233 new TemplateResponse ( {
@@ -42,12 +43,18 @@ export class StatusCommand {
4243 }
4344 }
4445
45- private async baseUrl ( ) : Promise < string > {
46+ private async baseUrl ( ) : Promise < string | undefined > {
4647 const env = await firstValueFrom ( this . envService . environment$ ) ;
4748 return env . getUrls ( ) . base ;
4849 }
4950
50- private async status ( ) : Promise < "unauthenticated" | "locked" | "unlocked" > {
51+ private async status (
52+ userId : UserId | undefined ,
53+ ) : Promise < "unauthenticated" | "locked" | "unlocked" > {
54+ if ( userId != null ) {
55+ await this . userAutoUnlockKeyService . setUserKeyInMemoryIfAutoUserKeySet ( userId ) ;
56+ }
57+
5158 const authStatus = await this . authService . getAuthStatus ( ) ;
5259 if ( authStatus === AuthenticationStatus . Unlocked ) {
5360 return "unlocked" ;
0 commit comments