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:
aj-rosado 2024-05-20 11:46:20 +01:00 committed by GitHub
parent adf7a38f87
commit 4e1173d5cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 233 additions and 219 deletions

View File

@ -32,12 +32,14 @@ export class Parser {
folder: SharedFolder,
options: ParserOptions,
): Promise<Account> {
let id: string;
try {
const placeholder = "decryption failed";
const reader = new BinaryReader(chunk.payload);
// Read all items
// 0: id
const id = Utils.fromBufferToUtf8(this.readItem(reader));
id = Utils.fromBufferToUtf8(this.readItem(reader));
// 1: name
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
@ -239,6 +241,11 @@ export class Parser {
account.isFavorite = isFavorite;
account.isShared = folder != null;
return account;
} catch (err) {
throw new Error(
"Error parsing accounts on item with ID:" + id + " errorMessage: " + err.message,
);
}
}
async parseShar(
@ -246,10 +253,12 @@ export class Parser {
encryptionKey: Uint8Array,
rsaKey: Uint8Array,
): Promise<SharedFolder> {
let id: string;
try {
const reader = new BinaryReader(chunk.payload);
// Id
const id = Utils.fromBufferToUtf8(this.readItem(reader));
id = Utils.fromBufferToUtf8(this.readItem(reader));
// Key
const folderKey = this.readItem(reader);
@ -270,6 +279,11 @@ export class Parser {
folder.name = name;
folder.encryptionKey = key;
return folder;
} catch (err) {
throw new Error(
"Error parsing shared folder with ID:" + id + " errorMessage: " + err.message,
);
}
}
async parseEncryptedPrivateKey(encryptedPrivateKey: string, encryptionKey: Uint8Array) {