mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Draft 010523
This commit is contained in:
parent
4f082dda84
commit
371514ac87
7 changed files with 6842 additions and 359 deletions
|
|
@ -103,7 +103,11 @@
|
|||
"message": "No logins found.",
|
||||
"description": "No logins found."
|
||||
},
|
||||
"errorMessagePaswordLengthExceeded": {
|
||||
"errorActionTimeout": {
|
||||
"message": "Action timeout.",
|
||||
"description": "Action timeout."
|
||||
},
|
||||
"errorMessagePasswordLengthExceeded": {
|
||||
"message": "Filled password is longer than field's allowed max length.",
|
||||
"description": "Error notification text shown when filled password is longer than defined maxLength of the input field."
|
||||
},
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ const kpErrors = {
|
|||
EMPTY_MESSAGE_RECEIVED: 13,
|
||||
NO_URL_PROVIDED: 14,
|
||||
NO_LOGINS_FOUND: 15,
|
||||
ACTION_TIMEOUT: 16,
|
||||
|
||||
errorMessages: {
|
||||
0: { msg: tr('errorMessageUnknown') },
|
||||
|
|
@ -75,7 +76,8 @@ const kpErrors = {
|
|||
12: { msg: tr('errorMessageIncorrectAction') },
|
||||
13: { msg: tr('errorMessageEmptyMessage') },
|
||||
14: { msg: tr('errorMessageNoURL') },
|
||||
15: { msg: tr('errorMessageNoLogins') }
|
||||
15: { msg: tr('errorMessageNoLogins') },
|
||||
16: { msg: tr('errorActionTimeout') }
|
||||
},
|
||||
|
||||
getError(errorCode) {
|
||||
|
|
@ -392,6 +394,10 @@ keepass.updatePopup = function() {
|
|||
|
||||
// Updates the database hashes to content script
|
||||
keepass.updateDatabase = async function() {
|
||||
if (!keepass.isKeePassXCAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
keepass.associated.value = false;
|
||||
keepass.associated.hash = null;
|
||||
page.clearAllLogins();
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ protocol.changePublicKeys = async function(tab, enableTimeout = false, connectio
|
|||
|
||||
try {
|
||||
const response = await protocolClient.sendNativeMessage(kpAction, request, enableTimeout, connectionTimeout);
|
||||
if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, kpErrors.KEY_CHANGE_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
keepass.setcurrentKeePassXCVersion(response.version);
|
||||
keepass.protocolV2 = response?.protocolVersion === 2;
|
||||
|
||||
|
|
@ -189,7 +194,6 @@ protocol.getCredentials = async function(tab, args = []) {
|
|||
}
|
||||
|
||||
try {
|
||||
// TODO: Handle errors
|
||||
const response = await protocolClient.sendMessage(tab, messageData, false, triggerUnlock);
|
||||
if (response) {
|
||||
if (response.error && response.errorCode) {
|
||||
|
|
@ -258,7 +262,7 @@ protocol.getDatabaseGroups = async function(tab, args = []) {
|
|||
};
|
||||
|
||||
protocol.getDatabaseStatuses = async function(tab, args = []) {
|
||||
if (!keepass.isConnected) {
|
||||
if (!keepass.isKeePassXCAvailable) {
|
||||
keepass.handleError(tab, kpErrors.TIMEOUT_OR_NOT_CONNECTED);
|
||||
return;
|
||||
}
|
||||
|
|
@ -289,10 +293,10 @@ protocol.getDatabaseStatuses = async function(tab, args = []) {
|
|||
return response;
|
||||
}
|
||||
|
||||
keepass.isDatabaseClosed = true;
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
keepass.databaseHash = '';
|
||||
keepass.handleError(tab, kpErrors.TIMEOUT_OR_NOT_CONNECTED);
|
||||
//keepass.isDatabaseClosed = true;
|
||||
//keepass.isKeePassXCAvailable = false;
|
||||
//keepass.databaseHash = '';
|
||||
keepass.handleError(tab, kpErrors.ACTION_TIMEOUT);
|
||||
} catch (err) {
|
||||
logError(`getDatabaseStatuses failed: ${err}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,13 +36,14 @@ protocolClient.messageTimeout = 500; // Milliseconds
|
|||
protocolClient.nativeHostName = 'org.keepassxc.keepassxc_browser';
|
||||
protocolClient.nativePort = null;
|
||||
|
||||
protocolClient.sendNativeMessage = function(requestAction, request, enableTimeout = false, timeoutValue) {
|
||||
protocolClient.sendNativeMessage = function(requestAction, request, enableTimeout = false, timeoutValue = protocolClient.messageTimeout) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let timeout;
|
||||
const ev = protocolClient.nativePort.onMessage;
|
||||
|
||||
const listener = ((port) => {
|
||||
const handler = (msg) => {
|
||||
console.log('msg recevied: ', msg);
|
||||
if (msg && (msg?.requestID === request.requestID || msg?.action === kpActions.CHANGE_PUBLIC_KEYS)) {
|
||||
// Only resolve a matching response
|
||||
if (protocolBuffer.matchAndRemove(msg)) {
|
||||
|
|
@ -60,20 +61,22 @@ protocolClient.sendNativeMessage = function(requestAction, request, enableTimeou
|
|||
})(ev);
|
||||
ev.addListener(listener);
|
||||
|
||||
const messageTimeout = timeoutValue || protocolClient.messageTimeout;
|
||||
|
||||
// Handle timeouts
|
||||
if (enableTimeout) {
|
||||
timeout = setTimeout(() => {
|
||||
const errorMessage = {
|
||||
let error = kpErrors.ACTION_TIMEOUT;
|
||||
if (requestAction === kpActions.CHANGE_PUBLIC_KEYS) {
|
||||
error = kpErrors.TIMEOUT_OR_NOT_CONNECTED;
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
}
|
||||
|
||||
resolve({
|
||||
action: requestAction,
|
||||
error: kpErrors.getError(kpErrors.TIMEOUT_OR_NOT_CONNECTED),
|
||||
errorCode: kpErrors.TIMEOUT_OR_NOT_CONNECTED
|
||||
};
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
error: kpErrors.getError(error),
|
||||
errorCode: error
|
||||
});
|
||||
ev.removeListener(listener.handler);
|
||||
resolve(errorMessage);
|
||||
}, messageTimeout);
|
||||
}, timeoutValue);
|
||||
}
|
||||
|
||||
// Store the request to the buffer
|
||||
|
|
@ -93,7 +96,7 @@ protocolClient.sendMessage = async function(tab, messageData, enableTimeout = fa
|
|||
const response = await protocolClient.sendNativeMessage(messageData.action, request, enableTimeout);
|
||||
const incrementedNonce = protocolClient.incrementedNonce(nonce);
|
||||
|
||||
return protocolClient.handleResponse(response, incrementedNonce, tab);
|
||||
return protocolClient.handleResponse(response, incrementedNonce, request.requestID, tab);
|
||||
};
|
||||
|
||||
protocolClient.buildRequest = function(encryptedMessage, nonce, clientID, triggerUnlock = false) {
|
||||
|
|
@ -112,11 +115,12 @@ protocolClient.buildRequest = function(encryptedMessage, nonce, clientID, trigge
|
|||
};
|
||||
|
||||
// Verifies nonces, decrypts and parses the response
|
||||
protocolClient.handleResponse = function(response, incrementedNonce, tab) {
|
||||
protocolClient.handleResponse = function(response, incrementedNonce, requestID, tab) {
|
||||
if (response.message && protocolClient.verifyNonce(response, incrementedNonce)) {
|
||||
const res = protocolClient.decrypt(response.message, response.nonce);
|
||||
if (!res) {
|
||||
keepass.handleError(tab, kpErrors.CANNOT_DECRYPT_MESSAGE);
|
||||
protocolBuffer.matchAndRemove({ requestID: requestID });
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +129,7 @@ protocolClient.handleResponse = function(response, incrementedNonce, tab) {
|
|||
return parsed;
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
protocolBuffer.matchAndRemove({ requestID: requestID });
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ kpxcFill.fillInCredentials = async function(combination, predefinedUsername, uui
|
|||
if (combination.password.maxLength
|
||||
&& combination.password.maxLength > 0
|
||||
&& selectedCredentials.password.length > combination.password.maxLength) {
|
||||
kpxcUI.createNotification('error', tr('errorMessagePaswordLengthExceeded'));
|
||||
kpxcUI.createNotification('error', tr('errorMessagePasswordLengthExceeded'));
|
||||
}
|
||||
|
||||
kpxc.setValueWithChange(combination.password, selectedCredentials.password);
|
||||
|
|
|
|||
7139
package-lock.json
generated
7139
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,7 @@
|
|||
"dependencies": {
|
||||
"@npmcli/fs": "^2.1.0",
|
||||
"file-url": "^4.0.0",
|
||||
"web-ext": "^7.6.2",
|
||||
"zip-a-folder": "^1.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue