1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

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

@@ -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;
}