diff --git a/src/abstractions/auth.service.ts b/src/abstractions/auth.service.ts index 56c93b07cc..45f7ca034d 100644 --- a/src/abstractions/auth.service.ts +++ b/src/abstractions/auth.service.ts @@ -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; logOut: (callback: Function) => void; } diff --git a/src/abstractions/cipher.service.ts b/src/abstractions/cipher.service.ts index 58f092b696..d639d99a01 100644 --- a/src/abstractions/cipher.service.ts +++ b/src/abstractions/cipher.service.ts @@ -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; - encryptFields(fieldsModel: any[], key: SymmetricCryptoKey): Promise; - encryptField(fieldModel: any, key: SymmetricCryptoKey): Promise; - get(id: string): Promise; - getAll(): Promise; - getAllDecrypted(): Promise; - getAllDecryptedForGrouping(groupingId: string, folder?: boolean): Promise; - getAllDecryptedForDomain(domain: string, includeOtherTypes?: any[]): Promise; - getLastUsedForDomain(domain: string): Promise; - updateLastUsedDate(id: string): Promise; - saveNeverDomain(domain: string): Promise; - saveWithServer(cipher: Cipher): Promise; - saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any): Promise; - upsert(cipher: CipherData | CipherData[]): Promise; - replace(ciphers: { [id: string]: CipherData; }): Promise; - clear(userId: string): Promise; - delete(id: string | string[]): Promise; - deleteWithServer(id: string): Promise; - deleteAttachment(id: string, attachmentId: string): Promise; - deleteAttachmentWithServer(id: string, attachmentId: string): Promise; - sortCiphersByLastUsed(a: any, b: any): number; - sortCiphersByLastUsedThenName(a: any, b: any): number; + + clearCache: () => void; + encrypt: (model: any) => Promise; + encryptFields: (fieldsModel: any[], key: SymmetricCryptoKey) => Promise; + encryptField: (fieldModel: any, key: SymmetricCryptoKey) => Promise; + get: (id: string) => Promise; + getAll: () => Promise; + getAllDecrypted: () => Promise; + getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise; + getAllDecryptedForDomain: (domain: string, includeOtherTypes?: any[]) => Promise; + getLastUsedForDomain: (domain: string) => Promise; + updateLastUsedDate: (id: string) => Promise; + saveNeverDomain: (domain: string) => Promise; + saveWithServer: (cipher: Cipher) => Promise; + saveAttachmentWithServer: (cipher: Cipher, unencryptedFile: any) => Promise; + upsert: (cipher: CipherData | CipherData[]) => Promise; + replace: (ciphers: { [id: string]: CipherData; }) => Promise; + clear: (userId: string) => Promise; + delete: (id: string | string[]) => Promise; + deleteWithServer: (id: string) => Promise; + deleteAttachment: (id: string, attachmentId: string) => Promise; + deleteAttachmentWithServer: (id: string, attachmentId: string) => Promise; + sortCiphersByLastUsed: (a: any, b: any) => number; + sortCiphersByLastUsedThenName: (a: any, b: any) => number; } diff --git a/src/abstractions/collection.service.ts b/src/abstractions/collection.service.ts index e33532d3ce..0f7f25e7ab 100644 --- a/src/abstractions/collection.service.ts +++ b/src/abstractions/collection.service.ts @@ -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; - getAll(): Promise; - getAllDecrypted(): Promise; - upsert(collection: CollectionData | CollectionData[]): Promise; - replace(collections: { [id: string]: CollectionData; }): Promise; - clear(userId: string): Promise; - delete(id: string | string[]): Promise; + clearCache: () => void; + get: (id: string) => Promise; + getAll: () => Promise; + getAllDecrypted: () => Promise; + upsert: (collection: CollectionData | CollectionData[]) => Promise; + replace: (collections: { [id: string]: CollectionData; }) => Promise; + clear: (userId: string) => Promise; + delete: (id: string | string[]) => Promise; } diff --git a/src/abstractions/environment.service.ts b/src/abstractions/environment.service.ts index a021db8910..67a8857fde 100644 --- a/src/abstractions/environment.service.ts +++ b/src/abstractions/environment.service.ts @@ -1,10 +1,10 @@ -export interface EnvironmentService { +export abstract class EnvironmentService { baseUrl: string; webVaultUrl: string; apiUrl: string; identityUrl: string; iconsUrl: string; - setUrlsFromStorage(): Promise; - setUrls(urls: any): Promise; + setUrlsFromStorage:() => Promise; + setUrls: (urls: any) => Promise; } diff --git a/src/abstractions/folder.service.ts b/src/abstractions/folder.service.ts index 7de2430534..7b75f6aebc 100644 --- a/src/abstractions/folder.service.ts +++ b/src/abstractions/folder.service.ts @@ -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; - get(id: string): Promise; - getAll(): Promise; - getAllDecrypted(): Promise; - saveWithServer(folder: Folder): Promise; - upsert(folder: FolderData | FolderData[]): Promise; - replace(folders: { [id: string]: FolderData; }): Promise; - clear(userId: string): Promise; - delete(id: string | string[]): Promise; - deleteWithServer(id: string): Promise; + clearCache: () => void; + encrypt: (model: any) => Promise; + get: (id: string) => Promise; + getAll: () => Promise; + getAllDecrypted: () => Promise; + saveWithServer: (folder: Folder) => Promise; + upsert: (folder: FolderData | FolderData[]) => Promise; + replace: (folders: { [id: string]: FolderData; }) => Promise; + clear: (userId: string) => Promise; + delete: (id: string | string[]) => Promise; + deleteWithServer: (id: string) => Promise; } diff --git a/src/services/auth.service.ts b/src/services/auth.service.ts index 4b123a5885..2d2328c6a3 100644 --- a/src/services/auth.service.ts +++ b/src/services/auth.service.ts @@ -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) { } diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index 364be57cac..9f6e8fba3e 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -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; diff --git a/src/services/collection.service.ts b/src/services/collection.service.ts index 35327f1e2a..f85dfcf8b1 100644 --- a/src/services/collection.service.ts +++ b/src/services/collection.service.ts @@ -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, diff --git a/src/services/environment.service.ts b/src/services/environment.service.ts index 2ba63ad6bf..e1544489f1 100644 --- a/src/services/environment.service.ts +++ b/src/services/environment.service.ts @@ -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; diff --git a/src/services/folder.service.ts b/src/services/folder.service.ts index aa027fdd6a..0f8096849a 100644 --- a/src/services/folder.service.ts +++ b/src/services/folder.service.ts @@ -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,