diff --git a/libs/common/src/vault/abstractions/fido2/fido2-authenticator.service.abstraction.ts b/libs/common/src/vault/abstractions/fido2/fido2-authenticator.service.abstraction.ts index 5a406aeb14..671c6cb9fe 100644 --- a/libs/common/src/vault/abstractions/fido2/fido2-authenticator.service.abstraction.ts +++ b/libs/common/src/vault/abstractions/fido2/fido2-authenticator.service.abstraction.ts @@ -39,7 +39,7 @@ export enum Fido2AlgorithmIdentifier { RS256 = -257, } -export enum Fido2AutenticatorErrorCode { +export enum Fido2AuthenticatorErrorCode { Unknown = "UnknownError", NotSupported = "NotSupportedError", InvalidState = "InvalidStateError", @@ -47,8 +47,8 @@ export enum Fido2AutenticatorErrorCode { Constraint = "ConstraintError", } -export class Fido2AutenticatorError extends Error { - constructor(readonly errorCode: Fido2AutenticatorErrorCode) { +export class Fido2AuthenticatorError extends Error { + constructor(readonly errorCode: Fido2AuthenticatorErrorCode) { super(errorCode); } } diff --git a/libs/common/src/vault/services/fido2/fido2-authenticator.service.spec.ts b/libs/common/src/vault/services/fido2/fido2-authenticator.service.spec.ts index c519fccffc..ecf6f03d7e 100644 --- a/libs/common/src/vault/services/fido2/fido2-authenticator.service.spec.ts +++ b/libs/common/src/vault/services/fido2/fido2-authenticator.service.spec.ts @@ -5,7 +5,7 @@ import { mock, MockProxy } from "jest-mock-extended"; import { Utils } from "../../../platform/misc/utils"; import { CipherService } from "../../abstractions/cipher.service"; import { - Fido2AutenticatorErrorCode, + Fido2AuthenticatorErrorCode, Fido2AuthenticatorGetAssertionParams, Fido2AuthenticatorMakeCredentialsParams, } from "../../abstractions/fido2/fido2-authenticator.service.abstraction"; @@ -60,19 +60,19 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(invalidParams.unsupportedAlgorithm, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotSupported); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotSupported); }); it("should throw error when requireResidentKey has invalid value", async () => { const result = async () => await authenticator.makeCredential(invalidParams.invalidRk, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); it("should throw error when requireUserVerification has invalid value", async () => { const result = async () => await authenticator.makeCredential(invalidParams.invalidUv, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); /** @@ -85,7 +85,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Constraint); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Constraint); }); it("should not request confirmation from user", async () => { @@ -151,7 +151,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotAllowed); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotAllowed); }); /** Devation: Organization ciphers are not checked against excluded credentials, even if the user has access to them. */ @@ -267,7 +267,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotAllowed); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotAllowed); }); it("should throw error if user verification fails and cipher requires reprompt", async () => { @@ -281,7 +281,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); /** Spec: If any error occurred while creating the new credential object, return an error code equivalent to "UnknownError" and terminate the operation. */ @@ -296,7 +296,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.makeCredential(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); }); @@ -434,7 +434,7 @@ describe("FidoAuthenticatorService", () => { it("should throw error when requireUserVerification has invalid value", async () => { const result = async () => await authenticator.getAssertion(invalidParams.invalidUv, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); /** @@ -447,7 +447,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.getAssertion(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Constraint); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Constraint); }); }); @@ -512,7 +512,7 @@ describe("FidoAuthenticatorService", () => { it("should throw error", async () => { const result = async () => await authenticator.getAssertion(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotAllowed); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotAllowed); }); }); @@ -600,7 +600,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.getAssertion(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotAllowed); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotAllowed); }); it("should throw error if user verification fails and cipher requires reprompt", async () => { @@ -612,7 +612,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.getAssertion(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.NotAllowed); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotAllowed); }); }); @@ -737,7 +737,7 @@ describe("FidoAuthenticatorService", () => { const result = async () => await authenticator.getAssertion(params, tab); - await expect(result).rejects.toThrowError(Fido2AutenticatorErrorCode.Unknown); + await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.Unknown); }); }); diff --git a/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts b/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts index e009d8b18c..bef5616ca7 100644 --- a/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts +++ b/libs/common/src/vault/services/fido2/fido2-authenticator.service.ts @@ -3,8 +3,8 @@ import { Utils } from "../../../platform/misc/utils"; import { CipherService } from "../../abstractions/cipher.service"; import { Fido2AlgorithmIdentifier, - Fido2AutenticatorError, - Fido2AutenticatorErrorCode, + Fido2AuthenticatorError, + Fido2AuthenticatorErrorCode, Fido2AuthenticatorGetAssertionParams, Fido2AuthenticatorGetAssertionResult, Fido2AuthenticatorMakeCredentialResult, @@ -62,7 +62,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.warning( `[Fido2Authenticator] No compatible algorithms found, RP requested: ${requestedAlgorithms}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotSupported); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotSupported); } if ( @@ -74,7 +74,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr params.requireResidentKey )}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } if ( @@ -86,7 +86,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr params.requireUserVerification )}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } await userInterfaceSession.ensureUnlockedVault(); @@ -100,7 +100,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr `[Fido2Authenticator] Aborting due to excluded credential found in vault.` ); await userInterfaceSession.informExcludedCredential(existingCipherIds); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } let cipher: CipherView; @@ -120,7 +120,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.warning( `[Fido2Authenticator] Aborting because user confirmation was not recieved.` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } try { @@ -138,7 +138,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.warning( `[Fido2Authenticator] Aborting because user verification was unsuccessful.` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } fido2Credential = await createKeyView(params, keyPair.privateKey); @@ -150,7 +150,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.error( `[Fido2Authenticator] Aborting because of unknown error when creating credential: ${error}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } const authData = await generateAuthData({ @@ -200,7 +200,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr params.requireUserVerification )}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } let cipherOptions: CipherView[]; @@ -222,7 +222,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr `[Fido2Authenticator] Aborting because no matching credentials were found in the vault.` ); await userInterfaceSession.informCredentialNotFound(); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } const response = await userInterfaceSession.pickCredential({ @@ -237,7 +237,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.error( `[Fido2Authenticator] Aborting because the selected credential could not be found.` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } if ( @@ -247,7 +247,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.warning( `[Fido2Authenticator] Aborting because user verification was unsuccessful.` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.NotAllowed); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.NotAllowed); } try { @@ -289,7 +289,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr this.logService?.error( `[Fido2Authenticator] Aborting because of unknown error when asserting credential: ${error}` ); - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } } finally { userInterfaceSession.close(); @@ -383,7 +383,7 @@ async function createKeyView( keyValue: CryptoKey ): Promise { if (keyValue.algorithm.name !== "ECDSA" && (keyValue.algorithm as any).namedCurve !== "P-256") { - throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown); + throw new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.Unknown); } const pkcs8Key = await crypto.subtle.exportKey("pkcs8", keyValue); diff --git a/libs/common/src/vault/services/fido2/fido2-client.service.spec.ts b/libs/common/src/vault/services/fido2/fido2-client.service.spec.ts index a8b2a071c1..3bab5da102 100644 --- a/libs/common/src/vault/services/fido2/fido2-client.service.spec.ts +++ b/libs/common/src/vault/services/fido2/fido2-client.service.spec.ts @@ -5,8 +5,8 @@ import { AuthenticationStatus } from "../../../auth/enums/authentication-status" import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction"; import { Utils } from "../../../platform/misc/utils"; import { - Fido2AutenticatorError, - Fido2AutenticatorErrorCode, + Fido2AuthenticatorError, + Fido2AuthenticatorErrorCode, Fido2AuthenticatorGetAssertionResult, Fido2AuthenticatorMakeCredentialResult, } from "../../abstractions/fido2/fido2-authenticator.service.abstraction"; @@ -181,7 +181,7 @@ describe("FidoAuthenticatorService", () => { it("should throw error if authenticator throws InvalidState", async () => { const params = createParams(); authenticator.makeCredential.mockRejectedValue( - new Fido2AutenticatorError(Fido2AutenticatorErrorCode.InvalidState) + new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.InvalidState) ); const result = async () => await client.createCredential(params, tab); @@ -329,7 +329,7 @@ describe("FidoAuthenticatorService", () => { it("should throw error if authenticator throws InvalidState", async () => { const params = createParams(); authenticator.getAssertion.mockRejectedValue( - new Fido2AutenticatorError(Fido2AutenticatorErrorCode.InvalidState) + new Fido2AuthenticatorError(Fido2AuthenticatorErrorCode.InvalidState) ); const result = async () => await client.assertCredential(params, tab); diff --git a/libs/common/src/vault/services/fido2/fido2-client.service.ts b/libs/common/src/vault/services/fido2/fido2-client.service.ts index 16049fd08a..4c7eaf00a7 100644 --- a/libs/common/src/vault/services/fido2/fido2-client.service.ts +++ b/libs/common/src/vault/services/fido2/fido2-client.service.ts @@ -7,8 +7,8 @@ import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/ import { LogService } from "../../../platform/abstractions/log.service"; import { Utils } from "../../../platform/misc/utils"; import { - Fido2AutenticatorError, - Fido2AutenticatorErrorCode, + Fido2AuthenticatorError, + Fido2AuthenticatorErrorCode, Fido2AuthenticatorGetAssertionParams, Fido2AuthenticatorMakeCredentialsParams, Fido2AuthenticatorService, @@ -162,8 +162,8 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction { } if ( - error instanceof Fido2AutenticatorError && - error.errorCode === Fido2AutenticatorErrorCode.InvalidState + error instanceof Fido2AuthenticatorError && + error.errorCode === Fido2AuthenticatorErrorCode.InvalidState ) { this.logService?.warning(`[Fido2Client] Unknown error: ${error}`); throw new DOMException("Unknown error occured.", "InvalidStateError"); @@ -268,8 +268,8 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction { } if ( - error instanceof Fido2AutenticatorError && - error.errorCode === Fido2AutenticatorErrorCode.InvalidState + error instanceof Fido2AuthenticatorError && + error.errorCode === Fido2AuthenticatorErrorCode.InvalidState ) { this.logService?.warning(`[Fido2Client] Unknown error: ${error}`); throw new DOMException("Unknown error occured.", "InvalidStateError");