mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Improved timeout handling
This commit is contained in:
parent
ac4a57b36d
commit
51b9259fca
5 changed files with 35 additions and 21 deletions
|
|
@ -1,3 +1,7 @@
|
|||
0.3.2 (2017-09-30)
|
||||
=========================
|
||||
- Improved timeout handling
|
||||
|
||||
0.3.1 (2017-09-29)
|
||||
=========================
|
||||
- Added timeout handling for postMessage(). Allows proxy application to be reloaded.
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ event.onGetStatus = function(callback, tab) {
|
|||
keepass.isConfigured((configured) => {
|
||||
event.showStatus(configured, tab, callback);
|
||||
});
|
||||
}, tab);
|
||||
}, tab, true);
|
||||
};
|
||||
|
||||
event.onReconnect = function(callback, tab) {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password,
|
|||
});
|
||||
};
|
||||
|
||||
keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallback, triggerUnlock) {
|
||||
keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallback) {
|
||||
page.debug('keepass.retrieveCredentials(callback, {1}, {2}, {3}, {4})', tab.id, url, submiturl, forceCallback);
|
||||
|
||||
keepass.testAssociation((response) => {
|
||||
|
|
@ -204,12 +204,15 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb
|
|||
};
|
||||
|
||||
// Redirects the callback to a listener (handleReply())
|
||||
keepass.callbackOnId = function(ev, action, tab, callback) {
|
||||
keepass.callbackOnId = function(ev, action, tab, callback, enableTimeout = false) {
|
||||
let timeout;
|
||||
let listener = ((port, action) => {
|
||||
let handler = (msg) => {
|
||||
if (msg && msg.action === action) {
|
||||
ev.removeListener(handler);
|
||||
clearTimeout(timeout);
|
||||
if (enableTimeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
callback(msg);
|
||||
}
|
||||
};
|
||||
|
|
@ -218,16 +221,18 @@ keepass.callbackOnId = function(ev, action, tab, callback) {
|
|||
ev.addListener(listener);
|
||||
|
||||
// Handle timeouts
|
||||
let timeout = setTimeout(() => {
|
||||
const errorMessage = {
|
||||
action: action,
|
||||
error: kpErrors.getError(5),
|
||||
errorCode: 5
|
||||
};
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
callback(errorMessage);
|
||||
ev.removeListener(listener.handler);
|
||||
}, keepass.messageTimeout);
|
||||
if (enableTimeout) {
|
||||
timeout = setTimeout(() => {
|
||||
const errorMessage = {
|
||||
action: action,
|
||||
error: kpErrors.getError(5),
|
||||
errorCode: 5
|
||||
};
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
callback(errorMessage);
|
||||
ev.removeListener(listener.handler);
|
||||
}, keepass.messageTimeout);
|
||||
}
|
||||
};
|
||||
|
||||
keepass.generatePassword = function(callback, tab, forceCallback) {
|
||||
|
|
@ -351,7 +356,7 @@ keepass.associate = function(callback, tab) {
|
|||
}, tab);
|
||||
};
|
||||
|
||||
keepass.testAssociation = function(callback, tab, triggerUnlock) {
|
||||
keepass.testAssociation = function(callback, tab, enableTimeout = false) {
|
||||
if (tab && page.tabs[tab.id]) {
|
||||
page.tabs[tab.id].errorMessage = null;
|
||||
}
|
||||
|
|
@ -438,10 +443,10 @@ keepass.testAssociation = function(callback, tab, triggerUnlock) {
|
|||
callback(keepass.isAssociated());
|
||||
});
|
||||
keepass.nativePort.postMessage(request);
|
||||
}, tab, triggerUnlock);
|
||||
}, tab, enableTimeout);
|
||||
};
|
||||
|
||||
keepass.getDatabaseHash = function(callback, tab, triggerUnlock) {
|
||||
keepass.getDatabaseHash = function(callback, tab, enableTimeout = false) {
|
||||
if (!keepass.isConnected) {
|
||||
keepass.handleError(tab, kpErrors.TIMEOUT_OR_NOT_CONNECTED);
|
||||
callback([]);
|
||||
|
|
@ -505,10 +510,16 @@ keepass.getDatabaseHash = function(callback, tab, triggerUnlock) {
|
|||
else {
|
||||
keepass.databaseHash = 'no-hash';
|
||||
keepass.isDatabaseClosed = true;
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
if (response.message === "") {
|
||||
keepass.handleError(tab, kpErrors.TIMEOUT_OR_NOT_CONNECTED);
|
||||
}
|
||||
else {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
//keepass.handleError(tab, response.errorCode, response.error);
|
||||
callback(keepass.databaseHash);
|
||||
}
|
||||
});
|
||||
}, enableTimeout);
|
||||
keepass.nativePort.postMessage(request);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1120,7 +1120,6 @@ cip.detectNewActiveFields = function() {
|
|||
//if (hiddenFields > 0) {
|
||||
const divDetect = setInterval(function() {
|
||||
const fields = cipFields.getAllFields();
|
||||
console.log(fields.length);
|
||||
if (fields.length > 1) {
|
||||
cip.initCredentialFields(true);
|
||||
clearInterval(divDetect);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "keepassxc-browser",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"description": "KeePassXC integration for modern web browsers",
|
||||
"author": "Sami Vänttinen",
|
||||
"icons": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue