1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-12 06:23:38 +00:00

Read CipherViewLike from CipherService.cipherListViews$.

This commit is contained in:
Isaiah Inuwa
2026-01-08 08:29:13 -06:00
parent 41eb3c36d6
commit 5de23bd24f
3 changed files with 16 additions and 10 deletions

View File

@@ -29,7 +29,7 @@
<button bitLink [title]="c.name" type="button">
{{ c.name }}
</button>
<span slot="secondary">{{ c.subTitle }}</span>
<span slot="secondary">{{ getSubtitle(c) }}</span>
<span bitBadge slot="end">{{ "select" | i18n }}</span>
</button>
</bit-item>

View File

@@ -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<void>();
private ciphersSubject = new BehaviorSubject<CipherView[]>([]);
ciphers$: Observable<CipherView[]> = this.ciphersSubject.asObservable();
private ciphersSubject = new BehaviorSubject<CipherViewLike[]>([]);
ciphers$: Observable<CipherViewLike[]> = this.ciphersSubject.asObservable();
cipherIds$: Observable<string[]> | undefined;
readonly Icons = { BitwardenShield };
@@ -88,7 +89,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}
async chooseCipher(cipher: CipherView): Promise<void> {
async chooseCipher(cipher: CipherViewLike): Promise<void> {
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<boolean> {
getSubtitle(cipher: CipherViewLike): string | undefined {
return CipherViewLikeUtils.subtitle(cipher)
}
private async validateCipherAccess(cipher: CipherViewLike): Promise<boolean> {
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");
}
}

View File

@@ -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.");