1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 19:53:59 +00:00

[PM-3810] Unify Passkeys view (#6335)

* 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

* Allow duplication

* Removed launchable behaviours from fido2 key view

* Reworked desktop views from standalone fido2keys to unified fido2keys in the login

* Reworked web views from standalone fido2keys to unified fido2keys in the login

* Fixed test case to not create standalone fido2keys

* Updated views to use fido2key creation date

* removed unused locale

* moved logic from template to class

* Removed fido2key ciphertype

* Removed fido2key ciphertype references
This commit is contained in:
SmithThe4th
2023-09-26 16:13:33 -04:00
committed by GitHub
parent 6fbc0c29f9
commit 9778cd73df
30 changed files with 64 additions and 516 deletions

View File

@@ -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<boolean> {
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;
}
}

View File

@@ -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;

View File

@@ -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);
});
});
});
});

View File

@@ -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;