diff --git a/CHANGELOG b/CHANGELOG index 4613414..3e638bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +0.2.4 (2017-07-11) +========================= +- Changed comparison operators to strict ones (and some code cleaning) +- Copy and Fill & copy buttons are now hidden when Password Generator has an error +- Fix to a bug when reconnecting to KeePassXC (sometimes public keys are changed too quickly) +- Fix for password generator (error is now shown immediately instead of a blank dialog) +- Use a single password generator icon + 0.2.3 (2017-07-05) ========================= - Fixed a few variables diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js index efac982..df48312 100644 --- a/keepassxc-browser/background/event.js +++ b/keepassxc-browser/background/event.js @@ -141,33 +141,37 @@ event.onGetStatus = function(callback, tab) { event.onReconnect = function(callback, tab) { keepass.connectToNative(); - keepass.generateNewKeyPair(); - keepass.changePublicKeys(null, (pkRes) => { - keepass.getDatabaseHash((gdRes) => { - if (gdRes) { - keepass.testAssociation((response) => { - keepass.isConfigured((configured) => { - let keyId = null; - if (configured) { - keyId = keepass.keyRing[keepass.databaseHash].id; - } - browserAction.showDefault(null, tab); - console.log(page.tabs[tab.id].errorMessage); - callback({ - identifier: keyId, - configured: configured, - databaseClosed: keepass.isDatabaseClosed, - keePassXCAvailable: keepass.isKeePassXCAvailable, - encryptionKeyUnrecognized: keepass.isEncryptionKeyUnrecognized, - associated: keepass.isAssociated(), - error: page.tabs[tab.id].errorMessage - }); - }); - }, tab); - } - }, null); - }); + // Add a small timeout after reconnecting. Just to make sure. It's not pretty, I know :( + setTimeout(() => { + keepass.generateNewKeyPair(); + keepass.changePublicKeys(tab, (pkRes) => { + keepass.getDatabaseHash((gdRes) => { + if (gdRes) { + keepass.testAssociation((response) => { + keepass.isConfigured((configured) => { + let keyId = null; + if (configured) { + keyId = keepass.keyRing[keepass.databaseHash].id; + } + + browserAction.showDefault(null, tab); + console.log(page.tabs[tab.id].errorMessage); + callback({ + identifier: keyId, + configured: configured, + databaseClosed: keepass.isDatabaseClosed, + keePassXCAvailable: keepass.isKeePassXCAvailable, + encryptionKeyUnrecognized: keepass.isEncryptionKeyUnrecognized, + associated: keepass.isAssociated(), + error: page.tabs[tab.id].errorMessage + }); + }); + }, tab); + } + }, null); + }); + }, 2000); } event.onPopStack = function(callback, tab) { diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js index 0658ba4..4ce6be0 100644 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -188,6 +188,7 @@ keepass.callbackOnId = function (ev, id, callback) { keepass.generatePassword = function (callback, tab, forceCallback) { if (!keepass.isConnected) { + callback([]); return; } @@ -429,7 +430,7 @@ keepass.getDatabaseHash = function (callback, tab, triggerUnlock) { } if (!keepass.serverPublicKey) { - keepass.changePublicKeys(tab, (res) => {}); + keepass.changePublicKeys(tab, null); } const kpAction = kpActions.GET_DATABASE_HASH; diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js index 4bf9400..f8421c3 100644 --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -5,8 +5,6 @@ window.browser = (function () { })(); var page = {}; - -// special information for every tab page.tabs = {}; page.currentTabId = -1; @@ -114,7 +112,7 @@ page.debugConsole = function() { }; page.sprintf = function(input, args) { - return input.replace(/{(\d+)}/g, function(match, number) { + return input.replace(/{(\d+)}/g, (match, number) => { return typeof args[number] !== 'undefined' ? (typeof args[number] === 'object' ? JSON.stringify(args[number]) : args[number]) : match diff --git a/keepassxc-browser/icons/key_24x24.png b/keepassxc-browser/icons/key.png similarity index 100% rename from keepassxc-browser/icons/key_24x24.png rename to keepassxc-browser/icons/key.png diff --git a/keepassxc-browser/icons/key.svg b/keepassxc-browser/icons/key.svg deleted file mode 100644 index 21d4df8..0000000 --- a/keepassxc-browser/icons/key.svg +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Key - - - - - - - - - - - - - image/svg+xml - - Key - - - - Sami Vänttinen - - - - - - - - - - - - - - - - - - - - - - diff --git a/keepassxc-browser/icons/key_16x16.png b/keepassxc-browser/icons/key_16x16.png deleted file mode 100644 index 1dafc30..0000000 Binary files a/keepassxc-browser/icons/key_16x16.png and /dev/null differ diff --git a/keepassxc-browser/keepassxc-browser.css b/keepassxc-browser/keepassxc-browser.css index 4a7be25..d640627 100644 --- a/keepassxc-browser/keepassxc-browser.css +++ b/keepassxc-browser/keepassxc-browser.css @@ -69,49 +69,13 @@ input.genpw-text { position: absolute; cursor: pointer; } -.cip-genpw-icon.small { - width: 16px; - height: 16px; - background-image: url(chrome-extension://__MSG_@@extension_id__/icons/key_16x16.png); +.cip-genpw-icon.key { + background: url('chrome-extension://__MSG_@@extension_id__/icons/key.png') right no-repeat; + background-size: contain; } -.cip-genpw-icon.big { - width: 24px; - height: 24px; - background-image: url(chrome-extension://__MSG_@@extension_id__/icons/key_24x24.png); -} -.cip-genpw-icon.small-moz { - width: 16px; - height: 16px; - background-image: url(moz-extension://__MSG_@@extension_id__/icons/key_16x16.png); -} -.cip-genpw-icon.big-moz { - width: 24px; - height: 24px; - background-image: url(moz-extension://__MSG_@@extension_id__/icons/key_24x24.png); -} -.cip-warning-icon { - position: absolute; - cursor: pointer; -} -.cip-warning-icon.small { - width: 16px; - height: 16px; - background-image: url(chrome-extension://__MSG_@@extension_id__/icons/warning_16x16.png); -} -.cip-warning-icon.big { - width: 24px; - height: 24px; - background-image: url(chrome-extension://__MSG_@@extension_id__/icons/warning_24x24.png); -} -.cip-warning-icon.small-moz { - width: 16px; - height: 16px; - background-image: url(moz-extension://__MSG_@@extension_id__/icons/warning_16x16.png); -} -.cip-warning-icon.big-moz { - width: 24px; - height: 24px; - background-image: url(moz-extension://__MSG_@@extension_id__/icons/warning_24x24.png); +.cip-genpw-icon.key-moz { + background: url('moz-extension://__MSG_@@extension_id__/icons/key.png') right no-repeat; + background-size: contain; } #cip-genpw-btn-fillin { diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index 0aa45ac..2449087 100644 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -335,36 +335,17 @@ cipPassword.createDialog = function() { } cipPassword.createIcon = function(field) { - const $className = (field.outerHeight() > 28) ? (isFirefox ? 'big-moz' : 'big') : (isFirefox ? 'small-moz' : 'small'); + const $className = (isFirefox ? 'key-moz' : 'key'); const $size = (field.outerHeight() > 28) ? 24 : 16; let $offset = Math.floor((field.outerHeight() - $size) / 3); $offset = ($offset < 0) ? 0 : $offset; - let $zIndex = 0; - let $zIndexField = field; - let z; - let c = 0; - while ($zIndexField.length > 0) { - if (c > 100 || $zIndexField[0].nodeName === '#document') { - break; - } - z = $zIndexField.css('z-index'); - if (!isNaN(z) && Number(z) > $zIndex) { - $zIndex = Number(z); - } - $zIndexField = $zIndexField.parent(); - c++; - } - - if (isNaN($zIndex) || $zIndex < 1) { - $zIndex = 1; - } - $zIndex += 1; - const $icon = jQuery('
').addClass('cip-genpw-icon') .addClass($className) .attr('title', 'Generate password') - .css('z-index', $zIndex) + .css('z-index', '9999') + .css('width', $size) + .css('height', $size) .data('size', $size) .data('offset', $offset) .data('cip-genpw-field-id', field.data('cip-id')); @@ -396,7 +377,6 @@ cipPassword.createIcon = function(field) { }); cipPassword.observedIcons.push($icon); - jQuery('body').append($icon); } diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json index 851f922..fc2ea8c 100644 --- a/keepassxc-browser/manifest.json +++ b/keepassxc-browser/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "keepassxc-browser", - "version": "0.2.3", + "version": "0.2.4", "description": "KeePassXC integration for modern web browsers", "author": "Sami Vänttinen", "icons": { @@ -60,9 +60,7 @@ } }, "web_accessible_resources": [ - "icons/key_16x16.png", - "icons/key_24x24.png", - "icons/key.svg" + "icons/key.png" ], "permissions": [ "contextMenus",