Skip to content

Commit

Permalink
Make the filter consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
criticic committed Feb 27, 2024
1 parent 320a8cc commit 32d6dfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions packages/lib/services/synchronizer/syncInfoUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -265,7 +265,7 @@ describe('syncInfoUtils', () => {
'updated_time': 1708103706234,
},
],
'ppk_': {
'ppk': {
'updatedTime': 1633274368892,
'value': {
'createdTime': 1633274368892,
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions packages/lib/services/synchronizer/syncInfoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,21 @@ 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;
});
}

// 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;
}
Expand Down

0 comments on commit 32d6dfa

Please sign in to comment.