Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions keepassxc-browser/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,14 @@
"message": "Credentials are cleared from background tabs after the timeout and permissions for those pages will be asked again.",
"description": "Clear credentials timeout help text."
},
"optionsConnectionTimeout": {
"message": "KeepassXC connection timeout: $1 seconds",
"description": "Connection timeout label text."
},
"optionsConnectionTimeoutHelpText": {
"message": "When KeePassXC browser extension tries to connect to to keepass, this timeout value is used. Default value is 1.5. Maximum is 60.0.",
"description": "Connection timeout label text."
},
"optionsVersionInfoText": {
"message": "KeePassXC-Browser needs KeePassXC to retrieve credentials.",
"description": "Settings page version info text."
Expand Down
2 changes: 1 addition & 1 deletion keepassxc-browser/background/keepass.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ keepass.disableAutomaticReconnect = function() {
keepass.reconnectLoop = null;
};

keepass.reconnect = async function(tab = null, connectionTimeout = 1500) {
keepass.reconnect = async function(tab = null, connectionTimeout = page.settings.connectionTimeout) {
keepassClient.connectToNative();
keepass.generateNewKeyPair();
const keyChangeResult = await keepass.changePublicKeys(tab, !!connectionTimeout, connectionTimeout).catch(() => false);
Expand Down
2 changes: 2 additions & 0 deletions keepassxc-browser/background/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaultSettings = {
bannerPosition: BannerPosition.TOP,
checkUpdateKeePassXC: CHECK_UPDATE_NEVER,
clearCredentialsTimeout: 10,
connectionTimeout: 1500,
colorTheme: 'system',
credentialSorting: SORT_BY_GROUP_AND_TITLE,
debugLogging: false,
Expand Down Expand Up @@ -47,6 +48,7 @@ page.autoSubmitPerformed = false;
page.attributeMenuItems = [];
page.blockedTabs = [];
page.clearCredentialsTimeout = null;
page.connectionTimeout = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is not used, and not needed.

page.currentRequest = {};
page.currentTabId = -1;
page.isFirefox = false;
Expand Down
4 changes: 4 additions & 0 deletions keepassxc-browser/managed_storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"title": "Clear credential info from tabs after timeout. Default (seconds): 10",
"type": "integer"
},
"connectionTimeout": {
"title": "Connection timeout to KeePassXC. Default (seconds): 1.5",
"type": "integer"
},
"colorTheme": {
"title": "Extension color scheme. Default: system",
"type": "string"
Expand Down
8 changes: 8 additions & 0 deletions keepassxc-browser/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,14 @@ <h2 class="pb-3 mt-0" data-i18n="optionsGeneralSettingsTab"></h2>
<div class="form-text" data-i18n="optionsClearCredentialsTimeoutHelpText"></div>
</div>


<!-- Keepass connectiontimeout -->
<div class="form-group mt-2 pb-1">
<label id="connectionTimeoutLabel" class="font-weight-normal" for="connectionTimeout" data-i18n="optionsConnectionTimeout" data-i18n-placeholder="1.5"></label>
<input type="range" class="form-range" id="connectionTimeout" name="connectionTimeout" min="1.5" max="60.0" step="0.5" value="1.5">
<div class="form-text" data-i18n="optionsConnectionTimeoutHelpText"></div>
</div>

<!-- Debug logging -->
<div class="form-group mt-2 pb-1">
<div class="form-check form-switch">
Expand Down
27 changes: 22 additions & 5 deletions keepassxc-browser/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ options.initGeneralSettings = async function() {
$('#tab-general-settings input[type=radio]#checkUpdateOneMonth').value = CHECK_UPDATE_ONE_MONTH;
$('#tab-general-settings input[type=radio]#checkUpdateNever').value = CHECK_UPDATE_NEVER;

$('#tab-general-settings input[type=range]').value = options.settings['redirectAllowance'];
$('#tab-general-settings #redirectAllowance').value = options.settings['redirectAllowance'];
$('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance',
options.settings['redirectAllowance'] === 11 ? 'Infinite' : String(options.settings['redirectAllowance']));

Expand All @@ -124,6 +124,9 @@ options.initGeneralSettings = async function() {
$('#tab-general-settings input#defaultGroup').value = options.settings['defaultGroup'];
$('#tab-general-settings input#defaultPasskeyGroup').value = options.settings['defaultPasskeyGroup'];
$('#tab-general-settings input#clearCredentialTimeout').value = options.settings['clearCredentialsTimeout'];
const connectionTimeout = (options.settings['connectionTimeout']/1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this. Just retrieve the value from settings and do any modifications to it when inserting it as element value.

$('#tab-general-settings input#connectionTimeout').value = connectionTimeout;
$('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', String(connectionTimeout));

const generalSettingsRadioInputs = document.querySelectorAll('#tab-general-settings input[type=radio]');
for (const radio of generalSettingsRadioInputs) {
Expand Down Expand Up @@ -173,7 +176,21 @@ options.initGeneralSettings = async function() {
});

// Change label text dynamically with the range input
$('#tab-general-settings input[type=range]').addEventListener('input', function(e) {
$('#tab-general-settings input#connectionTimeout').addEventListener('input', function(e) {
$('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', e.target.value);
});

$('#tab-general-settings input#connectionTimeout').addEventListener('change', async function(e) {
if (e.target.valueAsNumber < 1.5 || e.target.valueAsNumber > 60) {
return;
}

options.settings['connectionTimeout'] = e.target.valueAsNumber * 1000;
await options.saveSettings();
});

// Change label text dynamically with the range input
$('#tab-general-settings input#redirectAllowance').addEventListener('input', function(e) {
const currentValue = e.target.valueAsNumber === 11 ? 'Infinite' : e.target.value;
$('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance', currentValue);
});
Expand Down Expand Up @@ -726,7 +743,7 @@ options.initSitePreferences = function() {

// Page URL
row.children[0].children[0].children[0].value = url;
row.children[0].children[0]?.addEventListener('dblclick', (e) =>
row.children[0].children[0]?.addEventListener('dblclick', (e) =>
enterEditMode(e, row, inputField, editButton, cancelButton, saveButton)
);

Expand Down Expand Up @@ -891,7 +908,7 @@ const getBrowserId = function(userAgent) {
return `${query.name} ${getVersion(userAgent, query.findStr)}`;
}
}

return 'Other/Unknown';
};

Expand Down Expand Up @@ -919,7 +936,7 @@ const updateDropdownPosition = function(e, dropdown) {
if (!rect) {
return;
}

const zoom = getComputedStyle(document.body).zoom || 1;
const scrollTop = document.defaultView.scrollY / zoom;
const scrollLeft = document.defaultView?.scrollX / zoom;
Expand Down