mirror of
https://github.com/bitwarden/browser
synced 2026-02-22 04:14:04 +00:00
add decryption errors from sdk
This commit is contained in:
@@ -85,7 +85,10 @@ export class AttachmentView implements View {
|
||||
/**
|
||||
* Converts the SDK AttachmentView to a AttachmentView.
|
||||
*/
|
||||
static fromSdkAttachmentView(obj: SdkAttachmentView): AttachmentView | undefined {
|
||||
static fromSdkAttachmentView(
|
||||
obj: SdkAttachmentView,
|
||||
failure = false,
|
||||
): AttachmentView | undefined {
|
||||
if (!obj) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -99,7 +102,7 @@ export class AttachmentView implements View {
|
||||
// TODO: PM-23005 - Temporary field, should be removed when encrypted migration is complete
|
||||
view.key = obj.decryptedKey ? SymmetricCryptoKey.fromString(obj.decryptedKey) : undefined;
|
||||
view.encryptedKey = obj.key ? new EncString(obj.key) : undefined;
|
||||
view._hasDecryptionError = obj.decryptionFailure;
|
||||
view._hasDecryptionError = failure;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -275,6 +275,14 @@ export class CipherView implements View, InitializerMetadata {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)) ?? [];
|
||||
|
||||
if (obj.attachmentDecryptionFailures?.length) {
|
||||
obj.attachmentDecryptionFailures.forEach((attachment) => {
|
||||
attachments.push(AttachmentView.fromSdkAttachmentView(attachment, true)!);
|
||||
});
|
||||
}
|
||||
|
||||
const cipherView = new CipherView();
|
||||
cipherView.id = uuidAsString(obj.id);
|
||||
cipherView.organizationId = uuidAsString(obj.organizationId);
|
||||
@@ -290,8 +298,7 @@ export class CipherView implements View, InitializerMetadata {
|
||||
cipherView.edit = obj.edit;
|
||||
cipherView.viewPassword = obj.viewPassword;
|
||||
cipherView.localData = fromSdkLocalData(obj.localData);
|
||||
cipherView.attachments =
|
||||
obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)!) ?? [];
|
||||
cipherView.attachments = attachments;
|
||||
cipherView.fields = obj.fields?.map((f) => FieldView.fromSdkFieldView(f)!) ?? [];
|
||||
cipherView.passwordHistory =
|
||||
obj.passwordHistory?.map((ph) => PasswordHistoryView.fromSdkPasswordHistoryView(ph)!) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user