convert services to abstractions

This commit is contained in:
Kyle Spearrin 2018-01-23 17:29:15 -05:00
parent 6c9e0c4cd3
commit edc3bd1f81
10 changed files with 60 additions and 59 deletions

View File

@ -1,5 +1,5 @@
export abstract class AuthService {
logIn: (email: string, masterPassword: string, twoFactorProvider?: number,
twoFactorToken?: string, remember?: boolean) => any;
logIn: (email: string, masterPassword: string, twoFactorProvider?: number, twoFactorToken?: string,
remember?: boolean) => Promise<any>;
logOut: (callback: Function) => void;
}

View File

@ -4,29 +4,30 @@ import { Cipher } from '../models/domain/cipher';
import { Field } from '../models/domain/field';
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
export interface CipherService {
export abstract class CipherService {
decryptedCipherCache: any[];
clearCache(): void;
encrypt(model: any): Promise<Cipher>;
encryptFields(fieldsModel: any[], key: SymmetricCryptoKey): Promise<Field[]>;
encryptField(fieldModel: any, key: SymmetricCryptoKey): Promise<Field>;
get(id: string): Promise<Cipher>;
getAll(): Promise<Cipher[]>;
getAllDecrypted(): Promise<any[]>;
getAllDecryptedForGrouping(groupingId: string, folder?: boolean): Promise<any[]>;
getAllDecryptedForDomain(domain: string, includeOtherTypes?: any[]): Promise<any[]>;
getLastUsedForDomain(domain: string): Promise<any>;
updateLastUsedDate(id: string): Promise<void>;
saveNeverDomain(domain: string): Promise<void>;
saveWithServer(cipher: Cipher): Promise<any>;
saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any): Promise<any>;
upsert(cipher: CipherData | CipherData[]): Promise<any>;
replace(ciphers: { [id: string]: CipherData; }): Promise<any>;
clear(userId: string): Promise<any>;
delete(id: string | string[]): Promise<any>;
deleteWithServer(id: string): Promise<any>;
deleteAttachment(id: string, attachmentId: string): Promise<void>;
deleteAttachmentWithServer(id: string, attachmentId: string): Promise<void>;
sortCiphersByLastUsed(a: any, b: any): number;
sortCiphersByLastUsedThenName(a: any, b: any): number;
clearCache: () => void;
encrypt: (model: any) => Promise<Cipher>;
encryptFields: (fieldsModel: any[], key: SymmetricCryptoKey) => Promise<Field[]>;
encryptField: (fieldModel: any, key: SymmetricCryptoKey) => Promise<Field>;
get: (id: string) => Promise<Cipher>;
getAll: () => Promise<Cipher[]>;
getAllDecrypted: () => Promise<any[]>;
getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise<any[]>;
getAllDecryptedForDomain: (domain: string, includeOtherTypes?: any[]) => Promise<any[]>;
getLastUsedForDomain: (domain: string) => Promise<any>;
updateLastUsedDate: (id: string) => Promise<void>;
saveNeverDomain: (domain: string) => Promise<void>;
saveWithServer: (cipher: Cipher) => Promise<any>;
saveAttachmentWithServer: (cipher: Cipher, unencryptedFile: any) => Promise<any>;
upsert: (cipher: CipherData | CipherData[]) => Promise<any>;
replace: (ciphers: { [id: string]: CipherData; }) => Promise<any>;
clear: (userId: string) => Promise<any>;
delete: (id: string | string[]) => Promise<any>;
deleteWithServer: (id: string) => Promise<any>;
deleteAttachment: (id: string, attachmentId: string) => Promise<void>;
deleteAttachmentWithServer: (id: string, attachmentId: string) => Promise<void>;
sortCiphersByLastUsed: (a: any, b: any) => number;
sortCiphersByLastUsedThenName: (a: any, b: any) => number;
}

View File

@ -2,15 +2,15 @@ import { CollectionData } from '../models/data/collectionData';
import { Collection } from '../models/domain/collection';
export interface CollectionService {
export abstract class CollectionService {
decryptedCollectionCache: any[];
clearCache(): void;
get(id: string): Promise<Collection>;
getAll(): Promise<Collection[]>;
getAllDecrypted(): Promise<any[]>;
upsert(collection: CollectionData | CollectionData[]): Promise<any>;
replace(collections: { [id: string]: CollectionData; }): Promise<any>;
clear(userId: string): Promise<any>;
delete(id: string | string[]): Promise<any>;
clearCache: () => void;
get: (id: string) => Promise<Collection>;
getAll: () => Promise<Collection[]>;
getAllDecrypted: () => Promise<any[]>;
upsert: (collection: CollectionData | CollectionData[]) => Promise<any>;
replace: (collections: { [id: string]: CollectionData; }) => Promise<any>;
clear: (userId: string) => Promise<any>;
delete: (id: string | string[]) => Promise<any>;
}

View File

@ -1,10 +1,10 @@
export interface EnvironmentService {
export abstract class EnvironmentService {
baseUrl: string;
webVaultUrl: string;
apiUrl: string;
identityUrl: string;
iconsUrl: string;
setUrlsFromStorage(): Promise<void>;
setUrls(urls: any): Promise<any>;
setUrlsFromStorage:() => Promise<void>;
setUrls: (urls: any) => Promise<any>;
}

View File

@ -2,18 +2,18 @@ import { FolderData } from '../models/data/folderData';
import { Folder } from '../models/domain/folder';
export interface FolderService {
export abstract class FolderService {
decryptedFolderCache: any[];
clearCache(): void;
encrypt(model: any): Promise<Folder>;
get(id: string): Promise<Folder>;
getAll(): Promise<Folder[]>;
getAllDecrypted(): Promise<any[]>;
saveWithServer(folder: Folder): Promise<any>;
upsert(folder: FolderData | FolderData[]): Promise<any>;
replace(folders: { [id: string]: FolderData; }): Promise<any>;
clear(userId: string): Promise<any>;
delete(id: string | string[]): Promise<any>;
deleteWithServer(id: string): Promise<any>;
clearCache: () => void;
encrypt: (model: any) => Promise<Folder>;
get: (id: string) => Promise<Folder>;
getAll: () => Promise<Folder[]>;
getAllDecrypted: () => Promise<any[]>;
saveWithServer: (folder: Folder) => Promise<any>;
upsert: (folder: FolderData | FolderData[]) => Promise<any>;
replace: (folders: { [id: string]: FolderData; }) => Promise<any>;
clear: (userId: string) => Promise<any>;
delete: (id: string | string[]) => Promise<any>;
deleteWithServer: (id: string) => Promise<any>;
}

View File

@ -13,7 +13,7 @@ import { UserService } from '../abstractions/user.service';
export class AuthService {
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 messagingService: MessagingService) {
}

View File

@ -15,7 +15,7 @@ import { ErrorResponse } from '../models/response/errorResponse';
import { ConstantsService } from './constants.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 { SettingsService } from '../abstractions/settings.service';
import { StorageService } from '../abstractions/storage.service';
@ -27,7 +27,7 @@ const Keys = {
neverDomains: 'neverDomains',
};
export class CipherService implements CipherServiceInterface {
export class CipherService implements CipherServiceAbstraction {
static sortCiphersByLastUsed(a: any, b: any): number {
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;

View File

@ -2,7 +2,7 @@ import { CollectionData } from '../models/data/collectionData';
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 { StorageService } from '../abstractions/storage.service';
import { UserService } from '../abstractions/user.service';
@ -11,7 +11,7 @@ const Keys = {
collectionsPrefix: 'collections_',
};
export class CollectionService implements CollectionServiceInterface {
export class CollectionService implements CollectionServiceAbstraction {
decryptedCollectionCache: any[];
constructor(private cryptoService: CryptoService, private userService: UserService,

View File

@ -3,10 +3,10 @@ import { EnvironmentUrls } from '../models/domain/environmentUrls';
import { ConstantsService } from './constants.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';
export class EnvironmentService implements EnvironmentServiceInterface {
export class EnvironmentService implements EnvironmentServiceAbstraction {
baseUrl: string;
webVaultUrl: string;
apiUrl: string;

View File

@ -8,7 +8,7 @@ import { FolderResponse } from '../models/response/folderResponse';
import { ApiService } from '../abstractions/api.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 { UserService } from '../abstractions/user.service';
@ -16,7 +16,7 @@ const Keys = {
foldersPrefix: 'folders_',
};
export class FolderService implements FolderServiceInterface {
export class FolderService implements FolderServiceAbstraction {
decryptedFolderCache: any[];
constructor(private cryptoService: CryptoService, private userService: UserService,