Merge pull request #1142 from keepassxreboot/feature/add_predefined_sites_to_totp

Add TOTP possibility to Predefined Sites
This commit is contained in:
Sami Vänttinen 2020-12-16 09:45:18 +02:00 committed by GitHub
commit 51e0d9cf0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -66,3 +66,12 @@ kpxcSites.exceptionFound = function(classList) {
return false;
};
kpxcSites.expectedTOTPMaxLength = function() {
if (document.location.origin.startsWith('https://www.amazon')
&& document.location.href.includes('/ap/mfa')) {
return 20;
}
return MAX_TOTP_INPUT_LENGTH;
};

View file

@ -2,8 +2,6 @@
const ignoreRegex = /(bank|coupon|postal|user|zip).*code|comment|author/i;
const ignoredTypes = [ 'email', 'password', 'username' ];
const MIN_INPUT_LENGTH = 6;
const MAX_INPUT_LENGTH = 10;
const acceptedOTPFields = [
'2fa',
@ -57,7 +55,7 @@ kpxcTOTPIcons.isValid = function(field, forced) {
if (ignoredTypes.some(t => t === field.type)
|| field.offsetWidth < MINIMUM_INPUT_FIELD_WIDTH
|| field.size < 2
|| (field.maxLength > 0 && (field.maxLength < MIN_INPUT_LENGTH || field.maxLength > MAX_INPUT_LENGTH))
|| (field.maxLength > 0 && (field.maxLength < MIN_TOTP_INPUT_LENGTH || field.maxLength > kpxcSites.expectedTOTPMaxLength()))
|| ignoredTypes.some(t => t === field.autocomplete)
|| field.id.match(ignoreRegex)
|| field.name.match(ignoreRegex)

View file

@ -1,6 +1,8 @@
'use strict';
const MINIMUM_INPUT_FIELD_WIDTH = 60;
const MIN_TOTP_INPUT_LENGTH = 6;
const MAX_TOTP_INPUT_LENGTH = 10;
const DatabaseState = {
DISCONNECTED: 0,