From 4b2447df398765f97710c24bae3d20985b2ea899 Mon Sep 17 00:00:00 2001 From: Jeffrey Holland Date: Wed, 26 Mar 2025 14:42:30 +0100 Subject: [PATCH 1/2] Followup to remove comments and timeouts and handle errors --- .../src/autofill/services/desktop-autofill.service.ts | 4 ---- .../services/desktop-fido2-user-interface.service.ts | 1 - .../src/modal/passkeys/create/fido2-create.component.ts | 9 +++------ apps/desktop/src/modal/passkeys/fido2-vault.component.ts | 6 +++--- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/apps/desktop/src/autofill/services/desktop-autofill.service.ts b/apps/desktop/src/autofill/services/desktop-autofill.service.ts index 22ba64d4d76..a104a036bda 100644 --- a/apps/desktop/src/autofill/services/desktop-autofill.service.ts +++ b/apps/desktop/src/autofill/services/desktop-autofill.service.ts @@ -60,10 +60,6 @@ export class DesktopAutofillService implements OnDestroy { .pipe( distinctUntilChanged(), switchMap((enabled) => { - /* if (!enabled) { - return EMPTY; - } */ - return this.accountService.activeAccount$.pipe( map((account) => account?.id), filter((userId): userId is UserId => userId != 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 70e01ed8079..02608345910 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 @@ -160,7 +160,6 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi this.rpId.pipe( filter((id) => id != null), take(1), - timeout(5000), // 5 seconds timeout ), ); } 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 fb0093067ac..776ceae9d85 100644 --- a/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts +++ b/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts @@ -7,6 +7,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module"; import { BitwardenShield } from "@bitwarden/auth/angular"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service"; +import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { @@ -21,14 +22,12 @@ import { SectionHeaderComponent, BitIconButtonComponent, } from "@bitwarden/components"; -// import { SearchComponent } from "@bitwarden/components/src/search/search.component"; import { DesktopFido2UserInterfaceService, DesktopFido2UserInterfaceSession, } from "../../../autofill/services/desktop-fido2-user-interface.service"; import { DesktopSettingsService } from "../../../platform/services/desktop-settings.service"; -// import { AnchorLinkDirective } from "../../../../../libs/components/src/link/link.directive"; @Component({ standalone: true, @@ -45,7 +44,6 @@ import { DesktopSettingsService } from "../../../platform/services/desktop-setti SectionComponent, ItemModule, BadgeModule, - // SearchComponent, ], templateUrl: "fido2-create.component.html", }) @@ -62,6 +60,7 @@ export class Fido2CreateComponent implements OnInit { private readonly cipherService: CipherService, private readonly dialogService: DialogService, private readonly domainSettingsService: DomainSettingsService, + private readonly logService: LogService, private readonly router: Router, ) {} @@ -90,9 +89,7 @@ export class Fido2CreateComponent implements OnInit { }); this.ciphersSubject.next(relevantCiphers); }) - .catch(() => { - // console.error(err); - }); + .catch((error) => this.logService.error(error)); } async addPasskeyToCipher(cipher: CipherView) { diff --git a/apps/desktop/src/modal/passkeys/fido2-vault.component.ts b/apps/desktop/src/modal/passkeys/fido2-vault.component.ts index 977b61df9b1..ba84929ec8d 100644 --- a/apps/desktop/src/modal/passkeys/fido2-vault.component.ts +++ b/apps/desktop/src/modal/passkeys/fido2-vault.component.ts @@ -6,6 +6,7 @@ import { firstValueFrom, map, BehaviorSubject, Observable } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { BitwardenShield } from "@bitwarden/auth/angular"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { @@ -57,6 +58,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { private readonly fido2UserInterfaceService: DesktopFido2UserInterfaceService, private readonly cipherService: CipherService, private readonly accountService: AccountService, + private readonly logService: LogService, private readonly router: Router, ) {} @@ -75,9 +77,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { .then((ciphers) => { this.ciphersSubject.next(ciphers); }) - .catch(() => { - // console.error(err); - }); + .catch((error) => this.logService.error(error)); }); } From 66923240a7c8cd6855fda59c3727aae878043a40 Mon Sep 17 00:00:00 2001 From: Jeffrey Holland Date: Wed, 26 Mar 2025 16:23:39 +0100 Subject: [PATCH 2/2] Address lint issue by using `takeUntilDestroyed` --- apps/desktop/src/modal/passkeys/fido2-vault.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/modal/passkeys/fido2-vault.component.ts b/apps/desktop/src/modal/passkeys/fido2-vault.component.ts index ba84929ec8d..ac8cc4a8638 100644 --- a/apps/desktop/src/modal/passkeys/fido2-vault.component.ts +++ b/apps/desktop/src/modal/passkeys/fido2-vault.component.ts @@ -1,5 +1,6 @@ import { CommonModule } from "@angular/common"; import { Component, OnInit, OnDestroy } from "@angular/core"; +import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { RouterModule, Router } from "@angular/router"; import { firstValueFrom, map, BehaviorSubject, Observable } from "rxjs"; @@ -70,8 +71,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { this.session = this.fido2UserInterfaceService.getCurrentSession(); this.cipherIds$ = this.session?.availableCipherIds$; - // eslint-disable-next-line rxjs-angular/prefer-takeuntil - this.cipherIds$.subscribe((cipherIds) => { + this.cipherIds$.pipe(takeUntilDestroyed()).subscribe((cipherIds) => { this.cipherService .getAllDecryptedForIds(activeUserId, cipherIds || []) .then((ciphers) => {