mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +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)) {
|
if (!this.isComplete(chunks)) {
|
||||||
throw new Error("Blob is truncated or corrupted");
|
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(
|
private async parseAccounts(
|
||||||
|
@ -11,7 +11,14 @@ export class CryptoUtils {
|
|||||||
if (iterationCount == 1) {
|
if (iterationCount == 1) {
|
||||||
return await this.cryptoFunctionService.hash(username + password, "sha256");
|
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) {
|
async deriveKeyHash(username: string, password: string, iterationCount: number) {
|
||||||
|
@ -273,12 +273,20 @@ export class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {
|
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {
|
||||||
const decrypted = await this.cryptoUtils.decryptAes256(
|
let decrypted: string;
|
||||||
Utils.fromHexToArray(encryptedPrivateKey),
|
try {
|
||||||
encryptionKey,
|
decrypted = await this.cryptoUtils.decryptAes256(
|
||||||
"cbc",
|
Utils.fromHexToArray(encryptedPrivateKey),
|
||||||
encryptionKey.subarray(0, 16),
|
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 header = "LastPassPrivateKey<";
|
||||||
const footer = ">LastPassPrivateKey";
|
const footer = ">LastPassPrivateKey";
|
||||||
@ -286,9 +294,16 @@ export class Parser {
|
|||||||
throw new Error("Failed to decrypt private key");
|
throw new Error("Failed to decrypt private key");
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedKey = decrypted.substring(header.length, decrypted.length - footer.length);
|
try {
|
||||||
const pkcs8 = Utils.fromHexToArray(parsedKey);
|
const parsedKey = decrypted.substring(header.length, decrypted.length - footer.length);
|
||||||
return pkcs8;
|
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 {
|
makeAccountPath(group: string, folder: SharedFolder): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user