Various fixes for 1.8.0 release (#1638)

Various small fixes for 1.8.0 release.
This commit is contained in:
Sami Vänttinen 2022-06-22 07:22:05 +03:00 committed by GitHub
parent ba5a7141fb
commit 063e6d990a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 31 additions and 22 deletions

View file

@ -331,7 +331,7 @@ function onDisconnected() {
keepass.associated.hash = null;
keepass.databaseHash = '';
page.clearCredentials(page.currentTabId, true);
page.clearAllLogins();
keepass.updatePopup('cross');
keepass.updateDatabaseHashToContent();
logError(`Failed to connect: ${(browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message)}`);

View file

@ -88,7 +88,7 @@ keepass.updateCredentials = async function(tab, args = []) {
const response = await keepassClient.sendMessage(kpAction, tab, messageData, nonce);
if (response) {
// KeePassXC versions lower than 2.5.0 will have an empty parsed.error
let successMessage = parsed.error;
let successMessage = response.error;
if (response.error === 'success' || response.error === '') {
successMessage = entryId ? 'updated' : 'created';
}

View file

@ -290,7 +290,7 @@ page.createTabEntry = function(tabId) {
credentials: [],
errorMessage: null,
loginList: [],
loginId: -1
loginId: undefined
};
page.clearSubmittedCredentials();
@ -320,14 +320,14 @@ page.retrieveCredentials = async function(tab, args = []) {
};
page.getLoginId = async function(tab) {
const currentTab = page.tabs[tab.id];
// If there's only one credential available and loginId is not set
if (page.tabs[tab.id] && page.tabs[tab.id].loginId < 0
&& page.tabs[tab.id]
&& page.tabs[tab.id].credentials.length === 1) {
return 0; // Index to the first credential
if (currentTab && !currentTab.loginId && currentTab.credentials.length === 1) {
return currentTab.credentials[0].uuid;
}
return page.tabs[tab.id] ? page.tabs[tab.id].loginId : undefined;
return currentTab ? currentTab.loginId : undefined;
};
page.setLoginId = async function(tab, loginId) {

View file

@ -34,6 +34,7 @@ const PREDEFINED_SITELIST = [
'https://idmsa.apple.com/*',
'https://secure.soundcloud.com/*',
'https://icloud.com/*',
'https://signin.benl.ebay.be/*',
'https://signin.ebay.de/*',
'https://signin.ebay.com/*',
'https://signin.ebay.com.au/*',

View file

@ -171,12 +171,14 @@ kpxcFields.getAllPageInputs = async function(previousInputs = []) {
kpxcFields.getCombination = async function(field, givenType) {
// If givenType is not set, return the combination that uses the selected field
for (const combination of kpxc.combinations) {
if (!givenType && Object.values(combination).find(c => c === field)) {
return combination;
} else if (givenType && combination[givenType]) {
if (combination[givenType] === field || combination[givenType].includes(field)) {
if (givenType) {
// Strictly search a given type
const c = combination[givenType];
if (c && (c === field || (Array.isArray(c) && c.includes(field)))) {
return combination;
}
} else if (Object.values(combination).find(c => c === field)) {
return combination;
}
}

View file

@ -108,8 +108,10 @@ kpxcIcons.hasIcon = function(field) {
};
// Sets the icons to corresponding database lock status
kpxcIcons.switchIcons = function() {
kpxcUsernameIcons.switchIcon(kpxc.databaseState);
kpxcPasswordIcons.switchIcon(kpxc.databaseState);
kpxcTOTPIcons.switchIcon(kpxc.databaseState);
kpxcIcons.switchIcons = async function() {
const uuid = await sendMessage('page_get_login_id');
kpxcUsernameIcons.switchIcon(kpxc.databaseState, uuid);
kpxcPasswordIcons.switchIcon(kpxc.databaseState, uuid);
kpxcTOTPIcons.switchIcon(kpxc.databaseState, uuid);
};

View file

@ -701,13 +701,14 @@ kpxc.siteIgnored = async function(condition) {
// Updates database status and icons when tab is activated again
kpxc.triggerActivatedTab = async function() {
await kpxc.updateDatabaseState();
kpxcIcons.switchIcons();
if (kpxc.databaseState === DatabaseState.UNLOCKED && kpxc.credentials.length === 0) {
await kpxc.retrieveCredentials();
} else if (kpxc.credentials.length > 0) {
kpxc.initLoginPopup();
}
kpxcIcons.switchIcons();
};
// Updates the database state to the content script

View file

@ -139,7 +139,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
}
// Filter out any input fields with type 'hidden' right away
const inputFields = [];
let inputFields = [];
Array.from(target.getElementsByTagName('input')).forEach(e => {
if (e.type !== 'hidden' && !e.disabled && !kpxcObserverHelper.alreadyIdentified(e)) {
inputFields.push(e);

View file

@ -31,8 +31,8 @@ kpxcTOTPIcons.newIcon = function(field, databaseState = DatabaseState.DISCONNECT
kpxcTOTPIcons.icons.push(new TOTPFieldIcon(field, databaseState, segmented));
};
kpxcTOTPIcons.switchIcon = function(state) {
kpxcTOTPIcons.icons.forEach(u => u.switchIcon(state));
kpxcTOTPIcons.switchIcon = function(state, uuid) {
kpxcTOTPIcons.icons.forEach(u => u.switchIcon(state, uuid));
};
kpxcTOTPIcons.deleteHiddenIcons = function() {
@ -127,6 +127,8 @@ TOTPFieldIcon.prototype.createIcon = function(field, segmented = false) {
if (this.databaseState === DatabaseState.DISCONNECTED || this.databaseState === DatabaseState.LOCKED) {
icon.style.filter = 'saturate(0%)';
} else {
icon.style.filter = 'saturate(100%)';
}
icon.addEventListener('click', async function(e) {

View file

@ -44,13 +44,13 @@ class Icon {
}
}
switchIcon(state) {
switchIcon(state, uuid) {
if (!this.icon) {
return;
}
if (state === DatabaseState.UNLOCKED) {
this.icon.style.filter = kpxc.credentials.length === 0 ? 'saturate(0%)' : 'saturate(100%)';
this.icon.style.filter = kpxc.credentials.length === 0 && !uuid ? 'saturate(0%)' : 'saturate(100%)';
} else {
this.icon.style.filter = 'saturate(0%)';
}

View file

@ -122,6 +122,7 @@ code {
}
#options-button {
height: 31px;
width: 2.5rem;
}