1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

import ts through node_modules alias

This commit is contained in:
Kyle Spearrin
2018-01-09 14:26:20 -05:00
parent e165b5cc70
commit f51bebd99a
49 changed files with 515 additions and 322 deletions

View File

@@ -30,7 +30,19 @@ import GlobalModule from './global/global.module';
import SettingsModule from './settings/settings.module';
// Model imports
import { Data, Domain, Request, Response } from '@bitwarden/jslib';
import { Attachment } from '../../../node_modules/@bitwarden/jslib/src/models/domain/attachment';
import { Card } from '../../../node_modules/@bitwarden/jslib/src/models/domain/card';
import { Cipher } from '../../../node_modules/@bitwarden/jslib/src/models/domain/cipher';
import { CipherString } from '../../../node_modules/@bitwarden/jslib/src/models/domain/cipherString';
import { Field } from '../../../node_modules/@bitwarden/jslib/src/models/domain/field';
import { Folder } from '../../../node_modules/@bitwarden/jslib/src/models/domain/folder';
import { Identity } from '../../../node_modules/@bitwarden/jslib/src/models/domain/identity';
import { Login } from '../../../node_modules/@bitwarden/jslib/src/models/domain/login';
import { SecureNote } from '../../../node_modules/@bitwarden/jslib/src/models/domain/secureNote';
import * as Data from '../../../node_modules/@bitwarden/jslib/src/models/data';
import * as Request from '../../../node_modules/@bitwarden/jslib/src/models/request';
import * as Response from '../../../node_modules/@bitwarden/jslib/src/models/response';
angular
.module('bit', [

View File

@@ -1,6 +1,6 @@
import * as template from './action-buttons.component.html';
import { Abstractions } from '@bitwarden/jslib';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class ActionButtonsController implements ng.IController {
onView: Function;
@@ -12,7 +12,7 @@ export class ActionButtonsController implements ng.IController {
constructor(private i18nService: any, private $analytics: any, private constantsService: any, private toastr: any,
private $timeout: any, private $window: any,
private platformUtilsService: Abstractions.PlatformUtilsService) {
private platformUtilsService: PlatformUtilsService) {
this.i18n = i18nService;
this.constants = constantsService;
}

View File

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

View File

@@ -1,4 +1,7 @@
import { Abstractions, Enums } from '@bitwarden/jslib';
import { CipherType } from 'jslib/enums/cipherType';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { UtilsService } from 'jslib/abstractions/utils.service';
import * as template from './current.component.html';
@@ -17,8 +20,8 @@ export class CurrentController {
disableSearch: boolean = false;
constructor($scope: any, private cipherService: any,
private platformUtilsService: Abstractions.PlatformUtilsService,
private utilsService: Abstractions.UtilsService, private toastr: any, private $window: any, private $state: any,
private platformUtilsService: PlatformUtilsService,
private utilsService: 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 +120,8 @@ export class CurrentController {
});
const otherTypes = [
Enums.CipherType.Card,
Enums.CipherType.Identity,
CipherType.Card,
CipherType.Identity,
];
this.cipherService.getAllDecryptedForDomain(this.domain, otherTypes).then((ciphers: any[]) => {
@@ -131,13 +134,13 @@ export class CurrentController {
sortedCiphers.forEach((cipher: any) => {
switch (cipher.type) {
case Enums.CipherType.Login:
case CipherType.Login:
loginCiphers.push(cipher);
break;
case Enums.CipherType.Card:
case CipherType.Card:
cardCiphers.push(cipher);
break;
case Enums.CipherType.Identity:
case CipherType.Identity:
identityCiphers.push(cipher);
break;
default:

View File

@@ -1,4 +1,4 @@
import { Abstractions } from '@bitwarden/jslib';
import { UtilsService } from 'jslib/abstractions/utils.service';
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: Abstractions.UtilsService, $window: any) {
i18nService: any, $analytics: any, utilsService: UtilsService, $window: any) {
this.animation = '';
this.xsBody = $window.screen.availHeight < 600;
this.smBody = !this.xsBody && $window.screen.availHeight <= 800;

View File

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

View File

@@ -1,14 +1,19 @@
import { Abstractions, Request } from '@bitwarden/jslib';
import { DeviceRequest } from 'jslib/models/request/deviceRequest';
import { TokenRequest } from 'jslib/models/request/tokenRequest';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
class AuthService {
constructor(public cryptoService: Abstractions.CryptoService, public apiService: any, public userService: any,
constructor(public cryptoService: CryptoService, public apiService: any, public userService: any,
public tokenService: any, public $rootScope: any, public appIdService: any,
public platformUtilsService: Abstractions.PlatformUtilsService, public constantsService: any,
public messagingService: Abstractions.MessagingService) {
public platformUtilsService: PlatformUtilsService, public constantsService: any,
public messagingService: MessagingService) {
}
async logIn(email: string, masterPassword: string, twoFactorProvider?: number,
twoFactorToken?: string, remember?: boolean) {
twoFactorToken?: string, remember?: boolean) {
email = email.toLowerCase();
const key = this.cryptoService.makeKey(masterPassword, email);
@@ -16,18 +21,18 @@ class AuthService {
const storedTwoFactorToken = await this.tokenService.getTwoFactorToken(email);
const hashedPassword = await this.cryptoService.hashPassword(masterPassword, key);
const deviceRequest = new Request.Device(appId, this.platformUtilsService);
const deviceRequest = new DeviceRequest(appId, this.platformUtilsService);
let request: Request.Token;
let request: TokenRequest;
if (twoFactorToken != null && twoFactorProvider != null) {
request = new Request.Token(email, hashedPassword, twoFactorProvider, twoFactorToken, remember,
request = new TokenRequest(email, hashedPassword, twoFactorProvider, twoFactorToken, remember,
deviceRequest);
} else if (storedTwoFactorToken) {
request = new Request.Token(email, hashedPassword, this.constantsService.twoFactorProvider.remember,
request = new TokenRequest(email, hashedPassword, this.constantsService.twoFactorProvider.remember,
storedTwoFactorToken, false, deviceRequest);
} else {
request = new Request.Token(email, hashedPassword, null, null, false, deviceRequest);
request = new TokenRequest(email, hashedPassword, null, null, false, deviceRequest);
}
const response = await this.apiService.postIdentityToken(request);

View File

@@ -1,4 +1,7 @@
import { Abstractions } from '@bitwarden/jslib';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { UtilsService } from 'jslib/abstractions/utils.service';
function getBackgroundService<T>(service: string) {
return (): T => {
@@ -7,18 +10,18 @@ function getBackgroundService<T>(service: string) {
};
}
export const storageService = getBackgroundService<Abstractions.StorageService>('storageService');
export const storageService = getBackgroundService<StorageService>('storageService');
export const tokenService = getBackgroundService<any>('tokenService');
export const cryptoService = getBackgroundService<any>('cryptoService');
export const userService = getBackgroundService<any>('userService');
export const apiService = getBackgroundService<any>('apiService');
export const folderService = getBackgroundService<any>('folderService');
export const cipherService = getBackgroundService<Abstractions.CryptoService>('cipherService');
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<Abstractions.PlatformUtilsService>('platformUtilsService');
export const utilsService = getBackgroundService<Abstractions.UtilsService>('utilsService');
export const platformUtilsService = getBackgroundService<PlatformUtilsService>('platformUtilsService');
export const utilsService = getBackgroundService<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 { Abstractions } from '@bitwarden/jslib';
import { StorageService } from 'jslib/abstractions/storage.service';
class StateService {
private state: any = {};
constructor(private storageService: Abstractions.StorageService, private constantsService: any) {
constructor(private storageService: 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 { Abstractions } from '@bitwarden/jslib';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class EnvironmentController {
iconsUrl: string;
@@ -12,7 +12,7 @@ export class EnvironmentController {
i18n: any;
constructor(private i18nService: any, private $analytics: any,
platformUtilsService: Abstractions.PlatformUtilsService,
platformUtilsService: PlatformUtilsService,
private environmentService: any, private toastr: any, private $timeout: ng.ITimeoutService) {
this.i18n = i18nService;

View File

@@ -1,7 +1,9 @@
import * as angular from 'angular';
import * as template from './add-folder.component.html';
import { Abstractions, Domain } from '@bitwarden/jslib';
import { Folder } from 'jslib/models/domain/';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class AddFolderController {
savePromise: any;
@@ -9,7 +11,7 @@ export class AddFolderController {
i18n: any;
constructor(private folderService: any, private $state: any, private toastr: any,
platformUtilsService: Abstractions.PlatformUtilsService, private $analytics: any, private i18nService: any,
platformUtilsService: PlatformUtilsService, private $analytics: any, private i18nService: any,
$timeout: any) {
$timeout(() => {
platformUtilsService.initListSectionItemListeners(document, angular);
@@ -28,7 +30,7 @@ export class AddFolderController {
}
this.savePromise = this.folderService.encrypt(model).then((folderModel: any) => {
const folder = new Domain.Folder(folderModel, true);
const folder = new Folder(folderModel, true);
return this.folderService.saveWithServer(folder);
}).then((folder: any) => {
this.$analytics.eventTrack('Added Folder');

View File

@@ -1,17 +1,19 @@
import * as angular from 'angular';
import * as template from './edit-folder.component.html';
import { Abstractions, Domain } from '@bitwarden/jslib';
import { Folder } from 'jslib/models/domain/';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class EditFolderController {
$transition$: any;
folderId: any;
savePromise: any = null;
i18n: any;
folder: Domain.Folder;
folder: Folder;
constructor($scope: any, $stateParams: any, private folderService: any, private toastr: any, private $state: any,
private SweetAlert: any, platformUtilsService: Abstractions.PlatformUtilsService, private $analytics: any,
private SweetAlert: any, platformUtilsService: PlatformUtilsService, private $analytics: any,
private i18nService: any, $timeout: any) {
this.i18n = i18nService;
@@ -27,7 +29,7 @@ export class EditFolderController {
this.folderId = this.$transition$.params('to').folderId;
this.folderService.get(this.folderId).then((folder: any) => {
return folder.decrypt();
}).then((model: Domain.Folder) => {
}).then((model: Folder) => {
this.folder = model;
});
}
@@ -39,7 +41,7 @@ export class EditFolderController {
}
this.savePromise = this.folderService.encrypt(model).then((folderModel: any) => {
const folder = new Domain.Folder(folderModel, true);
const folder = new Folder(folderModel, true);
return this.folderService.saveWithServer(folder);
}).then((folder: any) => {
this.$analytics.eventTrack('Edited Folder');

View File

@@ -1,9 +1,9 @@
import * as template from './folders.component.html';
import { Domain } from '@bitwarden/jslib';
import { Folder } from 'jslib/models/domain';
export class FoldersController {
folders: Domain.Folder[] = [];
folders: Folder[] = [];
i18n: any;
loaded = false;

View File

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

View File

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

View File

@@ -2,14 +2,17 @@ import * as angular from 'angular';
import * as papa from 'papaparse';
import * as template from './export.component.html';
import { Abstractions, Enums } from '@bitwarden/jslib';
import { CipherType } from 'jslib/enums/cipherType';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { UtilsService } from 'jslib/abstractions/utils.service';
export class ExportController {
i18n: any;
masterPassword: string;
constructor(private $state: any, private cryptoService: Abstractions.CryptoService,
private toastr: any, private utilsService: Abstractions.UtilsService, private $analytics: any,
constructor(private $state: any, private cryptoService: CryptoService,
private toastr: any, private utilsService: UtilsService, private $analytics: any,
private i18nService: any, private folderService: any, private cipherService: any,
private $window: any, private userService: any) {
this.i18n = i18nService;
@@ -72,7 +75,7 @@ export class ExportController {
const exportCiphers = [];
for (const c of decCiphers) {
// only export logins and secure notes
if (c.type !== Enums.CipherType.Login && c.type !== Enums.CipherType.SecureNote) {
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
continue;
}
@@ -103,14 +106,14 @@ export class ExportController {
}
switch (c.type) {
case Enums.CipherType.Login:
case 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 Enums.CipherType.SecureNote:
case CipherType.SecureNote:
cipher.type = 'note';
break;
default:

View File

@@ -1,10 +1,10 @@
import * as template from './password-generator-history.component.html';
import { Domain } from '@bitwarden/jslib';
import { PasswordHistory } from 'jslib/models/domain/passwordHistory';
export class PasswordGeneratorHistoryController {
$transition$: any;
history: Domain.PasswordHistory[];
history: PasswordHistory[];
editState: any;
addState: any;
i18n: any;

View File

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

View File

@@ -1,6 +1,6 @@
import * as template from './tools.component.html';
import { Abstractions } from '@bitwarden/jslib';
import { PlatformUtilsService } from 'jslib/abstractions';
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: Abstractions.PlatformUtilsService,
private $analytics: any, private platformUtilsService: PlatformUtilsService,
private environmentService: any) {
this.i18n = i18nService;
this.showExport = !platformUtilsService.isEdge();