1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +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,6 +1,6 @@
import * as template from './action-buttons.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class ActionButtonsController implements ng.IController {
onView: Function;
@@ -11,7 +11,8 @@ export class ActionButtonsController implements ng.IController {
constants: any;
constructor(private i18nService: any, private $analytics: any, private constantsService: any, private toastr: any,
private $timeout: any, private $window: any, private platformUtilsService: PlatformUtilsService) {
private $timeout: any, private $window: any,
private platformUtilsService: Abstractions.PlatformUtilsService) {
this.i18n = i18nService;
this.constants = constantsService;
}

View File

@@ -1,11 +1,12 @@
import * as template from './pop-out.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class PopOutController implements ng.IController {
i18n: any;
constructor(private $analytics: any, private $window: any, private platformUtilsService: PlatformUtilsService,
constructor(private $analytics: any, private $window: any,
private platformUtilsService: Abstractions.PlatformUtilsService,
private i18nService: any) {
this.i18n = i18nService;
}

View File

@@ -1,6 +1,5 @@
import { CipherType } from '@bitwarden/jslib';
import { Abstractions, Enums } from '@bitwarden/jslib';
import { PlatformUtilsService, UtilsService } from '@bitwarden/jslib';
import * as template from './current.component.html';
export class CurrentController {
@@ -17,8 +16,9 @@ export class CurrentController {
inSidebar: boolean = false;
disableSearch: boolean = false;
constructor($scope: any, private cipherService: any, private platformUtilsService: PlatformUtilsService,
private utilsService: UtilsService, private toastr: any, private $window: any, private $state: any,
constructor($scope: any, private cipherService: any,
private platformUtilsService: Abstractions.PlatformUtilsService,
private utilsService: Abstractions.UtilsService, private toastr: any, private $window: any, private $state: any,
private $timeout: any, private autofillService: any, private $analytics: any, private i18nService: any,
private $filter: any) {
this.i18n = i18nService;
@@ -117,8 +117,8 @@ export class CurrentController {
});
const otherTypes = [
CipherType.Card,
CipherType.Identity,
Enums.CipherType.Card,
Enums.CipherType.Identity,
];
this.cipherService.getAllDecryptedForDomain(this.domain, otherTypes).then((ciphers: any[]) => {
@@ -131,13 +131,13 @@ export class CurrentController {
sortedCiphers.forEach((cipher: any) => {
switch (cipher.type) {
case CipherType.Login:
case Enums.CipherType.Login:
loginCiphers.push(cipher);
break;
case CipherType.Card:
case Enums.CipherType.Card:
cardCiphers.push(cipher);
break;
case CipherType.Identity:
case Enums.CipherType.Identity:
identityCiphers.push(cipher);
break;
default:

View File

@@ -1,4 +1,4 @@
import { UtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class MainController implements ng.IController {
smBody: boolean;
@@ -6,7 +6,7 @@ export class MainController implements ng.IController {
animation: string;
constructor($scope: any, $transitions: any, $state: any, authService: any, toastr: any,
i18nService: any, $analytics: any, utilsService: UtilsService, $window: any) {
i18nService: any, $analytics: any, utilsService: Abstractions.UtilsService, $window: any) {
this.animation = '';
this.xsBody = $window.screen.availHeight < 600;
this.smBody = !this.xsBody && $window.screen.availHeight <= 800;

View File

@@ -3,15 +3,16 @@ import * as template from './lock.component.html';
import { CryptoService } from '../../../services/abstractions/crypto.service';
import { MessagingService, PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class LockController {
i18n: any;
masterPassword: string;
constructor(public $state: any, public i18nService: any, private $timeout: any,
private platformUtilsService: PlatformUtilsService, public cryptoService: CryptoService, public toastr: any,
public userService: any, public messagingService: MessagingService, public SweetAlert: any) {
private platformUtilsService: Abstractions.PlatformUtilsService,
public cryptoService: CryptoService, public toastr: any, public userService: any,
public messagingService: Abstractions.MessagingService, public SweetAlert: any) {
this.i18n = i18nService;
}

View File

@@ -3,13 +3,13 @@ import { TokenRequest } from '../../../models/request/tokenRequest';
import { CryptoService } from '../../../services/abstractions/crypto.service';
import { MessagingService, PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
class AuthService {
constructor(public cryptoService: CryptoService, public apiService: any, public userService: any,
public tokenService: any, public $rootScope: any, public appIdService: any,
public platformUtilsService: PlatformUtilsService, public constantsService: any,
public messagingService: MessagingService) {
public platformUtilsService: Abstractions.PlatformUtilsService, public constantsService: any,
public messagingService: Abstractions.MessagingService) {
}
async logIn(email: string, masterPassword: string, twoFactorProvider?: number,

View File

@@ -1,6 +1,6 @@
import { CryptoService } from '../../../services/abstractions/crypto.service';
import { PlatformUtilsService, StorageService, UtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
function getBackgroundService<T>(service: string) {
return (): T => {
@@ -9,7 +9,7 @@ function getBackgroundService<T>(service: string) {
};
}
export const storageService = getBackgroundService<StorageService>('storageService');
export const storageService = getBackgroundService<Abstractions.StorageService>('storageService');
export const tokenService = getBackgroundService<any>('tokenService');
export const cryptoService = getBackgroundService<any>('cryptoService');
export const userService = getBackgroundService<any>('userService');
@@ -19,8 +19,8 @@ export const cipherService = getBackgroundService<CryptoService>('cipherService'
export const syncService = getBackgroundService<any>('syncService');
export const autofillService = getBackgroundService<any>('autofillService');
export const passwordGenerationService = getBackgroundService<any>('passwordGenerationService');
export const platformUtilsService = getBackgroundService<PlatformUtilsService>('platformUtilsService');
export const utilsService = getBackgroundService<UtilsService>('utilsService');
export const platformUtilsService = getBackgroundService<Abstractions.PlatformUtilsService>('platformUtilsService');
export const utilsService = getBackgroundService<Abstractions.UtilsService>('utilsService');
export const appIdService = getBackgroundService<any>('appIdService');
export const i18nService = getBackgroundService<any>('i18nService');
export const constantsService = getBackgroundService<any>('constantsService');

View File

@@ -1,9 +1,9 @@
import { StorageService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
class StateService {
private state: any = {};
constructor(private storageService: StorageService, private constantsService: any) {
constructor(private storageService: Abstractions.StorageService, private constantsService: any) {
}
async init() {

View File

@@ -1,7 +1,7 @@
import * as angular from 'angular';
import * as template from './environment.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class EnvironmentController {
iconsUrl: string;
@@ -11,7 +11,8 @@ export class EnvironmentController {
baseUrl: string;
i18n: any;
constructor(private i18nService: any, private $analytics: any, platformUtilsService: PlatformUtilsService,
constructor(private i18nService: any, private $analytics: any,
platformUtilsService: Abstractions.PlatformUtilsService,
private environmentService: any, private toastr: any, private $timeout: ng.ITimeoutService) {
this.i18n = i18nService;

View File

@@ -2,7 +2,7 @@ import * as angular from 'angular';
import { Folder } from '../../../../models/domain/folder';
import * as template from './add-folder.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class AddFolderController {
savePromise: any;
@@ -10,7 +10,7 @@ export class AddFolderController {
i18n: any;
constructor(private folderService: any, private $state: any, private toastr: any,
platformUtilsService: PlatformUtilsService, private $analytics: any, private i18nService: any,
platformUtilsService: Abstractions.PlatformUtilsService, private $analytics: any, private i18nService: any,
$timeout: any) {
$timeout(() => {
platformUtilsService.initListSectionItemListeners(document, angular);

View File

@@ -2,7 +2,7 @@ import * as angular from 'angular';
import { Folder } from '../../../../models/domain/folder';
import * as template from './edit-folder.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class EditFolderController {
$transition$: any;
@@ -12,7 +12,7 @@ export class EditFolderController {
folder: Folder;
constructor($scope: any, $stateParams: any, private folderService: any, private toastr: any, private $state: any,
private SweetAlert: any, platformUtilsService: PlatformUtilsService, private $analytics: any,
private SweetAlert: any, platformUtilsService: Abstractions.PlatformUtilsService, private $analytics: any,
private i18nService: any, $timeout: any) {
this.i18n = i18nService;

View File

@@ -1,6 +1,6 @@
import * as angular from 'angular';
import { MessagingService, PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
import StateService from '../services/state.service';
import * as template from './options.component.html';
@@ -15,9 +15,9 @@ export class OptionsController {
i18n: any;
constructor(private i18nService: any, private $analytics: any, private constantsService: any,
private platformUtilsService: PlatformUtilsService, private totpService: any,
private stateService: StateService, private storageService: StorageService,
public messagingService: MessagingService, private $timeout: ng.ITimeoutService) {
private platformUtilsService: Abstractions.PlatformUtilsService, private totpService: any,
private stateService: StateService, private storageService: Abstractions.StorageService,
public messagingService: Abstractions.MessagingService, private $timeout: ng.ITimeoutService) {
this.i18n = i18nService;
$timeout(() => {

View File

@@ -1,6 +1,6 @@
import * as angular from 'angular';
import { DeviceType, MessagingService, PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { Abstractions, Enums } from '@bitwarden/jslib';
import { CryptoService } from '../../../services/abstractions/crypto.service';
import ConstantsService from '../../../services/constants.service';
@@ -8,17 +8,17 @@ import ConstantsService from '../../../services/constants.service';
import * as template from './settings.component.html';
const RateUrls = {
[DeviceType.Chrome]:
[Enums.DeviceType.Chrome]:
'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews',
[DeviceType.Firefox]:
[Enums.DeviceType.Firefox]:
'https://addons.mozilla.org/en-US/firefox/addon/bitwarden-password-manager/#reviews',
[DeviceType.Opera]:
[Enums.DeviceType.Opera]:
'https://addons.opera.com/en/extensions/details/bitwarden-free-password-manager/#feedback-container',
[DeviceType.Edge]:
[Enums.DeviceType.Edge]:
'https://www.microsoft.com/store/p/bitwarden-free-password-manager/9p6kxl0svnnl',
[DeviceType.Vivaldi]:
[Enums.DeviceType.Vivaldi]:
'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews',
[DeviceType.Safari]:
[Enums.DeviceType.Safari]:
'https://itunes.com', // TODO
};
@@ -27,10 +27,12 @@ export class SettingsController {
i18n: any;
showOnLocked: boolean;
constructor(private $state: any, private SweetAlert: any, private platformUtilsService: PlatformUtilsService,
private $analytics: any, private i18nService: any, private constantsService: ConstantsService,
private cryptoService: CryptoService, private lockService: any, private storageService: StorageService,
public messagingService: MessagingService, private $timeout: ng.ITimeoutService) {
constructor(private $state: any, private SweetAlert: any,
private platformUtilsService: Abstractions.PlatformUtilsService, private $analytics: any,
private i18nService: any, private constantsService: ConstantsService,
private cryptoService: CryptoService, private lockService: any,
private storageService: Abstractions.StorageService,
public messagingService: Abstractions.MessagingService, private $timeout: ng.ITimeoutService) {
this.i18n = i18nService;
$timeout(() => {

View File

@@ -2,7 +2,7 @@ import * as angular from 'angular';
import * as papa from 'papaparse';
import * as template from './export.component.html';
import { CipherType, UtilsService } from '@bitwarden/jslib';
import { Abstractions, Enums } from '@bitwarden/jslib';
import { CryptoService } from '../../../services/abstractions/crypto.service';
@@ -11,7 +11,7 @@ export class ExportController {
masterPassword: string;
constructor(private $state: any, private cryptoService: CryptoService,
private toastr: any, private utilsService: UtilsService, private $analytics: any,
private toastr: any, private utilsService: Abstractions.UtilsService, private $analytics: any,
private i18nService: any, private folderService: any, private cipherService: any,
private $window: any, private userService: any) {
this.i18n = i18nService;
@@ -74,7 +74,7 @@ export class ExportController {
const exportCiphers = [];
for (const c of decCiphers) {
// only export logins and secure notes
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
if (c.type !== Enums.CipherType.Login && c.type !== Enums.CipherType.SecureNote) {
continue;
}
@@ -105,14 +105,14 @@ export class ExportController {
}
switch (c.type) {
case CipherType.Login:
case Enums.CipherType.Login:
cipher.type = 'login';
cipher.login_uri = c.login.uri;
cipher.login_username = c.login.username;
cipher.login_password = c.login.password;
cipher.login_totp = c.login.totp;
break;
case CipherType.SecureNote:
case Enums.CipherType.SecureNote:
cipher.type = 'note';
break;
default:

View File

@@ -1,7 +1,7 @@
import * as angular from 'angular';
import * as template from './password-generator.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class PasswordGeneratorController {
$transition$: any;
@@ -13,8 +13,8 @@ export class PasswordGeneratorController {
i18n: any;
constructor(private $state: any, private passwordGenerationService: any,
private toastr: any, private platformUtilsService: PlatformUtilsService, private $analytics: any,
private i18nService: any, private $timeout: any) {
private toastr: any, private platformUtilsService: Abstractions.PlatformUtilsService,
private $analytics: any, private i18nService: any, private $timeout: any) {
this.i18n = i18nService;
passwordGenerationService.getOptions().then((options: any) => {

View File

@@ -1,6 +1,6 @@
import * as template from './tools.component.html';
import { PlatformUtilsService } from '@bitwarden/jslib';
import { Abstractions } from '@bitwarden/jslib';
export class ToolsController {
showExport: boolean;
@@ -8,7 +8,7 @@ export class ToolsController {
private webVaultBaseUrl: string = 'https://vault.bitwarden.com';
constructor(private SweetAlert: any, private i18nService: any,
private $analytics: any, private platformUtilsService: PlatformUtilsService,
private $analytics: any, private platformUtilsService: Abstractions.PlatformUtilsService,
private environmentService: any) {
this.i18n = i18nService;
this.showExport = !platformUtilsService.isEdge();