convert services to abstractions
This commit is contained in:
parent
6c9e0c4cd3
commit
edc3bd1f81
|
@ -1,5 +1,5 @@
|
||||||
export abstract class AuthService {
|
export abstract class AuthService {
|
||||||
logIn: (email: string, masterPassword: string, twoFactorProvider?: number,
|
logIn: (email: string, masterPassword: string, twoFactorProvider?: number, twoFactorToken?: string,
|
||||||
twoFactorToken?: string, remember?: boolean) => any;
|
remember?: boolean) => Promise<any>;
|
||||||
logOut: (callback: Function) => void;
|
logOut: (callback: Function) => void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,29 +4,30 @@ import { Cipher } from '../models/domain/cipher';
|
||||||
import { Field } from '../models/domain/field';
|
import { Field } from '../models/domain/field';
|
||||||
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
|
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
|
||||||
|
|
||||||
export interface CipherService {
|
export abstract class CipherService {
|
||||||
decryptedCipherCache: any[];
|
decryptedCipherCache: any[];
|
||||||
clearCache(): void;
|
|
||||||
encrypt(model: any): Promise<Cipher>;
|
clearCache: () => void;
|
||||||
encryptFields(fieldsModel: any[], key: SymmetricCryptoKey): Promise<Field[]>;
|
encrypt: (model: any) => Promise<Cipher>;
|
||||||
encryptField(fieldModel: any, key: SymmetricCryptoKey): Promise<Field>;
|
encryptFields: (fieldsModel: any[], key: SymmetricCryptoKey) => Promise<Field[]>;
|
||||||
get(id: string): Promise<Cipher>;
|
encryptField: (fieldModel: any, key: SymmetricCryptoKey) => Promise<Field>;
|
||||||
getAll(): Promise<Cipher[]>;
|
get: (id: string) => Promise<Cipher>;
|
||||||
getAllDecrypted(): Promise<any[]>;
|
getAll: () => Promise<Cipher[]>;
|
||||||
getAllDecryptedForGrouping(groupingId: string, folder?: boolean): Promise<any[]>;
|
getAllDecrypted: () => Promise<any[]>;
|
||||||
getAllDecryptedForDomain(domain: string, includeOtherTypes?: any[]): Promise<any[]>;
|
getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise<any[]>;
|
||||||
getLastUsedForDomain(domain: string): Promise<any>;
|
getAllDecryptedForDomain: (domain: string, includeOtherTypes?: any[]) => Promise<any[]>;
|
||||||
updateLastUsedDate(id: string): Promise<void>;
|
getLastUsedForDomain: (domain: string) => Promise<any>;
|
||||||
saveNeverDomain(domain: string): Promise<void>;
|
updateLastUsedDate: (id: string) => Promise<void>;
|
||||||
saveWithServer(cipher: Cipher): Promise<any>;
|
saveNeverDomain: (domain: string) => Promise<void>;
|
||||||
saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any): Promise<any>;
|
saveWithServer: (cipher: Cipher) => Promise<any>;
|
||||||
upsert(cipher: CipherData | CipherData[]): Promise<any>;
|
saveAttachmentWithServer: (cipher: Cipher, unencryptedFile: any) => Promise<any>;
|
||||||
replace(ciphers: { [id: string]: CipherData; }): Promise<any>;
|
upsert: (cipher: CipherData | CipherData[]) => Promise<any>;
|
||||||
clear(userId: string): Promise<any>;
|
replace: (ciphers: { [id: string]: CipherData; }) => Promise<any>;
|
||||||
delete(id: string | string[]): Promise<any>;
|
clear: (userId: string) => Promise<any>;
|
||||||
deleteWithServer(id: string): Promise<any>;
|
delete: (id: string | string[]) => Promise<any>;
|
||||||
deleteAttachment(id: string, attachmentId: string): Promise<void>;
|
deleteWithServer: (id: string) => Promise<any>;
|
||||||
deleteAttachmentWithServer(id: string, attachmentId: string): Promise<void>;
|
deleteAttachment: (id: string, attachmentId: string) => Promise<void>;
|
||||||
sortCiphersByLastUsed(a: any, b: any): number;
|
deleteAttachmentWithServer: (id: string, attachmentId: string) => Promise<void>;
|
||||||
sortCiphersByLastUsedThenName(a: any, b: any): number;
|
sortCiphersByLastUsed: (a: any, b: any) => number;
|
||||||
|
sortCiphersByLastUsedThenName: (a: any, b: any) => number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ import { CollectionData } from '../models/data/collectionData';
|
||||||
|
|
||||||
import { Collection } from '../models/domain/collection';
|
import { Collection } from '../models/domain/collection';
|
||||||
|
|
||||||
export interface CollectionService {
|
export abstract class CollectionService {
|
||||||
decryptedCollectionCache: any[];
|
decryptedCollectionCache: any[];
|
||||||
|
|
||||||
clearCache(): void;
|
clearCache: () => void;
|
||||||
get(id: string): Promise<Collection>;
|
get: (id: string) => Promise<Collection>;
|
||||||
getAll(): Promise<Collection[]>;
|
getAll: () => Promise<Collection[]>;
|
||||||
getAllDecrypted(): Promise<any[]>;
|
getAllDecrypted: () => Promise<any[]>;
|
||||||
upsert(collection: CollectionData | CollectionData[]): Promise<any>;
|
upsert: (collection: CollectionData | CollectionData[]) => Promise<any>;
|
||||||
replace(collections: { [id: string]: CollectionData; }): Promise<any>;
|
replace: (collections: { [id: string]: CollectionData; }) => Promise<any>;
|
||||||
clear(userId: string): Promise<any>;
|
clear: (userId: string) => Promise<any>;
|
||||||
delete(id: string | string[]): Promise<any>;
|
delete: (id: string | string[]) => Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
export interface EnvironmentService {
|
export abstract class EnvironmentService {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
webVaultUrl: string;
|
webVaultUrl: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
identityUrl: string;
|
identityUrl: string;
|
||||||
iconsUrl: string;
|
iconsUrl: string;
|
||||||
|
|
||||||
setUrlsFromStorage(): Promise<void>;
|
setUrlsFromStorage:() => Promise<void>;
|
||||||
setUrls(urls: any): Promise<any>;
|
setUrls: (urls: any) => Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,18 @@ import { FolderData } from '../models/data/folderData';
|
||||||
|
|
||||||
import { Folder } from '../models/domain/folder';
|
import { Folder } from '../models/domain/folder';
|
||||||
|
|
||||||
export interface FolderService {
|
export abstract class FolderService {
|
||||||
decryptedFolderCache: any[];
|
decryptedFolderCache: any[];
|
||||||
|
|
||||||
clearCache(): void;
|
clearCache: () => void;
|
||||||
encrypt(model: any): Promise<Folder>;
|
encrypt: (model: any) => Promise<Folder>;
|
||||||
get(id: string): Promise<Folder>;
|
get: (id: string) => Promise<Folder>;
|
||||||
getAll(): Promise<Folder[]>;
|
getAll: () => Promise<Folder[]>;
|
||||||
getAllDecrypted(): Promise<any[]>;
|
getAllDecrypted: () => Promise<any[]>;
|
||||||
saveWithServer(folder: Folder): Promise<any>;
|
saveWithServer: (folder: Folder) => Promise<any>;
|
||||||
upsert(folder: FolderData | FolderData[]): Promise<any>;
|
upsert: (folder: FolderData | FolderData[]) => Promise<any>;
|
||||||
replace(folders: { [id: string]: FolderData; }): Promise<any>;
|
replace: (folders: { [id: string]: FolderData; }) => Promise<any>;
|
||||||
clear(userId: string): Promise<any>;
|
clear: (userId: string) => Promise<any>;
|
||||||
delete(id: string | string[]): Promise<any>;
|
delete: (id: string | string[]) => Promise<any>;
|
||||||
deleteWithServer(id: string): Promise<any>;
|
deleteWithServer: (id: string) => Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { UserService } from '../abstractions/user.service';
|
||||||
|
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
constructor(public cryptoService: CryptoService, public apiService: ApiService, public userService: UserService,
|
constructor(public cryptoService: CryptoService, public apiService: ApiService, public userService: UserService,
|
||||||
public tokenService: TokenService, public $rootScope: any, public appIdService: AppIdService,
|
public tokenService: TokenService, public appIdService: AppIdService,
|
||||||
public platformUtilsService: PlatformUtilsService, public constantsService: ConstantsService,
|
public platformUtilsService: PlatformUtilsService, public constantsService: ConstantsService,
|
||||||
public messagingService: MessagingService) {
|
public messagingService: MessagingService) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { ErrorResponse } from '../models/response/errorResponse';
|
||||||
import { ConstantsService } from './constants.service';
|
import { ConstantsService } from './constants.service';
|
||||||
|
|
||||||
import { ApiService } from '../abstractions/api.service';
|
import { ApiService } from '../abstractions/api.service';
|
||||||
import { CipherService as CipherServiceInterface } from '../abstractions/cipher.service';
|
import { CipherService as CipherServiceAbstraction } from '../abstractions/cipher.service';
|
||||||
import { CryptoService } from '../abstractions/crypto.service';
|
import { CryptoService } from '../abstractions/crypto.service';
|
||||||
import { SettingsService } from '../abstractions/settings.service';
|
import { SettingsService } from '../abstractions/settings.service';
|
||||||
import { StorageService } from '../abstractions/storage.service';
|
import { StorageService } from '../abstractions/storage.service';
|
||||||
|
@ -27,7 +27,7 @@ const Keys = {
|
||||||
neverDomains: 'neverDomains',
|
neverDomains: 'neverDomains',
|
||||||
};
|
};
|
||||||
|
|
||||||
export class CipherService implements CipherServiceInterface {
|
export class CipherService implements CipherServiceAbstraction {
|
||||||
static sortCiphersByLastUsed(a: any, b: any): number {
|
static sortCiphersByLastUsed(a: any, b: any): number {
|
||||||
const aLastUsed = a.localData && a.localData.lastUsedDate ? a.localData.lastUsedDate as number : null;
|
const aLastUsed = a.localData && a.localData.lastUsedDate ? a.localData.lastUsedDate as number : null;
|
||||||
const bLastUsed = b.localData && b.localData.lastUsedDate ? b.localData.lastUsedDate as number : null;
|
const bLastUsed = b.localData && b.localData.lastUsedDate ? b.localData.lastUsedDate as number : null;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CollectionData } from '../models/data/collectionData';
|
||||||
|
|
||||||
import { Collection } from '../models/domain/collection';
|
import { Collection } from '../models/domain/collection';
|
||||||
|
|
||||||
import { CollectionService as CollectionServiceInterface } from '../abstractions/collection.service';
|
import { CollectionService as CollectionServiceAbstraction } from '../abstractions/collection.service';
|
||||||
import { CryptoService } from '../abstractions/crypto.service';
|
import { CryptoService } from '../abstractions/crypto.service';
|
||||||
import { StorageService } from '../abstractions/storage.service';
|
import { StorageService } from '../abstractions/storage.service';
|
||||||
import { UserService } from '../abstractions/user.service';
|
import { UserService } from '../abstractions/user.service';
|
||||||
|
@ -11,7 +11,7 @@ const Keys = {
|
||||||
collectionsPrefix: 'collections_',
|
collectionsPrefix: 'collections_',
|
||||||
};
|
};
|
||||||
|
|
||||||
export class CollectionService implements CollectionServiceInterface {
|
export class CollectionService implements CollectionServiceAbstraction {
|
||||||
decryptedCollectionCache: any[];
|
decryptedCollectionCache: any[];
|
||||||
|
|
||||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
constructor(private cryptoService: CryptoService, private userService: UserService,
|
||||||
|
|
|
@ -3,10 +3,10 @@ import { EnvironmentUrls } from '../models/domain/environmentUrls';
|
||||||
import { ConstantsService } from './constants.service';
|
import { ConstantsService } from './constants.service';
|
||||||
|
|
||||||
import { ApiService } from '../abstractions/api.service';
|
import { ApiService } from '../abstractions/api.service';
|
||||||
import { EnvironmentService as EnvironmentServiceInterface } from '../abstractions/environment.service';
|
import { EnvironmentService as EnvironmentServiceAbstraction } from '../abstractions/environment.service';
|
||||||
import { StorageService } from '../abstractions/storage.service';
|
import { StorageService } from '../abstractions/storage.service';
|
||||||
|
|
||||||
export class EnvironmentService implements EnvironmentServiceInterface {
|
export class EnvironmentService implements EnvironmentServiceAbstraction {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
webVaultUrl: string;
|
webVaultUrl: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { FolderResponse } from '../models/response/folderResponse';
|
||||||
|
|
||||||
import { ApiService } from '../abstractions/api.service';
|
import { ApiService } from '../abstractions/api.service';
|
||||||
import { CryptoService } from '../abstractions/crypto.service';
|
import { CryptoService } from '../abstractions/crypto.service';
|
||||||
import { FolderService as FolderServiceInterface } from '../abstractions/folder.service';
|
import { FolderService as FolderServiceAbstraction } from '../abstractions/folder.service';
|
||||||
import { StorageService } from '../abstractions/storage.service';
|
import { StorageService } from '../abstractions/storage.service';
|
||||||
import { UserService } from '../abstractions/user.service';
|
import { UserService } from '../abstractions/user.service';
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const Keys = {
|
||||||
foldersPrefix: 'folders_',
|
foldersPrefix: 'folders_',
|
||||||
};
|
};
|
||||||
|
|
||||||
export class FolderService implements FolderServiceInterface {
|
export class FolderService implements FolderServiceAbstraction {
|
||||||
decryptedFolderCache: any[];
|
decryptedFolderCache: any[];
|
||||||
|
|
||||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
constructor(private cryptoService: CryptoService, private userService: UserService,
|
||||||
|
|
Loading…
Reference in New Issue