Merge branch 'develop'

This commit is contained in:
varjolintu 2017-07-31 14:16:19 +03:00
commit 0e2370a08c
20 changed files with 107 additions and 72 deletions

View file

@ -1,3 +1,12 @@
0.2.7 (2017-07-31)
=========================
- Some Firefox related changes (credits to projectgus)
- Fixed Skip button function when choosing own credential fields
- Adjusted some callbacks
- Fixed showing an error message on the same tab when KeePassXC is instantly closed
- Added null checking for onDisconnected()
- Any Chrome related stuff is now disabled on options pages when using Firefox
0.2.6 (2017-07-23)
=========================
- Fixed error message variables

View file

@ -2,6 +2,7 @@
Chrome extension for [KeePassXC](https://keepassxc.org/) with Native Messaging.
This is a heavily forked version of [pfn](https://github.com/pfn)'s [chromeIPass](https://github.com/pfn/passifox).
Some changes merged also from [projectgus'](https://github.com/projectgus/passifox) fork.
For testing purposes, please use following unofficial KeePassXC [release's](https://github.com/varjolintu/keepassxc/releases).
Get the extension for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) or [Chrome/Chromium](https://chrome.google.com/webstore/detail/keepassxc-browser/iopaggbpplllidnfmcghoonnokmjoicf).

View file

@ -5,6 +5,7 @@
"type": "stdio",
"allowed_origins": [
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/"
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/",
"chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/"
]
}

View file

@ -5,6 +5,7 @@
"type": "stdio",
"allowed_origins": [
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/"
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/",
"chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/"
]
}

View file

@ -249,7 +249,9 @@ function getValueOrDefault(settings, key, defaultVal, min) {
val = defaultVal;
}
return val;
} catch(e) { return defaultVal; }
} catch(e) {
return defaultVal;
}
}
browserAction.generateIconName = function(iconType, icon) {

View file

@ -44,11 +44,6 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) {
page.removePageInformationFromNotExistingTabs();
browser.tabs.get(senderTabId, (tab) => {
//browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, function(tabs) {
//if (tabs.length === 0)
// return; // For example: only the background devtools or a popup are opened
//var tab = tabs[0];
if (!tab) {
return;
}
@ -95,6 +90,7 @@ event.showStatus = function(configured, tab, callback) {
}
browserAction.showDefault(null, tab);
const errorMessage = page.tabs[tab.id].errorMessage;
callback({
identifier: keyId,
configured: configured,
@ -102,7 +98,7 @@ event.showStatus = function(configured, tab, callback) {
keePassXCAvailable: keepass.isKeePassXCAvailable,
encryptionKeyUnrecognized: keepass.isEncryptionKeyUnrecognized,
associated: keepass.isAssociated(),
error: page.tabs[tab.id].errorMessage
error: errorMessage ? errorMessage : null
});
}
@ -260,6 +256,5 @@ event.messageHandlers = {
'stack_add': browserAction.stackAdd,
'update_available_keepassxc': event.onUpdateAvailableKeePassXC,
'generate_password': keepass.generatePassword,
'copy_password': keepass.copyPassword,
'reconnect': event.onReconnect
};

View file

@ -10,7 +10,9 @@ keepass.changePublicKeys(null, (pkRes) => {
window.browser = (function () { return window.msBrowser || window.browser || window.chrome; })();
// Set initial tab-ID
browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => {
//browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => {
browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => {
//browser.tabs.query({"active": true, "currentWindow": true}).then((tabs) => {
if (tabs.length === 0)
return; // For example: only the background devtools or a popup are opened
page.currentTabId = tabs[0].id;

View file

@ -45,6 +45,7 @@ const kpErrors = {
KEY_CHANGE_FAILED: 9,
ENCRYPTION_KEY_UNRECOGNIZED: 10,
NO_SAVED_DATABASES_FOUND: 11,
errorMessages : {
0: { msg: 'Unknown error' },
1: { msg: 'Database not opened' },
@ -58,6 +59,10 @@ const kpErrors = {
9: { msg: 'Key change was not successful.' },
10: { msg: 'Encryption key is not recognized' },
11: { msg: 'No saved databases found.' }
},
getError(errorCode) {
return this.errorMessages[errorCode].msg;
}
};
@ -139,6 +144,7 @@ keepass.retrieveCredentials = function (callback, tab, url, submiturl, forceCall
page.tabs[tab.id].errorMessage = null;
if (!keepass.isConnected) {
callback([]);
return;
}
@ -199,7 +205,7 @@ keepass.retrieveCredentials = function (callback, tab, url, submiturl, forceCall
// Redirects the callback to a listener (handleReply())
keepass.callbackOnId = function (ev, id, callback) {
let listener = ( (port, id) => {
let listener = ((port, id) => {
let handler = (msg) => {
if (msg && msg.action === id) {
ev.removeListener(handler);
@ -273,37 +279,15 @@ keepass.generatePassword = function (callback, tab, forceCallback) {
}, tab);
}
keepass.copyPassword = function(callback, tab, password) {
browser.runtime.getBackgroundPage((bg) => {
let c2c = bg.document.getElementById('copy2clipboard');
if (!c2c) {
let input = document.createElement('input');
input.type = 'text';
input.id = 'copy2clipboard';
bg.document.getElementsByTagName('body')[0].appendChild(input);
c2c = bg.document.getElementById('copy2clipboard');
}
c2c.value = password;
c2c.select();
try {
document.execCommand('copy');
c2c.value = '';
callback(true);
}
catch (err) {
console.log('Could not copy password to clipboard: ' + err);
}
});
}
keepass.associate = function(callback, tab) {
if (keepass.isAssociated()) {
callback([]);
return;
}
keepass.getDatabaseHash((res) => {
if (keepass.isDatabaseClosed || !keepass.isKeePassXCAvailable) {
callback([]);
return;
}
@ -511,6 +495,7 @@ keepass.getDatabaseHash = function (callback, tab, triggerUnlock) {
keepass.changePublicKeys = function(tab, callback) {
if (!keepass.isConnected) {
callback([]);
return;
}
@ -635,16 +620,14 @@ keepass.keePassXCUpdateAvailable = function() {
keepass.checkForNewKeePassXCVersion = function() {
let xhr = new XMLHttpRequest();
let version = -1;
xhr.open('GET', keepass.latestVersionUrl, true);
xhr.onload = function(e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
const json = JSON.parse(xhr.responseText);
if (json.tag_name) {
version = json.tag_name;
keepass.latestKeePassXC.version = version;
keepass.latestKeePassXC.versionParsed = Number(version.replace(/\./g, ''));
}
if (xhr.readyState === 4 && xhr.status === 200) {
const json = JSON.parse(xhr.responseText);
if (json.tag_name) {
version = json.tag_name;
keepass.latestKeePassXC.version = version;
keepass.latestKeePassXC.versionParsed = Number(version.replace(/\./g, ''));
}
}
@ -654,10 +637,16 @@ keepass.checkForNewKeePassXCVersion = function() {
};
xhr.onerror = function(e) {
console.log('checkForNewKeePassXCVersion error: ${e}');
console.log('checkForNewKeePassXCVersion error:' + e);
}
xhr.send();
try {
xhr.open('GET', keepass.latestVersionUrl, true);
xhr.send();
}
catch (ex) {
console.log(ex);
}
keepass.latestKeePassXC.lastChecked = new Date();
}
@ -672,11 +661,11 @@ keepass.onNativeMessage = function (response) {
}
function onDisconnected() {
console.log('Failed to connect: ' + browser.runtime.lastError.message);
keepass.nativePort = null;
keepass.isConnected = false;
keepass.isDatabaseClosed = true;
keepass.isKeePassXCAvailable = false;
console.log('Failed to connect: ' + (browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message));
}
keepass.nativeConnect = function() {
@ -734,7 +723,7 @@ keepass.verifyResponse = function(response, nonce, id) {
keepass.handleError = function(tab, errorCode, errorMessage = '') {
if (errorMessage.length === 0) {
errorMessage = kpErrors.errorMessages[errorCode].msg;
errorMessage = kpErrors.getError(errorCode);
}
console.log('Error ' + errorCode + ': ' + errorMessage);
if (tab && page.tabs[tab.id]) {

View file

@ -79,7 +79,6 @@ function _fs(fieldId) {
}
var cipAutocomplete = {};
// objects of username + description for autocomplete
@ -271,10 +270,7 @@ cipPassword.createDialog = function() {
id: 'cip-genpw-btn-clipboard',
click: (e) => {
e.preventDefault();
browser.runtime.sendMessage({
action: 'copy_password',
args: [jQuery('input#cip-genpw-textfield-password').val()]
}, cipPassword.callbackPasswordCopied);
cipPassword.copyPasswordToClipboard();
}
},
'Fill & copy':
@ -309,11 +305,7 @@ cipPassword.createDialog = function() {
}
}
// Copy password to clipboard
browser.runtime.sendMessage({
action: 'copy_password',
args: [$password]
}, cipPassword.callbackPasswordCopied);
cipPassword.copyPasswordToClipboard();
}
}
}
@ -381,6 +373,26 @@ cipPassword.setIconPosition = function($icon, $field) {
.css('left', $field.offset().left + $field.outerWidth() - $icon.data('size') - $icon.data('offset'))
}
cipPassword.copyPasswordToClipboard = function(e) {
if (e) {
e.preventDefault();
}
const input = jQuery("input#cip-genpw-textfield-password");
input.select()
try {
const success = document.execCommand('copy');
if (success) {
jQuery("#cip-genpw-btn-clipboard").addClass("b2c-btn-success");
}
jQuery("#cip-genpw-dialog").select();
input.value = '';
}
catch (err) {
console.log('Could not copy password to clipboard: ' + err);
}
}
cipPassword.callbackPasswordCopied = function(bool) {
if (bool) {
jQuery('#cip-genpw-btn-clipboard').addClass('btn-success');
@ -549,12 +561,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'));

View file

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "keepassxc-browser",
"version": "0.2.6",
"version": "0.2.7",
"description": "KeePassXC integration for modern web browsers",
"author": "Sami Vänttinen",
"icons": {
@ -36,9 +36,19 @@
},
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*" ],
"js": [ "jquery-3.2.1.min.js", "jquery-ui.min.js", "keepassxc-browser.js" ],
"css": [ "jquery-ui.min.css", "keepassxc-browser.css" ],
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"jquery-3.2.1.min.js",
"jquery-ui.min.js",
"keepassxc-browser.js"
],
"css": [
"jquery-ui.min.css",
"keepassxc-browser.css"
],
"run_at": "document_idle",
"all_frames": true
}

View file

@ -2,7 +2,7 @@
<html>
<head>
<title>Settings | keepassxc-browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" href="bootstrap.min.css" />
<link rel="stylesheet" href="options.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>
@ -29,7 +29,8 @@
<p>
If you just want to insert username + password into the fields where your focus is, press <code>Ctrl + Shift + U</code>.
<br />
If you only want to insert the password, just press <code>Ctrl + Shift + P</code>. You can customize these shortcuts on <code>chrome://extensions/configureCommands</code> page
If you only want to insert the password, just press <code>Ctrl + Shift + P</code>.
<span id="chrome-only">You can customize these shortcuts on <code>chrome://extensions/configureCommands</code> page</span>
</p>
<p>
<div class="form-group">

View file

@ -1,3 +1,8 @@
var isFirefox = false;
if (typeof browser !== 'undefined') {
isFirefox = true;
}
window.browser = (function () { return window.msBrowser || window.browser || window.chrome; })();
if (jQuery) {
@ -36,7 +41,7 @@ options.saveSetting = function(name) {
localStorage.settings = JSON.stringify(options.settings);
chrome.extension.sendMessage({
browser.runtime.sendMessage({
action: 'load_settings'
});
}
@ -257,4 +262,7 @@ options.initSpecifiedCredentialFields = function() {
options.initAbout = function() {
$('#tab-about em.versionCIP').text(browser.runtime.getManifest().version);
if (isFirefox) {
$('#chrome-only').remove();
}
}

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>KeePassXC - Popup</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../options/bootstrap.min.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>

View file

@ -55,7 +55,7 @@ $(function() {
});
$('#redetect-fields-button').click(function() {
browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => {
browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => {
if (tabs.length === 0)
return; // For example: only the background devtools or a popup are opened
let tab = tabs[0];

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>keepassxc-browser - Popup</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../options/bootstrap.min.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>

View file

@ -2,8 +2,7 @@ window.browser = (function () { return window.msBrowser || window.browser || win
$(function() {
browser.runtime.getBackgroundPage(function(global) {
browser.tabs.query(null, (tab) => {
//const data = global.tab_httpauth_list['tab' + tab.id];
browser.tabs.query({"active": true, "currentWindow": true}, (tab) => {
const data = global.page.tabs[tab.id].loginList;
let ul = document.getElementById('login-list');
for (let i = 0; i < data.logins.length; i++) {

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>KeePassXC - Popup</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../options/bootstrap.min.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>

View file

@ -2,7 +2,7 @@ window.browser = (function () { return window.msBrowser || window.browser || win
$(function() {
browser.runtime.getBackgroundPage(function(global) {
browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, function(tabs) {
browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => {
if (tabs.length === 0)
return; // For example: only the background devtools or a popup are opened
const tab = tabs[0];

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>keepassxc-browser - Popup</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../options/bootstrap.min.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>keepassxc-browser - Popup</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../options/bootstrap.min.css" />
<script type="text/javascript" src="../jquery-3.2.1.min.js"></script>