Merge branch 'autofill/pm-12775-fix-bitwarden-autofilling-two-factor-in-web-app' into autofill/pm-8833-implement-on-page-autofill-menu-for-password-generation

This commit is contained in:
Cesar Gonzalez 2024-10-01 12:18:29 -05:00
commit 8ee5aabb0b
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 11 additions and 5 deletions

View File

@ -35,10 +35,8 @@ export class AutoFillConstants {
"2facode",
"approvals_code",
"mfacode",
"otc",
"otc-code",
"onetimecode",
"otp",
"otp-code",
"otpcode",
"onetimepassword",
@ -49,6 +47,14 @@ export class AutoFillConstants {
"verification code",
];
static readonly AmbiguousTotpFieldNames: string[] = [
"code",
"pin",
"otc",
"otp",
...AutoFillConstants.TotpFieldNames,
];
static readonly SearchFieldNames: string[] = ["search", "query", "find", "go"];
static readonly FieldIgnoreList: string[] = ["captcha", "findanything", "forgot"];

View File

@ -887,7 +887,7 @@ export default class AutofillService implements AutofillServiceInterface {
options.allowTotpAutofill &&
f.viewable &&
(f.type === "text" || f.type === "number") &&
(AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.TotpFieldNames) ||
(AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.AmbiguousTotpFieldNames) ||
f.autoCompleteType === "one-time-code")
) {
totps.push(f);
@ -2678,12 +2678,12 @@ export default class AutofillService implements AutofillServiceInterface {
(withoutForm || f.form === passwordField.form) &&
(canBeHidden || f.viewable) &&
(f.type === "text" || f.type === "number") &&
AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.TotpFieldNames)
AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.AmbiguousTotpFieldNames)
) {
totpField = f;
if (
this.findMatchingFieldIndex(f, AutoFillConstants.TotpFieldNames) > -1 ||
this.findMatchingFieldIndex(f, AutoFillConstants.AmbiguousTotpFieldNames) > -1 ||
f.autoCompleteType === "one-time-code"
) {
// We found an exact match. No need to keep looking.