1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-23 16:38:45 +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 MainBackground from './main.background';
import { StorageService } from '../services/abstractions/storage.service';
import { StorageService } from '@bitwarden/jslib';
export default class IdleBackground {
private idle: any;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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 {
onView: Function;

View File

@ -1,6 +1,6 @@
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 {
i18n: any;

View File

@ -1,7 +1,6 @@
import { CipherType } from '@bitwarden/jslib';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service';
import { UtilsService } from '../../../services/abstractions/utils.service';
import { PlatformUtilsService, UtilsService } from '@bitwarden/jslib';
import * as template from './current.component.html';
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 {
smBody: boolean;

View File

@ -2,8 +2,8 @@ import * as angular from 'angular';
import * as template from './lock.component.html';
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 {
i18n: any;

View File

@ -2,8 +2,8 @@ import { DeviceRequest } from '../../../models/request/deviceRequest';
import { TokenRequest } from '../../../models/request/tokenRequest';
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 {
constructor(public cryptoService: CryptoService, public apiService: any, public userService: any,

View File

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

View File

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

View File

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

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 '../../../../services/abstractions/platformUtils.service';
import { PlatformUtilsService } from '@bitwarden/jslib';
export class AddFolderController {
savePromise: any;

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 '../../../../services/abstractions/platformUtils.service';
import { PlatformUtilsService } from '@bitwarden/jslib';
export class EditFolderController {
$transition$: any;

View File

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

View File

@ -1,11 +1,8 @@
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 { 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 * as template from './settings.component.html';

View File

@ -2,10 +2,9 @@ import * as angular from 'angular';
import * as papa from 'papaparse';
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 { UtilsService } from '../../../services/abstractions/utils.service';
export class ExportController {
i18n: any;

View File

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

View File

@ -1,6 +1,6 @@
import * as template from './tools.component.html';
import { PlatformUtilsService } from '../../../services/abstractions/platformUtils.service';
import { PlatformUtilsService } from '@bitwarden/jslib';
export class ToolsController {
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 TokenService from './token.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
import { PlatformUtilsService } from '@bitwarden/jslib';
import EnvironmentUrls from '../models/domain/environmentUrls';

View File

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

View File

@ -10,7 +10,7 @@ import TokenService from './token.service';
import TotpService from './totp.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',
'placeholder', 'label-left', 'label-top'];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import ApiService from './api.service';
import CryptoService from './crypto.service';
import UserService from './user.service';
import { StorageService } from './abstractions/storage.service';
import { StorageService } from '@bitwarden/jslib';
const Keys = {
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) {
const edgeMessages: any = {};

View File

@ -4,8 +4,7 @@ import ConstantsService from './constants.service';
import CryptoService from './crypto.service';
import FolderService from './folder.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
import { StorageService } from './abstractions/storage.service';
import { PlatformUtilsService, StorageService } from '@bitwarden/jslib';
export default class LockService {
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 UtilsService from './utils.service';
import { StorageService } from './abstractions/storage.service';
import { StorageService } from '@bitwarden/jslib';
const DefaultOptions = {
length: 14,

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import TokenService from './token.service';
import { StorageService } from './abstractions/storage.service';
import { StorageService } from '@bitwarden/jslib';
const Keys = {
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 {
static copyToClipboard(text: string, doc?: Document): void {