From 889bbf8e2f362c686f03e3f3fc1ce34725199c51 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 15:47:33 +0200 Subject: [PATCH 01/31] Removed checks for locked vault from collectPageDetails --- src/background/main.background.ts | 4 ---- src/background/runtime.background.ts | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 161ca0ced9..bc36b031d5 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -374,10 +374,6 @@ export default class MainBackground { return; } - if (await this.vaultTimeoutService.isLocked()) { - return; - } - const options: any = {}; if (frameId != null) { options.frameId = frameId; diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 3034c66f58..aadb228ee8 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -126,9 +126,6 @@ export default class RuntimeBackground { await this.main.reseedStorage(); break; case 'collectPageDetailsResponse': - if (await this.vaultTimeoutService.isLocked()) { - return; - } switch (msg.sender) { case 'notificationBar': const forms = this.autofillService.getFormsWithPasswordFields(msg.details); From 210e0801ff58134da6bffd6c942b85d59e2302d2 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:03:14 +0200 Subject: [PATCH 02/31] Open notificationBar (new and existing login) even though vault is locked --- .../models/addChangePasswordQueueMessage.ts | 9 +++ src/background/models/addLoginQueueMessage.ts | 10 ++++ src/background/runtime.background.ts | 59 ++++++++++++------- 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 src/background/models/addChangePasswordQueueMessage.ts create mode 100644 src/background/models/addLoginQueueMessage.ts diff --git a/src/background/models/addChangePasswordQueueMessage.ts b/src/background/models/addChangePasswordQueueMessage.ts new file mode 100644 index 0000000000..568dcc6dd7 --- /dev/null +++ b/src/background/models/addChangePasswordQueueMessage.ts @@ -0,0 +1,9 @@ +export default class addChangePasswordQueueMessage { + type: string; + cipherId: string; + newPassword: string; + domain: string; + tabId: string; + expires: Date; + wasVaultLocked: boolean; +} diff --git a/src/background/models/addLoginQueueMessage.ts b/src/background/models/addLoginQueueMessage.ts new file mode 100644 index 0000000000..cd9b95f511 --- /dev/null +++ b/src/background/models/addLoginQueueMessage.ts @@ -0,0 +1,10 @@ +export default class addLoginQueueMessage { + type: string; + username: string; + password: string; + domain: string; + uri: string; + tabId: string; + expires: Date; + wasVaultLocked: boolean; +} diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index aadb228ee8..afe4409377 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -27,6 +27,9 @@ import { Utils } from 'jslib-common/misc/utils'; import { PolicyType } from 'jslib-common/enums/policyType'; +import addChangePasswordQueueMessage from './models/addChangePasswordQueueMessage'; +import addLoginQueueMessage from './models/addLoginQueueMessage'; + export default class RuntimeBackground { private runtime: any; private autofillTimeout: any; @@ -217,6 +220,7 @@ export default class RuntimeBackground { } private async saveAddLogin(tab: any, folderId: string) { + console.log('saveAddLogin triggered'); if (await this.vaultTimeoutService.isLocked()) { return; } @@ -260,6 +264,7 @@ export default class RuntimeBackground { } private async saveChangePassword(tab: any) { + console.log('saveChangePassword triggered'); if (await this.vaultTimeoutService.isLocked()) { return; } @@ -309,10 +314,7 @@ export default class RuntimeBackground { } private async addLogin(loginInfo: any, tab: any) { - if (await this.vaultTimeoutService.isLocked()) { - return; - } - + console.log('addLogin triggered'); const loginDomain = Utils.getDomain(loginInfo.url); if (loginDomain == null) { return; @@ -323,6 +325,11 @@ export default class RuntimeBackground { normalizedUsername = normalizedUsername.toLowerCase(); } + if (await this.vaultTimeoutService.isLocked()) { + this.pushAddLoginToQueue(loginDomain, loginInfo, tab, true); + return; + } + const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url); const usernameMatches = ciphers.filter(c => c.login.username != null && c.login.username.toLowerCase() === normalizedUsername); @@ -337,9 +344,22 @@ export default class RuntimeBackground { return; } + this.pushAddLoginToQueue(loginDomain, loginInfo, tab); + + } else if (usernameMatches.length === 1 && usernameMatches[0].login.password !== loginInfo.password) { + const disabledChangePassword = await this.storageService.get( + ConstantsService.disableChangedPasswordNotificationKey); + if (disabledChangePassword) { + return; + } + this.pushChangePasswordToQueue(usernameMatches[0].id, loginDomain, loginInfo.password, tab); + } + } + + private async pushAddLoginToQueue(loginDomain: string, loginInfo: any, tab: any, isVaultLocked: boolean = false) { // remove any old messages for this tab this.removeTabFromNotificationQueue(tab); - this.main.notificationQueue.push({ + const message: addLoginQueueMessage = { type: 'addLogin', username: loginInfo.username, password: loginInfo.password, @@ -347,25 +367,20 @@ export default class RuntimeBackground { uri: loginInfo.url, tabId: tab.id, expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes - }); + wasVaultLocked: isVaultLocked, + }; + this.main.notificationQueue.push(message); await this.main.checkNotificationQueue(tab); - } else if (usernameMatches.length === 1 && usernameMatches[0].login.password !== loginInfo.password) { - const disabledChangePassword = await this.storageService.get( - ConstantsService.disableChangedPasswordNotificationKey); - if (disabledChangePassword) { - return; - } - this.addChangedPasswordToQueue(usernameMatches[0].id, loginDomain, loginInfo.password, tab); - } } private async changedPassword(changeData: any, tab: any) { - if (await this.vaultTimeoutService.isLocked()) { + const loginDomain = Utils.getDomain(changeData.url); + if (loginDomain == null) { return; } - const loginDomain = Utils.getDomain(changeData.url); - if (loginDomain == null) { + if (await this.vaultTimeoutService.isLocked()) { + this.pushChangePasswordToQueue(null, loginDomain, changeData.newPassword, tab, true); return; } @@ -380,21 +395,23 @@ export default class RuntimeBackground { id = ciphers[0].id; } if (id != null) { - this.addChangedPasswordToQueue(id, loginDomain, changeData.newPassword, tab); + this.pushChangePasswordToQueue(id, loginDomain, changeData.newPassword, tab); } } - private async addChangedPasswordToQueue(cipherId: string, loginDomain: string, newPassword: string, tab: any) { + private async pushChangePasswordToQueue(cipherId: string, loginDomain: string, newPassword: string, tab: any, isVaultLocked: boolean = false) { // remove any old messages for this tab this.removeTabFromNotificationQueue(tab); - this.main.notificationQueue.push({ + const message: addChangePasswordQueueMessage = { type: 'changePassword', cipherId: cipherId, newPassword: newPassword, domain: loginDomain, tabId: tab.id, expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes - }); + wasVaultLocked: isVaultLocked, + }; + this.main.notificationQueue.push(message); await this.main.checkNotificationQueue(tab); } From 686c7fbfffd3dc4347825c8e2b60db84a8abc264 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:09:42 +0200 Subject: [PATCH 03/31] Pass vault state (locked/unlocked) to notificationBar --- src/background/main.background.ts | 7 +++++++ src/content/notificationBar.ts | 4 ++-- src/notification/bar.js | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index bc36b031d5..56d230aeba 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -676,13 +676,20 @@ export default class MainBackground { if (this.notificationQueue[i].tabId !== tab.id || this.notificationQueue[i].domain !== tabDomain) { continue; } + if (this.notificationQueue[i].type === 'addLogin') { BrowserApi.tabSendMessageData(tab, 'openNotificationBar', { type: 'add', + typeData: { + isVaultLocked: this.notificationQueue[i].wasVaultLocked, + }, }); } else if (this.notificationQueue[i].type === 'changePassword') { BrowserApi.tabSendMessageData(tab, 'openNotificationBar', { type: 'change', + typeData: { + isVaultLocked: this.notificationQueue[i].wasVaultLocked, + }, }); } break; diff --git a/src/content/notificationBar.ts b/src/content/notificationBar.ts index a3e215d411..13c7c7e354 100644 --- a/src/content/notificationBar.ts +++ b/src/content/notificationBar.ts @@ -444,10 +444,10 @@ document.addEventListener('DOMContentLoaded', event => { barPage = barPage + '?success=' + typeData.text; break; case 'add': - barPage = barPage + '?add=1'; + barPage = barPage + '?add=1&isVaultLocked=' + typeData.isVaultLocked; break; case 'change': - barPage = barPage + '?change=1'; + barPage = barPage + '?change=1&isVaultLocked=' + typeData.isVaultLocked; break; default: break; diff --git a/src/notification/bar.js b/src/notification/bar.js index b4d658577e..affa1e81b6 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -20,6 +20,7 @@ document.addEventListener('DOMContentLoaded', () => { setTimeout(load, 50); function load() { + const isVaultLocked = getQueryVariable('isVaultLocked') == 'true'; var closeButton = document.getElementById('close-button'), body = document.querySelector('body'), bodyRect = body.getBoundingClientRect(); From e0240c6884a433e843e71d2c08b73fdca9fd9551 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:13:29 +0200 Subject: [PATCH 04/31] Only retrieve folder list when vault is unlocked --- src/notification/bar.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/notification/bar.js b/src/notification/bar.js index affa1e81b6..6bfa9a2249 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -70,16 +70,18 @@ document.addEventListener('DOMContentLoaded', () => { }); }); - const responseFoldersCommand = 'notificationBarGetFoldersList'; - chrome.runtime.onMessage.addListener((msg) => { - if (msg.command === responseFoldersCommand && msg.data) { - fillSelectorWithFolders(msg.data.folders); - } - }); - sendPlatformMessage({ - command: 'bgGetDataForTab', - responseCommand: responseFoldersCommand - }); + if (!isVaultLocked) { + const responseFoldersCommand = 'notificationBarGetFoldersList'; + chrome.runtime.onMessage.addListener((msg) => { + if (msg.command === responseFoldersCommand && msg.data) { + fillSelectorWithFolders(msg.data.folders); + } + }); + sendPlatformMessage({ + command: 'bgGetDataForTab', + responseCommand: responseFoldersCommand + }); + } } else if (getQueryVariable('change')) { setContent(document.getElementById('template-change')); var changeButton = document.querySelector('#template-change-clone .change-save'); From 16e77645684c8548a162b0d3ebe2afbabbfc1b89 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:15:18 +0200 Subject: [PATCH 05/31] Hide folder selection when vault is locked --- src/notification/bar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notification/bar.js b/src/notification/bar.js index 6bfa9a2249..6a43cad20b 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -40,7 +40,7 @@ document.addEventListener('DOMContentLoaded', () => { } else { document.querySelector('#template-add .add-save').textContent = i18n.notificationAddSave; document.querySelector('#template-add .never-save').textContent = i18n.notificationNeverSave; - document.querySelector('#template-add .select-folder').style.display = 'initial'; + document.querySelector('#template-add .select-folder').style.display = isVaultLocked ? 'none' : 'initial'; document.querySelector('#template-add .select-folder').setAttribute('aria-label', i18n.folder); document.querySelector('#template-change .change-save').textContent = i18n.notificationChangeSave; } From 7aa4655512f0ae8a4c79f8f468cb98add621d2f9 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:17:59 +0200 Subject: [PATCH 06/31] Use Bitwarden product logo instead of company logo --- src/notification/bar.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/notification/bar.html b/src/notification/bar.html index d5b8c95b87..6262caa6cf 100644 --- a/src/notification/bar.html +++ b/src/notification/bar.html @@ -1,20 +1,24 @@ - + + Bitwarden + @@ -36,4 +40,5 @@
+ From 642af32c89460f4a0f8031fd8259c48cef9d9a3c Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:20:18 +0200 Subject: [PATCH 07/31] Show Bitwarden logo with lock when vault is locked --- src/notification/bar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/notification/bar.js b/src/notification/bar.js index 6a43cad20b..4e7871b872 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -3,7 +3,7 @@ require('./bar.scss'); document.addEventListener('DOMContentLoaded', () => { var i18n = {}; var lang = window.navigator.language; - + i18n.appName = chrome.i18n.getMessage('appName'); i18n.close = chrome.i18n.getMessage('close'); i18n.yes = chrome.i18n.getMessage('yes'); @@ -16,11 +16,16 @@ document.addEventListener('DOMContentLoaded', () => { i18n.notificationChangeDesc = chrome.i18n.getMessage('notificationChangeDesc'); lang = chrome.i18n.getUILanguage(); + const lockedImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhE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l62zOUUry3p4+Ne/oYiN05lcyvc5bRiXeBGYYaKMV4pCfOS+29HDwTQ+tJoslJ2bLSneop1W7Fbd7fF+LVbb18dzFBxtYk0+VTCp1JOWbURPckomZTOYl+9adp2X0TAN9gtnywbGJQur3J456HE11lZxuVEgbpMvxpQNvphAOgbm6kpd9p+62wt61csJT3KU4kg8wSKrf+FSoLOCGUysA5cc/P4dCMrcl4xQqlpKcUMJHup+ryhxD/sxQ7Bly0oelfwo2jbs49CP4AAAAASUVORK5CYII="; // delay 50ms so that we get proper body dimensions setTimeout(load, 50); function load() { const isVaultLocked = getQueryVariable('isVaultLocked') == 'true'; + if (isVaultLocked) { + document.getElementById('logo').src = lockedImage; + } + var closeButton = document.getElementById('close-button'), body = document.querySelector('body'), bodyRect = body.getBoundingClientRect(); From 5c175e2201f4f4ceac9ef9eb864a6679115cb7b4 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:33:33 +0200 Subject: [PATCH 08/31] Open login prompt as popout when vault is locked --- src/background/main.background.ts | 2 +- src/background/runtime.background.ts | 6 +++++- src/notification/bar.js | 26 ++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 56d230aeba..288ca3f729 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -240,7 +240,7 @@ export default class MainBackground { this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService, this.notificationsService, this.systemService, this.vaultTimeoutService, - this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService); + this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService, this.popupUtilsService); this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService, this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService, this.platformUtilsService); diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index afe4409377..733147eaa4 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -16,6 +16,7 @@ import { SystemService } from 'jslib-common/abstractions/system.service'; import { UserService } from 'jslib-common/abstractions/user.service'; import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service'; import { ConstantsService } from 'jslib-common/services/constants.service'; +import { PopupUtilsService } from '../popup/services/popup-utils.service'; import { AutofillService } from '../services/abstractions/autofill.service'; import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service'; @@ -43,7 +44,7 @@ export default class RuntimeBackground { private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService, private environmentService: EnvironmentService, private policyService: PolicyService, private userService: UserService, private messagingService: MessagingService, - private folderService: FolderService) { + private folderService: FolderService, private popupUtilsService: PopupUtilsService) { // onInstalled listener must be wired up before anything else, so we do it in the ctor chrome.runtime.onInstalled.addListener((details: any) => { @@ -82,6 +83,9 @@ export default class RuntimeBackground { case 'openPopup': await this.main.openPopup(); break; + case 'openPopout': + await this.popupUtilsService.popOut(window, 'popup/index.html?uilocation=popout'); + break; case 'showDialogResolve': this.platformUtilsService.resolveDialogPromise(msg.dialogId, msg.confirmed); break; diff --git a/src/notification/bar.js b/src/notification/bar.js index 4e7871b872..e26132b522 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -61,11 +61,21 @@ document.addEventListener('DOMContentLoaded', () => { addButton.addEventListener('click', (e) => { e.preventDefault(); + const folderId = document.querySelector('#template-add-clone .select-folder').value; - sendPlatformMessage({ + + const bgAddSaveMessage = { command: 'bgAddSave', folder: folderId, - }); + }; + + if (isVaultLocked) { + sendPlatformMessage({ + command: 'openPopout' + }); + } + + sendPlatformMessage(bgAddSaveMessage); }); neverButton.addEventListener('click', (e) => { @@ -92,9 +102,17 @@ document.addEventListener('DOMContentLoaded', () => { var changeButton = document.querySelector('#template-change-clone .change-save'); changeButton.addEventListener('click', (e) => { e.preventDefault(); - sendPlatformMessage({ + + const bgChangeSaveMessage = { command: 'bgChangeSave' - }); + }; + + if (isVaultLocked) { + sendPlatformMessage({ + command: 'openPopout' + }); + } + sendPlatformMessage(bgChangeSaveMessage); }); } else if (getQueryVariable('info')) { setContent(document.getElementById('template-alert')); From 838bfe94547ec004246ff03ddb83574341ef0b77 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:43:10 +0200 Subject: [PATCH 09/31] Wait for user to log in before trying to save credentials --- src/background/main.background.ts | 1 + src/background/runtime.background.ts | 40 +++++++++++++++------------- src/notification/bar.js | 12 +++++++++ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 288ca3f729..1671946e11 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -127,6 +127,7 @@ export default class MainBackground { onReplacedRan: boolean; loginToAutoFill: any = null; notificationQueue: any[] = []; + retryQueue: any[] = []; private commandsBackground: CommandsBackground; private contextMenusBackground: ContextMenusBackground; diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 733147eaa4..2722ccd303 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -71,6 +71,18 @@ export default class RuntimeBackground { await this.main.refreshBadgeAndMenu(false); this.notificationsService.updateConnection(msg.command === 'unlocked'); this.systemService.cancelProcessReload(); + + if (this.main.retryQueue.length > 0) { + const retryItem = this.main.retryQueue.pop(); + await this.processMessage(retryItem.msg, retryItem.sender, null); + } + break; + case 'addToRetryQueue': + const retryMessage = { + msg: msg.retryItem, + sender: sender, + }; + this.main.retryQueue.push(retryMessage); break; case 'logout': await this.main.logout(msg.expired); @@ -224,10 +236,6 @@ export default class RuntimeBackground { } private async saveAddLogin(tab: any, folderId: string) { - console.log('saveAddLogin triggered'); - if (await this.vaultTimeoutService.isLocked()) { - return; - } for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) { const queueMessage = this.main.notificationQueue[i]; @@ -268,10 +276,6 @@ export default class RuntimeBackground { } private async saveChangePassword(tab: any) { - console.log('saveChangePassword triggered'); - if (await this.vaultTimeoutService.isLocked()) { - return; - } for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) { const queueMessage = this.main.notificationQueue[i]; @@ -361,20 +365,20 @@ export default class RuntimeBackground { } private async pushAddLoginToQueue(loginDomain: string, loginInfo: any, tab: any, isVaultLocked: boolean = false) { - // remove any old messages for this tab - this.removeTabFromNotificationQueue(tab); + // remove any old messages for this tab + this.removeTabFromNotificationQueue(tab); const message: addLoginQueueMessage = { - type: 'addLogin', - username: loginInfo.username, - password: loginInfo.password, - domain: loginDomain, - uri: loginInfo.url, - tabId: tab.id, - expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes + type: 'addLogin', + username: loginInfo.username, + password: loginInfo.password, + domain: loginDomain, + uri: loginInfo.url, + tabId: tab.id, + expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes wasVaultLocked: isVaultLocked, }; this.main.notificationQueue.push(message); - await this.main.checkNotificationQueue(tab); + await this.main.checkNotificationQueue(tab); } private async changedPassword(changeData: any, tab: any) { diff --git a/src/notification/bar.js b/src/notification/bar.js index e26132b522..a010226907 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -73,6 +73,12 @@ document.addEventListener('DOMContentLoaded', () => { sendPlatformMessage({ command: 'openPopout' }); + + sendPlatformMessage({ + command: 'addToRetryQueue', + retryItem: bgAddSaveMessage + }); + return; } sendPlatformMessage(bgAddSaveMessage); @@ -111,6 +117,12 @@ document.addEventListener('DOMContentLoaded', () => { sendPlatformMessage({ command: 'openPopout' }); + + sendPlatformMessage({ + command: 'addToRetryQueue', + retryItem: bgChangeSaveMessage, + }); + return; } sendPlatformMessage(bgChangeSaveMessage); }); From de0e9a4d9425ca8805405c51154834488927283e Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:48:06 +0200 Subject: [PATCH 10/31] Combined saving credentials and added fallback to update only password if only that changed --- src/background/runtime.background.ts | 103 ++++++++++++++++----------- 1 file changed, 61 insertions(+), 42 deletions(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 2722ccd303..948139ccc1 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -127,10 +127,8 @@ export default class RuntimeBackground { this.removeTabFromNotificationQueue(sender.tab); break; case 'bgAddSave': - await this.saveAddLogin(sender.tab, msg.folder); - break; case 'bgChangeSave': - await this.saveChangePassword(sender.tab); + await this.saveOrUpdateCredentials(sender.tab, msg.folder); break; case 'bgNeverSave': await this.saveNever(sender.tab); @@ -235,11 +233,11 @@ export default class RuntimeBackground { this.pageDetailsToAutoFill = []; } - private async saveAddLogin(tab: any, folderId: string) { - + private async saveOrUpdateCredentials(tab: any, folderId?: string) { for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) { const queueMessage = this.main.notificationQueue[i]; - if (queueMessage.tabId !== tab.id || queueMessage.type !== 'addLogin') { + if (queueMessage.tabId !== tab.id || + (queueMessage.type !== 'addLogin' && queueMessage.type !== 'changePassword')) { continue; } @@ -251,53 +249,74 @@ export default class RuntimeBackground { this.main.notificationQueue.splice(i, 1); BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); - const loginModel = new LoginView(); - const loginUri = new LoginUriView(); - loginUri.uri = queueMessage.uri; - loginModel.uris = [loginUri]; - loginModel.username = queueMessage.username; - loginModel.password = queueMessage.password; - const model = new CipherView(); - model.name = Utils.getHostname(queueMessage.uri) || queueMessage.domain; - model.name = model.name.replace(/^www\./, ''); - model.type = CipherType.Login; - model.login = loginModel; - - if (!Utils.isNullOrWhitespace(folderId)) { - const folders = await this.folderService.getAllDecrypted(); - if (folders.some(x => x.id === folderId)) { - model.folderId = folderId; + if (queueMessage.type === 'changePassword') { + const message = (queueMessage as addChangePasswordQueueMessage); + const cipher = await this.getDecryptedCipherById(message.cipherId); + if (cipher == null) { + return; } + await this.updateCipher(cipher, message.newPassword); + return; } - const cipher = await this.cipherService.encrypt(model); - await this.cipherService.saveWithServer(cipher); + if (!queueMessage.wasVaultLocked) { + await this.createNewCipher(queueMessage, folderId); + } + + // If the vault was locked, check if a cipher needs updating instead of creating a new one + if (queueMessage.type === 'addLogin' && queueMessage.wasVaultLocked === true) { + const message = (queueMessage as addLoginQueueMessage); + const ciphers = await this.cipherService.getAllDecryptedForUrl(message.uri); + const usernameMatches = ciphers.filter(c => c.login.username != null && + c.login.username.toLowerCase() === message.username); + + if (usernameMatches.length === 1) { + await this.updateCipher(usernameMatches[0], message.password); + return; + } + + await this.createNewCipher(message, folderId); + } } } - private async saveChangePassword(tab: any) { + private async createNewCipher(queueMessage: addLoginQueueMessage, folderId: string) { + const loginModel = new LoginView(); + const loginUri = new LoginUriView(); + loginUri.uri = queueMessage.uri; + loginModel.uris = [loginUri]; + loginModel.username = queueMessage.username; + loginModel.password = queueMessage.password; + const model = new CipherView(); + model.name = Utils.getHostname(queueMessage.uri) || queueMessage.domain; + model.name = model.name.replace(/^www\./, ''); + model.type = CipherType.Login; + model.login = loginModel; - for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) { - const queueMessage = this.main.notificationQueue[i]; - if (queueMessage.tabId !== tab.id || queueMessage.type !== 'changePassword') { - continue; + if (!Utils.isNullOrWhitespace(folderId)) { + const folders = await this.folderService.getAllDecrypted(); + if (folders.some(x => x.id === folderId)) { + model.folderId = folderId; } + } - const tabDomain = Utils.getDomain(tab.url); - if (tabDomain != null && tabDomain !== queueMessage.domain) { - continue; - } + const cipher = await this.cipherService.encrypt(model); + await this.cipherService.saveWithServer(cipher); + } - this.main.notificationQueue.splice(i, 1); - BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); + private async getDecryptedCipherById(cipherId: string) { + const cipher = await this.cipherService.get(cipherId); + if (cipher != null && cipher.type === CipherType.Login) { + return await cipher.decrypt(); + } + return null; + } - const cipher = await this.cipherService.get(queueMessage.cipherId); - if (cipher != null && cipher.type === CipherType.Login) { - const model = await cipher.decrypt(); - model.login.password = queueMessage.newPassword; - const newCipher = await this.cipherService.encrypt(model); - await this.cipherService.saveWithServer(newCipher); - } + private async updateCipher(cipher: CipherView, newPassword: string) { + if (cipher != null && cipher.type === CipherType.Login) { + cipher.login.password = newPassword; + const newCipher = await this.cipherService.encrypt(cipher); + await this.cipherService.saveWithServer(newCipher); } } From 705c287e1a1b4eac7313407a50abb5921f102d80 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:50:17 +0200 Subject: [PATCH 11/31] Removed unneeded alert/info functionality from notificationBar --- src/background/runtime.background.ts | 3 --- src/content/notificationBar.ts | 12 ------------ src/notification/bar.html | 3 +-- src/notification/bar.js | 3 --- 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 948139ccc1..2fce414f08 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -104,9 +104,6 @@ export default class RuntimeBackground { case 'bgGetDataForTab': await this.getDataForTab(sender.tab, msg.responseCommand); break; - case 'bgOpenNotificationBar': - await BrowserApi.tabSendMessageData(sender.tab, 'openNotificationBar', msg.data); - break; case 'bgCloseNotificationBar': await BrowserApi.tabSendMessageData(sender.tab, 'closeNotificationBar'); break; diff --git a/src/content/notificationBar.ts b/src/content/notificationBar.ts index 13c7c7e354..103b819d6e 100644 --- a/src/content/notificationBar.ts +++ b/src/content/notificationBar.ts @@ -431,18 +431,6 @@ document.addEventListener('DOMContentLoaded', event => { function closeExistingAndOpenBar(type: string, typeData: any) { let barPage = 'notification/bar.html'; switch (type) { - case 'info': - barPage = barPage + '?info=' + typeData.text; - break; - case 'warning': - barPage = barPage + '?warning=' + typeData.text; - break; - case 'error': - barPage = barPage + '?error=' + typeData.text; - break; - case 'success': - barPage = barPage + '?success=' + typeData.text; - break; case 'add': barPage = barPage + '?add=1&isVaultLocked=' + typeData.isVaultLocked; break; diff --git a/src/notification/bar.html b/src/notification/bar.html index 6262caa6cf..533e0deeb6 100644 --- a/src/notification/bar.html +++ b/src/notification/bar.html @@ -1,4 +1,4 @@ - + @@ -37,7 +37,6 @@ -
diff --git a/src/notification/bar.js b/src/notification/bar.js index a010226907..c299482b63 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -126,9 +126,6 @@ document.addEventListener('DOMContentLoaded', () => { } sendPlatformMessage(bgChangeSaveMessage); }); - } else if (getQueryVariable('info')) { - setContent(document.getElementById('template-alert')); - document.getElementById('template-alert-clone').textContent = getQueryVariable('info'); } closeButton.addEventListener('click', (e) => { From 83ef310400eb9916a33e7a04d9a396d3fc6a12bb Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:51:53 +0200 Subject: [PATCH 12/31] Removed dead code from getDataForTab --- src/background/runtime.background.ts | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 2fce414f08..2bf14393b0 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -476,29 +476,7 @@ export default class RuntimeBackground { private async getDataForTab(tab: any, responseCommand: string) { const responseData: any = {}; - if (responseCommand === 'notificationBarDataResponse') { - responseData.neverDomains = await this.storageService.get(ConstantsService.neverDomainsKey); - const disableAddLoginFromOptions = await this.storageService.get( - ConstantsService.disableAddLoginNotificationKey); - responseData.disabledAddLoginNotification = disableAddLoginFromOptions || !(await this.allowPersonalOwnership()); - responseData.disabledChangedPasswordNotification = await this.storageService.get( - ConstantsService.disableChangedPasswordNotificationKey); - } else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') { - responseData.autofillEnabled = await this.storageService.get( - ConstantsService.enableAutoFillOnPageLoadKey); - } else if (responseCommand === 'notificationBarFrameDataResponse') { - responseData.i18n = { - appName: this.i18nService.t('appName'), - close: this.i18nService.t('close'), - yes: this.i18nService.t('yes'), - never: this.i18nService.t('never'), - notificationAddSave: this.i18nService.t('notificationAddSave'), - notificationNeverSave: this.i18nService.t('notificationNeverSave'), - notificationAddDesc: this.i18nService.t('notificationAddDesc'), - notificationChangeSave: this.i18nService.t('notificationChangeSave'), - notificationChangeDesc: this.i18nService.t('notificationChangeDesc'), - }; - } else if (responseCommand === 'notificationBarGetFoldersList') { + if (responseCommand === 'notificationBarGetFoldersList') { responseData.folders = await this.folderService.getAllDecrypted(); } From 23517272fdbcfd10b6e9db1597004e67813ea986 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:56:04 +0200 Subject: [PATCH 13/31] saveOrUpdateCredentials: If more than one matching fallback cipher is found, update atleast the first one of them, to ensure saving PW change --- src/background/runtime.background.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 2bf14393b0..2e3ea993c9 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -267,7 +267,7 @@ export default class RuntimeBackground { const usernameMatches = ciphers.filter(c => c.login.username != null && c.login.username.toLowerCase() === message.username); - if (usernameMatches.length === 1) { + if (usernameMatches.length >= 1) { await this.updateCipher(usernameMatches[0], message.password); return; } From 418f37de8cb0388a0173126b1c60583008017b9b Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 30 Sep 2021 16:58:48 +0200 Subject: [PATCH 14/31] Remove console.log --- src/background/runtime.background.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 2e3ea993c9..67d23d26ad 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -338,7 +338,6 @@ export default class RuntimeBackground { } private async addLogin(loginInfo: any, tab: any) { - console.log('addLogin triggered'); const loginDomain = Utils.getDomain(loginInfo.url); if (loginDomain == null) { return; From 75c8c4205fc041592fc7a310e9c55d7384ccae57 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Fri, 8 Oct 2021 13:23:05 +0200 Subject: [PATCH 15/31] Move retryQueue from main to runtime and rename it to lockedVaultPendingNotifications --- src/background/main.background.ts | 1 - src/background/runtime.background.ts | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 4a813f191c..2e78aad86a 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -127,7 +127,6 @@ export default class MainBackground { onReplacedRan: boolean; loginToAutoFill: any = null; notificationQueue: any[] = []; - retryQueue: any[] = []; private commandsBackground: CommandsBackground; private contextMenusBackground: ContextMenusBackground; diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 67d23d26ad..03825d43f2 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -37,6 +37,8 @@ export default class RuntimeBackground { private pageDetailsToAutoFill: any[] = []; private onInstalledReason: string = null; + private lockedVaultPendingNotifications: any[] = []; + constructor(private main: MainBackground, private autofillService: AutofillService, private cipherService: CipherService, private platformUtilsService: BrowserPlatformUtilsService, private storageService: StorageService, private i18nService: I18nService, @@ -72,8 +74,8 @@ export default class RuntimeBackground { this.notificationsService.updateConnection(msg.command === 'unlocked'); this.systemService.cancelProcessReload(); - if (this.main.retryQueue.length > 0) { - const retryItem = this.main.retryQueue.pop(); + if (this.lockedVaultPendingNotifications.length > 0) { + const retryItem = this.lockedVaultPendingNotifications.pop(); await this.processMessage(retryItem.msg, retryItem.sender, null); } break; @@ -82,7 +84,7 @@ export default class RuntimeBackground { msg: msg.retryItem, sender: sender, }; - this.main.retryQueue.push(retryMessage); + this.lockedVaultPendingNotifications.push(retryMessage); break; case 'logout': await this.main.logout(msg.expired); From 042c7677e84d3a92b163cc90bc974df7a7b4317e Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Fri, 8 Oct 2021 13:28:07 +0200 Subject: [PATCH 16/31] Removed base64 encoded images and load them from path instead --- src/images/close.png | Bin 0 -> 288 bytes src/manifest.json | 5 ++++- src/notification/bar.html | 12 ++---------- src/notification/bar.js | 9 +++++---- 4 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 src/images/close.png diff --git a/src/images/close.png b/src/images/close.png new file mode 100644 index 0000000000000000000000000000000000000000..ccbb3b1d5c706eb45f148494fa8f08c5eaa057c7 GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^av;pY3?xs=ZJr3E7>k44ofvPP)Tsw@I14-?iy0Wi zR6&^0Gf3qFP*5nqC&U#<8>51JnXIQkQMQsGzhDN31^*M~A9y|82`Dnv)5S5QVovD9 zi=2lIcwDYNVC0HaxS)3-=68Mp`-y*-ubg_htGn literal 0 HcmV?d00001 diff --git a/src/manifest.json b/src/manifest.json index 316a943203..15b78418a6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -128,7 +128,10 @@ } }, "web_accessible_resources": [ - "notification/bar.html" + "notification/bar.html", + "images/icon38.png", + "images/icon38_locked.png", + "images/close.png" ], "applications": { "gecko": { diff --git a/src/notification/bar.html b/src/notification/bar.html index 0b0b29417c..5c82a4e4d3 100644 --- a/src/notification/bar.html +++ b/src/notification/bar.html @@ -10,22 +10,14 @@
-<<<<<<< HEAD - - X - -======= ->>>>>>> a3876db30bdfb5ac42bda44ec02a728a52ae149c
diff --git a/src/notification/bar.js b/src/notification/bar.js index 318207de36..4cad508a05 100644 --- a/src/notification/bar.js +++ b/src/notification/bar.js @@ -26,6 +26,7 @@ document.addEventListener('DOMContentLoaded', () => { : chrome.runtime.getURL('images/icon38.png'); document.getElementById('close').src = chrome.runtime.getURL('images/close.png'); + document.getElementById('close').alt = i18n.close; var closeButton = document.getElementById('close-button'), body = document.querySelector('body'), From d8dbeab911eb4436ab2522ef91669d0b73abb52c Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Wed, 13 Oct 2021 22:32:43 +0200 Subject: [PATCH 29/31] Position the unlock button closer to the master password entry --- src/popup/scss/base.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/popup/scss/base.scss b/src/popup/scss/base.scss index 92716c2d37..a1c5806457 100644 --- a/src/popup/scss/base.scss +++ b/src/popup/scss/base.scss @@ -347,8 +347,12 @@ app-root { } @media only screen and (min-width: 601px) { + app-lock header { + padding: 0 calc((100% - 500px) / 2) + } + app-lock content { - padding: 0 35%; + padding: 0 calc((100% - 500px) / 2) } } From 732f065012846019527748556c4a3c1419c0c507 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 14 Oct 2021 18:59:38 +0200 Subject: [PATCH 30/31] Add missing semicolons to base.scss --- src/popup/scss/base.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/popup/scss/base.scss b/src/popup/scss/base.scss index a1c5806457..2cda55e9b5 100644 --- a/src/popup/scss/base.scss +++ b/src/popup/scss/base.scss @@ -348,11 +348,11 @@ app-root { @media only screen and (min-width: 601px) { app-lock header { - padding: 0 calc((100% - 500px) / 2) + padding: 0 calc((100% - 500px) / 2); } app-lock content { - padding: 0 calc((100% - 500px) / 2) + padding: 0 calc((100% - 500px) / 2); } } From 40ba8a5cde484b5978217312a3492b6e2ec4c19b Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Thu, 14 Oct 2021 19:05:02 +0200 Subject: [PATCH 31/31] Removed devepency on popupUtilsService as not needed for login via Tab --- src/background/main.background.ts | 2 +- src/background/runtime.background.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 2e78aad86a..f3538028db 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -240,7 +240,7 @@ export default class MainBackground { this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService, this.notificationsService, this.systemService, this.vaultTimeoutService, - this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService, this.popupUtilsService); + this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService); this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService, this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService, this.platformUtilsService); diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index bcee42cdce..a46d174aac 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -16,7 +16,6 @@ import { SystemService } from 'jslib-common/abstractions/system.service'; import { UserService } from 'jslib-common/abstractions/user.service'; import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service'; import { ConstantsService } from 'jslib-common/services/constants.service'; -import { PopupUtilsService } from '../popup/services/popup-utils.service'; import { AutofillService } from '../services/abstractions/autofill.service'; import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service'; @@ -46,7 +45,7 @@ export default class RuntimeBackground { private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService, private environmentService: EnvironmentService, private policyService: PolicyService, private userService: UserService, private messagingService: MessagingService, - private folderService: FolderService, private popupUtilsService: PopupUtilsService) { + private folderService: FolderService) { // onInstalled listener must be wired up before anything else, so we do it in the ctor chrome.runtime.onInstalled.addListener((details: any) => {