|
|
|
|
@ -17,6 +17,8 @@ import {
@@ -17,6 +17,8 @@ import {
|
|
|
|
|
throwError, |
|
|
|
|
} from "rxjs"; |
|
|
|
|
|
|
|
|
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; |
|
|
|
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; |
|
|
|
|
import { Utils } from "@bitwarden/common/platform/misc/utils"; |
|
|
|
|
import { UserRequestedFallbackAbortReason } from "@bitwarden/common/vault/abstractions/fido2/fido2-client.service.abstraction"; |
|
|
|
|
import { |
|
|
|
|
@ -114,7 +116,10 @@ export type BrowserFido2Message = { sessionId: string } & (
@@ -114,7 +116,10 @@ export type BrowserFido2Message = { sessionId: string } & (
|
|
|
|
|
* The user interface is implemented as a popout and the service uses the browser's messaging API to communicate with it. |
|
|
|
|
*/ |
|
|
|
|
export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServiceAbstraction { |
|
|
|
|
constructor(private browserPopoutWindowService: BrowserPopoutWindowService) {} |
|
|
|
|
constructor( |
|
|
|
|
private browserPopoutWindowService: BrowserPopoutWindowService, |
|
|
|
|
private authService: AuthService |
|
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
async newSession( |
|
|
|
|
fallbackSupported: boolean, |
|
|
|
|
@ -123,6 +128,7 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
@@ -123,6 +128,7 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
|
|
|
|
|
): Promise<Fido2UserInterfaceSession> { |
|
|
|
|
return await BrowserFido2UserInterfaceSession.create( |
|
|
|
|
this.browserPopoutWindowService, |
|
|
|
|
this.authService, |
|
|
|
|
fallbackSupported, |
|
|
|
|
tab, |
|
|
|
|
abortController |
|
|
|
|
@ -133,12 +139,14 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
@@ -133,12 +139,14 @@ export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServi
|
|
|
|
|
export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSession { |
|
|
|
|
static async create( |
|
|
|
|
browserPopoutWindowService: BrowserPopoutWindowService, |
|
|
|
|
authService: AuthService, |
|
|
|
|
fallbackSupported: boolean, |
|
|
|
|
tab: chrome.tabs.Tab, |
|
|
|
|
abortController?: AbortController |
|
|
|
|
): Promise<BrowserFido2UserInterfaceSession> { |
|
|
|
|
return new BrowserFido2UserInterfaceSession( |
|
|
|
|
browserPopoutWindowService, |
|
|
|
|
authService, |
|
|
|
|
fallbackSupported, |
|
|
|
|
tab, |
|
|
|
|
abortController |
|
|
|
|
@ -176,6 +184,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
@@ -176,6 +184,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|
|
|
|
|
|
|
|
|
private constructor( |
|
|
|
|
private readonly browserPopoutWindowService: BrowserPopoutWindowService, |
|
|
|
|
private readonly authService: AuthService, |
|
|
|
|
private readonly fallbackSupported: boolean, |
|
|
|
|
private readonly tab: chrome.tabs.Tab, |
|
|
|
|
readonly abortController = new AbortController(), |
|
|
|
|
@ -278,7 +287,9 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
@@ -278,7 +287,9 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async ensureUnlockedVault(): Promise<void> { |
|
|
|
|
await this.connect(); |
|
|
|
|
if ((await this.authService.getAuthStatus()) !== AuthenticationStatus.Unlocked) { |
|
|
|
|
await this.connect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async informCredentialNotFound(): Promise<void> { |
|
|
|
|
|