1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Refactor for barrels. Utils service to jslib

This commit is contained in:
Kyle Spearrin
2018-01-06 22:13:48 -05:00
parent c018f096b4
commit 03258e50f7
56 changed files with 270 additions and 433 deletions

View File

@@ -1,5 +1,4 @@
import { CipherType } from '@bitwarden/jslib';
import { FieldType } from '@bitwarden/jslib';
import { Abstractions, Enums, Services } from '@bitwarden/jslib';
import AutofillField from '../models/domain/autofillField';
import AutofillPageDetails from '../models/domain/autofillPageDetails';
@@ -8,9 +7,6 @@ import AutofillScript from '../models/domain/autofillScript';
import CipherService from './cipher.service';
import TokenService from './token.service';
import TotpService from './totp.service';
import UtilsService from './utils.service';
import { PlatformUtilsService } from '@bitwarden/jslib';
const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag',
'placeholder', 'label-left', 'label-top'];
@@ -94,8 +90,8 @@ var IsoProvinces: { [id: string]: string; } = {
export default class AutofillService {
constructor(public cipherService: CipherService, public tokenService: TokenService,
public totpService: TotpService, public utilsService: UtilsService,
public platformUtilsService: PlatformUtilsService) {
public totpService: TotpService, public utilsService: Services.UtilsService,
public platformUtilsService: Abstractions.PlatformUtilsService) {
}
getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] {
@@ -169,7 +165,7 @@ export default class AutofillService {
fillScript: fillScript,
}, { frameId: pd.frameId });
if (options.cipher.type !== CipherType.Login || totpPromise ||
if (options.cipher.type !== Enums.CipherType.Login || totpPromise ||
(options.fromBackground && this.platformUtilsService.isFirefox()) || options.skipTotp ||
!options.cipher.login.totp || !this.tokenService.getPremium()) {
return;
@@ -183,7 +179,7 @@ export default class AutofillService {
return null;
}).then((code: string) => {
if (code) {
UtilsService.copyToClipboard(code);
Services.UtilsService.copyToClipboard(code);
}
return code;
@@ -271,7 +267,7 @@ export default class AutofillService {
const matchingIndex = this.findMatchingFieldIndex(field, fieldNames);
if (matchingIndex > -1) {
let val = fields[matchingIndex].value;
if (val == null && fields[matchingIndex].type === FieldType.Boolean) {
if (val == null && fields[matchingIndex].type === Enums.FieldType.Boolean) {
val = 'false';
}
@@ -283,13 +279,13 @@ export default class AutofillService {
}
switch (options.cipher.type) {
case CipherType.Login:
case Enums.CipherType.Login:
fillScript = this.generateLoginFillScript(fillScript, pageDetails, filledFields, options);
break;
case CipherType.Card:
case Enums.CipherType.Card:
fillScript = this.generateCardFillScript(fillScript, pageDetails, filledFields, options);
break;
case CipherType.Identity:
case Enums.CipherType.Identity:
fillScript = this.generateIdentityFillScript(fillScript, pageDetails, filledFields, options);
break;
default: