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("
");
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("")
.attr("id", "btn-warning")
@@ -726,12 +726,12 @@ cipDefine.markAllStringFields = function($chooser) {
cipDefine.markFields = function ($chooser, $pattern) {
//var $found = false;
jQuery($pattern).each(function() {
- if(cipDefine.isFieldSelected(jQuery(this).data("cip-id"))) {
+ if (cipDefine.isFieldSelected(jQuery(this).data("cip-id"))) {
//continue
return true;
}
- if(jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
+ if (jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
var $field = jQuery("").addClass("b2c-fixed-field")
.css("top", jQuery(this).offset().top)
.css("left", jQuery(this).offset().left)
@@ -781,7 +781,7 @@ cipDefine.prepareStep3 = function() {
}
*/
- if(!cipDefine.selection.username && !cipDefine.selection.password) {
+ if (!cipDefine.selection.username && !cipDefine.selection.password) {
jQuery("button#b2c-btn-confirm:first").removeClass("b2c-btn-primary").attr("disabled", true);
}
@@ -803,13 +803,13 @@ cipFields.uniqueNumber = 342845638;
cipFields.combinations = [];
cipFields.setUniqueId = function(field) {
- if(field && !field.attr("data-cip-id")) {
+ if (field && !field.attr("data-cip-id")) {
// use ID of field if it is unique
// yes, it should be, but there are many bad developers outside...
var fieldId = field.attr("id");
- if(fieldId) {
+ if (fieldId) {
var foundIds = jQuery("input#" + cipFields.prepareId(fieldId));
- if(foundIds.length == 1) {
+ if (foundIds.length == 1) {
field.attr("data-cip-id", fieldId);
return;
}
@@ -831,7 +831,7 @@ cipFields.getAllFields = function() {
var fields = [];
// get all input fields which are text, email or password and visible
jQuery(cipFields.inputQueryPattern).each(function() {
- if(jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
+ if (jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
cipFields.setUniqueId(jQuery(this));
fields.push(jQuery(this));
}
@@ -842,7 +842,7 @@ cipFields.getAllFields = function() {
cipFields.prepareVisibleFieldsWithID = function($pattern) {
jQuery($pattern).each(function() {
- if(jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
+ if (jQuery(this).is(":visible") && jQuery(this).css("visibility") != "hidden" && jQuery(this).css("visibility") != "collapsed") {
cipFields.setUniqueId(jQuery(this));
}
});
@@ -851,12 +851,12 @@ cipFields.prepareVisibleFieldsWithID = function($pattern) {
cipFields.getAllCombinations = function(inputs) {
var fields = [];
var uField = null;
- for(var i = 0; i < inputs.length; i++) {
- if(!inputs[i] || inputs[i].length < 1) {
+ for (var i = 0; i < inputs.length; i++) {
+ if (!inputs[i] || inputs[i].length < 1) {
continue;
}
- if(inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
+ if (inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
var uId = (!uField || uField.length < 1) ? null : cipFields.prepareId(uField.attr("data-cip-id"));
var combination = {
@@ -878,18 +878,18 @@ cipFields.getAllCombinations = function(inputs) {
}
cipFields.getCombination = function(givenType, fieldId) {
- if(cipFields.combinations.length == 0) {
- if(cipFields.useDefinedCredentialFields()) {
+ if (cipFields.combinations.length == 0) {
+ if( cipFields.useDefinedCredentialFields()) {
return cipFields.combinations[0];
}
}
// use defined credential fields (already loaded into combinations)
- 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]) {
return cipFields.combinations[0];
}
- for(var i = 0; i < cipFields.combinations.length; i++) {
- if(cipFields.combinations[i][givenType] == fieldId) {
+ for (var i = 0; i < cipFields.combinations.length; i++) {
+ if (cipFields.combinations[i][givenType] == fieldId) {
return cipFields.combinations[i];
}
}
@@ -901,10 +901,10 @@ cipFields.getCombination = function(givenType, fieldId) {
};
var newCombi = false;
- if(givenType == "username") {
+ if (givenType == "username") {
var passwordField = cipFields.getPasswordField(fieldId, true);
var passwordId = null;
- if(passwordField && passwordField.length > 0) {
+ if (passwordField && passwordField.length > 0) {
passwordId = cipFields.prepareId(passwordField.attr("data-cip-id"));
}
combination = {
@@ -913,10 +913,10 @@ cipFields.getCombination = function(givenType, fieldId) {
};
newCombi = true;
}
- else if(givenType == "password") {
+ else if (givenType == "password") {
var usernameField = cipFields.getUsernameField(fieldId, true);
var usernameId = null;
- if(usernameField && usernameField.length > 0) {
+ if (usernameField && usernameField.length > 0) {
usernameId = cipFields.prepareId(usernameField.attr("data-cip-id"));
}
combination = {
@@ -926,17 +926,17 @@ cipFields.getCombination = function(givenType, fieldId) {
newCombi = true;
}
- if(combination.username || combination.password) {
+ if (combination.username || combination.password) {
cipFields.combinations.push(combination);
}
- if(combination.username) {
- if(cip.credentials.length > 0) {
+ if (combination.username) {
+ if (cip.credentials.length > 0) {
cip.preparePageForMultipleCredentials(cip.credentials);
}
}
- if(newCombi) {
+ if (newCombi) {
combination.isNew = true;
}
return combination;
@@ -947,7 +947,7 @@ cipFields.getCombination = function(givenType, fieldId) {
*/
cipFields.getUsernameField = function(passwordId, checkDisabled) {
var passwordField = _f(passwordId);
- if(!passwordField) {
+ if (!passwordField) {
return null;
}
@@ -955,15 +955,15 @@ cipFields.getUsernameField = function(passwordId, checkDisabled) {
var usernameField = null;
// search all inputs on this one form
- if(form) {
+ if (form) {
jQuery(cipFields.inputQueryPattern, form).each(function() {
cipFields.setUniqueId(jQuery(this));
- if(jQuery(this).attr("data-cip-id") == passwordId) {
+ if (jQuery(this).attr("data-cip-id") == passwordId) {
// break
return false;
}
- if(jQuery(this).attr("type") && jQuery(this).attr("type").toLowerCase() == "password") {
+ if (jQuery(this).attr("type") && jQuery(this).attr("type").toLowerCase() == "password") {
// continue
return true;
}
@@ -975,12 +975,12 @@ cipFields.getUsernameField = function(passwordId, checkDisabled) {
else {
var inputs = cipFields.getAllFields();
cip.initPasswordGenerator(inputs);
- for(var i = 0; i < inputs.length; i++) {
- if(inputs[i].attr("data-cip-id") == passwordId) {
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].attr("data-cip-id") == passwordId) {
break;
}
- if(inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
+ if (inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
continue;
}
@@ -988,10 +988,10 @@ cipFields.getUsernameField = function(passwordId, checkDisabled) {
}
}
- if(usernameField && !checkDisabled) {
+ if (usernameField && !checkDisabled) {
var usernameId = usernameField.attr("data-cip-id");
// check if usernameField is already used by another combination
- for(var i = 0; i < cipFields.combinations.length; i++) {
+ for (var i = 0; i < cipFields.combinations.length; i++) {
if(cipFields.combinations[i].username == usernameId) {
usernameField = null;
break;
@@ -1009,7 +1009,7 @@ cipFields.getUsernameField = function(passwordId, checkDisabled) {
*/
cipFields.getPasswordField = function(usernameId, checkDisabled) {
var usernameField = _f(usernameId);
- if(!usernameField) {
+ if (!usernameField) {
return null;
}
@@ -1017,13 +1017,13 @@ cipFields.getPasswordField = function(usernameId, checkDisabled) {
var passwordField = null;
// search all inputs on this one form
- if(form) {
+ if (form) {
passwordField = jQuery("input[type='password']:first", form);
- if(passwordField.length < 1) {
+ if (passwordField.length < 1) {
passwordField = null;
}
- if(cip.settings.usePasswordGenerator) {
+ if (cip.settings.usePasswordGenerator) {
cipPassword.init();
cipPassword.initField(passwordField);
}
@@ -1034,22 +1034,22 @@ cipFields.getPasswordField = function(usernameId, checkDisabled) {
cip.initPasswordGenerator(inputs);
var active = false;
- for(var i = 0; i < inputs.length; i++) {
- if(inputs[i].attr("data-cip-id") == usernameId) {
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].attr("data-cip-id") == usernameId) {
active = true;
}
- if(active && jQuery(inputs[i]).attr("type") && jQuery(inputs[i]).attr("type").toLowerCase() == "password") {
+ if (active && jQuery(inputs[i]).attr("type") && jQuery(inputs[i]).attr("type").toLowerCase() == "password") {
passwordField = inputs[i];
break;
}
}
}
- if(passwordField && !checkDisabled) {
+ if (passwordField && !checkDisabled) {
var passwordId = passwordField.attr("data-cip-id");
// check if passwordField is already used by another combination
- for(var i = 0; i < cipFields.combinations.length; i++) {
- if(cipFields.combinations[i].password == passwordId) {
+ for (var i = 0; i < cipFields.combinations.length; i++) {
+ if (cipFields.combinations[i].password == passwordId) {
passwordField = null;
break;
}
@@ -1062,10 +1062,10 @@ cipFields.getPasswordField = function(usernameId, checkDisabled) {
}
cipFields.prepareCombinations = function(combinations) {
- for(var i = 0; i < combinations.length; i++) {
+ for (var i = 0; i < combinations.length; i++) {
var pwField = _f(combinations[i].password);
// needed for auto-complete: don't overwrite manually filled-in password field
- if(pwField && !pwField.data("cipFields-onChange")) {
+ if (pwField && !pwField.data("cipFields-onChange")) {
pwField.data("cipFields-onChange", true);
pwField.change(function() {
jQuery(this).data("unchanged", false);
@@ -1075,9 +1075,9 @@ cipFields.prepareCombinations = function(combinations) {
// initialize form-submit for remembering credentials
var fieldId = combinations[i].password || combinations[i].username;
var field = _f(fieldId);
- if(field) {
+ if (field) {
var form = field.closest("form");
- if(form && form.length > 0) {
+ if (form && form.length > 0) {
cipForm.init(form, combinations[i]);
}
}
@@ -1085,18 +1085,18 @@ cipFields.prepareCombinations = function(combinations) {
}
cipFields.useDefinedCredentialFields = function() {
- 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 creds = cip.settings["defined-credential-fields"][document.location.origin];
var $found = _f(creds.username) || _f(creds.password);
- for(var i = 0; i < creds.fields.length; i++) {
- if(_fs(creds.fields[i])) {
+ for (var i = 0; i < creds.fields.length; i++) {
+ if (_fs(creds.fields[i])) {
$found = true;
break;
}
}
- if($found) {
+ if ($found) {
var fields = {
"username": creds.username,
"password": creds.password,
@@ -1143,7 +1143,7 @@ cip.init = function() {
}
cip.initCredentialFields = function(forceCall) {
- if(_called.initCredentialFields && !forceCall) {
+ if (_called.initCredentialFields && !forceCall) {
return;
}
_called.initCredentialFields = true;
@@ -1152,13 +1152,13 @@ cip.initCredentialFields = function(forceCall) {
cipFields.prepareVisibleFieldsWithID("select");
cip.initPasswordGenerator(inputs);
- if(!cipFields.useDefinedCredentialFields()) {
+ if (!cipFields.useDefinedCredentialFields()) {
// get all combinations of username + password fields
cipFields.combinations = cipFields.getAllCombinations(inputs);
}
cipFields.prepareCombinations(cipFields.combinations);
- if(cipFields.combinations.length == 0) {
+ if (cipFields.combinations.length == 0) {
chrome.extension.sendMessage({
'action': 'show_default_browseraction'
});
@@ -1168,7 +1168,7 @@ cip.initCredentialFields = function(forceCall) {
cip.url = document.location.origin;
cip.submitUrl = cip.getFormActionUrl(cipFields.combinations[0]);
- if(cip.settings.autoRetrieveCredentials) {
+ if (cip.settings.autoRetrieveCredentials) {
chrome.extension.sendMessage({
'action': 'retrieve_credentials',
'args': [ cip.url, cip.submitUrl ]
@@ -1177,11 +1177,11 @@ cip.initCredentialFields = function(forceCall) {
} // end function init
cip.initPasswordGenerator = function(inputs) {
- if(cip.settings.usePasswordGenerator) {
+ if (cip.settings.usePasswordGenerator) {
cipPassword.init();
- for(var i = 0; i < inputs.length; i++) {
- if(inputs[i] && inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i] && inputs[i].attr("type") && inputs[i].attr("type").toLowerCase() == "password") {
cipPassword.initField(inputs[i], inputs, i);
}
}
@@ -1189,7 +1189,7 @@ cip.initPasswordGenerator = function(inputs) {
}
cip.receiveCredentialsIfNecessary = function () {
- if(cip.credentials.length == 0) {
+ if (cip.credentials.length == 0) {
chrome.extension.sendMessage({
'action': 'retrieve_credentials',
'args': [ cip.url, cip.submitUrl ]
@@ -1213,7 +1213,7 @@ cip.prepareFieldsForCredentials = function(autoFillInForSingle) {
// only one login for this site
if (autoFillInForSingle && cip.settings.autoFillSingleEntry && cip.credentials.length == 1) {
var combination = null;
- if(!cip.p && !cip.u && cipFields.combinations.length > 0) {
+ if (!cip.p && !cip.u && cipFields.combinations.length > 0) {
cip.u = _f(cipFields.combinations[0].username);
cip.p = _f(cipFields.combinations[0].password);
combination = cipFields.combinations[0];
@@ -1227,9 +1227,9 @@ cip.prepareFieldsForCredentials = function(autoFillInForSingle) {
combination = cipFields.getCombination("password", cip.p);
}
- if(combination) {
+ if (combination) {
var list = {};
- if(cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
+ if (cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
cipForm.destroy(false, {"password": list.list[0], "username": list.list[1]});
}
}
@@ -1251,7 +1251,7 @@ cip.preparePageForMultipleCredentials = function(credentials) {
var usernames = [];
cipAutocomplete.elements = [];
var visibleLogin;
- for(var i = 0; i < credentials.length; i++) {
+ for (var i = 0; i < credentials.length; i++) {
visibleLogin = (credentials[i].login.length > 0) ? credentials[i].login : "- no username -";
usernames.push(visibleLogin + " (" + credentials[i].name + ")");
var item = {
@@ -1269,9 +1269,9 @@ cip.preparePageForMultipleCredentials = function(credentials) {
});
// initialize autocomplete for username fields
- if(cip.settings.autoCompleteUsernames) {
- for(var i = 0; i < cipFields.combinations.length; i++) {
- if(_f(cipFields.combinations[i].username)) {
+ if (cip.settings.autoCompleteUsernames) {
+ for (var i = 0; i < cipFields.combinations.length; i++) {
+ if (_f(cipFields.combinations[i].username)) {
cipAutocomplete.init(_f(cipFields.combinations[i].username));
}
}
@@ -1281,18 +1281,18 @@ cip.preparePageForMultipleCredentials = function(credentials) {
cip.getFormActionUrl = function(combination) {
var field = _f(combination.password) || _f(combination.username);
- if(field == null) {
+ if (field == null) {
return null;
}
var form = field.closest("form");
var action = null;
- if(form && form.length > 0) {
+ if (form && form.length > 0) {
action = form[0].action;
}
- if(typeof(action) != "string" || action == "") {
+ if (typeof(action) != "string" || action == "") {
action = document.location.origin + document.location.pathname;
}
@@ -1305,26 +1305,26 @@ cip.fillInCredentials = function(combination, onlyPassword, suppressWarnings) {
var u = _f(combination.username);
var p = _f(combination.password);
- if(combination.isNew) {
+ if (combination.isNew) {
// initialize form-submit for remembering credentials
var fieldId = combination.password || combination.username;
var field = _f(fieldId);
- if(field) {
+ if (field) {
var form2 = field.closest("form");
- if(form2 && form2.length > 0) {
+ if (form2 && form2.length > 0) {
cipForm.init(form2, combination);
}
}
}
- if(u) {
+ if (u) {
cip.u = u;
}
- if(p) {
+ if (p) {
cip.p = p;
}
- if(cip.url == document.location.origin && cip.submitUrl == action && cip.credentials.length > 0) {
+ if (cip.url == document.location.origin && cip.submitUrl == action && cip.credentials.length > 0) {
cip.fillIn(combination, onlyPassword, suppressWarnings);
}
else {
@@ -1344,7 +1344,7 @@ cip.fillInCredentials = function(combination, onlyPassword, suppressWarnings) {
cip.fillInFromActiveElement = function(suppressWarnings) {
var el = document.activeElement;
if (el.tagName.toLowerCase() != "input") {
- if(cipFields.combinations.length > 0) {
+ if (cipFields.combinations.length > 0) {
cip.fillInCredentials(cipFields.combinations[0], false, suppressWarnings);
}
return;
@@ -1353,7 +1353,7 @@ cip.fillInFromActiveElement = function(suppressWarnings) {
cipFields.setUniqueId(jQuery(el));
var fieldId = cipFields.prepareId(jQuery(el).attr("data-cip-id"));
var combination = null;
- if(el.type && el.type.toLowerCase() == "password") {
+ if (el.type && el.type.toLowerCase() == "password") {
combination = cipFields.getCombination("password", fieldId);
}
else {
@@ -1367,7 +1367,7 @@ cip.fillInFromActiveElement = function(suppressWarnings) {
cip.fillInFromActiveElementPassOnly = function(suppressWarnings) {
var el = document.activeElement;
if (el.tagName.toLowerCase() != "input") {
- if(cipFields.combinations.length > 0) {
+ if (cipFields.combinations.length > 0) {
cip.fillInCredentials(cipFields.combinations[0], false, suppressWarnings);
}
return;
@@ -1376,14 +1376,14 @@ cip.fillInFromActiveElementPassOnly = function(suppressWarnings) {
cipFields.setUniqueId(jQuery(el));
var fieldId = cipFields.prepareId(jQuery(el).attr("data-cip-id"));
var combination = null;
- if(el.type && el.type.toLowerCase() == "password") {
+ if (el.type && el.type.toLowerCase() == "password") {
combination = cipFields.getCombination("password", fieldId);
}
else {
combination = cipFields.getCombination("username", fieldId);
}
- if(!_f(combination.password)) {
+ if (!_f(combination.password)) {
var message = "Unable to find a password field";
chrome.extension.sendMessage({
action: 'alert',
@@ -1398,10 +1398,10 @@ cip.fillInFromActiveElementPassOnly = function(suppressWarnings) {
}
cip.setValue = function(field, value) {
- if(field.is("select")) {
+ if (field.is("select")) {
value = value.toLowerCase().trim();
jQuery("option", field).each(function() {
- if(jQuery(this).text().toLowerCase().trim() == value) {
+ if (jQuery(this).text().toLowerCase().trim() == value) {
cip.setValueWithChange(field, jQuery(this).val());
return false;
}
@@ -1417,10 +1417,10 @@ cip.fillInStringFields = function(fields, StringFields, filledInFields) {
var $filledIn = false;
filledInFields.list = [];
- if(fields && StringFields && fields.length > 0 && StringFields.length > 0) {
- for(var i = 0; i < fields.length; i++) {
+ if (fields && StringFields && fields.length > 0 && StringFields.length > 0) {
+ for (var i = 0; i < fields.length; i++) {
var $sf = _fs(fields[i]);
- if($sf && StringFields[i]) {
+ if ($sf && StringFields[i]) {
//$sf.val(StringFields[i].Value);
cip.setValue($sf, StringFields[i].Value);
filledInFields.list.push(fields[i]);
@@ -1466,11 +1466,11 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
// exactly one pair of credentials available
if (cip.credentials.length == 1) {
var filledIn = false;
- if(uField && !onlyPassword) {
+ if (uField && !onlyPassword) {
cip.setValueWithChange(uField, cip.credentials[0].login);
filledIn = true;
}
- if(pField) {
+ if (pField) {
pField.attr("type", "password");
cip.setValueWithChange(pField, cip.credentials[0].password);
pField.data("unchanged", true);
@@ -1478,13 +1478,13 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
}
var list = {};
- if(cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
+ if (cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
cipForm.destroy(false, {"password": list.list[0], "username": list.list[1]});
filledIn = true;
}
- if(!filledIn) {
- if(!suppressWarnings) {
+ if (!filledIn) {
+ if (!suppressWarnings) {
var message = "Error #101\nCannot find fields to fill in.";
chrome.extension.sendMessage({
action: 'alert',
@@ -1494,27 +1494,27 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
}
}
// specific login id given
- else if(combination.loginId != undefined && cip.credentials[combination.loginId]) {
+ else if (combination.loginId != undefined && cip.credentials[combination.loginId]) {
var filledIn = false;
- if(uField) {
+ if (uField) {
cip.setValueWithChange(uField, cip.credentials[combination.loginId].login);
filledIn = true;
}
- if(pField) {
+ if (pField) {
cip.setValueWithChange(pField, cip.credentials[combination.loginId].password);
pField.data("unchanged", true);
filledIn = true;
}
var list = {};
- if(cip.fillInStringFields(combination.fields, cip.credentials[combination.loginId].stringFields, list)) {
+ if (cip.fillInStringFields(combination.fields, cip.credentials[combination.loginId].stringFields, list)) {
cipForm.destroy(false, {"password": list.list[0], "username": list.list[1]});
filledIn = true;
}
- if(!filledIn) {
- if(!suppressWarnings) {
+ if (!filledIn) {
+ if (!suppressWarnings) {
var message = "Error #102\nCannot find fields to fill in.";
chrome.extension.sendMessage({
action: 'alert',
@@ -1528,7 +1528,7 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
// check if only one password for given username exists
var countPasswords = 0;
- if(uField) {
+ if (uField) {
var valPassword = "";
var valUsername = "";
var valStringFields = [];
@@ -1536,7 +1536,7 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
// find passwords to given username (even those with empty username)
for (var i = 0; i < cip.credentials.length; i++) {
- if(cip.credentials[i].login.toLowerCase() == valQueryUsername) {
+ if (cip.credentials[i].login.toLowerCase() == valQueryUsername) {
countPasswords += 1;
valPassword = cip.credentials[i].password;
valUsername = cip.credentials[i].login;
@@ -1545,30 +1545,30 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
}
// for the correct alert message: 0 = no logins, X > 1 = too many logins
- if(countPasswords == 0) {
+ if (countPasswords == 0) {
countPasswords = cip.credentials.length;
}
// only one mapping username found
- if(countPasswords == 1) {
- if(!onlyPassword) {
+ if (countPasswords == 1) {
+ if (!onlyPassword) {
cip.setValueWithChange(uField, valUsername);
}
- if(pField) {
+ if (pField) {
cip.setValueWithChange(pField, valPassword);
pField.data("unchanged", true);
}
var list = {};
- if(cip.fillInStringFields(combination.fields, valStringFields, list)) {
+ if (cip.fillInStringFields(combination.fields, valStringFields, list)) {
cipForm.destroy(false, {"password": list.list[0], "username": list.list[1]});
}
}
// user has to select correct credentials by himself
- if(countPasswords > 1) {
- if(!suppressWarnings) {
- var message = "Error #105\nMore than one login was found in KeePass!\n" +
+ if (countPasswords > 1) {
+ if (!suppressWarnings) {
+ var message = "Error #105\nMore than one login was found in KeePassXC!\n" +
"Press the chromeIPass icon for more options.";
chrome.extension.sendMessage({
action: 'alert',
@@ -1576,8 +1576,8 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
});
}
}
- else if(countPasswords < 1) {
- if(!suppressWarnings) {
+ else if (countPasswords < 1) {
+ if (!suppressWarnings) {
var message = "Error #103\nNo credentials for given username found.";
chrome.extension.sendMessage({
action: 'alert',
@@ -1587,9 +1587,9 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
}
}
else {
- if(!suppressWarnings) {
- var message = "Error #104\nMore than one login was found in KeePass!\n" +
- "Press the chromeIPass icon for more options.";
+ if (!suppressWarnings) {
+ var message = "Error #104\nMore than one login was found in KeePassXC!\n" +
+ "Press the chromeKeePassXC icon for more options.";
chrome.extension.sendMessage({
action: 'alert',
args: [message]
@@ -1608,7 +1608,7 @@ cip.contextMenuRememberCredentials = function() {
cipFields.setUniqueId(jQuery(el));
var fieldId = cipFields.prepareId(jQuery(el).attr("data-cip-id"));
var combination = null;
- if(el.type && el.type.toLowerCase() == "password") {
+ if (el.type && el.type.toLowerCase() == "password") {
combination = cipFields.getCombination("password", fieldId);
}
else {
@@ -1621,14 +1621,14 @@ cip.contextMenuRememberCredentials = function() {
var usernameField = _f(combination.username);
var passwordField = _f(combination.password);
- if(usernameField) {
+ if (usernameField) {
usernameValue = usernameField.val();
}
- if(passwordField) {
+ if (passwordField) {
passwordValue = passwordField.val();
}
- if(!cip.rememberCredentials(usernameValue, passwordValue)) {
+ if (!cip.rememberCredentials(usernameValue, passwordValue)) {
alert("Could not detect changed credentials.");
}
};
@@ -1636,35 +1636,35 @@ cip.contextMenuRememberCredentials = function() {
cip.rememberCredentials = function(usernameValue, passwordValue) {
// no password given or field cleaned by a site-running script
// --> no password to save
- if(passwordValue == "") {
+ if (passwordValue == "") {
return false;
}
var usernameExists = false;
var nothingChanged = false;
- for(var i = 0; i < cip.credentials.length; i++) {
- if(cip.credentials[i].login == usernameValue && cip.credentials[i].password == passwordValue) {
+ for (var i = 0; i < cip.credentials.length; i++) {
+ if (cip.credentials[i].login == usernameValue && cip.credentials[i].password == passwordValue) {
nothingChanged = true;
break;
}
- if(cip.credentials[i].login == usernameValue) {
+ if (cip.credentials[i].login == usernameValue) {
usernameExists = true;
}
}
- if(!nothingChanged) {
- if(!usernameExists) {
- for(var i = 0; i < cip.credentials.length; i++) {
- if(cip.credentials[i].login == usernameValue) {
+ if (!nothingChanged) {
+ if (!usernameExists) {
+ for (var i = 0; i < cip.credentials.length; i++) {
+ if (cip.credentials[i].login == usernameValue) {
usernameExists = true;
break;
}
}
}
var credentialsList = [];
- for(var i = 0; i < cip.credentials.length; i++) {
+ for (var i = 0; i < cip.credentials.length; i++) {
credentialsList.push({
"Login": cip.credentials[i].login,
"Name": cip.credentials[i].name,
@@ -1673,11 +1673,11 @@ cip.rememberCredentials = function(usernameValue, passwordValue) {
}
var url = jQuery(this)[0].action;
- if(!url) {
+ if (!url) {
url = document.location.href;
- if(url.indexOf("?") > 0) {
+ if (url.indexOf("?") > 0) {
url = url.substring(0, url.indexOf("?"));
- if(url.length < document.location.origin.length) {
+ if (url.length < document.location.origin.length) {
url = document.location.origin;
}
}
@@ -1702,11 +1702,11 @@ cipEvents.clearCredentials = function() {
cip.credentials = [];
cipAutocomplete.elements = [];
- if(cip.settings.autoCompleteUsernames) {
- for(var i = 0; i < cipFields.combinations.length; i++) {
+ if (cip.settings.autoCompleteUsernames) {
+ for (var i = 0; i < cipFields.combinations.length; i++) {
var uField = _f(cipFields.combinations[i].username);
- if(uField) {
- if(uField.hasClass("cip-ui-autocomplete-input")) {
+ if (uField) {
+ if (uField.hasClass("cip-ui-autocomplete-input")) {
uField.autocomplete("destroy");
}
}
@@ -1720,7 +1720,7 @@ cipEvents.triggerActivatedTab = function() {
// initCredentialFields calls also "retrieve_credentials", to prevent it
// check of init() was already called
- if(_called.initCredentialFields && (cip.url || cip.submitUrl) && cip.settings.autoRetrieveCredentials) {
+ if (_called.initCredentialFields && (cip.url || cip.submitUrl) && cip.settings.autoRetrieveCredentials) {
chrome.extension.sendMessage({
'action': 'retrieve_credentials',
'args': [ cip.url, cip.submitUrl ]
diff --git a/chromeKeePassXC/options/options.html b/chromeKeePassXC/options/options.html
index 1e66d72..b7e8a4d 100644
--- a/chromeKeePassXC/options/options.html
+++ b/chromeKeePassXC/options/options.html
@@ -107,6 +107,7 @@
Automatically fill-in single credentials entry.
If chromeKeePassXC does only receive a single entry from KeePassXC it automatically fills this credentials into the found credential fields.
+ Warning! Using auto-fill is not safe. Use at your own risk.
@@ -162,15 +163,13 @@
Connected Databases
- If you are using several KeePass databases you can define a specific icon-color to each of them.
-
- This will help you to easily determine from which database the credentials are retrieved.
+ The following KeePassXC databases are connected to chromeKeePassXC.
Identifier
- Icon
+ Hash
Last used
Created
Delete
diff --git a/chromeKeePassXC/options/options.js b/chromeKeePassXC/options/options.js
index 9506937..b98057d 100644
--- a/chromeKeePassXC/options/options.js
+++ b/chromeKeePassXC/options/options.js
@@ -73,8 +73,6 @@ options.initGeneralSettings = function() {
$("#dangerousSettings").toggle();
});
- $("#hostname").val(options.settings["hostname"]);
- $("#port").val(options.settings["port"]);
$("#blinkTimeout").val(options.settings["blinkTimeout"]);
$("#blinkMinTimeout").val(options.settings["blinkMinTimeout"]);
$("#allowedRedirect").val(options.settings["allowedRedirect"]);
@@ -172,20 +170,6 @@ options.initConnectedDatabases = function() {
$("#tab-connected-databases tr.clone:first .dropdown-menu:first").width("230px");
- $("#tab-connected-databases tr.clone:first .color.dropdown .dropdown-menu a").click(function(e) {
- e.preventDefault();
- var $icon = $(this).attr("href").substring(1);
- var $hash = $(this).closest("tr").data("hash");
-
- $(this).parent().parent().find("a.dropdown-toggle:first").find("img:first").attr("src", "/icons/19x19/icon_normal_" + $icon + "_19x19.png");
-
- options.keyRing[$hash].icon = $icon;
- localStorage.keyRing = JSON.stringify(options.keyRing);
- chrome.extension.sendMessage({
- action: 'load_keyring'
- });
- });
-
var $trClone = $("#tab-connected-databases table tr.clone:first").clone(true);
$trClone.removeClass("clone");
for(var hash in options.keyRing) {
@@ -197,6 +181,7 @@ options.initConnectedDatabases = function() {
$("a.dropdown-toggle:first img:first", $tr).attr("src", "/icons/19x19/icon_normal_" + $icon + "_19x19.png");
$tr.children("td:first").text(options.keyRing[hash].id);
+ $tr.children("td:eq(1)").text(hash);
var lastUsed = (options.keyRing[hash].lastUsed) ? new Date(options.keyRing[hash].lastUsed).toLocaleString() : "unknown";
$tr.children("td:eq(2)").text(lastUsed);
var date = (options.keyRing[hash].created) ? new Date(options.keyRing[hash].created).toLocaleDateString() : "unknown";
diff --git a/chromeKeePassXC/popups/popup.js b/chromeKeePassXC/popups/popup.js
index 336ac1d..910e8f8 100644
--- a/chromeKeePassXC/popups/popup.js
+++ b/chromeKeePassXC/popups/popup.js
@@ -6,7 +6,6 @@ function status_response(r) {
$('#configured-and-associated').hide();
$('#configured-not-associated').hide();
-
if(!r.keePassXCAvailable || r.databaseClosed) {
$('#error-message').html(r.error);
$('#error-encountered').show();