From 32d6dfaf176dbd5f8f922a9d86d69f4c1ca3c2ed Mon Sep 17 00:00:00 2001 From: Sagnik Mandal Date: Tue, 27 Feb 2024 22:51:57 +0530 Subject: [PATCH] Make the filter consistent --- .../services/synchronizer/syncInfoUtils.test.ts | 14 +++++++------- .../lib/services/synchronizer/syncInfoUtils.ts | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/lib/services/synchronizer/syncInfoUtils.test.ts b/packages/lib/services/synchronizer/syncInfoUtils.test.ts index c5dc9936191..2dfd307d159 100644 --- a/packages/lib/services/synchronizer/syncInfoUtils.test.ts +++ b/packages/lib/services/synchronizer/syncInfoUtils.test.ts @@ -246,16 +246,16 @@ describe('syncInfoUtils', () => { const filteredSyncInfo = syncInfo.filterSyncInfo(); expect(filteredSyncInfo).toEqual({ - 'activeMasterKeyId_': { + 'activeMasterKeyId': { 'updatedTime': 0, 'value': '400227d2222c4d3bb7346514861c643b', }, - 'appMinVersion_': '0.0.0', - 'e2ee_': { + 'appMinVersion': '0.0.0', + 'e2ee': { 'updatedTime': 0, 'value': true, }, - 'masterKeys_': [ + 'masterKeys': [ { 'created_time': 1515008161362, 'encryption_method': 4, @@ -265,7 +265,7 @@ describe('syncInfoUtils', () => { 'updated_time': 1708103706234, }, ], - 'ppk_': { + 'ppk': { 'updatedTime': 1633274368892, 'value': { 'createdTime': 1633274368892, @@ -275,10 +275,10 @@ describe('syncInfoUtils', () => { 'ciphertext': '{"iv":"Z2y11b4nCYvpm...TqWOF+6eYn8Q+Y3YIY"}', 'encryptionMethod': 4, }, - 'publicKey': '-----BEGIN RSA PUBLI... RSA PUBLIC KEY-----', + 'publicKey': '-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCA...', }, }, - 'version_': 3, + 'version': 3, }); }); // cSpell:enable diff --git a/packages/lib/services/synchronizer/syncInfoUtils.ts b/packages/lib/services/synchronizer/syncInfoUtils.ts index 46cc44a68b5..c2d6dcfab44 100644 --- a/packages/lib/services/synchronizer/syncInfoUtils.ts +++ b/packages/lib/services/synchronizer/syncInfoUtils.ts @@ -241,11 +241,11 @@ export class SyncInfo { } public filterSyncInfo() { - const filtered = JSON.parse(JSON.stringify(this)); + const filtered = JSON.parse(JSON.stringify(this.toObject())); // Filter content and checksum properties from master keys - if (filtered.masterKeys_) { - filtered.masterKeys_ = filtered.masterKeys_.map((mk: MasterKeyEntity) => { + if (filtered.masterKeys) { + filtered.masterKeys = filtered.masterKeys.map((mk: MasterKeyEntity) => { delete mk.content; delete mk.checksum; return mk; @@ -253,9 +253,9 @@ export class SyncInfo { } // Truncate the private key and public key - if (filtered.ppk_.value) { - filtered.ppk_.value.privateKey.ciphertext = `${filtered.ppk_.value.privateKey.ciphertext.substr(0, 20)}...${filtered.ppk_.value.privateKey.ciphertext.substr(-20)}`; - filtered.ppk_.value.publicKey = `${filtered.ppk_.value.publicKey.substr(0, 20)}...${filtered.ppk_.value.publicKey.substr(-20)}`; + if (filtered.ppk.value) { + filtered.ppk.value.privateKey.ciphertext = `${filtered.ppk.value.privateKey.ciphertext.substr(0, 20)}...${filtered.ppk.value.privateKey.ciphertext.substr(-20)}`; + filtered.ppk.value.publicKey = `${filtered.ppk.value.publicKey.substr(0, 40)}...`; } return filtered; }