diff --git a/CHANGELOG b/CHANGELOG index f5642dc..adf145c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ -0.2.9 (2017-??-??) +0.2.9 (2017-08-27) ========================= -- Code cleaning, global functions +- Code cleaning, global functions moved to global.js +- New popup state and button when database is closed or locked +- Fixed HTTP auth login with Chrome/Chromium/Vivaldi 0.2.8 (2017-08-08) ========================= diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js index c2f4dc7..39fa94c 100644 --- a/keepassxc-browser/background/browserAction.js +++ b/keepassxc-browser/background/browserAction.js @@ -3,6 +3,8 @@ var browserAction = {}; const BLINK_TIMEOUT_DEFAULT = 7500; const BLINK_TIMEOUT_REDIRECT_THRESHOLD_TIME_DEFAULT = -1; const BLINK_TIMEOUT_REDIRECT_COUNT_DEFAULT = 1; +const MAXIMUM_POLL_COUNT = 8; // _interval (250 ms) * 8 = 2 sec +let databasePollCount = 0; browserAction.show = function(callback, tab) { let data = {}; @@ -34,6 +36,21 @@ browserAction.update = function(interval) { let data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1]; + // Poll the database if it's open or closed + if (databasePollCount >= MAXIMUM_POLL_COUNT) { + if (keepass.isKeePassXCAvailable) { + keepass.testAssociation((response) => { + keepass.isConfigured((configured) => { + data.iconType = configured ? 'normal' : 'cross'; + browserAction.show(null, {'id': page.currentTabId}); + }); + }, null); + } + databasePollCount = 0; + } else { + databasePollCount += 1; + } + if (typeof data.visibleForMilliSeconds !== 'undefined') { if (data.visibleForMilliSeconds <= 0) { browserAction.stackPop(page.currentTabId); diff --git a/keepassxc-browser/background/httpauth.js b/keepassxc-browser/background/httpauth.js index 065f362..5c91eca 100644 --- a/keepassxc-browser/background/httpauth.js +++ b/keepassxc-browser/background/httpauth.js @@ -2,12 +2,12 @@ var httpAuth = httpAuth || {}; httpAuth.pendingCallbacks = []; httpAuth.requestId = ''; -httpAuth.callback = null; httpAuth.tabId = 0; httpAuth.url = null; httpAuth.isProxy = false; httpAuth.proxyUrl = null; - +httpAuth.resolve = null; +httpAuth.reject = null; httpAuth.handleRequest = function (details, callback) { if (httpAuth.requestId == details.requestId || !page.tabs[details.tabId]) { @@ -62,4 +62,4 @@ httpAuth.loginOrShowCredentials = function(logins) { else { httpAuth.callback({}); } -} +} \ No newline at end of file diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js index 76be8fb..3f94f04 100644 --- a/keepassxc-browser/background/init.js +++ b/keepassxc-browser/background/init.js @@ -8,13 +8,12 @@ keepass.changePublicKeys(null, (pkRes) => { }); // Set initial tab-ID -//browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => { browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => { -//browser.tabs.query({"active": true, "currentWindow": true}).then((tabs) => { if (tabs.length === 0) return; // For example: only the background devtools or a popup are opened page.currentTabId = tabs[0].id; }); + // Milliseconds for intervall (e.g. to update browserAction) let _interval = 250; diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js index 033a10a..8b0a662 100644 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -336,6 +336,10 @@ keepass.associate = function(callback, tab) { } keepass.testAssociation = function (callback, tab, triggerUnlock) { + if (tab && page.tabs[tab.id]) { + page.tabs[tab.id].errorMessage = null; + } + keepass.getDatabaseHash((dbHash) => { if (!dbHash) { callback(false); @@ -519,6 +523,7 @@ keepass.changePublicKeys = function(tab, callback) { } } else { + keepass.isKeePassXCAvailable = true; console.log('Server public key: ' + keepass.b64e(keepass.serverPublicKey)); } callback(true); @@ -663,6 +668,8 @@ function onDisconnected() { keepass.isConnected = false; keepass.isDatabaseClosed = true; keepass.isKeePassXCAvailable = false; + keepass.associated.value = false; + keepass.associated.hash = null; console.log('Failed to connect: ' + (browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message)); } diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json index 2f03a3f..3dddae5 100644 --- a/keepassxc-browser/manifest.json +++ b/keepassxc-browser/manifest.json @@ -81,6 +81,8 @@ "tabs", "webRequest", "webRequestBlocking", + "https://*/*", + "http://*/*", "https://api.github.com/" ], "applications": { diff --git a/keepassxc-browser/popups/popup.html b/keepassxc-browser/popups/popup.html index d341a35..f02373d 100644 --- a/keepassxc-browser/popups/popup.html +++ b/keepassxc-browser/popups/popup.html @@ -79,5 +79,17 @@ + + diff --git a/keepassxc-browser/popups/popup.js b/keepassxc-browser/popups/popup.js index 3704966..a289c4e 100644 --- a/keepassxc-browser/popups/popup.js +++ b/keepassxc-browser/popups/popup.js @@ -6,18 +6,22 @@ function status_response(r) { $('#configured-and-associated').hide(); $('#configured-not-associated').hide(); - if(!r.keePassXCAvailable || r.databaseClosed) { + if (!r.keePassXCAvailable) { $('#error-message').html(r.error); $('#error-encountered').show(); } - else if(!r.configured) { + else if (r.keePassXCAvailable && r.databaseClosed) { + $('#database-error-message').html(r.error); + $('#database-not-opened').show(); + } + else if (!r.configured) { $('#not-configured').show(); } - else if(r.encryptionKeyUnrecognized) { + else if (r.encryptionKeyUnrecognized) { $('#need-reconfigure').show(); $('#need-reconfigure-message').html(r.error); } - else if(!r.associated) { + else if (!r.associated) { $('#need-reconfigure').show(); $('#need-reconfigure-message').html(r.error); } @@ -52,6 +56,13 @@ $(function() { }, status_response); }); + $('#reopen-database-button').click(function() { + browser.runtime.sendMessage({ + action: 'get_status' + }, status_response); + close(); + }); + $('#redetect-fields-button').click(function() { browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => { if (tabs.length === 0)