diff --git a/libs/common/src/vault/models/domain/cipher.spec.ts b/libs/common/src/vault/models/domain/cipher.spec.ts index c4e1832ae38..f97ef8b31ac 100644 --- a/libs/common/src/vault/models/domain/cipher.spec.ts +++ b/libs/common/src/vault/models/domain/cipher.spec.ts @@ -770,6 +770,9 @@ describe("Cipher DTO", () => { describe("toSdkCipher", () => { it("should map to SDK Cipher", () => { + const lastUsedDate = new Date("2025-04-15T12:00:00.000Z").getTime(); + const lastLaunched = new Date("2025-04-15T12:00:00.000Z").getTime(); + const cipherData: CipherData = { id: "id", organizationId: "orgId", @@ -838,7 +841,7 @@ describe("Cipher DTO", () => { ], }; - const cipher = new Cipher(cipherData); + const cipher = new Cipher(cipherData, { lastUsedDate, lastLaunched }); const sdkCipher = cipher.toSdkCipher(); expect(sdkCipher).toEqual({ @@ -875,7 +878,10 @@ describe("Cipher DTO", () => { edit: true, permissions: new CipherPermissionsApi(), viewPassword: true, - localData: undefined, + localData: { + lastUsedDate: "2025-04-15T12:00:00.000Z", + lastLaunched: "2025-04-15T12:00:00.000Z", + }, attachments: [ { id: "a1", diff --git a/libs/common/src/vault/models/domain/cipher.ts b/libs/common/src/vault/models/domain/cipher.ts index 5db8809f3f5..ef05bdadfe1 100644 --- a/libs/common/src/vault/models/domain/cipher.ts +++ b/libs/common/src/vault/models/domain/cipher.ts @@ -358,7 +358,14 @@ export class Cipher extends Domain implements Decryptable { permissions: this.permissions, viewPassword: this.viewPassword, localData: this.localData - ? { lastUsedDate: this.localData.lastUsedDate, lastLaunched: this.localData.lastLaunched } + ? { + lastUsedDate: this.localData.lastUsedDate + ? new Date(this.localData.lastUsedDate).toISOString() + : undefined, + lastLaunched: this.localData.lastLaunched + ? new Date(this.localData.lastLaunched).toISOString() + : undefined, + } : undefined, attachments: this.attachments?.map((a) => a.toSdkAttachment()), fields: this.fields?.map((f) => f.toSdkField()), diff --git a/libs/common/src/vault/models/view/cipher.view.ts b/libs/common/src/vault/models/view/cipher.view.ts index dc447551bff..b57a4274122 100644 --- a/libs/common/src/vault/models/view/cipher.view.ts +++ b/libs/common/src/vault/models/view/cipher.view.ts @@ -245,7 +245,16 @@ export class CipherView implements View, InitializerMetadata { cipherView.permissions = CipherPermissionsApi.fromSdkCipherPermissions(obj.permissions); cipherView.edit = obj.edit; cipherView.viewPassword = obj.viewPassword; - cipherView.localData = obj.localData; + cipherView.localData = obj.localData + ? { + lastUsedDate: obj.localData.lastUsedDate + ? new Date(obj.localData.lastUsedDate).getTime() + : undefined, + lastLaunched: obj.localData.lastLaunched + ? new Date(obj.localData.lastLaunched).getTime() + : undefined, + } + : undefined; cipherView.attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)); cipherView.fields = obj.fields?.map((f) => FieldView.fromSdkFieldView(f)); cipherView.passwordHistory = obj.passwordHistory?.map((ph) => diff --git a/libs/common/src/vault/services/default-cipher-encryption.service.ts b/libs/common/src/vault/services/default-cipher-encryption.service.ts index 34f9ea27344..ce937bc8bbc 100644 --- a/libs/common/src/vault/services/default-cipher-encryption.service.ts +++ b/libs/common/src/vault/services/default-cipher-encryption.service.ts @@ -30,7 +30,7 @@ export class DefaultCipherEncryptionService implements CipherEncryptionService { using ref = sdk.take(); const sdkCipherView = ref.value.vault().ciphers().decrypt(cipher.toSdkCipher()); - // The SDK returns a cipherView or throws an error if decryption fails. + const clientCipherView = CipherView.fromSdkCipherView(sdkCipherView)!; // Decrypt Fido2 credentials if available