Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc-browser.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Vänttinen <sami.vanttinen@protonmail.com>2022-09-06 20:40:02 +0300
committerGitHub <noreply@github.com>2022-09-06 20:40:02 +0300
commit5f40d24df1c5ee7bdcc68c91bd2a43e9b1774f01 (patch)
treee286500b8ed2aa7a173ad64788d3bbda935bdbc4
parent908cd410370e8bfc1b2d8fee05193540badaa5ca (diff)
Fix Steam TOTP (#1711)1.8.2
Fix Steam TOTP
-rw-r--r--keepassxc-browser/common/sites.js17
-rw-r--r--keepassxc-browser/content/fields.js21
-rw-r--r--keepassxc-browser/content/fill.js6
3 files changed, 36 insertions, 8 deletions
diff --git a/keepassxc-browser/common/sites.js b/keepassxc-browser/common/sites.js
index 41a3929..55635f0 100644
--- a/keepassxc-browser/common/sites.js
+++ b/keepassxc-browser/common/sites.js
@@ -139,6 +139,23 @@ kpxcSites.totpExceptionFound = function(field) {
return false;
};
+/**
+ * Handles a few exceptions for certain sites where segmented 2FA fields are not regognized properly.
+ * @param {object} form Form Element
+ * @returns {boolean} True if an Element has a match with the needed indentfifiers and document location
+ */
+kpxcSites.segmentedTotpExceptionFound = function(form) {
+ if (!form || form.nodeName !== 'FORM') {
+ return false;
+ }
+
+ if (document.location.href.startsWith('https://store.steampowered.com') && form.length === 5) {
+ return true;
+ }
+
+ return false;
+};
+
kpxcSites.expectedTOTPMaxLength = function() {
if (document.location.origin.startsWith('https://www.amazon')
&& document.location.href.includes('/ap/mfa')) {
diff --git a/keepassxc-browser/content/fields.js b/keepassxc-browser/content/fields.js
index 2170c2e..d6bd949 100644
--- a/keepassxc-browser/content/fields.js
+++ b/keepassxc-browser/content/fields.js
@@ -1,5 +1,7 @@
'use strict';
+const DEFAULT_SEGMENTED_TOTP_FIELDS = 6;
+
/**
* @Object kpxcFields
* Provides methods for input field handling.
@@ -92,9 +94,12 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
if (!kpxc.settings.showOTPIcon) {
return;
}
- const addTotpFieldsToCombination = function(inputFields) {
+
+ let exceptionFound = false;
+
+ const addTotpFieldsToCombination = function(inputFields, ignoreLength = false) {
const totpInputs = Array.from(inputFields).filter(e => e.nodeName === 'INPUT' && e.type !== 'password' && e.type !== 'hidden');
- if (totpInputs.length === 6) {
+ if (totpInputs.length === DEFAULT_SEGMENTED_TOTP_FIELDS || ignoreLength) {
const combination = {
form: form,
totpInputs: totpInputs,
@@ -121,7 +126,7 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
}
// Accept 6 inputs directly
- if (currentForm.length === 6) {
+ if (currentForm.length === DEFAULT_SEGMENTED_TOTP_FIELDS) {
return true;
}
@@ -132,6 +137,12 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
return true;
}
+ // Accept any other site-specific exceptions
+ if (kpxcSites.segmentedTotpExceptionFound(currentForm)) {
+ exceptionFound = true;
+ return true;
+ }
+
return false;
};
@@ -141,8 +152,8 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
|| (form.name && typeof(form.name) === 'string' && form.name.includes(f))
|| formLengthMatches(form)))) {
// Use the form's elements
- addTotpFieldsToCombination(form.elements);
- } else if (inputs.length === 6 && inputs.every(i => (i.inputMode === 'numeric' && i.pattern.includes('0-9'))
+ addTotpFieldsToCombination(form.elements, exceptionFound);
+ } else if (inputs.length === DEFAULT_SEGMENTED_TOTP_FIELDS && inputs.every(i => (i.inputMode === 'numeric' && i.pattern.includes('0-9'))
|| (i.type === 'text' && i.maxLength === 1)
|| i.type === 'tel')) {
// No form is found, but input fields are possibly segmented TOTP fields
diff --git a/keepassxc-browser/content/fill.js b/keepassxc-browser/content/fill.js
index 7bf07d0..f7b375c 100644
--- a/keepassxc-browser/content/fill.js
+++ b/keepassxc-browser/content/fill.js
@@ -175,7 +175,7 @@ kpxcFill.setTOTPValue = function(elem, val) {
}
for (const comb of kpxc.combinations) {
- if (comb.totpInputs && comb.totpInputs.length === 6) {
+ if (comb.totpInputs && comb.totpInputs.length > 0) {
kpxcFill.fillSegmentedTotp(elem, val, comb.totpInputs);
return;
}
@@ -186,11 +186,11 @@ kpxcFill.setTOTPValue = function(elem, val) {
// Fill TOTP in parts
kpxcFill.fillSegmentedTotp = function(elem, val, totpInputs) {
- if (!totpInputs.includes(elem)) {
+ if (!totpInputs.includes(elem) || val.length < totpInputs.length) {
return;
}
- for (let i = 0; i < 6; ++i) {
+ for (let i = 0; i < totpInputs.length; ++i) {
kpxc.setValue(totpInputs[i], val[i]);
}
};