mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
Add info on the item failing the parse when importing from LastPass (#9068)
* Added more error log info into methods called on openVault from LastPass Direct importer
* Adding error messages to help identify errors on the ParseAccounts and ParseShar methods from the lastpass importer parser.ts
* removed unintended throw
* Revert "Added more error log info into methods called on openVault from LastPass Direct importer"
This reverts commit dc83722c2f.
* Cleaned up error messages on LastPass's parser.ts
* throwing the error message if it exists on the Error object
* Using const on name instead let on parseShar
This commit is contained in:
@@ -32,12 +32,14 @@ export class Parser {
|
|||||||
folder: SharedFolder,
|
folder: SharedFolder,
|
||||||
options: ParserOptions,
|
options: ParserOptions,
|
||||||
): Promise<Account> {
|
): Promise<Account> {
|
||||||
|
let id: string;
|
||||||
|
try {
|
||||||
const placeholder = "decryption failed";
|
const placeholder = "decryption failed";
|
||||||
const reader = new BinaryReader(chunk.payload);
|
const reader = new BinaryReader(chunk.payload);
|
||||||
|
|
||||||
// Read all items
|
// Read all items
|
||||||
// 0: id
|
// 0: id
|
||||||
const id = Utils.fromBufferToUtf8(this.readItem(reader));
|
id = Utils.fromBufferToUtf8(this.readItem(reader));
|
||||||
|
|
||||||
// 1: name
|
// 1: name
|
||||||
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
@@ -239,6 +241,11 @@ export class Parser {
|
|||||||
account.isFavorite = isFavorite;
|
account.isFavorite = isFavorite;
|
||||||
account.isShared = folder != null;
|
account.isShared = folder != null;
|
||||||
return account;
|
return account;
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
"Error parsing accounts on item with ID:" + id + " errorMessage: " + err.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseShar(
|
async parseShar(
|
||||||
@@ -246,10 +253,12 @@ export class Parser {
|
|||||||
encryptionKey: Uint8Array,
|
encryptionKey: Uint8Array,
|
||||||
rsaKey: Uint8Array,
|
rsaKey: Uint8Array,
|
||||||
): Promise<SharedFolder> {
|
): Promise<SharedFolder> {
|
||||||
|
let id: string;
|
||||||
|
try {
|
||||||
const reader = new BinaryReader(chunk.payload);
|
const reader = new BinaryReader(chunk.payload);
|
||||||
|
|
||||||
// Id
|
// Id
|
||||||
const id = Utils.fromBufferToUtf8(this.readItem(reader));
|
id = Utils.fromBufferToUtf8(this.readItem(reader));
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
const folderKey = this.readItem(reader);
|
const folderKey = this.readItem(reader);
|
||||||
@@ -270,6 +279,11 @@ export class Parser {
|
|||||||
folder.name = name;
|
folder.name = name;
|
||||||
folder.encryptionKey = key;
|
folder.encryptionKey = key;
|
||||||
return folder;
|
return folder;
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
"Error parsing shared folder with ID:" + id + " errorMessage: " + err.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {
|
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {
|
||||||
|
|||||||
Reference in New Issue
Block a user