From f72d6f877f76b5c42b449208e43a61a1e5099304 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Tue, 10 Oct 2023 21:58:27 -0400 Subject: [PATCH] Rough draft to combine user verification required and master password required prompts --- .../popup/components/fido2/fido2.component.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/browser/src/vault/popup/components/fido2/fido2.component.ts b/apps/browser/src/vault/popup/components/fido2/fido2.component.ts index fbba7a5a0112..6146247a0d0f 100644 --- a/apps/browser/src/vault/popup/components/fido2/fido2.component.ts +++ b/apps/browser/src/vault/popup/components/fido2/fido2.component.ts @@ -220,9 +220,10 @@ export class Fido2Component implements OnInit, OnDestroy { async submit() { const data = this.message$.value; if (data?.type === "PickCredentialRequest") { - let userVerified = false; - if (data.userVerification) { - userVerified = await this.passwordRepromptService.showPasswordPrompt(); + const userVerified = await this.handleUserVerification(data.userVerification); + + if (!userVerified) { + return; } this.send({ @@ -232,8 +233,6 @@ export class Fido2Component implements OnInit, OnDestroy { userVerified, }); } else if (data?.type === "ConfirmNewCredentialRequest") { - let userVerified = false; - if (this.cipher.login.fido2Credentials.length > 0) { const confirmed = await this.dialogService.openSimpleDialog({ title: { key: "overwritePasskey" }, @@ -246,8 +245,10 @@ export class Fido2Component implements OnInit, OnDestroy { } } - if (data.userVerification) { - userVerified = await this.passwordRepromptService.showPasswordPrompt(); + const userVerified = await this.handleUserVerification(data.userVerification); + + if (!userVerified) { + return; } this.send({ @@ -404,6 +405,16 @@ export class Fido2Component implements OnInit, OnDestroy { this.destroy$.complete(); } + private async handleUserVerification(userVerification: boolean): Promise { + const masterPasswordRempromptRequired = this.cipher && this.cipher.reprompt !== 0; + + if (!masterPasswordRempromptRequired && !userVerification) { + return true; + } + + return await this.passwordRepromptService.showPasswordPrompt(); + } + private send(msg: BrowserFido2Message) { BrowserFido2UserInterfaceSession.sendMessage({ sessionId: this.sessionId,