Separate Identity constants into its own class
This commit is contained in:
parent
47b40e0049
commit
5fb9d0ee7f
|
@ -21,7 +21,7 @@ import AutofillScript from '../models/autofillScript';
|
||||||
|
|
||||||
import { BrowserApi } from '../browser/browserApi';
|
import { BrowserApi } from '../browser/browserApi';
|
||||||
|
|
||||||
import { AutoFillConstants, CreditCardAutoFillConstants } from './autofillConstants';
|
import { AutoFillConstants, CreditCardAutoFillConstants, IdentityAutoFillConstants } from './autofillConstants';
|
||||||
export default class AutofillService implements AutofillServiceInterface {
|
export default class AutofillService implements AutofillServiceInterface {
|
||||||
|
|
||||||
constructor(private cipherService: CipherService, private userService: UserService,
|
constructor(private cipherService: CipherService, private userService: UserService,
|
||||||
|
@ -609,8 +609,8 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < AutoFillConstants.IdentityAttributes.length; i++) {
|
for (let i = 0; i < IdentityAutoFillConstants.IdentityAttributes.length; i++) {
|
||||||
const attr = AutoFillConstants.IdentityAttributes[i];
|
const attr = IdentityAutoFillConstants.IdentityAttributes[i];
|
||||||
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
fillFields.name = f;
|
fillFields.name = f;
|
||||||
break;
|
break;
|
||||||
} else if (!fillFields.firstName && this.isFieldMatch(f[attr],
|
} else if (!fillFields.firstName && this.isFieldMatch(f[attr],
|
||||||
AutoFillConstants.FirstnameFieldNames)) {
|
IdentityAutoFillConstants.FirstnameFieldNames)) {
|
||||||
fillFields.firstName = f;
|
fillFields.firstName = f;
|
||||||
break;
|
break;
|
||||||
} else if (!fillFields.middleName && this.isFieldMatch(f[attr],
|
} else if (!fillFields.middleName && this.isFieldMatch(f[attr],
|
||||||
|
@ -630,7 +630,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
fillFields.middleName = f;
|
fillFields.middleName = f;
|
||||||
break;
|
break;
|
||||||
} else if (!fillFields.lastName && this.isFieldMatch(f[attr],
|
} else if (!fillFields.lastName && this.isFieldMatch(f[attr],
|
||||||
AutoFillConstants.LastnameFieldNames)) {
|
IdentityAutoFillConstants.LastnameFieldNames)) {
|
||||||
fillFields.lastName = f;
|
fillFields.lastName = f;
|
||||||
break;
|
break;
|
||||||
} else if (!fillFields.title && this.isFieldMatch(f[attr],
|
} else if (!fillFields.title && this.isFieldMatch(f[attr],
|
||||||
|
@ -711,7 +711,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
let filledState = false;
|
let filledState = false;
|
||||||
if (fillFields.state && identity.state && identity.state.length > 2) {
|
if (fillFields.state && identity.state && identity.state.length > 2) {
|
||||||
const stateLower = identity.state.toLowerCase();
|
const stateLower = identity.state.toLowerCase();
|
||||||
const isoState = AutoFillConstants.IsoStates[stateLower] || AutoFillConstants.IsoProvinces[stateLower];
|
const isoState = IdentityAutoFillConstants.IsoStates[stateLower] || IdentityAutoFillConstants.IsoProvinces[stateLower];
|
||||||
if (isoState) {
|
if (isoState) {
|
||||||
filledState = true;
|
filledState = true;
|
||||||
this.makeScriptActionWithValue(fillScript, isoState, fillFields.state, filledFields);
|
this.makeScriptActionWithValue(fillScript, isoState, fillFields.state, filledFields);
|
||||||
|
@ -725,7 +725,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
let filledCountry = false;
|
let filledCountry = false;
|
||||||
if (fillFields.country && identity.country && identity.country.length > 2) {
|
if (fillFields.country && identity.country && identity.country.length > 2) {
|
||||||
const countryLower = identity.country.toLowerCase();
|
const countryLower = identity.country.toLowerCase();
|
||||||
const isoCountry = AutoFillConstants.IsoCountries[countryLower];
|
const isoCountry = IdentityAutoFillConstants.IsoCountries[countryLower];
|
||||||
if (isoCountry) {
|
if (isoCountry) {
|
||||||
filledCountry = true;
|
filledCountry = true;
|
||||||
this.makeScriptActionWithValue(fillScript, isoCountry, fillFields.country, filledFields);
|
this.makeScriptActionWithValue(fillScript, isoCountry, fillFields.country, filledFields);
|
||||||
|
|
|
@ -1,16 +1,4 @@
|
||||||
export class AutoFillConstants {
|
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[] = [
|
static readonly UsernameFieldNames: string[] = [
|
||||||
// English
|
// English
|
||||||
"username",
|
"username",
|
||||||
|
@ -32,6 +20,58 @@ export class AutoFillConstants {
|
||||||
"benutzer id",
|
"benutzer id",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
static readonly ExcludedAutofillTypes: string[] = [
|
||||||
|
"radio",
|
||||||
|
"checkbox",
|
||||||
|
"hidden",
|
||||||
|
"file",
|
||||||
|
"button",
|
||||||
|
"image",
|
||||||
|
"reset",
|
||||||
|
"search",
|
||||||
|
];
|
||||||
|
|
||||||
|
static readonly OperationDelays = new Map<string, number>([["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[] = [
|
static readonly FirstnameFieldNames: string[] = [
|
||||||
// English
|
// English
|
||||||
"f-name",
|
"f-name",
|
||||||
|
@ -56,19 +96,6 @@ export class AutoFillConstants {
|
||||||
"familienname",
|
"familienname",
|
||||||
];
|
];
|
||||||
|
|
||||||
static readonly ExcludedAutofillTypes: string[] = [
|
|
||||||
"radio",
|
|
||||||
"checkbox",
|
|
||||||
"hidden",
|
|
||||||
"file",
|
|
||||||
"button",
|
|
||||||
"image",
|
|
||||||
"reset",
|
|
||||||
"search",
|
|
||||||
];
|
|
||||||
|
|
||||||
static readonly OperationDelays = new Map<string, number>([["buzzsprout.com", 100]]);
|
|
||||||
|
|
||||||
static readonly IsoCountries: { [id: string]: string } = {
|
static readonly IsoCountries: { [id: string]: string } = {
|
||||||
afghanistan: "AF",
|
afghanistan: "AF",
|
||||||
"aland islands": "AX",
|
"aland islands": "AX",
|
||||||
|
@ -395,28 +422,3 @@ export class AutoFillConstants {
|
||||||
saskatchewan: "SK",
|
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"];
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue