From cd6b3d47c2c8a04f37d2dc7468ee29990a6762fc Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 23 Nov 2020 08:48:40 -0600 Subject: [PATCH] Include revision date in cipher requests (#203) This is in conjunction with API changes that validates the last known revision date provided here with the actual last revision date on the server to block potential data loss due to client desyncs. Co-authored-by: Matt Gibson --- src/models/request/cipherRequest.ts | 2 ++ src/services/cipher.service.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/models/request/cipherRequest.ts b/src/models/request/cipherRequest.ts index 9333e753f5..5c1e950311 100644 --- a/src/models/request/cipherRequest.ts +++ b/src/models/request/cipherRequest.ts @@ -28,6 +28,7 @@ export class CipherRequest { // Deprecated, remove at some point and rename attachments2 to attachments attachments: { [id: string]: string; }; attachments2: { [id: string]: AttachmentRequest; }; + lastKnownRevisionDate: Date; constructor(cipher: Cipher) { this.type = cipher.type; @@ -36,6 +37,7 @@ export class CipherRequest { this.name = cipher.name ? cipher.name.encryptedString : null; this.notes = cipher.notes ? cipher.notes.encryptedString : null; this.favorite = cipher.favorite; + this.lastKnownRevisionDate = cipher.revisionDate; switch (this.type) { case CipherType.Login: diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index 6cd58de8d5..c45965367d 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -143,6 +143,7 @@ export class CipherService implements CipherServiceAbstraction { cipher.organizationId = model.organizationId; cipher.type = model.type; cipher.collectionIds = model.collectionIds; + cipher.revisionDate = model.revisionDate; if (key == null && cipher.organizationId != null) { key = await this.cryptoService.getOrgKey(cipher.organizationId);