mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-19 15:57:42 +01:00
moved service abstractions to jslib
This commit is contained in:
parent
dc15edcd4d
commit
c018f096b4
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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[] = [];
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { UtilsService } from '../../../services/abstractions/utils.service';
|
||||
import { UtilsService } from '@bitwarden/jslib';
|
||||
|
||||
export class MainController implements ng.IController {
|
||||
smBody: boolean;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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 => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StorageService } from '../../../services/abstractions/storage.service';
|
||||
import { StorageService } from '@bitwarden/jslib';
|
||||
|
||||
class StateService {
|
||||
private state: any = {};
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -1,3 +0,0 @@
|
||||
export interface MessagingService {
|
||||
send(subscriber: string, arg?: any): void;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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>;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
export interface UtilsService {
|
||||
copyToClipboard(text: string, doc?: Document): void;
|
||||
getHostname(uriString: string): string;
|
||||
}
|
@ -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';
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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'];
|
||||
|
@ -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) {
|
||||
|
@ -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',
|
||||
|
@ -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) {
|
||||
|
@ -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_',
|
||||
|
@ -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_',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { PlatformUtilsService } from './abstractions/platformUtils.service';
|
||||
import { PlatformUtilsService } from '@bitwarden/jslib';
|
||||
|
||||
export default class ConstantsService {
|
||||
static readonly environmentUrlsKey: string = 'environmentUrls';
|
||||
|
@ -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',
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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_',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { PlatformUtilsService } from './abstractions/platformUtils.service';
|
||||
import { PlatformUtilsService } from '@bitwarden/jslib';
|
||||
|
||||
export default function i18nService(platformUtilsService: PlatformUtilsService) {
|
||||
const edgeMessages: any = {};
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import UserService from './user.service';
|
||||
|
||||
import { StorageService } from './abstractions/storage.service';
|
||||
import { StorageService } from '@bitwarden/jslib';
|
||||
|
||||
const Keys = {
|
||||
settingsPrefix: 'settings_',
|
||||
|
@ -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_',
|
||||
|
@ -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',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import ConstantsService from './constants.service';
|
||||
|
||||
import { StorageService } from './abstractions/storage.service';
|
||||
import { StorageService } from '@bitwarden/jslib';
|
||||
|
||||
const b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import TokenService from './token.service';
|
||||
|
||||
import { StorageService } from './abstractions/storage.service';
|
||||
import { StorageService } from '@bitwarden/jslib';
|
||||
|
||||
const Keys = {
|
||||
userId: 'userId',
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user