1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-6400] Move core FIDO2 code from vault to platform ownership (#8044)

* [PM-6400] Move core FIDO2 code from vault to platform ownership

- lib/common/vault/abstractions/fido2 -> lib/common/platform/abstractions/fido2
- lib/common/vault/services/fido2 -> lib/common/platform/services/fido2

* [PM-6400] fix: wrong imports
This commit is contained in:
Andreas Coroiu
2024-05-14 16:08:41 +02:00
committed by GitHub
parent 79a0b0d46d
commit 7f91e84456
28 changed files with 46 additions and 46 deletions

View File

@@ -0,0 +1,40 @@
import { Fido2Utils } from "./fido2-utils";
describe("Fido2 Utils", () => {
const asciiHelloWorldArray = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100];
const b64HelloWorldString = "aGVsbG8gd29ybGQ=";
describe("fromBufferToB64(...)", () => {
it("should convert an ArrayBuffer to a b64 string", () => {
const buffer = new Uint8Array(asciiHelloWorldArray).buffer;
const b64String = Fido2Utils.fromBufferToB64(buffer);
expect(b64String).toBe(b64HelloWorldString);
});
it("should return an empty string when given an empty ArrayBuffer", () => {
const buffer = new Uint8Array([]).buffer;
const b64String = Fido2Utils.fromBufferToB64(buffer);
expect(b64String).toBe("");
});
it("should return null when given null input", () => {
const b64String = Fido2Utils.fromBufferToB64(null);
expect(b64String).toBeNull();
});
});
describe("fromB64ToArray(...)", () => {
it("should convert a b64 string to an Uint8Array", () => {
const expectedArray = new Uint8Array(asciiHelloWorldArray);
const resultArray = Fido2Utils.fromB64ToArray(b64HelloWorldString);
expect(resultArray).toEqual(expectedArray);
});
it("should return null when given null input", () => {
const expectedArray = Fido2Utils.fromB64ToArray(null);
expect(expectedArray).toBeNull();
});
});
});