1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 07:13:32 +00:00

[PM-13779] Add vNext CollectionService without ActiveUserState (#11705)

- add tests
- install jest-extended for additional matchers
- allow for generation of different crypto keys in tests
This commit is contained in:
Thomas Rittson
2024-10-28 10:13:32 +10:00
committed by GitHub
parent e83dca529b
commit d0ed9aaa5d
8 changed files with 636 additions and 2 deletions

View File

@@ -46,8 +46,15 @@ export function makeStaticByteArray(length: number, start = 0) {
return arr;
}
export function makeSymmetricCryptoKey<T extends SymmetricCryptoKey>(length: 32 | 64 = 64) {
return new SymmetricCryptoKey(makeStaticByteArray(length)) as T;
/**
* Creates a symmetric crypto key for use in tests. This is deterministic, i.e. it will produce identical keys
* for identical argument values. Provide a unique value to the `seed` parameter to create different keys.
*/
export function makeSymmetricCryptoKey<T extends SymmetricCryptoKey>(
length: 32 | 64 = 64,
seed = 0,
) {
return new SymmetricCryptoKey(makeStaticByteArray(length, seed)) as T;
}
/**