Merge branch 'develop'

This commit is contained in:
varjolintu 2017-08-27 10:12:01 +03:00
commit a0ecbc0c53
8 changed files with 61 additions and 11 deletions

View file

@ -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)
=========================

View file

@ -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);

View file

@ -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({});
}
}
}

View file

@ -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;

View file

@ -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));
}

View file

@ -81,6 +81,8 @@
"tabs",
"webRequest",
"webRequestBlocking",
"https://*/*",
"http://*/*",
"https://api.github.com/"
],
"applications": {

View file

@ -79,5 +79,17 @@
<button id="reload-status-button" class="btn btn-primary">Reload</button>
</div>
</div>
<div id="database-not-opened" style="display: none">
<p>
keepassxc-browser has encountered an error:
</p>
<p style="margin-left: 1em">
<code id="database-error-message"></code>
</p>
<div style="text-align: right">
<button id="reopen-database-button" class="btn btn-primary">Reopen database</button>
</div>
</div>
</body>
</html>

View file

@ -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)