From 375a9e8d4a191fc13577dc127045af151aacb94a Mon Sep 17 00:00:00 2001 From: varjolintu Date: Mon, 3 Apr 2017 09:57:30 +0300 Subject: [PATCH] Changes to database storing in the plugin --- README.md | 1 + chromeKeePassXC/background/event.js | 22 +- chromeKeePassXC/background/init.js | 2 +- chromeKeePassXC/background/keepass.js | 77 +++--- chromeKeePassXC/background/page.js | 6 - chromeKeePassXC/chromekeepassxc.js | 352 +++++++++++++------------- chromeKeePassXC/options/options.html | 7 +- chromeKeePassXC/options/options.js | 17 +- chromeKeePassXC/popups/popup.js | 1 - 9 files changed, 235 insertions(+), 250 deletions(-) diff --git a/README.md b/README.md index 9af6df4..79a72fe 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Now the requests are encrypted by [TweetNaCl.js](https://github.com/dchest/tweet 3. All messages (excluding get-databasehash) are now encrypted. 4. When chromeKeePassXC sends a message it is encrypted with KeePassXC's public key, a random generated nonce and chromeKeePassXC's secret key. 5. When KeePassXC sends a message it is encrypted with chromeKeePassXC's public key etc. +6. Databases are stored based on the database hash instead of the key because a new key pair is generated each time chromeKeePassXC is launched. Encrypted messages are built with these JSON parameters: - action - `test-associate`, `associate`, `get-logins`, `get-logins-count`, `set-login`... diff --git a/chromeKeePassXC/background/event.js b/chromeKeePassXC/background/event.js index 2817d1e..1f01bff 100644 --- a/chromeKeePassXC/background/event.js +++ b/chromeKeePassXC/background/event.js @@ -5,7 +5,7 @@ event.onMessage = function(request, sender, callback) { if (request.action in event.messageHandlers) { //console.log("onMessage(" + request.action + ") for #" + sender.tab.id); - if(!sender.hasOwnProperty('tab') || sender.tab.id < 1) { + if (!sender.hasOwnProperty('tab') || sender.tab.id < 1) { sender.tab = {}; sender.tab.id = page.currentTabId; } @@ -14,7 +14,7 @@ event.onMessage = function(request, sender, callback) { // onMessage closes channel for callback automatically // if this method does not return true - if(callback) { + if (callback) { return true; } } @@ -32,11 +32,11 @@ event.onMessage = function(request, sender, callback) { * @returns null (asynchronous) */ event.invoke = function(handler, callback, senderTabId, args, secondTime) { - if(senderTabId < 1) { + if (senderTabId < 1) { return; } - if(!page.tabs[senderTabId]) { + if (!page.tabs[senderTabId]) { page.createTabEntry(senderTabId); } @@ -49,7 +49,7 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) { // return; // For example: only the background devtools or a popup are opened //var tab = tabs[0]; - if(!tab) { + if (!tab) { return; } @@ -64,7 +64,7 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) { return; } - if(!page.tabs[tab.id]) { + if (!page.tabs[tab.id]) { page.createTabEntry(tab.id); } @@ -73,7 +73,7 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) { args.unshift(tab); args.unshift(callback); - if(handler) { + if (handler) { handler.apply(this, args); } else { @@ -84,7 +84,7 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) { event.onShowAlert = function(callback, tab, message) { - if( page.settings.supressAlerts ){ console.log(message); } + if (page.settings.supressAlerts) { console.log(message); } else { alert(message); } } @@ -94,7 +94,7 @@ event.onLoadSettings = function(callback, tab) { event.onLoadKeyRing = function(callback, tab) { keepass.keyRing = (typeof(localStorage.keyRing) == 'undefined') ? {} : JSON.parse(localStorage.keyRing); - if(keepass.isAssociated() && !keepass.keyRing[keepass.associated.hash]) { + if (keepass.isAssociated() && !keepass.keyRing[keepass.associated.hash]) { keepass.associated = { "value": false, "hash": null @@ -122,7 +122,7 @@ event.onGetStatus = function(callback, tab) { } browserAction.showDefault(null, tab); - + console.log(page.tabs[tab.id].errorMessage); callback({ identifier: keyId, configured: configured, @@ -153,7 +153,7 @@ event.onGetConnectedDatabase = function(callback, tab) { } event.onGetKeePassXCVersions = function(callback, tab) { - if(keepass.currentKeePassXC.version == 0) { + if (keepass.currentKeePassXC.version == 0) { keepass.getDatabaseHash(tab); } callback({"current": keepass.currentKeePassXC.version, "latest": keepass.latestKeePassXC.version}); diff --git a/chromeKeePassXC/background/init.js b/chromeKeePassXC/background/init.js index 46526c5..cc0c812 100644 --- a/chromeKeePassXC/background/init.js +++ b/chromeKeePassXC/background/init.js @@ -8,7 +8,7 @@ page.initOpenedTabs(); keepass.connectToNative(); keepass.generateNewKeyPair(); keepass.getDatabaseHash(null); -keepass.changePublicKeys(); +keepass.changePublicKeys(null); // set initial tab-ID chrome.tabs.query({"active": true, "windowId": chrome.windows.WINDOW_ID_CURRENT}, function(tabs) { if (tabs.length === 0) diff --git a/chromeKeePassXC/background/keepass.js b/chromeKeePassXC/background/keepass.js index eb4f710..79983c0 100644 --- a/chromeKeePassXC/background/keepass.js +++ b/chromeKeePassXC/background/keepass.js @@ -6,7 +6,6 @@ keepass.serverPublicKey = ""; keepass.isConnected = false; keepass.isDatabaseClosed = false; keepass.isKeePassXCAvailable = false; -keepass.useBox = false; keepass.isEncryptionKeyUnrecognized = false; keepass.currentKeePassXC = {"version": 0, "versionParsed": 0}; keepass.latestKeePassXC = (typeof(localStorage.latestKeePassXC) == 'undefined') ? {"version": 0, "versionParsed": 0, "lastChecked": null} : JSON.parse(localStorage.latestKeePassXC); @@ -36,7 +35,7 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password, page.tabs[tab.id].errorMessage = null; // is browser associated to keepass? - if(!keepass.testAssociation(tab)) { + if (!keepass.testAssociation(tab)) { browserAction.showDefault(null, tab); callback("error"); return; @@ -97,7 +96,7 @@ keepass.retrieveCredentials = function (callback, tab, url, submiturl, forceCall page.debug("keepass.retrieveCredentials(callback, {1}, {2}, {3}, {4})", tab.id, url, submiturl, forceCallback); // is browser associated to keepass? - if(!keepass.testAssociation(tab)) { + if (!keepass.testAssociation(tab)) { browserAction.showDefault(null, tab); callback("error"); return; @@ -203,13 +202,13 @@ keepass.generatePassword = function (callback, tab, forceCallback) { } // is browser associated to keepass? - if(!keepass.testAssociation(tab)) { + if (!keepass.testAssociation(tab)) { browserAction.showDefault(null, tab); callback("error"); return; } - if(keepass.currentKeePassXC.versionParsed < keepass.requiredKeePassXC) { + if (keepass.currentKeePassXC.versionParsed < keepass.requiredKeePassXC) { callback([]); return; } @@ -247,7 +246,7 @@ keepass.generatePassword = function (callback, tab, forceCallback) { var rIv = response.nonce; // var response = JSON.stringify({ Login: (msg.password.length * 8), Password: msg.password }); - if(parsed.entries) { + if (parsed.entries) { passwords = parsed.entries; keepass.updateLastUsed(keepass.databaseHash); } @@ -268,7 +267,7 @@ keepass.generatePassword = function (callback, tab, forceCallback) { keepass.copyPassword = function(callback, tab, password) { var bg = chrome.extension.getBackgroundPage(); var c2c = bg.document.getElementById("copy2clipboard"); - if(!c2c) { + if (!c2c) { var input = document.createElement('input'); input.type = "text"; input.id = "copy2clipboard"; @@ -284,13 +283,13 @@ keepass.copyPassword = function(callback, tab, password) { } keepass.associate = function(callback, tab) { - if(keepass.isAssociated()) { + if (keepass.isAssociated()) { return; } keepass.getDatabaseHash(callback, tab); - if(keepass.isDatabaseClosed || !keepass.isKeePassXCAvailable) { + if (keepass.isDatabaseClosed || !keepass.isKeePassXCAvailable) { return; } @@ -330,7 +329,7 @@ keepass.associate = function(callback, tab) { } var id = parsed.id; - if(!keepass.verifyResponse(parsed, response.nonce)) { + if (!keepass.verifyResponse(parsed, response.nonce)) { page.tabs[tab.id].errorMessage = "KeePassXC association failed, try again."; } else { @@ -350,11 +349,11 @@ keepass.associate = function(callback, tab) { keepass.testAssociation = function (tab, triggerUnlock) { keepass.getDatabaseHash(null, tab, triggerUnlock); - if(keepass.isDatabaseClosed || !keepass.isKeePassXCAvailable) { + if (keepass.isDatabaseClosed || !keepass.isKeePassXCAvailable) { return false; } - if(keepass.isAssociated()) { + if (keepass.isAssociated()) { return true; } @@ -394,7 +393,7 @@ keepass.testAssociation = function (tab, triggerUnlock) { var id = parsed.id; keepass.isEncryptionKeyUnrecognized = false; - if(!keepass.verifyResponse(parsed, response.nonce)) { + if (!keepass.verifyResponse(parsed, response.nonce)) { var hash = response.hash || 0; keepass.deleteKey(hash); keepass.isEncryptionKeyUnrecognized = true; @@ -403,15 +402,19 @@ keepass.testAssociation = function (tab, triggerUnlock) { keepass.associated.value = false; keepass.associated.hash = null; } - else if(!keepass.isAssociated()) { + else if (!keepass.isAssociated()) { console.log("Association was not successful"); page.tabs[tab.id].errorMessage = "Association was not successful."; } + else { + if (tab && page.tabs[tab.id]) { + delete page.tabs[tab.id].errorMessage; + } + } } } }); keepass.nativePort.postMessage(request); - return keepass.isAssociated(); } @@ -427,11 +430,15 @@ keepass.getDatabaseHash = function (callback, tab, triggerUnlock) { keepass.setcurrentKeePassXCVersion(response.version); keepass.databaseHash = response.hash || "no-hash"; - if(oldDatabaseHash && oldDatabaseHash != keepass.databaseHash) { + if (oldDatabaseHash && oldDatabaseHash != keepass.databaseHash) { keepass.associated.value = false; keepass.associated.hash = null; } + if (tab && page.tabs[tab.id]) { + delete page.tabs[tab.id].errorMessage; + } + statusOK(); return keepass.databaseHash; }); @@ -463,7 +470,7 @@ keepass.changePublicKeys = function() { } var id = response.id; - if(!keepass.verifyKeyResponse(response, key, nonce)) { + if (!keepass.verifyKeyResponse(response, key, nonce)) { console.log("Error"); } else { @@ -488,7 +495,7 @@ keepass.generateNewKeyPair = function() { } keepass.isConfigured = function() { - if(typeof(keepass.databaseHash) == "undefined") { + if (typeof(keepass.databaseHash) == "undefined") { keepass.getDatabaseHash(); } return (keepass.databaseHash in keepass.keyRing); @@ -504,27 +511,27 @@ keepass.checkStatus = function (status, tab) { keepass.isDatabaseClosed = false; keepass.isKeePassXCAvailable = true; - if(tab && page.tabs[tab.id]) { + if (tab && page.tabs[tab.id]) { delete page.tabs[tab.id].errorMessage; } if (!success) { keepass.associated.value = false; keepass.associated.hash = null; - if(tab && page.tabs[tab.id]) { + if (tab && page.tabs[tab.id]) { page.tabs[tab.id].errorMessage = "Unknown error: " + status; } console.log("Error: "+ status); if (status == 503) { keepass.isDatabaseClosed = true; console.log("KeePass database is not opened"); - if(tab && page.tabs[tab.id]) { + if (tab && page.tabs[tab.id]) { page.tabs[tab.id].errorMessage = "KeePass database is not opened."; } } else if (status == 0) { keepass.isKeePassXCAvailable = false; console.log("Could not connect to keepass"); - if(tab && page.tabs[tab.id]) { + if (tab && page.tabs[tab.id]) { page.tabs[tab.id].errorMessage = "Is KeePassXC installed and running?"; } } @@ -536,7 +543,7 @@ keepass.checkStatus = function (status, tab) { } keepass.convertKeyToKeyRing = function() { - if(keepass.keyId in localStorage && keepass.keyBody in localStorage && !("keyRing" in localStorage)) { + if (keepass.keyId in localStorage && keepass.keyBody in localStorage && !("keyRing" in localStorage)) { keepass.getDatabaseHash(function(hash) { keepass.saveKey(hash, localStorage[keepass.keyId], localStorage[keepass.keyBody]); }, null); @@ -549,7 +556,7 @@ keepass.convertKeyToKeyRing = function() { } keepass.saveKey = function(hash, id, key) { - if(!(hash in keepass.keyRing)) { + if (!(hash in keepass.keyRing)) { keepass.keyRing[hash] = { "id": id, //"key": key, @@ -568,7 +575,7 @@ keepass.saveKey = function(hash, id, key) { } keepass.updateLastUsed = function(hash) { - if((hash in keepass.keyRing)) { + if ((hash in keepass.keyRing)) { keepass.keyRing[hash].lastUsed = new Date(); localStorage.keyRing = JSON.stringify(keepass.keyRing); } @@ -584,7 +591,7 @@ keepass.getIconColor = function() { } keepass.setcurrentKeePassXCVersion = function(version) { - if(version) { + if (version) { keepass.currentKeePassXC = { "version": version, "versionParsed": parseInt(version.replace(/\./g,"")) @@ -593,10 +600,10 @@ keepass.setcurrentKeePassXCVersion = function(version) { } keepass.keePassXCUpdateAvailable = function() { - if(page.settings.checkUpdateKeePassXC && page.settings.checkUpdateKeePassXC > 0) { + if (page.settings.checkUpdateKeePassXC && page.settings.checkUpdateKeePassXC > 0) { var lastChecked = (keepass.latestKeePassXC.lastChecked) ? new Date(keepass.latestKeePassXC.lastChecked) : new Date("11/21/1986"); var daysSinceLastCheck = Math.floor(((new Date()).getTime()-lastChecked.getTime())/86400000); - if(daysSinceLastCheck >= page.settings.checkUpdateKeePassXC) { + if (daysSinceLastCheck >= page.settings.checkUpdateKeePassXC) { keepass.checkForNewKeePassXCVersion(); } } @@ -611,7 +618,7 @@ keepass.checkForNewKeePassXCVersion = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var $version = xhr.responseText; - if($version.substring(0, 1) == "2") { + if ($version.substring(0, 1) == "2") { $version = $version.substring(0, $version.indexOf(" ")); keepass.latestKeePassXC.version = $version; keepass.latestKeePassXC.versionParsed = parseInt($version.replace(/\./g,"")); @@ -622,7 +629,7 @@ keepass.checkForNewKeePassXCVersion = function() { } } - if($version != -1) { + if ($version != -1) { localStorage.latestKeePassXC = JSON.stringify(keepass.latestKeePassXC); } }; @@ -668,7 +675,7 @@ keepass.setVerifier = function(request, inputKey) { var key = inputKey || null; var id = null; - if(!key) { + if (!key) { var info = keepass.getCryptoKey(); if (info == null) { return null; @@ -677,7 +684,7 @@ keepass.setVerifier = function(request, inputKey) { key = info[1]; } - if(id) { + if (id) { request.id = id; } @@ -725,7 +732,7 @@ keepass.verifyResponse = function(response, nonce, id) { keepass.associated.value = (response.nonce == nonce); - if(id) { + if (id) { keepass.associated.value = (keepass.associated.value && id == response.id); } @@ -744,14 +751,14 @@ keepass.b64d = function(d) { } keepass.getCryptoKey = function() { - if(!(keepass.databaseHash in keepass.keyRing)) { + if (!(keepass.databaseHash in keepass.keyRing)) { return null; } var id = keepass.keyRing[keepass.databaseHash].id; var key = null; - if(id) { + if (id) { //key = keepass.keyRing[keepass.databaseHash].key; key = keepass.b64e(keepass.keyPair.publicKey); } diff --git a/chromeKeePassXC/background/page.js b/chromeKeePassXC/background/page.js index 5d1f13f..a4f6fa9 100644 --- a/chromeKeePassXC/background/page.js +++ b/chromeKeePassXC/background/page.js @@ -27,12 +27,6 @@ page.initSettings = function() { if(!("autoRetrieveCredentials" in page.settings)) { page.settings.autoRetrieveCredentials = 1; } - if(!("hostname" in page.settings)) { - page.settings.hostname = "localhost"; - } - if(!("port" in page.settings)) { - page.settings.port = "19455"; - } localStorage.settings = JSON.stringify(page.settings); } diff --git a/chromeKeePassXC/chromekeepassxc.js b/chromeKeePassXC/chromekeepassxc.js index dc7a8d8..c729e42 100644 --- a/chromeKeePassXC/chromekeepassxc.js +++ b/chromeKeePassXC/chromekeepassxc.js @@ -35,7 +35,7 @@ chrome.extension.onMessage.addListener(function(req, sender, callback) { else if (req.action == "activate_password_generator") { cip.initPasswordGenerator(cipFields.getAllFields()); } - else if(req.action == "remember_credentials") { + else if (req.action == "remember_credentials") { cip.contextMenuRememberCredentials(); } else if (req.action == "choose_credential_fields") { @@ -126,7 +126,7 @@ cipAutocomplete.onOpen = function(event, ui) { cipAutocomplete.onSource = function (request, callback) { var matches = jQuery.map( cipAutocomplete.elements, function(tag) { - if ( tag.label.toUpperCase().indexOf(request.term.toUpperCase()) === 0 ) { + if (tag.label.toUpperCase().indexOf(request.term.toUpperCase()) === 0) { return tag; } }); @@ -144,13 +144,13 @@ cipAutocomplete.onSelect = function (e, ui) { } cipAutocomplete.onBlur = function() { - if(jQuery(this).data("fetched") == true) { + if (jQuery(this).data("fetched") == true) { jQuery(this).data("fetched", false); } else { var fieldId = cipFields.prepareId(jQuery(this).attr("data-cip-id")); var fields = cipFields.getCombination("username", fieldId); - if(_f(fields.password) && _f(fields.password).data("unchanged") != true && jQuery(this).val() != "") { + if (_f(fields.password) && _f(fields.password).data("unchanged") != true && jQuery(this).val() != "") { cip.fillInCredentials(fields, true, true); } } @@ -159,7 +159,7 @@ cipAutocomplete.onBlur = function() { cipAutocomplete.onFocus = function() { cip.u = jQuery(this); - if(jQuery(this).val() == "") { + if (jQuery(this).val() == "") { jQuery(this).autocomplete("search", ""); } } @@ -172,7 +172,7 @@ cipPassword.observedIcons = []; cipPassword.observingLock = false; cipPassword.init = function() { - if("initPasswordGenerator" in _called) { + if ("initPasswordGenerator" in _called) { return; } @@ -184,10 +184,10 @@ cipPassword.init = function() { } cipPassword.initField = function(field, inputs, pos) { - if(!field || field.length != 1) { + if (!field || field.length != 1) { return; } - if(field.data("cip-password-generator")) { + if (field.data("cip-password-generator")) { return; } @@ -197,9 +197,9 @@ cipPassword.initField = function(field, inputs, pos) { cipPassword.createDialog(); var $found = false; - if(inputs) { - for(var i = pos + 1; i < inputs.length; i++) { - if(inputs[i] && inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") { + if (inputs) { + for (var i = pos + 1; i < inputs.length; i++) { + if (inputs[i] && inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") { field.data("cip-genpw-next-field-id", inputs[i].data("cip-id")); field.data("cip-genpw-next-is-password-field", (i == 0)); $found = true; @@ -212,7 +212,7 @@ cipPassword.initField = function(field, inputs, pos) { } cipPassword.createDialog = function() { - if("passwordCreateDialog" in _called) { + if ("passwordCreateDialog" in _called) { return; } @@ -292,11 +292,11 @@ cipPassword.createDialog = function() { var fieldId = jQuery("#cip-genpw-dialog:first").data("cip-genpw-field-id"); var field = jQuery("input[data-cip-id='"+fieldId+"']:first"); - if(field.length == 1) { + if (field.length == 1) { var $password = jQuery("input#cip-genpw-textfield-password:first").val(); - if(field.attr("maxlength")) { - if($password.length > field.attr("maxlength")) { + if (field.attr("maxlength")) { + if ($password.length > field.attr("maxlength")) { $password = $password.substring(0, field.attr("maxlength")); jQuery("input#cip-genpw-textfield-password:first").val($password); jQuery("#cip-genpw-btn-clipboard:first").removeClass("b2c-btn-success"); @@ -305,7 +305,7 @@ cipPassword.createDialog = function() { } field.val($password); - if(jQuery("input#cip-genpw-checkbox-next-field:checked").length == 1) { + if (jQuery("input#cip-genpw-checkbox-next-field:checked").length == 1) { if(field.data("cip-genpw-next-field-exists")) { var nextFieldId = field.data("cip-genpw-next-field-id"); var nextField = jQuery("input[data-cip-id='"+nextFieldId+"']:first"); @@ -338,7 +338,7 @@ cipPassword.createDialog = function() { jQuery("#cip-genpw-dialog:first").dialog("close"); }); - if(jQuery("input#cip-genpw-textfield-password:first").val() == "") { + if (jQuery("input#cip-genpw-textfield-password:first").val() == "") { jQuery("button#cip-genpw-btn-generate:first").click(); } } @@ -355,19 +355,19 @@ cipPassword.createIcon = function(field) { var $zIndexField = field; var z; var c = 0; - while($zIndexField.length > 0) { - if(c > 100 || $zIndexField[0].nodeName == "#document") { + while ($zIndexField.length > 0) { + if( c > 100 || $zIndexField[0].nodeName == "#document") { break; } z = $zIndexField.css("z-index"); - if(!isNaN(z) && parseInt(z) > $zIndex) { + if (!isNaN(z) && parseInt(z) > $zIndex) { $zIndex = parseInt(z); } $zIndexField = $zIndexField.parent(); c++; } - if(isNaN($zIndex) || $zIndex < 1) { + if (isNaN($zIndex) || $zIndex < 1) { $zIndex = 1; } $zIndex += 1; @@ -382,14 +382,14 @@ cipPassword.createIcon = function(field) { $icon.click(function(e) { e.preventDefault(); - if(!field.is(":visible")) { + if (!field.is(":visible")) { $icon.remove(); field.removeData("cip-password-generator"); return; } var $dialog = jQuery("#cip-genpw-dialog"); - if($dialog.dialog("isOpen")) { + if ($dialog.dialog("isOpen")) { $dialog.dialog("close"); } $dialog.dialog("option", "position", { my: "left-10px top", at: "center bottom", of: jQuery(this) }); @@ -416,17 +416,17 @@ cipPassword.setIconPosition = function($icon, $field) { } cipPassword.callbackPasswordCopied = function(bool) { - if(bool) { + if (bool) { jQuery("#cip-genpw-btn-clipboard").addClass("btn-success"); } } cipPassword.callbackGeneratedPassword = function(entries) { - if(entries && entries.length >= 1) { + if (entries && entries.length >= 1) { console.log(entries[0]); jQuery("#cip-genpw-btn-clipboard:first").removeClass("btn-success"); jQuery("input#cip-genpw-textfield-password:first").val(entries[0].password); - if(isNaN(entries[0].login)) { + if (isNaN(entries[0].login)) { jQuery("#cip-genpw-quality:first").text("??? Bits"); } else { @@ -434,7 +434,7 @@ cipPassword.callbackGeneratedPassword = function(entries) { } } else { - if(jQuery("div#cip-genpw-error:first").length == 0) { + if (jQuery("div#cip-genpw-error:first").length == 0) { jQuery("button#cip-genpw-btn-generate:first").after("
Cannot receive generated password.
Is your version of KeePassXC up-to-date?

Please visit the KeePassXC homepage
"); jQuery("input#cip-genpw-textfield-password:first").parent().hide(); jQuery("input#cip-genpw-checkbox-next-field:first").parent("label").hide(); @@ -452,24 +452,24 @@ cipPassword.onRequestPassword = function() { } cipPassword.checkObservedElements = function() { - if(cipPassword.observingLock) { + if (cipPassword.observingLock) { return; } cipPassword.observingLock = true; jQuery.each(cipPassword.observedIcons, function(index, iconField) { - if(iconField && iconField.length == 1) { + if (iconField && iconField.length == 1) { var fieldId = iconField.data("cip-genpw-field-id"); var field = jQuery("input[data-cip-id='"+fieldId+"']:first"); - if(!field || field.length != 1) { + if (!field || field.length != 1) { iconField.remove(); cipPassword.observedIcons.splice(index, 1); } - else if(!field.is(":visible")) { + else if (!field.is(":visible")) { iconField.hide(); //field.removeData("cip-password-generator"); } - else if(field.is(":visible")) { + else if (field.is(":visible")) { iconField.show(); cipPassword.setIconPosition(iconField, field); field.data("cip-password-generator", true); @@ -490,7 +490,7 @@ cipForm.init = function(form, credentialFields) { // TODO: could be called multiple times --> update credentialFields // not already initialized && password-field is not null - if(!form.data("cipForm-initialized") && credentialFields.password) { + if (!form.data("cipForm-initialized") && credentialFields.password) { form.data("cipForm-initialized", true); cipForm.setInputFields(form, credentialFields); form.submit(cipForm.onSubmit); @@ -498,14 +498,14 @@ cipForm.init = function(form, credentialFields) { } cipForm.destroy = function(form, credentialFields) { - if(form === false && credentialFields) { + if (form === false && credentialFields) { var field = _f(credentialFields.password) || _f(credentialFields.username); if(field) { form = field.closest("form"); } } - if(form && jQuery(form).length > 0) { + if (form && jQuery(form).length > 0) { jQuery(form).unbind('submit', cipForm.onSubmit); } } @@ -525,10 +525,10 @@ cipForm.onSubmit = function() { var usernameField = _f(usernameId); var passwordField = _f(passwordId); - if(usernameField) { + if (usernameField) { usernameValue = usernameField.val(); } - if(passwordField) { + if (passwordField) { passwordValue = passwordField.val(); } @@ -583,12 +583,12 @@ cipDefine.initDescription = function() { .addClass("btn").addClass("btn-info") .css("margin-right", "5px") .click(function() { - if(jQuery(this).data("step") == 1) { + if (jQuery(this).data("step") == 1) { cipDefine.selection.username = null; cipDefine.prepareStep2(); cipDefine.markAllPasswordFields(jQuery("#b2c-cipDefine-fields")); } - else if(jQuery(this).data("step") == 2) { + else if (jQuery(this).data("step") == 2) { cipDefine.selection.password = null; cipDefine.prepareStep3(); cipDefine.markAllStringFields(jQuery("#b2c-cipDefine-fields")); @@ -607,22 +607,22 @@ cipDefine.initDescription = function() { .addClass("btn").addClass("btn-primary") .css("margin-right", "15px") .click(function(e) { - if(!cip.settings["defined-credential-fields"]) { + if (!cip.settings["defined-credential-fields"]) { cip.settings["defined-credential-fields"] = {}; } - if(cipDefine.selection.username) { + if (cipDefine.selection.username) { cipDefine.selection.username = cipFields.prepareId(cipDefine.selection.username); } var passwordId = jQuery("div#b2c-cipDefine-fields").data("password"); - if(cipDefine.selection.password) { + if (cipDefine.selection.password) { cipDefine.selection.password = cipFields.prepareId(cipDefine.selection.password); } var fieldIds = []; var fieldKeys = Object.keys(cipDefine.selection.fields); - for(var i = 0; i < fieldKeys.length; i++) { + for (var i = 0; i < fieldKeys.length; i++) { fieldIds.push(cipFields.prepareId(fieldKeys[i])); } @@ -646,7 +646,7 @@ cipDefine.initDescription = function() { $description.append($btnAgain); $description.append($btnDismiss); - if(cip.settings["defined-credential-fields"] && cip.settings["defined-credential-fields"][document.location.origin]) { + if (cip.settings["defined-credential-fields"] && cip.settings["defined-credential-fields"][document.location.origin]) { var $p = jQuery("

").html("For this page credential fields are already selected and will be overwritten.
"); var $btnDiscard = jQuery("