1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

[EC-598] feat: improve error handling

This commit is contained in:
Andreas Coroiu
2022-12-16 15:23:39 +01:00
parent 555c132fe1
commit 9dd1a65b29
2 changed files with 28 additions and 5 deletions

View File

@@ -8,6 +8,8 @@ import {
CredentialRegistrationParams,
CredentialRegistrationResult,
Fido2Service as Fido2ServiceAbstraction,
NoCredentialFoundError,
OriginMismatchError,
} from "../../abstractions/fido2/fido2.service.abstraction";
import { Utils } from "../../misc/utils";
@@ -118,11 +120,11 @@ export class Fido2Service implements Fido2ServiceAbstraction {
}
if (credential === undefined) {
throw new Error("No valid credentials found");
throw new NoCredentialFoundError();
}
if (credential.origin !== params.origin) {
throw new Error("Not allowed: Origin mismatch");
throw new OriginMismatchError();
}
const encoder = new TextEncoder();