From 4d1d635c769ba8ecf51dfb004f499fcdb1180c53 Mon Sep 17 00:00:00 2001 From: Evan Bassler Date: Tue, 18 Feb 2025 08:24:44 -0600 Subject: [PATCH] update cipher handling --- .../desktop-fido2-user-interface.service.ts | 3 ++- .../passkeys/create/fido2-create.component.ts | 23 +++++++++++++------ .../src/vault/abstractions/cipher.service.ts | 1 - .../src/vault/services/cipher.service.ts | 8 ------- 4 files changed, 18 insertions(+), 17 deletions(-) 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 4e89af55535..dccb4472442 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,6 +160,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi } async getRpId(): Promise { + console.log("getRpId"); return lastValueFrom( this.rpId.pipe( filter((id) => id != null), @@ -215,6 +216,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi userVerification, rpId, ); + this.rpId.next(rpId); try { await this.showUi("/passkey-create"); @@ -262,7 +264,6 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi */ async createCipher({ credentialName, userName, rpId }: NewCredentialParams): Promise { // Store the passkey on a new cipher to avoid replacing something important - this.rpId.next(rpId); const cipher = new CipherView(); cipher.name = credentialName; 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 34bb0b163da..4271fececa3 100644 --- a/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts +++ b/apps/desktop/src/modal/passkeys/create/fido2-create.component.ts @@ -62,21 +62,30 @@ export class Fido2CreateComponent implements OnInit { ) {} async ngOnInit() { + console.log("fido2 create component"); this.session = this.fido2UserInterfaceService.getCurrentSession(); - + console.log(this.session, "session"); const rpid = await this.session.getRpId(); const equivalentDomains = await firstValueFrom( this.domainSettingsService.getUrlEquivalentDomains(rpid), ); + console.log(rpid, "webdomain stuff"); + this.cipherService - .getPasskeyCiphersForUrl(rpid) + .getAllDecrypted() .then((ciphers) => { - const relevantCiphers = ciphers.filter( - (cipher) => - cipher.login.matchesUri(rpid, equivalentDomains) && - (!cipher.login.fido2Credentials || cipher.login.fido2Credentials.length === 0), - ); + console.log(ciphers, "ciphers from url"); + const relevantCiphers = ciphers.filter((cipher) => { + if (!cipher.login) { + return false; + } + + return ( + cipher.login.uri === rpid && + (!cipher.login.fido2Credentials || cipher.login.fido2Credentials.length === 0) + ); + }); this.ciphersSubject.next(relevantCiphers); }) .catch(() => { diff --git a/libs/common/src/vault/abstractions/cipher.service.ts b/libs/common/src/vault/abstractions/cipher.service.ts index d551684f129..30ffcb242b0 100644 --- a/libs/common/src/vault/abstractions/cipher.service.ts +++ b/libs/common/src/vault/abstractions/cipher.service.ts @@ -46,7 +46,6 @@ export abstract class CipherService implements UserKeyRotationDataProvider Promise; getAllDecryptedForIds: (ids: string[]) => Promise; - getPasskeyCiphersForUrl: (url: string) => Promise; getPasskeyCiphers: () => Promise; filterCiphersForUrl: ( ciphers: CipherView[], diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index 955bdd0c256..4b64d2e96f2 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -1637,14 +1637,6 @@ export class CipherService implements CipherServiceAbstraction { } } - async getPasskeyCiphersForUrl(url: string): Promise { - let ciphers = await this.getAllDecryptedForUrl(url); - if (!ciphers) { - return null; - } - ciphers = ciphers.filter((cipher) => cipher.login.fido2Credentials?.length); - return ciphers; - } async getPasskeyCiphers(): Promise { let ciphers = await this.getAllDecrypted(); if (!ciphers) {