1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-29 17:38:04 +01:00

moved service abstractions to jslib

This commit is contained in:
Kyle Spearrin 2018-01-06 15:47:46 -05:00
parent dc15edcd4d
commit c018f096b4
46 changed files with 48 additions and 92 deletions

View File

@ -2,7 +2,7 @@ import ConstantsService from '../services/constants.service';
import LockService from '../services/lock.service'; import LockService from '../services/lock.service';
import MainBackground from './main.background'; import MainBackground from './main.background';
import { StorageService } from '../services/abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
export default class IdleBackground { export default class IdleBackground {
private idle: any; private idle: any;

View File

@ -35,9 +35,7 @@ import TotpService from '../services/totp.service';
import UserService from '../services/user.service'; import UserService from '../services/user.service';
import UtilsService from '../services/utils.service'; import UtilsService from '../services/utils.service';
import { MessagingService } from '../services/abstractions/messaging.service'; import { MessagingService, PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service';
import { StorageService } from '../services/abstractions/storage.service';
export default class MainBackground { export default class MainBackground {
messagingService: MessagingService; messagingService: MessagingService;

View File

@ -8,7 +8,7 @@ import AutofillService from '../services/autofill.service';
import CipherService from '../services/cipher.service'; import CipherService from '../services/cipher.service';
import UtilsService from '../services/utils.service'; import UtilsService from '../services/utils.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export default class RuntimeBackground { export default class RuntimeBackground {
private runtime: any; private runtime: any;

View File

@ -1,6 +1,6 @@
import CipherService from '../services/cipher.service'; import CipherService from '../services/cipher.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export default class WebRequestBackground { export default class WebRequestBackground {
private pendingAuthRequests: any[] = []; private pendingAuthRequests: any[] = [];

View File

@ -1,5 +1,4 @@
import { DeviceType } from '@bitwarden/jslib'; import { DeviceType, PlatformUtilsService } from '@bitwarden/jslib';
import { PlatformUtilsService } from '../../services/abstractions/platformUtils.service';
class DeviceRequest { class DeviceRequest {
type: DeviceType; type: DeviceType;

View File

@ -1,6 +1,6 @@
import * as template from './action-buttons.component.html'; import * as template from './action-buttons.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class ActionButtonsController implements ng.IController { export class ActionButtonsController implements ng.IController {
onView: Function; onView: Function;

View File

@ -1,6 +1,6 @@
import * as template from './pop-out.component.html'; import * as template from './pop-out.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class PopOutController implements ng.IController { export class PopOutController implements ng.IController {
i18n: any; i18n: any;

View File

@ -1,7 +1,6 @@
import { CipherType } from '@bitwarden/jslib'; import { CipherType } from '@bitwarden/jslib';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService, UtilsService } from '@bitwarden/jslib';
import { UtilsService } from '../../../services/abstractions/utils.service';
import * as template from './current.component.html'; import * as template from './current.component.html';
export class CurrentController { export class CurrentController {

View File

@ -1,4 +1,4 @@
import { UtilsService } from '../../../services/abstractions/utils.service'; import { UtilsService } from '@bitwarden/jslib';
export class MainController implements ng.IController { export class MainController implements ng.IController {
smBody: boolean; smBody: boolean;

View File

@ -2,8 +2,8 @@ import * as angular from 'angular';
import * as template from './lock.component.html'; import * as template from './lock.component.html';
import { CryptoService } from '../../../services/abstractions/crypto.service'; import { CryptoService } from '../../../services/abstractions/crypto.service';
import { MessagingService } from '../../../services/abstractions/messaging.service';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { MessagingService, PlatformUtilsService } from '@bitwarden/jslib';
export class LockController { export class LockController {
i18n: any; i18n: any;

View File

@ -2,8 +2,8 @@ import { DeviceRequest } from '../../../models/request/deviceRequest';
import { TokenRequest } from '../../../models/request/tokenRequest'; import { TokenRequest } from '../../../models/request/tokenRequest';
import { CryptoService } from '../../../services/abstractions/crypto.service'; import { CryptoService } from '../../../services/abstractions/crypto.service';
import { MessagingService } from '../../../services/abstractions/messaging.service';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { MessagingService, PlatformUtilsService } from '@bitwarden/jslib';
class AuthService { class AuthService {
constructor(public cryptoService: CryptoService, public apiService: any, public userService: any, constructor(public cryptoService: CryptoService, public apiService: any, public userService: any,

View File

@ -1,7 +1,6 @@
import { CryptoService } from '../../../services/abstractions/crypto.service'; import { CryptoService } from '../../../services/abstractions/crypto.service';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service';
import { StorageService } from '../../../services/abstractions/storage.service'; import { PlatformUtilsService, StorageService, UtilsService } from '@bitwarden/jslib';
import { UtilsService } from '../../../services/abstractions/utils.service';
function getBackgroundService<T>(service: string) { function getBackgroundService<T>(service: string) {
return (): T => { return (): T => {

View File

@ -1,4 +1,4 @@
import { StorageService } from '../../../services/abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
class StateService { class StateService {
private state: any = {}; private state: any = {};

View File

@ -1,7 +1,7 @@
import * as angular from 'angular'; import * as angular from 'angular';
import * as template from './environment.component.html'; import * as template from './environment.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class EnvironmentController { export class EnvironmentController {
iconsUrl: string; iconsUrl: string;

View File

@ -2,7 +2,7 @@ import * as angular from 'angular';
import { Folder } from '../../../../models/domain/folder'; import { Folder } from '../../../../models/domain/folder';
import * as template from './add-folder.component.html'; import * as template from './add-folder.component.html';
import { PlatformUtilsService } from '../../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class AddFolderController { export class AddFolderController {
savePromise: any; savePromise: any;

View File

@ -2,7 +2,7 @@ import * as angular from 'angular';
import { Folder } from '../../../../models/domain/folder'; import { Folder } from '../../../../models/domain/folder';
import * as template from './edit-folder.component.html'; import * as template from './edit-folder.component.html';
import { PlatformUtilsService } from '../../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class EditFolderController { export class EditFolderController {
$transition$: any; $transition$: any;

View File

@ -1,7 +1,7 @@
import * as angular from 'angular'; import * as angular from 'angular';
import { MessagingService } from '../../../services/abstractions/messaging.service';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { MessagingService, PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { StorageService } from '../../../services/abstractions/storage.service';
import StateService from '../services/state.service'; import StateService from '../services/state.service';
import * as template from './options.component.html'; import * as template from './options.component.html';

View File

@ -1,11 +1,8 @@
import * as angular from 'angular'; import * as angular from 'angular';
import { DeviceType } from '@bitwarden/jslib'; import { DeviceType, MessagingService, PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { CryptoService } from '../../../services/abstractions/crypto.service'; import { CryptoService } from '../../../services/abstractions/crypto.service';
import { MessagingService } from '../../../services/abstractions/messaging.service';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service';
import { StorageService } from '../../../services/abstractions/storage.service';
import ConstantsService from '../../../services/constants.service'; import ConstantsService from '../../../services/constants.service';
import * as template from './settings.component.html'; import * as template from './settings.component.html';

View File

@ -2,10 +2,9 @@ import * as angular from 'angular';
import * as papa from 'papaparse'; import * as papa from 'papaparse';
import * as template from './export.component.html'; import * as template from './export.component.html';
import { CipherType } from '@bitwarden/jslib'; import { CipherType, UtilsService } from '@bitwarden/jslib';
import { CryptoService } from '../../../services/abstractions/crypto.service'; import { CryptoService } from '../../../services/abstractions/crypto.service';
import { UtilsService } from '../../../services/abstractions/utils.service';
export class ExportController { export class ExportController {
i18n: any; i18n: any;

View File

@ -1,7 +1,7 @@
import * as angular from 'angular'; import * as angular from 'angular';
import * as template from './password-generator.component.html'; import * as template from './password-generator.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class PasswordGeneratorController { export class PasswordGeneratorController {
$transition$: any; $transition$: any;

View File

@ -1,6 +1,6 @@
import * as template from './tools.component.html'; import * as template from './tools.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export class ToolsController { export class ToolsController {
showExport: boolean; showExport: boolean;

View File

@ -1,3 +0,0 @@
export interface MessagingService {
send(subscriber: string, arg?: any): void;
}

View File

@ -1,18 +0,0 @@
import { DeviceType } from '@bitwarden/jslib';
export interface PlatformUtilsService {
getDevice(): DeviceType;
getDeviceString(): string;
isFirefox(): boolean;
isChrome(): boolean;
isEdge(): boolean;
isOpera(): boolean;
analyticsId(): string;
initListSectionItemListeners(doc: Document, angular: any): void;
getDomain(uriString: string): string;
inSidebar(theWindow: Window): boolean;
inTab(theWindow: Window): boolean;
inPopout(theWindow: Window): boolean;
inPopup(theWindow: Window): boolean;
isViewOpen(): boolean;
}

View File

@ -1,5 +0,0 @@
export interface StorageService {
get<T>(key: string): Promise<T>;
save(key: string, obj: any): Promise<any>;
remove(key: string): Promise<any>;
}

View File

@ -1,4 +0,0 @@
export interface UtilsService {
copyToClipboard(text: string, doc?: Document): void;
getHostname(uriString: string): string;
}

View File

@ -2,7 +2,7 @@ import AppIdService from './appId.service';
import ConstantsService from './constants.service'; import ConstantsService from './constants.service';
import TokenService from './token.service'; import TokenService from './token.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
import EnvironmentUrls from '../models/domain/environmentUrls'; import EnvironmentUrls from '../models/domain/environmentUrls';

View File

@ -1,6 +1,6 @@
import UtilsService from './utils.service'; import UtilsService from './utils.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
export default class AppIdService { export default class AppIdService {
constructor(private storageService: StorageService) { constructor(private storageService: StorageService) {

View File

@ -10,7 +10,7 @@ import TokenService from './token.service';
import TotpService from './totp.service'; import TotpService from './totp.service';
import UtilsService from './utils.service'; import UtilsService from './utils.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag', const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag',
'placeholder', 'label-left', 'label-top']; 'placeholder', 'label-left', 'label-top'];

View File

@ -1,5 +1,4 @@
import { MessagingService as MessagingServiceInterface } from './abstractions/messaging.service'; import { MessagingService as MessagingServiceInterface, PlatformUtilsService } from '@bitwarden/jslib';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
export default class BrowserMessagingService implements MessagingServiceInterface { export default class BrowserMessagingService implements MessagingServiceInterface {
constructor(private platformUtilsService: PlatformUtilsService) { constructor(private platformUtilsService: PlatformUtilsService) {

View File

@ -1,8 +1,6 @@
import * as tldjs from 'tldjs'; import * as tldjs from 'tldjs';
import { DeviceType } from '@bitwarden/jslib'; import { DeviceType, PlatformUtilsService as PlatformUtilsServiceInterface } from '@bitwarden/jslib';
import { PlatformUtilsService as PlatformUtilsServiceInterface } from './abstractions/platformUtils.service';
const AnalyticsIds = { const AnalyticsIds = {
[DeviceType.Chrome]: 'UA-81915606-6', [DeviceType.Chrome]: 'UA-81915606-6',

View File

@ -1,5 +1,4 @@
import { PlatformUtilsService } from './abstractions/platformUtils.service'; import { PlatformUtilsService, StorageService as StorageServiceInterface } from '@bitwarden/jslib';
import { StorageService as StorageServiceInterface } from './abstractions/storage.service';
export default class BrowserStorageService implements StorageServiceInterface { export default class BrowserStorageService implements StorageServiceInterface {
constructor(private platformUtilsService: PlatformUtilsService) { constructor(private platformUtilsService: PlatformUtilsService) {

View File

@ -17,7 +17,7 @@ import CryptoService from './crypto.service';
import SettingsService from './settings.service'; import SettingsService from './settings.service';
import UserService from './user.service'; import UserService from './user.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
ciphersPrefix: 'ciphers_', ciphersPrefix: 'ciphers_',

View File

@ -6,7 +6,7 @@ import { CollectionData } from '../models/data/collectionData';
import CryptoService from './crypto.service'; import CryptoService from './crypto.service';
import UserService from './user.service'; import UserService from './user.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
collectionsPrefix: 'collections_', collectionsPrefix: 'collections_',

View File

@ -1,4 +1,4 @@
import { PlatformUtilsService } from './abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export default class ConstantsService { export default class ConstantsService {
static readonly environmentUrlsKey: string = 'environmentUrls'; static readonly environmentUrlsKey: string = 'environmentUrls';

View File

@ -11,7 +11,8 @@ import ConstantsService from './constants.service';
import UtilsService from './utils.service'; import UtilsService from './utils.service';
import { CryptoService as CryptoServiceInterface } from './abstractions/crypto.service'; import { CryptoService as CryptoServiceInterface } from './abstractions/crypto.service';
import { StorageService } from './abstractions/storage.service';
import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
key: 'key', key: 'key',

View File

@ -1,7 +1,7 @@
import ApiService from './api.service'; import ApiService from './api.service';
import ConstantsService from './constants.service'; import ConstantsService from './constants.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
import EnvironmentUrls from '../models/domain/environmentUrls'; import EnvironmentUrls from '../models/domain/environmentUrls';

View File

@ -10,7 +10,7 @@ import ApiService from './api.service';
import CryptoService from './crypto.service'; import CryptoService from './crypto.service';
import UserService from './user.service'; import UserService from './user.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
foldersPrefix: 'folders_', foldersPrefix: 'folders_',

View File

@ -1,4 +1,4 @@
import { PlatformUtilsService } from './abstractions/platformUtils.service'; import { PlatformUtilsService } from '@bitwarden/jslib';
export default function i18nService(platformUtilsService: PlatformUtilsService) { export default function i18nService(platformUtilsService: PlatformUtilsService) {
const edgeMessages: any = {}; const edgeMessages: any = {};

View File

@ -4,8 +4,7 @@ import ConstantsService from './constants.service';
import CryptoService from './crypto.service'; import CryptoService from './crypto.service';
import FolderService from './folder.service'; import FolderService from './folder.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service'; import { PlatformUtilsService, StorageService } from '@bitwarden/jslib';
import { StorageService } from './abstractions/storage.service';
export default class LockService { export default class LockService {
constructor(private cipherService: CipherService, private folderService: FolderService, constructor(private cipherService: CipherService, private folderService: FolderService,

View File

@ -4,7 +4,7 @@ import PasswordHistory from '../models/domain/passwordHistory';
import CryptoService from './crypto.service'; import CryptoService from './crypto.service';
import UtilsService from './utils.service'; import UtilsService from './utils.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const DefaultOptions = { const DefaultOptions = {
length: 14, length: 14,

View File

@ -1,6 +1,6 @@
import UserService from './user.service'; import UserService from './user.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
settingsPrefix: 'settings_', settingsPrefix: 'settings_',

View File

@ -17,8 +17,7 @@ import FolderService from './folder.service';
import SettingsService from './settings.service'; import SettingsService from './settings.service';
import UserService from './user.service'; import UserService from './user.service';
import { MessagingService } from './abstractions/messaging.service'; import { MessagingService, StorageService } from '@bitwarden/jslib';
import { StorageService } from './abstractions/storage.service';
const Keys = { const Keys = {
lastSyncPrefix: 'lastSync_', lastSyncPrefix: 'lastSync_',

View File

@ -1,7 +1,7 @@
import ConstantsService from './constants.service'; import ConstantsService from './constants.service';
import UtilsService from './utils.service'; import UtilsService from './utils.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
accessToken: 'accessToken', accessToken: 'accessToken',

View File

@ -1,6 +1,6 @@
import ConstantsService from './constants.service'; import ConstantsService from './constants.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; const b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';

View File

@ -1,6 +1,6 @@
import TokenService from './token.service'; import TokenService from './token.service';
import { StorageService } from './abstractions/storage.service'; import { StorageService } from '@bitwarden/jslib';
const Keys = { const Keys = {
userId: 'userId', userId: 'userId',

View File

@ -1,4 +1,4 @@
import { UtilsService as UtilsServiceInterface } from './abstractions/utils.service'; import { UtilsService as UtilsServiceInterface } from '@bitwarden/jslib';
export default class UtilsService implements UtilsServiceInterface { export default class UtilsService implements UtilsServiceInterface {
static copyToClipboard(text: string, doc?: Document): void { static copyToClipboard(text: string, doc?: Document): void {