diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 72f4e36..1928bd9 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -231,6 +231,10 @@ "message": "Search all open Kee Vaults and KeePass databases", "description": "" }, + "pref_excludeExpiredEntries_label": { + "message": "Exclude expired entries", + "description": "When enabled, matching entries that have expired (Expires=true and ExpiryTime is in the past) will be hidden from the result list." + }, "pref_when_kee_chooses_standard_form_desc": { "message": "When Kee chooses a matching login for a standard form, Kee should", "description": "Context/label for user when changing setting relating to auto-fill/submit behaviour. A list of potential actions will be displayed immediately after this string and the user can select their preferred behaviour from that list." diff --git a/package-lock.json b/package-lock.json index 734cda6..f1ba984 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3503,28 +3503,6 @@ "node": ">=10" } }, - "node_modules/addons-linter/node_modules/node-fetch": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", - "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/addons-linter/node_modules/postcss": { "version": "8.4.33", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", @@ -3582,34 +3560,6 @@ "node": ">=8" } }, - "node_modules/addons-linter/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true, - "optional": true, - "peer": true - }, - "node_modules/addons-linter/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true, - "optional": true, - "peer": true - }, - "node_modules/addons-linter/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/addons-linter/node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/src/background/jsonrpcClient.ts b/src/background/jsonrpcClient.ts index 6741d31..9a55e5e 100644 --- a/src/background/jsonrpcClient.ts +++ b/src/background/jsonrpcClient.ts @@ -244,6 +244,7 @@ export class jsonrpcClient { username ]); const results: Entry[] = []; + const now = new Date(); for (const sessionResponse of sessionResponses) { if (sessionResponse.resultWrapper?.result?.[0]) { const db = DatabaseSummary.fromKPRPCDatabaseSummaryDTO( @@ -256,6 +257,13 @@ export class jsonrpcClient { ); } } + if (configManager.current.excludeExpiredEntries) { + return results.filter(entry => { + if (!entry.expires || !entry.expiryTime) return true; + const expiry = new Date(entry.expiryTime); + return isNaN(expiry.getTime()) || expiry >= now; + }); + } return results; } diff --git a/src/common/ConfigManager.ts b/src/common/ConfigManager.ts index 2b8d3a2..ce70c6e 100644 --- a/src/common/ConfigManager.ts +++ b/src/common/ConfigManager.ts @@ -78,6 +78,7 @@ defaultConfig.theme = null; defaultConfig.hideConfirmationAfterSave = false; defaultConfig.mustShowReleaseNotesAtStartup = false; defaultConfig.autoFillFieldsWithExistingValue = false; +defaultConfig.excludeExpiredEntries = false; export class ConfigManager { public current: Config; diff --git a/src/common/config.ts b/src/common/config.ts index a0e3e14..e072221 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -96,4 +96,5 @@ export class Config { hideConfirmationAfterSave: boolean; mustShowReleaseNotesAtStartup: boolean; autoFillFieldsWithExistingValue: boolean; + excludeExpiredEntries: boolean; } diff --git a/src/common/model/Entry.ts b/src/common/model/Entry.ts index c7f1dda..a2c5a9b 100644 --- a/src/common/model/Entry.ts +++ b/src/common/model/Entry.ts @@ -44,6 +44,9 @@ export class Entry { readonly database: DatabaseSummary; + readonly expires: boolean; + readonly expiryTime: string; + // How relevant this entry is to the current form in // the browser - transient (not stored in KeePass) //TODO:5 put all match data into a new object? @@ -67,6 +70,8 @@ export class Entry { this.matchAccuracy = e.matchAccuracy || 0; this.icon = e.icon || { version: 1, iconImageData: "" }; this.database = e.database || new Database({}); + this.expires = e.expires || false; + this.expiryTime = e.expiryTime || ""; this.relevanceScore = e.relevanceScore; this.lowFieldMatchRatio = e.lowFieldMatchRatio; this.formIndex = e.formIndex; @@ -120,7 +125,9 @@ export class Entry { httpRealm: entryDto.hTTPRealm, uuid: entryDto.uniqueID, title: entryDto.title, - fields: sortedFields + fields: sortedFields, + expires: entryDto.expires, + expiryTime: entryDto.expiryTime }); return entry; diff --git a/src/common/model/KPRPCDTOs.ts b/src/common/model/KPRPCDTOs.ts index ca71fbe..70fc9f9 100644 --- a/src/common/model/KPRPCDTOs.ts +++ b/src/common/model/KPRPCDTOs.ts @@ -85,6 +85,8 @@ export class EntryDto { uniqueID: string; title: string; formFieldList: FieldDto[]; + expires: boolean; + expiryTime: string; } export class EntrySummaryDto { diff --git a/src/settings/index.html b/src/settings/index.html index e1e2ae6..17b864e 100644 --- a/src/settings/index.html +++ b/src/settings/index.html @@ -84,6 +84,9 @@