From 5de23bd24f289507aa24ac19b15ec3178b08eaf3 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Thu, 8 Jan 2026 08:29:13 -0600 Subject: [PATCH] Read CipherViewLike from CipherService.cipherListViews$. --- .../credentials/fido2-vault.component.html | 2 +- .../credentials/fido2-vault.component.ts | 19 ++++++++++++------- .../desktop-fido2-user-interface.service.ts | 5 +++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.html b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.html index ed04993d09f..4cb5c983a25 100644 --- a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.html +++ b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.html @@ -29,7 +29,7 @@ - {{ c.subTitle }} + {{ getSubtitle(c) }} {{ "select" | i18n }} diff --git a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts index ba8e097df92..25a78b601c3 100644 --- a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts +++ b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts @@ -38,6 +38,7 @@ import { DesktopFido2UserInterfaceService, DesktopFido2UserInterfaceSession, } from "../../services/desktop-fido2-user-interface.service"; +import { CipherViewLike, CipherViewLikeUtils } from "@bitwarden/common/vault/utils/cipher-view-like-utils"; @Component({ standalone: true, @@ -61,8 +62,8 @@ import { export class Fido2VaultComponent implements OnInit, OnDestroy { session?: DesktopFido2UserInterfaceSession = null; private destroy$ = new Subject(); - private ciphersSubject = new BehaviorSubject([]); - ciphers$: Observable = this.ciphersSubject.asObservable(); + private ciphersSubject = new BehaviorSubject([]); + ciphers$: Observable = this.ciphersSubject.asObservable(); cipherIds$: Observable | undefined; readonly Icons = { BitwardenShield }; @@ -88,7 +89,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { this.destroy$.complete(); } - async chooseCipher(cipher: CipherView): Promise { + async chooseCipher(cipher: CipherViewLike): Promise { if (!this.session) { await this.dialogService.openSimpleDialog({ title: { key: "unexpectedErrorShort" }, @@ -103,7 +104,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { } const isConfirmed = await this.validateCipherAccess(cipher); - this.session.confirmChosenCipher(cipher.id, isConfirmed); + this.session.confirmChosenCipher(cipher.id as string, isConfirmed); await this.closeModal(); } @@ -146,17 +147,21 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { takeUntil(this.destroy$), ) .subscribe({ - next: (ciphers) => this.ciphersSubject.next(ciphers as CipherView[]), + next: (ciphers) => this.ciphersSubject.next(ciphers), error: (error: unknown) => this.logService.error("Failed to load ciphers", error), }); } - private async validateCipherAccess(cipher: CipherView): Promise { + getSubtitle(cipher: CipherViewLike): string | undefined { + return CipherViewLikeUtils.subtitle(cipher) + } + + private async validateCipherAccess(cipher: CipherViewLike): Promise { if (cipher.reprompt !== CipherRepromptType.None) { return this.passwordRepromptService.showPasswordPrompt(); } - const username = cipher.login.username ?? cipher.name; + const username = CipherViewLikeUtils.getLogin(cipher).username ?? cipher.name; return this.session.promptForUserVerification(username, "Verify it's you to log in"); } } 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 778edc21f69..b636a677a1b 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 @@ -34,6 +34,7 @@ import { SecureNoteView } from "@bitwarden/common/vault/models/view/secure-note. import { NativeAutofillUserVerificationCommand } from "../../platform/main/autofill/user-verification.command"; import { DesktopSettingsService } from "../../platform/services/desktop-settings.service"; +import { CipherViewLikeUtils } from "@bitwarden/common/vault/utils/cipher-view-like-utils"; /** * This type is used to pass the window position from the native UI @@ -152,10 +153,10 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi return; } const cipherView = await firstValueFrom(this.cipherService.cipherListViews$(activeUserId).pipe(map((ciphers) => { - return ciphers.find((cipher) => cipher.id == selectedCipherId && !cipher.deletedDate) as CipherView; + return ciphers.find((cipher) => cipher.id == selectedCipherId && !cipher.deletedDate); }))); - const username = cipherView.login.username ?? cipherView.name + const username = CipherViewLikeUtils.getLogin(cipherView).username ?? cipherView.name try { // TODO: internationalization const isConfirmed = await this.promptForUserVerification(username, "Verify it's you to log in with Bitwarden.");