mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-19 11:15:21 +01:00
Separate CreditCard constants into its own class
This commit is contained in:
parent
0fbeabf7a6
commit
47b40e0049
@ -21,7 +21,7 @@ import AutofillScript from '../models/autofillScript';
|
||||
|
||||
import { BrowserApi } from '../browser/browserApi';
|
||||
|
||||
import { AutoFillConstants } from './autofillConstants';
|
||||
import { AutoFillConstants, CreditCardAutoFillConstants } from './autofillConstants';
|
||||
export default class AutofillService implements AutofillServiceInterface {
|
||||
|
||||
constructor(private cipherService: CipherService, private userService: UserService,
|
||||
@ -373,8 +373,8 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < AutoFillConstants.CardAttributes.length; i++) {
|
||||
const attr = AutoFillConstants.CardAttributes[i];
|
||||
for (let i = 0; i < CreditCardAutoFillConstants.CardAttributes.length; i++) {
|
||||
const attr = CreditCardAutoFillConstants.CardAttributes[i];
|
||||
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
||||
continue;
|
||||
}
|
||||
@ -525,36 +525,36 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
}
|
||||
|
||||
let exp: string = null;
|
||||
for (let i = 0; i < AutoFillConstants.MonthAbbr.length; i++) {
|
||||
if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '/' + AutoFillConstants.YearAbbrShort[i]) &&
|
||||
for (let i = 0; i < CreditCardAutoFillConstants.MonthAbbr.length; i++) {
|
||||
if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '/' + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||
partYear != null) {
|
||||
exp = fullMonth + '/' + partYear;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '/' + AutoFillConstants.YearAbbrLong[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '/' + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||
exp = fullMonth + '/' + fullYear;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + '/' + AutoFillConstants.MonthAbbr[i]) &&
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + '/' + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||
partYear != null) {
|
||||
exp = partYear + '/' + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + '/' + AutoFillConstants.MonthAbbr[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + '/' + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||
exp = fullYear + '/' + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '-' + AutoFillConstants.YearAbbrShort[i]) &&
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '-' + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||
partYear != null) {
|
||||
exp = fullMonth + '-' + partYear;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '-' + AutoFillConstants.YearAbbrLong[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '-' + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||
exp = fullMonth + '-' + fullYear;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + '-' + AutoFillConstants.MonthAbbr[i]) &&
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + '-' + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||
partYear != null) {
|
||||
exp = partYear + '-' + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + '-' + AutoFillConstants.MonthAbbr[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + '-' + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||
exp = fullYear + '-' + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + AutoFillConstants.MonthAbbr[i]) &&
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||
partYear != null) {
|
||||
exp = partYear + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + AutoFillConstants.MonthAbbr[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||
exp = fullYear + fullMonth;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + AutoFillConstants.YearAbbrShort[i]) &&
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||
partYear != null) {
|
||||
exp = fullMonth + partYear;
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + AutoFillConstants.YearAbbrLong[i])) {
|
||||
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||
exp = fullMonth + fullYear;
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
}
|
||||
|
||||
let doesContain = false;
|
||||
AutoFillConstants.CardAttributesExtended.forEach(attr => {
|
||||
CreditCardAutoFillConstants.CardAttributesExtended.forEach(attr => {
|
||||
if (doesContain || !field.hasOwnProperty(attr) || !field[attr]) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,21 +1,4 @@
|
||||
export class AutoFillConstants {
|
||||
static readonly CardAttributes: string[] = [
|
||||
"autoCompleteType",
|
||||
"data-stripe",
|
||||
"htmlName",
|
||||
"htmlID",
|
||||
"label-tag",
|
||||
"placeholder",
|
||||
"label-left",
|
||||
"label-top",
|
||||
"data-recurly",
|
||||
];
|
||||
|
||||
static readonly CardAttributesExtended: string[] = [
|
||||
...AutoFillConstants.CardAttributes,
|
||||
"label-right",
|
||||
];
|
||||
|
||||
static readonly IdentityAttributes: string[] = [
|
||||
"autoCompleteType",
|
||||
"data-stripe",
|
||||
@ -84,12 +67,6 @@ export class AutoFillConstants {
|
||||
"search",
|
||||
];
|
||||
|
||||
// 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"];
|
||||
|
||||
static readonly OperationDelays = new Map<string, number>([["buzzsprout.com", 100]]);
|
||||
|
||||
static readonly IsoCountries: { [id: string]: string } = {
|
||||
@ -418,3 +395,28 @@ 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"];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user