mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
Fix failing crypto tests (#5948)
* Change everything to Uint8Array related to https://github.com/jestjs/jest/issues/14379 * Work on failing type tests * Revert changes to custom matcher setup * Remove last BufferArrays from tests * Fix custom matcher type errors in vscode * Remove errant `.buffer` calls on Uint8Arrays * Encryption Pair should serialize Array Buffer and Uint8Array * Fix EncArrayBuffer encryption --------- Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
This commit is contained in:
@@ -51,7 +51,7 @@ export class ConfirmCommand {
|
||||
}
|
||||
const publicKeyResponse = await this.apiService.getUserPublicKey(orgUser.userId);
|
||||
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
||||
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
|
||||
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey);
|
||||
const req = new OrganizationUserConfirmRequest();
|
||||
req.key = key.encryptedString;
|
||||
await this.organizationUserService.postOrganizationUserConfirm(
|
||||
|
||||
@@ -513,7 +513,7 @@ export class GetCommand extends DownloadCommand {
|
||||
try {
|
||||
const response = await this.apiService.getUserPublicKey(id);
|
||||
const pubKey = Utils.fromB64ToArray(response.publicKey);
|
||||
fingerprint = await this.cryptoService.getFingerprint(id, pubKey.buffer);
|
||||
fingerprint = await this.cryptoService.getFingerprint(id, pubKey);
|
||||
} catch {
|
||||
// eslint-disable-next-line
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
throw new Error("No session key available.");
|
||||
}
|
||||
const encValue = await this.cryptoService().encryptToBytes(
|
||||
Utils.fromB64ToArray(plainValue).buffer,
|
||||
Utils.fromB64ToArray(plainValue),
|
||||
sessionKey
|
||||
);
|
||||
if (encValue == null) {
|
||||
@@ -81,7 +81,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
private getSessionKey() {
|
||||
try {
|
||||
if (process.env.BW_SESSION != null) {
|
||||
const sessionBuffer = Utils.fromB64ToArray(process.env.BW_SESSION).buffer;
|
||||
const sessionBuffer = Utils.fromB64ToArray(process.env.BW_SESSION);
|
||||
if (sessionBuffer != null) {
|
||||
const sessionKey = new SymmetricCryptoKey(sessionBuffer);
|
||||
if (sessionBuffer != null) {
|
||||
|
||||
@@ -121,7 +121,7 @@ export class SendReceiveCommand extends DownloadCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private async getUnlockedPassword(password: string, keyArray: ArrayBuffer) {
|
||||
private async getUnlockedPassword(password: string, keyArray: Uint8Array) {
|
||||
const passwordHash = await this.cryptoFunctionService.pbkdf2(
|
||||
password,
|
||||
keyArray,
|
||||
@@ -134,7 +134,7 @@ export class SendReceiveCommand extends DownloadCommand {
|
||||
private async sendRequest(
|
||||
url: string,
|
||||
id: string,
|
||||
key: ArrayBuffer
|
||||
key: Uint8Array
|
||||
): Promise<Response | SendAccessView> {
|
||||
try {
|
||||
const sendResponse = await this.sendApiService.postSendAccess(
|
||||
|
||||
Reference in New Issue
Block a user