From 548b59f5a2d06f28ba2686c0c3d8bbec9d97e8b1 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Mon, 12 Feb 2018 09:44:08 +0200 Subject: [PATCH] Version 0.5.2 --- CHANGELOG | 11 +++ keepassxc-browser/background/browserAction.js | 68 ++++++++++--------- keepassxc-browser/background/event.js | 2 +- keepassxc-browser/background/httpauth.js | 22 ++++-- keepassxc-browser/background/keepass.js | 4 +- keepassxc-browser/background/page.js | 6 +- keepassxc-browser/global.js | 9 +++ keepassxc-browser/keepassxc-browser.js | 16 ++--- keepassxc-browser/manifest.json | 3 +- keepassxc-browser/options/options.html | 9 +++ 10 files changed, 101 insertions(+), 49 deletions(-) mode change 100644 => 100755 CHANGELOG mode change 100644 => 100755 keepassxc-browser/background/browserAction.js mode change 100644 => 100755 keepassxc-browser/background/event.js mode change 100644 => 100755 keepassxc-browser/background/httpauth.js mode change 100644 => 100755 keepassxc-browser/background/keepass.js mode change 100644 => 100755 keepassxc-browser/background/page.js mode change 100644 => 100755 keepassxc-browser/global.js mode change 100644 => 100755 keepassxc-browser/keepassxc-browser.js mode change 100644 => 100755 keepassxc-browser/manifest.json mode change 100644 => 100755 keepassxc-browser/options/options.html diff --git a/CHANGELOG b/CHANGELOG old mode 100644 new mode 100755 index 5e8a773..640c8e2 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +0.5.2 (02-02-2018) +========================= +- Choose own credential fields saves the full URL instead of host +- HTTP Auth no longer gets stuck when there are no credentials available +- Added option to show notifications (enabled by default) +- Added notifications for HTTP Auth and saving new credentialsList (new permission needed) + +0.5.1 (23-01-2018) +========================= +- Fixed unnecessary credential retrieving when input fields are not available + 0.5.0 (22-01-2018) ========================= - Fixed an error when filling only a password diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js old mode 100644 new mode 100755 index c2a78fc..7b72292 --- a/keepassxc-browser/background/browserAction.js +++ b/keepassxc-browser/background/browserAction.js @@ -200,43 +200,49 @@ browserAction.removeRememberPopup = function(callback, tab, removeImmediately) { }; browserAction.setRememberPopup = function(tabId, username, password, url, usernameExists, credentialsList) { - const settings = typeof(localStorage.settings) === 'undefined' ? {} : JSON.parse(localStorage.settings); - const id = tabId || page.currentTabId; - let timeoutMinMillis = Number(getValueOrDefault(settings, 'blinkMinTimeout', BLINK_TIMEOUT_REDIRECT_THRESHOLD_TIME_DEFAULT, 0)); + browser.storage.local.get({'settings': {}}).then(function(item) { + const settings = item.settings; + const id = tabId || page.currentTabId; + let timeoutMinMillis = Number(getValueOrDefault(settings, 'blinkMinTimeout', BLINK_TIMEOUT_REDIRECT_THRESHOLD_TIME_DEFAULT, 0)); - if (timeoutMinMillis > 0) { - timeoutMinMillis += Date.now(); - } + if (timeoutMinMillis > 0) { + timeoutMinMillis += Date.now(); + } - const blinkTimeout = getValueOrDefault(settings, 'blinkTimeout', BLINK_TIMEOUT_DEFAULT, 0); - const pageUpdateAllowance = getValueOrDefault(settings, 'allowedRedirect', BLINK_TIMEOUT_REDIRECT_COUNT_DEFAULT, 0); + const blinkTimeout = getValueOrDefault(settings, 'blinkTimeout', BLINK_TIMEOUT_DEFAULT, 0); + const pageUpdateAllowance = getValueOrDefault(settings, 'allowedRedirect', BLINK_TIMEOUT_REDIRECT_COUNT_DEFAULT, 0); - const stackData = { - visibleForMilliSeconds: blinkTimeout, - visibleForPageUpdates: pageUpdateAllowance, - redirectOffset: timeoutMinMillis, - level: 10, - intervalIcon: { - index: 0, - counter: 0, - max: 2, - icons: ['icon_remember_red_background_19x19.png', 'icon_remember_red_lock_19x19.png'] - }, - icon: 'icon_remember_red_background_19x19.png', - popup: 'popup_remember.html' - }; + const stackData = { + visibleForMilliSeconds: blinkTimeout, + visibleForPageUpdates: pageUpdateAllowance, + redirectOffset: timeoutMinMillis, + level: 10, + intervalIcon: { + index: 0, + counter: 0, + max: 2, + icons: ['icon_remember_red_background_19x19.png', 'icon_remember_red_lock_19x19.png'] + }, + icon: 'icon_remember_red_background_19x19.png', + popup: 'popup_remember.html' + }; - browserAction.stackPush(stackData, id); + browserAction.stackPush(stackData, id); - page.tabs[id].credentials = { - username: username, - password: password, - url: url, - usernameExists: usernameExists, - list: credentialsList - }; + page.tabs[id].credentials = { + username: username, + password: password, + url: url, + usernameExists: usernameExists, + list: credentialsList + }; - browserAction.show(null, {'id': id}); + browserAction.show(null, {'id': id}); + + if (page.settings.showNotifications) { + showNotification('Create or modify the credentials by clicking on the extension icon.'); + } + }); }; function getValueOrDefault(settings, key, defaultVal, min) { diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js old mode 100644 new mode 100755 index f87ad10..8bbd797 --- a/keepassxc-browser/background/event.js +++ b/keepassxc-browser/background/event.js @@ -198,7 +198,7 @@ kpxcEvent.onGetKeePassXCVersions = function(callback, tab) { }, tab); } else { callback({"current": keepass.currentKeePassXC.version, "latest": keepass.currentKeePassXC.version}); -} + } }; kpxcEvent.onCheckUpdateKeePassXC = function(callback, tab) { diff --git a/keepassxc-browser/background/httpauth.js b/keepassxc-browser/background/httpauth.js old mode 100644 new mode 100755 index d6eede0..5457caa --- a/keepassxc-browser/background/httpauth.js +++ b/keepassxc-browser/background/httpauth.js @@ -45,9 +45,17 @@ httpAuth.handleRequestCallback = function(details, callback) { httpAuth.processPendingCallbacks(details, callback, callback); }; -httpAuth.processPendingCallbacks = function(details, resolve, reject) { +httpAuth.retrieveCredentials = function(tabId, url, submitUrl, forceCallback) { + return new Promise((resolve, reject) => { + keepass.retrieveCredentials((logins) => { + resolve(logins); + }, tabId, url, submitUrl, forceCallback); + }); +}; + +httpAuth.processPendingCallbacks = async function(details, resolve, reject) { if (httpAuth.requests.indexOf(details.requestId) >= 0 || !page.tabs[details.tabId]) { - reject({}); + reject({cancel: false}); return; } @@ -59,9 +67,8 @@ httpAuth.processPendingCallbacks = function(details, resolve, reject) { details.searchUrl = (details.isProxy && details.proxyUrl) ? details.proxyUrl : details.url; - keepass.retrieveCredentials((logins) => { - httpAuth.loginOrShowCredentials(logins, details, resolve, reject); - }, { "id": details.tabId }, details.searchUrl, details.searchUrl, true); + const logins = await httpAuth.retrieveCredentials({ 'id': details.tabId }, details.searchUrl, details.searchUrl, true); + httpAuth.loginOrShowCredentials(logins, details, resolve, reject); }; httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) { @@ -75,11 +82,14 @@ httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) { } }); } else { + if (page.settings.showNotifications) { + showNotification('Multiple credentials detected. Click on the extension icon to choose the correct one.'); + } kpxcEvent.onHTTPAuthPopup(null, { 'id': details.tabId }, { 'logins': logins, 'url': details.searchUrl, 'resolve': resolve }); } } // no logins found else { - reject({}); + reject({cancel: false}); } }; diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js old mode 100644 new mode 100755 index 95fcb00..e734ca1 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -62,7 +62,7 @@ const kpErrors = { 4: { msg: 'Cannot decrypt message' }, 5: { msg: 'Timeout or not connected to KeePassXC' }, 6: { msg: 'Action cancelled or denied' }, - 7: { msg: 'Cannot encrypt message or public key not found. Is Native Messaging enabled in KeePassXC?' }, + 7: { msg: 'Cannot encrypt message or public key not found. Is native messaging or support for your browser enabled in KeePassXC?' }, 8: { msg: 'KeePassXC association failed, try again.' }, 9: { msg: 'Key change was not successful.' }, 10: { msg: 'Encryption key is not recognized' }, @@ -265,9 +265,11 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb } else if (response.error && response.errorCode) { keepass.handleError(tab, response.errorCode, response.error); + callback([]); } else { browserAction.showDefault(null, tab); + callback([]); } }); }, tab, false, triggerUnlock); diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js old mode 100644 new mode 100755 index bcc126b..f82b2ea --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -4,7 +4,8 @@ const defaultSettings = { autoFillAndSend: true, usePasswordGenerator: true, autoFillSingleEntry: false, - autoRetrieveCredentials: true + autoRetrieveCredentials: true, + showNotifications: true }; var page = {}; @@ -34,6 +35,9 @@ page.initSettings = function() { if (!('autoRetrieveCredentials' in page.settings)) { page.settings.autoRetrieveCredentials = defaultSettings.autoRetrieveCredentials; } + if (!('showNotifications' in page.settings)) { + page.settings.showNotifications = defaultSettings.showNotifications; + } browser.storage.local.set({'settings': page.settings}); resolve(page.settings); }); diff --git a/keepassxc-browser/global.js b/keepassxc-browser/global.js old mode 100644 new mode 100755 index 8f38453..558dc9d --- a/keepassxc-browser/global.js +++ b/keepassxc-browser/global.js @@ -4,3 +4,12 @@ var isFirefox = function() { } return false; }; + +var showNotification = function(message) { + browser.notifications.create({ + 'type': 'basic', + 'iconUrl': browser.extension.getURL('icons/keepassxc_64x64.png'), + 'title': 'KeePassXC-Browser', + 'message': message + }); +}; diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js old mode 100644 new mode 100755 index 2cbec96..9fe2f78 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -623,7 +623,7 @@ cipDefine.initDescription = function() { fieldIds.push(cipFields.prepareId(i)); } - cip.settings['defined-credential-fields'][document.location.origin] = { + cip.settings['defined-credential-fields'][document.location.href] = { username: cipDefine.selection.username, password: cipDefine.selection.password, fields: fieldIds @@ -643,7 +643,7 @@ cipDefine.initDescription = function() { $description.append($btnAgain); $description.append($btnDismiss); - if (cip.settings['defined-credential-fields'] && cip.settings['defined-credential-fields'][document.location.origin]) { + if (cip.settings['defined-credential-fields'] && cip.settings['defined-credential-fields'][document.location.href]) { const $p = jQuery('

').html('For this page credential fields are already selected and will be overwritten.
'); const $btnDiscard = jQuery('