diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 48d69ace9d2..cad4ff91c35 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -2503,8 +2503,8 @@ "choosePasskey": { "message": "Choose a login to save this passkey to" }, - "fido2Item": { - "message": "Fido2 Item" + "passkeyItem": { + "message": "Passkey Item" }, "overwritePasskey": { "message": "Overwrite passkey?" diff --git a/apps/browser/src/auth/guards/fido2-auth.guard.ts b/apps/browser/src/auth/guards/fido2-auth.guard.ts index dfe70c6f0b3..7ff0060663d 100644 --- a/apps/browser/src/auth/guards/fido2-auth.guard.ts +++ b/apps/browser/src/auth/guards/fido2-auth.guard.ts @@ -11,6 +11,10 @@ import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authenticatio import { BrowserRouterService } from "../../platform/popup/services/browser-router.service"; +/** + * This guard verifies the user's authetication status. + * If "Locked", it saves the intended route in memory and redirects to the lock screen. Otherwise, the intended route is allowed. + */ export const fido2AuthGuard: CanActivateFn = async ( route: ActivatedRouteSnapshot, state: RouterStateSnapshot diff --git a/apps/browser/src/platform/browser/browser-api.ts b/apps/browser/src/platform/browser/browser-api.ts index a09c63e18ab..13081765c3f 100644 --- a/apps/browser/src/platform/browser/browser-api.ts +++ b/apps/browser/src/platform/browser/browser-api.ts @@ -274,7 +274,16 @@ export class BrowserApi { BrowserApi.messageListener("message", handler); - return () => chrome.runtime.onMessage.removeListener(handler); + return () => { + chrome.runtime.onMessage.removeListener(handler); + + if (BrowserApi.isSafariApi) { + const index = BrowserApi.registeredMessageListeners.indexOf(handler); + if (index !== -1) { + BrowserApi.registeredMessageListeners.splice(index, 1); + } + } + }; }); } diff --git a/apps/browser/src/popup/services/popup-utils.service.ts b/apps/browser/src/popup/services/popup-utils.service.ts index 9d424586b20..b5a5a058171 100644 --- a/apps/browser/src/popup/services/popup-utils.service.ts +++ b/apps/browser/src/popup/services/popup-utils.service.ts @@ -64,7 +64,7 @@ export class PopupUtilsService { href = win.location.href; } - if (chrome?.windows?.create != null) { + if (typeof chrome !== "undefined" && chrome?.windows?.create != null) { if (href.indexOf("?uilocation=") > -1) { href = href .replace("uilocation=popup", "uilocation=popout") diff --git a/apps/browser/src/vault/popup/components/fido2/fido2-use-browser-link.component.html b/apps/browser/src/vault/popup/components/fido2/fido2-use-browser-link.component.html index 886ec3247d9..3e71675aa2c 100644 --- a/apps/browser/src/vault/popup/components/fido2/fido2-use-browser-link.component.html +++ b/apps/browser/src/vault/popup/components/fido2/fido2-use-browser-link.component.html @@ -1,5 +1,5 @@ diff --git a/apps/browser/src/vault/popup/components/fido2/fido2.component.html b/apps/browser/src/vault/popup/components/fido2/fido2.component.html index 5ce39c89c9c..0f298b67fb6 100644 --- a/apps/browser/src/vault/popup/components/fido2/fido2.component.html +++ b/apps/browser/src/vault/popup/components/fido2/fido2.component.html @@ -53,7 +53,7 @@ *ngFor="let cipherItem of displayedCiphers" [cipher]="cipherItem" [isSearching]="searchPending" - title="{{ 'fido2Item' | i18n }}" + title="{{ 'passkeyItem' | i18n }}" (onSelected)="selectedPasskey($event)" [isSelected]="cipher === cipherItem" > @@ -108,7 +108,7 @@ @@ -131,9 +131,9 @@ diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index b829a0234be..52fdbf1b560 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -2419,12 +2419,6 @@ "typePasskey": { "message": "Passkey" }, - "application": { - "message": "Application" - }, - "duplicatePasskey": { - "message": "A passkey with this ID already exists in this organization." - }, "passkeyNotCopied": { "message": "Passkey will not be copied" }, diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 64ba1a224d9..e2942b49774 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -7269,12 +7269,6 @@ "typePasskey": { "message": "Passkey" }, - "application": { - "message": "Application" - }, - "duplicatePasskey": { - "message": "A passkey with this ID already exists in this organization." - }, "passkeyNotCopied": { "message": "Passkey will not be copied" }, diff --git a/libs/common/src/models/export/fido2-credential.export.ts b/libs/common/src/models/export/fido2-credential.export.ts index 67f7b7b4408..258699c8daf 100644 --- a/libs/common/src/models/export/fido2-credential.export.ts +++ b/libs/common/src/models/export/fido2-credential.export.ts @@ -2,7 +2,14 @@ import { EncString } from "../../platform/models/domain/enc-string"; import { Fido2Credential } from "../../vault/models/domain/fido2-credential"; import { Fido2CredentialView } from "../../vault/models/view/fido2-credential.view"; +/** + * Represents format of Fido2 Credentials in JSON exports. + */ export class Fido2CredentialExport { + /** + * Generates a template for Fido2CredentialExport + * @returns Instance of Fido2CredentialExport with predefined values. + */ static template(): Fido2CredentialExport { const req = new Fido2CredentialExport(); req.credentialId = "keyId"; @@ -20,6 +27,12 @@ export class Fido2CredentialExport { return req; } + /** + * Converts a Fido2CredentialExport object to its view representation. + * @param req - The Fido2CredentialExport object to be converted. + * @param view - (Optional) The Fido2CredentialView object to popualte with Fido2CredentialExport data + * @returns Fido2CredentialView - The populated view, or a new instance if none was provided. + */ static toView(req: Fido2CredentialExport, view = new Fido2CredentialView()) { view.credentialId = req.credentialId; view.keyType = req.keyType as "public-key"; @@ -36,6 +49,12 @@ export class Fido2CredentialExport { return view; } + /** + * Converts a Fido2CredentialExport object to its domain representation. + * @param req - The Fido2CredentialExport object to be converted. + * @param domain - (Optional) The Fido2Credential object to popualte with Fido2CredentialExport data + * @returns Fido2Credential - The populated domain, or a new instance if none was provided. + */ static toDomain(req: Fido2CredentialExport, domain = new Fido2Credential()) { domain.credentialId = req.credentialId != null ? new EncString(req.credentialId) : null; domain.keyType = req.keyType != null ? new EncString(req.keyType) : null; @@ -66,6 +85,11 @@ export class Fido2CredentialExport { discoverable: string; creationDate: Date; + /** + * Constructs a new Fid2CredentialExport instance. + * + * @param o - The credential storing the data being exported. When not provided, an empty export is created instead. + */ constructor(o?: Fido2CredentialView | Fido2Credential) { if (o == null) { return; diff --git a/libs/common/src/models/export/login.export.ts b/libs/common/src/models/export/login.export.ts index c64d30b5b67..a5d9348c2ca 100644 --- a/libs/common/src/models/export/login.export.ts +++ b/libs/common/src/models/export/login.export.ts @@ -36,7 +36,8 @@ export class LoginExport { domain.username = req.username != null ? new EncString(req.username) : null; domain.password = req.password != null ? new EncString(req.password) : null; domain.totp = req.totp != null ? new EncString(req.totp) : null; - //left out fido2Credential for now + // Fido2credentials are currently not supported for exports. + return domain; }