From 3a0b72b8a09d6d4ac5f6e4c2fa14783d7134bac9 Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:03:24 -0400 Subject: [PATCH 1/6] Add CreationDate to common libs --- libs/common/spec/domain/cipher.spec.ts | 17 +++++++++++++++++ libs/common/src/models/data/cipherData.ts | 2 ++ libs/common/src/models/domain/cipher.ts | 3 +++ .../src/models/response/cipherResponse.ts | 2 ++ libs/common/src/models/view/cipherView.ts | 2 ++ 5 files changed, 26 insertions(+) diff --git a/libs/common/spec/domain/cipher.spec.ts b/libs/common/spec/domain/cipher.spec.ts index 6bc3b933ced7..0cbe18293dfb 100644 --- a/libs/common/spec/domain/cipher.spec.ts +++ b/libs/common/spec/domain/cipher.spec.ts @@ -36,6 +36,7 @@ describe("Cipher DTO", () => { revisionDate: null, collectionIds: undefined, localData: null, + creationDate: null, deletedDate: null, reprompt: undefined, attachments: null, @@ -60,6 +61,7 @@ describe("Cipher DTO", () => { type: CipherType.Login, name: "EncryptedString", notes: "EncryptedString", + creationDate: null, deletedDate: null, reprompt: CipherRepromptType.None, login: { @@ -125,6 +127,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, + creationDate: null, deletedDate: null, reprompt: 0, login: { @@ -194,6 +197,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Login; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); + cipher.creationDate = null; cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -224,6 +228,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), + creationDate: null, deletedDate: null, reprompt: 0, localData: undefined, @@ -247,6 +252,7 @@ describe("Cipher DTO", () => { type: CipherType.SecureNote, name: "EncryptedString", notes: "EncryptedString", + creationDate: null, deletedDate: null, reprompt: CipherRepromptType.None, secureNote: { @@ -272,6 +278,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, + creationDate: null, deletedDate: null, reprompt: 0, secureNote: { type: SecureNoteType.Generic }, @@ -299,6 +306,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.SecureNote; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); + cipher.creationDate = null; cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; cipher.secureNote = new SecureNote(); @@ -323,6 +331,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), + creationDate: null, deletedDate: null, reprompt: 0, localData: undefined, @@ -346,6 +355,7 @@ describe("Cipher DTO", () => { type: CipherType.Card, name: "EncryptedString", notes: "EncryptedString", + creationDate: null, deletedDate: null, reprompt: CipherRepromptType.None, card: { @@ -376,6 +386,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, + creationDate: null, deletedDate: null, reprompt: 0, card: { @@ -410,6 +421,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Card; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); + cipher.creationDate = null; cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -440,6 +452,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), + creationDate: null, deletedDate: null, reprompt: 0, localData: undefined, @@ -463,6 +476,7 @@ describe("Cipher DTO", () => { type: CipherType.Identity, name: "EncryptedString", notes: "EncryptedString", + creationDate: null, deletedDate: null, reprompt: CipherRepromptType.None, identity: { @@ -505,6 +519,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, + creationDate: null, deletedDate: null, reprompt: 0, identity: { @@ -551,6 +566,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Identity; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); + cipher.creationDate = null; cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -581,6 +597,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), + creationDate: null, deletedDate: null, reprompt: 0, localData: undefined, diff --git a/libs/common/src/models/data/cipherData.ts b/libs/common/src/models/data/cipherData.ts index aa82a5fd0be8..34815a65968c 100644 --- a/libs/common/src/models/data/cipherData.ts +++ b/libs/common/src/models/data/cipherData.ts @@ -30,6 +30,7 @@ export class CipherData { attachments?: AttachmentData[]; passwordHistory?: PasswordHistoryData[]; collectionIds?: string[]; + creationDate: string; deletedDate: string; reprompt: CipherRepromptType; @@ -50,6 +51,7 @@ export class CipherData { this.name = response.name; this.notes = response.notes; this.collectionIds = collectionIds != null ? collectionIds : response.collectionIds; + this.creationDate = response.creationDate; this.deletedDate = response.deletedDate; this.reprompt = response.reprompt; diff --git a/libs/common/src/models/domain/cipher.ts b/libs/common/src/models/domain/cipher.ts index b25be3552019..07ec8caafac0 100644 --- a/libs/common/src/models/domain/cipher.ts +++ b/libs/common/src/models/domain/cipher.ts @@ -35,6 +35,7 @@ export class Cipher extends Domain { fields: Field[]; passwordHistory: Password[]; collectionIds: string[]; + creationDate: Date; deletedDate: Date; reprompt: CipherRepromptType; @@ -69,6 +70,7 @@ export class Cipher extends Domain { this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null; this.collectionIds = obj.collectionIds; this.localData = localData; + this.creationDate = obj.creationDate != null ? new Date(obj.creationDate) : null; this.deletedDate = obj.deletedDate != null ? new Date(obj.deletedDate) : null; this.reprompt = obj.reprompt; @@ -197,6 +199,7 @@ export class Cipher extends Domain { c.revisionDate = this.revisionDate != null ? this.revisionDate.toISOString() : null; c.type = this.type; c.collectionIds = this.collectionIds; + c.creationDate = this.creationDate != null ? this.creationDate.toISOString() : null; c.deletedDate = this.deletedDate != null ? this.deletedDate.toISOString() : null; c.reprompt = this.reprompt; diff --git a/libs/common/src/models/response/cipherResponse.ts b/libs/common/src/models/response/cipherResponse.ts index 5b461438e976..8eba6f627314 100644 --- a/libs/common/src/models/response/cipherResponse.ts +++ b/libs/common/src/models/response/cipherResponse.ts @@ -29,6 +29,7 @@ export class CipherResponse extends BaseResponse { attachments: AttachmentResponse[]; passwordHistory: PasswordHistoryResponse[]; collectionIds: string[]; + creationDate: string; deletedDate: string; reprompt: CipherRepromptType; @@ -50,6 +51,7 @@ export class CipherResponse extends BaseResponse { this.organizationUseTotp = this.getResponseProperty("OrganizationUseTotp"); this.revisionDate = this.getResponseProperty("RevisionDate"); this.collectionIds = this.getResponseProperty("CollectionIds"); + this.creationDate = this.getResponseProperty("CreationDate"); this.deletedDate = this.getResponseProperty("DeletedDate"); const login = this.getResponseProperty("Login"); diff --git a/libs/common/src/models/view/cipherView.ts b/libs/common/src/models/view/cipherView.ts index 3d1f16c14fd3..c8d68ec26795 100644 --- a/libs/common/src/models/view/cipherView.ts +++ b/libs/common/src/models/view/cipherView.ts @@ -33,6 +33,7 @@ export class CipherView implements View { passwordHistory: PasswordHistoryView[] = null; collectionIds: string[] = null; revisionDate: Date = null; + creationDate: Date = null; deletedDate: Date = null; reprompt: CipherRepromptType = CipherRepromptType.None; @@ -52,6 +53,7 @@ export class CipherView implements View { this.localData = c.localData; this.collectionIds = c.collectionIds; this.revisionDate = c.revisionDate; + this.creationDate = c.creationDate; this.deletedDate = c.deletedDate; // Old locally stored ciphers might have reprompt == null. If so set it to None. this.reprompt = c.reprompt ?? CipherRepromptType.None; From bc68c407461ede98325cbfd5790b73080ee125e1 Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:04:03 -0400 Subject: [PATCH 2/6] Add CreationDate to Browser --- apps/browser/src/_locales/en/messages.json | 4 ++++ apps/browser/src/popup/vault/view.component.html | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 4592e295b8f7..b32b0a056fa4 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -1311,6 +1311,10 @@ "message": "Updated", "description": "ex. Date this item was updated" }, + "dateCreated": { + "message": "Created", + "description": "ex. Date this item was created" + }, "datePasswordUpdated": { "message": "Password Updated", "description": "ex. Date this password was updated" diff --git a/apps/browser/src/popup/vault/view.component.html b/apps/browser/src/popup/vault/view.component.html index feb176066696..7d563cd65555 100644 --- a/apps/browser/src/popup/vault/view.component.html +++ b/apps/browser/src/popup/vault/view.component.html @@ -501,6 +501,10 @@

{{ "dateUpdated" | i18n }}: {{ cipher.revisionDate | date: "medium" }} +
+ {{ "dateCreated" | i18n }}: + {{ cipher.creationDate | date: "medium" }} +
{{ "datePasswordUpdated" | i18n }}: {{ cipher.passwordRevisionDisplayDate | date: "medium" }} From 36c8d751d046c0d45cb6de57e3eacf4f899cfba0 Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:04:22 -0400 Subject: [PATCH 3/6] Add CreationDate to CLI --- apps/cli/src/models/response/cipherResponse.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/cli/src/models/response/cipherResponse.ts b/apps/cli/src/models/response/cipherResponse.ts index a52084de7729..9f44fbb38a8a 100644 --- a/apps/cli/src/models/response/cipherResponse.ts +++ b/apps/cli/src/models/response/cipherResponse.ts @@ -11,6 +11,7 @@ export class CipherResponse extends CipherWithIdExport implements BaseResponse { object: string; attachments: AttachmentResponse[]; revisionDate: Date; + creationDate: Date; deletedDate: Date; passwordHistory: PasswordHistoryResponse[]; @@ -22,6 +23,9 @@ export class CipherResponse extends CipherWithIdExport implements BaseResponse { this.attachments = o.attachments.map((a) => new AttachmentResponse(a)); } this.revisionDate = o.revisionDate; + if (o.creationDate != null) { + this.creationDate = o.creationDate; + } this.deletedDate = o.deletedDate; if (o.passwordHistory != null) { this.passwordHistory = o.passwordHistory.map((h) => new PasswordHistoryResponse(h)); From 039ee4a702eaa0706526fd2d267c8d2465472e62 Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:05:14 -0400 Subject: [PATCH 4/6] Add CreationDate to Desktop --- apps/desktop/src/app/vault/view.component.html | 4 ++++ apps/desktop/src/locales/en/messages.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/apps/desktop/src/app/vault/view.component.html b/apps/desktop/src/app/vault/view.component.html index a033cdd8272f..ac49a0020db0 100644 --- a/apps/desktop/src/app/vault/view.component.html +++ b/apps/desktop/src/app/vault/view.component.html @@ -355,6 +355,10 @@ {{ "dateUpdated" | i18n }}: {{ cipher.revisionDate | date: "medium" }}
+
+ {{ "dateCreated" | i18n }}: + {{ cipher.creationDate | date: "medium" }} +
{{ "datePasswordUpdated" | i18n }}: {{ cipher.passwordRevisionDisplayDate | date: "medium" }} diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 53fcb31879da..01d6f460393c 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -1266,6 +1266,10 @@ "message": "Updated", "description": "ex. Date this item was updated" }, + "dateCreated": { + "message": "Created", + "description": "ex. Date this item was created" + }, "datePasswordUpdated": { "message": "Password Updated", "description": "ex. Date this password was updated" From adc9425878d8d2192cccb2455f3c7ae009bbcbcd Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:05:28 -0400 Subject: [PATCH 5/6] Add CreationDate to Web --- apps/web/src/app/vault/add-edit.component.html | 4 ++++ apps/web/src/locales/en/messages.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/apps/web/src/app/vault/add-edit.component.html b/apps/web/src/app/vault/add-edit.component.html index 54b707c9f6e9..bf76de571bc3 100644 --- a/apps/web/src/app/vault/add-edit.component.html +++ b/apps/web/src/app/vault/add-edit.component.html @@ -753,6 +753,10 @@

{{ "collections" | i18n }}

{{ "dateUpdated" | i18n }}: {{ cipher.revisionDate | date: "medium" }}
+
+ {{ "dateCreated" | i18n }}: + {{ cipher.creationDate | date: "medium" }} +
{{ "datePasswordUpdated" | i18n }}: {{ cipher.passwordRevisionDisplayDate | date: "medium" }} diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 11dec443941d..ce14e81fab05 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -3250,6 +3250,10 @@ "message": "Updated", "description": "ex. Date this item was updated" }, + "dateCreated": { + "message": "Created", + "description": "ex. Date this item was created" + }, "datePasswordUpdated": { "message": "Password Updated", "description": "ex. Date this password was updated" From 11cd0ffdc3f52dbd6ceed11c5e4331bb7009ecd8 Mon Sep 17 00:00:00 2001 From: David Frankel <42774874+frankeld@users.noreply.github.com> Date: Mon, 3 Oct 2022 00:03:25 -0400 Subject: [PATCH 6/6] Update tests --- libs/common/spec/models/domain/cipher.spec.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/common/spec/models/domain/cipher.spec.ts b/libs/common/spec/models/domain/cipher.spec.ts index 36979e95ced6..e864bdba155b 100644 --- a/libs/common/spec/models/domain/cipher.spec.ts +++ b/libs/common/spec/models/domain/cipher.spec.ts @@ -61,7 +61,7 @@ describe("Cipher DTO", () => { type: CipherType.Login, name: "EncryptedString", notes: "EncryptedString", - creationDate: null, + creationDate: "2022-01-01T12:00:00.000Z", deletedDate: null, reprompt: CipherRepromptType.None, login: { @@ -127,7 +127,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, login: { @@ -197,7 +197,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Login; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); - cipher.creationDate = null; + cipher.creationDate = new Date("2022-01-01T12:00:00.000Z"); cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -228,7 +228,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, localData: undefined, @@ -252,7 +252,7 @@ describe("Cipher DTO", () => { type: CipherType.SecureNote, name: "EncryptedString", notes: "EncryptedString", - creationDate: null, + creationDate: "2022-01-01T12:00:00.000Z", deletedDate: null, reprompt: CipherRepromptType.None, secureNote: { @@ -278,7 +278,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, secureNote: { type: SecureNoteType.Generic }, @@ -306,7 +306,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.SecureNote; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); - cipher.creationDate = null; + cipher.creationDate = new Date("2022-01-01T12:00:00.000Z"); cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; cipher.secureNote = new SecureNote(); @@ -331,7 +331,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, localData: undefined, @@ -355,7 +355,7 @@ describe("Cipher DTO", () => { type: CipherType.Card, name: "EncryptedString", notes: "EncryptedString", - creationDate: null, + creationDate: "2022-01-01T12:00:00.000Z", deletedDate: null, reprompt: CipherRepromptType.None, card: { @@ -386,7 +386,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, card: { @@ -421,7 +421,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Card; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); - cipher.creationDate = null; + cipher.creationDate = new Date("2022-01-01T12:00:00.000Z"); cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -452,7 +452,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, localData: undefined, @@ -476,7 +476,7 @@ describe("Cipher DTO", () => { type: CipherType.Identity, name: "EncryptedString", notes: "EncryptedString", - creationDate: null, + creationDate: "2022-01-01T12:00:00.000Z", deletedDate: null, reprompt: CipherRepromptType.None, identity: { @@ -519,7 +519,7 @@ describe("Cipher DTO", () => { revisionDate: new Date("2022-01-31T12:00:00.000Z"), collectionIds: undefined, localData: null, - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, identity: { @@ -566,7 +566,7 @@ describe("Cipher DTO", () => { cipher.type = CipherType.Identity; cipher.name = mockEnc("EncryptedString"); cipher.notes = mockEnc("EncryptedString"); - cipher.creationDate = null; + cipher.creationDate = new Date("2022-01-01T12:00:00.000Z"); cipher.deletedDate = null; cipher.reprompt = CipherRepromptType.None; @@ -597,7 +597,7 @@ describe("Cipher DTO", () => { passwordHistory: null, collectionIds: undefined, revisionDate: new Date("2022-01-31T12:00:00.000Z"), - creationDate: null, + creationDate: new Date("2022-01-01T12:00:00.000Z"), deletedDate: null, reprompt: 0, localData: undefined,