import { ProfileOrganizationResponse } from "../../admin-console/models/response/profile-organization.response"; import { ProfileProviderOrganizationResponse } from "../../admin-console/models/response/profile-provider-organization.response"; import { ProfileProviderResponse } from "../../admin-console/models/response/profile-provider.response"; import { KdfConfig } from "../../auth/models/domain/kdf-config"; import { KeySuffixOptions, KdfType, HashPurpose } from "../../enums"; import { EncArrayBuffer } from "../models/domain/enc-array-buffer"; import { EncString } from "../models/domain/enc-string"; import { MasterKey, PinKey, SymmetricCryptoKey, UserSymKey, } from "../models/domain/symmetric-crypto-key"; export abstract class CryptoService { // TODO: This works right? getKeyForUserEncryption: (key?: SymmetricCryptoKey) => Promise; setUserKey: (key: SymmetricCryptoKey) => Promise; getUserKey: (keySuffix?: KeySuffixOptions, userId?: string) => Promise; getUserKeyFromStorage: (keySuffix: KeySuffixOptions, userId?: string) => Promise; hasUserKey: () => Promise; hasUserKeyInMemory: (userId?: string) => Promise; hasUserKeyStored: (keySuffix?: KeySuffixOptions, userId?: string) => Promise; makeUserSymKey: (key: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, EncString]>; clearUserKey: (clearSecretStorage?: boolean, userId?: string) => Promise; clearUserKeyFromStorage: (keySuffix: KeySuffixOptions) => Promise; setMasterKey: (key: MasterKey, userId?: string) => Promise; getMasterKey: (userId?: string) => Promise; makeMasterKey: ( password: string, email: string, kdf: KdfType, KdfConfig: KdfConfig ) => Promise; encryptUserSymKeyWithMasterKey: ( masterKey: MasterKey, userSymKey?: UserSymKey ) => Promise<[UserSymKey, EncString]>; hashPassword: (password: string, key: MasterKey, hashPurpose?: HashPurpose) => Promise; setKeyHash: (keyHash: string) => Promise; getKeyHash: () => Promise; clearKeyHash: () => Promise; compareAndUpdateKeyHash: (masterPassword: string, key: MasterKey) => Promise; setOrgKeys: ( orgs: ProfileOrganizationResponse[], providerOrgs: ProfileProviderOrganizationResponse[] ) => Promise; getOrgKey: (orgId: string) => Promise; getOrgKeys: () => Promise>; clearOrgKeys: (memoryOnly?: boolean, userId?: string) => Promise; setProviderKeys: (orgs: ProfileProviderResponse[]) => Promise; getProviderKey: (providerId: string) => Promise; getProviderKeys: () => Promise>; clearProviderKeys: (memoryOnly?: boolean) => Promise; getPublicKey: () => Promise; makeShareKey: () => Promise<[EncString, SymmetricCryptoKey]>; setPrivateKey: (encPrivateKey: string) => Promise; getPrivateKey: () => Promise; getFingerprint: (fingerprintMaterial: string, publicKey?: ArrayBuffer) => Promise; makeKeyPair: (key?: UserSymKey) => Promise<[string, EncString]>; clearKeyPair: (memoryOnly?: boolean, userId?: string) => Promise; makePinKey: (pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig) => Promise; clearPinProtectedKey: () => Promise; decryptUserSymKeyWithPin: ( pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig, protectedKeyCs?: EncString ) => Promise; makeSendKey: (keyMaterial: ArrayBuffer) => Promise; clearKeys: (userId?: string) => Promise; rsaEncrypt: (data: ArrayBuffer, publicKey?: ArrayBuffer) => Promise; rsaDecrypt: (encValue: string, privateKeyValue?: ArrayBuffer) => Promise; randomNumber: (min: number, max: number) => Promise; // deprecate encrypt: (plainValue: string | ArrayBuffer, key?: SymmetricCryptoKey) => Promise; encryptToBytes: (plainValue: ArrayBuffer, key?: SymmetricCryptoKey) => Promise; decryptToBytes: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptToUtf8: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptFromBytes: (encBuffer: EncArrayBuffer, key: SymmetricCryptoKey) => Promise; setEncKey: (encKey: string) => Promise; getEncKey: (key?: SymmetricCryptoKey) => Promise; hasEncKey: () => Promise; clearEncKey: (memoryOnly?: boolean, userId?: string) => Promise; toggleKey: () => Promise; }