1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-16 10:45:20 +01:00

[EC-598] chore: remove unused clas

This commit is contained in:
Andreas Coroiu 2023-04-12 15:19:06 +02:00
parent 6d969439ef
commit a3176ad704
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A

View File

@ -1,42 +0,0 @@
import { Fido2Utils } from "../abstractions/fido2-utils";
export class InvalidCredentialIdEncodingError extends Error {
constructor(readonly input: unknown) {
super("Could not create instance of credentialId: Input has unknown encoding");
}
}
export class CredentialId {
readonly raw: Uint8Array;
readonly encoded: string;
constructor(rawOrEncoded: BufferSource | Uint8Array | string) {
if (rawOrEncoded instanceof Uint8Array) {
this.raw = rawOrEncoded;
this.encoded = CredentialId.encode(this.raw);
} else if (typeof rawOrEncoded === "string") {
this.encoded = rawOrEncoded;
this.raw = CredentialId.decode(this.encoded);
} else if (rawOrEncoded instanceof window.ArrayBuffer) {
this.raw = new Uint8Array(rawOrEncoded);
this.encoded = CredentialId.encode(this.raw);
} else if (rawOrEncoded.buffer) {
this.raw = new Uint8Array(rawOrEncoded.buffer);
this.encoded = CredentialId.encode(this.raw);
} else {
throw new InvalidCredentialIdEncodingError(rawOrEncoded);
}
}
equals(other: CredentialId) {
return this.encoded === other.encoded;
}
private static encode(raw: Uint8Array): string {
return Fido2Utils.bufferToString(raw);
}
private static decode(encoded: string): Uint8Array {
return Fido2Utils.stringToBuffer(encoded);
}
}