From 077889d3b061a9af65d15c02a558e08561b829ae Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Fri, 15 Sep 2023 16:08:03 -0400 Subject: [PATCH 01/11] Removed standalone fido2key view, update login view to show created date when a fido2key is present, reverted icon component to previous state without fido2key type, removed filters to handle standalone fido2key as login type --- .../components/action-buttons.component.html | 38 ------------- .../components/vault/add-edit.component.html | 35 +----------- .../vault/vault-filter.component.html | 6 +-- .../vault/vault-filter.component.ts | 15 +----- .../components/vault/vault-items.component.ts | 20 ++----- .../components/vault/view.component.html | 53 +------------------ .../src/vault/components/icon.component.ts | 32 ++++++----- .../models/vault-filter.model.spec.ts | 13 ----- .../vault-filter/models/vault-filter.model.ts | 8 +-- .../src/vault/models/view/cipher.view.ts | 2 - 10 files changed, 26 insertions(+), 196 deletions(-) diff --git a/apps/browser/src/vault/popup/components/action-buttons.component.html b/apps/browser/src/vault/popup/components/action-buttons.component.html index c1afffd508cd..f63c1f1ac325 100644 --- a/apps/browser/src/vault/popup/components/action-buttons.component.html +++ b/apps/browser/src/vault/popup/components/action-buttons.component.html @@ -100,41 +100,3 @@ - - - - - diff --git a/apps/browser/src/vault/popup/components/vault/add-edit.component.html b/apps/browser/src/vault/popup/components/vault/add-edit.component.html index 7b4b12044799..58e9b5c4e094 100644 --- a/apps/browser/src/vault/popup/components/vault/add-edit.component.html +++ b/apps/browser/src/vault/popup/components/vault/add-edit.component.html @@ -138,7 +138,7 @@

{{ "typePasskey" | i18n }} - {{ "passkeyTwoStepLogin" | i18n }} + {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}
@@ -475,39 +475,6 @@

/> - -
-
- - -
-
- {{ "typePasskey" | i18n }} - {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }} -
- -
-
-
- - -
-
-
-
diff --git a/apps/browser/src/vault/popup/components/vault/vault-filter.component.html b/apps/browser/src/vault/popup/components/vault/vault-filter.component.html index 2065181ba253..564cf19f2c4a 100644 --- a/apps/browser/src/vault/popup/components/vault/vault-filter.component.html +++ b/apps/browser/src/vault/popup/components/vault/vault-filter.component.html @@ -70,9 +70,9 @@

{{ "typeLogin" | i18n }}

- {{ - getTypeCountsSum(typeCounts, cipherType.Login, cipherType.Fido2Key) - }} + + {{ typeCounts.get(cipherType.Login) || 0 }} + - - - - - -
diff --git a/libs/angular/src/vault/components/icon.component.ts b/libs/angular/src/vault/components/icon.component.ts index 57ce74a94ae8..84a72ca0c3c5 100644 --- a/libs/angular/src/vault/components/icon.component.ts +++ b/libs/angular/src/vault/components/icon.component.ts @@ -70,34 +70,33 @@ export class IconComponent implements OnInit { switch (cipher.type) { case CipherType.Login: - case CipherType.Fido2Key: { - icon = cipher.type === CipherType.Login ? "bwi-globe" : "bwi-passkey"; + icon = "bwi-globe"; - let uri = - cipher.type === CipherType.Login ? cipher.login.uri : cipher.fido2Key.launchUri; - let isWebsite = false; + if (cipher.login.uri) { + let hostnameUri = cipher.login.uri; + let isWebsite = false; - if (uri) { - if (uri.indexOf("androidapp://") === 0) { + if (hostnameUri.indexOf("androidapp://") === 0) { icon = "bwi-android"; image = null; - } else if (uri.indexOf("iosapp://") === 0) { + } else if (hostnameUri.indexOf("iosapp://") === 0) { icon = "bwi-apple"; image = null; - } else if (imageEnabled && uri.indexOf("://") === -1 && uri.indexOf(".") > -1) { - uri = "http://" + uri; + } else if ( + imageEnabled && + hostnameUri.indexOf("://") === -1 && + hostnameUri.indexOf(".") > -1 + ) { + hostnameUri = "http://" + hostnameUri; isWebsite = true; } else if (imageEnabled) { - isWebsite = uri.indexOf("http") === 0 && uri.indexOf(".") > -1; + isWebsite = hostnameUri.indexOf("http") === 0 && hostnameUri.indexOf(".") > -1; } if (imageEnabled && isWebsite) { try { - image = iconsUrl + "/" + Utils.getHostname(uri) + "/icon.png"; - fallbackImage = - cipher.type === CipherType.Login - ? "images/bwi-globe.png" - : "images/bwi-passkey.png"; + image = iconsUrl + "/" + Utils.getHostname(hostnameUri) + "/icon.png"; + fallbackImage = "images/bwi-globe.png"; } catch (e) { // Ignore error since the fallback icon will be shown if image is null. } @@ -106,7 +105,6 @@ export class IconComponent implements OnInit { image = null; } break; - } case CipherType.SecureNote: icon = "bwi-sticky-note"; break; diff --git a/libs/angular/src/vault/vault-filter/models/vault-filter.model.spec.ts b/libs/angular/src/vault/vault-filter/models/vault-filter.model.spec.ts index 6fef66c3faa0..1fab9727a5a6 100644 --- a/libs/angular/src/vault/vault-filter/models/vault-filter.model.spec.ts +++ b/libs/angular/src/vault/vault-filter/models/vault-filter.model.spec.ts @@ -216,19 +216,6 @@ describe("VaultFilter", () => { expect(result).toBe(true); }); }); - - describe("given a cipher with Fido2Key type", () => { - it("should return true when filter is login", () => { - const cipher = createCipher({ type: CipherType.Fido2Key }); - const filterFunction = createFilterFunction({ - cipherType: CipherType.Fido2Key, - }); - - const result = filterFunction(cipher); - - expect(result).toBe(true); - }); - }); }); }); diff --git a/libs/angular/src/vault/vault-filter/models/vault-filter.model.ts b/libs/angular/src/vault/vault-filter/models/vault-filter.model.ts index 9b7f3282bd71..ae4151f9648b 100644 --- a/libs/angular/src/vault/vault-filter/models/vault-filter.model.ts +++ b/libs/angular/src/vault/vault-filter/models/vault-filter.model.ts @@ -45,13 +45,7 @@ export class VaultFilter { cipherPassesFilter = cipher.isDeleted; } if (this.cipherType != null && cipherPassesFilter) { - // Fido2Key's should also be included in the Login type - if (this.cipherType === CipherType.Login) { - cipherPassesFilter = - cipher.type === this.cipherType || cipher.type === CipherType.Fido2Key; - } else { - cipherPassesFilter = cipher.type === this.cipherType; - } + cipherPassesFilter = cipher.type === this.cipherType; } if (this.selectedFolder && this.selectedFolderId == null && cipherPassesFilter) { cipherPassesFilter = cipher.folderId == null; diff --git a/libs/common/src/vault/models/view/cipher.view.ts b/libs/common/src/vault/models/view/cipher.view.ts index 4b342fd57fb9..0667519be7ec 100644 --- a/libs/common/src/vault/models/view/cipher.view.ts +++ b/libs/common/src/vault/models/view/cipher.view.ts @@ -11,7 +11,6 @@ import { Cipher } from "../domain/cipher"; import { AttachmentView } from "./attachment.view"; import { CardView } from "./card.view"; -import { Fido2KeyView } from "./fido2-key.view"; import { FieldView } from "./field.view"; import { IdentityView } from "./identity.view"; import { LoginView } from "./login.view"; @@ -36,7 +35,6 @@ export class CipherView implements View, InitializerMetadata { identity = new IdentityView(); card = new CardView(); secureNote = new SecureNoteView(); - fido2Key = new Fido2KeyView(); attachments: AttachmentView[] = null; fields: FieldView[] = null; passwordHistory: PasswordHistoryView[] = null; From ed59a7768e80947e04f3364a69a4470b0bdc8a09 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Fri, 15 Sep 2023 17:39:23 -0400 Subject: [PATCH 02/11] Allow duplication --- .../angular/src/components/share.component.ts | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/libs/angular/src/components/share.component.ts b/libs/angular/src/components/share.component.ts index ee2b4348c5ab..73792f91fef7 100644 --- a/libs/angular/src/components/share.component.ts +++ b/libs/angular/src/components/share.component.ts @@ -11,7 +11,6 @@ import { Utils } from "@bitwarden/common/platform/misc/utils"; import { Checkable, isChecked } from "@bitwarden/common/types/checkable"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service"; -import { CipherType } from "@bitwarden/common/vault/enums/cipher-type"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view"; @@ -100,15 +99,6 @@ export class ShareComponent implements OnInit, OnDestroy { const orgName = orgs.find((o) => o.id === this.organizationId)?.name ?? this.i18nService.t("organization"); - if (await this.checkFido2KeyExistsInOrg(cipherView, this.organizationId)) { - this.platformUtilsService.showToast( - "error", - this.i18nService.t("errorOccurred"), - this.i18nService.t("duplicatePasskey") - ); - return; - } - try { this.formPromise = this.cipherService .shareWithServer(cipherView, this.organizationId, selectedCollectionIds) @@ -138,26 +128,4 @@ export class ShareComponent implements OnInit, OnDestroy { } return false; } - - private async checkFido2KeyExistsInOrg(cipher: CipherView, orgId: string): Promise { - if (cipher.type === CipherType.Fido2Key || cipher.login?.fido2Keys[0]) { - //Determine if Fido2Key object is disvoverable or non discoverable - const newFido2Key = cipher.login?.fido2Keys[0] || cipher.fido2Key; - - const ciphers = await this.cipherService.getAllDecrypted(); - const exisitingOrgCiphers = ciphers.filter((c) => c.organizationId === orgId); - - return exisitingOrgCiphers.some((c) => { - const existingFido2key = c.login?.fido2Keys[0] || c.fido2Key; - - return ( - !c.isDeleted && - existingFido2key.rpId === newFido2Key.rpId && - existingFido2key.userHandle === newFido2Key.userHandle - ); - }); - } - - return false; - } } From ceb26c04e21db81183bb7e021916a29e6746a2c8 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Fri, 15 Sep 2023 17:40:38 -0400 Subject: [PATCH 03/11] Removed launchable behaviours from fido2 key view --- libs/common/src/vault/models/view/fido2-key.view.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libs/common/src/vault/models/view/fido2-key.view.ts b/libs/common/src/vault/models/view/fido2-key.view.ts index 8af29af70d3d..802e91a6942e 100644 --- a/libs/common/src/vault/models/view/fido2-key.view.ts +++ b/libs/common/src/vault/models/view/fido2-key.view.ts @@ -19,14 +19,6 @@ export class Fido2KeyView extends ItemView { return this.userDisplayName; } - get canLaunch(): boolean { - return this.rpId != null; - } - - get launchUri(): string { - return this.canLaunch ? `https://${this.rpId}` : null; - } - static fromJSON(obj: Partial>): Fido2KeyView { return Object.assign(new Fido2KeyView(), obj); } From a062c3aa2af2f3ec46e6f50890bbf33551e9a0e1 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Fri, 15 Sep 2023 20:07:33 -0400 Subject: [PATCH 04/11] Reworked desktop views from standalone fido2keys to unified fido2keys in the login --- .../vault/app/vault/add-edit.component.html | 38 +------------ .../src/vault/app/vault/vault.component.ts | 10 +--- .../src/vault/app/vault/view.component.html | 54 +------------------ 3 files changed, 4 insertions(+), 98 deletions(-) diff --git a/apps/desktop/src/vault/app/vault/add-edit.component.html b/apps/desktop/src/vault/app/vault/add-edit.component.html index f5aeb1658fd5..9d5242b486e9 100644 --- a/apps/desktop/src/vault/app/vault/add-edit.component.html +++ b/apps/desktop/src/vault/app/vault/add-edit.component.html @@ -121,7 +121,7 @@

appBoxRow > {{ "typePasskey" | i18n }} - {{ "passkeyTwoStepLogin" | i18n }} + {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}

@@ -458,24 +458,6 @@

/>

- -
-
- - -
-
- {{ "typePasskey" | i18n }} - {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }} -
-
@@ -556,24 +538,6 @@

- -
-
-
- - -
-
- -
diff --git a/apps/desktop/src/vault/app/vault/vault.component.ts b/apps/desktop/src/vault/app/vault/vault.component.ts index 08a97a15a617..194cee098f7f 100644 --- a/apps/desktop/src/vault/app/vault/vault.component.ts +++ b/apps/desktop/src/vault/app/vault/vault.component.ts @@ -286,7 +286,7 @@ export class VaultComponent implements OnInit, OnDestroy { this.editCipher(cipher); }), }); - if (!cipher.organizationId && !cipher.fido2Key?.rpId) { + if (!cipher.organizationId) { menu.push({ label: this.i18nService.t("clone"), click: () => @@ -357,14 +357,6 @@ export class VaultComponent implements OnInit, OnDestroy { }); } break; - case CipherType.Fido2Key: - if (cipher.fido2Key.canLaunch) { - menu.push({ - label: this.i18nService.t("launch"), - click: () => this.platformUtilsService.launchUri(cipher.fido2Key.launchUri), - }); - } - break; default: break; } diff --git a/apps/desktop/src/vault/app/vault/view.component.html b/apps/desktop/src/vault/app/vault/view.component.html index ad953246aa03..d5cacae3cf5c 100644 --- a/apps/desktop/src/vault/app/vault/view.component.html +++ b/apps/desktop/src/vault/app/vault/view.component.html @@ -121,7 +121,7 @@

{{ "typePasskey" | i18n }} - {{ "passkeyTwoStepLogin" | i18n }} + {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}
{{ cipher.identity.country }}

- -
-
-
- {{ "username" | i18n }} - {{ cipher.fido2Key.userDisplayName }} -
-
-
- {{ "typePasskey" | i18n }} - {{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }} -
-
@@ -483,43 +470,6 @@

{{ cipher.notes }}

-
-
-
-
- - - - -
-
- - -
-
-
-
- - - - -
- -
- -
-
- - -
-
- -
- -
- - -
-
- {{ "passkeyEditInformation" | i18n }} -
-
-