From b62220ace1483c8833f55e403f056ac6a7a20dc7 Mon Sep 17 00:00:00 2001 From: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com> Date: Fri, 11 Apr 2025 09:41:30 +0200 Subject: [PATCH] Autofill/pm 17444 use reprompt (#14004) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Passkey stuff Co-authored-by: Anders Åberg * Ugly hacks * Work On Modal State Management * Applying modalStyles * modal * Improved hide/show * fixed promise * File name * fix prettier * Protecting against null API's and undefined data * Only show fake popup to devs * cleanup mock code * rename minmimal-app to modal-app * Added comment * Added comment * removed old comment * Avoided changing minimum size * Add small comment * Rename component * adress feedback * Fixed uppercase file * Fixed build * Added codeowners * added void * commentary * feat: reset setting on app start * Moved reset to be in main / process launch * Add comment to create window * Added a little bit of styling * Use Messaging service to loadUrl * Enable passkeysautofill * Add logging * halfbaked * Integration working * And now it works without extra delay * Clean up * add note about messaging * lb * removed console.logs * Cleanup and adress review feedback * This hides the swift UI * add modal components * update modal with correct ciphers and functionality * add create screen * pick credential, draft * Remove logger * a whole lot of wiring * not working * Improved wiring * Cancel after 90s * Introduced observable * update cipher handling * update to use matchesUri * Launching bitwarden if its not running * Passing position from native to electron * Rename inModalMode to modalMode * remove tap * revert spaces * added back isDev * cleaned up a bit * Cleanup swift file * tweaked logging * clean up * Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift Co-authored-by: Andreas Coroiu * Update apps/desktop/src/platform/main/autofill/native-autofill.main.ts Co-authored-by: Andreas Coroiu * Update apps/desktop/src/platform/services/desktop-settings.service.ts Co-authored-by: Andreas Coroiu * adress position feedback * Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift Co-authored-by: Andreas Coroiu * Removed extra logging * Adjusted error logging * Use .error to log errors * remove dead code * Update desktop-autofill.service.ts * use parseCredentialId instead of guidToRawFormat * Update apps/desktop/src/autofill/services/desktop-autofill.service.ts Co-authored-by: Andreas Coroiu * Change windowXy to a Record instead of [number,number] * Update apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts Co-authored-by: Andreas Coroiu * Remove unsued dep and comment * changed timeout to be spec recommended maxium, 10 minutes, for now. * Correctly assume UP * Removed extra cancelRequest in deinint * Add timeout and UV to confirmChoseCipher UV is performed by UI, not the service * Improved docs regarding undefined cipherId * cleanup: UP is no longer undefined * Run completeError if ipc messages conversion failed * don't throw, instead return undefined * Disabled passkey provider * Throw error if no activeUserId was found * removed comment * Fixed lint * removed unsued service * reset entitlement formatting * Update entitlements.mas.plist * Fix build issues * Fix import issues * Update route names to use `fido2` * Fix being unable to select a passkey * Fix linting issues * Added support for handling a locked vault * Followup to fix merge issues and other comments * Update `userHandle` value * Add error handling for missing session or other errors * Remove unused route * Fix linting issues * Simplify updateCredential method * Add master password reprompt on passkey create * Followup to remove comments and timeouts and handle errors * Address lint issue by using `takeUntilDestroyed` * Add MP prompt to cipher selection * Change how timeout is handled * Include `of` from rxjs * Hide blue header for passkey popouts (#14095) * Hide blue header for passkey popouts * Fix issue with test * Fix ngOnDestroy complaint * Import OnDestroy correctly * Only require master password if item requires it --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> Co-authored-by: Anders Åberg Co-authored-by: Anders Åberg Co-authored-by: Colton Hurst Co-authored-by: Andreas Coroiu Co-authored-by: Evan Bassler Co-authored-by: Andreas Coroiu --- apps/desktop/src/app/app.component.ts | 3 +- .../desktop-fido2-user-interface.service.ts | 2 +- .../create/fido2-create.component.html | 4 +-- .../passkeys/create/fido2-create.component.ts | 17 +++++++++-- .../modal/passkeys/fido2-vault.component.html | 6 ++-- .../modal/passkeys/fido2-vault.component.ts | 28 +++++++++++++------ apps/desktop/src/scss/header.scss | 8 ++++++ libs/common/spec/fake-account-service.ts | 7 +++++ .../src/auth/abstractions/account.service.ts | 6 ++++ .../src/auth/services/account.service.spec.ts | 10 +++++++ .../src/auth/services/account.service.ts | 7 +++++ .../src/vault/abstractions/cipher.service.ts | 1 + .../src/vault/services/cipher.service.ts | 9 +++++- 13 files changed, 89 insertions(+), 19 deletions(-) diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 924bc2dd30f..25d5bcff7d0 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -86,7 +86,7 @@ const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours - +
@@ -112,6 +112,7 @@ export class AppComponent implements OnInit, OnDestroy { @ViewChild("loginApproval", { read: ViewContainerRef, static: true }) loginApprovalModalRef: ViewContainerRef; + showHeader$ = this.accountService.showHeader$; loading = false; private lastActivity: Date = null; diff --git a/apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts b/apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts index 765ccabe0fd..35ac1fe9571 100644 --- a/apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts +++ b/apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts @@ -97,7 +97,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi private updatedCipher: CipherView; - private rpId = new BehaviorSubject(""); + private rpId = new BehaviorSubject(null); private availableCipherIdsSubject = new BehaviorSubject([""]); /** * Observable that emits available cipher IDs once they're confirmed by the UI diff --git a/apps/desktop/src/modal/passkeys/create/fido2-create.component.html b/apps/desktop/src/modal/passkeys/create/fido2-create.component.html index e3423d6d7f8..8fefae29fd0 100644 --- a/apps/desktop/src/modal/passkeys/create/fido2-create.component.html +++ b/apps/desktop/src/modal/passkeys/create/fido2-create.component.html @@ -3,7 +3,7 @@ disableMargin class="tw-border-0 tw-border-b tw-border-solid tw-border-secondary-300" > - +
@@ -16,7 +16,7 @@ type="button" bitIconButton="bwi-close" slot="end" - class="tw-mb-4 tw-mr-2" + class="passkey-header-close tw-mb-4 tw-mr-2" (click)="closeModal()" > Close diff --git a/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts b/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts index 776ceae9d85..48047f3a365 100644 --- a/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts +++ b/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from "@angular/common"; -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit, OnDestroy } from "@angular/core"; import { RouterModule, Router } from "@angular/router"; import { BehaviorSubject, firstValueFrom, map, Observable } from "rxjs"; @@ -22,6 +22,7 @@ import { SectionHeaderComponent, BitIconButtonComponent, } from "@bitwarden/components"; +import { PasswordRepromptService } from "@bitwarden/vault"; import { DesktopFido2UserInterfaceService, @@ -47,7 +48,7 @@ import { DesktopSettingsService } from "../../../platform/services/desktop-setti ], templateUrl: "fido2-create.component.html", }) -export class Fido2CreateComponent implements OnInit { +export class Fido2CreateComponent implements OnInit, OnDestroy { session?: DesktopFido2UserInterfaceSession = null; private ciphersSubject = new BehaviorSubject([]); ciphers$: Observable = this.ciphersSubject.asObservable(); @@ -61,10 +62,12 @@ export class Fido2CreateComponent implements OnInit { private readonly dialogService: DialogService, private readonly domainSettingsService: DomainSettingsService, private readonly logService: LogService, + private readonly passwordRepromptService: PasswordRepromptService, private readonly router: Router, ) {} async ngOnInit() { + await this.accountService.setShowHeader(false); this.session = this.fido2UserInterfaceService.getCurrentSession(); const rpid = await this.session.getRpId(); const equivalentDomains = await firstValueFrom( @@ -92,8 +95,16 @@ export class Fido2CreateComponent implements OnInit { .catch((error) => this.logService.error(error)); } + async ngOnDestroy() { + await this.accountService.setShowHeader(true); + } + async addPasskeyToCipher(cipher: CipherView) { - this.session.notifyConfirmCreateCredential(true, cipher); + const userVerified = cipher.reprompt + ? await this.passwordRepromptService.showPasswordPrompt() + : true; + + this.session.notifyConfirmCreateCredential(userVerified, cipher); } async confirmPasskey() { diff --git a/apps/desktop/src/modal/passkeys/fido2-vault.component.html b/apps/desktop/src/modal/passkeys/fido2-vault.component.html index edc241c4d21..5191dcb1b6e 100644 --- a/apps/desktop/src/modal/passkeys/fido2-vault.component.html +++ b/apps/desktop/src/modal/passkeys/fido2-vault.component.html @@ -3,7 +3,7 @@ disableMargin class="tw-border-0 tw-border-b tw-border-solid tw-border-secondary-300" > - +
@@ -13,7 +13,7 @@ type="button" bitIconButton="bwi-close" slot="end" - class="tw-mb-4 tw-mr-2" + class="passkey-header-close tw-mb-4 tw-mr-2" (click)="closeModal()" > Close @@ -23,7 +23,7 @@ -