From 4f94d4f7a3a0884fe4263bd47da503882a716b39 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Thu, 7 Apr 2022 18:40:24 +0300 Subject: [PATCH] Add support for the new password generator --- keepassxc-browser/background/keepass.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js index e8b0d73..ab299cb 100755 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -334,12 +334,16 @@ keepass.generatePassword = async function(tab) { const kpAction = kpActions.GENERATE_PASSWORD; const [ nonce, incrementedNonce ] = keepass.getNonces(); - const request = { + const messageData = { action: kpAction, nonce: nonce, - clientID: keepass.clientID + clientID: keepass.clientID, + requestID: keepass.getRequestId(), }; + const request = keepass.buildRequest(kpAction, keepass.encrypt(messageData, nonce), nonce, messageData.clientID); + request["requestID"] = messageData.requestID; + const response = await keepass.sendNativeMessage(request); if (response.message && response.nonce) { const res = keepass.decrypt(response.message, response.nonce); @@ -902,6 +906,11 @@ keepass.generateNewKeyPair = function() { //console.log(nacl.util.encodeBase64(keepass.keyPair.publicKey) + ' ' + nacl.util.encodeBase64(keepass.keyPair.secretKey)); }; +// Creates a random 8 character string for Request ID +keepass.getRequestId = function() { + return Math.random().toString(16).substring(2, 10); +}; + keepass.isConfigured = async function() { if (typeof(keepass.databaseHash) === 'undefined') { const hash = keepass.getDatabaseHash();