Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed May 9, 2018
2 parents 3eccf42 + a01109e commit da2685c
Show file tree
Hide file tree
Showing 22 changed files with 472 additions and 151 deletions.
15 changes: 7 additions & 8 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<!--- Provide a general summary of the issue in the title above -->

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->


## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from the current behavior -->


## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->


## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
Expand All @@ -22,11 +24,8 @@

## Debug info
<!--- Please copy/paste the browser's JavaScript console messages and errors here -->

## General Info
KeePassXC fork - VERSION
keepassxc-browser - VERSION

Operating system: OS
Browser: BROWSER
KeePassXC - {VERSION}
keepassxc-browser - {VERSION}
Operating system: Mac/Win/Linux
Browser: Chrome/Firefox/Vivaldi/Chromium
Proxy used: YES/NO
12 changes: 12 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
1.1.0 (09-05-2018)
=========================
- Allow specifying ignored sites
- Add new notification options
- Improve detection of username fields
- Change conflicting shortcuts
- Redetect credential fields after reload
- Don't show popup when database is closed
- Various password generator fixes
- Fix various resource leaks
- Fix searching in all databases

1.0.1 (04-03-2018)
=========================
- Don't fill password fields if they already have data
Expand Down
54 changes: 52 additions & 2 deletions keepassxc-browser/background/browserAction.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const browserAction = {};

const BLINK_TIMEOUT_DEFAULT = 7500;
Expand Down Expand Up @@ -202,6 +204,14 @@ browserAction.removeRememberPopup = function(callback, tab, removeImmediately) {
browserAction.setRememberPopup = function(tabId, username, password, url, usernameExists, credentialsList) {
browser.storage.local.get({'settings': {}}).then(function(item) {
const settings = item.settings;

// Don't show anything if the site is in the ignore list
for (const site in settings.ignoredSites) {
if (site === url) {
return;
}
}

const id = tabId || page.currentTabId;
let timeoutMinMillis = Number(getValueOrDefault(settings, 'blinkMinTimeout', BLINK_TIMEOUT_REDIRECT_THRESHOLD_TIME_DEFAULT, 0));

Expand Down Expand Up @@ -239,8 +249,30 @@ browserAction.setRememberPopup = function(tabId, username, password, url, userna

browserAction.show(null, {'id': id});

if (page.settings.showNotifications) {
showNotification('Create or modify the credentials by clicking on the extension icon.');
if (page.settings.showLoginNotifications) {
const message = 'Create or modify the credentials by clicking on the extension icon.';
const buttons = [
{
'title': 'Close'
},
{
'title': 'Never ask for this page'
}];

browser.notifications.create({
'type': 'basic',
'iconUrl': browser.extension.getURL('icons/keepassxc_64x64.png'),
'title': 'KeePassXC-Browser',
'message': message,
'buttons': buttons
});

browser.notifications.onButtonClicked.addListener((id, index) => {
browser.notifications.clear(id);
if (index === 1) {
browserAction.ignoreSite(url);
}
});
}
});
};
Expand Down Expand Up @@ -269,3 +301,21 @@ browserAction.generateIconName = function(iconType, icon) {

return name;
};

browserAction.ignoreSite = function(url) {
browser.windows.getCurrent().then((win) => {
// Get current active window
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
const tab = tabs[0];

// Send the message to the current tab's content script
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.sendMessage(tab.id, {
action: 'ignore-site',
args: [url]
});
});
});
});
};

45 changes: 28 additions & 17 deletions keepassxc-browser/background/event.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const kpxcEvent = {};

kpxcEvent.onMessage = function(request, sender, callback) {
Expand Down Expand Up @@ -72,12 +74,15 @@ kpxcEvent.invoke = function(handler, callback, senderTabId, args, secondTime) {
else {
console.log('undefined handler for tab ' + tab.id);
}
}).catch((e) => {console.log(e);});
}).catch((e) => {
console.log(e);
});
};

kpxcEvent.onShowAlert = function(callback, tab, message) {
if (page.settings.supressAlerts) { console.log(message); }
else { alert(message); }
kpxcEvent.onShowNotification = function(callback, tab, message) {
if (page.settings.showNotifications) {
showNotification(message);
}
};

kpxcEvent.showStatus = function(configured, tab, callback) {
Expand Down Expand Up @@ -159,13 +164,18 @@ kpxcEvent.onReconnect = function(callback, tab) {
if (gdRes) {
keepass.testAssociation((response) => {
keepass.isConfigured().then((configured) => {
browser.tabs.sendMessage(tab.id, {
action: 'redetect_fields'
});
kpxcEvent.showStatus(configured, tab, callback);
}).catch((e) => {console.log(e);});
}).catch((e) => {
console.log(e);
});
}, tab);
}
}, null);
});
}, 2000);
}, 500);
};

kpxcEvent.lockDatabase = function(callback, tab) {
Expand Down Expand Up @@ -216,7 +226,17 @@ kpxcEvent.onRemoveCredentialsFromTabInformation = function(callback, tab) {
};

kpxcEvent.onSetRememberPopup = function(callback, tab, username, password, url, usernameExists, credentialsList) {
browserAction.setRememberPopup(tab.id, username, password, url, usernameExists, credentialsList);
keepass.testAssociation((response) => {
if (response) {
keepass.isConfigured().then((configured) => {
if (configured) {
browserAction.setRememberPopup(tab.id, username, password, url, usernameExists, credentialsList);
}
}).catch((e) => {
console.log(e);
});
}
}, tab);
};

kpxcEvent.onLoginPopup = function(callback, tab, logins) {
Expand Down Expand Up @@ -263,20 +283,10 @@ kpxcEvent.pageClearLogins = function(callback, tab, alreadyCalled) {
callback();
};

kpxcEvent.oldDatabaseHash = 'no-hash';
kpxcEvent.checkDatabaseHash = function(callback, tab) {
keepass.checkDatabaseHash((response) => {
callback({old: kpxcEvent.oldDatabaseHash, new: response});
kpxcEvent.oldDatabaseHash = response;
});
};

// all methods named in this object have to be declared BEFORE this!
kpxcEvent.messageHandlers = {
'add_credentials': keepass.addCredentials,
'alert': kpxcEvent.onShowAlert,
'associate': keepass.associate,
'check_databasehash': kpxcEvent.checkDatabaseHash,
'check_update_keepassxc': kpxcEvent.onCheckUpdateKeePassXC,
'generate_password': keepass.generatePassword,
'get_connected_database': kpxcEvent.onGetConnectedDatabase,
Expand All @@ -298,6 +308,7 @@ kpxcEvent.messageHandlers = {
'update_credentials': keepass.updateCredentials,
'save_settings': kpxcEvent.onSaveSettings,
'set_remember_credentials': kpxcEvent.onSetRememberPopup,
'show_notification': kpxcEvent.onShowNotification,
'stack_add': browserAction.stackAdd,
'update_available_keepassxc': kpxcEvent.onUpdateAvailableKeePassXC
};
2 changes: 2 additions & 0 deletions keepassxc-browser/background/httpauth.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const httpAuth = {};

httpAuth.requests = [];
Expand Down
2 changes: 2 additions & 0 deletions keepassxc-browser/background/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

keepass.migrateKeyRing().then(() => {
page.initSettings().then(() => {
page.initOpenedTabs().then(() => {
Expand Down
27 changes: 24 additions & 3 deletions keepassxc-browser/background/keepass.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ keepass.keySize = 24;
keepass.latestVersionUrl = 'https://api.github.com/repos/keepassxreboot/keepassxc/releases/latest';
keepass.cacheTimeout = 30 * 1000; // milliseconds
keepass.databaseHash = 'no-hash'; //no-hash = KeePassXC is too old and does not return a hash value
keepass.previousDatabaseHash = 'no-hash';
keepass.keyId = 'keepassxc-browser-cryptokey-name';
keepass.keyBody = 'keepassxc-browser-key';
keepass.messageTimeout = 500; // milliseconds
Expand Down Expand Up @@ -214,15 +215,24 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb
}

let entries = [];
let keys = [];
const kpAction = kpActions.GET_LOGINS;
const nonce = keepass.getNonce();
const incrementedNonce = keepass.incrementedNonce(nonce);
const {dbid} = keepass.getCryptoKey();

for (let keyHash in keepass.keyRing) {
keys.push({
id: keepass.keyRing[keyHash].id,
key: keepass.keyRing[keyHash].key
});
}

let messageData = {
action: kpAction,
id: dbid,
url: url
url: url,
keys: keys
};

if (submiturl) {
Expand Down Expand Up @@ -704,7 +714,7 @@ keepass.isAssociated = function() {
keepass.migrateKeyRing = function() {
return new Promise((resolve, reject) => {
browser.storage.local.get('keyRing').then((item) => {
const keyring = item.keyRing;
const keyring = item.keyRing;
// Change dates to numbers, for compatibilty with Chromium based browsers
if (keyring) {
let num = 0;
Expand Down Expand Up @@ -826,11 +836,22 @@ keepass.onNativeMessage = function(response) {

// Handle database lock/unlock status
if (response.action === kpActions.DATABASE_LOCKED || response.action === kpActions.DATABASE_UNLOCKED) {
keepass.testAssociation((response) => {
keepass.testAssociation((associationResponse) => {
keepass.isConfigured().then((configured) => {
let data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
data.iconType = configured ? 'normal' : 'cross';
browserAction.show(null, {'id': page.currentTabId});

// Send message to content script
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
if (tabs.length) {
browser.tabs.sendMessage(tabs[0].id, {
action: 'check_database_hash',
hash: {old: kpxcEvent.previousDatabaseHash, new: keepass.databaseHash}
});
keepass.previousDatabaseHash = keepass.databaseHash;
}
});
});
}, null);
}
Expand Down
18 changes: 14 additions & 4 deletions keepassxc-browser/background/page.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
'use strict';

const defaultSettings = {
checkUpdateKeePassXC: 3,
autoCompleteUsernames: true,
autoFillAndSend: true,
usePasswordGenerator: true,
autoFillSingleEntry: false,
autoRetrieveCredentials: true,
showNotifications: true
showNotifications: true,
showLoginNotifications: true,
saveDomainOnly: true
};

var page = {};
page.tabs = {};
page.tabs = [];
page.currentTabId = -1;
page.blockedTabs = {};
page.blockedTabs = [];

page.initSettings = function() {
return new Promise((resolve, reject) => {
Expand All @@ -38,6 +42,12 @@ page.initSettings = function() {
if (!('showNotifications' in page.settings)) {
page.settings.showNotifications = defaultSettings.showNotifications;
}
if (!('showLoginNotifications' in page.settings)) {
page.settings.showLoginNotifications = defaultSettings.showLoginNotifications;
}
if (!('saveDomainOnly' in page.settings)) {
page.settings.saveDomainOnly = defaultSettings.saveDomainOnly;
}
browser.storage.local.set({'settings': page.settings});
resolve(page.settings);
});
Expand Down Expand Up @@ -101,7 +111,7 @@ page.createTabEntry = function(tabId) {
page.tabs[tabId] = {
'stack': [],
'errorMessage': null,
'loginList': {}
'loginList': []
};
};

Expand Down
2 changes: 2 additions & 0 deletions keepassxc-browser/global.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var isFirefox = function() {
if (!(/Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor))) {
return true;
Expand Down
9 changes: 7 additions & 2 deletions keepassxc-browser/keepassxc-browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.kpxc .ui-dialog {
font-size: 12px !important;
box-shadow: 0 4px 6px 0 hsla(0, 0%, 0%, 0.2);
z-index: 2147483645;
}

.kpxc .ui-widget-overlay {
Expand Down Expand Up @@ -57,10 +58,10 @@ input.genpw-text {
}

.genpw-input-group-addon {
font-size: inherit !important;
font-size: .9em !important;
background-color: #eee;
border: 1px solid #ccc;
padding: .4em;
padding: .2em;
border-radius: 4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
Expand Down Expand Up @@ -102,6 +103,10 @@ input.genpw-text {
margin-right: 5px;
}

#cip-genpw-quality {
text-align: center;
}

.b2c-modal-backdrop {
position: fixed;
top: 0;
Expand Down
Loading

0 comments on commit da2685c

Please sign in to comment.