From f8ac1ed12b686527fa888009964e24b4654de752 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Sat, 16 Apr 2022 17:00:48 +0200 Subject: [PATCH] Remove support for alreadyEncrypted (#762) --- common/src/models/domain/attachment.ts | 3 +-- common/src/models/domain/card.ts | 3 +-- common/src/models/domain/cipher.ts | 15 +++++++-------- common/src/models/domain/collection.ts | 3 +-- common/src/models/domain/domainBase.ts | 3 +-- common/src/models/domain/field.ts | 3 +-- common/src/models/domain/folder.ts | 3 +-- common/src/models/domain/identity.ts | 3 +-- common/src/models/domain/login.ts | 5 ++--- common/src/models/domain/loginUri.ts | 3 +-- common/src/models/domain/password.ts | 13 ++++--------- common/src/models/domain/send.ts | 7 +++---- common/src/models/domain/sendAccess.ts | 7 +++---- common/src/models/domain/sendFile.ts | 3 +-- common/src/models/domain/sendText.ts | 3 +-- common/src/services/cipher.service.ts | 4 ++-- 16 files changed, 31 insertions(+), 50 deletions(-) diff --git a/common/src/models/domain/attachment.ts b/common/src/models/domain/attachment.ts index aded9d25e8..712382ea98 100644 --- a/common/src/models/domain/attachment.ts +++ b/common/src/models/domain/attachment.ts @@ -15,7 +15,7 @@ export class Attachment extends Domain { key: EncString; fileName: EncString; - constructor(obj?: AttachmentData, alreadyEncrypted = false) { + constructor(obj?: AttachmentData) { super(); if (obj == null) { return; @@ -32,7 +32,6 @@ export class Attachment extends Domain { fileName: null, key: null, }, - alreadyEncrypted, ["id", "url", "sizeName"] ); } diff --git a/common/src/models/domain/card.ts b/common/src/models/domain/card.ts index 170b7c1aba..59f73f9028 100644 --- a/common/src/models/domain/card.ts +++ b/common/src/models/domain/card.ts @@ -13,7 +13,7 @@ export class Card extends Domain { expYear: EncString; code: EncString; - constructor(obj?: CardData, alreadyEncrypted = false) { + constructor(obj?: CardData) { super(); if (obj == null) { return; @@ -30,7 +30,6 @@ export class Card extends Domain { expYear: null, code: null, }, - alreadyEncrypted, [] ); } diff --git a/common/src/models/domain/cipher.ts b/common/src/models/domain/cipher.ts index d548e67374..23f98686fe 100644 --- a/common/src/models/domain/cipher.ts +++ b/common/src/models/domain/cipher.ts @@ -38,7 +38,7 @@ export class Cipher extends Domain { deletedDate: Date; reprompt: CipherRepromptType; - constructor(obj?: CipherData, alreadyEncrypted = false, localData: any = null) { + constructor(obj?: CipherData, localData: any = null) { super(); if (obj == null) { return; @@ -55,7 +55,6 @@ export class Cipher extends Domain { name: null, notes: null, }, - alreadyEncrypted, ["id", "userId", "organizationId", "folderId"] ); @@ -76,35 +75,35 @@ export class Cipher extends Domain { switch (this.type) { case CipherType.Login: - this.login = new Login(obj.login, alreadyEncrypted); + this.login = new Login(obj.login); break; case CipherType.SecureNote: this.secureNote = new SecureNote(obj.secureNote); break; case CipherType.Card: - this.card = new Card(obj.card, alreadyEncrypted); + this.card = new Card(obj.card); break; case CipherType.Identity: - this.identity = new Identity(obj.identity, alreadyEncrypted); + this.identity = new Identity(obj.identity); break; default: break; } if (obj.attachments != null) { - this.attachments = obj.attachments.map((a) => new Attachment(a, alreadyEncrypted)); + this.attachments = obj.attachments.map((a) => new Attachment(a)); } else { this.attachments = null; } if (obj.fields != null) { - this.fields = obj.fields.map((f) => new Field(f, alreadyEncrypted)); + this.fields = obj.fields.map((f) => new Field(f)); } else { this.fields = null; } if (obj.passwordHistory != null) { - this.passwordHistory = obj.passwordHistory.map((ph) => new Password(ph, alreadyEncrypted)); + this.passwordHistory = obj.passwordHistory.map((ph) => new Password(ph)); } else { this.passwordHistory = null; } diff --git a/common/src/models/domain/collection.ts b/common/src/models/domain/collection.ts index 740cada30c..6f737cd477 100644 --- a/common/src/models/domain/collection.ts +++ b/common/src/models/domain/collection.ts @@ -12,7 +12,7 @@ export class Collection extends Domain { readOnly: boolean; hidePasswords: boolean; - constructor(obj?: CollectionData, alreadyEncrypted = false) { + constructor(obj?: CollectionData) { super(); if (obj == null) { return; @@ -29,7 +29,6 @@ export class Collection extends Domain { readOnly: null, hidePasswords: null, }, - alreadyEncrypted, ["id", "organizationId", "externalId", "readOnly", "hidePasswords"] ); } diff --git a/common/src/models/domain/domainBase.ts b/common/src/models/domain/domainBase.ts index aa4d97e4e8..0c9e5ad688 100644 --- a/common/src/models/domain/domainBase.ts +++ b/common/src/models/domain/domainBase.ts @@ -8,7 +8,6 @@ export default class Domain { domain: D, dataObj: any, map: any, - alreadyEncrypted: boolean, notEncList: any[] = [] ) { for (const prop in map) { @@ -18,7 +17,7 @@ export default class Domain { } const objProp = dataObj[map[prop] || prop]; - if (alreadyEncrypted === true || notEncList.indexOf(prop) > -1) { + if (notEncList.indexOf(prop) > -1) { (domain as any)[prop] = objProp ? objProp : null; } else { (domain as any)[prop] = objProp ? new EncString(objProp) : null; diff --git a/common/src/models/domain/field.ts b/common/src/models/domain/field.ts index aab53c4b5d..71dc615afd 100644 --- a/common/src/models/domain/field.ts +++ b/common/src/models/domain/field.ts @@ -13,7 +13,7 @@ export class Field extends Domain { type: FieldType; linkedId: LinkedIdType; - constructor(obj?: FieldData, alreadyEncrypted = false) { + constructor(obj?: FieldData) { super(); if (obj == null) { return; @@ -28,7 +28,6 @@ export class Field extends Domain { name: null, value: null, }, - alreadyEncrypted, [] ); } diff --git a/common/src/models/domain/folder.ts b/common/src/models/domain/folder.ts index f27d1e5f4f..8596e94d76 100644 --- a/common/src/models/domain/folder.ts +++ b/common/src/models/domain/folder.ts @@ -9,7 +9,7 @@ export class Folder extends Domain { name: EncString; revisionDate: Date; - constructor(obj?: FolderData, alreadyEncrypted = false) { + constructor(obj?: FolderData) { super(); if (obj == null) { return; @@ -22,7 +22,6 @@ export class Folder extends Domain { id: null, name: null, }, - alreadyEncrypted, ["id"] ); diff --git a/common/src/models/domain/identity.ts b/common/src/models/domain/identity.ts index 8bc3c8a682..4af228499b 100644 --- a/common/src/models/domain/identity.ts +++ b/common/src/models/domain/identity.ts @@ -25,7 +25,7 @@ export class Identity extends Domain { passportNumber: EncString; licenseNumber: EncString; - constructor(obj?: IdentityData, alreadyEncrypted = false) { + constructor(obj?: IdentityData) { super(); if (obj == null) { return; @@ -54,7 +54,6 @@ export class Identity extends Domain { passportNumber: null, licenseNumber: null, }, - alreadyEncrypted, [] ); } diff --git a/common/src/models/domain/login.ts b/common/src/models/domain/login.ts index 4ada798623..76ba402000 100644 --- a/common/src/models/domain/login.ts +++ b/common/src/models/domain/login.ts @@ -14,7 +14,7 @@ export class Login extends Domain { totp: EncString; autofillOnPageLoad: boolean; - constructor(obj?: LoginData, alreadyEncrypted = false) { + constructor(obj?: LoginData) { super(); if (obj == null) { return; @@ -31,14 +31,13 @@ export class Login extends Domain { password: null, totp: null, }, - alreadyEncrypted, [] ); if (obj.uris) { this.uris = []; obj.uris.forEach((u) => { - this.uris.push(new LoginUri(u, alreadyEncrypted)); + this.uris.push(new LoginUri(u)); }); } } diff --git a/common/src/models/domain/loginUri.ts b/common/src/models/domain/loginUri.ts index 15a513199f..685ce4a938 100644 --- a/common/src/models/domain/loginUri.ts +++ b/common/src/models/domain/loginUri.ts @@ -10,7 +10,7 @@ export class LoginUri extends Domain { uri: EncString; match: UriMatchType; - constructor(obj?: LoginUriData, alreadyEncrypted = false) { + constructor(obj?: LoginUriData) { super(); if (obj == null) { return; @@ -23,7 +23,6 @@ export class LoginUri extends Domain { { uri: null, }, - alreadyEncrypted, [] ); } diff --git a/common/src/models/domain/password.ts b/common/src/models/domain/password.ts index 0408938a39..ae47b18db8 100644 --- a/common/src/models/domain/password.ts +++ b/common/src/models/domain/password.ts @@ -9,20 +9,15 @@ export class Password extends Domain { password: EncString; lastUsedDate: Date; - constructor(obj?: PasswordHistoryData, alreadyEncrypted = false) { + constructor(obj?: PasswordHistoryData) { super(); if (obj == null) { return; } - this.buildDomainModel( - this, - obj, - { - password: null, - }, - alreadyEncrypted - ); + this.buildDomainModel(this, obj, { + password: null, + }); this.lastUsedDate = new Date(obj.lastUsedDate); } diff --git a/common/src/models/domain/send.ts b/common/src/models/domain/send.ts index 29809b296c..c2e769ece5 100644 --- a/common/src/models/domain/send.ts +++ b/common/src/models/domain/send.ts @@ -28,7 +28,7 @@ export class Send extends Domain { disabled: boolean; hideEmail: boolean; - constructor(obj?: SendData, alreadyEncrypted = false) { + constructor(obj?: SendData) { super(); if (obj == null) { return; @@ -45,7 +45,6 @@ export class Send extends Domain { notes: null, key: null, }, - alreadyEncrypted, ["id", "accessId", "userId"] ); @@ -61,10 +60,10 @@ export class Send extends Domain { switch (this.type) { case SendType.Text: - this.text = new SendText(obj.text, alreadyEncrypted); + this.text = new SendText(obj.text); break; case SendType.File: - this.file = new SendFile(obj.file, alreadyEncrypted); + this.file = new SendFile(obj.file); break; default: break; diff --git a/common/src/models/domain/sendAccess.ts b/common/src/models/domain/sendAccess.ts index dce6960cbb..dab68cc646 100644 --- a/common/src/models/domain/sendAccess.ts +++ b/common/src/models/domain/sendAccess.ts @@ -17,7 +17,7 @@ export class SendAccess extends Domain { expirationDate: Date; creatorIdentifier: string; - constructor(obj?: SendAccessResponse, alreadyEncrypted = false) { + constructor(obj?: SendAccessResponse) { super(); if (obj == null) { return; @@ -32,7 +32,6 @@ export class SendAccess extends Domain { expirationDate: null, creatorIdentifier: null, }, - alreadyEncrypted, ["id", "expirationDate", "creatorIdentifier"] ); @@ -40,10 +39,10 @@ export class SendAccess extends Domain { switch (this.type) { case SendType.Text: - this.text = new SendText(obj.text, alreadyEncrypted); + this.text = new SendText(obj.text); break; case SendType.File: - this.file = new SendFile(obj.file, alreadyEncrypted); + this.file = new SendFile(obj.file); break; default: break; diff --git a/common/src/models/domain/sendFile.ts b/common/src/models/domain/sendFile.ts index 5c954044d0..177994078f 100644 --- a/common/src/models/domain/sendFile.ts +++ b/common/src/models/domain/sendFile.ts @@ -11,7 +11,7 @@ export class SendFile extends Domain { sizeName: string; fileName: EncString; - constructor(obj?: SendFileData, alreadyEncrypted = false) { + constructor(obj?: SendFileData) { super(); if (obj == null) { return; @@ -26,7 +26,6 @@ export class SendFile extends Domain { sizeName: null, fileName: null, }, - alreadyEncrypted, ["id", "sizeName"] ); } diff --git a/common/src/models/domain/sendText.ts b/common/src/models/domain/sendText.ts index a306c6c382..523e5ee58a 100644 --- a/common/src/models/domain/sendText.ts +++ b/common/src/models/domain/sendText.ts @@ -9,7 +9,7 @@ export class SendText extends Domain { text: EncString; hidden: boolean; - constructor(obj?: SendTextData, alreadyEncrypted = false) { + constructor(obj?: SendTextData) { super(); if (obj == null) { return; @@ -22,7 +22,6 @@ export class SendText extends Domain { { text: null, }, - alreadyEncrypted, [] ); } diff --git a/common/src/services/cipher.service.ts b/common/src/services/cipher.service.ts index 0c5a9eaab8..1deeec8eae 100644 --- a/common/src/services/cipher.service.ts +++ b/common/src/services/cipher.service.ts @@ -306,7 +306,7 @@ export class CipherService implements CipherServiceAbstraction { } const localData = await this.stateService.getLocalData(); - return new Cipher(ciphers[id], false, localData ? localData[id] : null); + return new Cipher(ciphers[id], localData ? localData[id] : null); } async getAll(): Promise { @@ -316,7 +316,7 @@ export class CipherService implements CipherServiceAbstraction { for (const id in ciphers) { // eslint-disable-next-line if (ciphers.hasOwnProperty(id)) { - response.push(new Cipher(ciphers[id], false, localData ? localData[id] : null)); + response.push(new Cipher(ciphers[id], localData ? localData[id] : null)); } } return response;