From 685597f487fecce7a92778ed536e769a750f6115 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Wed, 9 Apr 2025 17:48:19 -0400 Subject: [PATCH] Manually set fields --- .../src/vault/models/view/cipher.view.spec.ts | 8 ++--- .../src/vault/models/view/cipher.view.ts | 35 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/libs/common/src/vault/models/view/cipher.view.spec.ts b/libs/common/src/vault/models/view/cipher.view.spec.ts index 785e481b636..38e3d7827d6 100644 --- a/libs/common/src/vault/models/view/cipher.view.spec.ts +++ b/libs/common/src/vault/models/view/cipher.view.spec.ts @@ -183,10 +183,10 @@ describe("CipherView", () => { autofillOnPageLoad: true, __fromSdk: true, }, - identity: undefined, - card: undefined, - secureNote: undefined, - sshKey: undefined, + identity: new IdentityView(), + card: new CardView(), + secureNote: new SecureNoteView(), + sshKey: new SshKeyView(), fields: [ { name: "fieldName", diff --git a/libs/common/src/vault/models/view/cipher.view.ts b/libs/common/src/vault/models/view/cipher.view.ts index 44ce11fe115..dc447551bff 100644 --- a/libs/common/src/vault/models/view/cipher.view.ts +++ b/libs/common/src/vault/models/view/cipher.view.ts @@ -234,23 +234,28 @@ export class CipherView implements View, InitializerMetadata { } const cipherView = new CipherView(); - const attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)); - const fields = obj.fields?.map((f) => FieldView.fromSdkFieldView(f)); - const passwordHistory = obj.passwordHistory?.map((ph) => + cipherView.id = obj.id; + cipherView.organizationId = obj.organizationId; + cipherView.folderId = obj.folderId; + cipherView.name = obj.name; + cipherView.notes = obj.notes; + cipherView.type = obj.type; + cipherView.favorite = obj.favorite; + cipherView.organizationUseTotp = obj.organizationUseTotp; + cipherView.permissions = CipherPermissionsApi.fromSdkCipherPermissions(obj.permissions); + cipherView.edit = obj.edit; + cipherView.viewPassword = obj.viewPassword; + cipherView.localData = obj.localData; + cipherView.attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)); + cipherView.fields = obj.fields?.map((f) => FieldView.fromSdkFieldView(f)); + cipherView.passwordHistory = obj.passwordHistory?.map((ph) => PasswordHistoryView.fromSdkPasswordHistoryView(ph), ); - const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate); - const creationDate = obj.creationDate == null ? null : new Date(obj.creationDate); - const deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate); - - Object.assign(cipherView, obj, { - revisionDate: revisionDate, - creationDate: creationDate, - deletedDate: deletedDate, - attachments: attachments, - fields: fields, - passwordHistory: passwordHistory, - }); + cipherView.collectionIds = obj.collectionIds; + cipherView.revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate); + cipherView.creationDate = obj.creationDate == null ? null : new Date(obj.creationDate); + cipherView.deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate); + cipherView.reprompt = obj.reprompt ?? CipherRepromptType.None; switch (obj.type) { case CipherType.Card: