1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

defining more abstractions

This commit is contained in:
Kyle Spearrin
2018-01-25 14:26:09 -05:00
parent e5c1adedff
commit 11755e409a
9 changed files with 111 additions and 45 deletions

View File

@@ -3,31 +3,31 @@ import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
import { ProfileOrganizationResponse } from '../models/response/profileOrganizationResponse';
export interface CryptoService {
setKey(key: SymmetricCryptoKey): Promise<any>;
setKeyHash(keyHash: string): Promise<{}>;
setEncKey(encKey: string): Promise<{}>;
setEncPrivateKey(encPrivateKey: string): Promise<{}>;
setOrgKeys(orgs: ProfileOrganizationResponse[]): Promise<{}>;
getKey(): Promise<SymmetricCryptoKey>;
getKeyHash(): Promise<string>;
getEncKey(): Promise<SymmetricCryptoKey>;
getPrivateKey(): Promise<ArrayBuffer>;
getOrgKeys(): Promise<Map<string, SymmetricCryptoKey>>;
getOrgKey(orgId: string): Promise<SymmetricCryptoKey>;
clearKey(): Promise<any>;
clearKeyHash(): Promise<any>;
clearEncKey(memoryOnly?: boolean): Promise<any>;
clearPrivateKey(memoryOnly?: boolean): Promise<any>;
clearOrgKeys(memoryOnly?: boolean): Promise<any>;
clearKeys(): Promise<any>;
toggleKey(): Promise<any>;
makeKey(password: string, salt: string): SymmetricCryptoKey;
hashPassword(password: string, key: SymmetricCryptoKey): Promise<string>;
makeEncKey(key: SymmetricCryptoKey): Promise<CipherString>;
encrypt(plainValue: string | Uint8Array, key?: SymmetricCryptoKey, plainValueEncoding?: string): Promise<CipherString>;
encryptToBytes(plainValue: ArrayBuffer, key?: SymmetricCryptoKey): Promise<ArrayBuffer>;
decrypt(cipherString: CipherString, key?: SymmetricCryptoKey, outputEncoding?: string): Promise<string>;
decryptFromBytes(encBuf: ArrayBuffer, key: SymmetricCryptoKey): Promise<ArrayBuffer>;
rsaDecrypt(encValue: string): Promise<string>;
export abstract class CryptoService {
setKey: (key: SymmetricCryptoKey) => Promise<any>;
setKeyHash: (keyHash: string) => Promise<{}>;
setEncKey: (encKey: string) => Promise<{}>;
setEncPrivateKey: (encPrivateKey: string) => Promise<{}>;
setOrgKeys: (orgs: ProfileOrganizationResponse[]) => Promise<{}>;
getKey: () => Promise<SymmetricCryptoKey>;
getKeyHash: () => Promise<string>;
getEncKey: () => Promise<SymmetricCryptoKey>;
getPrivateKey: () => Promise<ArrayBuffer>;
getOrgKeys: () => Promise<Map<string, SymmetricCryptoKey>>;
getOrgKey: (orgId: string) => Promise<SymmetricCryptoKey>;
clearKey: () => Promise<any>;
clearKeyHash: () => Promise<any>;
clearEncKey: (memoryOnly?: boolean) => Promise<any>;
clearPrivateKey: (memoryOnly?: boolean) => Promise<any>;
clearOrgKeys: (memoryOnly?: boolean) => Promise<any>;
clearKeys: () => Promise<any>;
toggleKey: () => Promise<any>;
makeKey: (password: string, salt: string) => SymmetricCryptoKey;
hashPassword: (password: string, key: SymmetricCryptoKey) => Promise<string>;
makeEncKey: (key: SymmetricCryptoKey) => Promise<CipherString>;
encrypt: (plainValue: string | Uint8Array, key?: SymmetricCryptoKey, plainValueEncoding?: string) => Promise<CipherString>;
encryptToBytes: (plainValue: ArrayBuffer, key?: SymmetricCryptoKey) => Promise<ArrayBuffer>;
decrypt: (cipherString: CipherString, key?: SymmetricCryptoKey, outputEncoding?: string) => Promise<string>;
decryptFromBytes: (encBuf: ArrayBuffer, key: SymmetricCryptoKey) => Promise<ArrayBuffer>;
rsaDecrypt: (encValue: string) => Promise<string>;
}