mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
Added more error log info into methods called on openVault from LastPass Direct importer
This commit is contained in:
parent
09ff12fc02
commit
dc83722c2f
@ -82,7 +82,15 @@ export class Client {
|
||||
if (!this.isComplete(chunks)) {
|
||||
throw new Error("Blob is truncated or corrupted");
|
||||
}
|
||||
return await this.parseAccounts(chunks, encryptionKey, privateKey, options);
|
||||
|
||||
try {
|
||||
return await this.parseAccounts(chunks, encryptionKey, privateKey, options);
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
"Error while parsing accounts: " +
|
||||
(error.message || "An error occurred without a specific message.");
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private async parseAccounts(
|
||||
|
@ -11,7 +11,14 @@ export class CryptoUtils {
|
||||
if (iterationCount == 1) {
|
||||
return await this.cryptoFunctionService.hash(username + password, "sha256");
|
||||
}
|
||||
return await this.cryptoFunctionService.pbkdf2(password, username, "sha256", iterationCount);
|
||||
try {
|
||||
return await this.cryptoFunctionService.pbkdf2(password, username, "sha256", iterationCount);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
"Error in derive key: " +
|
||||
(error.message || "An error occurred without a specific message."),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async deriveKeyHash(username: string, password: string, iterationCount: number) {
|
||||
|
@ -273,12 +273,20 @@ export class Parser {
|
||||
}
|
||||
|
||||
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {
|
||||
const decrypted = await this.cryptoUtils.decryptAes256(
|
||||
Utils.fromHexToArray(encryptedPrivateKey),
|
||||
encryptionKey,
|
||||
"cbc",
|
||||
encryptionKey.subarray(0, 16),
|
||||
);
|
||||
let decrypted: string;
|
||||
try {
|
||||
decrypted = await this.cryptoUtils.decryptAes256(
|
||||
Utils.fromHexToArray(encryptedPrivateKey),
|
||||
encryptionKey,
|
||||
"cbc",
|
||||
encryptionKey.subarray(0, 16),
|
||||
);
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
"Error decrypting AES key: " +
|
||||
(error.message || "An error occurred without a specific message.");
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
const header = "LastPassPrivateKey<";
|
||||
const footer = ">LastPassPrivateKey";
|
||||
@ -286,9 +294,16 @@ export class Parser {
|
||||
throw new Error("Failed to decrypt private key");
|
||||
}
|
||||
|
||||
const parsedKey = decrypted.substring(header.length, decrypted.length - footer.length);
|
||||
const pkcs8 = Utils.fromHexToArray(parsedKey);
|
||||
return pkcs8;
|
||||
try {
|
||||
const parsedKey = decrypted.substring(header.length, decrypted.length - footer.length);
|
||||
const pkcs8 = Utils.fromHexToArray(parsedKey);
|
||||
return pkcs8;
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
"Error decrypting key: " +
|
||||
(error.message || "An error occurred without a specific message.");
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
makeAccountPath(group: string, folder: SharedFolder): string {
|
||||
|
Loading…
Reference in New Issue
Block a user