diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index f415677cde..8ec9983d71 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -21,7 +21,7 @@ import AutofillScript from '../models/autofillScript'; import { BrowserApi } from '../browser/browserApi'; -import { AutoFillConstants, CreditCardAutoFillConstants } from './autofillConstants'; +import { AutoFillConstants, CreditCardAutoFillConstants, IdentityAutoFillConstants } from './autofillConstants'; export default class AutofillService implements AutofillServiceInterface { constructor(private cipherService: CipherService, private userService: UserService, @@ -609,8 +609,8 @@ export default class AutofillService implements AutofillServiceInterface { return; } - for (let i = 0; i < AutoFillConstants.IdentityAttributes.length; i++) { - const attr = AutoFillConstants.IdentityAttributes[i]; + for (let i = 0; i < IdentityAutoFillConstants.IdentityAttributes.length; i++) { + const attr = IdentityAutoFillConstants.IdentityAttributes[i]; if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) { continue; } @@ -622,7 +622,7 @@ export default class AutofillService implements AutofillServiceInterface { fillFields.name = f; break; } else if (!fillFields.firstName && this.isFieldMatch(f[attr], - AutoFillConstants.FirstnameFieldNames)) { + IdentityAutoFillConstants.FirstnameFieldNames)) { fillFields.firstName = f; break; } else if (!fillFields.middleName && this.isFieldMatch(f[attr], @@ -630,7 +630,7 @@ export default class AutofillService implements AutofillServiceInterface { fillFields.middleName = f; break; } else if (!fillFields.lastName && this.isFieldMatch(f[attr], - AutoFillConstants.LastnameFieldNames)) { + IdentityAutoFillConstants.LastnameFieldNames)) { fillFields.lastName = f; break; } else if (!fillFields.title && this.isFieldMatch(f[attr], @@ -711,7 +711,7 @@ export default class AutofillService implements AutofillServiceInterface { let filledState = false; if (fillFields.state && identity.state && identity.state.length > 2) { const stateLower = identity.state.toLowerCase(); - const isoState = AutoFillConstants.IsoStates[stateLower] || AutoFillConstants.IsoProvinces[stateLower]; + const isoState = IdentityAutoFillConstants.IsoStates[stateLower] || IdentityAutoFillConstants.IsoProvinces[stateLower]; if (isoState) { filledState = true; this.makeScriptActionWithValue(fillScript, isoState, fillFields.state, filledFields); @@ -725,7 +725,7 @@ export default class AutofillService implements AutofillServiceInterface { let filledCountry = false; if (fillFields.country && identity.country && identity.country.length > 2) { const countryLower = identity.country.toLowerCase(); - const isoCountry = AutoFillConstants.IsoCountries[countryLower]; + const isoCountry = IdentityAutoFillConstants.IsoCountries[countryLower]; if (isoCountry) { filledCountry = true; this.makeScriptActionWithValue(fillScript, isoCountry, fillFields.country, filledFields); diff --git a/src/services/autofillConstants.ts b/src/services/autofillConstants.ts index 5cb7e40686..5d2f171f4b 100644 --- a/src/services/autofillConstants.ts +++ b/src/services/autofillConstants.ts @@ -1,16 +1,4 @@ export class AutoFillConstants { - static readonly IdentityAttributes: string[] = [ - "autoCompleteType", - "data-stripe", - "htmlName", - "htmlID", - "label-tag", - "placeholder", - "label-left", - "label-top", - "data-recurly", - ]; - static readonly UsernameFieldNames: string[] = [ // English "username", @@ -32,6 +20,58 @@ export class AutoFillConstants { "benutzer id", ]; + static readonly ExcludedAutofillTypes: string[] = [ + "radio", + "checkbox", + "hidden", + "file", + "button", + "image", + "reset", + "search", + ]; + + static readonly OperationDelays = new Map([["buzzsprout.com", 100]]); +} + +export class CreditCardAutoFillConstants { + static readonly CardAttributes: string[] = [ + "autoCompleteType", + "data-stripe", + "htmlName", + "htmlID", + "label-tag", + "placeholder", + "label-left", + "label-top", + "data-recurly", + ]; + + static readonly CardAttributesExtended: string[] = [ + ...CreditCardAutoFillConstants.CardAttributes, + "label-right", + ]; + + // Each index represents a language. These three arrays should all be the same length. + // 0: English, 1: Danish, 2: German/Dutch, 3: French/Spanish/Italian, 4: Russian, 5: Portuguese + static readonly MonthAbbr = ["mm", "mm", "mm", "mm", "mm", "mm"]; + static readonly YearAbbrShort = ["yy", "åå", "jj", "aa", "гг", "rr"]; + static readonly YearAbbrLong = ["yyyy", "åååå", "jjjj", "aa", "гггг", "rrrr"]; +} + +export class IdentityAutoFillConstants { + static readonly IdentityAttributes: string[] = [ + "autoCompleteType", + "data-stripe", + "htmlName", + "htmlID", + "label-tag", + "placeholder", + "label-left", + "label-top", + "data-recurly", + ]; + static readonly FirstnameFieldNames: string[] = [ // English "f-name", @@ -56,19 +96,6 @@ export class AutoFillConstants { "familienname", ]; - static readonly ExcludedAutofillTypes: string[] = [ - "radio", - "checkbox", - "hidden", - "file", - "button", - "image", - "reset", - "search", - ]; - - static readonly OperationDelays = new Map([["buzzsprout.com", 100]]); - static readonly IsoCountries: { [id: string]: string } = { afghanistan: "AF", "aland islands": "AX", @@ -395,28 +422,3 @@ export class AutoFillConstants { saskatchewan: "SK", }; } - -export class CreditCardAutoFillConstants { - static readonly CardAttributes: string[] = [ - "autoCompleteType", - "data-stripe", - "htmlName", - "htmlID", - "label-tag", - "placeholder", - "label-left", - "label-top", - "data-recurly", - ]; - - static readonly CardAttributesExtended: string[] = [ - ...CreditCardAutoFillConstants.CardAttributes, - "label-right", - ]; - - // Each index represents a language. These three arrays should all be the same length. - // 0: English, 1: Danish, 2: German/Dutch, 3: French/Spanish/Italian, 4: Russian, 5: Portuguese - static readonly MonthAbbr = ["mm", "mm", "mm", "mm", "mm", "mm"]; - static readonly YearAbbrShort = ["yy", "åå", "jj", "aa", "гг", "rr"]; - static readonly YearAbbrLong = ["yyyy", "åååå", "jjjj", "aa", "гггг", "rrrr"]; -}